diff options
Diffstat (limited to 'include/linux/btf.h')
-rw-r--r-- | include/linux/btf.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/linux/btf.h b/include/linux/btf.h new file mode 100644 index 000000000000..a966dc6d61ee --- /dev/null +++ b/include/linux/btf.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* Copyright (c) 2018 Facebook */ | ||
3 | |||
4 | #ifndef _LINUX_BTF_H | ||
5 | #define _LINUX_BTF_H 1 | ||
6 | |||
7 | #include <linux/types.h> | ||
8 | |||
9 | struct btf; | ||
10 | struct btf_type; | ||
11 | union bpf_attr; | ||
12 | |||
13 | extern const struct file_operations btf_fops; | ||
14 | |||
15 | void btf_put(struct btf *btf); | ||
16 | int btf_new_fd(const union bpf_attr *attr); | ||
17 | struct btf *btf_get_by_fd(int fd); | ||
18 | int btf_get_info_by_fd(const struct btf *btf, | ||
19 | const union bpf_attr *attr, | ||
20 | union bpf_attr __user *uattr); | ||
21 | /* Figure out the size of a type_id. If type_id is a modifier | ||
22 | * (e.g. const), it will be resolved to find out the type with size. | ||
23 | * | ||
24 | * For example: | ||
25 | * In describing "const void *", type_id is "const" and "const" | ||
26 | * refers to "void *". The return type will be "void *". | ||
27 | * | ||
28 | * If type_id is a simple "int", then return type will be "int". | ||
29 | * | ||
30 | * @btf: struct btf object | ||
31 | * @type_id: Find out the size of type_id. The type_id of the return | ||
32 | * type is set to *type_id. | ||
33 | * @ret_size: It can be NULL. If not NULL, the size of the return | ||
34 | * type is set to *ret_size. | ||
35 | * Return: The btf_type (resolved to another type with size info if needed). | ||
36 | * NULL is returned if type_id itself does not have size info | ||
37 | * (e.g. void) or it cannot be resolved to another type that | ||
38 | * has size info. | ||
39 | * *type_id and *ret_size will not be changed in the | ||
40 | * NULL return case. | ||
41 | */ | ||
42 | const struct btf_type *btf_type_id_size(const struct btf *btf, | ||
43 | u32 *type_id, | ||
44 | u32 *ret_size); | ||
45 | void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, | ||
46 | struct seq_file *m); | ||
47 | |||
48 | #endif | ||