blob: da1be01637c8d826c1cdb7794d9ff077b7356776 [file] [log] [blame]
Nishad Kamdarb33f69f2020-03-28 15:34:46 +05301/* SPDX-License-Identifier: GPL-2.0 */
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -05002/**
3 * trace.h - DesignWare USB3 DRD Controller Trace Support
4 *
Alexander A. Klimov10623b82020-07-11 15:58:04 +02005 * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -05006 *
7 * Author: Felipe Balbi <balbi@ti.com>
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -05008 */
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
Felipe Balbi4dd5a692016-09-30 15:52:19 +030022DECLARE_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 ),
35 TP_printk("addr %p value %08x", __entry->base + __entry->offset,
36 __entry->value)
37);
38
39DEFINE_EVENT(dwc3_log_io, dwc3_readl,
Vincent Pelletier204ec1a2017-12-01 00:16:31 +000040 TP_PROTO(void __iomem *base, u32 offset, u32 value),
Felipe Balbi4dd5a692016-09-30 15:52:19 +030041 TP_ARGS(base, offset, value)
42);
43
44DEFINE_EVENT(dwc3_log_io, dwc3_writel,
Vincent Pelletier204ec1a2017-12-01 00:16:31 +000045 TP_PROTO(void __iomem *base, u32 offset, u32 value),
Felipe Balbi4dd5a692016-09-30 15:52:19 +030046 TP_ARGS(base, offset, value)
47);
48
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050049DECLARE_EVENT_CLASS(dwc3_log_event,
Felipe Balbi43c96be2016-09-26 13:23:34 +030050 TP_PROTO(u32 event, struct dwc3 *dwc),
51 TP_ARGS(event, dwc),
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050052 TP_STRUCT__entry(
53 __field(u32, event)
Felipe Balbi43c96be2016-09-26 13:23:34 +030054 __field(u32, ep0state)
Felipe Balbi3587f362017-04-28 11:28:35 +030055 __dynamic_array(char, str, DWC3_MSG_MAX)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050056 ),
57 TP_fast_assign(
58 __entry->event = event;
Felipe Balbi43c96be2016-09-26 13:23:34 +030059 __entry->ep0state = dwc->ep0state;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050060 ),
Felipe Balbif75cacc2016-05-23 11:10:08 +030061 TP_printk("event (%08x): %s", __entry->event,
Felipe Balbi7790b352019-02-04 15:43:38 +020062 dwc3_decode_event(__get_str(str), DWC3_MSG_MAX,
63 __entry->event, __entry->ep0state))
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050064);
65
66DEFINE_EVENT(dwc3_log_event, dwc3_event,
Felipe Balbi43c96be2016-09-26 13:23:34 +030067 TP_PROTO(u32 event, struct dwc3 *dwc),
68 TP_ARGS(event, dwc)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050069);
70
71DECLARE_EVENT_CLASS(dwc3_log_ctrl,
72 TP_PROTO(struct usb_ctrlrequest *ctrl),
73 TP_ARGS(ctrl),
74 TP_STRUCT__entry(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -050075 __field(__u8, bRequestType)
76 __field(__u8, bRequest)
John Youn96bedb62016-05-23 11:32:47 -070077 __field(__u16, wValue)
78 __field(__u16, wIndex)
79 __field(__u16, wLength)
Felipe Balbiaf324232017-04-26 16:09:09 +030080 __dynamic_array(char, str, DWC3_MSG_MAX)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050081 ),
82 TP_fast_assign(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -050083 __entry->bRequestType = ctrl->bRequestType;
84 __entry->bRequest = ctrl->bRequest;
John Youn96bedb62016-05-23 11:32:47 -070085 __entry->wValue = le16_to_cpu(ctrl->wValue);
86 __entry->wIndex = le16_to_cpu(ctrl->wIndex);
87 __entry->wLength = le16_to_cpu(ctrl->wLength);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050088 ),
Pawel Laszczak91f255a2019-08-26 12:19:27 +010089 TP_printk("%s", usb_decode_ctrl(__get_str(str), DWC3_MSG_MAX,
Felipe Balbi7790b352019-02-04 15:43:38 +020090 __entry->bRequestType,
Felipe Balbiaf324232017-04-26 16:09:09 +030091 __entry->bRequest, __entry->wValue,
92 __entry->wIndex, __entry->wLength)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050093 )
94);
95
96DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
97 TP_PROTO(struct usb_ctrlrequest *ctrl),
98 TP_ARGS(ctrl)
99);
100
101DECLARE_EVENT_CLASS(dwc3_log_request,
102 TP_PROTO(struct dwc3_request *req),
103 TP_ARGS(req),
104 TP_STRUCT__entry(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300105 __string(name, req->dep->name)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500106 __field(struct dwc3_request *, req)
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500107 __field(unsigned, actual)
108 __field(unsigned, length)
109 __field(int, status)
Felipe Balbi46a01422015-12-03 15:27:32 -0600110 __field(int, zero)
111 __field(int, short_not_ok)
112 __field(int, no_interrupt)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500113 ),
114 TP_fast_assign(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300115 __assign_str(name, req->dep->name);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500116 __entry->req = req;
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500117 __entry->actual = req->request.actual;
118 __entry->length = req->request.length;
119 __entry->status = req->request.status;
Felipe Balbi46a01422015-12-03 15:27:32 -0600120 __entry->zero = req->request.zero;
121 __entry->short_not_ok = req->request.short_not_ok;
122 __entry->no_interrupt = req->request.no_interrupt;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500123 ),
Felipe Balbi46a01422015-12-03 15:27:32 -0600124 TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500125 __get_str(name), __entry->req, __entry->actual, __entry->length,
Felipe Balbi46a01422015-12-03 15:27:32 -0600126 __entry->zero ? "Z" : "z",
127 __entry->short_not_ok ? "S" : "s",
128 __entry->no_interrupt ? "i" : "I",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500129 __entry->status
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500130 )
131);
132
133DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
134 TP_PROTO(struct dwc3_request *req),
135 TP_ARGS(req)
136);
137
138DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
139 TP_PROTO(struct dwc3_request *req),
140 TP_ARGS(req)
141);
142
143DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
144 TP_PROTO(struct dwc3_request *req),
145 TP_ARGS(req)
146);
147
148DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
149 TP_PROTO(struct dwc3_request *req),
150 TP_ARGS(req)
151);
152
153DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
154 TP_PROTO(struct dwc3_request *req),
155 TP_ARGS(req)
156);
157
158DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
Felipe Balbi71f7e702016-05-23 14:16:19 +0300159 TP_PROTO(unsigned int cmd, u32 param, int status),
160 TP_ARGS(cmd, param, status),
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500161 TP_STRUCT__entry(
162 __field(unsigned int, cmd)
163 __field(u32, param)
Felipe Balbi71f7e702016-05-23 14:16:19 +0300164 __field(int, status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500165 ),
166 TP_fast_assign(
167 __entry->cmd = cmd;
168 __entry->param = param;
Felipe Balbi71f7e702016-05-23 14:16:19 +0300169 __entry->status = status;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500170 ),
Felipe Balbiaad7c252017-03-22 13:03:13 +0200171 TP_printk("cmd '%s' [%x] param %08x --> status: %s",
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500172 dwc3_gadget_generic_cmd_string(__entry->cmd),
Felipe Balbi71f7e702016-05-23 14:16:19 +0300173 __entry->cmd, __entry->param,
174 dwc3_gadget_generic_cmd_status_string(__entry->status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500175 )
176);
177
178DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
Felipe Balbi71f7e702016-05-23 14:16:19 +0300179 TP_PROTO(unsigned int cmd, u32 param, int status),
180 TP_ARGS(cmd, param, status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500181);
182
183DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
184 TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
Felipe Balbi0933df12016-05-23 14:02:33 +0300185 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
186 TP_ARGS(dep, cmd, params, cmd_status),
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500187 TP_STRUCT__entry(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300188 __string(name, dep->name)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500189 __field(unsigned int, cmd)
Felipe Balbia4722fd32014-11-20 10:12:32 -0600190 __field(u32, param0)
191 __field(u32, param1)
192 __field(u32, param2)
Felipe Balbi0933df12016-05-23 14:02:33 +0300193 __field(int, cmd_status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500194 ),
195 TP_fast_assign(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300196 __assign_str(name, dep->name);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500197 __entry->cmd = cmd;
Felipe Balbia4722fd32014-11-20 10:12:32 -0600198 __entry->param0 = params->param0;
199 __entry->param1 = params->param1;
200 __entry->param2 = params->param2;
Felipe Balbi0933df12016-05-23 14:02:33 +0300201 __entry->cmd_status = cmd_status;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500202 ),
Felipe Balbi15172652018-08-15 08:30:59 +0300203 TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500204 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
Felipe Balbia4722fd32014-11-20 10:12:32 -0600205 __entry->cmd, __entry->param0,
Felipe Balbi0933df12016-05-23 14:02:33 +0300206 __entry->param1, __entry->param2,
207 dwc3_ep_cmd_status_string(__entry->cmd_status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500208 )
209);
210
211DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
212 TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
Felipe Balbi0933df12016-05-23 14:02:33 +0300213 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
214 TP_ARGS(dep, cmd, params, cmd_status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500215);
216
217DECLARE_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(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300221 __string(name, dep->name)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500222 __field(struct dwc3_trb *, trb)
Felipe Balbi68d34c82016-05-30 13:34:58 +0300223 __field(u32, allocated)
224 __field(u32, queued)
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500225 __field(u32, bpl)
226 __field(u32, bph)
227 __field(u32, size)
228 __field(u32, ctrl)
Felipe Balbifa8d9652016-09-28 14:58:33 +0300229 __field(u32, type)
Felipe Balbi30ad6272020-01-29 09:20:19 +0200230 __field(u32, enqueue)
231 __field(u32, dequeue)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500232 ),
233 TP_fast_assign(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300234 __assign_str(name, dep->name);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500235 __entry->trb = trb;
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500236 __entry->bpl = trb->bpl;
237 __entry->bph = trb->bph;
238 __entry->size = trb->size;
239 __entry->ctrl = trb->ctrl;
Felipe Balbifa8d9652016-09-28 14:58:33 +0300240 __entry->type = usb_endpoint_type(dep->endpoint.desc);
Felipe Balbi30ad6272020-01-29 09:20:19 +0200241 __entry->enqueue = dep->trb_enqueue;
242 __entry->dequeue = dep->trb_dequeue;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500243 ),
Felipe Balbi30ad6272020-01-29 09:20:19 +0200244 TP_printk("%s: trb %p (E%d:D%d) buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)",
245 __get_str(name), __entry->trb, __entry->enqueue,
246 __entry->dequeue, __entry->bph, __entry->bpl,
Felipe Balbifa8d9652016-09-28 14:58:33 +0300247 ({char *s;
248 int pcm = ((__entry->size >> 24) & 3) + 1;
249 switch (__entry->type) {
250 case USB_ENDPOINT_XFER_INT:
251 case USB_ENDPOINT_XFER_ISOC:
252 switch (pcm) {
253 case 1:
254 s = "1x ";
255 break;
256 case 2:
257 s = "2x ";
258 break;
259 case 3:
Andy Shevchenko54d48182018-12-03 11:28:47 +0200260 default:
Felipe Balbifa8d9652016-09-28 14:58:33 +0300261 s = "3x ";
262 break;
263 }
Andy Shevchenko54d48182018-12-03 11:28:47 +0200264 break;
Felipe Balbifa8d9652016-09-28 14:58:33 +0300265 default:
266 s = "";
267 } s; }),
268 DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl,
Janusz Dziedzic22f2c612016-05-20 10:37:13 +0200269 __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',
Felipe Balbib5c7ed52017-03-31 14:44:09 +0300275 dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500276 )
277);
278
279DEFINE_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
284DEFINE_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
Felipe Balbi2870e502016-11-03 13:53:29 +0200289DECLARE_EVENT_CLASS(dwc3_log_ep,
290 TP_PROTO(struct dwc3_ep *dep),
291 TP_ARGS(dep),
292 TP_STRUCT__entry(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300293 __string(name, dep->name)
Felipe Balbi2870e502016-11-03 13:53:29 +0200294 __field(unsigned, maxpacket)
295 __field(unsigned, maxpacket_limit)
296 __field(unsigned, max_streams)
297 __field(unsigned, maxburst)
298 __field(unsigned, flags)
299 __field(unsigned, direction)
300 __field(u8, trb_enqueue)
301 __field(u8, trb_dequeue)
302 ),
303 TP_fast_assign(
Felipe Balbie42f09b2017-04-28 12:54:52 +0300304 __assign_str(name, dep->name);
Felipe Balbi2870e502016-11-03 13:53:29 +0200305 __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 ),
Felipe Balbi3aec9912019-01-21 13:08:44 +0200314 TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c",
Felipe Balbi2870e502016-11-03 13:53:29 +0200315 __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',
Felipe Balbi5f2e7972018-03-29 11:10:45 +0300322 __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b',
Felipe Balbi2870e502016-11-03 13:53:29 +0200323 __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
Felipe Balbi2870e502016-11-03 13:53:29 +0200324 __entry->direction ? '<' : '>'
325 )
326);
327
328DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable,
329 TP_PROTO(struct dwc3_ep *dep),
330 TP_ARGS(dep)
331);
332
333DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable,
334 TP_PROTO(struct dwc3_ep *dep),
335 TP_ARGS(dep)
336);
337
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500338#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>