]> Git Repo - linux.git/blob - drivers/usb/dwc3/trace.h
sched/deadline: Move DL related code from sched/core.c to sched/deadline.c
[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 <[email protected]>
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_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
47 DEFINE_EVENT(dwc3_log_io, dwc3_readl,
48         TP_PROTO(void *base, u32 offset, u32 value),
49         TP_ARGS(base, offset, value)
50 );
51
52 DEFINE_EVENT(dwc3_log_io, dwc3_writel,
53         TP_PROTO(void *base, u32 offset, u32 value),
54         TP_ARGS(base, offset, value)
55 );
56
57 DECLARE_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         ),
64         TP_fast_assign(
65                 __entry->event = event;
66                 __entry->ep0state = dwc->ep0state;
67         ),
68         TP_printk("event (%08x): %s", __entry->event,
69                         dwc3_decode_event(__entry->event, __entry->ep0state))
70 );
71
72 DEFINE_EVENT(dwc3_log_event, dwc3_event,
73         TP_PROTO(u32 event, struct dwc3 *dwc),
74         TP_ARGS(event, dwc)
75 );
76
77 DECLARE_EVENT_CLASS(dwc3_log_ctrl,
78         TP_PROTO(struct usb_ctrlrequest *ctrl),
79         TP_ARGS(ctrl),
80         TP_STRUCT__entry(
81                 __field(__u8, bRequestType)
82                 __field(__u8, bRequest)
83                 __field(__u16, wValue)
84                 __field(__u16, wIndex)
85                 __field(__u16, wLength)
86         ),
87         TP_fast_assign(
88                 __entry->bRequestType = ctrl->bRequestType;
89                 __entry->bRequest = ctrl->bRequest;
90                 __entry->wValue = le16_to_cpu(ctrl->wValue);
91                 __entry->wIndex = le16_to_cpu(ctrl->wIndex);
92                 __entry->wLength = le16_to_cpu(ctrl->wLength);
93         ),
94         TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
95                 __entry->bRequestType, __entry->bRequest,
96                 __entry->wValue, __entry->wIndex,
97                 __entry->wLength
98         )
99 );
100
101 DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
102         TP_PROTO(struct usb_ctrlrequest *ctrl),
103         TP_ARGS(ctrl)
104 );
105
106 DECLARE_EVENT_CLASS(dwc3_log_request,
107         TP_PROTO(struct dwc3_request *req),
108         TP_ARGS(req),
109         TP_STRUCT__entry(
110                 __dynamic_array(char, name, DWC3_MSG_MAX)
111                 __field(struct dwc3_request *, req)
112                 __field(unsigned, actual)
113                 __field(unsigned, length)
114                 __field(int, status)
115                 __field(int, zero)
116                 __field(int, short_not_ok)
117                 __field(int, no_interrupt)
118         ),
119         TP_fast_assign(
120                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
121                 __entry->req = req;
122                 __entry->actual = req->request.actual;
123                 __entry->length = req->request.length;
124                 __entry->status = req->request.status;
125                 __entry->zero = req->request.zero;
126                 __entry->short_not_ok = req->request.short_not_ok;
127                 __entry->no_interrupt = req->request.no_interrupt;
128         ),
129         TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
130                 __get_str(name), __entry->req, __entry->actual, __entry->length,
131                 __entry->zero ? "Z" : "z",
132                 __entry->short_not_ok ? "S" : "s",
133                 __entry->no_interrupt ? "i" : "I",
134                 __entry->status
135         )
136 );
137
138 DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
139         TP_PROTO(struct dwc3_request *req),
140         TP_ARGS(req)
141 );
142
143 DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
144         TP_PROTO(struct dwc3_request *req),
145         TP_ARGS(req)
146 );
147
148 DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
149         TP_PROTO(struct dwc3_request *req),
150         TP_ARGS(req)
151 );
152
153 DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
154         TP_PROTO(struct dwc3_request *req),
155         TP_ARGS(req)
156 );
157
158 DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
159         TP_PROTO(struct dwc3_request *req),
160         TP_ARGS(req)
161 );
162
163 DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
164         TP_PROTO(unsigned int cmd, u32 param, int status),
165         TP_ARGS(cmd, param, status),
166         TP_STRUCT__entry(
167                 __field(unsigned int, cmd)
168                 __field(u32, param)
169                 __field(int, status)
170         ),
171         TP_fast_assign(
172                 __entry->cmd = cmd;
173                 __entry->param = param;
174                 __entry->status = status;
175         ),
176         TP_printk("cmd '%s' [%x] param %08x --> status: %s",
177                 dwc3_gadget_generic_cmd_string(__entry->cmd),
178                 __entry->cmd, __entry->param,
179                 dwc3_gadget_generic_cmd_status_string(__entry->status)
180         )
181 );
182
183 DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
184         TP_PROTO(unsigned int cmd, u32 param, int status),
185         TP_ARGS(cmd, param, status)
186 );
187
188 DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
189         TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
190                 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
191         TP_ARGS(dep, cmd, params, cmd_status),
192         TP_STRUCT__entry(
193                 __dynamic_array(char, name, DWC3_MSG_MAX)
194                 __field(unsigned int, cmd)
195                 __field(u32, param0)
196                 __field(u32, param1)
197                 __field(u32, param2)
198                 __field(int, cmd_status)
199         ),
200         TP_fast_assign(
201                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
202                 __entry->cmd = cmd;
203                 __entry->param0 = params->param0;
204                 __entry->param1 = params->param1;
205                 __entry->param2 = params->param2;
206                 __entry->cmd_status = cmd_status;
207         ),
208         TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",
209                 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
210                 __entry->cmd, __entry->param0,
211                 __entry->param1, __entry->param2,
212                 dwc3_ep_cmd_status_string(__entry->cmd_status)
213         )
214 );
215
216 DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
217         TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
218                 struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
219         TP_ARGS(dep, cmd, params, cmd_status)
220 );
221
222 DECLARE_EVENT_CLASS(dwc3_log_trb,
223         TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
224         TP_ARGS(dep, trb),
225         TP_STRUCT__entry(
226                 __dynamic_array(char, name, DWC3_MSG_MAX)
227                 __field(struct dwc3_trb *, trb)
228                 __field(u32, allocated)
229                 __field(u32, queued)
230                 __field(u32, bpl)
231                 __field(u32, bph)
232                 __field(u32, size)
233                 __field(u32, ctrl)
234                 __field(u32, type)
235         ),
236         TP_fast_assign(
237                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
238                 __entry->trb = trb;
239                 __entry->allocated = dep->allocated_requests;
240                 __entry->queued = dep->queued_requests;
241                 __entry->bpl = trb->bpl;
242                 __entry->bph = trb->bph;
243                 __entry->size = trb->size;
244                 __entry->ctrl = trb->ctrl;
245                 __entry->type = usb_endpoint_type(dep->endpoint.desc);
246         ),
247         TP_printk("%s: %d/%d trb %p buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)",
248                 __get_str(name), __entry->queued, __entry->allocated,
249                 __entry->trb, __entry->bph, __entry->bpl,
250                 ({char *s;
251                 int pcm = ((__entry->size >> 24) & 3) + 1;
252                 switch (__entry->type) {
253                 case USB_ENDPOINT_XFER_INT:
254                 case USB_ENDPOINT_XFER_ISOC:
255                         switch (pcm) {
256                         case 1:
257                                 s = "1x ";
258                                 break;
259                         case 2:
260                                 s = "2x ";
261                                 break;
262                         case 3:
263                                 s = "3x ";
264                                 break;
265                         }
266                 default:
267                         s = "";
268                 } s; }),
269                 DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl,
270                 __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
271                 __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
272                 __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
273                 __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
274                 __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
275                 __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
276                   dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))
277         )
278 );
279
280 DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
281         TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
282         TP_ARGS(dep, trb)
283 );
284
285 DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
286         TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
287         TP_ARGS(dep, trb)
288 );
289
290 DECLARE_EVENT_CLASS(dwc3_log_ep,
291         TP_PROTO(struct dwc3_ep *dep),
292         TP_ARGS(dep),
293         TP_STRUCT__entry(
294                 __dynamic_array(char, name, DWC3_MSG_MAX)
295                 __field(unsigned, maxpacket)
296                 __field(unsigned, maxpacket_limit)
297                 __field(unsigned, max_streams)
298                 __field(unsigned, maxburst)
299                 __field(unsigned, flags)
300                 __field(unsigned, direction)
301                 __field(u8, trb_enqueue)
302                 __field(u8, trb_dequeue)
303         ),
304         TP_fast_assign(
305                 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
306                 __entry->maxpacket = dep->endpoint.maxpacket;
307                 __entry->maxpacket_limit = dep->endpoint.maxpacket_limit;
308                 __entry->max_streams = dep->endpoint.max_streams;
309                 __entry->maxburst = dep->endpoint.maxburst;
310                 __entry->flags = dep->flags;
311                 __entry->direction = dep->direction;
312                 __entry->trb_enqueue = dep->trb_enqueue;
313                 __entry->trb_dequeue = dep->trb_dequeue;
314         ),
315         TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c%c:%c:%c",
316                 __get_str(name), __entry->maxpacket,
317                 __entry->maxpacket_limit, __entry->max_streams,
318                 __entry->maxburst, __entry->trb_enqueue,
319                 __entry->trb_dequeue,
320                 __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',
321                 __entry->flags & DWC3_EP_STALL ? 'S' : 's',
322                 __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',
323                 __entry->flags & DWC3_EP_BUSY ? 'B' : 'b',
324                 __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
325                 __entry->flags & DWC3_EP_MISSED_ISOC ? 'M' : 'm',
326                 __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e',
327                 __entry->direction ? '<' : '>'
328         )
329 );
330
331 DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable,
332         TP_PROTO(struct dwc3_ep *dep),
333         TP_ARGS(dep)
334 );
335
336 DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable,
337         TP_PROTO(struct dwc3_ep *dep),
338         TP_ARGS(dep)
339 );
340
341 #endif /* __DWC3_TRACE_H */
342
343 /* this part has to be here */
344
345 #undef TRACE_INCLUDE_PATH
346 #define TRACE_INCLUDE_PATH .
347
348 #undef TRACE_INCLUDE_FILE
349 #define TRACE_INCLUDE_FILE trace
350
351 #include <trace/define_trace.h>
This page took 0.052119 seconds and 4 git commands to generate.