xref: /openbmc/linux/drivers/usb/chipidea/trace.h (revision 413d6ed3)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Trace support header file for device mode
4  *
5  * Copyright (C) 2020 NXP
6  *
7  * Author: Peter Chen <peter.chen@nxp.com>
8  */
9 
10 #undef TRACE_SYSTEM
11 #define TRACE_SYSTEM chipidea
12 
13 #if !defined(__LINUX_CHIPIDEA_TRACE) || defined(TRACE_HEADER_MULTI_READ)
14 #define __LINUX_CHIPIDEA_TRACE
15 
16 #include <linux/types.h>
17 #include <linux/tracepoint.h>
18 #include <linux/usb/chipidea.h>
19 #include "ci.h"
20 #include "udc.h"
21 
22 #define CHIPIDEA_MSG_MAX	500
23 
24 void ci_log(struct ci_hdrc *ci, const char *fmt, ...);
25 
26 TRACE_EVENT(ci_log,
27 	TP_PROTO(struct ci_hdrc *ci, struct va_format *vaf),
28 	TP_ARGS(ci, vaf),
29 	TP_STRUCT__entry(
30 		__string(name, dev_name(ci->dev))
31 		__dynamic_array(char, msg, CHIPIDEA_MSG_MAX)
32 	),
33 	TP_fast_assign(
34 		__assign_str(name, dev_name(ci->dev));
35 		vsnprintf(__get_str(msg), CHIPIDEA_MSG_MAX, vaf->fmt, *vaf->va);
36 	),
37 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
38 );
39 
40 DECLARE_EVENT_CLASS(ci_log_trb,
41 	TP_PROTO(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, struct td_node *td),
42 	TP_ARGS(hwep, hwreq, td),
43 	TP_STRUCT__entry(
44 		__string(name, hwep->name)
45 		__field(struct td_node *, td)
46 		__field(struct usb_request *, req)
47 		__field(dma_addr_t, dma)
48 		__field(s32, td_remaining_size)
49 		__field(u32, next)
50 		__field(u32, token)
51 		__field(u32, type)
52 	),
53 	TP_fast_assign(
54 		__assign_str(name, hwep->name);
55 		__entry->req = &hwreq->req;
56 		__entry->td = td;
57 		__entry->dma = td->dma;
58 		__entry->td_remaining_size = td->td_remaining_size;
59 		__entry->next = le32_to_cpu(td->ptr->next);
60 		__entry->token = le32_to_cpu(td->ptr->token);
61 		__entry->type = usb_endpoint_type(hwep->ep.desc);
62 	),
63 	TP_printk("%s: req: %p, td: %p, td_dma_address: %pad, remaining_size: %d, "
64 	       "next: %x, total bytes: %d, status: %lx",
65 		__get_str(name), __entry->req, __entry->td, &__entry->dma,
66 		__entry->td_remaining_size, __entry->next,
67 		(int)((__entry->token & TD_TOTAL_BYTES) >> __ffs(TD_TOTAL_BYTES)),
68 		__entry->token & TD_STATUS
69 	)
70 );
71 
72 DEFINE_EVENT(ci_log_trb, ci_prepare_td,
73 	TP_PROTO(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, struct td_node *td),
74 	TP_ARGS(hwep, hwreq, td)
75 );
76 
77 DEFINE_EVENT(ci_log_trb, ci_complete_td,
78 	TP_PROTO(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, struct td_node *td),
79 	TP_ARGS(hwep, hwreq, td)
80 );
81 
82 #endif /* __LINUX_CHIPIDEA_TRACE */
83 
84 /* this part must be outside header guard */
85 
86 #undef TRACE_INCLUDE_PATH
87 #define TRACE_INCLUDE_PATH .
88 
89 #undef TRACE_INCLUDE_FILE
90 #define TRACE_INCLUDE_FILE trace
91 
92 #include <trace/define_trace.h>
93