^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __PERF_BPF_EVENT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __PERF_BPF_EVENT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/rbtree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <pthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <api/fd/array.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct bpf_prog_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) union perf_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct perf_env;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct perf_sample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct perf_session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct record_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct evlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct bpf_prog_info_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct bpf_prog_info_linear *info_linear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct rb_node rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct btf_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct rb_node rb_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) u32 data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) char data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #ifdef HAVE_LIBBPF_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) int machine__process_bpf(struct machine *machine, union perf_event *event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct perf_sample *sample);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int evlist__add_bpf_sb_event(struct evlist *evlist, struct perf_env *env);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct perf_env *env,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) FILE *fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static inline int machine__process_bpf(struct machine *machine __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) union perf_event *event __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct perf_sample *sample __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static inline int evlist__add_bpf_sb_event(struct evlist *evlist __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct perf_env *env __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static inline void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct perf_env *env __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) FILE *fp __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #endif // HAVE_LIBBPF_SUPPORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #endif