xref: /openbmc/linux/drivers/usb/gadget/udc/trace.h (revision 7c7e33b7)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * udc.c - Core UDC Framework
4  *
5  * Copyright (C) 2016 Intel Corporation
6  * Author: Felipe Balbi <felipe.balbi@linux.intel.com>
7  */
8 
9 #undef TRACE_SYSTEM
10 #define TRACE_SYSTEM gadget
11 
12 #if !defined(__UDC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
13 #define __UDC_TRACE_H
14 
15 #include <linux/types.h>
16 #include <linux/tracepoint.h>
17 #include <asm/byteorder.h>
18 #include <linux/usb/gadget.h>
19 
20 DECLARE_EVENT_CLASS(udc_log_gadget,
21 	TP_PROTO(struct usb_gadget *g, int ret),
22 	TP_ARGS(g, ret),
23 	TP_STRUCT__entry(
24 		__field(enum usb_device_speed, speed)
25 		__field(enum usb_device_speed, max_speed)
26 		__field(enum usb_device_state, state)
27 		__field(unsigned, mA)
28 		__field(unsigned, sg_supported)
29 		__field(unsigned, is_otg)
30 		__field(unsigned, is_a_peripheral)
31 		__field(unsigned, b_hnp_enable)
32 		__field(unsigned, a_hnp_support)
33 		__field(unsigned, hnp_polling_support)
34 		__field(unsigned, host_request_flag)
35 		__field(unsigned, quirk_ep_out_aligned_size)
36 		__field(unsigned, quirk_altset_not_supp)
37 		__field(unsigned, quirk_stall_not_supp)
38 		__field(unsigned, quirk_zlp_not_supp)
39 		__field(unsigned, is_selfpowered)
40 		__field(unsigned, deactivated)
41 		__field(unsigned, connected)
42 		__field(int, ret)
43 	),
44 	TP_fast_assign(
45 		__entry->speed = g->speed;
46 		__entry->max_speed = g->max_speed;
47 		__entry->state = g->state;
48 		__entry->mA = g->mA;
49 		__entry->sg_supported = g->sg_supported;
50 		__entry->is_otg = g->is_otg;
51 		__entry->is_a_peripheral = g->is_a_peripheral;
52 		__entry->b_hnp_enable = g->b_hnp_enable;
53 		__entry->a_hnp_support = g->a_hnp_support;
54 		__entry->hnp_polling_support = g->hnp_polling_support;
55 		__entry->host_request_flag = g->host_request_flag;
56 		__entry->quirk_ep_out_aligned_size = g->quirk_ep_out_aligned_size;
57 		__entry->quirk_altset_not_supp = g->quirk_altset_not_supp;
58 		__entry->quirk_stall_not_supp = g->quirk_stall_not_supp;
59 		__entry->quirk_zlp_not_supp = g->quirk_zlp_not_supp;
60 		__entry->is_selfpowered = g->is_selfpowered;
61 		__entry->deactivated = g->deactivated;
62 		__entry->connected = g->connected;
63 		__entry->ret = ret;
64 	),
65 	TP_printk("speed %d/%d state %d %dmA [%s%s%s%s%s%s%s%s%s%s%s%s%s%s] --> %d",
66 		__entry->speed, __entry->max_speed, __entry->state, __entry->mA,
67 		__entry->sg_supported ? "sg:" : "",
68 		__entry->is_otg ? "OTG:" : "",
69 		__entry->is_a_peripheral ? "a_peripheral:" : "",
70 		__entry->b_hnp_enable ? "b_hnp:" : "",
71 		__entry->a_hnp_support ? "a_hnp:" : "",
72 		__entry->hnp_polling_support ? "hnp_poll:" : "",
73 		__entry->host_request_flag ? "hostreq:" : "",
74 		__entry->quirk_ep_out_aligned_size ? "out_aligned:" : "",
75 		__entry->quirk_altset_not_supp ? "no_altset:" : "",
76 		__entry->quirk_stall_not_supp ? "no_stall:" : "",
77 		__entry->quirk_zlp_not_supp ? "no_zlp" : "",
78 		__entry->is_selfpowered ? "self-powered:" : "bus-powered:",
79 		__entry->deactivated ? "deactivated:" : "activated:",
80 		__entry->connected ? "connected" : "disconnected",
81 		__entry->ret)
82 );
83 
84 DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
85 	TP_PROTO(struct usb_gadget *g, int ret),
86 	TP_ARGS(g, ret)
87 );
88 
89 DEFINE_EVENT(udc_log_gadget, usb_gadget_wakeup,
90 	TP_PROTO(struct usb_gadget *g, int ret),
91 	TP_ARGS(g, ret)
92 );
93 
94 DEFINE_EVENT(udc_log_gadget, usb_gadget_set_remote_wakeup,
95 	TP_PROTO(struct usb_gadget *g, int ret),
96 	TP_ARGS(g, ret)
97 );
98 
99 DEFINE_EVENT(udc_log_gadget, usb_gadget_set_selfpowered,
100 	TP_PROTO(struct usb_gadget *g, int ret),
101 	TP_ARGS(g, ret)
102 );
103 
104 DEFINE_EVENT(udc_log_gadget, usb_gadget_clear_selfpowered,
105 	TP_PROTO(struct usb_gadget *g, int ret),
106 	TP_ARGS(g, ret)
107 );
108 
109 DEFINE_EVENT(udc_log_gadget, usb_gadget_vbus_connect,
110 	TP_PROTO(struct usb_gadget *g, int ret),
111 	TP_ARGS(g, ret)
112 );
113 
114 DEFINE_EVENT(udc_log_gadget, usb_gadget_vbus_draw,
115 	TP_PROTO(struct usb_gadget *g, int ret),
116 	TP_ARGS(g, ret)
117 );
118 
119 DEFINE_EVENT(udc_log_gadget, usb_gadget_vbus_disconnect,
120 	TP_PROTO(struct usb_gadget *g, int ret),
121 	TP_ARGS(g, ret)
122 );
123 
124 DEFINE_EVENT(udc_log_gadget, usb_gadget_connect,
125 	TP_PROTO(struct usb_gadget *g, int ret),
126 	TP_ARGS(g, ret)
127 );
128 
129 DEFINE_EVENT(udc_log_gadget, usb_gadget_disconnect,
130 	TP_PROTO(struct usb_gadget *g, int ret),
131 	TP_ARGS(g, ret)
132 );
133 
134 DEFINE_EVENT(udc_log_gadget, usb_gadget_deactivate,
135 	TP_PROTO(struct usb_gadget *g, int ret),
136 	TP_ARGS(g, ret)
137 );
138 
139 DEFINE_EVENT(udc_log_gadget, usb_gadget_activate,
140 	TP_PROTO(struct usb_gadget *g, int ret),
141 	TP_ARGS(g, ret)
142 );
143 
144 DECLARE_EVENT_CLASS(udc_log_ep,
145 	TP_PROTO(struct usb_ep *ep, int ret),
146 	TP_ARGS(ep, ret),
147 	TP_STRUCT__entry(
148 		__string(name, ep->name)
149 		__field(unsigned, maxpacket)
150 		__field(unsigned, maxpacket_limit)
151 		__field(unsigned, max_streams)
152 		__field(unsigned, mult)
153 		__field(unsigned, maxburst)
154 		__field(u8, address)
155 		__field(bool, claimed)
156 		__field(bool, enabled)
157 		__field(int, ret)
158 	),
159 	TP_fast_assign(
160 		__assign_str(name, ep->name);
161 		__entry->maxpacket = ep->maxpacket;
162 		__entry->maxpacket_limit = ep->maxpacket_limit;
163 		__entry->max_streams = ep->max_streams;
164 		__entry->mult = ep->mult;
165 		__entry->maxburst = ep->maxburst;
166 		__entry->address = ep->address,
167 		__entry->claimed = ep->claimed;
168 		__entry->enabled = ep->enabled;
169 		__entry->ret = ret;
170 	),
171 	TP_printk("%s: mps %d/%d streams %d mult %d burst %d addr %02x %s%s --> %d",
172 		__get_str(name), __entry->maxpacket, __entry->maxpacket_limit,
173 		__entry->max_streams, __entry->mult, __entry->maxburst,
174 		__entry->address, __entry->claimed ? "claimed:" : "released:",
175 		__entry->enabled ? "enabled" : "disabled", ret)
176 );
177 
178 DEFINE_EVENT(udc_log_ep, usb_ep_set_maxpacket_limit,
179 	TP_PROTO(struct usb_ep *ep, int ret),
180 	TP_ARGS(ep, ret)
181 );
182 
183 DEFINE_EVENT(udc_log_ep, usb_ep_enable,
184 	TP_PROTO(struct usb_ep *ep, int ret),
185 	TP_ARGS(ep, ret)
186 );
187 
188 DEFINE_EVENT(udc_log_ep, usb_ep_disable,
189 	TP_PROTO(struct usb_ep *ep, int ret),
190 	TP_ARGS(ep, ret)
191 );
192 
193 DEFINE_EVENT(udc_log_ep, usb_ep_set_halt,
194 	TP_PROTO(struct usb_ep *ep, int ret),
195 	TP_ARGS(ep, ret)
196 );
197 
198 DEFINE_EVENT(udc_log_ep, usb_ep_clear_halt,
199 	TP_PROTO(struct usb_ep *ep, int ret),
200 	TP_ARGS(ep, ret)
201 );
202 
203 DEFINE_EVENT(udc_log_ep, usb_ep_set_wedge,
204 	TP_PROTO(struct usb_ep *ep, int ret),
205 	TP_ARGS(ep, ret)
206 );
207 
208 DEFINE_EVENT(udc_log_ep, usb_ep_fifo_status,
209 	TP_PROTO(struct usb_ep *ep, int ret),
210 	TP_ARGS(ep, ret)
211 );
212 
213 DEFINE_EVENT(udc_log_ep, usb_ep_fifo_flush,
214 	TP_PROTO(struct usb_ep *ep, int ret),
215 	TP_ARGS(ep, ret)
216 );
217 
218 DECLARE_EVENT_CLASS(udc_log_req,
219 	TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
220 	TP_ARGS(ep, req, ret),
221 	TP_STRUCT__entry(
222 		__string(name, ep->name)
223 		__field(unsigned, length)
224 		__field(unsigned, actual)
225 		__field(unsigned, num_sgs)
226 		__field(unsigned, num_mapped_sgs)
227 		__field(unsigned, stream_id)
228 		__field(unsigned, no_interrupt)
229 		__field(unsigned, zero)
230 		__field(unsigned, short_not_ok)
231 		__field(int, status)
232 		__field(int, ret)
233 		__field(struct usb_request *, req)
234 	),
235 	TP_fast_assign(
236 		__assign_str(name, ep->name);
237 		__entry->length = req->length;
238 		__entry->actual = req->actual;
239 		__entry->num_sgs = req->num_sgs;
240 		__entry->num_mapped_sgs = req->num_mapped_sgs;
241 		__entry->stream_id = req->stream_id;
242 		__entry->no_interrupt = req->no_interrupt;
243 		__entry->zero = req->zero;
244 		__entry->short_not_ok = req->short_not_ok;
245 		__entry->status = req->status;
246 		__entry->ret = ret;
247 		__entry->req = req;
248 	),
249 	TP_printk("%s: req %p length %d/%d sgs %d/%d stream %d %s%s%s status %d --> %d",
250 		__get_str(name),__entry->req,  __entry->actual, __entry->length,
251 		__entry->num_mapped_sgs, __entry->num_sgs, __entry->stream_id,
252 		__entry->zero ? "Z" : "z",
253 		__entry->short_not_ok ? "S" : "s",
254 		__entry->no_interrupt ? "i" : "I",
255 		__entry->status, __entry->ret
256 	)
257 );
258 
259 DEFINE_EVENT(udc_log_req, usb_ep_alloc_request,
260 	TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
261 	TP_ARGS(ep, req, ret)
262 );
263 
264 DEFINE_EVENT(udc_log_req, usb_ep_free_request,
265 	TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
266 	TP_ARGS(ep, req, ret)
267 );
268 
269 DEFINE_EVENT(udc_log_req, usb_ep_queue,
270 	TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
271 	TP_ARGS(ep, req, ret)
272 );
273 
274 DEFINE_EVENT(udc_log_req, usb_ep_dequeue,
275 	TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
276 	TP_ARGS(ep, req, ret)
277 );
278 
279 DEFINE_EVENT(udc_log_req, usb_gadget_giveback_request,
280 	TP_PROTO(struct usb_ep *ep, struct usb_request *req, int ret),
281 	TP_ARGS(ep, req, ret)
282 );
283 
284 #endif /* __UDC_TRACE_H */
285 
286 /* this part has to be here */
287 
288 #undef TRACE_INCLUDE_PATH
289 #define TRACE_INCLUDE_PATH .
290 
291 #undef TRACE_INCLUDE_FILE
292 #define TRACE_INCLUDE_FILE trace
293 
294 #include <trace/define_trace.h>
295