Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __PERF_BPF_COUNTER_H
3#define __PERF_BPF_COUNTER_H 1
4
5#include <linux/list.h>
6
7struct evsel;
8struct target;
9struct bpf_counter;
10
11typedef int (*bpf_counter_evsel_op)(struct evsel *evsel);
12typedef int (*bpf_counter_evsel_target_op)(struct evsel *evsel,
13 struct target *target);
14typedef int (*bpf_counter_evsel_install_pe_op)(struct evsel *evsel,
15 int cpu,
16 int fd);
17
18struct bpf_counter_ops {
19 bpf_counter_evsel_target_op load;
20 bpf_counter_evsel_op enable;
21 bpf_counter_evsel_op disable;
22 bpf_counter_evsel_op read;
23 bpf_counter_evsel_op destroy;
24 bpf_counter_evsel_install_pe_op install_pe;
25};
26
27struct bpf_counter {
28 void *skel;
29 struct list_head list;
30};
31
32#ifdef HAVE_BPF_SKEL
33
34int bpf_counter__load(struct evsel *evsel, struct target *target);
35int bpf_counter__enable(struct evsel *evsel);
36int bpf_counter__disable(struct evsel *evsel);
37int bpf_counter__read(struct evsel *evsel);
38void bpf_counter__destroy(struct evsel *evsel);
39int bpf_counter__install_pe(struct evsel *evsel, int cpu, int fd);
40
41#else /* HAVE_BPF_SKEL */
42
43#include <linux/err.h>
44
45static inline int bpf_counter__load(struct evsel *evsel __maybe_unused,
46 struct target *target __maybe_unused)
47{
48 return 0;
49}
50
51static inline int bpf_counter__enable(struct evsel *evsel __maybe_unused)
52{
53 return 0;
54}
55
56static inline int bpf_counter__disable(struct evsel *evsel __maybe_unused)
57{
58 return 0;
59}
60
61static inline int bpf_counter__read(struct evsel *evsel __maybe_unused)
62{
63 return -EAGAIN;
64}
65
66static inline void bpf_counter__destroy(struct evsel *evsel __maybe_unused)
67{
68}
69
70static inline int bpf_counter__install_pe(struct evsel *evsel __maybe_unused,
71 int cpu __maybe_unused,
72 int fd __maybe_unused)
73{
74 return 0;
75}
76
77#endif /* HAVE_BPF_SKEL */
78
79#endif /* __PERF_BPF_COUNTER_H */