Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 1 | /** |
| 2 | * trace.h - DesignWare USB3 DRD Controller Trace Support |
| 3 | * |
| 4 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com |
| 5 | * |
| 6 | * Author: Felipe Balbi <balbi@ti.com> |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 of |
| 10 | * the License as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #undef TRACE_SYSTEM |
| 19 | #define TRACE_SYSTEM dwc3 |
| 20 | |
| 21 | #if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) |
| 22 | #define __DWC3_TRACE_H |
| 23 | |
| 24 | #include <linux/types.h> |
| 25 | #include <linux/tracepoint.h> |
| 26 | #include <asm/byteorder.h> |
| 27 | #include "core.h" |
| 28 | #include "debug.h" |
| 29 | |
| 30 | DECLARE_EVENT_CLASS(dwc3_log_msg, |
| 31 | TP_PROTO(struct va_format *vaf), |
| 32 | TP_ARGS(vaf), |
| 33 | TP_STRUCT__entry(__dynamic_array(char, msg, DWC3_MSG_MAX)), |
| 34 | TP_fast_assign( |
| 35 | vsnprintf(__get_str(msg), DWC3_MSG_MAX, vaf->fmt, *vaf->va); |
| 36 | ), |
| 37 | TP_printk("%s", __get_str(msg)) |
| 38 | ); |
| 39 | |
| 40 | DEFINE_EVENT(dwc3_log_msg, dwc3_readl, |
| 41 | TP_PROTO(struct va_format *vaf), |
| 42 | TP_ARGS(vaf) |
| 43 | ); |
| 44 | |
| 45 | DEFINE_EVENT(dwc3_log_msg, dwc3_writel, |
| 46 | TP_PROTO(struct va_format *vaf), |
| 47 | TP_ARGS(vaf) |
| 48 | ); |
| 49 | |
Felipe Balbi | 6bac4ff | 2015-01-27 13:47:02 -0600 | [diff] [blame] | 50 | DEFINE_EVENT(dwc3_log_msg, dwc3_gadget, |
| 51 | TP_PROTO(struct va_format *vaf), |
| 52 | TP_ARGS(vaf) |
| 53 | ); |
| 54 | |
| 55 | DEFINE_EVENT(dwc3_log_msg, dwc3_core, |
| 56 | TP_PROTO(struct va_format *vaf), |
| 57 | TP_ARGS(vaf) |
| 58 | ); |
| 59 | |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 60 | DEFINE_EVENT(dwc3_log_msg, dwc3_ep0, |
| 61 | TP_PROTO(struct va_format *vaf), |
| 62 | TP_ARGS(vaf) |
| 63 | ); |
| 64 | |
| 65 | DECLARE_EVENT_CLASS(dwc3_log_event, |
| 66 | TP_PROTO(u32 event), |
| 67 | TP_ARGS(event), |
| 68 | TP_STRUCT__entry( |
| 69 | __field(u32, event) |
| 70 | ), |
| 71 | TP_fast_assign( |
| 72 | __entry->event = event; |
| 73 | ), |
Felipe Balbi | f75cacc | 2016-05-23 11:10:08 +0300 | [diff] [blame] | 74 | TP_printk("event (%08x): %s", __entry->event, |
| 75 | dwc3_decode_event(__entry->event)) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 76 | ); |
| 77 | |
| 78 | DEFINE_EVENT(dwc3_log_event, dwc3_event, |
| 79 | TP_PROTO(u32 event), |
| 80 | TP_ARGS(event) |
| 81 | ); |
| 82 | |
| 83 | DECLARE_EVENT_CLASS(dwc3_log_ctrl, |
| 84 | TP_PROTO(struct usb_ctrlrequest *ctrl), |
| 85 | TP_ARGS(ctrl), |
| 86 | TP_STRUCT__entry( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 87 | __field(__u8, bRequestType) |
| 88 | __field(__u8, bRequest) |
John Youn | 96bedb6 | 2016-05-23 11:32:47 -0700 | [diff] [blame] | 89 | __field(__u16, wValue) |
| 90 | __field(__u16, wIndex) |
| 91 | __field(__u16, wLength) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 92 | ), |
| 93 | TP_fast_assign( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 94 | __entry->bRequestType = ctrl->bRequestType; |
| 95 | __entry->bRequest = ctrl->bRequest; |
John Youn | 96bedb6 | 2016-05-23 11:32:47 -0700 | [diff] [blame] | 96 | __entry->wValue = le16_to_cpu(ctrl->wValue); |
| 97 | __entry->wIndex = le16_to_cpu(ctrl->wIndex); |
| 98 | __entry->wLength = le16_to_cpu(ctrl->wLength); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 99 | ), |
| 100 | TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d", |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 101 | __entry->bRequestType, __entry->bRequest, |
John Youn | 96bedb6 | 2016-05-23 11:32:47 -0700 | [diff] [blame] | 102 | __entry->wValue, __entry->wIndex, |
| 103 | __entry->wLength |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 104 | ) |
| 105 | ); |
| 106 | |
| 107 | DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req, |
| 108 | TP_PROTO(struct usb_ctrlrequest *ctrl), |
| 109 | TP_ARGS(ctrl) |
| 110 | ); |
| 111 | |
| 112 | DECLARE_EVENT_CLASS(dwc3_log_request, |
| 113 | TP_PROTO(struct dwc3_request *req), |
| 114 | TP_ARGS(req), |
| 115 | TP_STRUCT__entry( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 116 | __dynamic_array(char, name, DWC3_MSG_MAX) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 117 | __field(struct dwc3_request *, req) |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 118 | __field(unsigned, actual) |
| 119 | __field(unsigned, length) |
| 120 | __field(int, status) |
Felipe Balbi | 46a0142 | 2015-12-03 15:27:32 -0600 | [diff] [blame] | 121 | __field(int, zero) |
| 122 | __field(int, short_not_ok) |
| 123 | __field(int, no_interrupt) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 124 | ), |
| 125 | TP_fast_assign( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 126 | snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 127 | __entry->req = req; |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 128 | __entry->actual = req->request.actual; |
| 129 | __entry->length = req->request.length; |
| 130 | __entry->status = req->request.status; |
Felipe Balbi | 46a0142 | 2015-12-03 15:27:32 -0600 | [diff] [blame] | 131 | __entry->zero = req->request.zero; |
| 132 | __entry->short_not_ok = req->request.short_not_ok; |
| 133 | __entry->no_interrupt = req->request.no_interrupt; |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 134 | ), |
Felipe Balbi | 46a0142 | 2015-12-03 15:27:32 -0600 | [diff] [blame] | 135 | TP_printk("%s: req %p length %u/%u %s%s%s ==> %d", |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 136 | __get_str(name), __entry->req, __entry->actual, __entry->length, |
Felipe Balbi | 46a0142 | 2015-12-03 15:27:32 -0600 | [diff] [blame] | 137 | __entry->zero ? "Z" : "z", |
| 138 | __entry->short_not_ok ? "S" : "s", |
| 139 | __entry->no_interrupt ? "i" : "I", |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 140 | __entry->status |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 141 | ) |
| 142 | ); |
| 143 | |
| 144 | DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request, |
| 145 | TP_PROTO(struct dwc3_request *req), |
| 146 | TP_ARGS(req) |
| 147 | ); |
| 148 | |
| 149 | DEFINE_EVENT(dwc3_log_request, dwc3_free_request, |
| 150 | TP_PROTO(struct dwc3_request *req), |
| 151 | TP_ARGS(req) |
| 152 | ); |
| 153 | |
| 154 | DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue, |
| 155 | TP_PROTO(struct dwc3_request *req), |
| 156 | TP_ARGS(req) |
| 157 | ); |
| 158 | |
| 159 | DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue, |
| 160 | TP_PROTO(struct dwc3_request *req), |
| 161 | TP_ARGS(req) |
| 162 | ); |
| 163 | |
| 164 | DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback, |
| 165 | TP_PROTO(struct dwc3_request *req), |
| 166 | TP_ARGS(req) |
| 167 | ); |
| 168 | |
| 169 | DECLARE_EVENT_CLASS(dwc3_log_generic_cmd, |
Felipe Balbi | 71f7e70 | 2016-05-23 14:16:19 +0300 | [diff] [blame] | 170 | TP_PROTO(unsigned int cmd, u32 param, int status), |
| 171 | TP_ARGS(cmd, param, status), |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 172 | TP_STRUCT__entry( |
| 173 | __field(unsigned int, cmd) |
| 174 | __field(u32, param) |
Felipe Balbi | 71f7e70 | 2016-05-23 14:16:19 +0300 | [diff] [blame] | 175 | __field(int, status) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 176 | ), |
| 177 | TP_fast_assign( |
| 178 | __entry->cmd = cmd; |
| 179 | __entry->param = param; |
Felipe Balbi | 71f7e70 | 2016-05-23 14:16:19 +0300 | [diff] [blame] | 180 | __entry->status = status; |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 181 | ), |
Felipe Balbi | 71f7e70 | 2016-05-23 14:16:19 +0300 | [diff] [blame] | 182 | TP_printk("cmd '%s' [%d] param %08x --> status: %s", |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 183 | dwc3_gadget_generic_cmd_string(__entry->cmd), |
Felipe Balbi | 71f7e70 | 2016-05-23 14:16:19 +0300 | [diff] [blame] | 184 | __entry->cmd, __entry->param, |
| 185 | dwc3_gadget_generic_cmd_status_string(__entry->status) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 186 | ) |
| 187 | ); |
| 188 | |
| 189 | DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd, |
Felipe Balbi | 71f7e70 | 2016-05-23 14:16:19 +0300 | [diff] [blame] | 190 | TP_PROTO(unsigned int cmd, u32 param, int status), |
| 191 | TP_ARGS(cmd, param, status) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 192 | ); |
| 193 | |
| 194 | DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd, |
| 195 | TP_PROTO(struct dwc3_ep *dep, unsigned int cmd, |
Felipe Balbi | 0933df1 | 2016-05-23 14:02:33 +0300 | [diff] [blame] | 196 | struct dwc3_gadget_ep_cmd_params *params, int cmd_status), |
| 197 | TP_ARGS(dep, cmd, params, cmd_status), |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 198 | TP_STRUCT__entry( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 199 | __dynamic_array(char, name, DWC3_MSG_MAX) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 200 | __field(unsigned int, cmd) |
Felipe Balbi | a4722fd3 | 2014-11-20 10:12:32 -0600 | [diff] [blame] | 201 | __field(u32, param0) |
| 202 | __field(u32, param1) |
| 203 | __field(u32, param2) |
Felipe Balbi | 0933df1 | 2016-05-23 14:02:33 +0300 | [diff] [blame] | 204 | __field(int, cmd_status) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 205 | ), |
| 206 | TP_fast_assign( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 207 | snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 208 | __entry->cmd = cmd; |
Felipe Balbi | a4722fd3 | 2014-11-20 10:12:32 -0600 | [diff] [blame] | 209 | __entry->param0 = params->param0; |
| 210 | __entry->param1 = params->param1; |
| 211 | __entry->param2 = params->param2; |
Felipe Balbi | 0933df1 | 2016-05-23 14:02:33 +0300 | [diff] [blame] | 212 | __entry->cmd_status = cmd_status; |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 213 | ), |
Felipe Balbi | 0933df1 | 2016-05-23 14:02:33 +0300 | [diff] [blame] | 214 | TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s", |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 215 | __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd), |
Felipe Balbi | a4722fd3 | 2014-11-20 10:12:32 -0600 | [diff] [blame] | 216 | __entry->cmd, __entry->param0, |
Felipe Balbi | 0933df1 | 2016-05-23 14:02:33 +0300 | [diff] [blame] | 217 | __entry->param1, __entry->param2, |
| 218 | dwc3_ep_cmd_status_string(__entry->cmd_status) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 219 | ) |
| 220 | ); |
| 221 | |
| 222 | DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd, |
| 223 | TP_PROTO(struct dwc3_ep *dep, unsigned int cmd, |
Felipe Balbi | 0933df1 | 2016-05-23 14:02:33 +0300 | [diff] [blame] | 224 | struct dwc3_gadget_ep_cmd_params *params, int cmd_status), |
| 225 | TP_ARGS(dep, cmd, params, cmd_status) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 226 | ); |
| 227 | |
| 228 | DECLARE_EVENT_CLASS(dwc3_log_trb, |
| 229 | TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), |
| 230 | TP_ARGS(dep, trb), |
| 231 | TP_STRUCT__entry( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 232 | __dynamic_array(char, name, DWC3_MSG_MAX) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 233 | __field(struct dwc3_trb *, trb) |
Felipe Balbi | 68d34c8 | 2016-05-30 13:34:58 +0300 | [diff] [blame] | 234 | __field(u32, allocated) |
| 235 | __field(u32, queued) |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 236 | __field(u32, bpl) |
| 237 | __field(u32, bph) |
| 238 | __field(u32, size) |
| 239 | __field(u32, ctrl) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 240 | ), |
| 241 | TP_fast_assign( |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 242 | snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name); |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 243 | __entry->trb = trb; |
Felipe Balbi | 68d34c8 | 2016-05-30 13:34:58 +0300 | [diff] [blame] | 244 | __entry->allocated = dep->allocated_requests; |
| 245 | __entry->queued = dep->queued_requests; |
Felipe Balbi | 4ac4fc9 | 2014-09-17 16:28:38 -0500 | [diff] [blame] | 246 | __entry->bpl = trb->bpl; |
| 247 | __entry->bph = trb->bph; |
| 248 | __entry->size = trb->size; |
| 249 | __entry->ctrl = trb->ctrl; |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 250 | ), |
Felipe Balbi | 68d34c8 | 2016-05-30 13:34:58 +0300 | [diff] [blame] | 251 | TP_printk("%s: %d/%d trb %p buf %08x%08x size %d ctrl %08x (%c%c%c%c:%c%c:%s)", |
| 252 | __get_str(name), __entry->queued, __entry->allocated, |
| 253 | __entry->trb, __entry->bph, __entry->bpl, |
Janusz Dziedzic | 22f2c61 | 2016-05-20 10:37:13 +0200 | [diff] [blame] | 254 | __entry->size, __entry->ctrl, |
| 255 | __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h', |
| 256 | __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l', |
| 257 | __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c', |
| 258 | __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's', |
| 259 | __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's', |
| 260 | __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c', |
| 261 | ({char *s; |
| 262 | switch (__entry->ctrl & 0x3f0) { |
| 263 | case DWC3_TRBCTL_NORMAL: |
| 264 | s = "normal"; |
| 265 | break; |
| 266 | case DWC3_TRBCTL_CONTROL_SETUP: |
| 267 | s = "setup"; |
| 268 | break; |
| 269 | case DWC3_TRBCTL_CONTROL_STATUS2: |
| 270 | s = "status2"; |
| 271 | break; |
| 272 | case DWC3_TRBCTL_CONTROL_STATUS3: |
| 273 | s = "status3"; |
| 274 | break; |
| 275 | case DWC3_TRBCTL_CONTROL_DATA: |
| 276 | s = "data"; |
| 277 | break; |
| 278 | case DWC3_TRBCTL_ISOCHRONOUS_FIRST: |
| 279 | s = "isoc-first"; |
| 280 | break; |
| 281 | case DWC3_TRBCTL_ISOCHRONOUS: |
| 282 | s = "isoc"; |
| 283 | break; |
| 284 | case DWC3_TRBCTL_LINK_TRB: |
| 285 | s = "link"; |
| 286 | break; |
| 287 | default: |
| 288 | s = "UNKNOWN"; |
| 289 | break; |
| 290 | } s; }) |
Felipe Balbi | 2c4cbe6e5 | 2014-04-30 17:45:10 -0500 | [diff] [blame] | 291 | ) |
| 292 | ); |
| 293 | |
| 294 | DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb, |
| 295 | TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), |
| 296 | TP_ARGS(dep, trb) |
| 297 | ); |
| 298 | |
| 299 | DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb, |
| 300 | TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), |
| 301 | TP_ARGS(dep, trb) |
| 302 | ); |
| 303 | |
| 304 | #endif /* __DWC3_TRACE_H */ |
| 305 | |
| 306 | /* this part has to be here */ |
| 307 | |
| 308 | #undef TRACE_INCLUDE_PATH |
| 309 | #define TRACE_INCLUDE_PATH . |
| 310 | |
| 311 | #undef TRACE_INCLUDE_FILE |
| 312 | #define TRACE_INCLUDE_FILE trace |
| 313 | |
| 314 | #include <trace/define_trace.h> |