perf bpf filter: Implement event sample filtering
[platform/kernel/linux-starfive.git] / tools / perf / util / bpf-filter.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PERF_UTIL_BPF_FILTER_H
3 #define PERF_UTIL_BPF_FILTER_H
4
5 #include <linux/list.h>
6
7 #include "bpf_skel/sample-filter.h"
8
9 struct perf_bpf_filter_expr {
10         struct list_head list;
11         enum perf_bpf_filter_op op;
12         unsigned long sample_flags;
13         unsigned long val;
14 };
15
16 struct evsel;
17
18 #ifdef HAVE_BPF_SKEL
19 struct perf_bpf_filter_expr *perf_bpf_filter_expr__new(unsigned long sample_flags,
20                                                        enum perf_bpf_filter_op op,
21                                                        unsigned long val);
22 int perf_bpf_filter__parse(struct list_head *expr_head, const char *str);
23 int perf_bpf_filter__prepare(struct evsel *evsel);
24 int perf_bpf_filter__destroy(struct evsel *evsel);
25
26 #else /* !HAVE_BPF_SKEL */
27
28 static inline int perf_bpf_filter__parse(struct list_head *expr_head __maybe_unused,
29                                          const char *str __maybe_unused)
30 {
31         return -EOPNOTSUPP;
32 }
33 static inline int perf_bpf_filter__prepare(struct evsel *evsel __maybe_unused)
34 {
35         return -EOPNOTSUPP;
36 }
37 static inline int perf_bpf_filter__destroy(struct evsel *evsel __maybe_unused)
38 {
39         return -EOPNOTSUPP;
40 }
41 #endif /* HAVE_BPF_SKEL*/
42 #endif /* PERF_UTIL_BPF_FILTER_H */