Skip to content

Commit 2c0d808

Browse files
danish-tikuba-moo
authored andcommitted
net: ti: icssg-prueth: Fix tx_total_bytes count
ICSSG HW stats on TX side considers 8 preamble bytes as data bytes. Due to this the tx_bytes of ICSSG interface doesn't match the rx_bytes of the link partner. There is no public errata available yet. As a workaround to fix this, decrease tx_bytes by 8 bytes for every tx frame. Fixes: c1e10d5 ("net: ti: icssg-prueth: Add ICSSG Stats") Signed-off-by: MD Danish Anwar <danishanwar@ti.com> Link: https://lore.kernel.org/r/20231012064626.977466-1-danishanwar@ti.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a258c80 commit 2c0d808

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/net/ethernet/ti/icssg/icssg_stats.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include "icssg_stats.h"
1010
#include <linux/regmap.h>
1111

12+
#define ICSSG_TX_PACKET_OFFSET 0xA0
13+
#define ICSSG_TX_BYTE_OFFSET 0xEC
14+
1215
static u32 stats_base[] = { 0x54c, /* Slice 0 stats start */
1316
0xb18, /* Slice 1 stats start */
1417
};
@@ -18,6 +21,7 @@ void emac_update_hardware_stats(struct prueth_emac *emac)
1821
struct prueth *prueth = emac->prueth;
1922
int slice = prueth_emac_slice(emac);
2023
u32 base = stats_base[slice];
24+
u32 tx_pkt_cnt = 0;
2125
u32 val;
2226
int i;
2327

@@ -29,7 +33,12 @@ void emac_update_hardware_stats(struct prueth_emac *emac)
2933
base + icssg_all_stats[i].offset,
3034
val);
3135

36+
if (icssg_all_stats[i].offset == ICSSG_TX_PACKET_OFFSET)
37+
tx_pkt_cnt = val;
38+
3239
emac->stats[i] += val;
40+
if (icssg_all_stats[i].offset == ICSSG_TX_BYTE_OFFSET)
41+
emac->stats[i] -= tx_pkt_cnt * 8;
3342
}
3443
}
3544

0 commit comments

Comments
 (0)