blob: a4ef5e7bf6b86ccebf2efd08f992a96a8a0e6f4f [file] [log] [blame]
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -05001/**
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_msg,
31 TP_PROTO(struct va_format *vaf),
32 TP_ARGS(vaf),
33 TP_STRUCT__entry(__dynamic_array(char, msg, DWC3_MSG_MAX)),
34 TP_fast_assign(
35 vsnprintf(__get_str(msg), DWC3_MSG_MAX, vaf->fmt, *vaf->va);
36 ),
37 TP_printk("%s", __get_str(msg))
38);
39
40DEFINE_EVENT(dwc3_log_msg, dwc3_readl,
41 TP_PROTO(struct va_format *vaf),
42 TP_ARGS(vaf)
43);
44
45DEFINE_EVENT(dwc3_log_msg, dwc3_writel,
46 TP_PROTO(struct va_format *vaf),
47 TP_ARGS(vaf)
48);
49
Felipe Balbi6bac4ff2015-01-27 13:47:02 -060050DEFINE_EVENT(dwc3_log_msg, dwc3_gadget,
51 TP_PROTO(struct va_format *vaf),
52 TP_ARGS(vaf)
53);
54
55DEFINE_EVENT(dwc3_log_msg, dwc3_core,
56 TP_PROTO(struct va_format *vaf),
57 TP_ARGS(vaf)
58);
59
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050060DEFINE_EVENT(dwc3_log_msg, dwc3_ep0,
61 TP_PROTO(struct va_format *vaf),
62 TP_ARGS(vaf)
63);
64
65DECLARE_EVENT_CLASS(dwc3_log_event,
Felipe Balbi43c96be2016-09-26 13:23:34 +030066 TP_PROTO(u32 event, struct dwc3 *dwc),
67 TP_ARGS(event, dwc),
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050068 TP_STRUCT__entry(
69 __field(u32, event)
Felipe Balbi43c96be2016-09-26 13:23:34 +030070 __field(u32, ep0state)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050071 ),
72 TP_fast_assign(
73 __entry->event = event;
Felipe Balbi43c96be2016-09-26 13:23:34 +030074 __entry->ep0state = dwc->ep0state;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050075 ),
Felipe Balbif75cacc2016-05-23 11:10:08 +030076 TP_printk("event (%08x): %s", __entry->event,
Felipe Balbi43c96be2016-09-26 13:23:34 +030077 dwc3_decode_event(__entry->event, __entry->ep0state))
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050078);
79
80DEFINE_EVENT(dwc3_log_event, dwc3_event,
Felipe Balbi43c96be2016-09-26 13:23:34 +030081 TP_PROTO(u32 event, struct dwc3 *dwc),
82 TP_ARGS(event, dwc)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050083);
84
85DECLARE_EVENT_CLASS(dwc3_log_ctrl,
86 TP_PROTO(struct usb_ctrlrequest *ctrl),
87 TP_ARGS(ctrl),
88 TP_STRUCT__entry(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -050089 __field(__u8, bRequestType)
90 __field(__u8, bRequest)
John Youn96bedb62016-05-23 11:32:47 -070091 __field(__u16, wValue)
92 __field(__u16, wIndex)
93 __field(__u16, wLength)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -050094 ),
95 TP_fast_assign(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -050096 __entry->bRequestType = ctrl->bRequestType;
97 __entry->bRequest = ctrl->bRequest;
John Youn96bedb62016-05-23 11:32:47 -070098 __entry->wValue = le16_to_cpu(ctrl->wValue);
99 __entry->wIndex = le16_to_cpu(ctrl->wIndex);
100 __entry->wLength = le16_to_cpu(ctrl->wLength);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500101 ),
102 TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500103 __entry->bRequestType, __entry->bRequest,
John Youn96bedb62016-05-23 11:32:47 -0700104 __entry->wValue, __entry->wIndex,
105 __entry->wLength
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500106 )
107);
108
109DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
110 TP_PROTO(struct usb_ctrlrequest *ctrl),
111 TP_ARGS(ctrl)
112);
113
114DECLARE_EVENT_CLASS(dwc3_log_request,
115 TP_PROTO(struct dwc3_request *req),
116 TP_ARGS(req),
117 TP_STRUCT__entry(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500118 __dynamic_array(char, name, DWC3_MSG_MAX)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500119 __field(struct dwc3_request *, req)
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500120 __field(unsigned, actual)
121 __field(unsigned, length)
122 __field(int, status)
Felipe Balbi46a01422015-12-03 15:27:32 -0600123 __field(int, zero)
124 __field(int, short_not_ok)
125 __field(int, no_interrupt)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500126 ),
127 TP_fast_assign(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500128 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500129 __entry->req = req;
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500130 __entry->actual = req->request.actual;
131 __entry->length = req->request.length;
132 __entry->status = req->request.status;
Felipe Balbi46a01422015-12-03 15:27:32 -0600133 __entry->zero = req->request.zero;
134 __entry->short_not_ok = req->request.short_not_ok;
135 __entry->no_interrupt = req->request.no_interrupt;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500136 ),
Felipe Balbi46a01422015-12-03 15:27:32 -0600137 TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500138 __get_str(name), __entry->req, __entry->actual, __entry->length,
Felipe Balbi46a01422015-12-03 15:27:32 -0600139 __entry->zero ? "Z" : "z",
140 __entry->short_not_ok ? "S" : "s",
141 __entry->no_interrupt ? "i" : "I",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500142 __entry->status
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500143 )
144);
145
146DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
147 TP_PROTO(struct dwc3_request *req),
148 TP_ARGS(req)
149);
150
151DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
152 TP_PROTO(struct dwc3_request *req),
153 TP_ARGS(req)
154);
155
156DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
157 TP_PROTO(struct dwc3_request *req),
158 TP_ARGS(req)
159);
160
161DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
162 TP_PROTO(struct dwc3_request *req),
163 TP_ARGS(req)
164);
165
166DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
167 TP_PROTO(struct dwc3_request *req),
168 TP_ARGS(req)
169);
170
171DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
Felipe Balbi71f7e702016-05-23 14:16:19 +0300172 TP_PROTO(unsigned int cmd, u32 param, int status),
173 TP_ARGS(cmd, param, status),
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500174 TP_STRUCT__entry(
175 __field(unsigned int, cmd)
176 __field(u32, param)
Felipe Balbi71f7e702016-05-23 14:16:19 +0300177 __field(int, status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500178 ),
179 TP_fast_assign(
180 __entry->cmd = cmd;
181 __entry->param = param;
Felipe Balbi71f7e702016-05-23 14:16:19 +0300182 __entry->status = status;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500183 ),
Felipe Balbi71f7e702016-05-23 14:16:19 +0300184 TP_printk("cmd '%s' [%d] param %08x --> status: %s",
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500185 dwc3_gadget_generic_cmd_string(__entry->cmd),
Felipe Balbi71f7e702016-05-23 14:16:19 +0300186 __entry->cmd, __entry->param,
187 dwc3_gadget_generic_cmd_status_string(__entry->status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500188 )
189);
190
191DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
Felipe Balbi71f7e702016-05-23 14:16:19 +0300192 TP_PROTO(unsigned int cmd, u32 param, int status),
193 TP_ARGS(cmd, param, status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500194);
195
196DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
197 TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
Felipe Balbi0933df12016-05-23 14:02:33 +0300198 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
199 TP_ARGS(dep, cmd, params, cmd_status),
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500200 TP_STRUCT__entry(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500201 __dynamic_array(char, name, DWC3_MSG_MAX)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500202 __field(unsigned int, cmd)
Felipe Balbia4722fd32014-11-20 10:12:32 -0600203 __field(u32, param0)
204 __field(u32, param1)
205 __field(u32, param2)
Felipe Balbi0933df12016-05-23 14:02:33 +0300206 __field(int, cmd_status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500207 ),
208 TP_fast_assign(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500209 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500210 __entry->cmd = cmd;
Felipe Balbia4722fd32014-11-20 10:12:32 -0600211 __entry->param0 = params->param0;
212 __entry->param1 = params->param1;
213 __entry->param2 = params->param2;
Felipe Balbi0933df12016-05-23 14:02:33 +0300214 __entry->cmd_status = cmd_status;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500215 ),
Felipe Balbi0933df12016-05-23 14:02:33 +0300216 TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500217 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
Felipe Balbia4722fd32014-11-20 10:12:32 -0600218 __entry->cmd, __entry->param0,
Felipe Balbi0933df12016-05-23 14:02:33 +0300219 __entry->param1, __entry->param2,
220 dwc3_ep_cmd_status_string(__entry->cmd_status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500221 )
222);
223
224DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
225 TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
Felipe Balbi0933df12016-05-23 14:02:33 +0300226 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
227 TP_ARGS(dep, cmd, params, cmd_status)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500228);
229
230DECLARE_EVENT_CLASS(dwc3_log_trb,
231 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
232 TP_ARGS(dep, trb),
233 TP_STRUCT__entry(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500234 __dynamic_array(char, name, DWC3_MSG_MAX)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500235 __field(struct dwc3_trb *, trb)
Felipe Balbi68d34c82016-05-30 13:34:58 +0300236 __field(u32, allocated)
237 __field(u32, queued)
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500238 __field(u32, bpl)
239 __field(u32, bph)
240 __field(u32, size)
241 __field(u32, ctrl)
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500242 ),
243 TP_fast_assign(
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500244 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500245 __entry->trb = trb;
Felipe Balbi68d34c82016-05-30 13:34:58 +0300246 __entry->allocated = dep->allocated_requests;
247 __entry->queued = dep->queued_requests;
Felipe Balbi4ac4fc92014-09-17 16:28:38 -0500248 __entry->bpl = trb->bpl;
249 __entry->bph = trb->bph;
250 __entry->size = trb->size;
251 __entry->ctrl = trb->ctrl;
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500252 ),
Felipe Balbi68d34c82016-05-30 13:34:58 +0300253 TP_printk("%s: %d/%d trb %p buf %08x%08x size %d ctrl %08x (%c%c%c%c:%c%c:%s)",
254 __get_str(name), __entry->queued, __entry->allocated,
255 __entry->trb, __entry->bph, __entry->bpl,
Janusz Dziedzic22f2c612016-05-20 10:37:13 +0200256 __entry->size, __entry->ctrl,
257 __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
258 __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
259 __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
260 __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
261 __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
262 __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
263 ({char *s;
264 switch (__entry->ctrl & 0x3f0) {
265 case DWC3_TRBCTL_NORMAL:
266 s = "normal";
267 break;
268 case DWC3_TRBCTL_CONTROL_SETUP:
269 s = "setup";
270 break;
271 case DWC3_TRBCTL_CONTROL_STATUS2:
272 s = "status2";
273 break;
274 case DWC3_TRBCTL_CONTROL_STATUS3:
275 s = "status3";
276 break;
277 case DWC3_TRBCTL_CONTROL_DATA:
278 s = "data";
279 break;
280 case DWC3_TRBCTL_ISOCHRONOUS_FIRST:
281 s = "isoc-first";
282 break;
283 case DWC3_TRBCTL_ISOCHRONOUS:
284 s = "isoc";
285 break;
286 case DWC3_TRBCTL_LINK_TRB:
287 s = "link";
288 break;
289 default:
290 s = "UNKNOWN";
291 break;
292 } s; })
Felipe Balbi2c4cbe6e52014-04-30 17:45:10 -0500293 )
294);
295
296DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
297 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
298 TP_ARGS(dep, trb)
299);
300
301DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
302 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
303 TP_ARGS(dep, trb)
304);
305
306#endif /* __DWC3_TRACE_H */
307
308/* this part has to be here */
309
310#undef TRACE_INCLUDE_PATH
311#define TRACE_INCLUDE_PATH .
312
313#undef TRACE_INCLUDE_FILE
314#define TRACE_INCLUDE_FILE trace
315
316#include <trace/define_trace.h>