xref: /openbmc/linux/include/trace/events/ufs.h (revision f4c3b83b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
4  */
5 
6 #undef TRACE_SYSTEM
7 #define TRACE_SYSTEM ufs
8 
9 #if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ)
10 #define _TRACE_UFS_H
11 
12 #include <linux/tracepoint.h>
13 
14 #define str_opcode(opcode)						\
15 	__print_symbolic(opcode,					\
16 		{ WRITE_16,		"WRITE_16" },			\
17 		{ WRITE_10,		"WRITE_10" },			\
18 		{ READ_16,		"READ_16" },			\
19 		{ READ_10,		"READ_10" },			\
20 		{ SYNCHRONIZE_CACHE,	"SYNC" },			\
21 		{ UNMAP,		"UNMAP" })
22 
23 #define UFS_LINK_STATES			\
24 	EM(UIC_LINK_OFF_STATE)		\
25 	EM(UIC_LINK_ACTIVE_STATE)	\
26 	EMe(UIC_LINK_HIBERN8_STATE)
27 
28 #define UFS_PWR_MODES			\
29 	EM(UFS_ACTIVE_PWR_MODE)		\
30 	EM(UFS_SLEEP_PWR_MODE)		\
31 	EM(UFS_POWERDOWN_PWR_MODE)	\
32 	EMe(UFS_DEEPSLEEP_PWR_MODE)
33 
34 #define UFSCHD_CLK_GATING_STATES	\
35 	EM(CLKS_OFF)			\
36 	EM(CLKS_ON)			\
37 	EM(REQ_CLKS_OFF)		\
38 	EMe(REQ_CLKS_ON)
39 
40 /* Enums require being exported to userspace, for user tool parsing */
41 #undef EM
42 #undef EMe
43 #define EM(a)	TRACE_DEFINE_ENUM(a);
44 #define EMe(a)	TRACE_DEFINE_ENUM(a);
45 
46 UFS_LINK_STATES;
47 UFS_PWR_MODES;
48 UFSCHD_CLK_GATING_STATES;
49 
50 /*
51  * Now redefine the EM() and EMe() macros to map the enums to the strings
52  * that will be printed in the output.
53  */
54 #undef EM
55 #undef EMe
56 #define EM(a)	{ a, #a },
57 #define EMe(a)	{ a, #a }
58 
59 TRACE_EVENT(ufshcd_clk_gating,
60 
61 	TP_PROTO(const char *dev_name, int state),
62 
63 	TP_ARGS(dev_name, state),
64 
65 	TP_STRUCT__entry(
66 		__string(dev_name, dev_name)
67 		__field(int, state)
68 	),
69 
70 	TP_fast_assign(
71 		__assign_str(dev_name, dev_name);
72 		__entry->state = state;
73 	),
74 
75 	TP_printk("%s: gating state changed to %s",
76 		__get_str(dev_name),
77 		__print_symbolic(__entry->state, UFSCHD_CLK_GATING_STATES))
78 );
79 
80 TRACE_EVENT(ufshcd_clk_scaling,
81 
82 	TP_PROTO(const char *dev_name, const char *state, const char *clk,
83 		u32 prev_state, u32 curr_state),
84 
85 	TP_ARGS(dev_name, state, clk, prev_state, curr_state),
86 
87 	TP_STRUCT__entry(
88 		__string(dev_name, dev_name)
89 		__string(state, state)
90 		__string(clk, clk)
91 		__field(u32, prev_state)
92 		__field(u32, curr_state)
93 	),
94 
95 	TP_fast_assign(
96 		__assign_str(dev_name, dev_name);
97 		__assign_str(state, state);
98 		__assign_str(clk, clk);
99 		__entry->prev_state = prev_state;
100 		__entry->curr_state = curr_state;
101 	),
102 
103 	TP_printk("%s: %s %s from %u to %u Hz",
104 		__get_str(dev_name), __get_str(state), __get_str(clk),
105 		__entry->prev_state, __entry->curr_state)
106 );
107 
108 TRACE_EVENT(ufshcd_auto_bkops_state,
109 
110 	TP_PROTO(const char *dev_name, const char *state),
111 
112 	TP_ARGS(dev_name, state),
113 
114 	TP_STRUCT__entry(
115 		__string(dev_name, dev_name)
116 		__string(state, state)
117 	),
118 
119 	TP_fast_assign(
120 		__assign_str(dev_name, dev_name);
121 		__assign_str(state, state);
122 	),
123 
124 	TP_printk("%s: auto bkops - %s",
125 		__get_str(dev_name), __get_str(state))
126 );
127 
128 DECLARE_EVENT_CLASS(ufshcd_profiling_template,
129 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
130 		 int err),
131 
132 	TP_ARGS(dev_name, profile_info, time_us, err),
133 
134 	TP_STRUCT__entry(
135 		__string(dev_name, dev_name)
136 		__string(profile_info, profile_info)
137 		__field(s64, time_us)
138 		__field(int, err)
139 	),
140 
141 	TP_fast_assign(
142 		__assign_str(dev_name, dev_name);
143 		__assign_str(profile_info, profile_info);
144 		__entry->time_us = time_us;
145 		__entry->err = err;
146 	),
147 
148 	TP_printk("%s: %s: took %lld usecs, err %d",
149 		__get_str(dev_name), __get_str(profile_info),
150 		__entry->time_us, __entry->err)
151 );
152 
153 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_hibern8,
154 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
155 		 int err),
156 	TP_ARGS(dev_name, profile_info, time_us, err));
157 
158 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_gating,
159 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
160 		 int err),
161 	TP_ARGS(dev_name, profile_info, time_us, err));
162 
163 DEFINE_EVENT(ufshcd_profiling_template, ufshcd_profile_clk_scaling,
164 	TP_PROTO(const char *dev_name, const char *profile_info, s64 time_us,
165 		 int err),
166 	TP_ARGS(dev_name, profile_info, time_us, err));
167 
168 DECLARE_EVENT_CLASS(ufshcd_template,
169 	TP_PROTO(const char *dev_name, int err, s64 usecs,
170 		 int dev_state, int link_state),
171 
172 	TP_ARGS(dev_name, err, usecs, dev_state, link_state),
173 
174 	TP_STRUCT__entry(
175 		__field(s64, usecs)
176 		__field(int, err)
177 		__string(dev_name, dev_name)
178 		__field(int, dev_state)
179 		__field(int, link_state)
180 	),
181 
182 	TP_fast_assign(
183 		__entry->usecs = usecs;
184 		__entry->err = err;
185 		__assign_str(dev_name, dev_name);
186 		__entry->dev_state = dev_state;
187 		__entry->link_state = link_state;
188 	),
189 
190 	TP_printk(
191 		"%s: took %lld usecs, dev_state: %s, link_state: %s, err %d",
192 		__get_str(dev_name),
193 		__entry->usecs,
194 		__print_symbolic(__entry->dev_state, UFS_PWR_MODES),
195 		__print_symbolic(__entry->link_state, UFS_LINK_STATES),
196 		__entry->err
197 	)
198 );
199 
200 DEFINE_EVENT(ufshcd_template, ufshcd_system_suspend,
201 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
202 		      int dev_state, int link_state),
203 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
204 
205 DEFINE_EVENT(ufshcd_template, ufshcd_system_resume,
206 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
207 		      int dev_state, int link_state),
208 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
209 
210 DEFINE_EVENT(ufshcd_template, ufshcd_runtime_suspend,
211 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
212 		      int dev_state, int link_state),
213 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
214 
215 DEFINE_EVENT(ufshcd_template, ufshcd_runtime_resume,
216 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
217 		      int dev_state, int link_state),
218 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
219 
220 DEFINE_EVENT(ufshcd_template, ufshcd_init,
221 	     TP_PROTO(const char *dev_name, int err, s64 usecs,
222 		      int dev_state, int link_state),
223 	     TP_ARGS(dev_name, err, usecs, dev_state, link_state));
224 
225 TRACE_EVENT(ufshcd_command,
226 	TP_PROTO(const char *dev_name, const char *str, unsigned int tag,
227 			u32 doorbell, int transfer_len, u32 intr, u64 lba,
228 			u8 opcode, u8 group_id),
229 
230 	TP_ARGS(dev_name, str, tag, doorbell, transfer_len,
231 				intr, lba, opcode, group_id),
232 
233 	TP_STRUCT__entry(
234 		__string(dev_name, dev_name)
235 		__string(str, str)
236 		__field(unsigned int, tag)
237 		__field(u32, doorbell)
238 		__field(int, transfer_len)
239 		__field(u32, intr)
240 		__field(u64, lba)
241 		__field(u8, opcode)
242 		__field(u8, group_id)
243 	),
244 
245 	TP_fast_assign(
246 		__assign_str(dev_name, dev_name);
247 		__assign_str(str, str);
248 		__entry->tag = tag;
249 		__entry->doorbell = doorbell;
250 		__entry->transfer_len = transfer_len;
251 		__entry->intr = intr;
252 		__entry->lba = lba;
253 		__entry->opcode = opcode;
254 		__entry->group_id = group_id;
255 	),
256 
257 	TP_printk(
258 		"%s: %s: tag: %u, DB: 0x%x, size: %d, IS: %u, LBA: %llu, opcode: 0x%x (%s), group_id: 0x%x",
259 		__get_str(str), __get_str(dev_name), __entry->tag,
260 		__entry->doorbell, __entry->transfer_len,
261 		__entry->intr, __entry->lba, (u32)__entry->opcode,
262 		str_opcode(__entry->opcode), (u32)__entry->group_id
263 	)
264 );
265 
266 TRACE_EVENT(ufshcd_uic_command,
267 	TP_PROTO(const char *dev_name, const char *str, u32 cmd,
268 		 u32 arg1, u32 arg2, u32 arg3),
269 
270 	TP_ARGS(dev_name, str, cmd, arg1, arg2, arg3),
271 
272 	TP_STRUCT__entry(
273 		__string(dev_name, dev_name)
274 		__string(str, str)
275 		__field(u32, cmd)
276 		__field(u32, arg1)
277 		__field(u32, arg2)
278 		__field(u32, arg3)
279 	),
280 
281 	TP_fast_assign(
282 		__assign_str(dev_name, dev_name);
283 		__assign_str(str, str);
284 		__entry->cmd = cmd;
285 		__entry->arg1 = arg1;
286 		__entry->arg2 = arg2;
287 		__entry->arg3 = arg3;
288 	),
289 
290 	TP_printk(
291 		"%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x",
292 		__get_str(str), __get_str(dev_name), __entry->cmd,
293 		__entry->arg1, __entry->arg2, __entry->arg3
294 	)
295 );
296 
297 TRACE_EVENT(ufshcd_upiu,
298 	TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf),
299 
300 	TP_ARGS(dev_name, str, hdr, tsf),
301 
302 	TP_STRUCT__entry(
303 		__string(dev_name, dev_name)
304 		__string(str, str)
305 		__array(unsigned char, hdr, 12)
306 		__array(unsigned char, tsf, 16)
307 	),
308 
309 	TP_fast_assign(
310 		__assign_str(dev_name, dev_name);
311 		__assign_str(str, str);
312 		memcpy(__entry->hdr, hdr, sizeof(__entry->hdr));
313 		memcpy(__entry->tsf, tsf, sizeof(__entry->tsf));
314 	),
315 
316 	TP_printk(
317 		"%s: %s: HDR:%s, CDB:%s",
318 		__get_str(str), __get_str(dev_name),
319 		__print_hex(__entry->hdr, sizeof(__entry->hdr)),
320 		__print_hex(__entry->tsf, sizeof(__entry->tsf))
321 	)
322 );
323 
324 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
325 
326 /* This part must be outside protection */
327 #include <trace/define_trace.h>
328