blob: c3a74e0e17a211a2e802d74b5523d3e17ca45065 [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;
Matt Fleming46441bd2014-09-24 15:04:06 +010033};
34
Kan Liangdcb4e102014-10-07 11:08:50 -040035#define UNIT_MAX_LEN 31 /* max length for event unit name */
36
37struct perf_pmu_alias {
38 char *name;
39 struct list_head terms; /* HEAD struct parse_events_term -> list */
40 struct list_head list; /* ELEM */
41 char unit[UNIT_MAX_LEN+1];
42 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010043 bool per_pkg;
Kan Liangdcb4e102014-10-07 11:08:50 -040044};
45
Adrian Hunterb6b96fb2013-07-04 16:20:25 +030046struct perf_pmu *perf_pmu__find(const char *name);
Jiri Olsacd82a322012-03-15 20:09:17 +010047int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
48 struct list_head *head_terms);
Jiri Olsacff7f952012-11-10 01:46:50 +010049int perf_pmu__config_terms(struct list_head *formats,
50 struct perf_event_attr *attr,
Adrian Hunterdc0a6202014-07-31 09:00:49 +030051 struct list_head *head_terms,
52 bool zero);
Stephane Eranian410136f2013-11-12 17:58:49 +010053int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
Matt Fleming46441bd2014-09-24 15:04:06 +010054 struct perf_pmu_info *info);
Zheng Yana6146d52012-06-15 14:31:41 +080055struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
Arnaldo Carvalho de Melo5c6ccc32013-01-18 16:54:00 -030056 struct list_head *head_terms);
Jiri Olsacd82a322012-03-15 20:09:17 +010057int perf_pmu_wrap(void);
58void perf_pmu_error(struct list_head *list, char *name, char const *msg);
59
60int perf_pmu__new_format(struct list_head *list, char *name,
61 int config, unsigned long *bits);
62void perf_pmu__set_format(unsigned long *bits, long from, long to);
Jiri Olsacff7f952012-11-10 01:46:50 +010063int perf_pmu__format_parse(char *dir, struct list_head *head);
Jiri Olsacd82a322012-03-15 20:09:17 +010064
Robert Richter50a96672012-08-16 21:10:24 +020065struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
66
Andi Kleendc098b32013-04-20 11:02:29 -070067void print_pmu_events(const char *event_glob, bool name_only);
Andi Kleen4cabc3d2013-08-21 16:47:26 -070068bool pmu_have_event(const char *pname, const char *name);
Andi Kleendc098b32013-04-20 11:02:29 -070069
Adrian Hunter7d4bdab2014-07-31 09:00:50 +030070int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
71 ...) __attribute__((format(scanf, 3, 4)));
72
Jiri Olsacd82a322012-03-15 20:09:17 +010073int perf_pmu__test(void);
Adrian Hunterdc0a6202014-07-31 09:00:49 +030074
75struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
76
Jiri Olsacd82a322012-03-15 20:09:17 +010077#endif /* __PMU_H */