xref: /linux/tools/perf/util/bpf-filter.h (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
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  	struct list_head groups;
12  	enum perf_bpf_filter_op op;
13  	int part;
14  	enum perf_bpf_filter_term term;
15  	unsigned long val;
16  };
17  
18  struct evsel;
19  struct target;
20  
21  /* path in BPF-fs for the pinned program and maps */
22  #define PERF_BPF_FILTER_PIN_PATH  "perf_filter"
23  
24  #ifdef HAVE_BPF_SKEL
25  struct perf_bpf_filter_expr *perf_bpf_filter_expr__new(enum perf_bpf_filter_term term,
26  						       int part,
27  						       enum perf_bpf_filter_op op,
28  						       unsigned long val);
29  int perf_bpf_filter__parse(struct list_head *expr_head, const char *str);
30  int perf_bpf_filter__prepare(struct evsel *evsel, struct target *target);
31  int perf_bpf_filter__destroy(struct evsel *evsel);
32  u64 perf_bpf_filter__lost_count(struct evsel *evsel);
33  int perf_bpf_filter__pin(void);
34  int perf_bpf_filter__unpin(void);
35  
36  #else /* !HAVE_BPF_SKEL */
37  
perf_bpf_filter__parse(struct list_head * expr_head __maybe_unused,const char * str __maybe_unused)38  static inline int perf_bpf_filter__parse(struct list_head *expr_head __maybe_unused,
39  					 const char *str __maybe_unused)
40  {
41  	return -EOPNOTSUPP;
42  }
perf_bpf_filter__prepare(struct evsel * evsel __maybe_unused,struct target * target __maybe_unused)43  static inline int perf_bpf_filter__prepare(struct evsel *evsel __maybe_unused,
44  					   struct target *target __maybe_unused)
45  {
46  	return -EOPNOTSUPP;
47  }
perf_bpf_filter__destroy(struct evsel * evsel __maybe_unused)48  static inline int perf_bpf_filter__destroy(struct evsel *evsel __maybe_unused)
49  {
50  	return -EOPNOTSUPP;
51  }
perf_bpf_filter__lost_count(struct evsel * evsel __maybe_unused)52  static inline u64 perf_bpf_filter__lost_count(struct evsel *evsel __maybe_unused)
53  {
54  	return 0;
55  }
perf_bpf_filter__pin(void)56  static inline int perf_bpf_filter__pin(void)
57  {
58  	return -EOPNOTSUPP;
59  }
perf_bpf_filter__unpin(void)60  static inline int perf_bpf_filter__unpin(void)
61  {
62  	return -EOPNOTSUPP;
63  }
64  #endif /* HAVE_BPF_SKEL*/
65  #endif /* PERF_UTIL_BPF_FILTER_H */
66