xref: /openbmc/linux/tools/lib/perf/include/perf/evsel.h (revision 89e3106f)
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>
79a5b2d1aSShunsuke Nakamura #include <stdbool.h>
89a5b2d1aSShunsuke 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;
21*89e3106fSNamhyung Kim 			uint64_t id;
22*89e3106fSNamhyung Kim 			uint64_t lost;
233ce311afSJiri Olsa 		};
24*89e3106fSNamhyung Kim 		uint64_t values[5];
253ce311afSJiri Olsa 	};
263ce311afSJiri Olsa };
273ce311afSJiri Olsa 
283ce311afSJiri Olsa LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);
293ce311afSJiri Olsa LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);
303ce311afSJiri Olsa LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,
313ce311afSJiri Olsa 				 struct perf_thread_map *threads);
323ce311afSJiri Olsa LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);
337e3d1784SIan Rogers LIBPERF_API void perf_evsel__close_cpu(struct perf_evsel *evsel, int cpu_map_idx);
346cd70754SRob Herring LIBPERF_API int perf_evsel__mmap(struct perf_evsel *evsel, int pages);
356cd70754SRob Herring LIBPERF_API void perf_evsel__munmap(struct perf_evsel *evsel);
367e3d1784SIan Rogers LIBPERF_API void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu_map_idx, int thread);
377e3d1784SIan Rogers LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu_map_idx, int thread,
383ce311afSJiri Olsa 				 struct perf_counts_values *count);
393ce311afSJiri Olsa LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel);
407e3d1784SIan Rogers LIBPERF_API int perf_evsel__enable_cpu(struct perf_evsel *evsel, int cpu_map_idx);
4100632610SAdrian Hunter LIBPERF_API int perf_evsel__enable_thread(struct perf_evsel *evsel, int thread);
423ce311afSJiri Olsa LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel);
437e3d1784SIan Rogers LIBPERF_API int perf_evsel__disable_cpu(struct perf_evsel *evsel, int cpu_map_idx);
443ce311afSJiri Olsa LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel);
453ce311afSJiri Olsa LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);
463ce311afSJiri Olsa LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);
479a5b2d1aSShunsuke Nakamura LIBPERF_API void perf_counts_values__scale(struct perf_counts_values *count,
489a5b2d1aSShunsuke Nakamura 					   bool scale, __s8 *pscaled);
493ce311afSJiri Olsa 
503ce311afSJiri Olsa #endif /* __LIBPERF_EVSEL_H */
51