From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, pabeni@redhat.com,
shuah@kernel.org, alexander.duyck@gmail.com
Subject: [PATCH net-next 04/14] selftests: net: shaper: Add basic_groups_with_rate test
Date: Tue, 4 Aug 2026 20:09:26 -0700 [thread overview]
Message-ID: <20260805030936.1092907-5-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20260805030936.1092907-1-mohsin.bashr@gmail.com>
From: Mohsin Bashir <hmohsin@meta.com>
Add a test that groups queues under the netdev parent with rate
limiting enabled. Extract the common group-under-netdev flow into
_group_under_netdev helper to share with basic_groups.
The test independently checks for netdev scope bw_max and metric
capabilities before proceeding, and verifies that the netdev
shaper persists after leaf deletion.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
tools/testing/selftests/drivers/net/shaper.py | 83 +++++++++++++++----
1 file changed, 68 insertions(+), 15 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/shaper.py b/tools/testing/selftests/drivers/net/shaper.py
index 45a4bf42995e..168a8dd057e5 100755
--- a/tools/testing/selftests/drivers/net/shaper.py
+++ b/tools/testing/selftests/drivers/net/shaper.py
@@ -167,20 +167,25 @@ def del_nshapers(cfg, nl_shaper) -> None:
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
ksft_eq(len(shapers), 0)
-def basic_groups(cfg, nl_shaper) -> None:
- _require_queues(cfg, 3)
-
- _require_caps(cfg, nl_shaper, 'netdev', [], "netdev scope not supported by the device")
- _require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'],
- "queue scope not supported with nesting and weight")
-
- node_handle = nl_shaper.group({
- 'ifindex': cfg.ifindex,
- 'leaves':[{'handle': {'scope': 'queue', 'id': 1},
- 'weight': 1},
- {'handle': {'scope': 'queue', 'id': 2},
- 'weight': 2}],
- 'handle': {'scope':'netdev'}})
+def _group_under_netdev(cfg, nl_shaper, bw_max=None):
+ r"""Group queues under a netdev-scope node; caller owns node teardown.
+
+ netdev netdev
+ / \ del Q1,Q2
+ Q1 Q2 -------> (netdev node persists)
+ """
+ group_args = {
+ 'ifindex': cfg.ifindex,
+ 'leaves': [{'handle': {'scope': 'queue', 'id': 1},
+ 'weight': 1},
+ {'handle': {'scope': 'queue', 'id': 2},
+ 'weight': 2}],
+ 'handle': {'scope': 'netdev'}}
+ if bw_max:
+ group_args['metric'] = 'bps'
+ group_args['bw-max'] = bw_max
+
+ node_handle = nl_shaper.group(group_args)
ksft_eq(node_handle, {'ifindex': cfg.ifindex,
'handle': {'scope': 'netdev'}})
@@ -194,10 +199,29 @@ def basic_groups(cfg, nl_shaper) -> None:
ksft_eq(shaper, {'ifindex': cfg.ifindex,
'parent': {'scope': 'netdev'},
'handle': {'scope': 'queue', 'id': 1},
- 'weight': 1 })
+ 'weight': 1})
for dq in del_queues:
dq.exec()
+ # Caller owns the node teardown so it can verify the netdev-scope node
+ # survives leaf deletion before removing it.
+ return del_node
+
+def basic_groups(cfg, nl_shaper) -> None:
+ r"""Group queues under a netdev-scope node, then tear it down.
+
+ netdev
+ / \
+ Q1 Q2
+ """
+ _require_queues(cfg, 3)
+
+ _require_caps(cfg, nl_shaper, 'netdev', [], "netdev scope not supported by the device")
+ _require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'],
+ "queue scope not supported with nesting and weight")
+
+ del_node = _group_under_netdev(cfg, nl_shaper)
+
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
ksft_eq(shapers, [{'ifindex': cfg.ifindex,
'handle': {'scope': 'netdev'}}])
@@ -206,6 +230,34 @@ def basic_groups(cfg, nl_shaper) -> None:
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
ksft_eq(len(shapers), 0)
+def basic_groups_with_rate(cfg, nl_shaper) -> None:
+ r"""Rate-limited netdev-scope node outlives deletion of its leaves.
+
+ netdev[10kbps] netdev[10kbps]
+ / \ del Q1,Q2
+ Q1 Q2 -------> (node persists)
+ """
+ bw_max = 10000
+
+ _require_queues(cfg, 3)
+
+ _require_caps(cfg, nl_shaper, 'netdev', ['support-bw-max', 'support-metric-bps'],
+ "device does not support netdev scope rate limiting")
+ _require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'],
+ "device does not support queue scope shapers with nesting and weight")
+
+ del_node = _group_under_netdev(cfg, nl_shaper, bw_max=bw_max)
+
+ # Deleting all the leaves shaper does not affect the node one
+ # when the latter has 'netdev' scope.
+ shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
+ ksft_eq(shapers, [{'ifindex': cfg.ifindex,
+ 'handle': {'scope': 'netdev'},
+ 'metric': 'bps',
+ 'bw-max': bw_max}])
+
+ del_node.exec()
+
def qgroups(cfg, nl_shaper) -> None:
_require_queues(cfg, 4)
_require_caps(cfg, nl_shaper, 'node',
@@ -488,6 +540,7 @@ def main() -> None:
set_nshapers,
del_nshapers,
basic_groups,
+ basic_groups_with_rate,
qgroups,
delegation,
dup_leaves,
--
2.53.0-Meta
next prev parent reply other threads:[~2026-08-05 3:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 3:09 [PATCH net-next 00/14] selftests: net: shaper: Expand shaper API coverage Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 01/14] selftests: net: shaper: Drop redundant command timeouts Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 02/14] selftests: net: shaper: Prepare helpers for group tests Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 03/14] selftests: net: shaper: Decouple basic_groups from netdev rate limiting Mohsin Bashir
2026-08-05 3:09 ` Mohsin Bashir [this message]
2026-08-05 3:09 ` [PATCH net-next 05/14] selftests: net: shaper: Add node scope .set rate update test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 06/14] selftests: net: shaper: Add .group " Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 07/14] selftests: net: shaper: Add nested depth limit discovery test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 08/14] selftests: net: shaper: Add child node deletion reparent test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 09/14] selftests: net: shaper: Add queue migration between nodes test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 10/14] selftests: net: shaper: Add reparenting rejection test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 11/14] selftests: net: shaper: Cover scalar attributes Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 12/14] selftests: net: shaper: Reject invalid set requests Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 13/14] selftests: net: shaper: Cover mixed-parent grouping Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 14/14] selftests: net: shaper: Cover recursive node cleanup Mohsin Bashir
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=20260805030936.1092907-5-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=alexander.duyck@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.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