Skip to content

Commit 0c8754b

Browse files
committed
selftests: drv-net: test RSS header field configuration
Test reading RXFH fields over IOCTL and netlink. # ./tools/testing/selftests/drivers/net/hw/rss_api.py TAP version 13 1..3 ok 1 rss_api.test_rxfh_indir_ntf ok 2 rss_api.test_rxfh_indir_ctx_ntf ok 3 rss_api.test_rxfh_fields # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0 Link: https://patch.msgid.link/20250708220640.2738464-6-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 1783317 commit 0c8754b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tools/testing/selftests/drivers/net/hw/rss_api.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,38 @@ def _ethtool_create(cfg, act, opts):
2020
return int(output.split()[-1])
2121

2222

23+
def _ethtool_get_cfg(cfg, fl_type, to_nl=False):
24+
descr = ethtool(f"-n {cfg.ifname} rx-flow-hash {fl_type}").stdout
25+
26+
if to_nl:
27+
converter = {
28+
"IP SA": "ip-src",
29+
"IP DA": "ip-dst",
30+
"L4 bytes 0 & 1 [TCP/UDP src port]": "l4-b-0-1",
31+
"L4 bytes 2 & 3 [TCP/UDP dst port]": "l4-b-2-3",
32+
}
33+
34+
ret = set()
35+
else:
36+
converter = {
37+
"IP SA": "s",
38+
"IP DA": "d",
39+
"L3 proto": "t",
40+
"L4 bytes 0 & 1 [TCP/UDP src port]": "f",
41+
"L4 bytes 2 & 3 [TCP/UDP dst port]": "n",
42+
}
43+
44+
ret = ""
45+
46+
for line in descr.split("\n")[1:-2]:
47+
# if this raises we probably need to add more keys to converter above
48+
if to_nl:
49+
ret.add(converter[line])
50+
else:
51+
ret += converter[line]
52+
return ret
53+
54+
2355
def test_rxfh_indir_ntf(cfg):
2456
"""
2557
Check that Netlink notifications are generated when RSS indirection
@@ -77,6 +109,21 @@ def test_rxfh_indir_ctx_ntf(cfg):
77109
ksft_eq(set(ntf["msg"]["indir"]), {1})
78110

79111

112+
def test_rxfh_fields(cfg):
113+
"""
114+
Test reading Rx Flow Hash over Netlink.
115+
"""
116+
117+
flow_types = ["tcp4", "tcp6", "udp4", "udp6"]
118+
ethnl = EthtoolFamily()
119+
120+
cfg_nl = ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
121+
for fl_type in flow_types:
122+
one = _ethtool_get_cfg(cfg, fl_type, to_nl=True)
123+
ksft_eq(one, cfg_nl["flow-hash"][fl_type],
124+
comment="Config for " + fl_type)
125+
126+
80127
def main() -> None:
81128
""" Ksft boiler plate main """
82129

0 commit comments

Comments
 (0)