🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27409

Re: [PATCH net-next v12 09/10] bnge: add aRFS flow steering ndo support

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

Critical: 0 · High: 0 · Medium: 2 · Low: 2

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] Installed aRFS rules are not revalidated when the L2 filter
  they were programmed against is recreated or deleted while the…
- [Medium] In the expire loop of bnge_cfg_ntp_filters(), the return value
  of bnge_hwrm_cfa_ntuple_filter_free() is ignored and…
- [Low] bnge_cfg_one_usr_fltr() now writes ntp_fltr->l2_key and
  l2_filter_id under ntp_fltr_lock.
- [Low] The comment on bnge_net::ntp_fltr_lock still says it "Protects
  the aRFS/ntuple hash table add and delete".

--

bnge: add aRFS flow steering ndo support

This adds bnge_rx_flow_steer() as the ndo_rx_flow_steer callback. It
creates aRFS ntuple filters, and bnge_cfg_ntp_filters(), run from sp_task,
programs, retargets and expires them. The ntuple rule matching now
compares the L2 filter key instead of the firmware L2 filter id.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
> index 639c36d571f24..b7261018216bc 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_filter.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_filter.c

[ ... ]

> @@ -643,7 +658,11 @@ static void bnge_cfg_one_usr_fltr(struct bnge_net *bn,
>  	if (fltr->type == BNGE_FLTR_TYPE_NTUPLE) {
>  		ntp_fltr = container_of(fltr, struct bnge_ntuple_filter, base);
>  		l2_fltr = bn->vnic_info[BNGE_VNIC_DEFAULT].l2_filters[0];
> +		/* bnge_rx_flow_steer() can already run and match this rule */
> +		spin_lock_bh(&bn->ntp_fltr_lock);
>  		ntp_fltr->l2_filter_id = l2_fltr->base.filter_id;
> +		ntp_fltr->l2_key = l2_fltr->l2_key;
> +		spin_unlock_bh(&bn->ntp_fltr_lock);

[Severity: Low]
Does ntp_fltr_lock order this write against bnge_rx_flow_steer()?

The first match in bnge_rx_flow_steer() runs under rcu_read_lock() only:

bnge_rx_flow_steer()
  rcu_read_lock()
  bnge_lookup_ntp_filter_from_idx()
    bnge_fltr_match()
      ether_addr_equal(f1->l2_key.dst_mac_addr,
                       f2->l2_key.dst_mac_addr) &&
      f1->l2_key.vlan == f2->l2_key.vlan;

Those are plain loads done without ntp_fltr_lock. The lock therefore only
orders this write against the second match in bnge_insert_ntp_filter().

bnge_open_core() sets BNGE_STATE_OPEN and enables NAPI and interrupts
before it calls bnge_cfg_usr_fltrs(). RX and aRFS can run while this
struct copy updates a rule that is already in ntp_fltr_hash_tbl.

If a torn read causes a false miss, bnge_insert_ntp_filter() catches it
with -EEXIST. A false match returns the user rule's sw_id, and no aRFS
rule gets installed for that flow.

The impact looks small. Should the comment be corrected and the lockless
accesses annotated?

[ ... ]

> @@ -716,3 +735,105 @@ void bnge_clear_usr_fltrs(struct bnge_net *bn)
>  		}
>  	}
>  }
> +
> +void bnge_cfg_ntp_filters(struct bnge_net *bn)
> +{

[ ... ]

> +	list_for_each_entry_safe(fltr, tmp, &install_list, base.list_node) {
> +		list_del_init(&fltr->base.list_node);
> +		/* The firmware id of the L2 filter changes whenever the filter
> +		 * is recreated, so look it up again from the key before
> +		 * programming the rule.
> +		 */
> +		l2_id = bnge_lookup_l2_filter_from_key(bn, &fltr->l2_key);

[Severity: Medium]
The L2 id is looked up again only here, for rules on install_list. What
happens to rules that are already BNGE_FLTR_VALID when their L2 filter is
recreated or deleted while the interface is up?

In the non-dev_addr branch of bnge_rx_flow_steer(),
bnge_lookup_l2_filter_from_key() can return a secondary unicast filter
(vnic->l2_filters[1..]) or a vlan 0 user ETHER_FLOW L2 filter.

On a unicast list change, bnge_set_rx_mode()->bnge_cfg_rx_mode() frees
all of them in firmware and recreates them with new ids:

bnge_cfg_rx_mode() {
    ...
	for (i = 1; i < vnic->uc_filter_count; i++) {
		struct bnge_l2_filter *fltr = vnic->l2_filters[i];

		if (!fltr)
			continue;
		bnge_hwrm_l2_filter_free(bd, fltr);
		bnge_del_l2_filter_rcu(bn, fltr);
	}
    ...
}

bnge_srxclsrldel() does the same to a user L2 filter, through
bnge_hwrm_l2_filter_free() and bnge_del_usr_l2_filter().

Neither path touches the ntuple rules that depend on those filters. A
BNGE_FLTR_VALID aRFS rule keeps a firmware entry built on the freed L2
context until the flow expires or moves to another queue.

Depending on the firmware, that entry either keeps steering with a stale
context, or it is removed silently. In the second case, later
bnge_hwrm_cfa_ntuple_filter_free() calls fail, and the driver state no
longer matches the hardware.

The new comment on struct bnge_ntuple_filter also says l2_filter_id "is
reassigned by firmware on every open". The commit message says the id also
changes "after a unicast address list change".

Should installed rules be revalidated when this happens, or should the
comment at least describe the limitation?

For reference, bnxt_cfg_rx_mode() also frees the firmware L2 filter while
ntuple rules hold a refcount on it. That refcount only keeps the software
struct alive, so the real effect depends on how the firmware treats ntuple
entries whose L2 context is freed.

[ ... ]

> +		hlist_del_init_rcu(&fltr->base.hlist);
> +		spin_unlock_bh(&bn->ntp_fltr_lock);
> +
> +		bnge_hwrm_cfa_ntuple_filter_free(bn->bd, fltr);
> +		bnge_del_ntp_filter_rcu(bn, fltr);

[Severity: Medium]
Can this leak the firmware ntuple entry?

bnge_hwrm_cfa_ntuple_filter_free() can fail in bnge_hwrm_req_init() or
bnge_hwrm_req_send(). On failure it leaves filter_id valid:

	rc = bnge_hwrm_req_send(bd, req);
	if (!rc)
		fltr->base.filter_id = BNGE_FLTR_ID_INVALID;
	return rc;

bnge_del_ntp_filter_rcu() then frees the only copy of base.filter_id and
releases the sw_id. Nothing retries the free.

The firmware entry keeps steering that 5-tuple to the old ring until the
VNIC is torn down at close. A later aRFS rule for the same flow is either
programmed next to it or refused as a duplicate. If it is refused, every
later attempt repeats alloc -> sp_task -> firmware alloc failure ->
delete.

The update loop above checks the return value of the same call. Should
the expire path handle a failed free as well?

> +	}
> +#endif
> +}

