netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et
@ 2017-02-09 14:54 Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 1/4] devlink: fix the name of eswitch commands Jiri Pirko
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jiri Pirko @ 2017-02-09 14:54 UTC (permalink / raw)
  To: netdev; +Cc: davem, ogerlitz, mlxsw, ivecera

From: Jiri Pirko <jiri@mellanox.com>

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(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch net-next 1/4] devlink: fix the name of eswitch commands
  2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
@ 2017-02-09 14:54 ` Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 2/4] devlink: rename devlink_eswitch_fill to devlink_nl_eswitch_fill Jiri Pirko
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2017-02-09 14:54 UTC (permalink / raw)
  To: netdev; +Cc: davem, ogerlitz, mlxsw, ivecera

From: Jiri Pirko <jiri@mellanox.com>

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.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 include/uapi/linux/devlink.h | 10 ++++++++--
 net/core/devlink.c           | 18 +++++++++---------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 9014c33..0f1f3a1 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -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,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 2b5bf9e..7aa8e53 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -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,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net-next 2/4] devlink: rename devlink_eswitch_fill to devlink_nl_eswitch_fill
  2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 1/4] devlink: fix the name of eswitch commands Jiri Pirko
@ 2017-02-09 14:54 ` Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 3/4] devlink: use nla_put_failure goto label instead of out Jiri Pirko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2017-02-09 14:54 UTC (permalink / raw)
  To: netdev; +Cc: davem, ogerlitz, mlxsw, ivecera

From: Jiri Pirko <jiri@mellanox.com>

Be aligned with the rest of the file and name the helper function
accordingly.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/core/devlink.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 7aa8e53..f361924 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net-next 3/4] devlink: use nla_put_failure goto label instead of out
  2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 1/4] devlink: fix the name of eswitch commands Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 2/4] devlink: rename devlink_eswitch_fill to devlink_nl_eswitch_fill Jiri Pirko
@ 2017-02-09 14:54 ` Jiri Pirko
  2017-02-09 14:54 ` [patch net-next 4/4] devlink: allow to fillup eswitch attrs even if mode_get op does not exist Jiri Pirko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2017-02-09 14:54 UTC (permalink / raw)
  To: netdev; +Cc: davem, ogerlitz, mlxsw, ivecera

From: Jiri Pirko <jiri@mellanox.com>

Be aligned with the rest of the code and use label named nla_put_failure.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/core/devlink.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index f361924..7f88cc8 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -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;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [patch net-next 4/4] devlink: allow to fillup eswitch attrs even if mode_get op does not exist
  2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
                   ` (2 preceding siblings ...)
  2017-02-09 14:54 ` [patch net-next 3/4] devlink: use nla_put_failure goto label instead of out Jiri Pirko
@ 2017-02-09 14:54 ` Jiri Pirko
  2017-02-09 16:14 ` [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Or Gerlitz
  2017-02-10 19:43 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2017-02-09 14:54 UTC (permalink / raw)
  To: netdev; +Cc: davem, ogerlitz, mlxsw, ivecera

From: Jiri Pirko <jiri@mellanox.com>

Even when mode_get op is not present, other eswitch attrs need to be
filled-up.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 net/core/devlink.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 7f88cc8..e9c1e6a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et
  2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
                   ` (3 preceding siblings ...)
  2017-02-09 14:54 ` [patch net-next 4/4] devlink: allow to fillup eswitch attrs even if mode_get op does not exist Jiri Pirko
@ 2017-02-09 16:14 ` Or Gerlitz
  2017-02-10 19:43 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Or Gerlitz @ 2017-02-09 16:14 UTC (permalink / raw)
  To: Jiri Pirko; +Cc: Linux Netdev List, David Miller, Or Gerlitz, mlxsw, ivecera

On Thu, Feb 9, 2017 at 4:54 PM, Jiri Pirko <jiri@resnulli.us> wrote:
> From: Jiri Pirko <jiri@mellanox.com>
>
> Contains small devlink cleanup around eswitch get/set commands.

Jiri, looks good, thanks for spotting the wrong naming and fixing it up.

Or.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et
  2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
                   ` (4 preceding siblings ...)
  2017-02-09 16:14 ` [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Or Gerlitz
@ 2017-02-10 19:43 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-02-10 19:43 UTC (permalink / raw)
  To: jiri; +Cc: netdev, ogerlitz, mlxsw, ivecera

From: Jiri Pirko <jiri@resnulli.us>
Date: Thu,  9 Feb 2017 15:54:32 +0100

> Contains small devlink cleanup around eswitch get/set commands.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-02-10 19:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 14:54 [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Jiri Pirko
2017-02-09 14:54 ` [patch net-next 1/4] devlink: fix the name of eswitch commands Jiri Pirko
2017-02-09 14:54 ` [patch net-next 2/4] devlink: rename devlink_eswitch_fill to devlink_nl_eswitch_fill Jiri Pirko
2017-02-09 14:54 ` [patch net-next 3/4] devlink: use nla_put_failure goto label instead of out Jiri Pirko
2017-02-09 14:54 ` [patch net-next 4/4] devlink: allow to fillup eswitch attrs even if mode_get op does not exist Jiri Pirko
2017-02-09 16:14 ` [patch net-next 0/4] devlink: small cleanup around eswitch [sg]et Or Gerlitz
2017-02-10 19:43 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).