File: bpf-filter.h

package info (click to toggle)
linux 6.18.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,742,212 kB
  • sloc: ansic: 26,783,651; asm: 272,129; sh: 148,799; python: 79,242; makefile: 57,742; perl: 36,527; xml: 19,542; cpp: 5,911; yacc: 4,939; lex: 2,950; awk: 1,607; sed: 30; ruby: 25
file content (68 lines) | stat: -rw-r--r-- 1,894 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef PERF_UTIL_BPF_FILTER_H
#define PERF_UTIL_BPF_FILTER_H

#include <linux/list.h>

#include "bpf_skel/sample-filter.h"
#include "util/debug.h"

struct perf_bpf_filter_expr {
	struct list_head list;
	struct list_head groups;
	enum perf_bpf_filter_op op;
	int part;
	enum perf_bpf_filter_term term;
	unsigned long val;
};

struct evsel;
struct target;

/* path in BPF-fs for the pinned program and maps */
#define PERF_BPF_FILTER_PIN_PATH  "perf_filter"

#ifdef HAVE_BPF_SKEL
struct perf_bpf_filter_expr *perf_bpf_filter_expr__new(enum perf_bpf_filter_term term,
						       int part,
						       enum perf_bpf_filter_op op,
						       unsigned long val);
int perf_bpf_filter__parse(struct list_head *expr_head, const char *str);
int perf_bpf_filter__prepare(struct evsel *evsel, struct target *target);
int perf_bpf_filter__destroy(struct evsel *evsel);
u64 perf_bpf_filter__lost_count(struct evsel *evsel);
int perf_bpf_filter__pin(void);
int perf_bpf_filter__unpin(void);

#else /* !HAVE_BPF_SKEL */

static inline int perf_bpf_filter__parse(struct list_head *expr_head __maybe_unused,
					 const char *str __maybe_unused)
{
	pr_err("Error: BPF filter is requested but perf is not built with BPF.\n"
		"\tPlease make sure to build with libbpf and BPF skeleton.\n");
	return -EOPNOTSUPP;
}
static inline int perf_bpf_filter__prepare(struct evsel *evsel __maybe_unused,
					   struct target *target __maybe_unused)
{
	return -EOPNOTSUPP;
}
static inline int perf_bpf_filter__destroy(struct evsel *evsel __maybe_unused)
{
	return -EOPNOTSUPP;
}
static inline u64 perf_bpf_filter__lost_count(struct evsel *evsel __maybe_unused)
{
	return 0;
}
static inline int perf_bpf_filter__pin(void)
{
	return -EOPNOTSUPP;
}
static inline int perf_bpf_filter__unpin(void)
{
	return -EOPNOTSUPP;
}
#endif /* HAVE_BPF_SKEL*/
#endif /* PERF_UTIL_BPF_FILTER_H */