Netdev List
 help / color / mirror / Atom feed
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 v12 09/10] bnge: add aRFS flow steering ndo support
Date: Sat, 05 Dec 2026 14:46:21 +0000	[thread overview]
Message-ID: <179648198178.3146.7542356016116033536@kernel.org> (raw)
In-Reply-To: <20261201132011.2705569-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] 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

  reply	other threads:[~2026-12-05 14:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 13:20 [PATCH net-next v12 00/10] add features to bnge Vikas Gupta
2026-12-01 13:20 ` [PATCH net-next v12 01/10] bnge: restructure VNIC and filter code Vikas Gupta
2026-12-01 13:20 ` [PATCH net-next v12 02/10] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-12-01 13:20 ` [PATCH net-next v12 03/10] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-12-05 14:46   ` netdev-bot+sashiko
2026-12-01 13:20 ` [PATCH net-next v12 04/10] bnge: add RXFH ethtool support Vikas Gupta
2026-12-05 14:46   ` netdev-bot+sashiko
2026-12-01 13:20 ` [PATCH net-next v12 05/10] bnge: add ethtool support to manage RSS contexts Vikas Gupta
2026-12-05 14:46   ` netdev-bot+sashiko
2026-12-01 13:20 ` [PATCH net-next v12 06/10] bnge: remove refcount from L2 filter Vikas Gupta
2026-12-01 13:20 ` [PATCH net-next v12 07/10] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-12-05 14:46   ` netdev-bot+sashiko
2026-12-01 13:20 ` [PATCH net-next v12 08/10] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-12-05 14:46   ` netdev-bot+sashiko
2026-12-01 13:20 ` [PATCH net-next v12 09/10] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-12-05 14:46   ` netdev-bot+sashiko [this message]
2026-12-01 13:20 ` [PATCH net-next v12 10/10] bnge: add cpu_rmap support for IRQ affinity Vikas Gupta
2026-12-05 14: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=179648198178.3146.7542356016116033536@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