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 #define MAX_BPF_STACK_SIZE 0x200 12 13 struct rte_bpf { 14 struct rte_bpf_prm prm; 15 struct rte_bpf_jit jit; 16 size_t sz; 17 uint32_t stack_sz; 18 }; 19 20 extern int bpf_validate(struct rte_bpf *bpf); 21 22 extern int bpf_jit(struct rte_bpf *bpf); 23 24 extern int bpf_jit_x86(struct rte_bpf *); 25 extern int bpf_jit_arm64(struct rte_bpf *); 26 27 extern int rte_bpf_logtype; 28 29 #define RTE_BPF_LOG(lvl, fmt, args...) \ 30 rte_log(RTE_LOG_## lvl, rte_bpf_logtype, fmt, ##args) 31 32 static inline size_t 33 bpf_size(uint32_t bpf_op_sz) 34 { 35 if (bpf_op_sz == BPF_B) 36 return sizeof(uint8_t); 37 else if (bpf_op_sz == BPF_H) 38 return sizeof(uint16_t); 39 else if (bpf_op_sz == BPF_W) 40 return sizeof(uint32_t); 41 else if (bpf_op_sz == EBPF_DW) 42 return sizeof(uint64_t); 43 return 0; 44 } 45 46 #endif /* _BPF_H_ */ 47