Skip to content

Commit 169b262

Browse files
committed
selftests: drv-net: rss_api: test setting hashing key via Netlink
Test setting hashing key via Netlink. # ./tools/testing/selftests/drivers/net/hw/rss_api.py TAP version 13 1..7 ok 1 rss_api.test_rxfh_nl_set_fail ok 2 rss_api.test_rxfh_nl_set_indir ok 3 rss_api.test_rxfh_nl_set_indir_ctx ok 4 rss_api.test_rxfh_indir_ntf ok 5 rss_api.test_rxfh_indir_ctx_ntf ok 6 rss_api.test_rxfh_nl_set_key ok 7 rss_api.test_rxfh_fields # Totals: pass:7 fail:0 xfail:0 xpass:0 skip:0 error:0 Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 51798c5 commit 169b262

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import glob
9+
import random
910
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_is, ksft_ne, ksft_raises
1011
from lib.py import KsftSkipEx, KsftFailEx
1112
from lib.py import defer, ethtool, CmdExitFailure
@@ -199,6 +200,38 @@ def test_rxfh_indir_ctx_ntf(cfg):
199200
ksft_eq(set(ntf["msg"]["indir"]), {1})
200201

201202

203+
def test_rxfh_nl_set_key(cfg):
204+
"""
205+
Test setting hashing key via Netlink.
206+
"""
207+
208+
dflt = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
209+
defer(cfg.ethnl.rss_set,
210+
{"header": {"dev-index": cfg.ifindex},
211+
"hkey": dflt["hkey"], "indir": None})
212+
213+
# Empty key should error out
214+
with ksft_raises(NlError) as cm:
215+
cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex},
216+
"hkey": None})
217+
ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.hkey')
218+
219+
# Set key to random
220+
mod = random.randbytes(len(dflt["hkey"]))
221+
cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex},
222+
"hkey": mod})
223+
rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
224+
ksft_eq(rss.get("hkey", [-1]), mod)
225+
226+
# Set key to random and indir tbl to something at once
227+
mod = random.randbytes(len(dflt["hkey"]))
228+
cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex},
229+
"indir": [0, 1], "hkey": mod})
230+
rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}})
231+
ksft_eq(rss.get("hkey", [-1]), mod)
232+
ksft_eq(set(rss.get("indir", [-1])), {0, 1})
233+
234+
202235
def test_rxfh_fields(cfg):
203236
"""
204237
Test reading Rx Flow Hash over Netlink.

0 commit comments

Comments
 (0)