Skip to contentSkip to conversation

devlink: add generic max_sfs parameter and mlx5 support

PATCH Superseded Tariq Toukan 3 participants 6 messages May 17 – May 18

Subsystems (6)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

cover devlink: add generic max_sfs parameter and mlx5 support

Hi,

This series by Nikolay introduces a new generic devlink device parameter, max_sfs, to control the number of light-weight NIC subfunctions (SFs) that can be created on a device.

The first patch adds the generic devlink parameter and infrastructure support.
The second patch implements support for the parameter in the mlx5 driver.

With this addition, users can enable or disable SF creation directly via devlink, without relying on external vendor-specific tools.

Regards,
Tariq

Nikolay Aleksandrov (2):
devlink: add generic device max_sfs parameter
net/mlx5: implement max_sfs parameter

 .../networking/devlink/devlink-params.rst     |  6 ++
 Documentation/networking/devlink/mlx5.rst     |  7 +-
 .../mellanox/mlx5/core/lib/nv_param.c         | 83 ++++++++++++++++++-
 include/net/devlink.h                         |  4 +
 net/devlink/param.c                           |  5 ++
 5 files changed, 101 insertions(+), 4 deletions(-)

base-commit: 627ac78f2741e2ebd2225e2e953b6964a8a9182f

Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 1/2 devlink: add generic device max_sfs parameter

From: Nikolay Aleksandrov <[email protected]>

Add a new generic devlink device parameter (max_sfs) to control if and how many light-weight NIC subfunctions can be created. Subfunctions are a light-weight network functions backed by an underlying PCI function. Their lifecycle can already be managed by devlink, but currently users cannot enable them in the device. They can be enabled/disabled only via external vendor tools. This parameter allows subfunctions to be enabled (>0) or disabled (0) via devlink. A subsequent patch will add support for max_sfs to the mlx5 driver.

---
 Documentation/networking/devlink/devlink-params.rst | 6 ++++++
 include/net/devlink.h                               | 4 ++++
 net/devlink/param.c                                 | 5 +++++
 3 files changed, 15 insertions(+)
Documentation/networking/devlink/devlink-params.rst +6 -0
index ea17756dcda6..29b8a9246fb6 100644
@@ -165,3 +165,9 @@ own name.
      - u32
      - Controls the maximum number of MAC address filters that can be assigned
        to a Virtual Function (VF).
