๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27405

Re: [PATCH net-next v12 03/10] bnge: add helper functions for multi RSS contexts

#27405
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 14:46
178 lines
14866 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 4 ยท Low: 0

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).

- [Medium] Baseline decision is FALSE: it is fixed later in the series
  and never reachable at any commit.
- [Medium] Baseline decision is FALSE: the speculative precondition is
  disproven and the code is fixed later.
- [Medium] Baseline decision is FALSE: it is fixed later in the series.
- [Medium] Baseline decision is FALSE: it is fixed later in the series
  and never reachable unlocked.

--

bnge: add helper functions for multi RSS contexts

This commit adds helpers to modify, restore and delete user-defined RSS
contexts. Each context is backed by its own VNIC. It also moves the RSS
table and hash key allocation into a new bnge_alloc_vnic_rss_table()
helper, so the next patch can build the ethtool commands on top of it.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c
> index d98a6196c859c..a44971a7c74d3 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c
> @@ -129,3 +129,116 @@ int bnge_alloc_rfs_vnic(struct bnge_net *bn)
>  	vnic = &bn->vnic_info[BNGE_VNIC_NTUPLE];
>  	return bnge_alloc_and_setup_vnic(bn, vnic, bn->bd->rx_nr_rings);
>  }
> +
> +void bnge_modify_rss(struct bnge_net *bn, struct ethtool_rxfh_context *ctx,
> +		     struct bnge_rss_ctx *rss_ctx,
> +		     const struct ethtool_rxfh_param *rxfh)
> +{

[ ... ]

> +	if (rxfh->indir) {
> +		u32 i, pad, tbl_size = bnge_get_rxfh_indir_size(bd);
> +		u32 *indir_tbl = bd->rss_indir_tbl;
> +
> +		if (rss_ctx)
> +			indir_tbl = ethtool_rxfh_context_indir(ctx);

[Severity: Medium]
Where does the hardware pick up this per-context table? At this commit,
bnge_fill_hw_rss_tbl() only handles the ntuple VNIC and the global table:

    if (vnic->flags & BNGE_VNIC_NTUPLE_FLAG)
        j = ethtool_rxfh_indir_default(i, bd->rx_nr_rings);
    else
        j = bd->rss_indir_tbl[i];

A context VNIC programmed through this path would get the default table,
not the one written here:

    bnge_setup_vnic()->bnge_hwrm_vnic_rss_cfg()->bnge_fill_hw_rss_tbl()

None of the new helpers has a caller yet. The follow-up patch "bnge: add
ethtool support to manage RSS contexts" adds BNGE_VNIC_RSSCTX_FLAG, a
vnic->rss_ctx back-pointer and the matching branch in
bnge_fill_hw_rss_tbl(). So this does not look reachable at any commit in
the series.

Could that branch be added together with this helper?

> +		for (i = 0; i < tbl_size; i++)
> +			indir_tbl[i] = rxfh->indir[i];
> +		pad = bd->rss_indir_tbl_entries - tbl_size;
> +		if (pad)
> +			memset(&indir_tbl[i], 0, pad * sizeof(*indir_tbl));

[Severity: Medium]
When rss_ctx is non-NULL, can this memset() write past the end of the
context's indirection table?

pad comes from bd->rss_indir_tbl_entries, which is the size of the
device-global table. ethtool_rxfh_context_indir(ctx) points into the
buffer that ethtool_rxfh_ctx_alloc() sized as max(indir_size,
ops->rxfh_indir_space).

In the series this is covered. "bnge: add RXFH ethtool support" sets
.rxfh_indir_space = BNGE_MAX_RSS_TABLE_ENTRIES and .rxfh_priv_size, and
its only caller passes rss_ctx == NULL. "bnge: add ethtool support to
manage RSS contexts" then changes the check to "if (pad && !rss_ctx)".

Should the !rss_ctx check be part of this helper from the start?

> +	}
> +}
> +
> +void bnge_del_one_rss_ctx(struct bnge_net *bn, struct bnge_rss_ctx *rss_ctx,
> +			  bool all)
> +{
> +	struct bnge_vnic_info *vnic = &rss_ctx->vnic;
> +	int i;
> +
> +	bnge_hwrm_vnic_free_one(bn->bd, &rss_ctx->vnic);
> +	for (i = 0; i < BNGE_MAX_CTX_PER_VNIC; i++) {
> +		if (vnic->fw_rss_cos_lb_ctx[i] != INVALID_HW_RING_ID)
> +			bnge_hwrm_vnic_ctx_free_one(bn->bd, vnic, i);
> +	}

[Severity: Medium]
What sets the INVALID_HW_RING_ID sentinels for a context VNIC? struct
bnge_rss_ctx lives in the zeroed ethtool private area. Nothing in this
patch sets fw_vnic_id or fw_rss_cos_lb_ctx[] to INVALID_HW_RING_ID.
That means this function could send VNIC_FREE and RSS_COS_LB_CTX_FREE
for firmware id 0.

vnic_id is also left at 0, which is BNGE_VNIC_DEFAULT. As a result,
bnge_hwrm_vnic_alloc() called from bnge_hwrm_realloc_rss_ctx_vnic()
would set VNIC_ALLOC_REQ_FLAGS_DEFAULT for a context VNIC.

Nothing calls these helpers yet, and the problem is fixed later in the
series. "bnge: add ethtool support to manage RSS contexts" adds
bnge_init_vnic_mem() and sets
vnic->vnic_id = BNGE_BASE_VNICS + rxfh->rss_context before any HWRM call.

Could that initialization be done in this patch instead?

[ ... ]

> +void bnge_hwrm_realloc_rss_ctx_vnic(struct bnge_net *bn)
> +{
> +	u32 tpa_flags = bn->priv_flags & BNGE_NET_EN_TPA;
> +	struct ethtool_rxfh_context *ctx;
> +	unsigned long context;
> +
> +	xa_for_each(&bn->netdev->ethtool->rss_ctx, context, ctx) {
> +		struct bnge_rss_ctx *rss_ctx = ethtool_rxfh_context_priv(ctx);
> +		struct bnge_vnic_info *vnic = &rss_ctx->vnic;
> +
> +		if (bnge_hwrm_vnic_alloc(bn->bd, vnic, bn->bd->rx_nr_rings) ||
> +		    bnge_hwrm_vnic_set_tpa(bn->bd, vnic, tpa_flags) ||
> +		    bnge_setup_vnic(bn, vnic)) {
> +			netdev_err(bn->netdev, "Failed to restore RSS ctx %d\n",
> +				   rss_ctx->index);
> +			bnge_del_one_rss_ctx(bn, rss_ctx, true);
> +			ethtool_rxfh_context_lost(bn->netdev, rss_ctx->index);

[Severity: Medium]
Which lock protects this xarray walk and the erase? On failure,
ethtool_rxfh_context_lost() calls xa_erase() and kfree() on the context.
It also warns unless rtnl or dev->ethtool->rss_lock is held:

    WARN_ONCE(!rtnl_is_locked() &&
              !lockdep_is_held_type(&dev->ethtool->rss_lock, -1),
              "RSS context lock assertion failed\n");

This loop does not take rss_lock. With request_ops_lock, the caller may
not hold rtnl either.

There is no caller at this commit. "bnge: add ethtool support to manage
RSS contexts" wraps the loop in mutex_lock(&bn->netdev->ethtool->rss_lock)
in the same patch that adds the caller in bnge_open_core().

bnge_clear_rss_ctxs() also walks the xarray without rss_lock. That one
looks fine: it does not erase entries, and its only caller,
bnge_close_core(), runs under the netdev instance lock.

Would it make sense to add the rss_lock locking here, where
bnge_hwrm_realloc_rss_ctx_vnic() is introduced?

> +		}
> +	}
> +}

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201132011.2705569-1-vikas.gupta%40broadcom.com
Technical Details
Message-ID: <179648197443.3146.16431511104934574498@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378019-linux-kernel-netdev=dewy.ru
References: <20261201132011.2705569-4-vikas.gupta@broadcom.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378019-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v12 03/10] bnge: add helper functions for multi RSS contexts
Date: Sat, 05 Dec 2026 14:46:14 +0000
Organization: Usenet Network
Message-ID: <179648197443.3146.16431511104934574498@kernel.org>
References: <20261201132011.2705569-4-vikas.gupta@broadcom.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3049121"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cuKQ9b27tp7csQ8h+kxRzWF6iaM= sha256:hlEGAzWJJOg7W7GPPpUFureoODGg9b5RYGUNn40Vm5w= sha1:W9Xpj9JW91QQr/a6NUp2su+g3Z4= sha256:ZwsdXFMhBtJ7RNC9C+1lY0vX88OAdtfmzQqIp10uUaQ=
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 AF721117E40; Sat,  5 Dec 2026 17:46:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.14, 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 wOWB0NYsx06g; Sat,  5 Dec 2026 17:46:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-378019-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 6B7FA117E3F; Sat,  5 Dec 2026 17:46:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 388B6607475; Sat,  5 Dec 2026 14:46:29 +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=1796481982; b=kl4+c5NfZeoXKP0Q7wY6qXCTG5UdMVNfj0D8npB6M7c32CylzhisNnN3CL2dWjtfUrmY yyoeYvhTkSZiT8z+z9vKnk5UI0i5qefoVT3k6HaM1CVaZsygWq9BxQ1Evwt+HVpEOxi2Z GMpKsV2yKYmub8sh7QeSGVByiPpV234WQ7GPf2oWnTkuzYhFv1NE1xB+6OmAPRzLKpYQO NKABEYt/Zg+nLB2Hd3g9JwnJ01SjgtEZhd/8oLmoKKyE1xhYh74UDgDdEEb+8ndiozbA+ 0kyExg1zzZ5GRbvRer4oyiTxiUsiFn0w7nFCLjY2S493tnavfxJErUo8EaPLUKuJ/uw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796481982; 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=4Ul2ZzKhc0XS8SY7m20H1PkHNlR3pQl7KcVaYpZrHAQ=; b=kZR5KBQrW6teVZFvkJZikVu66NpfddgQcmr2ar8wMkJKHHvvd2w1bdz3SkAm2lYsv3fG 0VgIwjxB2qL/mj/zj0IcNFALflKPX/LJGggSw0bZW0Ssp1P4OiMecBGt2Og/w4XtsAxtq CFp7vAxtu+y6CHo2Tfa/kcI1+QmT1FlGHIO696PvGmmRNlNvQHY/ILV9PhGPm+hJXRkfi Rbob4c5+tahojwXS6EAHQt4hhyx+hC8NXqqfYCdOE2dC/PagNJId0/c5ruIfrwYC+i2/y tfzZrSk35rmIV+Smc+9znNxjqM6kZKWPS4LQvCj1RtZTJaoP7aFQwTqX4zaaL4YSiVg==
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=P3t18mUK; 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 18022606A6AF; Sat,  5 Dec 2026 14:46:22 +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=P3t18mUK
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=1796481976; b=lTjB6kwNDJjW6/C0cIH8r+2zAWYCeB3PtUkFBGZX1rayXn27zUmB144brkiQ6EHRCOoL o6Q/1SGo9rlyjnjUx0QcQRGaccfyx5Smxicf3hAN8t7hgYwJ9lVif6t1ep9Q7xiNSHgt9 9aG9nxkFBfcn+zB1rmZQGU+sPSdBs3J8tjxDg9t1a8A5d2AtLqk8PHR0llCj1S1JZdsIy 6A8rOwYCiYh7oTMrKtrfb1mP/kxt6RXlGthUGWr3kN2z55YSdgwcbw9n3Zs8+VOFE3bvs PBx5gNsZRpZ/RI3Y0V7xDgjFsheaWbzoI9YrMELPsTtxTMEYs32dFD1g7nmabzG89TA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796481976; 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=4Ul2ZzKhc0XS8SY7m20H1PkHNlR3pQl7KcVaYpZrHAQ=; b=WmKxvRSTtygDbEZH1AJS/GXGw5s+1+zK2bK/7KB3y1qerwn53F9cBmDFzBNcVYDu7NSj J878fedZQm9Fsl3NQrE9t6V6qMnthRjfs+WQ1EaTjiXgG49GTxZR8cg+0WMEna/sd1xWT DsRd9hxvb8Mo7Ezm75m6OTriB75zANkVc7Mdtx7JAvLdZesoKJDYZkVWuk+IVzdemCAn3 pfH1edt1JXWIWQAwFoIYKcikcJ/yRyUcpqZa8TV+vLPRbnGWeEkKuBdJncvLs260pCHlI a4jiHoTj+rfN18WfQ00zkXhD3lQ1pTKxoLCVsunYwhSc3ad2CO0dRH+8cmd+aUpgR/Q==
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=P3t18mUK; 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 346F9606A322; Sat,  5 Dec 2026 14:46:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E99FD1F0092B; Sat,  5 Dec 2026 14:46:14 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796481975; bh=4Ul2ZzKhc0XS8SY7m20H1PkHNlR3pQl7KcVaYpZrHAQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=P3t18mUKzqTHbgGiIdsitiNlwbOABrQTlR4MldWpAg8EVia3K80ja87pSEGG3aI54 EK/bUqKovxgLGy3eaM0/jo5gzm+Zz8SklIKa/1/NRFl1636tot/GDUbcSAmifM5fKM XpRE4k7hgkegjf/RUC+CBNjqzTfTVxjNcWFveVGyImdCvSDcY427ID0XvjbOWzDrRj 3e6+o/iceXr9Fccn9HRsBYUmLk8PfHfec8MN9i8XvR1WwUSwtRCH7kPrtS1XTTkIOh 5PifMYqMYn65+Yo6OCRhkE8VY5svnH33uELOwNBq2BqKzQBf2JF/mNPuswUj/F9s5F kw5/LRmNAa4CA==
X-Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bhargava.marreddy@broadcom.com, rahul-rg.gupta@broadcom.com, vsrama-krishna.nemani@broadcom.com, rajashekar.hudumula@broadcom.com, dharmender.garg@broadcom.com, ajit.khaparde@broadcom.com
X-In-Reply-To: <20261201132011.2705569-4-vikas.gupta@broadcom.com>
X-sashiko-severity: Medium
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