All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: ioana.ciornei@nxp.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	linux-kernel@vger.kernel.org, davem@davemloft.net,
	edumazet@google.com, andrew+netdev@lunn.ch,
	netdev@vger.kernel.org, pabeni@redhat.com, horms@kernel.org
Subject: Re: [PATCH net-next v4 3/3] net: dpaa2-mac: export standard statistics
Date: Fri, 20 Mar 2026 19:19:16 -0700	[thread overview]
Message-ID: <20260321021916.3948080-1-kuba@kernel.org> (raw)
In-Reply-To: <20260319142346.2483232-4-ioana.ciornei@nxp.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
---
net: dpaa2-mac: export standard statistics

This commit adds support for exporting MAC statistics through the
standard ethtool statistics structures (rmon, eth-ctrl, eth-mac, and
pause) in the dpaa2-mac driver for both dpaa2-eth and dpaa2-switch.

> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
> index baab4f1c908d..59f5c778df38 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ethtool.c

[ ... ]

> @@ -962,4 +1017,8 @@ const struct ethtool_ops dpaa2_ethtool_ops = {
>  	.get_coalesce = dpaa2_eth_get_coalesce,
>  	.set_coalesce = dpaa2_eth_set_coalesce,
>  	.get_channels = dpaa2_eth_get_channels,
> +	.get_rmon_stats = dpaa2_eth_get_rmon_stats,
> +	.get_pause_stats = dpaa2_eth_get_pause_stats,
> +	.get_eth_ctrl_stats = dpaa2_eth_get_ctrl_stats,
> +	.get_eth_mac_stats = dpaa2_eth_get_eth_mac_stats,
>  };

[ ... ]

> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c
> index a888f6e6e9b0..f5d9321c7ef9 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-ethtool.c

[ ... ]

> @@ -210,6 +210,49 @@ static void dpaa2_switch_ethtool_get_stats(struct net_device *netdev,
>  	mutex_unlock(&port_priv->mac_lock);
>  }
>
> +static void
> +dpaa2_switch_get_rmon_stats(struct net_device *netdev,
> +			    struct ethtool_rmon_stats *rmon_stats,
> +			    const struct ethtool_rmon_hist_range **ranges)
> +{
> +	struct ethsw_port_priv *port_priv = netdev_priv(netdev);
> +
> +	mutex_lock(&port_priv->mac_lock);
> +
> +	if (dpaa2_switch_port_has_mac(port_priv))
> +		dpaa2_mac_get_rmon_stats(port_priv->mac, rmon_stats, ranges);
> +
> +	mutex_unlock(&port_priv->mac_lock);
> +}
> +
> +static void
> +dpaa2_switch_get_ctrl_stats(struct net_device *net_dev,
> +			    struct ethtool_eth_ctrl_stats *ctrl_stats)
> +{
> +	struct ethsw_port_priv *port_priv = netdev_priv(net_dev);
> +
> +	mutex_lock(&port_priv->mac_lock);
> +
> +	if (dpaa2_switch_port_has_mac(port_priv))
> +		dpaa2_mac_get_ctrl_stats(port_priv->mac, ctrl_stats);
> +
> +	mutex_unlock(&port_priv->mac_lock);
> +}
> +
> +static void
> +dpaa2_switch_get_eth_mac_stats(struct net_device *net_dev,
> +			       struct ethtool_eth_mac_stats *eth_mac_stats)
> +{
> +	struct ethsw_port_priv *port_priv = netdev_priv(net_dev);
> +
> +	mutex_lock(&port_priv->mac_lock);
> +
> +	if (dpaa2_switch_port_has_mac(port_priv))
> +		dpaa2_mac_get_eth_mac_stats(port_priv->mac, eth_mac_stats);
> +
> +	mutex_unlock(&port_priv->mac_lock);
> +}
> +
>  const struct ethtool_ops dpaa2_switch_port_ethtool_ops = {
>  	.get_drvinfo		= dpaa2_switch_get_drvinfo,
>  	.get_link		= ethtool_op_get_link,
> @@ -218,4 +261,7 @@ const struct ethtool_ops dpaa2_switch_port_ethtool_ops = {
>  	.get_strings		= dpaa2_switch_ethtool_get_strings,
>  	.get_ethtool_stats	= dpaa2_switch_ethtool_get_stats,
>  	.get_sset_count		= dpaa2_switch_ethtool_get_sset_count,
> +	.get_rmon_stats		= dpaa2_switch_get_rmon_stats,
> +	.get_eth_ctrl_stats	= dpaa2_switch_get_ctrl_stats,
> +	.get_eth_mac_stats	= dpaa2_switch_get_eth_mac_stats,
>  };

Is the .get_pause_stats callback missing from the dpaa2-switch driver?

The commit message states that rmon, eth-ctrl, eth-mac, and pause
statistics are exported for both dpaa2-eth and dpaa2-switch drivers.

Looking at dpaa2-ethtool.c, the dpaa2-eth driver registers all four
callbacks in dpaa2_ethtool_ops:

	.get_rmon_stats = dpaa2_eth_get_rmon_stats,
	.get_pause_stats = dpaa2_eth_get_pause_stats,
	.get_eth_ctrl_stats = dpaa2_eth_get_ctrl_stats,
	.get_eth_mac_stats = dpaa2_eth_get_eth_mac_stats,

But dpaa2_switch_port_ethtool_ops only registers three callbacks. The
underlying MAC layer function dpaa2_mac_get_pause_stats() exists and is
declared in dpaa2-mac.h.

Also, dpaa2_mac_open() allocates DMA memory for mac->pause_stats when
DPAA2_MAC_FEATURE_STANDARD_STATS is set:

drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c:dpaa2_mac_open() {
	...
	if (mac->features & DPAA2_MAC_FEATURE_STANDARD_STATS) {
		dpaa2_mac_setup_stats(mac, &mac->rmon_stats,
				      DPAA2_MAC_NUM_RMON_STATS,
				      dpaa2_mac_rmon_stats);

		dpaa2_mac_setup_stats(mac, &mac->pause_stats,
				      DPAA2_MAC_NUM_PAUSE_STATS,
				      dpaa2_mac_pause_stats);

		dpaa2_mac_setup_stats(mac, &mac->eth_ctrl_stats,
				      DPAA2_MAC_NUM_ETH_CTRL_STATS,
				      dpaa2_mac_eth_ctrl_stats);

		dpaa2_mac_setup_stats(mac, &mac->eth_mac_stats,
				      DPAA2_MAC_NUM_ETH_MAC_STATS,
				      dpaa2_mac_eth_mac_stats);
	}
	...
}

Without the .get_pause_stats callback in the switch driver, would the
pause_stats DMA resources be allocated but never used?
-- 
pw-bot: cr

  reply	other threads:[~2026-03-21  2:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 14:23 [PATCH net-next v4 0/3] net: dpaa2-mac: export standard statistics Ioana Ciornei
2026-03-19 14:23 ` [PATCH net-next v4 1/3] net: dpaa2-mac: extend APIs related to statistics Ioana Ciornei
2026-03-19 14:23 ` [PATCH net-next v4 2/3] net: dpaa2-mac: retrieve MAC statistics in one firmware command Ioana Ciornei
2026-03-19 14:23 ` [PATCH net-next v4 3/3] net: dpaa2-mac: export standard statistics Ioana Ciornei
2026-03-21  2:19   ` Jakub Kicinski [this message]
2026-03-21  2:19   ` Jakub Kicinski

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=20260321021916.3948080-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=ioana.ciornei@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.