xref: /openbmc/linux/drivers/usb/musb/musb_trace.h (revision 09c434b8)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * musb_trace.h - MUSB Controller Trace Support
4  *
5  * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
6  *
7  * Author: Bin Liu <b-liu@ti.com>
8  */
9 
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM musb
12 
13 #if !defined(__MUSB_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #define __MUSB_TRACE_H
15 
16 #include <linux/types.h>
17 #include <linux/tracepoint.h>
18 #include <linux/usb.h>
19 #include "musb_core.h"
20 #ifdef CONFIG_USB_TI_CPPI41_DMA
21 #include "cppi_dma.h"
22 #endif
23 
24 #define MUSB_MSG_MAX   500
25 
26 TRACE_EVENT(musb_log,
27 	TP_PROTO(struct musb *musb, struct va_format *vaf),
28 	TP_ARGS(musb, vaf),
29 	TP_STRUCT__entry(
30 		__string(name, dev_name(musb->controller))
31 		__dynamic_array(char, msg, MUSB_MSG_MAX)
32 	),
33 	TP_fast_assign(
34 		__assign_str(name, dev_name(musb->controller));
35 		vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va);
36 	),
37 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
38 );
39 
40 DECLARE_EVENT_CLASS(musb_regb,
41 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data),
42 	TP_ARGS(caller, addr, offset, data),
43 	TP_STRUCT__entry(
44 		__field(void *, caller)
45 		__field(const void *, addr)
46 		__field(unsigned int, offset)
47 		__field(u8, data)
48 	),
49 	TP_fast_assign(
50 		__entry->caller = caller;
51 		__entry->addr = addr;
52 		__entry->offset = offset;
53 		__entry->data = data;
54 	),
55 	TP_printk("%pS: %p + %04x: %02x",
56 		__entry->caller, __entry->addr, __entry->offset, __entry->data)
57 );
58 
59 DEFINE_EVENT(musb_regb, musb_readb,
60 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data),
61 	TP_ARGS(caller, addr, offset, data)
62 );
63 
64 DEFINE_EVENT(musb_regb, musb_writeb,
65 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u8 data),
66 	TP_ARGS(caller, addr, offset, data)
67 );
68 
69 DECLARE_EVENT_CLASS(musb_regw,
70 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data),
71 	TP_ARGS(caller, addr, offset, data),
72 	TP_STRUCT__entry(
73 		__field(void *, caller)
74 		__field(const void *, addr)
75 		__field(unsigned int, offset)
76 		__field(u16, data)
77 	),
78 	TP_fast_assign(
79 		__entry->caller = caller;
80 		__entry->addr = addr;
81 		__entry->offset = offset;
82 		__entry->data = data;
83 	),
84 	TP_printk("%pS: %p + %04x: %04x",
85 		__entry->caller, __entry->addr, __entry->offset, __entry->data)
86 );
87 
88 DEFINE_EVENT(musb_regw, musb_readw,
89 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data),
90 	TP_ARGS(caller, addr, offset, data)
91 );
92 
93 DEFINE_EVENT(musb_regw, musb_writew,
94 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u16 data),
95 	TP_ARGS(caller, addr, offset, data)
96 );
97 
98 DECLARE_EVENT_CLASS(musb_regl,
99 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data),
100 	TP_ARGS(caller, addr, offset, data),
101 	TP_STRUCT__entry(
102 		__field(void *, caller)
103 		__field(const void *, addr)
104 		__field(unsigned int, offset)
105 		__field(u32, data)
106 	),
107 	TP_fast_assign(
108 		__entry->caller = caller;
109 		__entry->addr = addr;
110 		__entry->offset = offset;
111 		__entry->data = data;
112 	),
113 	TP_printk("%pS: %p + %04x: %08x",
114 		__entry->caller, __entry->addr, __entry->offset, __entry->data)
115 );
116 
117 DEFINE_EVENT(musb_regl, musb_readl,
118 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data),
119 	TP_ARGS(caller, addr, offset, data)
120 );
121 
122 DEFINE_EVENT(musb_regl, musb_writel,
123 	TP_PROTO(void *caller, const void *addr, unsigned int offset, u32 data),
124 	TP_ARGS(caller, addr, offset, data)
125 );
126 
127 TRACE_EVENT(musb_isr,
128 	TP_PROTO(struct musb *musb),
129 	TP_ARGS(musb),
130 	TP_STRUCT__entry(
131 		__string(name, dev_name(musb->controller))
132 		__field(u8, int_usb)
133 		__field(u16, int_tx)
134 		__field(u16, int_rx)
135 	),
136 	TP_fast_assign(
137 		__assign_str(name, dev_name(musb->controller));
138 		__entry->int_usb = musb->int_usb;
139 		__entry->int_tx = musb->int_tx;
140 		__entry->int_rx = musb->int_rx;
141 	),
142 	TP_printk("%s: usb %02x, tx %04x, rx %04x",
143 		__get_str(name), __entry->int_usb,
144 		__entry->int_tx, __entry->int_rx
145 	)
146 );
147 
148 DECLARE_EVENT_CLASS(musb_urb,
149 	TP_PROTO(struct musb *musb, struct urb *urb),
150 	TP_ARGS(musb, urb),
151 	TP_STRUCT__entry(
152 		__string(name, dev_name(musb->controller))
153 		__field(struct urb *, urb)
154 		__field(unsigned int, pipe)
155 		__field(int, status)
156 		__field(unsigned int, flag)
157 		__field(u32, buf_len)
158 		__field(u32, actual_len)
159 	),
160 	TP_fast_assign(
161 		__assign_str(name, dev_name(musb->controller));
162 		__entry->urb = urb;
163 		__entry->pipe = urb->pipe;
164 		__entry->status = urb->status;
165 		__entry->flag = urb->transfer_flags;
166 		__entry->buf_len = urb->transfer_buffer_length;
167 		__entry->actual_len = urb->actual_length;
168 	),
169 	TP_printk("%s: %p, dev%d ep%d%s, flag 0x%x, len %d/%d, status %d",
170 			__get_str(name), __entry->urb,
171 			usb_pipedevice(__entry->pipe),
172 			usb_pipeendpoint(__entry->pipe),
173 			usb_pipein(__entry->pipe) ? "in" : "out",
174 			__entry->flag,
175 			__entry->actual_len, __entry->buf_len,
176 			__entry->status
177 	)
178 );
179 
180 DEFINE_EVENT(musb_urb, musb_urb_start,
181 	TP_PROTO(struct musb *musb, struct urb *urb),
182 	TP_ARGS(musb, urb)
183 );
184 
185 DEFINE_EVENT(musb_urb, musb_urb_gb,
186 	TP_PROTO(struct musb *musb, struct urb *urb),
187 	TP_ARGS(musb, urb)
188 );
189 
190 DEFINE_EVENT(musb_urb, musb_urb_rx,
191 	TP_PROTO(struct musb *musb, struct urb *urb),
192 	TP_ARGS(musb, urb)
193 );
194 
195 DEFINE_EVENT(musb_urb, musb_urb_tx,
196 	TP_PROTO(struct musb *musb, struct urb *urb),
197 	TP_ARGS(musb, urb)
198 );
199 
200 DEFINE_EVENT(musb_urb, musb_urb_enq,
201 	TP_PROTO(struct musb *musb, struct urb *urb),
202 	TP_ARGS(musb, urb)
203 );
204 
205 DEFINE_EVENT(musb_urb, musb_urb_deq,
206 	TP_PROTO(struct musb *musb, struct urb *urb),
207 	TP_ARGS(musb, urb)
208 );
209 
210 DECLARE_EVENT_CLASS(musb_req,
211 	TP_PROTO(struct musb_request *req),
212 	TP_ARGS(req),
213 	TP_STRUCT__entry(
214 		__field(struct usb_request *, req)
215 		__field(u8, is_tx)
216 		__field(u8, epnum)
217 		__field(int, status)
218 		__field(unsigned int, buf_len)
219 		__field(unsigned int, actual_len)
220 		__field(unsigned int, zero)
221 		__field(unsigned int, short_not_ok)
222 		__field(unsigned int, no_interrupt)
223 	),
224 	TP_fast_assign(
225 		__entry->req = &req->request;
226 		__entry->is_tx = req->tx;
227 		__entry->epnum = req->epnum;
228 		__entry->status = req->request.status;
229 		__entry->buf_len = req->request.length;
230 		__entry->actual_len = req->request.actual;
231 		__entry->zero = req->request.zero;
232 		__entry->short_not_ok = req->request.short_not_ok;
233 		__entry->no_interrupt = req->request.no_interrupt;
234 	),
235 	TP_printk("%p, ep%d %s, %s%s%s, len %d/%d, status %d",
236 			__entry->req, __entry->epnum,
237 			__entry->is_tx ? "tx/IN" : "rx/OUT",
238 			__entry->zero ? "Z" : "z",
239 			__entry->short_not_ok ? "S" : "s",
240 			__entry->no_interrupt ? "I" : "i",
241 			__entry->actual_len, __entry->buf_len,
242 			__entry->status
243 	)
244 );
245 
246 DEFINE_EVENT(musb_req, musb_req_gb,
247 	TP_PROTO(struct musb_request *req),
248 	TP_ARGS(req)
249 );
250 
251 DEFINE_EVENT(musb_req, musb_req_tx,
252 	TP_PROTO(struct musb_request *req),
253 	TP_ARGS(req)
254 );
255 
256 DEFINE_EVENT(musb_req, musb_req_rx,
257 	TP_PROTO(struct musb_request *req),
258 	TP_ARGS(req)
259 );
260 
261 DEFINE_EVENT(musb_req, musb_req_alloc,
262 	TP_PROTO(struct musb_request *req),
263 	TP_ARGS(req)
264 );
265 
266 DEFINE_EVENT(musb_req, musb_req_free,
267 	TP_PROTO(struct musb_request *req),
268 	TP_ARGS(req)
269 );
270 
271 DEFINE_EVENT(musb_req, musb_req_start,
272 	TP_PROTO(struct musb_request *req),
273 	TP_ARGS(req)
274 );
275 
276 DEFINE_EVENT(musb_req, musb_req_enq,
277 	TP_PROTO(struct musb_request *req),
278 	TP_ARGS(req)
279 );
280 
281 DEFINE_EVENT(musb_req, musb_req_deq,
282 	TP_PROTO(struct musb_request *req),
283 	TP_ARGS(req)
284 );
285 
286 #ifdef CONFIG_USB_TI_CPPI41_DMA
287 DECLARE_EVENT_CLASS(musb_cppi41,
288 	TP_PROTO(struct cppi41_dma_channel *ch),
289 	TP_ARGS(ch),
290 	TP_STRUCT__entry(
291 		__field(struct cppi41_dma_channel *, ch)
292 		__string(name, dev_name(ch->hw_ep->musb->controller))
293 		__field(u8, hwep)
294 		__field(u8, port)
295 		__field(u8, is_tx)
296 		__field(u32, len)
297 		__field(u32, prog_len)
298 		__field(u32, xferred)
299 	),
300 	TP_fast_assign(
301 		__entry->ch = ch;
302 		__assign_str(name, dev_name(ch->hw_ep->musb->controller));
303 		__entry->hwep = ch->hw_ep->epnum;
304 		__entry->port = ch->port_num;
305 		__entry->is_tx = ch->is_tx;
306 		__entry->len = ch->total_len;
307 		__entry->prog_len = ch->prog_len;
308 		__entry->xferred = ch->transferred;
309 	),
310 	TP_printk("%s: %p, hwep%d ch%d%s, prog_len %d, len %d/%d",
311 			__get_str(name), __entry->ch, __entry->hwep,
312 			__entry->port, __entry->is_tx ? "tx" : "rx",
313 			__entry->prog_len, __entry->xferred, __entry->len
314 	)
315 );
316 
317 DEFINE_EVENT(musb_cppi41, musb_cppi41_done,
318 	TP_PROTO(struct cppi41_dma_channel *ch),
319 	TP_ARGS(ch)
320 );
321 
322 DEFINE_EVENT(musb_cppi41, musb_cppi41_gb,
323 	TP_PROTO(struct cppi41_dma_channel *ch),
324 	TP_ARGS(ch)
325 );
326 
327 DEFINE_EVENT(musb_cppi41, musb_cppi41_config,
328 	TP_PROTO(struct cppi41_dma_channel *ch),
329 	TP_ARGS(ch)
330 );
331 
332 DEFINE_EVENT(musb_cppi41, musb_cppi41_cont,
333 	TP_PROTO(struct cppi41_dma_channel *ch),
334 	TP_ARGS(ch)
335 );
336 
337 DEFINE_EVENT(musb_cppi41, musb_cppi41_alloc,
338 	TP_PROTO(struct cppi41_dma_channel *ch),
339 	TP_ARGS(ch)
340 );
341 
342 DEFINE_EVENT(musb_cppi41, musb_cppi41_abort,
343 	TP_PROTO(struct cppi41_dma_channel *ch),
344 	TP_ARGS(ch)
345 );
346 
347 DEFINE_EVENT(musb_cppi41, musb_cppi41_free,
348 	TP_PROTO(struct cppi41_dma_channel *ch),
349 	TP_ARGS(ch)
350 );
351 #endif /* CONFIG_USB_TI_CPPI41_DMA */
352 
353 #endif /* __MUSB_TRACE_H */
354 
355 /* this part has to be here */
356 
357 #undef TRACE_INCLUDE_PATH
358 #define TRACE_INCLUDE_PATH .
359 
360 #undef TRACE_INCLUDE_FILE
361 #define TRACE_INCLUDE_FILE musb_trace
362 
363 #include <trace/define_trace.h>
364