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_selfpowered, 95 TP_PROTO(struct usb_gadget *g, int ret), 96 TP_ARGS(g, ret) 97 ); 98 99 DEFINE_EVENT(udc_log_gadget, usb_gadget_clear_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_vbus_connect, 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_draw, 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_disconnect, 115 TP_PROTO(struct usb_gadget *g, int ret), 116 TP_ARGS(g, ret) 117 ); 118 119 DEFINE_EVENT(udc_log_gadget, usb_gadget_connect, 120 TP_PROTO(struct usb_gadget *g, int ret), 121 TP_ARGS(g, ret) 122 ); 123 124 DEFINE_EVENT(udc_log_gadget, usb_gadget_disconnect, 125 TP_PROTO(struct usb_gadget *g, int ret), 126 TP_ARGS(g, ret) 127 ); 128 129 DEFINE_EVENT(udc_log_gadget, usb_gadget_deactivate, 130 TP_PROTO(struct usb_gadget *g, int ret), 131 TP_ARGS(g, ret) 132 ); 133 134 DEFINE_EVENT(udc_log_gadget, usb_gadget_activate, 135 TP_PROTO(struct usb_gadget *g, int ret), 136 TP_ARGS(g, ret) 137 ); 138 139 DECLARE_EVENT_CLASS(udc_log_ep, 140 TP_PROTO(struct usb_ep *ep, int ret), 141 TP_ARGS(ep, ret), 142 TP_STRUCT__entry( 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) 149 __field(u8, address) 150 __field(bool, claimed) 151 __field(bool, enabled) 152 __field(int, ret) 153 ), 154 TP_fast_assign( 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; 164 __entry->ret = ret; 165 ), 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) 171 ); 172 173 DEFINE_EVENT(udc_log_ep, usb_ep_set_maxpacket_limit, 174 TP_PROTO(struct usb_ep *ep, int ret), 175 TP_ARGS(ep, ret) 176 ); 177 178 DEFINE_EVENT(udc_log_ep, usb_ep_enable, 179 TP_PROTO(struct usb_ep *ep, int ret), 180 TP_ARGS(ep, ret) 181 ); 182 183 DEFINE_EVENT(udc_log_ep, usb_ep_disable, 184 TP_PROTO(struct usb_ep *ep, int ret), 185 TP_ARGS(ep, ret) 186 ); 187 188 DEFINE_EVENT(udc_log_ep, usb_ep_set_halt, 189 TP_PROTO(struct usb_ep *ep, int ret), 190 TP_ARGS(ep, ret) 191 ); 192 193 DEFINE_EVENT(udc_log_ep, usb_ep_clear_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_set_wedge, 199 TP_PROTO(struct usb_ep *ep, int ret), 200 TP_ARGS(ep, ret) 201 ); 202 203 DEFINE_EVENT(udc_log_ep, usb_ep_fifo_status, 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_flush, 209 TP_PROTO(struct usb_ep *ep, int ret), 210 TP_ARGS(ep, ret) 211 ); 212 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), 216 TP_STRUCT__entry( 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) 226 __field(int, status) 227 __field(int, ret) 228 __field(struct usb_request *, req) 229 ), 230 TP_fast_assign( 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; 241 __entry->ret = ret; 242 __entry->req = req; 243 ), 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 251 ) 252 ); 253 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) 257 ); 258 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) 262 ); 263 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) 267 ); 268 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) 272 ); 273 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) 277 ); 278 279 #endif /* __UDC_TRACE_H */ 280 281 /* this part has to be here */ 282 283 #undef TRACE_INCLUDE_PATH 284 #define TRACE_INCLUDE_PATH . 285 286 #undef TRACE_INCLUDE_FILE 287 #define TRACE_INCLUDE_FILE trace 288 289 #include <trace/define_trace.h> 290