From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 800601073C84 for ; Wed, 8 Apr 2026 09:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:Content-Type :Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dtVN72wGnZ6TO0cAYb5J7S2eJNnpZu9n4ngwxR3LA7o=; b=nooYDhv2yzxzObtUNE+cmK1Z6d 4pt0+FYTxOs358KaUdxsdS+RYGJ5fXHJSv9vw2f2Rx7ZvYcw8PmT6q3Y1N9vZl8PjoFbWTRv1WHlk Q/Yywbw+BFsYji+VwQjxzf8xsMvmRix2oANCtUB2p7b0rAQKGg9HJ5029Q60oTBIJZvg9J1SduKlD Px1MOdwGSe4CkBEJIzkSG6Beeuv5lrTrxeZHCMweKJZ7JREwnzulKfYfK/I8wUcpBJOVq47dtmJ+U PF9dPvA79A5oZ+UlJ4JRHa/r4QqBx+QgELUyjNYiaa4jcRoe/7bJYp+0j7FAyFpBlNiJlezKhsSpI yue2sQDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wAPRT-00000008dDo-3Eg4; Wed, 08 Apr 2026 09:43:23 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wAPRS-00000008dDU-0tC4 for linux-arm-kernel@lists.infradead.org; Wed, 08 Apr 2026 09:43:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dtVN72wGnZ6TO0cAYb5J7S2eJNnpZu9n4ngwxR3LA7o=; b=pMmFVqfW9d0y0Vunkjgw90tppX e6SHEF9NLrmIAYbhuF6NYMuzwDOppOsK4e22goBrdIiKzvwduIXBRma6wH5ml1NdEv6wFPF46mgjY ZjleLyH++ly3sn9TqN8TkvoxEpyRVEG/JnAG40jPB6MfzSIA1BCj91LVWhBomWJMcd4iaFjqmE6cF 6tn+0yEbovFt6d5tYDwYkcYq2HfcBD6VTd78TXwFg0EDFcrcCsX1oCgXHy24shjczrNA34YJABqLq bWPkQB0TU6h7mui5mHBwDdhMZcH/sVs+TMusmJGUn/E/oJ+/eW9OAIhWiXviE4E+XFLAb9rge0YTg vYTvPrrg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33734 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAPC7-00000000244-1u7L; Wed, 08 Apr 2026 10:27:31 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1wAPBw-0000000F7kf-0VA5; Wed, 08 Apr 2026 10:27:20 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn Cc: Alexandre Torgue , Andrew Lunn , Chen-Yu Tsai , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jitendra Vegiraju , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, netdev@vger.kernel.org, Paolo Abeni , Samuel Holland Subject: [PATCH RFC net-next 08/10] net: stmmac: simplify stmmac_get_ethtool_stats() MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Date: Wed, 08 Apr 2026 10:27:20 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260408_024322_268817_58EA6A92 X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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) --- .../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