]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: ti: icssg-prueth: Fix swapped TX stats for MII interfaces.
authorMeghana Malladi <m-malladi@ti.com>
Tue, 3 Jun 2025 05:29:04 +0000 (10:59 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jun 2025 13:32:19 +0000 (15:32 +0200)
[ Upstream commit 919d763d609428c2680ec8159257d9655f002f89 ]

In MII mode, Tx lines are swapped for port0 and port1, which means
Tx port0 receives data from PRU1 and the Tx port1 receives data from
PRU0. This is an expected hardware behavior and reading the Tx stats
needs to be handled accordingly in the driver. Update the driver to
read Tx stats from the PRU1 for port0 and PRU0 for port1.

Fixes: c1e10d5dc7a1 ("net: ti: icssg-prueth: Add ICSSG Stats")
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250603052904.431203-1-m-malladi@ti.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/ti/icssg/icssg_stats.c

index 6f0edae38ea242394d9e92e6a0d0cd9736e9b448..172ae38381b453a8ffb5f6ac3041dd86aceaccd0 100644 (file)
@@ -29,6 +29,14 @@ void emac_update_hardware_stats(struct prueth_emac *emac)
        spin_lock(&prueth->stats_lock);
 
        for (i = 0; i < ARRAY_SIZE(icssg_all_miig_stats); i++) {
+               /* In MII mode TX lines are swapped inside ICSSG, so read Tx stats
+                * from slice1 for port0 and slice0 for port1 to get accurate Tx
+                * stats for a given port
+                */
+               if (emac->phy_if == PHY_INTERFACE_MODE_MII &&
+                   icssg_all_miig_stats[i].offset >= ICSSG_TX_PACKET_OFFSET &&
+                   icssg_all_miig_stats[i].offset <= ICSSG_TX_BYTE_OFFSET)
+                       base = stats_base[slice ^ 1];
                regmap_read(prueth->miig_rt,
                            base + icssg_all_miig_stats[i].offset,
                            &val);