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 v8 02/10] bnge: add NTUPLE/ARFS VNIC
Date: Thu, 19 Nov 2026 17:09:04 +0000	[thread overview]
Message-ID: <179510814465.3136.8399207150280899643@kernel.org> (raw)
In-Reply-To: <20261116140653.1685797-3-vikas.gupta@broadcom.com>

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

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

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).

- [High] At the target commit, bnge_reserve_rings() writes
  bd->tx_nr_rings (361), bd->tx_nr_rings_per_tc (363), bd->rx_nr_rings…
- [Low] At this commit, bnge_set_dflt_rfs() (bnge_netdev.c:3310-3315)
  sets NETIF_F_NTUPLE in netdev->hw_features and netdev->features, and…
- [Low] The commit message mentions only adding bnge_set_dflt_rfs() "to
  configure the default NTUPLE feature state".
- [Low] The patch adds the prototype `bool bnge_arfs_capable(struct
  bnge_dev *bd, bool new_rss_ctx);` to bnge_resc.h:78.

--

bnge: add NTUPLE/ARFS VNIC

This patch allocates a second VNIC for NTUPLE/aRFS, which brings the VNIC
count to BNGE_BASE_VNICS (2). bnge_reserve_rings() now also requires the
matching RSS contexts from firmware. The patch adds ndo_fix_features and
ndo_set_features handling for NETIF_F_NTUPLE and turns the feature on by
default via bnge_set_dflt_rfs().

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> index 31ca314fd52b8..e79e05be25e11 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c

[ ... ]

> @@ -3051,6 +3056,11 @@ static int bnge_close(struct net_device *dev)
>  	bnge_hwrm_if_change(bn->bd, false);
>  	bn->sp_event = 0;
>  
> +	/* netif_running() is false now. Apply an NTUPLE change that
> +	 * bnge_fix_features() held back while the interface was up.
> +	 */
> +	netdev_update_features(dev);
> +
>  	return 0;
>  }
>  
> @@ -3133,6 +3143,36 @@ static const struct netdev_stat_ops bnge_stat_ops = {
>  	.get_base_stats		= bnge_get_base_stats,
>  };
>  
> +static netdev_features_t bnge_fix_features(struct net_device *dev,
> +					   netdev_features_t features)
> +{
> +	/* NTUPLE can only be changed while the interface is down. */
> +	if (netif_running(dev)) {
> +		if (dev->features & NETIF_F_NTUPLE)
> +			features |= NETIF_F_NTUPLE;
> +		else
> +			features &= ~NETIF_F_NTUPLE;
> +	}
> +	return features;
> +}

[Severity: Low]
This isn't a bug, but the commit message only says:

  Add bnge_set_dflt_rfs() to configure the default NTUPLE feature state
  at netdev allocation time.

The patch does more than that. It adds .ndo_fix_features and
.ndo_set_features, silently holds back NTUPLE changes while the interface
is running, applies them later from bnge_close() via
netdev_update_features(), and turns ntuple-filters on by default.

Could the commit message describe the down-only policy for NTUPLE changes
and the new netdev ops? Right now that policy is only explained later in
the series, in "bnge: add aRFS flow steering ndo support".

> +
> +static int bnge_set_features(struct net_device *dev, netdev_features_t features)
> +{
> +	struct bnge_net *bn = netdev_priv(dev);
> +	u32 flags = bn->priv_flags;
> +
> +	flags &= ~BNGE_NET_EN_NTUPLE;
> +	if (features & NETIF_F_NTUPLE)
> +		flags |= BNGE_NET_EN_NTUPLE;
> +
> +	if (flags == bn->priv_flags)
> +		return 0;
> +
> +	bn->priv_flags = flags;
> +
> +	return 0;
> +}
> +

[ ... ]

> @@ -3265,6 +3307,13 @@ static void bnge_init_ring_params(struct bnge_net *bn)
>  	bn->netdev->cfg->hds_thresh = max(BNGE_DEFAULT_RX_COPYBREAK, rx_size);
>  }
>  
> +static void bnge_set_dflt_rfs(struct bnge_net *bn)
> +{
> +	bn->netdev->hw_features |= NETIF_F_NTUPLE;
> +	bn->netdev->features |= NETIF_F_NTUPLE;
> +	bn->priv_flags |= BNGE_NET_EN_NTUPLE;
> +}

[Severity: Low]
Is NETIF_F_NTUPLE meant to be advertised and enabled at this point in the
series?

At this commit, drivers/net/ethernet/broadcom/bnge/ has no
get_rxnfc/set_rxnfc ethtool ops, no ndo_rx_flow_steer and no rx_cpu_rmap.
BNGE_NET_EN_NTUPLE is written by bnge_set_dflt_rfs() and
bnge_set_features(), but nothing reads it.

