1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef __PERF_HEADER_H |
3 | #define |
4 | |
5 | #include <linux/stddef.h> |
6 | #include <linux/perf_event.h> |
7 | #include <sys/types.h> |
8 | #include <stdio.h> // FILE |
9 | #include <stdbool.h> |
10 | #include <linux/bitmap.h> |
11 | #include <linux/types.h> |
12 | #include "env.h" |
13 | #include "pmu.h" |
14 | |
15 | enum { |
16 | = 0, /* always cleared */ |
17 | = 1, |
18 | = 1, |
19 | , |
20 | |
21 | , |
22 | , |
23 | , |
24 | , |
25 | , |
26 | , |
27 | , |
28 | , |
29 | , |
30 | , |
31 | , |
32 | , |
33 | , |
34 | , |
35 | , |
36 | , |
37 | , |
38 | , |
39 | , |
40 | , |
41 | , |
42 | , |
43 | , |
44 | , |
45 | , |
46 | , |
47 | , |
48 | , |
49 | , |
50 | , |
51 | = 256, |
52 | }; |
53 | |
54 | enum { |
55 | , |
56 | , |
57 | }; |
58 | |
59 | struct perf_file_section { |
60 | u64 offset; |
61 | u64 size; |
62 | }; |
63 | |
64 | struct { |
65 | u64 ; |
66 | u64 ; |
67 | u64 ; |
68 | struct perf_file_section ; |
69 | struct perf_file_section ; |
70 | /* event_types is ignored */ |
71 | struct perf_file_section ; |
72 | DECLARE_BITMAP(, HEADER_FEAT_BITS); |
73 | }; |
74 | |
75 | struct { |
76 | u64 ; |
77 | u64 ; |
78 | }; |
79 | |
80 | struct perf_header; |
81 | |
82 | int (struct perf_file_header *, |
83 | struct perf_header *ph, int fd); |
84 | |
85 | struct { |
86 | enum perf_header_version ; |
87 | bool ; |
88 | u64 ; |
89 | u64 ; |
90 | u64 ; |
91 | DECLARE_BITMAP(, HEADER_FEAT_BITS); |
92 | struct perf_env ; |
93 | }; |
94 | |
95 | struct feat_fd { |
96 | struct perf_header *ph; |
97 | int fd; |
98 | void *buf; /* Either buf != NULL or fd >= 0 */ |
99 | ssize_t offset; |
100 | size_t size; |
101 | struct evsel *events; |
102 | }; |
103 | |
104 | struct { |
105 | int (*)(struct feat_fd *ff, struct evlist *evlist); |
106 | void (*)(struct feat_fd *ff, FILE *fp); |
107 | int (*)(struct feat_fd *ff, void *data); |
108 | const char *; |
109 | bool ; |
110 | bool ; |
111 | }; |
112 | |
113 | struct evlist; |
114 | struct perf_session; |
115 | struct perf_tool; |
116 | union perf_event; |
117 | |
118 | extern const char perf_version_string[]; |
119 | |
120 | int (struct perf_session *session, int repipe_fd); |
121 | int (struct perf_session *session, |
122 | struct evlist *evlist, |
123 | int fd, bool at_exit); |
124 | int (int fd); |
125 | |
126 | /* feat_writer writes a feature section to output */ |
127 | struct feat_writer { |
128 | int (*write)(struct feat_writer *fw, void *buf, size_t sz); |
129 | }; |
130 | |
131 | /* feat_copier copies a feature section using feat_writer to output */ |
132 | struct feat_copier { |
133 | int (*copy)(struct feat_copier *fc, int feat, struct feat_writer *fw); |
134 | }; |
135 | |
136 | int (struct perf_session *session, |
137 | struct evlist *evlist, |
138 | int fd, |
139 | struct feat_copier *fc); |
140 | |
141 | size_t perf_session__data_offset(const struct evlist *evlist); |
142 | |
143 | void (struct perf_header *, int feat); |
144 | void (struct perf_header *, int feat); |
145 | bool (const struct perf_header *, int feat); |
146 | |
147 | int (int argc, const char **argv); |
148 | |
149 | int (struct perf_header *, int fd, |
150 | void *data, |
151 | int (*process)(struct perf_file_section *section, |
152 | struct perf_header *ph, |
153 | int feat, int fd, void *data)); |
154 | |
155 | int (struct perf_session *s, FILE *fp, bool full); |
156 | |
157 | int perf_event__process_feature(struct perf_session *session, |
158 | union perf_event *event); |
159 | int perf_event__process_attr(struct perf_tool *tool, union perf_event *event, |
160 | struct evlist **pevlist); |
161 | int perf_event__process_event_update(struct perf_tool *tool, |
162 | union perf_event *event, |
163 | struct evlist **pevlist); |
164 | size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp); |
165 | #ifdef HAVE_LIBTRACEEVENT |
166 | int perf_event__process_tracing_data(struct perf_session *session, |
167 | union perf_event *event); |
168 | #endif |
169 | int perf_event__process_build_id(struct perf_session *session, |
170 | union perf_event *event); |
171 | bool is_perf_magic(u64 magic); |
172 | |
173 | #define NAME_ALIGN 64 |
174 | |
175 | struct feat_fd; |
176 | |
177 | int do_write(struct feat_fd *fd, const void *buf, size_t size); |
178 | |
179 | int write_padded(struct feat_fd *fd, const void *bf, |
180 | size_t count, size_t count_aligned); |
181 | |
182 | #define MAX_CACHE_LVL 4 |
183 | |
184 | int is_cpu_online(unsigned int cpu); |
185 | int build_caches_for_cpu(u32 cpu, struct cpu_cache_level caches[], u32 *cntp); |
186 | |
187 | /* |
188 | * arch specific callback |
189 | */ |
190 | int get_cpuid(char *buffer, size_t sz); |
191 | |
192 | char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused); |
193 | int strcmp_cpuid_str(const char *s1, const char *s2); |
194 | #endif /* __PERF_HEADER_H */ |
195 | |