[PATCH net-next v2 0/9] net: sparx5: add L3 unicast routing offload
From: Jens Emil Schulz Østergaard <hidden>
Date: 2026-08-10 11:23:43
Also in:
linux-arm-kernel, linux-hardening, lkml
Add L3 unicast route offloading for IPv4 and IPv6 on Sparx5 and
LAN969x. This enables hardware-accelerated l3 routing between VLAN
upper interfaces on a bridge, with ECMP support.
This series covers the core unicast data path: FIB offload, nexthop
groups, ARP/NDP neighbour resolution, and router leg management.
Routes are programmed into the hardware LPM (Longest Prefix Match)
VCAP, with nexthops resolved through the hardware ARP table for ECMP
or inline VCAP actions for single nexthops.
The LPM VCAP also requires type_id-aware rule decoding, since it has
actionsets of identical length that differ only in their type_id
field.
Patch 1 fixes a latent bug in the VCAP rule-move algorithm that
becomes reachable once the LPM VCAP is added, since LPM is the first
VCAP to use rules of coprime size (2 and 3).
Patches 2-4 are the remaining preparatory commits for the shared VCAP
API. They add the LPM VCAP keysets and actionsets to the autogenerated
model for lan969x and sparx5, update the action-side rule decoder to
differentiate actionsets by type_id, and expose two helpers
(vcap_val_add_rule() and vcap_rule_mod_action_bit()) used by the LPM
driver.
Patch 5 adds autogenerated register macros for the L3 routing blocks
on sparx5 and lan969x.
Patch 6 adds the LPM VCAP implementation for sparx5 and lan969x.
Patches 7-9 add L3 unicast routing to sparx5 and lan969x. The router
code is split into three patches:
Patch 7 (infrastructure + legs): Router leg lifecycle tied to VLAN
uppers on a bridge, address event handling, base MAC tracking,
blackhole leg for blackhole routes, and the hardware enable sequence.
Patch 8 (FIB + nexthop + neighbour CRUD): This is a large patch.
Splitting it further is difficult because the neighbour and nexthop CRUD
is shared between the leg-teardown path and the neighbour-event path: leg
teardown flushes the legs neighbours and refreshes their dependent
nexthops, and the NETEVENT_NEIGH_UPDATE handler in patch 9 drives the
same helpers.
Patch 9 (neighbour events): Registers the netevent notifier for
NETEVENT_NEIGH_UPDATE used in ARP/NDP resolution, wiring up the final
piece.
The Super VCAP shared-register race reported on v1 is fixed separately by
commit d7a8d500d7e4 ("net: microchip: vcap: fix races on the shared Super
VCAP block"), which is now in net-next.
Signed-off-by: Jens Emil Schulz Østergaard <redacted>
---
Changes in v2:
- Reworked neighbour lifetime: anchor neighbours to the router leg
instead of the most-specific covering FIB entry (matching
mlxsw/prestera). Fixes a neighbour-entry leak (memory + VMID + host
VCAP rule + netdev reference) and lets the software LPM be removed
entirely.
- Fixed a heap overflow in the fib6 nexthop prune path.
- Fixed a leak on the router_init() error path.
- Hardening: netns filtering and offload-ownership checks on the global
notifiers, and a NETDEV_UNREGISTER leg-teardown backstop.
- Fixed do_div() misuse on a 32-bit value. Added the missing RCU
annotation on in_dev->ifa_list.
- Zero-initialise the actionfield data in vcap_rule_mod_action_bit().
- Updated the sparx5_router.c header comment to describe the
leg-anchored model.
- Link to v1: https://lore.kernel.org/r/20260612-sparx5_l3_routing-v1-0-fc3c10160f49@microchip.com (local)
---
Jens Emil Schulz Østergaard (9):
net: microchip: vcap: fix rule move for rules of coprime size
net: microchip: vcap: add lpm vcap to autogen vcap api
net: microchip: vcap: make vcap actionset decoding type_id aware
net: microchip: vcap: expose helpers in vcap api and update debugfs
net: sparx5: add l3 routing registers
net: sparx5: vcap: add lpm vcap implementation
net: sparx5: add L3 router infrastructure and leg management
net: sparx5: add L3 FIB, nexthop and neighbour entry management
net: sparx5: add neighbour event handling for L3 routing
drivers/net/ethernet/microchip/sparx5/Makefile | 2 +-
.../ethernet/microchip/sparx5/lan969x/lan969x.c | 2 +
.../microchip/sparx5/lan969x/lan969x_regs.c | 20 +-
.../microchip/sparx5/lan969x/lan969x_vcap_ag_api.c | 373 ++-
.../microchip/sparx5/lan969x/lan969x_vcap_impl.c | 12 +
.../net/ethernet/microchip/sparx5/sparx5_main.c | 13 +-
.../net/ethernet/microchip/sparx5/sparx5_main.h | 44 +
.../ethernet/microchip/sparx5/sparx5_main_regs.h | 691 ++++-
.../net/ethernet/microchip/sparx5/sparx5_regs.c | 20 +-
.../net/ethernet/microchip/sparx5/sparx5_regs.h | 20 +-
.../net/ethernet/microchip/sparx5/sparx5_router.c | 3021 ++++++++++++++++++++
.../ethernet/microchip/sparx5/sparx5_vcap_ag_api.c | 373 ++-
.../ethernet/microchip/sparx5/sparx5_vcap_ag_api.h | 6 +-
.../ethernet/microchip/sparx5/sparx5_vcap_impl.c | 159 +-
.../ethernet/microchip/sparx5/sparx5_vcap_impl.h | 5 +
drivers/net/ethernet/microchip/vcap/vcap_ag_api.h | 94 +-
drivers/net/ethernet/microchip/vcap/vcap_api.c | 219 +-
drivers/net/ethernet/microchip/vcap/vcap_api.h | 4 +-
.../net/ethernet/microchip/vcap/vcap_api_client.h | 6 +
.../net/ethernet/microchip/vcap/vcap_api_debugfs.c | 13 +-
.../net/ethernet/microchip/vcap/vcap_api_kunit.c | 81 +-
.../net/ethernet/microchip/vcap/vcap_model_kunit.c | 6 +-
22 files changed, 5047 insertions(+), 137 deletions(-)
---
base-commit: 001b5d347d8ba39b2dccaefcc57967b18caec8fe
change-id: 20260210-sparx5_l3_routing-962458e4d3da
Best regards,
--
Jens Emil Schulz Østergaard [off-list ref]