xref: /linux/tools/perf/util/tool_pmu.h (revision 60675d4ca1ef0857e44eba5849b74a3a998d0c0f)
1240505b2SIan Rogers /* SPDX-License-Identifier: GPL-2.0 */
2240505b2SIan Rogers #ifndef __TOOL_PMU_H
3240505b2SIan Rogers #define __TOOL_PMU_H
4240505b2SIan Rogers 
5240505b2SIan Rogers #include "pmu.h"
6240505b2SIan Rogers 
7240505b2SIan Rogers struct evsel;
8240505b2SIan Rogers struct perf_thread_map;
9240505b2SIan Rogers struct print_callbacks;
10240505b2SIan Rogers 
110709a82cSIan Rogers enum tool_pmu_event {
120709a82cSIan Rogers 	TOOL_PMU__EVENT_NONE = 0,
1306905723SIan Rogers 	TOOL_PMU__EVENT_DURATION_TIME,
1406905723SIan Rogers 	TOOL_PMU__EVENT_USER_TIME,
1506905723SIan Rogers 	TOOL_PMU__EVENT_SYSTEM_TIME,
1606905723SIan Rogers 	TOOL_PMU__EVENT_HAS_PMEM,
1706905723SIan Rogers 	TOOL_PMU__EVENT_NUM_CORES,
1806905723SIan Rogers 	TOOL_PMU__EVENT_NUM_CPUS,
1906905723SIan Rogers 	TOOL_PMU__EVENT_NUM_CPUS_ONLINE,
2006905723SIan Rogers 	TOOL_PMU__EVENT_NUM_DIES,
2106905723SIan Rogers 	TOOL_PMU__EVENT_NUM_PACKAGES,
2206905723SIan Rogers 	TOOL_PMU__EVENT_SLOTS,
2306905723SIan Rogers 	TOOL_PMU__EVENT_SMT_ON,
2406905723SIan Rogers 	TOOL_PMU__EVENT_SYSTEM_TSC_FREQ,
25240505b2SIan Rogers 
260709a82cSIan Rogers 	TOOL_PMU__EVENT_MAX,
27240505b2SIan Rogers };
28240505b2SIan Rogers 
29b8f1a1b0SIan Rogers #define tool_pmu__for_each_event(ev)					\
300709a82cSIan Rogers 	for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)
31240505b2SIan Rogers 
32b8f1a1b0SIan Rogers const char *tool_pmu__event_to_str(enum tool_pmu_event ev);
33b8f1a1b0SIan Rogers enum tool_pmu_event tool_pmu__str_to_event(const char *str);
34*609aa266SIan Rogers bool tool_pmu__skip_event(const char *name);
35*609aa266SIan Rogers int tool_pmu__num_skip_events(void);
36*609aa266SIan Rogers 
3706905723SIan Rogers bool tool_pmu__read_event(enum tool_pmu_event ev, u64 *result);
3806905723SIan Rogers 
3906905723SIan Rogers u64 tool_pmu__cpu_slots_per_cycle(void);
40240505b2SIan Rogers 
41240505b2SIan Rogers bool perf_pmu__is_tool(const struct perf_pmu *pmu);
42240505b2SIan Rogers 
43240505b2SIan Rogers bool evsel__is_tool(const struct evsel *evsel);
440709a82cSIan Rogers enum tool_pmu_event evsel__tool_event(const struct evsel *evsel);
45240505b2SIan Rogers const char *evsel__tool_pmu_event_name(const struct evsel *evsel);
46240505b2SIan Rogers int evsel__tool_pmu_prepare_open(struct evsel *evsel,
47240505b2SIan Rogers 				 struct perf_cpu_map *cpus,
48240505b2SIan Rogers 				 int nthreads);
49240505b2SIan Rogers int evsel__tool_pmu_open(struct evsel *evsel,
50240505b2SIan Rogers 			 struct perf_thread_map *threads,
51240505b2SIan Rogers 			 int start_cpu_map_idx, int end_cpu_map_idx);
52b8f1a1b0SIan Rogers int evsel__tool_pmu_read(struct evsel *evsel, int cpu_map_idx, int thread);
53240505b2SIan Rogers 
54240505b2SIan Rogers struct perf_pmu *perf_pmus__tool_pmu(void);
55240505b2SIan Rogers 
56240505b2SIan Rogers #endif /* __TOOL_PMU_H */
57