1 #ifndef __PMU_H 2 #define __PMU_H 3 4 #include <linux/bitmap.h> 5 #include <linux/compiler.h> 6 #include <linux/perf_event.h> 7 #include <stdbool.h> 8 #include "evsel.h" 9 #include "parse-events.h" 10 11 enum { 12 PERF_PMU_FORMAT_VALUE_CONFIG, 13 PERF_PMU_FORMAT_VALUE_CONFIG1, 14 PERF_PMU_FORMAT_VALUE_CONFIG2, 15 }; 16 17 #define PERF_PMU_FORMAT_BITS 64 18 19 struct perf_event_attr; 20 21 struct perf_pmu { 22 char *name; 23 __u32 type; 24 bool selectable; 25 struct perf_event_attr *default_config; 26 struct cpu_map *cpus; 27 struct list_head format; /* HEAD struct perf_pmu_format -> list */ 28 struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ 29 struct list_head list; /* ELEM */ 30 int (*set_drv_config) (struct perf_evsel_config_term *term); 31 }; 32 33 struct perf_pmu_info { 34 const char *unit; 35 const char *metric_expr; 36 const char *metric_name; 37 double scale; 38 bool per_pkg; 39 bool snapshot; 40 }; 41 42 #define UNIT_MAX_LEN 31 /* max length for event unit name */ 43 44 struct perf_pmu_alias { 45 char *name; 46 char *desc; 47 char *long_desc; 48 char *topic; 49 char *str; 50 struct list_head terms; /* HEAD struct parse_events_term -> list */ 51 struct list_head list; /* ELEM */ 52 char unit[UNIT_MAX_LEN+1]; 53 double scale; 54 bool per_pkg; 55 bool snapshot; 56 char *metric_expr; 57 char *metric_name; 58 }; 59 60 struct perf_pmu *perf_pmu__find(const char *name); 61 int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, 62 struct list_head *head_terms, 63 struct parse_events_error *error); 64 int perf_pmu__config_terms(struct list_head *formats, 65 struct perf_event_attr *attr, 66 struct list_head *head_terms, 67 bool zero, struct parse_events_error *error); 68 __u64 perf_pmu__format_bits(struct list_head *formats, const char *name); 69 int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, 70 struct perf_pmu_info *info); 71 struct list_head *perf_pmu__alias(struct perf_pmu *pmu, 72 struct list_head *head_terms); 73 int perf_pmu_wrap(void); 74 void perf_pmu_error(struct list_head *list, char *name, char const *msg); 75 76 int perf_pmu__new_format(struct list_head *list, char *name, 77 int config, unsigned long *bits); 78 void perf_pmu__set_format(unsigned long *bits, long from, long to); 79 int perf_pmu__format_parse(char *dir, struct list_head *head); 80 81 struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); 82 83 void print_pmu_events(const char *event_glob, bool name_only, bool quiet, 84 bool long_desc, bool details_flag); 85 bool pmu_have_event(const char *pname, const char *name); 86 87 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, ...) __scanf(3, 4); 88 89 int perf_pmu__test(void); 90 91 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); 92 93 #endif /* __PMU_H */ 94