1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 * Copyright 2017 Mellanox Technologies, Ltd.
8 #include <tap_autoconf.h>
10 #ifdef HAVE_BPF_PROG_LOAD
11 #include <linux/bpf.h>
13 /* BPF_MAP_UPDATE_ELEM command flags */
14 #define BPF_ANY 0 /* create a new element or update an existing */
16 /* BPF architecture instruction struct */
22 __s32 imm; /* immediate value */
25 /* BPF program types */
28 BPF_PROG_TYPE_SOCKET_FILTER,
30 BPF_PROG_TYPE_SCHED_CLS,
31 BPF_PROG_TYPE_SCHED_ACT,
34 /* BPF commands types */
50 /* union of anonymous structs used with TAP BPF commands */
52 /* BPF_MAP_CREATE command */
62 /* BPF_MAP_UPDATE_ELEM, BPF_MAP_DELETE_ELEM commands */
68 __aligned_u64 next_key;
73 /* BPF_PROG_LOAD command */
78 __aligned_u64 license;
81 __aligned_u64 log_buf;
85 } __attribute__((aligned(8)));
89 # if defined(__i386__)
91 # elif defined(__x86_64__)
93 # elif defined(__aarch64__)
95 # elif defined(__sparc__)
97 # elif defined(__s390__)
100 # error __NR_bpf not defined
109 static int bpf_load(enum bpf_prog_type type, const struct bpf_insn *insns,
110 size_t insns_cnt, const char *license);
112 #endif /* __TAP_BPF_H__ */