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.

selftests: flip local/remote endpoints in iou-zcrx.py

The iou-zcrx selftest currently runs the server on the remote host
and the client on the local host. This commit flips the endpoints
such that server runs on localhost and client on remote.
This change brings the iou-zcrx selftest in convention with other
selftests.

Drive-by fix for a missing import exception that happens when the
network interface has less than 2 combined channels.

Test plan: ran iou-zcrx.py selftest between 2 physical machines

Signed-off-by: Vishwanath Seshagiri <vishs@fb.com>
Link: https://patch.msgid.link/20250710165337.614159-1-vishs@meta.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vishwanath Seshagiri and committed by
Jakub Kicinski
650fe2a9 4159a55f

+49 -49
+49 -49
tools/testing/selftests/drivers/net/hw/iou-zcrx.py
··· 3 3 4 4 import re 5 5 from os import path 6 - from lib.py import ksft_run, ksft_exit 6 + from lib.py import ksft_run, ksft_exit, KsftSkipEx 7 7 from lib.py import NetDrvEpEnv 8 8 from lib.py import bkg, cmd, defer, ethtool, rand_port, wait_port_listen 9 9 10 10 11 11 def _get_current_settings(cfg): 12 - output = ethtool(f"-g {cfg.ifname}", json=True, host=cfg.remote)[0] 12 + output = ethtool(f"-g {cfg.ifname}", json=True)[0] 13 13 return (output['rx'], output['hds-thresh']) 14 14 15 15 16 16 def _get_combined_channels(cfg): 17 - output = ethtool(f"-l {cfg.ifname}", host=cfg.remote).stdout 17 + output = ethtool(f"-l {cfg.ifname}").stdout 18 18 values = re.findall(r'Combined:\s+(\d+)', output) 19 19 return int(values[1]) 20 20 21 21 22 22 def _create_rss_ctx(cfg, chan): 23 - output = ethtool(f"-X {cfg.ifname} context new start {chan} equal 1", host=cfg.remote).stdout 23 + output = ethtool(f"-X {cfg.ifname} context new start {chan} equal 1").stdout 24 24 values = re.search(r'New RSS context is (\d+)', output).group(1) 25 25 ctx_id = int(values) 26 - return (ctx_id, defer(ethtool, f"-X {cfg.ifname} delete context {ctx_id}", host=cfg.remote)) 26 + return (ctx_id, defer(ethtool, f"-X {cfg.ifname} delete context {ctx_id}")) 27 27 28 28 29 29 def _set_flow_rule(cfg, port, chan): 30 - output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} action {chan}", host=cfg.remote).stdout 30 + output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} action {chan}").stdout 31 31 values = re.search(r'ID (\d+)', output).group(1) 32 32 return int(values) 33 33 34 34 35 35 def _set_flow_rule_rss(cfg, port, ctx_id): 36 - output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} context {ctx_id}", host=cfg.remote).stdout 36 + output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} context {ctx_id}").stdout 37 37 values = re.search(r'ID (\d+)', output).group(1) 38 38 return int(values) 39 39 ··· 47 47 (rx_ring, hds_thresh) = _get_current_settings(cfg) 48 48 port = rand_port() 49 49 50 - ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 51 - defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 50 + ethtool(f"-G {cfg.ifname} tcp-data-split on") 51 + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto") 52 52 53 - ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote) 54 - defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote) 53 + ethtool(f"-G {cfg.ifname} hds-thresh 0") 54 + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}") 55 55 56 - ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 57 - defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 56 + ethtool(f"-G {cfg.ifname} rx 64") 57 + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}") 58 58 59 - ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 60 - defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote) 59 + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}") 60 + defer(ethtool, f"-X {cfg.ifname} default") 61 61 62 62 flow_rule_id = _set_flow_rule(cfg, port, combined_chans - 1) 63 - defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 63 + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}") 64 64 65 - rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}" 66 - tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 12840" 67 - with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 68 - wait_port_listen(port, proto="tcp", host=cfg.remote) 69 - cmd(tx_cmd) 65 + rx_cmd = f"{cfg.bin_local} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}" 66 + tx_cmd = f"{cfg.bin_remote} -c -h {cfg.addr_v['6']} -p {port} -l 12840" 67 + with bkg(rx_cmd, exit_wait=True): 68 + wait_port_listen(port, proto="tcp") 69 + cmd(tx_cmd, host=cfg.remote) 70 70 71 71 72 72 def test_zcrx_oneshot(cfg) -> None: ··· 78 78 (rx_ring, hds_thresh) = _get_current_settings(cfg) 79 79 port = rand_port() 80 80 81 - ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 82 - defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 81 + ethtool(f"-G {cfg.ifname} tcp-data-split on") 82 + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto") 83 83 84 - ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote) 85 - defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote) 84 + ethtool(f"-G {cfg.ifname} hds-thresh 0") 85 + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}") 86 86 87 - ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 88 - defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 87 + ethtool(f"-G {cfg.ifname} rx 64") 88 + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}") 89 89 90 - ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 91 - defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote) 90 + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}") 91 + defer(ethtool, f"-X {cfg.ifname} default") 92 92 93 93 flow_rule_id = _set_flow_rule(cfg, port, combined_chans - 1) 94 - defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 94 + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}") 95 95 96 - rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1} -o 4" 97 - tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 4096 -z 16384" 98 - with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 99 - wait_port_listen(port, proto="tcp", host=cfg.remote) 100 - cmd(tx_cmd) 96 + rx_cmd = f"{cfg.bin_local} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1} -o 4" 97 + tx_cmd = f"{cfg.bin_remote} -c -h {cfg.addr_v['6']} -p {port} -l 4096 -z 16384" 98 + with bkg(rx_cmd, exit_wait=True): 99 + wait_port_listen(port, proto="tcp") 100 + cmd(tx_cmd, host=cfg.remote) 101 101 102 102 103 103 def test_zcrx_rss(cfg) -> None: ··· 109 109 (rx_ring, hds_thresh) = _get_current_settings(cfg) 110 110 port = rand_port() 111 111 112 - ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote) 113 - defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote) 112 + ethtool(f"-G {cfg.ifname} tcp-data-split on") 113 + defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto") 114 114 115 - ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote) 116 - defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote) 115 + ethtool(f"-G {cfg.ifname} hds-thresh 0") 116 + defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}") 117 117 118 - ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote) 119 - defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote) 118 + ethtool(f"-G {cfg.ifname} rx 64") 119 + defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}") 120 120 121 - ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote) 122 - defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote) 121 + ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}") 122 + defer(ethtool, f"-X {cfg.ifname} default") 123 123 124 124 (ctx_id, delete_ctx) = _create_rss_ctx(cfg, combined_chans - 1) 125 125 flow_rule_id = _set_flow_rule_rss(cfg, port, ctx_id) 126 - defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote) 126 + defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}") 127 127 128 - rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}" 129 - tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 12840" 130 - with bkg(rx_cmd, host=cfg.remote, exit_wait=True): 131 - wait_port_listen(port, proto="tcp", host=cfg.remote) 132 - cmd(tx_cmd) 128 + rx_cmd = f"{cfg.bin_local} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}" 129 + tx_cmd = f"{cfg.bin_remote} -c -h {cfg.addr_v['6']} -p {port} -l 12840" 130 + with bkg(rx_cmd, exit_wait=True): 131 + wait_port_listen(port, proto="tcp") 132 + cmd(tx_cmd, host=cfg.remote) 133 133 134 134 135 135 def main() -> None: