Martin KaFai Lau | eb3f595 | 2018-04-18 15:55:58 -0700 | [diff] [blame] | 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; |
Martin KaFai Lau | f56a653 | 2018-04-18 15:56:01 -0700 | [diff] [blame^] | 11 | union bpf_attr; |
Martin KaFai Lau | eb3f595 | 2018-04-18 15:55:58 -0700 | [diff] [blame] | 12 | |
Martin KaFai Lau | f56a653 | 2018-04-18 15:56:01 -0700 | [diff] [blame^] | 13 | void btf_put(struct btf *btf); |
| 14 | int btf_new_fd(const union bpf_attr *attr); |
| 15 | struct btf *btf_get_by_fd(int fd); |
Martin KaFai Lau | eb3f595 | 2018-04-18 15:55:58 -0700 | [diff] [blame] | 16 | /* Figure out the size of a type_id. If type_id is a modifier |
| 17 | * (e.g. const), it will be resolved to find out the type with size. |
| 18 | * |
| 19 | * For example: |
| 20 | * In describing "const void *", type_id is "const" and "const" |
| 21 | * refers to "void *". The return type will be "void *". |
| 22 | * |
| 23 | * If type_id is a simple "int", then return type will be "int". |
| 24 | * |
| 25 | * @btf: struct btf object |
| 26 | * @type_id: Find out the size of type_id. The type_id of the return |
| 27 | * type is set to *type_id. |
| 28 | * @ret_size: It can be NULL. If not NULL, the size of the return |
| 29 | * type is set to *ret_size. |
| 30 | * Return: The btf_type (resolved to another type with size info if needed). |
| 31 | * NULL is returned if type_id itself does not have size info |
| 32 | * (e.g. void) or it cannot be resolved to another type that |
| 33 | * has size info. |
| 34 | * *type_id and *ret_size will not be changed in the |
| 35 | * NULL return case. |
| 36 | */ |
| 37 | const struct btf_type *btf_type_id_size(const struct btf *btf, |
| 38 | u32 *type_id, |
| 39 | u32 *ret_size); |
Martin KaFai Lau | b00b8da | 2018-04-18 15:56:00 -0700 | [diff] [blame] | 40 | void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, |
| 41 | struct seq_file *m); |
Martin KaFai Lau | eb3f595 | 2018-04-18 15:55:58 -0700 | [diff] [blame] | 42 | |
| 43 | #endif |