Skip to content

Commit fca42a2

Browse files
Eran Ben Elishadavem330
authored andcommitted
devlink: Add health diagnose command
Add devlink health diagnose command, in order to run a diagnose operation over a specific reporter. It is expected from driver's callback for diagnose command to fill it via the devlink fmsg API. Devlink will parse it and convert it to netlink nla API in order to pass it to the user. Signed-off-by: Eran Ben Elisha <[email protected]> Reviewed-by: Moshe Shemesh <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 20a0943 commit fca42a2

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

include/uapi/linux/devlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ enum devlink_command {
9999
DEVLINK_CMD_HEALTH_REPORTER_GET,
100100
DEVLINK_CMD_HEALTH_REPORTER_SET,
101101
DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
102+
DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
102103

103104
/* add new commands above here */
104105
__DEVLINK_CMD_MAX,

net/core/devlink.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,6 +4752,45 @@ static int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
47524752
return devlink_health_reporter_recover(reporter, NULL);
47534753
}
47544754

4755+
static int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
4756+
struct genl_info *info)
4757+
{
4758+
struct devlink *devlink = info->user_ptr[0];
4759+
struct devlink_health_reporter *reporter;
4760+
struct devlink_fmsg *fmsg;
4761+
int err;
4762+
4763+
reporter = devlink_health_reporter_get_from_info(devlink, info);
4764+
if (!reporter)
4765+
return -EINVAL;
4766+
4767+
if (!reporter->ops->diagnose)
4768+
return -EOPNOTSUPP;
4769+
4770+
fmsg = devlink_fmsg_alloc();
4771+
if (!fmsg)
4772+
return -ENOMEM;
4773+
4774+
err = devlink_fmsg_obj_nest_start(fmsg);
4775+
if (err)
4776+
goto out;
4777+
4778+
err = reporter->ops->diagnose(reporter, fmsg);
4779+
if (err)
4780+
goto out;
4781+
4782+
err = devlink_fmsg_obj_nest_end(fmsg);
4783+
if (err)
4784+
goto out;
4785+
4786+
err = devlink_fmsg_snd(fmsg, info,
4787+
DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, 0);
4788+
4789+
out:
4790+
devlink_fmsg_free(fmsg);
4791+
return err;
4792+
}
4793+
47554794
static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
47564795
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING },
47574796
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING },
@@ -5045,6 +5084,13 @@ static const struct genl_ops devlink_nl_ops[] = {
50455084
.flags = GENL_ADMIN_PERM,
50465085
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK,
50475086
},
5087+
{
5088+
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
5089+
.doit = devlink_nl_cmd_health_reporter_diagnose_doit,
5090+
.policy = devlink_nl_policy,
5091+
.flags = GENL_ADMIN_PERM,
5092+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK,
5093+
},
50485094
};
50495095

50505096
static struct genl_family devlink_nl_family __ro_after_init = {

0 commit comments

Comments
 (0)