1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2 #ifndef __BPF_LEGACY__
3 #define __BPF_LEGACY__
4 
5 /*
6  * legacy bpf_map_def with extra fields supported only by bpf_load(), do not
7  * use outside of samples/bpf
8  */
9 struct bpf_map_def_legacy {
10 	unsigned int type;
11 	unsigned int key_size;
12 	unsigned int value_size;
13 	unsigned int max_entries;
14 	unsigned int map_flags;
15 	unsigned int inner_map_idx;
16 	unsigned int numa_node;
17 };
18 
19 #define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val)		\
20 	struct ____btf_map_##name {				\
21 		type_key key;					\
22 		type_val value;					\
23 	};							\
24 	struct ____btf_map_##name				\
25 	__attribute__ ((section(".maps." #name), used))		\
26 		____btf_map_##name = { }
27 
28 /* llvm builtin functions that eBPF C program may use to
29  * emit BPF_LD_ABS and BPF_LD_IND instructions
30  */
31 unsigned long long load_byte(void *skb,
32 			     unsigned long long off) asm("llvm.bpf.load.byte");
33 unsigned long long load_half(void *skb,
34 			     unsigned long long off) asm("llvm.bpf.load.half");
35 unsigned long long load_word(void *skb,
36 			     unsigned long long off) asm("llvm.bpf.load.word");
37 
38 #endif
39 
40