firewire: core/cdev: add tracepoints events for asynchronous phy packet

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>
This commit is contained in:
Takashi Sakamoto 2024-04-30 09:14:03 +09:00
parent 624a8535f7
commit 1a4c53cf35
3 changed files with 61 additions and 0 deletions

View 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;

View 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);

View 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>