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