rdma: IB device rename
Subsystems (3)
cover rdma: IB device rename
From: Leon Romanovsky <[email protected]>
Changelog:
* Dropped RFC tag after kernel part was accepted
* Updated commit message of first patch to include correct SHA1
-----------------------------------------------------------------------
Hi,
This is comprehensive part of kernel series posted earlier. The kernel part is not accepted yet, so first patch will have different commit message with different commit SHA1. This is why it is marked as RFC.
An example:
[leonro@server /]$ lspci |grep -i Ether
00:08.0 Ethernet controller: Red Hat, Inc. Virtio network device
00:09.0 Ethernet controller: Mellanox Technologies MT27700 Family [ConnectX-4] [leonro@server /]$ sudo rdma dev
1: mlx5_0: node_type ca fw 3.8.9999 node_guid 5254:00c0:fe12:3455 sys_image_guid 5254:00c0:fe12:3455 [leonro@server /]$ sudo rdma dev set mlx5_0 name hfi1_0
[leonro@server /]$ sudo rdma dev
1: hfi1_0: node_type ca fw 3.8.9999 node_guid 5254:00c0:fe12:3455 sys_image_guid 5254:00c0:fe12:3455
Thanks
Leon Romanovsky (3):
rdma: Update kernel include file to support IB device renaming
rdma: Introduce command execution helper with required device name
rdma: Add an option to rename IB device interface
rdma/dev.c | 35 +++++++++++++++++++++++++++++++++++ rdma/include/uapi/rdma/rdma_netlink.h | 3 ++- rdma/rdma.h | 1 + rdma/utils.c | 10 ++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-)
PATCH 1/3 rdma: Update kernel include file to support IB device renaming
From: Leon Romanovsky <[email protected]>
Bring kernel header file changes upto commit 05d940d3a3ec ("RDMA/nldev: Allow IB device rename through RDMA netlink")
--- rdma/include/uapi/rdma/rdma_netlink.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
rdma/include/uapi/rdma/rdma_netlink.h +2 -1
@@ -227,8 +227,9 @@ enum rdma_nldev_command {RDMA_NLDEV_CMD_UNSPEC ,RDMA_NLDEV_CMD_GET ,/* can dump */ +RDMA_NLDEV_CMD_SET , -/* 2 - 4 are free to use */ +/* 3 - 4 are free to use */ RDMA_NLDEV_CMD_PORT_GET = 5, /* can dump */
Signature · 1 line
2.14.4
PATCH 2/3 rdma: Introduce command execution helper with required device name
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
In contradiction to various show commands, the set command explicitly requires to use device name as an argument. Provide new command execution helper which enforces it.
--- rdma/rdma.h | 1 + rdma/utils.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
rdma/rdma.h +1 -0
@@ -90,6 +90,7 @@ int cmd_link(struct rd *rd);int cmd_res (struct rd *rd);int rd_exec_cmd (struct rd *rd,const struct rd_cmd *c,const char *str);int rd_exec_dev (struct rd *rd,int (*cb)(struct rd *rd)); +int rd_exec_require_dev (struct rd *rd,int (*cb)(struct rd *rd));int rd_exec_link (struct rd *rd,int (*cb)(struct rd *rd),bool strict_port);void rd_free (struct rd *rd);int rd_set_arg_to_devname (struct rd *rd);
rdma/utils.c +10 -0
@@ -577,6 +577,16 @@ out:return ret; } +int rd_exec_require_dev (struct rd *rd,int (*cb)(struct rd *rd)) +{ +if (rd_no_arg (rd)) { +pr_err ("Please provide device name.\n" ); +return -EINVAL ; + } + +return rd_exec_dev (rd, cb); +} +int rd_exec_cmd (struct rd *rd,const struct rd_cmd *cmds,const char *str) {const struct rd_cmd *c;
Signature · 1 line
2.14.4
PATCH 3/3 rdma: Add an option to rename IB device interface
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Enrich rdmatool with an option to rename IB devices, the command interface follows Iproute2 convention:
"rdma dev set [OLD-DEVNAME] name NEW-DEVNAME"
--- rdma/dev.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
rdma/dev.c +35 -0
@@ -14,6 +14,7 @@static int dev_help (struct rd *rd) {pr_out ("Usage: %s dev show [DEV]\n" , rd->filename); +pr_out (" %s dev set [DEV] name DEVNAME\n" , rd->filename);return 0 ; }
@@ -240,17 +241,51 @@ static int dev_one_show(struct rd *rd)return rd_exec_cmd (rd, cmds,"parameter" ); } +static int dev_set_name (struct rd *rd) +{ +uint32_t seq; + +if (rd_no_arg (rd)) { +pr_err ("Please provide device new name.\n" ); +return -EINVAL ; + } + +rd_prepare_msg (rd,RDMA_NLDEV_CMD_SET , + &seq, (NLM_F_REQUEST |NLM_F_ACK )); +mnl_attr_put_u32 (rd->nlh,RDMA_NLDEV_ATTR_DEV_INDEX , rd->dev_idx); +mnl_attr_put_strz (rd->nlh,RDMA_NLDEV_ATTR_DEV_NAME ,rd_argv (rd)); + +return rd_send_msg (rd); +} + +static int dev_one_set (struct rd *rd) +{ +const struct rd_cmd cmds[] = { + {NULL , dev_help}, + {"name" , dev_set_name}, + {0 } + }; + +return rd_exec_cmd (rd, cmds,"parameter" ); +} +static int dev_show (struct rd *rd) {return rd_exec_dev (rd, dev_one_show); } +static int dev_set (struct rd *rd) +{ +return rd_exec_require_dev (rd, dev_one_set); +} +int cmd_dev (struct rd *rd) {const struct rd_cmd cmds[] = { {NULL , dev_show }, {"show" , dev_show }, {"list" , dev_show }, + {"set" , dev_set }, {"help" , dev_help }, {0 } };
Signature · 1 line
2.14.4
Re: [PATCH iproute2-next 3/3] rdma: Add an option to rename IB device interface
Quoted 25 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Enrich rdmatool with an option to rename IB devices, the command interface follows Iproute2 convention:
"rdma dev set [OLD-DEVNAME] name NEW-DEVNAME"Signed-off-by Leon Romanovsky <[email protected]>--- rdma/dev.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)rdma/dev.c +1
-0@@ -14,6 +14,7 @@static int dev_help (struct rd *rd) {pr_out ("Usage: %s dev show [DEV]\n" , rd->filename); +pr_out (" %s dev set [DEV] name DEVNAME\n" , rd->filename);return 0 ; }@@ -240,17 +241,51 @@ static int dev_one_show(struct rd *rd)return rd_exec_cmd (rd, cmds,"parameter" );
rdma/dev.c static int dev_one_show(struct rd *rd) · line 251
Quoted 10 lines
rdma/dev.c +8
-0} +static int dev_set_name (struct rd *rd) +{ +uint32_t seq; + +if (rd_no_arg (rd)) { +pr_err ("Please provide device new name.\n" ); +return -EINVAL ; + }
This is redundant with rd_exec_require_dev which is the required path to get to this point.
Re: [PATCH iproute2-next 3/3] rdma: Add an option to rename IB device interface
Quoted 28 lines · David Ahern
Quoted 27 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Enrich rdmatool with an option to rename IB devices, the command interface follows Iproute2 convention:
"rdma dev set [OLD-DEVNAME] name NEW-DEVNAME"Signed-off-by Leon Romanovsky <[email protected]>--- rdma/dev.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)rdma/dev.c +1
-0@@ -14,6 +14,7 @@static int dev_help (struct rd *rd) {pr_out ("Usage: %s dev show [DEV]\n" , rd->filename); +pr_out (" %s dev set [DEV] name DEVNAME\n" , rd->filename);return 0 ; }@@ -240,17 +241,51 @@ static int dev_one_show(struct rd *rd)return rd_exec_cmd (rd, cmds,"parameter" ); }
Quoted 11 lines
rdma/dev.c static int dev_one_show(struct rd *rd) · line 251
Quoted 8 lines
rdma/dev.c +8
-0+static int dev_set_name (struct rd *rd) +{ +uint32_t seq; + +if (rd_no_arg (rd)) { +pr_err ("Please provide device new name.\n" ); +return -EINVAL ; + }This is redundant with
rd_exec_require_devwhich is the required path to get to this point.
Sorry for being slow in response, I was on vacation.
----------
This print is intended to warn about missing "new name" and it is not checked by rd_exec_require_dev()
To emphasize it:
rdma/dev.c +0 -0
@@ -246,6 +246,7 @@ static int dev_set_name(struct rd *rd)uint32_t seq;
if (rd_no_arg(rd)) {
+ pr_err("hello world\n");
pr_err("Please provide device new name.\n");
return -EINVAL;
}Produces the following output:
[leonro@server iproute2]$ ./rdma/rdma dev set mlx5_0 name hello world
Please provide device new name.
So how will we progress from here? Should I respin?
Thanks
Re: [PATCH iproute2-next 3/3] rdma: Add an option to rename IB device interface
Quoted 22 lines · Leon Romanovsky
Sorry for being slow in response, I was on vacation.
----------This print is intended to warn about missing "new name" and it is not checked by
rd_exec_require_dev()To emphasize it:
rdma/dev.c +1
-0@@ -246,6 +246,7 @@ static int dev_set_name(struct rd *rd)uint32_t seq;if (rd_no_arg (rd)) { +pr_err ("hello world\n" );pr_err ("Please provide device new name.\n" );return -EINVAL ; }
Quoted 6 lines
Produces the following output:
[leonro@server iproute2]$ ./rdma/rdma dev setmlx5_0name hello world
Please provide device new name.So how will we progress from here? Should I respin?
ok, thanks for the explanation.
Steve mentioned an update to the man page is needed as well. Please do that in the respin.
Thanks,
Re: [PATCH iproute2-next 3/3] rdma: Add an option to rename IB device interface
Quoted 28 lines · David Ahern
Quoted 27 lines · Leon Romanovsky
Sorry for being slow in response, I was on vacation.
----------This print is intended to warn about missing "new name" and it is not checked by
rd_exec_require_dev()To emphasize it:
rdma/dev.c +1
-0@@ -246,6 +246,7 @@ static int dev_set_name(struct rd *rd)uint32_t seq;if (rd_no_arg (rd)) { +pr_err ("hello world\n" );pr_err ("Please provide device new name.\n" );return -EINVAL ; }Produces the following output:
[leonro@server iproute2]$ ./rdma/rdma dev setmlx5_0name hello world
Please provide device new name.
Quoted 6 lines
Quoted 1 line
So how will we progress from here? Should I respin?
ok, thanks for the explanation.
Steve mentioned an update to the man page is needed as well. Please do that in the respin.
No problem, will do, thanks
Quoted 2 lines
Thanks,