From: Or Har-Toov <[email protected]> Extend 'devlink resource show' to accept DEV/PORT_INDEX, sending DEVLINK_ATTR_PORT_INDEX to the kernel so it returns only that port's resources directly.
For example: $ devlink resource show pci/0000:03:00.0/196608 pci/0000:03:00.0/196608: name max_SFs size 128 unit entry dpipe_tables none Signed-off-by: Or Har-Toov <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> --- bash-completion/devlink | 1 + devlink/devlink.c | 5 +++-- man/man8/devlink-resource.8 | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bash-completion/devlink b/bash-completion/devlink index 7ec6a7cb6abd..3d8452a8869e 100644 --- a/bash-completion/devlink +++ b/bash-completion/devlink @@ -704,6 +704,7 @@ _devlink_resource() show) if [[ $cword -eq 3 ]]; then _devlink_direct_complete "dev" + _devlink_direct_complete "port" fi return ;; diff --git a/devlink/devlink.c b/devlink/devlink.c index 737cfc7437f9..4224b7fa6792 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -9013,7 +9013,8 @@ static int cmd_resource_show(struct dl *dl) int err; err = dl_argv_parse_with_selector(dl, &flags, DEVLINK_CMD_RESOURCE_DUMP, - DL_OPT_HANDLE, 0, 0, 0); + DL_OPT_HANDLE | DL_OPT_HANDLEP, + 0, 0, 0); if (err) return err; @@ -9035,7 +9036,7 @@ static int cmd_resource_show(struct dl *dl) static void cmd_resource_help(void) { - pr_err("Usage: devlink resource show [ DEV ]\n" + pr_err("Usage: devlink resource show [ DEV[/PORT_INDEX] ]\n" " devlink resource set DEV path PATH size SIZE\n"); } diff --git a/man/man8/devlink-resource.8 b/man/man8/devlink-resource.8 index b55138d950c7..1e7d96126ce5 100644 --- a/man/man8/devlink-resource.8 +++ b/man/man8/devlink-resource.8 @@ -19,7 +19,7 @@ devlink-resource \- devlink device resource configuration .ti -8 .B devlink resource show -.RI "[ " DEV " ]" +.RI "[ " DEV "[/" PORT_INDEX "] ]" .ti -8 .B devlink resource help @@ -43,6 +43,16 @@ Format is: .in +2 BUS_NAME/BUS_ADDRESS +.PP +.I "PORT_INDEX" +- specifies the port to show resources for. +When given, only port-level resources for that port are shown. + +.in +4 +Format is: +.in +2 +BUS_NAME/BUS_ADDRESS/PORT_INDEX + .SS devlink resource set - sets resource size of specific resource .PP @@ -69,6 +79,11 @@ devlink resource show pci/0000:01:00.0 Shows the resources of the specified devlink device. .RE .PP +devlink resource show pci/0000:01:00.0/1 +.RS 4 +Shows port-level resources for port 1 of the specified devlink device. +.RE +.PP devlink resource set pci/0000:01:00.0 path /kvd/linear size 98304 .RS 4 Sets the size of the specified resource for the specified devlink device. -- 2.44.0

