netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2-next v4 0/3] devlink: add support to run selftest
@ 2022-07-29 10:18 Vikas Gupta
  2022-07-29 10:18 ` [PATCH iproute2-next v4 1/3] devlink: update the devlink.h Vikas Gupta
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vikas Gupta @ 2022-07-29 10:18 UTC (permalink / raw)
  To: jiri, dsahern, stephen
  Cc: kuba, netdev, edumazet, michael.chan, andrew.gospodarek,
	Vikas Gupta

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

Hi,
  This patchset adds support in devlink to run selftests.
  A related patchset for kernel has been merged.

 Below are the few examples for the commands implemented in the
 patchset.
  
Examples:
$ devlink dev selftests run pci/0000:03:00.0 id flash
pci/0000:03:00.0:
    flash:
      status passed

$ devlink dev selftests show pci/0000:03:00.0
pci/0000:03:00.0
      flash

changes from:
v3->v4
    Updated with the UAPI kernel header and hence related implementation
    for selftests impacted due to reorganization of enums/attributes.

v2->v3
    a) Update the implementation of commands according to 
       the latest patch set of kernel devlink patch.
    b) Added bash-completion.

v1->v2
    a) Changes required to implement command due to changes
       in kernel patch (under review).
    b) Added commands descriptions in devlink-dev man page.

Thanks,
Vikas 

Vikas Gupta (3):
  devlink: update the devlink.h
  devlink: add support for running selftestst
  devlink : update man page and bash-completion for new commands

 bash-completion/devlink      |  21 ++-
 devlink/devlink.c            | 294 +++++++++++++++++++++++++++++++++++
 include/uapi/linux/devlink.h |  31 ++++
 man/man8/devlink-dev.8       |  48 ++++++
 4 files changed, 393 insertions(+), 1 deletion(-)

-- 
2.31.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH iproute2-next v4 1/3] devlink: update the devlink.h
  2022-07-29 10:18 [PATCH iproute2-next v4 0/3] devlink: add support to run selftest Vikas Gupta
@ 2022-07-29 10:18 ` Vikas Gupta
  2022-07-29 10:18 ` [PATCH iproute2-next v4 2/3] devlink: add support for running selftestst Vikas Gupta
  2022-07-29 10:18 ` [PATCH iproute2-next v4 3/3] devlink : update man page and bash-completion for new commands Vikas Gupta
  2 siblings, 0 replies; 6+ messages in thread
From: Vikas Gupta @ 2022-07-29 10:18 UTC (permalink / raw)
  To: jiri, dsahern, stephen
  Cc: kuba, netdev, edumazet, michael.chan, andrew.gospodarek,
	Vikas Gupta

