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