blob: 8092de78e8188dff7e4f23d0f0473b3c1d3b800f [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;
32};
33
Kan Liangdcb4e102014-10-07 11:08:50 -040034#define UNIT_MAX_LEN 31 /* max length for event unit name */
35
36struct perf_pmu_alias {
37 char *name;
38 struct list_head terms; /* HEAD struct parse_events_term -> list */
39 struct list_head list; /* ELEM */
40 char unit[UNIT_MAX_LEN+1];
41 double scale;
42};
43
Adrian Hunterb6b96fb2013-07-04 16:20:25 +030044struct perf_pmu *perf_pmu__find(const char *name);
Jiri Olsacd82a322012-03-15 20:09:17 +010045int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
46 struct list_head *head_terms);
Jiri Olsacff7f952012-11-10 01:46:50 +010047int perf_pmu__config_terms(struct list_head *formats,
48 struct perf_event_attr *attr,
Adrian Hunterdc0a6202014-07-31 09:00:49 +030049 struct list_head *head_terms,
50 bool zero);
Stephane Eranian410136f2013-11-12 17:58:49 +010051int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
Matt Fleming46441bd2014-09-24 15:04:06 +010052 struct perf_pmu_info *info);
Zheng Yana6146d52012-06-15 14:31:41 +080053struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
Arnaldo Carvalho de Melo5c6ccc32013-01-18 16:54:00 -030054 struct list_head *head_terms);
Jiri Olsacd82a322012-03-15 20:09:17 +010055int perf_pmu_wrap(void);
56void perf_pmu_error(struct list_head *list, char *name, char const *msg);
57
58int perf_pmu__new_format(struct list_head *list, char *name,
59 int config, unsigned long *bits);
60void perf_pmu__set_format(unsigned long *bits, long from, long to);
Jiri Olsacff7f952012-11-10 01:46:50 +010061int perf_pmu__format_parse(char *dir, struct list_head *head);
Jiri Olsacd82a322012-03-15 20:09:17 +010062
Robert Richter50a96672012-08-16 21:10:24 +020063struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
64
Andi Kleendc098b32013-04-20 11:02:29 -070065void print_pmu_events(const char *event_glob, bool name_only);
Andi Kleen4cabc3d2013-08-21 16:47:26 -070066bool pmu_have_event(const char *pname, const char *name);
Andi Kleendc098b32013-04-20 11:02:29 -070067
Adrian Hunter7d4bdab2014-07-31 09:00:50 +030068int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
69 ...) __attribute__((format(scanf, 3, 4)));
70
Jiri Olsacd82a322012-03-15 20:09:17 +010071int perf_pmu__test(void);
Adrian Hunterdc0a6202014-07-31 09:00:49 +030072
73struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
74
Jiri Olsacd82a322012-03-15 20:09:17 +010075#endif /* __PMU_H */