From 27c512af190e037a6f330e9461fc4741fb77da45 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Thu, 20 Nov 2025 20:02:56 -0800 Subject: selftests: hw-net: toeplitz: make sure NICs have pure Toeplitz configured Make sure that the NIC under test is configured for pure Toeplitz hashing, and no input key transform (no symmetric hashing). Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20251121040259.3647749-3-kuba@kernel.org Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/hw/toeplitz.py | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'tools/testing/selftests/drivers/net/hw/toeplitz.py') diff --git a/tools/testing/selftests/drivers/net/hw/toeplitz.py b/tools/testing/selftests/drivers/net/hw/toeplitz.py index 9019a8c1ff62..642a5cc385b6 100755 --- a/tools/testing/selftests/drivers/net/hw/toeplitz.py +++ b/tools/testing/selftests/drivers/net/hw/toeplitz.py @@ -17,6 +17,9 @@ from lib.py import cmd, bkg, rand_port, defer from lib.py import ksft_in from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, KsftFailEx +# "define" for the ID of the Toeplitz hash function +ETH_RSS_HASH_TOP = 1 + def _check_rps_and_rfs_not_configured(cfg): """Verify that RPS is not already configured.""" @@ -34,16 +37,6 @@ def _check_rps_and_rfs_not_configured(cfg): raise KsftSkipEx(f"RFS already configured {rfs_file}: {val}") -def _get_rss_key(cfg): - """ - Read the RSS key from the device. - Return a string in the traditional %02x:%02x:%02x:.. format. - """ - - rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) - return ':'.join(f'{b:02x}' for b in rss["hkey"]) - - def _get_cpu_for_irq(irq): with open(f"/proc/irq/{irq}/smp_affinity_list", "r", encoding="utf-8") as fp: @@ -153,8 +146,22 @@ def test(cfg, proto_flag, ipver, grp): # Check that rxhash is enabled ksft_in("receive-hashing: on", cmd(f"ethtool -k {cfg.ifname}").stdout) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + # Make sure NIC is configured to use Toeplitz hash, and no key xfrm. + if rss.get('hfunc') != ETH_RSS_HASH_TOP or rss.get('input-xfrm'): + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "hfunc": ETH_RSS_HASH_TOP, + "input-xfrm": {}}) + defer(cfg.ethnl.rss_set, {"header": {"dev-index": cfg.ifindex}, + "hfunc": rss.get('hfunc'), + "input-xfrm": rss.get('input-xfrm', {}) + }) + # Refresh in case changing hfunc changes things. + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + + key = ':'.join(f'{b:02x}' for b in rss["hkey"]) + port = rand_port(socket.SOCK_DGRAM) - key = _get_rss_key(cfg) toeplitz_path = cfg.test_dir / "toeplitz" rx_cmd = [ -- cgit v1.2.3 From aa91dbf3eda2977e3046d4838eadf7af4dbd47ec Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Thu, 20 Nov 2025 20:02:57 -0800 Subject: selftests: hw-net: toeplitz: read the RSS key directly from C Now that we have YNL support for RSS accessing the RSS info from C is very easy. Instead of passing the RSS key from Python do it directly in the C code. Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20251121040259.3647749-4-kuba@kernel.org Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/hw/toeplitz.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tools/testing/selftests/drivers/net/hw/toeplitz.py') diff --git a/tools/testing/selftests/drivers/net/hw/toeplitz.py b/tools/testing/selftests/drivers/net/hw/toeplitz.py index 642a5cc385b6..945c58d23310 100755 --- a/tools/testing/selftests/drivers/net/hw/toeplitz.py +++ b/tools/testing/selftests/drivers/net/hw/toeplitz.py @@ -156,10 +156,6 @@ def test(cfg, proto_flag, ipver, grp): "hfunc": rss.get('hfunc'), "input-xfrm": rss.get('input-xfrm', {}) }) - # Refresh in case changing hfunc changes things. - rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) - - key = ':'.join(f'{b:02x}' for b in rss["hkey"]) port = rand_port(socket.SOCK_DGRAM) @@ -170,7 +166,6 @@ def test(cfg, proto_flag, ipver, grp): proto_flag, "-d", str(port), "-i", cfg.ifname, - "-k", key, "-T", "1000", "-s", "-v" -- cgit v1.2.3 From 5aadc155849eb85d799604939fd9e9024b7392a3 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Thu, 20 Nov 2025 20:02:59 -0800 Subject: selftests: hw-net: toeplitz: give the test up to 4 seconds Increase the receiver timeout. When running between machines in different geographic regions the test needs more than a second to SSH across and send the frames. The bkg() command that runs the receiver defaults to 5 sec timeout, so using 4 sec sounds like a reasonable value for the receiver itself. Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20251121040259.3647749-6-kuba@kernel.org Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/hw/toeplitz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/testing/selftests/drivers/net/hw/toeplitz.py') diff --git a/tools/testing/selftests/drivers/net/hw/toeplitz.py b/tools/testing/selftests/drivers/net/hw/toeplitz.py index 945c58d23310..d2db5ee9e358 100755 --- a/tools/testing/selftests/drivers/net/hw/toeplitz.py +++ b/tools/testing/selftests/drivers/net/hw/toeplitz.py @@ -166,7 +166,7 @@ def test(cfg, proto_flag, ipver, grp): proto_flag, "-d", str(port), "-i", cfg.ifname, - "-T", "1000", + "-T", "4000", "-s", "-v" ] -- cgit v1.2.3