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 card_index, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count), 40 TP_ARGS(transaction, card_index, generation, scode, header, data, data_count), 41 TP_STRUCT__entry( 42 __field(u64, transaction) 43 __field(u8, card_index) 44 __field(u8, generation) 45 __field(u8, scode) 46 __array(u32, header, ASYNC_HEADER_QUADLET_COUNT) 47 __dynamic_array(u32, data, data_count) 48 ), 49 TP_fast_assign( 50 __entry->transaction = transaction; 51 __entry->card_index = card_index; 52 __entry->generation = generation; 53 __entry->scode = scode; 54 memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUNT); 55 memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data)); 56 ), 57 // This format is for the request subaction. 58 TP_printk( 59 "transaction=0x%llx card_index=%u generation=%u scode=%u dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x offset=0x%012llx header=%s data=%s", 60 __entry->transaction, 61 __entry->card_index, 62 __entry->generation, 63 __entry->scode, 64 ASYNC_HEADER_GET_DESTINATION(__entry->header), 65 ASYNC_HEADER_GET_TLABEL(__entry->header), 66 ASYNC_HEADER_GET_TCODE(__entry->header), 67 ASYNC_HEADER_GET_SOURCE(__entry->header), 68 ASYNC_HEADER_GET_OFFSET(__entry->header), 69 __print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE), 70 __print_array(__get_dynamic_array(data), 71 __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE) 72 ) 73 ); 74 75 // The value of status is one of ack codes and rcodes specific to Linux FireWire subsystem. 76 DECLARE_EVENT_CLASS(async_outbound_complete_template, 77 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp), 78 TP_ARGS(transaction, card_index, generation, scode, status, timestamp), 79 TP_STRUCT__entry( 80 __field(u64, transaction) 81 __field(u8, card_index) 82 __field(u8, generation) 83 __field(u8, scode) 84 __field(u8, status) 85 __field(u16, timestamp) 86 ), 87 TP_fast_assign( 88 __entry->transaction = transaction; 89 __entry->card_index = card_index; 90 __entry->generation = generation; 91 __entry->scode = scode; 92 __entry->status = status; 93 __entry->timestamp = timestamp; 94 ), 95 TP_printk( 96 "transaction=0x%llx card_index=%u generation=%u scode=%u status=%u timestamp=0x%04x", 97 __entry->transaction, 98 __entry->card_index, 99 __entry->generation, 100 __entry->scode, 101 __entry->status, 102 __entry->timestamp 103 ) 104 ); 105 106 // The value of status is one of ack codes and rcodes specific to Linux FireWire subsystem. 107 DECLARE_EVENT_CLASS(async_inbound_template, 108 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count), 109 TP_ARGS(transaction, card_index, generation, scode, status, timestamp, header, data, data_count), 110 TP_STRUCT__entry( 111 __field(u64, transaction) 112 __field(u8, card_index) 113 __field(u8, generation) 114 __field(u8, scode) 115 __field(u8, status) 116 __field(u16, timestamp) 117 __array(u32, header, ASYNC_HEADER_QUADLET_COUNT) 118 __dynamic_array(u32, data, data_count) 119 ), 120 TP_fast_assign( 121 __entry->transaction = transaction; 122 __entry->card_index = card_index; 123 __entry->generation = generation; 124 __entry->scode = scode; 125 __entry->status = status; 126 __entry->timestamp = timestamp; 127 memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUNT); 128 memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data)); 129 ), 130 // This format is for the response subaction. 131 TP_printk( 132 "transaction=0x%llx card_index=%u 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", 133 __entry->transaction, 134 __entry->card_index, 135 __entry->generation, 136 __entry->scode, 137 __entry->status, 138 __entry->timestamp, 139 ASYNC_HEADER_GET_DESTINATION(__entry->header), 140 ASYNC_HEADER_GET_TLABEL(__entry->header), 141 ASYNC_HEADER_GET_TCODE(__entry->header), 142 ASYNC_HEADER_GET_SOURCE(__entry->header), 143 ASYNC_HEADER_GET_RCODE(__entry->header), 144 __print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE), 145 __print_array(__get_dynamic_array(data), 146 __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE) 147 ) 148 ); 149 150 DEFINE_EVENT(async_outbound_initiate_template, async_request_outbound_initiate, 151 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count), 152 TP_ARGS(transaction, card_index, generation, scode, header, data, data_count) 153 ); 154 155 DEFINE_EVENT(async_outbound_complete_template, async_request_outbound_complete, 156 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp), 157 TP_ARGS(transaction, card_index, generation, scode, status, timestamp) 158 ); 159 160 DEFINE_EVENT(async_inbound_template, async_response_inbound, 161 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count), 162 TP_ARGS(transaction, card_index, generation, scode, status, timestamp, header, data, data_count) 163 ); 164 165 DEFINE_EVENT_PRINT(async_inbound_template, async_request_inbound, 166 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count), 167 TP_ARGS(transaction, card_index, generation, scode, status, timestamp, header, data, data_count), 168 TP_printk( 169 "transaction=0x%llx card_index=%u 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", 170 __entry->transaction, 171 __entry->card_index, 172 __entry->generation, 173 __entry->scode, 174 __entry->status, 175 __entry->timestamp, 176 ASYNC_HEADER_GET_DESTINATION(__entry->header), 177 ASYNC_HEADER_GET_TLABEL(__entry->header), 178 ASYNC_HEADER_GET_TCODE(__entry->header), 179 ASYNC_HEADER_GET_SOURCE(__entry->header), 180 ASYNC_HEADER_GET_OFFSET(__entry->header), 181 __print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE), 182 __print_array(__get_dynamic_array(data), 183 __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE) 184 ) 185 ); 186 187 DEFINE_EVENT_PRINT(async_outbound_initiate_template, async_response_outbound_initiate, 188 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count), 189 TP_ARGS(transaction, card_index, generation, scode, header, data, data_count), 190 TP_printk( 191 "transaction=0x%llx card_index=%u generation=%u scode=%u dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x rcode=%u header=%s data=%s", 192 __entry->transaction, 193 __entry->card_index, 194 __entry->generation, 195 __entry->scode, 196 ASYNC_HEADER_GET_DESTINATION(__entry->header), 197 ASYNC_HEADER_GET_TLABEL(__entry->header), 198 ASYNC_HEADER_GET_TCODE(__entry->header), 199 ASYNC_HEADER_GET_SOURCE(__entry->header), 200 ASYNC_HEADER_GET_RCODE(__entry->header), 201 __print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE), 202 __print_array(__get_dynamic_array(data), 203 __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE) 204 ) 205 ); 206 207 DEFINE_EVENT(async_outbound_complete_template, async_response_outbound_complete, 208 TP_PROTO(u64 transaction, unsigned int card_index, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp), 209 TP_ARGS(transaction, card_index, generation, scode, status, timestamp) 210 ); 211 212 #undef ASYNC_HEADER_GET_DESTINATION 213 #undef ASYNC_HEADER_GET_TLABEL 214 #undef ASYNC_HEADER_GET_TCODE 215 #undef ASYNC_HEADER_GET_SOURCE 216 #undef ASYNC_HEADER_GET_OFFSET 217 #undef ASYNC_HEADER_GET_RCODE 218 219 TRACE_EVENT(async_phy_outbound_initiate, 220 TP_PROTO(u64 packet, unsigned int card_index, unsigned int generation, u32 first_quadlet, u32 second_quadlet), 221 TP_ARGS(packet, card_index, generation, first_quadlet, second_quadlet), 222 TP_STRUCT__entry( 223 __field(u64, packet) 224 __field(u8, card_index) 225 __field(u8, generation) 226 __field(u32, first_quadlet) 227 __field(u32, second_quadlet) 228 ), 229 TP_fast_assign( 230 __entry->packet = packet; 231 __entry->card_index = card_index; 232 __entry->generation = generation; 233 __entry->first_quadlet = first_quadlet; 234 __entry->second_quadlet = second_quadlet 235 ), 236 TP_printk( 237 "packet=0x%llx card_index=%u generation=%u first_quadlet=0x%08x second_quadlet=0x%08x", 238 __entry->packet, 239 __entry->card_index, 240 __entry->generation, 241 __entry->first_quadlet, 242 __entry->second_quadlet 243 ) 244 ); 245 246 TRACE_EVENT(async_phy_outbound_complete, 247 TP_PROTO(u64 packet, unsigned int card_index, unsigned int generation, unsigned int status, unsigned int timestamp), 248 TP_ARGS(packet, card_index, generation, status, timestamp), 249 TP_STRUCT__entry( 250 __field(u64, packet) 251 __field(u8, card_index) 252 __field(u8, generation) 253 __field(u8, status) 254 __field(u16, timestamp) 255 ), 256 TP_fast_assign( 257 __entry->packet = packet; 258 __entry->card_index = card_index; 259 __entry->generation = generation; 260 __entry->status = status; 261 __entry->timestamp = timestamp; 262 ), 263 TP_printk( 264 "packet=0x%llx card_index=%u generation=%u status=%u timestamp=0x%04x", 265 __entry->packet, 266 __entry->card_index, 267 __entry->generation, 268 __entry->status, 269 __entry->timestamp 270 ) 271 ); 272 273 TRACE_EVENT(async_phy_inbound, 274 TP_PROTO(u64 packet, unsigned int card_index, unsigned int generation, unsigned int status, unsigned int timestamp, u32 first_quadlet, u32 second_quadlet), 275 TP_ARGS(packet, card_index, generation, status, timestamp, first_quadlet, second_quadlet), 276 TP_STRUCT__entry( 277 __field(u64, packet) 278 __field(u8, card_index) 279 __field(u8, generation) 280 __field(u8, status) 281 __field(u16, timestamp) 282 __field(u32, first_quadlet) 283 __field(u32, second_quadlet) 284 ), 285 TP_fast_assign( 286 __entry->packet = packet; 287 __entry->generation = generation; 288 __entry->status = status; 289 __entry->timestamp = timestamp; 290 __entry->first_quadlet = first_quadlet; 291 __entry->second_quadlet = second_quadlet 292 ), 293 TP_printk( 294 "packet=0x%llx card_index=%u generation=%u status=%u timestamp=0x%04x first_quadlet=0x%08x second_quadlet=0x%08x", 295 __entry->packet, 296 __entry->card_index, 297 __entry->generation, 298 __entry->status, 299 __entry->timestamp, 300 __entry->first_quadlet, 301 __entry->second_quadlet 302 ) 303 ); 304 305 DECLARE_EVENT_CLASS(bus_reset_arrange_template, 306 TP_PROTO(unsigned int card_index, unsigned int generation, bool short_reset), 307 TP_ARGS(card_index, generation, short_reset), 308 TP_STRUCT__entry( 309 __field(u8, card_index) 310 __field(u8, generation) 311 __field(bool, short_reset) 312 ), 313 TP_fast_assign( 314 __entry->card_index = card_index; 315 __entry->generation = generation; 316 __entry->short_reset = short_reset; 317 ), 318 TP_printk( 319 "card_index=%u generation=%u short_reset=%s", 320 __entry->card_index, 321 __entry->generation, 322 __entry->short_reset ? "true" : "false" 323 ) 324 ); 325 326 DEFINE_EVENT(bus_reset_arrange_template, bus_reset_initiate, 327 TP_PROTO(unsigned int card_index, unsigned int generation, bool short_reset), 328 TP_ARGS(card_index, generation, short_reset) 329 ); 330 331 DEFINE_EVENT(bus_reset_arrange_template, bus_reset_schedule, 332 TP_PROTO(unsigned int card_index, unsigned int generation, bool short_reset), 333 TP_ARGS(card_index, generation, short_reset) 334 ); 335 336 DEFINE_EVENT(bus_reset_arrange_template, bus_reset_postpone, 337 TP_PROTO(unsigned int card_index, unsigned int generation, bool short_reset), 338 TP_ARGS(card_index, generation, short_reset) 339 ); 340 341 TRACE_EVENT(bus_reset_handle, 342 TP_PROTO(unsigned int card_index, unsigned int generation, unsigned int node_id, bool bm_abdicate, u32 *self_ids, unsigned int self_id_count), 343 TP_ARGS(card_index, generation, node_id, bm_abdicate, self_ids, self_id_count), 344 TP_STRUCT__entry( 345 __field(u8, card_index) 346 __field(u8, generation) 347 __field(u8, node_id) 348 __field(bool, bm_abdicate) 349 __dynamic_array(u32, self_ids, self_id_count) 350 ), 351 TP_fast_assign( 352 __entry->card_index = card_index; 353 __entry->generation = generation; 354 __entry->node_id = node_id; 355 __entry->bm_abdicate = bm_abdicate; 356 memcpy(__get_dynamic_array(self_ids), self_ids, __get_dynamic_array_len(self_ids)); 357 ), 358 TP_printk( 359 "card_index=%u generation=%u node_id=0x%04x bm_abdicate=%s self_ids=%s", 360 __entry->card_index, 361 __entry->generation, 362 __entry->node_id, 363 __entry->bm_abdicate ? "true" : "false", 364 __print_array(__get_dynamic_array(self_ids), 365 __get_dynamic_array_len(self_ids) / QUADLET_SIZE, QUADLET_SIZE) 366 ) 367 ); 368 369 #undef QUADLET_SIZE 370 371 #endif // _FIREWIRE_TRACE_EVENT_H 372 373 #include <trace/define_trace.h> 374