[-- Attachment #1: Type: text/plain, Size: 2030 bytes --]

update the devlink.h to comaptible with net-next kernel.

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
---
 include/uapi/linux/devlink.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index da0f1ba8..0224b8bd 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -136,6 +136,9 @@ enum devlink_command {
 	DEVLINK_CMD_LINECARD_NEW,
 	DEVLINK_CMD_LINECARD_DEL,
 
+	DEVLINK_CMD_SELFTESTS_GET,	/* can dump */
+	DEVLINK_CMD_SELFTESTS_RUN,
+
 	/* add new commands above here */
 	__DEVLINK_CMD_MAX,
 	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
@@ -276,6 +279,30 @@ enum {
 #define DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS \
 	(_BITUL(__DEVLINK_FLASH_OVERWRITE_MAX_BIT) - 1)
 
+enum devlink_attr_selftest_id {
+	DEVLINK_ATTR_SELFTEST_ID_UNSPEC,
+	DEVLINK_ATTR_SELFTEST_ID_FLASH,	/* flag */
+
+	__DEVLINK_ATTR_SELFTEST_ID_MAX,
+	DEVLINK_ATTR_SELFTEST_ID_MAX = __DEVLINK_ATTR_SELFTEST_ID_MAX - 1
+};
+
+enum devlink_selftest_status {
+	DEVLINK_SELFTEST_STATUS_SKIP,
+	DEVLINK_SELFTEST_STATUS_PASS,
+	DEVLINK_SELFTEST_STATUS_FAIL
+};
+
+enum devlink_attr_selftest_result {
+	DEVLINK_ATTR_SELFTEST_RESULT_UNSPEC,
+	DEVLINK_ATTR_SELFTEST_RESULT,		/* nested */
+	DEVLINK_ATTR_SELFTEST_RESULT_ID,	/* u32, enum devlink_attr_selftest_id */
+	DEVLINK_ATTR_SELFTEST_RESULT_STATUS,	/* u8, enum devlink_selftest_status */
+
+	__DEVLINK_ATTR_SELFTEST_RESULT_MAX,
+	DEVLINK_ATTR_SELFTEST_RESULT_MAX = __DEVLINK_ATTR_SELFTEST_RESULT_MAX - 1
+};
+
 /**
  * enum devlink_trap_action - Packet trap action.
  * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not
@@ -576,6 +603,10 @@ enum devlink_attr {
 	DEVLINK_ATTR_LINECARD_TYPE,		/* string */
 	DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES,	/* nested */
 
+	DEVLINK_ATTR_NESTED_DEVLINK,		/* nested */
+
+	DEVLINK_ATTR_SELFTESTS,			/* nested */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
-- 
2.31.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH iproute2-next v4 2/3] devlink: add support for running selftestst
  2022-07-29 10:18 [PATCH iproute2-next v4 0/3] devlink: add support to run selftest Vikas Gupta
  2022-07-29 10:18 ` [PATCH iproute2-next v4 1/3] devlink: update the devlink.h Vikas Gupta
@ 2022-07-29 10:18 ` Vikas Gupta
  2022-07-30  9:35   ` Jiri Pirko
  2022-07-29 10:18 ` [PATCH iproute2-next v4 3/3] devlink : update man page and bash-completion for new commands Vikas Gupta
  2 siblings, 1 reply; 6+ messages in thread
From: Vikas Gupta @ 2022-07-29 10:18 UTC (permalink / raw)
  To: jiri, dsahern, stephen
  Cc: kuba, netdev, edumazet, michael.chan, andrew.gospodarek,
	Vikas Gupta

[-- Attachment #1: Type: text/plain, Size: 11101 bytes --]

Add command and helper APIs to run selfests.
Also add a selftest for a non volatile memory i.e. flash.

Examples:
$ devlink dev selftests run pci/0000:03:00.0 id flash
pci/0000:03:00.0:
    flash:
      status passed

$ devlink dev selftests show pci/0000:03:00.0
pci/0000:03:00.0
      flash

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
---
 devlink/devlink.c | 294 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 294 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index ddf430bb..5ab11345 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -294,6 +294,7 @@ static void ifname_map_free(struct ifname_map *ifname_map)
 #define DL_OPT_PORT_FN_RATE_TX_MAX	BIT(49)
 #define DL_OPT_PORT_FN_RATE_NODE_NAME	BIT(50)
 #define DL_OPT_PORT_FN_RATE_PARENT	BIT(51)
+#define DL_OPT_SELFTESTS		BIT(52)
 
 struct dl_opts {
 	uint64_t present; /* flags of present items */
@@ -354,6 +355,7 @@ struct dl_opts {
 	uint64_t rate_tx_max;
 	char *rate_node_name;
 	const char *rate_parent_node;
+	bool selftests_opt[DEVLINK_ATTR_SELFTEST_ID_MAX + 1];
 };
 
 struct dl {
@@ -693,6 +695,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_TRAP_POLICER_ID] = MNL_TYPE_U32,
 	[DEVLINK_ATTR_TRAP_POLICER_RATE] = MNL_TYPE_U64,
 	[DEVLINK_ATTR_TRAP_POLICER_BURST] = MNL_TYPE_U64,
+	[DEVLINK_ATTR_SELFTESTS] = MNL_TYPE_NESTED,
 };
 
 static const enum mnl_attr_data_type
@@ -1401,6 +1404,17 @@ static struct str_num_map port_fn_opstate_map[] = {
 	{ .str = NULL, }
 };
 
+static int selftests_get(const char *selftest_name, bool *selftests_opt)
+{
+	if (strcmp(selftest_name, "flash") == 0) {
+		selftests_opt[0] = 1;
+	} else {
+		pr_err("Unknown selftest \"%s\"\n", selftest_name);
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static int port_flavour_parse(const char *flavour, uint16_t *value)
 {
 	int num;
@@ -1490,6 +1504,7 @@ static const struct dl_args_metadata dl_args_required[] = {
 	{DL_OPT_PORT_FUNCTION_HW_ADDR, "Port function's hardware address is expected."},
 	{DL_OPT_PORT_FLAVOUR,          "Port flavour is expected."},
 	{DL_OPT_PORT_PFNUMBER,         "Port PCI PF number is expected."},
+	{DL_OPT_SELFTESTS,             "Test name is expected"},
 };
 
 static int dl_args_finding_required_validate(uint64_t o_required,
@@ -1793,6 +1808,20 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
 				return err;
 			o_found |= DL_OPT_FLASH_OVERWRITE;
 
+		} else if (dl_argv_match(dl, "id") &&
+				(o_all & DL_OPT_SELFTESTS)) {
+			const char *selftest_name;
+
+			dl_arg_inc(dl);
+			err = dl_argv_str(dl, &selftest_name);
+			if (err)
+				return err;
+			err = selftests_get(selftest_name,
+					    opts->selftests_opt);
+			if (err)
+				return err;
+			o_found |= DL_OPT_SELFTESTS;
+
 		} else if (dl_argv_match(dl, "reporter") &&
 			   (o_all & DL_OPT_HEALTH_REPORTER_NAME)) {
 			dl_arg_inc(dl);
@@ -2063,6 +2092,34 @@ dl_reload_limits_put(struct nlmsghdr *nlh, const struct dl_opts *opts)
 	mnl_attr_put(nlh, DEVLINK_ATTR_RELOAD_LIMITS, sizeof(limits), &limits);
 }
 
+static void
+dl_selftests_put(struct nlmsghdr *nlh, const struct dl_opts *opts)
+{
+	bool test_sel = false;
+	struct nlattr *nest;
+	int id;
+
+	nest = mnl_attr_nest_start(nlh, DEVLINK_ATTR_SELFTESTS);
+
+	for (id = DEVLINK_ATTR_SELFTEST_ID_UNSPEC + 1;
+	     id <= DEVLINK_ATTR_SELFTEST_ID_MAX &&
+		opts->selftests_opt[id]; id++) {
+		if (opts->selftests_opt[id]) {
+			test_sel = true;
+			mnl_attr_put(nlh, id, 0, NULL);
+		}
+	}
+
+	/* No test selcted from user, select all */
+	if (!test_sel) {
+		for (id = DEVLINK_ATTR_SELFTEST_ID_UNSPEC + 1;
+		     id <= DEVLINK_ATTR_SELFTEST_ID_MAX; id++)
+			mnl_attr_put(nlh, id, 0, NULL);
+	}
+
+	mnl_attr_nest_end(nlh, nest);
+}
+
 static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
 {
 	struct dl_opts *opts = &dl->opts;
@@ -2157,6 +2214,8 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
 				  opts->flash_component);
 	if (opts->present & DL_OPT_FLASH_OVERWRITE)
 		dl_flash_update_overwrite_put(nlh, opts);
+	if (opts->present & DL_OPT_SELFTESTS)
+		dl_selftests_put(nlh, opts);
 	if (opts->present & DL_OPT_HEALTH_REPORTER_NAME)
 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME,
 				  opts->reporter_name);
@@ -2285,6 +2344,8 @@ static void cmd_dev_help(void)
 	pr_err("                              [ action { driver_reinit | fw_activate } ] [ limit no_reset ]\n");
 	pr_err("       devlink dev info [ DEV ]\n");
 	pr_err("       devlink dev flash DEV file PATH [ component NAME ] [ overwrite SECTION ]\n");
+	pr_err("       devlink dev selftests show [DEV]\n");
+	pr_err("       devlink dev selftests run DEV [id TESTNAME ]\n");
 }
 
 static bool cmp_arr_last_handle(struct dl *dl, const char *bus_name,
@@ -3904,6 +3965,236 @@ err_socket:
 	return err;
 }
 
+static const char *devlink_get_selftest_name(int id)
+{
+	switch (id) {
+	case DEVLINK_ATTR_SELFTEST_ID_FLASH:
+		return "flash";
+	default:
+		return "unknown";
+	}
+}
+
+static const enum mnl_attr_data_type
+devlink_selftest_id_policy[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = {
+	[DEVLINK_ATTR_SELFTEST_ID_FLASH] = MNL_TYPE_FLAG,
+};
+
+static int selftests_list_attr_cb(const struct nlattr *attr, void *data)
+{
+	const struct nlattr **tb = data;
+	int type;
+
+	if (mnl_attr_type_valid(attr, DEVLINK_ATTR_SELFTEST_ID_MAX) < 0)
+		return MNL_CB_OK;
+
+	type = mnl_attr_get_type(attr);
+	if (mnl_attr_validate(attr, devlink_selftest_id_policy[type]) < 0)
+		return MNL_CB_ERROR;
+
+	tb[type] = attr;
+	return MNL_CB_OK;
+}
+
+static int cmd_dev_selftests_show_cb(const struct nlmsghdr *nlh, void *data)
+{
+	struct nlattr *selftests[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = {};
+	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+	struct dl *dl = data;
+	int avail = 0;
+	int err;
+	int i;
+
+	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+
+	if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
+	    !tb[DEVLINK_ATTR_SELFTESTS])
+		return MNL_CB_ERROR;
+
+	err = mnl_attr_parse_nested(tb[DEVLINK_ATTR_SELFTESTS],
+				    selftests_list_attr_cb, selftests);
+	if (err != MNL_CB_OK)
+		return MNL_CB_ERROR;
+
+	for (i = DEVLINK_ATTR_SELFTEST_ID_UNSPEC + 1;
+	     i <= DEVLINK_ATTR_SELFTEST_ID_MAX; i++) {
+		if (!(selftests[i]))
+			continue;
+
+		if (!avail) {
+			__pr_out_handle_start(dl, tb, true, false);
+			__pr_out_indent_inc();
+			if (!dl->json_output)
+				__pr_out_newline();
+			avail = 1;
+		}
+
+		check_indent_newline(dl);
+		print_string(PRINT_ANY, NULL, "%s", devlink_get_selftest_name(i));
+		if (!dl->json_output)
+			__pr_out_newline();
+	}
+
+	if (avail) {
+		__pr_out_indent_dec();
+		pr_out_handle_end(dl);
+	}
+
+	return MNL_CB_OK;
+}
+
+static const char *devlink_selftest_status_to_str(uint8_t status)
+{
+	switch (status) {
+	case DEVLINK_SELFTEST_STATUS_SKIP:
+		return "skipped";
+	case DEVLINK_SELFTEST_STATUS_PASS:
+		return "passed";
+	case DEVLINK_SELFTEST_STATUS_FAIL:
+		return "failed";
+	default:
+		return "unknown";
+	}
+}
+
+static const enum mnl_attr_data_type
+devlink_selftests_result_policy[DEVLINK_ATTR_SELFTEST_RESULT_MAX + 1] = {
+	[DEVLINK_ATTR_SELFTEST_RESULT] = MNL_TYPE_NESTED,
+	[DEVLINK_ATTR_SELFTEST_RESULT_ID] = MNL_TYPE_U32,
+	[DEVLINK_ATTR_SELFTEST_RESULT_STATUS] = MNL_TYPE_U8,
+};
+
+static int selftests_status_attr_cb(const struct nlattr *attr, void *data)
+{
+	const struct nlattr **tb = data;
+	int type;
+
+	if (mnl_attr_type_valid(attr, DEVLINK_ATTR_SELFTEST_RESULT_MAX) < 0)
+		return MNL_CB_OK;
+
+	type = mnl_attr_get_type(attr);
+	if (mnl_attr_validate(attr, devlink_selftests_result_policy[type]) < 0)
+		return MNL_CB_ERROR;
+
+	tb[type] = attr;
+	return MNL_CB_OK;
+}
+
+static int cmd_dev_selftests_run_cb(const struct nlmsghdr *nlh, void *data)
+{
+	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+	struct nlattr *selftest;
+	struct dl *dl = data;
+	int avail = 0;
+
+	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+
+	if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
+	    !tb[DEVLINK_ATTR_SELFTESTS])
+		return MNL_CB_ERROR;
+
+	mnl_attr_for_each_nested(selftest, tb[DEVLINK_ATTR_SELFTESTS]) {
+		struct nlattr *result[DEVLINK_ATTR_SELFTEST_RESULT_MAX + 1] = {};
+		uint8_t status;
+		int err;
+		int id;
+
+		err = mnl_attr_parse_nested(selftest,
+					    selftests_status_attr_cb, result);
+		if (err != MNL_CB_OK)
+			return MNL_CB_ERROR;
+
+		if (!result[DEVLINK_ATTR_SELFTEST_RESULT_ID] ||
+		    !result[DEVLINK_ATTR_SELFTEST_RESULT_STATUS])
+			return MNL_CB_ERROR;
+
+		if (!avail) {
+			__pr_out_handle_start(dl, tb, true, false);
+			__pr_out_indent_inc();
+			avail = 1;
+			if (!dl->json_output)
+				__pr_out_newline();
+		}
+
+		id = mnl_attr_get_u32(result[DEVLINK_ATTR_SELFTEST_RESULT_ID]);
+		status = mnl_attr_get_u8(result[DEVLINK_ATTR_SELFTEST_RESULT_STATUS]);
+
+		pr_out_object_start(dl, devlink_get_selftest_name(id));
+		check_indent_newline(dl);
+		print_string_name_value("status",
+					devlink_selftest_status_to_str(status));
+		pr_out_object_end(dl);
+		if (!dl->json_output)
+			__pr_out_newline();
+	}
+
+	if (avail) {
+		__pr_out_indent_dec();
+		pr_out_handle_end(dl);
+	}
+
+	return MNL_CB_OK;
+}
+
+static int cmd_dev_selftests_run(struct dl *dl)
+{
+	struct nlmsghdr *nlh;
+	uint16_t flags = NLM_F_REQUEST | NLM_F_ACK;
+	int err;
+
+	nlh = mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_SELFTESTS_RUN, flags);
+
+	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE, DL_OPT_SELFTESTS);
+	if (err)
+		return err;
+
+	if (!(dl->opts.present & DL_OPT_SELFTESTS))
+		dl_selftests_put(nlh, &dl->opts);
+
+	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_dev_selftests_run_cb, dl);
+	return err;
+}
+
+static int cmd_dev_selftests_show(struct dl *dl)
+{
+	uint16_t flags = NLM_F_REQUEST | NLM_F_ACK;
+	struct nlmsghdr *nlh;
+	int err;
+
+	if (dl_argc(dl) == 0)
+		flags |= NLM_F_DUMP;
+
+	nlh = mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_SELFTESTS_GET, flags);
+
+	if (dl_argc(dl) > 0) {
+		err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE, 0);
+		if (err)
+			return err;
+	}
+
+	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_dev_selftests_show_cb, dl);
+	return err;
+}
+
+static int cmd_dev_selftests(struct dl *dl)
+{
+	if (dl_argv_match(dl, "help")) {
+		cmd_dev_help();
+		return 0;
+	} else if (dl_argv_match(dl, "show") ||
+		   dl_argv_match(dl, "list") || dl_no_arg(dl)) {
+		dl_arg_inc(dl);
+		return cmd_dev_selftests_show(dl);
+	} else if (dl_argv_match(dl, "run")) {
+		dl_arg_inc(dl);
+		return cmd_dev_selftests_run(dl);
+	}
+	pr_err("Command \"%s\" not found\n", dl_argv(dl));
+	return -ENOENT;
+}
+
 static int cmd_dev(struct dl *dl)
 {
 	if (dl_argv_match(dl, "help")) {
@@ -3928,6 +4219,9 @@ static int cmd_dev(struct dl *dl)
 	} else if (dl_argv_match(dl, "flash")) {
 		dl_arg_inc(dl);
 		return cmd_dev_flash(dl);
+	} else if (dl_argv_match(dl, "selftests")) {
+		dl_arg_inc(dl);
+		return cmd_dev_selftests(dl);
 	}
 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
 	return -ENOENT;
-- 
2.31.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH iproute2-next v4 3/3] devlink : update man page and bash-completion for new commands
  2022-07-29 10:18 [PATCH iproute2-next v4 0/3] devlink: add support to run selftest Vikas Gupta
  2022-07-29 10:18 ` [PATCH iproute2-next v4 1/3] devlink: update the devlink.h Vikas Gupta
  2022-07-29 10:18 ` [PATCH iproute2-next v4 2/3] devlink: add support for running selftestst Vikas Gupta
