xhci-trace.h 7.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * xHCI host controller driver
 *
 * Copyright (C) 2013 Xenia Ragiadakou
 *
 * Author: Xenia Ragiadakou
 * Email : burzalodowa@gmail.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM xhci-hcd

17 18 19 20 21 22 23
/*
 * The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a
 * legitimate C variable. It is not exported to user space.
 */
#undef TRACE_SYSTEM_VAR
#define TRACE_SYSTEM_VAR xhci_hcd

24 25 26 27
#if !defined(__XHCI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define __XHCI_TRACE_H

#include <linux/tracepoint.h>
28
#include "xhci.h"
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

#define XHCI_MSG_MAX	500

DECLARE_EVENT_CLASS(xhci_log_msg,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf),
	TP_STRUCT__entry(__dynamic_array(char, msg, XHCI_MSG_MAX)),
	TP_fast_assign(
		vsnprintf(__get_str(msg), XHCI_MSG_MAX, vaf->fmt, *vaf->va);
	),
	TP_printk("%s", __get_str(msg))
);

DEFINE_EVENT(xhci_log_msg, xhci_dbg_address,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

47 48 49 50 51
DEFINE_EVENT(xhci_log_msg, xhci_dbg_context_change,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

52 53 54 55 56
DEFINE_EVENT(xhci_log_msg, xhci_dbg_quirks,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

57 58 59 60 61
DEFINE_EVENT(xhci_log_msg, xhci_dbg_reset_ep,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

62 63 64 65 66
DEFINE_EVENT(xhci_log_msg, xhci_dbg_cancel_urb,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

67 68 69 70 71
DEFINE_EVENT(xhci_log_msg, xhci_dbg_init,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

72 73 74 75 76
DEFINE_EVENT(xhci_log_msg, xhci_dbg_ring_expansion,
	TP_PROTO(struct va_format *vaf),
	TP_ARGS(vaf)
);

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
DECLARE_EVENT_CLASS(xhci_log_ctx,
	TP_PROTO(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx,
		 unsigned int ep_num),
	TP_ARGS(xhci, ctx, ep_num),
	TP_STRUCT__entry(
		__field(int, ctx_64)
		__field(unsigned, ctx_type)
		__field(dma_addr_t, ctx_dma)
		__field(u8 *, ctx_va)
		__field(unsigned, ctx_ep_num)
		__field(int, slot_id)
		__dynamic_array(u32, ctx_data,
			((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 8) *
			((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1))
	),
	TP_fast_assign(
		struct usb_device *udev;

		udev = to_usb_device(xhci_to_hcd(xhci)->self.controller);
		__entry->ctx_64 = HCC_64BYTE_CONTEXT(xhci->hcc_params);
		__entry->ctx_type = ctx->type;
		__entry->ctx_dma = ctx->dma;
		__entry->ctx_va = ctx->bytes;
		__entry->slot_id = udev->slot_id;
		__entry->ctx_ep_num = ep_num;
		memcpy(__get_dynamic_array(ctx_data), ctx->bytes,
			((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 32) *
			((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1));
	),
106
	TP_printk("ctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p",
107 108 109 110 111 112 113 114 115 116 117
			__entry->ctx_64, __entry->ctx_type,
			(unsigned long long) __entry->ctx_dma, __entry->ctx_va
	)
);

DEFINE_EVENT(xhci_log_ctx, xhci_address_ctx,
	TP_PROTO(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx,
		 unsigned int ep_num),
	TP_ARGS(xhci, ctx, ep_num)
);

118 119 120
DECLARE_EVENT_CLASS(xhci_log_trb,
	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
	TP_ARGS(ring, trb),
121
	TP_STRUCT__entry(
122 123 124 125 126
		__field(u32, type)
		__field(u32, field0)
		__field(u32, field1)
		__field(u32, field2)
		__field(u32, field3)
127 128
	),
	TP_fast_assign(
129 130 131 132 133
		__entry->type = ring->type;
		__entry->field0 = le32_to_cpu(trb->field[0]);
		__entry->field1 = le32_to_cpu(trb->field[1]);
		__entry->field2 = le32_to_cpu(trb->field[2]);
		__entry->field3 = le32_to_cpu(trb->field[3]);
134
	),
135 136 137
	TP_printk("%s: %s", xhci_ring_type_string(__entry->type),
			xhci_decode_trb(__entry->field0, __entry->field1,
					__entry->field2, __entry->field3)
138 139 140
	)
);

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
DEFINE_EVENT(xhci_log_trb, xhci_handle_event,
	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
	TP_ARGS(ring, trb)
);

DEFINE_EVENT(xhci_log_trb, xhci_handle_command,
	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
	TP_ARGS(ring, trb)
);

DEFINE_EVENT(xhci_log_trb, xhci_handle_transfer,
	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
	TP_ARGS(ring, trb)
);

DEFINE_EVENT(xhci_log_trb, xhci_queue_trb,
	TP_PROTO(struct xhci_ring *ring, struct xhci_generic_trb *trb),
	TP_ARGS(ring, trb)
159 160
);

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
DECLARE_EVENT_CLASS(xhci_log_virt_dev,
	TP_PROTO(struct xhci_virt_device *vdev),
	TP_ARGS(vdev),
	TP_STRUCT__entry(
		__field(void *, vdev)
		__field(unsigned long long, out_ctx)
		__field(unsigned long long, in_ctx)
		__field(int, devnum)
		__field(int, state)
		__field(int, speed)
		__field(u8, portnum)
		__field(u8, level)
		__field(int, slot_id)
	),
	TP_fast_assign(
		__entry->vdev = vdev;
		__entry->in_ctx = (unsigned long long) vdev->in_ctx->dma;
		__entry->out_ctx = (unsigned long long) vdev->out_ctx->dma;
		__entry->devnum = vdev->udev->devnum;
		__entry->state = vdev->udev->state;
		__entry->speed = vdev->udev->speed;
		__entry->portnum = vdev->udev->portnum;
		__entry->level = vdev->udev->level;
		__entry->slot_id = vdev->udev->slot_id;
	),
	TP_printk("vdev %p ctx %llx | %llx num %d state %d speed %d port %d level %d slot %d",
		__entry->vdev, __entry->in_ctx, __entry->out_ctx,
		__entry->devnum, __entry->state, __entry->speed,
		__entry->portnum, __entry->level, __entry->slot_id
	)
);

DEFINE_EVENT(xhci_log_virt_dev, xhci_alloc_virt_device,
	TP_PROTO(struct xhci_virt_device *vdev),
	TP_ARGS(vdev)
);

DEFINE_EVENT(xhci_log_virt_dev, xhci_free_virt_device,
	TP_PROTO(struct xhci_virt_device *vdev),
	TP_ARGS(vdev)
);

DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_device,
	TP_PROTO(struct xhci_virt_device *vdev),
	TP_ARGS(vdev)
);

DEFINE_EVENT(xhci_log_virt_dev, xhci_setup_addressable_virt_device,
	TP_PROTO(struct xhci_virt_device *vdev),
	TP_ARGS(vdev)
);

DEFINE_EVENT(xhci_log_virt_dev, xhci_stop_device,
	TP_PROTO(struct xhci_virt_device *vdev),
	TP_ARGS(vdev)
);

218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
DECLARE_EVENT_CLASS(xhci_log_urb,
	TP_PROTO(struct urb *urb),
	TP_ARGS(urb),
	TP_STRUCT__entry(
		__field(void *, urb)
		__field(unsigned int, pipe)
		__field(unsigned int, stream)
		__field(int, status)
		__field(unsigned int, flags)
		__field(int, num_mapped_sgs)
		__field(int, num_sgs)
		__field(int, length)
		__field(int, actual)
		__field(int, epnum)
		__field(int, dir_in)
		__field(int, type)
234
		__field(int, slot_id)
235 236 237 238 239 240 241 242 243 244 245 246 247 248
	),
	TP_fast_assign(
		__entry->urb = urb;
		__entry->pipe = urb->pipe;
		__entry->stream = urb->stream_id;
		__entry->status = urb->status;
		__entry->flags = urb->transfer_flags;
		__entry->num_mapped_sgs = urb->num_mapped_sgs;
		__entry->num_sgs = urb->num_sgs;
		__entry->length = urb->transfer_buffer_length;
		__entry->actual = urb->actual_length;
		__entry->epnum = usb_endpoint_num(&urb->ep->desc);
		__entry->dir_in = usb_endpoint_dir_in(&urb->ep->desc);
		__entry->type = usb_endpoint_type(&urb->ep->desc);
249
		__entry->slot_id = urb->dev->slot_id;
250
	),
251
	TP_printk("ep%d%s-%s: urb %p pipe %u slot %d length %d/%d sgs %d/%d stream %d flags %08x",
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
			__entry->epnum, __entry->dir_in ? "in" : "out",
			({ char *s;
			switch (__entry->type) {
			case USB_ENDPOINT_XFER_INT:
				s = "intr";
				break;
			case USB_ENDPOINT_XFER_CONTROL:
				s = "control";
				break;
			case USB_ENDPOINT_XFER_BULK:
				s = "bulk";
				break;
			case USB_ENDPOINT_XFER_ISOC:
				s = "isoc";
				break;
			default:
				s = "UNKNOWN";
269 270
			} s; }), __entry->urb, __entry->pipe, __entry->slot_id,
			__entry->actual, __entry->length, __entry->num_mapped_sgs,
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
			__entry->num_sgs, __entry->stream, __entry->flags
		)
);

DEFINE_EVENT(xhci_log_urb, xhci_urb_enqueue,
	TP_PROTO(struct urb *urb),
	TP_ARGS(urb)
);

DEFINE_EVENT(xhci_log_urb, xhci_urb_giveback,
	TP_PROTO(struct urb *urb),
	TP_ARGS(urb)
);

DEFINE_EVENT(xhci_log_urb, xhci_urb_dequeue,
	TP_PROTO(struct urb *urb),
	TP_ARGS(urb)
);

290 291 292 293 294 295 296 297 298 299 300
#endif /* __XHCI_TRACE_H */

/* this part must be outside header guard */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .

#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE xhci-trace

#include <trace/define_trace.h>