blob: 5d7e84466bee5a0124fe8c81db64e83a9f483e99 [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 Olsae64b0202015-04-22 21:10:21 +02007#include "parse-events.h"
Jiri Olsacd82a322012-03-15 20:09:17 +01008
9enum {
10 PERF_PMU_FORMAT_VALUE_CONFIG,
11 PERF_PMU_FORMAT_VALUE_CONFIG1,
12 PERF_PMU_FORMAT_VALUE_CONFIG2,
13};
14
15#define PERF_PMU_FORMAT_BITS 64
16
Adrian Hunterdc0a6202014-07-31 09:00:49 +030017struct perf_event_attr;
18
Jiri Olsacd82a322012-03-15 20:09:17 +010019struct perf_pmu {
20 char *name;
21 __u32 type;
Adrian Hunter42634bc2014-10-23 13:45:10 +030022 bool selectable;
Adrian Hunterdc0a6202014-07-31 09:00:49 +030023 struct perf_event_attr *default_config;
Yan, Zheng7ae92e72012-09-10 15:53:50 +080024 struct cpu_map *cpus;
Cody P Schafer885b5932014-08-15 00:26:14 -070025 struct list_head format; /* HEAD struct perf_pmu_format -> list */
26 struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
27 struct list_head list; /* ELEM */
Jiri Olsacd82a322012-03-15 20:09:17 +010028};
29
Matt Fleming46441bd2014-09-24 15:04:06 +010030struct perf_pmu_info {
31 const char *unit;
32 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010033 bool per_pkg;
Jiri Olsa1d9e4462014-11-21 10:31:13 +010034 bool snapshot;
Matt Fleming46441bd2014-09-24 15:04:06 +010035};
36
Kan Liangdcb4e102014-10-07 11:08:50 -040037#define UNIT_MAX_LEN 31 /* max length for event unit name */
38
39struct perf_pmu_alias {
40 char *name;
41 struct list_head terms; /* HEAD struct parse_events_term -> list */
42 struct list_head list; /* ELEM */
43 char unit[UNIT_MAX_LEN+1];
44 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010045 bool per_pkg;
Jiri Olsa1d9e4462014-11-21 10:31:13 +010046 bool snapshot;
Kan Liangdcb4e102014-10-07 11:08:50 -040047};
48
Adrian Hunterb6b96fb2013-07-04 16:20:25 +030049struct perf_pmu *perf_pmu__find(const char *name);
Jiri Olsacd82a322012-03-15 20:09:17 +010050int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
Jiri Olsae64b0202015-04-22 21:10:21 +020051 struct list_head *head_terms,
52 struct parse_events_error *error);
Jiri Olsacff7f952012-11-10 01:46:50 +010053int perf_pmu__config_terms(struct list_head *formats,
54 struct perf_event_attr *attr,
Adrian Hunterdc0a6202014-07-31 09:00:49 +030055 struct list_head *head_terms,
Jiri Olsae64b0202015-04-22 21:10:21 +020056 bool zero, struct parse_events_error *error);
Adrian Hunter09ff6072015-07-17 19:33:49 +030057__u64 perf_pmu__format_bits(struct list_head *formats, const char *name);
Stephane Eranian410136f2013-11-12 17:58:49 +010058int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
Matt Fleming46441bd2014-09-24 15:04:06 +010059 struct perf_pmu_info *info);
Zheng Yana6146d52012-06-15 14:31:41 +080060struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
Arnaldo Carvalho de Melo5c6ccc32013-01-18 16:54:00 -030061 struct list_head *head_terms);
Jiri Olsacd82a322012-03-15 20:09:17 +010062int perf_pmu_wrap(void);
63void perf_pmu_error(struct list_head *list, char *name, char const *msg);
64
65int perf_pmu__new_format(struct list_head *list, char *name,
66 int config, unsigned long *bits);
67void perf_pmu__set_format(unsigned long *bits, long from, long to);
Jiri Olsacff7f952012-11-10 01:46:50 +010068int perf_pmu__format_parse(char *dir, struct list_head *head);
Jiri Olsacd82a322012-03-15 20:09:17 +010069
Robert Richter50a96672012-08-16 21:10:24 +020070struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
71
Andi Kleendc098b32013-04-20 11:02:29 -070072void print_pmu_events(const char *event_glob, bool name_only);
Andi Kleen4cabc3d2013-08-21 16:47:26 -070073bool pmu_have_event(const char *pname, const char *name);
Andi Kleendc098b32013-04-20 11:02:29 -070074
Adrian Hunter7d4bdab2014-07-31 09:00:50 +030075int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
76 ...) __attribute__((format(scanf, 3, 4)));
77
Jiri Olsacd82a322012-03-15 20:09:17 +010078int perf_pmu__test(void);
Adrian Hunterdc0a6202014-07-31 09:00:49 +030079
80struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
81
Jiri Olsacd82a322012-03-15 20:09:17 +010082#endif /* __PMU_H */