devlink, mlx5: Add new parameters for link management and SRIOV/eSwitch configurations
Subsystems (8)
cover devlink, mlx5: Add new parameters for link management and SRIOV/eSwitch configurations
From: Saeed Mahameed <[email protected]>
This patch series introduces several devlink parameters improving device configuration capabilities, link management, and SRIOV/eSwitch, by adding NV config boot time parameters.
Below is a summary of the key changes:
1) Enable support for devlink port parameters
2) Implement multi attribute devlink param value data, for u32 array type parameters
3) Implement the following parameters:
3.a) total_vfs Parameter:
-------------------------
Adds support for managing the number of VFs (total_vfs) and enabling SR-IOV (enable_sriov for mlx5) through devlink. These additions enhance user control over virtualization features directly from standard kernel interfaces without relying on additional external tools. total_vfs functionality is critical for environments that require flexible num VF configuration.
3.b) devlink keep_link_up Parameter:
------------------------------------
Introduces a new devlink parameter 'keep_link_up', allowing devices to keep the link active even when the driver is not loaded. This functionality is especially useful for maintaining link stability during driver upgrades or reboots without dropping connectivity.
3.c) eSwitch Hairpin per Priority Buffers:
------------------------------------------
Implements new devlink parameters to configure eSwitch hairpin per priority buffers. These parameters provide granular control over how packets are buffered for IEEE802.1p priorities, offering improved traffic management and efficiency for specific priority levels.
3.d) CQE Compression Type:
--------------------------
Introduces a new devlink parameter, cqe_compress_type, to configure the rate of CQE compression based on PCIe bus conditions. This setting provides a balance between compression efficiency and overall NIC performance under different traffic loads.
Detailed examples of usage for each parameter have been included in the respective commits.
Jiri Pirko (2):
devlink: define enum for attr types of dynamic attributes
devlink: pass struct devlink_port * as arg to devlink_nl_param_fill()
Saeed Mahameed (9):
net/mlx5: Implement cqe_compress_type via devlink params
devlink: Implement port params registration
devlink: Implement get/dump netlink commands for port params
devlink: Implement set netlink command for port params
devlink: Add 'keep_link_up' generic devlink device param net/mlx5: Implement devlink keep_link_up port parameter
devlink: Throw extack messages on param value validation error
devlink: Implement devlink param multi attribute nested data values net/mlx5: Implement eSwitch hairpin per prio buffers devlink params
Vlad Dumitrescu (3):
devlink: Add 'total_vfs' generic device param net/mlx5: Implement devlink enable_sriov parameter net/mlx5: Implement devlink total_vfs parameter
Documentation/netlink/specs/devlink.yaml | 45 +- .../networking/devlink/devlink-params.rst | 7 + Documentation/networking/devlink/mlx5.rst | 65 +- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 9 + .../net/ethernet/mellanox/mlx5/core/devlink.h | 3 + .../ethernet/mellanox/mlx5/core/en/devlink.c | 16 +- .../ethernet/mellanox/mlx5/core/en/devlink.h | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../mellanox/mlx5/core/lib/nv_param.c | 944 ++++++++++++++++++ .../mellanox/mlx5/core/lib/nv_param.h | 16 + include/linux/mlx5/driver.h | 1 + include/net/devlink.h | 30 + include/uapi/linux/devlink.h | 18 + net/devlink/health.c | 17 +- net/devlink/netlink_gen.c | 23 +- net/devlink/param.c | 437 ++++++-- net/devlink/port.c | 3 + 18 files changed, 1536 insertions(+), 107 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.h
Signature · 1 line
2.48.1
PATCH 1/14 devlink: define enum for attr types of dynamic attributes
From: Jiri Pirko <[email protected]>
Devlink param and health reporter fmsg use attributes with dynamic type which is determined according to a different type. Currently used values are NLA_*. The problem is, they are not part of UAPI. They may change which would cause a break.
To make this future safe, introduce a enum that shadows NLA_* values in it and is part of UAPI.
Also, this allows to possibly carry types that are unrelated to NLA_* values.
--- Documentation/netlink/specs/devlink.yaml | 23 ++++++++++++++++++ include/uapi/linux/devlink.h | 17 ++++++++++++++ net/devlink/health.c | 17 ++++++++++++-- net/devlink/param.c | 30 ++++++++++++------------ 4 files changed, 70 insertions(+), 17 deletions(-)
Documentation/netlink/specs/devlink.yaml +23 -0
@@ -202,6 +202,29 @@ definitions: name: exception - name: control + - + type: enum + name: dyn_attr_type + entries: + - + name: u8 + value: 1 + - + name: u16 + - + name: u32 + - + name: u64 + - + name: string + - + name: flag + - + name: nul_string + value: 10 + - + name: binary + - attribute-sets: -
include/uapi/linux/devlink.h +17 -0
@@ -385,6 +385,23 @@ enum devlink_linecard_state {DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX -1 }; +/** +* enum devlink_dyn_attr_type - Dynamic attribute type type. +*/ +enum devlink_dyn_attr_type { +/* Following values relate to the internal NLA_* values */ +DEVLINK_DYN_ATTR_TYPE_U8 =1 , +DEVLINK_DYN_ATTR_TYPE_U16 , +DEVLINK_DYN_ATTR_TYPE_U32 , +DEVLINK_DYN_ATTR_TYPE_U64 , +DEVLINK_DYN_ATTR_TYPE_STRING , +DEVLINK_DYN_ATTR_TYPE_FLAG , +DEVLINK_DYN_ATTR_TYPE_NUL_STRING =10 , +DEVLINK_DYN_ATTR_TYPE_BINARY , + __DEVLINK_DYN_ATTR_TYPE_CUSTOM_BASE =0x80 , +/* Any possible custom types, unrelated to NLA_* values go below */ +}; +enum devlink_attr {/* don't change the order or add anything between, this is ABI! */ DEVLINK_ATTR_UNSPEC ,
net/devlink/health.c +15 -2
@@ -930,18 +930,31 @@ EXPORT_SYMBOL_GPL(devlink_fmsg_binary_pair_put);static int devlink_fmsg_item_fill_type (struct devlink_fmsg_item *msg,struct sk_buff *skb) { +enum devlink_dyn_attr_type dyn_attr_type; +switch (msg->nla_type) {case NLA_FLAG : + dyn_attr_type =DEVLINK_DYN_ATTR_TYPE_FLAG ; +break ;case NLA_U8 : + dyn_attr_type =DEVLINK_DYN_ATTR_TYPE_U8 ; +break ;case NLA_U32 : + dyn_attr_type =DEVLINK_DYN_ATTR_TYPE_U32 ; +break ;case NLA_U64 : + dyn_attr_type =DEVLINK_DYN_ATTR_TYPE_U64 ; +break ;case NLA_NUL_STRING : + dyn_attr_type =DEVLINK_DYN_ATTR_TYPE_NUL_STRING ; +break ;case NLA_BINARY : -return nla_put_u8 (skb,DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE , - msg->nla_type); + dyn_attr_type =DEVLINK_DYN_ATTR_TYPE_BINARY ; +break ;default :return -EINVAL ; } +return nla_put_u8 (skb,DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE , dyn_attr_type); } static int
net/devlink/param.c +15 -15
@@ -167,19 +167,19 @@ static int devlink_param_set(struct devlink *devlink, }static int -devlink_param_type_to_nla_type (enum devlink_param_type param_type) +devlink_param_type_to_dyn_attr_type (enum devlink_param_type param_type) {switch (param_type) {case DEVLINK_PARAM_TYPE_U8 : -return NLA_U8 ; +return DEVLINK_DYN_ATTR_TYPE_U8 ;case DEVLINK_PARAM_TYPE_U16 : -return NLA_U16 ; +return DEVLINK_DYN_ATTR_TYPE_U16 ;case DEVLINK_PARAM_TYPE_U32 : -return NLA_U32 ; +return DEVLINK_DYN_ATTR_TYPE_U32 ;case DEVLINK_PARAM_TYPE_STRING : -return NLA_STRING ; +return DEVLINK_DYN_ATTR_TYPE_STRING ;case DEVLINK_PARAM_TYPE_BOOL : -return NLA_FLAG ; +return DEVLINK_DYN_ATTR_TYPE_FLAG ;default :return -EINVAL ; }
@@ -247,7 +247,7 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,struct devlink_param_gset_ctx ctx;struct nlattr *param_values_list;struct nlattr *param_attr; -int nla_type; +int dyn_attr_type;void *hdr;int err;int i;
@@ -294,10 +294,10 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,if (param->generic &&nla_put_flag (msg,DEVLINK_ATTR_PARAM_GENERIC )) goto param_nest_cancel; - nla_type =devlink_param_type_to_nla_type (param->type); -if (nla_type <0 ) + dyn_attr_type =devlink_param_type_to_dyn_attr_type (param->type); +if (dyn_attr_type <0 ) goto param_nest_cancel; -if (nla_put_u8 (msg,DEVLINK_ATTR_PARAM_TYPE , nla_type)) +if (nla_put_u8 (msg,DEVLINK_ATTR_PARAM_TYPE , dyn_attr_type)) goto param_nest_cancel; param_values_list = nla_nest_start_noflag(msg,
@@ -420,19 +420,19 @@ devlink_param_type_get_from_info(struct genl_info *info,return -EINVAL ;switch (nla_get_u8 (info->attrs[DEVLINK_ATTR_PARAM_TYPE ])) { -case NLA_U8 : +case DEVLINK_DYN_ATTR_TYPE_U8 : *param_type =DEVLINK_PARAM_TYPE_U8 ;break ; -case NLA_U16 : +case DEVLINK_DYN_ATTR_TYPE_U16 : *param_type =DEVLINK_PARAM_TYPE_U16 ;break ; -case NLA_U32 : +case DEVLINK_DYN_ATTR_TYPE_U32 : *param_type =DEVLINK_PARAM_TYPE_U32 ;break ; -case NLA_STRING : +case DEVLINK_DYN_ATTR_TYPE_STRING : *param_type =DEVLINK_PARAM_TYPE_STRING ;break ; -case NLA_FLAG : +case DEVLINK_DYN_ATTR_TYPE_FLAG : *param_type =DEVLINK_PARAM_TYPE_BOOL ;break ;default :
Signature · 1 line
2.48.1
PATCH 2/14 devlink: Add 'total_vfs' generic device param
In reply to Saeed MahameedFrom: Vlad Dumitrescu <[email protected]>
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.
--- Documentation/networking/devlink/devlink-params.rst | 3 +++ include/net/devlink.h | 4 ++++ net/devlink/param.c | 5 +++++ 3 files changed, 12 insertions(+)
Documentation/networking/devlink/devlink-params.rst +3 -0
@@ -137,3 +137,6 @@ own name. * - ``event_eq_size`` - u32 - Control the size of asynchronous control events EQ. + * - ``total_vfs`` + - u32 + - The total number of Virtual Functions (VFs) supported by the PF.
include/net/devlink.h +4 -0
@@ -520,6 +520,7 @@ enum devlink_param_generic_id {DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP ,DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE ,DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE , +DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS ,/* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -578,6 +579,9 @@ enum devlink_param_generic_id {#define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME "event_eq_size"#define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE DEVLINK_PARAM_TYPE_U32 +#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, \
net/devlink/param.c +5 -0
@@ -92,6 +92,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME, .type = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_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)
Signature · 1 line
2.48.1
PATCH 3/14 net/mlx5: Implement cqe_compress_type via devlink params
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Selects which algorithm should be used by the NIC in order to decide rate of CQE compression dependeng on PCIe bus conditions.
Supported values:
1) balanced, merges fewer CQEs, resulting in a moderate compression ratio but maintaining a balance between bandwidth savings and performance
2) aggressive, merges more CQEs into a single entry, achieving a higher compression rate and maximizing performance, particularly under high traffic loads.
--- Documentation/networking/devlink/mlx5.rst | 9 + .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 8 + .../net/ethernet/mellanox/mlx5/core/devlink.h | 1 + .../mellanox/mlx5/core/lib/nv_param.c | 234 ++++++++++++++++++ .../mellanox/mlx5/core/lib/nv_param.h | 14 ++ include/linux/mlx5/driver.h | 1 + 7 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.h
Documentation/networking/devlink/mlx5.rst +9 -0
@@ -117,6 +117,15 @@ parameters. - driverinit - Control the size (in packets) of the hairpin queues. + * - ``cqe_compress_type`` + - string + - permanent + - Configure which algorithm should be used by the NIC in order to decide + rate of CQE compression dependeng on PCIe bus conditions. + + * ``balanced`` : Merges fewer CQEs, resulting in a moderate compression ratio but maintaining a balance between bandwidth savings and performance + * ``aggressive`` : Merges more CQEs into a single entry, achieving a higher compression rate and maximizing performance, particularly under high traffic loads + The ``mlx5`` driver supports reloading via ``DEVLINK_CMD_RELOAD`` Info versions
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -17,7 +17,7 @@ mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \ fs_counters.o fs_ft_pool.o rl.o lag/debugfs.o lag/lag.o dev.o events.o wq.o lib/gid.o \ lib/devcom.o lib/pci_vsc.o lib/dm.o lib/fs_ttc.o diag/fs_tracepoint.o \ diag/fw_tracer.o diag/crdump.o devlink.o diag/rsc_dump.o diag/reporter_vnic.o \ - fw_reset.o qos.o lib/tout.o lib/aso.o wc.o fs_pool.o + fw_reset.o qos.o lib/tout.o lib/aso.o wc.o fs_pool.o lib/nv_param.o # # Netdev basic
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +8 -0
@@ -10,6 +10,7 @@#include "esw/qos.h" #include "sf/dev/dev.h" #include "sf/sf.h" +#include "lib/nv_param.h" static int mlx5_devlink_flash_update(struct devlink *devlink, struct devlink_flash_update_params *params,
@@ -836,8 +837,14 @@ int mlx5_devlink_params_register(struct devlink *devlink)if (err) goto max_uc_list_err; + err =mlx5_nv_param_register_dl_params (devlink); +if (err) + goto nv_param_err; +return 0 ; +nv_param_err: +mlx5_devlink_max_uc_list_params_unregister (devlink); max_uc_list_err:mlx5_devlink_auxdev_params_unregister (devlink); auxdev_reg_err:
@@ -848,6 +855,7 @@ int mlx5_devlink_params_register(struct devlink *devlink)void mlx5_devlink_params_unregister (struct devlink *devlink) { +mlx5_nv_param_unregister_dl_params (devlink);mlx5_devlink_max_uc_list_params_unregister (devlink);mlx5_devlink_auxdev_params_unregister (devlink); devl_params_unregister(devlink, mlx5_devlink_params,
drivers/net/ethernet/mellanox/mlx5/core/devlink.h +1 -0
@@ -22,6 +22,7 @@ enum mlx5_devlink_param_id {MLX5_DEVLINK_PARAM_ID_ESW_MULTIPORT ,MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES ,MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE , +MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE }; struct mlx5_trap_ctx {
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c new file +234 -0
234 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_NV_PARAM_H +#define __MLX5_NV_PARAM_H + +#include <linux/mlx5/driver.h> +#include "devlink.h" + +int mlx5_nv_param_register_dl_params (struct devlink *devlink); +void mlx5_nv_param_unregister_dl_params (struct devlink *devlink); + +#endif +
include/linux/mlx5/driver.h +1 -0
@@ -135,6 +135,7 @@ enum {MLX5_REG_MTCAP =0x9009 ,MLX5_REG_MTMP =0x900A ,MLX5_REG_MCIA =0x9014 , +MLX5_REG_MNVDA =0x9024 ,MLX5_REG_MFRL =0x9028 ,MLX5_REG_MLCR =0x902b , MLX5_REG_MRTC = 0x902d,
Signature · 1 line
2.48.1
PATCH 4/14 net/mlx5: Implement devlink enable_sriov parameter
In reply to Saeed MahameedFrom: Vlad Dumitrescu <[email protected]>
Example usage:
devlink dev param set pci/0000:01:00.0 name enable_sriov value {true, false} cmode permanent devlink dev reload pci/0000:01:00.0 action fw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_*
--- Documentation/networking/devlink/mlx5.rst | 14 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 1 + .../mellanox/mlx5/core/lib/nv_param.c | 184 ++++++++++++++++++ 3 files changed, 196 insertions(+), 3 deletions(-)
Documentation/networking/devlink/mlx5.rst +11 -3
@@ -15,23 +15,31 @@ Parameters * - Name - Mode - Validation + - Notes * - ``enable_roce`` - driverinit - - Type: Boolean - - If the device supports RoCE disablement, RoCE enablement state controls + - Boolean + - If the device supports RoCE disablement, RoCE enablement state controls device support for RoCE capability. Otherwise, the control occurs in the driver stack. When RoCE is disabled at the driver level, only raw ethernet QPs are supported. * - ``io_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``event_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``max_macs`` - driverinit - The range is between 1 and 2^31. Only power of 2 values are supported. + - + * - ``enable_sriov`` + - permanent + - Boolean + - Applies to each physical function (PF) independently, if the device + supports it. Otherwise, it applies symmetrically to all PFs. The ``mlx5`` driver also implements the following driver-specific parameters.
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1 -0
@@ -8,6 +8,7 @@#include "fs_core.h" #include "eswitch.h" #include "esw/qos.h" +#include "lib/nv_param.h" #include "sf/dev/dev.h" #include "sf/sf.h" #include "lib/nv_param.h"
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +184 -0
213 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 5/14 net/mlx5: Implement devlink total_vfs parameter
In reply to Saeed MahameedFrom: Vlad Dumitrescu <[email protected]>
Some devices support both symmetric (same value for all PFs) and asymmetric, while others only support symmetric configuration. This implementation prefers asymmetric, since it is closer to the devlink model (per function settings), but falls back to symmetric when needed.
Example usage:
devlink dev param set pci/0000:01:00.0 name total_vfs value <u16> cmode permanent devlink dev reload pci/0000:01:00.0 action fw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
cat /sys/bus/pci/devices/0000:01:00.0/sriov_totalvfs
--- Documentation/networking/devlink/mlx5.rst | 22 +++ .../mellanox/mlx5/core/lib/nv_param.c | 125 ++++++++++++++++++ 2 files changed, 147 insertions(+)
Documentation/networking/devlink/mlx5.rst +22 -0
@@ -40,6 +40,28 @@ Parameters - Boolean - Applies to each physical function (PF) independently, if the device supports it. Otherwise, it applies symmetrically to all PFs. + * - ``total_vfs`` + - permanent + - 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. + +Note: permanent parameters such as ``enable_sriov`` and ``total_vfs`` require FW reset to take effect + +.. code-block:: bash + + # setup parameters + devlink dev param set pci/0000:01:00.0 name enable_sriov value true cmode permanent + devlink dev param set pci/0000:01:00.0 name total_vfs value 8 cmode permanent + + # Fw reset + devlink dev reload pci/0000:01:00.0 action fw_activate + + # for PCI related config such as sriov PCI reset/rescan is required: + echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove + echo 1 >/sys/bus/pci/rescan + grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_* + The ``mlx5`` driver also implements the following driver-specific parameters.
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +125 -0
135 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 6/14 devlink: pass struct devlink_port * as arg to devlink_nl_param_fill()
In reply to Saeed MahameedFrom: Jiri Pirko <[email protected]>
As the follow-up patch will need to get struct devlink_port *, avoid unnecessary lookup and instead of port_index pass the struct devlink_port * directly.
--- net/devlink/param.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
net/devlink/param.c +15 -14
@@ -241,7 +241,7 @@ devlink_nl_param_value_fill_one(struct sk_buff *msg, }static int devlink_nl_param_fill (struct sk_buff *msg,struct devlink *devlink, -unsigned int port_index, +struct devlink_port *devlink_port,struct devlink_param_item *param_item,enum devlink_command cmd,u32 portid,u32 seq,int flags)
@@ -288,7 +288,8 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,if (cmd ==DEVLINK_CMD_PORT_PARAM_GET || cmd ==DEVLINK_CMD_PORT_PARAM_NEW || cmd ==DEVLINK_CMD_PORT_PARAM_DEL ) -if (nla_put_u32 (msg,DEVLINK_ATTR_PORT_INDEX , port_index)) +if (nla_put_u32 (msg,DEVLINK_ATTR_PORT_INDEX , + devlink_port->index)) goto genlmsg_cancel; param_attr =nla_nest_start_noflag (msg,DEVLINK_ATTR_PARAM );
@@ -334,7 +335,7 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink, }static void devlink_param_notify (struct devlink *devlink, -unsigned int port_index, +struct devlink_port *devlink_port,struct devlink_param_item *param_item,enum devlink_command cmd) {
@@ -355,7 +356,7 @@ static void devlink_param_notify(struct devlink *devlink, msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );if (!msg)return ; - err =devlink_nl_param_fill (msg, devlink, port_index, param_item, cmd, + err =devlink_nl_param_fill (msg, devlink, devlink_port, param_item, cmd,0 ,0 ,0 );if (err) {nlmsg_free (msg);
@@ -372,7 +373,7 @@ static void devlink_params_notify(struct devlink *devlink,unsigned long param_id;xa_for_each (&devlink->params, param_id, param_item) -devlink_param_notify (devlink,0 , param_item, cmd); +devlink_param_notify (devlink,NULL , param_item, cmd); }void devlink_params_notify_register (struct devlink *devlink)
@@ -396,7 +397,7 @@ static int devlink_nl_param_get_dump_one(struct sk_buff *msg,int err =0 ;xa_for_each_start (&devlink->params, param_id, param_item, state->idx) { - err =devlink_nl_param_fill (msg, devlink,0 , param_item, + err =devlink_nl_param_fill (msg, devlink,NULL , param_item,DEVLINK_CMD_PARAM_GET ,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, flags);
@@ -520,7 +521,7 @@ int devlink_nl_param_get_doit(struct sk_buff *skb,if (!msg)return -ENOMEM ; - err =devlink_nl_param_fill (msg, devlink,0 , param_item, + err =devlink_nl_param_fill (msg, devlink,NULL , param_item,DEVLINK_CMD_PARAM_GET , info->snd_portid, info->snd_seq,0 );if (err) {
@@ -532,7 +533,7 @@ int devlink_nl_param_get_doit(struct sk_buff *skb, }static int __devlink_nl_cmd_param_set_doit (struct devlink *devlink, -unsigned int port_index, +struct devlink_port *devlink_port,struct xarray *params,struct genl_info *info,enum devlink_command cmd)
@@ -582,7 +583,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,return err; } -devlink_param_notify (devlink, port_index, param_item, cmd); +devlink_param_notify (devlink, devlink_port, param_item, cmd);return 0 ; }
@@ -590,7 +591,7 @@ int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info) {struct devlink *devlink = info->user_ptr[0 ]; -return __devlink_nl_cmd_param_set_doit (devlink,0 , &devlink->params, +return __devlink_nl_cmd_param_set_doit (devlink,NULL , &devlink->params, info,DEVLINK_CMD_PARAM_NEW ); }
@@ -649,7 +650,7 @@ static int devlink_param_register(struct devlink *devlink,if (err) goto err_xa_insert; -devlink_param_notify (devlink,0 , param_item,DEVLINK_CMD_PARAM_NEW ); +devlink_param_notify (devlink,NULL , param_item,DEVLINK_CMD_PARAM_NEW );return 0 ; err_xa_insert:
@@ -665,7 +666,7 @@ static void devlink_param_unregister(struct devlink *devlink, param_item =devlink_param_find_by_id (&devlink->params, param->id);if (WARN_ON (!param_item))return ; -devlink_param_notify (devlink,0 , param_item,DEVLINK_CMD_PARAM_DEL ); +devlink_param_notify (devlink,NULL , param_item,DEVLINK_CMD_PARAM_DEL );xa_erase (&devlink->params, param->id);kfree (param_item); }
@@ -826,7 +827,7 @@ void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id, param_item->driverinit_value = init_val; param_item->driverinit_value_valid = true; -devlink_param_notify (devlink,0 , param_item,DEVLINK_CMD_PARAM_NEW ); +devlink_param_notify (devlink,NULL , param_item,DEVLINK_CMD_PARAM_NEW ); }EXPORT_SYMBOL_GPL (devl_param_driverinit_value_set);
@@ -865,6 +866,6 @@ void devl_param_value_changed(struct devlink *devlink, u32 param_id) param_item =devlink_param_find_by_id (&devlink->params, param_id);WARN_ON (!param_item); -devlink_param_notify (devlink,0 , param_item,DEVLINK_CMD_PARAM_NEW ); +devlink_param_notify (devlink,NULL , param_item,DEVLINK_CMD_PARAM_NEW ); }EXPORT_SYMBOL_GPL (devl_param_value_changed);
Signature · 1 line
2.48.1
PATCH 7/14 devlink: Implement port params registration
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Port params infrastructure is incomplete and needs a bit of plumbing to support port params commands from netlink.
Introduce port params registration API, very similar to current devlink params API, add the params xarray to devlink_port structure and decouple devlink params registration routines from the devlink structure.
--- include/net/devlink.h | 14 ++++ net/devlink/param.c | 150 ++++++++++++++++++++++++++++++++++-------- net/devlink/port.c | 3 + 3 files changed, 140 insertions(+), 27 deletions(-)
include/net/devlink.h +14 -0
@@ -125,6 +125,7 @@ struct devlink_port {struct list_head region_list;struct devlink *devlink;const struct devlink_port_ops *ops; +struct xarray params;unsigned int index;spinlock_t type_lock;/* Protects type and type_eth/ib * structures consistency.
@@ -1823,6 +1824,19 @@ void devl_params_unregister(struct devlink *devlink,void devlink_params_unregister (struct devlink *devlink,const struct devlink_param *params,size_t params_count); +int devl_port_params_register (struct devlink_port *devlink_port, +const struct devlink_param *params, +size_t params_count); +int devlink_port_params_register (struct devlink_port *devlink_port, +const struct devlink_param *params, +size_t params_count); +void devl_port_params_unregister (struct devlink_port *devlink_port, +const struct devlink_param *params, +size_t params_count); +void devlink_port_params_unregister (struct devlink_port *devlink_port, +const struct devlink_param *params, +size_t params_count); +int devl_param_driverinit_value_get (struct devlink *devlink,u32 param_id,union devlink_param_value *val); void devl_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
net/devlink/param.c +123 -27
221 lines not on this page · raw message
net/devlink/port.c +3 -0
@@ -1075,6 +1075,8 @@ int devl_port_register_with_ops(struct devlink *devlink, devlink_port->registered = true; devlink_port->index = port_index; devlink_port->ops = ops ? ops : &devlink_port_dummy_ops; +xa_init_flags (&devlink_port->params,XA_FLAGS_ALLOC ); +spin_lock_init (&devlink_port->type_lock);INIT_LIST_HEAD (&devlink_port->reporter_list); err =xa_insert (&devlink->ports, port_index, devlink_port,GFP_KERNEL );
@@ -1134,6 +1136,7 @@ void devl_port_unregister(struct devlink_port *devlink_port)devlink_port_type_warn_cancel (devlink_port);devlink_port_notify (devlink_port,DEVLINK_CMD_PORT_DEL );xa_erase (&devlink_port->devlink->ports, devlink_port->index); +xa_destroy (&devlink_port->params);WARN_ON (!list_empty (&devlink_port->reporter_list)); devlink_port->registered = false; }
Signature · 1 line
2.48.1
PATCH 8/14 devlink: Implement get/dump netlink commands for port params
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Add missing port-params netlink attributes and policies to devlink's spec, reuse existing get_doit/dump_doit of the devlink params for port params and implement the dump command for all devlink ports params.
This implements:
1) devlink port param show 2) devlink port param show <device>/<port> 3) devlink port param show <device>/<port> name <param_name>
--- Documentation/netlink/specs/devlink.yaml | 13 ++-- include/net/devlink.h | 1 + net/devlink/netlink_gen.c | 16 ++++- net/devlink/param.c | 88 ++++++++++++++++++++---- 4 files changed, 99 insertions(+), 19 deletions(-)
Documentation/netlink/specs/devlink.yaml +9 -4
@@ -1851,12 +1851,17 @@ operations: pre: devlink-nl-pre-doit-port post: devlink-nl-post-doit request: - attributes: *port-id-attrs - reply: - attributes: *port-id-attrs + attributes: &port-param-id-attrs + - bus-name + - dev-name + - port-index + - param-name + reply: &port-param-get-reply + attributes: *port-param-id-attrs dump: - reply: + request: attributes: *port-id-attrs + reply: *port-param-get-reply - name: port-param-set
include/net/devlink.h +1 -0
@@ -439,6 +439,7 @@ union devlink_param_value {struct devlink_param_gset_ctx {union devlink_param_value val;enum devlink_param_cmode cmode; +struct devlink_port *devlink_port; };/**
net/devlink/netlink_gen.c +13 -3
@@ -322,7 +322,15 @@ static const struct nla_policy devlink_region_read_nl_policy[DEVLINK_ATTR_REGION };/* DEVLINK_CMD_PORT_PARAM_GET - do */ -static const struct nla_policy devlink_port_param_get_nl_policy[DEVLINK_ATTR_PORT_INDEX +1 ] = { +static const struct nla_policy devlink_port_param_get_do_nl_policy[DEVLINK_ATTR_PARAM_NAME +1 ] = { + [DEVLINK_ATTR_BUS_NAME ] = { .type =NLA_NUL_STRING , }, + [DEVLINK_ATTR_DEV_NAME ] = { .type =NLA_NUL_STRING , }, + [DEVLINK_ATTR_PORT_INDEX ] = { .type =NLA_U32 , }, + [DEVLINK_ATTR_PARAM_NAME ] = { .type =NLA_NUL_STRING , }, +}; + +/* DEVLINK_CMD_PORT_PARAM_GET - dump */ +static const struct nla_policy devlink_port_param_get_dump_nl_policy[DEVLINK_ATTR_PORT_INDEX +1 ] = { [DEVLINK_ATTR_BUS_NAME ] = { .type =NLA_NUL_STRING , }, [DEVLINK_ATTR_DEV_NAME ] = { .type =NLA_NUL_STRING , }, [DEVLINK_ATTR_PORT_INDEX ] = { .type =NLA_U32 , },
@@ -938,14 +946,16 @@ const struct genl_split_ops devlink_nl_ops[74] = { .pre_doit = devlink_nl_pre_doit_port, .doit = devlink_nl_port_param_get_doit, .post_doit = devlink_nl_post_doit, - .policy = devlink_port_param_get_nl_policy, - .maxattr = DEVLINK_ATTR_PORT_INDEX, + .policy = devlink_port_param_get_do_nl_policy, + .maxattr = DEVLINK_ATTR_PARAM_NAME, .flags = GENL_CMD_CAP_DO, }, { .cmd = DEVLINK_CMD_PORT_PARAM_GET, .validate = GENL_DONT_VALIDATE_DUMP_STRICT, .dumpit = devlink_nl_port_param_get_dumpit, + .policy = devlink_port_param_get_dump_nl_policy, + .maxattr = DEVLINK_ATTR_PORT_INDEX, .flags = GENL_CMD_CAP_DUMP, }, {
net/devlink/param.c +76 -12
148 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 9/14 devlink: Implement set netlink command for port params
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Add missing port-params netlink attributes and policies to devlink's spec, reuse existing set_doit of the devlink dev params.
This implements:
devlink port param set <device>/<port> name <param_name> value <val> \
cmode <cmode>
--- Documentation/netlink/specs/devlink.yaml | 9 ++++++++- net/devlink/netlink_gen.c | 7 +++++-- net/devlink/param.c | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-)
Documentation/netlink/specs/devlink.yaml +8 -1
@@ -1873,7 +1873,14 @@ operations: pre: devlink-nl-pre-doit-port post: devlink-nl-post-doit request: - attributes: *port-id-attrs + attributes: + - bus-name + - dev-name + - port-index + - param-name + - param-type + # param-value-data is missing here as the type is variable + - param-value-cmode - name: info-get
net/devlink/netlink_gen.c +5 -2
@@ -337,10 +337,13 @@ static const struct nla_policy devlink_port_param_get_dump_nl_policy[DEVLINK_ATT };/* DEVLINK_CMD_PORT_PARAM_SET - do */ -static const struct nla_policy devlink_port_param_set_nl_policy[DEVLINK_ATTR_PORT_INDEX +1 ] = { +static const struct nla_policy devlink_port_param_set_nl_policy[DEVLINK_ATTR_PARAM_VALUE_CMODE +1 ] = { [DEVLINK_ATTR_BUS_NAME ] = { .type =NLA_NUL_STRING , }, [DEVLINK_ATTR_DEV_NAME ] = { .type =NLA_NUL_STRING , }, [DEVLINK_ATTR_PORT_INDEX ] = { .type =NLA_U32 , }, + [DEVLINK_ATTR_PARAM_NAME ] = { .type =NLA_NUL_STRING , }, + [DEVLINK_ATTR_PARAM_TYPE ] = { .type =NLA_U8 , }, + [DEVLINK_ATTR_PARAM_VALUE_CMODE ] =NLA_POLICY_MAX (NLA_U8 ,2 ), };/* DEVLINK_CMD_INFO_GET - do */
@@ -965,7 +968,7 @@ const struct genl_split_ops devlink_nl_ops[74] = { .doit = devlink_nl_port_param_set_doit, .post_doit = devlink_nl_post_doit, .policy = devlink_port_param_set_nl_policy, - .maxattr = DEVLINK_ATTR_PORT_INDEX, + .maxattr = DEVLINK_ATTR_PARAM_VALUE_CMODE, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, {
net/devlink/param.c +12 -4
@@ -165,12 +165,15 @@ static int devlink_param_get(struct devlink *devlink, }static int devlink_param_set (struct devlink *devlink, +struct devlink_port *devlink_port,const struct devlink_param *param,struct devlink_param_gset_ctx *ctx,struct netlink_ext_ack *extack) {if (!param->set)return -EOPNOTSUPP ; + + ctx->devlink_port = devlink_port;return param->set (devlink, param->id, ctx, extack); }
@@ -550,8 +553,8 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink, struct genl_info *info, enum devlink_command cmd) { +struct devlink_param_gset_ctx ctx = {};enum devlink_param_type param_type; -struct devlink_param_gset_ctx ctx;enum devlink_param_cmode cmode;struct devlink_param_item *param_item;const struct devlink_param *param;
@@ -590,7 +593,8 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,return -EOPNOTSUPP ; ctx.val = value; ctx.cmode = cmode; - err =devlink_param_set (devlink, param, &ctx, info->extack); + err =devlink_param_set (devlink, devlink_port, param, + &ctx, info->extack);if (err)return err; }
@@ -676,8 +680,12 @@ int devlink_nl_port_param_get_doit(struct sk_buff *skb,int devlink_nl_port_param_set_doit (struct sk_buff *skb,struct genl_info *info) { -NL_SET_ERR_MSG (info->extack,"Port params are not supported" ); -return -EINVAL ; +struct devlink_port *devlink_port = info->user_ptr[1 ]; +struct devlink *devlink = info->user_ptr[0 ]; + +return __devlink_nl_cmd_param_set_doit (devlink, devlink_port, + &devlink_port->params, info, +DEVLINK_CMD_PORT_PARAM_NEW ); }static int devlink_param_verify (const struct devlink_param *param)
Signature · 1 line
2.48.1
PATCH 10/14 devlink: Add 'keep_link_up' generic devlink device param
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Devices that support this in permanent mode will be requested to keep the port link up even when driver is not loaded, netdev carrier state won't affect the physical port link state.
This is useful for when the link is needed to access onboard management such as BMC, even if the host driver isn't loaded.
--- Documentation/networking/devlink/devlink-params.rst | 4 ++++ include/net/devlink.h | 4 ++++ net/devlink/param.c | 4 ++++ 3 files changed, 12 insertions(+)
Documentation/networking/devlink/devlink-params.rst +4 -0
@@ -140,3 +140,7 @@ own name. * - ``total_vfs`` - u32 - The total number of Virtual Functions (VFs) supported by the PF. + * - ``keep_link_up`` + - Boolean + - When enabled, the device will keep the port link up even if the driver is + not loaded.
include/net/devlink.h +4 -0
@@ -523,6 +523,7 @@ enum devlink_param_generic_id {DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE ,DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE ,DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS , +DEVLINK_PARAM_GENERIC_ID_KEEP_LINK_UP ,/* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX,
@@ -584,6 +585,9 @@ enum devlink_param_generic_id {#define DEVLINK_PARAM_GENERIC_TOTAL_VFS_NAME "total_vfs"#define DEVLINK_PARAM_GENERIC_TOTAL_VFS_TYPE DEVLINK_PARAM_TYPE_U32 +#define DEVLINK_PARAM_GENERIC_KEEP_LINK_UP_NAME "keep_link_up" +#define DEVLINK_PARAM_GENERIC_KEEP_LINK_UP_TYPE DEVLINK_PARAM_TYPE_BOOL +#define DEVLINK_PARAM_GENERIC (_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \
net/devlink/param.c +4 -0
@@ -97,6 +97,10 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_TOTAL_VFS_NAME, .type = DEVLINK_PARAM_GENERIC_TOTAL_VFS_TYPE, }, + { .id = DEVLINK_PARAM_GENERIC_ID_KEEP_LINK_UP, + .name = DEVLINK_PARAM_GENERIC_KEEP_LINK_UP_NAME, + .type = DEVLINK_PARAM_GENERIC_KEEP_LINK_UP_TYPE, + }, };static int devlink_param_generic_verify (const struct devlink_param *param)
Signature · 1 line
2.48.1
PATCH 11/14 net/mlx5: Implement devlink keep_link_up port parameter
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
When set, the NIC keeps the link up as long as the host is not in standby mode, even when the driver is not loaded.
When enabled, netdev carrier state won't affect the physical port link state.
This is useful for when the link is needed to access onboard management such as BMC, even if the host driver isn't loaded.
--- Documentation/networking/devlink/mlx5.rst | 5 + .../ethernet/mellanox/mlx5/core/en/devlink.c | 16 ++- .../ethernet/mellanox/mlx5/core/en/devlink.h | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../mellanox/mlx5/core/lib/nv_param.c | 129 ++++++++++++++++++ .../mellanox/mlx5/core/lib/nv_param.h | 2 + 6 files changed, 153 insertions(+), 6 deletions(-)
Documentation/networking/devlink/mlx5.rst +5 -0
@@ -45,6 +45,11 @@ 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. + * - ``keep_link_up`` + - permanent + - Boolean + - When set, the NIC keeps the link up as long as the host is not in standby + mode, even when the driver is not loaded. Note: permanent parameters such as ``enable_sriov`` and ``total_vfs`` require FW reset to take effect
drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c +13 -3
@@ -3,6 +3,7 @@#include "en/devlink.h" #include "eswitch.h" +#include "lib/nv_param.h" static const struct devlink_ops mlx5e_devlink_ops = { };
@@ -54,6 +55,7 @@ int mlx5e_devlink_port_register(struct mlx5e_dev *mlx5e_dev,struct devlink_port_attrs attrs = {};struct netdev_phys_item_id ppid = {};unsigned int dl_port_index; +int err;if (mlx5_core_is_pf (mdev)) { attrs.flavour =DEVLINK_PORT_FLAVOUR_PHYSICAL ;
@@ -72,11 +74,19 @@ int mlx5e_devlink_port_register(struct mlx5e_dev *mlx5e_dev,devlink_port_attrs_set (&mlx5e_dev->dl_port, &attrs); -return devlink_port_register (devlink, &mlx5e_dev->dl_port, - dl_port_index); + err =devlink_port_register (devlink, &mlx5e_dev->dl_port, + dl_port_index); +if (err) +return err; + + err =mlx5_nv_port_param_register (mdev, &mlx5e_dev->dl_port); +if (err) +mlx5_core_warn (mdev,"Failed to register eth port params\n" ); +return 0 ; } -void mlx5e_devlink_port_unregister (struct mlx5e_dev *mlx5e_dev) +void mlx5e_devlink_port_unregister (struct mlx5e_dev *mlx5e_dev,struct mlx5_core_dev *mdev) { +mlx5_nv_port_param_unregister (mdev, &mlx5e_dev->dl_port);devlink_port_unregister (&mlx5e_dev->dl_port); }
drivers/net/ethernet/mellanox/mlx5/core/en/devlink.h +2 -1
@@ -12,6 +12,7 @@ struct mlx5e_dev *mlx5e_create_devlink(struct device *dev,void mlx5e_destroy_devlink (struct mlx5e_dev *mlx5e_dev);int mlx5e_devlink_port_register (struct mlx5e_dev *mlx5e_dev,struct mlx5_core_dev *mdev); -void mlx5e_devlink_port_unregister (struct mlx5e_dev *mlx5e_dev); +void mlx5e_devlink_port_unregister (struct mlx5e_dev *mlx5e_dev, +struct mlx5_core_dev *mdev);#endif
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -2
@@ -6484,7 +6484,7 @@ static int _mlx5e_probe(struct auxiliary_device *adev) err_destroy_netdev:mlx5e_destroy_netdev (priv); err_devlink_port_unregister: -mlx5e_devlink_port_unregister (mlx5e_dev); +mlx5e_devlink_port_unregister (mlx5e_dev, mdev); err_devlink_unregister:mlx5e_destroy_devlink (mlx5e_dev);return err;
@@ -6538,7 +6538,7 @@ static void _mlx5e_remove(struct auxiliary_device *adev)if (priv->profile) priv->profile->cleanup (priv);mlx5e_destroy_netdev (priv); -mlx5e_devlink_port_unregister (mlx5e_dev); +mlx5e_devlink_port_unregister (mlx5e_dev, mdev);mlx5e_destroy_devlink (mlx5e_dev); }
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +129 -0
162 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.h +2 -0
@@ -9,6 +9,8 @@int mlx5_nv_param_register_dl_params (struct devlink *devlink);void mlx5_nv_param_unregister_dl_params (struct devlink *devlink); +int mlx5_nv_port_param_register (struct mlx5_core_dev *dev,struct devlink_port *port); +void mlx5_nv_port_param_unregister (struct mlx5_core_dev *dev,struct devlink_port *port);#endif
Signature · 1 line
2.48.1
PATCH 12/14 devlink: Throw extack messages on param value validation error
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Centralize devlink param value data validation in one function and fill corresponding extack error messages on validation error.
--- net/devlink/param.c | 76 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 16 deletions(-)
net/devlink/param.c +60 -16
@@ -458,45 +458,89 @@ devlink_param_type_get_from_info(struct genl_info *info,return 0 ; } +static int +devlink_param_value_validate (struct genl_info *info, +enum devlink_param_type type) +{ +struct netlink_ext_ack *extack = info->extack; +struct nlattr *param_data; +int len =0 ; + +if (type !=DEVLINK_PARAM_TYPE_BOOL && +GENL_REQ_ATTR_CHECK (info,DEVLINK_ATTR_PARAM_VALUE_DATA )) +return -EINVAL ; + + param_data = info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA ]; + +if (param_data) + len =nla_len (param_data); + +switch (type) { +case DEVLINK_PARAM_TYPE_U8 : +if (len ==sizeof (u8)) +return 0 ; +NL_SET_ERR_MSG_FMT_MOD (extack, +"Expected uint8, got %d bytes" , len); +break ; +case DEVLINK_PARAM_TYPE_U16 : +if (len ==sizeof (u16)) +return 0 ; +NL_SET_ERR_MSG_FMT_MOD (extack, +"Expected uint16, got %d bytes" , len); +break ; +case DEVLINK_PARAM_TYPE_U32 : +if (len ==sizeof (u32)) +return 0 ; +NL_SET_ERR_MSG_FMT_MOD (extack, +"Expected uint32, got %d bytes" , len); +break ; +case DEVLINK_PARAM_TYPE_STRING : + len =strnlen (nla_data (param_data),nla_len (param_data)); + +if (len <nla_len (param_data) && + len < __DEVLINK_PARAM_MAX_STRING_VALUE) +return 0 ; +NL_SET_ERR_MSG_MOD (extack,"String too long" ); +break ; +case DEVLINK_PARAM_TYPE_BOOL : +if (!len) +return 0 ; +NL_SET_ERR_MSG_MOD (extack,"Expected flag, got data" ); +break ; +default : +NL_SET_ERR_MSG_FMT_MOD (extack, +"Not supported value type %d" , type); +break ; + } +return -EINVAL ; +} +static int devlink_param_value_get_from_info (const struct devlink_param *param,struct genl_info *info,union devlink_param_value *value) {struct nlattr *param_data; -int len; - - param_data = info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA ]; -if (param->type !=DEVLINK_PARAM_TYPE_BOOL && !param_data) +if (devlink_param_value_validate (info, param->type))return -EINVAL ; + param_data = info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA ]; +switch (param->type) {case DEVLINK_PARAM_TYPE_U8 : -if (nla_len (param_data) !=sizeof (u8)) -return -EINVAL ; value->vu8 =nla_get_u8 (param_data);break ;case DEVLINK_PARAM_TYPE_U16 : -if (nla_len (param_data) !=sizeof (u16)) -return -EINVAL ; value->vu16 =nla_get_u16 (param_data);break ;case DEVLINK_PARAM_TYPE_U32 : -if (nla_len (param_data) !=sizeof (u32)) -return -EINVAL ; value->vu32 =nla_get_u32 (param_data);break ;case DEVLINK_PARAM_TYPE_STRING : - len =strnlen (nla_data (param_data),nla_len (param_data)); -if (len ==nla_len (param_data) || - len >= __DEVLINK_PARAM_MAX_STRING_VALUE) -return -EINVAL ;strcpy (value->vstr,nla_data (param_data));break ;case DEVLINK_PARAM_TYPE_BOOL : -if (param_data &&nla_len (param_data)) -return -EINVAL ; value->vbool =nla_get_flag (param_data);break ; }
Signature · 1 line
2.48.1
PATCH 13/14 devlink: Implement devlink param multi attribute nested data values
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
Devlink param value attribute is not defined since devlink is handling the value validating and parsing internally, this allows us to implement multi attribute values without breaking any policies.
Devlink param multi-attribute values are considered to be dynamically sized arrays of u32 values, by introducing a new devlink param type DEVLINK_PARAM_TYPE_ARR_U32, driver and user space can set a variable count of u32 values into the DEVLINK_ATTR_PARAM_VALUE_DATA attribute.
Implement get/set parsing and add to the internal value structure passed to drivers.
This is useful for devices that need to configure a list of values for a specific configuration.
example:
$ devlink dev param show pci/... name multi-value-param
name multi-value-param type driver-specific
values:
cmode permanent value: 0,1,2,3,4,5,6,7$ devlink dev param set pci/... name multi-value-param \ value 4,5,6,7,0,1,2,3 cmode permanent
--- include/net/devlink.h | 7 ++++++ include/uapi/linux/devlink.h | 1 + net/devlink/param.c | 47 +++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 1 deletion(-)
include/net/devlink.h +7 -0
@@ -420,12 +420,15 @@ typedef u64 devlink_resource_occ_get_t(void *priv);#define DEVLINK_RESOURCE_GENERIC_NAME_PORTS "physical_ports"#define __DEVLINK_PARAM_MAX_STRING_VALUE 32 +#define __DEVLINK_PARAM_MAX_ARRAY_SIZE 32 +enum devlink_param_type {DEVLINK_PARAM_TYPE_U8 ,DEVLINK_PARAM_TYPE_U16 ,DEVLINK_PARAM_TYPE_U32 ,DEVLINK_PARAM_TYPE_STRING ,DEVLINK_PARAM_TYPE_BOOL , +DEVLINK_PARAM_TYPE_ARR_U32 , };union devlink_param_value {
@@ -434,6 +437,10 @@ union devlink_param_value {u32 vu32;char vstr[__DEVLINK_PARAM_MAX_STRING_VALUE];bool vbool; +struct { +u32 size; +u32 vu32[__DEVLINK_PARAM_MAX_ARRAY_SIZE]; + } arr; };struct devlink_param_gset_ctx {
include/uapi/linux/devlink.h +1 -0
@@ -400,6 +400,7 @@ enum devlink_dyn_attr_type {DEVLINK_DYN_ATTR_TYPE_BINARY , __DEVLINK_DYN_ATTR_TYPE_CUSTOM_BASE =0x80 ,/* Any possible custom types, unrelated to NLA_* values go below */ + DEVLINK_DYN_ATTR_TYPE_U32_ARRAY, }; enum devlink_attr {
net/devlink/param.c +46 -1
89 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH 14/14 net/mlx5: Implement eSwitch hairpin per prio buffers devlink params
In reply to Saeed MahameedFrom: Saeed Mahameed <[email protected]>
E-Switch hairpin per prio buffers are controlled and configurable by the device, add two devlink params to control them.
esw_haripin_per_prio_log_queue_size: p0,p1,....,p7
Log(base 2) of the number of packets descriptors allocated internally for hairpin for IEEE802.1p priorities. 0 means that no descriptors are allocated for this priority and traffic with this priority will be dropped.
esw_hairpin_per_prio_log_buf_size: p0,p1,...,p7
Log(base 2) of the buffer size (in bytes) allocated internally for hairpin for IEEE802.1p priorities.
0 means no buffer for this priority and traffic with this priority will be dropped.
--- Documentation/networking/devlink/mlx5.rst | 15 + .../net/ethernet/mellanox/mlx5/core/devlink.h | 4 +- .../mellanox/mlx5/core/lib/nv_param.c | 272 ++++++++++++++++++ 3 files changed, 290 insertions(+), 1 deletion(-)
Documentation/networking/devlink/mlx5.rst +15 -0
@@ -161,6 +161,21 @@ parameters. * ``balanced`` : Merges fewer CQEs, resulting in a moderate compression ratio but maintaining a balance between bandwidth savings and performance * ``aggressive`` : Merges more CQEs into a single entry, achieving a higher compression rate and maximizing performance, particularly under high traffic loads + * - ``esw_hairpin_per_prio_log_queue_size`` + - u32 array[8] + - permanent + - each item is log(base 2) of the number of packet descriptors allocated + internally for hairpin for IEEE802.1p priorities. + 0 means that no descriptors are allocated for this priority + and traffic with this priority will be dropped. + + * - ``esw_hairpin_per_prio_log_buf_size`` + - u32 array[8] + - permanent + - each item is log(base 2) of the buffer size (in bytes) allocated internally + for hairpin for IEEE802.1p priorities. + 0 means no buffer for this priority and traffic with this priority will be dropped. + The ``mlx5`` driver supports reloading via ``DEVLINK_CMD_RELOAD`` Info versions
drivers/net/ethernet/mellanox/mlx5/core/devlink.h +3 -1
@@ -22,7 +22,9 @@ enum mlx5_devlink_param_id {MLX5_DEVLINK_PARAM_ID_ESW_MULTIPORT ,MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES ,MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE , -MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE +MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE , +MLX5_DEVLINK_PARAM_ID_ESW_HAIRPIN_DESCRIPTORS , + MLX5_DEVLINK_PARAM_ID_ESW_HAIRPIN_DATA_SIZE, }; struct mlx5_trap_ctx {
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +272 -0
301 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH net-next 07/14] devlink: Implement port params registration
In reply to Saeed MahameedQuoted 10 lines · Saeed Mahameed
From: Saeed Mahameed <[email protected]>
Port params infrastructure is incomplete and needs a bit of plumbing to support port params commands from netlink.
Introduce port params registration API, very similar to current devlink params API, add the params xarray to
devlink_portstructure and decouple devlink params registration routines from the devlink structure.
Quoted 7 lines
Signed-off-by Saeed Mahameed <[email protected]>Reviewed-by Jiri Pirko <[email protected]>--- include/net/devlink.h | 14 ++++ net/devlink/param.c | 150 ++++++++++++++++++++++++++++++++++-------- net/devlink/port.c | 3 + 3 files changed, 140 insertions(+), 27 deletions(-)
For me devlink and devlink-port should be really the same, to the point that the only difference is bool is_port flag inside of the struct devlink. Then you could put special logic if really desired (to exclude something for port).
Then for ease of driver programming you could have also a flag "for_port" in the struct devlink_param, so developers will fill that out statically and call it on all their devlinks (incl port).
Multiplying the APIs instead of rethinking a problem is not a good long term solution.
Jiri Pirko
maintainerRe: [PATCH net-next 07/14] devlink: Implement port params registration
Quoted 18 lines · Fri, Feb 28, 2025 at 12:58:38PM +0100, [email protected] wrote:
Quoted 10 lines · Saeed Mahameed
From: Saeed Mahameed <[email protected]>
Port params infrastructure is incomplete and needs a bit of plumbing to support port params commands from netlink.
Introduce port params registration API, very similar to current devlink params API, add the params xarray to
devlink_portstructure and decouple devlink params registration routines from the devlink structure.Quoted 7 lines
Signed-off-by Saeed Mahameed <[email protected]>Reviewed-by Jiri Pirko <[email protected]>--- include/net/devlink.h | 14 ++++ net/devlink/param.c | 150 ++++++++++++++++++++++++++++++++++-------- net/devlink/port.c | 3 + 3 files changed, 140 insertions(+), 27 deletions(-)
Quoted 4 lines
For me devlink and devlink-port should be really the same, to the point that the only difference is
bool is_portflag inside of the struct devlink. Then you could put special logic if really desired (to exclude something for port).
Why? Why other devlink objects shouldn't be the same as well. Then we can have one union. Does not make sense to me. The only think dev and port is sharing would be params. What else? Totally different beast.
Quoted 7 lines
Then for ease of driver programming you could have also a flag "
for_port" in the structdevlink_param, so developers will fill that out statically and call it on all their devlinks (incl port).Multiplying the APIs instead of rethinking a problem is not a good long term solution.
Re: [PATCH net-next 02/14] devlink: Add 'total_vfs' generic device param
In reply to Saeed MahameedQuoted 11 lines · Fri, Feb 28, 2025 at 03:12:15AM +0100, [email protected] wrote:
From: Vlad Dumitrescu <[email protected]>
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_vfsparameter 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 <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Jiri Pirko
maintainerRe: [PATCH net-next 04/14] net/mlx5: Implement devlink enable_sriov parameter
In reply to Saeed MahameedQuoted 259 lines · Fri, Feb 28, 2025 at 03:12:17AM +0100, [email protected] wrote:
From: Vlad Dumitrescu <[email protected]>
Example usage:
devlink dev param set pci/0000:01:00.0 nameenable_sriovvalue {true, false} cmode permanent devlink dev reload pci/0000:01:00.0 actionfw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_*Signed-off-by Vlad Dumitrescu <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>---
Documentation/networking/devlink/mlx5.rst | 14 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 1 + .../mellanox/mlx5/core/lib/nv_param.c | 184 ++++++++++++++++++ 3 files changed, 196 insertions(+), 3 deletions(-)Documentation/networking/devlink/mlx5.rst +11
-3@@ -15,23 +15,31 @@ Parameters * - Name - Mode - Validation + - Notes * - ``enable_roce`` - driverinit - - Type: Boolean - - If the device supports RoCE disablement, RoCE enablement state controls + - Boolean + - If the device supports RoCE disablement, RoCE enablement state controls device support for RoCE capability. Otherwise, the control occurs in the driver stack. When RoCE is disabled at the driver level, only raw ethernet QPs are supported. * - ``io_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``event_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``max_macs`` - driverinit - The range is between 1 and 2^31. Only power of 2 values are supported. + - + * - ``enable_sriov`` + - permanent + - Boolean + - Applies to each physical function (PF) independently, if the device + supports it. Otherwise, it applies symmetrically to all PFs.The ``mlx5`` driver also implements the following driver-specific parameters.
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1
-0@@ -8,6 +8,7 @@#include "fs_core.h" #include "eswitch.h" #include "esw/qos.h" +#include "lib/nv_param.h" #include "sf/dev/dev.h" #include "sf/sf.h" #include "lib/nv_param.h" drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +158
-0@@ -5,7 +5,11 @@#include "mlx5_core.h" enum { +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF =0x80 , +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP =0x81 ,MLX5_CLASS_0_CTRL_ID_NV_SW_OFFLOAD_CONFIG =0x10a , + +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF =0x80 , };struct mlx5_ifc_configuration_item_type_class_global_bits {@@ -13,9 +17,18 @@ struct mlx5_ifc_configuration_item_type_class_global_bits {u8 parameter_index[0x18 ]; }; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits { +u8 type_class[0x8 ]; +u8 pf_index[0x6 ]; +u8 pci_bus_index[0x8 ]; +u8 parameter_index[0xa ]; +}; +union mlx5_ifc_config_item_type_auto_bits {struct mlx5_ifc_configuration_item_type_class_global_bits configuration_item_type_class_global; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits + configuration_item_type_class_per_host_pf;u8 reserved_at_0[0x20 ]; };@@ -45,6 +58,45 @@ struct mlx5_ifc_mnvda_reg_bits {u8 configuration_item_data[64 ][0x20 ]; }; +struct mlx5_ifc_nv_global_pci_conf_bits { +u8 sriov_valid[0x1 ]; +u8 reserved_at_1[0x10 ]; +u8 per_pf_total_vf[0x1 ]; +u8 reserved_at_12[0xe ]; + +u8 sriov_en[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 total_vfs[0x10 ]; + +u8 reserved_at_40[0x20 ]; +}; + +struct mlx5_ifc_nv_global_pci_cap_bits { +u8 max_vfs_per_pf_valid[0x1 ]; +u8 reserved_at_1[0x13 ]; +u8 per_pf_total_vf_supported[0x1 ]; +u8 reserved_at_15[0xb ]; + +u8 sriov_support[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 max_vfs_per_pf[0x10 ]; + +u8 reserved_at_40[0x60 ]; +}; + +struct mlx5_ifc_nv_pf_pci_conf_bits { +u8 reserved_at_0[0x9 ]; +u8 pf_total_vf_en[0x1 ]; +u8 reserved_at_a[0x16 ]; + +u8 reserved_at_20[0x20 ]; + +u8 reserved_at_40[0x10 ]; +u8 total_vf[0x10 ]; + +u8 reserved_at_60[0x20 ]; +}; +struct mlx5_ifc_nv_sw_offload_conf_bits {u8 ip_over_vxlan_port[0x10 ];u8 tunnel_ecn_copy_offload_disable[0x1 ];@@ -206,7 +258,139 @@ static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 ireturn mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); } +static int +mlx5_nv_param_read_global_pci_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_global_pci_cap (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_cap); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_per_host_pf_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, type_class,3 ); +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, parameter_index, +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_pf_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int mlx5_devlink_enable_sriov_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +void *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_cap, data, sriov_support)) { + ctx->val.vbool = false; +return 0 ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_conf, data, per_pf_total_vf)) { + ctx->val.vbool =MLX5_GET (nv_global_pci_conf, data, sriov_en); +return 0 ; + } + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + ctx->val.vbool =MLX5_GET (nv_pf_pci_conf, data, pf_total_vf_en); +return 0 ; +} + +static int mlx5_devlink_enable_sriov_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +bool per_pf_support; +void *cap, *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to read global PCI capability" ); +return err; + } + + cap =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + per_pf_support =MLX5_GET (nv_global_pci_cap, cap, per_pf_total_vf_supported); + +if (!MLX5_GET (nv_global_pci_cap, cap, sriov_support)) { +NL_SET_ERR_MSG_MOD (extack,"Not configurable on this device" ); +return -EOPNOTSUPP ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read global PCI configuration" ); +return err; + } + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +MLX5_SET (nv_global_pci_conf, data, sriov_valid,1 );
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 i · line 376
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +10
-0+MLX5_SET (nv_global_pci_conf, data, sriov_en, ctx->val.vbool); +MLX5_SET (nv_global_pci_conf, data, per_pf_total_vf, per_pf_support); + + err =mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to write global PCI configuration" ); +return err; + } + +if (!per_pf_support)
Hmm, given the discussion we have in parallel about some shared-PF devlink instance, perhaps it would be good idea to allow only per-pf configuration here for now and let the "global" per-device configuration knob to be attached on the shared-PF devlink, when/if it lands. What do you think?
Quoted 24 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +16
-0+return 0 ; + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read per host PF configuration" ); +return err; + } +MLX5_SET (nv_pf_pci_conf, data, pf_total_vf_en, ctx->val.vbool); +return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +} +static const struct devlink_param mlx5_nv_param_devlink_params[] = { +DEVLINK_PARAM_GENERIC (ENABLE_SRIOV ,BIT (DEVLINK_PARAM_CMODE_PERMANENT ), + mlx5_devlink_enable_sriov_get, + mlx5_devlink_enable_sriov_set,NULL ), DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE, "cqe_compress_type", DEVLINK_PARAM_TYPE_STRING, BIT(DEVLINK_PARAM_CMODE_PERMANENT),Signature · 1 line
2.48.1
Re: [PATCH net-next 09/14] devlink: Implement set netlink command for port params
In reply to Saeed MahameedQuoted 10 lines · Fri, Feb 28, 2025 at 03:12:22AM +0100, [email protected] wrote:
From: Saeed Mahameed <[email protected]>
Add missing port-params netlink attributes and policies to devlink's spec, reuse existing
set_doitof the devlink dev params.This implements:
devlink port param set <device>/<port> name <param_name> value <val> \
cmode <cmode>Signed-off-by Saeed Mahameed <[email protected]>
Re: [PATCH net-next 10/14] devlink: Add 'keep_link_up' generic devlink device param
In reply to Saeed MahameedQuoted 10 lines · Fri, Feb 28, 2025 at 03:12:23AM +0100, [email protected] wrote:
From: Saeed Mahameed <[email protected]>
Devices that support this in permanent mode will be requested to keep the port link up even when driver is not loaded, netdev carrier state won't affect the physical port link state.
This is useful for when the link is needed to access onboard management such as BMC, even if the host driver isn't loaded.
Signed-off-by Saeed Mahameed <[email protected]>
Re: [PATCH net-next 11/14] net/mlx5: Implement devlink keep_link_up port parameter
In reply to Saeed MahameedQuoted 11 lines · Fri, Feb 28, 2025 at 03:12:24AM +0100, [email protected] wrote:
From: Saeed Mahameed <[email protected]>
When set, the NIC keeps the link up as long as the host is not in standby mode, even when the driver is not loaded.
When enabled, netdev carrier state won't affect the physical port link state.
This is useful for when the link is needed to access onboard management such as BMC, even if the host driver isn't loaded.
Signed-off-by Saeed Mahameed <[email protected]>
Re: [PATCH net-next 12/14] devlink: Throw extack messages on param value validation error
In reply to Saeed MahameedQuoted 6 lines · Fri, Feb 28, 2025 at 03:12:25AM +0100, [email protected] wrote:
From: Saeed Mahameed <[email protected]>
Centralize devlink param value data validation in one function and fill corresponding extack error messages on validation error.
Signed-off-by Saeed Mahameed <[email protected]>
Re: [PATCH net-next 07/14] devlink: Implement port params registration
In reply to Jiri PirkoQuoted 19 lines · Jiri Pirko
Quoted 18 lines · Fri, Feb 28, 2025 at 12:58:38PM +0100, [email protected] wrote:
Quoted 17 lines · Saeed Mahameed
From: Saeed Mahameed <[email protected]>
Port params infrastructure is incomplete and needs a bit of plumbing to support port params commands from netlink.
Introduce port params registration API, very similar to current devlink params API, add the params xarray to
devlink_portstructure and decouple devlink params registration routines from the devlink structure.Signed-off-by Saeed Mahameed <[email protected]>Reviewed-by Jiri Pirko <[email protected]>--- include/net/devlink.h | 14 ++++ net/devlink/param.c | 150 ++++++++++++++++++++++++++++++++++-------- net/devlink/port.c | 3 + 3 files changed, 140 insertions(+), 27 deletions(-)
Quoted 8 lines
Quoted 4 lines
For me devlink and devlink-port should be really the same, to the point that the only difference is
bool is_portflag inside of the struct devlink. Then you could put special logic if really desired (to exclude something for port).Why? Why other devlink objects shouldn't be the same as well. Then we can have one union. Does not make sense to me. The only think dev and port is sharing would be params. What else? Totally different beast.
Instead of focusing on differences try to find similarities.
health reporters per port and "toplevel",
just by grepping:devlink_nl_sb_pool_fill()devlink_nl_sb_port_pool_fill(),
devlink_region_create()devlink_port_region_create()
and there is no reason to assume that someone will not want to extend ports to have devlink resources or other thing
Jiri Pirko
maintainerRe: [PATCH net-next 07/14] devlink: Implement port params registration
Quoted 29 lines · Fri, Feb 28, 2025 at 02:23:00PM +0100, [email protected] wrote:
Quoted 19 lines · Jiri Pirko
Quoted 18 lines · Fri, Feb 28, 2025 at 12:58:38PM +0100, [email protected] wrote:
Quoted 17 lines · Saeed Mahameed
From: Saeed Mahameed <[email protected]>
Port params infrastructure is incomplete and needs a bit of plumbing to support port params commands from netlink.
Introduce port params registration API, very similar to current devlink params API, add the params xarray to
devlink_portstructure and decouple devlink params registration routines from the devlink structure.Signed-off-by Saeed Mahameed <[email protected]>Reviewed-by Jiri Pirko <[email protected]>--- include/net/devlink.h | 14 ++++ net/devlink/param.c | 150 ++++++++++++++++++++++++++++++++++-------- net/devlink/port.c | 3 + 3 files changed, 140 insertions(+), 27 deletions(-)Quoted 8 lines
Quoted 4 lines
For me devlink and devlink-port should be really the same, to the point that the only difference is
bool is_portflag inside of the struct devlink. Then you could put special logic if really desired (to exclude something for port).Why? Why other devlink objects shouldn't be the same as well. Then we can have one union. Does not make sense to me. The only think dev and port is sharing would be params. What else? Totally different beast.
Quoted 6 lines
Instead of focusing on differences try to find similarities.
health reporters per port and "toplevel",
just by grepping:devlink_nl_sb_pool_fill()devlink_nl_sb_port_pool_fill(),
Sharedbuffer is separate story.
Quoted 3 lines
devlink_region_create()devlink_port_region_create()
Okay, regions I missed.
Quoted 3 lines
and there is no reason to assume that someone will not want to extend ports to have devlink resources or other thing
But looks at differences. They are huge.
But perhaps I'm missing the point. What you want to achieve? Just to reduce API? That is always a tradeoff. I don't think the pros top the cons here.
Saeed Mahameed
maintainerRe: [PATCH net-next 04/14] net/mlx5: Implement devlink enable_sriov parameter
In reply to Jiri PirkoQuoted 269 lines · Jiri Pirko
Quoted 268 lines · Fri, Feb 28, 2025 at 03:12:17AM +0100, [email protected] wrote:
From: Vlad Dumitrescu <[email protected]>
Example usage:
devlink dev param set pci/0000:01:00.0 nameenable_sriovvalue {true, false} cmode permanent devlink dev reload pci/0000:01:00.0 actionfw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_*Signed-off-by Vlad Dumitrescu <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>---
Documentation/networking/devlink/mlx5.rst | 14 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 1 + .../mellanox/mlx5/core/lib/nv_param.c | 184 ++++++++++++++++++ 3 files changed, 196 insertions(+), 3 deletions(-)Documentation/networking/devlink/mlx5.rst +11
-3@@ -15,23 +15,31 @@ Parameters * - Name - Mode - Validation + - Notes * - ``enable_roce`` - driverinit - - Type: Boolean - - If the device supports RoCE disablement, RoCE enablement state controls + - Boolean + - If the device supports RoCE disablement, RoCE enablement state controls device support for RoCE capability. Otherwise, the control occurs in the driver stack. When RoCE is disabled at the driver level, only raw ethernet QPs are supported. * - ``io_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``event_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``max_macs`` - driverinit - The range is between 1 and 2^31. Only power of 2 values are supported. + - + * - ``enable_sriov`` + - permanent + - Boolean + - Applies to each physical function (PF) independently, if the device + supports it. Otherwise, it applies symmetrically to all PFs.The ``mlx5`` driver also implements the following driver-specific parameters.
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1
-0@@ -8,6 +8,7 @@#include "fs_core.h" #include "eswitch.h" #include "esw/qos.h" +#include "lib/nv_param.h" #include "sf/dev/dev.h" #include "sf/sf.h" #include "lib/nv_param.h" drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +167
-0@@ -5,7 +5,11 @@#include "mlx5_core.h" enum { +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF =0x80 , +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP =0x81 ,MLX5_CLASS_0_CTRL_ID_NV_SW_OFFLOAD_CONFIG =0x10a , + +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF =0x80 , };struct mlx5_ifc_configuration_item_type_class_global_bits {@@ -13,9 +17,18 @@ struct mlx5_ifc_configuration_item_type_class_global_bits {u8 parameter_index[0x18 ]; }; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits { +u8 type_class[0x8 ]; +u8 pf_index[0x6 ]; +u8 pci_bus_index[0x8 ]; +u8 parameter_index[0xa ]; +}; +union mlx5_ifc_config_item_type_auto_bits {struct mlx5_ifc_configuration_item_type_class_global_bits configuration_item_type_class_global; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits + configuration_item_type_class_per_host_pf;u8 reserved_at_0[0x20 ]; };@@ -45,6 +58,45 @@ struct mlx5_ifc_mnvda_reg_bits {u8 configuration_item_data[64 ][0x20 ]; }; +struct mlx5_ifc_nv_global_pci_conf_bits { +u8 sriov_valid[0x1 ]; +u8 reserved_at_1[0x10 ]; +u8 per_pf_total_vf[0x1 ]; +u8 reserved_at_12[0xe ]; + +u8 sriov_en[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 total_vfs[0x10 ]; + +u8 reserved_at_40[0x20 ]; +}; + +struct mlx5_ifc_nv_global_pci_cap_bits { +u8 max_vfs_per_pf_valid[0x1 ]; +u8 reserved_at_1[0x13 ]; +u8 per_pf_total_vf_supported[0x1 ]; +u8 reserved_at_15[0xb ]; + +u8 sriov_support[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 max_vfs_per_pf[0x10 ]; + +u8 reserved_at_40[0x60 ]; +}; + +struct mlx5_ifc_nv_pf_pci_conf_bits { +u8 reserved_at_0[0x9 ]; +u8 pf_total_vf_en[0x1 ]; +u8 reserved_at_a[0x16 ]; + +u8 reserved_at_20[0x20 ]; + +u8 reserved_at_40[0x10 ]; +u8 total_vf[0x10 ]; + +u8 reserved_at_60[0x20 ]; +}; +struct mlx5_ifc_nv_sw_offload_conf_bits {u8 ip_over_vxlan_port[0x10 ];u8 tunnel_ecn_copy_offload_disable[0x1 ];@@ -206,7 +258,139 @@ static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 ireturn mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); } +static int +mlx5_nv_param_read_global_pci_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_global_pci_cap (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_cap); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_per_host_pf_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, type_class,3 ); +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, parameter_index, +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_pf_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int mlx5_devlink_enable_sriov_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +void *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_cap, data, sriov_support)) { + ctx->val.vbool = false; +return 0 ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_conf, data, per_pf_total_vf)) { + ctx->val.vbool =MLX5_GET (nv_global_pci_conf, data, sriov_en); +return 0 ; + } + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + ctx->val.vbool =MLX5_GET (nv_pf_pci_conf, data, pf_total_vf_en); +return 0 ; +} + +static int mlx5_devlink_enable_sriov_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +bool per_pf_support; +void *cap, *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to read global PCI capability" ); +return err; + } + + cap =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + per_pf_support =MLX5_GET (nv_global_pci_cap, cap, per_pf_total_vf_supported); + +if (!MLX5_GET (nv_global_pci_cap, cap, sriov_support)) { +NL_SET_ERR_MSG_MOD (extack,"Not configurable on this device" ); +return -EOPNOTSUPP ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read global PCI configuration" ); +return err; + } + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +MLX5_SET (nv_global_pci_conf, data, sriov_valid,1 ); +MLX5_SET (nv_global_pci_conf, data, sriov_en, ctx->val.vbool); +MLX5_SET (nv_global_pci_conf, data, per_pf_total_vf, per_pf_support); + + err =mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to write global PCI configuration" ); +return err; + } +
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 i · line 376
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +1
-0+if (!per_pf_support)Hmm, given the discussion we have in parallel about some shared-PF devlink instance, perhaps it would be good idea to allow only per-pf configuration here for now and let the "global" per-device configuration knob to be attached on the shared-PF devlink, when/if it lands. What do you think?
Do we have an RFC? can you point me to it?
I am just worried about the conflicts between per-pf and global configs this will introduce, currently it is driver best effort, after that we might want to pick one direction, global vs per-pf if it will be separate knobs, and we probably will go with per-pf. Most CX devices support both modes and it is up to the driver to chose. So why do both global and per-pf when you can almost always do per-pf?
Quoted 26 lines
Quoted 26 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +16
-1+return 0 ; + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read per host PF configuration" ); +return err; + } +MLX5_SET (nv_pf_pci_conf, data, pf_total_vf_en, ctx->val.vbool); +return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +} +static const struct devlink_param mlx5_nv_param_devlink_params[] = { +DEVLINK_PARAM_GENERIC (ENABLE_SRIOV ,BIT (DEVLINK_PARAM_CMODE_PERMANENT ), + mlx5_devlink_enable_sriov_get, + mlx5_devlink_enable_sriov_set,NULL ), DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE, "cqe_compress_type", DEVLINK_PARAM_TYPE_STRING, BIT(DEVLINK_PARAM_CMODE_PERMANENT), --2.48.1
kernel test robot
build botRe: [PATCH net-next 04/14] net/mlx5: Implement devlink enable_sriov parameter
In reply to Saeed Mahameedkernel test robot noticed the following build warnings:
Hi Saeed,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Saeed-Mahameed/devlink-define-enum-for-attr-types-of-dynamic-attributes/20250228-101818 base: net-next/main patch link: https://lore.kernel.org/r/20250228021227.871993-5-saeed%40kernel.org patch subject: [PATCH net-next 04/14] net/mlx5: Implement devlink enable_sriov parameter compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
includecheck warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/mellanox/mlx5/core/devlink.c: lib/nv_param.h is included more than once.
vim +11 drivers/net/ethernet/mellanox/mlx5/core/devlink.c
5
6 #include "mlx5_core.h"
7 #include "fw_reset.h"
8 #include "fs_core.h"
9 #include "eswitch.h"
10 #include "esw/qos.h"
> 11 #include "lib/nv_param.h"
12 #include "sf/dev/dev.h"
13 #include "sf/sf.h"
> 14 #include "lib/nv_param.h"
15 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH net-next 12/14] devlink: Throw extack messages on param value validation error
In reply to Saeed MahameedHi Saeed,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Saeed-Mahameed/devlink-define-enum-for-attr-types-of-dynamic-attributes/20250228-101818 base: net-next/main patch link: https://lore.kernel.org/r/20250228021227.871993-13-saeed%40kernel.org patch subject: [PATCH net-next 12/14] devlink: Throw extack messages on param value validation error config: sparc-randconfig-r071-20250302 (https://download.01.org/0day-ci/archive/20250302/[email protected]/config) compiler: sparc-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:net/devlink/param.c:498 devlink_param_value_validate() error: we previously assumed 'param_data' could be null (see line 475)
vim +/param_data +498 net/devlink/param.c
ca557d9df319fed Saeed Mahameed 2025-02-27 461 static int
ca557d9df319fed Saeed Mahameed 2025-02-27 462 devlink_param_value_validate(struct genl_info *info,
ca557d9df319fed Saeed Mahameed 2025-02-27 463 enum devlink_param_type type)
ca557d9df319fed Saeed Mahameed 2025-02-27 464 {
ca557d9df319fed Saeed Mahameed 2025-02-27 465 struct netlink_ext_ack *extack = info->extack;
ca557d9df319fed Saeed Mahameed 2025-02-27 466 struct nlattr *param_data;
ca557d9df319fed Saeed Mahameed 2025-02-27 467 int len = 0;
ca557d9df319fed Saeed Mahameed 2025-02-27 468
ca557d9df319fed Saeed Mahameed 2025-02-27 469 if (type != DEVLINK_PARAM_TYPE_BOOL &&
ca557d9df319fed Saeed Mahameed 2025-02-27 470 GENL_REQ_ATTR_CHECK(info, DEVLINK_ATTR_PARAM_VALUE_DATA))
ca557d9df319fed Saeed Mahameed 2025-02-27 471 return -EINVAL;
ca557d9df319fed Saeed Mahameed 2025-02-27 472
ca557d9df319fed Saeed Mahameed 2025-02-27 473 param_data = info->attrs[DEVLINK_ATTR_PARAM_VALUE_DATA];
ca557d9df319fed Saeed Mahameed 2025-02-27 474 ca557d9df319fed Saeed Mahameed 2025-02-27 @475 if (param_data)
This assumes param_data can be NULL
ca557d9df319fed Saeed Mahameed 2025-02-27 476 len = nla_len(param_data);
ca557d9df319fed Saeed Mahameed 2025-02-27 477
ca557d9df319fed Saeed Mahameed 2025-02-27 478 switch (type) {
ca557d9df319fed Saeed Mahameed 2025-02-27 479 case DEVLINK_PARAM_TYPE_U8:
ca557d9df319fed Saeed Mahameed 2025-02-27 480 if (len == sizeof(u8))
ca557d9df319fed Saeed Mahameed 2025-02-27 481 return 0;
ca557d9df319fed Saeed Mahameed 2025-02-27 482 NL_SET_ERR_MSG_FMT_MOD(extack,
ca557d9df319fed Saeed Mahameed 2025-02-27 483 "Expected uint8, got %d bytes", len);
ca557d9df319fed Saeed Mahameed 2025-02-27 484 break;
ca557d9df319fed Saeed Mahameed 2025-02-27 485 case DEVLINK_PARAM_TYPE_U16:
ca557d9df319fed Saeed Mahameed 2025-02-27 486 if (len == sizeof(u16))
ca557d9df319fed Saeed Mahameed 2025-02-27 487 return 0;
ca557d9df319fed Saeed Mahameed 2025-02-27 488 NL_SET_ERR_MSG_FMT_MOD(extack,
ca557d9df319fed Saeed Mahameed 2025-02-27 489 "Expected uint16, got %d bytes", len);
ca557d9df319fed Saeed Mahameed 2025-02-27 490 break;
ca557d9df319fed Saeed Mahameed 2025-02-27 491 case DEVLINK_PARAM_TYPE_U32:
ca557d9df319fed Saeed Mahameed 2025-02-27 492 if (len == sizeof(u32))
ca557d9df319fed Saeed Mahameed 2025-02-27 493 return 0;
ca557d9df319fed Saeed Mahameed 2025-02-27 494 NL_SET_ERR_MSG_FMT_MOD(extack,
ca557d9df319fed Saeed Mahameed 2025-02-27 495 "Expected uint32, got %d bytes", len);
ca557d9df319fed Saeed Mahameed 2025-02-27 496 break;
ca557d9df319fed Saeed Mahameed 2025-02-27 497 case DEVLINK_PARAM_TYPE_STRING:
ca557d9df319fed Saeed Mahameed 2025-02-27 @498 len = strnlen(nla_data(param_data), nla_len(param_data));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Unchecked dereferences
ca557d9df319fed Saeed Mahameed 2025-02-27 499 ca557d9df319fed Saeed Mahameed 2025-02-27 500 if (len < nla_len(param_data) && ca557d9df319fed Saeed Mahameed 2025-02-27 501 len < __DEVLINK_PARAM_MAX_STRING_VALUE) ca557d9df319fed Saeed Mahameed 2025-02-27 502 return 0; ca557d9df319fed Saeed Mahameed 2025-02-27 503 NL_SET_ERR_MSG_MOD(extack, "String too long"); ca557d9df319fed Saeed Mahameed 2025-02-27 504 break; ca557d9df319fed Saeed Mahameed 2025-02-27 505 case DEVLINK_PARAM_TYPE_BOOL: ca557d9df319fed Saeed Mahameed 2025-02-27 506 if (!len) ca557d9df319fed Saeed Mahameed 2025-02-27 507 return 0; ca557d9df319fed Saeed Mahameed 2025-02-27 508 NL_SET_ERR_MSG_MOD(extack, "Expected flag, got data"); ca557d9df319fed Saeed Mahameed 2025-02-27 509 break; ca557d9df319fed Saeed Mahameed 2025-02-27 510 default: ca557d9df319fed Saeed Mahameed 2025-02-27 511 NL_SET_ERR_MSG_FMT_MOD(extack, ca557d9df319fed Saeed Mahameed 2025-02-27 512 "Not supported value type %d", type); ca557d9df319fed Saeed Mahameed 2025-02-27 513 break; ca557d9df319fed Saeed Mahameed 2025-02-27 514 } ca557d9df319fed Saeed Mahameed 2025-02-27 515 return -EINVAL; ca557d9df319fed Saeed Mahameed 2025-02-27 516 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jiri Pirko
maintainerRe: [PATCH net-next 04/14] net/mlx5: Implement devlink enable_sriov parameter
In reply to Saeed MahameedQuoted 279 lines · Fri, Feb 28, 2025 at 07:19:19PM +0100, [email protected] wrote:
Quoted 269 lines · Jiri Pirko
Quoted 268 lines · Fri, Feb 28, 2025 at 03:12:17AM +0100, [email protected] wrote:
From: Vlad Dumitrescu <[email protected]>
Example usage:
devlink dev param set pci/0000:01:00.0 nameenable_sriovvalue {true, false} cmode permanent devlink dev reload pci/0000:01:00.0 actionfw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_*Signed-off-by Vlad Dumitrescu <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>---
Documentation/networking/devlink/mlx5.rst | 14 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 1 + .../mellanox/mlx5/core/lib/nv_param.c | 184 ++++++++++++++++++ 3 files changed, 196 insertions(+), 3 deletions(-)Documentation/networking/devlink/mlx5.rst +11
-3@@ -15,23 +15,31 @@ Parameters * - Name - Mode - Validation + - Notes * - ``enable_roce`` - driverinit - - Type: Boolean - - If the device supports RoCE disablement, RoCE enablement state controls + - Boolean + - If the device supports RoCE disablement, RoCE enablement state controls device support for RoCE capability. Otherwise, the control occurs in the driver stack. When RoCE is disabled at the driver level, only raw ethernet QPs are supported. * - ``io_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``event_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``max_macs`` - driverinit - The range is between 1 and 2^31. Only power of 2 values are supported. + - + * - ``enable_sriov`` + - permanent + - Boolean + - Applies to each physical function (PF) independently, if the device + supports it. Otherwise, it applies symmetrically to all PFs.The ``mlx5`` driver also implements the following driver-specific parameters.
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1
-0@@ -8,6 +8,7 @@#include "fs_core.h" #include "eswitch.h" #include "esw/qos.h" +#include "lib/nv_param.h" #include "sf/dev/dev.h" #include "sf/sf.h" #include "lib/nv_param.h" drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +167
-0@@ -5,7 +5,11 @@#include "mlx5_core.h" enum { +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF =0x80 , +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP =0x81 ,MLX5_CLASS_0_CTRL_ID_NV_SW_OFFLOAD_CONFIG =0x10a , + +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF =0x80 , };struct mlx5_ifc_configuration_item_type_class_global_bits {@@ -13,9 +17,18 @@ struct mlx5_ifc_configuration_item_type_class_global_bits {u8 parameter_index[0x18 ]; }; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits { +u8 type_class[0x8 ]; +u8 pf_index[0x6 ]; +u8 pci_bus_index[0x8 ]; +u8 parameter_index[0xa ]; +}; +union mlx5_ifc_config_item_type_auto_bits {struct mlx5_ifc_configuration_item_type_class_global_bits configuration_item_type_class_global; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits + configuration_item_type_class_per_host_pf;u8 reserved_at_0[0x20 ]; };@@ -45,6 +58,45 @@ struct mlx5_ifc_mnvda_reg_bits {u8 configuration_item_data[64 ][0x20 ]; }; +struct mlx5_ifc_nv_global_pci_conf_bits { +u8 sriov_valid[0x1 ]; +u8 reserved_at_1[0x10 ]; +u8 per_pf_total_vf[0x1 ]; +u8 reserved_at_12[0xe ]; + +u8 sriov_en[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 total_vfs[0x10 ]; + +u8 reserved_at_40[0x20 ]; +}; + +struct mlx5_ifc_nv_global_pci_cap_bits { +u8 max_vfs_per_pf_valid[0x1 ]; +u8 reserved_at_1[0x13 ]; +u8 per_pf_total_vf_supported[0x1 ]; +u8 reserved_at_15[0xb ]; + +u8 sriov_support[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 max_vfs_per_pf[0x10 ]; + +u8 reserved_at_40[0x60 ]; +}; + +struct mlx5_ifc_nv_pf_pci_conf_bits { +u8 reserved_at_0[0x9 ]; +u8 pf_total_vf_en[0x1 ]; +u8 reserved_at_a[0x16 ]; + +u8 reserved_at_20[0x20 ]; + +u8 reserved_at_40[0x10 ]; +u8 total_vf[0x10 ]; + +u8 reserved_at_60[0x20 ]; +}; +struct mlx5_ifc_nv_sw_offload_conf_bits {u8 ip_over_vxlan_port[0x10 ];u8 tunnel_ecn_copy_offload_disable[0x1 ];@@ -206,7 +258,139 @@ static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 ireturn mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); } +static int +mlx5_nv_param_read_global_pci_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_global_pci_cap (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_cap); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_per_host_pf_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, type_class,3 ); +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, parameter_index, +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_pf_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int mlx5_devlink_enable_sriov_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +void *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_cap, data, sriov_support)) { + ctx->val.vbool = false; +return 0 ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_conf, data, per_pf_total_vf)) { + ctx->val.vbool =MLX5_GET (nv_global_pci_conf, data, sriov_en); +return 0 ; + } + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + ctx->val.vbool =MLX5_GET (nv_pf_pci_conf, data, pf_total_vf_en); +return 0 ; +} + +static int mlx5_devlink_enable_sriov_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +bool per_pf_support; +void *cap, *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to read global PCI capability" ); +return err; + } + + cap =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + per_pf_support =MLX5_GET (nv_global_pci_cap, cap, per_pf_total_vf_supported); + +if (!MLX5_GET (nv_global_pci_cap, cap, sriov_support)) { +NL_SET_ERR_MSG_MOD (extack,"Not configurable on this device" ); +return -EOPNOTSUPP ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read global PCI configuration" ); +return err; + } + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +MLX5_SET (nv_global_pci_conf, data, sriov_valid,1 ); +MLX5_SET (nv_global_pci_conf, data, sriov_en, ctx->val.vbool); +MLX5_SET (nv_global_pci_conf, data, per_pf_total_vf, per_pf_support); + + err =mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to write global PCI configuration" ); +return err; + } +Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 i · line 376
Quoted 1 line
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +1
-0+if (!per_pf_support)Hmm, given the discussion we have in parallel about some shared-PF devlink instance, perhaps it would be good idea to allow only per-pf configuration here for now and let the "global" per-device configuration knob to be attached on the shared-PF devlink, when/if it lands. What do you think?
Quoted 1 line
Do we have an RFC? can you point me to it?
https://lore.kernel.org/all/[email protected]/
Quoted 7 lines
I am just worried about the conflicts between per-pf and global configs this will introduce, currently it is driver best effort, after that we might want to pick one direction, global vs per-pf if it will be separate knobs, and we probably will go with per-pf. Most CX devices support both modes and it is up to the driver to chose. So why do both global and per-pf when you can almost always do per-pf?
I was thinking that is device supports per-pf, only per-pf knob will be present. And if not, only "global" know will be present on the shared devlink instance.
Okay. So let's implement per-pf only now. And if the global is needed in the future for older devices and we'll have a devlink instance to hang in on, let's add it later. Makes sense?
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +16
-1+return 0 ; + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read per host PF configuration" ); +return err; + } +MLX5_SET (nv_pf_pci_conf, data, pf_total_vf_en, ctx->val.vbool); +return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +} +static const struct devlink_param mlx5_nv_param_devlink_params[] = { +DEVLINK_PARAM_GENERIC (ENABLE_SRIOV ,BIT (DEVLINK_PARAM_CMODE_PERMANENT ), + mlx5_devlink_enable_sriov_get, + mlx5_devlink_enable_sriov_set,NULL ), DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE, "cqe_compress_type", DEVLINK_PARAM_TYPE_STRING, BIT(DEVLINK_PARAM_CMODE_PERMANENT), --2.48.1
Re: [PATCH net-next 02/14] devlink: Add 'total_vfs' generic device param
In reply to Saeed MahameedQuoted 11 lines · Saeed Mahameed
From: Vlad Dumitrescu <[email protected]>
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_vfsparameter 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 <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Quoted 59 lines
--- Documentation/networking/devlink/devlink-params.rst | 3 +++ include/net/devlink.h | 4 ++++ net/devlink/param.c | 5 +++++ 3 files changed, 12 insertions(+)Documentation/networking/devlink/devlink-params.rst +3
-0@@ -137,3 +137,6 @@ own name. * - ``event_eq_size`` - u32 - Control the size of asynchronous control events EQ. + * - ``total_vfs`` + - u32 + - The total number of Virtual Functions (VFs) supported by the PF.include/net/devlink.h +4
-0@@ -520,6 +520,7 @@ enum devlink_param_generic_id {DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP ,DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE ,DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE , +DEVLINK_PARAM_GENERIC_ID_TOTAL_VFS ,/* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX,@@ -578,6 +579,9 @@ enum devlink_param_generic_id {#define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME "event_eq_size"#define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE DEVLINK_PARAM_TYPE_U32 +#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, \net/devlink/param.c +5
-0@@ -92,6 +92,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME, .type = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_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)Signature · 1 line
2.48.1
Re: [PATCH net-next 04/14] net/mlx5: Implement devlink enable_sriov parameter
In reply to Saeed MahameedQuoted 11 lines · Saeed Mahameed
From: Vlad Dumitrescu <[email protected]>
Example usage:
devlink dev param set pci/0000:01:00.0 nameenable_sriovvalue {true, false} cmode permanent devlink dev reload pci/0000:01:00.0 actionfw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_*Signed-off-by Vlad Dumitrescu <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>
Quoted 282 lines
--- Documentation/networking/devlink/mlx5.rst | 14 +- .../net/ethernet/mellanox/mlx5/core/devlink.c | 1 + .../mellanox/mlx5/core/lib/nv_param.c | 184 ++++++++++++++++++ 3 files changed, 196 insertions(+), 3 deletions(-)Documentation/networking/devlink/mlx5.rst +11
-3@@ -15,23 +15,31 @@ Parameters * - Name - Mode - Validation + - Notes * - ``enable_roce`` - driverinit - - Type: Boolean - - If the device supports RoCE disablement, RoCE enablement state controls + - Boolean + - If the device supports RoCE disablement, RoCE enablement state controls device support for RoCE capability. Otherwise, the control occurs in the driver stack. When RoCE is disabled at the driver level, only raw ethernet QPs are supported. * - ``io_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``event_eq_size`` - driverinit - The range is between 64 and 4096. + - * - ``max_macs`` - driverinit - The range is between 1 and 2^31. Only power of 2 values are supported. + - + * - ``enable_sriov`` + - permanent + - Boolean + - Applies to each physical function (PF) independently, if the device + supports it. Otherwise, it applies symmetrically to all PFs. The ``mlx5`` driver also implements the following driver-specific parameters.drivers/net/ethernet/mellanox/mlx5/core/devlink.c +1
-0@@ -8,6 +8,7 @@#include "fs_core.h" #include "eswitch.h" #include "esw/qos.h" +#include "lib/nv_param.h" #include "sf/dev/dev.h" #include "sf/sf.h" #include "lib/nv_param.h" drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +184
-0@@ -5,7 +5,11 @@#include "mlx5_core.h" enum { +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF =0x80 , +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP =0x81 ,MLX5_CLASS_0_CTRL_ID_NV_SW_OFFLOAD_CONFIG =0x10a , + +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF =0x80 , };struct mlx5_ifc_configuration_item_type_class_global_bits {@@ -13,9 +17,18 @@ struct mlx5_ifc_configuration_item_type_class_global_bits {u8 parameter_index[0x18 ]; }; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits { +u8 type_class[0x8 ]; +u8 pf_index[0x6 ]; +u8 pci_bus_index[0x8 ]; +u8 parameter_index[0xa ]; +}; +union mlx5_ifc_config_item_type_auto_bits {struct mlx5_ifc_configuration_item_type_class_global_bits configuration_item_type_class_global; +struct mlx5_ifc_configuration_item_type_class_per_host_pf_bits + configuration_item_type_class_per_host_pf;u8 reserved_at_0[0x20 ]; };@@ -45,6 +58,45 @@ struct mlx5_ifc_mnvda_reg_bits {u8 configuration_item_data[64 ][0x20 ]; }; +struct mlx5_ifc_nv_global_pci_conf_bits { +u8 sriov_valid[0x1 ]; +u8 reserved_at_1[0x10 ]; +u8 per_pf_total_vf[0x1 ]; +u8 reserved_at_12[0xe ]; + +u8 sriov_en[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 total_vfs[0x10 ]; + +u8 reserved_at_40[0x20 ]; +}; + +struct mlx5_ifc_nv_global_pci_cap_bits { +u8 max_vfs_per_pf_valid[0x1 ]; +u8 reserved_at_1[0x13 ]; +u8 per_pf_total_vf_supported[0x1 ]; +u8 reserved_at_15[0xb ]; + +u8 sriov_support[0x1 ]; +u8 reserved_at_21[0xf ]; +u8 max_vfs_per_pf[0x10 ]; + +u8 reserved_at_40[0x60 ]; +}; + +struct mlx5_ifc_nv_pf_pci_conf_bits { +u8 reserved_at_0[0x9 ]; +u8 pf_total_vf_en[0x1 ]; +u8 reserved_at_a[0x16 ]; + +u8 reserved_at_20[0x20 ]; + +u8 reserved_at_40[0x10 ]; +u8 total_vf[0x10 ]; + +u8 reserved_at_60[0x20 ]; +}; +struct mlx5_ifc_nv_sw_offload_conf_bits {u8 ip_over_vxlan_port[0x10 ];u8 tunnel_ecn_copy_offload_disable[0x1 ];@@ -206,7 +258,139 @@ static int mlx5_nv_param_devlink_cqe_compress_set(struct devlink *devlink, u32 ireturn mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); } +static int +mlx5_nv_param_read_global_pci_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_global_pci_cap (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, type_class,0 ); +MLX5_SET_CONFIG_ITEM_TYPE (global, mnvda, parameter_index, +MLX5_CLASS_0_CTRL_ID_NV_GLOBAL_PCI_CAP ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_global_pci_cap); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int +mlx5_nv_param_read_per_host_pf_conf (struct mlx5_core_dev *dev,void *mnvda,size_t len) +{ +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, type_class,3 ); +MLX5_SET_CONFIG_ITEM_TYPE (per_host_pf, mnvda, parameter_index, +MLX5_CLASS_3_CTRL_ID_NV_PF_PCI_CONF ); +MLX5_SET_CONFIG_HDR_LEN (mnvda, nv_pf_pci_conf); + +return mlx5_nv_param_read (dev, mnvda, len); +} + +static int mlx5_devlink_enable_sriov_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +void *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_cap, data, sriov_support)) { + ctx->val.vbool = false; +return 0 ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_conf, data, per_pf_total_vf)) { + ctx->val.vbool =MLX5_GET (nv_global_pci_conf, data, sriov_en); +return 0 ; + } + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + ctx->val.vbool =MLX5_GET (nv_pf_pci_conf, data, pf_total_vf_en); +return 0 ; +} + +static int mlx5_devlink_enable_sriov_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +bool per_pf_support; +void *cap, *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to read global PCI capability" ); +return err; + } + + cap =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + per_pf_support =MLX5_GET (nv_global_pci_cap, cap, per_pf_total_vf_supported); + +if (!MLX5_GET (nv_global_pci_cap, cap, sriov_support)) { +NL_SET_ERR_MSG_MOD (extack,"Not configurable on this device" ); +return -EOPNOTSUPP ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read global PCI configuration" ); +return err; + } + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +MLX5_SET (nv_global_pci_conf, data, sriov_valid,1 ); +MLX5_SET (nv_global_pci_conf, data, sriov_en, ctx->val.vbool); +MLX5_SET (nv_global_pci_conf, data, per_pf_total_vf, per_pf_support); + + err =mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to write global PCI configuration" ); +return err; + } + +if (!per_pf_support) +return 0 ; + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Unable to read per host PF configuration" ); +return err; + } +MLX5_SET (nv_pf_pci_conf, data, pf_total_vf_en, ctx->val.vbool); +return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +} +static const struct devlink_param mlx5_nv_param_devlink_params[] = { +DEVLINK_PARAM_GENERIC (ENABLE_SRIOV ,BIT (DEVLINK_PARAM_CMODE_PERMANENT ), + mlx5_devlink_enable_sriov_get, + mlx5_devlink_enable_sriov_set,NULL ), DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE, "cqe_compress_type", DEVLINK_PARAM_TYPE_STRING, BIT(DEVLINK_PARAM_CMODE_PERMANENT),Signature · 1 line
2.48.1
Re: [PATCH net-next 05/14] net/mlx5: Implement devlink total_vfs parameter
In reply to Saeed MahameedQuoted 14 lines · Saeed Mahameed
From: Vlad Dumitrescu <[email protected]>
Some devices support both symmetric (same value for all PFs) and asymmetric, while others only support symmetric configuration. This implementation prefers asymmetric, since it is closer to the devlink model (per function settings), but falls back to symmetric when needed.
Example usage:
devlink dev param set pci/0000:01:00.0 nametotal_vfsvalue <u16> cmode permanent devlink dev reload pci/0000:01:00.0 actionfw_activate
echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove
echo 1 >/sys/bus/pci/rescan
cat /sys/bus/pci/devices/0000:01:00.0/sriov_totalvfs
Quoted 3 lines
Signed-off-by Vlad Dumitrescu <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>Reviewed-by Jiri Pirko <[email protected]>
Quoted 182 lines
--- Documentation/networking/devlink/mlx5.rst | 22 +++ .../mellanox/mlx5/core/lib/nv_param.c | 125 ++++++++++++++++++ 2 files changed, 147 insertions(+)Documentation/networking/devlink/mlx5.rst +22
-0@@ -40,6 +40,28 @@ Parameters - Boolean - Applies to each physical function (PF) independently, if the device supports it. Otherwise, it applies symmetrically to all PFs. + * - ``total_vfs`` + - permanent + - 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. + +Note: permanent parameters such as ``enable_sriov`` and ``total_vfs`` require FW reset to take effect + +.. code-block:: bash + + # setup parameters + devlink dev param set pci/0000:01:00.0 name enable_sriov value true cmode permanent + devlink dev param set pci/0000:01:00.0 name total_vfs value 8 cmode permanent + + # Fw reset + devlink dev reload pci/0000:01:00.0 action fw_activate + + # for PCI related config such as sriov PCI reset/rescan is required: + echo 1 >/sys/bus/pci/devices/0000:01:00.0/remove + echo 1 >/sys/bus/pci/rescan + grep ^ /sys/bus/pci/devices/0000:01:00.0/sriov_* + The ``mlx5`` driver also implements the following driver-specific parameters.drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c +125
-0@@ -387,10 +387,135 @@ static int mlx5_devlink_enable_sriov_set(struct devlink *devlink, u32 id,return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); } +static int mlx5_devlink_total_vfs_get (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)] = {}; +void *data; +int err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + +if (!MLX5_GET (nv_global_pci_cap, data, sriov_support)) { + ctx->val.vu32 =0 ; +return 0 ; + } + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + +if (!MLX5_GET (nv_global_pci_conf, data, per_pf_total_vf)) { + ctx->val.vu32 =MLX5_GET (nv_global_pci_conf, data, total_vfs); +return 0 ; + } + +/* SRIOV is per PF */ +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + ctx->val.vu32 =MLX5_GET (nv_pf_pci_conf, data, total_vf); + +return 0 ; +} + +static int mlx5_devlink_total_vfs_set (struct devlink *devlink,u32 id, +struct devlink_param_gset_ctx *ctx, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 mnvda[MLX5_ST_SZ_DW (mnvda_reg)]; +bool per_pf_support; +void *data; +int err; + + err =mlx5_nv_param_read_global_pci_cap (dev, mnvda,sizeof (mnvda)); +if (err) { +NL_SET_ERR_MSG_MOD (extack,"Failed to read global pci cap" ); +return err; + } + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +if (!MLX5_GET (nv_global_pci_cap, data, sriov_support)) { +NL_SET_ERR_MSG_MOD (extack,"Not configurable on this device" ); +return -EOPNOTSUPP ; + } + + per_pf_support =MLX5_GET (nv_global_pci_cap, data, per_pf_total_vf_supported); +memset (mnvda,0 ,sizeof (mnvda)); + + err =mlx5_nv_param_read_global_pci_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + +MLX5_SET (nv_global_pci_conf, data, sriov_valid,1 ); +MLX5_SET (nv_global_pci_conf, data, per_pf_total_vf, per_pf_support); + +if (!per_pf_support) { +MLX5_SET (nv_global_pci_conf, data, total_vfs, ctx->val.vu32); +return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); + } + +/* SRIOV is per PF */ + err =mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + +memset (mnvda,0 ,sizeof (mnvda)); + err =mlx5_nv_param_read_per_host_pf_conf (dev, mnvda,sizeof (mnvda)); +if (err) +return err; + + data =MLX5_ADDR_OF (mnvda_reg, mnvda, configuration_item_data); +MLX5_SET (nv_pf_pci_conf, data, pf_total_vf_en,1 ); +MLX5_SET (nv_pf_pci_conf, data, total_vf, ctx->val.vu32); +return mlx5_nv_param_write (dev, mnvda,sizeof (mnvda)); +} + +static int mlx5_devlink_total_vfs_validate (struct devlink *devlink,u32 id, +union devlink_param_value val, +struct netlink_ext_ack *extack) +{ +struct mlx5_core_dev *dev =devlink_priv (devlink); +u32 cap[MLX5_ST_SZ_DW (mnvda_reg)]; +void *data; +u16 max; +int err; + + data =MLX5_ADDR_OF (mnvda_reg, cap, configuration_item_data); + + err =mlx5_nv_param_read_global_pci_cap (dev, cap,sizeof (cap)); +if (err) +return err; + +if (!MLX5_GET (nv_global_pci_cap, data, max_vfs_per_pf_valid)) +return 0 ;/* optimistic, but set might fail later */ + + max =MLX5_GET (nv_global_pci_cap, data, max_vfs_per_pf); +if (val.vu16 > max) { +NL_SET_ERR_MSG_FMT_MOD (extack, +"Max allowed by device is %u" , max); +return -EINVAL ; + } + +return 0 ; +} +static const struct devlink_param mlx5_nv_param_devlink_params[] = {DEVLINK_PARAM_GENERIC (ENABLE_SRIOV ,BIT (DEVLINK_PARAM_CMODE_PERMANENT ), mlx5_devlink_enable_sriov_get, mlx5_devlink_enable_sriov_set,NULL ), +DEVLINK_PARAM_GENERIC (TOTAL_VFS ,BIT (DEVLINK_PARAM_CMODE_PERMANENT ), + mlx5_devlink_total_vfs_get, mlx5_devlink_total_vfs_set, + mlx5_devlink_total_vfs_validate), DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CQE_COMPRESSION_TYPE, "cqe_compress_type", DEVLINK_PARAM_TYPE_STRING, BIT(DEVLINK_PARAM_CMODE_PERMANENT),Signature · 1 line
2.48.1
Simon Horman
reviewerRe: [PATCH net-next 01/14] devlink: define enum for attr types of dynamic attributes
In reply to Saeed MahameedQuoted 46 lines · Saeed Mahameed
From: Jiri Pirko <[email protected]>
Devlink param and health reporter fmsg use attributes with dynamic type which is determined according to a different type. Currently used values are NLA_*. The problem is, they are not part of UAPI. They may change which would cause a break.
To make this future safe, introduce a enum that shadows NLA_* values in it and is part of UAPI.
Also, this allows to possibly carry types that are unrelated to NLA_* values.
Signed-off-by Jiri Pirko <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- Documentation/netlink/specs/devlink.yaml | 23 ++++++++++++++++++ include/uapi/linux/devlink.h | 17 ++++++++++++++ net/devlink/health.c | 17 ++++++++++++-- net/devlink/param.c | 30 ++++++++++++------------ 4 files changed, 70 insertions(+), 17 deletions(-)Documentation/netlink/specs/devlink.yaml +16
-0@@ -202,6 +202,29 @@ definitions: name: exception - name: control + - + type: enum + name: dyn_attr_type + entries: + - + name: u8 + value: 1 + - + name: u16 + - + name: u32 + - + name: u64 + - + name: string + -
Documentation/netlink/specs/devlink.yaml definitions: · line 230
Quoted 10 lines
Documentation/netlink/specs/devlink.yaml +7
-0+ name: flag + - + name: nul_string + value: 10 + - + name: binary + - attribute-sets: -
Hi Saeed,
Thanks for these patches.
Unfortunately the above seems to cause ynl-regen to blow up. I don't know why, but I see:
$ ./tools/net/ynl/ynl-regen.sh
Traceback (most recent call last):
File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/ynl_gen_c.py", line 3074, in <module>
main()
~~~~^^
File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/ynl_gen_c.py", line 2783, in main
parsed = Family(args.spec, exclude_ops)
File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/ynl_gen_c.py", line 954, in __init__
super().__init__(file_name, exclude_ops=exclude_ops)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/lib/nlspec.py", line 462, in __init__
jsonschema.validate(self.yaml, schema)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/jsonschema/validators.py", line 1307, in validate
raise error
jsonschema.exceptions.ValidationError: None is not of type 'object'...
Perhaps I need a newer version of jsonschema?
include/uapi/linux/devlink.h enum devlink_linecard_state { · line 389
Quoted 10 lines
include/uapi/linux/devlink.h +2
-0@@ -385,6 +385,23 @@ enum devlink_linecard_state { DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1 }; +/** +* enum devlink_dyn_attr_type - Dynamic attribute type type.
Perhaps this relates to auto-generation.
But I think the Kernel doc should also document the enum values:DEVLINK_DYN_ATTR_TYPE_U8, ...
Quoted 18 lines
include/uapi/linux/devlink.h +15
-0+*/ +enum devlink_dyn_attr_type { +/* Following values relate to the internal NLA_* values */ +DEVLINK_DYN_ATTR_TYPE_U8 =1 , +DEVLINK_DYN_ATTR_TYPE_U16 , +DEVLINK_DYN_ATTR_TYPE_U32 , +DEVLINK_DYN_ATTR_TYPE_U64 , +DEVLINK_DYN_ATTR_TYPE_STRING , +DEVLINK_DYN_ATTR_TYPE_FLAG , +DEVLINK_DYN_ATTR_TYPE_NUL_STRING =10 , +DEVLINK_DYN_ATTR_TYPE_BINARY , + __DEVLINK_DYN_ATTR_TYPE_CUSTOM_BASE =0x80 , +/* Any possible custom types, unrelated to NLA_* values go below */ +}; +enum devlink_attr {/* don't change the order or add anything between, this is ABI! */ DEVLINK_ATTR_UNSPEC ,
...
Re: [PATCH net-next 01/14] devlink: define enum for attr types of dynamic attributes
Quoted 46 lines · Simon Horman
Quoted 45 lines · Saeed Mahameed
From: Jiri Pirko <[email protected]>
Devlink param and health reporter fmsg use attributes with dynamic type which is determined according to a different type. Currently used values are NLA_*. The problem is, they are not part of UAPI. They may change which would cause a break.
To make this future safe, introduce a enum that shadows NLA_* values in it and is part of UAPI.
Also, this allows to possibly carry types that are unrelated to NLA_* values.
Signed-off-by Jiri Pirko <[email protected]>Signed-off-by Saeed Mahameed <[email protected]>--- Documentation/netlink/specs/devlink.yaml | 23 ++++++++++++++++++ include/uapi/linux/devlink.h | 17 ++++++++++++++ net/devlink/health.c | 17 ++++++++++++-- net/devlink/param.c | 30 ++++++++++++------------ 4 files changed, 70 insertions(+), 17 deletions(-)Documentation/netlink/specs/devlink.yaml +15
-0@@ -202,6 +202,29 @@ definitions: name: exception - name: control + - + type: enum + name: dyn_attr_type + entries: + - + name: u8 + value: 1 + - + name: u16 + - + name: u32 + - + name: u64 + - + name: string
Quoted 8 lines
Documentation/netlink/specs/devlink.yaml definitions: · line 227
Quoted 8 lines
Documentation/netlink/specs/devlink.yaml +8
-0+ - + name: flag + - + name: nul_string + value: 10 + - + name: binary + -
^^^^^^^ extra empty type..
Quoted 6 lines
Hi Saeed,
Thanks for these patches.
Unfortunately the above seems to cause ynl-regen to blow up.
Thanks Simon, good catch, there was an extra empty type added by mistake, see above, will remove in V2.
Quoted 59 lines
I don't know why, but I see:
$ ./tools/net/ynl/ynl-regen.sh Traceback (most recent call last): File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/ynl_gen_c.py", line 3074, in <module> main() ~~~~^^ File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/ynl_gen_c.py", line 2783, in main parsed = Family(args.spec, exclude_ops) File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/ynl_gen_c.py", line 954, in __init__ super().__init__(file_name, exclude_ops=exclude_ops) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/nipa/net-next/wt-1/tools/net/ynl/pyynl/lib/nlspec.py", line 462, in __init__ jsonschema.validate(self.yaml, schema) ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/site-packages/jsonschema/validators.py", line 1307, in validate raise error jsonschema.exceptions.ValidationError: None is not of type 'object'...
Perhaps I need a newer version of jsonschema?
include/uapi/linux/devlink.h enum devlink_linecard_state { · line 389
Quoted 10 lines
include/uapi/linux/devlink.h +2
-0@@ -385,6 +385,23 @@ enum devlink_linecard_state { DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1 }; +/** +* enum devlink_dyn_attr_type - Dynamic attribute type type. Perhaps this relates to auto-generation.
But I think the Kernel doc should also document the enum values:DEVLINK_DYN_ATTR_TYPE_U8, ...Quoted 18 lines
include/uapi/linux/devlink.h +15
-0+*/ +enum devlink_dyn_attr_type { +/* Following values relate to the internal NLA_* values */ +DEVLINK_DYN_ATTR_TYPE_U8 =1 , +DEVLINK_DYN_ATTR_TYPE_U16 , +DEVLINK_DYN_ATTR_TYPE_U32 , +DEVLINK_DYN_ATTR_TYPE_U64 , +DEVLINK_DYN_ATTR_TYPE_STRING , +DEVLINK_DYN_ATTR_TYPE_FLAG , +DEVLINK_DYN_ATTR_TYPE_NUL_STRING =10 , +DEVLINK_DYN_ATTR_TYPE_BINARY , + __DEVLINK_DYN_ATTR_TYPE_CUSTOM_BASE =0x80 , +/* Any possible custom types, unrelated to NLA_* values go below */ +}; +enum devlink_attr {/* don't change the order or add anything between, this is ABI! */ DEVLINK_ATTR_UNSPEC ,...
Re: [PATCH net-next 07/14] devlink: Implement port params registration
In reply to Jiri PirkoQuoted 46 lines · Jiri Pirko
Quoted 29 lines · Fri, Feb 28, 2025 at 02:23:00PM +0100, [email protected] wrote:
Quoted 19 lines · Jiri Pirko
Quoted 18 lines · Fri, Feb 28, 2025 at 12:58:38PM +0100, [email protected] wrote:
Quoted 17 lines · Saeed Mahameed
From: Saeed Mahameed <[email protected]>
Port params infrastructure is incomplete and needs a bit of plumbing to support port params commands from netlink.
Introduce port params registration API, very similar to current devlink params API, add the params xarray to
devlink_portstructure and decouple devlink params registration routines from the devlink structure.Signed-off-by Saeed Mahameed <[email protected]>Reviewed-by Jiri Pirko <[email protected]>--- include/net/devlink.h | 14 ++++ net/devlink/param.c | 150 ++++++++++++++++++++++++++++++++++-------- net/devlink/port.c | 3 + 3 files changed, 140 insertions(+), 27 deletions(-)Quoted 8 lines
Quoted 4 lines
For me devlink and devlink-port should be really the same, to the point that the only difference is
bool is_portflag inside of the struct devlink. Then you could put special logic if really desired (to exclude something for port).Why? Why other devlink objects shouldn't be the same as well. Then we can have one union. Does not make sense to me. The only think dev and port is sharing would be params. What else? Totally different beast.
Quoted 6 lines
Instead of focusing on differences try to find similarities.
health reporters per port and "toplevel",
just by grepping:devlink_nl_sb_pool_fill()devlink_nl_sb_port_pool_fill(),Sharedbuffer is separate story.
Quoted 3 lines
devlink_region_create()devlink_port_region_create()Okay, regions I missed.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
and there is no reason to assume that someone will not want to extend ports to have devlink resources or other thing
But looks at differences. They are huge.
But perhaps I'm missing the point. What you want to achieve? Just to reduce API? That is always a tradeoff. I don't think the pros top the cons here.
not necessarily "reduce API", rather reuse the impl but it is not a request for this series, just a comment
by itself this series is an improvement, and I didn't found anything wrong in the code