1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PMU_EVENTS_H
3 #define PMU_EVENTS_H
4 
5 struct perf_pmu;
6 
7 enum aggr_mode_class {
8 	PerChip = 1,
9 	PerCore
10 };
11 
12 /*
13  * Describe each PMU event. Each CPU has a table of PMU events.
14  */
15 struct pmu_event {
16 	const char *name;
17 	const char *compat;
18 	const char *event;
19 	const char *desc;
20 	const char *topic;
21 	const char *long_desc;
22 	const char *pmu;
23 	const char *unit;
24 	const char *perpkg;
25 	const char *aggr_mode;
26 	const char *deprecated;
27 };
28 
29 struct pmu_metric {
30 	const char *metric_name;
31 	const char *metric_group;
32 	const char *metric_expr;
33 	const char *unit;
34 	const char *compat;
35 	const char *aggr_mode;
36 	const char *metric_constraint;
37 	const char *desc;
38 	const char *long_desc;
39 };
40 
41 struct pmu_events_table;
42 struct pmu_metrics_table;
43 
44 typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe,
45 				 const struct pmu_events_table *table,
46 				 void *data);
47 
48 typedef int (*pmu_metric_iter_fn)(const struct pmu_metric *pm,
49 				  const struct pmu_metrics_table *table,
50 				  void *data);
51 
52 int pmu_events_table_for_each_event(const struct pmu_events_table *table, pmu_event_iter_fn fn,
53 				    void *data);
54 int pmu_metrics_table_for_each_metric(const struct pmu_metrics_table *table, pmu_metric_iter_fn fn,
55 				     void *data);
56 
57 const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu);
58 const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu);
59 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid);
60 const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid);
61 int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data);
62 int pmu_for_each_core_metric(pmu_metric_iter_fn fn, void *data);
63 
64 const struct pmu_events_table *find_sys_events_table(const char *name);
65 const struct pmu_metrics_table *find_sys_metrics_table(const char *name);
66 int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data);
67 int pmu_for_each_sys_metric(pmu_metric_iter_fn fn, void *data);
68 
69 #endif
70