1 /* SPDX-License-Identifier: GPL-2.0
2 * Copyright(c) 2020 Intel Corporation.
8 #include "xsk_xdp_progs.skel.h"
22 #ifndef SO_BUSY_POLL_BUDGET
23 #define SO_BUSY_POLL_BUDGET 70
26 #ifndef SO_PREFER_BUSY_POLL
27 #define SO_PREFER_BUSY_POLL 69
31 #define TEST_FAILURE -1
32 #define TEST_CONTINUE 1
33 #define MAX_INTERFACES 2
34 #define MAX_INTERFACE_NAME_CHARS 16
36 #define MAX_TEST_NAME_SIZE 32
37 #define MAX_TEARDOWN_ITER 10
38 #define PKT_HDR_SIZE (sizeof(struct ethhdr) + 2) /* Just to align the data in the packet */
39 #define MIN_PKT_SIZE 64
40 #define USLEEP_MAX 10000
41 #define SOCK_RECONF_CTR 10
43 #define POLL_TMOUT 1000
44 #define THREAD_TMOUT 3
45 #define DEFAULT_PKT_CNT (4 * 1024)
46 #define DEFAULT_UMEM_BUFFERS (DEFAULT_PKT_CNT / 4)
47 #define RX_FULL_RXQSIZE 32
48 #define UMEM_HEADROOM_TEST_SIZE 128
49 #define XSK_UMEM__INVALID_FRAME_SIZE (XSK_UMEM__DEFAULT_FRAME_SIZE + 1)
50 #define HUGEPAGE_SIZE (2 * 1024 * 1024)
51 #define PKT_DUMP_NB_TO_PRINT 16
53 #define print_verbose(x...) do { if (opt_verbose) ksft_print_msg(x); } while (0)
63 TEST_TYPE_RUN_TO_COMPLETION,
64 TEST_TYPE_RUN_TO_COMPLETION_2K_FRAME,
65 TEST_TYPE_RUN_TO_COMPLETION_SINGLE_PKT,
68 TEST_TYPE_POLL_RXQ_TMOUT,
69 TEST_TYPE_POLL_TXQ_TMOUT,
71 TEST_TYPE_ALIGNED_INV_DESC,
72 TEST_TYPE_ALIGNED_INV_DESC_2K_FRAME,
73 TEST_TYPE_UNALIGNED_INV_DESC,
74 TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME,
78 TEST_TYPE_STATS_RX_DROPPED,
79 TEST_TYPE_STATS_TX_INVALID_DESCS,
80 TEST_TYPE_STATS_RX_FULL,
81 TEST_TYPE_STATS_FILL_EMPTY,
83 TEST_TYPE_XDP_DROP_HALF,
84 TEST_TYPE_XDP_METADATA_COUNT,
88 static bool opt_verbose;
90 struct xsk_umem_info {
91 struct xsk_ring_prod fq;
92 struct xsk_ring_cons cq;
93 struct xsk_umem *umem;
103 struct xsk_socket_info {
104 struct xsk_ring_cons rx;
105 struct xsk_ring_prod tx;
106 struct xsk_umem_info *umem;
107 struct xsk_socket *xsk;
126 typedef int (*validation_func_t)(struct ifobject *ifobj);
127 typedef void *(*thread_func_t)(void *arg);
130 char ifname[MAX_INTERFACE_NAME_CHARS];
131 struct xsk_socket_info *xsk;
132 struct xsk_socket_info *xsk_arr;
133 struct xsk_umem_info *umem;
134 thread_func_t func_ptr;
135 validation_func_t validation_func;
136 struct pkt_stream *pkt_stream;
137 struct xsk_xdp_progs *xdp_progs;
138 struct bpf_map *xskmap;
139 struct bpf_program *xdp_prog;
151 u8 dst_mac[ETH_ALEN];
152 u8 src_mac[ETH_ALEN];
156 struct ifobject *ifobj_tx;
157 struct ifobject *ifobj_rx;
158 struct pkt_stream *tx_pkt_stream_default;
159 struct pkt_stream *rx_pkt_stream_default;
160 struct bpf_program *xdp_prog_rx;
161 struct bpf_program *xdp_prog_tx;
162 struct bpf_map *xskmap_rx;
163 struct bpf_map *xskmap_tx;
169 char name[MAX_TEST_NAME_SIZE];
172 pthread_barrier_t barr;
173 pthread_mutex_t pacing_mutex = PTHREAD_MUTEX_INITIALIZER;
174 pthread_cond_t pacing_cond = PTHREAD_COND_INITIALIZER;
178 #endif /* XSKXCEIVER_H_ */