@ 2022-07-29 10:18 ` Vikas Gupta
  2022-07-30 12:28   ` Jiri Pirko
  2 siblings, 1 reply; 6+ messages in thread
From: Vikas Gupta @ 2022-07-29 10:18 UTC (permalink / raw)
  To: jiri, dsahern, stephen
  Cc: kuba, netdev, edumazet, michael.chan, andrew.gospodarek,
	Vikas Gupta

[-- Attachment #1: Type: text/plain, Size: 2826 bytes --]

Update the man page for newly added selftests commands.
Examples:
 devlink dev selftests run pci/0000:03:00.0 id flash
 devlink dev selftests show pci/0000:03:00.0

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
---
 bash-completion/devlink | 21 +++++++++++++++++-
 man/man8/devlink-dev.8  | 48 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/bash-completion/devlink b/bash-completion/devlink
index 361be9fe..608a60d0 100644
--- a/bash-completion/devlink
+++ b/bash-completion/devlink
@@ -262,6 +262,25 @@ _devlink_dev_flash()
      esac
 }
 
+# Completion for devlink dev selftests
+_devlink_dev_selftests()
+{
+    case "$cword" in
+        3)
+            COMPREPLY=( $( compgen -W "show run" -- "$cur" ) )
+            return
+            ;;
+        4)
+            _devlink_direct_complete "dev"
+            return
+            ;;
+        5)
+            COMPREPLY=( $( compgen -W "id" -- "$cur" ) )
+            return
+            ;;
+    esac
+}
+
 # Completion for devlink dev
 _devlink_dev()
 {
@@ -274,7 +293,7 @@ _devlink_dev()
             fi
             return
             ;;
-        eswitch|param)
+        eswitch|param|selftests)
             _devlink_dev_$command
             return
             ;;
diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8
index 6906e509..5a06682a 100644
--- a/man/man8/devlink-dev.8
+++ b/man/man8/devlink-dev.8
@@ -85,6 +85,20 @@ devlink-dev \- devlink device configuration
 .I ID
 ]
 
+.ti -8
+.B devlink dev selftests show
+[
+.I DEV
+]
+
+.ti -8
+.B devlink dev selftests run
+.I DEV
+[
+.B id
+.RI "{ " TESTNAME " }"
+]
+
 .SH "DESCRIPTION"
 .SS devlink dev show - display devlink device attributes
 
@@ -249,6 +263,30 @@ should match the component names from
 .B "devlink dev info"
 and may be driver-dependent.
 
+.SS devlink dev selftests show - shows supported selftests on devlink device.
+
+.PP
+.I "DEV"
+- specifies the devlink device.
+If this argument is omitted all selftests for devlink devices are listed.
+
+.SS devlink dev selftests run - runs selftests on devlink device.
+
+.PP
+.I "DEV"
+- specifies the devlink device to execute selftests.
+
+.B id
+{
+.RI { " ID " }
+}
+- The value of
+.I ID
+should match the selftests shown in
+.B "devlink dev selftests show".
+to execute a selftest on the devlink device.
+If this argument is omitted all selftets supported by devlink devices are executed.
+
 .SH "EXAMPLES"
 .PP
 devlink dev show
