[RFC PATCH 13/13] firewire: core: add tracepoints events for asynchronous outbound response

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


In a view of core transaction service, the asynchronous outbound response
consists of two stages; initiation and completion.

This commit adds a pair of events for the asynchronous outbound response.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/core-transaction.c | 21 ++++++---
drivers/firewire/trace.h | 68 +++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 1b972e95fe36..c963832d9824 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -667,6 +667,8 @@ static void free_response_callback(struct fw_packet *packet,
{
struct fw_request *request = container_of(packet, struct fw_request, response);

+ trace_async_response_outbound_complete(card, request, packet);
+
// Decrease the reference count since not at in-flight.
fw_request_put(request);

@@ -849,6 +851,9 @@ static struct fw_request *allocate_request(struct fw_card *card,
void fw_send_response(struct fw_card *card,
struct fw_request *request, int rcode)
{
+ u32 *data = NULL;
+ unsigned int data_length = 0;
+
/* unified transaction or broadcast transaction: don't respond */
if (request->ack != ACK_PENDING ||
HEADER_DESTINATION_IS_BROADCAST(request->request_header)) {
@@ -856,17 +861,19 @@ void fw_send_response(struct fw_card *card,
return;
}

- if (rcode == RCODE_COMPLETE)
- fw_fill_response(&request->response, request->request_header,
- rcode, request->data,
- fw_get_response_length(request));
- else
- fw_fill_response(&request->response, request->request_header,
- rcode, NULL, 0);
+ if (rcode == RCODE_COMPLETE) {
+ data = request->data;
+ data_length = fw_get_response_length(request);
+ }
+
+ fw_fill_response(&request->response, request->request_header, rcode, data, data_length);

// Increase the reference count so that the object is kept during in-flight.
fw_request_get(request);

+ trace_async_response_outbound_initiate(card, request, &request->response, data,
+ data ? data_length / 4 : 0);
+
card->driver->send_response(card, &request->response);
}
EXPORT_SYMBOL(fw_send_response);
diff --git a/drivers/firewire/trace.h b/drivers/firewire/trace.h
index ba09eb720933..0109a70d3b02 100644
--- a/drivers/firewire/trace.h
+++ b/drivers/firewire/trace.h
@@ -190,6 +190,74 @@ TRACE_EVENT(async_request_inbound,
)
)

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

#define TRACE_INCLUDE_PATH .
--
2.43.0