xref: /OK3568_Linux_fs/kernel/drivers/usb/host/xhci-trace.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * xHCI host controller driver
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2013 Xenia Ragiadakou
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Author: Xenia Ragiadakou
8*4882a593Smuzhiyun  * Email : burzalodowa@gmail.com
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #undef TRACE_SYSTEM
12*4882a593Smuzhiyun #define TRACE_SYSTEM xhci-hcd
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun /*
15*4882a593Smuzhiyun  * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
16*4882a593Smuzhiyun  * legitimate C variable. It is not exported to user space.
17*4882a593Smuzhiyun  */
18*4882a593Smuzhiyun #undef TRACE_SYSTEM_VAR
19*4882a593Smuzhiyun #define TRACE_SYSTEM_VAR xhci_hcd
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun #if !defined(__XHCI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
22*4882a593Smuzhiyun #define __XHCI_TRACE_H
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #include <linux/tracepoint.h>
25*4882a593Smuzhiyun #include "xhci.h"
26*4882a593Smuzhiyun #include "xhci-dbgcap.h"
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_msg,
29*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
30*4882a593Smuzhiyun 	TP_ARGS(vaf),
31*4882a593Smuzhiyun 	TP_STRUCT__entry(__dynamic_array(char, msg, XHCI_MSG_MAX)),
32*4882a593Smuzhiyun 	TP_fast_assign(
33*4882a593Smuzhiyun 		vsnprintf(__get_str(msg), XHCI_MSG_MAX, vaf->fmt, *vaf->va);
34*4882a593Smuzhiyun 	),
35*4882a593Smuzhiyun 	TP_printk("%s", __get_str(msg))
36*4882a593Smuzhiyun );
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_address,
39*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
40*4882a593Smuzhiyun 	TP_ARGS(vaf)
41*4882a593Smuzhiyun );
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_context_change,
44*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
45*4882a593Smuzhiyun 	TP_ARGS(vaf)
46*4882a593Smuzhiyun );
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_quirks,
49*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
50*4882a593Smuzhiyun 	TP_ARGS(vaf)
51*4882a593Smuzhiyun );
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_reset_ep,
54*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
55*4882a593Smuzhiyun 	TP_ARGS(vaf)
56*4882a593Smuzhiyun );
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_cancel_urb,
59*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
60*4882a593Smuzhiyun 	TP_ARGS(vaf)
61*4882a593Smuzhiyun );
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_init,
64*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
65*4882a593Smuzhiyun 	TP_ARGS(vaf)
66*4882a593Smuzhiyun );
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_msg, xhci_dbg_ring_expansion,
69*4882a593Smuzhiyun 	TP_PROTO(struct va_format *vaf),
70*4882a593Smuzhiyun 	TP_ARGS(vaf)
71*4882a593Smuzhiyun );
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_ctx,
74*4882a593Smuzhiyun 	TP_PROTO(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx,
75*4882a593Smuzhiyun 		 unsigned int ep_num),
76*4882a593Smuzhiyun 	TP_ARGS(xhci, ctx, ep_num),
77*4882a593Smuzhiyun 	TP_STRUCT__entry(
78*4882a593Smuzhiyun 		__field(int, ctx_64)
79*4882a593Smuzhiyun 		__field(unsigned, ctx_type)
80*4882a593Smuzhiyun 		__field(dma_addr_t, ctx_dma)
81*4882a593Smuzhiyun 		__field(u8 *, ctx_va)
82*4882a593Smuzhiyun 		__field(unsigned, ctx_ep_num)
83*4882a593Smuzhiyun 		__field(int, slot_id)
84*4882a593Smuzhiyun 		__dynamic_array(u32, ctx_data,
85*4882a593Smuzhiyun 			((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 8) *
86*4882a593Smuzhiyun 			((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1))
87*4882a593Smuzhiyun 	),
88*4882a593Smuzhiyun 	TP_fast_assign(
89*4882a593Smuzhiyun 		struct usb_device *udev;
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 		udev = to_usb_device(xhci_to_hcd(xhci)->self.controller);
92*4882a593Smuzhiyun 		__entry->ctx_64 = HCC_64BYTE_CONTEXT(xhci->hcc_params);
93*4882a593Smuzhiyun 		__entry->ctx_type = ctx->type;
94*4882a593Smuzhiyun 		__entry->ctx_dma = ctx->dma;
95*4882a593Smuzhiyun 		__entry->ctx_va = ctx->bytes;
96*4882a593Smuzhiyun 		__entry->slot_id = udev->slot_id;
97*4882a593Smuzhiyun 		__entry->ctx_ep_num = ep_num;
98*4882a593Smuzhiyun 		memcpy(__get_dynamic_array(ctx_data), ctx->bytes,
99*4882a593Smuzhiyun 			((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 32) *
100*4882a593Smuzhiyun 			((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1));
101*4882a593Smuzhiyun 	),
102*4882a593Smuzhiyun 	TP_printk("ctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p",
103*4882a593Smuzhiyun 			__entry->ctx_64, __entry->ctx_type,
104*4882a593Smuzhiyun 			(unsigned long long) __entry->ctx_dma, __entry->ctx_va
105*4882a593Smuzhiyun 	)
106*4882a593Smuzhiyun );
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ctx, xhci_address_ctx,
109*4882a593Smuzhiyun 	TP_PROTO(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx,
110*4882a593Smuzhiyun 		 unsigned int ep_num),
111*4882a593Smuzhiyun 	TP_ARGS(xhci, ctx, ep_num)
112*4882a593Smuzhiyun );
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_trb,
115*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
116*4882a593Smuzhiyun 	TP_ARGS(ring, trb),
117*4882a593Smuzhiyun 	TP_STRUCT__entry(
118*4882a593Smuzhiyun 		__field(u32, type)
119*4882a593Smuzhiyun 		__field(u32, field0)
120*4882a593Smuzhiyun 		__field(u32, field1)
121*4882a593Smuzhiyun 		__field(u32, field2)
122*4882a593Smuzhiyun 		__field(u32, field3)
123*4882a593Smuzhiyun 		__dynamic_array(char, str, XHCI_MSG_MAX)
124*4882a593Smuzhiyun 	),
125*4882a593Smuzhiyun 	TP_fast_assign(
126*4882a593Smuzhiyun 		__entry->type = ring->type;
127*4882a593Smuzhiyun 		__entry->field0 = le32_to_cpu(trb->field[0]);
128*4882a593Smuzhiyun 		__entry->field1 = le32_to_cpu(trb->field[1]);
129*4882a593Smuzhiyun 		__entry->field2 = le32_to_cpu(trb->field[2]);
130*4882a593Smuzhiyun 		__entry->field3 = le32_to_cpu(trb->field[3]);
131*4882a593Smuzhiyun 	),
132*4882a593Smuzhiyun 	TP_printk("%s: %s", xhci_ring_type_string(__entry->type),
133*4882a593Smuzhiyun 		  xhci_decode_trb(__get_str(str), XHCI_MSG_MAX, __entry->field0, __entry->field1,
134*4882a593Smuzhiyun 					__entry->field2, __entry->field3)
135*4882a593Smuzhiyun 	)
136*4882a593Smuzhiyun );
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_handle_event,
139*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
140*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
141*4882a593Smuzhiyun );
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_handle_command,
144*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
145*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
146*4882a593Smuzhiyun );
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_handle_transfer,
149*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
150*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
151*4882a593Smuzhiyun );
152*4882a593Smuzhiyun 
153*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_queue_trb,
154*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
155*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
156*4882a593Smuzhiyun );
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_dbc_handle_event,
159*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
160*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
161*4882a593Smuzhiyun );
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_dbc_handle_transfer,
164*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
165*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
166*4882a593Smuzhiyun );
167*4882a593Smuzhiyun 
168*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_trb, xhci_dbc_gadget_ep_queue,
169*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
170*4882a593Smuzhiyun 	TP_ARGS(ring, trb)
171*4882a593Smuzhiyun );
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_free_virt_dev,
174*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
175*4882a593Smuzhiyun 	TP_ARGS(vdev),
176*4882a593Smuzhiyun 	TP_STRUCT__entry(
177*4882a593Smuzhiyun 		__field(void *, vdev)
178*4882a593Smuzhiyun 		__field(unsigned long long, out_ctx)
179*4882a593Smuzhiyun 		__field(unsigned long long, in_ctx)
180*4882a593Smuzhiyun 		__field(u8, fake_port)
181*4882a593Smuzhiyun 		__field(u8, real_port)
182*4882a593Smuzhiyun 		__field(u16, current_mel)
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun 	),
185*4882a593Smuzhiyun 	TP_fast_assign(
186*4882a593Smuzhiyun 		__entry->vdev = vdev;
187*4882a593Smuzhiyun 		__entry->in_ctx = (unsigned long long) vdev->in_ctx->dma;
188*4882a593Smuzhiyun 		__entry->out_ctx = (unsigned long long) vdev->out_ctx->dma;
189*4882a593Smuzhiyun 		__entry->fake_port = (u8) vdev->fake_port;
190*4882a593Smuzhiyun 		__entry->real_port = (u8) vdev->real_port;
191*4882a593Smuzhiyun 		__entry->current_mel = (u16) vdev->current_mel;
192*4882a593Smuzhiyun 		),
193*4882a593Smuzhiyun 	TP_printk("vdev %p ctx %llx | %llx fake_port %d real_port %d current_mel %d",
194*4882a593Smuzhiyun 		__entry->vdev, __entry->in_ctx, __entry->out_ctx,
195*4882a593Smuzhiyun 		__entry->fake_port, __entry->real_port, __entry->current_mel
196*4882a593Smuzhiyun 	)
197*4882a593Smuzhiyun );
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_free_virt_dev, xhci_free_virt_device,
200*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
201*4882a593Smuzhiyun 	TP_ARGS(vdev)
202*4882a593Smuzhiyun );
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_virt_dev,
205*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
206*4882a593Smuzhiyun 	TP_ARGS(vdev),
207*4882a593Smuzhiyun 	TP_STRUCT__entry(
208*4882a593Smuzhiyun 		__field(void *, vdev)
209*4882a593Smuzhiyun 		__field(unsigned long long, out_ctx)
210*4882a593Smuzhiyun 		__field(unsigned long long, in_ctx)
211*4882a593Smuzhiyun 		__field(int, devnum)
212*4882a593Smuzhiyun 		__field(int, state)
213*4882a593Smuzhiyun 		__field(int, speed)
214*4882a593Smuzhiyun 		__field(u8, portnum)
215*4882a593Smuzhiyun 		__field(u8, level)
216*4882a593Smuzhiyun 		__field(int, slot_id)
217*4882a593Smuzhiyun 	),
218*4882a593Smuzhiyun 	TP_fast_assign(
219*4882a593Smuzhiyun 		__entry->vdev = vdev;
220*4882a593Smuzhiyun 		__entry->in_ctx = (unsigned long long) vdev->in_ctx->dma;
221*4882a593Smuzhiyun 		__entry->out_ctx = (unsigned long long) vdev->out_ctx->dma;
222*4882a593Smuzhiyun 		__entry->devnum = vdev->udev->devnum;
223*4882a593Smuzhiyun 		__entry->state = vdev->udev->state;
224*4882a593Smuzhiyun 		__entry->speed = vdev->udev->speed;
225*4882a593Smuzhiyun 		__entry->portnum = vdev->udev->portnum;
226*4882a593Smuzhiyun 		__entry->level = vdev->udev->level;
227*4882a593Smuzhiyun 		__entry->slot_id = vdev->udev->slot_id;
228*4882a593Smuzhiyun 	),
229*4882a593Smuzhiyun 	TP_printk("vdev %p ctx %llx | %llx num %d state %d speed %d port %d level %d slot %d",
230*4882a593Smuzhiyun 		__entry->vdev, __entry->in_ctx, __entry->out_ctx,
231*4882a593Smuzhiyun 		__entry->devnum, __entry->state, __entry->speed,
232*4882a593Smuzhiyun 		__entry->portnum, __entry->level, __entry->slot_id
233*4882a593Smuzhiyun 	)
234*4882a593Smuzhiyun );
235*4882a593Smuzhiyun 
236*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_virt_dev, xhci_alloc_virt_device,
237*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
238*4882a593Smuzhiyun 	TP_ARGS(vdev)
239*4882a593Smuzhiyun );
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device,
242*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
243*4882a593Smuzhiyun 	TP_ARGS(vdev)
244*4882a593Smuzhiyun );
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_addressable_virt_device,
247*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
248*4882a593Smuzhiyun 	TP_ARGS(vdev)
249*4882a593Smuzhiyun );
250*4882a593Smuzhiyun 
251*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_virt_dev, xhci_stop_device,
252*4882a593Smuzhiyun 	TP_PROTO(struct xhci_virt_device *vdev),
253*4882a593Smuzhiyun 	TP_ARGS(vdev)
254*4882a593Smuzhiyun );
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_urb,
257*4882a593Smuzhiyun 	TP_PROTO(struct urb *urb),
258*4882a593Smuzhiyun 	TP_ARGS(urb),
259*4882a593Smuzhiyun 	TP_STRUCT__entry(
260*4882a593Smuzhiyun 		__field(void *, urb)
261*4882a593Smuzhiyun 		__field(unsigned int, pipe)
262*4882a593Smuzhiyun 		__field(unsigned int, stream)
263*4882a593Smuzhiyun 		__field(int, status)
264*4882a593Smuzhiyun 		__field(unsigned int, flags)
265*4882a593Smuzhiyun 		__field(int, num_mapped_sgs)
266*4882a593Smuzhiyun 		__field(int, num_sgs)
267*4882a593Smuzhiyun 		__field(int, length)
268*4882a593Smuzhiyun 		__field(int, actual)
269*4882a593Smuzhiyun 		__field(int, epnum)
270*4882a593Smuzhiyun 		__field(int, dir_in)
271*4882a593Smuzhiyun 		__field(int, type)
272*4882a593Smuzhiyun 		__field(int, slot_id)
273*4882a593Smuzhiyun 	),
274*4882a593Smuzhiyun 	TP_fast_assign(
275*4882a593Smuzhiyun 		__entry->urb = urb;
276*4882a593Smuzhiyun 		__entry->pipe = urb->pipe;
277*4882a593Smuzhiyun 		__entry->stream = urb->stream_id;
278*4882a593Smuzhiyun 		__entry->status = urb->status;
279*4882a593Smuzhiyun 		__entry->flags = urb->transfer_flags;
280*4882a593Smuzhiyun 		__entry->num_mapped_sgs = urb->num_mapped_sgs;
281*4882a593Smuzhiyun 		__entry->num_sgs = urb->num_sgs;
282*4882a593Smuzhiyun 		__entry->length = urb->transfer_buffer_length;
283*4882a593Smuzhiyun 		__entry->actual = urb->actual_length;
284*4882a593Smuzhiyun 		__entry->epnum = usb_endpoint_num(&urb->ep->desc);
285*4882a593Smuzhiyun 		__entry->dir_in = usb_endpoint_dir_in(&urb->ep->desc);
286*4882a593Smuzhiyun 		__entry->type = usb_endpoint_type(&urb->ep->desc);
287*4882a593Smuzhiyun 		__entry->slot_id = urb->dev->slot_id;
288*4882a593Smuzhiyun 	),
289*4882a593Smuzhiyun 	TP_printk("ep%d%s-%s: urb %p pipe %u slot %d length %d/%d sgs %d/%d stream %d flags %08x",
290*4882a593Smuzhiyun 			__entry->epnum, __entry->dir_in ? "in" : "out",
291*4882a593Smuzhiyun 			__print_symbolic(__entry->type,
292*4882a593Smuzhiyun 				   { USB_ENDPOINT_XFER_INT,	"intr" },
293*4882a593Smuzhiyun 				   { USB_ENDPOINT_XFER_CONTROL,	"control" },
294*4882a593Smuzhiyun 				   { USB_ENDPOINT_XFER_BULK,	"bulk" },
295*4882a593Smuzhiyun 				   { USB_ENDPOINT_XFER_ISOC,	"isoc" }),
296*4882a593Smuzhiyun 			__entry->urb, __entry->pipe, __entry->slot_id,
297*4882a593Smuzhiyun 			__entry->actual, __entry->length, __entry->num_mapped_sgs,
298*4882a593Smuzhiyun 			__entry->num_sgs, __entry->stream, __entry->flags
299*4882a593Smuzhiyun 		)
300*4882a593Smuzhiyun );
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_urb, xhci_urb_enqueue,
303*4882a593Smuzhiyun 	TP_PROTO(struct urb *urb),
304*4882a593Smuzhiyun 	TP_ARGS(urb)
305*4882a593Smuzhiyun );
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_urb, xhci_urb_giveback,
308*4882a593Smuzhiyun 	TP_PROTO(struct urb *urb),
309*4882a593Smuzhiyun 	TP_ARGS(urb)
310*4882a593Smuzhiyun );
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_urb, xhci_urb_dequeue,
313*4882a593Smuzhiyun 	TP_PROTO(struct urb *urb),
314*4882a593Smuzhiyun 	TP_ARGS(urb)
315*4882a593Smuzhiyun );
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_ep_ctx,
318*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ep_ctx *ctx),
319*4882a593Smuzhiyun 	TP_ARGS(ctx),
320*4882a593Smuzhiyun 	TP_STRUCT__entry(
321*4882a593Smuzhiyun 		__field(u32, info)
322*4882a593Smuzhiyun 		__field(u32, info2)
323*4882a593Smuzhiyun 		__field(u64, deq)
324*4882a593Smuzhiyun 		__field(u32, tx_info)
325*4882a593Smuzhiyun 		__dynamic_array(char, str, XHCI_MSG_MAX)
326*4882a593Smuzhiyun 	),
327*4882a593Smuzhiyun 	TP_fast_assign(
328*4882a593Smuzhiyun 		__entry->info = le32_to_cpu(ctx->ep_info);
329*4882a593Smuzhiyun 		__entry->info2 = le32_to_cpu(ctx->ep_info2);
330*4882a593Smuzhiyun 		__entry->deq = le64_to_cpu(ctx->deq);
331*4882a593Smuzhiyun 		__entry->tx_info = le32_to_cpu(ctx->tx_info);
332*4882a593Smuzhiyun 	),
333*4882a593Smuzhiyun 	TP_printk("%s", xhci_decode_ep_context(__get_str(str),
334*4882a593Smuzhiyun 		__entry->info, __entry->info2, __entry->deq, __entry->tx_info)
335*4882a593Smuzhiyun 	)
336*4882a593Smuzhiyun );
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ep_ctx, xhci_handle_cmd_stop_ep,
339*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ep_ctx *ctx),
340*4882a593Smuzhiyun 	TP_ARGS(ctx)
341*4882a593Smuzhiyun );
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ep_ctx, xhci_handle_cmd_set_deq_ep,
344*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ep_ctx *ctx),
345*4882a593Smuzhiyun 	TP_ARGS(ctx)
346*4882a593Smuzhiyun );
347*4882a593Smuzhiyun 
348*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ep_ctx, xhci_handle_cmd_reset_ep,
349*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ep_ctx *ctx),
350*4882a593Smuzhiyun 	TP_ARGS(ctx)
351*4882a593Smuzhiyun );
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ep_ctx, xhci_handle_cmd_config_ep,
354*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ep_ctx *ctx),
355*4882a593Smuzhiyun 	TP_ARGS(ctx)
356*4882a593Smuzhiyun );
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ep_ctx, xhci_add_endpoint,
359*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ep_ctx *ctx),
360*4882a593Smuzhiyun 	TP_ARGS(ctx)
361*4882a593Smuzhiyun );
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_slot_ctx,
364*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
365*4882a593Smuzhiyun 	TP_ARGS(ctx),
366*4882a593Smuzhiyun 	TP_STRUCT__entry(
367*4882a593Smuzhiyun 		__field(u32, info)
368*4882a593Smuzhiyun 		__field(u32, info2)
369*4882a593Smuzhiyun 		__field(u32, tt_info)
370*4882a593Smuzhiyun 		__field(u32, state)
371*4882a593Smuzhiyun 		__dynamic_array(char, str, XHCI_MSG_MAX)
372*4882a593Smuzhiyun 	),
373*4882a593Smuzhiyun 	TP_fast_assign(
374*4882a593Smuzhiyun 		__entry->info = le32_to_cpu(ctx->dev_info);
375*4882a593Smuzhiyun 		__entry->info2 = le32_to_cpu(ctx->dev_info2);
376*4882a593Smuzhiyun 		__entry->tt_info = le64_to_cpu(ctx->tt_info);
377*4882a593Smuzhiyun 		__entry->state = le32_to_cpu(ctx->dev_state);
378*4882a593Smuzhiyun 	),
379*4882a593Smuzhiyun 	TP_printk("%s", xhci_decode_slot_context(__get_str(str),
380*4882a593Smuzhiyun 			__entry->info, __entry->info2,
381*4882a593Smuzhiyun 			__entry->tt_info, __entry->state)
382*4882a593Smuzhiyun 	)
383*4882a593Smuzhiyun );
384*4882a593Smuzhiyun 
385*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_alloc_dev,
386*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
387*4882a593Smuzhiyun 	TP_ARGS(ctx)
388*4882a593Smuzhiyun );
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_free_dev,
391*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
392*4882a593Smuzhiyun 	TP_ARGS(ctx)
393*4882a593Smuzhiyun );
394*4882a593Smuzhiyun 
395*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_handle_cmd_disable_slot,
396*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
397*4882a593Smuzhiyun 	TP_ARGS(ctx)
398*4882a593Smuzhiyun );
399*4882a593Smuzhiyun 
400*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_discover_or_reset_device,
401*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
402*4882a593Smuzhiyun 	TP_ARGS(ctx)
403*4882a593Smuzhiyun );
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_setup_device_slot,
406*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
407*4882a593Smuzhiyun 	TP_ARGS(ctx)
408*4882a593Smuzhiyun );
409*4882a593Smuzhiyun 
410*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_handle_cmd_addr_dev,
411*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
412*4882a593Smuzhiyun 	TP_ARGS(ctx)
413*4882a593Smuzhiyun );
414*4882a593Smuzhiyun 
415*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_handle_cmd_reset_dev,
416*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
417*4882a593Smuzhiyun 	TP_ARGS(ctx)
418*4882a593Smuzhiyun );
419*4882a593Smuzhiyun 
420*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_handle_cmd_set_deq,
421*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
422*4882a593Smuzhiyun 	TP_ARGS(ctx)
423*4882a593Smuzhiyun );
424*4882a593Smuzhiyun 
425*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_slot_ctx, xhci_configure_endpoint,
426*4882a593Smuzhiyun 	TP_PROTO(struct xhci_slot_ctx *ctx),
427*4882a593Smuzhiyun 	TP_ARGS(ctx)
428*4882a593Smuzhiyun );
429*4882a593Smuzhiyun 
430*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_ctrl_ctx,
431*4882a593Smuzhiyun 	TP_PROTO(struct xhci_input_control_ctx *ctrl_ctx),
432*4882a593Smuzhiyun 	TP_ARGS(ctrl_ctx),
433*4882a593Smuzhiyun 	TP_STRUCT__entry(
434*4882a593Smuzhiyun 		__field(u32, drop)
435*4882a593Smuzhiyun 		__field(u32, add)
436*4882a593Smuzhiyun 		__dynamic_array(char, str, XHCI_MSG_MAX)
437*4882a593Smuzhiyun 	),
438*4882a593Smuzhiyun 	TP_fast_assign(
439*4882a593Smuzhiyun 		__entry->drop = le32_to_cpu(ctrl_ctx->drop_flags);
440*4882a593Smuzhiyun 		__entry->add = le32_to_cpu(ctrl_ctx->add_flags);
441*4882a593Smuzhiyun 	),
442*4882a593Smuzhiyun 	TP_printk("%s", xhci_decode_ctrl_ctx(__get_str(str), __entry->drop, __entry->add)
443*4882a593Smuzhiyun 	)
444*4882a593Smuzhiyun );
445*4882a593Smuzhiyun 
446*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ctrl_ctx, xhci_address_ctrl_ctx,
447*4882a593Smuzhiyun 	TP_PROTO(struct xhci_input_control_ctx *ctrl_ctx),
448*4882a593Smuzhiyun 	TP_ARGS(ctrl_ctx)
449*4882a593Smuzhiyun );
450*4882a593Smuzhiyun 
451*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ctrl_ctx, xhci_configure_endpoint_ctrl_ctx,
452*4882a593Smuzhiyun 	TP_PROTO(struct xhci_input_control_ctx *ctrl_ctx),
453*4882a593Smuzhiyun 	TP_ARGS(ctrl_ctx)
454*4882a593Smuzhiyun );
455*4882a593Smuzhiyun 
456*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_ring,
457*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring),
458*4882a593Smuzhiyun 	TP_ARGS(ring),
459*4882a593Smuzhiyun 	TP_STRUCT__entry(
460*4882a593Smuzhiyun 		__field(u32, type)
461*4882a593Smuzhiyun 		__field(void *, ring)
462*4882a593Smuzhiyun 		__field(dma_addr_t, enq)
463*4882a593Smuzhiyun 		__field(dma_addr_t, deq)
464*4882a593Smuzhiyun 		__field(dma_addr_t, enq_seg)
465*4882a593Smuzhiyun 		__field(dma_addr_t, deq_seg)
466*4882a593Smuzhiyun 		__field(unsigned int, num_segs)
467*4882a593Smuzhiyun 		__field(unsigned int, stream_id)
468*4882a593Smuzhiyun 		__field(unsigned int, cycle_state)
469*4882a593Smuzhiyun 		__field(unsigned int, num_trbs_free)
470*4882a593Smuzhiyun 		__field(unsigned int, bounce_buf_len)
471*4882a593Smuzhiyun 	),
472*4882a593Smuzhiyun 	TP_fast_assign(
473*4882a593Smuzhiyun 		__entry->ring = ring;
474*4882a593Smuzhiyun 		__entry->type = ring->type;
475*4882a593Smuzhiyun 		__entry->num_segs = ring->num_segs;
476*4882a593Smuzhiyun 		__entry->stream_id = ring->stream_id;
477*4882a593Smuzhiyun 		__entry->enq_seg = ring->enq_seg->dma;
478*4882a593Smuzhiyun 		__entry->deq_seg = ring->deq_seg->dma;
479*4882a593Smuzhiyun 		__entry->cycle_state = ring->cycle_state;
480*4882a593Smuzhiyun 		__entry->num_trbs_free = ring->num_trbs_free;
481*4882a593Smuzhiyun 		__entry->bounce_buf_len = ring->bounce_buf_len;
482*4882a593Smuzhiyun 		__entry->enq = xhci_trb_virt_to_dma(ring->enq_seg, ring->enqueue);
483*4882a593Smuzhiyun 		__entry->deq = xhci_trb_virt_to_dma(ring->deq_seg, ring->dequeue);
484*4882a593Smuzhiyun 	),
485*4882a593Smuzhiyun 	TP_printk("%s %p: enq %pad(%pad) deq %pad(%pad) segs %d stream %d free_trbs %d bounce %d cycle %d",
486*4882a593Smuzhiyun 			xhci_ring_type_string(__entry->type), __entry->ring,
487*4882a593Smuzhiyun 			&__entry->enq, &__entry->enq_seg,
488*4882a593Smuzhiyun 			&__entry->deq, &__entry->deq_seg,
489*4882a593Smuzhiyun 			__entry->num_segs,
490*4882a593Smuzhiyun 			__entry->stream_id,
491*4882a593Smuzhiyun 			__entry->num_trbs_free,
492*4882a593Smuzhiyun 			__entry->bounce_buf_len,
493*4882a593Smuzhiyun 			__entry->cycle_state
494*4882a593Smuzhiyun 		)
495*4882a593Smuzhiyun );
496*4882a593Smuzhiyun 
497*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ring, xhci_ring_alloc,
498*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring),
499*4882a593Smuzhiyun 	TP_ARGS(ring)
500*4882a593Smuzhiyun );
501*4882a593Smuzhiyun 
502*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ring, xhci_ring_free,
503*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring),
504*4882a593Smuzhiyun 	TP_ARGS(ring)
505*4882a593Smuzhiyun );
506*4882a593Smuzhiyun 
507*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ring, xhci_ring_expansion,
508*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring),
509*4882a593Smuzhiyun 	TP_ARGS(ring)
510*4882a593Smuzhiyun );
511*4882a593Smuzhiyun 
512*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ring, xhci_inc_enq,
513*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring),
514*4882a593Smuzhiyun 	TP_ARGS(ring)
515*4882a593Smuzhiyun );
516*4882a593Smuzhiyun 
517*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_ring, xhci_inc_deq,
518*4882a593Smuzhiyun 	TP_PROTO(struct xhci_ring *ring),
519*4882a593Smuzhiyun 	TP_ARGS(ring)
520*4882a593Smuzhiyun );
521*4882a593Smuzhiyun 
522*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_portsc,
523*4882a593Smuzhiyun 		    TP_PROTO(u32 portnum, u32 portsc),
524*4882a593Smuzhiyun 		    TP_ARGS(portnum, portsc),
525*4882a593Smuzhiyun 		    TP_STRUCT__entry(
526*4882a593Smuzhiyun 				     __field(u32, portnum)
527*4882a593Smuzhiyun 				     __field(u32, portsc)
528*4882a593Smuzhiyun 				     __dynamic_array(char, str, XHCI_MSG_MAX)
529*4882a593Smuzhiyun 				     ),
530*4882a593Smuzhiyun 		    TP_fast_assign(
531*4882a593Smuzhiyun 				   __entry->portnum = portnum;
532*4882a593Smuzhiyun 				   __entry->portsc = portsc;
533*4882a593Smuzhiyun 				   ),
534*4882a593Smuzhiyun 		    TP_printk("port-%d: %s",
535*4882a593Smuzhiyun 			      __entry->portnum,
536*4882a593Smuzhiyun 			      xhci_decode_portsc(__get_str(str), __entry->portsc)
537*4882a593Smuzhiyun 			      )
538*4882a593Smuzhiyun );
539*4882a593Smuzhiyun 
540*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_portsc, xhci_handle_port_status,
541*4882a593Smuzhiyun 	     TP_PROTO(u32 portnum, u32 portsc),
542*4882a593Smuzhiyun 	     TP_ARGS(portnum, portsc)
543*4882a593Smuzhiyun );
544*4882a593Smuzhiyun 
545*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_portsc, xhci_get_port_status,
546*4882a593Smuzhiyun 	     TP_PROTO(u32 portnum, u32 portsc),
547*4882a593Smuzhiyun 	     TP_ARGS(portnum, portsc)
548*4882a593Smuzhiyun );
549*4882a593Smuzhiyun 
550*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_portsc, xhci_hub_status_data,
551*4882a593Smuzhiyun 	     TP_PROTO(u32 portnum, u32 portsc),
552*4882a593Smuzhiyun 	     TP_ARGS(portnum, portsc)
553*4882a593Smuzhiyun );
554*4882a593Smuzhiyun 
555*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_log_doorbell,
556*4882a593Smuzhiyun 	TP_PROTO(u32 slot, u32 doorbell),
557*4882a593Smuzhiyun 	TP_ARGS(slot, doorbell),
558*4882a593Smuzhiyun 	TP_STRUCT__entry(
559*4882a593Smuzhiyun 		__field(u32, slot)
560*4882a593Smuzhiyun 		__field(u32, doorbell)
561*4882a593Smuzhiyun 		__dynamic_array(char, str, XHCI_MSG_MAX)
562*4882a593Smuzhiyun 	),
563*4882a593Smuzhiyun 	TP_fast_assign(
564*4882a593Smuzhiyun 		__entry->slot = slot;
565*4882a593Smuzhiyun 		__entry->doorbell = doorbell;
566*4882a593Smuzhiyun 	),
567*4882a593Smuzhiyun 	TP_printk("Ring doorbell for %s",
568*4882a593Smuzhiyun 		  xhci_decode_doorbell(__get_str(str), __entry->slot, __entry->doorbell)
569*4882a593Smuzhiyun 	)
570*4882a593Smuzhiyun );
571*4882a593Smuzhiyun 
572*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_doorbell, xhci_ring_ep_doorbell,
573*4882a593Smuzhiyun 	     TP_PROTO(u32 slot, u32 doorbell),
574*4882a593Smuzhiyun 	     TP_ARGS(slot, doorbell)
575*4882a593Smuzhiyun );
576*4882a593Smuzhiyun 
577*4882a593Smuzhiyun DEFINE_EVENT(xhci_log_doorbell, xhci_ring_host_doorbell,
578*4882a593Smuzhiyun 	     TP_PROTO(u32 slot, u32 doorbell),
579*4882a593Smuzhiyun 	     TP_ARGS(slot, doorbell)
580*4882a593Smuzhiyun );
581*4882a593Smuzhiyun 
582*4882a593Smuzhiyun DECLARE_EVENT_CLASS(xhci_dbc_log_request,
583*4882a593Smuzhiyun 	TP_PROTO(struct dbc_request *req),
584*4882a593Smuzhiyun 	TP_ARGS(req),
585*4882a593Smuzhiyun 	TP_STRUCT__entry(
586*4882a593Smuzhiyun 		__field(struct dbc_request *, req)
587*4882a593Smuzhiyun 		__field(bool, dir)
588*4882a593Smuzhiyun 		__field(unsigned int, actual)
589*4882a593Smuzhiyun 		__field(unsigned int, length)
590*4882a593Smuzhiyun 		__field(int, status)
591*4882a593Smuzhiyun 	),
592*4882a593Smuzhiyun 	TP_fast_assign(
593*4882a593Smuzhiyun 		__entry->req = req;
594*4882a593Smuzhiyun 		__entry->dir = req->direction;
595*4882a593Smuzhiyun 		__entry->actual = req->actual;
596*4882a593Smuzhiyun 		__entry->length = req->length;
597*4882a593Smuzhiyun 		__entry->status = req->status;
598*4882a593Smuzhiyun 	),
599*4882a593Smuzhiyun 	TP_printk("%s: req %p length %u/%u ==> %d",
600*4882a593Smuzhiyun 		__entry->dir ? "bulk-in" : "bulk-out",
601*4882a593Smuzhiyun 		__entry->req, __entry->actual,
602*4882a593Smuzhiyun 		__entry->length, __entry->status
603*4882a593Smuzhiyun 	)
604*4882a593Smuzhiyun );
605*4882a593Smuzhiyun 
606*4882a593Smuzhiyun DEFINE_EVENT(xhci_dbc_log_request, xhci_dbc_alloc_request,
607*4882a593Smuzhiyun 	TP_PROTO(struct dbc_request *req),
608*4882a593Smuzhiyun 	TP_ARGS(req)
609*4882a593Smuzhiyun );
610*4882a593Smuzhiyun 
611*4882a593Smuzhiyun DEFINE_EVENT(xhci_dbc_log_request, xhci_dbc_free_request,
612*4882a593Smuzhiyun 	TP_PROTO(struct dbc_request *req),
613*4882a593Smuzhiyun 	TP_ARGS(req)
614*4882a593Smuzhiyun );
615*4882a593Smuzhiyun 
616*4882a593Smuzhiyun DEFINE_EVENT(xhci_dbc_log_request, xhci_dbc_queue_request,
617*4882a593Smuzhiyun 	TP_PROTO(struct dbc_request *req),
618*4882a593Smuzhiyun 	TP_ARGS(req)
619*4882a593Smuzhiyun );
620*4882a593Smuzhiyun 
621*4882a593Smuzhiyun DEFINE_EVENT(xhci_dbc_log_request, xhci_dbc_giveback_request,
622*4882a593Smuzhiyun 	TP_PROTO(struct dbc_request *req),
623*4882a593Smuzhiyun 	TP_ARGS(req)
624*4882a593Smuzhiyun );
625*4882a593Smuzhiyun #endif /* __XHCI_TRACE_H */
626*4882a593Smuzhiyun 
627*4882a593Smuzhiyun /* this part must be outside header guard */
628*4882a593Smuzhiyun 
629*4882a593Smuzhiyun #undef TRACE_INCLUDE_PATH
630*4882a593Smuzhiyun #define TRACE_INCLUDE_PATH .
631*4882a593Smuzhiyun 
632*4882a593Smuzhiyun #undef TRACE_INCLUDE_FILE
633*4882a593Smuzhiyun #define TRACE_INCLUDE_FILE xhci-trace
634*4882a593Smuzhiyun 
635*4882a593Smuzhiyun #include <trace/define_trace.h>
636