]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: mscc: ocelot: fix incorrect ndo_get_stats64 packet counters
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 16 Aug 2022 13:53:46 +0000 (16:53 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Aug 2022 04:58:30 +0000 (21:58 -0700)
Reading stats using the SYS_COUNT_* register definitions is only used by
ocelot_get_stats64() from the ocelot switchdev driver, however,
currently the bucket definitions are incorrect.

Separately, on both RX and TX, we have the following problems:
- a 256-1023 bucket which actually tracks the 256-511 packets
- the 1024-1526 bucket actually tracks the 512-1023 packets
- the 1527-max bucket actually tracks the 1024-1526 packets

=> nobody tracks the packets from the real 1527-max bucket

Additionally, the RX_PAUSE, RX_CONTROL, RX_LONGS and RX_CLASSIFIED_DROPS
all track the wrong thing. However this doesn't seem to have any
consequence, since ocelot_get_stats64() doesn't use these.

Even though this problem only manifests itself for the switchdev driver,
we cannot split the fix for ocelot and for DSA, since it requires fixing
the bucket definitions from enum ocelot_reg, which makes us necessarily
adapt the structures from felix and seville as well.

Fixes: a83ee1de50e3 ("net: dsa: felix: introduce support for Seville VSC9953 switch")
Fixes: 34efb4cbfb94 ("net: dsa: ocelot: add driver for Felix switch family")
Fixes: 1bed22a67906 ("net: mscc: Add initial Ocelot switch support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/ocelot/felix_vsc9959.c
drivers/net/dsa/ocelot/seville_vsc9953.c
drivers/net/ethernet/mscc/ocelot_net.c
drivers/net/ethernet/mscc/vsc7514_regs.c
include/soc/mscc/ocelot.h

index 5859ef3b242c0b84400d733755c62cbcc0bceffd..e1ebe21cad0078752a5de94ccff11f78224df61a 100644 (file)
@@ -281,19 +281,23 @@ static const u32 vsc9959_sys_regmap[] = {
        REG(SYS_COUNT_RX_64,                    0x000024),
        REG(SYS_COUNT_RX_65_127,                0x000028),
        REG(SYS_COUNT_RX_128_255,               0x00002c),
-       REG(SYS_COUNT_RX_256_1023,              0x000030),
-       REG(SYS_COUNT_RX_1024_1526,             0x000034),
-       REG(SYS_COUNT_RX_1527_MAX,              0x000038),
-       REG(SYS_COUNT_RX_LONGS,                 0x000044),
+       REG(SYS_COUNT_RX_256_511,               0x000030),
+       REG(SYS_COUNT_RX_512_1023,              0x000034),
+       REG(SYS_COUNT_RX_1024_1526,             0x000038),
+       REG(SYS_COUNT_RX_1527_MAX,              0x00003c),
+       REG(SYS_COUNT_RX_PAUSE,                 0x000040),
+       REG(SYS_COUNT_RX_CONTROL,               0x000044),
+       REG(SYS_COUNT_RX_LONGS,                 0x000048),
        REG(SYS_COUNT_TX_OCTETS,                0x000200),
        REG(SYS_COUNT_TX_COLLISION,             0x000210),
        REG(SYS_COUNT_TX_DROPS,                 0x000214),
        REG(SYS_COUNT_TX_64,                    0x00021c),
        REG(SYS_COUNT_TX_65_127,                0x000220),
-       REG(SYS_COUNT_TX_128_511,               0x000224),
-       REG(SYS_COUNT_TX_512_1023,              0x000228),
-       REG(SYS_COUNT_TX_1024_1526,             0x00022c),
-       REG(SYS_COUNT_TX_1527_MAX,              0x000230),
+       REG(SYS_COUNT_TX_128_255,               0x000224),
+       REG(SYS_COUNT_TX_256_511,               0x000228),
+       REG(SYS_COUNT_TX_512_1023,              0x00022c),
+       REG(SYS_COUNT_TX_1024_1526,             0x000230),
+       REG(SYS_COUNT_TX_1527_MAX,              0x000234),
        REG(SYS_COUNT_TX_AGING,                 0x000278),
        REG(SYS_RESET_CFG,                      0x000e00),
        REG(SYS_SR_ETYPE_CFG,                   0x000e04),
index ea0649211356882c8aced655710cce6a190b6c5f..ebe9ddbbe2b77baaecfaa87dd4e6a0c3ec1033eb 100644 (file)
@@ -277,19 +277,21 @@ static const u32 vsc9953_sys_regmap[] = {
        REG(SYS_COUNT_RX_64,                    0x000024),
        REG(SYS_COUNT_RX_65_127,                0x000028),
        REG(SYS_COUNT_RX_128_255,               0x00002c),
-       REG(SYS_COUNT_RX_256_1023,              0x000030),
-       REG(SYS_COUNT_RX_1024_1526,             0x000034),
-       REG(SYS_COUNT_RX_1527_MAX,              0x000038),
+       REG(SYS_COUNT_RX_256_511,               0x000030),
+       REG(SYS_COUNT_RX_512_1023,              0x000034),
+       REG(SYS_COUNT_RX_1024_1526,             0x000038),
+       REG(SYS_COUNT_RX_1527_MAX,              0x00003c),
        REG(SYS_COUNT_RX_LONGS,                 0x000048),
        REG(SYS_COUNT_TX_OCTETS,                0x000100),
        REG(SYS_COUNT_TX_COLLISION,             0x000110),
        REG(SYS_COUNT_TX_DROPS,                 0x000114),
        REG(SYS_COUNT_TX_64,                    0x00011c),
        REG(SYS_COUNT_TX_65_127,                0x000120),
-       REG(SYS_COUNT_TX_128_511,               0x000124),
-       REG(SYS_COUNT_TX_512_1023,              0x000128),
-       REG(SYS_COUNT_TX_1024_1526,             0x00012c),
-       REG(SYS_COUNT_TX_1527_MAX,              0x000130),
+       REG(SYS_COUNT_TX_128_255,               0x000124),
+       REG(SYS_COUNT_TX_256_511,               0x000128),
+       REG(SYS_COUNT_TX_512_1023,              0x00012c),
+       REG(SYS_COUNT_TX_1024_1526,             0x000130),
+       REG(SYS_COUNT_TX_1527_MAX,              0x000134),
        REG(SYS_COUNT_TX_AGING,                 0x000178),
        REG(SYS_RESET_CFG,                      0x000318),
        REG_RESERVED(SYS_SR_ETYPE_CFG),
index 5e6136e80282b092bbf0bdb9220abce29913ad8f..9d8cea16245ef6445c77e32c44c038dc044e0217 100644 (file)
@@ -739,7 +739,8 @@ static void ocelot_get_stats64(struct net_device *dev,
                            ocelot_read(ocelot, SYS_COUNT_RX_64) +
                            ocelot_read(ocelot, SYS_COUNT_RX_65_127) +
                            ocelot_read(ocelot, SYS_COUNT_RX_128_255) +
-                           ocelot_read(ocelot, SYS_COUNT_RX_256_1023) +
+                           ocelot_read(ocelot, SYS_COUNT_RX_256_511) +
+                           ocelot_read(ocelot, SYS_COUNT_RX_512_1023) +
                            ocelot_read(ocelot, SYS_COUNT_RX_1024_1526) +
                            ocelot_read(ocelot, SYS_COUNT_RX_1527_MAX);
        stats->multicast = ocelot_read(ocelot, SYS_COUNT_RX_MULTICAST);
@@ -749,7 +750,8 @@ static void ocelot_get_stats64(struct net_device *dev,
        stats->tx_bytes = ocelot_read(ocelot, SYS_COUNT_TX_OCTETS);
        stats->tx_packets = ocelot_read(ocelot, SYS_COUNT_TX_64) +
                            ocelot_read(ocelot, SYS_COUNT_TX_65_127) +
-                           ocelot_read(ocelot, SYS_COUNT_TX_128_511) +
+                           ocelot_read(ocelot, SYS_COUNT_TX_128_255) +
+                           ocelot_read(ocelot, SYS_COUNT_TX_256_511) +
                            ocelot_read(ocelot, SYS_COUNT_TX_512_1023) +
                            ocelot_read(ocelot, SYS_COUNT_TX_1024_1526) +
                            ocelot_read(ocelot, SYS_COUNT_TX_1527_MAX);
index c2af4eb8ca5d345ad1df5ee5fdacdee124b101e2..38ab20b48cd439253ca071fe8bd3b3d92cd8e782 100644 (file)
@@ -180,13 +180,14 @@ const u32 vsc7514_sys_regmap[] = {
        REG(SYS_COUNT_RX_64,                            0x000024),
        REG(SYS_COUNT_RX_65_127,                        0x000028),
        REG(SYS_COUNT_RX_128_255,                       0x00002c),
-       REG(SYS_COUNT_RX_256_1023,                      0x000030),
-       REG(SYS_COUNT_RX_1024_1526,                     0x000034),
-       REG(SYS_COUNT_RX_1527_MAX,                      0x000038),
-       REG(SYS_COUNT_RX_PAUSE,                         0x00003c),
-       REG(SYS_COUNT_RX_CONTROL,                       0x000040),
-       REG(SYS_COUNT_RX_LONGS,                         0x000044),
-       REG(SYS_COUNT_RX_CLASSIFIED_DROPS,              0x000048),
+       REG(SYS_COUNT_RX_256_511,                       0x000030),
+       REG(SYS_COUNT_RX_512_1023,                      0x000034),
+       REG(SYS_COUNT_RX_1024_1526,                     0x000038),
+       REG(SYS_COUNT_RX_1527_MAX,                      0x00003c),
+       REG(SYS_COUNT_RX_PAUSE,                         0x000040),
+       REG(SYS_COUNT_RX_CONTROL,                       0x000044),
+       REG(SYS_COUNT_RX_LONGS,                         0x000048),
+       REG(SYS_COUNT_RX_CLASSIFIED_DROPS,              0x00004c),
        REG(SYS_COUNT_TX_OCTETS,                        0x000100),
        REG(SYS_COUNT_TX_UNICAST,                       0x000104),
        REG(SYS_COUNT_TX_MULTICAST,                     0x000108),
@@ -196,10 +197,11 @@ const u32 vsc7514_sys_regmap[] = {
        REG(SYS_COUNT_TX_PAUSE,                         0x000118),
        REG(SYS_COUNT_TX_64,                            0x00011c),
        REG(SYS_COUNT_TX_65_127,                        0x000120),
-       REG(SYS_COUNT_TX_128_511,                       0x000124),
-       REG(SYS_COUNT_TX_512_1023,                      0x000128),
-       REG(SYS_COUNT_TX_1024_1526,                     0x00012c),
-       REG(SYS_COUNT_TX_1527_MAX,                      0x000130),
+       REG(SYS_COUNT_TX_128_255,                       0x000124),
+       REG(SYS_COUNT_TX_256_511,                       0x000128),
+       REG(SYS_COUNT_TX_512_1023,                      0x00012c),
+       REG(SYS_COUNT_TX_1024_1526,                     0x000130),
+       REG(SYS_COUNT_TX_1527_MAX,                      0x000134),
        REG(SYS_COUNT_TX_AGING,                         0x000170),
        REG(SYS_RESET_CFG,                              0x000508),
        REG(SYS_CMID,                                   0x00050c),
index ac151ecc7f19f0e657ec2877e8734f00af7d6b27..e7e5b06deb2d84f72726feda518728338ca5553e 100644 (file)
@@ -335,7 +335,8 @@ enum ocelot_reg {
        SYS_COUNT_RX_64,
        SYS_COUNT_RX_65_127,
        SYS_COUNT_RX_128_255,
-       SYS_COUNT_RX_256_1023,
+       SYS_COUNT_RX_256_511,
+       SYS_COUNT_RX_512_1023,
        SYS_COUNT_RX_1024_1526,
        SYS_COUNT_RX_1527_MAX,
        SYS_COUNT_RX_PAUSE,
@@ -351,7 +352,8 @@ enum ocelot_reg {
        SYS_COUNT_TX_PAUSE,
        SYS_COUNT_TX_64,
        SYS_COUNT_TX_65_127,
-       SYS_COUNT_TX_128_511,
+       SYS_COUNT_TX_128_255,
+       SYS_COUNT_TX_256_511,
        SYS_COUNT_TX_512_1023,
        SYS_COUNT_TX_1024_1526,
        SYS_COUNT_TX_1527_MAX,