2 * udc.c - Core UDC Framework
4 * Copyright (C) 2016 Intel Corporation
5 * Author: Felipe Balbi <felipe.balbi@linux.intel.com>
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.
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.
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/>.
21 #define TRACE_SYSTEM gadget
23 #if !defined(__UDC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
26 #include <linux/types.h>
27 #include <linux/tracepoint.h>
28 #include <asm/byteorder.h>
29 #include <linux/usb/gadget.h>
31 DECLARE_EVENT_CLASS(udc_log_gadget
,
32 TP_PROTO(struct usb_gadget
*g
, int ret
),
35 __field(enum usb_device_speed
, speed
)
36 __field(enum usb_device_speed
, max_speed
)
37 __field(enum usb_device_state
, state
)
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
)
56 __entry
->speed
= g
->speed
;
57 __entry
->max_speed
= g
->max_speed
;
58 __entry
->state
= g
->state
;
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
;
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",
95 DEFINE_EVENT(udc_log_gadget
, usb_gadget_frame_number
,
96 TP_PROTO(struct usb_gadget
*g
, int ret
),
100 DEFINE_EVENT(udc_log_gadget
, usb_gadget_wakeup
,
101 TP_PROTO(struct usb_gadget
*g
, int ret
),
105 DEFINE_EVENT(udc_log_gadget
, usb_gadget_set_selfpowered
,
106 TP_PROTO(struct usb_gadget
*g
, int ret
),
110 DEFINE_EVENT(udc_log_gadget
, usb_gadget_clear_selfpowered
,
111 TP_PROTO(struct usb_gadget
*g
, int ret
),
115 DEFINE_EVENT(udc_log_gadget
, usb_gadget_vbus_connect
,
116 TP_PROTO(struct usb_gadget
*g
, int ret
),
120 DEFINE_EVENT(udc_log_gadget
, usb_gadget_vbus_draw
,
121 TP_PROTO(struct usb_gadget
*g
, int ret
),
125 DEFINE_EVENT(udc_log_gadget
, usb_gadget_vbus_disconnect
,
126 TP_PROTO(struct usb_gadget
*g
, int ret
),
130 DEFINE_EVENT(udc_log_gadget
, usb_gadget_connect
,
131 TP_PROTO(struct usb_gadget
*g
, int ret
),
135 DEFINE_EVENT(udc_log_gadget
, usb_gadget_disconnect
,
136 TP_PROTO(struct usb_gadget
*g
, int ret
),
140 DEFINE_EVENT(udc_log_gadget
, usb_gadget_deactivate
,
141 TP_PROTO(struct usb_gadget
*g
, int ret
),
145 DEFINE_EVENT(udc_log_gadget
, usb_gadget_activate
,
146 TP_PROTO(struct usb_gadget
*g
, int ret
),
150 DECLARE_EVENT_CLASS(udc_log_ep
,
151 TP_PROTO(struct usb_ep
*ep
, int ret
),
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
)
161 __field(bool, claimed
)
162 __field(bool, enabled
)
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
;
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
)
184 DEFINE_EVENT(udc_log_ep
, usb_ep_set_maxpacket_limit
,
185 TP_PROTO(struct usb_ep
*ep
, int ret
),
189 DEFINE_EVENT(udc_log_ep
, usb_ep_enable
,
190 TP_PROTO(struct usb_ep
*ep
, int ret
),
194 DEFINE_EVENT(udc_log_ep
, usb_ep_disable
,
195 TP_PROTO(struct usb_ep
*ep
, int ret
),
199 DEFINE_EVENT(udc_log_ep
, usb_ep_set_halt
,
200 TP_PROTO(struct usb_ep
*ep
, int ret
),
204 DEFINE_EVENT(udc_log_ep
, usb_ep_clear_halt
,
205 TP_PROTO(struct usb_ep
*ep
, int ret
),
209 DEFINE_EVENT(udc_log_ep
, usb_ep_set_wedge
,
210 TP_PROTO(struct usb_ep
*ep
, int ret
),
214 DEFINE_EVENT(udc_log_ep
, usb_ep_fifo_status
,
215 TP_PROTO(struct usb_ep
*ep
, int ret
),
219 DEFINE_EVENT(udc_log_ep
, usb_ep_fifo_flush
,
220 TP_PROTO(struct usb_ep
*ep
, int ret
),
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
),
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
)
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
;
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
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
)
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
)
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
)
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
)
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
)
288 #endif /* __UDC_TRACE_H */
290 /* this part has to be here */
292 #undef TRACE_INCLUDE_PATH
293 #define TRACE_INCLUDE_PATH .
295 #undef TRACE_INCLUDE_FILE
296 #define TRACE_INCLUDE_FILE trace
298 #include <trace/define_trace.h>