Skip to content

Commit 944b068

Browse files
committed
firewire: core: add tracepoints events for asynchronous outbound request
In a view of core transaction service, the asynchronous outbound request consists of two stages; initiation and completion. This commit adds a pair of event for them. The following example is for asynchronous lock request with compare_swap code to offset 0x'ffff'f000'0904 in node 0xffc0. async_request_outbound_initiate: \ transaction=0xffff955fc6a07a10 generation=5 scode=2 dst_id=0xffc0 \ tlabel=54 tcode=9 src_id=0xffc1 offset=0xfffff0000904 \ header={0xffc0d990,0xffc1ffff,0xf0000904,0x80002} data={0x80,0x940181} async_request_outbound_complete: \ transaction=0xffff955fc6a07a10 generation=5 scode=2 status=2 \ timestamp=0xd887 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 57614c2 commit 944b068

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

drivers/firewire/core-transaction.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <asm/byteorder.h>
3030

3131
#include "core.h"
32+
#include <trace/events/firewire.h>
3233
#include "packet-header-definitions.h"
3334

3435
#define HEADER_DESTINATION_IS_BROADCAST(header) \
@@ -173,6 +174,9 @@ static void transmit_complete_callback(struct fw_packet *packet,
173174
struct fw_transaction *t =
174175
container_of(packet, struct fw_transaction, packet);
175176

177+
trace_async_request_outbound_complete((uintptr_t)t, packet->generation, packet->speed,
178+
status, packet->timestamp);
179+
176180
switch (status) {
177181
case ACK_COMPLETE:
178182
close_transaction(t, card, RCODE_COMPLETE, packet->timestamp);
@@ -394,6 +398,9 @@ void __fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode
394398

395399
spin_unlock_irqrestore(&card->lock, flags);
396400

401+
trace_async_request_outbound_initiate((uintptr_t)t, generation, speed, t->packet.header, payload,
402+
tcode_is_read_request(tcode) ? 0 : length / 4);
403+
397404
card->driver->send_request(card, &t->packet);
398405
}
399406
EXPORT_SYMBOL_GPL(__fw_send_request);

include/trace/events/firewire.h

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,109 @@
77
#define _FIREWIRE_TRACE_EVENT_H
88

99
#include <linux/tracepoint.h>
10+
#include <linux/firewire.h>
1011

11-
// Placeholder for future use.
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 QUADLET_SIZE 4
34+
35+
DECLARE_EVENT_CLASS(async_outbound_initiate_template,
36+
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count),
37+
TP_ARGS(transaction, generation, scode, header, data, data_count),
38+
TP_STRUCT__entry(
39+
__field(u64, transaction)
40+
__field(u8, generation)
41+
__field(u8, scode)
42+
__array(u32, header, ASYNC_HEADER_QUADLET_COUNT)
43+
__dynamic_array(u32, data, data_count)
44+
),
45+
TP_fast_assign(
46+
__entry->transaction = transaction;
47+
__entry->generation = generation;
48+
__entry->scode = scode;
49+
memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUNT);
50+
memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data));
51+
),
52+
// This format is for the request subaction.
53+
TP_printk(
54+
"transaction=0x%llx generation=%u scode=%u dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x offset=0x%012llx header=%s data=%s",
55+
__entry->transaction,
56+
__entry->generation,
57+
__entry->scode,
58+
ASYNC_HEADER_GET_DESTINATION(__entry->header),
59+
ASYNC_HEADER_GET_TLABEL(__entry->header),
60+
ASYNC_HEADER_GET_TCODE(__entry->header),
61+
ASYNC_HEADER_GET_SOURCE(__entry->header),
62+
ASYNC_HEADER_GET_OFFSET(__entry->header),
63+
__print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE),
64+
__print_array(__get_dynamic_array(data),
65+
__get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE)
66+
)
67+
);
68+
69+
// The value of status is one of ack codes and rcodes specific to Linux FireWire subsystem.
70+
DECLARE_EVENT_CLASS(async_outbound_complete_template,
71+
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp),
72+
TP_ARGS(transaction, generation, scode, status, timestamp),
73+
TP_STRUCT__entry(
74+
__field(u64, transaction)
75+
__field(u8, generation)
76+
__field(u8, scode)
77+
__field(u8, status)
78+
__field(u16, timestamp)
79+
),
80+
TP_fast_assign(
81+
__entry->transaction = transaction;
82+
__entry->generation = generation;
83+
__entry->scode = scode;
84+
__entry->status = status;
85+
__entry->timestamp = timestamp;
86+
),
87+
TP_printk(
88+
"transaction=0x%llx generation=%u scode=%u status=%u timestamp=0x%04x",
89+
__entry->transaction,
90+
__entry->generation,
91+
__entry->scode,
92+
__entry->status,
93+
__entry->timestamp
94+
)
95+
);
96+
97+
DEFINE_EVENT(async_outbound_initiate_template, async_request_outbound_initiate,
98+
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count),
99+
TP_ARGS(transaction, generation, scode, header, data, data_count)
100+
);
101+
102+
DEFINE_EVENT(async_outbound_complete_template, async_request_outbound_complete,
103+
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp),
104+
TP_ARGS(transaction, generation, scode, status, timestamp)
105+
);
106+
107+
#undef ASYNC_HEADER_GET_DESTINATION
108+
#undef ASYNC_HEADER_GET_TLABEL
109+
#undef ASYNC_HEADER_GET_TCODE
110+
#undef ASYNC_HEADER_GET_SOURCE
111+
#undef ASYNC_HEADER_GET_OFFSET
112+
#undef QUADLET_SIZE
12113

13114
#endif // _FIREWIRE_TRACE_EVENT_H
14115

0 commit comments

Comments
 (0)