From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next 11/11] selftests: drv-net: tc_flower_police: Test policing with RSS contexts
Date: Thu, 3 Dec 2026 16:05:21 -0800 [thread overview]
Message-ID: <20261204000521.3396802-12-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20261204000521.3396802-1-mohsin.bashr@gmail.com>
From: Mohsin Bashir <hmohsin@meta.com>
Containers often get their own RSS context, with an ntuple rule steering
the container address to its queues. Add police_rss_ctx to verify that
the policers of two such containers limit their own traffic at their own
rate once it is steered to their context. The test needs 6 combined
channels, ntuple filters and RSS contexts, and skips otherwise.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
.../drivers/net/hw/tc_flower_police.py | 65 +++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
index d0315e8bf2b2..d3051dda49ed 100755
--- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
+++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
@@ -683,6 +683,70 @@ def police_with_ntuple(cfg, ntuple_first):
ksft_eq(idle, 0, f"Traffic on queues other than 0 and {queue}: {delta}")
+def police_rss_ctx(cfg):
+ """
+ Check policing of flows steered to RSS contexts: each flow is limited
+ to its own rate and stays on the queues of its context.
+ """
+ _setup_clsact(cfg)
+ _require_ntuple(cfg)
+ _rx_queue_pkts(cfg)
+
+ ehdr = {"header": {"dev-index": cfg.ifindex}}
+ try:
+ channels = cfg.ethnl.channels_get(ehdr)
+ except NlError as ex:
+ raise KsftSkipEx("channel-get not supported by device") from ex
+ cnt = channels.get("combined-count", 0)
+ if cnt < 6:
+ if channels.get("combined-max", 0) < 6:
+ raise KsftSkipEx("Need 6 combined channels")
+ defer(wait_file, f"/sys/class/net/{cfg.ifname}/carrier",
+ lambda x: x.strip() == "1", deadline=30)
+ defer(cfg.ethnl.channels_set, ehdr | {"combined-count": cnt})
+ try:
+ cfg.ethnl.channels_set(ehdr | {"combined-count": 6})
+ except NlError as ex:
+ raise KsftSkipEx("Cannot set 6 combined channels") from ex
+ wait_file(f"/sys/class/net/{cfg.ifname}/carrier",
+ lambda x: x.strip() == "1", deadline=30)
+
+ # Steer all other traffic to the default queues 0 and 1
+ _set_rss_indir(cfg, ehdr, [0, 1])
+ flows = []
+ for i in range(2):
+ queues = [2 + 2 * i, 3 + 2 * i]
+ try:
+ ctx = cfg.ethnl.rss_create_act(ehdr | {"indir": queues})["context"]
+ except NlError as ex:
+ raise KsftSkipEx("RSS context not created") from ex
+ defer(cfg.ethnl.rss_delete_act, ehdr | {"context": ctx})
+
+ dst = _add_secondary_addr(cfg)
+ _add_ntuple(cfg, f"flow-type ip6 dst-ip {dst} context {ctx}")
+
+ rule = f"protocol ipv6 flower dst_ip {dst}"
+ limit = RATE_MBIT // 2 * (i + 1)
+ flows.append((rule, dst, limit, queues))
+
+ _check_baseline_rate(cfg)
+ for i, (rule, _, limit, _) in enumerate(flows):
+ _add_filter(cfg, rule, _police(limit), pref=10 + i)
+
+ for i, (_, dst, limit, queues) in enumerate(flows):
+ other = flows[1 - i][3]
+ before = _rx_queue_pkts(cfg)
+ got = _iperf3(cfg, dst, OFFERED_MBIT)
+ after = _rx_queue_pkts(cfg)
+ delta = {q: after[q] - before.get(q, 0) for q in after}
+ expected = _expected_pkts(got)
+ _check_rate(got, limit, f"context {i}")
+ ksft_ge(sum(delta.get(q, 0) for q in queues), expected * 0.9,
+ f"Context {i} traffic not on queues {queues}: {delta}")
+ ksft_eq(sum(delta.get(q, 0) for q in other), 0,
+ f"Context {i} traffic on the other context: {delta}")
+
+
def _link_down(cfg):
ctl_file_write("/proc/sys/net/ipv6/conf/all/keep_addr_on_down", 1)
ip(f"link set dev {cfg.ifname} down")
@@ -758,6 +822,7 @@ def main() -> None:
police_channels,
police_ring_size,
police_with_ntuple,
+ police_rss_ctx,
police_link_flap,
police_add_while_down],
args=(cfg,))
--
2.53.1-Meta
prev parent reply other threads:[~2026-12-04 0:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 0:05 [PATCH net-next 00/11] selftests: drv-net: Test tc-flower police offload Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 01/11] selftests: drv-net: Iperf3Runner: Support UDP and server side results Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 02/11] selftests: drv-net: Add tc-flower police offload test Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 04/11] selftests: drv-net: tc_flower_police: Test the policed rate and its scope Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 05/11] selftests: drv-net: tc_flower_police: Test destination prefix rules Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 07/11] selftests: drv-net: tc_flower_police: Test multiple policers Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 08/11] selftests: drv-net: tc_flower_police: Test rule removal Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 09/11] selftests: drv-net: tc_flower_police: Test policing across reconfiguration Mohsin Bashir
2026-12-04 0:05 ` [PATCH net-next 10/11] selftests: drv-net: tc_flower_police: Test policing with ntuple steering Mohsin Bashir
2026-12-04 0:05 ` Mohsin Bashir [this message]
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=20261204000521.3396802-12-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--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
all inboxes | Powered by JetHome®