public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: vikas.gupta@broadcom.com
Cc: Simon Horman <horms@kernel.org>,
	vsrama-krishna.nemani@broadcom.com, edumazet@google.com,
	ajit.khaparde@broadcom.com, kuba@kernel.org,
	netdev@vger.kernel.org, pavan.chebbi@broadcom.com,
	rajashekar.hudumula@broadcom.com, pabeni@redhat.com,
	davem@davemloft.net, michael.chan@broadcom.com,
	bhargava.marreddy@broadcom.com, andrew+netdev@lunn.ch,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v8 10/10] bng_en: add support for ethtool -S stats display
Date: Fri, 20 Mar 2026 11:27:19 +0000	[thread overview]
Message-ID: <20260320112717.2065386-3-horms@kernel.org> (raw)
In-Reply-To: <20260319055124.1350670-11-vikas.gupta@broadcom.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html

Simon says: This is somewhat more subjective than the other two AI
generated reviews I released for this patch-set. But I think it does
at least warrant discussion.

---
bng_en: add support for ethtool -S stats display

This patch implements the legacy ethtool statistics interface to expose
hardware counters through ethtool -S, including per-queue ring stats,
TPA stats, port level stats, and per-priority stats.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
> index 2ae13f18e2d7..1a0eb987ef6f 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c

[ ... ]

> @@ -42,6 +307,219 @@ static void bnge_get_drvinfo(struct net_device *dev,
>  	strscpy(info->bus_info, pci_name(bd->pdev), sizeof(info->bus_info));
>  }
>
> +static int bnge_get_sset_count(struct net_device *dev, int sset)
> +{
> +	struct bnge_net *bn = netdev_priv(dev);
> +
> +	switch (sset) {
> +	case ETH_SS_STATS:
> +		return bnge_get_num_stats(bn);
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +}

[ ... ]

> +static void bnge_get_ethtool_stats(struct net_device *dev,
> +				   struct ethtool_stats *stats, u64 *buf)
> +{
> +	struct bnge_net *bn = netdev_priv(dev);
> +	struct bnge_dev *bd = bn->bd;
> +	u32 tpa_stats;
> +	u32 i, j = 0;
> +
> +	if (!bn->bnapi) {
> +		j += bnge_get_num_ring_stats(bd);
> +		goto skip_ring_stats;
> +	}
> +
> +	tpa_stats = bnge_get_num_tpa_ring_stats(bd);
> +	for (i = 0; i < bd->nq_nr_rings; i++) {
> +		struct bnge_napi *bnapi = bn->bnapi[i];
> +		struct bnge_nq_ring_info *nqr;
> +		u64 *sw_stats;
> +		int k;
> +
> +		nqr = &bnapi->nq_ring;
> +		sw_stats = nqr->stats.sw_stats;
> +
> +		if (is_rx_ring(bd, i)) {
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_ucast_pkts);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_mcast_pkts);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_bcast_pkts);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_ucast_bytes);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_mcast_bytes);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, rx_bcast_bytes);
> +		}
> +		if (is_tx_ring(bd, i)) {
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_ucast_pkts);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_mcast_pkts);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_bcast_pkts);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_ucast_bytes);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_mcast_bytes);
> +			buf[j++] = BNGE_GET_RING_STATS64(sw_stats, tx_bcast_bytes);
> +		}

This isn't a bug, but Documentation/networking/statistics.rst flags a
potential concern about interface duplication. The patch adds per-queue
ring statistics (rxqN_ucast_packets, rxqN_mcast_packets,
rxqN_bcast_packets, rxqN_ucast_bytes, rxqN_mcast_bytes, rxqN_bcast_bytes,
and tx equivalents) to the ethtool -S interface.

However, this driver already implements the standard per-queue statistics
API via netdev_stat_ops (bnge_get_queue_stats_rx and
bnge_get_queue_stats_tx in bnge_netdev.c). That interface exposes
per-queue packets and bytes through netlink, which is the designated
mechanism for per-queue counters.

According to Documentation/networking/statistics.rst, per-queue stats
should use the standard netdev_stat_ops interface rather than ethtool -S.
The documentation states that drivers should avoid adding new counters to
ethtool -S for values that have a standard uAPI.

While the ethtool -S stats provide a ucast/mcast/bcast breakdown not
directly available from the standard per-queue API (which aggregates to
total packets and bytes), this still represents duplication of the
fundamental per-queue packet and byte counters. Could these per-queue
stats be omitted from ethtool -S, keeping only the truly hardware-specific
stats like TPA, port-level, and priority stats that don't have a standard
interface?

[ ... ]

> @@ -262,6 +740,9 @@ static const struct ethtool_ops bnge_ethtool_ops = {
>  	.nway_reset		= bnge_nway_reset,
>  	.get_pauseparam		= bnge_get_pauseparam,
>  	.set_pauseparam		= bnge_set_pauseparam,
> +	.get_sset_count		= bnge_get_sset_count,
> +	.get_strings		= bnge_get_strings,
> +	.get_ethtool_stats	= bnge_get_ethtool_stats,
>  	.get_eth_phy_stats	= bnge_get_eth_phy_stats,
>  	.get_eth_mac_stats	= bnge_get_eth_mac_stats,
>  	.get_eth_ctrl_stats	= bnge_get_eth_ctrl_stats,

  reply	other threads:[~2026-03-20 11:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19  5:51 [PATCH net-next v8 00/10] bng_en: add link management and statistics support Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 01/10] bng_en: add per-PF workqueue, timer, and slow-path task Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 02/10] bng_en: query PHY capabilities and report link status Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 03/10] bng_en: add ethtool link settings, get_link, and nway_reset Vikas Gupta
2026-03-20 11:26   ` Simon Horman
2026-03-21  3:11   ` Jakub Kicinski
2026-03-19  5:51 ` [PATCH net-next v8 04/10] bng_en: implement ethtool pauseparam operations Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 05/10] bng_en: add support for link async events Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 06/10] bng_en: add HW stats infra and structured ethtool ops Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 07/10] bng_en: periodically fetch and accumulate hardware statistics Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 08/10] bng_en: implement ndo_get_stats64 Vikas Gupta
2026-03-19  5:51 ` [PATCH net-next v8 09/10] bng_en: implement netdev_stat_ops Vikas Gupta
2026-03-20 11:27   ` Simon Horman
2026-03-20 20:27     ` Bhargava Chenna Marreddy
2026-03-21  9:15       ` Simon Horman
2026-03-19  5:51 ` [PATCH net-next v8 10/10] bng_en: add support for ethtool -S stats display Vikas Gupta
2026-03-20 11:27   ` Simon Horman [this message]
2026-03-20 19:51     ` Bhargava Chenna Marreddy
2026-03-21  9:06       ` Simon Horman

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=20260320112717.2065386-3-horms@kernel.org \
    --to=horms@kernel.org \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bhargava.marreddy@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@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