Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'io_uring-zcrx-fix-selftests-and-add-new-test-for-rss-ctx'

David Wei says:

====================
io_uring/zcrx: fix selftests and add new test for rss ctx

Update io_uring zero copy receive selftest. Patch 1 does a requested
cleanup to use defer() for undoing ethtool actions during the test and
restoring the NIC under test back to its original state.

Patch 2 adds a required call to set hds_thresh to 0. This is needed for
the queue API.

Patch 3 adds a new test case for steering into RSS contexts. A real
application using io_uring zero copy receive relies on this working to
shard work across multiple queues. There seems to be some
differences/bugs with steering into RSS contexts and individual queues.
====================

Link: https://patch.msgid.link/20250425022049.3474590-1-dw@davidwei.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+78 -36
+78 -36
tools/testing/selftests/drivers/net/hw/iou-zcrx.py
··· 5 5 from os import path 6 6 from lib.py import ksft_run, ksft_exit 7 7 from lib.py import NetDrvEpEnv 8 - from lib.py import bkg, cmd, ethtool, wait_port_listen 8 + from lib.py import bkg, cmd, defer, ethtool, wait_port_listen 9 9 10 10 11 - def _get_rx_ring_entries(cfg): 11 + def _get_current_settings(cfg): 12 12 output = ethtool(f"-g {cfg.ifname}", host=cfg.remote).stdout 13 - values = re.findall(r'RX:\s+(\d+)', output) 14 - return int(values[1]) 13 + rx_ring = re.findall(r'RX:\s+(\d+)', output) 14 + hds_thresh = re.findall(r'HDS thresh:\s+(\d+)', output) 15 + return (int(rx_ring[1]), int(hds_thresh[1])) 15 16 16 17 17 18 def _get_combined_channels(cfg): ··· 21 20 return int(values[1]) 22 21 23 22 23 + def _create_rss_ctx(cfg, chans): 24 + output = ethtool(f"-X {cfg.ifname} context new start {chans - 1} equal 1", host=cfg.remote).stdout 25 + values = re.search(r'New RSS context is (\d+)', output).group(1) 26 + ctx_id = int(values) 27 + return (ctx_id, defer(ethtool, f"-X {cfg.ifname} delete context {ctx_id}", host=cfg.remote)) 28 + 29 + 24 30 def _set_flow_rule(cfg, chan): 31 + output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port 9999 action {chan}", host=cfg.remote).stdout 32 + values = re.search(r'ID (\d+)', output).group(1) 33 + return int(values) 34 + 35 + 36 + def _set_flow_rule_rss(cfg, chan): 25 37 output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port 9999 action {chan}", host=cfg.remote).stdout 26 38 values = re.search(r'ID (\d+)', output).group(1) 27 39 return int(values) ··· 46 32 combined_chans = _get_combined_channels(cfg) 47 33 if combined_chans < 2: 48 34 raise KsftSkipEx('at least 2 combined channels required') 49 - rx_ring = _get_rx_ring_entries(cfg) 35 + (rx_ring, hds_thresh) = _get_current_settings(cfg) 50 36 51 - try: 52 - ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 53 - ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 54 - ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 55 - flow_rule_id = _set_flow_rule(cfg, combined_chans - 1) 37 + ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 38 + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 39 + ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote) 40 + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote) 41 + ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 42 + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 43 + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 44 + defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote) 45 + flow_rule_id = _set_flow_rule(cfg, combined_chans - 1) 46 + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 56 47 57 - rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1}" 58 - tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 12840" 59 - with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 60 - wait_port_listen(9999, proto="tcp", host=cfg.remote) 61 - cmd(tx_cmd) 62 - finally: 63 - ethtool(f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 64 - ethtool(f"-X {cfg.ifname} default", host=cfg.remote) 65 - ethtool(f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 66 - ethtool(f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 48 + rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1}" 49 + tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 12840" 50 + with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 51 + wait_port_listen(9999, proto="tcp", host=cfg.remote) 52 + cmd(tx_cmd) 67 53 68 54 69 55 def test_zcrx_oneshot(cfg) -> None: ··· 72 58 combined_chans = _get_combined_channels(cfg) 73 59 if combined_chans < 2: 74 60 raise KsftSkipEx('at least 2 combined channels required') 75 - rx_ring = _get_rx_ring_entries(cfg) 61 + (rx_ring, hds_thresh) = _get_current_settings(cfg) 76 62 77 - try: 78 - ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 79 - ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 80 - ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 81 - flow_rule_id = _set_flow_rule(cfg, combined_chans - 1) 63 + ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 64 + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 65 + ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote) 66 + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote) 67 + ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 68 + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 69 + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 70 + defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote) 71 + flow_rule_id = _set_flow_rule(cfg, combined_chans - 1) 72 + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 82 73 83 - rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1} -o 4" 84 - tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 4096 -z 16384" 85 - with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 86 - wait_port_listen(9999, proto="tcp", host=cfg.remote) 87 - cmd(tx_cmd) 88 - finally: 89 - ethtool(f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 90 - ethtool(f"-X {cfg.ifname} default", host=cfg.remote) 91 - ethtool(f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 92 - ethtool(f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 74 + rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1} -o 4" 75 + tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 4096 -z 16384" 76 + with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 77 + wait_port_listen(9999, proto="tcp", host=cfg.remote) 78 + cmd(tx_cmd) 79 + 80 + 81 + def test_zcrx_rss(cfg) -> None: 82 + cfg.require_ipver('6') 83 + 84 + combined_chans = _get_combined_channels(cfg) 85 + if combined_chans < 2: 86 + raise KsftSkipEx('at least 2 combined channels required') 87 + (rx_ring, hds_thresh) = _get_current_settings(cfg) 88 + 89 + ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 90 + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 91 + ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote) 92 + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote) 93 + ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 94 + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 95 + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 96 + defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote) 97 + 98 + (ctx_id, delete_ctx) = _create_rss_ctx(cfg, combined_chans) 99 + flow_rule_id = _set_flow_rule_rss(cfg, ctx_id) 100 + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 101 + 102 + rx_cmd = f"{cfg.bin_remote} -s -p 9999 -i {cfg.ifname} -q {combined_chans - 1}" 103 + tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p 9999 -l 12840" 104 + with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 105 + wait_port_listen(9999, proto="tcp", host=cfg.remote) 106 + cmd(tx_cmd) 93 107 94 108 95 109 def main() -> None: