Commit 9b697956 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'bnxt_en-bug-fixes'

Michael Chan says:

====================
bnxt_en: Bug fixes

This series contains 5 miscellaneous fixes.  The fixes include adding
delay for FLR, buffer memory leak, RSS table size calculation,
ethtool self test kernel warning, and mqprio crash.
====================

Link: https://lore.kernel.org/r/20240117234515.226944-1-michael.chan@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 198bc90e 467739ba
...@@ -3817,7 +3817,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp) ...@@ -3817,7 +3817,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
{ {
bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS); bool sh = !!(bp->flags & BNXT_FLAG_SHARED_RINGS);
int i, j, rc, ulp_base_vec, ulp_msix; int i, j, rc, ulp_base_vec, ulp_msix;
int tcs = netdev_get_num_tc(bp->dev); int tcs = bp->num_tc;
if (!tcs) if (!tcs)
tcs = 1; tcs = 1;
...@@ -5935,8 +5935,12 @@ static u16 bnxt_get_max_rss_ring(struct bnxt *bp) ...@@ -5935,8 +5935,12 @@ static u16 bnxt_get_max_rss_ring(struct bnxt *bp)
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings) int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings)
{ {
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
return DIV_ROUND_UP(rx_rings, BNXT_RSS_TABLE_ENTRIES_P5); if (!rx_rings)
return 0;
return bnxt_calc_nr_ring_pages(rx_rings - 1,
BNXT_RSS_TABLE_ENTRIES_P5);
}
if (BNXT_CHIP_TYPE_NITRO_A0(bp)) if (BNXT_CHIP_TYPE_NITRO_A0(bp))
return 2; return 2;
return 1; return 1;
...@@ -6926,7 +6930,7 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp) ...@@ -6926,7 +6930,7 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp)
if (cp < (rx + tx)) { if (cp < (rx + tx)) {
rc = __bnxt_trim_rings(bp, &rx, &tx, cp, false); rc = __bnxt_trim_rings(bp, &rx, &tx, cp, false);
if (rc) if (rc)
return rc; goto get_rings_exit;
if (bp->flags & BNXT_FLAG_AGG_RINGS) if (bp->flags & BNXT_FLAG_AGG_RINGS)
rx <<= 1; rx <<= 1;
hw_resc->resv_rx_rings = rx; hw_resc->resv_rx_rings = rx;
...@@ -6938,8 +6942,9 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp) ...@@ -6938,8 +6942,9 @@ static int bnxt_hwrm_get_rings(struct bnxt *bp)
hw_resc->resv_cp_rings = cp; hw_resc->resv_cp_rings = cp;
hw_resc->resv_stat_ctxs = stats; hw_resc->resv_stat_ctxs = stats;
} }
get_rings_exit:
hwrm_req_drop(bp, req); hwrm_req_drop(bp, req);
return 0; return rc;
} }
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)
...@@ -7000,10 +7005,11 @@ __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, ...@@ -7000,10 +7005,11 @@ __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
req->num_rx_rings = cpu_to_le16(rx_rings); req->num_rx_rings = cpu_to_le16(rx_rings);
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
u16 rss_ctx = bnxt_get_nr_rss_ctxs(bp, ring_grps);
req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps);
req->num_msix = cpu_to_le16(cp_rings); req->num_msix = cpu_to_le16(cp_rings);
req->num_rsscos_ctxs = req->num_rsscos_ctxs = cpu_to_le16(rss_ctx);
cpu_to_le16(DIV_ROUND_UP(ring_grps, 64));
} else { } else {
req->num_cmpl_rings = cpu_to_le16(cp_rings); req->num_cmpl_rings = cpu_to_le16(cp_rings);
req->num_hw_ring_grps = cpu_to_le16(ring_grps); req->num_hw_ring_grps = cpu_to_le16(ring_grps);
...@@ -7050,8 +7056,10 @@ __bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, ...@@ -7050,8 +7056,10 @@ __bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
req->num_tx_rings = cpu_to_le16(tx_rings); req->num_tx_rings = cpu_to_le16(tx_rings);
req->num_rx_rings = cpu_to_le16(rx_rings); req->num_rx_rings = cpu_to_le16(rx_rings);
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
u16 rss_ctx = bnxt_get_nr_rss_ctxs(bp, ring_grps);
req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps); req->num_cmpl_rings = cpu_to_le16(tx_rings + ring_grps);
req->num_rsscos_ctxs = cpu_to_le16(DIV_ROUND_UP(ring_grps, 64)); req->num_rsscos_ctxs = cpu_to_le16(rss_ctx);
} else { } else {
req->num_cmpl_rings = cpu_to_le16(cp_rings); req->num_cmpl_rings = cpu_to_le16(cp_rings);
req->num_hw_ring_grps = cpu_to_le16(ring_grps); req->num_hw_ring_grps = cpu_to_le16(ring_grps);
...@@ -9938,7 +9946,7 @@ static int __bnxt_num_tx_to_cp(struct bnxt *bp, int tx, int tx_sets, int tx_xdp) ...@@ -9938,7 +9946,7 @@ static int __bnxt_num_tx_to_cp(struct bnxt *bp, int tx, int tx_sets, int tx_xdp)
int bnxt_num_tx_to_cp(struct bnxt *bp, int tx) int bnxt_num_tx_to_cp(struct bnxt *bp, int tx)
{ {
int tcs = netdev_get_num_tc(bp->dev); int tcs = bp->num_tc;
if (!tcs) if (!tcs)
tcs = 1; tcs = 1;
...@@ -9947,7 +9955,7 @@ int bnxt_num_tx_to_cp(struct bnxt *bp, int tx) ...@@ -9947,7 +9955,7 @@ int bnxt_num_tx_to_cp(struct bnxt *bp, int tx)
static int bnxt_num_cp_to_tx(struct bnxt *bp, int tx_cp) static int bnxt_num_cp_to_tx(struct bnxt *bp, int tx_cp)
{ {
int tcs = netdev_get_num_tc(bp->dev); int tcs = bp->num_tc;
return (tx_cp - bp->tx_nr_rings_xdp) * tcs + return (tx_cp - bp->tx_nr_rings_xdp) * tcs +
bp->tx_nr_rings_xdp; bp->tx_nr_rings_xdp;
...@@ -9977,7 +9985,7 @@ static void bnxt_setup_msix(struct bnxt *bp) ...@@ -9977,7 +9985,7 @@ static void bnxt_setup_msix(struct bnxt *bp)
struct net_device *dev = bp->dev; struct net_device *dev = bp->dev;
int tcs, i; int tcs, i;
tcs = netdev_get_num_tc(dev); tcs = bp->num_tc;
if (tcs) { if (tcs) {
int i, off, count; int i, off, count;
...@@ -10009,8 +10017,10 @@ static void bnxt_setup_inta(struct bnxt *bp) ...@@ -10009,8 +10017,10 @@ static void bnxt_setup_inta(struct bnxt *bp)
{ {
const int len = sizeof(bp->irq_tbl[0].name); const int len = sizeof(bp->irq_tbl[0].name);
if (netdev_get_num_tc(bp->dev)) if (bp->num_tc) {
netdev_reset_tc(bp->dev); netdev_reset_tc(bp->dev);
bp->num_tc = 0;
}
snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx",
0); 0);
...@@ -10236,8 +10246,8 @@ static void bnxt_clear_int_mode(struct bnxt *bp) ...@@ -10236,8 +10246,8 @@ static void bnxt_clear_int_mode(struct bnxt *bp)
int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
{ {
int tcs = netdev_get_num_tc(bp->dev);
bool irq_cleared = false; bool irq_cleared = false;
int tcs = bp->num_tc;
int rc; int rc;
if (!bnxt_need_reserve_rings(bp)) if (!bnxt_need_reserve_rings(bp))
...@@ -10263,6 +10273,7 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) ...@@ -10263,6 +10273,7 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
bp->tx_nr_rings - bp->tx_nr_rings_xdp)) { bp->tx_nr_rings - bp->tx_nr_rings_xdp)) {
netdev_err(bp->dev, "tx ring reservation failure\n"); netdev_err(bp->dev, "tx ring reservation failure\n");
netdev_reset_tc(bp->dev); netdev_reset_tc(bp->dev);
bp->num_tc = 0;
if (bp->tx_nr_rings_xdp) if (bp->tx_nr_rings_xdp)
bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp; bp->tx_nr_rings_per_tc = bp->tx_nr_rings_xdp;
else else
...@@ -11564,10 +11575,12 @@ int bnxt_half_open_nic(struct bnxt *bp) ...@@ -11564,10 +11575,12 @@ int bnxt_half_open_nic(struct bnxt *bp)
netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc); netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc);
goto half_open_err; goto half_open_err;
} }
bnxt_init_napi(bp);
set_bit(BNXT_STATE_HALF_OPEN, &bp->state); set_bit(BNXT_STATE_HALF_OPEN, &bp->state);
rc = bnxt_init_nic(bp, true); rc = bnxt_init_nic(bp, true);
if (rc) { if (rc) {
clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); clear_bit(BNXT_STATE_HALF_OPEN, &bp->state);
bnxt_del_napi(bp);
netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc); netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc);
goto half_open_err; goto half_open_err;
} }
...@@ -11586,6 +11599,7 @@ int bnxt_half_open_nic(struct bnxt *bp) ...@@ -11586,6 +11599,7 @@ int bnxt_half_open_nic(struct bnxt *bp)
void bnxt_half_close_nic(struct bnxt *bp) void bnxt_half_close_nic(struct bnxt *bp)
{ {
bnxt_hwrm_resource_free(bp, false, true); bnxt_hwrm_resource_free(bp, false, true);
bnxt_del_napi(bp);
bnxt_free_skbs(bp); bnxt_free_skbs(bp);
bnxt_free_mem(bp, true); bnxt_free_mem(bp, true);
clear_bit(BNXT_STATE_HALF_OPEN, &bp->state); clear_bit(BNXT_STATE_HALF_OPEN, &bp->state);
...@@ -13232,6 +13246,11 @@ static int bnxt_fw_init_one_p1(struct bnxt *bp) ...@@ -13232,6 +13246,11 @@ static int bnxt_fw_init_one_p1(struct bnxt *bp)
bp->fw_cap = 0; bp->fw_cap = 0;
rc = bnxt_hwrm_ver_get(bp); rc = bnxt_hwrm_ver_get(bp);
/* FW may be unresponsive after FLR. FLR must complete within 100 msec
* so wait before continuing with recovery.
*/
if (rc)
msleep(100);
bnxt_try_map_fw_health_reg(bp); bnxt_try_map_fw_health_reg(bp);
if (rc) { if (rc) {
rc = bnxt_try_recover_fw(bp); rc = bnxt_try_recover_fw(bp);
...@@ -13784,7 +13803,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc) ...@@ -13784,7 +13803,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
return -EINVAL; return -EINVAL;
} }
if (netdev_get_num_tc(dev) == tc) if (bp->num_tc == tc)
return 0; return 0;
if (bp->flags & BNXT_FLAG_SHARED_RINGS) if (bp->flags & BNXT_FLAG_SHARED_RINGS)
...@@ -13802,9 +13821,11 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc) ...@@ -13802,9 +13821,11 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
if (tc) { if (tc) {
bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc; bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc;
netdev_set_num_tc(dev, tc); netdev_set_num_tc(dev, tc);
bp->num_tc = tc;
} else { } else {
bp->tx_nr_rings = bp->tx_nr_rings_per_tc; bp->tx_nr_rings = bp->tx_nr_rings_per_tc;
netdev_reset_tc(dev); netdev_reset_tc(dev);
bp->num_tc = 0;
} }
bp->tx_nr_rings += bp->tx_nr_rings_xdp; bp->tx_nr_rings += bp->tx_nr_rings_xdp;
tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);
......
...@@ -2225,6 +2225,7 @@ struct bnxt { ...@@ -2225,6 +2225,7 @@ struct bnxt {
u8 tc_to_qidx[BNXT_MAX_QUEUE]; u8 tc_to_qidx[BNXT_MAX_QUEUE];
u8 q_ids[BNXT_MAX_QUEUE]; u8 q_ids[BNXT_MAX_QUEUE];
u8 max_q; u8 max_q;
u8 num_tc;
unsigned int current_interval; unsigned int current_interval;
#define BNXT_TIMER_INTERVAL HZ #define BNXT_TIMER_INTERVAL HZ
......
...@@ -228,7 +228,7 @@ static int bnxt_queue_remap(struct bnxt *bp, unsigned int lltc_mask) ...@@ -228,7 +228,7 @@ static int bnxt_queue_remap(struct bnxt *bp, unsigned int lltc_mask)
} }
} }
if (bp->ieee_ets) { if (bp->ieee_ets) {
int tc = netdev_get_num_tc(bp->dev); int tc = bp->num_tc;
if (!tc) if (!tc)
tc = 1; tc = 1;
......
...@@ -884,7 +884,7 @@ static void bnxt_get_channels(struct net_device *dev, ...@@ -884,7 +884,7 @@ static void bnxt_get_channels(struct net_device *dev,
if (max_tx_sch_inputs) if (max_tx_sch_inputs)
max_tx_rings = min_t(int, max_tx_rings, max_tx_sch_inputs); max_tx_rings = min_t(int, max_tx_rings, max_tx_sch_inputs);
tcs = netdev_get_num_tc(dev); tcs = bp->num_tc;
tx_grps = max(tcs, 1); tx_grps = max(tcs, 1);
if (bp->tx_nr_rings_xdp) if (bp->tx_nr_rings_xdp)
tx_grps++; tx_grps++;
...@@ -944,7 +944,7 @@ static int bnxt_set_channels(struct net_device *dev, ...@@ -944,7 +944,7 @@ static int bnxt_set_channels(struct net_device *dev,
if (channel->combined_count) if (channel->combined_count)
sh = true; sh = true;
tcs = netdev_get_num_tc(dev); tcs = bp->num_tc;
req_tx_rings = sh ? channel->combined_count : channel->tx_count; req_tx_rings = sh ? channel->combined_count : channel->tx_count;
req_rx_rings = sh ? channel->combined_count : channel->rx_count; req_rx_rings = sh ? channel->combined_count : channel->rx_count;
...@@ -1574,7 +1574,8 @@ u32 bnxt_get_rxfh_indir_size(struct net_device *dev) ...@@ -1574,7 +1574,8 @@ u32 bnxt_get_rxfh_indir_size(struct net_device *dev)
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)
return ALIGN(bp->rx_nr_rings, BNXT_RSS_TABLE_ENTRIES_P5); return bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) *
BNXT_RSS_TABLE_ENTRIES_P5;
return HW_HASH_INDEX_SIZE; return HW_HASH_INDEX_SIZE;
} }
......
...@@ -407,7 +407,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) ...@@ -407,7 +407,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
if (prog) if (prog)
tx_xdp = bp->rx_nr_rings; tx_xdp = bp->rx_nr_rings;
tc = netdev_get_num_tc(dev); tc = bp->num_tc;
if (!tc) if (!tc)
tc = 1; tc = 1;
rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings, rc = bnxt_check_rings(bp, bp->tx_nr_rings_per_tc, bp->rx_nr_rings,
......
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