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

selftests: xsk: Remove the num_tx_packets option

Remove the number of tx packet option as this should be decided by the
test itself. Also change the number of packets to be sent to 4096
speeding up the execution.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210825093722.10219-3-magnus.karlsson@gmail.com

authored by

Magnus Karlsson and committed by
Alexei Starovoitov
25c0a305 d18b09bf

+13 -27
+10 -23
tools/testing/selftests/bpf/xdpxceiver.c
··· 333 333 {"queue", optional_argument, 0, 'q'}, 334 334 {"dump-pkts", optional_argument, 0, 'D'}, 335 335 {"verbose", no_argument, 0, 'v'}, 336 - {"tx-pkt-count", optional_argument, 0, 'C'}, 337 336 {0, 0, 0, 0} 338 337 }; 339 338 340 339 static void usage(const char *prog) 341 340 { 342 341 const char *str = 343 - " Usage: %s [OPTIONS]\n" 344 - " Options:\n" 345 - " -i, --interface Use interface\n" 346 - " -q, --queue=n Use queue n (default 0)\n" 347 - " -D, --dump-pkts Dump packets L2 - L5\n" 348 - " -v, --verbose Verbose output\n" 349 - " -C, --tx-pkt-count=n Number of packets to send\n"; 342 + " Usage: %s [OPTIONS]\n" 343 + " Options:\n" 344 + " -i, --interface Use interface\n" 345 + " -q, --queue=n Use queue n (default 0)\n" 346 + " -D, --dump-pkts Dump packets L2 - L5\n" 347 + " -v, --verbose Verbose output\n"; 348 + 350 349 ksft_print_msg(str, prog); 351 350 } 352 351 ··· 391 392 opterr = 0; 392 393 393 394 for (;;) { 394 - c = getopt_long(argc, argv, "i:DC:v", long_options, &option_index); 395 + c = getopt_long(argc, argv, "i:Dv", long_options, &option_index); 395 396 396 397 if (c == -1) 397 398 break; ··· 414 415 case 'D': 415 416 debug_pkt_dump = 1; 416 417 break; 417 - case 'C': 418 - opt_pkt_count = atoi(optarg); 419 - break; 420 418 case 'v': 421 419 opt_verbose = 1; 422 420 break; ··· 421 425 usage(basename(argv[0])); 422 426 ksft_exit_xfail(); 423 427 } 424 - } 425 - 426 - if (!opt_pkt_count) { 427 - print_verbose("No tx-pkt-count specified, using default %u\n", DEFAULT_PKT_CNT); 428 - opt_pkt_count = DEFAULT_PKT_CNT; 429 428 } 430 429 431 430 if (!validate_interfaces()) { ··· 545 554 546 555 static int get_batch_size(int pkt_cnt) 547 556 { 548 - if (!opt_pkt_count) 549 - return BATCH_SIZE; 550 - 551 557 if (pkt_cnt + BATCH_SIZE <= opt_pkt_count) 552 558 return BATCH_SIZE; 553 559 ··· 574 586 fds[0].fd = xsk_socket__fd(ifobject->xsk->xsk); 575 587 fds[0].events = POLLOUT; 576 588 577 - while ((opt_pkt_count && pkt_cnt < opt_pkt_count) || !opt_pkt_count) { 589 + while (pkt_cnt < opt_pkt_count) { 578 590 int batch_size = get_batch_size(pkt_cnt); 579 591 580 592 if (test_type == TEST_TYPE_POLL) { ··· 590 602 pkt_cnt += batch_size; 591 603 } 592 604 593 - if (opt_pkt_count) 594 - complete_tx_only_all(ifobject); 605 + complete_tx_only_all(ifobject); 595 606 } 596 607 597 608 static void worker_pkt_dump(void)
+2 -2
tools/testing/selftests/bpf/xdpxceiver.h
··· 39 39 #define SOCK_RECONF_CTR 10 40 40 #define BATCH_SIZE 64 41 41 #define POLL_TMOUT 1000 42 - #define DEFAULT_PKT_CNT 10000 42 + #define DEFAULT_PKT_CNT (4 * 1024) 43 43 #define RX_FULL_RXQSIZE 32 44 44 45 45 #define print_verbose(x...) do { if (opt_verbose) ksft_print_msg(x); } while (0) ··· 79 79 static bool second_step; 80 80 static int test_type; 81 81 82 - static int opt_pkt_count; 82 + static u32 opt_pkt_count = DEFAULT_PKT_CNT; 83 83 static u8 opt_verbose; 84 84 85 85 static u32 xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
+1 -2
tools/testing/selftests/bpf/xsk_prereqs.sh
··· 10 10 11 11 SPECFILE=veth.spec 12 12 XSKOBJ=xdpxceiver 13 - NUMPKTS=10000 14 13 15 14 validate_root_exec() 16 15 { ··· 91 92 92 93 execxdpxceiver() 93 94 { 94 - ./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} -C ${NUMPKTS} ${VERBOSE_ARG} ${DUMP_PKTS_ARG} 95 + ./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${VERBOSE_ARG} ${DUMP_PKTS_ARG} 95 96 }