Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seltests/xsk: various improvements to xskxceiver #5669

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: seltests/xsk: various improvements to xskxceiver
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5bbb9e1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5bbb9e1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5bbb9e1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 558c50c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 558c50c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 558c50c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=783739
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 558c50c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=784071
version: 4

Print info about every packet in verbose mode, both for Tx and
Rx. This is useful to have when a test fails or to validate that a
test is really doing what it was designed to do. Info on what is
supposed to be received and sent is also printed for the custom packet
streams since they differ from the base line. Here is an example:

Tx addr: 37e0 len: 64 options: 0 pkt_nb: 8
Tx addr: 4000 len: 64 options: 0 pkt_nb: 9
Rx: addr: 100 len: 64 options: 0 pkt_nb: 0 valid: 1
Rx: addr: 1100 len: 64 options: 0 pkt_nb: 1 valid: 1
Rx: addr: 2100 len: 64 options: 0 pkt_nb: 4 valid: 1
Rx: addr: 3100 len: 64 options: 0 pkt_nb: 8 valid: 1
Rx: addr: 4100 len: 64 options: 0 pkt_nb: 9 valid: 1

One pointless verbose print statement is also deleted and another one
is made clearer.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Add a timeout for the transmission thread. If packets are not
completed properly, for some reason, the test harness would previously
get stuck forever in a while loop. But with this patch, this timeout
will trigger, flag the test as a failure, and continue with the next
test.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Add an option -m on the command line that allows the user to run the
tests in a single mode instead of all of them. Valid modes are skb,
drv, and zc (zero-copy). An example:

To run test suite in drv mode only:

./test_xsk.sh -m drv

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Prepare for the capability to be able to run a single test by moving
all the tests to their own functions. This function can then be called
to execute that test in the next commit.

Also, the tests named RUN_TO_COMPLETION_* were not named well, so
change them to SEND_RECEIVE_* as it is just a basic send and receive
test of 4K packets.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Declare the test names statically in a struct so that we can refer to
them when adding the support to execute a single test in the next
commit. Before this patch, the names of them were not declared in a
single place which made it not possible to refer to them.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Add a command line option (-l) that lists all the tests. The number
before the test will be used in the next commit for specifying a
single test to run. Here is an example of the output:

Tests:
0: SEND_RECEIVE
1: SEND_RECEIVE_2K_FRAME
2: SEND_RECEIVE_SINGLE_PKT
3: POLL_RX
4: POLL_TX
5: POLL_RXQ_FULL
6: POLL_TXQ_FULL
7: SEND_RECEIVE_UNALIGNED
:
:

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Add a command line option to be able to run a single test. This option
(-t) takes a number from the list of tests available with the "-l"
option. Here are two examples:

Run test number 2, the "receive single packet" test in all available modes:

./test_xsk.sh -t 2

Run test number 21, the metadata copy test in skb mode only

./test_xsh.sh -t 21 -m skb

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Use ksft_print_msg() instead of printf() and fprintf() in all places
as the ksefltests framework is being used. There is only one exception
and that is for the list-of-tests print out option, since no tests are
run in that case.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
In a number of places at en error, exit_with_error() is called that
terminates the whole test suite. This is not always desirable as it
would be more logical to only fail that test and then go along with
the other ones. So change this in a number of places in which I
thought it would be more logical to just fail the test in
question. Examples of this are in code that is only used by a single
test.

Also delete a pointless if-statement in receive_pkts() that has an
exit_with_error() in it. It can never occur since the return value is
an unsigned and the test is for less than zero.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Add the -h option to display all available command line options
available for test_xsk.sh and xskxceiver.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 558c50c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=784071
version: 4

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 8fa1934
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=784071
version: 4

Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/netdevbpf/list/?series=784071
error message:

Cmd('git') failed due to: exit code(128)
  cmdline: git am --3way
  stdout: 'Applying: selftests/xsk: print per packet info in verbose mode
