]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: show port resources in resource dump
authorOr Har-Toov <ohartoov@nvidia.com>
Tue, 9 Jun 2026 05:39:51 +0000 (08:39 +0300)
committerDavid Ahern <dsahern@kernel.org>
Sun, 28 Jun 2026 17:12:40 +0000 (11:12 -0600)
When the kernel returns port-level resource messages during a
DEVLINK_CMD_RESOURCE_DUMP, display them alongside device-level
resources.

For example:

$ devlink resource show
pci/0000:03:00.0:
  name max_local_SFs size 32 unit entry dpipe_tables none
  name max_external_SFs size 32 unit entry dpipe_tables none
pci/0000:03:00.0/196608:
  name max_SFs size 32 unit entry dpipe_tables none
pci/0000:03:00.1:
  name max_local_SFs size 32 unit entry dpipe_tables none
  name max_external_SFs size 32 unit entry dpipe_tables none
pci/0000:03:00.1/262144:
  name max_SFs size 32 unit entry dpipe_tables none

Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
devlink/devlink.c

index 0962ffd861adc0d2a78953144f3276a126db7988..737cfc7437f92ef37b9a48516bb54f0049ab57c4 100644 (file)
@@ -8954,18 +8954,23 @@ static void resources_dpipe_tables_fini(struct dpipe_ctx *dpipe_ctx,
 static void
 resources_show(struct resource_ctx *ctx, struct nlattr **tb)
 {
-       struct resources *resources = ctx->resources;
+       bool is_port = !!tb[DEVLINK_ATTR_PORT_INDEX];
        struct dpipe_ctx dpipe_ctx = {};
        struct resource *resource;
+       struct dl *dl = ctx->dl;
 
        resources_dpipe_tables_init(&dpipe_ctx, ctx, tb);
-
-       list_for_each_entry(resource, &resources->resource_list, list) {
-               pr_out_handle_start_arr(ctx->dl, tb);
+       list_for_each_entry(resource, &ctx->resources->resource_list, list) {
+               if (is_port)
+                       pr_out_port_handle_start_arr(dl, tb, false);
+               else
+                       pr_out_handle_start_arr(dl, tb);
                resource_show(resource, ctx);
-               pr_out_handle_end(ctx->dl);
+               if (is_port)
+                       pr_out_port_handle_end(dl);
+               else
+                       pr_out_handle_end(dl);
        }
-
        resources_dpipe_tables_fini(&dpipe_ctx, ctx);
 }