From: netdev-bot+sashiko@kernel.org
To: michael.chan@broadcom.com
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com
Subject: Re: [PATCH net-next v5 8/9] bnxt_en: Fix ring accounting/validation when rings are constrained by FW
Date: Tue, 24 Nov 2026 02:10:51 +0000 [thread overview]
Message-ID: <179548625149.3135.12297193407408194867@kernel.org> (raw)
In-Reply-To: <20261120012921.2537903-9-michael.chan@broadcom.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] This patch adds a new way for bp->rx_nr_rings to shrink, but
only the default RSS table is reconciled afterwards.
- [Low] __bnxt_reserve_rings() calls bnxt_adj_rings() after the firmware
reservation has already been committed and copied into bp->hw_resc by…
--
bnxt_en: Fix ring accounting/validation when rings are constrained by FW
This patch renames bnxt_adj_tx_rings() to bnxt_adj_rings() and reworks it
to scale TX, RX and CP rings evenly across TCs and XDP. In shared/combined
mode it now also clamps RX to match TX. It tightens bnxt_rings_ok() and
the tx/cp conversion helpers, and changes __bnxt_reserve_rings() to
validate before committing ring counts and to bail out through a common
exit label.
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index d76227d292824..565099088969e 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
[ ... ]
> @@ -8178,49 +8205,67 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
> hwr.stat -= bnxt_get_ulp_stat_ctxs(bp);
> hwr.cp = min_t(int, hwr.cp, hwr.stat);
> rc = bnxt_trim_rings(bp, &rx_rings, &hwr.tx, hwr.cp, sh);
> + if (rc)
> + goto reserve_rings_exit;
> +
[ ... ]
> + if (!bnxt_rings_ok(bp, &hwr)) {
> + rc = -ENOMEM;
> + goto reserve_rings_exit;
> }
> bp->tx_nr_rings = hwr.tx;
> + bp->rx_nr_rings = rx_rings;
> + bp->cp_nr_rings = hwr.cp;
>
> + if (!bp->bnapi)
> + bnxt_adj_rings(bp);
[Severity: Low]
By this point, bnxt_hwrm_reserve_rings() has already committed the
reservation in FW, and bnxt_copy_reserved_rings() has recorded it in
bp->hw_resc. bnxt_adj_rings() can then lower the counts below what FW
granted:
bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs;
This drops the remainder of the division. In shared mode, rx_nr_rings is
also clamped to tx_nr_rings_per_tc, and cp_nr_rings is then recomputed
lower.
On the open path, __bnxt_open_nic()->bnxt_reserve_rings()->
__bnxt_reserve_rings(), does anything issue another FUNC_CFG to give the
surplus back? bnxt_set_dflt_rings() has a second pass for this:
/* Rings may have been trimmed, re-reserve the trimmed rings. */
if (bnxt_need_reserve_rings(bp)) {
The open path doesn't seem to have an equivalent step.
Would the extra TX/RX rings, ring groups, completion rings, stat contexts
and IRQs stay reserved in FW until something re-reserves later? In that
window, hw_resc->resv_* would not match bp->*_nr_rings either. Also,
bnxt_sriov.c works out VF resources from the driver counts, for example:
vf_tx_rings = hw_resc->max_tx_rings - bp->tx_nr_rings;
The commit message says leftover rings are "intentionally left unused".
Here they also appear to stay reserved in FW, where VFs or other NPAR
functions cannot use them.
Before this patch, a TX grant not divisible by the TC count hit this
check in bnxt_reserve_rings() instead:
if (tcs && (bp->tx_nr_rings_per_tc * tcs !=
bp->tx_nr_rings - bp->tx_nr_rings_xdp)) {
netdev_err(bp->dev, "tx ring reservation failure\n");
The last patch in the series doesn't add a re-reservation either.
[ ... ]
> @@ -13156,13 +13214,29 @@ static void bnxt_set_xdp_tx_rings(struct bnxt *bp)
> bp->tx_nr_rings += bp->tx_nr_rings_xdp;
> }
>
> -static void bnxt_adj_tx_rings(struct bnxt *bp)
> +static void bnxt_adj_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);
> + int tcs = bp->num_tc ? bp->num_tc : 1;
> + int rx = bp->rx_nr_rings;
> +
> + /* Make adjustments to rings based on TC/XDP/shared rings policies */
> + if (bp->tx_nr_rings_xdp) {
> + tcs++;
> + bp->tx_nr_rings_per_tc = bp->tx_nr_rings / tcs;
> + bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc;
> + } else {
> + bp->tx_nr_rings_per_tc = bnxt_tx_nr_rings_per_tc(bp);
> + }
> +
> + if (bp->flags & BNXT_FLAG_SHARED_RINGS) {
> + bp->tx_nr_rings_per_tc = min(bp->tx_nr_rings_per_tc, rx);
> + bp->rx_nr_rings = bp->tx_nr_rings_per_tc;
> + if (bp->tx_nr_rings_xdp)
> + bp->tx_nr_rings_xdp = bp->tx_nr_rings_per_tc;
> + }
[Severity: High]
In shared rings mode, this clamp now lowers rx_nr_rings whenever FW
grants fewer TX rings, with or without XDP. bnxt_adj_tx_rings() never
changed rx_nr_rings.
After the shrink, __bnxt_reserve_rings() only reconciles the default
context, through bnxt_check_rss_tbl_lost() and
bnxt_set_dflt_rss_indir_tbl(bp, NULL). Can a user-created RSS context
still point at a ring index at or above the new rx_nr_rings?
Later in __bnxt_open_nic():
if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))
bnxt_hwrm_realloc_rss_ctx_vnic(bp);
bnxt_cfg_usr_fltrs(bp);
bnxt_hwrm_realloc_rss_ctx_vnic()->bnxt_hwrm_vnic_set_rss_p5()->
bnxt_fill_hw_rss_tbl_p5() does:
else if (vnic->flags & BNXT_VNIC_RSSCTX_FLAG)
j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i];
...
rxr = &bp->rx_ring[j];
bp->rx_ring is allocated from the new, smaller rx_nr_rings. Would a stale
j read past the end of bp->rx_ring[]? bnxt_cp_ring_for_rx() would then
dereference rxr->rx_cpr from adjacent memory.
Something similar seems possible in bnxt_cfg_usr_fltrs(). On firmware
without BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2,
bnxt_hwrm_cfa_ntuple_filter_alloc() uses a possibly stale queue index:
vnic = &bp->vnic_info[fltr->base.rxq + 1];
The commit message says the non-default RSS context and n-tuple problem
already exists and is deferred. The RX clamp driven by a TX shortage is
new in this patch, though. It makes the problem reachable in setups where
RX used to stay the same, for example an irq_re_init open after a
firmware reset or an XDP attach, where FW grants fewer TX rings than
requested.
The last patch in the series ("bnxt_en: Fix ring accounting/validation
when IRQs are constrained") also leaves this deferred.
> +
> + bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs;
> + bnxt_set_cp_rings(bp, bp->flags & BNXT_FLAG_SHARED_RINGS);
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120012921.2537903-1-michael.chan%40broadcom.com
next prev parent reply other threads:[~2026-11-24 2:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 1:29 [PATCH net-next v5 0/9] bnxt_en: Ring accounting fixes Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 1/9] bnxt_en: Clear bp->total_irqs when disabling IRQs Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko
2026-11-20 1:29 ` [PATCH net-next v5 2/9] bnxt_en: Fix bnxt_reinit_features() when irq_re_init is true Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 3/9] bnxt_en: Refactor RSS table check logic Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 4/9] bnxt_en: Refactor IRQs required logic Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 5/9] bnxt_en: Reinit IRQ when configuring LRO/GRO/HDS Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko
2026-11-20 1:29 ` [PATCH net-next v5 6/9] bnxt_en: Remove support for the old NITRO A0 chip Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 7/9] bnxt_en: Refactor bnxt_num_cp_to_tx()/bnxt_num_tx_to_cp() helpers Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 8/9] bnxt_en: Fix ring accounting/validation when rings are constrained by FW Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko [this message]
2026-11-20 1:29 ` [PATCH net-next v5 9/9] bnxt_en: Fix ring accounting/validation when IRQs are constrained Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179548625149.3135.12297193407408194867@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox