Cleanup: move to kernel style SPDX license identifiers
[lttng-modules.git] / instrumentation / events / lttng-module / power.h
CommitLineData
9f36eaed 1/* SPDX-License-Identifier: GPL-2.0 */
b283666f
PW
2#undef TRACE_SYSTEM
3#define TRACE_SYSTEM power
4
3bc29f0a
MD
5#if !defined(LTTNG_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
6#define LTTNG_TRACE_POWER_H
b283666f 7
6ec43db8 8#include <probes/lttng-tracepoint-event.h>
b283666f 9#include <linux/ktime.h>
7c68b363 10#include <linux/version.h>
b283666f 11
7c68b363 12#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3bc29f0a 13LTTNG_TRACEPOINT_EVENT_CLASS(power_cpu,
b283666f
PW
14
15 TP_PROTO(unsigned int state, unsigned int cpu_id),
16
17 TP_ARGS(state, cpu_id),
18
f127e61e
MD
19 TP_FIELDS(
20 ctf_integer(u32, state, state)
21 ctf_integer(u32, cpu_id, cpu_id)
22 )
b283666f
PW
23)
24
3bc29f0a 25LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu, cpu_idle,
9cf29d3e
MD
26
27 power_cpu_idle,
b283666f
PW
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
3bc29f0a 41LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_cpu, cpu_frequency,
9cf29d3e
MD
42
43 power_cpu_frequency,
b283666f
PW
44
45 TP_PROTO(unsigned int frequency, unsigned int cpu_id),
46
47 TP_ARGS(frequency, cpu_id)
48)
49
3bc29f0a 50LTTNG_TRACEPOINT_EVENT_MAP(machine_suspend,
9cf29d3e
MD
51
52 power_machine_suspend,
b283666f
PW
53
54 TP_PROTO(unsigned int state),
55
56 TP_ARGS(state),
57
f127e61e
MD
58 TP_FIELDS(
59 ctf_integer(u32, state, state)
60 )
b283666f 61)
7c68b363
AG
62#endif
63
64#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
3bc29f0a 65LTTNG_TRACEPOINT_EVENT_CLASS(power_wakeup_source,
7c68b363
AG
66
67 TP_PROTO(const char *name, unsigned int state),
68
69 TP_ARGS(name, state),
70
f127e61e
MD
71 TP_FIELDS(
72 ctf_string(name, name)
73 ctf_integer(u64, state, state)
74 )
7c68b363
AG
75)
76
3bc29f0a 77LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source, wakeup_source_activate,
9cf29d3e
MD
78
79 power_wakeup_source_activate,
7c68b363
AG
80
81 TP_PROTO(const char *name, unsigned int state),
82
83 TP_ARGS(name, state)
84)
85
3bc29f0a 86LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_wakeup_source, wakeup_source_deactivate,
9cf29d3e
MD
87
88 power_wakeup_source_deactivate,
7c68b363
AG
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
b283666f 101
b283666f
PW
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 */
3bc29f0a 108LTTNG_TRACEPOINT_EVENT_CLASS(power,
b283666f 109
7c68b363 110#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
111 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
112
113 TP_ARGS(type, state, cpu_id),
7c68b363
AG
114#else
115 TP_PROTO(unsigned int type, unsigned int state),
116
117 TP_ARGS(type, state),
118#endif
b283666f 119
f127e61e
MD
120 TP_FIELDS(
121 ctf_integer(u64, type, type)
122 ctf_integer(u64, state, state)
7c68b363 123#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
f127e61e 124 ctf_integer(u64, cpu_id, cpu_id)
7c68b363 125#endif
f127e61e 126 )
b283666f
PW
127)
128
3bc29f0a 129LTTNG_TRACEPOINT_EVENT_INSTANCE(power, power_start,
b283666f 130
7c68b363 131#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
132 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
133
134 TP_ARGS(type, state, cpu_id)
7c68b363
AG
135#else
136 TP_PROTO(unsigned int type, unsigned int state),
137
138 TP_ARGS(type, state)
139#endif
b283666f
PW
140)
141
3bc29f0a 142LTTNG_TRACEPOINT_EVENT_INSTANCE(power, power_frequency,
b283666f 143
7c68b363 144#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
145 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
146
147 TP_ARGS(type, state, cpu_id)
7c68b363
AG
148#else
149 TP_PROTO(unsigned int type, unsigned int state),
150
151 TP_ARGS(type, state)
152#endif
b283666f
PW
153)
154
3bc29f0a 155LTTNG_TRACEPOINT_EVENT(power_end,
b283666f 156
7c68b363 157#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
b283666f
PW
158 TP_PROTO(unsigned int cpu_id),
159
160 TP_ARGS(cpu_id),
7c68b363
AG
161#else
162 TP_PROTO(int dummy),
163
164 TP_ARGS(dummy),
165#endif
b283666f 166
f127e61e 167 TP_FIELDS(
7c68b363 168#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
f127e61e 169 ctf_integer(u64, cpu_id, cpu_id)
7c68b363 170#else
f127e61e 171 ctf_integer(u64, dummy, 0xffff)
7c68b363 172#endif
f127e61e 173 )
b283666f
PW
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
180enum {
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
191enum {
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 */
199static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
200static inline void trace_power_end(u64 cpuid) {};
7c68b363
AG
201#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
202static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
203static inline void trace_power_end_rcuidle(u64 cpuid) {};
204#endif
b283666f
PW
205static 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
7c68b363 210#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
b283666f
PW
211/*
212 * The clock events are used for clock enable/disable and for
213 * clock rate change
214 */
3bc29f0a 215LTTNG_TRACEPOINT_EVENT_CLASS(power_clock,
b283666f
PW
216
217 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
218
219 TP_ARGS(name, state, cpu_id),
220
f127e61e
MD
221 TP_FIELDS(
222 ctf_string(name, name)
223 ctf_integer(u64, state, state)
224 ctf_integer(u64, cpu_id, cpu_id)
225 )
b283666f
PW
226)
227
3bc29f0a 228LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_enable,
9cf29d3e
MD
229
230 power_clock_enable,
b283666f
PW
231
232 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
233
234 TP_ARGS(name, state, cpu_id)
235)
236
3bc29f0a 237LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_disable,
9cf29d3e
MD
238
239 power_clock_disable,
b283666f
PW
240
241 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
242
243 TP_ARGS(name, state, cpu_id)
244)
245
3bc29f0a 246LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(power_clock, clock_set_rate,
9cf29d3e
MD
247
248 power_clock_set_rate,
b283666f
PW
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 */
3bc29f0a 258LTTNG_TRACEPOINT_EVENT_CLASS(power_domain,
b283666f
PW
259
260 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
261
262 TP_ARGS(name, state, cpu_id),
263
f127e61e
MD
264 TP_FIELDS(
265 ctf_string(name, name)
266 ctf_integer(u64, state, state)
267 ctf_integer(u64, cpu_id, cpu_id)
268 )
b283666f
PW
269)
270
3bc29f0a 271LTTNG_TRACEPOINT_EVENT_INSTANCE(power_domain, power_domain_target,
b283666f
PW
272
273 TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
274
275 TP_ARGS(name, state, cpu_id)
276)
7c68b363
AG
277#endif
278
3bc29f0a 279#endif /* LTTNG_TRACE_POWER_H */
b283666f
PW
280
281/* This part must be outside protection */
6ec43db8 282#include <probes/define_trace.h>
This page took 0.043613 seconds and 4 git commands to generate.