xref: /openbmc/linux/tools/perf/util/pmu.h (revision 1a4e39c2e5ca2eb494a53ecd73055562f690bca0)
1 #ifndef __PMU_H
2 #define __PMU_H
3 
4 #include <linux/bitmap.h>
5 #include <linux/perf_event.h>
6 #include <stdbool.h>
7 
8 enum {
9 	PERF_PMU_FORMAT_VALUE_CONFIG,
10 	PERF_PMU_FORMAT_VALUE_CONFIG1,
11 	PERF_PMU_FORMAT_VALUE_CONFIG2,
12 };
13 
14 #define PERF_PMU_FORMAT_BITS 64
15 
16 struct perf_event_attr;
17 
18 struct perf_pmu {
19 	char *name;
20 	__u32 type;
21 	struct perf_event_attr *default_config;
22 	struct cpu_map *cpus;
23 	struct list_head format;  /* HEAD struct perf_pmu_format -> list */
24 	struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
25 	struct list_head list;    /* ELEM */
26 };
27 
28 struct perf_pmu_info {
29 	const char *unit;
30 	double scale;
31 };
32 
33 #define UNIT_MAX_LEN	31 /* max length for event unit name */
34 
35 struct perf_pmu_alias {
36 	char *name;
37 	struct list_head terms; /* HEAD struct parse_events_term -> list */
38 	struct list_head list;  /* ELEM */
39 	char unit[UNIT_MAX_LEN+1];
40 	double scale;
41 };
42 
43 struct perf_pmu *perf_pmu__find(const char *name);
44 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
45 		     struct list_head *head_terms);
46 int perf_pmu__config_terms(struct list_head *formats,
47 			   struct perf_event_attr *attr,
48 			   struct list_head *head_terms,
49 			   bool zero);
50 int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
51 			  struct perf_pmu_info *info);
52 struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
53 				  struct list_head *head_terms);
54 int perf_pmu_wrap(void);
55 void perf_pmu_error(struct list_head *list, char *name, char const *msg);
56 
57 int perf_pmu__new_format(struct list_head *list, char *name,
58 			 int config, unsigned long *bits);
59 void perf_pmu__set_format(unsigned long *bits, long from, long to);
60 int perf_pmu__format_parse(char *dir, struct list_head *head);
61 
62 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
63 
64 void print_pmu_events(const char *event_glob, bool name_only);
65 bool pmu_have_event(const char *pname, const char *name);
66 
67 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
68 			...) __attribute__((format(scanf, 3, 4)));
69 
70 int perf_pmu__test(void);
71 
72 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
73 
74 #endif /* __PMU_H */
75