]>
Commit | Line | Data |
---|---|---|
b33f69f5 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
27088e00 | 2 | /* |
2c4cbe6e FB |
3 | * trace.h - DesignWare USB3 DRD Controller Trace Support |
4 | * | |
10623b87 | 5 | * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com |
2c4cbe6e FB |
6 | * |
7 | * Author: Felipe Balbi <balbi@ti.com> | |
2c4cbe6e FB |
8 | */ |
9 | ||
10 | #undef TRACE_SYSTEM | |
11 | #define TRACE_SYSTEM dwc3 | |
12 | ||
13 | #if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) | |
14 | #define __DWC3_TRACE_H | |
15 | ||
16 | #include <linux/types.h> | |
17 | #include <linux/tracepoint.h> | |
18 | #include <asm/byteorder.h> | |
19 | #include "core.h" | |
20 | #include "debug.h" | |
21 | ||
4dd5a69e FB |
22 | DECLARE_EVENT_CLASS(dwc3_log_io, |
23 | TP_PROTO(void *base, u32 offset, u32 value), | |
24 | TP_ARGS(base, offset, value), | |
25 | TP_STRUCT__entry( | |
26 | __field(void *, base) | |
27 | __field(u32, offset) | |
28 | __field(u32, value) | |
29 | ), | |
30 | TP_fast_assign( | |
31 | __entry->base = base; | |
32 | __entry->offset = offset; | |
33 | __entry->value = value; | |
34 | ), | |
3fc63d07 TN |
35 | TP_printk("addr %p offset %04x value %08x", |
36 | __entry->base + __entry->offset, | |
37 | __entry->offset, | |
38 | __entry->value) | |
6bac4ff0 FB |
39 | ); |
40 | ||
4dd5a69e | 41 | DEFINE_EVENT(dwc3_log_io, dwc3_readl, |
204ec1af | 42 | TP_PROTO(void __iomem *base, u32 offset, u32 value), |
4dd5a69e FB |
43 | TP_ARGS(base, offset, value) |
44 | ); | |
45 | ||
46 | DEFINE_EVENT(dwc3_log_io, dwc3_writel, | |
204ec1af | 47 | TP_PROTO(void __iomem *base, u32 offset, u32 value), |
4dd5a69e | 48 | TP_ARGS(base, offset, value) |
2c4cbe6e FB |
49 | ); |
50 | ||
51 | DECLARE_EVENT_CLASS(dwc3_log_event, | |
43c96be1 FB |
52 | TP_PROTO(u32 event, struct dwc3 *dwc), |
53 | TP_ARGS(event, dwc), | |
2c4cbe6e FB |
54 | TP_STRUCT__entry( |
55 | __field(u32, event) | |
43c96be1 | 56 | __field(u32, ep0state) |
2c4cbe6e FB |
57 | ), |
58 | TP_fast_assign( | |
59 | __entry->event = event; | |
43c96be1 | 60 | __entry->ep0state = dwc->ep0state; |
2c4cbe6e | 61 | ), |
f75cacc4 | 62 | TP_printk("event (%08x): %s", __entry->event, |
f09d24aa | 63 | dwc3_decode_event(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX, |
7790b355 | 64 | __entry->event, __entry->ep0state)) |
2c4cbe6e FB |
65 | ); |
66 | ||
67 | DEFINE_EVENT(dwc3_log_event, dwc3_event, | |
43c96be1 FB |
68 | TP_PROTO(u32 event, struct dwc3 *dwc), |
69 | TP_ARGS(event, dwc) | |
2c4cbe6e FB |
70 | ); |
71 | ||
72 | DECLARE_EVENT_CLASS(dwc3_log_ctrl, | |
73 | TP_PROTO(struct usb_ctrlrequest *ctrl), | |
74 | TP_ARGS(ctrl), | |
75 | TP_STRUCT__entry( | |
4ac4fc93 FB |
76 | __field(__u8, bRequestType) |
77 | __field(__u8, bRequest) | |
96bedb63 JY |
78 | __field(__u16, wValue) |
79 | __field(__u16, wIndex) | |
80 | __field(__u16, wLength) | |
2c4cbe6e FB |
81 | ), |
82 | TP_fast_assign( | |
4ac4fc93 FB |
83 | __entry->bRequestType = ctrl->bRequestType; |
84 | __entry->bRequest = ctrl->bRequest; | |
96bedb63 JY |
85 | __entry->wValue = le16_to_cpu(ctrl->wValue); |
86 | __entry->wIndex = le16_to_cpu(ctrl->wIndex); | |
87 | __entry->wLength = le16_to_cpu(ctrl->wLength); | |
2c4cbe6e | 88 | ), |
f09d24aa | 89 | TP_printk("%s", usb_decode_ctrl(__get_buf(DWC3_MSG_MAX), DWC3_MSG_MAX, |
7790b355 | 90 | __entry->bRequestType, |
af32423a FB |
91 | __entry->bRequest, __entry->wValue, |
92 | __entry->wIndex, __entry->wLength) | |
2c4cbe6e FB |
93 | ) |
94 | ); | |
95 | ||
96 | DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req, | |
97 | TP_PROTO(struct usb_ctrlrequest *ctrl), | |
98 | TP_ARGS(ctrl) | |
99 | ); | |
100 | ||
101 | DECLARE_EVENT_CLASS(dwc3_log_request, | |
102 | TP_PROTO(struct dwc3_request *req), | |
103 | TP_ARGS(req), | |
104 | TP_STRUCT__entry( | |
e42f09b8 | 105 | __string(name, req->dep->name) |
2c4cbe6e | 106 | __field(struct dwc3_request *, req) |
159fdf29 FB |
107 | __field(unsigned int, actual) |
108 | __field(unsigned int, length) | |
4ac4fc93 | 109 | __field(int, status) |
46a01427 FB |
110 | __field(int, zero) |
111 | __field(int, short_not_ok) | |
112 | __field(int, no_interrupt) | |
2c4cbe6e FB |
113 | ), |
114 | TP_fast_assign( | |
2c92ca84 | 115 | __assign_str(name); |
2c4cbe6e | 116 | __entry->req = req; |
4ac4fc93 FB |
117 | __entry->actual = req->request.actual; |
118 | __entry->length = req->request.length; | |
119 | __entry->status = req->request.status; | |
46a01427 FB |
120 | __entry->zero = req->request.zero; |
121 | __entry->short_not_ok = req->request.short_not_ok; | |
122 | __entry->no_interrupt = req->request.no_interrupt; | |
2c4cbe6e | 123 | ), |
46a01427 | 124 | TP_printk("%s: req %p length %u/%u %s%s%s ==> %d", |
4ac4fc93 | 125 | __get_str(name), __entry->req, __entry->actual, __entry->length, |
46a01427 FB |
126 | __entry->zero ? "Z" : "z", |
127 | __entry->short_not_ok ? "S" : "s", | |
128 | __entry->no_interrupt ? "i" : "I", | |
4ac4fc93 | 129 | __entry->status |
2c4cbe6e FB |
130 | ) |
131 | ); | |
132 | ||
133 | DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request, | |
134 | TP_PROTO(struct dwc3_request *req), | |
135 | TP_ARGS(req) | |
136 | ); | |
137 | ||
138 | DEFINE_EVENT(dwc3_log_request, dwc3_free_request, | |
139 | TP_PROTO(struct dwc3_request *req), | |
140 | TP_ARGS(req) | |
141 | ); | |
142 | ||
143 | DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue, | |
144 | TP_PROTO(struct dwc3_request *req), | |
145 | TP_ARGS(req) | |
146 | ); | |
147 | ||
148 | DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue, | |
149 | TP_PROTO(struct dwc3_request *req), | |
150 | TP_ARGS(req) | |
151 | ); | |
152 | ||
153 | DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback, | |
154 | TP_PROTO(struct dwc3_request *req), | |
155 | TP_ARGS(req) | |
156 | ); | |
157 | ||
158 | DECLARE_EVENT_CLASS(dwc3_log_generic_cmd, | |
71f7e702 FB |
159 | TP_PROTO(unsigned int cmd, u32 param, int status), |
160 | TP_ARGS(cmd, param, status), | |
2c4cbe6e FB |
161 | TP_STRUCT__entry( |
162 | __field(unsigned int, cmd) | |
163 | __field(u32, param) | |
71f7e702 | 164 | __field(int, status) |
2c4cbe6e FB |
165 | ), |
166 | TP_fast_assign( | |
167 | __entry->cmd = cmd; | |
168 | __entry->param = param; | |
71f7e702 | 169 | __entry->status = status; |
2c4cbe6e | 170 | ), |
aad7c259 | 171 | TP_printk("cmd '%s' [%x] param %08x --> status: %s", |
2c4cbe6e | 172 | dwc3_gadget_generic_cmd_string(__entry->cmd), |
71f7e702 FB |
173 | __entry->cmd, __entry->param, |
174 | dwc3_gadget_generic_cmd_status_string(__entry->status) | |
2c4cbe6e FB |
175 | ) |
176 | ); | |
177 | ||
178 | DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd, | |
71f7e702 FB |
179 | TP_PROTO(unsigned int cmd, u32 param, int status), |
180 | TP_ARGS(cmd, param, status) | |
2c4cbe6e FB |
181 | ); |
182 | ||
183 | DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, | |
184 | TP_PROTO(struct dwc3_ep *dep, unsigned int cmd, | |
0933df15 FB |
185 | struct dwc3_gadget_ep_cmd_params *params, int cmd_status), |
186 | TP_ARGS(dep, cmd, params, cmd_status), | |
2c4cbe6e | 187 | TP_STRUCT__entry( |
e42f09b8 | 188 | __string(name, dep->name) |
2c4cbe6e | 189 | __field(unsigned int, cmd) |
a4722fd3 FB |
190 | __field(u32, param0) |
191 | __field(u32, param1) | |
192 | __field(u32, param2) | |
0933df15 | 193 | __field(int, cmd_status) |
2c4cbe6e FB |
194 | ), |
195 | TP_fast_assign( | |
2c92ca84 | 196 | __assign_str(name); |
2c4cbe6e | 197 | __entry->cmd = cmd; |
a4722fd3 FB |
198 | __entry->param0 = params->param0; |
199 | __entry->param1 = params->param1; | |
200 | __entry->param2 = params->param2; | |
0933df15 | 201 | __entry->cmd_status = cmd_status; |
2c4cbe6e | 202 | ), |
15172652 | 203 | TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s", |
4ac4fc93 | 204 | __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd), |
a4722fd3 | 205 | __entry->cmd, __entry->param0, |
0933df15 FB |
206 | __entry->param1, __entry->param2, |
207 | dwc3_ep_cmd_status_string(__entry->cmd_status) | |
2c4cbe6e FB |
208 | ) |
209 | ); | |
210 | ||
211 | DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd, | |
212 | TP_PROTO(struct dwc3_ep *dep, unsigned int cmd, | |
0933df15 FB |
213 | struct dwc3_gadget_ep_cmd_params *params, int cmd_status), |
214 | TP_ARGS(dep, cmd, params, cmd_status) | |
2c4cbe6e FB |
215 | ); |
216 | ||
217 | DECLARE_EVENT_CLASS(dwc3_log_trb, | |
218 | TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), | |
219 | TP_ARGS(dep, trb), | |
220 | TP_STRUCT__entry( | |
e42f09b8 | 221 | __string(name, dep->name) |
2c4cbe6e | 222 | __field(struct dwc3_trb *, trb) |
4ac4fc93 FB |
223 | __field(u32, bpl) |
224 | __field(u32, bph) | |
225 | __field(u32, size) | |
226 | __field(u32, ctrl) | |
fa8d965d | 227 | __field(u32, type) |
30ad6273 FB |
228 | __field(u32, enqueue) |
229 | __field(u32, dequeue) | |
2c4cbe6e FB |
230 | ), |
231 | TP_fast_assign( | |
2c92ca84 | 232 | __assign_str(name); |
2c4cbe6e | 233 | __entry->trb = trb; |
4ac4fc93 FB |
234 | __entry->bpl = trb->bpl; |
235 | __entry->bph = trb->bph; | |
236 | __entry->size = trb->size; | |
237 | __entry->ctrl = trb->ctrl; | |
fa8d965d | 238 | __entry->type = usb_endpoint_type(dep->endpoint.desc); |
30ad6273 FB |
239 | __entry->enqueue = dep->trb_enqueue; |
240 | __entry->dequeue = dep->trb_dequeue; | |
2c4cbe6e | 241 | ), |
808e8bff | 242 | TP_printk("%s: trb %p (E%d:D%d) buf %08x%08x size %s%d ctrl %08x sofn %08x (%c%c%c%c:%c%c:%s)", |
30ad6273 FB |
243 | __get_str(name), __entry->trb, __entry->enqueue, |
244 | __entry->dequeue, __entry->bph, __entry->bpl, | |
fa8d965d FB |
245 | ({char *s; |
246 | int pcm = ((__entry->size >> 24) & 3) + 1; | |
159fdf29 | 247 | |
fa8d965d FB |
248 | switch (__entry->type) { |
249 | case USB_ENDPOINT_XFER_INT: | |
250 | case USB_ENDPOINT_XFER_ISOC: | |
251 | switch (pcm) { | |
252 | case 1: | |
253 | s = "1x "; | |
254 | break; | |
255 | case 2: | |
256 | s = "2x "; | |
257 | break; | |
258 | case 3: | |
54d48183 | 259 | default: |
fa8d965d FB |
260 | s = "3x "; |
261 | break; | |
262 | } | |
54d48183 | 263 | break; |
fa8d965d FB |
264 | default: |
265 | s = ""; | |
266 | } s; }), | |
267 | DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl, | |
808e8bff | 268 | DWC3_TRB_CTRL_GET_SID_SOFN(__entry->ctrl), |
22f2c619 JD |
269 | __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h', |
270 | __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l', | |
271 | __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c', | |
272 | __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's', | |
273 | __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's', | |
274 | __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c', | |
b5c7ed5c | 275 | dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl)) |
2c4cbe6e FB |
276 | ) |
277 | ); | |
278 | ||
279 | DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb, | |
280 | TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), | |
281 | TP_ARGS(dep, trb) | |
282 | ); | |
283 | ||
284 | DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb, | |
285 | TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), | |
286 | TP_ARGS(dep, trb) | |
287 | ); | |
288 | ||
2870e501 FB |
289 | DECLARE_EVENT_CLASS(dwc3_log_ep, |
290 | TP_PROTO(struct dwc3_ep *dep), | |
291 | TP_ARGS(dep), | |
292 | TP_STRUCT__entry( | |
e42f09b8 | 293 | __string(name, dep->name) |
159fdf29 FB |
294 | __field(unsigned int, maxpacket) |
295 | __field(unsigned int, maxpacket_limit) | |
296 | __field(unsigned int, max_streams) | |
297 | __field(unsigned int, maxburst) | |
298 | __field(unsigned int, flags) | |
299 | __field(unsigned int, direction) | |
2870e501 FB |
300 | __field(u8, trb_enqueue) |
301 | __field(u8, trb_dequeue) | |
302 | ), | |
303 | TP_fast_assign( | |
2c92ca84 | 304 | __assign_str(name); |
2870e501 FB |
305 | __entry->maxpacket = dep->endpoint.maxpacket; |
306 | __entry->maxpacket_limit = dep->endpoint.maxpacket_limit; | |
307 | __entry->max_streams = dep->endpoint.max_streams; | |
308 | __entry->maxburst = dep->endpoint.maxburst; | |
309 | __entry->flags = dep->flags; | |
310 | __entry->direction = dep->direction; | |
311 | __entry->trb_enqueue = dep->trb_enqueue; | |
312 | __entry->trb_dequeue = dep->trb_dequeue; | |
313 | ), | |
3aec9915 | 314 | TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c", |
2870e501 FB |
315 | __get_str(name), __entry->maxpacket, |
316 | __entry->maxpacket_limit, __entry->max_streams, | |
317 | __entry->maxburst, __entry->trb_enqueue, | |
318 | __entry->trb_dequeue, | |
319 | __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e', | |
320 | __entry->flags & DWC3_EP_STALL ? 'S' : 's', | |
321 | __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w', | |
5f2e7975 | 322 | __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b', |
2870e501 | 323 | __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p', |
2870e501 FB |
324 | __entry->direction ? '<' : '>' |
325 | ) | |
326 | ); | |
327 | ||
328 | DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable, | |
329 | TP_PROTO(struct dwc3_ep *dep), | |
330 | TP_ARGS(dep) | |
331 | ); | |
332 | ||
333 | DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable, | |
334 | TP_PROTO(struct dwc3_ep *dep), | |
335 | TP_ARGS(dep) | |
336 | ); | |
337 | ||
2c4cbe6e FB |
338 | #endif /* __DWC3_TRACE_H */ |
339 | ||
340 | /* this part has to be here */ | |
341 | ||
342 | #undef TRACE_INCLUDE_PATH | |
343 | #define TRACE_INCLUDE_PATH . | |
344 | ||
345 | #undef TRACE_INCLUDE_FILE | |
346 | #define TRACE_INCLUDE_FILE trace | |
347 | ||
348 | #include <trace/define_trace.h> |