Skip to content

Commit 1a4c53c

Browse files
committed
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/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 624a853 commit 1a4c53c

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

drivers/firewire/core-cdev.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636

3737
#include "core.h"
38+
#include <trace/events/firewire.h>
3839

3940
/*
4041
* ABI version history is documented in linux/firewire-cdev.h.
@@ -1558,6 +1559,9 @@ static void outbound_phy_packet_callback(struct fw_packet *packet,
15581559
struct client *e_client = e->client;
15591560
u32 rcode;
15601561

1562+
trace_async_phy_outbound_complete((uintptr_t)packet, status, packet->generation,
1563+
packet->timestamp);
1564+
15611565
switch (status) {
15621566
// expected:
15631567
case ACK_COMPLETE:
@@ -1655,6 +1659,9 @@ static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
16551659
memcpy(pp->data, a->data, sizeof(a->data));
16561660
}
16571661

1662+
trace_async_phy_outbound_initiate((uintptr_t)&e->p, e->p.generation, e->p.header[1],
1663+
e->p.header[2]);
1664+
16581665
card->driver->send_request(card, &e->p);
16591666

16601667
return 0;

drivers/firewire/core-transaction.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ static DECLARE_COMPLETION(phy_config_done);
463463
static void transmit_phy_packet_callback(struct fw_packet *packet,
464464
struct fw_card *card, int status)
465465
{
466+
trace_async_phy_outbound_complete((uintptr_t)packet, packet->generation, status,
467+
packet->timestamp);
466468
complete(&phy_config_done);
467469
}
468470

@@ -501,6 +503,10 @@ void fw_send_phy_config(struct fw_card *card,
501503
phy_config_packet.generation = generation;
502504
reinit_completion(&phy_config_done);
503505

506+
trace_async_phy_outbound_initiate((uintptr_t)&phy_config_packet,
507+
phy_config_packet.generation, phy_config_packet.header[1],
508+
phy_config_packet.header[2]);
509+
504510
card->driver->send_request(card, &phy_config_packet);
505511
wait_for_completion_timeout(&phy_config_done, timeout);
506512

include/trace/events/firewire.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,54 @@ DEFINE_EVENT(async_outbound_complete_template, async_response_outbound_complete,
206206
#undef ASYNC_HEADER_GET_RCODE
207207
#undef QUADLET_SIZE
208208

209+
TRACE_EVENT(async_phy_outbound_initiate,
210+
TP_PROTO(u64 packet, unsigned int generation, u32 first_quadlet, u32 second_quadlet),
211+
TP_ARGS(packet, generation, first_quadlet, second_quadlet),
212+
TP_STRUCT__entry(
213+
__field(u64, packet)
214+
__field(u8, generation)
215+
__field(u32, first_quadlet)
216+
__field(u32, second_quadlet)
217+
),
218+
TP_fast_assign(
219+
__entry->packet = packet;
220+
__entry->generation = generation;
221+
__entry->first_quadlet = first_quadlet;
222+
__entry->second_quadlet = second_quadlet
223+
),
224+
TP_printk(
225+
"packet=0x%016llx generation=%u first_quadlet=0x%08x second_quadlet=0x%08x",
226+
__entry->packet,
227+
__entry->generation,
228+
__entry->first_quadlet,
229+
__entry->second_quadlet
230+
)
231+
);
232+
233+
TRACE_EVENT(async_phy_outbound_complete,
234+
TP_PROTO(u64 packet, unsigned int generation, unsigned int status, unsigned int timestamp),
235+
TP_ARGS(packet, generation, status, timestamp),
236+
TP_STRUCT__entry(
237+
__field(u64, packet)
238+
__field(u8, generation)
239+
__field(u8, status)
240+
__field(u16, timestamp)
241+
),
242+
TP_fast_assign(
243+
__entry->packet = packet;
244+
__entry->generation = generation;
245+
__entry->status = status;
246+
__entry->timestamp = timestamp;
247+
),
248+
TP_printk(
249+
"packet=0x%016llx generation=%u status=%u timestamp=0x%04x",
250+
__entry->packet,
251+
__entry->generation,
252+
__entry->status,
253+
__entry->timestamp
254+
)
255+
);
256+
209257
#endif // _FIREWIRE_TRACE_EVENT_H
210258

211259
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)