devlink: small cleanup around eswitch [sg]et
Subsystems (3)
Jiri Pirko
maintainercover devlink: small cleanup around eswitch [sg]et
From: Jiri Pirko <[email protected]>
Contains small devlink cleanup around eswitch get/set commands.
Jiri Pirko (4):
devlink: fix the name of eswitch commands
devlink: rename devlink_eswitch_fill to devlink_nl_eswitch_fill
devlink: use nla_put_failure goto label instead of out
devlink: allow to fillup eswitch attrs even if mode_get op does not
exist
include/uapi/linux/devlink.h | 10 +++++++-- net/core/devlink.c | 50 +++++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 26 deletions(-)
Signature · 1 line
2.7.4
Jiri Pirko
maintainerPATCH 1/4 devlink: fix the name of eswitch commands
From: Jiri Pirko <[email protected]>
The eswitch_[gs]et command is supposed to be similar to port_[gs]et command - for multiple eswitch attributes. However, when it was introduced by 08f4b5918b2d ("net/devlink: Add E-Switch mode control") it was wrongly named with the word "mode" in it. So fix this now, make the oririnal enum value existing but obsolete.
--- include/uapi/linux/devlink.h | 10 ++++++++-- net/core/devlink.c | 18 +++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-)
include/uapi/linux/devlink.h +8 -2
@@ -57,8 +57,14 @@ enum devlink_command {DEVLINK_CMD_SB_OCC_SNAPSHOT ,DEVLINK_CMD_SB_OCC_MAX_CLEAR , -DEVLINK_CMD_ESWITCH_MODE_GET , -DEVLINK_CMD_ESWITCH_MODE_SET , +DEVLINK_CMD_ESWITCH_GET , +#define DEVLINK_CMD_ESWITCH_MODE_GET /* obsolete, never use this! */ \ + DEVLINK_CMD_ESWITCH_GET + +DEVLINK_CMD_ESWITCH_SET , +#define DEVLINK_CMD_ESWITCH_MODE_SET /* obsolete, never use this! */ \ +DEVLINK_CMD_ESWITCH_SET +/* add new commands above here */ __DEVLINK_CMD_MAX,
net/core/devlink.c +9 -9
@@ -1435,8 +1435,8 @@ static int devlink_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,return err; } -static int devlink_nl_cmd_eswitch_mode_get_doit (struct sk_buff *skb, -struct genl_info *info) +static int devlink_nl_cmd_eswitch_get_doit (struct sk_buff *skb, +struct genl_info *info) {struct devlink *devlink = info->user_ptr[0 ];const struct devlink_ops *ops = devlink->ops;
@@ -1450,7 +1450,7 @@ static int devlink_nl_cmd_eswitch_mode_get_doit(struct sk_buff *skb,if (!msg)return -ENOMEM ; - err =devlink_eswitch_fill (msg, devlink,DEVLINK_CMD_ESWITCH_MODE_GET , + err =devlink_eswitch_fill (msg, devlink,DEVLINK_CMD_ESWITCH_GET , info->snd_portid, info->snd_seq,0 );if (err) {
@@ -1461,8 +1461,8 @@ static int devlink_nl_cmd_eswitch_mode_get_doit(struct sk_buff *skb,return genlmsg_reply (msg, info); } -static int devlink_nl_cmd_eswitch_mode_set_doit (struct sk_buff *skb, -struct genl_info *info) +static int devlink_nl_cmd_eswitch_set_doit (struct sk_buff *skb, +struct genl_info *info) {struct devlink *devlink = info->user_ptr[0 ];const struct devlink_ops *ops = devlink->ops;
@@ -1629,15 +1629,15 @@ static const struct genl_ops devlink_nl_ops[] = { DEVLINK_NL_FLAG_LOCK_PORTS, }, { - .cmd = DEVLINK_CMD_ESWITCH_MODE_GET, - .doit = devlink_nl_cmd_eswitch_mode_get_doit, + .cmd = DEVLINK_CMD_ESWITCH_GET, + .doit = devlink_nl_cmd_eswitch_get_doit, .policy = devlink_nl_policy, .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, }, { - .cmd = DEVLINK_CMD_ESWITCH_MODE_SET, - .doit = devlink_nl_cmd_eswitch_mode_set_doit, + .cmd = DEVLINK_CMD_ESWITCH_SET, + .doit = devlink_nl_cmd_eswitch_set_doit, .policy = devlink_nl_policy, .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK,
Signature · 1 line
2.7.4
Jiri Pirko
maintainerPATCH 2/4 devlink: rename devlink_eswitch_fill to devlink_nl_eswitch_fill
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Be aligned with the rest of the file and name the helper function accordingly.
--- net/core/devlink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/core/devlink.c +5 -5
@@ -1392,9 +1392,9 @@ static int devlink_nl_cmd_sb_occ_max_clear_doit(struct sk_buff *skb,return -EOPNOTSUPP ; } -static int devlink_eswitch_fill (struct sk_buff *msg,struct devlink *devlink, -enum devlink_command cmd,u32 portid, -u32 seq,int flags) +static int devlink_nl_eswitch_fill (struct sk_buff *msg,struct devlink *devlink, +enum devlink_command cmd,u32 portid, +u32 seq,int flags) {const struct devlink_ops *ops = devlink->ops;void *hdr;
@@ -1450,8 +1450,8 @@ static int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb,if (!msg)return -ENOMEM ; - err =devlink_eswitch_fill (msg, devlink,DEVLINK_CMD_ESWITCH_GET , - info->snd_portid, info->snd_seq,0 ); + err =devlink_nl_eswitch_fill (msg, devlink,DEVLINK_CMD_ESWITCH_GET , + info->snd_portid, info->snd_seq,0 );if (err) {nlmsg_free (msg);
Signature · 1 line
2.7.4
Jiri Pirko
maintainerPATCH 3/4 devlink: use nla_put_failure goto label instead of out
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Be aligned with the rest of the code and use label named nla_put_failure.
--- net/core/devlink.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/core/devlink.c +6 -6
@@ -1408,29 +1408,29 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink, err =devlink_nl_put_handle (msg, devlink);if (err) - goto out; + goto nla_put_failure; err = ops->eswitch_mode_get (devlink, &mode);if (err) - goto out; + goto nla_put_failure; err =nla_put_u16 (msg,DEVLINK_ATTR_ESWITCH_MODE , mode);if (err) - goto out; + goto nla_put_failure;if (ops->eswitch_inline_mode_get) { err = ops->eswitch_inline_mode_get (devlink, &inline_mode);if (err) - goto out; + goto nla_put_failure; err =nla_put_u8 (msg,DEVLINK_ATTR_ESWITCH_INLINE_MODE , inline_mode);if (err) - goto out; + goto nla_put_failure; }genlmsg_end (msg, hdr);return 0 ; -out: +nla_put_failure:genlmsg_cancel (msg, hdr);return err; }
Signature · 1 line
2.7.4
Jiri Pirko
maintainerPATCH 4/4 devlink: allow to fillup eswitch attrs even if mode_get op does not exist
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Even when mode_get op is not present, other eswitch attrs need to be filled-up.
--- net/core/devlink.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
net/core/devlink.c +9 -7
@@ -1410,12 +1410,14 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,if (err) goto nla_put_failure; - err = ops->eswitch_mode_get (devlink, &mode); -if (err) - goto nla_put_failure; - err =nla_put_u16 (msg,DEVLINK_ATTR_ESWITCH_MODE , mode); -if (err) - goto nla_put_failure; +if (ops->eswitch_mode_get) { + err = ops->eswitch_mode_get (devlink, &mode); +if (err) + goto nla_put_failure; + err =nla_put_u16 (msg,DEVLINK_ATTR_ESWITCH_MODE , mode); +if (err) + goto nla_put_failure; + }if (ops->eswitch_inline_mode_get) { err = ops->eswitch_inline_mode_get (devlink, &inline_mode);
@@ -1443,7 +1445,7 @@ static int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb,struct sk_buff *msg;int err; -if (!ops || !ops->eswitch_mode_get) +if (!ops)return -EOPNOTSUPP ; msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL );
Signature · 1 line
2.7.4
Quoted 3 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Contains small devlink cleanup around eswitch get/set commands.
Jiri, looks good, thanks for spotting the wrong naming and fixing it up.
Or.
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Thu, 9 Feb 2017 15:54:32 +0100
Quoted 1 line
Contains small devlink cleanup around eswitch get/set commands.
Series applied, thanks.