Commit 847aa551 authored by Jakub Kicinski's avatar Jakub Kicinski

selftests: drv-net: rss_ctx: factor out send traffic and check

Wrap up sending traffic and checking in which queues it landed
in a helper.

The method used for testing is to send a lot of iperf traffic
and check which queues received the most packets. Those should
be the queues where we expect iperf to land - either because we
installed a filter for the port iperf uses, or we didn't and
expect it to use context 0.

Contexts get disjoint queue sets, but the main context (AKA context 0)
may receive some background traffic (noise).
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20240708213627.226025-3-kuba@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a0aab7d7
......@@ -63,6 +63,30 @@ def _get_rx_cnts(cfg, prev=None):
return queue_stats
def _send_traffic_check(cfg, port, name, params):
# params is a dict with 3 possible keys:
# - "target": required, which queues we expect to get iperf traffic
# - "empty": optional, which queues should see no traffic at all
# - "noise": optional, which queues we expect to see low traffic;
# used for queues of the main context, since some background
# OS activity may use those queues while we're testing
# the value for each is a list, or some other iterable containing queue ids.
cnts = _get_rx_cnts(cfg)
GenerateTraffic(cfg, port=port).wait_pkts_and_stop(20000)
cnts = _get_rx_cnts(cfg, prev=cnts)
directed = sum(cnts[i] for i in params['target'])
ksft_ge(directed, 20000, f"traffic on {name}: " + str(cnts))
if params.get('noise'):
ksft_lt(sum(cnts[i] for i in params['noise']), directed / 2,
"traffic on other queues:" + str(cnts))
if params.get('empty'):
ksft_eq(sum(cnts[i] for i in params['empty']), 0,
"traffic on inactive queues: " + str(cnts))
def test_rss_key_indir(cfg):
"""Test basics like updating the main RSS key and indirection table."""
......@@ -170,15 +194,10 @@ def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None):
defer(ethtool, f"-N {cfg.ifname} delete {ntuple}")
for i in range(ctx_cnt):
cnts = _get_rx_cnts(cfg)
GenerateTraffic(cfg, port=ports[i]).wait_pkts_and_stop(20000)
cnts = _get_rx_cnts(cfg, prev=cnts)
directed = sum(cnts[2+i*2:4+i*2])
ksft_lt(sum(cnts[ :2]), directed / 2, "traffic on main context:" + str(cnts))
ksft_ge(directed, 20000, f"traffic on context {i}: " + str(cnts))
ksft_eq(sum(cnts[2:2+i*2] + cnts[4+i*2:]), 0, "traffic on other contexts: " + str(cnts))
_send_traffic_check(cfg, ports[i], f"context {i}",
{ 'target': (2+i*2, 3+i*2),
'noise': (0, 1),
'empty': list(range(2, 2+i*2)) + list(range(4+i*2, 2+2*ctx_cnt)) })
if requested_ctx_cnt != ctx_cnt:
raise KsftSkipEx(f"Tested only {ctx_cnt} contexts, wanted {requested_ctx_cnt}")
......@@ -230,18 +249,19 @@ def test_rss_context_out_of_order(cfg, ctx_cnt=4):
def check_traffic():
for i in range(ctx_cnt):
cnts = _get_rx_cnts(cfg)
GenerateTraffic(cfg, port=ports[i]).wait_pkts_and_stop(20000)
cnts = _get_rx_cnts(cfg, prev=cnts)
if ctx[i]:
directed = sum(cnts[2+i*2:4+i*2])
ksft_lt(sum(cnts[ :2]), directed / 2, "traffic on main context:" + str(cnts))
ksft_ge(directed, 20000, f"traffic on context {i}: " + str(cnts))
ksft_eq(sum(cnts[2:2+i*2] + cnts[4+i*2:]), 0, "traffic on other contexts: " + str(cnts))
expected = {
'target': (2+i*2, 3+i*2),
'noise': (0, 1),
'empty': list(range(2, 2+i*2)) + list(range(4+i*2, 2+2*ctx_cnt))
}
else:
ksft_ge(sum(cnts[ :2]), 20000, "traffic on main context:" + str(cnts))
ksft_eq(sum(cnts[2: ]), 0, "traffic on other contexts: " + str(cnts))
expected = {
'target': (0, 1),
'empty': range(2, 2+2*ctx_cnt)
}
_send_traffic_check(cfg, ports[i], f"context {i}", expected)
# Use queues 0 and 1 for normal traffic
ethtool(f"-X {cfg.ifname} equal 2")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment