1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * trace.h - DesignWare USB3 DRD Controller Trace Support 4 * 5 * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com 6 * 7 * Author: Felipe Balbi <balbi@ti.com> 8 */ 9 10 #undef TRACE_SYSTEM 11 #define TRACE_SYSTEM dwc3 12 13 #if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) 14 #define __DWC3_TRACE_H 15 16 #include <linux/types.h> 17 #include <linux/tracepoint.h> 18 #include <asm/byteorder.h> 19 #include "core.h" 20 #include "debug.h" 21 22 DECLARE_EVENT_CLASS(dwc3_log_io, 23 TP_PROTO(void *base, u32 offset, u32 value), 24 TP_ARGS(base, offset, value), 25 TP_STRUCT__entry( 26 __field(void *, base) 27 __field(u32, offset) 28 __field(u32, value) 29 ), 30 TP_fast_assign( 31 __entry->base = base; 32 __entry->offset = offset; 33 __entry->value = value; 34 ), 35 TP_printk("addr %p offset %04x value %08x", 36 __entry->base + __entry->offset, 37 __entry->offset, 38 __entry->value) 39 ); 40 41 DEFINE_EVENT(dwc3_log_io, dwc3_readl, 42 TP_PROTO(void __iomem *base, u32 offset, u32 value), 43 TP_ARGS(base, offset, value) 44 ); 45 46 DEFINE_EVENT(dwc3_log_io, dwc3_writel, 47 TP_PROTO(void __iomem *base, u32 offset, u32 value), 48 TP_ARGS(base, offset, value) 49 ); 50 51 DECLARE_EVENT_CLASS(dwc3_log_event, 52 TP_PROTO(u32 event, struct dwc3 *dwc), 53 TP_ARGS(event, dwc), 54 TP_STRUCT__entry( 55 __field(u32, event) 56 __field(u32, ep0state) 57 __dynamic_array(char, str, DWC3_MSG_MAX) 58 ), 59 TP_fast_assign( 60 __entry->event = event; 61 __entry->ep0state = dwc->ep0state; 62 ), 63 TP_printk("event (%08x): %s", __entry->event, 64 dwc3_decode_event(__get_str(str), DWC3_MSG_MAX, 65 __entry->event, __entry->ep0state)) 66 ); 67 68 DEFINE_EVENT(dwc3_log_event, dwc3_event, 69 TP_PROTO(u32 event, struct dwc3 *dwc), 70 TP_ARGS(event, dwc) 71 ); 72 73 DECLARE_EVENT_CLASS(dwc3_log_ctrl, 74 TP_PROTO(struct usb_ctrlrequest *ctrl), 75 TP_ARGS(ctrl), 76 TP_STRUCT__entry( 77 __field(__u8, bRequestType) 78 __field(__u8, bRequest) 79 __field(__u16, wValue) 80 __field(__u16, wIndex) 81 __field(__u16, wLength) 82 __dynamic_array(char, str, DWC3_MSG_MAX) 83 ), 84 TP_fast_assign( 85 __entry->bRequestType = ctrl->bRequestType; 86 __entry->bRequest = ctrl->bRequest; 87 __entry->wValue = le16_to_cpu(ctrl->wValue); 88 __entry->wIndex = le16_to_cpu(ctrl->wIndex); 89 __entry->wLength = le16_to_cpu(ctrl->wLength); 90 ), 91 TP_printk("%s", usb_decode_ctrl(__get_str(str), DWC3_MSG_MAX, 92 __entry->bRequestType, 93 __entry->bRequest, __entry->wValue, 94 __entry->wIndex, __entry->wLength) 95 ) 96 ); 97 98 DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req, 99 TP_PROTO(struct usb_ctrlrequest *ctrl), 100 TP_ARGS(ctrl) 101 ); 102 103 DECLARE_EVENT_CLASS(dwc3_log_request, 104 TP_PROTO(struct dwc3_request *req), 105 TP_ARGS(req), 106 TP_STRUCT__entry( 107 __string(name, req->dep->name) 108 __field(struct dwc3_request *, req) 109 __field(unsigned int, actual) 110 __field(unsigned int, length) 111 __field(int, status) 112 __field(int, zero) 113 __field(int, short_not_ok) 114 __field(int, no_interrupt) 115 ), 116 TP_fast_assign( 117 __assign_str(name, req->dep->name); 118 __entry->req = req; 119 __entry->actual = req->request.actual; 120 __entry->length = req->request.length; 121 __entry->status = req->request.status; 122 __entry->zero = req->request.zero; 123 __entry->short_not_ok = req->request.short_not_ok; 124 __entry->no_interrupt = req->request.no_interrupt; 125 ), 126 TP_printk("%s: req %p length %u/%u %s%s%s ==> %d", 127 __get_str(name), __entry->req, __entry->actual, __entry->length, 128 __entry->zero ? "Z" : "z", 129 __entry->short_not_ok ? "S" : "s", 130 __entry->no_interrupt ? "i" : "I", 131 __entry->status 132 ) 133 ); 134 135 DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request, 136 TP_PROTO(struct dwc3_request *req), 137 TP_ARGS(req) 138 ); 139 140 DEFINE_EVENT(dwc3_log_request, dwc3_free_request, 141 TP_PROTO(struct dwc3_request *req), 142 TP_ARGS(req) 143 ); 144 145 DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue, 146 TP_PROTO(struct dwc3_request *req), 147 TP_ARGS(req) 148 ); 149 150 DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue, 151 TP_PROTO(struct dwc3_request *req), 152 TP_ARGS(req) 153 ); 154 155 DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback, 156 TP_PROTO(struct dwc3_request *req), 157 TP_ARGS(req) 158 ); 159 160 DECLARE_EVENT_CLASS(dwc3_log_generic_cmd, 161 TP_PROTO(unsigned int cmd, u32 param, int status), 162 TP_ARGS(cmd, param, status), 163 TP_STRUCT__entry( 164 __field(unsigned int, cmd) 165 __field(u32, param) 166 __field(int, status) 167 ), 168 TP_fast_assign( 169 __entry->cmd = cmd; 170 __entry->param = param; 171 __entry->status = status; 172 ), 173 TP_printk("cmd '%s' [%x] param %08x --> status: %s", 174 dwc3_gadget_generic_cmd_string(__entry->cmd), 175 __entry->cmd, __entry->param, 176 dwc3_gadget_generic_cmd_status_string(__entry->status) 177 ) 178 ); 179 180 DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd, 181 TP_PROTO(unsigned int cmd, u32 param, int status), 182 TP_ARGS(cmd, param, status) 183 ); 184 185 DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, 186 TP_PROTO(struct dwc3_ep *dep, unsigned int cmd, 187 struct dwc3_gadget_ep_cmd_params *params, int cmd_status), 188 TP_ARGS(dep, cmd, params, cmd_status), 189 TP_STRUCT__entry( 190 __string(name, dep->name) 191 __field(unsigned int, cmd) 192 __field(u32, param0) 193 __field(u32, param1) 194 __field(u32, param2) 195 __field(int, cmd_status) 196 ), 197 TP_fast_assign( 198 __assign_str(name, dep->name); 199 __entry->cmd = cmd; 200 __entry->param0 = params->param0; 201 __entry->param1 = params->param1; 202 __entry->param2 = params->param2; 203 __entry->cmd_status = cmd_status; 204 ), 205 TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s", 206 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd), 207 __entry->cmd, __entry->param0, 208 __entry->param1, __entry->param2, 209 dwc3_ep_cmd_status_string(__entry->cmd_status) 210 ) 211 ); 212 213 DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd, 214 TP_PROTO(struct dwc3_ep *dep, unsigned int cmd, 215 struct dwc3_gadget_ep_cmd_params *params, int cmd_status), 216 TP_ARGS(dep, cmd, params, cmd_status) 217 ); 218 219 DECLARE_EVENT_CLASS(dwc3_log_trb, 220 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), 221 TP_ARGS(dep, trb), 222 TP_STRUCT__entry( 223 __string(name, dep->name) 224 __field(struct dwc3_trb *, trb) 225 __field(u32, allocated) 226 __field(u32, queued) 227 __field(u32, bpl) 228 __field(u32, bph) 229 __field(u32, size) 230 __field(u32, ctrl) 231 __field(u32, type) 232 __field(u32, enqueue) 233 __field(u32, dequeue) 234 ), 235 TP_fast_assign( 236 __assign_str(name, dep->name); 237 __entry->trb = trb; 238 __entry->bpl = trb->bpl; 239 __entry->bph = trb->bph; 240 __entry->size = trb->size; 241 __entry->ctrl = trb->ctrl; 242 __entry->type = usb_endpoint_type(dep->endpoint.desc); 243 __entry->enqueue = dep->trb_enqueue; 244 __entry->dequeue = dep->trb_dequeue; 245 ), 246 TP_printk("%s: trb %p (E%d:D%d) buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)", 247 __get_str(name), __entry->trb, __entry->enqueue, 248 __entry->dequeue, __entry->bph, __entry->bpl, 249 ({char *s; 250 int pcm = ((__entry->size >> 24) & 3) + 1; 251 252 switch (__entry->type) { 253 case USB_ENDPOINT_XFER_INT: 254 case USB_ENDPOINT_XFER_ISOC: 255 switch (pcm) { 256 case 1: 257 s = "1x "; 258 break; 259 case 2: 260 s = "2x "; 261 break; 262 case 3: 263 default: 264 s = "3x "; 265 break; 266 } 267 break; 268 default: 269 s = ""; 270 } s; }), 271 DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl, 272 __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h', 273 __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l', 274 __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c', 275 __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's', 276 __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's', 277 __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c', 278 dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl)) 279 ) 280 ); 281 282 DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb, 283 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), 284 TP_ARGS(dep, trb) 285 ); 286 287 DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb, 288 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), 289 TP_ARGS(dep, trb) 290 ); 291 292 DECLARE_EVENT_CLASS(dwc3_log_ep, 293 TP_PROTO(struct dwc3_ep *dep), 294 TP_ARGS(dep), 295 TP_STRUCT__entry( 296 __string(name, dep->name) 297 __field(unsigned int, maxpacket) 298 __field(unsigned int, maxpacket_limit) 299 __field(unsigned int, max_streams) 300 __field(unsigned int, maxburst) 301 __field(unsigned int, flags) 302 __field(unsigned int, direction) 303 __field(u8, trb_enqueue) 304 __field(u8, trb_dequeue) 305 ), 306 TP_fast_assign( 307 __assign_str(name, dep->name); 308 __entry->maxpacket = dep->endpoint.maxpacket; 309 __entry->maxpacket_limit = dep->endpoint.maxpacket_limit; 310 __entry->max_streams = dep->endpoint.max_streams; 311 __entry->maxburst = dep->endpoint.maxburst; 312 __entry->flags = dep->flags; 313 __entry->direction = dep->direction; 314 __entry->trb_enqueue = dep->trb_enqueue; 315 __entry->trb_dequeue = dep->trb_dequeue; 316 ), 317 TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c", 318 __get_str(name), __entry->maxpacket, 319 __entry->maxpacket_limit, __entry->max_streams, 320 __entry->maxburst, __entry->trb_enqueue, 321 __entry->trb_dequeue, 322 __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e', 323 __entry->flags & DWC3_EP_STALL ? 'S' : 's', 324 __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w', 325 __entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b', 326 __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p', 327 __entry->direction ? '<' : '>' 328 ) 329 ); 330 331 DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable, 332 TP_PROTO(struct dwc3_ep *dep), 333 TP_ARGS(dep) 334 ); 335 336 DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable, 337 TP_PROTO(struct dwc3_ep *dep), 338 TP_ARGS(dep) 339 ); 340 341 #endif /* __DWC3_TRACE_H */ 342 343 /* this part has to be here */ 344 345 #undef TRACE_INCLUDE_PATH 346 #define TRACE_INCLUDE_PATH . 347 348 #undef TRACE_INCLUDE_FILE 349 #define TRACE_INCLUDE_FILE trace 350 351 #include <trace/define_trace.h> 352