1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
import re
from os import path
from lib.py import ksft_run, ksft_exit
from lib.py import NetDrvEpEnv
from lib.py import bkg, cmd, defer, ethtool, rand_port, wait_port_listen
def _get_current_settings(cfg):
output = ethtool(f"-g {cfg.ifname}", json=True, host=cfg.remote)[0]
return (output['rx'], output['hds-thresh'])
def _get_combined_channels(cfg):
output = ethtool(f"-l {cfg.ifname}", host=cfg.remote).stdout
values = re.findall(r'Combined:\s+(\d+)', output)
return int(values[1])
def _create_rss_ctx(cfg, chan):
output = ethtool(f"-X {cfg.ifname} context new start {chan} equal 1", host=cfg.remote).stdout
values = re.search(r'New RSS context is (\d+)', output).group(1)
ctx_id = int(values)
return (ctx_id, defer(ethtool, f"-X {cfg.ifname} delete context {ctx_id}", host=cfg.remote))
def _set_flow_rule(cfg, port, chan):
output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} action {chan}", host=cfg.remote).stdout
values = re.search(r'ID (\d+)', output).group(1)
return int(values)
def _set_flow_rule_rss(cfg, port, ctx_id):
output = ethtool(f"-N {cfg.ifname} flow-type tcp6 dst-port {port} context {ctx_id}", host=cfg.remote).stdout
values = re.search(r'ID (\d+)', output).group(1)
return int(values)
def test_zcrx(cfg) -> None:
cfg.require_ipver('6')
combined_chans = _get_combined_channels(cfg)
if combined_chans < 2:
raise KsftSkipEx('at least 2 combined channels required')
(rx_ring, hds_thresh) = _get_current_settings(cfg)
port = rand_port()
ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
flow_rule_id = _set_flow_rule(cfg, port, combined_chans - 1)
defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}"
tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 12840"
with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
wait_port_listen(port, proto="tcp", host=cfg.remote)
cmd(tx_cmd)
def test_zcrx_oneshot(cfg) -> None:
cfg.require_ipver('6')
combined_chans = _get_combined_channels(cfg)
if combined_chans < 2:
raise KsftSkipEx('at least 2 combined channels required')
(rx_ring, hds_thresh) = _get_current_settings(cfg)
port = rand_port()
ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
flow_rule_id = _set_flow_rule(cfg, port, combined_chans - 1)
defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1} -o 4"
tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 4096 -z 16384"
with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
wait_port_listen(port, proto="tcp", host=cfg.remote)
cmd(tx_cmd)
def test_zcrx_rss(cfg) -> None:
cfg.require_ipver('6')
combined_chans = _get_combined_channels(cfg)
if combined_chans < 2:
raise KsftSkipEx('at least 2 combined channels required')
(rx_ring, hds_thresh) = _get_current_settings(cfg)
port = rand_port()
ethtool(f"-G {cfg.ifname} tcp-data-split on", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} tcp-data-split auto", host=cfg.remote)
ethtool(f"-G {cfg.ifname} hds-thresh 0", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} hds-thresh {hds_thresh}", host=cfg.remote)
ethtool(f"-G {cfg.ifname} rx 64", host=cfg.remote)
defer(ethtool, f"-G {cfg.ifname} rx {rx_ring}", host=cfg.remote)
ethtool(f"-X {cfg.ifname} equal {combined_chans - 1}", host=cfg.remote)
defer(ethtool, f"-X {cfg.ifname} default", host=cfg.remote)
(ctx_id, delete_ctx) = _create_rss_ctx(cfg, combined_chans - 1)
flow_rule_id = _set_flow_rule_rss(cfg, port, ctx_id)
defer(ethtool, f"-N {cfg.ifname} delete {flow_rule_id}", host=cfg.remote)
rx_cmd = f"{cfg.bin_remote} -s -p {port} -i {cfg.ifname} -q {combined_chans - 1}"
tx_cmd = f"{cfg.bin_local} -c -h {cfg.remote_addr_v['6']} -p {port} -l 12840"
with bkg(rx_cmd, host=cfg.remote, exit_wait=True):
wait_port_listen(port, proto="tcp", host=cfg.remote)
cmd(tx_cmd)
def main() -> None:
with NetDrvEpEnv(__file__) as cfg:
cfg.bin_local = path.abspath(path.dirname(__file__) + "/../../../drivers/net/hw/iou-zcrx")
cfg.bin_remote = cfg.remote.deploy(cfg.bin_local)
ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, ))
ksft_exit()
if __name__ == "__main__":
main()
|