Commit 8fa19341 authored by Alexei Starovoitov's avatar Alexei Starovoitov

Merge branch 'seltests-xsk-various-improvements-to-xskxceiver'

Magnus Karlsson says:

====================
seltests/xsk: various improvements to xskxceiver

This patch set implements several improvements to the xsk selftests
test suite that I thought were useful while debugging the xsk
multi-buffer code and tests. The largest new feature is the ability to
be able to execute a single test instead of the whole test suite. This
required some surgery on the current code, details below.

Anatomy of the path set:

1: Print useful info on a per packet basis with the option -v

2: Add a timeout in the transmission loop too. We only used to have
   one for the Rx thread, but Tx can lock up too waiting for
   completions.

3: Add an option (-m) to only run the tests (or a single test with a
   later patch) in a single mode: skb, drv, or zc (zero-copy).

4-5: Preparatory patches to be able to specify a test to run. Need to
     define the test names in a single structure and their entry
     points, so we can use this when wanting to run a specific test.

6: Adds a command line option (-l) that lists all the tests.

7: Adds a command line option (-t) that runs a specific test instead
   of the whole test suite. Can be combined with -m to specify a
   single mode too.

8: Use ksft_print_msg() uniformly throughout the tests. It was a mix
   of printf() and ksft_print_msg() before.

9: In some places, we failed the whole test suite instead of a single
   test in certain circumstances. Fix this so only the test in
   question is failed and the rest of the test suite continues.

10: Display the available command line options with -h

v3 -> v4:
* Fixed another spelling error in patch #9 [Maciej]
* Only allow the actual strings for the -m command [Maciej]
* Move some code from patch #7 to #3 [Maciej]

v2 -> v3:
* Drop the support for environment variables. Probably not useful. [Maciej]
* Fixed spelling mistake in patch #9 [Maciej]
* Fail gracefully if unsupported mode is chosen [Maciej]
* Simplified test run loop [Maciej]

v1 -> v2:

* Introduce XSKTEST_MODE env variable to be able to set the mode to
  use [Przemyslaw]