@@ -296,6 +334,16 @@ Flashing 100%
 .br
 Flashing done
 .RE
+.PP
+devlink dev selftests show pci/0000:01:00.0
+.RS 4
+Shows the supported selftests by the devlink device.
+.RE
+.PP
+devlink dev selftests run pci/0000:01:00.0 id flash
+.RS 4
+Perform a flash test on the devlink device.
+.RE
 
 .SH SEE ALSO
 .BR devlink (8),
-- 
2.31.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next v4 2/3] devlink: add support for running selftestst
  2022-07-29 10:18 ` [PATCH iproute2-next v4 2/3] devlink: add support for running selftestst Vikas Gupta
@ 2022-07-30  9:35   ` Jiri Pirko
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2022-07-30  9:35 UTC (permalink / raw)
  To: Vikas Gupta
  Cc: dsahern, stephen, kuba, netdev, edumazet, michael.chan,
	andrew.gospodarek

Fri, Jul 29, 2022 at 12:18:20PM CEST, vikas.gupta@broadcom.com wrote:
>Add command and helper APIs to run selfests.
>Also add a selftest for a non volatile memory i.e. flash.
>
>Examples:
>$ devlink dev selftests run pci/0000:03:00.0 id flash
>pci/0000:03:00.0:
>    flash:
>      status passed
>
>$ devlink dev selftests show pci/0000:03:00.0
>pci/0000:03:00.0
>      flash

Please include json outputs as well.


>
>Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
>---
> devlink/devlink.c | 294 ++++++++++++++++++++++++++++++++++++++++++++++

