Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: drivers: net: hw: Modify toeplitz.c to poll for packets

Prior to this the receiver would sleep for the configured timeout,
then attempt to receive as many packets as possible. This would result
in a large burst of packets, and we don't necessarily need that many samples.

The tests now run faster.

Before

ok 12 toeplitz.test.rps_udp_ipv6
# Totals: pass:12 fail:0 xfail:0 xpass:0 skip:0 error:0

real 0m54.792s
user 0m12.486s
sys 0m10.887s

After

ok 12 toeplitz.test.rps_udp_ipv6
# Totals: pass:12 fail:0 xfail:0 xpass:0 skip:0 error:0

real 0m36.892s
user 0m4.203s
sys 0m8.314s

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
Link: https://patch.msgid.link/20260207013018.551347-1-dimitri.daskalakis1@gmail.com
[pabeni@redhat.com: whitespaces fixes]
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Dimitri Daskalakis and committed by
Paolo Abeni
ccb32726 70f1fbee

+22 -4
+22 -4
tools/testing/selftests/drivers/net/hw/toeplitz.c
··· 72 72 73 73 #define RPS_MAX_CPUS 16UL /* must be a power of 2 */ 74 74 75 + #define MIN_PKT_SAMPLES 40 /* minimum number of packets to receive */ 76 + 75 77 /* configuration options (cmdline arguments) */ 76 78 static uint16_t cfg_dport = 8000; 77 79 static int cfg_family = AF_INET6; ··· 253 251 return true; 254 252 } 255 253 256 - /* simple test: sleep once unconditionally and then process all rings */ 254 + /* simple test: process all rings until MIN_PKT_SAMPLES packets are received, 255 + * or the test times out. 256 + */ 257 257 static void process_rings(void) 258 258 { 259 + struct timeval start, now; 260 + bool pkts_found = true; 261 + long elapsed_usec; 259 262 int i; 260 263 261 - usleep(1000 * cfg_timeout_msec); 264 + gettimeofday(&start, NULL); 262 265 263 - for (i = 0; i < num_cpus; i++) 264 - do {} while (recv_block(&rings[i])); 266 + do { 267 + if (!pkts_found) 268 + usleep(100); 269 + 270 + pkts_found = false; 271 + for (i = 0; i < num_cpus; i++) 272 + pkts_found |= recv_block(&rings[i]); 273 + 274 + gettimeofday(&now, NULL); 275 + elapsed_usec = (now.tv_sec - start.tv_sec) * 1000000 + 276 + (now.tv_usec - start.tv_usec); 277 + } while (frames_received - frames_nohash < MIN_PKT_SAMPLES && 278 + elapsed_usec < cfg_timeout_msec * 1000); 265 279 266 280 fprintf(stderr, "count: pass=%u nohash=%u fail=%u\n", 267 281 frames_received - frames_nohash - frames_error,