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