xref: /openbmc/linux/tools/lib/perf/include/perf/evsel.h (revision c94b731d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LIBPERF_EVSEL_H
3 #define __LIBPERF_EVSEL_H
4 
5 #include <stdint.h>
6 #include <perf/core.h>
7 #include <stdbool.h>
8 #include <linux/types.h>
9 
10 struct perf_evsel;
11 struct perf_event_attr;
12 struct perf_cpu_map;
13 struct perf_thread_map;
14 
15 struct perf_counts_values {
16 	union {
17 		struct {
18 			uint64_t val;
19 			uint64_t ena;
20 			uint64_t run;
21 		};
22 		uint64_t values[3];
23 	};
24 };
25 
26 LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);
27 LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);
28 LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
29 				 struct perf_thread_map *threads);
30 LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);
31 LIBPERF_API void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu_map_idx);
32 LIBPERF_API int perf_evsel__mmap(struct perf_evsel *evsel, int pages);
33 LIBPERF_API void perf_evsel__munmap(struct perf_evsel *evsel);
34 LIBPERF_API void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu_map_idx, int thread);
35 LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu_map_idx, int thread,
36 				 struct perf_counts_values *count);
37 LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel);
38 LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu_map_idx);
39 LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel);
40 LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu_map_idx);
41 LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
42 LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
43 LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
44 LIBPERF_API void perf_counts_values__scale(struct perf_counts_values *count,
45 					   bool scale, __s8 *pscaled);
46 
47 #endif /* __LIBPERF_EVSEL_H */
48