xref: /linux/include/trace/events/firewire.h (revision 90d32e92011eaae8e70a9169b4e7acf4ca8f9d3a)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 // Copyright (c) 2024 Takashi Sakamoto
3 
4 #define TRACE_SYSTEM	firewire
5 
6 #if !defined(_FIREWIRE_TRACE_EVENT_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define _FIREWIRE_TRACE_EVENT_H
8 
9 #include <linux/tracepoint.h>
10 #include <linux/firewire.h>
11 
12 #include <linux/firewire-constants.h>
13 
14 #include "../../../drivers/firewire/packet-header-definitions.h"
15 
16 // The content of TP_printk field is preprocessed, then put to the module binary.
17 #define ASYNC_HEADER_GET_DESTINATION(header)	\
18 	(((header)[0] & ASYNC_HEADER_Q0_DESTINATION_MASK) >> ASYNC_HEADER_Q0_DESTINATION_SHIFT)
19 
20 #define ASYNC_HEADER_GET_TLABEL(header)	\
21 	(((header)[0] & ASYNC_HEADER_Q0_TLABEL_MASK) >> ASYNC_HEADER_Q0_TLABEL_SHIFT)
22 
23 #define ASYNC_HEADER_GET_TCODE(header)	\
24 	(((header)[0] & ASYNC_HEADER_Q0_TCODE_MASK) >> ASYNC_HEADER_Q0_TCODE_SHIFT)
25 
26 #define ASYNC_HEADER_GET_SOURCE(header)	\
27 	(((header)[1] & ASYNC_HEADER_Q1_SOURCE_MASK) >> ASYNC_HEADER_Q1_SOURCE_SHIFT)
28 
29 #define ASYNC_HEADER_GET_OFFSET(header)	\
30 	((((unsigned long long)((header)[1] & ASYNC_HEADER_Q1_OFFSET_HIGH_MASK)) >> ASYNC_HEADER_Q1_OFFSET_HIGH_SHIFT) << 32)| \
31 	(header)[2]
32 
33 #define ASYNC_HEADER_GET_RCODE(header)	\
34 	(((header)[1] & ASYNC_HEADER_Q1_RCODE_MASK) >> ASYNC_HEADER_Q1_RCODE_SHIFT)
35 
36 #define QUADLET_SIZE	4
37 
38 DECLARE_EVENT_CLASS(async_outbound_initiate_template,
39 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count),
40 	TP_ARGS(transaction, generation, scode, header, data, data_count),
41 	TP_STRUCT__entry(
42 		__field(u64, transaction)
43 		__field(u8, generation)
44 		__field(u8, scode)
45 		__array(u32, header, ASYNC_HEADER_QUADLET_COUNT)
46 		__dynamic_array(u32, data, data_count)
47 	),
48 	TP_fast_assign(
49 		__entry->transaction = transaction;
50 		__entry->generation = generation;
51 		__entry->scode = scode;
52 		memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUNT);
53 		memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data));
54 	),
55 	// This format is for the request subaction.
56 	TP_printk(
57 		"transaction=0x%llx generation=%u scode=%u dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x offset=0x%012llx header=%s data=%s",
58 		__entry->transaction,
59 		__entry->generation,
60 		__entry->scode,
61 		ASYNC_HEADER_GET_DESTINATION(__entry->header),
62 		ASYNC_HEADER_GET_TLABEL(__entry->header),
63 		ASYNC_HEADER_GET_TCODE(__entry->header),
64 		ASYNC_HEADER_GET_SOURCE(__entry->header),
65 		ASYNC_HEADER_GET_OFFSET(__entry->header),
66 		__print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE),
67 		__print_array(__get_dynamic_array(data),
68 			      __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE)
69 	)
70 );
71 
72 // The value of status is one of ack codes and rcodes specific to Linux FireWire subsystem.
73 DECLARE_EVENT_CLASS(async_outbound_complete_template,
74 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp),
75 	TP_ARGS(transaction, generation, scode, status, timestamp),
76 	TP_STRUCT__entry(
77 		__field(u64, transaction)
78 		__field(u8, generation)
79 		__field(u8, scode)
80 		__field(u8, status)
81 		__field(u16, timestamp)
82 	),
83 	TP_fast_assign(
84 		__entry->transaction = transaction;
85 		__entry->generation = generation;
86 		__entry->scode = scode;
87 		__entry->status = status;
88 		__entry->timestamp = timestamp;
89 	),
90 	TP_printk(
91 		"transaction=0x%llx generation=%u scode=%u status=%u timestamp=0x%04x",
92 		__entry->transaction,
93 		__entry->generation,
94 		__entry->scode,
95 		__entry->status,
96 		__entry->timestamp
97 	)
98 );
99 
100 // The value of status is one of ack codes and rcodes specific to Linux FireWire subsystem.
101 DECLARE_EVENT_CLASS(async_inbound_template,
102 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count),
103 	TP_ARGS(transaction, generation, scode, status, timestamp, header, data, data_count),
104 	TP_STRUCT__entry(
105 		__field(u64, transaction)
106 		__field(u8, generation)
107 		__field(u8, scode)
108 		__field(u8, status)
109 		__field(u16, timestamp)
110 		__array(u32, header, ASYNC_HEADER_QUADLET_COUNT)
111 		__dynamic_array(u32, data, data_count)
112 	),
113 	TP_fast_assign(
114 		__entry->transaction = transaction;
115 		__entry->generation = generation;
116 		__entry->scode = scode;
117 		__entry->status = status;
118 		__entry->timestamp = timestamp;
119 		memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUNT);
120 		memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data));
121 	),
122 	// This format is for the response subaction.
123 	TP_printk(
124 		"transaction=0x%llx generation=%u scode=%u status=%u timestamp=0x%04x dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x rcode=%u header=%s data=%s",
125 		__entry->transaction,
126 		__entry->generation,
127 		__entry->scode,
128 		__entry->status,
129 		__entry->timestamp,
130 		ASYNC_HEADER_GET_DESTINATION(__entry->header),
131 		ASYNC_HEADER_GET_TLABEL(__entry->header),
132 		ASYNC_HEADER_GET_TCODE(__entry->header),
133 		ASYNC_HEADER_GET_SOURCE(__entry->header),
134 		ASYNC_HEADER_GET_RCODE(__entry->header),
135 		__print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE),
136 		__print_array(__get_dynamic_array(data),
137 			      __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE)
138 	)
139 );
140 
141 DEFINE_EVENT(async_outbound_initiate_template, async_request_outbound_initiate,
142 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count),
143 	TP_ARGS(transaction, generation, scode, header, data, data_count)
144 );
145 
146 DEFINE_EVENT(async_outbound_complete_template, async_request_outbound_complete,
147 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp),
148 	TP_ARGS(transaction, generation, scode, status, timestamp)
149 );
150 
151 DEFINE_EVENT(async_inbound_template, async_response_inbound,
152 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count),
153 	TP_ARGS(transaction, generation, scode, status, timestamp, header, data, data_count)
154 );
155 
156 DEFINE_EVENT_PRINT(async_inbound_template, async_request_inbound,
157 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count),
158 	TP_ARGS(transaction, generation, scode, status, timestamp, header, data, data_count),
159 	TP_printk(
160 		"transaction=0x%llx generation=%u scode=%u status=%u timestamp=0x%04x dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x offset=0x%012llx header=%s data=%s",
161 		__entry->transaction,
162 		__entry->generation,
163 		__entry->scode,
164 		__entry->status,
165 		__entry->timestamp,
166 		ASYNC_HEADER_GET_DESTINATION(__entry->header),
167 		ASYNC_HEADER_GET_TLABEL(__entry->header),
168 		ASYNC_HEADER_GET_TCODE(__entry->header),
169 		ASYNC_HEADER_GET_SOURCE(__entry->header),
170 		ASYNC_HEADER_GET_OFFSET(__entry->header),
171 		__print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE),
172 		__print_array(__get_dynamic_array(data),
173 			      __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE)
174 	)
175 );
176 
177 DEFINE_EVENT_PRINT(async_outbound_initiate_template, async_response_outbound_initiate,
178 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count),
179 	TP_ARGS(transaction, generation, scode, header, data, data_count),
180 	TP_printk(
181 		"transaction=0x%llx generation=%u scode=%u dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x rcode=%u header=%s data=%s",
182 		__entry->transaction,
183 		__entry->generation,
184 		__entry->scode,
185 		ASYNC_HEADER_GET_DESTINATION(__entry->header),
186 		ASYNC_HEADER_GET_TLABEL(__entry->header),
187 		ASYNC_HEADER_GET_TCODE(__entry->header),
188 		ASYNC_HEADER_GET_SOURCE(__entry->header),
189 		ASYNC_HEADER_GET_RCODE(__entry->header),
190 		__print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE),
191 		__print_array(__get_dynamic_array(data),
192 			      __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE)
193 	)
194 );
195 
196 DEFINE_EVENT(async_outbound_complete_template, async_response_outbound_complete,
197 	TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp),
198 	TP_ARGS(transaction, generation, scode, status, timestamp)
199 );
200 
201 #undef ASYNC_HEADER_GET_DESTINATION
202 #undef ASYNC_HEADER_GET_TLABEL
203 #undef ASYNC_HEADER_GET_TCODE
204 #undef ASYNC_HEADER_GET_SOURCE
205 #undef ASYNC_HEADER_GET_OFFSET
206 #undef ASYNC_HEADER_GET_RCODE
207 
208 TRACE_EVENT(async_phy_outbound_initiate,
209 	TP_PROTO(u64 packet, unsigned int generation, u32 first_quadlet, u32 second_quadlet),
210 	TP_ARGS(packet, generation, first_quadlet, second_quadlet),
211 	TP_STRUCT__entry(
212 		__field(u64, packet)
213 		__field(u8, generation)
214 		__field(u32, first_quadlet)
215 		__field(u32, second_quadlet)
216 	),
217 	TP_fast_assign(
218 		__entry->packet = packet;
219 		__entry->generation = generation;
220 		__entry->first_quadlet = first_quadlet;
221 		__entry->second_quadlet = second_quadlet
222 	),
223 	TP_printk(
224 		"packet=0x%llx generation=%u first_quadlet=0x%08x second_quadlet=0x%08x",
225 		__entry->packet,
226 		__entry->generation,
227 		__entry->first_quadlet,
228 		__entry->second_quadlet
229 	)
230 );
231 
232 TRACE_EVENT(async_phy_outbound_complete,
233 	TP_PROTO(u64 packet, unsigned int generation, unsigned int status, unsigned int timestamp),
234 	TP_ARGS(packet, generation, status, timestamp),
235 	TP_STRUCT__entry(
236 		__field(u64, packet)
237 		__field(u8, generation)
238 		__field(u8, status)
239 		__field(u16, timestamp)
240 	),
241 	TP_fast_assign(
242 		__entry->packet = packet;
243 		__entry->generation = generation;
244 		__entry->status = status;
245 		__entry->timestamp = timestamp;
246 	),
247 	TP_printk(
248 		"packet=0x%llx generation=%u status=%u timestamp=0x%04x",
249 		__entry->packet,
250 		__entry->generation,
251 		__entry->status,
252 		__entry->timestamp
253 	)
254 );
255 
256 TRACE_EVENT(async_phy_inbound,
257 	TP_PROTO(u64 packet, unsigned int generation, unsigned int status, unsigned int timestamp, u32 first_quadlet, u32 second_quadlet),
258 	TP_ARGS(packet, generation, status, timestamp, first_quadlet, second_quadlet),
259 	TP_STRUCT__entry(
260 		__field(u64, packet)
261 		__field(u8, generation)
262 		__field(u8, status)
263 		__field(u16, timestamp)
264 		__field(u32, first_quadlet)
265 		__field(u32, second_quadlet)
266 	),
267 	TP_fast_assign(
268 		__entry->packet = packet;
269 		__entry->generation = generation;
270 		__entry->status = status;
271 		__entry->timestamp = timestamp;
272 		__entry->first_quadlet = first_quadlet;
273 		__entry->second_quadlet = second_quadlet
274 	),
275 	TP_printk(
276 		"packet=0x%llx generation=%u status=%u timestamp=0x%04x first_quadlet=0x%08x second_quadlet=0x%08x",
277 		__entry->packet,
278 		__entry->generation,
279 		__entry->status,
280 		__entry->timestamp,
281 		__entry->first_quadlet,
282 		__entry->second_quadlet
283 	)
284 );
285 
286 DECLARE_EVENT_CLASS(bus_reset_arrange_template,
287 	TP_PROTO(unsigned int generation, bool short_reset),
288 	TP_ARGS(generation, short_reset),
289 	TP_STRUCT__entry(
290 		__field(u8, generation)
291 		__field(bool, short_reset)
292 	),
293 	TP_fast_assign(
294 		__entry->generation = generation;
295 		__entry->short_reset = short_reset;
296 	),
297 	TP_printk(
298 		"generation=%u short_reset=%s",
299 		__entry->generation,
300 		__entry->short_reset ? "true" : "false"
301 	)
302 );
303 
304 DEFINE_EVENT(bus_reset_arrange_template, bus_reset_initiate,
305 	TP_PROTO(unsigned int generation, bool short_reset),
306 	TP_ARGS(generation, short_reset)
307 );
308 
309 DEFINE_EVENT(bus_reset_arrange_template, bus_reset_schedule,
310 	TP_PROTO(unsigned int generation, bool short_reset),
311 	TP_ARGS(generation, short_reset)
312 );
313 
314 DEFINE_EVENT(bus_reset_arrange_template, bus_reset_postpone,
315 	TP_PROTO(unsigned int generation, bool short_reset),
316 	TP_ARGS(generation, short_reset)
317 );
318 
319 TRACE_EVENT(bus_reset_handle,
320 	TP_PROTO(unsigned int generation, unsigned int node_id, bool bm_abdicate, u32 *self_ids, unsigned int self_id_count),
321 	TP_ARGS(generation, node_id, bm_abdicate, self_ids, self_id_count),
322 	TP_STRUCT__entry(
323 		__field(u8, generation)
324 		__field(u8, node_id)
325 		__field(bool, bm_abdicate)
326 		__dynamic_array(u32, self_ids, self_id_count)
327 	),
328 	TP_fast_assign(
329 		__entry->generation = generation;
330 		__entry->node_id = node_id;
331 		__entry->bm_abdicate = bm_abdicate;
332 		memcpy(__get_dynamic_array(self_ids), self_ids, __get_dynamic_array_len(self_ids));
333 	),
334 	TP_printk(
335 		"generation=%u node_id=0x%04x bm_abdicate=%s self_ids=%s",
336 		__entry->generation,
337 		__entry->node_id,
338 		__entry->bm_abdicate ? "true" : "false",
339 		__print_array(__get_dynamic_array(self_ids),
340 			      __get_dynamic_array_len(self_ids) / QUADLET_SIZE, QUADLET_SIZE)
341 	)
342 );
343 
344 #undef QUADLET_SIZE
345 
346 #endif // _FIREWIRE_TRACE_EVENT_H
347 
348 #include <trace/define_trace.h>
349