]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/usb/dwc3/trace.h
usb: dwc3: trace: print ep cmd status with a single trace
[karo-tx-linux.git] / drivers / usb / dwc3 / trace.h
1 /**
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
30 DECLARE_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
40 DEFINE_EVENT(dwc3_log_msg, dwc3_readl,
41         TP_PROTO(struct va_format *vaf),
42         TP_ARGS(vaf)
43 );
44
45 DEFINE_EVENT(dwc3_log_msg, dwc3_writel,
46         TP_PROTO(struct va_format *vaf),
47         TP_ARGS(vaf)
48 );
49
50 DEFINE_EVENT(dwc3_log_msg, dwc3_gadget,
51         TP_PROTO(struct va_format *vaf),
52         TP_ARGS(vaf)
53 );
54
55 DEFINE_EVENT(dwc3_log_msg, dwc3_core,
56         TP_PROTO(struct va_format *vaf),
57         TP_ARGS(vaf)
58 );
59
60 DEFINE_EVENT(dwc3_log_msg, dwc3_ep0,
61         TP_PROTO(struct va_format *vaf),
62         TP_ARGS(vaf)
63 );
64
65 DECLARE_EVENT_CLASS(dwc3_log_event,
66         TP_PROTO(u32 event),
67         TP_ARGS(event),
68         TP_STRUCT__entry(
69                 __field(u32, event)
70         ),
71         TP_fast_assign(
72                 __entry->event = event;
73         ),
74         TP_printk("event (%08x): %s", __entry->event,
75                         dwc3_decode_event(__entry->event))
76 );
77
78 DEFINE_EVENT(dwc3_log_event, dwc3_event,
79         TP_PROTO(u32 event),
80         TP_ARGS(event)
81 );
82
83 DECLARE_EVENT_CLASS(dwc3_log_ctrl,
84         TP_PROTO(struct usb_ctrlrequest *ctrl),
85         TP_ARGS(ctrl),
86         TP_STRUCT__entry(
87                 __field(__u8, bRequestType)
88                 __field(__u8, bRequest)
89                 __field(__le16, wValue)
90                 __field(__le16, wIndex)
91                 __field(__le16, wLength)
92         ),
93         TP_fast_assign(
94                 __entry->bRequestType = ctrl->bRequestType;
95                 __entry->bRequest = ctrl->bRequest;
96                 __entry->wValue = ctrl->wValue;
97                 __entry->wIndex = ctrl->wIndex;
98                 __entry->wLength = ctrl->wLength;
99         ),
100         TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
101                 __entry->bRequestType, __entry->bRequest,
102                 le16_to_cpu(__entry->wValue), le16_to_cpu(__entry->wIndex),
103                 le16_to_cpu(__entry->wLength)
104         )
105 );
106
107 DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
108         TP_PROTO(struct usb_ctrlrequest *ctrl),
109         TP_ARGS(ctrl)
110 );
111
112 DECLARE_EVENT_CLASS(dwc3_log_request,
113         TP_PROTO(struct dwc3_request *req),
114         TP_ARGS(req),
115         TP_STRUCT__entry(
116                 __dynamic_array(char, name, DWC3_MSG_MAX)
117                 __field(struct dwc3_request *, req)
118                 __field(unsigned, actual)
119                 __field(unsigned, length)
120                 __field(int, status)
121                 __field(int, zero)
122                 __field(int, short_not_ok)
123                 __field(int, no_interrupt)
124         ),
125         TP_fast_assign(
126                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
127                 __entry->req = req;
128                 __entry->actual = req->request.actual;
129                 __entry->length = req->request.length;
130                 __entry->status = req->request.status;
131                 __entry->zero = req->request.zero;
132                 __entry->short_not_ok = req->request.short_not_ok;
133                 __entry->no_interrupt = req->request.no_interrupt;
134         ),
135         TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
136                 __get_str(name), __entry->req, __entry->actual, __entry->length,
137                 __entry->zero ? "Z" : "z",
138                 __entry->short_not_ok ? "S" : "s",
139                 __entry->no_interrupt ? "i" : "I",
140                 __entry->status
141         )
142 );
143
144 DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
145         TP_PROTO(struct dwc3_request *req),
146         TP_ARGS(req)
147 );
148
149 DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
150         TP_PROTO(struct dwc3_request *req),
151         TP_ARGS(req)
152 );
153
154 DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
155         TP_PROTO(struct dwc3_request *req),
156         TP_ARGS(req)
157 );
158
159 DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
160         TP_PROTO(struct dwc3_request *req),
161         TP_ARGS(req)
162 );
163
164 DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
165         TP_PROTO(struct dwc3_request *req),
166         TP_ARGS(req)
167 );
168
169 DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
170         TP_PROTO(unsigned int cmd, u32 param),
171         TP_ARGS(cmd, param),
172         TP_STRUCT__entry(
173                 __field(unsigned int, cmd)
174                 __field(u32, param)
175         ),
176         TP_fast_assign(
177                 __entry->cmd = cmd;
178                 __entry->param = param;
179         ),
180         TP_printk("cmd '%s' [%d] param %08x",
181                 dwc3_gadget_generic_cmd_string(__entry->cmd),
182                 __entry->cmd, __entry->param
183         )
184 );
185
186 DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
187         TP_PROTO(unsigned int cmd, u32 param),
188         TP_ARGS(cmd, param)
189 );
190
191 DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
192         TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
193                 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
194         TP_ARGS(dep, cmd, params, cmd_status),
195         TP_STRUCT__entry(
196                 __dynamic_array(char, name, DWC3_MSG_MAX)
197                 __field(unsigned int, cmd)
198                 __field(u32, param0)
199                 __field(u32, param1)
200                 __field(u32, param2)
201                 __field(int, cmd_status)
202         ),
203         TP_fast_assign(
204                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
205                 __entry->cmd = cmd;
206                 __entry->param0 = params->param0;
207                 __entry->param1 = params->param1;
208                 __entry->param2 = params->param2;
209                 __entry->cmd_status = cmd_status;
210         ),
211         TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
212                 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
213                 __entry->cmd, __entry->param0,
214                 __entry->param1, __entry->param2,
215                 dwc3_ep_cmd_status_string(__entry->cmd_status)
216         )
217 );
218
219 DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
220         TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
221                 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
222         TP_ARGS(dep, cmd, params, cmd_status)
223 );
224
225 DECLARE_EVENT_CLASS(dwc3_log_trb,
226         TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
227         TP_ARGS(dep, trb),
228         TP_STRUCT__entry(
229                 __dynamic_array(char, name, DWC3_MSG_MAX)
230                 __field(struct dwc3_trb *, trb)
231                 __field(u32, bpl)
232                 __field(u32, bph)
233                 __field(u32, size)
234                 __field(u32, ctrl)
235         ),
236         TP_fast_assign(
237                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
238                 __entry->trb = trb;
239                 __entry->bpl = trb->bpl;
240                 __entry->bph = trb->bph;
241                 __entry->size = trb->size;
242                 __entry->ctrl = trb->ctrl;
243         ),
244         TP_printk("%s: trb %p buf %08x%08x size %d ctrl %08x (%c%c%c%c:%c%c:%s)",
245                 __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
246                 __entry->size, __entry->ctrl,
247                 __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
248                 __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
249                 __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
250                 __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
251                 __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
252                 __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
253                 ({char *s;
254                 switch (__entry->ctrl & 0x3f0) {
255                 case DWC3_TRBCTL_NORMAL:
256                         s = "normal";
257                         break;
258                 case DWC3_TRBCTL_CONTROL_SETUP:
259                         s = "setup";
260                         break;
261                 case DWC3_TRBCTL_CONTROL_STATUS2:
262                         s = "status2";
263                         break;
264                 case DWC3_TRBCTL_CONTROL_STATUS3:
265                         s = "status3";
266                         break;
267                 case DWC3_TRBCTL_CONTROL_DATA:
268                         s = "data";
269                         break;
270                 case DWC3_TRBCTL_ISOCHRONOUS_FIRST:
271                         s = "isoc-first";
272                         break;
273                 case DWC3_TRBCTL_ISOCHRONOUS:
274                         s = "isoc";
275                         break;
276                 case DWC3_TRBCTL_LINK_TRB:
277                         s = "link";
278                         break;
279                 default:
280                         s = "UNKNOWN";
281                         break;
282                 } s; })
283         )
284 );
285
286 DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
287         TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
288         TP_ARGS(dep, trb)
289 );
290
291 DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
292         TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
293         TP_ARGS(dep, trb)
294 );
295
296 #endif /* __DWC3_TRACE_H */
297
298 /* this part has to be here */
299
300 #undef TRACE_INCLUDE_PATH
301 #define TRACE_INCLUDE_PATH .
302
303 #undef TRACE_INCLUDE_FILE
304 #define TRACE_INCLUDE_FILE trace
305
306 #include <trace/define_trace.h>