From: Moshe Shemesh <moshe@mellanox.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
David Ahern <dsahern@gmail.com>, Jakub Kicinski <kuba@kernel.org>,
Jiri Pirko <jiri@nvidia.com>,
netdev@vger.kernel.org
Cc: Moshe Shemesh <moshe@mellanox.com>
Subject: [PATCH iproute2-net v2 2/3] devlink: Add pr_out_dev() helper function
Date: Mon, 7 Dec 2020 07:35:21 +0200 [thread overview]
Message-ID: <1607319322-20970-3-git-send-email-moshe@mellanox.com> (raw)
In-Reply-To: <1607319322-20970-1-git-send-email-moshe@mellanox.com>
Add pr_out_dev() helper function and use it both by cmd_dev_show_cb()
and by cmd_mon_show_cb().
Dev stats will be added on the next patch to dev context, so
cmd_mon_show_cb() should print the whole dev context and not just dev
handle.
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
devlink/devlink.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index 128c81b8..b42eb1b9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -2975,17 +2975,11 @@ static int cmd_dev_param(struct dl *dl)
pr_err("Command \"%s\" not found\n", dl_argv(dl));
return -ENOENT;
}
-static int cmd_dev_show_cb(const struct nlmsghdr *nlh, void *data)
+
+static void pr_out_dev(struct dl *dl, struct nlattr **tb)
{
- struct dl *dl = data;
- struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
- struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
uint8_t reload_failed = 0;
- mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
- if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
- return MNL_CB_ERROR;
-
if (tb[DEVLINK_ATTR_RELOAD_FAILED])
reload_failed = mnl_attr_get_u8(tb[DEVLINK_ATTR_RELOAD_FAILED]);
@@ -2997,7 +2991,19 @@ static int cmd_dev_show_cb(const struct nlmsghdr *nlh, void *data)
} else {
pr_out_handle(dl, tb);
}
+}
+static int cmd_dev_show_cb(const struct nlmsghdr *nlh, void *data)
+{
+ struct dl *dl = data;
+ struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+ struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+
+ mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+ if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
+ return MNL_CB_ERROR;
+
+ pr_out_dev(dl, tb);
return MNL_CB_OK;
}
@@ -4842,7 +4848,7 @@ static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
return MNL_CB_ERROR;
pr_out_mon_header(genl->cmd);
- pr_out_handle(dl, tb);
+ pr_out_dev(dl, tb);
pr_out_mon_footer();
break;
case DEVLINK_CMD_PORT_GET: /* fall through */
--
2.26.2
next prev parent reply other threads:[~2020-12-07 5:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 5:35 [PATCH iproute2-net v2 0/3] devlink: Add devlink reload action limit and stats Moshe Shemesh
2020-12-07 5:35 ` [PATCH iproute2-net v2 1/3] devlink: Add devlink reload action and limit options Moshe Shemesh
2020-12-09 2:46 ` David Ahern
2020-12-09 5:32 ` Moshe Shemesh
2020-12-07 5:35 ` Moshe Shemesh [this message]
2020-12-07 5:35 ` [PATCH iproute2-net v2 3/3] devlink: Add reload stats to dev show Moshe Shemesh
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=1607319322-20970-3-git-send-email-moshe@mellanox.com \
--to=moshe@mellanox.com \
--cc=dsahern@gmail.com \
--cc=jiri@nvidia.com \
--cc=kuba@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).