As a result, ethtool -k shows ntuple-filters as on, while ethtool -N
returns -EOPNOTSUPP. The NTUPLE change that bnge_fix_features() holds back
and bnge_close() later applies also has no effect.

Later patches in the series add the missing code: "bnge: add NTUPLE filter
support in ethtool", "bnge: add aRFS flow steering ndo support" and "bnge:
add cpu_rmap support for IRQ affinity". Could the feature bit be set in
the patch that makes it work, so intermediate commits don't advertise a
feature they can't use?

[ ... ]

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> index 01205b161d822..506ceee775e19 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c

[ ... ]

> @@ -237,8 +241,12 @@ static void bnge_copy_reserved_rings(struct bnge_dev *bd,
>  
>  static bool bnge_rings_ok(struct bnge_hw_rings *hwr)
>  {
> -	return hwr->tx && hwr->rx && hwr->nq && hwr->grp && hwr->vnic &&
> -	       hwr->stat && hwr->cmpl;
> +	/* The default and the NTUPLE VNICs each need a full set of RSS
> +	 * contexts for the final number of ring groups.
> +	 */
> +	return hwr->tx && hwr->rx && hwr->nq && hwr->grp &&
> +	       hwr->vnic >= BNGE_BASE_VNICS && hwr->stat && hwr->cmpl &&
> +	       hwr->rss_ctx >= bnge_cal_nr_rss_ctxs(hwr->grp) * BNGE_BASE_VNICS;
>  }

[ ... ]

> @@ -358,6 +369,10 @@ int bnge_reserve_rings(struct bnge_dev *bd)
>  	bd->rx_nr_rings = rx_rings;
>  	bd->nq_nr_rings = hwr.nq;
>  
> +	/* One ring group per rx ring, so rss_ctx is checked against the final
> +	 * rx ring count.
> +	 */
> +	hwr.grp = rx_rings;
>  	if (!bnge_rings_ok(&hwr))
>  		return -ENOMEM;
>  

[Severity: High]
Can this -ENOMEM return leave bd->rss_indir_tbl stale?

With this patch, bnge_rings_ok() can fail depending on what firmware
grants: fewer than BNGE_BASE_VNICS VNICs, or fewer than
2 * bnge_cal_nr_rss_ctxs() RSS contexts.

By the time the check runs, bnge_reserve_rings() has already updated
bd->tx_nr_rings, bd->tx_nr_rings_per_tc, bd->rx_nr_rings and
bd->nq_nr_rings. The early return then skips the indirection table reset
that follows:

	if (old_rx_rings != bd->hw_resc.resv_rx_rings ||
	    old_rx_nr_rings != bd->rx_nr_rings)
		bnge_set_dflt_rss_indir_tbl(bd);

Suppose a retry gets the same RX grant but enough RSS contexts. Then
old_rx_rings matches resv_rx_rings, and old_rx_nr_rings matches the
already reduced bd->rx_nr_rings. So bnge_set_dflt_rss_indir_tbl() is never
called.

bnge_fill_hw_rss_tbl() then uses the table to index rx_ring[] without a
clamp:

		else
			j = bd->rss_indir_tbl[i];

		rxr = &bn->rx_ring[j];

The table may still hold entries computed for the older, larger ring
count. It may also never have been initialized, since
bnge_alloc_rss_indir_tbl() kmallocs it. In either case, can
bnge_init_chip()->bnge_setup_vnic()->...->bnge_fill_hw_rss_tbl() read
past the end of bn->rx_ring[] and pass bogus fw_ring_id values to
firmware?

A later patch in the series, "bnge: add ethtool support to manage RSS
contexts", appears to fix this. It moves the bnge_rings_ok() check ahead
of any bd-> updates and adds a j >= bd->rx_nr_rings clamp in
bnge_fill_hw_rss_tbl(). Could the reordering be folded into this patch,
since this is where the new failure conditions come from?

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.h b/drivers/net/ethernet/broadcom/bnge/bnge_resc.h
> index c0b6992d7f828..97e8ef08974c7 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.h
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.h
> @@ -75,6 +75,7 @@ void bnge_aux_init_dflt_config(struct bnge_dev *bd);
>  u32 bnge_get_rxfh_indir_size(struct bnge_dev *bd);
>  int bnge_cal_nr_rss_ctxs(u16 rx_rings);
>  bool bnge_aux_has_enough_resources(struct bnge_dev *bd);
> +bool bnge_arfs_capable(struct bnge_dev *bd, bool new_rss_ctx);

[Severity: Low]
This isn't a bug, but bnge_arfs_capable() is declared here with no
definition and no caller in this patch.

Later in the series the prototype is removed, and bnge_rss_ctx_capable()
in bnge_resc.c is used instead. Could this declaration be dropped from
this patch?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116140653.1685797-1-vikas.gupta%40broadcom.com

  reply	other threads:[~2026-11-19 17:09 UTC|newest]

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