Skip to content

Commit 128b343

Browse files
yonghong-songborkmann
authored andcommitted
tools/bpf: sync btf.h header from kernel to tools
Sync include/uapi/linux/btf.h to tools/include/uapi/linux/btf.h. Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent ffa0c1c commit 128b343

File tree

1 file changed

+18
-2
lines changed
  • tools/include/uapi/linux

1 file changed

+18
-2
lines changed

tools/include/uapi/linux/btf.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ struct btf_type {
3434
* bits 0-15: vlen (e.g. # of struct's members)
3535
* bits 16-23: unused
3636
* bits 24-27: kind (e.g. int, ptr, array...etc)
37-
* bits 28-31: unused
37+
* bits 28-30: unused
38+
* bit 31: kind_flag, currently used by
39+
* struct, union and fwd
3840
*/
3941
__u32 info;
4042
/* "size" is used by INT, ENUM, STRUCT and UNION.
@@ -52,6 +54,7 @@ struct btf_type {
5254

5355
#define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f)
5456
#define BTF_INFO_VLEN(info) ((info) & 0xffff)
57+
#define BTF_INFO_KFLAG(info) ((info) >> 31)
5558

5659
#define BTF_KIND_UNKN 0 /* Unknown */
5760
#define BTF_KIND_INT 1 /* Integer */
@@ -110,9 +113,22 @@ struct btf_array {
110113
struct btf_member {
111114
__u32 name_off;
112115
__u32 type;
113-
__u32 offset; /* offset in bits */
116+
/* If the type info kind_flag is set, the btf_member offset
117+
* contains both member bitfield size and bit offset. The
118+
* bitfield size is set for bitfield members. If the type
119+
* info kind_flag is not set, the offset contains only bit
120+
* offset.
121+
*/
122+
__u32 offset;
114123
};
115124

125+
/* If the struct/union type info kind_flag is set, the
126+
* following two macros are used to access bitfield_size
127+
* and bit_offset from btf_member.offset.
128+
*/
129+
#define BTF_MEMBER_BITFIELD_SIZE(val) ((val) >> 24)
130+
#define BTF_MEMBER_BIT_OFFSET(val) ((val) & 0xffffff)
131+
116132
/* BTF_KIND_FUNC_PROTO is followed by multiple "struct btf_param".
117133
* The exact number of btf_param is stored in the vlen (of the
118134
* info in "struct btf_type").

0 commit comments

Comments
 (0)