selftests: drv-net: driver tests for HW GRO
Subsystems (3)
Jakub Kicinski
maintainerv3 cover selftests: drv-net: driver tests for HW GRO
Add tests for HW GRO stats, packet ordering and depth.
The ynltool and bnxt patches from v2 were applied separately.
v3:
- [patch 3] add a note about fq being needed
v2: https://lore.kernel.org/[email protected]
- [patch 3] do not enable SO_TXTIME for multi-flow tests
- [patch 6] move the test to cover SW GRO
v1: https://lore.kernel.org/[email protected]
Jakub Kicinski (6):
selftests: net: move gro to lib for HW vs SW reuse
selftests: drv-net: give HW stats sync time extra 25% of margin
selftests: drv-net: gro: use SO_TXTIME to schedule packets together
selftests: drv-net: gro: test GRO stats
selftests: drv-net: gro: add test for packet ordering
selftests: drv-net: gro: add a test for GRO depth
tools/testing/selftests/drivers/net/Makefile | 1 -
.../testing/selftests/drivers/net/hw/Makefile | 1 +
tools/testing/selftests/net/lib/Makefile | 1 +
.../selftests/{drivers/net => net/lib}/gro.c | 252 ++++++++++++++-
.../testing/selftests/drivers/net/.gitignore | 1 -
tools/testing/selftests/drivers/net/gro.py | 203 ++++++++++--
.../selftests/drivers/net/hw/gro_hw.py | 294 ++++++++++++++++++
.../selftests/drivers/net/lib/py/env.py | 4 +-
tools/testing/selftests/net/lib/.gitignore | 1 +
9 files changed, 728 insertions(+), 30 deletions(-)
rename tools/testing/selftests/{drivers/net => net/lib}/gro.c (86%)
create mode 100755 tools/testing/selftests/drivers/net/hw/gro_hw.pySignature · 1 line
2.53.0
Jakub Kicinski
maintainerPATCH v3 1/6 selftests: net: move gro to lib for HW vs SW reuse
The gro.c packet sender is used for SW testing but bulk of incoming new tests will be HW-specific. So it's better to put them under drivers/net/hw/, to avoid tip-toeing around netdevsim. Move gro.c to lib so we can reuse it.
---
tools/testing/selftests/drivers/net/Makefile | 1 -
tools/testing/selftests/net/lib/Makefile | 1 +
tools/testing/selftests/{drivers/net => net/lib}/gro.c | 2 +-
tools/testing/selftests/drivers/net/.gitignore | 1 -
tools/testing/selftests/drivers/net/gro.py | 2 +-
tools/testing/selftests/net/lib/.gitignore | 1 +
6 files changed, 4 insertions(+), 4 deletions(-)
rename tools/testing/selftests/{drivers/net => net/lib}/gro.c (99%)tools/testing/selftests/drivers/net/Makefile +0 -1
@@ -6,7 +6,6 @@ TEST_INCLUDES := $(wildcard lib/py/*.py) \ ../../net/lib.sh \ TEST_GEN_FILES := \ - gro \ napi_id_helper \ # end of TEST_GEN_FILES
tools/testing/selftests/net/lib/Makefile +1 -0
@@ -14,6 +14,7 @@ TEST_FILES := \ TEST_GEN_FILES := \ $(patsubst %.c,%.o,$(wildcard *.bpf.c)) \ csum \ + gro \ xdp_helper \ # end of TEST_GEN_FILES
tools/testing/selftests/net/lib/gro.c renamed from tools/testing/selftests/drivers/net/gro.c +1 -1
@@ -77,7 +77,7 @@#include <unistd.h> #include "kselftest.h" -#include "../../net/lib/ksft.h" +#include "ksft.h" #define DPORT 8000#define SPORT 1500
tools/testing/selftests/drivers/net/.gitignore +0 -1
@@ -1,4 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -gro napi_id_helper psp_responder
tools/testing/selftests/drivers/net/gro.py +1 -1
@@ -117,7 +117,7 @@ from lib.py import ksft_variants """ Setup hardware loopback mode for GRO testing. """ if not hasattr(cfg, "bin_remote"): - cfg.bin_local = cfg.test_dir / "gro" + cfg.bin_local = cfg.net_lib_dir / "gro" cfg.bin_remote = cfg.remote.deploy(cfg.bin_local) if not hasattr(cfg, "feat"):
tools/testing/selftests/net/lib/.gitignore +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only csum +gro xdp_helper
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerPATCH v3 2/6 selftests: drv-net: give HW stats sync time extra 25% of margin
In reply to Jakub KicinskiThere are transient failures for devices which update stats periodically, especially if it's the FW DMA'ing the stats rather than host periodic work querying the FW. Wait 25% longer than strictly necessary.
For devices which don't report stats-block-usecs we retain 25 msec as the default wait time (0.025sec == 20,000usec * 1.25).
--- tools/testing/selftests/drivers/net/lib/py/env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/lib/py/env.py +2 -2
@@ -288,8 +288,8 @@ from . import bpftool, RtnlFamily, Netlink if "Operation not supported" not in e.cmd.stderr: raise - self._stats_settle_time = 0.025 + \ - data.get('stats-block-usecs', 0) / 1000 / 1000 + self._stats_settle_time = \ + 1.25 * data.get('stats-block-usecs', 20000) / 1000 / 1000 time.sleep(self._stats_settle_time)
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerPATCH v3 3/6 selftests: drv-net: gro: use SO_TXTIME to schedule packets together
In reply to Jakub KicinskiLonger packet sequence tests are quite flaky when the test is run over a real network. Try to avoid at least the jitter on the sender side by scheduling all the packets to be sent at once using SO_TXTIME. Use hardcoded tx time of 5msec in the future. In my test increasing this time past 2msec makes no difference so 5msec is plenty of margin. Since we now expect more output buffering make sure to raise SNDBUF.
Note that this is an opportunistic reliability improvement which will only work if the qdisc can schedule Tx time for us (fq). Fiddling with qdisc config was deemed too complex, so it's not part of the patch.
---
v3:
- update the commit msg
v2: https://lore.kernel.org/[email protected]
- only enable TXTIME when we are sending a single flow
v1: https://lore.kernel.org/[email protected]
--- tools/testing/selftests/net/lib/gro.c | 57 +++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-)
tools/testing/selftests/net/lib/gro.c +54 -3
@@ -63,6 +63,7 @@#include <linux/filter.h> #include <linux/if_packet.h> #include <linux/ipv6.h> +#include <linux/net_tstamp.h> #include <net/ethernet.h> #include <net/if.h> #include <netinet/in.h>
@@ -74,6 +75,7 @@#include <stdio.h> #include <stdarg.h> #include <string.h> +#include <time.h> #include <unistd.h> #include "kselftest.h"
@@ -123,6 +125,9 @@ static int tcp_offset = -1;static int total_hdr_len =-1 ;static int ethhdr_proto =-1 ;static bool ipip; +static uint64_t txtime_ns; + +#define TXTIME_DELAY_MS 5static void vlog (const char *fmt, ...) {
@@ -330,13 +335,37 @@ static void fill_transportlayer(void *buf, int seq_offset, int ack_offset,static void write_packet (int fd,char *buf,int len,struct sockaddr_ll *daddr) { +char control[CMSG_SPACE (sizeof (uint64_t ))]; +struct msghdr msg = {}; +struct iovec iov = {}; +struct cmsghdr *cm;int ret =-1 ; - ret =sendto (fd, buf, len,0 , (struct sockaddr *)daddr,sizeof (*daddr)); + iov.iov_base = buf; + iov.iov_len = len; + + msg.msg_iov = &iov; + msg.msg_iovlen =1 ; + msg.msg_name = daddr; + msg.msg_namelen =sizeof (*daddr); + +if (txtime_ns) { +memset (control,0 ,sizeof (control)); + msg.msg_control = control; + msg.msg_controllen =sizeof (control); + + cm =CMSG_FIRSTHDR (&msg); + cm->cmsg_level =SOL_SOCKET ; + cm->cmsg_type =SCM_TXTIME ; + cm->cmsg_len =CMSG_LEN (sizeof (uint64_t )); +memcpy (CMSG_DATA (cm), &txtime_ns,sizeof (txtime_ns)); + } + + ret =sendmsg (fd, &msg,0 );if (ret ==-1 ) -error (1 , errno,"sendto failure" ); +error (1 , errno,"sendmsg failure" );if (ret != len) -error (1 , errno,"sendto wrong length" ); +error (1 ,0 ,"sendmsg wrong length: %d vs %d" , ret, len); } static void create_packet(void *buf, int seq_offset, int ack_offset,
@@ -1058,6 +1087,7 @@ static void check_recv_pkts(int fd, int *correct_payload,static void gro_sender (void ) { +int bufsize =4 *1024 *1024 ;/* 4 MB */ const int fin_delay_us =100 *1000 ;static char fin_pkt[MAX_HDR_LEN ];struct sockaddr_ll daddr = {};
@@ -1067,6 +1097,27 @@ static void gro_sender(void)if (txfd <0 )error (1 , errno,"socket creation" ); +if (setsockopt (txfd,SOL_SOCKET ,SO_SNDBUF , &bufsize,sizeof (bufsize))) +error (1 , errno,"cannot set sndbuf size, setsockopt failed" ); + +/* Enable SO_TXTIME unless test case generates more than one flow +* SO_TXTIME could result in qdisc layer sorting the packets at sender. +*/ +if (true) { +struct sock_txtime so_txtime = { .clockid =CLOCK_MONOTONIC , }; +struct timespec ts; + +if (setsockopt (txfd,SOL_SOCKET ,SO_TXTIME , + &so_txtime,sizeof (so_txtime))) +error (1 , errno,"setsockopt SO_TXTIME" ); + +if (clock_gettime (CLOCK_MONOTONIC , &ts)) +error (1 , errno,"clock_gettime" ); + + txtime_ns = ts.tv_sec *1000000000ULL + ts.tv_nsec; + txtime_ns +=TXTIME_DELAY_MS *1000000ULL ; + } +memset (&daddr,0 ,sizeof (daddr)); daddr.sll_ifindex =if_nametoindex (ifname);if (daddr.sll_ifindex ==0 )
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerPATCH v3 4/6 selftests: drv-net: gro: test GRO stats
In reply to Jakub KicinskiTest accuracy of GRO stats. We want to cover two potentially tricky cases:
- single segment GRO
- packets which were eligible but didn't get GRO'd
The first case is trivial, teach gro.c to send one packet, and check GRO stats didn't move.
Second case requires gro.c to send a lot of flows expecting the NIC to run out of GRO flow capacity.
To avoid system traffic noise we steer the packets to a dedicated queue and operate on qstat.
--- .../testing/selftests/drivers/net/hw/Makefile | 1 + tools/testing/selftests/net/lib/gro.c | 163 ++++++++++- .../selftests/drivers/net/hw/gro_hw.py | 271 ++++++++++++++++++ 3 files changed, 433 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/hw/gro_hw.py
tools/testing/selftests/drivers/net/hw/Makefile +1 -0
@@ -26,6 +26,7 @@ TEST_PROGS = \ ethtool_extended_state.sh \ ethtool_mm.sh \ ethtool_rmon.sh \ + gro_hw.py \ hw_stats_l3.sh \ hw_stats_l3_gre.sh \ iou-zcrx.py \
tools/testing/selftests/net/lib/gro.c +161 -2
223 lines not on this page · raw message
tools/testing/selftests/drivers/net/hw/gro_hw.py new file +271 -0
271 lines not on this page · raw message
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerPATCH v3 5/6 selftests: drv-net: gro: add test for packet ordering
In reply to Jakub KicinskiAdd a test to check if the NIC reorders packets if the hit GRO.
--- tools/testing/selftests/net/lib/gro.c | 38 +++++++++++++++++-- .../selftests/drivers/net/hw/gro_hw.py | 29 ++++++++++++-- 2 files changed, 61 insertions(+), 6 deletions(-)
tools/testing/selftests/net/lib/gro.c +35 -3
@@ -131,6 +131,7 @@ static int ethhdr_proto = -1;static bool ipip;static uint64_t txtime_ns;static int num_flows =4 ; +static bool order_check;#define CAPACITY_PAYLOAD_LEN 200
@@ -1136,6 +1137,7 @@ static void check_capacity_pkts(int fd)static char buffer[IP_MAXPACKET +ETH_HLEN +1 ];struct iphdr *iph = (struct iphdr *)(buffer +ETH_HLEN );struct ipv6hdr *ip6h = (struct ipv6hdr *)(buffer +ETH_HLEN ); +int num_pkt =0 , num_coal =0 , pkt_idx;const char *fail_reason =NULL ;int flow_order[num_flows *2 ];int coalesced[num_flows];
@@ -1144,8 +1146,6 @@ static void check_capacity_pkts(int fd)int total_data =0 ;int pkt_size =-1 ;int data_len =0 ; -int num_pkt =0 ; -int num_coal =0 ;int flow_id;int sport;
@@ -1203,6 +1203,34 @@ static void check_capacity_pkts(int fd) total_data += data_len; } +/* Check flow ordering. We expect to see all non-coalesced first segs +* then interleaved coalesced and non-coalesced second frames. +*/ + pkt_idx =0 ; +for (flow_id =0 ; order_check && flow_id < num_flows; flow_id++) { +bool coaled = coalesced[flow_id] >CAPACITY_PAYLOAD_LEN ; + +if (coaled) +continue ; + +if (flow_order[pkt_idx] != flow_id) { +vlog ("Flow order mismatch (non-coalesced) at position %d: expected flow %d, got flow %d\n" , + pkt_idx, flow_id, flow_order[pkt_idx]); + fail_reason = fail_reason ?:"bad packet order (1)" ; + } + pkt_idx++; + } +for (flow_id =0 ; order_check && flow_id < num_flows; flow_id++) { +bool coaled = coalesced[flow_id] >CAPACITY_PAYLOAD_LEN ; + +if (flow_order[pkt_idx] != flow_id) { +vlog ("Flow order mismatch at position %d: expected flow %d, got flow %d, coalesced: %d\n" , + pkt_idx, flow_id, flow_order[pkt_idx], coaled); + fail_reason = fail_reason ?:"bad packet order (2)" ; + } + pkt_idx++; + } +if (!fail_reason) {vlog ("All %d flows coalesced correctly\n" , num_flows);printf ("Test succeeded\n\n" );
@@ -1622,12 +1650,13 @@ static void parse_args(int argc, char **argv) { "saddr", required_argument, NULL, 's' }, { "smac", required_argument, NULL, 'S' }, { "test", required_argument, NULL, 't' }, + { "order-check", no_argument, NULL, 'o' }, { "verbose", no_argument, NULL, 'v' }, { 0, 0, 0, 0 } };int c; -while ((c =getopt_long (argc, argv,"46d:D:ei:n:rs:S:t:v" , opts,NULL )) !=-1 ) { +while ((c =getopt_long (argc, argv,"46d:D:ei:n:rs:S:t:ov" , opts,NULL )) !=-1 ) {switch (c) {case '4' : proto =PF_INET ;
@@ -1666,6 +1695,9 @@ static void parse_args(int argc, char **argv)case 't' : testname = optarg;break ; +case 'o' : + order_check = true; +break ;case 'v' : verbose = true;break ;
tools/testing/selftests/drivers/net/hw/gro_hw.py +26 -3
@@ -10,7 +10,7 @@ import glob import re from lib.py import ksft_run, ksft_exit, ksft_pr -from lib.py import ksft_eq, ksft_ge +from lib.py import ksft_eq, ksft_ge, ksft_variants from lib.py import NetDrvEpEnv, NetdevFamily from lib.py import KsftSkipEx from lib.py import bkg, cmd, defer, ethtool, ip
@@ -78,7 +78,8 @@ GRO_DPORT = 8000 return test_queue -def _run_gro_test(cfg, test_name, num_flows=None, ignore_fail=False): +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.""" if not hasattr(cfg, "bin_remote"): cfg.bin_local = cfg.net_lib_dir / "gro"
@@ -98,6 +99,8 @@ GRO_DPORT = 8000 ] if num_flows: base_args.append(f"--num-flows {num_flows}") + if order_check: + base_args.append("--order-check") args = " ".join(base_args)
@@ -257,13 +260,33 @@ def _check_gro_stats(cfg, test_queue, stats_before, expect_wire=gro_coalesced * 2) +@ksft_variants([4, 32, 512]) +def test_gro_order(cfg, num_flows): + """ + Test that HW GRO preserves packet ordering between flows. + + Packets may get delayed until the aggregate is released, + but reordering between aggregates and packet terminating + the aggregate and normal packets should not happen. + + Note that this test is stricter than truly required. + Reordering packets between flows should not cause issues. + This test will also fail if traffic is run over an ECMP fabric. + """ + _setup_hw_gro(cfg) + _setup_isolated_queue(cfg) + + _run_gro_test(cfg, "capacity", num_flows=num_flows, order_check=True) + + def main() -> None: """ Ksft boiler plate main """ with NetDrvEpEnv(__file__, nsim_test=False) as cfg: cfg.netnl = NetdevFamily() ksft_run([test_gro_stats_single, - test_gro_stats_full], args=(cfg,)) + test_gro_stats_full, + test_gro_order], args=(cfg,)) ksft_exit()
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerPATCH v3 6/6 selftests: drv-net: gro: add a test for GRO depth
In reply to Jakub KicinskiReuse the long sequence test to max out the GRO contexts. Repeat for a single queue, 8 queues, and default number of queues but flow steering to just one.
The SW GRO's capacity should be around 64 per queue (8 buckets, up to 8 skbs in a chain).
---
v2:
- move this "test" to SW, we can check SW GRO capacity too
v1: https://lore.kernel.org/[email protected]
--- tools/testing/selftests/drivers/net/gro.py | 201 +++++++++++++++++++-- 1 file changed, 181 insertions(+), 20 deletions(-)
tools/testing/selftests/drivers/net/gro.py +181 -20
@@ -35,11 +35,18 @@ coalescing behavior. - large_rem: Large packet remainder handling """ +import glob import os +import re from lib.py import ksft_run, ksft_exit, ksft_pr from lib.py import NetDrvEpEnv, KsftXfailEx +from lib.py import NetdevFamily, EthtoolFamily from lib.py import bkg, cmd, defer, ethtool, ip -from lib.py import ksft_variants +from lib.py import ksft_variants, KsftNamedVariant + + +# gro.c uses hardcoded DPORT=8000 +GRO_DPORT = 8000 def _resolve_dmac(cfg, ipver):
@@ -113,6 +120,98 @@ from lib.py import ksft_variants ksft_pr(eth_cmd) +def _get_queue_stats(cfg, queue_id): + """Get stats for a specific Rx queue.""" + cfg.wait_hw_stats_settle() + data = cfg.netnl.qstats_get({"ifindex": cfg.ifindex, "scope": ["queue"]}, + dump=True) + for q in data: + if q.get('queue-type') == 'rx' and q.get('queue-id') == queue_id: + return q + return {} + + +def _setup_isolated_queue(cfg): + """Set up an isolated queue for testing using ntuple filter. + + Remove queue 1 from the default RSS context and steer test traffic to it. + """ + test_queue = 1 + + qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*")) + if qcnt < 2: + raise KsftXfailEx(f"Need at least 2 queues, have {qcnt}") + + # Remove queue 1 from default RSS context by setting its weight to 0 + weights = ["1"] * qcnt + weights[test_queue] = "0" + ethtool(f"-X {cfg.ifname} weight " + " ".join(weights)) + defer(ethtool, f"-X {cfg.ifname} default") + + # Set up ntuple filter to steer our test traffic to the isolated queue + flow = f"flow-type tcp{cfg.addr_ipver} " + flow += f"dst-ip {cfg.addr} dst-port {GRO_DPORT} action {test_queue}" + output = ethtool(f"-N {cfg.ifname} {flow}").stdout + ntuple_id = int(output.split()[-1]) + defer(ethtool, f"-N {cfg.ifname} delete {ntuple_id}") + + 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 KsftXfailEx(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_bin(cfg, test_name, protocol=None, num_flows=None, + order_check=False, verbose=False, fail=False): + """Run gro binary with given test and return the process result.""" + if not hasattr(cfg, "bin_remote"): + cfg.bin_local = cfg.net_lib_dir / "gro" + cfg.bin_remote = cfg.remote.deploy(cfg.bin_local) + + if protocol is None: + ipver = cfg.addr_ipver + protocol = f"ipv{ipver}" + else: + ipver = "6" if protocol[-1] == "6" else "4" + + dmac = _resolve_dmac(cfg, ipver) + + base_args = [ + f"--{protocol}", + f"--dmac {dmac}", + f"--smac {cfg.remote_dev['address']}", + f"--daddr {cfg.addr_v[ipver]}", + f"--saddr {cfg.remote_addr_v[ipver]}", + f"--test {test_name}", + ] + if num_flows: + base_args.append(f"--num-flows {num_flows}") + if order_check: + base_args.append("--order-check") + if verbose: + base_args.append("--verbose") + + args = " ".join(base_args) + + rx_cmd = f"{cfg.bin_local} {args} --rx --iface {cfg.ifname}" + tx_cmd = f"{cfg.bin_remote} {args} --iface {cfg.remote_ifname}" + + with bkg(rx_cmd, ksft_ready=True, exit_wait=True, fail=fail) as rx_proc: + cmd(tx_cmd, host=cfg.remote) + + return rx_proc + + def _setup(cfg, mode, test_name): """ Setup hardware loopback mode for GRO testing. """
@@ -233,30 +332,14 @@ from lib.py import ksft_variants _setup(cfg, mode, test_name) - base_cmd_args = [ - f"--{protocol}", - f"--dmac {_resolve_dmac(cfg, ipver)}", - f"--smac {cfg.remote_dev['address']}", - f"--daddr {cfg.addr_v[ipver]}", - f"--saddr {cfg.remote_addr_v[ipver]}", - f"--test {test_name}", - "--verbose" - ] - base_args = " ".join(base_cmd_args) - # Each test is run 6 times to deflake, because given the receive timing, # not all packets that should coalesce will be considered in the same flow # on every try. max_retries = 6 for attempt in range(max_retries): - rx_cmd = f"{cfg.bin_local} {base_args} --rx --iface {cfg.ifname}" - tx_cmd = f"{cfg.bin_remote} {base_args} --iface {cfg.remote_ifname}" - fail_now = attempt >= max_retries - 1 - - with bkg(rx_cmd, ksft_ready=True, exit_wait=True, - fail=fail_now) as rx_proc: - cmd(tx_cmd, host=cfg.remote) + rx_proc = _run_gro_bin(cfg, test_name, protocol=protocol, + verbose=True, fail=fail_now) if rx_proc.ret == 0: return
@@ -270,11 +353,89 @@ from lib.py import ksft_variants ksft_pr(f"Attempt {attempt + 1}/{max_retries} failed, retrying...") +def _capacity_variants(): + """Generate variants for capacity test: mode x queue setup.""" + setups = [ + ("isolated", _setup_isolated_queue), + ("1q", lambda cfg: _setup_queue_count(cfg, 1)), + ("8q", lambda cfg: _setup_queue_count(cfg, 8)), + ] + for mode in ["sw", "hw", "lro"]: + for name, func in setups: + yield KsftNamedVariant(f"{mode}_{name}", mode, func) + + +@ksft_variants(_capacity_variants()) +def test_gro_capacity(cfg, mode, setup_func): + """ + Probe GRO capacity. + + Start with 8 flows and increase by 2x on each successful run. + Retry up to 3 times on failure. + + Variants combine mode (sw, hw, lro) with queue setup: + - 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(cfg, mode, "capacity") + 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) + + rx_proc = _run_gro_bin(cfg, "capacity", num_flows=num_flows) + output = rx_proc.stdout + + 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)) + gro_pkts = (stats_after.get('rx-hw-gro-packets', 0) - + stats_before.get('rx-hw-gro-packets', 0)) + qstat_str = f" qstat={qstat_pkts} hw-gro={gro_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(rx_proc) + 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__) as cfg: - ksft_run(cases=[test], args=(cfg,)) + cfg.ethnl = EthtoolFamily() + cfg.netnl = NetdevFamily() + ksft_run(cases=[test, test_gro_capacity], args=(cfg,)) ksft_exit()
Signature · 1 line
2.53.0
Jakub Kicinski
maintainerRe: [PATCH net-next v3 6/6] selftests: drv-net: gro: add a test for GRO depth
tools/testing/selftests/drivers/net/gro.py from lib.py import ksft_variants · line 416
Quoted 4 lines · On Mon, 16 Mar 2026 15:45:05 -0700 Jakub Kicinski wrote:
tools/testing/selftests/drivers/net/gro.py +4
-0+ 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}]")
I'll have to repost this, [FAIL] is confusing NIPA.