* Introduce XSKTEST_ETH env variable to be able to set the ethernet
  interface to use by introducing a new patch (#11) [Magnus]
* Fixed spelling error in patch #5 [Przemyslaw, Maciej]
* Fixed confusing documentation in patch #10  [Przemyslaw]
* The -l option can now be used without being root [Magnus, Maciej]
* Fixed documentation error in patch #7 [Maciej]
* Added error handling to the -t option [Maciej]
* -h now displayed as an option [Maciej]

Thanks: Magnus
====================
Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20230914084900.492-1-magnus.karlsson@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 558c50cc 4a5f0ba5
...@@ -73,17 +73,33 @@ ...@@ -73,17 +73,33 @@
# #
# Run test suite for physical device in loopback mode # Run test suite for physical device in loopback mode
# sudo ./test_xsk.sh -i IFACE # sudo ./test_xsk.sh -i IFACE
#
# Run test suite in a specific mode only [skb,drv,zc]
# sudo ./test_xsk.sh -m MODE
#
# 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
. xsk_prereqs.sh . xsk_prereqs.sh
ETH="" ETH=""
while getopts "vi:d" flag while getopts "vi:dm:lt:h" flag
do do
case "${flag}" in case "${flag}" in
v) verbose=1;; v) verbose=1;;
d) debug=1;; d) debug=1;;
i) ETH=${OPTARG};; i) ETH=${OPTARG};;
m) MODE=${OPTARG};;
l) list=1;;
t) TEST=${OPTARG};;
h) help=1;;
esac esac
done done
...@@ -131,6 +147,16 @@ setup_vethPairs() { ...@@ -131,6 +147,16 @@ setup_vethPairs() {
ip link set ${VETH0} up ip link set ${VETH0} up
} }
if [[ $list -eq 1 ]]; then
./${XSKOBJ} -l
exit
fi
if [[ $help -eq 1 ]]; then
./${XSKOBJ}
exit
fi
if [ ! -z $ETH ]; then if [ ! -z $ETH ]; then
VETH0=${ETH} VETH0=${ETH}
VETH1=${ETH} VETH1=${ETH}
...@@ -153,6 +179,14 @@ if [[ $verbose -eq 1 ]]; then ...@@ -153,6 +179,14 @@ if [[ $verbose -eq 1 ]]; then
ARGS+="-v " ARGS+="-v "
fi fi
if [ -n "$MODE" ]; then
ARGS+="-m ${MODE} "
fi
if [ -n "$TEST" ]; then
ARGS+="-t ${TEST} "
fi
retval=$? retval=$?
test_status $retval "${TEST_NAME}" test_status $retval "${TEST_NAME}"
...@@ -175,6 +209,10 @@ else ...@@ -175,6 +209,10 @@ else
cleanup_iface ${ETH} ${MTU} cleanup_iface ${ETH} ${MTU}
fi fi
if [[ $list -eq 1 ]]; then
exit
fi
TEST_NAME="XSK_SELFTESTS_${VETH0}_BUSY_POLL" TEST_NAME="XSK_SELFTESTS_${VETH0}_BUSY_POLL"
busy_poll=1 busy_poll=1
......
...@@ -83,9 +83,11 @@ exec_xskxceiver() ...@@ -83,9 +83,11 @@ exec_xskxceiver()
fi fi
./${XSKOBJ} -i ${VETH0} -i ${VETH1} ${ARGS} ./${XSKOBJ} -i ${VETH0} -i ${VETH1} ${ARGS}
retval=$? retval=$?
if [[ $list -ne 1 ]]; then
test_status $retval "${TEST_NAME}" test_status $retval "${TEST_NAME}"
statusList+=($retval) statusList+=($retval)
nameList+=(${TEST_NAME}) nameList+=(${TEST_NAME})
fi
} }
This diff is collapsed.
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef XSKXCEIVER_H_ #ifndef XSKXCEIVER_H_
#define XSKXCEIVER_H_ #define XSKXCEIVER_H_
#include <limits.h>
#include "xsk_xdp_progs.skel.h" #include "xsk_xdp_progs.skel.h"
#ifndef SOL_XDP #ifndef SOL_XDP
...@@ -34,7 +36,7 @@ ...@@ -34,7 +36,7 @@
#define MAX_INTERFACES 2 #define MAX_INTERFACES 2
#define MAX_INTERFACE_NAME_CHARS 16 #define MAX_INTERFACE_NAME_CHARS 16
#define MAX_SOCKETS 2 #define MAX_SOCKETS 2
#define MAX_TEST_NAME_SIZE 32 #define MAX_TEST_NAME_SIZE 48
#define MAX_TEARDOWN_ITER 10 #define MAX_TEARDOWN_ITER 10
#define PKT_HDR_SIZE (sizeof(struct ethhdr) + 2) /* Just to align the data in the packet */ #define PKT_HDR_SIZE (sizeof(struct ethhdr) + 2) /* Just to align the data in the packet */
#define MIN_PKT_SIZE 64 #define MIN_PKT_SIZE 64
...@@ -56,6 +58,7 @@ ...@@ -56,6 +58,7 @@
#define XSK_DESC__MAX_SKB_FRAGS 18 #define XSK_DESC__MAX_SKB_FRAGS 18
#define HUGEPAGE_SIZE (2 * 1024 * 1024) #define HUGEPAGE_SIZE (2 * 1024 * 1024)
#define PKT_DUMP_NB_TO_PRINT 16 #define PKT_DUMP_NB_TO_PRINT 16
#define RUN_ALL_TESTS UINT_MAX
#define print_verbose(x...) do { if (opt_verbose) ksft_print_msg(x); } while (0) #define print_verbose(x...) do { if (opt_verbose) ksft_print_msg(x); } while (0)
...@@ -63,43 +66,9 @@ enum test_mode { ...@@ -63,43 +66,9 @@ enum test_mode {
TEST_MODE_SKB, TEST_MODE_SKB,
TEST_MODE_DRV, TEST_MODE_DRV,
TEST_MODE_ZC, TEST_MODE_ZC,
TEST_MODE_MAX TEST_MODE_ALL
};
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
}; };
static bool opt_verbose;
struct xsk_umem_info { struct xsk_umem_info {
struct xsk_ring_prod fq; struct xsk_ring_prod fq;
struct xsk_ring_cons cq; struct xsk_ring_cons cq;
...@@ -139,8 +108,10 @@ struct pkt_stream { ...@@ -139,8 +108,10 @@ struct pkt_stream {
}; };
struct ifobject; struct ifobject;
struct test_spec;
typedef int (*validation_func_t)(struct ifobject *ifobj); typedef int (*validation_func_t)(struct ifobject *ifobj);
typedef void *(*thread_func_t)(void *arg); typedef void *(*thread_func_t)(void *arg);
typedef int (*test_func_t)(struct test_spec *test);
struct ifobject { struct ifobject {
char ifname[MAX_INTERFACE_NAME_CHARS]; char ifname[MAX_INTERFACE_NAME_CHARS];
...@@ -182,6 +153,7 @@ struct test_spec { ...@@ -182,6 +153,7 @@ struct test_spec {
struct bpf_program *xdp_prog_tx; struct bpf_program *xdp_prog_tx;
struct bpf_map *xskmap_rx; struct bpf_map *xskmap_rx;
struct bpf_map *xskmap_tx; struct bpf_map *xskmap_tx;
test_func_t test_func;
int mtu; int mtu;
u16 total_steps; u16 total_steps;
u16 current_step; u16 current_step;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment