1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation.
5 #ifdef RTE_NET_AF_XDP_LIBXDP
11 #include <linux/version.h>
14 #if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
15 defined(RTE_NET_AF_XDP_SHARED_UMEM)
16 #define ETH_AF_XDP_SHARED_UMEM 1
19 #ifdef ETH_AF_XDP_SHARED_UMEM
20 static __rte_always_inline int
21 create_shared_socket(struct xsk_socket **xsk_ptr,
23 __u32 queue_id, struct xsk_umem *umem,
24 struct xsk_ring_cons *rx,
25 struct xsk_ring_prod *tx,
26 struct xsk_ring_prod *fill,
27 struct xsk_ring_cons *comp,
28 const struct xsk_socket_config *config)
30 return xsk_socket__create_shared(xsk_ptr, ifname, queue_id, umem, rx,
31 tx, fill, comp, config);
34 static __rte_always_inline int
35 create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
36 const char *ifname __rte_unused,
37 __u32 queue_id __rte_unused,
38 struct xsk_umem *umem __rte_unused,
39 struct xsk_ring_cons *rx __rte_unused,
40 struct xsk_ring_prod *tx __rte_unused,
41 struct xsk_ring_prod *fill __rte_unused,
42 struct xsk_ring_cons *comp __rte_unused,
43 const struct xsk_socket_config *config __rte_unused)
49 #ifdef XDP_USE_NEED_WAKEUP
51 tx_syscall_needed(struct xsk_ring_prod *q)
53 return xsk_ring_prod__needs_wakeup(q);
57 tx_syscall_needed(struct xsk_ring_prod *q __rte_unused)
63 #ifdef RTE_NET_AF_XDP_LIBBPF_OBJ_OPEN
64 static int load_program(const char *prog_path, struct bpf_object **obj)
66 struct bpf_program *prog;
69 *obj = bpf_object__open_file(prog_path, NULL);
70 err = libbpf_get_error(*obj);
74 err = bpf_object__load(*obj);
78 prog = bpf_object__next_program(*obj, NULL);
82 return bpf_program__fd(prog);
85 bpf_object__close(*obj);
89 static int load_program(const char *prog_path, struct bpf_object **obj)
93 ret = bpf_prog_load(prog_path, BPF_PROG_TYPE_XDP, obj, &prog_fd);