From patchwork Wed Apr 8 09:27:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 2004 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 1C0281C008C for ; Wed, 8 Apr 2026 11:43:39 +0200 (CEST) Authentication-Results: mxe881; dkim=fail header.d=armlinux.org.uk; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-22813-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-22813-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 96FCA3012BEC for ; Wed, 8 Apr 2026 09:43:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BDD73ACF0B; Wed, 8 Apr 2026 09:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="pMmFVqfW" X-Original-To: linux-sunxi@lists.linux.dev Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E7933ACEE1 for ; Wed, 8 Apr 2026 09:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775641406; cv=none; b=j012laG7sYLI1DXujLkTgfdm4/SxMrcSsV97TtUea3pZWLa/pOjaWVaRLqTI2K82gufW/wD2H7wDz2phBwhZljysl7dfCjW0T2jZTVN/onfuyaGxSBzrgcUGmeRT80yO757bV9HPWb+MazksR7lz4I5jUPMpTz4C6SozLzYwliE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775641406; c=relaxed/simple; bh=42cTnhbRNXDI42kmq2UqvJhTgEsYYP6zV+heY4u/ph4=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=DrmA99AV9fFq7Y2a4V5HF9LJDT1pVSnOV2RPNv7XklLMtJt8QTuow+gCl5vAPXucjis7CsIOXEGTetHD3LZHxIuv7XUazLuqkjNJ8gvrXb1J198svMY/Zqh7EKM7juTm1nITggXvm1PrCBBMW6TGhB2xPJS3XA9R8h9DZ2oaSmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=pMmFVqfW; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk 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() Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 08 Apr 2026 10:27:20 +0100 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.16 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.232.135.74:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[armlinux.org.uk : SPF not aligned (relaxed),none]; R_DKIM_REJECT(1.00)[armlinux.org.uk:s=pandora-2019]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[netdev]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[sto.lore.kernel.org:rdns,sto.lore.kernel.org:helo,armlinux.org.uk:email]; FORGED_SENDER_MAILLIST(0.00)[]; RCPT_COUNT_TWELVE(0.00)[14]; RCVD_COUNT_FIVE(0.00)[6]; TAGGED_FROM(0.00)[bounces-22813-noreply=patchwork.local,kernel]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[armlinux.org.uk:-]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74]; TO_DN_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[rmk@armlinux.org.uk,linux-sunxi@lists.linux.dev]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 1C0281C008C X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= 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 ==