[PATCH net-next v2 0/5] net: sparx5: add tc matchall port policer offload
Daniel Machon
daniel.machon at microchip.com
Mon Nov 2 04:21:23 PST 2026
This series adds offload of tc matchall filters with a police action to
the ingress port policers of Sparx5 and lan969x, which are both served
by the sparx5 driver.
In hardware, each ingress port has four single-rate leaky bucket
policers. A policer drops the frames that exceed its rate and burst.
The four policers of a port share the pass and drop statistics counters
of the port.
The driver uses one policer per port, because with more than one, the
statistics reported to tc could not be attributed to the right policer.
This matches lan966x and ocelot. The policer meters each frame without
preamble and inter-frame gap, so the configured rate is a data rate, as
tc police expects and as on lan966x and ocelot.
Since the policer meters all ingress frames on the port, only filters on
chain 0 with protocol all are offloaded, and filters on shared blocks
are rejected. A police action that is already offloaded as a port
policer on another port is rejected too, since in software it is a
single bucket for all of its users. Only drop is supported as the exceed
action, and the police overhead parameter is not supported.
Patch #1 drops a redundant prefix from the existing POL_UPD_INT_CFG
register macros.
Patch #2 adds the registers used by the port policer.
Patch #3 tracks whether the ingress block of a port is shared, and adds
the per-port policer state.
Patch #4 adds the hardware programming of the port policer.
Patch #5 adds the tc matchall offload.
Signed-off-by: Daniel Machon <daniel.machon at microchip.com>
---
Changes in v2:
- Patch #4: meter the data rate, not the line rate, by setting the gap
to 0 instead of 20 bytes. Fix the commit message, which wrongly said
that lan966x and ocelot meter the line rate.
- Patch #4: take queue_stats_lock around the existing ethtool read of
port stat counter 0, since reading the LSB latches the MSB.
- Patch #4: correct the comment on the traffic type mask.
- Patch #4: reject a packets-per-second police as unsupported before
checking for a missing byte rate, so the right message is reported.
- Patch #5: reject a police action that is already offloaded as a port
policer on another port.
- Link to v1: https://lore.kernel.org/r/20261009-b4-lan966x-pci-fdma-sparx5-lan969x-port-policers-v1-0-4916708a7ea2@microchip.com
---
Daniel Machon (5):
net: sparx5: Drop redundant POL_ prefix from POL_UPD_INT_CFG
net: sparx5: Add registers used by the port policer
net: sparx5: Track shared tc blocks and per-port policer state
net: sparx5: Add hardware programming for the port policer
net: sparx5: Offload tc port policers via matchall
.../microchip/sparx5/lan969x/lan969x_regs.c | 7 +
.../net/ethernet/microchip/sparx5/sparx5_ethtool.c | 6 +
.../net/ethernet/microchip/sparx5/sparx5_main.c | 6 +-
.../net/ethernet/microchip/sparx5/sparx5_main.h | 39 +-
.../ethernet/microchip/sparx5/sparx5_main_regs.h | 117 +++++-
.../net/ethernet/microchip/sparx5/sparx5_police.c | 431 ++++++++++++++++++++-
drivers/net/ethernet/microchip/sparx5/sparx5_qos.c | 4 +
.../net/ethernet/microchip/sparx5/sparx5_regs.c | 7 +
.../net/ethernet/microchip/sparx5/sparx5_regs.h | 7 +
drivers/net/ethernet/microchip/sparx5/sparx5_tc.c | 14 +-
.../ethernet/microchip/sparx5/sparx5_tc_matchall.c | 39 ++
11 files changed, 663 insertions(+), 14 deletions(-)
---
base-commit: 4dd16e31135ea8437a720222df34e8745f385d6d
change-id: 20260930-b4-lan966x-pci-fdma-sparx5-lan969x-port-policers-474610756e26
Best regards,
--
Daniel Machon <daniel.machon at microchip.com>
More information about the linux-arm-kernel
mailing list