• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __PMU_H
2 #define __PMU_H
3 
4 #include <linux/bitmap.h>
5 #include <linux/perf_event.h>
6 #include <stdbool.h>
7 #include "evsel.h"
8 #include "parse-events.h"
9 
10 enum {
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 
18 struct perf_event_attr;
19 
20 struct perf_pmu {
21 	char *name;
22 	__u32 type;
23 	bool selectable;
24 	struct perf_event_attr *default_config;
25 	struct cpu_map *cpus;
26 	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 */
29 	int (*set_drv_config)	(struct perf_evsel_config_term *term);
30 };
31 
32 struct perf_pmu_info {
33 	const char *unit;
34 	double scale;
35 	bool per_pkg;
36 	bool snapshot;
37 };
38 
39 #define UNIT_MAX_LEN	31 /* max length for event unit name */
40 
41 struct perf_pmu_alias {
42 	char *name;
43 	char *desc;
44 	char *long_desc;
45 	char *topic;
46 	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;
50 	bool per_pkg;
51 	bool snapshot;
52 };
53 
54 struct perf_pmu *perf_pmu__find(const char *name);
55 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
56 		     struct list_head *head_terms,
57 		     struct parse_events_error *error);
58 int perf_pmu__config_terms(struct list_head *formats,
59 			   struct perf_event_attr *attr,
60 			   struct list_head *head_terms,
61 			   bool zero, struct parse_events_error *error);
62 __u64 perf_pmu__format_bits(struct list_head *formats, const char *name);
63 int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
64 			  struct perf_pmu_info *info);
65 struct list_head *perf_pmu__alias(struct perf_pmu *pmu,
66 				  struct list_head *head_terms);
67 int perf_pmu_wrap(void);
68 void perf_pmu_error(struct list_head *list, char *name, char const *msg);
69 
70 int perf_pmu__new_format(struct list_head *list, char *name,
71 			 int config, unsigned long *bits);
72 void perf_pmu__set_format(unsigned long *bits, long from, long to);
73 int perf_pmu__format_parse(char *dir, struct list_head *head);
74 
75 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
76 
77 void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
78 		      bool long_desc);
79 bool pmu_have_event(const char *pname, const char *name);
80 
81 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
82 			...) __attribute__((format(scanf, 3, 4)));
83 
84 int perf_pmu__test(void);
85 
86 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
87 
88 #endif /* __PMU_H */
89