[ ... ]

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> index 44637152b075c..de7320521a3e0 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c

[ ... ]

> @@ -3433,6 +3442,146 @@ static int bnge_set_features(struct net_device *dev, netdev_features_t features)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_RFS_ACCEL
> +/* Called with ntp_fltr_lock held. Returns true if sp_task must be queued. */
> +static bool bnge_ntp_fltr_retarget(struct bnge_net *bn,
> +				   struct bnge_ntuple_filter *fltr,
> +				   u16 rxq_index, u32 flow_id)
> +{
> +	if ((fltr->base.flags & BNGE_ACT_NO_AGING) ||
> +	    READ_ONCE(fltr->base.rxq) == rxq_index)
> +		return false;
> +
> +	WRITE_ONCE(fltr->base.rxq, rxq_index);
> +	WRITE_ONCE(fltr->flow_id, flow_id);

[Severity: Low]
This isn't a bug, but the comment on bnge_net::ntp_fltr_lock in
bnge_netdev.h still says:

	/* Protects the aRFS/ntuple hash table add and delete. ...

This patch also uses the lock for per-filter state:

  - rxq and flow_id here
  - the expire re-check and unlink in bnge_cfg_ntp_filters()
  - the hlist_unhashed() check in bnge_rx_flow_steer()
  - the l2_key and l2_filter_id writes in bnge_cfg_one_usr_fltr()

Could the struct comment be updated, so a later change does not write rxq
or flow_id without holding the lock?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201132011.2705569-1-vikas.gupta%40broadcom.com
Technical Details
Message-ID: <179648198178.3146.7542356016116033536@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!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378024-linux-kernel-netdev=dewy.ru
References: <20261201132011.2705569-10-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!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378024-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v12 09/10] bnge: add aRFS flow steering ndo support
Date: Sat, 05 Dec 2026 14:46:21 +0000
Organization: Usenet Network
Message-ID: <179648198178.3146.7542356016116033536@kernel.org>
References: <20261201132011.2705569-10-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="3049375"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mZIgnyZc6J4RDpo5yZdTK++7WSo= sha256:03ly/+DwEAS9cDL8A6btllgDANX2QABqR7j7n0I7B68=
	sha1:uwI4gGHqaG37WVO7Koa3hJAtOvc= sha256:hBYeqqG3DX5KJbUKbtvzrBVuFEQ4SfAmVr8o4MUh7mI=
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 31832117E48; Sat,  5 Dec 2026 17:47:02 +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 fSQSxnsoYDCJ;
	Sat,  5 Dec 2026 17:46:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-378024-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 11FBD117E18; Sat,  5 Dec 2026 17:46:50 +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 D7D63607349; Sat,  5 Dec 2026 14:46:49 +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=1796481989;
	b=acD9+8x4Z8Fk4pB+1Gv63z9qgHYsOiaRn24U4komgKe5oW0nDhf09gf8it7u1QmFGxIY
	 PaPYnltRAvjDFzVxOHfxtCfhxYTT8gqgzwhZBDVgOQ3gJLg4TSRHIoNbhnPjYW4c+ZBPN
	 31TiD0u5YBSAeKAjUpJeq4v8+6nvTAXZxOXxrVhqRiyISS2U5wCoBxInyeVYyWJl9gAf4
	 gNL8Okm7Epe2FTRCFnAKfvhtT7LseSwReq73VUosD/OGew0riq0kBLVX3+6gMUgPjQbJf
	 RpdDitPJKYozFIvnhP4pNiEpIn0G2hE9bJmRbv4vrTHX4WPKN2imEpKs95/a4qdKb8w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796481989;
	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=6NuKmy9GPGqYX+mrEon2icEfI7hk4+4rAMC39UVMF5M=;
	b=IJ/QdmxduYAJp5NkZFxTi/AoeiKaE+vV4zLX5pVa7BTQsJ9AEqGJz+2w0We/g3Y7zEQ9
	 +lHctGpmkIpzqp//GqFwg0EeQ07JDJaJBm7AEk2BO38dIBEgU7DcDfea591lWV2d2QoZi
	 F4SIA11oMahzvwmanDHDdbNidE2Nwv8Z+aIqo8xikhpX+0MNtARWDs7CAg4fq3LHHAwG3
	 V6MjQzU34nTiAOciuJDngi7MsuwXUT1wn8nOMiF1l4UsnjaRyeQXrajn/5v22TtewXtfA
	 DqrekT5HiuoaBpm4yPumQO+rV7DGXAggSLysgjODLbMQN8rVC2Gtw+YH7oK9fwxMKMQ==
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=Q6cRTxlk;
	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 69753606A332;
	Sat,  5 Dec 2026 14:46:29 +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=Q6cRTxlk
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=1796481983;
	b=rVMUrUq5GiLobcUOimyZ45G0Y2gmtvWiuvPCVw27GXikqiAUIqKiITAVvF5XW8mPKGW2
	 +29nTod929KXCQgdn+atZXLX0w6piOjwBkbsAq/YiHZUqkZIHTyhqyzmfP2YY1aMWCtBl
	 drYfImrXMtT+o1GqVITckR0PbdDPrlU+DCbZNlyAwa+9S9/VnevKMLGC022IEipOk+0zU
	 iBxaZuVcSx/Cil3G84SzsmQl4N9tJyHjbXwGzGbz37QwGykjFs4mnxKwUS9mUdLN7WBZH
	 F87zgtruAibh76e6Uk/KvBdgvGtvVKYWBoIgv9VbXZYs8Ubn61/wKfDUvyKvHY+9EGQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796481983;
	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=6NuKmy9GPGqYX+mrEon2icEfI7hk4+4rAMC39UVMF5M=;
	b=w/6NdmenQwuaslK7ToPJ4n5LRpWa6xKBwV6sKdIZ74u1ogCcmSsuwaYeVtAZS75/k4tV
	 uTr6pep9EyjTJk+dyrUwPhQ1ChPzEXhuFupw66kHUKXny3C7tvxOZysVv7cszc+s1bdAO
	 JRzSn/gt2pQf0vJv4F4dEYOyR+9HOwwM5ubmznHk4cMpjT6i+hPfVQFSgoB4tLx/S9YxG
	 elUAMU9xtM1xXTNlADVNh/WRK0fXAgvTdPq3X4jsyKttqsX42Z8o0MhbcwbqBY/moIUbT
	 NiHCMuTBllKkK9WMPRty2PmhAcY9HWrNRJSNsKEALaT3fmh2Rvzi7Tbb78sJt0lvssg==
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=Q6cRTxlk;
	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 8A8F4606A6BB;
	Sat,  5 Dec 2026 14:46:23 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 428891F00A1B;
	Sat,  5 Dec 2026 14:46:22 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796481983;
	bh=6NuKmy9GPGqYX+mrEon2icEfI7hk4+4rAMC39UVMF5M=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Q6cRTxlkJa1yGk/LV3X7jdUqBzM2dOo8mjTi6pik/STRUv8E5OaAn0hHgkj7vgVyG
	 9HdprwkWAYufNk8JMKcFUTrlaQ35NPmGOA6unJ4yklUtemjNXCgwNyP5r3YfSQeYBh
	 1xUvP5qIUTeo0kXmLQHNI1eDcBb53F6BH/cjh5i4Ra6OkUhhKkHMKMCmjggXtZz/ne
	 PXypbJsxjjaU9cTOYyQHFzTxaQhwuJYWNMm9/m5pIzwUA65RHIlE4l4RXhPAe95U5j
	 3hHXfS/QA9vW8E32q2qzZsspEoDMWEckenY4yDawmw+w88XaCzbBq47DWq88yZ3pmw
	 NKoqsqg7QSpWA==
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-10-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