Cleanup: move to kernel style SPDX license identifiers
[lttng-modules.git] / instrumentation / events / lttng-module / power.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM power
4
5 #if !defined(LTTNG_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_POWER_H
7
8 #include <probes/lttng-tracepoint-event.h>
9 #include <linux/ktime.h>
10 #include <linux/version.h>
11
12 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13 LTTNG_TRACEPOINT_EVENT_CLASS(power_cpu,
14
15 TP_PROTO(unsigned int state, unsigned int cpu_id),
16
17 TP_ARGS(state, cpu_id),
18
19 TP_FIELDS(
20 ctf_integer(u32, state, state)
21 ctf_integer(u32, cpu_id, cpu_id)
22 )
23 )
24
25 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu, cpu_idle,
26
27 power_cpu_idle,
28
29 TP_PROTO(unsigned int state, unsigned int cpu_id),
30
31 TP_ARGS(state, cpu_id)
32 )
33
34 /* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
35 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
36 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING
37
38 #define PWR_EVENT_EXIT -1
39 #endif
40
41 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu, cpu_frequency,
42
43 power_cpu_frequency,
44
45 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
46
47 TP_ARGS(frequency, cpu_id)
48 )
49
50 LTTNG_TRACEPOINT_EVENT_MAP(machine_suspend,
51
52 power_machine_suspend,
53
54 TP_PROTO(unsigned int state),
55
56 TP_ARGS(state),
57
58 TP_FIELDS(
59 ctf_integer(u32, state, state)
60 )
61 )
62 #endif
63
64 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
65 LTTNG_TRACEPOINT_EVENT_CLASS(power_wakeup_source,
66
67 TP_PROTO(const char *name, unsigned int state),
68
69 TP_ARGS(name, state),
70
71 TP_FIELDS(
72 ctf_string(name, name)
73 ctf_integer(u64, state, state)
74 )
75 )
76
77 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source, wakeup_source_activate,
78
79 power_wakeup_source_activate,
80
81 TP_PROTO(const char *name, unsigned int state),
82
83 TP_ARGS(name, state)
84 )
85
86 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source, wakeup_source_deactivate,
87
88 power_wakeup_source_deactivate,
89
90 TP_PROTO(const char *name, unsigned int state),
91
92 TP_ARGS(name, state)
93 )
94 #endif
95
96 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
97 #undef CONFIG_EVENT_POWER_TRACING_DEPRECATED
98 #define CONFIG_EVENT_POWER_TRACING_DEPRECATED
99 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
100 #endif
101
102 #ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
103
104 /*
105 * The power events are used for cpuidle & suspend (power_start, power_end)
106 * and for cpufreq (power_frequency)
107 */
108 LTTNG_TRACEPOINT_EVENT_CLASS(power,
109
110 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
111 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
112
113 TP_ARGS(type, state, cpu_id),
114 #else
115 TP_PROTO(unsigned int type, unsigned int state),
116
117 TP_ARGS(type, state),
118 #endif
119
120 TP_FIELDS(
121 ctf_integer(u64, type, type)
122 ctf_integer(u64, state, state)
123 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
124 ctf_integer(u64, cpu_id, cpu_id)
125 #endif
126 )
127 )
128
129 LTTNG_TRACEPOINT_EVENT_INSTANCE(power, power_start,
130
131 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
132 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
133
134 TP_ARGS(type, state, cpu_id)
135 #else
136 TP_PROTO(unsigned int type, unsigned int state),
137
138 TP_ARGS(type, state)
139 #endif
140 )
141
142 LTTNG_TRACEPOINT_EVENT_INSTANCE(power, power_frequency,
143
144 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
145 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
146
147 TP_ARGS(type, state, cpu_id)
148 #else
149 TP_PROTO(unsigned int type, unsigned int state),
150
151 TP_ARGS(type, state)
152 #endif
153 )
154
155 LTTNG_TRACEPOINT_EVENT(power_end,
156
157 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
158 TP_PROTO(unsigned int cpu_id),
159
160 TP_ARGS(cpu_id),
161 #else
162 TP_PROTO(int dummy),
163
164 TP_ARGS(dummy),
165 #endif
166
167 TP_FIELDS(
168 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
169 ctf_integer(u64, cpu_id, cpu_id)
170 #else
171 ctf_integer(u64, dummy, 0xffff)
172 #endif
173 )
174 )
175
176 /* Deprecated dummy functions must be protected against multi-declartion */
177 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
178 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
179
180 enum {
181 POWER_NONE = 0,
182 POWER_CSTATE = 1,
183 POWER_PSTATE = 2,
184 };
185 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
186
187 #else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
188
189 #ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
190 #define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
191 enum {
192 POWER_NONE = 0,
193 POWER_CSTATE = 1,
194 POWER_PSTATE = 2,
195 };
196
197 /* These dummy declaration have to be ripped out when the deprecated
198 events get removed */
199 static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
200 static inline void trace_power_end(u64 cpuid) {};
201 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
202 static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
203 static inline void trace_power_end_rcuidle(u64 cpuid) {};
204 #endif
205 static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
206 #endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
207
208 #endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
209
210 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
211 /*
212 * The clock events are used for clock enable/disable and for
213 * clock rate change
214 */
215 LTTNG_TRACEPOINT_EVENT_CLASS(power_clock,
216
217 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
218
219 TP_ARGS(name, state, cpu_id),
220
221 TP_FIELDS(
222 ctf_string(name, name)
223 ctf_integer(u64, state, state)
224 ctf_integer(u64, cpu_id, cpu_id)
225 )
226 )
227
228 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_enable,
229
230 power_clock_enable,
231
232 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
233
234 TP_ARGS(name, state, cpu_id)
235 )
236
237 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_disable,
238
239 power_clock_disable,
240
241 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
242
243 TP_ARGS(name, state, cpu_id)
244 )
245
246 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_set_rate,
247
248 power_clock_set_rate,
249
250 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
251
252 TP_ARGS(name, state, cpu_id)
253 )
254
255 /*
256 * The power domain events are used for power domains transitions
257 */
258 LTTNG_TRACEPOINT_EVENT_CLASS(power_domain,
259
260 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
261
262 TP_ARGS(name, state, cpu_id),
263
264 TP_FIELDS(
265 ctf_string(name, name)
266 ctf_integer(u64, state, state)
267 ctf_integer(u64, cpu_id, cpu_id)
268 )
269 )
270
271 LTTNG_TRACEPOINT_EVENT_INSTANCE(power_domain, power_domain_target,
272
273 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
274
275 TP_ARGS(name, state, cpu_id)
276 )
277 #endif
278
279 #endif /* LTTNG_TRACE_POWER_H */
280
281 /* This part must be outside protection */
282 #include <probes/define_trace.h>
This page took 0.034455 seconds and 4 git commands to generate.