xref: /openbmc/linux/tools/perf/util/bpf-event.h (revision ea49e01c)
145178a92SSong Liu /* SPDX-License-Identifier: GPL-2.0 */
245178a92SSong Liu #ifndef __PERF_BPF_EVENT_H
345178a92SSong Liu #define __PERF_BPF_EVENT_H
445178a92SSong Liu 
545178a92SSong Liu #include <linux/compiler.h>
6e4378f0cSSong Liu #include <linux/rbtree.h>
7d56354dcSSong Liu #include <pthread.h>
8d56354dcSSong Liu #include <api/fd/array.h>
9f8dfeae0SSong Liu #include <stdio.h>
1045178a92SSong Liu 
11ea49e01cSArnaldo Carvalho de Melo struct bpf_prog_info;
1245178a92SSong Liu struct machine;
1345178a92SSong Liu union perf_event;
14d56354dcSSong Liu struct perf_env;
1545178a92SSong Liu struct perf_sample;
164cb3c6d5SArnaldo Carvalho de Melo struct perf_session;
177b612e29SSong Liu struct record_opts;
18d56354dcSSong Liu struct evlist;
19d56354dcSSong Liu struct target;
2045178a92SSong Liu 
21e4378f0cSSong Liu struct bpf_prog_info_node {
22e4378f0cSSong Liu 	struct bpf_prog_info_linear	*info_linear;
23e4378f0cSSong Liu 	struct rb_node			rb_node;
24e4378f0cSSong Liu };
25e4378f0cSSong Liu 
263792cb2fSSong Liu struct btf_node {
273792cb2fSSong Liu 	struct rb_node	rb_node;
283792cb2fSSong Liu 	u32		id;
293792cb2fSSong Liu 	u32		data_size;
303792cb2fSSong Liu 	char		data[];
313792cb2fSSong Liu };
323792cb2fSSong Liu 
3345178a92SSong Liu #ifdef HAVE_LIBBPF_SUPPORT
343f604b5fSArnaldo Carvalho de Melo int machine__process_bpf(struct machine *machine, union perf_event *event,
3545178a92SSong Liu 			 struct perf_sample *sample);
3663503dbaSJiri Olsa int bpf_event__add_sb_event(struct evlist **evlist,
37d56354dcSSong Liu 				 struct perf_env *env);
38f8dfeae0SSong Liu void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
39f8dfeae0SSong Liu 				    struct perf_env *env,
40f8dfeae0SSong Liu 				    FILE *fp);
4145178a92SSong Liu #else
423f604b5fSArnaldo Carvalho de Melo static inline int machine__process_bpf(struct machine *machine __maybe_unused,
4345178a92SSong Liu 				       union perf_event *event __maybe_unused,
4445178a92SSong Liu 				       struct perf_sample *sample __maybe_unused)
4545178a92SSong Liu {
4645178a92SSong Liu 	return 0;
4745178a92SSong Liu }
487b612e29SSong Liu 
4963503dbaSJiri Olsa static inline int bpf_event__add_sb_event(struct evlist **evlist __maybe_unused,
50d56354dcSSong Liu 					  struct perf_env *env __maybe_unused)
51d56354dcSSong Liu {
52d56354dcSSong Liu 	return 0;
53d56354dcSSong Liu }
54d56354dcSSong Liu 
55f8dfeae0SSong Liu static inline void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info __maybe_unused,
56f8dfeae0SSong Liu 						  struct perf_env *env __maybe_unused,
57f8dfeae0SSong Liu 						  FILE *fp __maybe_unused)
58f8dfeae0SSong Liu {
59f8dfeae0SSong Liu 
60f8dfeae0SSong Liu }
6145178a92SSong Liu #endif // HAVE_LIBBPF_SUPPORT
6245178a92SSong Liu #endif
63