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