xref: /openbmc/linux/tools/lib/perf/include/perf/evsel.h (revision d2a3b501)
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 			uint64_t id;
22 			uint64_t lost;
23 		};
24 		uint64_t values[5];
25 	};
26 };
27 
28 LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);
29 LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);
30 LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
31 				 struct perf_thread_map *threads);
32 LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);
33 LIBPERF_API void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu_map_idx);
34 LIBPERF_API int perf_evsel__mmap(struct perf_evsel *evsel, int pages);
35 LIBPERF_API void perf_evsel__munmap(struct perf_evsel *evsel);
36 LIBPERF_API void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu_map_idx, int thread);
37 LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu_map_idx, int thread,
38 				 struct perf_counts_values *count);
39 LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel);
40 LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu_map_idx);
41 LIBPERF_API int perf_evsel__enable_thread(struct perf_evsel *evsel, int thread);
42 LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel);
43 LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu_map_idx);
44 LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
45 LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
46 LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
47 LIBPERF_API void perf_counts_values__scale(struct perf_counts_values *count,
48 					   bool scale, __s8 *pscaled);
49 
50 #endif /* __LIBPERF_EVSEL_H */
51