From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795956410; b=Fgx59J4XKC2BkvPn6jUqMgLQU4tyPo/vaXse92mmVj+7vPSqwiaoe9D5+OUPas4Lkpno Y9ksO4wHtyJBNr5gEyD8N8WIDw7fHDDE0fJvfmOaVENzYl/cN7IhpHWxmXI1apvL6UFCL 6IKXDMyiWAGdJPUDzc/8A+XZnRSVZnJed1vfbSwo9taX+FMIEYp7AB95Jrw5miPufIgAu Bj10lhrCMP3Fuw2qiaCwBi6PRLw7TKidRJIfxZphHCw2tL2SS0ia7sNmNn2tsoA1G3jxD SlY3uX21MNtEteoVGGEyodPe3EEfXFaERwVWfo3ZrS/BRcB8OZQiGkSt8gMTXBrXAOw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795956410; 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=5Y3m1HJxfbuBSm3wrRMHAsK0xETb+vwL4kMBZCk/hf8=; b=5SZHwd1WdL/fbTRONeCaUaQdCrEg2f5+wVvW8vJ7e3Fcq8KyqKubzlT7JS+Z9t2JU4Cg LxXQJl5toLm5FeuQF0Yra3nwN+qsN6CyfvwR6kt6QuheNEcZdyeYMj2BDdahWIi8vtN7L s5sXDTaRIORX4R/uUEfmNiUyk8dNRABm5VFLDtNFpzw8occan4SkwHSgRcxBgEalJxMLN A/V9ZKtwaNVzc14Dl591yENENB34enKpT6i8/UF7Oqa1tx5FzOq2y6JnkPbFLIUXeGDO8 4fgEj6QYrAbbiPM9qNgl1oyPbFmAmaWFnyJ09QDYRtmvj1AdZz/O+3h+tnvqcB+RLAw== 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="UUGDCZ/3"; arc=none smtp.remote-ip=100.103.45.18 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 E51A5606A323; Sun, 29 Nov 2026 12:46:49 +0000 (UTC) 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=UUGDCZ/3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C42831F0089A; Sun, 29 Nov 2026 12:46:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795956409; bh=5Y3m1HJxfbuBSm3wrRMHAsK0xETb+vwL4kMBZCk/hf8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=UUGDCZ/3tOTEIdc5NkOp/03V6wT+2F6BmSOdfetZQtIQLF+6/oM6MMqqH2fj7/oUd 6/g3+eQBF/MxVizRTZ1M9bZAIXWkBRL4wBmJ58AMt+j5dxigBL+BhjiR9xWQsmnF0M D/gtz/EaCfB+Zh8OwO6CD7kmPjhFqN9cNQGg6c0zL4cfH/OgcDCjc4oT/+bCYJyRMO lN7LLj5hyMyxRHtpSuvRzgjex1nG2RY+eGbHJ3LB7QlYTGeGSh4yziBsLbROJXjWoB NsS0uWKDSe0OX96GSvCLq7eSYQ/zL35WfISTWZH9m4JcRizacVe52PB71mzqgLV98L 85D/RnXC+f14w== Subject: Re: [PATCH net-next v10 09/10] bnge: add aRFS flow steering ndo support From: netdev-bot+sashiko@kernel.org To: vikas.gupta@broadcom.com 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 Date: Sun, 29 Nov 2026 12:46:48 +0000 Message-ID: <179595640835.3146.6072756088467989236@kernel.org> In-Reply-To: <20261125115434.2080590-10-vikas.gupta@broadcom.com> References: <20261125115434.2080590-10-vikas.gupta@broadcom.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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] The commit message says the key-based L2 binding copes with the L2 filter's firmware id changing "after a unicast address list… - [Medium] In the expire_list loop of bnge_cfg_ntp_filters(), the return value of bnge_hwrm_cfa_ntuple_filter_free() is ignored before… - [Low] The patch adds a mechanism that the commit message never mentions. - [Low] In bnge_cfg_one_usr_fltr() the patch takes ntp_fltr_lock around the writes to ntp_fltr->l2_filter_id and ntp_fltr->l2_key, with the… -- bnge: add aRFS flow steering ndo support This adds bnge_rx_flow_steer() as the ndo_rx_flow_steer callback. It creates NTUPLE filters for aRFS, and sp_task programs them in firmware later through bnge_cfg_ntp_filters(). aRFS and user ntuple rules now record their L2 filter by key (MAC and VLAN), and the L2 firmware id is looked up again before an aRFS rule is programmed. > 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 [ ... ] > @@ -497,12 +507,17 @@ static bool bnge_fltr_match(struct bnge_ntuple_filter *f1, > return false; > } > > + /* Compare the L2 filter by key, not by firmware id: the id changes on > + * every open, the key does not. > + */ > return keys1->ports.src == keys2->ports.src && > masks1->ports.src == masks2->ports.src && > keys1->ports.dst == keys2->ports.dst && > masks1->ports.dst == masks2->ports.dst && > keys1->control.flags == keys2->control.flags && > - f1->l2_filter_id == f2->l2_filter_id; > + ether_addr_equal(f1->l2_key.dst_mac_addr, > + f2->l2_key.dst_mac_addr) && > + f1->l2_key.vlan == f2->l2_key.vlan; > } [Severity: Medium] Does matching by key leave installed aRFS rules bound to a stale L2 filter after a unicast address list change? The commit message says the key-based binding handles the L2 firmware id changing "after a unicast address list change". While the interface is up, bnge_cfg_rx_mode() with uc_update frees and recreates every secondary L2 filter: 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); } ... } The recreated filters get new firmware ids. However, bnge_cfg_ntp_filters() calls bnge_lookup_l2_filter_from_key() only for install_list entries, which are rules that are not VALID or were retargeted. An installed VALID aRFS rule bound to a secondary MAC keeps its old l2_filter_id. Its firmware rule still points at the freed L2 filter. The driver cannot see how firmware handles such a rule. Because of the key comparison here, a later bnge_rx_flow_steer() call for the same flow matches that stale rule. If rxq has not changed, bnge_ntp_fltr_retarget() returns false and the old sw_id is returned. No rule is ever programmed against the new L2 filter, and rps_may_expire_flow() keeps the stale entry while the flow stays active. With the old l2_filter_id comparison the request would not have matched. A new rule bound to the new L2 id would have been created instead. Could aRFS steering for flows to secondary unicast MACs silently stop working after a uc list change? [ ... ] > @@ -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 this lock cover the match that the comment refers to? bnge_rx_flow_steer() first matches through bnge_lookup_ntp_filter_from_idx(). That runs under rcu_read_lock() only, and bnge_fltr_match() reads f->l2_key before ntp_fltr_lock is taken: bnge_lookup_ntp_filter_from_idx() { head = &bn->ntp_fltr_hash_tbl[idx]; hlist_for_each_entry_rcu(f, head, base.hlist) { if (bnge_fltr_match(f, fltr)) return f; } return NULL; } Only the second match, in bnge_insert_ntp_filter(), runs under the lock. The lockless lookup can still race with the struct copy done here under the lock. The runtime effect looks small. Retarget is a no-op for BNGE_ACT_NO_AGING rules, and a missed match gets -EEXIST from bnge_insert_ntp_filter(). Could the comment be changed to say what the lock actually protects? The ntp_fltr_lock description in struct bnge_net also still says: /* Protects the aRFS/ntuple hash table add and delete. usr_fltr_list, * l2_fltr_hash_tbl and l2_fltr_bmap are covered by the netdev instance * lock instead. */ This patch now also uses the lock for per-filter fields: - l2_key and l2_filter_id here - rxq and flow_id in bnge_ntp_fltr_retarget() - the rxq and flow_id re-check in the expire loop of bnge_cfg_ntp_filters() Should that description be updated too? [ ... ] > @@ -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, &expire_list, base.list_node) { > + list_del_init(&fltr->base.list_node); [ ... ] > + spin_lock_bh(&bn->ntp_fltr_lock); > + if (test_bit(BNGE_FLTR_RXQ_UPDATE, &fltr->base.state) || > + !rps_may_expire_flow(bn->netdev, fltr->base.rxq, > + fltr->flow_id, fltr->base.sw_id)) { > + spin_unlock_bh(&bn->ntp_fltr_lock); > + continue; > + } > + 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 rule when the HWRM free fails? bnge_hwrm_cfa_ntuple_filter_free() clears filter_id only when the request succeeds: req->ntuple_filter_id = fltr->base.filter_id; rc = bnge_hwrm_req_send(bd, req); if (!rc) fltr->base.filter_id = BNGE_FLTR_ID_INVALID; return rc; The return value is ignored here. bnge_del_ntp_filter_rcu() then releases sw_id in ntp_fltr_bmap and calls kfree_rcu() on the object, which is the driver's only record of the firmware filter_id. The firmware rule keeps steering the flow to the old rxq, and nothing can free it later. The software entry is already unhashed, so bnge_rx_flow_steer() can then insert and program a new rule for the same tuple. That would leave a duplicate rule in firmware. The update_list loop earlier in this function does check the result and keeps the object on failure: if (bnge_hwrm_cfa_ntuple_filter_free(bn->bd, fltr)) continue; Should the expire path handle a failed free the same way? > + } > +#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); > + /* Pairs with test_and_clear_bit() in sp_task */ > + smp_mb__before_atomic(); > + set_bit(BNGE_FLTR_RXQ_UPDATE, &fltr->base.state); > + return true; > +} [Severity: Low] This isn't a bug, but the commit message doesn't mention the retargeting added here. It describes bnge_rx_flow_steer() as creating and inserting a filter, and bnge_cfg_ntp_filters() as handling "deferred filter programming and expiration". Sometimes bnge_rx_flow_steer() finds an existing filter for a flow that has moved to another queue. In that case bnge_ntp_fltr_retarget() rewrites rxq and flow_id and sets BNGE_FLTR_RXQ_UPDATE. sp_task then frees the firmware rule and reinstalls it on the new queue through the update_list path in bnge_cfg_ntp_filters(). If the reinstall fails, the rule is deleted. If the free fails, it is not retried. In the same case, bnxt_rx_flow_steer() just returns the existing sw_id, so this is a new design choice. The flow has no hardware rule between the free and the reinstall. An existing rule can also be dropped if the reinstall fails. Could the commit message describe the retarget path and these policies? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125115434.2080590-1-vikas.gupta%40broadcom.com