From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, dsahern@kernel.org, jiri@nvidia.com,
petrm@nvidia.com, Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH iproute2] devlink: Fix resource show output
Date: Thu, 15 Jan 2026 13:50:04 +0200 [thread overview]
Message-ID: <20260115115004.863685-1-idosch@nvidia.com> (raw)
When the user asks to show device resources, devlink first queries the
device's dpipe tables so that it will be able to show the association
between resources and dpipe tables.
In this flow, 'ctx->resources' is always NULL as resources have yet to
be retrieved. As a result, the dpipe tables are not associated with a
resource identifier and the resource show command does not show any
dpipe tables:
$ devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 258048 unit entry dpipe_tables none
resources:
name linear size 98304 occ 1 unit entry size_min 0 size_max 159744 size_gran 128 dpipe_tables none
resources:
name singles size 16384 occ 1 unit entry size_min 0 size_max 159744 size_gran 1 dpipe_tables none
name chunks size 49152 occ 0 unit entry size_min 0 size_max 159744 size_gran 32 dpipe_tables none
name large_chunks size 32768 occ 0 unit entry size_min 0 size_max 159744 size_gran 512 dpipe_tables none
name hash_double size 65408 unit entry size_min 32768 size_max 192512 size_gran 128 dpipe_tables none
name hash_single size 94336 unit entry size_min 65536 size_max 225280 size_gran 128 dpipe_tables none
name span_agents size 3 occ 0 unit entry dpipe_tables none
name counters size 32766 occ 4 unit entry dpipe_tables none
resources:
name rif size 8192 occ 0 unit entry dpipe_tables none
name flow size 24574 occ 4 unit entry dpipe_tables none
name global_policers size 1000 unit entry dpipe_tables none
resources:
name single_rate_policers size 968 occ 0 unit entry dpipe_tables none
name rif_mac_profiles size 1 occ 0 unit entry dpipe_tables none
name rifs size 1000 occ 1 unit entry dpipe_tables none
name port_range_registers size 16 occ 0 unit entry dpipe_tables none
name physical_ports size 64 occ 32 unit entry dpipe_tables none
Fix by moving the check against 'ctx->resources' to the place where it
is actually used. Output after the fix:
$ devlink resource show pci/0000:03:00.0
pci/0000:03:00.0:
name kvd size 258048 unit entry dpipe_tables none
resources:
name linear size 98304 occ 1 unit entry size_min 0 size_max 159744 size_gran 128
dpipe_tables:
table_name mlxsw_adj
resources:
name singles size 16384 occ 1 unit entry size_min 0 size_max 159744 size_gran 1 dpipe_tables none
name chunks size 49152 occ 0 unit entry size_min 0 size_max 159744 size_gran 32 dpipe_tables none
name large_chunks size 32768 occ 0 unit entry size_min 0 size_max 159744 size_gran 512 dpipe_tables none
name hash_double size 65408 unit entry size_min 32768 size_max 192512 size_gran 128
dpipe_tables:
table_name mlxsw_host6
name hash_single size 94336 unit entry size_min 65536 size_max 225280 size_gran 128
dpipe_tables:
table_name mlxsw_host4
name span_agents size 3 occ 0 unit entry dpipe_tables none
name counters size 32766 occ 4 unit entry dpipe_tables none
resources:
name rif size 8192 occ 0 unit entry dpipe_tables none
name flow size 24574 occ 4 unit entry dpipe_tables none
name global_policers size 1000 unit entry dpipe_tables none
resources:
name single_rate_policers size 968 occ 0 unit entry dpipe_tables none
name rif_mac_profiles size 1 occ 0 unit entry dpipe_tables none
name rifs size 1000 occ 1 unit entry dpipe_tables none
name port_range_registers size 16 occ 0 unit entry dpipe_tables none
name physical_ports size 64 occ 32 unit entry dpipe_tables none
Fixes: 0e7e1819453c ("devlink: relax dpipe table show dependency on resources")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
devlink/devlink.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/devlink/devlink.c b/devlink/devlink.c
index b95fd348007c..0b3bf197e6f2 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -8088,8 +8088,7 @@ static int dpipe_table_show(struct dpipe_ctx *ctx, struct nlattr *nl)
size = mnl_attr_get_u32(nla_table[DEVLINK_ATTR_DPIPE_TABLE_SIZE]);
counters_enabled = !!mnl_attr_get_u8(nla_table[DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED]);
- resource_valid = nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID] &&
- ctx->resources;
+ resource_valid = !!nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID];
if (resource_valid) {
table->resource_id = mnl_attr_get_u64(nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID]);
table->resource_valid = true;
@@ -8104,7 +8103,7 @@ static int dpipe_table_show(struct dpipe_ctx *ctx, struct nlattr *nl)
print_uint(PRINT_ANY, "size", " size %u", size);
print_bool(PRINT_ANY, "counters_enabled", " counters_enabled %s", counters_enabled);
- if (resource_valid) {
+ if (resource_valid && ctx->resources) {
resource_units = mnl_attr_get_u32(nla_table[DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS]);
resource_path_print(ctx->dl, ctx->resources,
table->resource_id);
--
2.52.0
next reply other threads:[~2026-01-15 11:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:50 Ido Schimmel [this message]
2026-01-20 23:30 ` [PATCH iproute2] devlink: Fix resource show output patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260115115004.863685-1-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=dsahern@kernel.org \
--cc=jiri@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox