From: Moshe Shemesh <moshe@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@mellanox.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Moshe Shemesh <moshe@mellanox.com>
Subject: [PATCH net-next RFC v4 04/15] devlink: Add reload actions stats to dev get
Date: Mon, 14 Sep 2020 09:07:51 +0300 [thread overview]
Message-ID: <1600063682-17313-5-git-send-email-moshe@mellanox.com> (raw)
In-Reply-To: <1600063682-17313-1-git-send-email-moshe@mellanox.com>
Expose devlink reload actions stats to the user through devlink dev
get command.
Examples:
$ devlink dev show
pci/0000:82:00.0:
reload_action_stats:
driver_reinit 2
fw_activate 1
driver_reinit_no_reset 0
fw_activate_no_reset 0
pci/0000:82:00.1:
reload_action_stats:
driver_reinit 1
fw_activate 1
driver_reinit_no_reset 0
fw_activate_no_reset 0
$ devlink dev show -jp
{
"dev": {
"pci/0000:82:00.0": {
"reload_action_stats": [ {
"driver_reinit": 2
},{
"fw_activate": 1
},{
"driver_reinit_no_reset": 0
},{
"fw_activate_no_reset": 0
} ]
},
"pci/0000:82:00.1": {
"reload_action_stats": [ {
"driver_reinit": 1
},{
"fw_activate": 1
},{
"driver_reinit_no_reset": 0
},{
"fw_activate_no_reset": 0
} ]
}
}
}
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
---
v3 -> v4:
- Renamed DEVLINK_ATTR_RELOAD_ACTION_CNT to
DEVLINK_ATTR_RELOAD_ACTION_STAT
- Add stats per action per limit level
v2 -> v3:
- Add reload actions counters instead of supported reload actions
(reload actions counters are only for supported action so no need for
both)
v1 -> v2:
- Removed DEVLINK_ATTR_RELOAD_DEFAULT_LEVEL
- Removed DEVLINK_ATTR_RELOAD_LEVELS_INFO
- Have actions instead of levels
---
include/uapi/linux/devlink.h | 3 +++
net/core/devlink.c | 45 ++++++++++++++++++++++++++++++++----
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index b19686fd80ff..ac9be467d243 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -495,6 +495,9 @@ enum devlink_attr {
DEVLINK_ATTR_RELOAD_ACTION, /* u8 */
DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED, /* nested */
DEVLINK_ATTR_RELOAD_ACTION_LIMIT_LEVEL, /* u8 */
+ DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */
+ DEVLINK_ATTR_RELOAD_ACTION_STAT, /* nested */
+ DEVLINK_ATTR_RELOAD_ACTION_STAT_VALUE, /* u32 */
/* add new attributes above here, update the policy in devlink.c */
diff --git a/net/core/devlink.c b/net/core/devlink.c
index cbf746966913..1063b7a4123a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -462,6 +462,11 @@ static int devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink)
return 0;
}
+static bool devlink_reload_supported(struct devlink *devlink)
+{
+ return devlink->ops->reload_down && devlink->ops->reload_up;
+}
+
static bool
devlink_reload_action_is_supported(struct devlink *devlink, enum devlink_reload_action action)
{
@@ -479,7 +484,9 @@ static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink,
enum devlink_command cmd, u32 portid,
u32 seq, int flags)
{
+ struct nlattr *reload_action_stats, *reload_action_stat;
+ int i, j, stat_idx;
void *hdr;
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
if (!hdr)
@@ -490,9 +497,42 @@ static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink,
if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_FAILED, devlink->reload_failed))
goto nla_put_failure;
+ if (!devlink_reload_supported(devlink))
+ goto out;
+
+ reload_action_stats = nla_nest_start(msg, DEVLINK_ATTR_RELOAD_ACTION_STATS);
+ if (!reload_action_stats)
+ goto nla_put_failure;
+
+ for (j = 0; j <= DEVLINK_RELOAD_ACTION_LIMIT_LEVEL_MAX; j++) {
+ if (!devlink_reload_action_limit_level_is_supported(devlink, j))
+ continue;
+ for (i = 0; i <= DEVLINK_RELOAD_ACTION_MAX; i++) {
+ if (!devlink_reload_action_is_supported(devlink, i))
+ continue;
+ reload_action_stat = nla_nest_start(msg, DEVLINK_ATTR_RELOAD_ACTION_STAT);
+ if (!reload_action_stat)
+ goto reload_action_stats_nest_cancel;
+ if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_ACTION, i))
+ goto reload_action_stat_nest_cancel;
+ if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_ACTION_LIMIT_LEVEL, j))
+ goto reload_action_stat_nest_cancel;
+ stat_idx = j * __DEVLINK_RELOAD_ACTION_MAX + i;
+ if (nla_put_u32(msg, DEVLINK_ATTR_RELOAD_ACTION_STAT_VALUE,
+ devlink->reload_action_stats[stat_idx]))
+ goto reload_action_stat_nest_cancel;
+ nla_nest_end(msg, reload_action_stat);
+ }
+ nla_nest_end(msg, reload_action_stats);
+ }
+out:
genlmsg_end(msg, hdr);
return 0;
+reload_action_stat_nest_cancel:
+ nla_nest_cancel(msg, reload_action_stat);
+reload_action_stats_nest_cancel:
+ nla_nest_cancel(msg, reload_action_stats);
nla_put_failure:
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
@@ -2961,11 +3001,6 @@ static void devlink_reload_netns_change(struct devlink *devlink,
DEVLINK_CMD_PARAM_NEW);
}
-static bool devlink_reload_supported(const struct devlink *devlink)
-{
- return devlink->ops->reload_down && devlink->ops->reload_up;
-}
-
static void devlink_reload_failed_set(struct devlink *devlink,
bool reload_failed)
{
--
2.17.1
next prev parent reply other threads:[~2020-09-14 6:10 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-14 6:07 [PATCH net-next RFC v4 00/15] Add devlink reload action and Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 01/15] devlink: Add reload action option to devlink reload command Moshe Shemesh
2020-09-14 7:08 ` Vasundhara Volam
2020-09-14 9:32 ` Jiri Pirko
2020-09-14 9:54 ` Vasundhara Volam
2020-09-14 11:28 ` Jiri Pirko
2020-09-14 21:31 ` Jakub Kicinski
2020-09-14 22:06 ` Michael Chan
2020-09-15 6:18 ` Jiri Pirko
2020-09-14 12:27 ` Jiri Pirko
2020-09-15 12:12 ` Moshe Shemesh
2020-09-15 13:26 ` Jiri Pirko
2020-09-15 20:06 ` Moshe Shemesh
2020-09-14 21:33 ` Jakub Kicinski
2020-09-15 12:56 ` Moshe Shemesh
2020-09-15 13:26 ` Jiri Pirko
2020-09-15 16:00 ` Jakub Kicinski
2020-09-14 6:07 ` [PATCH net-next RFC v4 02/15] devlink: Add reload action limit level Moshe Shemesh
2020-09-14 13:10 ` Jiri Pirko
2020-09-15 12:15 ` Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 03/15] devlink: Add reload action stats Moshe Shemesh
2020-09-14 13:39 ` Jiri Pirko
2020-09-15 12:30 ` Moshe Shemesh
2020-09-15 13:33 ` Jiri Pirko
2020-09-15 20:20 ` Moshe Shemesh
2020-09-16 6:07 ` Jiri Pirko
2020-09-14 6:07 ` Moshe Shemesh [this message]
2020-09-14 13:45 ` [PATCH net-next RFC v4 04/15] devlink: Add reload actions stats to dev get Jiri Pirko
2020-09-15 6:45 ` Ido Schimmel
2020-09-15 7:44 ` Jiri Pirko
2020-09-15 12:31 ` Moshe Shemesh
2020-09-15 13:34 ` Jiri Pirko
2020-09-15 20:33 ` Moshe Shemesh
2020-09-18 16:13 ` Moshe Shemesh
2020-09-21 10:33 ` Jiri Pirko
2020-09-14 6:07 ` [PATCH net-next RFC v4 05/15] net/mlx5: Add functions to set/query MFRL register Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 06/15] net/mlx5: Set cap for pci sync for fw update event Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 07/15] net/mlx5: Handle sync reset request event Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 08/15] net/mlx5: Handle sync reset now event Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 09/15] net/mlx5: Handle sync reset abort event Moshe Shemesh
2020-09-14 6:07 ` [PATCH net-next RFC v4 10/15] net/mlx5: Add support for devlink reload action fw activate Moshe Shemesh
2020-09-14 13:52 ` Jiri Pirko
2020-09-15 12:38 ` Moshe Shemesh
2020-09-14 13:54 ` Jiri Pirko
2020-09-15 12:44 ` Moshe Shemesh
2020-09-15 13:37 ` Jiri Pirko
2020-09-15 20:28 ` Moshe Shemesh
2020-09-16 6:08 ` Jiri Pirko
2020-09-14 6:07 ` [PATCH net-next RFC v4 11/15] devlink: Add enable_remote_dev_reset generic parameter Moshe Shemesh
2020-09-14 14:12 ` Jiri Pirko
2020-09-14 6:07 ` [PATCH net-next RFC v4 12/15] net/mlx5: Add devlink param enable_remote_dev_reset support Moshe Shemesh
2020-09-14 6:08 ` [PATCH net-next RFC v4 13/15] net/mlx5: Add support for fw live patch event Moshe Shemesh
2020-09-14 6:08 ` [PATCH net-next RFC v4 14/15] net/mlx5: Add support for devlink reload action limit level no reset Moshe Shemesh
2020-09-14 6:08 ` [PATCH net-next RFC v4 15/15] devlink: Add Documentation/networking/devlink/devlink-reload.rst Moshe Shemesh
2020-09-14 11:43 ` Jiri Pirko
2020-09-15 16:04 ` Jakub Kicinski
2020-09-15 19:59 ` 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=1600063682-17313-5-git-send-email-moshe@mellanox.com \
--to=moshe@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.