numam-dpdk/lib/bpf/bpf_impl.h
David Marchand 63f39a430a bpf: fix build with some libpcap version on FreeBSD
This is something caught in UNH FreeBSD env.

For some reason [1], the pcap/bpf.h header started to define _BPF_H_.

It happens that the bpf_impl.h internal DPDK header uses this define as
an internal guard.
This triggers a build failure in bpf_convert.c which can't find
RTE_BPF_LOG macro.

Fix the include guard to use the filename and remove _.

1: https://github.com/the-tcpdump-group/libpcap/pull/1074

Fixes: 94972f35a0 ("bpf: add BPF loading and execution framework")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
2022-03-14 11:41:52 +01:00

47 lines
921 B
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2018 Intel Corporation
*/
#ifndef BPF_IMPL_H
#define BPF_IMPL_H
#include <rte_bpf.h>
#include <sys/mman.h>
#define MAX_BPF_STACK_SIZE 0x200
struct rte_bpf {
struct rte_bpf_prm prm;
struct rte_bpf_jit jit;
size_t sz;
uint32_t stack_sz;
};
extern int bpf_validate(struct rte_bpf *bpf);
extern int bpf_jit(struct rte_bpf *bpf);
extern int bpf_jit_x86(struct rte_bpf *);
extern int bpf_jit_arm64(struct rte_bpf *);
extern int rte_bpf_logtype;
#define RTE_BPF_LOG(lvl, fmt, args...) \
rte_log(RTE_LOG_## lvl, rte_bpf_logtype, fmt, ##args)
static inline size_t
bpf_size(uint32_t bpf_op_sz)
{
if (bpf_op_sz == BPF_B)
return sizeof(uint8_t);
else if (bpf_op_sz == BPF_H)
return sizeof(uint16_t);
else if (bpf_op_sz == BPF_W)
return sizeof(uint32_t);
else if (bpf_op_sz == EBPF_DW)
return sizeof(uint64_t);
return 0;
}
#endif /* BPF_IMPL_H */