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 08/10] bnge: add NTUPLE filter support in ethtool
Date: Sat, 05 Dec 2026 14:46:20 +0000	[thread overview]
Message-ID: <179648198035.3146.10955388662827175312@kernel.org> (raw)
In-Reply-To: <20261201132011.2705569-9-vikas.gupta@broadcom.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] bnge_srxclsrldel() in
  drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c ignores the return…
- [Low] The commit message says user filters "stay in software while the
  interface is down" and that "bnge_cfg_usr_fltrs() programs them in…

--

bnge: add NTUPLE filter support in ethtool

This commit adds ethtool get_rxnfc/set_rxnfc support for ntuple and
ETHER_FLOW rules. User rules are kept in software across down/up and
programmed in firmware again on open. The unicast address filters now
share the L2 filter pool with these rules, and NETIF_F_NTUPLE is enabled
by default.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
> index 99a69f16a0a62..77edcd564b619 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c

[ ... ]

> +static int bnge_srxclsrldel(struct bnge_net *bn, struct ethtool_rxnfc *cmd)
> +{
> +	struct ethtool_rx_flow_spec *fs = &cmd->fs;
> +	struct bnge_filter_base *fltr_base;
> +	struct bnge_ntuple_filter *fltr;
> +	u32 id = fs->location;
> +
> +	rcu_read_lock();
> +	fltr_base = bnge_get_one_fltr_rcu(bn, bn->l2_fltr_hash_tbl,
> +					  BNGE_L2_FLTR_HASH_SIZE, id, 0);
> +	if (fltr_base) {
> +		struct bnge_l2_filter *l2_fltr;
> +
> +		l2_fltr = container_of(fltr_base, struct bnge_l2_filter, base);
> +		rcu_read_unlock();
> +		/* The firmware filter is gone once the interface is closed. */
> +		if (test_bit(BNGE_FLTR_VALID, &l2_fltr->base.state))
> +			bnge_hwrm_l2_filter_free(bn->bd, l2_fltr);
> +		bnge_del_usr_l2_filter(bn, l2_fltr);
> +		return 0;
> +	}

[ ... ]

> +	rcu_read_unlock();
> +	bnge_hwrm_cfa_ntuple_filter_free(bn->bd, fltr);
> +	bnge_del_ntp_filter_rcu(bn, fltr);
> +	return 0;
> +}

[Severity: Medium]
What happens here if the firmware fails HWRM_CFA_L2_FILTER_FREE or
HWRM_CFA_NTUPLE_FILTER_FREE?

bnge_srxclsrldel() drops the return values of bnge_hwrm_l2_filter_free()
and bnge_hwrm_cfa_ntuple_filter_free(). It then tears down the software
filter anyway, through bnge_del_usr_l2_filter()->bnge_del_l2_filter_rcu()
or through bnge_del_ntp_filter_rcu(). Those clear the sw_id bit, unlink
the list node and kfree_rcu() the object. Then 0 is returned to user
space.

bnge_hwrm_l2_filter_free() returns the result of bnge_hwrm_req_send(), so
a firmware busy error (-EAGAIN) or an HWRM timeout can reach this point.
bnge_cfg_rx_mode() already treats -EAGAIN from the firmware as a
transient condition.

Once the object is freed, base.filter_id is freed with it, and nothing
can release the firmware filter later. At close,
bnge_hwrm_clear_usr_l2_fltrs() walks usr_fltr_list, and the node is no
longer on it.

For an ETHER_FLOW rule, could the leaked filter keep steering the MAC to
the NTUPLE VNIC ring after ethtool -n stops listing it?
bnge_del_usr_l2_filter() would also program a default VNIC unicast filter
for the same MAC while the stale filter may still be active. A leaked
ntuple filter would likewise keep steering or dropping the matching
flows.

bnxt_srxclsrldel() uses the same pattern. Would it be better to return
the error and keep the software filter when the firmware free fails? The
last patch of the series still has this pattern.

bnge_hwrm_clear_usr_l2_fltrs() has a weaker version of the same thing.
It clears BNGE_FLTR_VALID before a free whose result is ignored. That is
the close path, though, where ignoring release errors is more usual.

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

[ ... ]

> +static void bnge_cfg_one_usr_fltr(struct bnge_net *bn,
> +				  struct bnge_filter_base *fltr)
> +{
> +	struct bnge_ntuple_filter *ntp_fltr;
> +	struct bnge_l2_filter *l2_fltr;
> +
> +	if (list_empty(&fltr->list_node))
> +		return;
> +
> +	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];
> +		ntp_fltr->l2_filter_id = l2_fltr->base.filter_id;
> +		if (bnge_usr_fltr_ring_lost(bn, fltr) ||
> +		    bnge_hwrm_cfa_ntuple_filter_alloc(bn->bd, ntp_fltr)) {
> +			netdev_err(bn->netdev,
> +				   "restoring previously configured ntuple filter id %d failed\n",
> +				   BNGE_MAX_L2_FLTRS + fltr->sw_id);
> +			bnge_del_ntp_filter_rcu(bn, ntp_fltr);
> +		}
> +	} else if (fltr->type == BNGE_FLTR_TYPE_L2) {
> +		l2_fltr = container_of(fltr, struct bnge_l2_filter, base);
> +		fltr->fw_vnic_id = bn->vnic_info[BNGE_VNIC_NTUPLE].fw_vnic_id;
> +		if (bnge_usr_fltr_ring_lost(bn, fltr) ||
> +		    bnge_hwrm_l2_filter_alloc(bn->bd, l2_fltr)) {
> +			netdev_err(bn->netdev,
> +				   "restoring previously configured l2 filter id %d failed\n",
> +				   fltr->sw_id);
> +			bnge_del_usr_l2_filter(bn, l2_fltr);
> +		}
> +	}
> +}

[Severity: Low]
The commit message says:

    User filters stay in software while the interface is down.
    bnge_cfg_usr_fltrs() programs them in firmware again on open, and
    bnge_clear_usr_fltrs() deletes them when NTUPLE is turned off.

Should it also say that bnge_cfg_one_usr_fltr() permanently deletes a
retained rule that it cannot restore on open?

The rule is dropped in two cases. One is when bnge_usr_fltr_ring_lost()
reports that the target RX ring no longer exists. The other is when the
firmware refuses bnge_hwrm_cfa_ntuple_filter_alloc() or
bnge_hwrm_l2_filter_alloc().

The rule then leaves usr_fltr_list, the hash table and the sw_id bitmap,
so it disappears from ethtool -n. Only a log message is left, and
bnge_open_core() still returns 0 after bnge_cfg_usr_fltrs().

The ring-lost case looks reachable. The ethtool core stops ethtool -L
from shrinking below the rings that rules use. However,
bnge_reserve_rings() in bnge_resc.c can still lower the ring count at
reservation time:

    dev_warn(bd->dev, "RX rings resv reduced to %d than earlier %d requested\n",
             rx_rings, bd->rx_nr_rings);
    ...
    bd->rx_nr_rings = rx_rings;

bnge_check_rss_ctxs_lost() already handles this case for RSS contexts.

The commit message covers the other caveats in detail. Could it also
note that rules can vanish after a down/up? This behavior is the same in
the last patch of the series.

-- 
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 [this message]
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
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=179648198035.3146.10955388662827175312@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