]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/lib/librte_bpf/bpf_impl.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / lib / librte_bpf / bpf_impl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
3 */
4
5 #ifndef _BPF_H_
6 #define _BPF_H_
7
8 #include <rte_bpf.h>
9 #include <sys/mman.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 #define MAX_BPF_STACK_SIZE 0x200
16
17 struct rte_bpf {
18 struct rte_bpf_prm prm;
19 struct rte_bpf_jit jit;
20 size_t sz;
21 uint32_t stack_sz;
22 };
23
24 extern int bpf_validate(struct rte_bpf *bpf);
25
26 extern int bpf_jit(struct rte_bpf *bpf);
27
28 #ifdef RTE_ARCH_X86_64
29 extern int bpf_jit_x86(struct rte_bpf *);
30 #endif
31
32 extern int rte_bpf_logtype;
33
34 #define RTE_BPF_LOG(lvl, fmt, args...) \
35 rte_log(RTE_LOG_## lvl, rte_bpf_logtype, fmt, ##args)
36
37 static inline size_t
38 bpf_size(uint32_t bpf_op_sz)
39 {
40 if (bpf_op_sz == BPF_B)
41 return sizeof(uint8_t);
42 else if (bpf_op_sz == BPF_H)
43 return sizeof(uint16_t);
44 else if (bpf_op_sz == BPF_W)
45 return sizeof(uint32_t);
46 else if (bpf_op_sz == EBPF_DW)
47 return sizeof(uint64_t);
48 return 0;
49 }
50
51 #ifdef __cplusplus
52 }
53 #endif
54
55 #endif /* _BPF_H_ */