xref: /linux/tools/perf/util/tool_pmu.h (revision e18655cf35a5958fbf4ae9ca3ebf28871a3a1801)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __TOOL_PMU_H
3 #define __TOOL_PMU_H
4 
5 #include "pmu.h"
6 
7 struct evsel;
8 struct perf_thread_map;
9 struct print_callbacks;
10 
11 enum tool_pmu_event {
12 	TOOL_PMU__EVENT_NONE = 0,
13 	TOOL_PMU__EVENT_DURATION_TIME,
14 	TOOL_PMU__EVENT_USER_TIME,
15 	TOOL_PMU__EVENT_SYSTEM_TIME,
16 	TOOL_PMU__EVENT_HAS_PMEM,
17 	TOOL_PMU__EVENT_NUM_CORES,
18 	TOOL_PMU__EVENT_NUM_CPUS,
19 	TOOL_PMU__EVENT_NUM_CPUS_ONLINE,
20 	TOOL_PMU__EVENT_NUM_DIES,
21 	TOOL_PMU__EVENT_NUM_PACKAGES,
22 	TOOL_PMU__EVENT_SLOTS,
23 	TOOL_PMU__EVENT_SMT_ON,
24 	TOOL_PMU__EVENT_SYSTEM_TSC_FREQ,
25 
26 	TOOL_PMU__EVENT_MAX,
27 };
28 
29 #define tool_pmu__for_each_event(ev)					\
30 	for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)
31 
32 const char *tool_pmu__event_to_str(enum tool_pmu_event ev);
33 enum tool_pmu_event tool_pmu__str_to_event(const char *str);
34 bool tool_pmu__skip_event(const char *name);
35 int tool_pmu__num_skip_events(void);
36 
37 bool tool_pmu__read_event(enum tool_pmu_event ev, u64 *result);
38 
39 u64 tool_pmu__cpu_slots_per_cycle(void);
40 
41 bool perf_pmu__is_tool(const struct perf_pmu *pmu);
42 
43 bool evsel__is_tool(const struct evsel *evsel);
44 enum tool_pmu_event evsel__tool_event(const struct evsel *evsel);
45 const char *evsel__tool_pmu_event_name(const struct evsel *evsel);
46 int evsel__tool_pmu_prepare_open(struct evsel *evsel,
47 				 struct perf_cpu_map *cpus,
48 				 int nthreads);
49 int evsel__tool_pmu_open(struct evsel *evsel,
50 			 struct perf_thread_map *threads,
51 			 int start_cpu_map_idx, int end_cpu_map_idx);
52 int evsel__tool_pmu_read(struct evsel *evsel, int cpu_map_idx, int thread);
53 
54 struct perf_pmu *perf_pmus__tool_pmu(void);
55 
56 #endif /* __TOOL_PMU_H */
57