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 11/14] selftests: net: shaper: Cover scalar attributes
Date: Tue, 4 Aug 2026 20:09:33 -0700 [thread overview]
Message-ID: <20260805030936.1092907-12-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20260805030936.1092907-1-mohsin.bashr@gmail.com>
From: Mohsin Bashir <hmohsin@meta.com>
Exercise queue-scope scalar shaper attributes reported by the device,
including rate limits, burst, priority and weight. Build the set request
from advertised capabilities so devices are tested for the attributes they
claim rather than skipped for missing unrelated fields.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
tools/testing/selftests/drivers/net/shaper.py | 68 +++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/shaper.py b/tools/testing/selftests/drivers/net/shaper.py
index e7af94264409..8dd4897e999e 100755
--- a/tools/testing/selftests/drivers/net/shaper.py
+++ b/tools/testing/selftests/drivers/net/shaper.py
@@ -168,6 +168,73 @@ def del_nshapers(cfg, nl_shaper) -> None:
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
ksft_eq(len(shapers), 0)
+def set_all_supported_attrs(cfg, nl_shaper) -> None:
+ """ Set every queue-scope attribute the device advertises and verify the read-back. """
+ _require_queues(cfg, 1)
+
+ _require_caps(cfg, nl_shaper, 'queue', [],
+ "queue scope shapers not supported by the device")
+ caps = _cap_get(cfg, nl_shaper, 'queue')
+
+ attrs = {'ifindex': cfg.ifindex,
+ 'handle': {'scope': 'queue', 'id': 0}}
+ expected = {'ifindex': cfg.ifindex,
+ 'parent': {'scope': 'netdev'},
+ 'handle': {'scope': 'queue', 'id': 0}}
+
+ rate_attrs = {'support-bw-min': ('bw-min', 10000, 100),
+ 'support-bw-max': ('bw-max', 20000, 200),
+ 'support-burst': ('burst', 3000, 30)}
+ rate_attr_supported = any(cap in caps for cap in rate_attrs)
+ bps_supported = 'support-metric-bps' in caps
+ pps_supported = 'support-metric-pps' in caps
+
+ def add_rate_attrs(metric, value_idx) -> None:
+ attrs['metric'] = metric
+ expected['metric'] = metric
+ for cap, (attr, bps_value, pps_value) in rate_attrs.items():
+ if cap not in caps:
+ continue
+
+ value = bps_value if value_idx == 0 else pps_value
+ attrs[attr] = value
+ expected[attr] = value
+
+ if rate_attr_supported:
+ if bps_supported:
+ add_rate_attrs('bps', 0)
+ elif pps_supported:
+ add_rate_attrs('pps', 1)
+
+ if 'support-priority' in caps:
+ attrs['priority'] = 1
+ expected['priority'] = 1
+ if 'support-weight' in caps:
+ attrs['weight'] = 2
+ expected['weight'] = 2
+
+ if len(attrs) == 2:
+ raise KsftSkipEx("device does not advertise any supported queue shaper attributes")
+
+ nl_shaper.set(attrs)
+ defer(_delete_shaper, cfg, nl_shaper, {'scope': 'queue', 'id': 0})
+
+ shaper = nl_shaper.get({'ifindex': cfg.ifindex,
+ 'handle': {'scope': 'queue', 'id': 0}})
+ ksft_eq(shaper, expected)
+
+ if rate_attr_supported and bps_supported and pps_supported:
+ add_rate_attrs('pps', 1)
+ nl_shaper.set(attrs)
+
+ shaper = nl_shaper.get({'ifindex': cfg.ifindex,
+ 'handle': {'scope': 'queue', 'id': 0}})
+ ksft_eq(shaper, expected)
+
+ _delete_shaper(cfg, nl_shaper, {'scope': 'queue', 'id': 0})
+ shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
+ ksft_eq(len(shapers), 0)
+
def _group_under_netdev(cfg, nl_shaper, bw_max=None):
r"""Group queues under a netdev-scope node; caller owns node teardown.
@@ -1084,6 +1151,7 @@ def main() -> None:
del_qshapers,
set_nshapers,
del_nshapers,
+ set_all_supported_attrs,
basic_groups,
basic_groups_with_rate,
qgroups,
--
2.53.0-Meta
next prev parent reply other threads:[~2026-08-05 3:10 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 ` [PATCH net-next 04/14] selftests: net: shaper: Add basic_groups_with_rate test Mohsin Bashir
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 ` Mohsin Bashir [this message]
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-12-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