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
Subject: Re: [PATCH net-next v10 09/10] bnge: add aRFS flow steering ndo support
Date: Sun, 29 Nov 2026 12:46:48 +0000 [thread overview]
Message-ID: <179595640835.3146.6072756088467989236@kernel.org> (raw)
In-Reply-To: <20261125115434.2080590-10-vikas.gupta@broadcom.com>
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
next prev parent reply other threads:[~2026-11-29 12:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:54 [PATCH net-next v10 00/10] add features to bnge Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 01/10] bnge: restructure VNIC and filter code Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 02/10] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 03/10] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 04/10] bnge: add RXFH ethtool support Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 05/10] bnge: add ethtool support to manage RSS contexts Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 06/10] bnge: remove refcount from L2 filter Vikas Gupta
2026-11-25 11:54 ` [PATCH net-next v10 07/10] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 08/10] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko
2026-11-25 11:54 ` [PATCH net-next v10 09/10] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-11-29 12:46 ` netdev-bot+sashiko [this message]
2026-11-25 11:54 ` [PATCH net-next v10 10/10] bnge: add cpu_rmap support for IRQ affinity Vikas Gupta
2026-11-29 12:46 ` 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=179595640835.3146.6072756088467989236@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=bhargava.marreddy@broadcom.com \
--cc=davem@davemloft.net \
--cc=dharmender.garg@broadcom.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rahul-rg.gupta@broadcom.com \
--cc=rajashekar.hudumula@broadcom.com \
--cc=vikas.gupta@broadcom.com \
--cc=vsrama-krishna.nemani@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
all inboxes | Powered by JetHome®