> 1 file changed, 294 insertions(+)
>
>diff --git a/devlink/devlink.c b/devlink/devlink.c
>index ddf430bb..5ab11345 100644
>--- a/devlink/devlink.c
>+++ b/devlink/devlink.c
>@@ -294,6 +294,7 @@ static void ifname_map_free(struct ifname_map *ifname_map)
> #define DL_OPT_PORT_FN_RATE_TX_MAX	BIT(49)
> #define DL_OPT_PORT_FN_RATE_NODE_NAME	BIT(50)
> #define DL_OPT_PORT_FN_RATE_PARENT	BIT(51)
>+#define DL_OPT_SELFTESTS		BIT(52)
> 
> struct dl_opts {
> 	uint64_t present; /* flags of present items */
>@@ -354,6 +355,7 @@ struct dl_opts {
> 	uint64_t rate_tx_max;
> 	char *rate_node_name;
> 	const char *rate_parent_node;
>+	bool selftests_opt[DEVLINK_ATTR_SELFTEST_ID_MAX + 1];
> };
> 
> struct dl {
>@@ -693,6 +695,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
> 	[DEVLINK_ATTR_TRAP_POLICER_ID] = MNL_TYPE_U32,
> 	[DEVLINK_ATTR_TRAP_POLICER_RATE] = MNL_TYPE_U64,
> 	[DEVLINK_ATTR_TRAP_POLICER_BURST] = MNL_TYPE_U64,
>+	[DEVLINK_ATTR_SELFTESTS] = MNL_TYPE_NESTED,
> };
> 
> static const enum mnl_attr_data_type
>@@ -1401,6 +1404,17 @@ static struct str_num_map port_fn_opstate_map[] = {
> 	{ .str = NULL, }
> };
> 
>+static int selftests_get(const char *selftest_name, bool *selftests_opt)
>+{
>+	if (strcmp(selftest_name, "flash") == 0) {
>+		selftests_opt[0] = 1;

s/1/true/

Use attr as an index here instead of "0".



>+	} else {
>+		pr_err("Unknown selftest \"%s\"\n", selftest_name);
>+		return -EINVAL;
>+	}
>+	return 0;
>+}
>+
> static int port_flavour_parse(const char *flavour, uint16_t *value)
> {
> 	int num;
>@@ -1490,6 +1504,7 @@ static const struct dl_args_metadata dl_args_required[] = {
> 	{DL_OPT_PORT_FUNCTION_HW_ADDR, "Port function's hardware address is expected."},
> 	{DL_OPT_PORT_FLAVOUR,          "Port flavour is expected."},
> 	{DL_OPT_PORT_PFNUMBER,         "Port PCI PF number is expected."},
>+	{DL_OPT_SELFTESTS,             "Test name is expected"},
> };
> 
> static int dl_args_finding_required_validate(uint64_t o_required,
>@@ -1793,6 +1808,20 @@ static int dl_argv_parse(struct dl *dl, uint64_t o_required,
> 				return err;
> 			o_found |= DL_OPT_FLASH_OVERWRITE;
> 
>+		} else if (dl_argv_match(dl, "id") &&
>+				(o_all & DL_OPT_SELFTESTS)) {
>+			const char *selftest_name;
>+
>+			dl_arg_inc(dl);
>+			err = dl_argv_str(dl, &selftest_name);
>+			if (err)
>+				return err;
>+			err = selftests_get(selftest_name,
>+					    opts->selftests_opt);
>+			if (err)
>+				return err;
>+			o_found |= DL_OPT_SELFTESTS;
>+
> 		} else if (dl_argv_match(dl, "reporter") &&
> 			   (o_all & DL_OPT_HEALTH_REPORTER_NAME)) {
> 			dl_arg_inc(dl);
>@@ -2063,6 +2092,34 @@ dl_reload_limits_put(struct nlmsghdr *nlh, const struct dl_opts *opts)
> 	mnl_attr_put(nlh, DEVLINK_ATTR_RELOAD_LIMITS, sizeof(limits), &limits);
> }
> 
>+static void
>+dl_selftests_put(struct nlmsghdr *nlh, const struct dl_opts *opts)
>+{
>+	bool test_sel = false;
>+	struct nlattr *nest;
>+	int id;
>+
>+	nest = mnl_attr_nest_start(nlh, DEVLINK_ATTR_SELFTESTS);
>+
>+	for (id = DEVLINK_ATTR_SELFTEST_ID_UNSPEC + 1;
>+	     id <= DEVLINK_ATTR_SELFTEST_ID_MAX &&
>+		opts->selftests_opt[id]; id++) {
>+		if (opts->selftests_opt[id]) {
>+			test_sel = true;
>+			mnl_attr_put(nlh, id, 0, NULL);
>+		}
>+	}
>+
>+	/* No test selcted from user, select all */

s/selcted/selected/

I wonder if that is desired behaviour. I guess so. I can't think of
anything better.



>+	if (!test_sel) {
>+		for (id = DEVLINK_ATTR_SELFTEST_ID_UNSPEC + 1;
>+		     id <= DEVLINK_ATTR_SELFTEST_ID_MAX; id++)
>+			mnl_attr_put(nlh, id, 0, NULL);
>+	}
>+
>+	mnl_attr_nest_end(nlh, nest);
>+}
>+
> static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
> {
> 	struct dl_opts *opts = &dl->opts;
>@@ -2157,6 +2214,8 @@ static void dl_opts_put(struct nlmsghdr *nlh, struct dl *dl)
> 				  opts->flash_component);
> 	if (opts->present & DL_OPT_FLASH_OVERWRITE)
> 		dl_flash_update_overwrite_put(nlh, opts);
>+	if (opts->present & DL_OPT_SELFTESTS)
>+		dl_selftests_put(nlh, opts);
> 	if (opts->present & DL_OPT_HEALTH_REPORTER_NAME)
> 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME,
> 				  opts->reporter_name);
>@@ -2285,6 +2344,8 @@ static void cmd_dev_help(void)
> 	pr_err("                              [ action { driver_reinit | fw_activate } ] [ limit no_reset ]\n");
> 	pr_err("       devlink dev info [ DEV ]\n");
> 	pr_err("       devlink dev flash DEV file PATH [ component NAME ] [ overwrite SECTION ]\n");
>+	pr_err("       devlink dev selftests show [DEV]\n");
>+	pr_err("       devlink dev selftests run DEV [id TESTNAME ]\n");
> }
> 
> static bool cmp_arr_last_handle(struct dl *dl, const char *bus_name,
>@@ -3904,6 +3965,236 @@ err_socket:
> 	return err;
> }
> 
>+static const char *devlink_get_selftest_name(int id)
>+{
>+	switch (id) {
>+	case DEVLINK_ATTR_SELFTEST_ID_FLASH:
>+		return "flash";
>+	default:
>+		return "unknown";
>+	}
>+}
>+
>+static const enum mnl_attr_data_type
>+devlink_selftest_id_policy[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = {
>+	[DEVLINK_ATTR_SELFTEST_ID_FLASH] = MNL_TYPE_FLAG,
>+};
>+
>+static int selftests_list_attr_cb(const struct nlattr *attr, void *data)
>+{
>+	const struct nlattr **tb = data;
>+	int type;
>+
>+	if (mnl_attr_type_valid(attr, DEVLINK_ATTR_SELFTEST_ID_MAX) < 0)
>+		return MNL_CB_OK;
>+
>+	type = mnl_attr_get_type(attr);
>+	if (mnl_attr_validate(attr, devlink_selftest_id_policy[type]) < 0)
>+		return MNL_CB_ERROR;
>+
>+	tb[type] = attr;
>+	return MNL_CB_OK;
>+}
>+
>+static int cmd_dev_selftests_show_cb(const struct nlmsghdr *nlh, void *data)
>+{
>+	struct nlattr *selftests[DEVLINK_ATTR_SELFTEST_ID_MAX + 1] = {};
>+	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
>+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
>+	struct dl *dl = data;
>+	int avail = 0;
>+	int err;
>+	int i;
>+
>+	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
>+
>+	if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
>+	    !tb[DEVLINK_ATTR_SELFTESTS])
>+		return MNL_CB_ERROR;
>+
>+	err = mnl_attr_parse_nested(tb[DEVLINK_ATTR_SELFTESTS],
>+				    selftests_list_attr_cb, selftests);
>+	if (err != MNL_CB_OK)
>+		return MNL_CB_ERROR;
>+
>+	for (i = DEVLINK_ATTR_SELFTEST_ID_UNSPEC + 1;
>+	     i <= DEVLINK_ATTR_SELFTEST_ID_MAX; i++) {
>+		if (!(selftests[i]))
>+			continue;
>+
>+		if (!avail) {
>+			__pr_out_handle_start(dl, tb, true, false);
>+			__pr_out_indent_inc();
>+			if (!dl->json_output)
>+				__pr_out_newline();
>+			avail = 1;
>+		}
>+
>+		check_indent_newline(dl);
>+		print_string(PRINT_ANY, NULL, "%s", devlink_get_selftest_name(i));
>+		if (!dl->json_output)
>+			__pr_out_newline();
>+	}
>+
>+	if (avail) {
>+		__pr_out_indent_dec();
>+		pr_out_handle_end(dl);
>+	}
>+
>+	return MNL_CB_OK;
>+}
>+
>+static const char *devlink_selftest_status_to_str(uint8_t status)
>+{
>+	switch (status) {
>+	case DEVLINK_SELFTEST_STATUS_SKIP:
>+		return "skipped";
>+	case DEVLINK_SELFTEST_STATUS_PASS:
>+		return "passed";
>+	case DEVLINK_SELFTEST_STATUS_FAIL:
>+		return "failed";
>+	default:
>+		return "unknown";
>+	}
>+}
>+
>+static const enum mnl_attr_data_type
>+devlink_selftests_result_policy[DEVLINK_ATTR_SELFTEST_RESULT_MAX + 1] = {
>+	[DEVLINK_ATTR_SELFTEST_RESULT] = MNL_TYPE_NESTED,
>+	[DEVLINK_ATTR_SELFTEST_RESULT_ID] = MNL_TYPE_U32,
>+	[DEVLINK_ATTR_SELFTEST_RESULT_STATUS] = MNL_TYPE_U8,
>+};
>+
>+static int selftests_status_attr_cb(const struct nlattr *attr, void *data)
>+{
>+	const struct nlattr **tb = data;
>+	int type;
>+
>+	if (mnl_attr_type_valid(attr, DEVLINK_ATTR_SELFTEST_RESULT_MAX) < 0)
>+		return MNL_CB_OK;
>+
>+	type = mnl_attr_get_type(attr);
>+	if (mnl_attr_validate(attr, devlink_selftests_result_policy[type]) < 0)
>+		return MNL_CB_ERROR;
>+
>+	tb[type] = attr;
>+	return MNL_CB_OK;
>+}
>+
>+static int cmd_dev_selftests_run_cb(const struct nlmsghdr *nlh, void *data)
>+{
>+	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
>+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
>+	struct nlattr *selftest;
>+	struct dl *dl = data;
>+	int avail = 0;
>+
>+	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
>+
>+	if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
>+	    !tb[DEVLINK_ATTR_SELFTESTS])
>+		return MNL_CB_ERROR;
>+
>+	mnl_attr_for_each_nested(selftest, tb[DEVLINK_ATTR_SELFTESTS]) {
>+		struct nlattr *result[DEVLINK_ATTR_SELFTEST_RESULT_MAX + 1] = {};
>+		uint8_t status;
>+		int err;
>+		int id;
>+
>+		err = mnl_attr_parse_nested(selftest,
>+					    selftests_status_attr_cb, result);
>+		if (err != MNL_CB_OK)
>+			return MNL_CB_ERROR;
>+
>+		if (!result[DEVLINK_ATTR_SELFTEST_RESULT_ID] ||
>+		    !result[DEVLINK_ATTR_SELFTEST_RESULT_STATUS])
>+			return MNL_CB_ERROR;
>+
>+		if (!avail) {
>+			__pr_out_handle_start(dl, tb, true, false);
>+			__pr_out_indent_inc();
>+			avail = 1;
>+			if (!dl->json_output)
>+				__pr_out_newline();
>+		}
>+
>+		id = mnl_attr_get_u32(result[DEVLINK_ATTR_SELFTEST_RESULT_ID]);
>+		status = mnl_attr_get_u8(result[DEVLINK_ATTR_SELFTEST_RESULT_STATUS]);
>+
>+		pr_out_object_start(dl, devlink_get_selftest_name(id));
>+		check_indent_newline(dl);
>+		print_string_name_value("status",
>+					devlink_selftest_status_to_str(status));
>+		pr_out_object_end(dl);
>+		if (!dl->json_output)
>+			__pr_out_newline();
>+	}
>+
>+	if (avail) {
>+		__pr_out_indent_dec();
>+		pr_out_handle_end(dl);
>+	}
>+
>+	return MNL_CB_OK;
>+}
>+
>+static int cmd_dev_selftests_run(struct dl *dl)
>+{
>+	struct nlmsghdr *nlh;
>+	uint16_t flags = NLM_F_REQUEST | NLM_F_ACK;
>+	int err;
>+
>+	nlh = mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_SELFTESTS_RUN, flags);
>+
>+	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE, DL_OPT_SELFTESTS);
>+	if (err)
>+		return err;
>+
>+	if (!(dl->opts.present & DL_OPT_SELFTESTS))
>+		dl_selftests_put(nlh, &dl->opts);
>+
>+	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_dev_selftests_run_cb, dl);
>+	return err;
>+}
>+
>+static int cmd_dev_selftests_show(struct dl *dl)
>+{
>+	uint16_t flags = NLM_F_REQUEST | NLM_F_ACK;
>+	struct nlmsghdr *nlh;
>+	int err;
>+
>+	if (dl_argc(dl) == 0)
>+		flags |= NLM_F_DUMP;
>+
>+	nlh = mnlu_gen_socket_cmd_prepare(&dl->nlg, DEVLINK_CMD_SELFTESTS_GET, flags);
>+
>+	if (dl_argc(dl) > 0) {
>+		err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE, 0);
>+		if (err)
>+			return err;
>+	}
>+
>+	err = mnlu_gen_socket_sndrcv(&dl->nlg, nlh, cmd_dev_selftests_show_cb, dl);
>+	return err;
>+}
>+
>+static int cmd_dev_selftests(struct dl *dl)
>+{
>+	if (dl_argv_match(dl, "help")) {
>+		cmd_dev_help();
>+		return 0;
>+	} else if (dl_argv_match(dl, "show") ||
>+		   dl_argv_match(dl, "list") || dl_no_arg(dl)) {
>+		dl_arg_inc(dl);
>+		return cmd_dev_selftests_show(dl);
>+	} else if (dl_argv_match(dl, "run")) {
>+		dl_arg_inc(dl);
>+		return cmd_dev_selftests_run(dl);
>+	}
>+	pr_err("Command \"%s\" not found\n", dl_argv(dl));
>+	return -ENOENT;
>+}
>+
> static int cmd_dev(struct dl *dl)
> {
> 	if (dl_argv_match(dl, "help")) {
>@@ -3928,6 +4219,9 @@ static int cmd_dev(struct dl *dl)
> 	} else if (dl_argv_match(dl, "flash")) {
> 		dl_arg_inc(dl);
> 		return cmd_dev_flash(dl);
>+	} else if (dl_argv_match(dl, "selftests")) {
>+		dl_arg_inc(dl);
>+		return cmd_dev_selftests(dl);
> 	}
> 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
> 	return -ENOENT;
>-- 
>2.31.1
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next v4 3/3] devlink : update man page and bash-completion for new commands
  2022-07-29 10:18 ` [PATCH iproute2-next v4 3/3] devlink : update man page and bash-completion for new commands Vikas Gupta
@ 2022-07-30 12:28   ` Jiri Pirko
  0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2022-07-30 12:28 UTC (permalink / raw)
  To: Vikas Gupta
  Cc: dsahern, stephen, kuba, netdev, edumazet, michael.chan,
	andrew.gospodarek

