[RFC PATCH 12/13] firewire: core: add tracepoint event for asynchronous inbound request

From: Takashi Sakamoto
Date: Thu Apr 18 2024 - 05:25:36 EST


This commit adds an event for asynchronous inbound request.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/core-transaction.c | 8 ++++-
drivers/firewire/trace.h | 54 +++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 977d8a36f969..1b972e95fe36 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -972,11 +972,13 @@ void fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
{
struct fw_request *request;
unsigned long long offset;
+ unsigned int tcode;

if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE)
return;

- if (tcode_is_link_internal(async_header_get_tcode(p->header))) {
+ tcode = async_header_get_tcode(p->header);
+ if (tcode_is_link_internal(tcode)) {
fw_cdev_handle_phy_packet(card, p);
return;
}
@@ -987,6 +989,10 @@ void fw_core_handle_request(struct fw_card *card, struct fw_packet *p)
return;
}

+ trace_async_request_inbound(card, request, p->ack, p->speed, p->timestamp, p->generation,
+ p->header, request->data,
+ tcode_is_read_request(tcode) ? 0 : request->length / 4);
+
offset = async_header_get_offset(p->header);

if (!is_in_fcp_region(offset, request->length))
diff --git a/drivers/firewire/trace.h b/drivers/firewire/trace.h
index 5187f5f2b140..ba09eb720933 100644
--- a/drivers/firewire/trace.h
+++ b/drivers/firewire/trace.h
@@ -136,6 +136,60 @@ TRACE_EVENT(async_response_inbound,
)
)

+TRACE_EVENT(async_request_inbound,
+ TP_PROTO(const struct fw_card *card, const struct fw_request *request, unsigned int ack,
+ unsigned int scode, unsigned int timestamp, unsigned int generation,
+ const u32 *header, const u32 *data, unsigned int data_count),
+ TP_ARGS(card, request, ack, scode, timestamp, generation, header, data, data_count),
+ TP_STRUCT__entry(
+ __field(u64, transaction)
+ __field(u8, scode)
+ __field(u8, ack)
+ __field(u8, generation)
+ __field(u16, timestamp)
+ __field(u16, destination)
+ __field(u8, tlabel)
+ __field(u8, retry)
+ __field(u8, tcode)
+ __field(u8, priority)
+ __field(u16, source)
+ __field(u64, offset)
+ __dynamic_array(u32, data, data_count)
+ ),
+ TP_fast_assign(
+ __entry->transaction = (u64)request;
+ __entry->scode = scode;
+ __entry->ack = ack;
+ __entry->generation = generation;
+ __entry->timestamp = timestamp;
+ __entry->destination = async_header_get_destination(header);
+ __entry->tlabel = async_header_get_tlabel(header);
+ __entry->retry = async_header_get_retry(header);
+ __entry->tcode = async_header_get_tcode(header);
+ __entry->priority = async_header_get_priority(header);
+ __entry->source = async_header_get_source(header);
+ __entry->offset = async_header_get_offset(header);
+ memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data));
+ ),
+ TP_printk(
+ "transaction=0x%llx scode=%u ack=%u generation=%u timestamp=0x%04x dst_id=0x%04x tlabel=%u retry=%u tcode=%u priority=%u src_id=0x%04x offset=0x%012llx data=%s",
+ __entry->transaction,
+ __entry->scode,
+ __entry->ack,
+ __entry->generation,
+ __entry->timestamp,
+ __entry->destination,
+ __entry->tlabel,
+ __entry->retry,
+ __entry->tcode,
+ __entry->priority,
+ __entry->source,
+ __entry->offset,
+ __print_array(__get_dynamic_array(data),
+ __get_dynamic_array_len(data) / sizeof(u32), sizeof(u32))
+ )
+)
+
#endif // _FIREWIRE_TRACE_EVENT_H

#define TRACE_INCLUDE_PATH .
--
2.43.0