]>
Commit | Line | Data |
---|---|---|
6054c1eb | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
6256f8c9 DB |
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" | |
c7272ca7 | 19 | #define ELF_SECTION_PROG "prog" |
6256f8c9 DB |
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 | ||
32e93fb7 DB |
26 | /* Object pinning settings */ |
27 | #define PIN_NONE 0 | |
28 | #define PIN_OBJECT_NS 1 | |
29 | #define PIN_GLOBAL_NS 2 | |
30 | ||
6256f8c9 DB |
31 | /* ELF map definition */ |
32 | struct bpf_elf_map { | |
33 | __u32 type; | |
34 | __u32 size_key; | |
35 | __u32 size_value; | |
36 | __u32 max_elem; | |
4dd3f50a | 37 | __u32 flags; |
6256f8c9 | 38 | __u32 id; |
f6793eec | 39 | __u32 pinning; |
612ff099 DB |
40 | __u32 inner_id; |
41 | __u32 inner_idx; | |
6256f8c9 DB |
42 | }; |
43 | ||
f823f360 DB |
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 | ||
6256f8c9 | 53 | #endif /* __BPF_ELF__ */ |