Fri, Jul 29, 2022 at 12:18:21PM CEST, vikas.gupta@broadcom.com wrote:
>Update the man page for newly added selftests commands.
>Examples:
> devlink dev selftests run pci/0000:03:00.0 id flash
> devlink dev selftests show pci/0000:03:00.0
>
>Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
>---
> bash-completion/devlink | 21 +++++++++++++++++-
> man/man8/devlink-dev.8  | 48 +++++++++++++++++++++++++++++++++++++++++

I don't think there is a separate patchset needed for this. Just squash
to the previous one.


> 2 files changed, 68 insertions(+), 1 deletion(-)
>
>diff --git a/bash-completion/devlink b/bash-completion/devlink
>index 361be9fe..608a60d0 100644
>--- a/bash-completion/devlink
>+++ b/bash-completion/devlink
>@@ -262,6 +262,25 @@ _devlink_dev_flash()
>      esac
> }
> 
>+# Completion for devlink dev selftests
>+_devlink_dev_selftests()
>+{
>+    case "$cword" in
>+        3)
>+            COMPREPLY=( $( compgen -W "show run" -- "$cur" ) )
>+            return
>+            ;;
>+        4)
>+            _devlink_direct_complete "dev"
>+            return
>+            ;;
>+        5)
>+            COMPREPLY=( $( compgen -W "id" -- "$cur" ) )
>+            return
>+            ;;

