Adding permanent config get/set to devlink
v2 cover Adding permanent config get/set to devlink
Changes since v1, based on the excellent feedback received:
* Implemented nested parameters correctly this time, I think.
* Submitting config get/set infrastructure separately from the parameters themselves, and then submitting just the first four parameters as separate patches. Once this approach is accepted, I will add additional parameters, taking into account comments received on them.
* Changed devlink_nl_sing_param_get/set to use _single_.
* Tried to make clear that all params using this command are permanent / NVRAM settings, not transient.
* Split out the reorganization of bnxt driver to separate patch, submitted to net-next earlier today.
* One non-change: The devices this change affects don't typically have a separate 'asic' pci b/d/f versus per-port b/d/f; they just have (typically multiple) b/d/f entities for each function on the device. So, doesn't seem to me like splitting these parameters into port vs. device params works here.
Adds a devlink command for getting & setting permanent (persistent / NVRAM) device configuration parameters, and enumerates the parameters as nested devlink attributes.
bnxt driver patch makes use of these new devlink cmds.
Steve Lin (6):
devlink: Add permanent config parameter get/set operations
devlink: Adding SR-IOV enablement NVRAM config param
devlink: Adding num VFs per PF NVRAM config param
devlink: Adding max PF MSI-X vectors NVRAM config param
devlink: Adding num MSI-X vectors per VF NVRAM config param
bnxt: Add devlink support for config get/set
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 245 +++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 17 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 100 +++++++++ include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 19 ++ net/core/devlink.c | 234 +++++++++++++++++++++ 6 files changed, 612 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/6 devlink: Add permanent config parameter get/set operations
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
--- include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)
include/net/devlink.h +3 -0
@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); +int (*perm_config_get)(struct devlink *devlink,u32 param,u32 *value); +int (*perm_config_set)(struct devlink *devlink,u32 param,u32 value, +u8 *restart_reqd); };static inline void *devlink_priv (struct devlink *devlink)
include/uapi/linux/devlink.h +11 -0
@@ -70,6 +70,10 @@ enum devlink_command {DEVLINK_CMD_DPIPE_HEADERS_GET ,DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET , +/* Permanent (NVRAM) device config get/set */ +DEVLINK_CMD_PERM_CONFIG_GET , +DEVLINK_CMD_PERM_CONFIG_SET , +/* add new commands above here */ __DEVLINK_CMD_MAX,DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX -1
@@ -202,6 +206,13 @@ enum devlink_attr {DEVLINK_ATTR_ESWITCH_ENCAP_MODE ,/* u8 */ +/* Permanent Configuration Parameters */ +DEVLINK_ATTR_PERM_CONFIGS ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG_PARAMETER ,/* u32 */ +DEVLINK_ATTR_PERM_CONFIG_VALUE ,/* u32 */ +DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,/* u8 */ +/* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX,
net/core/devlink.c +234 -0
252 lines not on this page · raw message
Signature · 1 line
2.7.4
RE: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 5 lines
Subject: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Given some of the attributes aren't Boolean, what about an API that allows the user to learn of supported values per option? Otherwise only way for configuring some of them would be trial & error.
Quoted 127 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)include/net/devlink.h +1
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); + int (*perm_config_get)(struct devlink *devlink, u32 param, u32*value);
include/net/devlink.h +1
-0+ int (*perm_config_set)(struct devlink *devlink, u32 param, u32value,
include/net/devlink.h +1
-0+ u8 *restart_reqd); };static inline void *devlink_priv (struct devlink *devlink)include/uapi/linux/devlink.h +9
-0@@ -70,6 +70,10 @@ enum devlink_command {DEVLINK_CMD_DPIPE_HEADERS_GET ,DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET , +/* Permanent (NVRAM) device config get/set */ +DEVLINK_CMD_PERM_CONFIG_GET , +DEVLINK_CMD_PERM_CONFIG_SET , +/* add new commands above here */ __DEVLINK_CMD_MAX,DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX -1 @@ -202,6 +206,13 @@ enum devlink_attr {DEVLINK_ATTR_ESWITCH_ENCAP_MODE ,/* u8 */ +/* Permanent Configuration Parameters */ +DEVLINK_ATTR_PERM_CONFIGS ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG_PARAMETER ,/* u32 */ + DEVLINK_ATTR_PERM_CONFIG_VALUE, /*u32 */
include/uapi/linux/devlink.h +2
-0+DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,/* u8 */ +/* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX,net/core/devlink.c +56
-0@@ -1566,6 +1566,224 @@ static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, return 0; } +static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX +1 ]; + +static int devlink_nl_single_param_get (struct sk_buff *msg, +struct devlink *devlink, +uint32_t param) +{ +u32 value; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *param_attr; + + err = ops->perm_config_get (devlink, param, &value); +if (err) +return err; + + param_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIG ); +nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_PARAMETER , param); +nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_VALUE , value); +nla_nest_end (msg, param_attr); + +return 0 ; +} + +static int devlink_nl_config_get_fill (struct sk_buff *msg, +struct devlink *devlink, +enum devlink_command cmd, +struct genl_info *info) +{ +void *hdr; +int err; +struct nlattr *attr; +int param_count =0 ; +struct nlattr *cfgparam_attr; +int rem; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; + + hdr =genlmsg_put (msg, info->snd_portid, info->snd_seq, + &devlink_nl_family,0 , cmd); +if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + +if (!info->attrs[DEVLINK_ATTR_PERM_CONFIGS ]) { +/* No configuration parameters */ + goto nla_put_failure; + } + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIGS ); + + nla_for_each_nested(attr, info-Quoted 1 line
attrs[DEVLINK_ATTR_PERM_CONFIGS],
net/core/devlink.c static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, · line 1625
Quoted 1 line
net/core/devlink.c +1
-0+ rem) {
Isn't it possible that a response for a single request for multiple ATTRs wouldn't fit in a single message?
net/core/devlink.c static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, · line 1637
Quoted 13 lines
net/core/devlink.c +8
-0+ err =nla_parse_nested (tb,DEVLINK_ATTR_MAX , attr, + devlink_nl_policy,NULL ); +if (err) + goto nla_nest_failure; +if (!tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ]) +continue ; + + param =
nla_get_u32(tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER]);net/core/devlink.c +4
-0+ err =devlink_nl_single_param_get (msg, devlink, param); +if (err) + goto nla_nest_failure; + param_count++;
Looks like an unused parameter
Quoted 133 lines
net/core/devlink.c +31
-0+ } + +nla_nest_end (msg, cfgparam_attr); + +genlmsg_end (msg, hdr); +return 0 ; + +nla_nest_failure: +nla_nest_cancel (msg, cfgparam_attr); +nla_put_failure: +genlmsg_cancel (msg, hdr); +nla_msg_failure: +return err; +} + +static int devlink_nl_cmd_perm_config_get_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct devlink *devlink = info->user_ptr[0 ]; +struct sk_buff *msg; +int err; + +if (!devlink->ops || !devlink->ops->perm_config_get) +return -EOPNOTSUPP ; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + err = devlink_nl_config_get_fill(msg, devlink, +
DEVLINK_CMD_PERM_CONFIG_GET, info);net/core/devlink.c +30
-0+ +if (err) { +nlmsg_free (msg); +return err; + } + +return genlmsg_reply (msg, info); +} + +static int devlink_nl_single_param_set (struct sk_buff *msg, +struct devlink *devlink, +u32 param,u32 value) +{ +u32 orig_value; +u8 need_restart; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *cfgparam_attr; + +/* First get current value of parameter */ + err = ops->perm_config_get (devlink, param, &orig_value); +if (err) +return err; + +/* Now set parameter */ + err = ops->perm_config_set (devlink, param, value, &need_restart); +if (err) +return err; + + cfgparam_attr = nla_nest_start(msg,
DEVLINK_ATTR_PERM_CONFIG);net/core/devlink.c +4
-0+/* Update restart reqd - if any param needs restart, should be set */ +if (need_restart) + err = nla_put_u8(msg, +
DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED, 1);net/core/devlink.c +3
-0+ +/* Since set was successful, write attr back to msg with orig val */ + err = nla_put_u32(msg,
DEVLINK_ATTR_PERM_CONFIG_PARAMETER, param);net/core/devlink.c +1
-0+ err = nla_put_u32(msg, DEVLINK_ATTR_PERM_CONFIG_VALUE,
orig_value);net/core/devlink.c +31
-0+ +nla_nest_end (msg, cfgparam_attr); + +return 0 ; +} + +static int devlink_nl_cmd_perm_config_set_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct devlink *devlink = info->user_ptr[0 ]; +struct sk_buff *msg; +void *hdr; +struct nlattr *attr; +int rem; +int err; +u8 restart_reqd =0 ; +struct nlattr *cfgparam_attr; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; +u32 value; + +if (!devlink->ops || !devlink->ops->perm_config_get || + !devlink->ops->perm_config_set) +return -EOPNOTSUPP ; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr = genlmsg_put(msg, info->snd_portid, info->snd_seq, + &devlink_nl_family, 0,
DEVLINK_CMD_PERM_CONFIG_SET);net/core/devlink.c +10
-0+if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + + cfgparam_attr = nla_nest_start(msg,
DEVLINK_ATTR_PERM_CONFIGS);net/core/devlink.c +2
-0+ + nla_for_each_nested(attr, info-Quoted 1 line
attrs[DEVLINK_ATTR_PERM_CONFIGS], rem) {
net/core/devlink.c +10
-0+ err =nla_parse_nested (tb,DEVLINK_ATTR_MAX , attr, + devlink_nl_policy,NULL ); +if (err) + goto nla_nest_failure; + +if (!tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ] || + !tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]) +continue ; + + param =
nla_get_u32(tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER]);net/core/devlink.c +1
-0+ value =
nla_get_u32(tb[DEVLINK_ATTR_PERM_CONFIG_VALUE]);
net/core/devlink.c static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, · line 1769
Quoted 9 lines
net/core/devlink.c +9
-0+ err =devlink_nl_single_param_set (msg, devlink, param, + value); +if (err) + goto nla_nest_failure; + } + +nla_nest_end (msg, cfgparam_attr); + +if (restart_reqd) {
Doesn't seem like you're ever setting it.
A leftover from when this was an attribute of the configs instead of per-config perhaps?
Quoted 57 lines
net/core/devlink.c +1
-0+ err = nla_put_u8(msg,
DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED,net/core/devlink.c +17
-0+ restart_reqd); +if (err) + goto nla_put_failure; + } + +genlmsg_end (msg, hdr); +return genlmsg_reply (msg, info); + +nla_nest_failure: +nla_nest_cancel (msg, cfgparam_attr); +nla_put_failure: +genlmsg_cancel (msg, hdr); +nla_msg_failure: +return err; +} +int devlink_dpipe_match_put (struct sk_buff *skb,struct devlink_dpipe_match *match) {@@ -2291,6 +2509,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 }, [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING }, [DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8 }, + [DEVLINK_ATTR_PERM_CONFIG_PARAMETER] = { .type = NLA_U32},
net/core/devlink.c +15
-1+ [DEVLINK_ATTR_PERM_CONFIG_VALUE] = { .type = NLA_U32 }, };static const struct genl_ops devlink_nl_ops[] = {@@ -2451,6 +2671,20 @@ static const struct genl_ops devlink_nl_ops[] = { .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_GET, + .doit = devlink_nl_cmd_perm_config_get_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_SET, + .doit = devlink_nl_cmd_perm_config_set_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, }; static struct genl_family devlink_nl_family __ro_after_init = { --2.7.4
Re: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 9 lines · Yuval Mintz
Quoted 5 lines
Subject: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Given some of the attributes aren't Boolean, what about an API that allows the user to learn of supported values per option? Otherwise only way for configuring some of them would be trial & error.
Interesting suggestion. There's a couple of places where this could be a factor. (1) When a user wants to know what values are defined/available in the API, and (2) When the user wants to know what values are supported by a specific driver/device.
The intention for (1) is to push that into userspace. The userspace devlink tool patches I am working on (not yet submitted) essentially mirror the config parameters and their options, with string "keywords" associated with each parameter and option, since it's the userspace app that will be parsing the command line strings and converting to API enums. So the userspace app can provide the list of parameters/options it supports, which could be a subset of what's available in the API.
For (2), currently there is no mechanism other than trial/error as you suggest (up to driver to either return an error or else make use of the value specified by the user). We could contemplate adding such a mechanism, but it's a little complicated as some options take a range (i.e. # of VFs per PF for example), and others may take one of a set of enumerated values (pre-boot link speed for example).
To clarify, are you suggesting some mechanism to allow a driver to report which parameters and options it supports (case (2))? Or are you suggesting something in the kernel API to handle case (1) above?
Quoted 127 lines
Quoted 127 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)include/net/devlink.h +1
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); + int (*perm_config_get)(struct devlink *devlink, u32 param, u32*value);
+ int (*perm_config_set)(struct devlink *devlink, u32 param, u32
value,include/net/devlink.h +1
-0+ u8 *restart_reqd); };static inline void *devlink_priv (struct devlink *devlink)include/uapi/linux/devlink.h +9
-0@@ -70,6 +70,10 @@ enum devlink_command {DEVLINK_CMD_DPIPE_HEADERS_GET ,DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET , +/* Permanent (NVRAM) device config get/set */ +DEVLINK_CMD_PERM_CONFIG_GET , +DEVLINK_CMD_PERM_CONFIG_SET , +/* add new commands above here */ __DEVLINK_CMD_MAX,DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX -1 @@ -202,6 +206,13 @@ enum devlink_attr {DEVLINK_ATTR_ESWITCH_ENCAP_MODE ,/* u8 */ +/* Permanent Configuration Parameters */ +DEVLINK_ATTR_PERM_CONFIGS ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG_PARAMETER ,/* u32 */ + DEVLINK_ATTR_PERM_CONFIG_VALUE, /*u32 */
include/uapi/linux/devlink.h +2
-0+DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,/* u8 */ +/* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX,net/core/devlink.c +56
-0@@ -1566,6 +1566,224 @@ static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, return 0; } +static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX +1 ]; + +static int devlink_nl_single_param_get (struct sk_buff *msg, +struct devlink *devlink, +uint32_t param) +{ +u32 value; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *param_attr; + + err = ops->perm_config_get (devlink, param, &value); +if (err) +return err; + + param_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIG ); +nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_PARAMETER , param); +nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_VALUE , value); +nla_nest_end (msg, param_attr); + +return 0 ; +} + +static int devlink_nl_config_get_fill (struct sk_buff *msg, +struct devlink *devlink, +enum devlink_command cmd, +struct genl_info *info) +{ +void *hdr; +int err; +struct nlattr *attr; +int param_count =0 ; +struct nlattr *cfgparam_attr; +int rem; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; + + hdr =genlmsg_put (msg, info->snd_portid, info->snd_seq, + &devlink_nl_family,0 , cmd); +if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + +if (!info->attrs[DEVLINK_ATTR_PERM_CONFIGS ]) { +/* No configuration parameters */ + goto nla_put_failure; + } + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIGS ); + + nla_for_each_nested(attr, info-
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
attrs[DEVLINK_ATTR_PERM_CONFIGS],
+ rem) {
Isn't it possible that a response for a single request for multiple ATTRs wouldn't fit in a single message?
Hmm... Given the small size and relatively small total number of these attributes, even when additional drivers add their own, I think it's unlikely that a single request would require a multipart message, even in the event it's requesting all of the parameters for a given device. I guess we could support NLM_F_MULTI type messages, but it didn't seem necessary to me for this application? Thoughts?
Quoted 11 lines
net/core/devlink.c static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, · line 1637
Quoted 3 lines
net/core/devlink.c +3
-0+if (err) + goto nla_nest_failure; + param_count++;Looks like an unused parameter
net/core/devlink.c
Quoted 2 lines
net/core/devlink.c +2
-0+ +if (restart_reqd) {Doesn't seem like you're ever setting it.
A leftover from when this was an attribute of the configs instead of per-config perhaps?
Thanks for catching these two issues - you're right, they are leftover from the v1 implementation; apologies for not catching them in v2. Will fix in v3.
RE: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 34 lines
Quoted 1 line · Yuval Mintz
Quoted 1 line
Subject: [PATCH net-next v2 1/6] devlink: Add permanent config
parameter
Quoted 8 lines
Quoted 4 lines
get/set operations
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Given some of the attributes aren't Boolean, what about an API that allows the user to learn of supported values per option? Otherwise only way for configuring some of them would be trial & error.
Interesting suggestion. There's a couple of places where this could be a factor. (1) When a user wants to know what values are defined/available in the API, and (2) When the user wants to know what values are supported by a specific driver/device.
The intention for (1) is to push that into userspace. The userspace devlink tool patches I am working on (not yet submitted) essentially mirror the config parameters and their options, with string "keywords" associated with each parameter and option, since it's the userspace app that will be parsing the command line strings and converting to API enums. So the userspace app can provide the list of parameters/options it supports, which could be a subset of what's available in the API.
For (2), currently there is no mechanism other than trial/error as you suggest (up to driver to either return an error or else make use of the value specified by the user). We could contemplate adding such a mechanism, but it's a little complicated as some options take a range (i.e. # of VFs per PF for example), and others may take one of a set of enumerated values (pre-boot link speed for example).
Quoted 3 lines
To clarify, are you suggesting some mechanism to allow a driver to report which parameters and options it supports (case (2))? Or are you suggesting something in the kernel API to handle case (1) above?
I was thinking of (2). And I agree it would take some effort.
Quoted 129 lines
Quoted 70 lines
Quoted 70 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)include/net/devlink.h +1
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); + int (*perm_config_get)(struct devlink *devlink, u32 param, u32*value);
+ int (*perm_config_set)(struct devlink *devlink, u32 param, u32
value,include/net/devlink.h +1
-0+ u8 *restart_reqd); };static inline void *devlink_priv (struct devlink *devlink)include/uapi/linux/devlink.h +9
-0@@ -70,6 +70,10 @@ enum devlink_command {DEVLINK_CMD_DPIPE_HEADERS_GET ,DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET , +/* Permanent (NVRAM) device config get/set */ +DEVLINK_CMD_PERM_CONFIG_GET , +DEVLINK_CMD_PERM_CONFIG_SET , +/* add new commands above here */ __DEVLINK_CMD_MAX,DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX -1 @@ -202,6 +206,13 @@ enum devlink_attr {DEVLINK_ATTR_ESWITCH_ENCAP_MODE ,/* u8 */ +/* Permanent Configuration Parameters */ +DEVLINK_ATTR_PERM_CONFIGS ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG ,/* nested */ +DEVLINK_ATTR_PERM_CONFIG_PARAMETER ,/* u32 */ + DEVLINK_ATTR_PERM_CONFIG_VALUE, /*u32 */
include/uapi/linux/devlink.h +2
-0+DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,/* u8 */ +/* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX,net/core/devlink.c +0
-0@@ -1566,6 +1566,224 @@ static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, return 0; }Quoted 1 line
net/core/devlink.c static int · line 1570
Quoted 1 line
net/core/devlink.c +1
-0+static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX +1];
Quoted 57 lines
Quoted 57 lines
net/core/devlink.c +55
-0+ +static int devlink_nl_single_param_get (struct sk_buff *msg, +struct devlink *devlink, +uint32_t param) +{ +u32 value; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *param_attr; + + err = ops->perm_config_get (devlink, param, &value); +if (err) +return err; + + param_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIG ); +nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_PARAMETER , param); +nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_VALUE , value); +nla_nest_end (msg, param_attr); + +return 0 ; +} + +static int devlink_nl_config_get_fill (struct sk_buff *msg, +struct devlink *devlink, +enum devlink_command cmd, +struct genl_info *info) +{ +void *hdr; +int err; +struct nlattr *attr; +int param_count =0 ; +struct nlattr *cfgparam_attr; +int rem; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; + + hdr =genlmsg_put (msg, info->snd_portid, info->snd_seq, + &devlink_nl_family,0 , cmd); +if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + +if (!info->attrs[DEVLINK_ATTR_PERM_CONFIGS ]) { +/* No configuration parameters */ + goto nla_put_failure; + } + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIGS ); + + nla_for_each_nested(attr, info-
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
attrs[DEVLINK_ATTR_PERM_CONFIGS],
+ rem) {
Isn't it possible that a response for a single request for multiple ATTRs wouldn't fit in a single message?
Hmm... Given the small size and relatively small total number of these attributes, even when additional drivers add their own, I think it's
We probably have a different idea about 'small'.
Didn’t your *initial* series attempt to add 35 attributes at once?
Quoted 20 lines
unlikely that a single request would require a multipart message, even in the event it's requesting all of the parameters for a given device. I guess we could support
NLM_F_MULTItype messages, but it didn't seem necessary to me for this application? Thoughts?Quoted 11 lines
net/core/devlink.c static int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, · line 1637
Quoted 3 lines
net/core/devlink.c +3
-0+if (err) + goto nla_nest_failure; + param_count++;Looks like an unused parameter
net/core/devlink.c
Quoted 2 lines
net/core/devlink.c +2
-0+ +if (restart_reqd) {Doesn't seem like you're ever setting it.
A leftover from when this was an attribute of the configs instead of per-config perhaps?Thanks for catching these two issues - you're right, they are leftover from the v1 implementation; apologies for not catching them in v2. Will fix in v3.
Re: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 34 lines · Yuval Mintz
Quoted 34 lines
Quoted 1 line · Yuval Mintz
Quoted 1 line
Subject: [PATCH net-next v2 1/6] devlink: Add permanent config
parameter
Quoted 8 lines
Quoted 4 lines
get/set operations
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Given some of the attributes aren't Boolean, what about an API that allows the user to learn of supported values per option? Otherwise only way for configuring some of them would be trial & error.
Interesting suggestion. There's a couple of places where this could be a factor. (1) When a user wants to know what values are defined/available in the API, and (2) When the user wants to know what values are supported by a specific driver/device.
The intention for (1) is to push that into userspace. The userspace devlink tool patches I am working on (not yet submitted) essentially mirror the config parameters and their options, with string "keywords" associated with each parameter and option, since it's the userspace app that will be parsing the command line strings and converting to API enums. So the userspace app can provide the list of parameters/options it supports, which could be a subset of what's available in the API.
For (2), currently there is no mechanism other than trial/error as you suggest (up to driver to either return an error or else make use of the value specified by the user). We could contemplate adding such a mechanism, but it's a little complicated as some options take a range (i.e. # of VFs per PF for example), and others may take one of a set of enumerated values (pre-boot link speed for example).
Quoted 5 lines
Quoted 3 lines
To clarify, are you suggesting some mechanism to allow a driver to report which parameters and options it supports (case (2))? Or are you suggesting something in the kernel API to handle case (1) above?
I was thinking of (2). And I agree it would take some effort.
I don't disagree that this could be a useful addition. But, it seems like this could be added as a follow on patch. I think many/most users of this permanent device config API probably already know what capabilities their device offers, and if they are wrong, the driver can indicate invalid config options. Nothing in the patchset prevents future work to add a new devlink operation to query the driver for supported options. Thoughts?
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Isn't it possible that a response for a single request for multiple ATTRs wouldn't fit in a single message?
Hmm... Given the small size and relatively small total number of these attributes, even when additional drivers add their own, I think it's
We probably have a different idea about 'small'.
Didn’t your *initial* series attempt to add 35 attributes at once?
Yes, and I'd still like to get those ~35 parameters in eventually! :) But even if there were 100 parameters, and all 100 were being get or set at once, if you assume 20 bytes per parameter (4 bytes each for DEVLINK_ATTR_CONFIG, DEVLINK_ATTR_CONFIG_PARAMETER, DEVLINK_ATTR_CONFIG_VALUE, 8 for nesting), that's ~2000 bytes in the message. A little overhead, too, of course, but still less than half a typical netlink message size of 4KB.
So, at some point - if a device with 250 parameters comes along, say, all of which are set/get at once - this could be a problem, but it's not clear if this is a realistic scenario to prepare for?
Jiri Pirko
maintainerRe: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
In reply to Steve LinQuoted 16 lines · Thu, Oct 19, 2017 at 09:17:05PM CEST, [email protected] wrote:
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>---
include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)include/net/devlink.h +0
-0
include/net/devlink.h struct devlink_ops { · line 274
Quoted 5 lines
include/net/devlink.h +2
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); +int (*perm_config_get)(struct devlink *devlink,u32 param,u32 *value); + int (*perm_config_set)(struct devlink *devlink, u32 param, u32 value,
Please use enum instead of "u32 param". Also, what would happen if the value is >u32, like string for example? I believe we need to take it into the consideration for the UAPI sake.
[...]
include/net/devlink.h struct devlink_ops {
Quoted 10 lines
include/net/devlink.h +10
-0+ +static int devlink_nl_single_param_set (struct sk_buff *msg, +struct devlink *devlink, +u32 param,u32 value) +{ +u32 orig_value; +u8 need_restart; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *cfgparam_attr;
Reverse christmas tree please (this applies to all functions)
include/net/devlink.h
Quoted 3 lines
include/net/devlink.h +3
-0+ +/* First get current value of parameter */ + err = ops->perm_config_get (devlink, param, &orig_value);
I'm missing why this is needed.
Quoted 7 lines
include/net/devlink.h +7
-0+if (err) +return err; + +/* Now set parameter */ + err = ops->perm_config_set (devlink, param, value, &need_restart); +if (err) +return err;
include/net/devlink.h
Quoted 10 lines
include/net/devlink.h +10
-0+ + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIG ); +/* Update restart reqd - if any param needs restart, should be set */ +if (need_restart) + err =nla_put_u8 (msg, +DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,1 ); + +/* Since set was successful, write attr back to msg with orig val */ + err =nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_PARAMETER , param); + err =nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_VALUE , orig_value);
Why to write it back?
Quoted 43 lines
include/net/devlink.h +43
-0+ +nla_nest_end (msg, cfgparam_attr); + +return 0 ; +} + +static int devlink_nl_cmd_perm_config_set_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct devlink *devlink = info->user_ptr[0 ]; +struct sk_buff *msg; +void *hdr; +struct nlattr *attr; +int rem; +int err; +u8 restart_reqd =0 ; +struct nlattr *cfgparam_attr; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; +u32 value; + +if (!devlink->ops || !devlink->ops->perm_config_get || + !devlink->ops->perm_config_set) +return -EOPNOTSUPP ; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr =genlmsg_put (msg, info->snd_portid, info->snd_seq, + &devlink_nl_family,0 ,DEVLINK_CMD_PERM_CONFIG_SET ); +if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIGS ); + +nla_for_each_nested (attr, info->attrs[DEVLINK_ATTR_PERM_CONFIGS ], rem) {
include/net/devlink.h
Quoted 10 lines
include/net/devlink.h +10
-0+ err =nla_parse_nested (tb,DEVLINK_ATTR_MAX , attr, + devlink_nl_policy,NULL ); +if (err) + goto nla_nest_failure; + +if (!tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ] || + !tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]) +continue ; + + param =nla_get_u32 (tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ]);
You should check it the "param" value is withing the enum boundary.
include/net/devlink.h
Quoted 5 lines
include/net/devlink.h +5
-0+ value =nla_get_u32 (tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]); + err =devlink_nl_single_param_set (msg, devlink, param, + value); +if (err) + goto nla_nest_failure;
Wouldn't it make sense to rollback to old values if any of the config parameters set would fail?
Quoted 58 lines
include/net/devlink.h +22
-0+ } + +nla_nest_end (msg, cfgparam_attr); + +if (restart_reqd) { + err =nla_put_u8 (msg,DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED , + restart_reqd); +if (err) + goto nla_put_failure; + } + +genlmsg_end (msg, hdr); +return genlmsg_reply (msg, info); + +nla_nest_failure: +nla_nest_cancel (msg, cfgparam_attr); +nla_put_failure: +genlmsg_cancel (msg, hdr); +nla_msg_failure: +return err; +} +int devlink_dpipe_match_put(struct
sk_buff*skb,
structdevlink_dpipe_match*match)
{include/net/devlink.h +16
-0@@ -2291,6 +2509,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 }, [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING }, [DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8 }, + [DEVLINK_ATTR_PERM_CONFIG_PARAMETER] = { .type = NLA_U32 }, + [DEVLINK_ATTR_PERM_CONFIG_VALUE] = { .type = NLA_U32 }, };static const struct genl_ops devlink_nl_ops[] = {@@ -2451,6 +2671,20 @@ static const struct genl_ops devlink_nl_ops[] = { .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_GET, + .doit = devlink_nl_cmd_perm_config_get_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_SET, + .doit = devlink_nl_cmd_perm_config_set_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, }; static struct genl_family devlink_nl_family __ro_after_init = {Signature · 1 line
2.7.4
Re: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 12 lines · Jiri Pirko
Quoted 11 lines · Thu, Oct 19, 2017 at 09:17:05PM CEST, [email protected] wrote:
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>---
include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)
Quoted 16 lines
include/net/devlink.h struct devlink_ops { · line 274
Quoted 10 lines
include/net/devlink.h +2
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); +int (*perm_config_get)(struct devlink *devlink,u32 param,u32 *value); + int (*perm_config_set)(struct devlink *devlink, u32 param, u32 value,Please use enum instead of "u32 param". Also, what would happen if the value is >u32, like string for example? I believe we need to take it into the consideration for the UAPI sake.
Using enum instead of u32 param: ok, will do in v3, thanks.
Value > u32: In the RFC and v1 versions of the patch, each parameter was its own attribute, so could have its own type (u32, string, whatever). In v2, trying to move to nested parameters w/ parameter being an enum, as requested, it seems to mean that the parameter value now must be defined as a specific type, so I went with u32.
If we need to support strings or other types > u32, then the perm_config_value attribute will not be a fixed type, so can't be policy checked. Or, I could go back to non-nested as in RFC/v1 case and have each parameter with its own type.
Quoted 15 lines
[...]
include/net/devlink.h
Quoted 10 lines
include/net/devlink.h +10
-0+ +static int devlink_nl_single_param_set (struct sk_buff *msg, +struct devlink *devlink, +u32 param,u32 value) +{ +u32 orig_value; +u8 need_restart; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *cfgparam_attr;Reverse christmas tree please (this applies to all functions)
Will do in v3, thanks.
Quoted 20 lines
include/net/devlink.h
Quoted 5 lines
include/net/devlink.h +3
-0+ +/* First get current value of parameter */ + err = ops->perm_config_get (devlink, param, &orig_value);I'm missing why this is needed.
Quoted 11 lines
include/net/devlink.h +11
-0+if (err) +return err; + +/* Now set parameter */ + err = ops->perm_config_set (devlink, param, value, &need_restart); +if (err) +return err; + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIG ); +/* Update restart reqd - if any param needs restart, should be set */ +if (need_restart)
Quoted 8 lines
include/net/devlink.h
Quoted 6 lines
include/net/devlink.h +6
-0+ err =nla_put_u8 (msg, +DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,1 ); + +/* Since set was successful, write attr back to msg with orig val */ + err =nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_PARAMETER , param); + err =nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_VALUE , orig_value);Why to write it back?
In a response to the "RFC" version of this patch, you wrote: "Also, we need to expose to the user the original value (currently being used) and the new one (to be used after driver re-instatiation)".
I understood that to mean that we need to return the current/original value of the parameter (and the user knows the new value, since they are setting it).
If I mis-interpreted that comment, then I'm happy to remove returning the original value to the user; it wasn't in there originally.
Quoted 49 lines
Quoted 49 lines
include/net/devlink.h +47
-0+ +nla_nest_end (msg, cfgparam_attr); + +return 0 ; +} + +static int devlink_nl_cmd_perm_config_set_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct devlink *devlink = info->user_ptr[0 ]; +struct sk_buff *msg; +void *hdr; +struct nlattr *attr; +int rem; +int err; +u8 restart_reqd =0 ; +struct nlattr *cfgparam_attr; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; +u32 value; + +if (!devlink->ops || !devlink->ops->perm_config_get || + !devlink->ops->perm_config_set) +return -EOPNOTSUPP ; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr =genlmsg_put (msg, info->snd_portid, info->snd_seq, + &devlink_nl_family,0 ,DEVLINK_CMD_PERM_CONFIG_SET ); +if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIGS ); + +nla_for_each_nested (attr, info->attrs[DEVLINK_ATTR_PERM_CONFIGS ], rem) { + err =nla_parse_nested (tb,DEVLINK_ATTR_MAX , attr, + devlink_nl_policy,NULL ); +if (err) + goto nla_nest_failure;
Quoted 8 lines
include/net/devlink.h
Quoted 6 lines
include/net/devlink.h +6
-0+ +if (!tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ] || + !tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]) +continue ; + + param =nla_get_u32 (tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ]);You should check it the "param" value is withing the enum boundary.
Will do in v3, I'll add a DEVLINK_PERM_CONFIG_MAX enum and check against that.
Quoted 10 lines
include/net/devlink.h
Quoted 7 lines
include/net/devlink.h +5
-0+ value =nla_get_u32 (tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]); + err =devlink_nl_single_param_set (msg, devlink, param, + value); +if (err) + goto nla_nest_failure;Wouldn't it make sense to rollback to old values if any of the config parameters set would fail?
Hmmmm.... We could do a rollback on failure of any of the set cmds, but I feel like that's more useful when the user doesn't know which sets failed. (i.e. if the response was just a boolean ok/not-ok response).
If the user knows which sets worked and which didn't, then maybe no rollback is necessary. So perhaps I change the code so that rather than falling out on error, it continues to try all the set cmds, but just returns the parameters which were successful.
Is there a convention for this? I'm fine either way.
Quoted 60 lines
Quoted 60 lines
include/net/devlink.h +22
-0+ } + +nla_nest_end (msg, cfgparam_attr); + +if (restart_reqd) { + err =nla_put_u8 (msg,DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED , + restart_reqd); +if (err) + goto nla_put_failure; + } + +genlmsg_end (msg, hdr); +return genlmsg_reply (msg, info); + +nla_nest_failure: +nla_nest_cancel (msg, cfgparam_attr); +nla_put_failure: +genlmsg_cancel (msg, hdr); +nla_msg_failure: +return err; +} +int devlink_dpipe_match_put(struct
sk_buff*skb,
structdevlink_dpipe_match*match)
{include/net/devlink.h +16
-1@@ -2291,6 +2509,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 }, [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING }, [DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8 }, + [DEVLINK_ATTR_PERM_CONFIG_PARAMETER] = { .type = NLA_U32 }, + [DEVLINK_ATTR_PERM_CONFIG_VALUE] = { .type = NLA_U32 }, };static const struct genl_ops devlink_nl_ops[] = {@@ -2451,6 +2671,20 @@ static const struct genl_ops devlink_nl_ops[] = { .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_GET, + .doit = devlink_nl_cmd_perm_config_get_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_SET, + .doit = devlink_nl_cmd_perm_config_set_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, }; static struct genl_family devlink_nl_family __ro_after_init = { --2.7.4
Jiri Pirko
maintainerRe: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 30 lines · Fri, Oct 20, 2017 at 05:13:39PM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 11 lines · Thu, Oct 19, 2017 at 09:17:05PM CEST, [email protected] wrote:
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>---
include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)Quoted 16 lines
include/net/devlink.h struct devlink_ops { · line 274
Quoted 10 lines
include/net/devlink.h +2
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); +int (*perm_config_get)(struct devlink *devlink,u32 param,u32 *value); + int (*perm_config_set)(struct devlink *devlink, u32 param, u32 value,Please use enum instead of "u32 param". Also, what would happen if the value is >u32, like string for example? I believe we need to take it into the consideration for the UAPI sake.
Quoted 7 lines
Using enum instead of u32 param: ok, will do in v3, thanks.
Value > u32: In the RFC and v1 versions of the patch, each parameter was its own attribute, so could have its own type (u32, string, whatever). In v2, trying to move to nested parameters w/ parameter being an enum, as requested, it seems to mean that the parameter value now must be defined as a specific type, so I went with u32.
Why? I have to be missing something. In the nest all is same as outside of the nest.
Also, please see team_nl_cmd_options_set() where something similar is done, for multiple option types.
Quoted 207 lines
If we need to support strings or other types > u32, then the
perm_config_valueattribute will not be a fixed type, so can't be policy checked. Or, I could go back to non-nested as in RFC/v1 case and have each parameter with its own type.Quoted 15 lines
[...]
include/net/devlink.h
Quoted 10 lines
include/net/devlink.h +10
-0+ +static int devlink_nl_single_param_set (struct sk_buff *msg, +struct devlink *devlink, +u32 param,u32 value) +{ +u32 orig_value; +u8 need_restart; +int err; +const struct devlink_ops *ops = devlink->ops; +struct nlattr *cfgparam_attr;Reverse christmas tree please (this applies to all functions)
Will do in v3, thanks.
Quoted 20 lines
include/net/devlink.h
Quoted 5 lines
include/net/devlink.h +3
-0+ +/* First get current value of parameter */ + err = ops->perm_config_get (devlink, param, &orig_value);I'm missing why this is needed.
Quoted 11 lines
include/net/devlink.h +11
-0+if (err) +return err; + +/* Now set parameter */ + err = ops->perm_config_set (devlink, param, value, &need_restart); +if (err) +return err; + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIG ); +/* Update restart reqd - if any param needs restart, should be set */ +if (need_restart)Quoted 8 lines
include/net/devlink.h
Quoted 6 lines
include/net/devlink.h +6
-0+ err =nla_put_u8 (msg, +DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED ,1 ); + +/* Since set was successful, write attr back to msg with orig val */ + err =nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_PARAMETER , param); + err =nla_put_u32 (msg,DEVLINK_ATTR_PERM_CONFIG_VALUE , orig_value);Why to write it back?
In a response to the "RFC" version of this patch, you wrote: "Also, we need to expose to the user the original value (currently being used) and the new one (to be used after driver re-instatiation)".
I understood that to mean that we need to return the current/original value of the parameter (and the user knows the new value, since they are setting it).
If I mis-interpreted that comment, then I'm happy to remove returning the original value to the user; it wasn't in there originally.
Quoted 49 lines
Quoted 49 lines
include/net/devlink.h +47
-0+ +nla_nest_end (msg, cfgparam_attr); + +return 0 ; +} + +static int devlink_nl_cmd_perm_config_set_doit (struct sk_buff *skb, +struct genl_info *info) +{ +struct devlink *devlink = info->user_ptr[0 ]; +struct sk_buff *msg; +void *hdr; +struct nlattr *attr; +int rem; +int err; +u8 restart_reqd =0 ; +struct nlattr *cfgparam_attr; +struct nlattr *tb[DEVLINK_ATTR_MAX +1 ]; +u32 param; +u32 value; + +if (!devlink->ops || !devlink->ops->perm_config_get || + !devlink->ops->perm_config_set) +return -EOPNOTSUPP ; + + msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +if (!msg) +return -ENOMEM ; + + hdr =genlmsg_put (msg, info->snd_portid, info->snd_seq, + &devlink_nl_family,0 ,DEVLINK_CMD_PERM_CONFIG_SET ); +if (!hdr) { + err = -EMSGSIZE ; + goto nla_msg_failure; + } + + err =devlink_nl_put_handle (msg, devlink); +if (err) + goto nla_put_failure; + + cfgparam_attr =nla_nest_start (msg,DEVLINK_ATTR_PERM_CONFIGS ); + +nla_for_each_nested (attr, info->attrs[DEVLINK_ATTR_PERM_CONFIGS ], rem) { + err =nla_parse_nested (tb,DEVLINK_ATTR_MAX , attr, + devlink_nl_policy,NULL ); +if (err) + goto nla_nest_failure;Quoted 8 lines
include/net/devlink.h
Quoted 6 lines
include/net/devlink.h +6
-0+ +if (!tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ] || + !tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]) +continue ; + + param =nla_get_u32 (tb[DEVLINK_ATTR_PERM_CONFIG_PARAMETER ]);You should check it the "param" value is withing the enum boundary.
Will do in v3, I'll add a
DEVLINK_PERM_CONFIG_MAXenum and check against that.Quoted 10 lines
include/net/devlink.h
Quoted 7 lines
include/net/devlink.h +5
-0+ value =nla_get_u32 (tb[DEVLINK_ATTR_PERM_CONFIG_VALUE ]); + err =devlink_nl_single_param_set (msg, devlink, param, + value); +if (err) + goto nla_nest_failure;Wouldn't it make sense to rollback to old values if any of the config parameters set would fail?
Hmmmm.... We could do a rollback on failure of any of the set cmds, but I feel like that's more useful when the user doesn't know which sets failed. (i.e. if the response was just a boolean ok/not-ok response).
If the user knows which sets worked and which didn't, then maybe no rollback is necessary. So perhaps I change the code so that rather than falling out on error, it continues to try all the set cmds, but just returns the parameters which were successful.
Is there a convention for this? I'm fine either way.
Quoted 60 lines
Quoted 60 lines
include/net/devlink.h +22
-0+ } + +nla_nest_end (msg, cfgparam_attr); + +if (restart_reqd) { + err =nla_put_u8 (msg,DEVLINK_ATTR_PERM_CONFIG_RESTART_REQUIRED , + restart_reqd); +if (err) + goto nla_put_failure; + } + +genlmsg_end (msg, hdr); +return genlmsg_reply (msg, info); + +nla_nest_failure: +nla_nest_cancel (msg, cfgparam_attr); +nla_put_failure: +genlmsg_cancel (msg, hdr); +nla_msg_failure: +return err; +} +int devlink_dpipe_match_put(struct
sk_buff*skb,
structdevlink_dpipe_match*match)
{include/net/devlink.h +16
-1@@ -2291,6 +2509,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 }, [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING }, [DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8 }, + [DEVLINK_ATTR_PERM_CONFIG_PARAMETER] = { .type = NLA_U32 }, + [DEVLINK_ATTR_PERM_CONFIG_VALUE] = { .type = NLA_U32 }, };static const struct genl_ops devlink_nl_ops[] = {@@ -2451,6 +2671,20 @@ static const struct genl_ops devlink_nl_ops[] = { .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_GET, + .doit = devlink_nl_cmd_perm_config_get_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, + { + .cmd = DEVLINK_CMD_PERM_CONFIG_SET, + .doit = devlink_nl_cmd_perm_config_set_doit, + .policy = devlink_nl_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, + }, }; static struct genl_family devlink_nl_family __ro_after_init = { --2.7.4
Re: [PATCH net-next v2 1/6] devlink: Add permanent config parameter get/set operations
Quoted 39 lines · Jiri Pirko
Quoted 30 lines · Fri, Oct 20, 2017 at 05:13:39PM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
Quoted 11 lines · Thu, Oct 19, 2017 at 09:17:05PM CEST, [email protected] wrote:
Add support for permanent config parameter get/set commands. Used for parameters held in NVRAM, persistent device configuration.
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>---
include/net/devlink.h | 3 + include/uapi/linux/devlink.h | 11 ++ net/core/devlink.c | 234 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+)Quoted 16 lines
include/net/devlink.h struct devlink_ops { · line 274
Quoted 10 lines
include/net/devlink.h +2
-0@@ -270,6 +270,9 @@ struct devlink_ops {int (*eswitch_inline_mode_set)(struct devlink *devlink,u8 inline_mode);int (*eswitch_encap_mode_get)(struct devlink *devlink,u8 *p_encap_mode);int (*eswitch_encap_mode_set)(struct devlink *devlink,u8 encap_mode); +int (*perm_config_get)(struct devlink *devlink,u32 param,u32 *value); + int (*perm_config_set)(struct devlink *devlink, u32 param, u32 value,Please use enum instead of "u32 param". Also, what would happen if the value is >u32, like string for example? I believe we need to take it into the consideration for the UAPI sake.
Quoted 7 lines
Using enum instead of u32 param: ok, will do in v3, thanks.
Value > u32: In the RFC and v1 versions of the patch, each parameter was its own attribute, so could have its own type (u32, string, whatever). In v2, trying to move to nested parameters w/ parameter being an enum, as requested, it seems to mean that the parameter value now must be defined as a specific type, so I went with u32.
Quoted 7 lines
Why? I have to be missing something. In the nest all is same as outside of the nest.
Also, please see
team_nl_cmd_options_set()where something similar is done, for multiple option types.
Okay, I can implement similar to that driver. In the current devlink.c/devlink.h, all attributes have specific types, and aren't dynamic types like the "data" attribute in the team driver, so I had thought having specific types defined for each attribute was required in devlink.
PATCH v2 2/6 devlink: Adding SR-IOV enablement NVRAM config param
In reply to Steve LinAdding DEVLINK_PERM_CONFIG_SRIOV_ENABLED permanent config parameter. If value is 1, SR-IOV is enabled. If value is 0, SR-IOV is disabled on this device. Value is permanent (stored in NVRAM), so becomes the new default value for this device.
--- include/uapi/linux/devlink.h | 5 +++++ 1 file changed, 5 insertions(+)
include/uapi/linux/devlink.h +5 -0
@@ -255,4 +255,9 @@ enum devlink_dpipe_header_id { DEVLINK_DPIPE_HEADER_IPV6, }; +/* Permanent (NVRAM) config parameters */ +enum devlink_perm_config_param { +DEVLINK_PERM_CONFIG_SRIOV_ENABLED , +}; +#endif /* _UAPI_LINUX_DEVLINK_H_ */
Signature · 1 line
2.7.4
Jiri Pirko
maintainerRe: [PATCH net-next v2 2/6] devlink: Adding SR-IOV enablement NVRAM config param
Quoted 16 lines · Thu, Oct 19, 2017 at 09:17:06PM CEST, [email protected] wrote:
Adding
DEVLINK_PERM_CONFIG_SRIOV_ENABLEDpermanent config parameter. If value is 1, SR-IOV is enabled. If value is 0, SR-IOV is disabled on this device. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>---
include/uapi/linux/devlink.h| 5 +++++1 file changed, 5 insertions(+)include/uapi/linux/devlink.h +0
-0
include/uapi/linux/devlink.h enum devlink_dpipe_header_id { · line 258
Quoted 4 lines
include/uapi/linux/devlink.h +1
-0@@ -255,4 +255,9 @@ enum devlink_dpipe_header_id { DEVLINK_DPIPE_HEADER_IPV6, }; +/* Permanent (NVRAM) config parameters */
We need the decription here in the header as well. Commit message alone is no good for this.
Also, there should not be mention of "NVRAM". It is up to the device implementation where is stores the value.
Quoted 8 lines
include/uapi/linux/devlink.h +4
-0+enum devlink_perm_config_param { +DEVLINK_PERM_CONFIG_SRIOV_ENABLED , +}; +#endif /* _UAPI_LINUX_DEVLINK_H_ */ Signature · 1 line
2.7.4
Re: [PATCH net-next v2 2/6] devlink: Adding SR-IOV enablement NVRAM config param
Quoted 20 lines · Jiri Pirko
Quoted 19 lines · Thu, Oct 19, 2017 at 09:17:06PM CEST, [email protected] wrote:
Adding
DEVLINK_PERM_CONFIG_SRIOV_ENABLEDpermanent config parameter. If value is 1, SR-IOV is enabled. If value is 0, SR-IOV is disabled on this device. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>---
include/uapi/linux/devlink.h| 5 +++++1 file changed, 5 insertions(+)include/uapi/linux/devlink.h +0
-0@@ -255,4 +255,9 @@ enum devlink_dpipe_header_id { DEVLINK_DPIPE_HEADER_IPV6, };
Quoted 9 lines
include/uapi/linux/devlink.h enum devlink_dpipe_header_id { · line 258
Quoted 1 line
include/uapi/linux/devlink.h +1
-0+/* Permanent (NVRAM) config parameters */ We need the decription here in the header as well. Commit message alone is no good for this.
Also, there should not be mention of "NVRAM". It is up to the device implementation where is stores the value.
Will do, I'll add descriptions in the header file and reword as requested. Thanks!
PATCH v2 3/6 devlink: Adding num VFs per PF NVRAM config param
In reply to Steve LinAdding DEVLINK_PERM_CONFIG_NUM_VF_PER_PF permanent config parameter, which sets the number of VFs per PF in SR-IOV mode. Value is permanent (stored in NVRAM), so becomes the new default value for this device.
--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/devlink.h +1 -0
@@ -258,6 +258,7 @@ enum devlink_dpipe_header_id {/* Permanent (NVRAM) config parameters */ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED , +DEVLINK_PERM_CONFIG_NUM_VF_PER_PF , };#endif /* _UAPI_LINUX_DEVLINK_H_ */
Signature · 1 line
2.7.4
PATCH v2 4/6 devlink: Adding max PF MSI-X vectors NVRAM config param
In reply to Steve LinAdding DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT permanent config parameter. Sets the maximum number of PF MSI-X (Message Signaled Interrupts) vectors. Value is permanent (stored in NVRAM), so becomes the new default value for this device.
--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/devlink.h +1 -0
@@ -259,6 +259,7 @@ enum devlink_dpipe_header_id {enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF , +DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , };#endif /* _UAPI_LINUX_DEVLINK_H_ */
Signature · 1 line
2.7.4
PATCH v2 5/6 devlink: Adding num MSI-X vectors per VF NVRAM config param
In reply to Steve LinAdding DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF permanent config parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.
--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/devlink.h +1 -0
@@ -260,6 +260,7 @@ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , + DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF, };#endif /* _UAPI_LINUX_DEVLINK_H_ */
Signature · 1 line
2.7.4
RE: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.
Sounds like you're having this enforce the same configuration for all child VFs.
Quoted 21 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/devlink.h +1
-1@@ -260,6 +260,7 @@ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , + DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF, };#endif /* _UAPI_LINUX_DEVLINK_H_ */ --2.7.4
Jiri Pirko
maintainerRe: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 7 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
Quoted 23 lines
Quoted 22 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/devlink.h +1
-1@@ -260,6 +260,7 @@ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , + DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF, };#endif /* _UAPI_LINUX_DEVLINK_H_ */ --2.7.4
Jiri Pirko
maintainerRe: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 10 lines · Thu, Oct 19, 2017 at 11:39:55PM CEST, [email protected] wrote:
Quoted 7 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
This opens old but lately silent discussion about introducing new port types for different things. Like VF, dsa CPU port or dsa inter-chip ports.
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/devlink.h +1
-1@@ -260,6 +260,7 @@ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , + DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF, };#endif /* _UAPI_LINUX_DEVLINK_H_ */ --2.7.4
Re: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 8 lines · Jiri Pirko
Quoted 7 lines · Thu, Oct 19, 2017 at 11:39:55PM CEST, [email protected] wrote:
Quoted 6 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
This opens old but lately silent discussion about introducing new port types for different things. Like VF, dsa CPU port or dsa inter-chip ports.
FWIW, the "issue" with representing VF, DSA CPU port or DSA inter-chip port is that you would be representing a pipe, so there is obviously a question of whether your represent one end or both ends of that pipe, and how do you make sure both stay in sync if you represent those.
For instance, for an inter-switch connection, I could decide to configure VLANs 1-3 tagged on one end of the connection, and forget to that on the other end of the connection, and that's just one example where things can go seriously wrong.
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/devlink.h +1
-1@@ -260,6 +260,7 @@ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , + DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF, };#endif /* _UAPI_LINUX_DEVLINK_H_ */ --2.7.4
Signature · 1 line
Florian
Jiri Pirko
maintainerRe: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 22 lines · Fri, Oct 20, 2017 at 03:01:35AM CEST, [email protected] wrote:
Quoted 8 lines · Jiri Pirko
Quoted 7 lines · Thu, Oct 19, 2017 at 11:39:55PM CEST, [email protected] wrote:
Quoted 6 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
This opens old but lately silent discussion about introducing new port types for different things. Like VF, dsa CPU port or dsa inter-chip ports.
FWIW, the "issue" with representing VF, DSA CPU port or DSA inter-chip port is that you would be representing a pipe, so there is obviously a question of whether your represent one end or both ends of that pipe, and how do you make sure both stay in sync if you represent those.
Quoted 4 lines
For instance, for an inter-switch connection, I could decide to configure VLANs 1-3 tagged on one end of the connection, and forget to that on the other end of the connection, and that's just one example where things can go seriously wrong.
Certainly you have to represent both ends. So in your dsa inter-port example, there should be onle devlink port instance for both dsa chips.
Quoted 31 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Signed-off-by Steve Lin <[email protected]>Acked-by Andy Gospodarek <[email protected]>--- include/uapi/linux/devlink.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/devlink.h +1
-1@@ -260,6 +260,7 @@ enum devlink_perm_config_param {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT , + DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF, };#endif /* _UAPI_LINUX_DEVLINK_H_ */ --2.7.4
Signature · 1 line
Florian
Re: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
In reply to Jiri PirkoQuoted 11 lines · Jiri Pirko
Quoted 7 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the MLNX cards work, and others that would be likely to use these cmds.
So, to summarize, you direct the command to the PCI b/d/f you want to target. Does this make sense?
Jiri Pirko
maintainerRe: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 28 lines · Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected] wrote:
Quoted 11 lines · Jiri Pirko
Quoted 7 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the MLNX cards work, and others that would be likely to use these cmds.
Quoted 2 lines
So, to summarize, you direct the command to the PCI b/d/f you want to target. Does this make sense?
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
Re: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 29 lines · Jiri Pirko
Quoted 28 lines · Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected] wrote:
Quoted 11 lines · Jiri Pirko
Quoted 7 lines · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 5 lines
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all child VFs.
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the MLNX cards work, and others that would be likely to use these cmds.
Quoted 6 lines
Quoted 2 lines
So, to summarize, you direct the command to the PCI b/d/f you want to target. Does this make sense?
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
For the commands proposed in this patchset, AFAIK they all apply on a per-PF or broader, i.e. per-port or whole-card, granularity, since they affect permanent config that applies at boot-up. So, no, the VFs don't really come into play here.
RE: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 35 lines · Jiri Pirko
Quoted 4 lines
Quoted 3 lines · Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko
Quoted 1 line · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 1 line
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all
child VFs.
Quoted 22 lines
Quoted 21 lines
Quoted 3 lines
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the MLNX cards work, and others that would be likely to use these cmds.
So, to summarize, you direct the command to the PCI b/d/f you want to target. Does this make sense?
Quoted 8 lines
Quoted 3 lines
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
For the commands proposed in this patchset, AFAIK they all apply on a per-PF or broader, i.e. per-port or whole-card, granularity, since they affect permanent config that applies at boot-up. So, no, the VFs don't really come into play here.
Regardless of whether you're planning on having VFs as devlink instances, the actual attribute question remains -
you're proposing an attribute that forces all VFs to have the same value. This probably suits your PCI core limitations but other vendors might have a different capability set, and accepting this design limitation now would muck all future extension attempts of such attributes.
I think VF configurations should be planned in advance for supporting a per-VF Configuration whenever it's possible - even if not required [/possible] by the one pushing the new attribute.
Re: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 51 lines · Yuval Mintz
Quoted 35 lines · Jiri Pirko
Quoted 4 lines
Quoted 3 lines · Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko
Quoted 1 line · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 1 line
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the new default value for this device.Sounds like you're having this enforce the same configuration for all
child VFs.
Quoted 22 lines
Quoted 21 lines
Quoted 3 lines
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the MLNX cards work, and others that would be likely to use these cmds.
So, to summarize, you direct the command to the PCI b/d/f you want to target. Does this make sense?
Quoted 8 lines
Quoted 3 lines
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
For the commands proposed in this patchset, AFAIK they all apply on a per-PF or broader, i.e. per-port or whole-card, granularity, since they affect permanent config that applies at boot-up. So, no, the VFs don't really come into play here.
Regardless of whether you're planning on having VFs as devlink instances, the actual attribute question remains -
you're proposing an attribute that forces all VFs to have the same value. This probably suits your PCI core limitations but other vendors might have a different capability set, and accepting this design limitation now would muck all future extension attempts of such attributes.
Quoted 4 lines
I think VF configurations should be planned in advance for supporting a per-VF Configuration whenever it's possible - even if not required [/possible] by the one pushing the new attribute.
The commands being added in this patch are for permanent (i.e. NVRAM) config - essentially setting the new default values for various features of the device at boot-up. At that initialization time, no VFs are yet instantiated.
So my perspective was, in general (not just for our specific device / design), it doesn't seem like permanent config parameters would be set on individual VFs. That was what my previous comment was trying to convey.
If that assumption is wrong, though, and there is some device that has NVRAM config that is set per-VF, I assume the user would instantiate the VF and then call the devlink API on the pci device corresponding to the VF they with to affect, and I think the model proposed still works.
Are you suggesting adding a mechanism to set NVRAM parameters on a per-VF basis, without instantiating the VF first? I would prefer not adding such a mechanism unless/until there's a use case for it.
RE: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 65 lines
Quoted 9 lines
Quoted 9 lines · Jiri Pirko
Quoted 4 lines
Quoted 3 lines · Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko
Quoted 1 line · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 1 line
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the newdefault
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
value for this device.
Sounds like you're having this enforce the same configuration for all
child VFs.
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the
MLNX
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
cards work, and others that would be likely to use these cmds.
So, to summarize, you direct the command to the PCI b/d/f you want
to
Quoted 18 lines
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
target. Does this make sense?
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
For the commands proposed in this patchset, AFAIK they all apply on a per-PF or broader, i.e. per-port or whole-card, granularity, since they affect permanent config that applies at boot-up. So, no, the VFs don't really come into play here.
Regardless of whether you're planning on having VFs as devlink instances, the actual attribute question remains -
you're proposing an attribute that forces all VFs to have the same value. This probably suits your PCI core limitations but other vendors might have a different capability set, and accepting this design limitation now would muck all future extension attempts of such attributes.Quoted 2 lines
I think VF configurations should be planned in advance for supporting a per-VF Configuration whenever it's possible - even if not required
[/possible]
Quoted 2 lines
by the one pushing the new attribute.
The commands being added in this patch are for permanent (i.e. NVRAM) config - essentially setting the new default values for various features of the device at boot-up. At that initialization time, no VFs are yet instantiated.
Quoted 4 lines
So my perspective was, in general (not just for our specific device / design), it doesn't seem like permanent config parameters would be set on individual VFs. That was what my previous comment was trying to convey.
That's an odd assumption; Why should you assume there's some device that allows configuring persistent behavior for all VFs but think no other would set the same on a per-VF basis?
Quoted 5 lines
If that assumption is wrong, though, and there is some device that has NVRAM config that is set per-VF, I assume the user would instantiate the VF and then call the devlink API on the pci device corresponding to the VF they with to affect, and I think the model proposed still works.
What would be the purpose of re-configuring a value reflected in the PCI device for an already instantiated VF?
Quoted 3 lines
Are you suggesting adding a mechanism to set NVRAM parameters on a per-VF basis, without instantiating the VF first? I would prefer not adding such a mechanism unless/until there's a use case for it.
The thing is that you're suggesting a new UAPI; We don't have the leisure of pushing a partial implementation and changing it later on.
Re: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 83 lines · Yuval Mintz
Quoted 65 lines
Quoted 9 lines
Quoted 9 lines · Jiri Pirko
Quoted 4 lines
Quoted 3 lines · Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected] wrote:
Quoted 2 lines · Jiri Pirko
Quoted 1 line · Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected] wrote:
Quoted 1 line
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the newdefault
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
value for this device.
Sounds like you're having this enforce the same configuration for all
child VFs.
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just allow a single value for this parameter for the entire card, covering all ports/PFs.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
To keep things simple and as general as possible, it made sense to set all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed commands do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on each port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the
MLNX
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
cards work, and others that would be likely to use these cmds.
So, to summarize, you direct the command to the PCI b/d/f you want
to
Quoted 18 lines
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
target. Does this make sense?
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
For the commands proposed in this patchset, AFAIK they all apply on a per-PF or broader, i.e. per-port or whole-card, granularity, since they affect permanent config that applies at boot-up. So, no, the VFs don't really come into play here.
Regardless of whether you're planning on having VFs as devlink instances, the actual attribute question remains -
you're proposing an attribute that forces all VFs to have the same value. This probably suits your PCI core limitations but other vendors might have a different capability set, and accepting this design limitation now would muck all future extension attempts of such attributes.Quoted 2 lines
I think VF configurations should be planned in advance for supporting a per-VF Configuration whenever it's possible - even if not required
[/possible]
Quoted 2 lines
by the one pushing the new attribute.
The commands being added in this patch are for permanent (i.e. NVRAM) config - essentially setting the new default values for various features of the device at boot-up. At that initialization time, no VFs are yet instantiated.
Quoted 4 lines
So my perspective was, in general (not just for our specific device / design), it doesn't seem like permanent config parameters would be set on individual VFs. That was what my previous comment was trying to convey.
That's an odd assumption; Why should you assume there's some device that allows configuring persistent behavior for all VFs but think no other would set the same on a per-VF basis?
Quoted 5 lines
If that assumption is wrong, though, and there is some device that has NVRAM config that is set per-VF, I assume the user would instantiate the VF and then call the devlink API on the pci device corresponding to the VF they with to affect, and I think the model proposed still works.
What would be the purpose of re-configuring a value reflected in the PCI device for an already instantiated VF?
Quoted 6 lines
Quoted 3 lines
Are you suggesting adding a mechanism to set NVRAM parameters on a per-VF basis, without instantiating the VF first? I would prefer not adding such a mechanism unless/until there's a use case for it.
The thing is that you're suggesting a new UAPI; We don't have the leisure of pushing a partial implementation and changing it later on.
I hope we're not talking past each other because I'm not sure we're saying the same thing. But if you have a device which has NVRAM config on an individual VF basis, and you want to be able to get/set that configuration without instantiating the VF first (i.e. without a PCI device to operate on), then one way to handle this is with a new attribute, DEVLINK_ATTR_PERM_CONFIG_VF_INDEX, for example.
It could be sent in the nested DEVLINK_ATTR_PERM_CONFIG attribute, along with the existing DEVLINK_ATTR_PERM_CONFIG_PARAMETER and _VALUE, to indicate a specific VF within the PF that you are targeting.
That seems like the type of thing that could be added later, if/when such a device needed support, without breaking the UAPI, couldn't it?
RE: [PATCH net-next v2 5/6] devlink: Adding num MSI-X vectors per VF NVRAM config param
Quoted 107 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Jiri Pirko
Quoted 1 line
Fri, Oct 20, 2017 at 04:03:55PM CEST, [email protected]
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Jiri Pirko
Quoted 1 line
Thu, Oct 19, 2017 at 10:32:21PM CEST, [email protected]
Quoted 9 lines · wrote:
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Adding
DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VFpermanent
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
config
parameter. Defines number of MSI-X vectors allocated per VF. Value is permanent (stored in NVRAM), so becomes the newdefault
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
value for this device.
Sounds like you're having this enforce the same configuration for
all
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
child VFs.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Yeah, this sounds like per-port config.
Well, it gets a little tricky here. I assume some cards handle this per-port. Other cards might handle this per PF, where PF may not always correspond 1:1 with a port. And some cards maybe just
allow a
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
single value for this parameter for the entire card, covering all ports/PFs.
To keep things simple and as general as possible, it made sense to
set
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
all parameters on a per-PCI device level. As I mentioned in my cover-letter, the devices most likely to use these proposed
commands
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
do not have a single "whole asic" PCI b/d/f with internal mechanism for accessing ports - most expose each port (and each function on
each
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
port) as a separate PCI b/d/f, with no separate "whole asic" PCI b/d/f. That's how the BCM cards work, and I think that's how the
MLNX
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
cards work, and others that would be likely to use these cmds.
So, to summarize, you direct the command to the PCI b/d/f you
want
Quoted 7 lines
Quoted 7 lines
to
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
target. Does this make sense?
So you plan to have 1 devlink instance for each vf? Not sure that does sound right to me :/
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
For the commands proposed in this patchset, AFAIK they all apply on a per-PF or broader, i.e. per-port or whole-card, granularity, since they affect permanent config that applies at boot-up. So, no, the VFs don't really come into play here.
Regardless of whether you're planning on having VFs as devlink
instances,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
the actual attribute question remains -
you're proposing an attribute that forces all VFs to have the same value. This probably suits your PCI core limitations but other vendors mighthave
Quoted 32 lines
Quoted 14 lines
Quoted 5 lines
a different capability set, and accepting this design limitation now would muck all future extension attempts of such attributes.
I think VF configurations should be planned in advance for supporting a per-VF Configuration whenever it's possible - even if not required
[/possible]
Quoted 2 lines
by the one pushing the new attribute.
The commands being added in this patch are for permanent (i.e. NVRAM) config - essentially setting the new default values for various features of the device at boot-up. At that initialization time, no VFs are yet instantiated.
Quoted 4 lines
So my perspective was, in general (not just for our specific device / design), it doesn't seem like permanent config parameters would be set on individual VFs. That was what my previous comment was trying to convey.
That's an odd assumption; Why should you assume there's some device that allows configuring persistent behavior for all VFs but think no other would set the same on a per-VF basis?
Quoted 5 lines
If that assumption is wrong, though, and there is some device that has NVRAM config that is set per-VF, I assume the user would instantiate the VF and then call the devlink API on the pci device corresponding to the VF they with to affect, and I think the model proposed still works.
What would be the purpose of re-configuring a value reflected in the PCI device for an already instantiated VF?
Quoted 6 lines
Quoted 3 lines
Are you suggesting adding a mechanism to set NVRAM parameters on a per-VF basis, without instantiating the VF first? I would prefer not adding such a mechanism unless/until there's a use case for it.
The thing is that you're suggesting a new UAPI; We don't have the leisure of pushing a partial implementation and changing it later on.
I hope we're not talking past each other because I'm not sure we're saying the same thing. But if you have a device which has NVRAM config on an individual VF basis, and you want to be able to get/set that configuration without instantiating the VF first (i.e. without a PCI device to operate on), then one way to handle this is with a new attribute,
DEVLINK_ATTR_PERM_CONFIG_VF_INDEX, for example.
Quoted 7 lines
It could be sent in the nested
DEVLINK_ATTR_PERM_CONFIGattribute, along with the existingDEVLINK_ATTR_PERM_CONFIG_PARAMETERand_VALUE,
to indicate a specific VF within the PF that you are targeting.That seems like the type of thing that could be added later, if/when such a device needed support, without breaking the UAPI, couldn't it?
Sounds feasible to me - as well as UAPI-conserving [albeit a bit un-conservative]
PATCH v2 6/6 bnxt: Add devlink support for config get/set
In reply to Steve LinImplements get and set of configuration parameters using new devlink config get/set API.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 245 +++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 17 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 100 +++++++++ 3 files changed, 356 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +239 -6
@@ -14,11 +14,244 @@#include "bnxt_vfr.h" #include "bnxt_devlink.h" -static const struct devlink_ops bnxt_dl_ops = { +struct bnxt_drv_cfgparam bnxt_drv_cfgparam_list[] = { + {DEVLINK_PERM_CONFIG_SRIOV_ENABLED ,BNXT_DRV_PF , +BNXT_DRV_APPL_SHARED ,1 ,401 }, + {DEVLINK_PERM_CONFIG_NUM_VF_PER_PF ,BNXT_DRV_PF , +BNXT_DRV_APPL_FUNCTION ,8 ,404 }, + {DEVLINK_PERM_CONFIG_MAX_NUM_PF_MSIX_VECT ,BNXT_DRV_PF , +BNXT_DRV_APPL_SHARED ,10 ,108 }, + {DEVLINK_PERM_CONFIG_MSIX_VECTORS_PER_VF ,BNXT_DRV_PF , +BNXT_DRV_APPL_FUNCTION ,10 ,406 }, +}; + +#define BNXT_NUM_DRV_CFGPARAM ARRAY_SIZE(bnxt_drv_cfgparam_list) + +static int bnxt_nvm_read (struct bnxt *bp,int nvm_param,int idx, +void *buf,int size) +{ +struct hwrm_nvm_get_variable_input req = {0 }; +void *dest_data_addr =NULL ; +dma_addr_t dest_data_dma_addr; +int rc; +int bytesize; + + bytesize = (size +7 ) /8 ; + dest_data_addr =dma_alloc_coherent (&bp->pdev->dev, bytesize, + &dest_data_dma_addr,GFP_KERNEL ); +if (!dest_data_addr) { +netdev_err (bp->dev,"dma_alloc_coherent failure\n" ); +return -ENOMEM ; + } + +bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_NVM_GET_VARIABLE ,-1 ,-1 ); + req.dest_data_addr =cpu_to_le64 (dest_data_dma_addr); + req.data_len =cpu_to_le16 (size); + req.option_num =cpu_to_le16 (nvm_param); + req.index_0 =cpu_to_le16 (idx); +if (idx !=0 ) + req.dimensions =cpu_to_le16 (1 ); + + rc =_hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); + +memcpy (buf, dest_data_addr, bytesize); + +dma_free_coherent (&bp->pdev->dev, bytesize, dest_data_addr, + dest_data_dma_addr); + +return rc; +} + +static int bnxt_nvm_write (struct bnxt *bp,int nvm_param,int idx, +const void *buf,int size) +{ +struct hwrm_nvm_set_variable_input req = {0 }; +void *src_data_addr =NULL ; +dma_addr_t src_data_dma_addr; +int rc; +int bytesize; + + bytesize = (size +7 ) /8 ; + + src_data_addr =dma_alloc_coherent (&bp->pdev->dev, bytesize, + &src_data_dma_addr,GFP_KERNEL ); +if (!src_data_addr) { +netdev_err (bp->dev,"dma_alloc_coherent failure\n" ); +return -ENOMEM ; + } + +memcpy (src_data_addr, buf, bytesize); + +bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_NVM_SET_VARIABLE ,-1 ,-1 ); + req.src_data_addr =cpu_to_le64 (src_data_dma_addr); + req.data_len =cpu_to_le16 (size); + req.option_num =cpu_to_le16 (nvm_param); + req.index_0 =cpu_to_le16 (idx); +if (idx !=0 ) + req.dimensions =cpu_to_le16 (1 ); + + rc =_hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); + +dma_free_coherent (&bp->pdev->dev, bytesize, src_data_addr, + src_data_dma_addr); + +return 0 ; +} + +static int bnxt_dl_perm_config_set (struct devlink *devlink, +u32 param,u32 value,u8 *restart_reqd) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (devlink); +int i; +int idx =0 ; +void *data; +int ret =0 ; +u32 bytesize; +struct bnxt_drv_cfgparam *entry; + + *restart_reqd =0 ; + +/* Find parameter in table */ +for (i =0 ; i <BNXT_NUM_DRV_CFGPARAM ; i++) { +if (param == bnxt_drv_cfgparam_list[i].param) { + entry = &bnxt_drv_cfgparam_list[i]; +break ; + } + } + +/* Not found */ +if (i ==BNXT_NUM_DRV_CFGPARAM ) +return -EINVAL ; + +/* Check to see if this func type can access variable */ +if (BNXT_PF (bp) && !(entry->func &BNXT_DRV_PF )) +return -EOPNOTSUPP ; +if (BNXT_VF (bp) && !(entry->func &BNXT_DRV_VF )) +return -EOPNOTSUPP ; + +/* If parameter is per port or function, compute index */ +if (entry->appl ==BNXT_DRV_APPL_PORT ) { + idx = bp->pf.port_id; + }else if (entry->appl ==BNXT_DRV_APPL_FUNCTION ) { +if (BNXT_PF (bp)) + idx = bp->pf.fw_fid -BNXT_FIRST_PF_FID ; +#ifdef CONFIG_BNXT_SRIOV + else + idx = bp->vf.fw_fid -BNXT_FIRST_VF_FID ; +#endif /* CONFIG_BNXT_SRIOV */ + } + + bytesize = (entry->bitlength +7 ) /8 ; + data =kmalloc (bytesize,GFP_KERNEL ); +if (!data) +return -ENOMEM ; + +if (bytesize ==1 ) { +u8 val8 = (value &0xff ); + +memcpy (data, &val8,sizeof (u8)); + }else if (bytesize ==2 ) { +u16 val16 = (value &0xffff ); + +memcpy (data, &val16,sizeof (u16)); + }else { +memcpy (data, &value,sizeof (u32)); + } + + ret =bnxt_nvm_write (bp, entry->nvm_param, idx, data, + entry->bitlength); + +/* Restart required for all nvm parameter writes */ + *restart_reqd =1 ; + +kfree (data); + +return ret; +} + +static int bnxt_dl_perm_config_get (struct devlink *devlink,u32 param, +u32 *value) +{ +struct bnxt *bp =bnxt_get_bp_from_dl (devlink); + +int i; +int idx =0 ; +void *data; +int ret =0 ; +u32 bytesize; +struct bnxt_drv_cfgparam *entry; + +/* Find parameter in table */ +for (i =0 ; i <BNXT_NUM_DRV_CFGPARAM ; i++) { +if (param == bnxt_drv_cfgparam_list[i].param) { + entry = &bnxt_drv_cfgparam_list[i]; +break ; + } + } + +/* Not found */ +if (i ==BNXT_NUM_DRV_CFGPARAM ) +return -EINVAL ; + +/* Check to see if this func type can access variable */ +if (BNXT_PF (bp) && !(entry->func &BNXT_DRV_PF )) +return -EOPNOTSUPP ; +if (BNXT_VF (bp) && !(entry->func &BNXT_DRV_VF )) +return -EOPNOTSUPP ; + +/* If parameter is per port or function, compute index */ +if (entry->appl ==BNXT_DRV_APPL_PORT ) { + idx = bp->pf.port_id; + }else if (entry->appl ==BNXT_DRV_APPL_FUNCTION ) { +if (BNXT_PF (bp)) + idx = bp->pf.fw_fid -BNXT_FIRST_PF_FID ; +#ifdef CONFIG_BNXT_SRIOV + else + idx = bp->vf.fw_fid -BNXT_FIRST_VF_FID ; +#endif /* CONFIG_BNXT_SRIOV */ + } + +/* Allocate space, retrieve value, and copy to result */ + bytesize = (entry->bitlength +7 ) /8 ; + data =kmalloc (bytesize,GFP_KERNEL ); +if (!data) +return -ENOMEM ; + ret =bnxt_nvm_read (bp, entry->nvm_param, idx, data, entry->bitlength); + +if (ret) { +kfree (data); +return ret; + } + +if (bytesize ==1 ) { +u8 val; + +memcpy (&val, data,sizeof (u8)); + *value = val; + }else if (bytesize ==2 ) { +u16 val; + +memcpy (&val, data,sizeof (u16)); + *value = val; + }else { +u32 val; + +memcpy (&val, data,sizeof (u32)); + *value = val; + } + +kfree (data); + +return 0 ; +} + +static struct devlink_ops bnxt_dl_ops = { #ifdef CONFIG_BNXT_SRIOV .eswitch_mode_set = bnxt_dl_eswitch_mode_set, .eswitch_mode_get = bnxt_dl_eswitch_mode_get, #endif /* CONFIG_BNXT_SRIOV */ + .perm_config_get = bnxt_dl_perm_config_get, + .perm_config_set = bnxt_dl_perm_config_set, };int bnxt_dl_register (struct bnxt *bp)
@@ -26,12 +259,12 @@ int bnxt_dl_register(struct bnxt *bp)struct devlink *dl;int rc; -if (!pci_find_ext_capability (bp->pdev,PCI_EXT_CAP_ID_SRIOV )) -return 0 ; - -if (bp->hwrm_spec_code <0x10800 ) { +if ((!pci_find_ext_capability (bp->pdev,PCI_EXT_CAP_ID_SRIOV )) || + bp->hwrm_spec_code <0x10800 ) { +/* eswitch switchdev mode not supported */ + bnxt_dl_ops.eswitch_mode_set =NULL ; + bnxt_dl_ops.eswitch_mode_get =NULL ;netdev_warn (bp->dev,"Firmware does not support SR-IOV E-Switch SWITCHDEV mode.\n" ); -return -ENOTSUPP ; } dl =devlink_alloc (&bnxt_dl_ops,sizeof (struct bnxt_dl ));
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h +17 -0
@@ -10,6 +10,23 @@ #ifndef BNXT_DEVLINK_H #define BNXT_DEVLINK_H +#define BNXT_DRV_PF 1 +#define BNXT_DRV_VF 2 + +enum bnxt_drv_appl { + BNXT_DRV_APPL_SHARED, + BNXT_DRV_APPL_PORT, + BNXT_DRV_APPL_FUNCTION +}; + +struct bnxt_drv_cfgparam { + enum devlink_perm_config_param param; + u8 func; /* BNXT_DRV_PF | BNXT_DRV_VF */ + enum bnxt_drv_appl appl; /* applicability (shared, func, port) */ + u32 bitlength; /* length, in bits */ + u32 nvm_param; +}; + /* Struct to hold housekeeping info needed by devlink interface */ struct bnxt_dl { struct bnxt *bp; /* back ptr to the controlling dev */
drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h +100 -0
106 lines not on this page · raw message
Signature · 1 line
2.7.4
Jiri Pirko
maintainerRe: [PATCH net-next v2 6/6] bnxt: Add devlink support for config get/set
Quoted 2 lines · Thu, Oct 19, 2017 at 09:17:10PM CEST, [email protected] wrote:
Implements get and set of configuration parameters using new devlink config get/set API.
Please split this patch too. One to introduce the infra, one per each config option.
Re: [PATCH net-next v2 6/6] bnxt: Add devlink support for config get/set
Quoted 6 lines · Jiri Pirko
Quoted 2 lines · Thu, Oct 19, 2017 at 09:17:10PM CEST, [email protected] wrote:
Implements get and set of configuration parameters using new devlink config get/set API.
Please split this patch too. One to introduce the infra, one per each config option.
Ok, will do in v3, thanks.