xhci: add xhci_cmd_completion trace event
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / xhci-trace.h
1 /*
2  * xHCI host controller driver
3  *
4  * Copyright (C) 2013 Xenia Ragiadakou
5  *
6  * Author: Xenia Ragiadakou
7  * Email : burzalodowa@gmail.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 as
11  * published by the Free Software Foundation.
12  */
13
14 #undef TRACE_SYSTEM
15 #define TRACE_SYSTEM xhci-hcd
16
17 #if !defined(__XHCI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
18 #define __XHCI_TRACE_H
19
20 #include <linux/tracepoint.h>
21 #include "xhci.h"
22
23 #define XHCI_MSG_MAX    500
24
25 DECLARE_EVENT_CLASS(xhci_log_msg,
26         TP_PROTO(struct va_format *vaf),
27         TP_ARGS(vaf),
28         TP_STRUCT__entry(__dynamic_array(char, msg, XHCI_MSG_MAX)),
29         TP_fast_assign(
30                 vsnprintf(__get_str(msg), XHCI_MSG_MAX, vaf->fmt, *vaf->va);
31         ),
32         TP_printk("%s", __get_str(msg))
33 );
34
35 DEFINE_EVENT(xhci_log_msg, xhci_dbg_address,
36         TP_PROTO(struct va_format *vaf),
37         TP_ARGS(vaf)
38 );
39
40 DEFINE_EVENT(xhci_log_msg, xhci_dbg_context_change,
41         TP_PROTO(struct va_format *vaf),
42         TP_ARGS(vaf)
43 );
44
45 DEFINE_EVENT(xhci_log_msg, xhci_dbg_quirks,
46         TP_PROTO(struct va_format *vaf),
47         TP_ARGS(vaf)
48 );
49
50 DEFINE_EVENT(xhci_log_msg, xhci_dbg_reset_ep,
51         TP_PROTO(struct va_format *vaf),
52         TP_ARGS(vaf)
53 );
54
55 DECLARE_EVENT_CLASS(xhci_log_ctx,
56         TP_PROTO(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx,
57                  unsigned int ep_num),
58         TP_ARGS(xhci, ctx, ep_num),
59         TP_STRUCT__entry(
60                 __field(int, ctx_64)
61                 __field(unsigned, ctx_type)
62                 __field(dma_addr_t, ctx_dma)
63                 __field(u8 *, ctx_va)
64                 __field(unsigned, ctx_ep_num)
65                 __field(int, slot_id)
66                 __dynamic_array(u32, ctx_data,
67                         ((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 8) *
68                         ((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1))
69         ),
70         TP_fast_assign(
71                 struct usb_device *udev;
72
73                 udev = to_usb_device(xhci_to_hcd(xhci)->self.controller);
74                 __entry->ctx_64 = HCC_64BYTE_CONTEXT(xhci->hcc_params);
75                 __entry->ctx_type = ctx->type;
76                 __entry->ctx_dma = ctx->dma;
77                 __entry->ctx_va = ctx->bytes;
78                 __entry->slot_id = udev->slot_id;
79                 __entry->ctx_ep_num = ep_num;
80                 memcpy(__get_dynamic_array(ctx_data), ctx->bytes,
81                         ((HCC_64BYTE_CONTEXT(xhci->hcc_params) + 1) * 32) *
82                         ((ctx->type == XHCI_CTX_TYPE_INPUT) + ep_num + 1));
83         ),
84         TP_printk("\nctx_64=%d, ctx_type=%u, ctx_dma=@%llx, ctx_va=@%p",
85                         __entry->ctx_64, __entry->ctx_type,
86                         (unsigned long long) __entry->ctx_dma, __entry->ctx_va
87         )
88 );
89
90 DEFINE_EVENT(xhci_log_ctx, xhci_address_ctx,
91         TP_PROTO(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx,
92                  unsigned int ep_num),
93         TP_ARGS(xhci, ctx, ep_num)
94 );
95
96 DECLARE_EVENT_CLASS(xhci_log_event,
97         TP_PROTO(void *trb_va, struct xhci_generic_trb *ev),
98         TP_ARGS(trb_va, ev),
99         TP_STRUCT__entry(
100                 __field(void *, va)
101                 __field(u64, dma)
102                 __field(u32, status)
103                 __field(u32, flags)
104                 __dynamic_array(__le32, trb, 4)
105         ),
106         TP_fast_assign(
107                 __entry->va = trb_va;
108                 __entry->dma = le64_to_cpu(((u64)ev->field[1]) << 32 |
109                                                 ev->field[0]);
110                 __entry->status = le32_to_cpu(ev->field[2]);
111                 __entry->flags = le32_to_cpu(ev->field[3]);
112                 memcpy(__get_dynamic_array(trb), trb_va,
113                         sizeof(struct xhci_generic_trb));
114         ),
115         TP_printk("\ntrb_dma=@%llx, trb_va=@%p, status=%08x, flags=%08x",
116                         (unsigned long long) __entry->dma, __entry->va,
117                         __entry->status, __entry->flags
118         )
119 );
120
121 DEFINE_EVENT(xhci_log_event, xhci_cmd_completion,
122         TP_PROTO(void *trb_va, struct xhci_generic_trb *ev),
123         TP_ARGS(trb_va, ev)
124 );
125
126 #endif /* __XHCI_TRACE_H */
127
128 /* this part must be outside header guard */
129
130 #undef TRACE_INCLUDE_PATH
131 #define TRACE_INCLUDE_PATH .
132
133 #undef TRACE_INCLUDE_FILE
134 #define TRACE_INCLUDE_FILE xhci-trace
135
136 #include <trace/define_trace.h>