blob: 25712034c815ba92856a03b5d6164ff158a9ad5c [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>
Mathieu Poirier859442b2016-09-16 09:50:02 -06007#include "evsel.h"
Jiri Olsae64b0202015-04-22 21:10:21 +02008#include "parse-events.h"
Jiri Olsacd82a322012-03-15 20:09:17 +01009
10enum {
11 PERF_PMU_FORMAT_VALUE_CONFIG,
12 PERF_PMU_FORMAT_VALUE_CONFIG1,
13 PERF_PMU_FORMAT_VALUE_CONFIG2,
14};
15
16#define PERF_PMU_FORMAT_BITS 64
17
Adrian Hunterdc0a6202014-07-31 09:00:49 +030018struct perf_event_attr;
19
Jiri Olsacd82a322012-03-15 20:09:17 +010020struct perf_pmu {
21 char *name;
22 __u32 type;
Adrian Hunter42634bc2014-10-23 13:45:10 +030023 bool selectable;
Adrian Hunterdc0a6202014-07-31 09:00:49 +030024 struct perf_event_attr *default_config;
Yan, Zheng7ae92e72012-09-10 15:53:50 +080025 struct cpu_map *cpus;
Cody P Schafer885b5932014-08-15 00:26:14 -070026 struct list_head format; /* HEAD struct perf_pmu_format -> list */
27 struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
28 struct list_head list; /* ELEM */
Mathieu Poirier859442b2016-09-16 09:50:02 -060029 int (*set_drv_config) (struct perf_evsel_config_term *term);
Jiri Olsacd82a322012-03-15 20:09:17 +010030};
31
Matt Fleming46441bd2014-09-24 15:04:06 +010032struct perf_pmu_info {
33 const char *unit;
34 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010035 bool per_pkg;
Jiri Olsa1d9e4462014-11-21 10:31:13 +010036 bool snapshot;
Matt Fleming46441bd2014-09-24 15:04:06 +010037};
38
Kan Liangdcb4e102014-10-07 11:08:50 -040039#define UNIT_MAX_LEN 31 /* max length for event unit name */
40
41struct perf_pmu_alias {
42 char *name;
Andi Kleen08e60ed2016-09-15 15:24:43 -070043 char *desc;
Sukadev Bhattiproluc8d68282016-09-15 15:24:48 -070044 char *long_desc;
Andi Kleendd5f1032016-09-15 15:24:50 -070045 char *topic;
Kan Liangdcb4e102014-10-07 11:08:50 -040046 struct list_head terms; /* HEAD struct parse_events_term -> list */
47 struct list_head list; /* ELEM */
48 char unit[UNIT_MAX_LEN+1];
49 double scale;
Matt Fleming044330c2014-11-21 10:31:12 +010050 bool per_pkg;
Jiri Olsa1d9e4462014-11-21 10:31:13 +010051 bool snapshot;
Kan Liangdcb4e102014-10-07 11:08:50 -040052};
53
Adrian Hunterb6b96fb2013-07-04 16:20:25 +030054struct perf_pmu *perf_pmu__find(const char *name);
Jiri Olsacd82a322012-03-15 20:09:17 +010055int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
Jiri Olsae64b0202015-04-22 21:10:21 +020056 struct list_head *head_terms,
57 struct parse_events_error *error);
Jiri Olsacff7f952012-11-10 01:46:50 +010058int perf_pmu__config_terms(struct list_head *formats,
59 struct perf_event_attr *attr,
Adrian Hunterdc0a6202014-07-31 09:00:49 +030060 struct list_head *head_terms,
Jiri Olsae64b0202015-04-22 21:10:21 +020061 bool zero, struct parse_events_error *error);
Adrian Hunter09ff6072015-07-17 19:33:49 +030062__u64 perf_pmu__format_bits(struct list_head *formats, const char *name);
Stephane Eranian410136f2013-11-12 17:58:49 +010063int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
Matt Fleming46441bd2014-09-24 15:04:06 +010064 struct perf_pmu_info *info);
Zheng Yana6146d52012-06-15 14:31:41 +080065struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
Arnaldo Carvalho de Melo5c6ccc32013-01-18 16:54:00 -030066 struct list_head *head_terms);
Jiri Olsacd82a322012-03-15 20:09:17 +010067int perf_pmu_wrap(void);
68void perf_pmu_error(struct list_head *list, char *name, char const *msg);
69
70int perf_pmu__new_format(struct list_head *list, char *name,
71 int config, unsigned long *bits);
72void perf_pmu__set_format(unsigned long *bits, long from, long to);
Jiri Olsacff7f952012-11-10 01:46:50 +010073int perf_pmu__format_parse(char *dir, struct list_head *head);
Jiri Olsacd82a322012-03-15 20:09:17 +010074
Robert Richter50a96672012-08-16 21:10:24 +020075struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
76
Sukadev Bhattiproluc8d68282016-09-15 15:24:48 -070077void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
78 bool long_desc);
Andi Kleen4cabc3d2013-08-21 16:47:26 -070079bool pmu_have_event(const char *pname, const char *name);
Andi Kleendc098b32013-04-20 11:02:29 -070080
Adrian Hunter7d4bdab2014-07-31 09:00:50 +030081int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
82 ...) __attribute__((format(scanf, 3, 4)));
83
Jiri Olsacd82a322012-03-15 20:09:17 +010084int perf_pmu__test(void);
Adrian Hunterdc0a6202014-07-31 09:00:49 +030085
86struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
87
Jiri Olsacd82a322012-03-15 20:09:17 +010088#endif /* __PMU_H */