diff options
Diffstat (limited to 'tools/lib/bpf/bpf.h')
-rw-r--r-- | tools/lib/bpf/bpf.h | 118 |
1 files changed, 65 insertions, 53 deletions
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 69a4d40c4227..258c3c178333 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -27,6 +27,10 @@ | |||
27 | #include <stdbool.h> | 27 | #include <stdbool.h> |
28 | #include <stddef.h> | 28 | #include <stddef.h> |
29 | 29 | ||
30 | #ifndef LIBBPF_API | ||
31 | #define LIBBPF_API __attribute__((visibility("default"))) | ||
32 | #endif | ||
33 | |||
30 | struct bpf_create_map_attr { | 34 | struct bpf_create_map_attr { |
31 | const char *name; | 35 | const char *name; |
32 | enum bpf_map_type map_type; | 36 | enum bpf_map_type map_type; |
@@ -42,21 +46,24 @@ struct bpf_create_map_attr { | |||
42 | __u32 inner_map_fd; | 46 | __u32 inner_map_fd; |
43 | }; | 47 | }; |
44 | 48 | ||
45 | int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr); | 49 | LIBBPF_API int |
46 | int bpf_create_map_node(enum bpf_map_type map_type, const char *name, | 50 | bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr); |
47 | int key_size, int value_size, int max_entries, | 51 | LIBBPF_API int bpf_create_map_node(enum bpf_map_type map_type, const char *name, |
48 | __u32 map_flags, int node); | 52 | int key_size, int value_size, |
49 | int bpf_create_map_name(enum bpf_map_type map_type, const char *name, | 53 | int max_entries, __u32 map_flags, int node); |
50 | int key_size, int value_size, int max_entries, | 54 | LIBBPF_API int bpf_create_map_name(enum bpf_map_type map_type, const char *name, |
51 | __u32 map_flags); | 55 | int key_size, int value_size, |
52 | int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size, | 56 | int max_entries, __u32 map_flags); |
53 | int max_entries, __u32 map_flags); | 57 | LIBBPF_API int bpf_create_map(enum bpf_map_type map_type, int key_size, |
54 | int bpf_create_map_in_map_node(enum bpf_map_type map_type, const char *name, | 58 | int value_size, int max_entries, __u32 map_flags); |
55 | int key_size, int inner_map_fd, int max_entries, | 59 | LIBBPF_API int bpf_create_map_in_map_node(enum bpf_map_type map_type, |
56 | __u32 map_flags, int node); | 60 | const char *name, int key_size, |
57 | int bpf_create_map_in_map(enum bpf_map_type map_type, const char *name, | 61 | int inner_map_fd, int max_entries, |
58 | int key_size, int inner_map_fd, int max_entries, | 62 | __u32 map_flags, int node); |
59 | __u32 map_flags); | 63 | LIBBPF_API int bpf_create_map_in_map(enum bpf_map_type map_type, |
64 | const char *name, int key_size, | ||
65 | int inner_map_fd, int max_entries, | ||
66 | __u32 map_flags); | ||
60 | 67 | ||
61 | struct bpf_load_program_attr { | 68 | struct bpf_load_program_attr { |
62 | enum bpf_prog_type prog_type; | 69 | enum bpf_prog_type prog_type; |
@@ -74,44 +81,49 @@ struct bpf_load_program_attr { | |||
74 | 81 | ||
75 | /* Recommend log buffer size */ | 82 | /* Recommend log buffer size */ |
76 | #define BPF_LOG_BUF_SIZE (256 * 1024) | 83 | #define BPF_LOG_BUF_SIZE (256 * 1024) |
77 | int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, | 84 | LIBBPF_API int |
78 | char *log_buf, size_t log_buf_sz); | 85 | bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr, |
79 | int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 86 | char *log_buf, size_t log_buf_sz); |
80 | size_t insns_cnt, const char *license, | 87 | LIBBPF_API int bpf_load_program(enum bpf_prog_type type, |
81 | __u32 kern_version, char *log_buf, | 88 | const struct bpf_insn *insns, size_t insns_cnt, |
82 | size_t log_buf_sz); | 89 | const char *license, __u32 kern_version, |
83 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 90 | char *log_buf, size_t log_buf_sz); |
84 | size_t insns_cnt, int strict_alignment, | 91 | LIBBPF_API int bpf_verify_program(enum bpf_prog_type type, |
85 | const char *license, __u32 kern_version, | 92 | const struct bpf_insn *insns, |
86 | char *log_buf, size_t log_buf_sz, int log_level); | 93 | size_t insns_cnt, int strict_alignment, |
94 | const char *license, __u32 kern_version, | ||
95 | char *log_buf, size_t log_buf_sz, | ||
96 | int log_level); | ||
87 | 97 | ||
88 | int bpf_map_update_elem(int fd, const void *key, const void *value, | 98 | LIBBPF_API int bpf_map_update_elem(int fd, const void *key, const void *value, |
89 | __u64 flags); | 99 | __u64 flags); |
90 | 100 | ||
91 | int bpf_map_lookup_elem(int fd, const void *key, void *value); | 101 | LIBBPF_API int bpf_map_lookup_elem(int fd, const void *key, void *value); |
92 | int bpf_map_delete_elem(int fd, const void *key); | 102 | LIBBPF_API int bpf_map_delete_elem(int fd, const void *key); |
93 | int bpf_map_get_next_key(int fd, const void *key, void *next_key); | 103 | LIBBPF_API int bpf_map_get_next_key(int fd, const void *key, void *next_key); |
94 | int bpf_obj_pin(int fd, const char *pathname); | 104 | LIBBPF_API int bpf_obj_pin(int fd, const char *pathname); |
95 | int bpf_obj_get(const char *pathname); | 105 | LIBBPF_API int bpf_obj_get(const char *pathname); |
96 | int bpf_prog_attach(int prog_fd, int attachable_fd, enum bpf_attach_type type, | 106 | LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd, |
97 | unsigned int flags); | 107 | enum bpf_attach_type type, unsigned int flags); |
98 | int bpf_prog_detach(int attachable_fd, enum bpf_attach_type type); | 108 | LIBBPF_API int bpf_prog_detach(int attachable_fd, enum bpf_attach_type type); |
99 | int bpf_prog_detach2(int prog_fd, int attachable_fd, enum bpf_attach_type type); | 109 | LIBBPF_API int bpf_prog_detach2(int prog_fd, int attachable_fd, |
100 | int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size, | 110 | enum bpf_attach_type type); |
101 | void *data_out, __u32 *size_out, __u32 *retval, | 111 | LIBBPF_API int bpf_prog_test_run(int prog_fd, int repeat, void *data, |
102 | __u32 *duration); | 112 | __u32 size, void *data_out, __u32 *size_out, |
103 | int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id); | 113 | __u32 *retval, __u32 *duration); |
104 | int bpf_map_get_next_id(__u32 start_id, __u32 *next_id); | 114 | LIBBPF_API int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id); |
105 | int bpf_prog_get_fd_by_id(__u32 id); | 115 | LIBBPF_API int bpf_map_get_next_id(__u32 start_id, __u32 *next_id); |
106 | int bpf_map_get_fd_by_id(__u32 id); | 116 | LIBBPF_API int bpf_prog_get_fd_by_id(__u32 id); |
107 | int bpf_btf_get_fd_by_id(__u32 id); | 117 | LIBBPF_API int bpf_map_get_fd_by_id(__u32 id); |
108 | int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len); | 118 | LIBBPF_API int bpf_btf_get_fd_by_id(__u32 id); |
109 | int bpf_prog_query(int target_fd, enum bpf_attach_type type, __u32 query_flags, | 119 | LIBBPF_API int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len); |
110 | __u32 *attach_flags, __u32 *prog_ids, __u32 *prog_cnt); | 120 | LIBBPF_API int bpf_prog_query(int target_fd, enum bpf_attach_type type, |
111 | int bpf_raw_tracepoint_open(const char *name, int prog_fd); | 121 | __u32 query_flags, __u32 *attach_flags, |
112 | int bpf_load_btf(void *btf, __u32 btf_size, char *log_buf, __u32 log_buf_size, | 122 | __u32 *prog_ids, __u32 *prog_cnt); |
113 | bool do_log); | 123 | LIBBPF_API int bpf_raw_tracepoint_open(const char *name, int prog_fd); |
114 | int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, __u32 *buf_len, | 124 | LIBBPF_API int bpf_load_btf(void *btf, __u32 btf_size, char *log_buf, |
115 | __u32 *prog_id, __u32 *fd_type, __u64 *probe_offset, | 125 | __u32 log_buf_size, bool do_log); |
116 | __u64 *probe_addr); | 126 | LIBBPF_API int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, |
127 | __u32 *buf_len, __u32 *prog_id, __u32 *fd_type, | ||
128 | __u64 *probe_offset, __u64 *probe_addr); | ||
117 | #endif /* __LIBBPF_BPF_H */ | 129 | #endif /* __LIBBPF_BPF_H */ |