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 v2 02/13] devlink: Add supported reload actions to dev get
Date: Mon, 17 Aug 2020 12:37:41 +0300 [thread overview]
Message-ID: <1597657072-3130-3-git-send-email-moshe@mellanox.com> (raw)
In-Reply-To: <1597657072-3130-1-git-send-email-moshe@mellanox.com>
Expose devlink reload supported actions to the user through devlink dev
get command.
Examples:
$ devlink dev show
pci/0000:82:00.0:
supported_reload_actions:
fw_live_patch driver_reinit fw_activate
pci/0000:82:00.1:
supported_reload_actions:
fw_live_patch driver_reinit fw_activate
$ devlink dev show -jp
{
"dev": {
"pci/0000:82:00.0": {
"supported_reload_actions": [ "fw_live_patch","driver_reinit","fw_activate" ]
},
"pci/0000:82:00.1": {
"supported_reload_actions": [ "fw_live_patch","driver_reinit","fw_activate" ]
}
}
}
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
---
v1 -> v2:
- Removed DEVLINK_ATTR_RELOAD_DEFAULT_LEVEL
- Removed DEVLINK_ATTR_RELOAD_LEVELS_INFO
- Have actions instead of levels
---
include/uapi/linux/devlink.h | 1 +
net/core/devlink.c | 28 +++++++++++++++++++++++-----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 6728029d2e1e..803a9717110c 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -476,6 +476,7 @@ enum devlink_attr {
DEVLINK_ATTR_PORT_SPLITTABLE, /* u8 */
DEVLINK_ATTR_RELOAD_ACTION, /* u8 */
+ DEVLINK_ATTR_RELOAD_SUPPORTED_ACTIONS, /* nested */
/* add new attributes above here, update the policy in devlink.c */
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 88438ffd6015..6bab1b02ca99 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)
{
@@ -472,7 +477,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 *supported_actions;
void *hdr;
+ int i;
hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
if (!hdr)
@@ -483,9 +490,25 @@ 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)) {
+ supported_actions = nla_nest_start(msg, DEVLINK_ATTR_RELOAD_SUPPORTED_ACTIONS);
+ if (!supported_actions)
+ goto nla_put_failure;
+
+ for (i = 0; i <= DEVLINK_RELOAD_ACTION_MAX; i++) {
+ if (!devlink_reload_action_is_supported(devlink, i))
+ continue;
+ if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_ACTION, i))
+ goto supported_actions_nest_cancel;
+ }
+ nla_nest_end(msg, supported_actions);
+ }
+
genlmsg_end(msg, hdr);
return 0;
+supported_actions_nest_cancel:
+ nla_nest_cancel(msg, supported_actions);
nla_put_failure:
genlmsg_cancel(msg, hdr);
return -EMSGSIZE;
@@ -2949,11 +2972,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-08-17 9:39 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 9:37 [PATCH net-next RFC v2 00/13] Add devlink reload action option Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 01/13] devlink: Add reload action option to devlink reload command Moshe Shemesh
2020-08-17 16:16 ` Jakub Kicinski
2020-08-18 9:06 ` Moshe Shemesh
2020-08-18 15:37 ` Jakub Kicinski
2020-08-17 16:36 ` Jiri Pirko
2020-08-18 9:10 ` Moshe Shemesh
2020-08-19 0:10 ` Jakub Kicinski
2020-08-19 12:18 ` Moshe Shemesh
2020-08-19 12:46 ` Jiri Pirko
2020-08-19 14:23 ` Moshe Shemesh
2020-08-19 15:18 ` Jiri Pirko
2020-08-19 16:25 ` Jakub Kicinski
2020-08-19 18:55 ` Jiri Pirko
2020-08-17 9:37 ` Moshe Shemesh [this message]
2020-08-17 9:37 ` [PATCH net-next RFC v2 03/13] net/mlx5: Add functions to set/query MFRL register Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 04/13] net/mlx5: Set cap for pci sync for fw update event Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 05/13] net/mlx5: Handle sync reset request event Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 06/13] net/mlx5: Handle sync reset now event Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 07/13] net/mlx5: Handle sync reset abort event Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 08/13] net/mlx5: Add support for devlink reload action fw activate Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 09/13] devlink: Add enable_remote_dev_reset generic parameter Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 10/13] net/mlx5: Add devlink param enable_remote_dev_reset support Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 11/13] net/mlx5: Add support for fw live patch event Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 12/13] net/mlx5: Add support for devlink reload action live patch Moshe Shemesh
2020-08-17 9:37 ` [PATCH net-next RFC v2 13/13] devlink: Add Documentation/networking/devlink/devlink-reload.rst Moshe Shemesh
2020-08-17 16:39 ` Jiri Pirko
2020-08-18 9:14 ` Moshe Shemesh
2020-08-18 11:07 ` Jiri Pirko
2020-08-18 20:04 ` 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=1597657072-3130-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®