On Fri, 20 Nov 2020 at 18:54, Yonghong Song yhs@fb.com wrote:
On 11/20/20 5:00 AM, Weqaar Janjua wrote:
Adds following tests:
- AF_XDP SKB mode Generic mode XDP is driver independent, used when the driver does not have support for XDP. Works on any netdevice using sockets and generic XDP path. XDP hook from netif_receive_skb(). a. nopoll - soft-irq processing b. poll - using poll() syscall
Signed-off-by: Weqaar Janjua weqaar.a.janjua@intel.com
tools/testing/selftests/bpf/Makefile | 5 +- .../selftests/bpf/test_xsk_prerequisites.sh | 15 +- .../selftests/bpf/test_xsk_skb_nopoll.sh | 20 + ..._xsk_framework.sh => test_xsk_skb_poll.sh} | 12 +- tools/testing/selftests/bpf/xdpxceiver.c | 961 ++++++++++++++++++ tools/testing/selftests/bpf/xdpxceiver.h | 151 +++ tools/testing/selftests/bpf/xsk_env.sh | 17 + 7 files changed, 1174 insertions(+), 7 deletions(-) create mode 100755 tools/testing/selftests/bpf/test_xsk_skb_nopoll.sh rename tools/testing/selftests/bpf/{test_xsk_framework.sh => test_xsk_skb_poll.sh} (61%) create mode 100644 tools/testing/selftests/bpf/xdpxceiver.c create mode 100644 tools/testing/selftests/bpf/xdpxceiver.h
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 51436db24f32..17af570a32d7 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -73,7 +73,8 @@ TEST_PROGS := test_kmod.sh \ test_bpftool.sh \ test_bpftool_metadata.sh \ test_xsk_prerequisites.sh \
test_xsk_framework.sh
test_xsk_skb_nopoll.sh \
test_xsk_skb_poll.sh
TEST_PROGS_EXTENDED := with_addr.sh \ with_tunnels.sh \
@@ -84,7 +85,7 @@ TEST_PROGS_EXTENDED := with_addr.sh \ # Compile but not part of 'make run_tests' TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \ flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \
test_lirc_mode2_user xdping test_cpp runqslower bench
test_lirc_mode2_user xdping test_cpp runqslower bench xdpxceiver
TEST_CUSTOM_PROGS = urandom_read
diff --git a/tools/testing/selftests/bpf/test_xsk_prerequisites.sh b/tools/testing/selftests/bpf/test_xsk_prerequisites.sh index 00bfcf53127c..a9ce8887dffc 100755 --- a/tools/testing/selftests/bpf/test_xsk_prerequisites.sh +++ b/tools/testing/selftests/bpf/test_xsk_prerequisites.sh @@ -8,8 +8,17 @@ # # Topology: # --------- -# ----------- ----------- -# | xskX | --------- | xskY | +# ----------- +# _ | Process | _ +# / ----------- \ +# / | \ +# / | \ +# ----------- | ----------- +# | Thread1 | | | Thread2 | +# ----------- | ----------- +# | | | +# ----------- | ----------- +# | xskX | | | xskY | # ----------- | ----------- # | | | # ----------- | ---------- @@ -40,6 +49,8 @@ # conflict with any existing interface # * tests the veth and xsk layers of the topology # +# See the source xdpxceiver.c for information on each test +# # Kernel configuration: # --------------------- # See "config" file for recommended kernel config options. diff --git a/tools/testing/selftests/bpf/test_xsk_skb_nopoll.sh b/tools/testing/selftests/bpf/test_xsk_skb_nopoll.sh new file mode 100755 index 000000000000..96600b0f5136 --- /dev/null +++ b/tools/testing/selftests/bpf/test_xsk_skb_nopoll.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright(c) 2020 Intel Corporation.
+# See test_xsk_prerequisites.sh for detailed information on tests
+. xsk_prereqs.sh +. xsk_env.sh
+TEST_NAME="SKB NOPOLL"
+vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
+params=("-S") +execxdpxceiver params
+retval=$? +test_status $retval "${TEST_NAME}"
+test_exit $retval 0 diff --git a/tools/testing/selftests/bpf/test_xsk_framework.sh b/tools/testing/selftests/bpf/test_xsk_skb_poll.sh similarity index 61% rename from tools/testing/selftests/bpf/test_xsk_framework.sh rename to tools/testing/selftests/bpf/test_xsk_skb_poll.sh index 2e3f099d001c..d152c8a24251 100755 --- a/tools/testing/selftests/bpf/test_xsk_framework.sh +++ b/tools/testing/selftests/bpf/test_xsk_skb_poll.sh @@ -7,11 +7,17 @@ . xsk_prereqs.sh . xsk_env.sh
Here both xsk_prereqs.sh and xsk_env.sh are executed. But xsk_env.sh also calls xsk_prereqs.sh. This double execution of xsk_prereqs.sh is required or is an oversight?
Oversight, will fix as v3 - in all 5/5 test_xsk_*.sh, thanks
-TEST_NAME="XSK FRAMEWORK" +TEST_NAME="SKB POLL"
-test_status $ksft_pass "${TEST_NAME}" +vethXDPgeneric ${VETH0} ${VETH1} ${NS1}
+params=("-S" "-p") +execxdpxceiver params
+retval=$? +test_status $retval "${TEST_NAME}"
# Must be called in the last test to execute cleanup_exit ${VETH0} ${VETH1} ${NS1}
-test_exit $ksft_pass 0 +test_exit $retval 0 diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
[...]