Skip to content

Commit e2ce94d

Browse files
Jiri Pirkodavem330
authored andcommitted
devlink: introduce the health reporter test command
Introduce a test command for health reporters. User might use this command to trigger test event on a reporter if the reporter supports it. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 191c0c2 commit e2ce94d

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎include/net/devlink.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ enum devlink_health_reporter_state {
566566
* @dump: callback to dump an object
567567
* if priv_ctx is NULL, run a full dump
568568
* @diagnose: callback to diagnose the current status
569+
* @test: callback to trigger a test event
569570
*/
570571

571572
struct devlink_health_reporter_ops {
@@ -578,6 +579,8 @@ struct devlink_health_reporter_ops {
578579
int (*diagnose)(struct devlink_health_reporter *reporter,
579580
struct devlink_fmsg *fmsg,
580581
struct netlink_ext_ack *extack);
582+
int (*test)(struct devlink_health_reporter *reporter,
583+
struct netlink_ext_ack *extack);
581584
};
582585

583586
/**

‎include/uapi/linux/devlink.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ enum devlink_command {
122122
DEVLINK_CMD_TRAP_POLICER_NEW,
123123
DEVLINK_CMD_TRAP_POLICER_DEL,
124124

125+
DEVLINK_CMD_HEALTH_REPORTER_TEST,
126+
125127
/* add new commands above here */
126128
__DEVLINK_CMD_MAX,
127129
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1

‎net/core/devlink.c‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6096,6 +6096,28 @@ devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
60966096
return 0;
60976097
}
60986098

6099+
static int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
6100+
struct genl_info *info)
6101+
{
6102+
struct devlink *devlink = info->user_ptr[0];
6103+
struct devlink_health_reporter *reporter;
6104+
int err;
6105+
6106+
reporter = devlink_health_reporter_get_from_info(devlink, info);
6107+
if (!reporter)
6108+
return -EINVAL;
6109+
6110+
if (!reporter->ops->test) {
6111+
devlink_health_reporter_put(reporter);
6112+
return -EOPNOTSUPP;
6113+
}
6114+
6115+
err = reporter->ops->test(reporter, info->extack);
6116+
6117+
devlink_health_reporter_put(reporter);
6118+
return err;
6119+
}
6120+
60996121
struct devlink_stats {
61006122
u64 rx_bytes;
61016123
u64 rx_packets;
@@ -7316,6 +7338,14 @@ static const struct genl_ops devlink_nl_ops[] = {
73167338
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
73177339
DEVLINK_NL_FLAG_NO_LOCK,
73187340
},
7341+
{
7342+
.cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST,
7343+
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7344+
.doit = devlink_nl_cmd_health_reporter_test_doit,
7345+
.flags = GENL_ADMIN_PERM,
7346+
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT |
7347+
DEVLINK_NL_FLAG_NO_LOCK,
7348+
},
73197349
{
73207350
.cmd = DEVLINK_CMD_FLASH_UPDATE,
73217351
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,

0 commit comments

Comments
 (0)