1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM intel_avs
4 
5 #if !defined(_TRACE_INTEL_AVS_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_INTEL_AVS_H
7 
8 #include <linux/types.h>
9 #include <linux/tracepoint.h>
10 
11 TRACE_EVENT(avs_dsp_core_op,
12 
13 	TP_PROTO(unsigned int reg, unsigned int mask, const char *op, bool flag),
14 
15 	TP_ARGS(reg, mask, op, flag),
16 
17 	TP_STRUCT__entry(
18 		__field(unsigned int,	reg	)
19 		__field(unsigned int,	mask	)
20 		__string(op,		op	)
21 		__field(bool,		flag	)
22 	),
23 
24 	TP_fast_assign(
25 		__entry->reg = reg;
26 		__entry->mask = mask;
27 		__assign_str(op, op);
28 		__entry->flag = flag;
29 	),
30 
31 	TP_printk("%s: %d, core mask: 0x%X, prev state: 0x%08X",
32 		  __get_str(op), __entry->flag, __entry->mask, __entry->reg)
33 );
34 
35 #ifndef __TRACE_INTEL_AVS_TRACE_HELPER
36 #define __TRACE_INTEL_AVS_TRACE_HELPER
37 
38 void trace_avs_msg_payload(const void *data, size_t size);
39 
40 #define trace_avs_request(msg, fwregs) \
41 ({ \
42 	trace_avs_ipc_request_msg((msg)->header, fwregs); \
43 	trace_avs_msg_payload((msg)->data, (msg)->size); \
44 })
45 
46 #define trace_avs_reply(msg, fwregs) \
47 ({ \
48 	trace_avs_ipc_reply_msg((msg)->header, fwregs); \
49 	trace_avs_msg_payload((msg)->data, (msg)->size); \
50 })
51 
52 #define trace_avs_notify(msg, fwregs) \
53 ({ \
54 	trace_avs_ipc_notify_msg((msg)->header, fwregs); \
55 	trace_avs_msg_payload((msg)->data, (msg)->size); \
56 })
57 #endif
58 
59 DECLARE_EVENT_CLASS(avs_ipc_msg_hdr,
60 
61 	TP_PROTO(u64 header, u64 fwregs),
62 
63 	TP_ARGS(header, fwregs),
64 
65 	TP_STRUCT__entry(
66 		__field(u64,	header)
67 		__field(u64,	fwregs)
68 	),
69 
70 	TP_fast_assign(
71 		__entry->header = header;
72 		__entry->fwregs = fwregs;
73 	),
74 
75 	TP_printk("primary: 0x%08X, extension: 0x%08X,\n"
76 		  "fwstatus: 0x%08X, fwerror: 0x%08X",
77 		  lower_32_bits(__entry->header), upper_32_bits(__entry->header),
78 		  lower_32_bits(__entry->fwregs), upper_32_bits(__entry->fwregs))
79 );
80 
81 DEFINE_EVENT(avs_ipc_msg_hdr, avs_ipc_request_msg,
82 	TP_PROTO(u64 header, u64 fwregs),
83 	TP_ARGS(header, fwregs)
84 );
85 
86 DEFINE_EVENT(avs_ipc_msg_hdr, avs_ipc_reply_msg,
87 	TP_PROTO(u64 header, u64 fwregs),
88 	TP_ARGS(header, fwregs)
89 );
90 
91 DEFINE_EVENT(avs_ipc_msg_hdr, avs_ipc_notify_msg,
92 	TP_PROTO(u64 header, u64 fwregs),
93 	TP_ARGS(header, fwregs)
94 );
95 
96 TRACE_EVENT_CONDITION(avs_ipc_msg_payload,
97 
98 	TP_PROTO(const u8 *data, size_t size, size_t offset, size_t total),
99 
100 	TP_ARGS(data, size, offset, total),
101 
102 	TP_CONDITION(data && size),
103 
104 	TP_STRUCT__entry(
105 		__dynamic_array(u8,	buf,	size	)
106 		__field(size_t,		offset		)
107 		__field(size_t,		pos		)
108 		__field(size_t,		total		)
109 	),
110 
111 	TP_fast_assign(
112 		memcpy(__get_dynamic_array(buf), data + offset, size);
113 		__entry->offset = offset;
114 		__entry->pos = offset + size;
115 		__entry->total = total;
116 	),
117 
118 	TP_printk("range %zu-%zu out of %zu bytes%s",
119 		  __entry->offset, __entry->pos, __entry->total,
120 		  __print_hex_dump("", DUMP_PREFIX_NONE, 16, 4,
121 				   __get_dynamic_array(buf),
122 				   __get_dynamic_array_len(buf), false))
123 );
124 
125 TRACE_EVENT(avs_d0ix,
126 
127 	TP_PROTO(const char *op, bool proceed, u64 header),
128 
129 	TP_ARGS(op, proceed, header),
130 
131 	TP_STRUCT__entry(
132 		__string(op,	op	)
133 		__field(bool,	proceed	)
134 		__field(u64,	header	)
135 	),
136 
137 	TP_fast_assign(
138 		__assign_str(op, op);
139 		__entry->proceed = proceed;
140 		__entry->header = header;
141 	),
142 
143 	TP_printk("%s%s for request: 0x%08X 0x%08X",
144 		  __entry->proceed ? "" : "ignore ", __get_str(op),
145 		  lower_32_bits(__entry->header), upper_32_bits(__entry->header))
146 );
147 
148 #endif /* _TRACE_INTEL_AVS_H */
149 
150 /* This part must be outside protection */
151 #undef TRACE_INCLUDE_PATH
152 #define TRACE_INCLUDE_PATH .
153 #define TRACE_INCLUDE_FILE trace
154 #include <trace/define_trace.h>
155