1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/bitmap.h>
6 #include <linux/compiler.h>
7 #include <linux/perf_event.h>
9 #include "parse-events.h"
10 #include "pmu-events/pmu-events.h"
12 struct evsel_config_term
;
15 PERF_PMU_FORMAT_VALUE_CONFIG
,
16 PERF_PMU_FORMAT_VALUE_CONFIG1
,
17 PERF_PMU_FORMAT_VALUE_CONFIG2
,
20 #define PERF_PMU_FORMAT_BITS 64
21 #define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/"
23 struct perf_event_attr
;
25 struct perf_pmu_caps
{
28 struct list_head list
;
38 struct perf_event_attr
*default_config
;
39 struct perf_cpu_map
*cpus
;
40 struct list_head format
; /* HEAD struct perf_pmu_format -> list */
41 struct list_head aliases
; /* HEAD struct perf_pmu_alias -> list */
42 struct list_head caps
; /* HEAD struct perf_pmu_caps -> list */
43 struct list_head list
; /* ELEM */
46 extern struct perf_pmu perf_pmu__fake
;
48 struct perf_pmu_info
{
50 const char *metric_expr
;
51 const char *metric_name
;
57 #define UNIT_MAX_LEN 31 /* max length for event unit name */
59 struct perf_pmu_alias
{
65 struct list_head terms
; /* HEAD struct parse_events_term -> list */
66 struct list_head list
; /* ELEM */
67 char unit
[UNIT_MAX_LEN
+1];
76 struct perf_pmu
*perf_pmu__find(const char *name
);
77 struct perf_pmu
*perf_pmu__find_by_type(unsigned int type
);
78 int perf_pmu__config(struct perf_pmu
*pmu
, struct perf_event_attr
*attr
,
79 struct list_head
*head_terms
,
80 struct parse_events_error
*error
);
81 int perf_pmu__config_terms(const char *pmu_name
, struct list_head
*formats
,
82 struct perf_event_attr
*attr
,
83 struct list_head
*head_terms
,
84 bool zero
, struct parse_events_error
*error
);
85 __u64
perf_pmu__format_bits(struct list_head
*formats
, const char *name
);
86 int perf_pmu__format_type(struct list_head
*formats
, const char *name
);
87 int perf_pmu__check_alias(struct perf_pmu
*pmu
, struct list_head
*head_terms
,
88 struct perf_pmu_info
*info
);
89 struct list_head
*perf_pmu__alias(struct perf_pmu
*pmu
,
90 struct list_head
*head_terms
);
91 void perf_pmu_error(struct list_head
*list
, char *name
, char const *msg
);
93 int perf_pmu__new_format(struct list_head
*list
, char *name
,
94 int config
, unsigned long *bits
);
95 void perf_pmu__set_format(unsigned long *bits
, long from
, long to
);
96 int perf_pmu__format_parse(char *dir
, struct list_head
*head
);
98 struct perf_pmu
*perf_pmu__scan(struct perf_pmu
*pmu
);
100 bool is_pmu_core(const char *name
);
101 void print_pmu_events(const char *event_glob
, bool name_only
, bool quiet
,
102 bool long_desc
, bool details_flag
,
104 bool pmu_have_event(const char *pname
, const char *name
);
106 int perf_pmu__scan_file(struct perf_pmu
*pmu
, const char *name
, const char *fmt
, ...) __scanf(3, 4);
108 int perf_pmu__test(void);
110 struct perf_event_attr
*perf_pmu__get_default_config(struct perf_pmu
*pmu
);
111 void pmu_add_cpu_aliases_map(struct list_head
*head
, struct perf_pmu
*pmu
,
112 struct pmu_events_map
*map
);
114 struct pmu_events_map
*perf_pmu__find_map(struct perf_pmu
*pmu
);
115 bool pmu_uncore_alias_match(const char *pmu_name
, const char *name
);
117 int perf_pmu__convert_scale(const char *scale
, char **end
, double *sval
);
119 int perf_pmu__caps_parse(struct perf_pmu
*pmu
);