public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Chen-Yu Tsai <wens@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jitendra Vegiraju <jitendra.vegiraju@broadcom.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-sunxi@lists.linux.dev, netdev@vger.kernel.org,
	Paolo Abeni <pabeni@redhat.com>,
	Samuel Holland <samuel@sholland.org>
Subject: [PATCH RFC net-next 08/10] net: stmmac: simplify stmmac_get_ethtool_stats()
Date: Wed, 08 Apr 2026 10:27:20 +0100	[thread overview]
Message-ID: <E1wAPBw-0000000F7kf-0VA5@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <adYfPBHsXxQUsMyr@shell.armlinux.org.uk>

As documented, stmmac_dma_diagnostic_fr() will return non-zero for
all non-DWMAC_CORE_MAC100 core types.

However, as DWMAC_CORE_MAC100 core types do not have DMA capabilities,
priv->dma_cap.rmon and priv->dma_cap.eee will be zero, and thus there
is no need to make this also conditional on the
stmmac_dma_diagnostic_fr() return value.

Remove this test and unindent the code, and remove unnecessary parens.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  | 60 +++++++++----------
 1 file changed, 28 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 0caa5b992519..77cb67f4c63c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -519,9 +519,9 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
 	u32 rx_queues_count = priv->plat->rx_queues_to_use;
 	u32 tx_queues_count = priv->plat->tx_queues_to_use;
 	u64 napi_poll = 0, normal_irq_n = 0;
-	int i, j = 0, pos, ret;
 	unsigned long count;
 	unsigned int start;
+	int i, j = 0, pos;
 
 	if (priv->dma_cap.asp) {
 		for (i = 0; i < STMMAC_SAFETY_FEAT_SIZE; i++) {
@@ -531,42 +531,38 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
 		}
 	}
 
-	/* Update the DMA HW counters for dwmac10/100 (DWMAC_CORE_MAC100),
-	 * where this will return zero. Other core types will have a non-zero
-	 * return value.
-	 */
-	ret = stmmac_dma_diagnostic_fr(priv, &priv->xstats, priv->ioaddr);
-	if (ret) {
-		/* If supported, for new GMAC chips expose the MMC counters */
-		if (priv->dma_cap.rmon) {
-			stmmac_mmc_read(priv, priv->mmcaddr, &priv->mmc);
+	/* Update the DMA HW counters for dwmac10/100 (DWMAC_CORE_MAC100). */
+	stmmac_dma_diagnostic_fr(priv, &priv->xstats, priv->ioaddr);
 
-			for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) {
-				char *p;
-				p = (char *)priv + stmmac_mmc[i].stat_offset;
+	/* If supported, for new GMAC chips expose the MMC counters */
+	if (priv->dma_cap.rmon) {
+		stmmac_mmc_read(priv, priv->mmcaddr, &priv->mmc);
 
-				data[j++] = (stmmac_mmc[i].sizeof_stat ==
-					     sizeof(u64)) ? (*(u64 *)p) :
-					     (*(u32 *)p);
-			}
-		}
-		if (priv->dma_cap.eee) {
-			int val = phylink_get_eee_err(priv->phylink);
-			if (val)
-				priv->xstats.phy_eee_wakeup_error_n = val;
+		for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) {
+			char *p = (char *)priv + stmmac_mmc[i].stat_offset;
+
+			data[j++] = stmmac_mmc[i].sizeof_stat == sizeof(u64) ?
+				    *(u64 *)p : *(u32 *)p;
 		}
+	}
 
-		/* Only dwmac1000 and dwmac4 implements the MAC .debug() method.
-		 * As there are different version spaces depending on core_type,
-		 * make this conditional on the appropriate core type.
-		 */
-		if ((priv->plat->core_type == DWMAC_CORE_GMAC ||
-		     priv->plat->core_type == DWMAC_CORE_GMAC4) &&
-		    priv->snpsver >= DWMAC_CORE_3_50)
-			stmmac_mac_debug(priv, priv->ioaddr,
-					(void *)&priv->xstats,
-					rx_queues_count, tx_queues_count);
+	if (priv->dma_cap.eee) {
+		int val = phylink_get_eee_err(priv->phylink);
+		if (val)
+			priv->xstats.phy_eee_wakeup_error_n = val;
 	}
+
+	/* Only dwmac1000 and dwmac4 implements the MAC .debug() method.
+	 * As there are different version spaces depending on core_type,
+	 * make this conditional on the appropriate core type.
+	 */
+	if ((priv->plat->core_type == DWMAC_CORE_GMAC ||
+	     priv->plat->core_type == DWMAC_CORE_GMAC4) &&
+	    priv->snpsver >= DWMAC_CORE_3_50)
+		stmmac_mac_debug(priv, priv->ioaddr,
+				(void *)&priv->xstats,
+				rx_queues_count, tx_queues_count);
+
 	for (i = 0; i < STMMAC_STATS_LEN; i++) {
 		char *p = (char *)priv + stmmac_gstrings_stats[i].stat_offset;
 		data[j++] = (stmmac_gstrings_stats[i].sizeof_stat ==
-- 
2.47.3



  parent reply	other threads:[~2026-04-08  9:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  9:26 [PATCH RFC net-next 00/10] net: stmmac: clean up / fix synopsys IP version checks Russell King (Oracle)
2026-04-08  9:26 ` [PATCH RFC net-next 01/10] net: stmmac: rename min_id to min_snpsver Russell King (Oracle)
2026-04-08  9:26 ` [PATCH RFC net-next 02/10] net: stmmac: rename dev_id to userver Russell King (Oracle)
2026-04-08  9:26 ` [PATCH RFC net-next 03/10] net: stmmac: always fill in ver->userver Russell King (Oracle)
2026-04-08  9:26 ` [PATCH RFC net-next 04/10] net: stmmac: use ver->userver and ver->snpsver to print version Russell King (Oracle)
2026-04-08  9:27 ` [PATCH RFC net-next 05/10] net: stmmac: rename confusing synopsys_id Russell King (Oracle)
2026-04-08  9:27 ` [PATCH RFC net-next 06/10] net: stmmac: dche is only for GMAC4 cores Russell King (Oracle)
2026-04-08  9:27 ` [PATCH RFC net-next 07/10] net: stmmac: limit MAC .debug() to dwmac1000 and dwmac4 Russell King (Oracle)
2026-04-08  9:27 ` Russell King (Oracle) [this message]
2026-04-08  9:27 ` [PATCH RFC net-next 09/10] net: stmmac: clean up test for rx_coe debug printing Russell King (Oracle)
2026-04-08  9:27 ` [PATCH RFC net-next 10/10] net: stmmac: only print receive COE type for GMAC cores Russell King (Oracle)

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=E1wAPBw-0000000F7kf-0VA5@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jitendra.vegiraju@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=samuel@sholland.org \
    --cc=wens@kernel.org \
    /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