Skip to content

Commit 2f0009a

Browse files
committed
net: stmmac: Fix queue statistics reading
Author: Kurt Kanzenbach <kurt@linutronix.de> 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: 68e9c5d ("net: stmmac: add ethtool per-queue statistic framework") Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de> Cc: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com> Cc: Wong Vee Khee <vee.khee.wong@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit c296c77) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100606 Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
1 parent 514957f commit 2f0009a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,16 +551,16 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data)
551551
p = (char *)priv + offsetof(struct stmmac_priv,
552552
xstats.txq_stats[q].tx_pkt_n);
553553
for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) {
554-
*data++ = (*(u64 *)p);
555-
p += sizeof(u64 *);
554+
*data++ = (*(unsigned long *)p);
555+
p += sizeof(unsigned long);
556556
}
557557
}
558558
for (q = 0; q < rx_cnt; q++) {
559559
p = (char *)priv + offsetof(struct stmmac_priv,
560560
xstats.rxq_stats[q].rx_pkt_n);
561561
for (stat = 0; stat < STMMAC_RXQ_STATS; stat++) {
562-
*data++ = (*(u64 *)p);
563-
p += sizeof(u64 *);
562+
*data++ = (*(unsigned long *)p);
563+
p += sizeof(unsigned long);
564564
}
565565
}
566566
}

0 commit comments

Comments
 (0)