Thread (6 messages) 6 messages, 2 authors, 2026-03-21

Re: [PATCH net-next v4 3/3] net: dpaa2-mac: export standard statistics

From: Jakub Kicinski <kuba@kernel.org>
Date: 2026-03-21 02:19:18
Also in: lkml

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.
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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,
 };
[ ... ]
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help