public inbox for netdev@vger.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, shuah@kernel.org,
	willemb@google.com, petrm@nvidia.com, donald.hunter@gmail.com,
	michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
	linux-kselftest@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 9/9] selftests: drv-net: gro: add a test for HW-GRO depth
Date: Thu,  5 Feb 2026 14:05:41 -0800	[thread overview]
Message-ID: <20260205220541.2992807-10-kuba@kernel.org> (raw)
In-Reply-To: <20260205220541.2992807-1-kuba@kernel.org>

Reuse the long sequence test to max out the NIC HW-GRO depth.
Repeat for a single queue and RSS context with 8 queues.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../selftests/drivers/net/hw/gro_hw.py        | 86 ++++++++++++++++++-
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/drivers/net/hw/gro_hw.py b/tools/testing/selftests/drivers/net/hw/gro_hw.py
index 18a3b1bceefd..7450b8884f44 100755
--- a/tools/testing/selftests/drivers/net/hw/gro_hw.py
+++ b/tools/testing/selftests/drivers/net/hw/gro_hw.py
@@ -10,8 +10,8 @@ import glob
 import re
 
 from lib.py import ksft_run, ksft_exit, ksft_pr
-from lib.py import ksft_eq, ksft_ge, ksft_variants
-from lib.py import NetDrvEpEnv, NetdevFamily
+from lib.py import ksft_eq, ksft_ge, ksft_variants, KsftNamedVariant
+from lib.py import NetDrvEpEnv, NetdevFamily, EthtoolFamily
 from lib.py import KsftSkipEx
 from lib.py import bkg, cmd, defer, ethtool, ip
 
@@ -78,6 +78,19 @@ GRO_DPORT = 8000
     return test_queue
 
 
+def _setup_queue_count(cfg, num_queues):
+    """Configure the NIC to use a specific number of queues."""
+    channels = cfg.ethnl.channels_get({'header': {'dev-index': cfg.ifindex}})
+    ch_max = channels.get('combined-max', 0)
+    qcnt = channels['combined-count']
+
+    if ch_max < num_queues:
+        raise KsftSkipEx(f"Need at least {num_queues} queues, max={ch_max}")
+
+    defer(ethtool, f"-L {cfg.ifname} combined {qcnt}")
+    ethtool(f"-L {cfg.ifname} combined {num_queues}")
+
+
 def _run_gro_test(cfg, test_name, num_flows=None, ignore_fail=False,
                   order_check=False):
     """Run gro binary with given test and return output."""
@@ -279,14 +292,81 @@ def _check_gro_stats(cfg, test_queue, stats_before,
     _run_gro_test(cfg, "capacity", num_flows=num_flows, order_check=True)
 
 
+@ksft_variants([
+    KsftNamedVariant("isolated", _setup_isolated_queue),
+    KsftNamedVariant("1q", lambda cfg: _setup_queue_count(cfg, 1)),
+    KsftNamedVariant("8q", lambda cfg: _setup_queue_count(cfg, 8)),
+])
+def test_gro_capacity(cfg, setup_func):
+    """
+    Probe HW GRO capacity.
+
+    Start with 8 flows and increase by 4x on each successful run.
+    Retry up to 3 times on failure.
+
+    Variants:
+      - isolated: Use a single queue isolated from RSS
+      - 1q: Configure NIC to use 1 queue
+      - 8q: Configure NIC to use 8 queues
+    """
+    max_retries = 3
+
+    _setup_hw_gro(cfg)
+    queue_id = setup_func(cfg)
+
+    num_flows = 8
+    while True:
+        success = False
+        for attempt in range(max_retries):
+            if queue_id is not None:
+                stats_before = _get_queue_stats(cfg, queue_id)
+
+            output = _run_gro_test(cfg, "capacity", num_flows=num_flows,
+                                   ignore_fail=True)
+
+            if queue_id is not None:
+                stats_after = _get_queue_stats(cfg, queue_id)
+                qstat_pkts = (stats_after.get('rx-packets', 0) -
+                              stats_before.get('rx-packets', 0))
+                qstat_str = f" qstat={qstat_pkts}"
+            else:
+                qstat_str = ""
+
+            # Parse and print STATS line
+            match = re.search(
+                r'STATS: received=(\d+) wire=(\d+) coalesced=(\d+)', output)
+            if match:
+                received = int(match.group(1))
+                wire = int(match.group(2))
+                coalesced = int(match.group(3))
+                status = "PASS" if received == num_flows else "FAIL"
+                ksft_pr(f"flows={num_flows} attempt={attempt + 1} "
+                        f"received={received} wire={wire} "
+                        f"coalesced={coalesced}{qstat_str} [{status}]")
+                if received == num_flows:
+                    success = True
+                    break
+            else:
+                ksft_pr(f"flows={num_flows} attempt={attempt + 1}"
+                        f"{qstat_str} [FAIL - can't parse stats]")
+
+        if not success:
+            ksft_pr(f"Stopped at {num_flows} flows")
+            break
+
+        num_flows *= 2
+
+
 def main() -> None:
     """ Ksft boiler plate main """
 
     with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
+        cfg.ethnl = EthtoolFamily()
         cfg.netnl = NetdevFamily()
         ksft_run([test_gro_stats_single,
                   test_gro_stats_full,
-                  test_gro_order], args=(cfg,))
+                  test_gro_order,
+                  test_gro_capacity], args=(cfg,))
     ksft_exit()
 
 
-- 
2.53.0


  parent reply	other threads:[~2026-02-05 22:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 22:05 [PATCH net-next 0/9] net: stats, tools, driver tests for HW GRO Jakub Kicinski
2026-02-05 22:05 ` [PATCH net-next 1/9] eth: bnxt: gather and report HW-GRO stats Jakub Kicinski
2026-02-05 22:44   ` Michael Chan
2026-02-06  0:24     ` Jakub Kicinski
2026-02-05 22:05 ` [PATCH net-next 2/9] tools: ynltool: factor out qstat dumping Jakub Kicinski
2026-02-06 14:58   ` Petr Machata
2026-02-05 22:05 ` [PATCH net-next 3/9] tools: ynltool: add qstats analysis for HW-GRO efficiency / savings Jakub Kicinski
2026-02-06 13:44   ` Petr Machata
2026-02-05 22:05 ` [PATCH net-next 4/9] selftests: net: move gro to lib for HW vs SW reuse Jakub Kicinski
2026-02-06 15:01   ` Petr Machata
2026-02-05 22:05 ` [PATCH net-next 5/9] selftests: drv-net: give HW stats sync time extra 25% of margin Jakub Kicinski
2026-02-06 14:40   ` Petr Machata
2026-02-05 22:05 ` [PATCH net-next 6/9] selftests: drv-net: gro: use SO_TXTIME to schedule packets together Jakub Kicinski
2026-02-06 15:19   ` Petr Machata
2026-02-05 22:05 ` [PATCH net-next 7/9] selftests: drv-net: gro: test GRO stats Jakub Kicinski
2026-02-05 22:05 ` [PATCH net-next 8/9] selftests: drv-net: gro: add test for packet ordering Jakub Kicinski
2026-02-05 22:05 ` Jakub Kicinski [this message]
2026-02-06 15:36 ` [PATCH net-next 0/9] net: stats, tools, driver tests for HW GRO Petr Machata

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=20260205220541.2992807-10-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox