devlink: Add boot-time defaults
Subsystems (6)
Mark Bloch
maintainerv2 cover devlink: Add boot-time defaults
This series adds a devlink= kernel command line parameter for applying selected devlink settings during device initialization.
Following a discussion with Jakub[1], I am sending this RFC to get the conversation moving. I started from Jakub's example/request and extended it to cover requirements from production systems and configurations that customers use. The implementation is intended to support the following properties:
- A system may have multiple devlink devices that usually need the same configuration. For a configuration such as eswitch mode switchdev, a user can specify either all devlink devices or an explicit list of devices to which that configuration applies.
- Deployments can set devlink defaults before normal userspace orchestration runs, while still using devlink concepts and driver callbacks rather than adding driver-specific module parameters.
A default is scoped to either all devlink handles or to a comma-separated list of devlink handles, for example:
devlink=[*]:esw:mode:switchdev devlink=[pci/0000:08:00.0,pci/0000:09:00.1]:esw:mode:switchdev_inactive
The first supported command is eswitch mode configuration.
mlx5 wires this into device initialization after the devlink instance is registered and after mlx5 devlink operations are available, so eswitch mode defaults can be applied to matching PCI devlink devices.
Patch 1 adds the devlink boot-default parser, storage, devl_apply_defaults() API, eswitch mode default support and documentation for the devlink= syntax.
Patch 2 calls devl_apply_defaults() from mlx5 device initialization.
Changelog:
V1 -> V2
- Reduced the series from 4 patches to 2 patches by folding the generic boot default infrastructure and eswitch mode support into one devlink patch.
- Narrowed the scope to eswitch mode defaults only. Dropped runtime devlink parameter boot defaults and simplified parser.
- Added [*] selector support to apply the same eswitch mode default to all devlink instances.
- Removed support for multiple comma-separated default groups and for assigning different defaults to different handles in the same devlink= parameter.
[1] https://lore.kernel.org/all/[email protected]/
V1 : https://lore.kernel.org/all/[email protected]/
Mark Bloch (2):
devlink: Add eswitch mode boot defaults net/mlx5: Apply devlink boot defaults during init
.../admin-guide/kernel-parameters.txt | 24 ++ .../networking/devlink/devlink-defaults.rst | 93 ++++++ Documentation/networking/devlink/index.rst | 1 + .../net/ethernet/mellanox/mlx5/core/main.c | 2 + include/net/devlink.h | 1 + net/devlink/core.c | 269 ++++++++++++++++++ 6 files changed, 390 insertions(+) create mode 100644 Documentation/networking/devlink/devlink-defaults.rst
base-commit: a93245816556ba03549bb626de48ea2b11c7f9d2
Signature · 1 line
2.34.1
Mark Bloch
maintainerRFC v2 1/2 devlink: Add eswitch mode boot defaults
Add devlink= kernel command line support for configuring devlink eswitch mode during device initialization.
The supported syntax selects either all devlink handles or one explicit comma-separated handle list:
devlink=[*]:esw:mode:<mode> devlink=[<handle>[,<handle>...]]:esw:mode:<mode>
where <mode> is one of legacy, switchdev or switchdev_inactive. All selected handles receive the same mode. Comma-separated default groups are not supported.
The default is applied through the existing eswitch_mode_set() devlink operation, matching the userspace devlink eswitch set command.
Document the devlink= syntax and duplicate handle handling.
--- .../admin-guide/kernel-parameters.txt | 24 ++ .../networking/devlink/devlink-defaults.rst | 93 ++++++ Documentation/networking/devlink/index.rst | 1 + include/net/devlink.h | 1 + net/devlink/core.c | 269 ++++++++++++++++++ 5 files changed, 388 insertions(+) create mode 100644 Documentation/networking/devlink/devlink-defaults.rst
Documentation/admin-guide/kernel-parameters.txt +24 -0
@@ -1278,6 +1278,30 @@ Kernel parameters dell_smm_hwmon.fan_max= [HW] Maximum configurable fan speed. + devlink= [NET] + Format: + [<selector>]:esw:mode:<mode> + + <selector>: + * | <handle>[,<handle>...] + + <handle>: + <bus-name>/<dev-name> + + Configure default devlink settings for matching + devlink instances during device initialization. + + Currently supported settings: + esw:mode:{ legacy | switchdev | switchdev_inactive } + + Examples: + devlink=[*]:esw:mode:switchdev + devlink=[pci/0000:08:00.0]:esw:mode:switchdev + devlink=[pci/0000:08:00.0,pci/0000:09:00.1]:esw:mode:legacy + + See Documentation/networking/devlink/devlink-defaults.rst + for the full syntax. + dfltcc= [HW,S390] Format: { on | off | def_only | inf_only | always } on: s390 zlib hardware support for compression on
Documentation/networking/devlink/devlink-defaults.rst new file +93 -0
93 lines not on this page · raw message
Documentation/networking/devlink/index.rst +1 -0
@@ -56,6 +56,7 @@ general. :maxdepth: 1 devlink-dpipe + devlink-defaults devlink-eswitch-attr devlink-flash devlink-health
include/net/devlink.h +1 -0
@@ -1622,6 +1622,7 @@ int devl_trylock(struct devlink *devlink);void devl_unlock (struct devlink *devlink);void devl_assert_locked (struct devlink *devlink);bool devl_lock_is_held (struct devlink *devlink); +int devl_apply_defaults (struct devlink *devlink); DEFINE_GUARD(devl, struct devlink *, devl_lock(_T), devl_unlock(_T));struct ib_device ;
net/devlink/core.c +269 -0
294 lines not on this page · raw message
Signature · 1 line
2.34.1
Mark Bloch
maintainerRFC v2 2/2 net/mlx5: Apply devlink boot defaults during init
In reply to Mark BlochApply devlink boot defaults for mlx5 devices after successful device initialization while holding the devlink instance lock.
At this point the devlink instance is registered and the mlx5 devlink operations are available, so eswitch mode defaults can be applied to the matching PCI devlink handle.
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/main.c +2 -0
@@ -1470,6 +1470,8 @@ int mlx5_init_one(struct mlx5_core_dev *dev) err =mlx5_init_one_devl_locked (dev);if (err)devl_unregister (devlink); +else +devl_apply_defaults (devlink); unlock:devl_unlock (devlink);return err;
Signature · 1 line
2.34.1