Article View: linux.kernel.netdev
Article #21470Re: [PATCH net-next v5 8/9] bnxt_en: Fix ring accounting/validation when rings are constrained by FW
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 02:10
Date: Tue, 24 Nov 2026 02:10
183 lines
14658 bytes
14658 bytes
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
Technical Details
Message-ID:
<179548625149.3135.12297193407408194867@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369954-linux-kernel-netdev=dewy.ruReferences:
<20261120012921.2537903-9-michael.chan@broadcom.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369954-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179548625149.3135.12297193407408194867@kernel.org> References: <20261120012921.2537903-9-michael.chan@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4031992"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:N1J6G8e/gRkmlJlgtPLzdhfObdo= sha256:EA1jjkx+SwuIIx7J5SsOtlOvMVEdaG8gb4qupCZNHlY= sha1:BmstYXwc4hwY/93Cc7K91WENAzs= sha256:0Mz/z51/7nc7rvMtpHICUULBrM+5xCOzLoQTskQJ1xY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id C5025125DC8; Tue, 24 Nov 2026 05:11:09 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kfFBQcagCXwU; Tue, 24 Nov 2026 05:11:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369954-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id CB547125DCB; Tue, 24 Nov 2026 05:10:57 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A949730C1D; Tue, 24 Nov 2026 02:10:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795486253; b=boOmLANp6v6gP56frCv38evA78vU0rRt2wYpaphPPvLtSFK9B3gprnpqA4tkteWzKFY2 d3QPkEty8aCwnLdtDrU2w7EeMuKDDaWhuPGxu0gu4GQDYFzI3B9MqiAq8e10M43P52wR4 fs7c29NZfLSruDS4z1LyWzk4hosTcCvXCRzse27XDz8hr8N+cD6hrTSdJwH02TV61o2WF 5aoBmegLqxAlPyfXKGVAdcJPssQefaOVOP40aINQnYmU2d7T3lpsmToTgAStpXJshyqrc imummYSIqMjCHLhcpiJmhv8DccmDYXoc2E9eAF8GBwaDX0WntLKH0Le6wjyezV5PAcw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795486253; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=q0h9ni7A5RKmJm8FNJQlgZpObVDobPInKxVYVgkJ24I=; b=k7GDwp/g8k3vOjxqlxPVlRRon/JoDhSJyOKnAYnLeF18lBib9hzkE6lsVJT7MhYYQOSD DQOc1Y0vXf8kjlfa0UvojW8MO7hf9KL3YkxAgKiEFZairIoyS1siqDZvYToqvmoPOIOoi ZJySNjjBoDlxppm3onljIvXg/iYP22f0JD4qfKxvnHrcHl3LqPOKTqJwnOMv+Oox4q9Yb N4Q0gSJkjY4eRq8ngF+nQBlQaHhHjlaKTpQcrUHirMlYi/1jbA+VEMv7SDjtd5c/jFFEJ Zv2qLG+27hlkeUNOSwpW/gLSmo/9qd9A6kD8QQkgksQ1pX1DuVikiRkbzIFYwpAxavw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=niGXzJXs; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B088606A31E; Tue, 24 Nov 2026 02:10:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=niGXzJXs X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795486252; b=ldWc7jNizfXps289XNNKNHquQvJPKaYnWmxaAvY6ADXMbTukwaR/N9RvbdX8Lq8O74y8 5udSlbN/kY/FtHS+82P1LkYWag/cWwGPF6HEHQeVcek83oE2XzNMPPVddk7Sero0K7Xhe bzzTMoymBp7lEu/Ggh/PoE9FhRcUJcd75RxDNRt2p30d0EjtxCTqt8u7qKMB4GxIbYoWu PM+P/+qCyWO+LFKUg15MvNLSoslYdaW8QaeWj2uVSSlAmMze+JlBMHwKse74u8KFkXDB2 F02+lEKwMgbR00OxPy2BVAV2uPhZIwFh4UXePNWdoHsGXttlCGAUiHtK/aQ6yhUHatw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795486252; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=q0h9ni7A5RKmJm8FNJQlgZpObVDobPInKxVYVgkJ24I=; b=y1kPMCuVSSXmsIdTqd14GL/cYtUQvaHtyhgoy4npOV/Pho9eDx1Wu6Rt1Ks0zNUN0KI+ a4j13Gx9NWSNVSEJ2NQJVfhHPcUnm2tSXUAY5kXJnY074bA48hKI15V14DfsWyCoaNSR3 Iu1mNwD+MsL/gIpFzRmgyp3+M/4iQzkEJhNuXYJjU2wHNKYw1kvk3VgWJff4gNLOPvs7F trPRmCwIhm+LiCGM7p2SuJkLKr56EGfUsMb0BjOlS8/n4phWSaHAEs961L8LMXAA0410s jXPWe54t+3jAlSian3trfe7+pGstD1tD1P5JUgv170PmzvE1G/7MG1eZgA/XRlLagdg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=niGXzJXs; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9866F606A32D for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 02:10:52 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7A541F000C4; Tue, 24 Nov 2026 02:10:51 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795486252; bh=q0h9ni7A5RKmJm8FNJQlgZpObVDobPInKxVYVgkJ24I=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=niGXzJXsbSy1xrnPrH+NS2XeLv6As75PcoXQytafE/nDsnOYB633yFiQxZD534FPD p+ybT2RXuys9FCukyRB5iE+iWzT+ChFVWh413YERSeMgmHq/YCGr9cCjIRylcFV2+J CB807z7E1aE4kPpHumCgnUKTRH8z0Fftdz+13ioAS5UAnX7PtYF2GBr55DwIVBQ/M7 rtdYQxZTAn3wirkd6i0pU7O879E6qcIwKULTBiNu7+E+rKNuvjfr/LbNTCR2/gDFxW cDMnqIx6ZHDljo7cXR1xzX2pKpu0HIxcUj0s2Qkb7lGX3tIP0RsULw5IqKUeKsjmnw YFq0UvZPs9dzA== X-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 X-In-Reply-To: <20261120012921.2537903-9-michael.chan@broadcom.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list