From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>
Cc: Simon Horman <horms@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Saeed Mahameed <saeedm@nvidia.com>,
"Leon Romanovsky" <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Shuah Khan <shuah@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
"Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
Carolina Jubran <cjubran@nvidia.com>,
Or Har-Toov <ohartoov@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>,
Dragos Tatulea <dtatulea@nvidia.com>,
Shahar Shitrit <shshitrit@nvidia.com>,
Daniel Zahka <daniel.zahka@gmail.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Cosmin Ratiu <cratiu@nvidia.com>, Parav Pandit <parav@nvidia.com>,
Shay Drori <shayd@nvidia.com>,
"Adithya Jayachandran" <ajayachandra@nvidia.com>,
Kees Cook <kees@kernel.org>,
"Daniel Jurgens" <danielj@nvidia.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
Gal Pressman <gal@nvidia.com>
Subject: [PATCH net-next V4 11/12] selftest: netdevsim: Add resource dump and scope filter test
Date: Wed, 1 Apr 2026 21:49:46 +0300 [thread overview]
Message-ID: <20260401184947.135205-12-tariqt@nvidia.com> (raw)
In-Reply-To: <20260401184947.135205-1-tariqt@nvidia.com>
From: Or Har-Toov <ohartoov@nvidia.com>
Add resource_dump_test() which verifies dumping resources for all
devices and ports, and tests that scope=dev returns only device-level
resources and scope=port returns only port resources.
Skip if userspace does not support the scope parameter.
Signed-off-by: Or Har-Toov <ohartoov@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../drivers/net/netdevsim/devlink.sh | 52 ++++++++++++++++++-
1 file changed, 51 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
index 2e63d02fae4b..8118cc211590 100755
--- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
+++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh
@@ -5,7 +5,7 @@ lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="fw_flash_test params_test \
params_default_test regions_test reload_test \
- netns_reload_test resource_test \
+ netns_reload_test resource_test resource_dump_test \
port_resource_doit_test dev_info_test \
empty_reporter_test dummy_reporter_test rate_test"
NUM_NETIFS=0
@@ -483,6 +483,56 @@ resource_test()
log_test "resource test"
}
+resource_dump_test()
+{
+ RET=0
+
+ local port_jq
+ local dev_jq
+ local dl_jq
+ local count
+
+ dl_jq="with_entries(select(.key | startswith(\"$DL_HANDLE\")))"
+ port_jq="[.[] | $dl_jq | keys |"
+ port_jq+=" map(select(test(\"/.+/\"))) | length] | add"
+ dev_jq="[.[] | $dl_jq | keys |"
+ dev_jq+=" map(select(test(\"/.+/\")|not)) | length] | add"
+
+ if ! devlink resource help 2>&1 | grep -q "scope"; then
+ echo "SKIP: devlink resource show not supported"
+ return
+ fi
+
+ devlink resource show > /dev/null 2>&1
+ check_err $? "Failed to dump all resources"
+
+ count=$(cmd_jq "devlink resource show -j" "$port_jq")
+ [ "$count" -gt "0" ]
+ check_err $? "missing port resources in resource dump"
+
+ count=$(cmd_jq "devlink resource show -j" "$dev_jq")
+ [ "$count" -gt "0" ]
+ check_err $? "missing device resources in resource dump"
+
+ count=$(cmd_jq "devlink resource show scope dev -j" "$dev_jq")
+ [ "$count" -gt "0" ]
+ check_err $? "dev scope missing device resources"
+
+ count=$(cmd_jq "devlink resource show scope dev -j" "$port_jq")
+ [ "$count" -eq "0" ]
+ check_err $? "dev scope returned port resources"
+
+ count=$(cmd_jq "devlink resource show scope port -j" "$port_jq")
+ [ "$count" -gt "0" ]
+ check_err $? "port scope missing port resources"
+
+ count=$(cmd_jq "devlink resource show scope port -j" "$dev_jq")
+ [ "$count" -eq "0" ]
+ check_err $? "port scope returned device resources"
+
+ log_test "resource dump test"
+}
+
info_get()
{
local name=$1
--
2.44.0
next prev parent reply other threads:[~2026-04-01 18:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 18:49 [PATCH net-next V4 00/12] devlink: add per-port resource support Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 01/12] devlink: Refactor resource functions to be generic Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 02/12] devlink: Add port-level resource registration infrastructure Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 03/12] net/mlx5: Register SF resource on PF port representor Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 04/12] netdevsim: Add devlink port resource registration Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 05/12] devlink: Add dump support for device-level resources Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 06/12] devlink: Include port resources in resource dump dumpit Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 07/12] devlink: Add port-specific option to resource dump doit Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 08/12] selftest: netdevsim: Add devlink port resource doit test Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 09/12] devlink: Document port-level resources and full dump Tariq Toukan
2026-04-01 18:49 ` [PATCH net-next V4 10/12] devlink: Add resource scope filtering to resource dump Tariq Toukan
2026-04-03 2:02 ` Jakub Kicinski
2026-04-06 16:18 ` Or Har-Toov
2026-04-01 18:49 ` Tariq Toukan [this message]
2026-04-01 18:49 ` [PATCH net-next V4 12/12] devlink: Document resource scope filtering Tariq Toukan
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=20260401184947.135205-12-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=ajayachandra@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=chuck.lever@oracle.com \
--cc=cjubran@nvidia.com \
--cc=corbet@lwn.net \
--cc=cratiu@nvidia.com \
--cc=daniel.zahka@gmail.com \
--cc=danielj@nvidia.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jiri@resnulli.us \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=ohartoov@nvidia.com \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.com \
--cc=shshitrit@nvidia.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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