[PATCH net-next 00/14] Standardized ethtool counters for Felix DSA driver

From: Vladimir Oltean
Date: Thu Sep 08 2022 - 12:48:53 EST


The main purpose of this change set is to add reporting of structured
ethtool statistics counters to the felix DSA driver (see patch 11/14 for
details), as a prerequisite for extending these counters to the
eMAC/pMAC defined by the IEEE MAC Merge layer.

Along the way, the main purpose has diverged into multiple sub-purposes
which are also tackled:

- A bug fix patch submitted to "net" has made ocelot->stats_lock a spin
lock, which is not an issue currently (all Ocelot switches are MMIO),
but will be an issue for Colin Foster who is working on a SPI
controlled Ocelot switch. We restore the hardware access to port stats
to be sleepable.

- PSFP (tc-gate, tc-police) tc-flower stats on Felix use a non-converged
procedure to access the hardware counters, although the interface is
very similar to what is used for the port counters. Benefit from the
logic used for the port counters, which gains us 64-bit tc-flower
stats that are resistant to overflows.

- Also export the ndo_get_stats64 method used by the ocelot switchdev
driver to Felix, so that ifconfig sees something hardware-based as
well (but not 100% up to date).

- Create a new ocelot_stats.c file which groups everything stats-related
together. Along with this, also move some other topic-specific code,
like FDB and PTP, out of the main ocelot.c.

- Minimize the lines of code for the stats layout definitions. These
changes alone cause the patch set to have an overall reduction of
lines of code in the driver, even though we are adding new
functionality as well.

Tested the port counters with lockdep and friends, with some
garden-variety traffic (ping, iperf3) and the PSFP counters with
tools/testing/selftests/drivers/net/ocelot/psfp.sh.

Vladimir Oltean (14):
net: dsa: felix: add definitions for the stream filter counters
net: mscc: ocelot: make access to STAT_VIEW sleepable again
net: dsa: felix: check the 32-bit PSFP stats against overflow
net: mscc: ocelot: report FIFO drop counters through stats->rx_dropped
net: mscc: ocelot: sort Makefile files alphabetically
net: mscc: ocelot: move stats code to ocelot_stats.c
net: mscc: ocelot: unexport ocelot_port_fdb_do_dump from the common
lib
net: mscc: ocelot: move more PTP code from the lib to ocelot_ptp.c
net: dsa: felix: use ocelot's ndo_get_stats64 method
net: mscc: ocelot: exclude stats from bulk regions based on reg, not
name
net: mscc: ocelot: add support for all sorts of standardized counters
present in DSA
net: mscc: ocelot: harmonize names of SYS_COUNT_TX_AGING and
OCELOT_STAT_TX_AGED
net: mscc: ocelot: minimize definitions for stats
net: mscc: ocelot: share the common stat definitions between all
drivers

drivers/net/dsa/ocelot/felix.c | 55 ++
drivers/net/dsa/ocelot/felix_vsc9959.c | 509 +++------------
drivers/net/dsa/ocelot/seville_vsc9953.c | 376 +----------
drivers/net/ethernet/mscc/Makefile | 11 +-
drivers/net/ethernet/mscc/ocelot.c | 707 +--------------------
drivers/net/ethernet/mscc/ocelot.h | 12 +-
drivers/net/ethernet/mscc/ocelot_net.c | 88 +--
drivers/net/ethernet/mscc/ocelot_ptp.c | 481 ++++++++++++++
drivers/net/ethernet/mscc/ocelot_stats.c | 458 +++++++++++++
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 373 +----------
drivers/net/ethernet/mscc/vsc7514_regs.c | 3 +-
include/soc/mscc/ocelot.h | 138 +++-
12 files changed, 1293 insertions(+), 1918 deletions(-)
create mode 100644 drivers/net/ethernet/mscc/ocelot_stats.c

--
2.34.1