Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firewire: core: add tracepoints event for self_id_sequence

It is helpful to trace the content of self ID sequence when the core
function building bus topology.

This commit adds a tracepoints event fot the purpose. It seems not to
achieve printing variable length of array in print time without any
storage, thus the structure of event includes a superfluous array to store
the state of port. Additionally, there is no helper function to print
symbol array, thus the state of port is printed as raw value.

Link: https://lore.kernel.org/r/20240605235155.116468-12-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+79 -2
+5 -2
drivers/firewire/core-topology.c
··· 95 95 * internally consistent. On success this function returns the 96 96 * fw_node corresponding to the local card otherwise NULL. 97 97 */ 98 - static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self_id_count) 98 + static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self_id_count, 99 + unsigned int generation) 99 100 { 100 101 struct self_id_sequence_enumerator enumerator = { 101 102 .cursor = sid, ··· 140 139 } 141 140 142 141 port_capacity = self_id_sequence_get_port_capacity(quadlet_count); 142 + trace_self_id_sequence(self_id_sequence, quadlet_count, generation); 143 + 143 144 for (port_index = 0; port_index < port_capacity; ++port_index) { 144 145 port_status = self_id_sequence_get_port_status(self_id_sequence, quadlet_count, 145 146 port_index); ··· 485 482 card->bm_abdicate = bm_abdicate; 486 483 fw_schedule_bm_work(card, 0); 487 484 488 - local_node = build_tree(card, self_ids, self_id_count); 485 + local_node = build_tree(card, self_ids, self_id_count, generation); 489 486 490 487 update_topology_map(card, self_ids, self_id_count); 491 488
+15
drivers/firewire/core-trace.c
··· 2 2 // Copyright (c) 2024 Takashi Sakamoto 3 3 4 4 #include <linux/types.h> 5 + #include <linux/err.h> 5 6 #include "packet-header-definitions.h" 7 + #include "phy-packet-definitions.h" 6 8 7 9 #define CREATE_TRACE_POINTS 8 10 #include <trace/events/firewire.h> 11 + 12 + #ifdef TRACEPOINTS_ENABLED 13 + void copy_port_status(u8 *port_status, unsigned int port_capacity, 14 + const u32 *self_id_sequence, unsigned int quadlet_count) 15 + { 16 + unsigned int port_index; 17 + 18 + for (port_index = 0; port_index < port_capacity; ++port_index) { 19 + port_status[port_index] = 20 + self_id_sequence_get_port_status(self_id_sequence, quadlet_count, port_index); 21 + } 22 + } 23 + #endif
+59
include/trace/events/firewire.h
··· 366 366 ) 367 367 ); 368 368 369 + // Some macros are defined in 'drivers/firewire/phy-packet-definitions.h'. 370 + 371 + // The content of TP_printk field is preprocessed, then put to the module binary. 372 + 373 + #define PHY_PACKET_SELF_ID_GET_PHY_ID(quads) \ 374 + ((((const u32 *)quads)[0] & SELF_ID_PHY_ID_MASK) >> SELF_ID_PHY_ID_SHIFT) 375 + 376 + #define PHY_PACKET_SELF_ID_GET_LINK_ACTIVE(quads) \ 377 + ((((const u32 *)quads)[0] & SELF_ID_ZERO_LINK_ACTIVE_MASK) >> SELF_ID_ZERO_LINK_ACTIVE_SHIFT) 378 + 379 + #define PHY_PACKET_SELF_ID_GET_GAP_COUNT(quads) \ 380 + ((((const u32 *)quads)[0] & SELF_ID_ZERO_GAP_COUNT_MASK) >> SELF_ID_ZERO_GAP_COUNT_SHIFT) 381 + 382 + #define PHY_PACKET_SELF_ID_GET_SCODE(quads) \ 383 + ((((const u32 *)quads)[0] & SELF_ID_ZERO_SCODE_MASK) >> SELF_ID_ZERO_SCODE_SHIFT) 384 + 385 + #define PHY_PACKET_SELF_ID_GET_CONTENDER(quads) \ 386 + ((((const u32 *)quads)[0] & SELF_ID_ZERO_CONTENDER_MASK) >> SELF_ID_ZERO_CONTENDER_SHIFT) 387 + 388 + #define PHY_PACKET_SELF_ID_GET_POWER_CLASS(quads) \ 389 + ((((const u32 *)quads)[0] & SELF_ID_ZERO_POWER_CLASS_MASK) >> SELF_ID_ZERO_POWER_CLASS_SHIFT) 390 + 391 + #define PHY_PACKET_SELF_ID_GET_INITIATED_RESET(quads) \ 392 + ((((const u32 *)quads)[0] & SELF_ID_ZERO_INITIATED_RESET_MASK) >> SELF_ID_ZERO_INITIATED_RESET_SHIFT) 393 + 394 + void copy_port_status(u8 *port_status, unsigned int port_capacity, const u32 *self_id_sequence, 395 + unsigned int quadlet_count); 396 + 397 + TRACE_EVENT(self_id_sequence, 398 + TP_PROTO(const u32 *self_id_sequence, unsigned int quadlet_count, unsigned int generation), 399 + TP_ARGS(self_id_sequence, quadlet_count, generation), 400 + TP_STRUCT__entry( 401 + __field(u8, generation) 402 + __dynamic_array(u8, port_status, self_id_sequence_get_port_capacity(quadlet_count)) 403 + __dynamic_array(u32, self_id_sequence, quadlet_count) 404 + ), 405 + TP_fast_assign( 406 + __entry->generation = generation; 407 + copy_port_status(__get_dynamic_array(port_status), __get_dynamic_array_len(port_status), 408 + self_id_sequence, quadlet_count); 409 + memcpy(__get_dynamic_array(self_id_sequence), self_id_sequence, 410 + __get_dynamic_array_len(self_id_sequence)); 411 + ), 412 + TP_printk( 413 + "generation=%u phy_id=0x%02x link_active=%s gap_count=%u scode=%u contender=%s power_class=%u initiated_reset=%s port_status=%s self_id_sequence=%s", 414 + __entry->generation, 415 + PHY_PACKET_SELF_ID_GET_PHY_ID(__get_dynamic_array(self_id_sequence)), 416 + PHY_PACKET_SELF_ID_GET_LINK_ACTIVE(__get_dynamic_array(self_id_sequence)) ? "true" : "false", 417 + PHY_PACKET_SELF_ID_GET_GAP_COUNT(__get_dynamic_array(self_id_sequence)), 418 + PHY_PACKET_SELF_ID_GET_SCODE(__get_dynamic_array(self_id_sequence)), 419 + PHY_PACKET_SELF_ID_GET_CONTENDER(__get_dynamic_array(self_id_sequence)) ? "true" : "false", 420 + PHY_PACKET_SELF_ID_GET_POWER_CLASS(__get_dynamic_array(self_id_sequence)), 421 + PHY_PACKET_SELF_ID_GET_INITIATED_RESET(__get_dynamic_array(self_id_sequence)) ? "true" : "false", 422 + __print_array(__get_dynamic_array(port_status), __get_dynamic_array_len(port_status), 1), 423 + __print_array(__get_dynamic_array(self_id_sequence), 424 + __get_dynamic_array_len(self_id_sequence) / QUADLET_SIZE, QUADLET_SIZE) 425 + ) 426 + ); 427 + 369 428 #undef QUADLET_SIZE 370 429 371 430 #endif // _FIREWIRE_TRACE_EVENT_H