Using index info to reconstruct a base tree...
M	tools/testing/selftests/bpf/xskxceiver.c
Falling back to patching base and 3-way merge...
Auto-merging tools/testing/selftests/bpf/xskxceiver.c
No changes -- Patch already applied.
Applying: selftests/xsk: add timeout for Tx thread
Using index info to reconstruct a base tree...
M	tools/testing/selftests/bpf/xskxceiver.c
Falling back to patching base and 3-way merge...
Auto-merging tools/testing/selftests/bpf/xskxceiver.c
No changes -- Patch already applied.
Applying: selftests/xsk: add option to only run tests in a single mode
Using index info to reconstruct a base tree...
M	tools/testing/selftests/bpf/test_xsk.sh
M	tools/testing/selftests/bpf/xskxceiver.c
M	tools/testing/selftests/bpf/xskxceiver.h
Falling back to patching base and 3-way merge...
Auto-merging tools/testing/selftests/bpf/xskxceiver.h
CONFLICT (content): Merge conflict in tools/testing/selftests/bpf/xskxceiver.h
Auto-merging tools/testing/selftests/bpf/xskxceiver.c
CONFLICT (content): Merge conflict in tools/testing/selftests/bpf/xskxceiver.c
Auto-merging tools/testing/selftests/bpf/test_xsk.sh
CONFLICT (content): Merge conflict in tools/testing/selftests/bpf/test_xsk.sh
Patch failed at 0003 selftests/xsk: add option to only run tests in a single mode
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".'
  stderr: 'error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch'

conflict:

diff --cc tools/testing/selftests/bpf/test_xsk.sh
index 65aafe0003db,85e7a7e843f7..000000000000
--- a/tools/testing/selftests/bpf/test_xsk.sh
+++ b/tools/testing/selftests/bpf/test_xsk.sh
@@@ -76,30 -76,18 +76,40 @@@
  #
  # Run test suite in a specific mode only [skb,drv,zc]
  #   sudo ./test_xsk.sh -m MODE
++<<<<<<< HEAD
 +#
 +# List available tests
 +#   ./test_xsk.sh -l
 +#
 +# Run a specific test from the test suite
 +#   sudo ./test_xsk.sh -t TEST_NAME
 +#
 +# Display the available command line options
 +#   ./test_xsk.sh -h
++=======
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  
  . xsk_prereqs.sh
  
  ETH=""
  
++<<<<<<< HEAD
 +while getopts "vi:dm:lt:h" flag
++=======
+ while getopts "vi:dm:" flag
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  do
  	case "${flag}" in
  		v) verbose=1;;
  		d) debug=1;;
  		i) ETH=${OPTARG};;
  		m) MODE=${OPTARG};;
++<<<<<<< HEAD
 +		l) list=1;;
 +		t) TEST=${OPTARG};;
 +		h) help=1;;
++=======
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  	esac
  done
  
@@@ -183,10 -161,6 +193,13 @@@ if [ -n "$MODE" ]; the
  	ARGS+="-m ${MODE} "
  fi
  
++<<<<<<< HEAD
 +if [ -n "$TEST" ]; then
 +	ARGS+="-t ${TEST} "
 +fi
 +
++=======
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  retval=$?
  test_status $retval "${TEST_NAME}"
  
diff --cc tools/testing/selftests/bpf/xskxceiver.c
index 43e0a5796929,64a671fca54a..000000000000
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@@ -108,9 -108,7 +108,13 @@@ static const char *MAC1 = "\x00\x0A\x56
  static const char *MAC2 = "\x00\x0A\x56\x9E\xEE\x61";
  
  static bool opt_verbose;
++<<<<<<< HEAD
 +static bool opt_print_tests;
  static enum test_mode opt_mode = TEST_MODE_ALL;
 +static u32 opt_run_test = RUN_ALL_TESTS;
++=======
++static enum test_mode opt_mode = TEST_MODE_ALL;
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  
  static void __exit_with_error(int error, const char *file, const char *func, int line)
  {
@@@ -316,9 -314,6 +320,12 @@@ static struct option long_options[] = 
  	{"busy-poll", no_argument, 0, 'b'},
  	{"verbose", no_argument, 0, 'v'},
  	{"mode", required_argument, 0, 'm'},
++<<<<<<< HEAD
 +	{"list", no_argument, 0, 'l'},
 +	{"test", required_argument, 0, 't'},
 +	{"help", no_argument, 0, 'h'},
++=======
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  	{0, 0, 0, 0}
  };
  
@@@ -330,13 -325,9 +337,17 @@@ static void print_usage(char **argv
  		"  -i, --interface      Use interface\n"
  		"  -v, --verbose        Verbose output\n"
  		"  -b, --busy-poll      Enable busy poll\n"
++<<<<<<< HEAD
 +		"  -m, --mode           Run only mode skb, drv, or zc\n"
 +		"  -l, --list           List all available tests\n"
 +		"  -t, --test           Run a specific test. Enter number from -l option.\n"
 +		"  -h, --help           Display this help and exit\n";
++=======
+ 		"  -m, --mode           Run only mode skb, drv, or zc\n";
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  
 -	ksft_print_msg(str, prog);
 +	ksft_print_msg(str, basename(argv[0]));
 +	ksft_exit_xfail();
  }
  
  static bool validate_interface(struct ifobject *ifobj)
@@@ -356,7 -347,7 +367,11 @@@ static void parse_command_line(struct i
  	opterr = 0;
  
  	for (;;) {
++<<<<<<< HEAD
 +		c = getopt_long(argc, argv, "i:vbm:lt:", long_options, &option_index);
++=======
+ 		c = getopt_long(argc, argv, "i:vbm:", long_options, &option_index);
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  		if (c == -1)
  			break;
  
@@@ -386,27 -377,20 +401,41 @@@
  			ifobj_rx->busy_poll = true;
  			break;
  		case 'm':
++<<<<<<< HEAD
 +			if (!strncmp("skb", optarg, strlen(optarg)))
 +				opt_mode = TEST_MODE_SKB;
 +			else if (!strncmp("drv", optarg, strlen(optarg)))
 +				opt_mode = TEST_MODE_DRV;
 +			else if (!strncmp("zc", optarg, strlen(optarg)))
 +				opt_mode = TEST_MODE_ZC;
 +			else
 +				print_usage(argv);
 +			break;
 +		case 'l':
 +			opt_print_tests = true;
 +			break;
 +		case 't':
 +			errno = 0;
 +			opt_run_test = strtol(optarg, NULL, 0);
 +			if (errno)
 +				print_usage(argv);
 +			break;
 +		case 'h':
++=======
+ 			if (!strncmp("skb", optarg, strlen(optarg))) {
+ 				opt_mode = TEST_MODE_SKB;
+ 			} else if (!strncmp("drv", optarg, strlen(optarg))) {
+ 				opt_mode = TEST_MODE_DRV;
+ 			} else if (!strncmp("zc", optarg, strlen(optarg))) {
+ 				opt_mode = TEST_MODE_ZC;
+ 			} else {
+ 				usage(basename(argv[0]));
+ 				ksft_exit_xfail();
+ 			}
+ 			break;
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  		default:
 -			usage(basename(argv[0]));
 -			ksft_exit_xfail();
 +			print_usage(argv);
  		}
  	}
  }
