aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/btf.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-02-06 19:56:20 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-06 19:56:20 -0500
commite90b1fd83c94d536375d8b9f4916afd15f4db0ed (patch)
treeba50688cc9a6712575aa861ff37b1db53dc472b8 /tools/lib/bpf/btf.h
parent907bea9cb8e9b7c4cb6a8042c164f3c24f141006 (diff)
parentdd9cef43c222df7c0d76d34451808e789952379d (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2019-02-07 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) Add a riscv64 JIT for BPF, from Björn. 2) Implement BTF deduplication algorithm for libbpf which takes BTF type information containing duplicate per-compilation unit information and reduces it to an equivalent set of BTF types with no duplication and without loss of information, from Andrii. 3) Offloaded and native BPF XDP programs can coexist today, enable also offloaded and generic ones as well, from Jakub. 4) Expose various BTF related helper functions in libbpf as API which are in particular helpful for JITed programs, from Yonghong. 5) Fix the recently added JMP32 code emission in s390x JIT, from Heiko. 6) Fix BPF kselftests' tcp_{server,client}.py to be able to run inside a network namespace, also add a fix for libbpf to get libbpf_print() working, from Stanislav. 7) Fixes for bpftool documentation, from Prashant. 8) Type cleanup in BPF kselftests' test_maps.c to silence a gcc8 warning, from Breno. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/lib/bpf/btf.h')
-rw-r--r--tools/lib/bpf/btf.h43
1 files changed, 27 insertions, 16 deletions
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index b0610dcdae6b..b393da90cc85 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -55,33 +55,44 @@ struct btf_ext_header {
55 __u32 line_info_len; 55 __u32 line_info_len;
56}; 56};
57 57
58typedef int (*btf_print_fn_t)(const char *, ...)
59 __attribute__((format(printf, 1, 2)));
60
61LIBBPF_API void btf__free(struct btf *btf); 58LIBBPF_API void btf__free(struct btf *btf);
62LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log); 59LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size);
63LIBBPF_API __s32 btf__find_by_name(const struct btf *btf, 60LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,
64 const char *type_name); 61 const char *type_name);
62LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf);
65LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf, 63LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
66 __u32 id); 64 __u32 id);
67LIBBPF_API __s64 btf__resolve_size(const struct btf *btf, __u32 type_id); 65LIBBPF_API __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
68LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id); 66LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id);
69LIBBPF_API int btf__fd(const struct btf *btf); 67LIBBPF_API int btf__fd(const struct btf *btf);
68LIBBPF_API void btf__get_strings(const struct btf *btf, const char **strings,
69 __u32 *str_len);
70LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset); 70LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset);
71LIBBPF_API int btf__get_from_id(__u32 id, struct btf **btf); 71LIBBPF_API int btf__get_from_id(__u32 id, struct btf **btf);
72LIBBPF_API int btf__get_map_kv_tids(const struct btf *btf, const char *map_name,
73 __u32 expected_key_size,
74 __u32 expected_value_size,
75 __u32 *key_type_id, __u32 *value_type_id);
76
77LIBBPF_API struct btf_ext *btf_ext__new(__u8 *data, __u32 size);
78LIBBPF_API void btf_ext__free(struct btf_ext *btf_ext);
79LIBBPF_API int btf_ext__reloc_func_info(const struct btf *btf,
80 const struct btf_ext *btf_ext,
81 const char *sec_name, __u32 insns_cnt,
82 void **func_info, __u32 *cnt);
83LIBBPF_API int btf_ext__reloc_line_info(const struct btf *btf,
84 const struct btf_ext *btf_ext,
85 const char *sec_name, __u32 insns_cnt,
86 void **line_info, __u32 *cnt);
87LIBBPF_API __u32 btf_ext__func_info_rec_size(const struct btf_ext *btf_ext);
88LIBBPF_API __u32 btf_ext__line_info_rec_size(const struct btf_ext *btf_ext);
89
90struct btf_dedup_opts {
91 bool dont_resolve_fwds;
92};
72 93
73struct btf_ext *btf_ext__new(__u8 *data, __u32 size, btf_print_fn_t err_log); 94LIBBPF_API int btf__dedup(struct btf *btf, struct btf_ext *btf_ext,
74void btf_ext__free(struct btf_ext *btf_ext); 95 const struct btf_dedup_opts *opts);
75int btf_ext__reloc_func_info(const struct btf *btf,
76 const struct btf_ext *btf_ext,
77 const char *sec_name, __u32 insns_cnt,
78 void **func_info, __u32 *func_info_len);
79int btf_ext__reloc_line_info(const struct btf *btf,
80 const struct btf_ext *btf_ext,
81 const char *sec_name, __u32 insns_cnt,
82 void **line_info, __u32 *cnt);
83__u32 btf_ext__func_info_rec_size(const struct btf_ext *btf_ext);
84__u32 btf_ext__line_info_rec_size(const struct btf_ext *btf_ext);
85 96
86#ifdef __cplusplus 97#ifdef __cplusplus
87} /* extern "C" */ 98} /* extern "C" */