xref: /openbmc/linux/tools/lib/perf/include/perf/evsel.h (revision 9a5b2d1a)
13ce311afSJiri Olsa /* SPDX-License-Identifier: GPL-2.0 */
23ce311afSJiri Olsa #ifndef __LIBPERF_EVSEL_H
33ce311afSJiri Olsa #define __LIBPERF_EVSEL_H
43ce311afSJiri Olsa 
53ce311afSJiri Olsa #include <stdint.h>
63ce311afSJiri Olsa #include <perf/core.h>
7*9a5b2d1aSShunsuke Nakamura #include <stdbool.h>
8*9a5b2d1aSShunsuke Nakamura #include <linux/types.h>
93ce311afSJiri Olsa 
103ce311afSJiri Olsa struct perf_evsel;
113ce311afSJiri Olsa struct perf_event_attr;
123ce311afSJiri Olsa struct perf_cpu_map;
133ce311afSJiri Olsa struct perf_thread_map;
143ce311afSJiri Olsa 
153ce311afSJiri Olsa struct perf_counts_values {
163ce311afSJiri Olsa 	union {
173ce311afSJiri Olsa 		struct {
183ce311afSJiri Olsa 			uint64_t val;
193ce311afSJiri Olsa 			uint64_t ena;
203ce311afSJiri Olsa 			uint64_t run;
213ce311afSJiri Olsa 		};
223ce311afSJiri Olsa 		uint64_t values[3];
233ce311afSJiri Olsa 	};
243ce311afSJiri Olsa };
253ce311afSJiri Olsa 
263ce311afSJiri Olsa LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);
273ce311afSJiri Olsa LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);
283ce311afSJiri Olsa LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
293ce311afSJiri Olsa 				 struct perf_thread_map *threads);
303ce311afSJiri Olsa LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);
313ce311afSJiri Olsa LIBPERF_API void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu);
326cd70754SRob Herring LIBPERF_API int perf_evsel__mmap(struct perf_evsel *evsel, int pages);
336cd70754SRob Herring LIBPERF_API void perf_evsel__munmap(struct perf_evsel *evsel);
346cd70754SRob Herring LIBPERF_API void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu, int thread);
353ce311afSJiri Olsa LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
363ce311afSJiri Olsa 				 struct perf_counts_values *count);
373ce311afSJiri Olsa LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel);
383ce311afSJiri Olsa LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu);
393ce311afSJiri Olsa LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel);
403ce311afSJiri Olsa LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu);
413ce311afSJiri Olsa LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
423ce311afSJiri Olsa LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
433ce311afSJiri Olsa LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
44*9a5b2d1aSShunsuke Nakamura LIBPERF_API void perf_counts_values__scale(struct perf_counts_values *count,
45*9a5b2d1aSShunsuke Nakamura 					   bool scale, __s8 *pscaled);
463ce311afSJiri Olsa 
473ce311afSJiri Olsa #endif /* __LIBPERF_EVSEL_H */
48