aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include
diff options
context:
space:
mode:
authorMartin KaFai Lau <kafai@fb.com>2018-05-22 17:57:22 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-05-23 06:03:32 -0400
commitf03b15d34bd805e57bf69523b4dca7af10e9eeb1 (patch)
tree700acca7f6bddbae98458871f42de2b82831e613 /tools/include
parent9b2cf328b2eccf761537a06bef914d2a0700fba7 (diff)
bpf: btf: Sync bpf.h and btf.h to tools
This patch sync the uapi bpf.h and btf.h to tools. Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/uapi/linux/bpf.h8
-rw-r--r--tools/include/uapi/linux/btf.h37
2 files changed, 15 insertions, 30 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 97446bbe2ca5..c3e502d06bc3 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -284,8 +284,8 @@ union bpf_attr {
284 char map_name[BPF_OBJ_NAME_LEN]; 284 char map_name[BPF_OBJ_NAME_LEN];
285 __u32 map_ifindex; /* ifindex of netdev to create on */ 285 __u32 map_ifindex; /* ifindex of netdev to create on */
286 __u32 btf_fd; /* fd pointing to a BTF type data */ 286 __u32 btf_fd; /* fd pointing to a BTF type data */
287 __u32 btf_key_id; /* BTF type_id of the key */ 287 __u32 btf_key_type_id; /* BTF type_id of the key */
288 __u32 btf_value_id; /* BTF type_id of the value */ 288 __u32 btf_value_type_id; /* BTF type_id of the value */
289 }; 289 };
290 290
291 struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */ 291 struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -2219,8 +2219,8 @@ struct bpf_map_info {
2219 __u64 netns_dev; 2219 __u64 netns_dev;
2220 __u64 netns_ino; 2220 __u64 netns_ino;
2221 __u32 btf_id; 2221 __u32 btf_id;
2222 __u32 btf_key_id; 2222 __u32 btf_key_type_id;
2223 __u32 btf_value_id; 2223 __u32 btf_value_type_id;
2224} __attribute__((aligned(8))); 2224} __attribute__((aligned(8)));
2225 2225
2226struct bpf_btf_info { 2226struct bpf_btf_info {
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h
index bcb56ee47014..0b5ddbe135a4 100644
--- a/tools/include/uapi/linux/btf.h
+++ b/tools/include/uapi/linux/btf.h
@@ -12,42 +12,29 @@ struct btf_header {
12 __u16 magic; 12 __u16 magic;
13 __u8 version; 13 __u8 version;
14 __u8 flags; 14 __u8 flags;
15 15 __u32 hdr_len;
16 __u32 parent_label;
17 __u32 parent_name;
18 16
19 /* All offsets are in bytes relative to the end of this header */ 17 /* All offsets are in bytes relative to the end of this header */
20 __u32 label_off; /* offset of label section */
21 __u32 object_off; /* offset of data object section*/
22 __u32 func_off; /* offset of function section */
23 __u32 type_off; /* offset of type section */ 18 __u32 type_off; /* offset of type section */
19 __u32 type_len; /* length of type section */
24 __u32 str_off; /* offset of string section */ 20 __u32 str_off; /* offset of string section */
25 __u32 str_len; /* length of string section */ 21 __u32 str_len; /* length of string section */
26}; 22};
27 23
28/* Max # of type identifier */ 24/* Max # of type identifier */
29#define BTF_MAX_TYPE 0x7fffffff 25#define BTF_MAX_TYPE 0x0000ffff
30/* Max offset into the string section */ 26/* Max offset into the string section */
31#define BTF_MAX_NAME_OFFSET 0x7fffffff 27#define BTF_MAX_NAME_OFFSET 0x0000ffff
32/* Max # of struct/union/enum members or func args */ 28/* Max # of struct/union/enum members or func args */
33#define BTF_MAX_VLEN 0xffff 29#define BTF_MAX_VLEN 0xffff
34 30
35/* The type id is referring to a parent BTF */
36#define BTF_TYPE_PARENT(id) (((id) >> 31) & 0x1)
37#define BTF_TYPE_ID(id) ((id) & BTF_MAX_TYPE)
38
39/* String is in the ELF string section */
40#define BTF_STR_TBL_ELF_ID(ref) (((ref) >> 31) & 0x1)
41#define BTF_STR_OFFSET(ref) ((ref) & BTF_MAX_NAME_OFFSET)
42
43struct btf_type { 31struct btf_type {
44 __u32 name_off; 32 __u32 name_off;
45 /* "info" bits arrangement 33 /* "info" bits arrangement
46 * bits 0-15: vlen (e.g. # of struct's members) 34 * bits 0-15: vlen (e.g. # of struct's members)
47 * bits 16-23: unused 35 * bits 16-23: unused
48 * bits 24-28: kind (e.g. int, ptr, array...etc) 36 * bits 24-27: kind (e.g. int, ptr, array...etc)
49 * bits 29-30: unused 37 * bits 28-31: unused
50 * bits 31: root
51 */ 38 */
52 __u32 info; 39 __u32 info;
53 /* "size" is used by INT, ENUM, STRUCT and UNION. 40 /* "size" is used by INT, ENUM, STRUCT and UNION.
@@ -62,8 +49,7 @@ struct btf_type {
62 }; 49 };
63}; 50};
64 51
65#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f) 52#define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f)
66#define BTF_INFO_ISROOT(info) (!!(((info) >> 24) & 0x80))
67#define BTF_INFO_VLEN(info) ((info) & 0xffff) 53#define BTF_INFO_VLEN(info) ((info) & 0xffff)
68 54
69#define BTF_KIND_UNKN 0 /* Unknown */ 55#define BTF_KIND_UNKN 0 /* Unknown */
@@ -88,15 +74,14 @@ struct btf_type {
88/* BTF_KIND_INT is followed by a u32 and the following 74/* BTF_KIND_INT is followed by a u32 and the following
89 * is the 32 bits arrangement: 75 * is the 32 bits arrangement:
90 */ 76 */
91#define BTF_INT_ENCODING(VAL) (((VAL) & 0xff000000) >> 24) 77#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
92#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16) 78#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16)
93#define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff) 79#define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff)
94 80
95/* Attributes stored in the BTF_INT_ENCODING */ 81/* Attributes stored in the BTF_INT_ENCODING */
96#define BTF_INT_SIGNED 0x1 82#define BTF_INT_SIGNED (1 << 0)
97#define BTF_INT_CHAR 0x2 83#define BTF_INT_CHAR (1 << 1)
98#define BTF_INT_BOOL 0x4 84#define BTF_INT_BOOL (1 << 2)
99#define BTF_INT_VARARGS 0x8
100 85
101/* BTF_KIND_ENUM is followed by multiple "struct btf_enum". 86/* BTF_KIND_ENUM is followed by multiple "struct btf_enum".
102 * The exact number of btf_enum is stored in the vlen (of the 87 * The exact number of btf_enum is stored in the vlen (of the