• Vladimir Oltean's avatar
    net: mscc: ocelot: add TX_MM_HOLD to ocelot_mm_stats_layout · 5291099e
    Vladimir Oltean authored
    The lack of a definition for this counter is what initially prompted me
    to investigate a problem which really manifested itself as the previous
    change, "net: mscc: ocelot: fix transfer from region->buf to ocelot->stats".
    
    When TX_MM_HOLD is defined in enum ocelot_stat but not in struct
    ocelot_stat_layout ocelot_mm_stats_layout, this creates a hole, which
    due to the aforementioned bug, makes all counters following TX_MM_HOLD
    be recorded off by one compared to their correct position. So for
    example, a non-zero TX_PMAC_OCTETS would be reported as TX_MERGE_FRAGMENTS,
    TX_PMAC_UNICAST would be reported as TX_PMAC_OCTETS, TX_PMAC_64 would be
    reported as TX_PMAC_PAUSE, etc etc. This is because the size of the hole
    (1) is much smaller than the size of the region, so the phenomenon where
    the stats are off-by-one, rather than lost, prevails.
    
    However, the phenomenon where stats are lost can be seen too, for
    example with DROP_LOCAL, which is at the beginning of its own region
    (offset 0x000400 vs the previous 0x0002b0 constitutes a discontinuity).
    This is also reported as off by one and saved to TX_PMAC_1527_MAX, but
    that counter is not reported to the unstructured "ethtool -S", as
    opposed to DROP_LOCAL which is (as "drop_local").
    
    Fixes: ab3f97a9 ("net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959")
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    5291099e
ocelot_stats.c 31.5 KB