Skip to contentSkip to conversation

selftests: drv-net: toeplitz: cap the Rx queue count

PATCH Applied Jakub Kicinski 3 participants 4 messages Jun 29 – Jul 2

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 selftests: drv-net: toeplitz: cap the Rx queue count

The RPS test needs a free CPU within the first RPS_MAX_CPUS (16) cores. This is easily violated if the NIC or env allocates the IRQs to cores linearly.

Cap the Rx queues at 8, we don't need more. This makes the test pass on CX7 in NIPA.

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 .../selftests/drivers/net/hw/toeplitz.py      | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
tools/testing/selftests/drivers/net/hw/toeplitz.py +22 -0
index cd7e080e6f84..571732198b93 100755
@@ -21,6 +21,8 @@ from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, KsftFailEx
 ETH_RSS_HASH_TOP = 1
 # Must match RPS_MAX_CPUS in toeplitz.c
 RPS_MAX_CPUS = 16
+# Cap Rx queues so IRQ pinning leaves free CPUs in the RPS_MAX_CPUS range
+QUEUE_CAP = 8
 
 
 def _check_rps_and_rfs_not_configured(cfg):
@@ -48,6 +50,25 @@ RPS_MAX_CPUS = 16
         return int(data)
 
 
+def _cap_queue_count(cfg):
+    ehdr = {"header": {"dev-index": cfg.ifindex}}
+    chans = cfg.ethnl.channels_get(ehdr)
+
+    config = {}
+    restore = {}
+    for key in ("combined-count", "rx-count"):
+        cur = chans.get(key, 0)
+        if cur > QUEUE_CAP:
+            config[key] = QUEUE_CAP
+            restore[key] = cur
+
+    if not config:
+        return
+
+    cfg.ethnl.channels_set(ehdr | config)
+    defer(cfg.ethnl.channels_set, ehdr | restore)
+
+
 def _get_irq_cpus(cfg):
     """
     Read the list of IRQs for the device Rx queues.
@@ -177,6 +198,7 @@ RPS_MAX_CPUS = 16
     ]
 
     if grp:
+        _cap_queue_count(cfg)
         _check_rps_and_rfs_not_configured(cfg)
     if grp == "rss":
         irq_cpus = ",".join([str(x) for x in _get_irq_cpus(cfg)])
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jakub Kicinski

The RPS test needs a free CPU within the first RPS_MAX_CPUS (16) cores. This is easily violated if the NIC or env allocates the IRQs to cores linearly.

Cap the Rx queues at 8, we don't need more. This makes the test pass on CX7 in NIPA.

Quoted 24 lines

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 .../selftests/drivers/net/hw/toeplitz.py      | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
tools/testing/selftests/drivers/net/hw/toeplitz.py +2 -0
index cd7e080e6f84..571732198b93 100755
@@ -21,6 +21,8 @@ from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, KsftFailEx
 ETH_RSS_HASH_TOP = 1
 # Must match RPS_MAX_CPUS in toeplitz.c
 RPS_MAX_CPUS = 16
+# Cap Rx queues so IRQ pinning leaves free CPUs in the RPS_MAX_CPUS range
+QUEUE_CAP = 8
 
 
 def _check_rps_and_rfs_not_configured(cfg):

tools/testing/selftests/drivers/net/hw/toeplitz.py RPS_MAX_CPUS = 16 · line 59

Quoted 10 lines
tools/testing/selftests/drivers/net/hw/toeplitz.py +7 -0
@@ -48,6 +50,25 @@ RPS_MAX_CPUS = 16
         return int(data)
 
 
+def _cap_queue_count(cfg):
+    ehdr = {"header": {"dev-index": cfg.ifindex}}
+    chans = cfg.ethnl.channels_get(ehdr)
+
+    config = {}
+    restore = {}
+    for key in ("combined-count", "rx-count"):

This assumes that combined and rx are not set at the same time. SGTM, not expected in real devices. But technically they could be.

Quoted 26 lines
tools/testing/selftests/drivers/net/hw/toeplitz.py +13 -0
+        cur = chans.get(key, 0)
+        if cur > QUEUE_CAP:
+            config[key] = QUEUE_CAP
+            restore[key] = cur
+
+    if not config:
+        return
+
+    cfg.ethnl.channels_set(ehdr | config)
+    defer(cfg.ethnl.channels_set, ehdr | restore)
+
+
 def _get_irq_cpus(cfg):
     """
     Read the list of IRQs for the device Rx queues.
@@ -177,6 +198,7 @@ RPS_MAX_CPUS = 16
     ]
 
     if grp:
+        _cap_queue_count(cfg)
         _check_rps_and_rfs_not_configured(cfg)
     if grp == "rss":
         irq_cpus = ",".join([str(x) for x in _get_irq_cpus(cfg)])
Signature · 1 line
2.54.0
author maintainer
#2 lore raw
Quoted 10 lines · On Tue, 30 Jun 2026 13:11:15 -0400 Willem de Bruijn wrote:

tools/testing/selftests/drivers/net/hw/toeplitz.py RPS_MAX_CPUS = 16 · line 59

Quoted 7 lines
tools/testing/selftests/drivers/net/hw/toeplitz.py +7 -0
+def _cap_queue_count(cfg):
+    ehdr = {"header": {"dev-index": cfg.ifindex}}
+    chans = cfg.ethnl.channels_get(ehdr)
+
+    config = {}
+    restore = {}
+    for key in ("combined-count", "rx-count"):  

This assumes that combined and rx are not set at the same time. SGTM, not expected in real devices. But technically they could be.

Ack, some tests just assume the NIC uses combined, which is most common. If this ever causes issues we should probably add support for provisioning min/max number of queues in the env setup itself. IIRC someone even posted that at some point.

#3 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Mon, 29 Jun 2026 16:43:53 -0700 you wrote:

The RPS test needs a free CPU within the first RPS_MAX_CPUS (16) cores. This is easily violated if the NIC or env allocates the IRQs to cores linearly.

Cap the Rx queues at 8, we don't need more. This makes the test pass on CX7 in NIPA.

[...]

Here is the summary with links:
- [net-next] selftests: drv-net: toeplitz: cap the Rx queue count

    https://git.kernel.org/netdev/net-next/c/07d3aaa046ce

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html