xref: /openbmc/linux/tools/perf/util/bpf-event.h (revision b38d85ef)
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);
36b38d85efSArnaldo Carvalho de Melo int evlist__add_bpf_sb_event(struct evlist *evlist, struct perf_env *env);
37f8dfeae0SSong Liu void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
38f8dfeae0SSong Liu 				    struct perf_env *env,
39f8dfeae0SSong Liu 				    FILE *fp);
4045178a92SSong Liu #else
413f604b5fSArnaldo Carvalho de Melo static inline int machine__process_bpf(struct machine *machine __maybe_unused,
4245178a92SSong Liu 				       union perf_event *event __maybe_unused,
4345178a92SSong Liu 				       struct perf_sample *sample __maybe_unused)
4445178a92SSong Liu {
4545178a92SSong Liu 	return 0;
4645178a92SSong Liu }
477b612e29SSong Liu 
48b38d85efSArnaldo Carvalho de Melo static inline int evlist__add_bpf_sb_event(struct evlist *evlist __maybe_unused,
49d56354dcSSong Liu 					   struct perf_env *env __maybe_unused)
50d56354dcSSong Liu {
51d56354dcSSong Liu 	return 0;
52d56354dcSSong Liu }
53d56354dcSSong Liu 
54f8dfeae0SSong Liu static inline void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info __maybe_unused,
55f8dfeae0SSong Liu 						  struct perf_env *env __maybe_unused,
56f8dfeae0SSong Liu 						  FILE *fp __maybe_unused)
57f8dfeae0SSong Liu {
58f8dfeae0SSong Liu 
59f8dfeae0SSong Liu }
6045178a92SSong Liu #endif // HAVE_LIBBPF_SUPPORT
6145178a92SSong Liu #endif
62