summaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/trace.h
blob: 1601fd86c4c10bffa0dfe07bd5ab0ff848477acb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Trace support header file for device mode
 *
 * Copyright (C) 2020 NXP
 *
 * Author: Peter Chen <peter.chen@nxp.com>
 */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM chipidea

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

#include <linux/types.h>
#include <linux/tracepoint.h>
#include <linux/usb/chipidea.h>
#include "ci.h"
#include "udc.h"

#define CHIPIDEA_MSG_MAX	500

void ci_log(struct ci_hdrc *ci, const char *fmt, ...);

TRACE_EVENT(ci_log,
	TP_PROTO(struct ci_hdrc *ci, struct va_format *vaf),
	TP_ARGS(ci, vaf),
	TP_STRUCT__entry(
		__string(name, dev_name(ci->dev))
		__dynamic_array(char, msg, CHIPIDEA_MSG_MAX)
	),
	TP_fast_assign(
		__assign_str(name, dev_name(ci->dev));
		vsnprintf(__get_str(msg), CHIPIDEA_MSG_MAX, vaf->fmt, *vaf->va);
	),
	TP_printk("%s: %s", __get_str(name), __get_str(msg))
);

DECLARE_EVENT_CLASS(ci_log_trb,
	TP_PROTO(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, struct td_node *td),
	TP_ARGS(hwep, hwreq, td),
	TP_STRUCT__entry(
		__string(name, hwep->name)
		__field(struct td_node *, td)
		__field(struct usb_request *, req)
		__field(dma_addr_t, dma)
		__field(s32, td_remaining_size)
		__field(u32, next)
		__field(u32, token)
		__field(u32, type)
	),
	TP_fast_assign(
		__assign_str(name, hwep->name);
		__entry->req = &hwreq->req;
		__entry->td = td;
		__entry->dma = td->dma;
		__entry->td_remaining_size = td->td_remaining_size;
		__entry->next = le32_to_cpu(td->ptr->next);
		__entry->token = le32_to_cpu(td->ptr->token);
		__entry->type = usb_endpoint_type(hwep->ep.desc);
	),
	TP_printk("%s: req: %p, td: %p, td_dma_address: %pad, remaining_size: %d, "
	       "next: %x, total bytes: %d, status: %lx",
		__get_str(name), __entry->req, __entry->td, &__entry->dma,
		__entry->td_remaining_size, __entry->next,
		(int)((__entry->token & TD_TOTAL_BYTES) >> __ffs(TD_TOTAL_BYTES)),
		__entry->token & TD_STATUS
	)
);

DEFINE_EVENT(ci_log_trb, ci_prepare_td,
	TP_PROTO(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, struct td_node *td),
	TP_ARGS(hwep, hwreq, td)
);

DEFINE_EVENT(ci_log_trb, ci_complete_td,
	TP_PROTO(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq, struct td_node *td),
	TP_ARGS(hwep, hwreq, td)
);

#endif /* __LINUX_CHIPIDEA_TRACE */

/* this part must be outside header guard */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .

#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE trace

#include <trace/define_trace.h>