mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>,
	<UNGLinuxDriver@microchip.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	Daniel Machon <daniel.machon@microchip.com>,
	"Steen Hegelund" <Steen.Hegelund@microchip.com>,
	Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Robert Marko <robert.marko@sartura.hr>,
	Eric Dumazet <edumazet@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-hardening@vger.kernel.org,
	"Jens Emil Schulz Østergaard"
	<jensemil.schulzostergaard@microchip.com>
Subject: [PATCH net-next v3 0/3] net: sparx5: add router legs for L3 routing offload
Date: Tue, 17 Nov 2026 14:17:36 +0100	[thread overview]
Message-ID: <20261117-sparx5_l3_routing-v3-0-e680ed79c7dc@microchip.com> (raw)

This is the first series adding L3 unicast routing offload for IPv4
and IPv6 to Sparx5 and LAN969x. It adds the routing registers and
the router legs, the hardware interfaces where routing happens. No
route is offloaded yet. Routing is enabled in the chip, but with no LPM
rule a routed frame misses the lookup and is redirected to the CPU, so
the kernel keeps routing every frame in software.

The chips only route in VLAN aware mode. A router leg is created for a
direct VLAN upper of the offloaded bridge when it gets its first
address, provided the upper qualifies for hardware routing: a non-zero
vid, the bridge VLAN protocol, the bridge MAC and no master. Any other
configuration is routed in software as usual.

Patch 1 adds the register macros for the L3 routing blocks.

Patch 2 adds the router legs, their lifecycle on address events, the
global leg base MAC and the hardware enable sequence.

Patch 3 keeps the legs in sync with the bridge. A transition that would
leave the hardware and kernel routing differently drops the leg instead
of being refused, and the leg is recreated once the upper qualifies.
It also follows bridge MAC and vid changes and the upper going down, and
recreates the legs when a switch port joins the bridge again.

The plan for future series building on this one:

  2: track FIB entries and trap them to the CPU, with the LPM VCAP
  3: main and local table arbitration, FIB rule refusal and neighbour
     host routes
  4: forwarding through a single nexthop, ECMP and blackhole routes
  5: routes through nexthop objects

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 <jensemil.schulzostergaard@microchip.com>
---
Changes in v3:
- Split the series. The router code is now rebuilt as smaller series.
  This series keeps the registers and the router legs. The VCAP
  preparation moves to the second series.
- Tighten which device may carry a router leg: a direct VLAN upper of
  the bridge whose ports are offloaded, without a master of its own,
  with a non-zero vid, the bridge VLAN protocol and the bridge MAC.
- Follow the transitions that would leave the chip and kernel out of
  sync: enslaving a leg to any master, changing its MAC, and disabling
  vlan_filtering or changing the VLAN protocol on its bridge drop the
  leg, which is created again when the upper qualifies.
- Destroy a leg created from the address validator when the address add
  fails afterwards, and handle IPv6 address removal from a work embedded
  in the router rather than one allocated per event.
- Keep addresses when a leg cannot be created, and route that upper
  in software.
- Disable a leg as an ingress router leg while its upper is down or the
  bridge does not carry its vid.
- Flush the legs of a bridge when its last switch port leaves and
  recreate them on rejoin.
- Program the leg base MAC from the bridge MAC when a leg is created,
  not only when the bridge MAC changes.
- Enable unicast routing only on the switch ports, and restore the
  routing registers when the router is torn down.
- Carry on without offload when the router cannot initialise, rather
  than failing the probe, and skip the router without CONFIG_VLAN_8021Q.
- Remove the blackhole leg and the IPv6 link-local trap.
- Link to v2: https://lore.kernel.org/r/20260810-sparx5_l3_routing-v2-0-59e68cc8c8ca@microchip.com

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

---
Jens Emil Schulz Østergaard (3):
      net: sparx5: add l3 routing registers
      net: sparx5: add L3 router legs
      net: sparx5: keep router legs in sync with the bridge

 drivers/net/ethernet/microchip/sparx5/Makefile     |   2 +-
 .../ethernet/microchip/sparx5/lan969x/lan969x.c    |   1 +
 .../microchip/sparx5/lan969x/lan969x_regs.c        |  11 +
 .../net/ethernet/microchip/sparx5/sparx5_main.c    |  13 +-
 .../net/ethernet/microchip/sparx5/sparx5_main.h    |  37 +
 .../ethernet/microchip/sparx5/sparx5_main_regs.h   | 528 ++++++++++++
 .../net/ethernet/microchip/sparx5/sparx5_regs.c    |  11 +
 .../net/ethernet/microchip/sparx5/sparx5_regs.h    |  11 +
 .../net/ethernet/microchip/sparx5/sparx5_router.c  | 913 +++++++++++++++++++++
 .../ethernet/microchip/sparx5/sparx5_switchdev.c   |  30 +-
 .../net/ethernet/microchip/sparx5/sparx5_vlan.c    |   2 +
 11 files changed, 1554 insertions(+), 5 deletions(-)
---
base-commit: 6ff4c5942a301675eb12e5b49d53a81e604624a1
change-id: 20260210-sparx5_l3_routing-962458e4d3da

Best regards,
-- 
Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>


             reply	other threads:[~2026-11-17 13:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 13:17 Jens Emil Schulz Østergaard [this message]
2026-11-17 13:17 ` [PATCH net-next v3 1/3] net: sparx5: add l3 routing registers Jens Emil Schulz Østergaard
2026-11-17 13:17 ` [PATCH net-next v3 2/3] net: sparx5: add L3 router legs Jens Emil Schulz Østergaard
2026-11-17 13:17 ` [PATCH net-next v3 3/3] net: sparx5: keep router legs in sync with the bridge Jens Emil Schulz Østergaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117-sparx5_l3_routing-v3-0-e680ed79c7dc@microchip.com \
    --to=jensemil.schulzostergaard@microchip.com \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=horatiu.vultur@microchip.com \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robert.marko@sartura.hr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®