Commit d3e3bf5b authored by Ciara Loftus's avatar Ciara Loftus Committed by Alexei Starovoitov

selftests/bpf: Restructure xsk selftests

Prior to this commit individual xsk tests were launched from the
shell script 'test_xsk.sh'. When adding a new test type, two new test
configurations had to be added to this file - one for each of the
supported XDP 'modes' (skb or drv). Should zero copy support be added to
the xsk selftest framework in the future, three new test configurations
would need to be added for each new test type. Each new test type also
typically requires new CLI arguments for the xdpxceiver program.

This commit aims to reduce the overhead of adding new tests, by launching
the test configurations from within the xdpxceiver program itself, using
simple loops. Every test is run every time the C program is executed. Many
of the CLI arguments can be removed as a result.
Signed-off-by: default avatarCiara Loftus <ciara.loftus@intel.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/bpf/20210223162304.7450-4-ciara.loftus@intel.com
parent d2b0dfd5
...@@ -152,117 +152,9 @@ test_status $retval "${TEST_NAME}" ...@@ -152,117 +152,9 @@ test_status $retval "${TEST_NAME}"
statusList=() statusList=()
### TEST 1 TEST_NAME="XSK KSELFTESTS"
TEST_NAME="XSK KSELFTEST FRAMEWORK"
if [[ $verbose -eq 1 ]]; then execxdpxceiver
echo "Switching interfaces [${VETH0}, ${VETH1}] to XDP Generic mode"
fi
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
retval=$?
if [ $retval -eq 0 ]; then
if [[ $verbose -eq 1 ]]; then
echo "Switching interfaces [${VETH0}, ${VETH1}] to XDP Native mode"
fi
vethXDPnative ${VETH0} ${VETH1} ${NS1}
fi
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 2
TEST_NAME="SKB NOPOLL"
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
params=("-S")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 3
TEST_NAME="SKB POLL"
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
params=("-S" "-p")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 4
TEST_NAME="DRV NOPOLL"
vethXDPnative ${VETH0} ${VETH1} ${NS1}
params=("-N")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 5
TEST_NAME="DRV POLL"
vethXDPnative ${VETH0} ${VETH1} ${NS1}
params=("-N" "-p")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 6
TEST_NAME="SKB SOCKET TEARDOWN"
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
params=("-S" "-T")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 7
TEST_NAME="DRV SOCKET TEARDOWN"
vethXDPnative ${VETH0} ${VETH1} ${NS1}
params=("-N" "-T")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 8
TEST_NAME="SKB BIDIRECTIONAL SOCKETS"
vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
params=("-S" "-B")
execxdpxceiver params
retval=$?
test_status $retval "${TEST_NAME}"
statusList+=($retval)
### TEST 9
TEST_NAME="DRV BIDIRECTIONAL SOCKETS"
vethXDPnative ${VETH0} ${VETH1} ${NS1}
params=("-N" "-B")
execxdpxceiver params
retval=$? retval=$?
test_status $retval "${TEST_NAME}" test_status $retval "${TEST_NAME}"
......
This diff is collapsed.
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#define BATCH_SIZE 64 #define BATCH_SIZE 64
#define POLL_TMOUT 1000 #define POLL_TMOUT 1000
#define NEED_WAKEUP true #define NEED_WAKEUP true
#define DEFAULT_PKT_CNT 10000
#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)
...@@ -48,28 +49,37 @@ typedef __u32 u32; ...@@ -48,28 +49,37 @@ typedef __u32 u32;
typedef __u16 u16; typedef __u16 u16;
typedef __u8 u8; typedef __u8 u8;
enum TESTS { enum TEST_MODES {
ORDER_CONTENT_VALIDATE_XDP_SKB = 0, TEST_MODE_UNCONFIGURED = -1,
ORDER_CONTENT_VALIDATE_XDP_DRV = 1, TEST_MODE_SKB,
TEST_MODE_DRV,
TEST_MODE_MAX
}; };
static u8 uut; enum TEST_TYPES {
TEST_TYPE_NOPOLL,
TEST_TYPE_POLL,
TEST_TYPE_TEARDOWN,
TEST_TYPE_BIDI,
TEST_TYPE_MAX
};
static int configured_mode = TEST_MODE_UNCONFIGURED;
static u8 debug_pkt_dump; static u8 debug_pkt_dump;
static u32 num_frames; static u32 num_frames;
static u8 switching_notify; static u8 switching_notify;
static u8 bidi_pass; static u8 bidi_pass;
static int test_type;
static u32 opt_xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
static int opt_queue; static int opt_queue;
static int opt_pkt_count; static int opt_pkt_count;
static int opt_poll;
static int opt_teardown;
static int opt_bidi;
static u32 opt_xdp_bind_flags = XDP_USE_NEED_WAKEUP;
static u8 opt_verbose; static u8 opt_verbose;
static u32 xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
static u32 xdp_bind_flags = XDP_USE_NEED_WAKEUP | XDP_COPY;
static u8 pkt_data[XSK_UMEM__DEFAULT_FRAME_SIZE]; static u8 pkt_data[XSK_UMEM__DEFAULT_FRAME_SIZE];
static u32 pkt_counter; static u32 pkt_counter;
static u32 prev_pkt = -1; static long prev_pkt = -1;
static int sigvar; static int sigvar;
struct xsk_umem_info { struct xsk_umem_info {
...@@ -140,8 +150,9 @@ pthread_t t0, t1, ns_thread; ...@@ -140,8 +150,9 @@ pthread_t t0, t1, ns_thread;
pthread_attr_t attr; pthread_attr_t attr;
struct targs { struct targs {
bool retptr; u8 retptr;
int idx; int idx;
u32 flags;
}; };
TAILQ_HEAD(head_s, pkt) head = TAILQ_HEAD_INITIALIZER(head); TAILQ_HEAD(head_s, pkt) head = TAILQ_HEAD_INITIALIZER(head);
......
...@@ -105,29 +105,7 @@ validate_ip_utility() ...@@ -105,29 +105,7 @@ validate_ip_utility()
[ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip 1; } [ ! $(type -P ip) ] && { echo "'ip' not found. Skipping tests."; test_exit $ksft_skip 1; }
} }
vethXDPgeneric()
{
ip link set dev $1 xdpdrv off
ip netns exec $3 ip link set dev $2 xdpdrv off
}
vethXDPnative()
{
ip link set dev $1 xdpgeneric off
ip netns exec $3 ip link set dev $2 xdpgeneric off
}
execxdpxceiver() execxdpxceiver()
{ {
local -a 'paramkeys=("${!'"$1"'[@]}")' copy ./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} -C ${NUMPKTS} ${VERBOSE_ARG} ${DUMP_PKTS_ARG}
paramkeysstr=${paramkeys[*]}
for index in $paramkeysstr;
do
current=$1"[$index]"
copy[$index]=${!current}
done
./${XSKOBJ} -i ${VETH0} -i ${VETH1},${NS1} ${copy[*]} -C ${NUMPKTS} ${VERBOSE_ARG} \
${DUMP_PKTS_ARG}
} }
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