blob: 6b1249fbdb5f3a736c7c55a4005bf2c679addfa7 [file] [log] [blame]
Jiri Olsacd82a322012-03-15 20:09:17 +01001#ifndef __PMU_H
2#define __PMU_H
3
Borislav Petkovd944c4e2014-04-25 21:31:02 +02004#include <linux/bitmap.h>
David Howellsd2709c72012-11-19 22:21:03 +00005#include <linux/perf_event.h>
Andi Kleendc098b32013-04-20 11:02:29 -07006#include <stdbool.h>
Jiri Olsacd82a322012-03-15 20:09:17 +01007
8enum {
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
Adrian Hunterdc0a6202014-07-31 09:00:49 +030016struct perf_event_attr;
17
Jiri Olsacd82a322012-03-15 20:09:17 +010018struct perf_pmu {
19 char *name;
20 __u32 type;
Adrian Hunter42634bc2014-10-23 13:45:10 +030021 bool selectable;
Adrian Hunterdc0a6202014-07-31 09:00:49 +030022 struct perf_event_attr *default_config;
Yan, Zheng7ae92e72012-09-10 15:53:50 +080023 struct cpu_map *cpus;
Cody P Schafer885b5932014-08-15 00:26:14 -070024 struct list_head format; /* HEAD struct perf_pmu_format -> list */
25 struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
26 struct list_head list; /* ELEM */
Jiri Olsacd82a322012-03-15 20:09:17 +010027};
28
Matt Fleming46441bd2014-09-24 15:04:06 +010029struct perf_pmu_info {
30 const char *unit;
31 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010032 bool per_pkg;
Jiri Olsa1d9e4462014-11-21 10:31:13 +010033 bool snapshot;
Matt Fleming46441bd2014-09-24 15:04:06 +010034};
35
Kan Liangdcb4e102014-10-07 11:08:50 -040036#define UNIT_MAX_LEN 31 /* max length for event unit name */
37
38struct perf_pmu_alias {
39 char *name;
40 struct list_head terms; /* HEAD struct parse_events_term -> list */
41 struct list_head list; /* ELEM */
42 char unit[UNIT_MAX_LEN+1];
43 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010044 bool per_pkg;
Jiri Olsa1d9e4462014-11-21 10:31:13 +010045 bool snapshot;
Kan Liangdcb4e102014-10-07 11:08:50 -040046};
47
Adrian Hunterb6b96fb2013-07-04 16:20:25 +030048struct perf_pmu *perf_pmu__find(const char *name);
Jiri Olsacd82a322012-03-15 20:09:17 +010049int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
50 struct list_head *head_terms);
Jiri Olsacff7f952012-11-10 01:46:50 +010051int perf_pmu__config_terms(struct list_head *formats,
52 struct perf_event_attr *attr,
Adrian Hunterdc0a6202014-07-31 09:00:49 +030053 struct list_head *head_terms,
54 bool zero);
Stephane Eranian410136f2013-11-12 17:58:49 +010055int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
Matt Fleming46441bd2014-09-24 15:04:06 +010056 struct perf_pmu_info *info);
Zheng Yana6146d52012-06-15 14:31:41 +080057struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
Arnaldo Carvalho de Melo5c6ccc32013-01-18 16:54:00 -030058 struct list_head *head_terms);
Jiri Olsacd82a322012-03-15 20:09:17 +010059int perf_pmu_wrap(void);
60void perf_pmu_error(struct list_head *list, char *name, char const *msg);
61
62int perf_pmu__new_format(struct list_head *list, char *name,
63 int config, unsigned long *bits);
64void perf_pmu__set_format(unsigned long *bits, long from, long to);
Jiri Olsacff7f952012-11-10 01:46:50 +010065int perf_pmu__format_parse(char *dir, struct list_head *head);
Jiri Olsacd82a322012-03-15 20:09:17 +010066
Robert Richter50a96672012-08-16 21:10:24 +020067struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
68
Andi Kleendc098b32013-04-20 11:02:29 -070069void print_pmu_events(const char *event_glob, bool name_only);
Andi Kleen4cabc3d2013-08-21 16:47:26 -070070bool pmu_have_event(const char *pname, const char *name);
Andi Kleendc098b32013-04-20 11:02:29 -070071
Adrian Hunter7d4bdab2014-07-31 09:00:50 +030072int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
73 ...) __attribute__((format(scanf, 3, 4)));
74
Jiri Olsacd82a322012-03-15 20:09:17 +010075int perf_pmu__test(void);
Adrian Hunterdc0a6202014-07-31 09:00:49 +030076
77struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
78
Jiri Olsacd82a322012-03-15 20:09:17 +010079#endif /* __PMU_H */