All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org, willemb@google.com,
	petrm@nvidia.com, dw@davidwei.uk, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 2/5] selftests: hw-net: toeplitz: make sure NICs have pure Toeplitz configured
Date: Thu, 20 Nov 2025 20:02:56 -0800	[thread overview]
Message-ID: <20251121040259.3647749-3-kuba@kernel.org> (raw)
In-Reply-To: <20251121040259.3647749-1-kuba@kernel.org>

Make sure that the NIC under test is configured for pure Toeplitz
hashing, and no input key transform (no symmetric hashing).

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../selftests/drivers/net/hw/toeplitz.py      | 29 ++++++++++++-------
 1 file changed, 18 insertions(+), 11 deletions(-)

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 @@ from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, KsftFailEx
             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 @@ from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, KsftFailEx
     # 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 = [
-- 
2.51.1


  parent reply	other threads:[~2025-11-21  4:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  4:02 [PATCH net-next 0/5] selftests: hw-net: toeplitz: read config from the NIC directly Jakub Kicinski
2025-11-21  4:02 ` [PATCH net-next 1/5] selftests: hw-net: auto-disable building the iouring C code Jakub Kicinski
2025-11-23  0:55   ` David Wei
2025-11-25  2:49     ` Jakub Kicinski
2025-11-21  4:02 ` Jakub Kicinski [this message]
2025-11-21  4:02 ` [PATCH net-next 3/5] selftests: hw-net: toeplitz: read the RSS key directly from C Jakub Kicinski
2025-11-23  2:07   ` David Wei
2025-11-21  4:02 ` [PATCH net-next 4/5] selftests: hw-net: toeplitz: read indirection table from the device Jakub Kicinski
2025-11-21 23:12   ` Willem de Bruijn
2025-11-22  1:32     ` Jakub Kicinski
2025-11-22  2:16       ` Willem de Bruijn
2025-11-21  4:02 ` [PATCH net-next 5/5] selftests: hw-net: toeplitz: give the test up to 4 seconds Jakub Kicinski
2025-11-21 23:10 ` [PATCH net-next 0/5] selftests: hw-net: toeplitz: read config from the NIC directly Willem de Bruijn
2025-11-25  3:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251121040259.3647749-3-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.