From: Leon Romanovsky <leon@kernel.org>
To: Steve Wise <larrystevenwise@gmail.com>
Cc: dsahern@gmail.com, stephen@networkplumber.org,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH v2 iproute2-next 3/4] rdma: add 'link add/delete' commands
Date: Mon, 1 Apr 2019 09:37:55 +0300 [thread overview]
Message-ID: <20190401063755.GG8348@mtr-leonro.mtl.com> (raw)
In-Reply-To: <a1b4b7640efb89346c45db060e88bb66103b4f50.1553627811.git.larrystevenwise@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3605 bytes --]
On Tue, Mar 26, 2019 at 02:18:29PM -0500, Steve Wise wrote:
> Add new 'link' subcommand 'add' and 'delete' to allow binding a soft-rdma
> device to a netdev interface.
>
> EG:
>
> rdma link add rxe_eth0 type rxe netdev eth0
> rdma link delete rxe_eth0
>
> Signed-off-by: Steve Wise <larrystevenwise@gmail.com>
> ---
> rdma/link.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> rdma/rdma.h | 2 ++
> 2 files changed, 85 insertions(+)
>
> diff --git a/rdma/link.c b/rdma/link.c
> index 89e81b84..982c2b16 100644
> --- a/rdma/link.c
> +++ b/rdma/link.c
> @@ -9,6 +9,9 @@
> static int link_help(struct rd *rd)
> {
> pr_out("Usage: %s link show [DEV/PORT_INDEX]\n", rd->filename);
> + pr_out("Usage: %s link add NAME type TYPE netdev NETDEV\n",
> + rd->filename);
> + pr_out("Usage: %s link delete NAME\n", rd->filename);
> return 0;
> }
>
> @@ -336,10 +339,90 @@ static int link_show(struct rd *rd)
> return rd_exec_link(rd, link_one_show, true);
> }
>
> +static int link_add_netdev(struct rd *rd)
> +{
> + rd->link_netdev = rd_argv(rd);
> + rd_arg_inc(rd);
> + return 0;
> +}
> +
> +static int link_add_type(struct rd *rd)
> +{
> + const struct rd_cmd cmds[] = {
> + { NULL, link_help},
> + { "netdev", link_add_netdev},
> + { 0 }
> + };
> + rd->link_type = rd_argv(rd);
> + rd_arg_inc(rd);
> + return rd_exec_cmd(rd, cmds, "parameter");
> +}
> +
> +static int link_add(struct rd *rd)
> +{
> + const struct rd_cmd cmds[] = {
> + { NULL, link_help},
> + { "type", link_add_type},
> + { 0 }
> + };
> +
> + uint32_t seq;
> + char *name;
> + int ret;
> +
> + if (rd_no_arg(rd)) {
> + pr_err("Please provide a link name to add.\n");
> + return -EINVAL;
> + }
> + name = rd_argv(rd);
> + rd_arg_inc(rd);
> +
> + ret = rd_exec_cmd(rd, cmds, "parameter");
> + if (ret)
> + return ret;
> +
> + if (!rd->link_type) {
> + pr_err("Please provide a link type name.\n");
> + return -EINVAL;
> + }
> + if (!rd->link_netdev) {
> + pr_err("Please provide a net device name.\n");
> + return -EINVAL;
> + }
After a little bit more thinking, the checks above are supposed to be
part of rd_exec_cmd() execution of chains. E.g if (!rd->link_type) needs
to be inside link_add_type().
> +
> + rd_prepare_msg(rd, RDMA_NLDEV_CMD_NEWLINK, &seq,
> + (NLM_F_REQUEST | NLM_F_ACK));
> + mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_DEV_NAME, name);
> + mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_LINK_TYPE, rd->link_type);
> + mnl_attr_put_strz(rd->nlh, RDMA_NLDEV_ATTR_NDEV_NAME, rd->link_netdev);
> + return rd_sendrecv_msg(rd, seq);
> +}
> +
> +static int _link_del(struct rd *rd)
> +{
> + uint32_t seq;
> +
> + if (!rd_no_arg(rd)) {
> + pr_err("Unknown parameter %s\n", rd_argv(rd));
> + return -EINVAL;
> + }
> + rd_prepare_msg(rd, RDMA_NLDEV_CMD_DELLINK, &seq,
> + (NLM_F_REQUEST | NLM_F_ACK));
> + mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
> + return rd_sendrecv_msg(rd, seq);
> +}
> +
> +static int link_del(struct rd *rd)
> +{
> + return rd_exec_require_dev(rd, _link_del);
> +}
> +
> int cmd_link(struct rd *rd)
> {
> const struct rd_cmd cmds[] = {
> { NULL, link_show },
> + { "add", link_add },
> + { "delete", link_del },
> { "show", link_show },
> { "list", link_show },
> { "help", link_help },
> diff --git a/rdma/rdma.h b/rdma/rdma.h
> index 6c7f7d15..070c8ddf 100644
> --- a/rdma/rdma.h
> +++ b/rdma/rdma.h
> @@ -70,6 +70,8 @@ struct rd {
> bool pretty_output;
> bool suppress_errors;
> struct list_head filter_list;
> + char *link_type;
> + char *link_netdev;
> };
>
> struct rd_cmd {
> --
> 2.20.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2019-04-01 6:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-26 19:18 [PATCH v2 iproute2-next 0/4] Dynamic rdma link creation Steve Wise
2019-03-26 19:18 ` [PATCH v2 iproute2-next 1/4] Add .mailmap file Steve Wise
2019-04-01 6:29 ` Leon Romanovsky
2019-03-26 19:18 ` [PATCH v2 iproute2-next 2/4] rdma: add helper rd_sendrecv_msg() Steve Wise
2019-04-01 2:06 ` David Ahern
2019-04-03 13:16 ` Steve Wise
2019-04-01 6:29 ` Leon Romanovsky
2019-03-26 19:18 ` [PATCH v2 iproute2-next 3/4] rdma: add 'link add/delete' commands Steve Wise
2019-04-01 6:31 ` Leon Romanovsky
2019-04-01 6:37 ` Leon Romanovsky [this message]
2019-04-02 14:33 ` Steve Wise
2019-03-26 19:18 ` [PATCH v2 iproute2-next 4/4] rdma: man page update for link add/delete Steve Wise
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190401063755.GG8348@mtr-leonro.mtl.com \
--to=leon@kernel.org \
--cc=dsahern@gmail.com \
--cc=larrystevenwise@gmail.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).