xref: /openbmc/linux/drivers/usb/cdns3/cdnsp-trace.h (revision 2a954832)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Cadence CDNSP DRD Driver.
4  * Trace support header file
5  *
6  * Copyright (C) 2020 Cadence.
7  *
8  * Author: Pawel Laszczak <pawell@cadence.com>
9  *
10  */
11 
12 #undef TRACE_SYSTEM
13 #define TRACE_SYSTEM cdnsp-dev
14 
15 /*
16  * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
17  * legitimate C variable. It is not exported to user space.
18  */
19 #undef TRACE_SYSTEM_VAR
20 #define TRACE_SYSTEM_VAR cdnsp_dev
21 
22 #if !defined(__CDNSP_DEV_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
23 #define __CDNSP_DEV_TRACE_H
24 
25 #include <linux/tracepoint.h>
26 #include "cdnsp-gadget.h"
27 #include "cdnsp-debug.h"
28 
29 /*
30  * There is limitation for single buffer size in TRACEPOINT subsystem.
31  * By default TRACE_BUF_SIZE is 1024, so no all data will be logged.
32  * To show more data this must be increased. In most cases the default
33  * value is sufficient.
34  */
35 #define CDNSP_MSG_MAX 500
36 
37 DECLARE_EVENT_CLASS(cdnsp_log_ep,
38 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
39 	TP_ARGS(pep, stream_id),
40 	TP_STRUCT__entry(
41 		__string(name, pep->name)
42 		__field(unsigned int, state)
43 		__field(u32, stream_id)
44 		__field(u8, enabled)
45 		__field(unsigned int, num_streams)
46 		__field(int, td_count)
47 		__field(u8, first_prime_det)
48 		__field(u8, drbls_count)
49 	),
50 	TP_fast_assign(
51 		__assign_str(name, pep->name);
52 		__entry->state = pep->ep_state;
53 		__entry->stream_id = stream_id;
54 		__entry->enabled = pep->ep_state & EP_HAS_STREAMS;
55 		__entry->num_streams = pep->stream_info.num_streams;
56 		__entry->td_count = pep->stream_info.td_count;
57 		__entry->first_prime_det = pep->stream_info.first_prime_det;
58 		__entry->drbls_count = pep->stream_info.drbls_count;
59 	),
60 	TP_printk("%s: SID: %08x, ep state: %x, stream: enabled: %d num %d "
61 		  "tds %d, first prime: %d drbls %d",
62 		  __get_str(name), __entry->stream_id, __entry->state,
63 		  __entry->enabled, __entry->num_streams, __entry->td_count,
64 		  __entry->first_prime_det, __entry->drbls_count)
65 );
66 
67 DEFINE_EVENT(cdnsp_log_ep, cdnsp_tr_drbl,
68 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
69 	TP_ARGS(pep, stream_id)
70 );
71 
72 DEFINE_EVENT(cdnsp_log_ep, cdnsp_wait_for_prime,
73 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
74 	TP_ARGS(pep, stream_id)
75 );
76 
77 DEFINE_EVENT(cdnsp_log_ep, cdnsp_ep_list_empty_with_skip,
78 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
79 	TP_ARGS(pep, stream_id)
80 );
81 
82 DEFINE_EVENT(cdnsp_log_ep, cdnsp_ep_enable_end,
83 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
84 	TP_ARGS(pep, stream_id)
85 );
86 
87 DEFINE_EVENT(cdnsp_log_ep, cdnsp_ep_disable_end,
88 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
89 	TP_ARGS(pep, stream_id)
90 );
91 
92 DEFINE_EVENT(cdnsp_log_ep, cdnsp_ep_busy_try_halt_again,
93 	TP_PROTO(struct cdnsp_ep *pep, u32 stream_id),
94 	TP_ARGS(pep, stream_id)
95 );
96 
97 DECLARE_EVENT_CLASS(cdnsp_log_enable_disable,
98 	TP_PROTO(int set),
99 	TP_ARGS(set),
100 	TP_STRUCT__entry(
101 		__field(int, set)
102 	),
103 	TP_fast_assign(
104 		__entry->set = set;
105 	),
106 	TP_printk("%s", __entry->set ? "enabled" : "disabled")
107 );
108 
109 DEFINE_EVENT(cdnsp_log_enable_disable, cdnsp_pullup,
110 	TP_PROTO(int set),
111 	TP_ARGS(set)
112 );
113 
114 DEFINE_EVENT(cdnsp_log_enable_disable, cdnsp_u1,
115 	TP_PROTO(int set),
116 	TP_ARGS(set)
117 );
118 
119 DEFINE_EVENT(cdnsp_log_enable_disable, cdnsp_u2,
120 	TP_PROTO(int set),
121 	TP_ARGS(set)
122 );
123 
124 DEFINE_EVENT(cdnsp_log_enable_disable, cdnsp_lpm,
125 	TP_PROTO(int set),
126 	TP_ARGS(set)
127 );
128 
129 DEFINE_EVENT(cdnsp_log_enable_disable, cdnsp_may_wakeup,
130 	TP_PROTO(int set),
131 	TP_ARGS(set)
132 );
133 
134 DECLARE_EVENT_CLASS(cdnsp_log_simple,
135 	TP_PROTO(char *msg),
136 	TP_ARGS(msg),
137 	TP_STRUCT__entry(
138 		__string(text, msg)
139 	),
140 	TP_fast_assign(
141 		__assign_str(text, msg);
142 	),
143 	TP_printk("%s", __get_str(text))
144 );
145 
146 DEFINE_EVENT(cdnsp_log_simple, cdnsp_exit,
147 	TP_PROTO(char *msg),
148 	TP_ARGS(msg)
149 );
150 
151 DEFINE_EVENT(cdnsp_log_simple, cdnsp_init,
152 	TP_PROTO(char *msg),
153 	TP_ARGS(msg)
154 );
155 
156 DEFINE_EVENT(cdnsp_log_simple, cdnsp_slot_id,
157 	TP_PROTO(char *msg),
158 	TP_ARGS(msg)
159 );
160 
161 DEFINE_EVENT(cdnsp_log_simple, cdnsp_no_room_on_ring,
162 	TP_PROTO(char *msg),
163 	TP_ARGS(msg)
164 );
165 
166 DEFINE_EVENT(cdnsp_log_simple, cdnsp_ep0_status_stage,
167 	TP_PROTO(char *msg),
168 	TP_ARGS(msg)
169 );
170 
171 DEFINE_EVENT(cdnsp_log_simple, cdnsp_ep0_request,
172 	TP_PROTO(char *msg),
173 	TP_ARGS(msg)
174 );
175 
176 DEFINE_EVENT(cdnsp_log_simple, cdnsp_ep0_set_config,
177 	TP_PROTO(char *msg),
178 	TP_ARGS(msg)
179 );
180 
181 DEFINE_EVENT(cdnsp_log_simple, cdnsp_ep0_halted,
182 	TP_PROTO(char *msg),
183 	TP_ARGS(msg)
184 );
185 
186 DEFINE_EVENT(cdnsp_log_simple, cdnsp_ep_halt,
187 	TP_PROTO(char *msg),
188 	TP_ARGS(msg)
189 );
190 
191 TRACE_EVENT(cdnsp_looking_trb_in_td,
192 	TP_PROTO(dma_addr_t suspect, dma_addr_t trb_start, dma_addr_t trb_end,
193 		 dma_addr_t curr_seg, dma_addr_t end_seg),
194 	TP_ARGS(suspect, trb_start, trb_end, curr_seg, end_seg),
195 	TP_STRUCT__entry(
196 		__field(dma_addr_t, suspect)
197 		__field(dma_addr_t, trb_start)
198 		__field(dma_addr_t, trb_end)
199 		__field(dma_addr_t, curr_seg)
200 		__field(dma_addr_t, end_seg)
201 	),
202 	TP_fast_assign(
203 		__entry->suspect = suspect;
204 		__entry->trb_start = trb_start;
205 		__entry->trb_end = trb_end;
206 		__entry->curr_seg = curr_seg;
207 		__entry->end_seg = end_seg;
208 	),
209 	TP_printk("DMA: suspect event: %pad, trb-start: %pad, trb-end %pad, "
210 		  "seg-start %pad, seg-end %pad",
211 		  &__entry->suspect, &__entry->trb_start, &__entry->trb_end,
212 		  &__entry->curr_seg, &__entry->end_seg)
213 );
214 
215 TRACE_EVENT(cdnsp_port_info,
216 	TP_PROTO(__le32 __iomem *addr, u32 offset, u32 count, u32 rev),
217 	TP_ARGS(addr, offset, count, rev),
218 	TP_STRUCT__entry(
219 		__field(__le32 __iomem *, addr)
220 		__field(u32, offset)
221 		__field(u32, count)
222 		__field(u32, rev)
223 	),
224 	TP_fast_assign(
225 		__entry->addr = addr;
226 		__entry->offset = offset;
227 		__entry->count = count;
228 		__entry->rev = rev;
229 	),
230 	TP_printk("Ext Cap %p, port offset = %u, count = %u, rev = 0x%x",
231 		  __entry->addr, __entry->offset, __entry->count, __entry->rev)
232 );
233 
234 DECLARE_EVENT_CLASS(cdnsp_log_deq_state,
235 	TP_PROTO(struct cdnsp_dequeue_state *state),
236 	TP_ARGS(state),
237 	TP_STRUCT__entry(
238 		__field(int, new_cycle_state)
239 		__field(struct cdnsp_segment *, new_deq_seg)
240 		__field(dma_addr_t, deq_seg_dma)
241 		__field(union cdnsp_trb	*, new_deq_ptr)
242 		__field(dma_addr_t, deq_ptr_dma)
243 	),
244 	TP_fast_assign(
245 		__entry->new_cycle_state = state->new_cycle_state;
246 		__entry->new_deq_seg = state->new_deq_seg;
247 		__entry->deq_seg_dma = state->new_deq_seg->dma;
248 		__entry->new_deq_ptr = state->new_deq_ptr,
249 		__entry->deq_ptr_dma = cdnsp_trb_virt_to_dma(state->new_deq_seg,
250 							     state->new_deq_ptr);
251 	),
252 	TP_printk("New cycle state = 0x%x, New dequeue segment = %p (0x%pad dma), "
253 		  "New dequeue pointer = %p (0x%pad dma)",
254 		  __entry->new_cycle_state, __entry->new_deq_seg,
255 		  &__entry->deq_seg_dma, __entry->new_deq_ptr,
256 		  &__entry->deq_ptr_dma
257 	)
258 );
259 
260 DEFINE_EVENT(cdnsp_log_deq_state, cdnsp_new_deq_state,
261 	TP_PROTO(struct cdnsp_dequeue_state *state),
262 	TP_ARGS(state)
263 );
264 
265 DECLARE_EVENT_CLASS(cdnsp_log_ctrl,
266 	TP_PROTO(struct usb_ctrlrequest *ctrl),
267 	TP_ARGS(ctrl),
268 	TP_STRUCT__entry(
269 		__field(u8, bRequestType)
270 		__field(u8, bRequest)
271 		__field(u16, wValue)
272 		__field(u16, wIndex)
273 		__field(u16, wLength)
274 	),
275 	TP_fast_assign(
276 		__entry->bRequestType = ctrl->bRequestType;
277 		__entry->bRequest = ctrl->bRequest;
278 		__entry->wValue = le16_to_cpu(ctrl->wValue);
279 		__entry->wIndex = le16_to_cpu(ctrl->wIndex);
280 		__entry->wLength = le16_to_cpu(ctrl->wLength);
281 	),
282 	TP_printk("%s", usb_decode_ctrl(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX,
283 					__entry->bRequestType,
284 					__entry->bRequest, __entry->wValue,
285 					__entry->wIndex, __entry->wLength)
286 	)
287 );
288 
289 DEFINE_EVENT(cdnsp_log_ctrl, cdnsp_ctrl_req,
290 	TP_PROTO(struct usb_ctrlrequest *ctrl),
291 	TP_ARGS(ctrl)
292 );
293 
294 DECLARE_EVENT_CLASS(cdnsp_log_bounce,
295 	TP_PROTO(struct cdnsp_request *preq, u32 new_buf_len, u32 offset,
296 		 dma_addr_t dma, unsigned int unalign),
297 	TP_ARGS(preq, new_buf_len, offset, dma, unalign),
298 	TP_STRUCT__entry(
299 		__string(name, preq->pep->name)
300 		__field(u32, new_buf_len)
301 		__field(u32, offset)
302 		__field(dma_addr_t, dma)
303 		__field(unsigned int, unalign)
304 	),
305 	TP_fast_assign(
306 		__assign_str(name, preq->pep->name);
307 		__entry->new_buf_len = new_buf_len;
308 		__entry->offset = offset;
309 		__entry->dma = dma;
310 		__entry->unalign = unalign;
311 	),
312 	TP_printk("%s buf len %d, offset %d, dma %pad, unalign %d",
313 		  __get_str(name), __entry->new_buf_len,
314 		  __entry->offset, &__entry->dma, __entry->unalign
315 	)
316 );
317 
318 DEFINE_EVENT(cdnsp_log_bounce, cdnsp_bounce_align_td_split,
319 	TP_PROTO(struct cdnsp_request *preq, u32 new_buf_len, u32 offset,
320 		 dma_addr_t dma, unsigned int unalign),
321 	TP_ARGS(preq, new_buf_len, offset, dma, unalign)
322 );
323 
324 DEFINE_EVENT(cdnsp_log_bounce, cdnsp_bounce_map,
325 	TP_PROTO(struct cdnsp_request *preq, u32 new_buf_len, u32 offset,
326 		 dma_addr_t dma, unsigned int unalign),
327 	TP_ARGS(preq, new_buf_len, offset, dma, unalign)
328 );
329 
330 DEFINE_EVENT(cdnsp_log_bounce, cdnsp_bounce_unmap,
331 	TP_PROTO(struct cdnsp_request *preq, u32 new_buf_len, u32 offset,
332 		 dma_addr_t dma, unsigned int unalign),
333 	TP_ARGS(preq, new_buf_len, offset, dma, unalign)
334 );
335 
336 DECLARE_EVENT_CLASS(cdnsp_log_trb,
337 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
338 	TP_ARGS(ring, trb),
339 	TP_STRUCT__entry(
340 		__field(u32, type)
341 		__field(u32, field0)
342 		__field(u32, field1)
343 		__field(u32, field2)
344 		__field(u32, field3)
345 		__field(union cdnsp_trb *, trb)
346 		__field(dma_addr_t, trb_dma)
347 	),
348 	TP_fast_assign(
349 		__entry->type = ring->type;
350 		__entry->field0 = le32_to_cpu(trb->field[0]);
351 		__entry->field1 = le32_to_cpu(trb->field[1]);
352 		__entry->field2 = le32_to_cpu(trb->field[2]);
353 		__entry->field3 = le32_to_cpu(trb->field[3]);
354 		__entry->trb = (union cdnsp_trb *)trb;
355 		__entry->trb_dma = cdnsp_trb_virt_to_dma(ring->deq_seg,
356 							 (union cdnsp_trb *)trb);
357 
358 	),
359 	TP_printk("%s: %s trb: %p(%pad)", cdnsp_ring_type_string(__entry->type),
360 		  cdnsp_decode_trb(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX,
361 				   __entry->field0, __entry->field1,
362 				   __entry->field2, __entry->field3),
363 				   __entry->trb, &__entry->trb_dma
364 	)
365 );
366 
367 DEFINE_EVENT(cdnsp_log_trb, cdnsp_handle_event,
368 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
369 	TP_ARGS(ring, trb)
370 );
371 
372 DEFINE_EVENT(cdnsp_log_trb, cdnsp_trb_without_td,
373 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
374 	TP_ARGS(ring, trb)
375 );
376 
377 DEFINE_EVENT(cdnsp_log_trb, cdnsp_handle_command,
378 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
379 	TP_ARGS(ring, trb)
380 );
381 
382 DEFINE_EVENT(cdnsp_log_trb, cdnsp_handle_transfer,
383 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
384 	TP_ARGS(ring, trb)
385 );
386 
387 DEFINE_EVENT(cdnsp_log_trb, cdnsp_queue_trb,
388 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
389 	TP_ARGS(ring, trb)
390 );
391 
392 DEFINE_EVENT(cdnsp_log_trb, cdnsp_cmd_wait_for_compl,
393 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
394 	TP_ARGS(ring, trb)
395 );
396 
397 DEFINE_EVENT(cdnsp_log_trb, cdnsp_cmd_timeout,
398 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
399 	TP_ARGS(ring, trb)
400 );
401 
402 DEFINE_EVENT(cdnsp_log_trb, cdnsp_defered_event,
403 	TP_PROTO(struct cdnsp_ring *ring, struct cdnsp_generic_trb *trb),
404 	TP_ARGS(ring, trb)
405 );
406 
407 DECLARE_EVENT_CLASS(cdnsp_log_pdev,
408 	TP_PROTO(struct cdnsp_device *pdev),
409 	TP_ARGS(pdev),
410 	TP_STRUCT__entry(
411 		__field(struct cdnsp_device *, pdev)
412 		__field(struct usb_gadget *, gadget)
413 		__field(dma_addr_t, out_ctx)
414 		__field(dma_addr_t, in_ctx)
415 		__field(u8, port_num)
416 	),
417 	TP_fast_assign(
418 		__entry->pdev = pdev;
419 		__entry->gadget = &pdev->gadget;
420 		__entry->in_ctx = pdev->in_ctx.dma;
421 		__entry->out_ctx = pdev->out_ctx.dma;
422 		__entry->port_num = pdev->active_port ?
423 				pdev->active_port->port_num : 0xFF;
424 	),
425 	TP_printk("pdev %p gadget %p ctx %pad | %pad, port %d ",
426 		  __entry->pdev, __entry->gadget, &__entry->in_ctx,
427 		  &__entry->out_ctx, __entry->port_num
428 	)
429 );
430 
431 DEFINE_EVENT(cdnsp_log_pdev, cdnsp_alloc_priv_device,
432 	TP_PROTO(struct cdnsp_device *vdev),
433 	TP_ARGS(vdev)
434 );
435 
436 DEFINE_EVENT(cdnsp_log_pdev, cdnsp_free_priv_device,
437 	TP_PROTO(struct cdnsp_device *vdev),
438 	TP_ARGS(vdev)
439 );
440 
441 DEFINE_EVENT(cdnsp_log_pdev, cdnsp_setup_device,
442 	TP_PROTO(struct cdnsp_device *vdev),
443 	TP_ARGS(vdev)
444 );
445 
446 DEFINE_EVENT(cdnsp_log_pdev, cdnsp_setup_addressable_priv_device,
447 	TP_PROTO(struct cdnsp_device *vdev),
448 	TP_ARGS(vdev)
449 );
450 
451 DECLARE_EVENT_CLASS(cdnsp_log_request,
452 	TP_PROTO(struct cdnsp_request *req),
453 	TP_ARGS(req),
454 	TP_STRUCT__entry(
455 		__string(name, req->pep->name)
456 		__field(struct usb_request *, request)
457 		__field(struct cdnsp_request *, preq)
458 		__field(void *, buf)
459 		__field(unsigned int, actual)
460 		__field(unsigned int, length)
461 		__field(int, status)
462 		__field(dma_addr_t, dma)
463 		__field(unsigned int, stream_id)
464 		__field(unsigned int, zero)
465 		__field(unsigned int, short_not_ok)
466 		__field(unsigned int, no_interrupt)
467 		__field(struct scatterlist*, sg)
468 		__field(unsigned int, num_sgs)
469 		__field(unsigned int, num_mapped_sgs)
470 
471 	),
472 	TP_fast_assign(
473 		__assign_str(name, req->pep->name);
474 		__entry->request = &req->request;
475 		__entry->preq = req;
476 		__entry->buf = req->request.buf;
477 		__entry->actual = req->request.actual;
478 		__entry->length = req->request.length;
479 		__entry->status = req->request.status;
480 		__entry->dma = req->request.dma;
481 		__entry->stream_id = req->request.stream_id;
482 		__entry->zero = req->request.zero;
483 		__entry->short_not_ok = req->request.short_not_ok;
484 		__entry->no_interrupt = req->request.no_interrupt;
485 		__entry->sg = req->request.sg;
486 		__entry->num_sgs = req->request.num_sgs;
487 		__entry->num_mapped_sgs = req->request.num_mapped_sgs;
488 	),
489 	TP_printk("%s; req U:%p/P:%p, req buf %p, length %u/%u, status %d, "
490 		  "buf dma (%pad), SID %u, %s%s%s, sg %p, num_sg %d,"
491 		  " num_m_sg %d",
492 		  __get_str(name), __entry->request, __entry->preq,
493 		  __entry->buf, __entry->actual, __entry->length,
494 		  __entry->status, &__entry->dma,
495 		  __entry->stream_id, __entry->zero ? "Z" : "z",
496 		  __entry->short_not_ok ? "S" : "s",
497 		  __entry->no_interrupt ? "I" : "i",
498 		  __entry->sg, __entry->num_sgs, __entry->num_mapped_sgs
499 		)
500 );
501 
502 DEFINE_EVENT(cdnsp_log_request, cdnsp_request_enqueue,
503 	TP_PROTO(struct cdnsp_request *req),
504 	TP_ARGS(req)
505 );
506 
507 DEFINE_EVENT(cdnsp_log_request, cdnsp_request_enqueue_busy,
508 	TP_PROTO(struct cdnsp_request *req),
509 	TP_ARGS(req)
510 );
511 
512 DEFINE_EVENT(cdnsp_log_request, cdnsp_request_enqueue_error,
513 	TP_PROTO(struct cdnsp_request *req),
514 	TP_ARGS(req)
515 );
516 
517 DEFINE_EVENT(cdnsp_log_request, cdnsp_request_dequeue,
518 	TP_PROTO(struct cdnsp_request *req),
519 	TP_ARGS(req)
520 );
521 
522 DEFINE_EVENT(cdnsp_log_request, cdnsp_request_giveback,
523 	TP_PROTO(struct cdnsp_request *req),
524 	TP_ARGS(req)
525 );
526 
527 DEFINE_EVENT(cdnsp_log_request, cdnsp_alloc_request,
528 	TP_PROTO(struct cdnsp_request *req),
529 	TP_ARGS(req)
530 );
531 
532 DEFINE_EVENT(cdnsp_log_request, cdnsp_free_request,
533 	TP_PROTO(struct cdnsp_request *req),
534 	TP_ARGS(req)
535 );
536 
537 DECLARE_EVENT_CLASS(cdnsp_log_ep_ctx,
538 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
539 	TP_ARGS(ctx),
540 	TP_STRUCT__entry(
541 		__field(u32, info)
542 		__field(u32, info2)
543 		__field(u64, deq)
544 		__field(u32, tx_info)
545 	),
546 	TP_fast_assign(
547 		__entry->info = le32_to_cpu(ctx->ep_info);
548 		__entry->info2 = le32_to_cpu(ctx->ep_info2);
549 		__entry->deq = le64_to_cpu(ctx->deq);
550 		__entry->tx_info = le32_to_cpu(ctx->tx_info);
551 	),
552 	TP_printk("%s", cdnsp_decode_ep_context(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX,
553 						__entry->info, __entry->info2,
554 						__entry->deq, __entry->tx_info)
555 	)
556 );
557 
558 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_ep_disabled,
559 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
560 	TP_ARGS(ctx)
561 );
562 
563 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_ep_stopped_or_disabled,
564 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
565 	TP_ARGS(ctx)
566 );
567 
568 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_remove_request,
569 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
570 	TP_ARGS(ctx)
571 );
572 
573 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_handle_cmd_stop_ep,
574 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
575 	TP_ARGS(ctx)
576 );
577 
578 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_handle_cmd_flush_ep,
579 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
580 	TP_ARGS(ctx)
581 );
582 
583 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_handle_cmd_set_deq_ep,
584 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
585 	TP_ARGS(ctx)
586 );
587 
588 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_handle_cmd_reset_ep,
589 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
590 	TP_ARGS(ctx)
591 );
592 
593 DEFINE_EVENT(cdnsp_log_ep_ctx, cdnsp_handle_cmd_config_ep,
594 	TP_PROTO(struct cdnsp_ep_ctx *ctx),
595 	TP_ARGS(ctx)
596 );
597 
598 DECLARE_EVENT_CLASS(cdnsp_log_slot_ctx,
599 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
600 	TP_ARGS(ctx),
601 	TP_STRUCT__entry(
602 		__field(u32, info)
603 		__field(u32, info2)
604 		__field(u32, int_target)
605 		__field(u32, state)
606 	),
607 	TP_fast_assign(
608 		__entry->info = le32_to_cpu(ctx->dev_info);
609 		__entry->info2 = le32_to_cpu(ctx->dev_port);
610 		__entry->int_target = le32_to_cpu(ctx->int_target);
611 		__entry->state = le32_to_cpu(ctx->dev_state);
612 	),
613 	TP_printk("%s", cdnsp_decode_slot_context(__entry->info,
614 						  __entry->info2,
615 						  __entry->int_target,
616 						  __entry->state)
617 	)
618 );
619 
620 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_slot_already_in_default,
621 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
622 	TP_ARGS(ctx)
623 );
624 
625 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_handle_cmd_enable_slot,
626 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
627 	TP_ARGS(ctx)
628 );
629 
630 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_handle_cmd_disable_slot,
631 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
632 	TP_ARGS(ctx)
633 );
634 
635 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_reset_device,
636 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
637 	TP_ARGS(ctx)
638 );
639 
640 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_setup_device_slot,
641 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
642 	TP_ARGS(ctx)
643 );
644 
645 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_handle_cmd_addr_dev,
646 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
647 	TP_ARGS(ctx)
648 );
649 
650 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_handle_cmd_reset_dev,
651 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
652 	TP_ARGS(ctx)
653 );
654 
655 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_handle_cmd_set_deq,
656 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
657 	TP_ARGS(ctx)
658 );
659 
660 DEFINE_EVENT(cdnsp_log_slot_ctx, cdnsp_configure_endpoint,
661 	TP_PROTO(struct cdnsp_slot_ctx *ctx),
662 	TP_ARGS(ctx)
663 );
664 
665 DECLARE_EVENT_CLASS(cdnsp_log_td_info,
666 	TP_PROTO(struct cdnsp_request *preq),
667 	TP_ARGS(preq),
668 	TP_STRUCT__entry(
669 		__string(name, preq->pep->name)
670 		__field(struct usb_request *, request)
671 		__field(struct cdnsp_request *, preq)
672 		__field(union cdnsp_trb *, first_trb)
673 		__field(union cdnsp_trb *, last_trb)
674 		__field(dma_addr_t, trb_dma)
675 	),
676 	TP_fast_assign(
677 		__assign_str(name, preq->pep->name);
678 		__entry->request = &preq->request;
679 		__entry->preq = preq;
680 		__entry->first_trb = preq->td.first_trb;
681 		__entry->last_trb = preq->td.last_trb;
682 		__entry->trb_dma = cdnsp_trb_virt_to_dma(preq->td.start_seg,
683 							 preq->td.first_trb)
684 	),
685 	TP_printk("%s req/preq:  %p/%p, first trb %p[vir]/%pad(dma), last trb %p",
686 		  __get_str(name), __entry->request, __entry->preq,
687 		  __entry->first_trb, &__entry->trb_dma,
688 		  __entry->last_trb
689 		)
690 );
691 
692 DEFINE_EVENT(cdnsp_log_td_info, cdnsp_remove_request_td,
693 	TP_PROTO(struct cdnsp_request *preq),
694 	TP_ARGS(preq)
695 );
696 
697 DECLARE_EVENT_CLASS(cdnsp_log_ring,
698 	TP_PROTO(struct cdnsp_ring *ring),
699 	TP_ARGS(ring),
700 	TP_STRUCT__entry(
701 		__field(u32, type)
702 		__field(void *, ring)
703 		__field(dma_addr_t, enq)
704 		__field(dma_addr_t, deq)
705 		__field(dma_addr_t, enq_seg)
706 		__field(dma_addr_t, deq_seg)
707 		__field(unsigned int, num_segs)
708 		__field(unsigned int, stream_id)
709 		__field(unsigned int, cycle_state)
710 		__field(unsigned int, num_trbs_free)
711 		__field(unsigned int, bounce_buf_len)
712 	),
713 	TP_fast_assign(
714 		__entry->ring = ring;
715 		__entry->type = ring->type;
716 		__entry->num_segs = ring->num_segs;
717 		__entry->stream_id = ring->stream_id;
718 		__entry->enq_seg = ring->enq_seg->dma;
719 		__entry->deq_seg = ring->deq_seg->dma;
720 		__entry->cycle_state = ring->cycle_state;
721 		__entry->num_trbs_free = ring->num_trbs_free;
722 		__entry->bounce_buf_len = ring->bounce_buf_len;
723 		__entry->enq = cdnsp_trb_virt_to_dma(ring->enq_seg,
724 						     ring->enqueue);
725 		__entry->deq = cdnsp_trb_virt_to_dma(ring->deq_seg,
726 						     ring->dequeue);
727 	),
728 	TP_printk("%s %p: enq %pad(%pad) deq %pad(%pad) segs %d stream %d"
729 		  " free_trbs %d bounce %d cycle %d",
730 		  cdnsp_ring_type_string(__entry->type), __entry->ring,
731 		  &__entry->enq, &__entry->enq_seg,
732 		  &__entry->deq, &__entry->deq_seg,
733 		  __entry->num_segs,
734 		  __entry->stream_id,
735 		  __entry->num_trbs_free,
736 		  __entry->bounce_buf_len,
737 		  __entry->cycle_state
738 		)
739 );
740 
741 DEFINE_EVENT(cdnsp_log_ring, cdnsp_ring_alloc,
742 	TP_PROTO(struct cdnsp_ring *ring),
743 	TP_ARGS(ring)
744 );
745 
746 DEFINE_EVENT(cdnsp_log_ring, cdnsp_ring_free,
747 	TP_PROTO(struct cdnsp_ring *ring),
748 	TP_ARGS(ring)
749 );
750 
751 DEFINE_EVENT(cdnsp_log_ring, cdnsp_set_stream_ring,
752 	TP_PROTO(struct cdnsp_ring *ring),
753 	TP_ARGS(ring)
754 );
755 
756 DEFINE_EVENT(cdnsp_log_ring, cdnsp_ring_expansion,
757 	TP_PROTO(struct cdnsp_ring *ring),
758 	TP_ARGS(ring)
759 );
760 
761 DEFINE_EVENT(cdnsp_log_ring, cdnsp_inc_enq,
762 	TP_PROTO(struct cdnsp_ring *ring),
763 	TP_ARGS(ring)
764 );
765 
766 DEFINE_EVENT(cdnsp_log_ring, cdnsp_inc_deq,
767 	TP_PROTO(struct cdnsp_ring *ring),
768 	TP_ARGS(ring)
769 );
770 
771 DECLARE_EVENT_CLASS(cdnsp_log_portsc,
772 		TP_PROTO(u32 portnum, u32 portsc),
773 		TP_ARGS(portnum, portsc),
774 		TP_STRUCT__entry(
775 				__field(u32, portnum)
776 				__field(u32, portsc)
777 				),
778 		TP_fast_assign(
779 				__entry->portnum = portnum;
780 				__entry->portsc = portsc;
781 				),
782 		TP_printk("port-%d: %s",
783 			  __entry->portnum,
784 			  cdnsp_decode_portsc(__get_buf(CDNSP_MSG_MAX), CDNSP_MSG_MAX,
785 					      __entry->portsc)
786 			)
787 );
788 
789 DEFINE_EVENT(cdnsp_log_portsc, cdnsp_handle_port_status,
790 		TP_PROTO(u32 portnum, u32 portsc),
791 		TP_ARGS(portnum, portsc)
792 );
793 
794 DEFINE_EVENT(cdnsp_log_portsc, cdnsp_link_state_changed,
795 		TP_PROTO(u32 portnum, u32 portsc),
796 		TP_ARGS(portnum, portsc)
797 );
798 
799 TRACE_EVENT(cdnsp_stream_number,
800 	TP_PROTO(struct cdnsp_ep *pep, int num_stream_ctxs, int num_streams),
801 	TP_ARGS(pep, num_stream_ctxs, num_streams),
802 	TP_STRUCT__entry(
803 		__string(name, pep->name)
804 		__field(int, num_stream_ctxs)
805 		__field(int, num_streams)
806 	),
807 	TP_fast_assign(
808 		__entry->num_stream_ctxs = num_stream_ctxs;
809 		__entry->num_streams = num_streams;
810 	),
811 	TP_printk("%s Need %u stream ctx entries for %u stream IDs.",
812 		  __get_str(name), __entry->num_stream_ctxs,
813 		  __entry->num_streams)
814 );
815 
816 #endif /* __CDNSP_TRACE_H */
817 
818 /* this part must be outside header guard */
819 
820 #undef TRACE_INCLUDE_PATH
821 #define TRACE_INCLUDE_PATH .
822 
823 #undef TRACE_INCLUDE_FILE
824 #define TRACE_INCLUDE_FILE cdnsp-trace
825 
826 #include <trace/define_trace.h>
827