Skip to content

Commit 61921bd

Browse files
ptesarikdavem330
authored andcommitted
net: stmmac: fix ethtool per-queue statistics
Fix per-queue statistics for devices with more than one queue. The output data pointer is currently reset in each loop iteration, effectively summing all queue statistics in the first four u64 values. The summary values are not even labeled correctly. For example, if eth0 has 2 queues, ethtool -S eth0 shows: q0_tx_pkt_n: 374 (actually tx_pkt_n over all queues) q0_tx_irq_n: 23 (actually tx_normal_irq_n over all queues) q1_tx_pkt_n: 462 (actually rx_pkt_n over all queues) q1_tx_irq_n: 446 (actually rx_normal_irq_n over all queues) q0_rx_pkt_n: 0 q0_rx_irq_n: 0 q1_rx_pkt_n: 0 q1_rx_irq_n: 0 Fixes: 133466c ("net: stmmac: use per-queue 64 bit statistics where necessary") Cc: stable@vger.kernel.org Signed-off-by: Petr Tesarik <petr@tesarici.cz> Reviewed-by: Jisheng Zhang <jszhang@kernel.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d375b98 commit 61921bd

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,41 +543,36 @@ static void stmmac_get_per_qstats(struct stmmac_priv *priv, u64 *data)
543543
u32 rx_cnt = priv->plat->rx_queues_to_use;
544544
unsigned int start;
545545
int q, stat;
546-
u64 *pos;
547546
char *p;
548547

549-
pos = data;
550548
for (q = 0; q < tx_cnt; q++) {
551549
struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[q];
552550
struct stmmac_txq_stats snapshot;
553551

554-
data = pos;
555552
do {
556553
start = u64_stats_fetch_begin(&txq_stats->syncp);
557554
snapshot = *txq_stats;
558555
} while (u64_stats_fetch_retry(&txq_stats->syncp, start));
559556

560557
p = (char *)&snapshot + offsetof(struct stmmac_txq_stats, tx_pkt_n);
561558
for (stat = 0; stat < STMMAC_TXQ_STATS; stat++) {
562-
*data++ += (*(u64 *)p);
559+
*data++ = (*(u64 *)p);
563560
p += sizeof(u64);
564561
}
565562
}
566563

567-
pos = data;
568564
for (q = 0; q < rx_cnt; q++) {
569565
struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[q];
570566
struct stmmac_rxq_stats snapshot;
571567

572-
data = pos;
573568
do {
574569
start = u64_stats_fetch_begin(&rxq_stats->syncp);
575570
snapshot = *rxq_stats;
576571
} while (u64_stats_fetch_retry(&rxq_stats->syncp, start));
577572

578573
p = (char *)&snapshot + offsetof(struct stmmac_rxq_stats, rx_pkt_n);
579574
for (stat = 0; stat < STMMAC_RXQ_STATS; stat++) {
580-
*data++ += (*(u64 *)p);
575+
*data++ = (*(u64 *)p);
581576
p += sizeof(u64);
582577
}
583578
}

0 commit comments

Comments
 (0)