+   * - ``max_sfs``
+     - u32
+     - The maximum number of subfunctions which can be created on the device.
+       Modifying this parameter may require a device restart and PCI bus
+       rescanning because the BAR layout may change. A value of 0 disables
+       subfunction creation.
include/net/devlink.h +4 -0
index bcd31de1f890..4ec455cfe7a4 100644
@@ -546,6 +546,7 @@ enum devlink_param_generic_id {
 	DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS,
 	DEVLINK_PARAM_GENERIC_ID_NUM_DOORBELLS,
 	DEVLINK_PARAM_GENERIC_ID_MAX_MAC_PER_VF,
+	DEVLINK_PARAM_GENERIC_ID_MAX_SFS,
 
 	/* add new param generic ids above here*/
 	__DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -619,6 +620,9 @@ enum devlink_param_generic_id {
 #define DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_NAME "max_mac_per_vf"
 #define DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_TYPE DEVLINK_PARAM_TYPE_U32
 
+#define DEVLINK_PARAM_GENERIC_MAX_SFS_NAME "max_sfs"
+#define DEVLINK_PARAM_GENERIC_MAX_SFS_TYPE DEVLINK_PARAM_TYPE_U32
+
 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate)	\
 {									\
 	.id = DEVLINK_PARAM_GENERIC_ID_##_id,				\
net/devlink/param.c +5 -0
index cf95268da5b0..523243e49d88 100644
@@ -117,6 +117,11 @@ static const struct devlink_param devlink_param_generic[] = {
 		.name = DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_NAME,
 		.type = DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_TYPE,
 	},
+	{
+		.id = DEVLINK_PARAM_GENERIC_ID_MAX_SFS,
+		.name = DEVLINK_PARAM_GENERIC_MAX_SFS_NAME,
+		.type = DEVLINK_PARAM_GENERIC_MAX_SFS_TYPE,
+	},
 };
 
 static int devlink_param_generic_verify(const struct devlink_param *param)
Signature · 1 line
2.44.0
author maintainer
#3 lore raw

PATCH 2/2 net/mlx5: implement max_sfs parameter

In reply to Tariq Toukan

From: Nikolay Aleksandrov <[email protected]>

Implement max_sfs generic parameter to allow users to control the total light-weight NIC subfunctions that can be created using devlink instead of external vendor tools. A value of 0 will effectively disable creation of new subfunction devices. A warning is sent to user-space via extack (returning extack without error code is interpreted as a warning by user-space tools).

---
 Documentation/networking/devlink/mlx5.rst     |  7 +-
 .../mellanox/mlx5/core/lib/nv_param.c         | 83 ++++++++++++++++++-
 2 files changed, 86 insertions(+), 4 deletions(-)
Documentation/networking/devlink/mlx5.rst +6 -1
index 4bba4d780a4a..283b93d16861 100644
@@ -45,8 +45,13 @@ Parameters
      - The range is between 1 and a device-specific max.
      - Applies to each physical function (PF) independently, if the device
        supports it. Otherwise, it applies symmetrically to all PFs.
+   * - ``max_sfs``
+     - permanent
+     - The range is between 0 and a device-specific max.
+     - Applies to each physical function (PF) independently.
 
-Note: permanent parameters such as ``enable_sriov`` and ``total_vfs`` require FW reset to take effect
+Note: permanent parameters such as ``enable_sriov``, ``total_vfs` and ``max_sfs``
+      require FW reset to take effect
 
 .. code-block:: bash
 
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +80 -3

108 lines not on this page · raw message

Signature · 1 line
2.44.0
Reviewed-by on v1 1/2
#2 lore raw

RE: [PATCH net-next 1/2] devlink: add generic device max_sfs parameter

In reply to Tariq Toukan
Quoted 104 lines

-----Original Message-----
From: Tariq Toukan <[email protected]>
Sent: Sunday, May 17, 2026 1:27 PM
To: Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>
Cc: Jiri Pirko <[email protected]>; Simon Horman <[email protected]>; Jonathan Corbet <[email protected]>; Shuah Khan <[email protected]>; Saeed Mahameed <[email protected]>; Leon Romanovsky <[email protected]>; Tariq Toukan <[email protected]>; Mark Bloch <[email protected]>; Vlad Dumitrescu <[email protected]>; Loktionov, Aleksandr <[email protected]>; Daniel Zahka <[email protected]>; David Ahern <[email protected]>; Nikolay Aleksandrov <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Gal Pressman <[email protected]>; Dragos Tatulea <[email protected]>; Jiri Pirko <[email protected]>; Nikolay Aleksandrov <[email protected]>
Subject: [PATCH net-next 1/2] devlink: add generic device max_sfs parameter

From: Nikolay Aleksandrov <[email protected]>

Add a new generic devlink device parameter (max_sfs) to control if and how many light-weight NIC subfunctions can be created. Subfunctions are a light-weight network functions backed by an underlying PCI function.
Their lifecycle can already be managed by devlink, but currently users cannot enable them in the device. They can be enabled/disabled only via external vendor tools. This parameter allows subfunctions to be enabled
(>0) or disabled (0) via devlink. A subsequent patch will add support for max_sfs to the mlx5 driver.

---
 Documentation/networking/devlink/devlink-params.rst | 6 ++++++
 include/net/devlink.h                               | 4 ++++
 net/devlink/param.c                                 | 5 +++++
 3 files changed, 15 insertions(+)
Documentation/networking/devlink/devlink-params.rst +0 -0
index ea17756dcda6..29b8a9246fb6 100644
@@ -165,3 +165,9 @@ own name.
      - u32
      - Controls the maximum number of MAC address filters that can be

assigned
to a Virtual Function (VF).

Documentation/networking/devlink/devlink-params.rst +3 -0
+   * - ``max_sfs``
+     - u32
+     - The maximum number of subfunctions which can be created on the

device.
+ Modifying this parameter may require a device restart and PCI
bus
+ rescanning because the BAR layout may change. A value of 0
disables

Documentation/networking/devlink/devlink-params.rst +1 -0
+       subfunction creation.
include/net/devlink.h index renamed from include/net/devlink.h +0 -0

bcd31de1f890..4ec455cfe7a4 100644

include/net/devlink.h +1 -0
@@ -546,6 +546,7 @@ enum devlink_param_generic_id {
 	DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS,
 	DEVLINK_PARAM_GENERIC_ID_NUM_DOORBELLS,
 	DEVLINK_PARAM_GENERIC_ID_MAX_MAC_PER_VF,
+	DEVLINK_PARAM_GENERIC_ID_MAX_SFS,
 
 	/* add new param generic ids above here*/
 	__DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -619,6 +620,9 @@ enum devlink_param_generic_id {  #define

DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_NAME "max_mac_per_vf"
#define DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_TYPE
DEVLINK_PARAM_TYPE_U32

include/net/devlink.h +3 -0
+#define DEVLINK_PARAM_GENERIC_MAX_SFS_NAME "max_sfs"
+#define DEVLINK_PARAM_GENERIC_MAX_SFS_TYPE DEVLINK_PARAM_TYPE_U32
+
 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate)	\
 {									\
 	.id = DEVLINK_PARAM_GENERIC_ID_##_id,				\
net/devlink/param.c index renamed from net/devlink/param.c +0 -0

cf95268da5b0..523243e49d88 100644

net/devlink/param.c +5 -0
@@ -117,6 +117,11 @@ static const struct devlink_param
 devlink_param_generic[] = {
 		.name = DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_NAME,
 		.type = DEVLINK_PARAM_GENERIC_MAX_MAC_PER_VF_TYPE,
 	},
+	{
+		.id = DEVLINK_PARAM_GENERIC_ID_MAX_SFS,
+		.name = DEVLINK_PARAM_GENERIC_MAX_SFS_NAME,
+		.type = DEVLINK_PARAM_GENERIC_MAX_SFS_TYPE,
+	},
 };
 
Quoted 4 lines

static int devlink_param_generic_verify(const struct devlink_param
*param)
--
2.44.0

#4 lore raw

RE: [PATCH net-next 2/2] net/mlx5: implement max_sfs parameter

In reply to Tariq Toukan
Quoted 56 lines

-----Original Message-----
From: Tariq Toukan <[email protected]>
Sent: Sunday, May 17, 2026 1:27 PM
To: Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>
Cc: Jiri Pirko <[email protected]>; Simon Horman <[email protected]>; Jonathan Corbet <[email protected]>; Shuah Khan <[email protected]>; Saeed Mahameed <[email protected]>; Leon Romanovsky <[email protected]>; Tariq Toukan <[email protected]>; Mark Bloch <[email protected]>; Vlad Dumitrescu <[email protected]>; Loktionov, Aleksandr <[email protected]>; Daniel Zahka <[email protected]>; David Ahern <[email protected]>; Nikolay Aleksandrov <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Gal Pressman <[email protected]>; Dragos Tatulea <[email protected]>; Jiri Pirko <[email protected]>; Nikolay Aleksandrov <[email protected]>
Subject: [PATCH net-next 2/2] net/mlx5: implement max_sfs parameter

From: Nikolay Aleksandrov <[email protected]>

Implement max_sfs generic parameter to allow users to control the total light-weight NIC subfunctions that can be created using devlink instead of external vendor tools. A value of 0 will effectively disable creation of new subfunction devices. A warning is sent to user-space via extack (returning extack without error code is interpreted as a warning by user-space tools).

---
 Documentation/networking/devlink/mlx5.rst     |  7 +-
 .../mellanox/mlx5/core/lib/nv_param.c         | 83
++++++++++++++++++-
 2 files changed, 86 insertions(+), 4 deletions(-)
Documentation/networking/devlink/mlx5.rst +0 -0
index 4bba4d780a4a..283b93d16861 100644
@@ -45,8 +45,13 @@ Parameters
      - The range is between 1 and a device-specific max.
      - Applies to each physical function (PF) independently, if the

device
supports it. Otherwise, it applies symmetrically to all PFs.

Documentation/networking/devlink/mlx5.rst +4 -1
+   * - ``max_sfs``
+     - permanent
+     - The range is between 0 and a device-specific max.
+     - Applies to each physical function (PF) independently.
 
-Note: permanent parameters such as ``enable_sriov`` and ``total_vfs``
Quoted 3 lines

require FW reset to take effect
+Note: permanent parameters such as ``enable_sriov``, ``total_vfs` and ``max_sfs``

I think one ` is missed after the ``total_vfs` ?

...

Quoted 8 lines

DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE
,
"cqe_compress_type",
DEVLINK_PARAM_TYPE_STRING,
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
--
2.44.0

#5 lore raw

Re: [PATCH net-next 2/2] net/mlx5: implement max_sfs parameter

Quoted 55 lines · Aleksandr
Quoted 55 lines

-----Original Message-----
From: Tariq Toukan <[email protected]>
Sent: Sunday, May 17, 2026 1:27 PM
To: Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>
Cc: Jiri Pirko <[email protected]>; Simon Horman <[email protected]>; Jonathan Corbet <[email protected]>; Shuah Khan <[email protected]>; Saeed Mahameed <[email protected]>; Leon Romanovsky <[email protected]>; Tariq Toukan <[email protected]>; Mark Bloch <[email protected]>; Vlad Dumitrescu <[email protected]>; Loktionov, Aleksandr <[email protected]>; Daniel Zahka <[email protected]>; David Ahern <[email protected]>; Nikolay Aleksandrov <[email protected]>; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Gal Pressman <[email protected]>; Dragos Tatulea <[email protected]>; Jiri Pirko <[email protected]>; Nikolay Aleksandrov <[email protected]>
Subject: [PATCH net-next 2/2] net/mlx5: implement max_sfs parameter

From: Nikolay Aleksandrov <[email protected]>

Implement max_sfs generic parameter to allow users to control the total light-weight NIC subfunctions that can be created using devlink instead of external vendor tools. A value of 0 will effectively disable creation of new subfunction devices. A warning is sent to user-space via extack (returning extack without error code is interpreted as a warning by user-space tools).

---
 Documentation/networking/devlink/mlx5.rst     |  7 +-
 .../mellanox/mlx5/core/lib/nv_param.c         | 83
++++++++++++++++++-
 2 files changed, 86 insertions(+), 4 deletions(-)
Documentation/networking/devlink/mlx5.rst +0 -0
index 4bba4d780a4a..283b93d16861 100644
@@ -45,8 +45,13 @@ Parameters
      - The range is between 1 and a device-specific max.
      - Applies to each physical function (PF) independently, if the

device
supports it. Otherwise, it applies symmetrically to all PFs.

Documentation/networking/devlink/mlx5.rst +4 -0
+   * - ``max_sfs``
+     - permanent
+     - The range is between 0 and a device-specific max.
+     - Applies to each physical function (PF) independently.
Quoted 9 lines
Quoted 4 lines

-Note: permanent parameters such as ``enable_sriov`` and ``total_vfs`` require FW reset to take effect
+Note: permanent parameters such as ``enable_sriov``, ``total_vfs` and ``max_sfs``

I think one ` is missed after the ``total_vfs` ?

...

ha, good catch! there's a missing ` indeed :)

Quoted 9 lines
Quoted 8 lines

DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE
,
"cqe_compress_type",
DEVLINK_PARAM_TYPE_STRING,
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
--
2.44.0