xref: /openbmc/linux/drivers/usb/mtu3/mtu3_trace.h (revision 5c306de8)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /**
3  * mtu3_trace.h - trace support
4  *
5  * Copyright (C) 2019 MediaTek Inc.
6  *
7  * Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
8  */
9 
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM mtu3
12 
13 #if !defined(__MTU3_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
14 #define __MTU3_TRACE_H__
15 
16 #include <linux/types.h>
17 #include <linux/tracepoint.h>
18 
19 #include "mtu3.h"
20 
21 TRACE_EVENT(mtu3_log,
22 	TP_PROTO(struct device *dev, struct va_format *vaf),
23 	TP_ARGS(dev, vaf),
24 	TP_STRUCT__entry(
25 		__string(name, dev_name(dev))
26 		__vstring(msg, vaf->fmt, vaf->va)
27 	),
28 	TP_fast_assign(
29 		__assign_str(name, dev_name(dev));
30 		__assign_vstr(msg, vaf->fmt, vaf->va);
31 	),
32 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
33 );
34 
35 TRACE_EVENT(mtu3_u3_ltssm_isr,
36 	TP_PROTO(u32 intr),
37 	TP_ARGS(intr),
38 	TP_STRUCT__entry(
39 		__field(u32, intr)
40 	),
41 	TP_fast_assign(
42 		__entry->intr = intr;
43 	),
44 	TP_printk("(%08x) %s %s %s %s %s %s", __entry->intr,
45 		__entry->intr & HOT_RST_INTR ? "HOT_RST" : "",
46 		__entry->intr & WARM_RST_INTR ? "WARM_RST" : "",
47 		__entry->intr & ENTER_U3_INTR ? "ENT_U3" : "",
48 		__entry->intr & EXIT_U3_INTR ? "EXIT_U3" : "",
49 		__entry->intr & VBUS_RISE_INTR ? "VBUS_RISE" : "",
50 		__entry->intr & VBUS_FALL_INTR ? "VBUS_FALL" : ""
51 	)
52 );
53 
54 TRACE_EVENT(mtu3_u2_common_isr,
55 	TP_PROTO(u32 intr),
56 	TP_ARGS(intr),
57 	TP_STRUCT__entry(
58 		__field(u32, intr)
59 	),
60 	TP_fast_assign(
61 		__entry->intr = intr;
62 	),
63 	TP_printk("(%08x) %s %s %s", __entry->intr,
64 		__entry->intr & SUSPEND_INTR ? "SUSPEND" : "",
65 		__entry->intr & RESUME_INTR ? "RESUME" : "",
66 		__entry->intr & RESET_INTR ? "RESET" : ""
67 	)
68 );
69 
70 TRACE_EVENT(mtu3_qmu_isr,
71 	TP_PROTO(u32 done_intr, u32 exp_intr),
72 	TP_ARGS(done_intr, exp_intr),
73 	TP_STRUCT__entry(
74 		__field(u32, done_intr)
75 		__field(u32, exp_intr)
76 	),
77 	TP_fast_assign(
78 		__entry->done_intr = done_intr;
79 		__entry->exp_intr = exp_intr;
80 	),
81 	TP_printk("done (tx %04x, rx %04x), exp (%08x)",
82 		__entry->done_intr & 0xffff,
83 		__entry->done_intr >> 16,
84 		__entry->exp_intr
85 	)
86 );
87 
88 DECLARE_EVENT_CLASS(mtu3_log_setup,
89 	TP_PROTO(struct usb_ctrlrequest *setup),
90 	TP_ARGS(setup),
91 	TP_STRUCT__entry(
92 		__field(__u8, bRequestType)
93 		__field(__u8, bRequest)
94 		__field(__u16, wValue)
95 		__field(__u16, wIndex)
96 		__field(__u16, wLength)
97 	),
98 	TP_fast_assign(
99 		__entry->bRequestType = setup->bRequestType;
100 		__entry->bRequest = setup->bRequest;
101 		__entry->wValue = le16_to_cpu(setup->wValue);
102 		__entry->wIndex = le16_to_cpu(setup->wIndex);
103 		__entry->wLength = le16_to_cpu(setup->wLength);
104 	),
105 	TP_printk("setup - %02x %02x %04x %04x %04x",
106 		__entry->bRequestType, __entry->bRequest,
107 		__entry->wValue, __entry->wIndex, __entry->wLength
108 	)
109 );
110 
111 DEFINE_EVENT(mtu3_log_setup, mtu3_handle_setup,
112 	TP_PROTO(struct usb_ctrlrequest *setup),
113 	TP_ARGS(setup)
114 );
115 
116 DECLARE_EVENT_CLASS(mtu3_log_request,
117 	TP_PROTO(struct mtu3_request *mreq),
118 	TP_ARGS(mreq),
119 	TP_STRUCT__entry(
120 		__string(name, mreq->mep->name)
121 		__field(struct mtu3_request *, mreq)
122 		__field(struct qmu_gpd *, gpd)
123 		__field(unsigned int, actual)
124 		__field(unsigned int, length)
125 		__field(int, status)
126 		__field(int, zero)
127 		__field(int, no_interrupt)
128 	),
129 	TP_fast_assign(
130 		__assign_str(name, mreq->mep->name);
131 		__entry->mreq = mreq;
132 		__entry->gpd = mreq->gpd;
133 		__entry->actual = mreq->request.actual;
134 		__entry->length = mreq->request.length;
135 		__entry->status = mreq->request.status;
136 		__entry->zero = mreq->request.zero;
137 		__entry->no_interrupt = mreq->request.no_interrupt;
138 	),
139 	TP_printk("%s: req %p gpd %p len %u/%u %s%s --> %d",
140 		__get_str(name), __entry->mreq, __entry->gpd,
141 		__entry->actual, __entry->length,
142 		__entry->zero ? "Z" : "z",
143 		__entry->no_interrupt ? "i" : "I",
144 		__entry->status
145 	)
146 );
147 
148 DEFINE_EVENT(mtu3_log_request, mtu3_alloc_request,
149 	TP_PROTO(struct mtu3_request *req),
150 	TP_ARGS(req)
151 );
152 
153 DEFINE_EVENT(mtu3_log_request, mtu3_free_request,
154 	TP_PROTO(struct mtu3_request *req),
155 	TP_ARGS(req)
156 );
157 
158 DEFINE_EVENT(mtu3_log_request, mtu3_gadget_queue,
159 	TP_PROTO(struct mtu3_request *req),
160 	TP_ARGS(req)
161 );
162 
163 DEFINE_EVENT(mtu3_log_request, mtu3_gadget_dequeue,
164 	TP_PROTO(struct mtu3_request *req),
165 	TP_ARGS(req)
166 );
167 
168 DEFINE_EVENT(mtu3_log_request, mtu3_req_complete,
169 	TP_PROTO(struct mtu3_request *req),
170 	TP_ARGS(req)
171 );
172 
173 DECLARE_EVENT_CLASS(mtu3_log_gpd,
174 	TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
175 	TP_ARGS(mep, gpd),
176 	TP_STRUCT__entry(
177 		__string(name, mep->name)
178 		__field(struct qmu_gpd *, gpd)
179 		__field(u32, dw0)
180 		__field(u32, dw1)
181 		__field(u32, dw2)
182 		__field(u32, dw3)
183 	),
184 	TP_fast_assign(
185 		__assign_str(name, mep->name);
186 		__entry->gpd = gpd;
187 		__entry->dw0 = le32_to_cpu(gpd->dw0_info);
188 		__entry->dw1 = le32_to_cpu(gpd->next_gpd);
189 		__entry->dw2 = le32_to_cpu(gpd->buffer);
190 		__entry->dw3 = le32_to_cpu(gpd->dw3_info);
191 	),
192 	TP_printk("%s: gpd %p - %08x %08x %08x %08x",
193 		__get_str(name), __entry->gpd,
194 		__entry->dw0, __entry->dw1,
195 		__entry->dw2, __entry->dw3
196 	)
197 );
198 
199 DEFINE_EVENT(mtu3_log_gpd, mtu3_prepare_gpd,
200 	TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
201 	TP_ARGS(mep, gpd)
202 );
203 
204 DEFINE_EVENT(mtu3_log_gpd, mtu3_complete_gpd,
205 	TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
206 	TP_ARGS(mep, gpd)
207 );
208 
209 DEFINE_EVENT(mtu3_log_gpd, mtu3_zlp_exp_gpd,
210 	TP_PROTO(struct mtu3_ep *mep, struct qmu_gpd *gpd),
211 	TP_ARGS(mep, gpd)
212 );
213 
214 DECLARE_EVENT_CLASS(mtu3_log_ep,
215 	TP_PROTO(struct mtu3_ep *mep),
216 	TP_ARGS(mep),
217 	TP_STRUCT__entry(
218 		__string(name, mep->name)
219 		__field(unsigned int, type)
220 		__field(unsigned int, slot)
221 		__field(unsigned int, maxp)
222 		__field(unsigned int, mult)
223 		__field(unsigned int, maxburst)
224 		__field(unsigned int, flags)
225 		__field(unsigned int, direction)
226 		__field(struct mtu3_gpd_ring *, gpd_ring)
227 	),
228 	TP_fast_assign(
229 		__assign_str(name, mep->name);
230 		__entry->type = mep->type;
231 		__entry->slot = mep->slot;
232 		__entry->maxp = mep->ep.maxpacket;
233 		__entry->mult = mep->ep.mult;
234 		__entry->maxburst = mep->ep.maxburst;
235 		__entry->flags = mep->flags;
236 		__entry->direction = mep->is_in;
237 		__entry->gpd_ring = &mep->gpd_ring;
238 	),
239 	TP_printk("%s: type %s maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c",
240 		__get_str(name), usb_ep_type_string(__entry->type),
241 		__entry->maxp, __entry->slot,
242 		__entry->mult, __entry->maxburst,
243 		__entry->gpd_ring, &__entry->gpd_ring->dma,
244 		__entry->flags & MTU3_EP_ENABLED ? 'E' : 'e',
245 		__entry->flags & MTU3_EP_STALL ? 'S' : 's',
246 		__entry->flags & MTU3_EP_WEDGE ? 'W' : 'w',
247 		__entry->flags & MTU3_EP_BUSY ? 'B' : 'b',
248 		__entry->direction ? '<' : '>'
249 	)
250 );
251 
252 DEFINE_EVENT(mtu3_log_ep, mtu3_gadget_ep_enable,
253 	TP_PROTO(struct mtu3_ep *mep),
254 	TP_ARGS(mep)
255 );
256 
257 DEFINE_EVENT(mtu3_log_ep, mtu3_gadget_ep_disable,
258 	TP_PROTO(struct mtu3_ep *mep),
259 	TP_ARGS(mep)
260 );
261 
262 DEFINE_EVENT(mtu3_log_ep, mtu3_gadget_ep_set_halt,
263 	TP_PROTO(struct mtu3_ep *mep),
264 	TP_ARGS(mep)
265 );
266 
267 #endif /* __MTU3_TRACE_H__ */
268 
269 /* this part has to be here */
270 
271 #undef TRACE_INCLUDE_PATH
272 #define TRACE_INCLUDE_PATH .
273 
274 #undef TRACE_INCLUDE_FILE
275 #define TRACE_INCLUDE_FILE mtu3_trace
276 
277 #include <trace/define_trace.h>
278