]> www.infradead.org Git - users/hch/misc.git/commitdiff
devlink: Add 'total_vfs' generic device param
authorVlad Dumitrescu <vdumitrescu@nvidia.com>
Sun, 7 Sep 2025 01:29:43 +0000 (18:29 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 10 Sep 2025 02:14:23 +0000 (19:14 -0700)
NICs are typically configured with total_vfs=0, forcing users to rely
on external tools to enable SR-IOV (a widely used and essential feature).

Add total_vfs parameter to devlink for SR-IOV max VF configurability.
Enables standard kernel tools to manage SR-IOV, addressing the need for
flexible VF configuration.

Signed-off-by: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Tested-by: Kamal Heib <kheib@redhat.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250907012953.301746-2-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/devlink/devlink-params.rst
include/net/devlink.h
net/devlink/param.c

index 211b58177e121157c77073bd027554ef9bb5eee2..c51da4fba7e759d122f08cb3a4623b6989295ab4 100644 (file)
@@ -143,3 +143,8 @@ own name.
    * - ``clock_id``
      - u64
      - Clock ID used by the device for registering DPLL devices and pins.
+   * - ``total_vfs``
+     - u32
+     - The max number of Virtual Functions (VFs) exposed by the PF.
+       after reboot/pci reset, 'sriov_totalvfs' entry under the device's sysfs
+       directory will report this value.
index 5f44e702c25ca0cf49afb5f691ca585fa3ef6e33..8d4362f010e4562d801f5610d13e7aec65ba7887 100644 (file)
@@ -530,6 +530,7 @@ enum devlink_param_generic_id {
        DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE,
        DEVLINK_PARAM_GENERIC_ID_ENABLE_PHC,
        DEVLINK_PARAM_GENERIC_ID_CLOCK_ID,
+       DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS,
 
        /* add new param generic ids above here*/
        __DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -594,6 +595,9 @@ enum devlink_param_generic_id {
 #define DEVLINK_PARAM_GENERIC_CLOCK_ID_NAME "clock_id"
 #define DEVLINK_PARAM_GENERIC_CLOCK_ID_TYPE DEVLINK_PARAM_TYPE_U64
 
+#define DEVLINK_PARAM_GENERIC_TOTAL_VFS_NAME "total_vfs"
+#define DEVLINK_PARAM_GENERIC_TOTAL_VFS_TYPE DEVLINK_PARAM_TYPE_U32
+
 #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate)     \
 {                                                                      \
        .id = DEVLINK_PARAM_GENERIC_ID_##_id,                           \
index 41dcc86cfd94458f71ea6acfd8fe533b96f21c79..33134940c2663c33c40914f6360f479f32d371fd 100644 (file)
@@ -102,6 +102,11 @@ static const struct devlink_param devlink_param_generic[] = {
                .name = DEVLINK_PARAM_GENERIC_CLOCK_ID_NAME,
                .type = DEVLINK_PARAM_GENERIC_CLOCK_ID_TYPE,
        },
+       {
+               .id = DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS,
+               .name = DEVLINK_PARAM_GENERIC_TOTAL_VFS_NAME,
+               .type = DEVLINK_PARAM_GENERIC_TOTAL_VFS_TYPE,
+       },
 };
 
 static int devlink_param_generic_verify(const struct devlink_param *param)