Commit 6a95147c authored by David S. Miller's avatar David S. Miller

Merge branch 'bnxt_en-next'

Michael Chan says:

====================
bnxt_en: Updates for net-next.

Two main changes in this seris plus some miscellaneous changes.

1. Improvements and fixes for resource accounting which are required
for enabling SR-IOV and RDMA on the new 57500 chips.  Only SR-IOV
for 57500 chips is enabled in this series.

2. New statistics counters and improvements to keep the basic
counters and port counters during IFDOWN.

3. Msic. small changes for ETS, returning proper error codes
when flashing NVRAM, and a link speed related fix for ethtool
loopback selftest.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 11789039 56d37462
This diff is collapsed.
...@@ -927,6 +927,8 @@ struct bnxt_hw_resc { ...@@ -927,6 +927,8 @@ struct bnxt_hw_resc {
u16 resv_vnics; u16 resv_vnics;
u16 min_stat_ctxs; u16 min_stat_ctxs;
u16 max_stat_ctxs; u16 max_stat_ctxs;
u16 resv_stat_ctxs;
u16 max_nqs;
u16 max_irqs; u16 max_irqs;
u16 resv_irqs; u16 resv_irqs;
}; };
...@@ -1416,8 +1418,6 @@ struct bnxt { ...@@ -1416,8 +1418,6 @@ struct bnxt {
int cp_nr_pages; int cp_nr_pages;
int cp_nr_rings; int cp_nr_rings;
int num_stat_ctxs;
/* grp_info indexed by completion ring index */ /* grp_info indexed by completion ring index */
struct bnxt_ring_grp_info *grp_info; struct bnxt_ring_grp_info *grp_info;
struct bnxt_vnic_info *vnic_info; struct bnxt_vnic_info *vnic_info;
...@@ -1472,6 +1472,7 @@ struct bnxt { ...@@ -1472,6 +1472,7 @@ struct bnxt {
void *hwrm_cmd_resp_addr; void *hwrm_cmd_resp_addr;
dma_addr_t hwrm_cmd_resp_dma_addr; dma_addr_t hwrm_cmd_resp_dma_addr;
struct rtnl_link_stats64 net_stats_prev;
struct rx_port_stats *hw_rx_port_stats; struct rx_port_stats *hw_rx_port_stats;
struct tx_port_stats *hw_tx_port_stats; struct tx_port_stats *hw_tx_port_stats;
struct rx_port_stats_ext *hw_rx_port_stats_ext; struct rx_port_stats_ext *hw_rx_port_stats_ext;
...@@ -1483,6 +1484,8 @@ struct bnxt { ...@@ -1483,6 +1484,8 @@ struct bnxt {
int hw_port_stats_size; int hw_port_stats_size;
u16 fw_rx_stats_ext_size; u16 fw_rx_stats_ext_size;
u16 fw_tx_stats_ext_size; u16 fw_tx_stats_ext_size;
u8 pri2cos[8];
u8 pri2cos_valid;
u16 hwrm_max_req_len; u16 hwrm_max_req_len;
u16 hwrm_max_ext_req_len; u16 hwrm_max_ext_req_len;
...@@ -1686,11 +1689,12 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap, ...@@ -1686,11 +1689,12 @@ int bnxt_hwrm_func_rgtr_async_events(struct bnxt *bp, unsigned long *bmap,
int bmap_size); int bmap_size);
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id);
int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings); int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
int bnxt_nq_rings_in_use(struct bnxt *bp);
int bnxt_hwrm_set_coal(struct bnxt *); int bnxt_hwrm_set_coal(struct bnxt *);
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp); unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
void bnxt_set_max_func_stat_ctxs(struct bnxt *bp, unsigned int max); unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);
unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp); unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp);
unsigned int bnxt_get_max_func_cp_rings_for_en(struct bnxt *bp); unsigned int bnxt_get_avail_cp_rings_for_en(struct bnxt *bp);
int bnxt_get_avail_msix(struct bnxt *bp, int num); int bnxt_get_avail_msix(struct bnxt *bp, int num);
int bnxt_reserve_rings(struct bnxt *bp); int bnxt_reserve_rings(struct bnxt *bp);
void bnxt_tx_disable(struct bnxt *bp); void bnxt_tx_disable(struct bnxt *bp);
......
...@@ -471,6 +471,9 @@ static int bnxt_ets_validate(struct bnxt *bp, struct ieee_ets *ets, u8 *tc) ...@@ -471,6 +471,9 @@ static int bnxt_ets_validate(struct bnxt *bp, struct ieee_ets *ets, u8 *tc)
if (total_ets_bw > 100) if (total_ets_bw > 100)
return -EINVAL; return -EINVAL;
if (max_tc >= bp->max_tc)
*tc = bp->max_tc;
else
*tc = max_tc + 1; *tc = max_tc + 1;
return 0; return 0;
} }
......
...@@ -207,6 +207,34 @@ static int bnxt_set_coalesce(struct net_device *dev, ...@@ -207,6 +207,34 @@ static int bnxt_set_coalesce(struct net_device *dev,
BNXT_TX_STATS_EXT_COS_ENTRY(6), \ BNXT_TX_STATS_EXT_COS_ENTRY(6), \
BNXT_TX_STATS_EXT_COS_ENTRY(7) \ BNXT_TX_STATS_EXT_COS_ENTRY(7) \
#define BNXT_RX_STATS_PRI_ENTRY(counter, n) \
{ BNXT_RX_STATS_EXT_OFFSET(counter##_cos0), \
__stringify(counter##_pri##n) }
#define BNXT_TX_STATS_PRI_ENTRY(counter, n) \
{ BNXT_TX_STATS_EXT_OFFSET(counter##_cos0), \
__stringify(counter##_pri##n) }
#define BNXT_RX_STATS_PRI_ENTRIES(counter) \
BNXT_RX_STATS_PRI_ENTRY(counter, 0), \
BNXT_RX_STATS_PRI_ENTRY(counter, 1), \
BNXT_RX_STATS_PRI_ENTRY(counter, 2), \
BNXT_RX_STATS_PRI_ENTRY(counter, 3), \
BNXT_RX_STATS_PRI_ENTRY(counter, 4), \
BNXT_RX_STATS_PRI_ENTRY(counter, 5), \
BNXT_RX_STATS_PRI_ENTRY(counter, 6), \
BNXT_RX_STATS_PRI_ENTRY(counter, 7)
#define BNXT_TX_STATS_PRI_ENTRIES(counter) \
BNXT_TX_STATS_PRI_ENTRY(counter, 0), \
BNXT_TX_STATS_PRI_ENTRY(counter, 1), \
BNXT_TX_STATS_PRI_ENTRY(counter, 2), \
BNXT_TX_STATS_PRI_ENTRY(counter, 3), \
BNXT_TX_STATS_PRI_ENTRY(counter, 4), \
BNXT_TX_STATS_PRI_ENTRY(counter, 5), \
BNXT_TX_STATS_PRI_ENTRY(counter, 6), \
BNXT_TX_STATS_PRI_ENTRY(counter, 7)
enum { enum {
RX_TOTAL_DISCARDS, RX_TOTAL_DISCARDS,
TX_TOTAL_DISCARDS, TX_TOTAL_DISCARDS,
...@@ -327,8 +355,41 @@ static const struct { ...@@ -327,8 +355,41 @@ static const struct {
BNXT_TX_STATS_EXT_PFC_ENTRIES, BNXT_TX_STATS_EXT_PFC_ENTRIES,
}; };
static const struct {
long base_off;
char string[ETH_GSTRING_LEN];
} bnxt_rx_bytes_pri_arr[] = {
BNXT_RX_STATS_PRI_ENTRIES(rx_bytes),
};
static const struct {
long base_off;
char string[ETH_GSTRING_LEN];
} bnxt_rx_pkts_pri_arr[] = {
BNXT_RX_STATS_PRI_ENTRIES(rx_packets),
};
static const struct {
long base_off;
char string[ETH_GSTRING_LEN];
} bnxt_tx_bytes_pri_arr[] = {
BNXT_TX_STATS_PRI_ENTRIES(tx_bytes),
};
static const struct {
long base_off;
char string[ETH_GSTRING_LEN];
} bnxt_tx_pkts_pri_arr[] = {
BNXT_TX_STATS_PRI_ENTRIES(tx_packets),
};
#define BNXT_NUM_SW_FUNC_STATS ARRAY_SIZE(bnxt_sw_func_stats) #define BNXT_NUM_SW_FUNC_STATS ARRAY_SIZE(bnxt_sw_func_stats)
#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr) #define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr)
#define BNXT_NUM_STATS_PRI \
(ARRAY_SIZE(bnxt_rx_bytes_pri_arr) + \
ARRAY_SIZE(bnxt_rx_pkts_pri_arr) + \
ARRAY_SIZE(bnxt_tx_bytes_pri_arr) + \
ARRAY_SIZE(bnxt_tx_pkts_pri_arr))
static int bnxt_get_num_stats(struct bnxt *bp) static int bnxt_get_num_stats(struct bnxt *bp)
{ {
...@@ -339,9 +400,12 @@ static int bnxt_get_num_stats(struct bnxt *bp) ...@@ -339,9 +400,12 @@ static int bnxt_get_num_stats(struct bnxt *bp)
if (bp->flags & BNXT_FLAG_PORT_STATS) if (bp->flags & BNXT_FLAG_PORT_STATS)
num_stats += BNXT_NUM_PORT_STATS; num_stats += BNXT_NUM_PORT_STATS;
if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) {
num_stats += bp->fw_rx_stats_ext_size + num_stats += bp->fw_rx_stats_ext_size +
bp->fw_tx_stats_ext_size; bp->fw_tx_stats_ext_size;
if (bp->pri2cos_valid)
num_stats += BNXT_NUM_STATS_PRI;
}
return num_stats; return num_stats;
} }
...@@ -369,8 +433,10 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -369,8 +433,10 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
u32 stat_fields = sizeof(struct ctx_hw_stats) / 8; u32 stat_fields = sizeof(struct ctx_hw_stats) / 8;
if (!bp->bnapi) if (!bp->bnapi) {
return; j += BNXT_NUM_STATS * bp->cp_nr_rings + BNXT_NUM_SW_FUNC_STATS;
goto skip_ring_stats;
}
for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++) for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++)
bnxt_sw_func_stats[i].counter = 0; bnxt_sw_func_stats[i].counter = 0;
...@@ -395,6 +461,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -395,6 +461,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++, j++) for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++, j++)
buf[j] = bnxt_sw_func_stats[i].counter; buf[j] = bnxt_sw_func_stats[i].counter;
skip_ring_stats:
if (bp->flags & BNXT_FLAG_PORT_STATS) { if (bp->flags & BNXT_FLAG_PORT_STATS) {
__le64 *port_stats = (__le64 *)bp->hw_rx_port_stats; __le64 *port_stats = (__le64 *)bp->hw_rx_port_stats;
...@@ -415,6 +482,32 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -415,6 +482,32 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
buf[j] = le64_to_cpu(*(tx_port_stats_ext + buf[j] = le64_to_cpu(*(tx_port_stats_ext +
bnxt_tx_port_stats_ext_arr[i].offset)); bnxt_tx_port_stats_ext_arr[i].offset));
} }
if (bp->pri2cos_valid) {
for (i = 0; i < 8; i++, j++) {
long n = bnxt_rx_bytes_pri_arr[i].base_off +
bp->pri2cos[i];
buf[j] = le64_to_cpu(*(rx_port_stats_ext + n));
}
for (i = 0; i < 8; i++, j++) {
long n = bnxt_rx_pkts_pri_arr[i].base_off +
bp->pri2cos[i];
buf[j] = le64_to_cpu(*(rx_port_stats_ext + n));
}
for (i = 0; i < 8; i++, j++) {
long n = bnxt_tx_bytes_pri_arr[i].base_off +
bp->pri2cos[i];
buf[j] = le64_to_cpu(*(tx_port_stats_ext + n));
}
for (i = 0; i < 8; i++, j++) {
long n = bnxt_tx_pkts_pri_arr[i].base_off +
bp->pri2cos[i];
buf[j] = le64_to_cpu(*(tx_port_stats_ext + n));
}
}
} }
} }
...@@ -493,6 +586,28 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf) ...@@ -493,6 +586,28 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
bnxt_tx_port_stats_ext_arr[i].string); bnxt_tx_port_stats_ext_arr[i].string);
buf += ETH_GSTRING_LEN; buf += ETH_GSTRING_LEN;
} }
if (bp->pri2cos_valid) {
for (i = 0; i < 8; i++) {
strcpy(buf,
bnxt_rx_bytes_pri_arr[i].string);
buf += ETH_GSTRING_LEN;
}
for (i = 0; i < 8; i++) {
strcpy(buf,
bnxt_rx_pkts_pri_arr[i].string);
buf += ETH_GSTRING_LEN;
}
for (i = 0; i < 8; i++) {
strcpy(buf,
bnxt_tx_bytes_pri_arr[i].string);
buf += ETH_GSTRING_LEN;
}
for (i = 0; i < 8; i++) {
strcpy(buf,
bnxt_tx_pkts_pri_arr[i].string);
buf += ETH_GSTRING_LEN;
}
}
} }
break; break;
case ETH_SS_TEST: case ETH_SS_TEST:
...@@ -663,8 +778,6 @@ static int bnxt_set_channels(struct net_device *dev, ...@@ -663,8 +778,6 @@ static int bnxt_set_channels(struct net_device *dev,
bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) :
bp->tx_nr_rings + bp->rx_nr_rings; bp->tx_nr_rings + bp->rx_nr_rings;
bp->num_stat_ctxs = bp->cp_nr_rings;
/* After changing number of rx channels, update NTUPLE feature. */ /* After changing number of rx channels, update NTUPLE feature. */
netdev_update_features(dev); netdev_update_features(dev);
if (netif_running(dev)) { if (netif_running(dev)) {
...@@ -1526,14 +1639,22 @@ static int bnxt_flash_nvram(struct net_device *dev, ...@@ -1526,14 +1639,22 @@ static int bnxt_flash_nvram(struct net_device *dev,
rc = hwrm_send_message(bp, &req, sizeof(req), FLASH_NVRAM_TIMEOUT); rc = hwrm_send_message(bp, &req, sizeof(req), FLASH_NVRAM_TIMEOUT);
dma_free_coherent(&bp->pdev->dev, data_len, kmem, dma_handle); dma_free_coherent(&bp->pdev->dev, data_len, kmem, dma_handle);
if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
netdev_info(dev,
"PF does not have admin privileges to flash the device\n");
rc = -EACCES;
} else if (rc) {
rc = -EIO;
}
return rc; return rc;
} }
static int bnxt_firmware_reset(struct net_device *dev, static int bnxt_firmware_reset(struct net_device *dev,
u16 dir_type) u16 dir_type)
{ {
struct bnxt *bp = netdev_priv(dev);
struct hwrm_fw_reset_input req = {0}; struct hwrm_fw_reset_input req = {0};
struct bnxt *bp = netdev_priv(dev);
int rc;
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_RESET, -1, -1); bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_RESET, -1, -1);
...@@ -1573,7 +1694,15 @@ static int bnxt_firmware_reset(struct net_device *dev, ...@@ -1573,7 +1694,15 @@ static int bnxt_firmware_reset(struct net_device *dev,
return -EINVAL; return -EINVAL;
} }
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
netdev_info(dev,
"PF does not have admin privileges to reset the device\n");
rc = -EACCES;
} else if (rc) {
rc = -EIO;
}
return rc;
} }
static int bnxt_flash_firmware(struct net_device *dev, static int bnxt_flash_firmware(struct net_device *dev,
...@@ -1780,9 +1909,9 @@ static int bnxt_flash_package_from_file(struct net_device *dev, ...@@ -1780,9 +1909,9 @@ static int bnxt_flash_package_from_file(struct net_device *dev,
struct hwrm_nvm_install_update_output *resp = bp->hwrm_cmd_resp_addr; struct hwrm_nvm_install_update_output *resp = bp->hwrm_cmd_resp_addr;
struct hwrm_nvm_install_update_input install = {0}; struct hwrm_nvm_install_update_input install = {0};
const struct firmware *fw; const struct firmware *fw;
int rc, hwrm_err = 0;
u32 item_len; u32 item_len;
u16 index; u16 index;
int rc;
bnxt_hwrm_fw_set_time(bp); bnxt_hwrm_fw_set_time(bp);
...@@ -1825,15 +1954,16 @@ static int bnxt_flash_package_from_file(struct net_device *dev, ...@@ -1825,15 +1954,16 @@ static int bnxt_flash_package_from_file(struct net_device *dev,
memcpy(kmem, fw->data, fw->size); memcpy(kmem, fw->data, fw->size);
modify.host_src_addr = cpu_to_le64(dma_handle); modify.host_src_addr = cpu_to_le64(dma_handle);
rc = hwrm_send_message(bp, &modify, sizeof(modify), hwrm_err = hwrm_send_message(bp, &modify,
sizeof(modify),
FLASH_PACKAGE_TIMEOUT); FLASH_PACKAGE_TIMEOUT);
dma_free_coherent(&bp->pdev->dev, fw->size, kmem, dma_free_coherent(&bp->pdev->dev, fw->size, kmem,
dma_handle); dma_handle);
} }
} }
release_firmware(fw); release_firmware(fw);
if (rc) if (rc || hwrm_err)
return rc; goto err_exit;
if ((install_type & 0xffff) == 0) if ((install_type & 0xffff) == 0)
install_type >>= 16; install_type >>= 16;
...@@ -1841,12 +1971,10 @@ static int bnxt_flash_package_from_file(struct net_device *dev, ...@@ -1841,12 +1971,10 @@ static int bnxt_flash_package_from_file(struct net_device *dev,
install.install_type = cpu_to_le32(install_type); install.install_type = cpu_to_le32(install_type);
mutex_lock(&bp->hwrm_cmd_lock); mutex_lock(&bp->hwrm_cmd_lock);
rc = _hwrm_send_message(bp, &install, sizeof(install), hwrm_err = _hwrm_send_message(bp, &install, sizeof(install),
INSTALL_PACKAGE_TIMEOUT); INSTALL_PACKAGE_TIMEOUT);
if (rc) { if (hwrm_err)
rc = -EOPNOTSUPP;
goto flash_pkg_exit; goto flash_pkg_exit;
}
if (resp->error_code) { if (resp->error_code) {
u8 error_code = ((struct hwrm_err_output *)resp)->cmd_err; u8 error_code = ((struct hwrm_err_output *)resp)->cmd_err;
...@@ -1854,14 +1982,13 @@ static int bnxt_flash_package_from_file(struct net_device *dev, ...@@ -1854,14 +1982,13 @@ static int bnxt_flash_package_from_file(struct net_device *dev,
if (error_code == NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) { if (error_code == NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) {
install.flags |= cpu_to_le16( install.flags |= cpu_to_le16(
NVM_INSTALL_UPDATE_REQ_FLAGS_ALLOWED_TO_DEFRAG); NVM_INSTALL_UPDATE_REQ_FLAGS_ALLOWED_TO_DEFRAG);
rc = _hwrm_send_message(bp, &install, sizeof(install), hwrm_err = _hwrm_send_message(bp, &install,
sizeof(install),
INSTALL_PACKAGE_TIMEOUT); INSTALL_PACKAGE_TIMEOUT);
if (rc) { if (hwrm_err)
rc = -EOPNOTSUPP;
goto flash_pkg_exit; goto flash_pkg_exit;
} }
} }
}
if (resp->result) { if (resp->result) {
netdev_err(dev, "PKG install error = %d, problem_item = %d\n", netdev_err(dev, "PKG install error = %d, problem_item = %d\n",
...@@ -1870,6 +1997,14 @@ static int bnxt_flash_package_from_file(struct net_device *dev, ...@@ -1870,6 +1997,14 @@ static int bnxt_flash_package_from_file(struct net_device *dev,
} }
flash_pkg_exit: flash_pkg_exit:
mutex_unlock(&bp->hwrm_cmd_lock); mutex_unlock(&bp->hwrm_cmd_lock);
err_exit:
if (hwrm_err == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
netdev_info(dev,
"PF does not have admin privileges to flash the device\n");
rc = -EACCES;
} else if (hwrm_err) {
rc = -EOPNOTSUPP;
}
return rc; return rc;
} }
...@@ -2450,17 +2585,37 @@ static int bnxt_hwrm_mac_loopback(struct bnxt *bp, bool enable) ...@@ -2450,17 +2585,37 @@ static int bnxt_hwrm_mac_loopback(struct bnxt *bp, bool enable)
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
} }
static int bnxt_query_force_speeds(struct bnxt *bp, u16 *force_speeds)
{
struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
struct hwrm_port_phy_qcaps_input req = {0};
int rc;
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_QCAPS, -1, -1);
mutex_lock(&bp->hwrm_cmd_lock);
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
if (!rc)
*force_speeds = le16_to_cpu(resp->supported_speeds_force_mode);
mutex_unlock(&bp->hwrm_cmd_lock);
return rc;
}
static int bnxt_disable_an_for_lpbk(struct bnxt *bp, static int bnxt_disable_an_for_lpbk(struct bnxt *bp,
struct hwrm_port_phy_cfg_input *req) struct hwrm_port_phy_cfg_input *req)
{ {
struct bnxt_link_info *link_info = &bp->link_info; struct bnxt_link_info *link_info = &bp->link_info;
u16 fw_advertising = link_info->advertising; u16 fw_advertising;
u16 fw_speed; u16 fw_speed;
int rc; int rc;
if (!link_info->autoneg) if (!link_info->autoneg)
return 0; return 0;
rc = bnxt_query_force_speeds(bp, &fw_advertising);
if (rc)
return rc;
fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB; fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
if (netif_carrier_ok(bp->dev)) if (netif_carrier_ok(bp->dev))
fw_speed = bp->link_info.link_speed; fw_speed = bp->link_info.link_speed;
......
...@@ -448,16 +448,22 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs) ...@@ -448,16 +448,22 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
u16 vf_stat_ctx, vf_vnics, vf_ring_grps; u16 vf_stat_ctx, vf_vnics, vf_ring_grps;
struct bnxt_pf_info *pf = &bp->pf; struct bnxt_pf_info *pf = &bp->pf;
int i, rc = 0, min = 1; int i, rc = 0, min = 1;
u16 vf_msix = 0;
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_RESOURCE_CFG, -1, -1); bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_RESOURCE_CFG, -1, -1);
vf_cp_rings = bnxt_get_max_func_cp_rings_for_en(bp) - bp->cp_nr_rings; if (bp->flags & BNXT_FLAG_CHIP_P5) {
vf_stat_ctx = hw_resc->max_stat_ctxs - bp->num_stat_ctxs; vf_msix = hw_resc->max_nqs - bnxt_nq_rings_in_use(bp);
vf_ring_grps = 0;
} else {
vf_ring_grps = hw_resc->max_hw_ring_grps - bp->rx_nr_rings;
}
vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp);
vf_stat_ctx = bnxt_get_avail_stat_ctxs_for_en(bp);
if (bp->flags & BNXT_FLAG_AGG_RINGS) if (bp->flags & BNXT_FLAG_AGG_RINGS)
vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings * 2; vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings * 2;
else else
vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings; vf_rx_rings = hw_resc->max_rx_rings - bp->rx_nr_rings;
vf_ring_grps = hw_resc->max_hw_ring_grps - bp->rx_nr_rings;
vf_tx_rings = hw_resc->max_tx_rings - bp->tx_nr_rings; vf_tx_rings = hw_resc->max_tx_rings - bp->tx_nr_rings;
vf_vnics = hw_resc->max_vnics - bp->nr_vnics; vf_vnics = hw_resc->max_vnics - bp->nr_vnics;
vf_vnics = min_t(u16, vf_vnics, vf_rx_rings); vf_vnics = min_t(u16, vf_vnics, vf_rx_rings);
...@@ -476,6 +482,7 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs) ...@@ -476,6 +482,7 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
req.min_l2_ctxs = cpu_to_le16(min); req.min_l2_ctxs = cpu_to_le16(min);
req.min_vnics = cpu_to_le16(min); req.min_vnics = cpu_to_le16(min);
req.min_stat_ctx = cpu_to_le16(min); req.min_stat_ctx = cpu_to_le16(min);
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
req.min_hw_ring_grps = cpu_to_le16(min); req.min_hw_ring_grps = cpu_to_le16(min);
} else { } else {
vf_cp_rings /= num_vfs; vf_cp_rings /= num_vfs;
...@@ -500,6 +507,8 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs) ...@@ -500,6 +507,8 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
req.max_vnics = cpu_to_le16(vf_vnics); req.max_vnics = cpu_to_le16(vf_vnics);
req.max_stat_ctx = cpu_to_le16(vf_stat_ctx); req.max_stat_ctx = cpu_to_le16(vf_stat_ctx);
req.max_hw_ring_grps = cpu_to_le16(vf_ring_grps); req.max_hw_ring_grps = cpu_to_le16(vf_ring_grps);
if (bp->flags & BNXT_FLAG_CHIP_P5)
req.max_msix = cpu_to_le16(vf_msix / num_vfs);
mutex_lock(&bp->hwrm_cmd_lock); mutex_lock(&bp->hwrm_cmd_lock);
for (i = 0; i < num_vfs; i++) { for (i = 0; i < num_vfs; i++) {
...@@ -525,6 +534,8 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs) ...@@ -525,6 +534,8 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
hw_resc->max_rsscos_ctxs -= pf->active_vfs; hw_resc->max_rsscos_ctxs -= pf->active_vfs;
hw_resc->max_stat_ctxs -= le16_to_cpu(req.min_stat_ctx) * n; hw_resc->max_stat_ctxs -= le16_to_cpu(req.min_stat_ctx) * n;
hw_resc->max_vnics -= le16_to_cpu(req.min_vnics) * n; hw_resc->max_vnics -= le16_to_cpu(req.min_vnics) * n;
if (bp->flags & BNXT_FLAG_CHIP_P5)
hw_resc->max_irqs -= vf_msix * n;
rc = pf->active_vfs; rc = pf->active_vfs;
} }
...@@ -539,19 +550,16 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs) ...@@ -539,19 +550,16 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
u32 rc = 0, mtu, i; u32 rc = 0, mtu, i;
u16 vf_tx_rings, vf_rx_rings, vf_cp_rings, vf_stat_ctx, vf_vnics; u16 vf_tx_rings, vf_rx_rings, vf_cp_rings, vf_stat_ctx, vf_vnics;
struct bnxt_hw_resc *hw_resc = &bp->hw_resc; struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
u16 vf_ring_grps, max_stat_ctxs;
struct hwrm_func_cfg_input req = {0}; struct hwrm_func_cfg_input req = {0};
struct bnxt_pf_info *pf = &bp->pf; struct bnxt_pf_info *pf = &bp->pf;
int total_vf_tx_rings = 0; int total_vf_tx_rings = 0;
u16 vf_ring_grps;
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1);
max_stat_ctxs = hw_resc->max_stat_ctxs;
/* Remaining rings are distributed equally amongs VF's for now */ /* Remaining rings are distributed equally amongs VF's for now */
vf_cp_rings = (bnxt_get_max_func_cp_rings_for_en(bp) - vf_cp_rings = bnxt_get_avail_cp_rings_for_en(bp) / num_vfs;
bp->cp_nr_rings) / num_vfs; vf_stat_ctx = bnxt_get_avail_stat_ctxs_for_en(bp) / num_vfs;
vf_stat_ctx = (max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;
if (bp->flags & BNXT_FLAG_AGG_RINGS) if (bp->flags & BNXT_FLAG_AGG_RINGS)
vf_rx_rings = (hw_resc->max_rx_rings - bp->rx_nr_rings * 2) / vf_rx_rings = (hw_resc->max_rx_rings - bp->rx_nr_rings * 2) /
num_vfs; num_vfs;
...@@ -644,8 +652,8 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) ...@@ -644,8 +652,8 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
*/ */
vfs_supported = *num_vfs; vfs_supported = *num_vfs;
avail_cp = bnxt_get_max_func_cp_rings_for_en(bp) - bp->cp_nr_rings; avail_cp = bnxt_get_avail_cp_rings_for_en(bp);
avail_stat = hw_resc->max_stat_ctxs - bp->num_stat_ctxs; avail_stat = bnxt_get_avail_stat_ctxs_for_en(bp);
avail_cp = min_t(int, avail_cp, avail_stat); avail_cp = min_t(int, avail_cp, avail_stat);
while (vfs_supported) { while (vfs_supported) {
......
...@@ -48,10 +48,8 @@ static int bnxt_register_dev(struct bnxt_en_dev *edev, int ulp_id, ...@@ -48,10 +48,8 @@ static int bnxt_register_dev(struct bnxt_en_dev *edev, int ulp_id,
max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp); max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS || if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS ||
bp->num_stat_ctxs == max_stat_ctxs) bp->cp_nr_rings == max_stat_ctxs)
return -ENOMEM; return -ENOMEM;
bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs -
BNXT_MIN_ROCE_STAT_CTXS);
} }
atomic_set(&ulp->ref_count, 0); atomic_set(&ulp->ref_count, 0);
...@@ -82,14 +80,9 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, int ulp_id) ...@@ -82,14 +80,9 @@ static int bnxt_unregister_dev(struct bnxt_en_dev *edev, int ulp_id)
netdev_err(bp->dev, "ulp id %d not registered\n", ulp_id); netdev_err(bp->dev, "ulp id %d not registered\n", ulp_id);
return -EINVAL; return -EINVAL;
} }
if (ulp_id == BNXT_ROCE_ULP) { if (ulp_id == BNXT_ROCE_ULP && ulp->msix_requested)
unsigned int max_stat_ctxs;
max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs + 1);
if (ulp->msix_requested)
edev->en_ops->bnxt_free_msix(edev, ulp_id); edev->en_ops->bnxt_free_msix(edev, ulp_id);
}
if (ulp->max_async_event_id) if (ulp->max_async_event_id)
bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0); bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0);
...@@ -218,6 +211,14 @@ int bnxt_get_ulp_msix_base(struct bnxt *bp) ...@@ -218,6 +211,14 @@ int bnxt_get_ulp_msix_base(struct bnxt *bp)
return 0; return 0;
} }
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
{
if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP))
return BNXT_MIN_ROCE_STAT_CTXS;
return 0;
}
static int bnxt_send_msg(struct bnxt_en_dev *edev, int ulp_id, static int bnxt_send_msg(struct bnxt_en_dev *edev, int ulp_id,
struct bnxt_fw_msg *fw_msg) struct bnxt_fw_msg *fw_msg)
{ {
......
...@@ -90,6 +90,7 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id) ...@@ -90,6 +90,7 @@ static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
int bnxt_get_ulp_msix_num(struct bnxt *bp); int bnxt_get_ulp_msix_num(struct bnxt *bp);
int bnxt_get_ulp_msix_base(struct bnxt *bp); int bnxt_get_ulp_msix_base(struct bnxt *bp);
int bnxt_get_ulp_stat_ctxs(struct bnxt *bp);
void bnxt_ulp_stop(struct bnxt *bp); void bnxt_ulp_stop(struct bnxt *bp);
void bnxt_ulp_start(struct bnxt *bp); void bnxt_ulp_start(struct bnxt *bp);
void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs); void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
......
...@@ -199,7 +199,6 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) ...@@ -199,7 +199,6 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
bp->tx_nr_rings_xdp = tx_xdp; bp->tx_nr_rings_xdp = tx_xdp;
bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp; bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp;
bp->cp_nr_rings = max_t(int, bp->tx_nr_rings, bp->rx_nr_rings); bp->cp_nr_rings = max_t(int, bp->tx_nr_rings, bp->rx_nr_rings);
bp->num_stat_ctxs = bp->cp_nr_rings;
bnxt_set_tpa_flags(bp); bnxt_set_tpa_flags(bp);
bnxt_set_ring_params(bp); bnxt_set_ring_params(bp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment