Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
cd82a32e JO |
2 | #ifndef __PMU_H |
3 | #define __PMU_H | |
4 | ||
d944c4ee | 5 | #include <linux/bitmap.h> |
3ee350fb | 6 | #include <linux/compiler.h> |
d2709c7c | 7 | #include <linux/perf_event.h> |
dc098b35 | 8 | #include <stdbool.h> |
859442bd | 9 | #include "evsel.h" |
e64b020b | 10 | #include "parse-events.h" |
cd82a32e JO |
11 | |
12 | enum { | |
13 | PERF_PMU_FORMAT_VALUE_CONFIG, | |
14 | PERF_PMU_FORMAT_VALUE_CONFIG1, | |
15 | PERF_PMU_FORMAT_VALUE_CONFIG2, | |
16 | }; | |
17 | ||
18 | #define PERF_PMU_FORMAT_BITS 64 | |
19 | ||
dc0a6202 AH |
20 | struct perf_event_attr; |
21 | ||
cd82a32e JO |
22 | struct perf_pmu { |
23 | char *name; | |
24 | __u32 type; | |
42634bc7 | 25 | bool selectable; |
66ec1191 | 26 | bool is_uncore; |
dc0a6202 | 27 | struct perf_event_attr *default_config; |
7ae92e74 | 28 | struct cpu_map *cpus; |
885b5930 CS |
29 | struct list_head format; /* HEAD struct perf_pmu_format -> list */ |
30 | struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ | |
31 | struct list_head list; /* ELEM */ | |
859442bd | 32 | int (*set_drv_config) (struct perf_evsel_config_term *term); |
cd82a32e JO |
33 | }; |
34 | ||
46441bdc MF |
35 | struct perf_pmu_info { |
36 | const char *unit; | |
37932c18 | 37 | const char *metric_expr; |
96284814 | 38 | const char *metric_name; |
46441bdc | 39 | double scale; |
044330c1 | 40 | bool per_pkg; |
1d9e446b | 41 | bool snapshot; |
46441bdc MF |
42 | }; |
43 | ||
dcb4e102 KL |
44 | #define UNIT_MAX_LEN 31 /* max length for event unit name */ |
45 | ||
46 | struct perf_pmu_alias { | |
47 | char *name; | |
08e60ed1 | 48 | char *desc; |
c8d6828a | 49 | char *long_desc; |
dd5f1036 | 50 | char *topic; |
f2361024 | 51 | char *str; |
dcb4e102 KL |
52 | struct list_head terms; /* HEAD struct parse_events_term -> list */ |
53 | struct list_head list; /* ELEM */ | |
54 | char unit[UNIT_MAX_LEN+1]; | |
55 | double scale; | |
044330c1 | 56 | bool per_pkg; |
1d9e446b | 57 | bool snapshot; |
00636c3b | 58 | char *metric_expr; |
96284814 | 59 | char *metric_name; |
dcb4e102 KL |
60 | }; |
61 | ||
b6b96fb4 | 62 | struct perf_pmu *perf_pmu__find(const char *name); |
cd82a32e | 63 | int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr, |
e64b020b JO |
64 | struct list_head *head_terms, |
65 | struct parse_events_error *error); | |
cff7f956 JO |
66 | int perf_pmu__config_terms(struct list_head *formats, |
67 | struct perf_event_attr *attr, | |
dc0a6202 | 68 | struct list_head *head_terms, |
e64b020b | 69 | bool zero, struct parse_events_error *error); |
09ff6071 | 70 | __u64 perf_pmu__format_bits(struct list_head *formats, const char *name); |
410136f5 | 71 | int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, |
46441bdc | 72 | struct perf_pmu_info *info); |
a6146d50 | 73 | struct list_head *perf_pmu__alias(struct perf_pmu *pmu, |
5c6ccc37 | 74 | struct list_head *head_terms); |
cd82a32e JO |
75 | int perf_pmu_wrap(void); |
76 | void perf_pmu_error(struct list_head *list, char *name, char const *msg); | |
77 | ||
78 | int perf_pmu__new_format(struct list_head *list, char *name, | |
79 | int config, unsigned long *bits); | |
80 | void perf_pmu__set_format(unsigned long *bits, long from, long to); | |
cff7f956 | 81 | int perf_pmu__format_parse(char *dir, struct list_head *head); |
cd82a32e | 82 | |
50a9667c RR |
83 | struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); |
84 | ||
c8d6828a | 85 | void print_pmu_events(const char *event_glob, bool name_only, bool quiet, |
bf874fcf | 86 | bool long_desc, bool details_flag); |
4cabc3d1 | 87 | bool pmu_have_event(const char *pname, const char *name); |
dc098b35 | 88 | |
3ee350fb | 89 | int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, ...) __scanf(3, 4); |
7d4bdab5 | 90 | |
cd82a32e | 91 | int perf_pmu__test(void); |
dc0a6202 AH |
92 | |
93 | struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); | |
94 | ||
cd82a32e | 95 | #endif /* __PMU_H */ |