Another tab should list available selftests for device.



>+    esac
>+}
>+
> # Completion for devlink dev
> _devlink_dev()
> {
>@@ -274,7 +293,7 @@ _devlink_dev()
>             fi
>             return
>             ;;
>-        eswitch|param)
>+        eswitch|param|selftests)
>             _devlink_dev_$command
>             return
>             ;;
>diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8
>index 6906e509..5a06682a 100644
>--- a/man/man8/devlink-dev.8
>+++ b/man/man8/devlink-dev.8
>@@ -85,6 +85,20 @@ devlink-dev \- devlink device configuration
> .I ID
> ]
> 
>+.ti -8
>+.B devlink dev selftests show
>+[
>+.I DEV
>+]
>+
>+.ti -8
>+.B devlink dev selftests run
>+.I DEV
>+[
>+.B id
>+.RI "{ " TESTNAME " }"
>+]
>+
> .SH "DESCRIPTION"
> .SS devlink dev show - display devlink device attributes
> 
>@@ -249,6 +263,30 @@ should match the component names from
> .B "devlink dev info"
> and may be driver-dependent.
> 
>+.SS devlink dev selftests show - shows supported selftests on devlink device.
>+
>+.PP
>+.I "DEV"
>+- specifies the devlink device.
>+If this argument is omitted all selftests for devlink devices are listed.
>+
>+.SS devlink dev selftests run - runs selftests on devlink device.
>+
>+.PP
>+.I "DEV"
>+- specifies the devlink device to execute selftests.
>+
>+.B id
>+{
>+.RI { " ID " }
>+}
>+- The value of
>+.I ID
>+should match the selftests shown in

You can specify multiple ids, can't you? If not, you should and you
should describe it here.


>+.B "devlink dev selftests show".
>+to execute a selftest on the devlink device.
>+If this argument is omitted all selftets supported by devlink devices are executed.

s/selftets/selftests/


>+
> .SH "EXAMPLES"
> .PP
> devlink dev show
>@@ -296,6 +334,16 @@ Flashing 100%
> .br
> Flashing done
> .RE
>+.PP
>+devlink dev selftests show pci/0000:01:00.0
>+.RS 4
>+Shows the supported selftests by the devlink device.
>+.RE
>+.PP
>+devlink dev selftests run pci/0000:01:00.0 id flash
>+.RS 4
>+Perform a flash test on the devlink device.
>+.RE
> 
> .SH SEE ALSO
> .BR devlink (8),
>-- 
>2.31.1
>




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-30 12:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-29 10:18 [PATCH iproute2-next v4 0/3] devlink: add support to run selftest Vikas Gupta
2022-07-29 10:18 ` [PATCH iproute2-next v4 1/3] devlink: update the devlink.h Vikas Gupta
2022-07-29 10:18 ` [PATCH iproute2-next v4 2/3] devlink: add support for running selftestst Vikas Gupta
2022-07-30  9:35   ` Jiri Pirko
2022-07-29 10:18 ` [PATCH iproute2-next v4 3/3] devlink : update man page and bash-completion for new commands Vikas Gupta
2022-07-30 12:28   ` Jiri Pirko

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).