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