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