firewire: core/cdev: add tracepoints events for asynchronous phy packet
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 30 Apr 2024 00:14:03 +0000 (09:14 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 6 May 2024 02:06:05 +0000 (11:06 +0900)
In IEEE 1394 bus, the type of asynchronous packet without any offset to
node address space is called as phy packet. The destination of packet is
IEEE 1394 phy itself. This type of packet is used for several purposes,
mainly for selfID at the state of bus reset, to force selection of root
node, and to adjust gap count.

This commit adds tracepoints events for the type of asynchronous outbound
packet. Like asynchronous outbound transaction packets, a pair of events
are added to trace initiation and completion of transmission.

In the case that the phy packet is sent by kernel API, the match between
the initiation and completion is not so easy, since the data of
'struct fw_packet' is allocated statically. In the case that it is sent by
userspace applications via cdev, the match is easy, since the data is
allocated per each.

This example is for Remote Access Packet by lsfirewirephy command in
linux-firewire-utils:

async_phy_outbound_initiate: \
  packet=0xffff89fb34e42e78 generation=1 first_quadlet=0x00148200 \
  second_quadlet=0xffeb7dff
async_phy_outbound_complete: \
  packet=0xffff89fb34e42e78 generation=1 status=1 timestamp=0x0619

Link: https://lore.kernel.org/r/20240430001404.734657-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-cdev.c
drivers/firewire/core-transaction.c
include/trace/events/firewire.h

index 6274b86eb943774bc9ec9b362c7ef20f7461f1dd..55993c9e0b9043da5c0bfdfb576d654ad890d4e2 100644 (file)
@@ -35,6 +35,7 @@
 
 
 #include "core.h"
+#include <trace/events/firewire.h>
 
 /*
  * ABI version history is documented in linux/firewire-cdev.h.
@@ -1558,6 +1559,9 @@ static void outbound_phy_packet_callback(struct fw_packet *packet,
        struct client *e_client = e->client;
        u32 rcode;
 
+       trace_async_phy_outbound_complete((uintptr_t)packet, status, packet->generation,
+                                         packet->timestamp);
+
        switch (status) {
        // expected:
        case ACK_COMPLETE:
@@ -1655,6 +1659,9 @@ static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
                memcpy(pp->data, a->data, sizeof(a->data));
        }
 
+       trace_async_phy_outbound_initiate((uintptr_t)&e->p, e->p.generation, e->p.header[1],
+                                         e->p.header[2]);
+
        card->driver->send_request(card, &e->p);
 
        return 0;
index 0e49ebf525002c907ae5733bff3f42d48c66370a..a828b7167d15babfbf905926e6c18cbf351af1b2 100644 (file)
@@ -463,6 +463,8 @@ static DECLARE_COMPLETION(phy_config_done);
 static void transmit_phy_packet_callback(struct fw_packet *packet,
                                         struct fw_card *card, int status)
 {
+       trace_async_phy_outbound_complete((uintptr_t)packet, packet->generation, status,
+                                         packet->timestamp);
        complete(&phy_config_done);
 }
 
@@ -501,6 +503,10 @@ void fw_send_phy_config(struct fw_card *card,
        phy_config_packet.generation = generation;
        reinit_completion(&phy_config_done);
 
+       trace_async_phy_outbound_initiate((uintptr_t)&phy_config_packet,
+                                         phy_config_packet.generation, phy_config_packet.header[1],
+                                         phy_config_packet.header[2]);
+
        card->driver->send_request(card, &phy_config_packet);
        wait_for_completion_timeout(&phy_config_done, timeout);
 
index d4688e3418376d60e1f8c2d8726530377a1452d4..3ade7d4b92686de59496f79517428373d8138705 100644 (file)
@@ -206,6 +206,54 @@ DEFINE_EVENT(async_outbound_complete_template, async_response_outbound_complete,
 #undef ASYNC_HEADER_GET_RCODE
 #undef QUADLET_SIZE
 
+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%016llx 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%016llx generation=%u status=%u timestamp=0x%04x",
+               __entry->packet,
+               __entry->generation,
+               __entry->status,
+               __entry->timestamp
+       )
+);
+
 #endif // _FIREWIRE_TRACE_EVENT_H
 
 #include <trace/define_trace.h>