Skip to content

Commit 9351edf

Browse files
committed
Merge branch 'bnxt_en-bug-fixes'
Michael Chan says: ==================== bnxt_en: Bug fixes The first patch is a refactor patch needed by the second patch to fix XDP ring initialization during FW reset. The third patch fixes an issue related to stats context reservation for RoCE. ==================== Link: https://patch.msgid.link/20260331065138.948205-1-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents a59dc0f + 071dbfa commit 9351edf

4 files changed

Lines changed: 52 additions & 27 deletions

File tree

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8045,6 +8045,8 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
80458045
ulp_msix = bnxt_get_avail_msix(bp, bp->ulp_num_msix_want);
80468046
if (!ulp_msix)
80478047
bnxt_set_ulp_stat_ctxs(bp, 0);
8048+
else
8049+
bnxt_set_dflt_ulp_stat_ctxs(bp);
80488050

80498051
if (ulp_msix > bp->ulp_num_msix_want)
80508052
ulp_msix = bp->ulp_num_msix_want;
@@ -12992,6 +12994,21 @@ static int bnxt_tx_nr_rings_per_tc(struct bnxt *bp)
1299212994
return bp->num_tc ? bp->tx_nr_rings / bp->num_tc : bp->tx_nr_rings;
1299312995
}
1299412996

12997+
static void bnxt_set_xdp_tx_rings(struct bnxt *bp)
12998+
{
12999+
bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc;
13000+
bp->tx_nr_rings += bp->tx_nr_rings_xdp;
13001+
}
13002+
13003+
static void bnxt_adj_tx_rings(struct bnxt *bp)
13004+
{
13005+
/* Make adjustments if reserved TX rings are less than requested */
13006+
bp->tx_nr_rings -= bp->tx_nr_rings_xdp;
13007+
bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);
13008+
if (bp->tx_nr_rings_xdp)
13009+
bnxt_set_xdp_tx_rings(bp);
13010+
}
13011+
1299513012
static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1299613013
{
1299713014
int rc = 0;
@@ -13009,13 +13026,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1300913026
if (rc)
1301013027
return rc;
1301113028

13012-
/* Make adjustments if reserved TX rings are less than requested */
13013-
bp->tx_nr_rings -= bp->tx_nr_rings_xdp;
13014-
bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);
13015-
if (bp->tx_nr_rings_xdp) {
13016-
bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc;
13017-
bp->tx_nr_rings += bp->tx_nr_rings_xdp;
13018-
}
13029+
bnxt_adj_tx_rings(bp);
1301913030
rc = bnxt_alloc_mem(bp, irq_re_init);
1302013031
if (rc) {
1302113032
netdev_err(bp->dev, "bnxt_alloc_mem err: %x\n", rc);
@@ -15436,11 +15447,19 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)
1543615447
return 0;
1543715448
}
1543815449

15450+
void bnxt_set_cp_rings(struct bnxt *bp, bool sh)
15451+
{
15452+
int tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);
15453+
15454+
bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) :
15455+
tx_cp + bp->rx_nr_rings;
15456+
}
15457+
1543915458
int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
1544015459
{
1544115460
struct bnxt *bp = netdev_priv(dev);
1544215461
bool sh = false;
15443-
int rc, tx_cp;
15462+
int rc;
1544415463

1544515464
if (tc > bp->max_tc) {
1544615465
netdev_err(dev, "Too many traffic classes requested: %d. Max supported is %d.\n",
@@ -15473,9 +15492,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
1547315492
bp->num_tc = 0;
1547415493
}
1547515494
bp->tx_nr_rings += bp->tx_nr_rings_xdp;
15476-
tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);
15477-
bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) :
15478-
tx_cp + bp->rx_nr_rings;
15495+
bnxt_set_cp_rings(bp, sh);
1547915496

1548015497
if (netif_running(bp->dev))
1548115498
return bnxt_open_nic(bp, true, false);
@@ -16525,6 +16542,19 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp)
1652516542
bp->tx_nr_rings = bnxt_tx_nr_rings(bp);
1652616543
}
1652716544

