[PATCH net-next V2 0/7] devlink: Add boot-time eswitch mode defaults

From: Mark Bloch

Date: Wed Jun 03 2026 - 15:38:23 EST


This series adds a devlink_eswitch_mode= kernel command line parameter for
applying a default devlink eswitch mode during device initialization.

Following the discussion with Jakub[1] and the feedback on the RFC
postings, this version keeps the scope limited to a boot-time devlink
eswitch mode default only.

The option selects either all devlink handles or an explicit comma
separated handle list:

devlink_eswitch_mode=[*]:switchdev
devlink_eswitch_mode=[pci/0000:08:00.0,pci/0000:09:00.1]:switchdev_inactive

The supported modes are legacy, switchdev and switchdev_inactive. The
selected mode is applied through the existing eswitch_mode_set() devlink
operation, the same operation used by the devlink eswitch mode command.

The preparatory patches move registration points that expose the devlink
instance before the driver is ready for a registration-time eswitch mode
change. Where registration is moved later, the matching unregister path is
moved earlier so unregister notifications are sent from devl_unregister()
before object teardown. The final patch adds the parser and applies the
default from devlink core when a matching instance is registered and after
a successful devlink reload that performed DRIVER_REINIT.

Patch 1 skips devlink health recovery notifications while a devlink
instance is not registered. Health state and counters are still updated,
but there is no registered instance for userspace to observe or receive
notifications from yet. This lets drivers move registration later without
hitting health notification registration assertions during early
initialization.

Patch 2 moves netdevsim devlink registration after device initialization,
so registration-time defaults can call eswitch_mode_set() after simulator
state is ready. It also unregisters devlink before netdevsim tears down the
objects that were registered before devlink became visible.

Patch 3 clears the mlx5 FW reset-in-progress bit before reloading after a
firmware reset.

Patch 4 moves mlx5 devlink registration after device initialization,
including the lightweight init path, and moves unregister before the
matching teardown.

Patch 5 moves octeontx2 AF devlink registration after SR-IOV setup and
switch lock initialization.

Patch 6 moves octeontx2 PF devlink registration after PF SR-IOV state
setup.

Patch 7 adds the devlink_eswitch_mode= parser, documentation,
registration-time default application and successful reload default
application.

Changelog:

v1 -> v2:

- Move default eswitch mode application into devlink core. The default is
now applied during devlink registration and after a successful devlink
reload that performed DRIVER_REINIT.

- Remove the exported devl_apply_default_esw_mode() driver API and the mlx5
driver-side call to it.

- Skip devlink health recovery notifications while the devlink instance is
not registered, so drivers can move registration later without early
health work hitting registration assertions.

- Move mlx5 devlink registration after device initialization, including the
lightweight init path, so the core can apply the default through the
normal registration flow.

- Move the matching netdevsim and mlx5 unregister paths before object
teardown, so unregister notifications come from devl_unregister() and the
later object teardown paths run while the devlink instance is no longer
registered.

- Add registration-ordering preparation patches for netdevsim and octeontx2
AF/PF, so their eswitch state is ready before registration-time defaults
may call eswitch_mode_set().

[1] https://lore.kernel.org/all/20260502184153.4fd8d06f@xxxxxxxxxx/
RFC V1 : https://lore.kernel.org/all/20260506123739.1959770-1-mbloch@xxxxxxxxxx/
RFC V2 : https://lore.kernel.org/all/20260510185424.2041415-1-mbloch@xxxxxxxxxx/
v1 : https://lore.kernel.org/all/20260521072434.362624-1-tariqt@xxxxxxxxxx/

Signed-off-by: Mark Bloch <mbloch@xxxxxxxxxx>

Mark Bloch (7):
devlink: Skip health recover notifications before register
netdevsim: Register devlink after device init
net/mlx5: Clear FW reset-in-progress bit before reload
net/mlx5: Register devlink after device init
octeontx2-af: Register devlink after SR-IOV init
octeontx2-pf: Register devlink after SR-IOV state init
devlink: Add eswitch mode boot defaults

.../admin-guide/kernel-parameters.txt | 25 ++
.../networking/devlink/devlink-defaults.rst | 80 ++++++
Documentation/networking/devlink/index.rst | 1 +
.../net/ethernet/marvell/octeontx2/af/rvu.c | 24 +-
.../ethernet/marvell/octeontx2/nic/otx2_pf.c | 17 +-
.../ethernet/mellanox/mlx5/core/fw_reset.c | 28 +-
.../net/ethernet/mellanox/mlx5/core/main.c | 34 ++-
drivers/net/netdevsim/dev.c | 15 +-
net/devlink/core.c | 261 ++++++++++++++++++
net/devlink/dev.c | 3 +
net/devlink/devl_internal.h | 1 +
net/devlink/health.c | 3 +-
12 files changed, 443 insertions(+), 49 deletions(-)
create mode 100644 Documentation/networking/devlink/devlink-defaults.rst


base-commit: dfcc2ff12925d99e858eaf539eaa4aaaf81fe2a6
--
2.34.1