]> git.proxmox.com Git - mirror_iproute2.git/blob - include/bpf_elf.h
ll_map: Add function to remove link cache entry by index
[mirror_iproute2.git] / include / bpf_elf.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __BPF_ELF__
3 #define __BPF_ELF__
4
5 #include <asm/types.h>
6
7 /* Note:
8 *
9 * Below ELF section names and bpf_elf_map structure definition
10 * are not (!) kernel ABI. It's rather a "contract" between the
11 * application and the BPF loader in tc. For compatibility, the
12 * section names should stay as-is. Introduction of aliases, if
13 * needed, are a possibility, though.
14 */
15
16 /* ELF section names, etc */
17 #define ELF_SECTION_LICENSE "license"
18 #define ELF_SECTION_MAPS "maps"
19 #define ELF_SECTION_PROG "prog"
20 #define ELF_SECTION_CLASSIFIER "classifier"
21 #define ELF_SECTION_ACTION "action"
22
23 #define ELF_MAX_MAPS 64
24 #define ELF_MAX_LICENSE_LEN 128
25
26 /* Object pinning settings */
27 #define PIN_NONE 0
28 #define PIN_OBJECT_NS 1
29 #define PIN_GLOBAL_NS 2
30
31 /* ELF map definition */
32 struct bpf_elf_map {
33 __u32 type;
34 __u32 size_key;
35 __u32 size_value;
36 __u32 max_elem;
37 __u32 flags;
38 __u32 id;
39 __u32 pinning;
40 __u32 inner_id;
41 __u32 inner_idx;
42 };
43
44 #define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) \
45 struct ____btf_map_##name { \
46 type_key key; \
47 type_val value; \
48 }; \
49 struct ____btf_map_##name \
50 __attribute__ ((section(".maps." #name), used)) \
51 ____btf_map_##name = { }
52
53 #endif /* __BPF_ELF__ */