1 // SPDX-License-Identifier: GPL-2.0
3 * trace.h - DesignWare USB3 DRD Controller Trace Support
5 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
7 * Author: Felipe Balbi <balbi@ti.com>
11 #define TRACE_SYSTEM dwc3
13 #if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
14 #define __DWC3_TRACE_H
16 #include <linux/types.h>
17 #include <linux/tracepoint.h>
18 #include <asm/byteorder.h>
22 DECLARE_EVENT_CLASS(dwc3_log_io
,
23 TP_PROTO(void *base
, u32 offset
, u32 value
),
24 TP_ARGS(base
, offset
, value
),
32 __entry
->offset
= offset
;
33 __entry
->value
= value
;
35 TP_printk("addr %p value %08x", __entry
->base
+ __entry
->offset
,
39 DEFINE_EVENT(dwc3_log_io
, dwc3_readl
,
40 TP_PROTO(void __iomem
*base
, u32 offset
, u32 value
),
41 TP_ARGS(base
, offset
, value
)
44 DEFINE_EVENT(dwc3_log_io
, dwc3_writel
,
45 TP_PROTO(void __iomem
*base
, u32 offset
, u32 value
),
46 TP_ARGS(base
, offset
, value
)
49 DECLARE_EVENT_CLASS(dwc3_log_event
,
50 TP_PROTO(u32 event
, struct dwc3
*dwc
),
54 __field(u32
, ep0state
)
55 __dynamic_array(char, str
, DWC3_MSG_MAX
)
58 __entry
->event
= event
;
59 __entry
->ep0state
= dwc
->ep0state
;
61 TP_printk("event (%08x): %s", __entry
->event
,
62 dwc3_decode_event(__get_str(str
), __entry
->event
,
66 DEFINE_EVENT(dwc3_log_event
, dwc3_event
,
67 TP_PROTO(u32 event
, struct dwc3
*dwc
),
71 DECLARE_EVENT_CLASS(dwc3_log_ctrl
,
72 TP_PROTO(struct usb_ctrlrequest
*ctrl
),
75 __field(__u8
, bRequestType
)
76 __field(__u8
, bRequest
)
77 __field(__u16
, wValue
)
78 __field(__u16
, wIndex
)
79 __field(__u16
, wLength
)
80 __dynamic_array(char, str
, DWC3_MSG_MAX
)
83 __entry
->bRequestType
= ctrl
->bRequestType
;
84 __entry
->bRequest
= ctrl
->bRequest
;
85 __entry
->wValue
= le16_to_cpu(ctrl
->wValue
);
86 __entry
->wIndex
= le16_to_cpu(ctrl
->wIndex
);
87 __entry
->wLength
= le16_to_cpu(ctrl
->wLength
);
89 TP_printk("%s", dwc3_decode_ctrl(__get_str(str
), __entry
->bRequestType
,
90 __entry
->bRequest
, __entry
->wValue
,
91 __entry
->wIndex
, __entry
->wLength
)
95 DEFINE_EVENT(dwc3_log_ctrl
, dwc3_ctrl_req
,
96 TP_PROTO(struct usb_ctrlrequest
*ctrl
),
100 DECLARE_EVENT_CLASS(dwc3_log_request
,
101 TP_PROTO(struct dwc3_request
*req
),
104 __string(name
, req
->dep
->name
)
105 __field(struct dwc3_request
*, req
)
106 __field(unsigned, actual
)
107 __field(unsigned, length
)
110 __field(int, short_not_ok
)
111 __field(int, no_interrupt
)
114 __assign_str(name
, req
->dep
->name
);
116 __entry
->actual
= req
->request
.actual
;
117 __entry
->length
= req
->request
.length
;
118 __entry
->status
= req
->request
.status
;
119 __entry
->zero
= req
->request
.zero
;
120 __entry
->short_not_ok
= req
->request
.short_not_ok
;
121 __entry
->no_interrupt
= req
->request
.no_interrupt
;
123 TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
124 __get_str(name
), __entry
->req
, __entry
->actual
, __entry
->length
,
125 __entry
->zero
? "Z" : "z",
126 __entry
->short_not_ok
? "S" : "s",
127 __entry
->no_interrupt
? "i" : "I",
132 DEFINE_EVENT(dwc3_log_request
, dwc3_alloc_request
,
133 TP_PROTO(struct dwc3_request
*req
),
137 DEFINE_EVENT(dwc3_log_request
, dwc3_free_request
,
138 TP_PROTO(struct dwc3_request
*req
),
142 DEFINE_EVENT(dwc3_log_request
, dwc3_ep_queue
,
143 TP_PROTO(struct dwc3_request
*req
),
147 DEFINE_EVENT(dwc3_log_request
, dwc3_ep_dequeue
,
148 TP_PROTO(struct dwc3_request
*req
),
152 DEFINE_EVENT(dwc3_log_request
, dwc3_gadget_giveback
,
153 TP_PROTO(struct dwc3_request
*req
),
157 DECLARE_EVENT_CLASS(dwc3_log_generic_cmd
,
158 TP_PROTO(unsigned int cmd
, u32 param
, int status
),
159 TP_ARGS(cmd
, param
, status
),
161 __field(unsigned int, cmd
)
167 __entry
->param
= param
;
168 __entry
->status
= status
;
170 TP_printk("cmd '%s' [%x] param %08x --> status: %s",
171 dwc3_gadget_generic_cmd_string(__entry
->cmd
),
172 __entry
->cmd
, __entry
->param
,
173 dwc3_gadget_generic_cmd_status_string(__entry
->status
)
177 DEFINE_EVENT(dwc3_log_generic_cmd
, dwc3_gadget_generic_cmd
,
178 TP_PROTO(unsigned int cmd
, u32 param
, int status
),
179 TP_ARGS(cmd
, param
, status
)
182 DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd
,
183 TP_PROTO(struct dwc3_ep
*dep
, unsigned int cmd
,
184 struct dwc3_gadget_ep_cmd_params
*params
, int cmd_status
),
185 TP_ARGS(dep
, cmd
, params
, cmd_status
),
187 __string(name
, dep
->name
)
188 __field(unsigned int, cmd
)
192 __field(int, cmd_status
)
195 __assign_str(name
, dep
->name
);
197 __entry
->param0
= params
->param0
;
198 __entry
->param1
= params
->param1
;
199 __entry
->param2
= params
->param2
;
200 __entry
->cmd_status
= cmd_status
;
202 TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
203 __get_str(name
), dwc3_gadget_ep_cmd_string(__entry
->cmd
),
204 __entry
->cmd
, __entry
->param0
,
205 __entry
->param1
, __entry
->param2
,
206 dwc3_ep_cmd_status_string(__entry
->cmd_status
)
210 DEFINE_EVENT(dwc3_log_gadget_ep_cmd
, dwc3_gadget_ep_cmd
,
211 TP_PROTO(struct dwc3_ep
*dep
, unsigned int cmd
,
212 struct dwc3_gadget_ep_cmd_params
*params
, int cmd_status
),
213 TP_ARGS(dep
, cmd
, params
, cmd_status
)
216 DECLARE_EVENT_CLASS(dwc3_log_trb
,
217 TP_PROTO(struct dwc3_ep
*dep
, struct dwc3_trb
*trb
),
220 __string(name
, dep
->name
)
221 __field(struct dwc3_trb
*, trb
)
222 __field(u32
, allocated
)
231 __assign_str(name
, dep
->name
);
233 __entry
->bpl
= trb
->bpl
;
234 __entry
->bph
= trb
->bph
;
235 __entry
->size
= trb
->size
;
236 __entry
->ctrl
= trb
->ctrl
;
237 __entry
->type
= usb_endpoint_type(dep
->endpoint
.desc
);
239 TP_printk("%s: trb %p buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)",
240 __get_str(name
), __entry
->trb
, __entry
->bph
, __entry
->bpl
,
242 int pcm
= ((__entry
->size
>> 24) & 3) + 1;
243 switch (__entry
->type
) {
244 case USB_ENDPOINT_XFER_INT
:
245 case USB_ENDPOINT_XFER_ISOC
:
260 DWC3_TRB_SIZE_LENGTH(__entry
->size
), __entry
->ctrl
,
261 __entry
->ctrl
& DWC3_TRB_CTRL_HWO
? 'H' : 'h',
262 __entry
->ctrl
& DWC3_TRB_CTRL_LST
? 'L' : 'l',
263 __entry
->ctrl
& DWC3_TRB_CTRL_CHN
? 'C' : 'c',
264 __entry
->ctrl
& DWC3_TRB_CTRL_CSP
? 'S' : 's',
265 __entry
->ctrl
& DWC3_TRB_CTRL_ISP_IMI
? 'S' : 's',
266 __entry
->ctrl
& DWC3_TRB_CTRL_IOC
? 'C' : 'c',
267 dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry
->ctrl
))
271 DEFINE_EVENT(dwc3_log_trb
, dwc3_prepare_trb
,
272 TP_PROTO(struct dwc3_ep
*dep
, struct dwc3_trb
*trb
),
276 DEFINE_EVENT(dwc3_log_trb
, dwc3_complete_trb
,
277 TP_PROTO(struct dwc3_ep
*dep
, struct dwc3_trb
*trb
),
281 DECLARE_EVENT_CLASS(dwc3_log_ep
,
282 TP_PROTO(struct dwc3_ep
*dep
),
285 __string(name
, dep
->name
)
286 __field(unsigned, maxpacket
)
287 __field(unsigned, maxpacket_limit
)
288 __field(unsigned, max_streams
)
289 __field(unsigned, maxburst
)
290 __field(unsigned, flags
)
291 __field(unsigned, direction
)
292 __field(u8
, trb_enqueue
)
293 __field(u8
, trb_dequeue
)
296 __assign_str(name
, dep
->name
);
297 __entry
->maxpacket
= dep
->endpoint
.maxpacket
;
298 __entry
->maxpacket_limit
= dep
->endpoint
.maxpacket_limit
;
299 __entry
->max_streams
= dep
->endpoint
.max_streams
;
300 __entry
->maxburst
= dep
->endpoint
.maxburst
;
301 __entry
->flags
= dep
->flags
;
302 __entry
->direction
= dep
->direction
;
303 __entry
->trb_enqueue
= dep
->trb_enqueue
;
304 __entry
->trb_dequeue
= dep
->trb_dequeue
;
306 TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c:%c",
307 __get_str(name
), __entry
->maxpacket
,
308 __entry
->maxpacket_limit
, __entry
->max_streams
,
309 __entry
->maxburst
, __entry
->trb_enqueue
,
310 __entry
->trb_dequeue
,
311 __entry
->flags
& DWC3_EP_ENABLED
? 'E' : 'e',
312 __entry
->flags
& DWC3_EP_STALL
? 'S' : 's',
313 __entry
->flags
& DWC3_EP_WEDGE
? 'W' : 'w',
314 __entry
->flags
& DWC3_EP_TRANSFER_STARTED
? 'B' : 'b',
315 __entry
->flags
& DWC3_EP_PENDING_REQUEST
? 'P' : 'p',
316 __entry
->flags
& DWC3_EP_END_TRANSFER_PENDING
? 'E' : 'e',
317 __entry
->direction
? '<' : '>'
321 DEFINE_EVENT(dwc3_log_ep
, dwc3_gadget_ep_enable
,
322 TP_PROTO(struct dwc3_ep
*dep
),
326 DEFINE_EVENT(dwc3_log_ep
, dwc3_gadget_ep_disable
,
327 TP_PROTO(struct dwc3_ep
*dep
),
331 #endif /* __DWC3_TRACE_H */
333 /* this part has to be here */
335 #undef TRACE_INCLUDE_PATH
336 #define TRACE_INCLUDE_PATH .
338 #undef TRACE_INCLUDE_FILE
339 #define TRACE_INCLUDE_FILE trace
341 #include <trace/define_trace.h>