From patchwork Sat Jan 14 12:04:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Kanzenbach X-Patchwork-Id: 13101941 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 A799BC3DA78 for ; Sat, 14 Jan 2023 12:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=AAaPkMgPO5f7VyCxxuD5MS4z43rgV0LMZfQaH2SnQHw=; b=u81UMiYt+GQBID QSK1Q5LLM5sgoMsno/dyjFWVFdgZC1oGYeWKkpq4qoH6GrPKcAefR12N46ea9WD0pjv8+X7kIH4bN tRP6uRbk/k4OXDJHXCJ9zjHI1TpGk6OzNEKu5tvk+/lkF0l6tJQSK9AVX90hHVJr24LSBJNMUMyvv cXfdP9wGU1FsNA30Trz227fKP3Ij4zj89WYMuOfQxa4NXbYagm+1cxNOYhg5gOtVY4mdlLESUMJaO 64Sg4+Uu5ltubP1Ail6k0ZX/tdYWoJPb6UFoXTq4guVPPSvry9ZLpgRPBVU803mdQJqpEsRvSqlbE ao3trDwHLxuf65HDL0Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGfI8-005lMS-9N; Sat, 14 Jan 2023 12:05:44 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGfI4-005lKh-RG for linux-arm-kernel@lists.infradead.org; Sat, 14 Jan 2023 12:05:42 +0000 From: Kurt Kanzenbach DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673697929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZNQUxrexq+SGlCNMDyxm1etQA6NjevWDm17rYmoWxvs=; b=yke8jv+LjgkotXSM7PKxqcpHE7qw3XPxnw09flP+XzJBgxC0fTqmZb1q76mm35EbHHBqjz 2OWsMfxIrxuDvZKMlviaYQwb8TBCEQZgquNdp6fRX4iUaAnufc+omsX6jdtY9WC3M+yVxF EhwHjPHl5SW8dLdiIw7zIbwmlqyD0btceCVFfdtd14Bb8AQsp5uWOkneWUshU85wPedLhZ 4QVoQq4claTUYy6UPeTUsYMGXrjrgqcxV6HxJG/qZcLLXDb0kG+51NS0A+t9+XkO7sjFSc QMvf7eiQh+yjZwBktiZ3z6MavUN14L1kYCVXkNTT1nznEznaqjnocHinOE8Cog== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673697929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZNQUxrexq+SGlCNMDyxm1etQA6NjevWDm17rYmoWxvs=; b=+eO09YP07+aMH9J8vYT/wWjcHR0iTrFmLUeVuYmzQzkS+Tlvr/zVCA0+xrbcHPNaqb29qp +DoOslFrIAVjssAg== To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Kurt Kanzenbach , Vijayakannan Ayyathurai , Wong Vee Khee Subject: [PATCH net v1] net: stmmac: Fix queue statistics reading Date: Sat, 14 Jan 2023 13:04:37 +0100 Message-Id: <20230114120437.383514-1-kurt@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230114_040541_081215_5E302DCF X-CRM114-Status: UNSURE ( 8.53 ) X-CRM114-Notice: Please train this message. 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 Correct queue statistics reading. All queue statistics are stored as unsigned long values. The retrieval for ethtool fetches these values as u64. However, on some systems the size of the counters are 32 bit. That yields wrong queue statistic counters e.g., on arm32 systems such as the stm32mp157. Fix it by using the correct data type. Tested on Olimex STMP157-OLinuXino-LIME2 by simple running linuxptp for a short period of time: Non-patched kernel: |root@st1:~# ethtool -S eth0 | grep q0 | q0_tx_pkt_n: 3775276254951 # ??? | q0_tx_irq_n: 879 | q0_rx_pkt_n: 1194000908909 # ??? | q0_rx_irq_n: 278 Patched kernel: |root@st1:~# ethtool -S eth0 | grep q0 | q0_tx_pkt_n: 2434 | q0_tx_irq_n: 1274 | q0_rx_pkt_n: 1604 | q0_rx_irq_n: 846 Fixes: 68e9c5dee1cf ("net: stmmac: add ethtool per-queue statistic framework") Signed-off-by: Kurt Kanzenbach Cc: Vijayakannan Ayyathurai Cc: Wong Vee Khee --- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index f453b0d09366..35c8dd92d369 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -551,16 +551,16 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data) p = (char *)priv + offsetof(struct stmmac_priv, xstats.txq_stats[q].tx_pkt_n); for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) { - *data++ = (*(u64 *)p); - p += sizeof(u64 *); + *data++ = (*(unsigned long *)p); + p += sizeof(unsigned long); } } for (q = 0; q < rx_cnt; q++) { p = (char *)priv + offsetof(struct stmmac_priv, xstats.rxq_stats[q].rx_pkt_n); for (stat = 0; stat < STMMAC_RXQ_STATS; stat++) { - *data++ = (*(u64 *)p); - p += sizeof(u64 *); + *data++ = (*(unsigned long *)p); + p += sizeof(unsigned long); } } }