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 #endif
69