Skip to content

Commit 5c3524b

Browse files
spikehkuba-moo
authored andcommitted
io_uring/zcrx: selftests: add test case for rss ctx
RSS contexts are used to shard work across multiple queues for an application using io_uring zero copy receive. Add a test case checking that steering flows into an RSS context works. Until I add multi-thread support to the selftest binary, this test case only has 1 queue in the RSS context. Signed-off-by: David Wei <dw@davidwei.uk> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Joe Damato <jdamato@fastly.com> Link: https://patch.msgid.link/20250425022049.3474590-4-dw@davidwei.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4ce3ade commit 5c3524b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tools/testing/selftests/drivers/net/hw/iou-zcrx.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,25 @@ def _get_combined_channels(cfg):
2121
return int(values[1])
2222

2323

24+
def _create_rss_ctx(cfg, chans):
25+
output = ethtool(f"-X {cfg.ifname} context new start {chans - 1} equal 1", host=cfg.remote).stdout
26+
values = re.search(r'New RSS context is (\d+)', output).group(1)
27+
ctx_id = int(values)
28+
return (ctx_id, defer(ethtool, f"-X {cfg.ifname} delete context {ctx_id}", host=cfg.remote))
29+
30+
2431
def _set_flow_rule(cfg, chan):
2532
output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port 9999 action {chan}", host=cfg.remote).stdout
2633
values = re.search(r'ID (\d+)', output).group(1)
2734
return int(values)
2835

2936

37+
def _set_flow_rule_rss(cfg, chan):
38+
output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port 9999 action {chan}", host=cfg.remote).stdout
39+
values = re.search(r'ID (\d+)', output).group(1)
40+
return int(values)
41+
42+
3043
def test_zcrx(cfg) -> None:
3144
cfg.require_ipver('6')
3245

@@ -79,6 +92,34 @@ def test_zcrx_oneshot(cfg) -> None:
7992
cmd(tx_cmd)
8093

8194

95+
def test_zcrx_rss(cfg) -> None:
96+
cfg.require_ipver('6')
97+
98+
combined_chans = _get_combined_channels(cfg)
99+
if combined_chans < 2:
100+
raise KsftSkipEx('at least 2 combined channels required')
101+
(rx_ring, hds_thresh) = _get_current_settings(cfg)
102+
103+
ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
104+
defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
105+
ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
106+
defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
107+
ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
108+
defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
109+
ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
110+
defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
111+
112+
(ctx_id, delete_ctx) = _create_rss_ctx(cfg, combined_chans)
113+
flow_rule_id = _set_flow_rule_rss(cfg, ctx_id)
114+
defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
115+
116+
rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1}"
117+
tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 12840"
118+
with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
119+
wait_port_listen(9999, proto="tcp", host=cfg.remote)
120+
cmd(tx_cmd)
121+
122+
82123
def main() -> None:
83124
with NetDrvEpEnv(__file__) as cfg:
84125
cfg.bin_local = path.abspath(path.dirname(__file__) + "/../../../drivers/net/hw/iou-zcrx")

0 commit comments

Comments
 (0)