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 9struct btf; 10struct btf_type; 11union bpf_attr; 12 13extern const struct file_operations btf_fops; 14 15void btf_put(struct btf *btf); 16int btf_new_fd(const union bpf_attr *attr); 17struct btf *btf_get_by_fd(int fd); 18int 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 */ 42const struct btf_type *btf_type_id_size(const struct btf *btf, 43 u32 *type_id, 44 u32 *ret_size); 45void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, 46 struct seq_file *m); 47int btf_get_fd_by_id(u32 id); 48u32 btf_id(const struct btf *btf); 49 50#endif 51