1 #ifndef __BPF_EXPERIMENTAL__ 2 #define __BPF_EXPERIMENTAL__ 3 4 #include <vmlinux.h> 5 #include <bpf/bpf_tracing.h> 6 #include <bpf/bpf_helpers.h> 7 #include <bpf/bpf_core_read.h> 8 9 #define __contains(name, node) __attribute__((btf_decl_tag("contains:" #name ":" #node))) 10 11 /* Description 12 * Allocates an object of the type represented by 'local_type_id' in 13 * program BTF. User may use the bpf_core_type_id_local macro to pass the 14 * type ID of a struct in program BTF. 15 * 16 * The 'local_type_id' parameter must be a known constant. 17 * The 'meta' parameter is a hidden argument that is ignored. 18 * Returns 19 * A pointer to an object of the type corresponding to the passed in 20 * 'local_type_id', or NULL on failure. 21 */ 22 extern void *bpf_obj_new_impl(__u64 local_type_id, void *meta) __ksym; 23 24 /* Convenience macro to wrap over bpf_obj_new_impl */ 25 #define bpf_obj_new(type) ((type *)bpf_obj_new_impl(bpf_core_type_id_local(type), NULL)) 26 27 /* Description 28 * Free an allocated object. All fields of the object that require 29 * destruction will be destructed before the storage is freed. 30 * 31 * The 'meta' parameter is a hidden argument that is ignored. 32 * Returns 33 * Void. 34 */ 35 extern void bpf_obj_drop_impl(void *kptr, void *meta) __ksym; 36 37 /* Convenience macro to wrap over bpf_obj_drop_impl */ 38 #define bpf_obj_drop(kptr) bpf_obj_drop_impl(kptr, NULL) 39 40 /* Description 41 * Add a new entry to the beginning of the BPF linked list. 42 * Returns 43 * Void. 44 */ 45 extern void bpf_list_push_front(struct bpf_list_head *head, struct bpf_list_node *node) __ksym; 46 47 /* Description 48 * Add a new entry to the end of the BPF linked list. 49 * Returns 50 * Void. 51 */ 52 extern void bpf_list_push_back(struct bpf_list_head *head, struct bpf_list_node *node) __ksym; 53 54 /* Description 55 * Remove the entry at the beginning of the BPF linked list. 56 * Returns 57 * Pointer to bpf_list_node of deleted entry, or NULL if list is empty. 58 */ 59 extern struct bpf_list_node *bpf_list_pop_front(struct bpf_list_head *head) __ksym; 60 61 /* Description 62 * Remove the entry at the end of the BPF linked list. 63 * Returns 64 * Pointer to bpf_list_node of deleted entry, or NULL if list is empty. 65 */ 66 extern struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head) __ksym; 67 68 /* Description 69 * Remove 'node' from rbtree with root 'root' 70 * Returns 71 * Pointer to the removed node, or NULL if 'root' didn't contain 'node' 72 */ 73 extern struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root, 74 struct bpf_rb_node *node) __ksym; 75 76 /* Description 77 * Add 'node' to rbtree with root 'root' using comparator 'less' 78 * Returns 79 * Nothing 80 */ 81 extern void bpf_rbtree_add(struct bpf_rb_root *root, struct bpf_rb_node *node, 82 bool (less)(struct bpf_rb_node *a, const struct bpf_rb_node *b)) __ksym; 83 84 /* Description 85 * Return the first (leftmost) node in input tree 86 * Returns 87 * Pointer to the node, which is _not_ removed from the tree. If the tree 88 * contains no nodes, returns NULL. 89 */ 90 extern struct bpf_rb_node *bpf_rbtree_first(struct bpf_rb_root *root) __ksym; 91 92 #endif 93