1 // SPDX-License-Identifier: GPL-2.0
3 * udc.c - Core UDC Framework
5 * Copyright (C) 2016 Intel Corporation
6 * Author: Felipe Balbi <felipe.balbi@linux.intel.com>
10 #define TRACE_SYSTEM gadget
12 #if !defined(__UDC_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
15 #include <linux/types.h>
16 #include <linux/tracepoint.h>
17 #include <asm/byteorder.h>
18 #include <linux/usb/gadget.h>
20 DECLARE_EVENT_CLASS(udc_log_gadget
,
21 TP_PROTO(struct usb_gadget
*g
, int ret
),
24 __field(enum usb_device_speed
, speed
)
25 __field(enum usb_device_speed
, max_speed
)
26 __field(enum usb_device_state
, state
)
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
)
45 __entry
->speed
= g
->speed
;
46 __entry
->max_speed
= g
->max_speed
;
47 __entry
->state
= g
->state
;
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
;
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",
84 DEFINE_EVENT(udc_log_gadget
, usb_gadget_frame_number
,
85 TP_PROTO(struct usb_gadget
*g
, int ret
),
89 DEFINE_EVENT(udc_log_gadget
, usb_gadget_wakeup
,
90 TP_PROTO(struct usb_gadget
*g
, int ret
),
94 DEFINE_EVENT(udc_log_gadget
, usb_gadget_set_selfpowered
,
95 TP_PROTO(struct usb_gadget
*g
, int ret
),
99 DEFINE_EVENT(udc_log_gadget
, usb_gadget_clear_selfpowered
,
100 TP_PROTO(struct usb_gadget
*g
, int ret
),
104 DEFINE_EVENT(udc_log_gadget
, usb_gadget_vbus_connect
,
105 TP_PROTO(struct usb_gadget
*g
, int ret
),
109 DEFINE_EVENT(udc_log_gadget
, usb_gadget_vbus_draw
,
110 TP_PROTO(struct usb_gadget
*g
, int ret
),
114 DEFINE_EVENT(udc_log_gadget
, usb_gadget_vbus_disconnect
,
115 TP_PROTO(struct usb_gadget
*g
, int ret
),
119 DEFINE_EVENT(udc_log_gadget
, usb_gadget_connect
,
120 TP_PROTO(struct usb_gadget
*g
, int ret
),
124 DEFINE_EVENT(udc_log_gadget
, usb_gadget_disconnect
,
125 TP_PROTO(struct usb_gadget
*g
, int ret
),
129 DEFINE_EVENT(udc_log_gadget
, usb_gadget_deactivate
,
130 TP_PROTO(struct usb_gadget
*g
, int ret
),
134 DEFINE_EVENT(udc_log_gadget
, usb_gadget_activate
,
135 TP_PROTO(struct usb_gadget
*g
, int ret
),
139 DECLARE_EVENT_CLASS(udc_log_ep
,
140 TP_PROTO(struct usb_ep
*ep
, int ret
),
143 __dynamic_array(char, name
, UDC_TRACE_STR_MAX
)
144 __field(unsigned, maxpacket
)
145 __field(unsigned, maxpacket_limit
)
146 __field(unsigned, max_streams
)
147 __field(unsigned, mult
)
148 __field(unsigned, maxburst
)
150 __field(bool, claimed
)
151 __field(bool, enabled
)
155 snprintf(__get_str(name
), UDC_TRACE_STR_MAX
, "%s", ep
->name
);
156 __entry
->maxpacket
= ep
->maxpacket
;
157 __entry
->maxpacket_limit
= ep
->maxpacket_limit
;
158 __entry
->max_streams
= ep
->max_streams
;
159 __entry
->mult
= ep
->mult
;
160 __entry
->maxburst
= ep
->maxburst
;
161 __entry
->address
= ep
->address
,
162 __entry
->claimed
= ep
->claimed
;
163 __entry
->enabled
= ep
->enabled
;
166 TP_printk("%s: mps %d/%d streams %d mult %d burst %d addr %02x %s%s --> %d",
167 __get_str(name
), __entry
->maxpacket
, __entry
->maxpacket_limit
,
168 __entry
->max_streams
, __entry
->mult
, __entry
->maxburst
,
169 __entry
->address
, __entry
->claimed
? "claimed:" : "released:",
170 __entry
->enabled
? "enabled" : "disabled", ret
)
173 DEFINE_EVENT(udc_log_ep
, usb_ep_set_maxpacket_limit
,
174 TP_PROTO(struct usb_ep
*ep
, int ret
),
178 DEFINE_EVENT(udc_log_ep
, usb_ep_enable
,
179 TP_PROTO(struct usb_ep
*ep
, int ret
),
183 DEFINE_EVENT(udc_log_ep
, usb_ep_disable
,
184 TP_PROTO(struct usb_ep
*ep
, int ret
),
188 DEFINE_EVENT(udc_log_ep
, usb_ep_set_halt
,
189 TP_PROTO(struct usb_ep
*ep
, int ret
),
193 DEFINE_EVENT(udc_log_ep
, usb_ep_clear_halt
,
194 TP_PROTO(struct usb_ep
*ep
, int ret
),
198 DEFINE_EVENT(udc_log_ep
, usb_ep_set_wedge
,
199 TP_PROTO(struct usb_ep
*ep
, int ret
),
203 DEFINE_EVENT(udc_log_ep
, usb_ep_fifo_status
,
204 TP_PROTO(struct usb_ep
*ep
, int ret
),
208 DEFINE_EVENT(udc_log_ep
, usb_ep_fifo_flush
,
209 TP_PROTO(struct usb_ep
*ep
, int ret
),
213 DECLARE_EVENT_CLASS(udc_log_req
,
214 TP_PROTO(struct usb_ep
*ep
, struct usb_request
*req
, int ret
),
215 TP_ARGS(ep
, req
, ret
),
217 __dynamic_array(char, name
, UDC_TRACE_STR_MAX
)
218 __field(unsigned, length
)
219 __field(unsigned, actual
)
220 __field(unsigned, num_sgs
)
221 __field(unsigned, num_mapped_sgs
)
222 __field(unsigned, stream_id
)
223 __field(unsigned, no_interrupt
)
224 __field(unsigned, zero
)
225 __field(unsigned, short_not_ok
)
228 __field(struct usb_request
*, req
)
231 snprintf(__get_str(name
), UDC_TRACE_STR_MAX
, "%s", ep
->name
);
232 __entry
->length
= req
->length
;
233 __entry
->actual
= req
->actual
;
234 __entry
->num_sgs
= req
->num_sgs
;
235 __entry
->num_mapped_sgs
= req
->num_mapped_sgs
;
236 __entry
->stream_id
= req
->stream_id
;
237 __entry
->no_interrupt
= req
->no_interrupt
;
238 __entry
->zero
= req
->zero
;
239 __entry
->short_not_ok
= req
->short_not_ok
;
240 __entry
->status
= req
->status
;
244 TP_printk("%s: req %p length %d/%d sgs %d/%d stream %d %s%s%s status %d --> %d",
245 __get_str(name
),__entry
->req
, __entry
->actual
, __entry
->length
,
246 __entry
->num_mapped_sgs
, __entry
->num_sgs
, __entry
->stream_id
,
247 __entry
->zero
? "Z" : "z",
248 __entry
->short_not_ok
? "S" : "s",
249 __entry
->no_interrupt
? "i" : "I",
250 __entry
->status
, __entry
->ret
254 DEFINE_EVENT(udc_log_req
, usb_ep_alloc_request
,
255 TP_PROTO(struct usb_ep
*ep
, struct usb_request
*req
, int ret
),
256 TP_ARGS(ep
, req
, ret
)
259 DEFINE_EVENT(udc_log_req
, usb_ep_free_request
,
260 TP_PROTO(struct usb_ep
*ep
, struct usb_request
*req
, int ret
),
261 TP_ARGS(ep
, req
, ret
)
264 DEFINE_EVENT(udc_log_req
, usb_ep_queue
,
265 TP_PROTO(struct usb_ep
*ep
, struct usb_request
*req
, int ret
),
266 TP_ARGS(ep
, req
, ret
)
269 DEFINE_EVENT(udc_log_req
, usb_ep_dequeue
,
270 TP_PROTO(struct usb_ep
*ep
, struct usb_request
*req
, int ret
),
271 TP_ARGS(ep
, req
, ret
)
274 DEFINE_EVENT(udc_log_req
, usb_gadget_giveback_request
,
275 TP_PROTO(struct usb_ep
*ep
, struct usb_request
*req
, int ret
),
276 TP_ARGS(ep
, req
, ret
)
279 #endif /* __UDC_TRACE_H */
281 /* this part has to be here */
283 #undef TRACE_INCLUDE_PATH
284 #define TRACE_INCLUDE_PATH .
286 #undef TRACE_INCLUDE_FILE
287 #define TRACE_INCLUDE_FILE trace
289 #include <trace/define_trace.h>