@@@ -2412,12 -2382,8 +2441,17 @@@ int main(int argc, char **argv
  	test.tx_pkt_stream_default = tx_pkt_stream_default;
  	test.rx_pkt_stream_default = rx_pkt_stream_default;
  
++<<<<<<< HEAD
 +	if (opt_run_test == RUN_ALL_TESTS)
 +		nb_tests = ARRAY_SIZE(tests);
 +	else
 +		nb_tests = 1;
 +	if (opt_mode == TEST_MODE_ALL) {
 +		ksft_set_plan(modes * nb_tests);
++=======
+ 	if (opt_mode == TEST_MODE_ALL) {
+ 		ksft_set_plan(modes * TEST_TYPE_MAX);
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  	} else {
  		if (opt_mode == TEST_MODE_DRV && modes <= TEST_MODE_DRV) {
  			ksft_print_msg("Error: XDP_DRV mode not supported.\n");
@@@ -2428,19 -2394,16 +2462,29 @@@
  			ksft_exit_xfail();
  		}
  
++<<<<<<< HEAD
 +		ksft_set_plan(nb_tests);
++=======
+ 		ksft_set_plan(TEST_TYPE_MAX);
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  	}
  
  	for (i = 0; i < modes; i++) {
  		if (opt_mode != TEST_MODE_ALL && i != opt_mode)
  			continue;
  
++<<<<<<< HEAD
 +		for (j = 0; j < ARRAY_SIZE(tests); j++) {
 +			if (opt_run_test != RUN_ALL_TESTS && j != opt_run_test)
 +				continue;
 +
 +			test_spec_init(&test, ifobj_tx, ifobj_rx, i, &tests[j]);
 +			run_pkt_test(&test);
++=======
+ 		for (j = 0; j < TEST_TYPE_MAX; j++) {
+ 			test_spec_init(&test, ifobj_tx, ifobj_rx, i);
+ 			run_pkt_test(&test, i, j);
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  			usleep(USLEEP_MAX);
  
  			if (test.fail)
diff --cc tools/testing/selftests/bpf/xskxceiver.h
index 8015aeea839d,1412492e9618..000000000000
--- a/tools/testing/selftests/bpf/xskxceiver.h
+++ b/tools/testing/selftests/bpf/xskxceiver.h
@@@ -67,6 -64,38 +67,41 @@@ enum test_mode 
  	TEST_MODE_DRV,
  	TEST_MODE_ZC,
  	TEST_MODE_ALL
++<<<<<<< HEAD
++=======
+ };
+ 
+ enum test_type {
+ 	TEST_TYPE_RUN_TO_COMPLETION,
+ 	TEST_TYPE_RUN_TO_COMPLETION_2K_FRAME,
+ 	TEST_TYPE_RUN_TO_COMPLETION_SINGLE_PKT,
+ 	TEST_TYPE_RX_POLL,
+ 	TEST_TYPE_TX_POLL,
+ 	TEST_TYPE_POLL_RXQ_TMOUT,
+ 	TEST_TYPE_POLL_TXQ_TMOUT,
+ 	TEST_TYPE_UNALIGNED,
+ 	TEST_TYPE_ALIGNED_INV_DESC,
+ 	TEST_TYPE_ALIGNED_INV_DESC_2K_FRAME,
+ 	TEST_TYPE_UNALIGNED_INV_DESC,
+ 	TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME,
+ 	TEST_TYPE_HEADROOM,
+ 	TEST_TYPE_TEARDOWN,
+ 	TEST_TYPE_BIDI,
+ 	TEST_TYPE_STATS_RX_DROPPED,
+ 	TEST_TYPE_STATS_TX_INVALID_DESCS,
+ 	TEST_TYPE_STATS_RX_FULL,
+ 	TEST_TYPE_STATS_FILL_EMPTY,
+ 	TEST_TYPE_BPF_RES,
+ 	TEST_TYPE_XDP_DROP_HALF,
+ 	TEST_TYPE_XDP_METADATA_COUNT,
+ 	TEST_TYPE_XDP_METADATA_COUNT_MB,
+ 	TEST_TYPE_RUN_TO_COMPLETION_MB,
+ 	TEST_TYPE_UNALIGNED_MB,
+ 	TEST_TYPE_ALIGNED_INV_DESC_MB,
+ 	TEST_TYPE_UNALIGNED_INV_DESC_MB,
+ 	TEST_TYPE_TOO_MANY_FRAGS,
+ 	TEST_TYPE_MAX
++>>>>>>> selftests/xsk: add option to only run tests in a single mode
  };
  
  struct xsk_umem_info {

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=784071 irrelevant now. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant