Switchdev: the Linux switching framework – Bert Vermeulen

An Ethernet switch forwards Ethernet frames. It uses a forwarding database (FDB) to decide to which port(s) a frame has to be sent, based on the MAC address. There are timers to make sure the FDB stays up to date. Then came VLANs to isolate virtual networks from each other, and to assign priorities.

The kernel has been able to emulate a switch for a long time with a bridge. But everything is done by the CPU, so it’s not very efficient. Hardware switches have specialised memory for fast FDB lookup and high-bandwidth forwarding paths.

OpenWRT started to be able to configure the switch chips on commercial routers. Basically the OS configures the FDB in the switch – the frames never end up on the CPU. The vendor software isn’t usable because it’s hacky (nothing standardized, custom userspace programs). For different platforms, wildly different things have to be done. swconfig adds an abstraction layer (mostly in kernel, with a bit of userspace tooling). However, it was never upstreamed – when it was attempted, the competing DSA feature was being upstreamed as well.

DSA is based on Marvell chips but it’s pretty generic. DSA exposes each Ethernet port as an actual NIC. When ports are configured in a bridge, the kernel will configure the switching in hardware instead of using the software bridge. So the existing brctl etc. just work. The problem with it is that it is limited to MDIO only, other buses were not possible.

switchdev is a proper kernel subsystem that can be used on any bus, e.g. it can be created for a PCIe device. It is more generic than DSA – DSA was reconverted into a switchdev driver. DSA is now more or less the MDIO part of switchdev.

switchdev implements the FDB support, multicast routing, VLAN configuration.

DSA was for a long time the only switchdev device. Recently the Mellanox Switch X-2 was added (6.4Tbps total 32×32 100Gbps switch).

The interface can be found in include/linux/switchdev.h



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s