summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/xdpxceiver.c
diff options
context:
space:
mode:
authorWeqaar Janjua <weqaar.janjua@gmail.com>2020-12-07 21:53:31 +0000
committerDaniel Borkmann <daniel@iogearbox.net>2020-12-09 16:44:45 +0100
commit9103a8594d9324d8e1512442ba580e4e91d42c2d (patch)
tree4a880824b12765b2bac99a2af13a7d50f6f76c9f /tools/testing/selftests/bpf/xdpxceiver.c
parentfacb7cb2e909ad2d21ebbfdc051726d4cd8f1d35 (diff)
selftests/bpf: Xsk selftests - DRV POLL, NOPOLL
Adds following tests: 2. AF_XDP DRV/Native mode Works on any netdevice with XDP_REDIRECT support, driver dependent. Processes packets before SKB allocation. Provides better performance than SKB. Driver hook available just after DMA of buffer descriptor. a. nopoll b. poll * Only copy mode is supported because veth does not currently support zero-copy mode Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Tested-by: Yonghong Song <yhs@fb.com> Acked-by: Björn Töpel <bjorn.topel@intel.com> Link: https://lore.kernel.org/bpf/20201207215333.11586-4-weqaar.a.janjua@intel.com
Diffstat (limited to 'tools/testing/selftests/bpf/xdpxceiver.c')
-rw-r--r--tools/testing/selftests/bpf/xdpxceiver.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c
index 3f2a65b6a9f5..9fcd80a38b07 100644
--- a/tools/testing/selftests/bpf/xdpxceiver.c
+++ b/tools/testing/selftests/bpf/xdpxceiver.c
@@ -27,7 +27,16 @@
* a. nopoll - soft-irq processing
* b. poll - using poll() syscall
*
- * Total tests: 2
+ * 2. AF_XDP DRV/Native mode
+ * Works on any netdevice with XDP_REDIRECT support, driver dependent. Processes
+ * packets before SKB allocation. Provides better performance than SKB. Driver
+ * hook available just after DMA of buffer descriptor.
+ * a. nopoll
+ * b. poll
+ * - Only copy mode is supported because veth does not currently support
+ * zero-copy mode
+ *
+ * Total tests: 4
*
* Flow:
* -----
@@ -88,7 +97,7 @@ static void __exit_with_error(int error, const char *file, const char *func, int
#define exit_with_error(error) __exit_with_error(error, __FILE__, __func__, __LINE__)
#define print_ksft_result(void)\
- (ksft_test_result_pass("PASS: %s %s\n", uut ? "" : "SKB", opt_poll ? "POLL" : "NOPOLL"))
+ (ksft_test_result_pass("PASS: %s %s\n", uut ? "DRV" : "SKB", opt_poll ? "POLL" : "NOPOLL"))
static void pthread_init_mutex(void)
{
@@ -311,6 +320,7 @@ static struct option long_options[] = {
{"queue", optional_argument, 0, 'q'},
{"poll", no_argument, 0, 'p'},
{"xdp-skb", no_argument, 0, 'S'},
+ {"xdp-native", no_argument, 0, 'N'},
{"copy", no_argument, 0, 'c'},
{"debug", optional_argument, 0, 'D'},
{"tx-pkt-count", optional_argument, 0, 'C'},
@@ -326,6 +336,7 @@ static void usage(const char *prog)
" -q, --queue=n Use queue n (default 0)\n"
" -p, --poll Use poll syscall\n"
" -S, --xdp-skb=n Use XDP SKB mode\n"
+ " -N, --xdp-native=n Enforce XDP DRV (native) mode\n"
" -c, --copy Force copy mode\n"
" -D, --debug Debug mode - dump packets L2 - L5\n"
" -C, --tx-pkt-count=n Number of packets to send\n";
@@ -417,7 +428,7 @@ static void parse_command_line(int argc, char **argv)
opterr = 0;
for (;;) {
- c = getopt_long(argc, argv, "i:q:pScDC:", long_options, &option_index);
+ c = getopt_long(argc, argv, "i:q:pSNcDC:", long_options, &option_index);
if (c == -1)
break;
@@ -448,6 +459,11 @@ static void parse_command_line(int argc, char **argv)
opt_xdp_bind_flags |= XDP_COPY;
uut = ORDER_CONTENT_VALIDATE_XDP_SKB;
break;
+ case 'N':
+ opt_xdp_flags |= XDP_FLAGS_DRV_MODE;
+ opt_xdp_bind_flags |= XDP_COPY;
+ uut = ORDER_CONTENT_VALIDATE_XDP_DRV;
+ break;
case 'c':
opt_xdp_bind_flags |= XDP_COPY;
break;