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