Skip to content

Commit 40516d0

Browse files
shifty91gregkh
authored andcommitted
net: stmmac: Fix queue statistics reading
[ Upstream commit c296c77 ] 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 <[email protected]> Cc: Vijayakannan Ayyathurai <[email protected]> Cc: Wong Vee Khee <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 620aa67 commit 40516d0

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
@@ -548,16 +548,16 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data)
548548
p = (char *)priv + offsetof(struct stmmac_priv,
549549
xstats.txq_stats[q].tx_pkt_n);
550550
for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) {
551-
*data++ = (*(u64 *)p);
552-
p += sizeof(u64 *);
551+
*data++ = (*(unsigned long *)p);
552+
p += sizeof(unsigned long);
553553
}
554554
}
555555
for (q = 0; q < rx_cnt; q++) {
556556
p = (char *)priv + offsetof(struct stmmac_priv,
557557
xstats.rxq_stats[q].rx_pkt_n);
558558
for (stat = 0; stat < STMMAC_RXQ_STATS; stat++) {
559-
*data++ = (*(u64 *)p);
560-
p += sizeof(u64 *);
559+
*data++ = (*(unsigned long *)p);
560+
p += sizeof(unsigned long);
561561
}
562562
}
563563
}

0 commit comments

Comments
 (0)