Skip to content

Commit 06cc078

Browse files
committed
firewire: core: add tracepoints event for asynchronous inbound response
In the transaction of IEEE 1394, the node to receive the asynchronous request transfers any response packet to the requester except for the unified transaction. This commit adds an event for the inbound packet. Note that the code to decode the packet header is moved, against the note about the sanity check. The following example is for asynchronous lock response with compare_and_swap code. async_response_inbound: \ transaction=0xffff955fc6a07a10 generation=5 scode=2 status=1 \ timestamp=0x0089 dst_id=0xffc1 tlabel=54 tcode=11 src_id=0xffc0 \ rcode=0 header={0xffc1d9b0,0xffc00000,0x0,0x40002} data={0x50800080} Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 944b068 commit 06cc078

File tree

2 files changed

+79
-26
lines changed

2 files changed

+79
-26
lines changed

drivers/firewire/core-transaction.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,32 +1011,10 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
10111011
source = async_header_get_source(p->header);
10121012
rcode = async_header_get_rcode(p->header);
10131013

1014-
spin_lock_irqsave(&card->lock, flags);
1015-
list_for_each_entry(iter, &card->transaction_list, link) {
1016-
if (iter->node_id == source && iter->tlabel == tlabel) {
1017-
if (!try_cancel_split_timeout(iter)) {
1018-
spin_unlock_irqrestore(&card->lock, flags);
1019-
goto timed_out;
1020-
}
1021-
list_del_init(&iter->link);
1022-
card->tlabel_mask &= ~(1ULL << iter->tlabel);
1023-
t = iter;
1024-
break;
1025-
}
1026-
}
1027-
spin_unlock_irqrestore(&card->lock, flags);
1028-
1029-
if (!t) {
1030-
timed_out:
1031-
fw_notice(card, "unsolicited response (source %x, tlabel %x)\n",
1032-
source, tlabel);
1033-
return;
1034-
}
1035-
1036-
/*
1037-
* FIXME: sanity check packet, is length correct, does tcodes
1038-
* and addresses match.
1039-
*/
1014+
// FIXME: sanity check packet, is length correct, does tcodes
1015+
// and addresses match to the transaction request queried later.
1016+
//
1017+
// For the tracepoints event, let us decode the header here against the concern.
10401018

10411019
switch (tcode) {
10421020
case TCODE_READ_QUADLET_RESPONSE:
@@ -1062,6 +1040,31 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
10621040
break;
10631041
}
10641042

1043+
spin_lock_irqsave(&card->lock, flags);
1044+
list_for_each_entry(iter, &card->transaction_list, link) {
1045+
if (iter->node_id == source && iter->tlabel == tlabel) {
1046+
if (!try_cancel_split_timeout(iter)) {
1047+
spin_unlock_irqrestore(&card->lock, flags);
1048+
goto timed_out;
1049+
}
1050+
list_del_init(&iter->link);
1051+
card->tlabel_mask &= ~(1ULL << iter->tlabel);
1052+
t = iter;
1053+
break;
1054+
}
1055+
}
1056+
spin_unlock_irqrestore(&card->lock, flags);
1057+
1058+
trace_async_response_inbound((uintptr_t)t, p->generation, p->speed, p->ack, p->timestamp,
1059+
p->header, data, data_length / 4);
1060+
1061+
if (!t) {
1062+
timed_out:
1063+
fw_notice(card, "unsolicited response (source %x, tlabel %x)\n",
1064+
source, tlabel);
1065+
return;
1066+
}
1067+
10651068
/*
10661069
* The response handler may be executed while the request handler
10671070
* is still pending. Cancel the request handler.

include/trace/events/firewire.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
((((unsigned long long)((header)[1] & ASYNC_HEADER_Q1_OFFSET_HIGH_MASK)) >> ASYNC_HEADER_Q1_OFFSET_HIGH_SHIFT) << 32)| \
3131
(header)[2]
3232

33+
#define ASYNC_HEADER_GET_RCODE(header) \
34+
(((header)[1] & ASYNC_HEADER_Q1_RCODE_MASK) >> ASYNC_HEADER_Q1_RCODE_SHIFT)
35+
3336
#define QUADLET_SIZE 4
3437

3538
DECLARE_EVENT_CLASS(async_outbound_initiate_template,
@@ -94,6 +97,47 @@ DECLARE_EVENT_CLASS(async_outbound_complete_template,
9497
)
9598
);
9699

100+
// The value of status is one of ack codes and rcodes specific to Linux FireWire subsystem.
101+
DECLARE_EVENT_CLASS(async_inbound_template,
102+
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count),
103+
TP_ARGS(transaction, generation, scode, status, timestamp, header, data, data_count),
104+
TP_STRUCT__entry(
105+
__field(u64, transaction)
106+
__field(u8, generation)
107+
__field(u8, scode)
108+
__field(u8, status)
109+
__field(u8, timestamp)
110+
__array(u32, header, ASYNC_HEADER_QUADLET_COUNT)
111+
__dynamic_array(u32, data, data_count)
112+
),
113+
TP_fast_assign(
114+
__entry->transaction = transaction;
115+
__entry->generation = generation;
116+
__entry->scode = scode;
117+
__entry->status = status;
118+
__entry->timestamp = timestamp;
119+
memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUNT);
120+
memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data));
121+
),
122+
// This format is for the response subaction.
123+
TP_printk(
124+
"transaction=0x%llx generation=%u scode=%u status=%u timestamp=0x%04x dst_id=0x%04x tlabel=%u tcode=%u src_id=0x%04x rcode=%u header=%s data=%s",
125+
__entry->transaction,
126+
__entry->generation,
127+
__entry->scode,
128+
__entry->status,
129+
__entry->timestamp,
130+
ASYNC_HEADER_GET_DESTINATION(__entry->header),
131+
ASYNC_HEADER_GET_TLABEL(__entry->header),
132+
ASYNC_HEADER_GET_TCODE(__entry->header),
133+
ASYNC_HEADER_GET_SOURCE(__entry->header),
134+
ASYNC_HEADER_GET_RCODE(__entry->header),
135+
__print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE),
136+
__print_array(__get_dynamic_array(data),
137+
__get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE)
138+
)
139+
);
140+
97141
DEFINE_EVENT(async_outbound_initiate_template, async_request_outbound_initiate,
98142
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, const u32 *header, const u32 *data, unsigned int data_count),
99143
TP_ARGS(transaction, generation, scode, header, data, data_count)
@@ -104,11 +148,17 @@ DEFINE_EVENT(async_outbound_complete_template, async_request_outbound_complete,
104148
TP_ARGS(transaction, generation, scode, status, timestamp)
105149
);
106150

151+
DEFINE_EVENT(async_inbound_template, async_response_inbound,
152+
TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, unsigned int status, unsigned int timestamp, const u32 *header, const u32 *data, unsigned int data_count),
153+
TP_ARGS(transaction, generation, scode, status, timestamp, header, data, data_count)
154+
);
155+
107156
#undef ASYNC_HEADER_GET_DESTINATION
108157
#undef ASYNC_HEADER_GET_TLABEL
109158
#undef ASYNC_HEADER_GET_TCODE
110159
#undef ASYNC_HEADER_GET_SOURCE
111160
#undef ASYNC_HEADER_GET_OFFSET
161+
#undef ASYNC_HEADER_GET_RCODE
112162
#undef QUADLET_SIZE
113163

114164
#endif // _FIREWIRE_TRACE_EVENT_H

0 commit comments

Comments
 (0)