devlink: add support to run selftest
Subsystems (3)
v5 cover devlink: add support to run selftest
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
flashchanges from:v4->v5
Addressed the comments by [email protected]. Change in json output for seltests show command.
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 (2):
devlink: update the devlink.h
devlink: add support for running selftests
bash-completion/devlink | 30 +++- devlink/devlink.c | 328 +++++++++++++++++++++++++++++++++++ include/uapi/linux/devlink.h | 31 ++++ man/man8/devlink-dev.8 | 46 +++++ 4 files changed, 434 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
PATCH v5 1/2 devlink: update the devlink.h
update the devlink.h to comaptible with net-next kernel.
--- include/uapi/linux/devlink.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
include/uapi/linux/devlink.h +31 -0
@@ -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,
Signature · 1 line
2.31.1
Re: [PATCH iproute2-next v5 1/2] devlink: update the devlink.h
Quoted 7 lines · Vikas Gupta
update the
devlink.hto comaptible with net-next kernel.Signed-off-by Vikas Gupta <[email protected]>--- include/uapi/linux/devlink.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
always send patch sets against top of tree -- iproute2-next in this case.
This patch is not needed as the header file has already been updated.
PATCH v5 2/2 devlink: add support for running selftests
In reply to Vikas GuptaAdd commands and helper APIs to run selftests. Include a selftest id for a non volatile memory i.e. flash. Also, update the man page and bash-completion for selftests commands.
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$ devlink dev selftests show pci/0000:03:00.0 -j
{"selftests":{"pci/0000:03:00.0":["flash"]}}$ devlink dev selftests run pci/0000:03:00.0 id flash -j
{"selftests":{"pci/0000:03:00.0":{"flash":{"status":"passed"}}}}--- bash-completion/devlink | 30 +++- devlink/devlink.c | 328 ++++++++++++++++++++++++++++++++++++++++ man/man8/devlink-dev.8 | 46 ++++++ 3 files changed, 403 insertions(+), 1 deletion(-)
bash-completion/devlink +29 -1
@@ -33,6 +33,11 @@ _devlink_direct_complete() dev) value=$(devlink dev show 2>/dev/null) ;; + selftests_id) + dev=${words[4]} + value=$(devlink -j dev selftests show 2>/dev/null \ + | jq ".selftests[\"$dev\"][]") + ;; param_name) dev=${words[4]} value=$(devlink -j dev param show 2>/dev/null \
@@ -262,6 +267,29 @@ _devlink_dev_flash() esac } +# Completion for devlink dev selftests +_devlink_dev_selftests() +{ + if [[ $cword -gt 5 ]]; then + _devlink_direct_complete "selftests_id" + return + fi + 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 +302,7 @@ _devlink_dev() fi return ;; - eswitch|param) + eswitch|param|selftests) _devlink_dev_$command return ;;
devlink/devlink.c +328 -0
400 lines not on this page · raw message
man/man8/devlink-dev.8 +46 -0
64 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH iproute2-next v5 2/2] devlink: add support for running selftests
Quoted 15 lines · Wed, Aug 03, 2022 at 11:10:25AM CEST, [email protected] wrote:
Add commands and helper APIs to run selftests. Include a selftest id for a non volatile memory i.e. flash. Also, update the man page and bash-completion for selftests commands.
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
Quoted 7 lines
$ devlink dev selftests show pci/0000:03:00.0 -j {"selftests":{"pci/0000:03:00.0":["flash"]}}$ devlink dev selftests run pci/0000:03:00.0 id flash -j {"selftests":{"pci/0000:03:00.0":{"flash":{"status":"passed"}}}}Signed-off-by Vikas Gupta <[email protected]>