bnxt_en: Bug fixes
Michael Chan
maintainerv2 cover 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.
v2: Fix Fixes tag commit ID for patch #2
v1: https://lore.kernel.org/netdev/[email protected]/
Michael Chan (2):
bnxt_en: Refactor some basic ring setup and adjustment logic
bnxt_en: Don't assume XDP is never enabled in
bnxt_init_dflt_ring_mode()
Pavan Chebbi (1):
bnxt_en: Restore default stat ctxs for ULP when resource is available
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 68 +++++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 5 +- 4 files changed, 52 insertions(+), 27 deletions(-)
Signature · 1 line
2.51.0
Michael Chan
maintainerPATCH v2 1/3 bnxt_en: Refactor some basic ring setup and adjustment logic
Refactor out the basic code that trims the default rings, sets up and adjusts XDP TX rings and CP rings. There is no change in behavior. This is to prepare for the next bug fix patch.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 53 +++++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 5 +- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 5 +- 4 files changed, 41 insertions(+), 23 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +37 -16
@@ -12992,6 +12992,21 @@ static int bnxt_tx_nr_rings_per_tc(struct bnxt *bp)return bp->num_tc ? bp->tx_nr_rings / bp->num_tc : bp->tx_nr_rings; } +static void bnxt_set_xdp_tx_rings (struct bnxt *bp) +{ + bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc; + bp->tx_nr_rings += bp->tx_nr_rings_xdp; +} + +static void bnxt_adj_tx_rings (struct bnxt *bp) +{ +/* Make adjustments if reserved TX rings are less than requested */ + bp->tx_nr_rings -= bp->tx_nr_rings_xdp; + bp->tx_nr_rings_per_tc =bnxt_tx_nr_rings_per_tc (bp); +if (bp->tx_nr_rings_xdp) +bnxt_set_xdp_tx_rings (bp); +} +static int __bnxt_open_nic (struct bnxt *bp,bool irq_re_init,bool link_re_init) {int rc =0 ;
@@ -13009,13 +13024,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)if (rc)return rc; -/* Make adjustments if reserved TX rings are less than requested */ - bp->tx_nr_rings -= bp->tx_nr_rings_xdp; - bp->tx_nr_rings_per_tc =bnxt_tx_nr_rings_per_tc (bp); -if (bp->tx_nr_rings_xdp) { - bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc; - bp->tx_nr_rings += bp->tx_nr_rings_xdp; - } +bnxt_adj_tx_rings (bp); rc =bnxt_alloc_mem (bp, irq_re_init);if (rc) {netdev_err (bp->dev,"bnxt_alloc_mem err: %x\n" , rc);
@@ -15436,11 +15445,19 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)return 0 ; } +void bnxt_set_cp_rings (struct bnxt *bp,bool sh) +{ +int tx_cp =bnxt_num_tx_to_cp (bp, bp->tx_nr_rings); + + bp->cp_nr_rings = sh ?max_t (int, tx_cp, bp->rx_nr_rings) : + tx_cp + bp->rx_nr_rings; +} +int bnxt_setup_mq_tc (struct net_device *dev,u8 tc) {struct bnxt *bp =netdev_priv (dev);bool sh = false; -int rc, tx_cp; +int rc;if (tc > bp->max_tc) { netdev_err(dev, "Too many traffic classes requested: %d. Max supported is %d.\n",
@@ -15473,9 +15490,7 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc) bp->num_tc =0 ; } bp->tx_nr_rings += bp->tx_nr_rings_xdp; - tx_cp =bnxt_num_tx_to_cp (bp, bp->tx_nr_rings); - bp->cp_nr_rings = sh ?max_t (int, tx_cp, bp->rx_nr_rings) : - tx_cp + bp->rx_nr_rings; +bnxt_set_cp_rings (bp, sh);if (netif_running (bp->dev))return bnxt_open_nic (bp, true, false);
@@ -16525,6 +16540,15 @@ static void bnxt_trim_dflt_sh_rings(struct bnxt *bp) bp->tx_nr_rings =bnxt_tx_nr_rings (bp); } +static void bnxt_adj_dflt_rings (struct bnxt *bp,bool sh) +{ +if (sh) +bnxt_trim_dflt_sh_rings (bp); +else + bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; + bp->tx_nr_rings =bnxt_tx_nr_rings (bp); +} +static int bnxt_set_dflt_rings (struct bnxt *bp,bool sh) {int dflt_rings, max_rx_rings, max_tx_rings, rc;
@@ -16550,11 +16574,8 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh)return rc; bp->rx_nr_rings =min_t (int, dflt_rings, max_rx_rings); bp->tx_nr_rings_per_tc =min_t (int, dflt_rings, max_tx_rings); -if (sh) -bnxt_trim_dflt_sh_rings (bp); -else - bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; - bp->tx_nr_rings =bnxt_tx_nr_rings (bp); + +bnxt_adj_dflt_rings (bp, sh); avail_msix =bnxt_get_max_func_irqs (bp) - bp->cp_nr_rings;if (avail_msix >=BNXT_MIN_ROCE_CP_RINGS ) {
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -2985,6 +2985,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, int tx_xdp);int bnxt_fw_init_one (struct bnxt *bp);bool bnxt_hwrm_reset_permitted (struct bnxt *bp); +void bnxt_set_cp_rings (struct bnxt *bp,bool sh);int bnxt_setup_mq_tc (struct net_device *dev,u8 tc);struct bnxt_ntuple_filter *bnxt_lookup_ntp_filter_from_idx (struct bnxt *bp,struct bnxt_ntuple_filter *fltr,u32 idx);
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -4
@@ -945,7 +945,6 @@ static int bnxt_set_channels(struct net_device *dev,bool sh = false;int tx_xdp =0 ;int rc =0 ; -int tx_cp;if (channel->other_count)return -EINVAL ;
@@ -1013,9 +1012,7 @@ static int bnxt_set_channels(struct net_device *dev,if (tcs >1 ) bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs + tx_xdp; - tx_cp =bnxt_num_tx_to_cp (bp, bp->tx_nr_rings); - bp->cp_nr_rings = sh ?max_t (int, tx_cp, bp->rx_nr_rings) : - tx_cp + bp->rx_nr_rings; +bnxt_set_cp_rings (bp, sh);/* After changing number of rx channels, update NTUPLE feature. */ netdev_update_features (dev);
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +2 -3
@@ -384,7 +384,7 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,static int bnxt_xdp_set (struct bnxt *bp,struct bpf_prog *prog) {struct net_device *dev = bp->dev; -int tx_xdp =0 , tx_cp, rc, tc; +int tx_xdp =0 , rc, tc;struct bpf_prog *old;netdev_assert_locked (dev);
@@ -431,8 +431,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) } bp->tx_nr_rings_xdp = tx_xdp; bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp; - tx_cp =bnxt_num_tx_to_cp (bp, bp->tx_nr_rings); - bp->cp_nr_rings =max_t (int, tx_cp, bp->rx_nr_rings); +bnxt_set_cp_rings (bp, true);bnxt_set_tpa_flags (bp);bnxt_set_ring_params (bp);
Signature · 1 line
2.51.0
Michael Chan
maintainerPATCH v2 2/3 bnxt_en: Don't assume XDP is never enabled in bnxt_init_dflt_ring_mode()
In reply to Michael ChanThe original code made the assumption that when we set up the initial default ring mode, we must be just loading the driver and XDP cannot be enabled yet. This is not true when the FW goes through a resource or capability change. Resource reservations will be cancelled and reinitialized with XDP already enabled. devlink reload with XDP enabled will also have the same issue. This scenario will cause the ring arithmetic to be all wrong in the bnxt_init_dflt_ring_mode() path causing failure:
bnxt_en 0000:a1:00.0 ens2f0np0: bnxt_setup_int_mode err: ffffffea bnxt_en 0000:a1:00.0 ens2f0np0: bnxt_request_irq err: ffffffea bnxt_en 0000:a1:00.0 ens2f0np0: nic open fail (rc: ffffffea)
Fix it by properly accounting for XDP in the bnxt_init_dflt_ring_mode() path by using the refactored helper functions in the previous patch.
---
v2: Fix commit ID of a Fixes tag
v1: https://lore.kernel.org/netdev/[email protected]/
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +9 -4
@@ -16547,6 +16547,10 @@ static void bnxt_adj_dflt_rings(struct bnxt *bp, bool sh)else bp->cp_nr_rings = bp->tx_nr_rings_per_tc + bp->rx_nr_rings; bp->tx_nr_rings =bnxt_tx_nr_rings (bp); +if (sh &&READ_ONCE (bp->xdp_prog)) { +bnxt_set_xdp_tx_rings (bp); +bnxt_set_cp_rings (bp, true); + } }static int bnxt_set_dflt_rings (struct bnxt *bp,bool sh)
@@ -16588,16 +16592,17 @@ static int bnxt_set_dflt_rings(struct bnxt *bp, bool sh) rc =__bnxt_reserve_rings (bp);if (rc && rc != -ENODEV )netdev_warn (bp->dev,"Unable to reserve tx rings\n" ); - bp->tx_nr_rings_per_tc =bnxt_tx_nr_rings_per_tc (bp); + +bnxt_adj_tx_rings (bp);if (sh) -bnxt_trim_dflt_sh_rings (bp); +bnxt_adj_dflt_rings (bp, true);/* Rings may have been trimmed, re-reserve the trimmed rings. */ if (bnxt_need_reserve_rings (bp)) { rc =__bnxt_reserve_rings (bp);if (rc && rc != -ENODEV )netdev_warn (bp->dev,"2nd rings reservation failed.\n" ); - bp->tx_nr_rings_per_tc =bnxt_tx_nr_rings_per_tc (bp); +bnxt_adj_tx_rings (bp); }if (BNXT_CHIP_TYPE_NITRO_A0 (bp)) { bp->rx_nr_rings++;
@@ -16631,7 +16636,7 @@ static int bnxt_init_dflt_ring_mode(struct bnxt *bp)if (rc) goto init_dflt_ring_err; - bp->tx_nr_rings_per_tc =bnxt_tx_nr_rings_per_tc (bp); +bnxt_adj_tx_rings (bp);bnxt_set_dflt_rfs (bp);
Signature · 1 line
2.51.0
Michael Chan
maintainerPATCH v2 3/3 bnxt_en: Restore default stat ctxs for ULP when resource is available
In reply to Michael ChanFrom: Pavan Chebbi <[email protected]>
During resource reservation, if the L2 driver does not have enough MSIX vectors to provide to the RoCE driver, it sets the stat ctxs for ULP also to 0 so that we don't have to reserve it unnecessarily.
However, subsequently the user may reduce L2 rings thereby freeing up some resources that the L2 driver can now earmark for RoCE. In this case, the driver should restore the default ULP stat ctxs to make sure that all RoCE resources are ready for use.
The RoCE driver may fail to initialize in this scenario without this fix.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 -0
@@ -8045,6 +8045,8 @@ static int __bnxt_reserve_rings(struct bnxt *bp) ulp_msix =bnxt_get_avail_msix (bp, bp->ulp_num_msix_want);if (!ulp_msix)bnxt_set_ulp_stat_ctxs (bp,0 ); +else +bnxt_set_dflt_ulp_stat_ctxs (bp);if (ulp_msix > bp->ulp_num_msix_want) ulp_msix = bp->ulp_num_msix_want;
Signature · 1 line
2.51.0
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 30 Mar 2026 23:51:35 -0700 you wrote:
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.
v2: Fix Fixes tag commit ID for patch #2
v1: https://lore.kernel.org/netdev/[email protected]/
[...]
Here is the summary with links:
- [net,v2,1/3] bnxt_en: Refactor some basic ring setup and adjustment logic
https://git.kernel.org/netdev/net/c/ceee35e5674a - [net,v2,2/3] bnxt_en: Don't assume XDP is never enabled in bnxt_init_dflt_ring_mode() https://git.kernel.org/netdev/net/c/e4bf81dcad0a - [net,v2,3/3] bnxt_en: Restore default stat ctxs for ULP when resource is available https://git.kernel.org/netdev/net/c/071dbfa304e8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html