16545+
static void bnxt_adj_dflt_rings(struct bnxt *bp, bool sh)
16546+
{
16547+
if (sh)
16548+
bnxt_trim_dflt_sh_rings(bp);
16549+
else
16550+
bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings;
16551+
bp->tx_nr_rings = bnxt_tx_nr_rings(bp);
16552+
if (sh && READ_ONCE(bp->xdp_prog)) {
16553+
bnxt_set_xdp_tx_rings(bp);
16554+
bnxt_set_cp_rings(bp, true);
16555+
}
16556+
}
16557+
1652816558
static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1652916559
{
1653016560
int dflt_rings, max_rx_rings, max_tx_rings, rc;
@@ -16550,11 +16580,8 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1655016580
return rc;
1655116581
bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings);
1655216582
bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings);
16553-
if (sh)
16554-
bnxt_trim_dflt_sh_rings(bp);
16555-
else
16556-
bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings;
16557-
bp->tx_nr_rings = bnxt_tx_nr_rings(bp);
16583+
16584+
bnxt_adj_dflt_rings(bp, sh);
1655816585

1655916586
avail_msix = bnxt_get_max_func_irqs(bp) - bp->cp_nr_rings;
1656016587
if (avail_msix >= BNXT_MIN_ROCE_CP_RINGS) {
@@ -16567,16 +16594,17 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)
1656716594
rc = __bnxt_reserve_rings(bp);
1656816595
if (rc && rc != -ENODEV)
1656916596
netdev_warn(bp->dev, "Unable to reserve tx rings\n");
16570-
bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);
16597+
16598+
bnxt_adj_tx_rings(bp);
1657116599
if (sh)
16572-
bnxt_trim_dflt_sh_rings(bp);
16600+
bnxt_adj_dflt_rings(bp, true);
1657316601

1657416602
/* Rings may have been trimmed, re-reserve the trimmed rings. */
1657516603
if (bnxt_need_reserve_rings(bp)) {
1657616604
rc = __bnxt_reserve_rings(bp);
1657716605
if (rc && rc != -ENODEV)
1657816606
netdev_warn(bp->dev, "2nd rings reservation failed.\n");
16579-
bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);
16607+
bnxt_adj_tx_rings(bp);
1658016608
}
1658116609
if (BNXT_CHIP_TYPE_NITRO_A0(bp)) {
1658216610
bp->rx_nr_rings++;
@@ -16610,7 +16638,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp)
1661016638
if (rc)
1661116639
goto init_dflt_ring_err;
1661216640

16613-
bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);
16641+
bnxt_adj_tx_rings(bp);
1661416642

1661516643
bnxt_set_dflt_rfs(bp);
1661616644

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs,
29852985
int tx_xdp);
29862986
int bnxt_fw_init_one(struct bnxt *bp);
29872987
bool bnxt_hwrm_reset_permitted(struct bnxt *bp);
2988+
void bnxt_set_cp_rings(struct bnxt *bp, bool sh);
29882989
int bnxt_setup_mq_tc(struct net_device *dev, u8 tc);
29892990
struct bnxt_ntuple_filter *bnxt_lookup_ntp_filter_from_idx(struct bnxt *bp,
29902991
struct bnxt_ntuple_filter *fltr, u32 idx);

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ static int bnxt_set_channels(struct net_device *dev,
945945
bool sh = false;
946946
int tx_xdp = 0;
947947
int rc = 0;
948-
int tx_cp;
949948

950949
if (channel->other_count)
951950
return -EINVAL;
@@ -1013,9 +1012,7 @@ static int bnxt_set_channels(struct net_device *dev,
10131012
if (tcs > 1)
10141013
bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs + tx_xdp;
10151014

1016-
tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);
1017-
bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) :
1018-
tx_cp + bp->rx_nr_rings;
1015+
bnxt_set_cp_rings(bp, sh);
10191016

10201017
/* After changing number of rx channels, update NTUPLE feature. */
10211018
netdev_update_features(dev);

drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,
384384
static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
385385
{
386386
struct net_device *dev = bp->dev;
387-
int tx_xdp = 0, tx_cp, rc, tc;
387+
int tx_xdp = 0, rc, tc;
388388
struct bpf_prog *old;
389389

390390
netdev_assert_locked(dev);
@@ -431,8 +431,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)
431431
}
432432
bp->tx_nr_rings_xdp = tx_xdp;
433433
bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp;
434-
tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings);
435-
bp->cp_nr_rings = max_t(int, tx_cp, bp->rx_nr_rings);
434+
bnxt_set_cp_rings(bp, true);
436435
bnxt_set_tpa_flags(bp);
437436
bnxt_set_ring_params(bp);
438437

0 commit comments

Comments
 (0)