trace.h 9.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4
/**
 * trace.h - DesignWare USB3 DRD Controller Trace Support
 *
5
 * Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * Author: Felipe Balbi <balbi@ti.com>
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM dwc3

#if !defined(__DWC3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define __DWC3_TRACE_H

#include <linux/types.h>
#include <linux/tracepoint.h>
#include <asm/byteorder.h>
#include "core.h"
#include "debug.h"

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
DECLARE_EVENT_CLASS(dwc3_log_io,
	TP_PROTO(void *base, u32 offset, u32 value),
	TP_ARGS(base, offset, value),
	TP_STRUCT__entry(
		__field(void *, base)
		__field(u32, offset)
		__field(u32, value)
	),
	TP_fast_assign(
		__entry->base = base;
		__entry->offset = offset;
		__entry->value = value;
	),
	TP_printk("addr %p value %08x", __entry->base + __entry->offset,
			__entry->value)
37 38
);

39
DEFINE_EVENT(dwc3_log_io, dwc3_readl,
40
	TP_PROTO(void __iomem *base, u32 offset, u32 value),
41 42 43 44
	TP_ARGS(base, offset, value)
);

DEFINE_EVENT(dwc3_log_io, dwc3_writel,
45
	TP_PROTO(void __iomem *base, u32 offset, u32 value),
46
	TP_ARGS(base, offset, value)
47 48 49
);

DECLARE_EVENT_CLASS(dwc3_log_event,
50 51
	TP_PROTO(u32 event, struct dwc3 *dwc),
	TP_ARGS(event, dwc),
52 53
	TP_STRUCT__entry(
		__field(u32, event)
54
		__field(u32, ep0state)
55
		__dynamic_array(char, str, DWC3_MSG_MAX)
56 57 58
	),
	TP_fast_assign(
		__entry->event = event;
59
		__entry->ep0state = dwc->ep0state;
60
	),
61
	TP_printk("event (%08x): %s", __entry->event,
62 63
			dwc3_decode_event(__get_str(str), DWC3_MSG_MAX,
					__entry->event, __entry->ep0state))
64 65 66
);

DEFINE_EVENT(dwc3_log_event, dwc3_event,
67 68
	TP_PROTO(u32 event, struct dwc3 *dwc),
	TP_ARGS(event, dwc)
69 70 71 72 73 74
);

DECLARE_EVENT_CLASS(dwc3_log_ctrl,
	TP_PROTO(struct usb_ctrlrequest *ctrl),
	TP_ARGS(ctrl),
	TP_STRUCT__entry(
75 76
		__field(__u8, bRequestType)
		__field(__u8, bRequest)
77 78 79
		__field(__u16, wValue)
		__field(__u16, wIndex)
		__field(__u16, wLength)
80
		__dynamic_array(char, str, DWC3_MSG_MAX)
81 82
	),
	TP_fast_assign(
83 84
		__entry->bRequestType = ctrl->bRequestType;
		__entry->bRequest = ctrl->bRequest;
85 86 87
		__entry->wValue = le16_to_cpu(ctrl->wValue);
		__entry->wIndex = le16_to_cpu(ctrl->wIndex);
		__entry->wLength = le16_to_cpu(ctrl->wLength);
88
	),
89
	TP_printk("%s", usb_decode_ctrl(__get_str(str), DWC3_MSG_MAX,
90
					__entry->bRequestType,
91 92
					__entry->bRequest, __entry->wValue,
					__entry->wIndex, __entry->wLength)
93 94 95 96 97 98 99 100 101 102 103 104
	)
);

DEFINE_EVENT(dwc3_log_ctrl, dwc3_ctrl_req,
	TP_PROTO(struct usb_ctrlrequest *ctrl),
	TP_ARGS(ctrl)
);

DECLARE_EVENT_CLASS(dwc3_log_request,
	TP_PROTO(struct dwc3_request *req),
	TP_ARGS(req),
	TP_STRUCT__entry(
105
		__string(name, req->dep->name)
106
		__field(struct dwc3_request *, req)
107 108
		__field(unsigned int, actual)
		__field(unsigned int, length)
109
		__field(int, status)
110 111 112
		__field(int, zero)
		__field(int, short_not_ok)
		__field(int, no_interrupt)
113 114
	),
	TP_fast_assign(
115
		__assign_str(name, req->dep->name);
116
		__entry->req = req;
117 118 119
		__entry->actual = req->request.actual;
		__entry->length = req->request.length;
		__entry->status = req->request.status;
120 121 122
		__entry->zero = req->request.zero;
		__entry->short_not_ok = req->request.short_not_ok;
		__entry->no_interrupt = req->request.no_interrupt;
123
	),
124
	TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",
125
		__get_str(name), __entry->req, __entry->actual, __entry->length,
126 127 128
		__entry->zero ? "Z" : "z",
		__entry->short_not_ok ? "S" : "s",
		__entry->no_interrupt ? "i" : "I",
129
		__entry->status
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
	)
);

DEFINE_EVENT(dwc3_log_request, dwc3_alloc_request,
	TP_PROTO(struct dwc3_request *req),
	TP_ARGS(req)
);

DEFINE_EVENT(dwc3_log_request, dwc3_free_request,
	TP_PROTO(struct dwc3_request *req),
	TP_ARGS(req)
);

DEFINE_EVENT(dwc3_log_request, dwc3_ep_queue,
	TP_PROTO(struct dwc3_request *req),
	TP_ARGS(req)
);

DEFINE_EVENT(dwc3_log_request, dwc3_ep_dequeue,
	TP_PROTO(struct dwc3_request *req),
	TP_ARGS(req)
);

DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
	TP_PROTO(struct dwc3_request *req),
	TP_ARGS(req)
);

DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
159 160
	TP_PROTO(unsigned int cmd, u32 param, int status),
	TP_ARGS(cmd, param, status),
161 162 163
	TP_STRUCT__entry(
		__field(unsigned int, cmd)
		__field(u32, param)
164
		__field(int, status)
165 166 167 168
	),
	TP_fast_assign(
		__entry->cmd = cmd;
		__entry->param = param;
169
		__entry->status = status;
170
	),
171
	TP_printk("cmd '%s' [%x] param %08x --> status: %s",
172
		dwc3_gadget_generic_cmd_string(__entry->cmd),
173 174
		__entry->cmd, __entry->param,
		dwc3_gadget_generic_cmd_status_string(__entry->status)
175 176 177 178
	)
);

DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
179 180
	TP_PROTO(unsigned int cmd, u32 param, int status),
	TP_ARGS(cmd, param, status)
181 182 183 184
);

DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
	TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
185 186
		struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
	TP_ARGS(dep, cmd, params, cmd_status),
187
	TP_STRUCT__entry(
188
		__string(name, dep->name)
189
		__field(unsigned int, cmd)
190 191 192
		__field(u32, param0)
		__field(u32, param1)
		__field(u32, param2)
193
		__field(int, cmd_status)
194 195
	),
	TP_fast_assign(
196
		__assign_str(name, dep->name);
197
		__entry->cmd = cmd;
198 199 200
		__entry->param0 = params->param0;
		__entry->param1 = params->param1;
		__entry->param2 = params->param2;
201
		__entry->cmd_status = cmd_status;
202
	),
203
	TP_printk("%s: cmd '%s' [%x] params %08x %08x %08x --> status: %s",
204
		__get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
205
		__entry->cmd, __entry->param0,
206 207
		__entry->param1, __entry->param2,
		dwc3_ep_cmd_status_string(__entry->cmd_status)
208 209 210 211 212
	)
);

DEFINE_EVENT(dwc3_log_gadget_ep_cmd, dwc3_gadget_ep_cmd,
	TP_PROTO(struct dwc3_ep *dep, unsigned int cmd,
213 214
		struct dwc3_gadget_ep_cmd_params *params, int cmd_status),
	TP_ARGS(dep, cmd, params, cmd_status)
215 216 217 218 219 220
);

DECLARE_EVENT_CLASS(dwc3_log_trb,
	TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
	TP_ARGS(dep, trb),
	TP_STRUCT__entry(
221
		__string(name, dep->name)
222
		__field(struct dwc3_trb *, trb)
223 224
		__field(u32, allocated)
		__field(u32, queued)
225 226 227 228
		__field(u32, bpl)
		__field(u32, bph)
		__field(u32, size)
		__field(u32, ctrl)
229
		__field(u32, type)
230 231
		__field(u32, enqueue)
		__field(u32, dequeue)
232 233
	),
	TP_fast_assign(
234
		__assign_str(name, dep->name);
235
		__entry->trb = trb;
236 237 238 239
		__entry->bpl = trb->bpl;
		__entry->bph = trb->bph;
		__entry->size = trb->size;
		__entry->ctrl = trb->ctrl;
240
		__entry->type = usb_endpoint_type(dep->endpoint.desc);
241 242
		__entry->enqueue = dep->trb_enqueue;
		__entry->dequeue = dep->trb_dequeue;
243
	),
244 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)",
		__get_str(name), __entry->trb, __entry->enqueue,
		__entry->dequeue, __entry->bph, __entry->bpl,
247 248
		({char *s;
		int pcm = ((__entry->size >> 24) & 3) + 1;
249

250 251 252 253 254 255 256 257 258 259 260
		switch (__entry->type) {
		case USB_ENDPOINT_XFER_INT:
		case USB_ENDPOINT_XFER_ISOC:
			switch (pcm) {
			case 1:
				s = "1x ";
				break;
			case 2:
				s = "2x ";
				break;
			case 3:
261
			default:
262 263 264
				s = "3x ";
				break;
			}
265
			break;
266 267 268 269
		default:
			s = "";
		} s; }),
		DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl,
270 271 272 273 274 275
		__entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',
		__entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',
		__entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',
		__entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',
		__entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',
		__entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',
276
		  dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))
277 278 279 280 281 282 283 284 285 286 287 288 289
	)
);

DEFINE_EVENT(dwc3_log_trb, dwc3_prepare_trb,
	TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
	TP_ARGS(dep, trb)
);

DEFINE_EVENT(dwc3_log_trb, dwc3_complete_trb,
	TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
	TP_ARGS(dep, trb)
);

290 291 292 293
DECLARE_EVENT_CLASS(dwc3_log_ep,
	TP_PROTO(struct dwc3_ep *dep),
	TP_ARGS(dep),
	TP_STRUCT__entry(
294
		__string(name, dep->name)
295 296 297 298 299 300
		__field(unsigned int, maxpacket)
		__field(unsigned int, maxpacket_limit)
		__field(unsigned int, max_streams)
		__field(unsigned int, maxburst)
		__field(unsigned int, flags)
		__field(unsigned int, direction)
301 302 303 304
		__field(u8, trb_enqueue)
		__field(u8, trb_dequeue)
	),
	TP_fast_assign(
305
		__assign_str(name, dep->name);
306 307 308 309 310 311 312 313 314
		__entry->maxpacket = dep->endpoint.maxpacket;
		__entry->maxpacket_limit = dep->endpoint.maxpacket_limit;
		__entry->max_streams = dep->endpoint.max_streams;
		__entry->maxburst = dep->endpoint.maxburst;
		__entry->flags = dep->flags;
		__entry->direction = dep->direction;
		__entry->trb_enqueue = dep->trb_enqueue;
		__entry->trb_dequeue = dep->trb_dequeue;
	),
315
	TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c:%c",
316 317 318 319 320 321 322
		__get_str(name), __entry->maxpacket,
		__entry->maxpacket_limit, __entry->max_streams,
		__entry->maxburst, __entry->trb_enqueue,
		__entry->trb_dequeue,
		__entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',
		__entry->flags & DWC3_EP_STALL ? 'S' : 's',
		__entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',
323
		__entry->flags & DWC3_EP_TRANSFER_STARTED ? 'B' : 'b',
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
		__entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',
		__entry->direction ? '<' : '>'
	)
);

DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_enable,
	TP_PROTO(struct dwc3_ep *dep),
	TP_ARGS(dep)
);

DEFINE_EVENT(dwc3_log_ep, dwc3_gadget_ep_disable,
	TP_PROTO(struct dwc3_ep *dep),
	TP_ARGS(dep)
);

339 340 341 342 343 344 345 346 347 348 349
#endif /* __DWC3_TRACE_H */

/* this part has to be here */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .

#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace

#include <trace/define_trace.h>