xref: /linux/tools/perf/util/bpf-event.h (revision ab38e84ba9a80581e055408e0f8c0158998fa4b9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_BPF_EVENT_H
3 #define __PERF_BPF_EVENT_H
4 
5 #include <linux/compiler.h>
6 #include <linux/rbtree.h>
7 #include <api/fd/array.h>
8 #include <stdio.h>
9 
10 struct bpf_prog_info;
11 struct machine;
12 union perf_event;
13 struct perf_env;
14 struct perf_sample;
15 struct perf_session;
16 struct record_opts;
17 struct evlist;
18 struct target;
19 
20 struct bpf_metadata {
21 	union perf_event *event;
22 	char		 **prog_names;
23 	__u64		 nr_prog_names;
24 };
25 
26 struct bpf_prog_info_node {
27 	struct perf_bpil		*info_linear;
28 	struct rb_node			rb_node;
29 };
30 
31 struct btf_node {
32 	struct rb_node	rb_node;
33 	u32		id;
34 	u32		data_size;
35 	char		data[];
36 };
37 
38 #ifdef HAVE_LIBBPF_SUPPORT
39 int machine__process_bpf(struct machine *machine, union perf_event *event,
40 			 struct perf_sample *sample);
41 int evlist__add_bpf_sb_event(struct evlist *evlist, struct perf_env *env);
42 void __bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
43 				      struct perf_env *env,
44 				      FILE *fp);
45 void bpf_metadata_free(struct bpf_metadata *metadata);
46 #else
47 static inline int machine__process_bpf(struct machine *machine __maybe_unused,
48 				       union perf_event *event __maybe_unused,
49 				       struct perf_sample *sample __maybe_unused)
50 {
51 	return 0;
52 }
53 
54 static inline int evlist__add_bpf_sb_event(struct evlist *evlist __maybe_unused,
55 					   struct perf_env *env __maybe_unused)
56 {
57 	return 0;
58 }
59 
60 static inline void __bpf_event__print_bpf_prog_info(struct bpf_prog_info *info __maybe_unused,
61 						    struct perf_env *env __maybe_unused,
62 						    FILE *fp __maybe_unused)
63 {
64 
65 }
66 
67 static inline void bpf_metadata_free(struct bpf_metadata *metadata __maybe_unused)
68 {
69 
70 }
71 #endif // HAVE_LIBBPF_SUPPORT
72 #endif
73