From nobody Fri Dec 19 12:33:27 2025 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42AD6BE62 for ; Mon, 29 Apr 2024 04:32:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714365150; cv=none; b=ocuFhTi/odpAdUzdUDjbTQrLV97QjCXKOAZlGsMdcnFevTgkFkf91mESNgEZUFOA/OEVUtZWdGQbXxUY5imGoqLh3jEwudMvfo/wP7WmjjRJZqmjSif65TRkbmO60+TjnLZU16W101j9GrLt5rnkHX0Vpi3ye0kuEwLOWe66Co8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714365150; c=relaxed/simple; bh=CQy+2C2nKRJNzvpkFfrqatnLUHdid88Yiz8r9I9HVHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gdG1s62C9pyQ3ViZ6CZztLqTIYI99nCJrmMpzJ8VH5FqE1RVPirRykl5P2e9Nt1+riBaieeQ7/3kh8sUFz7CMZpeI6p8NEvSqOgd4xYNcDJxFY2qvDH4Gpfzx7TQZ7EWBM4HX96YaXHHzKIacuXGqkvAQWHXBKXNQ25j6JymEos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=K7T/dUzV; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YF2Vv2pi; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="K7T/dUzV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YF2Vv2pi" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 81EDE1380234; Mon, 29 Apr 2024 00:32:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 29 Apr 2024 00:32:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1714365147; x= 1714451547; bh=c5X9sc3Zt5b5UZQSiCbWNAlpqM0YI+asugIh/bdaOy8=; b=K 7T/dUzVMtROr4/mzKxqkI6XvlMJU+kHDJwNZIg+hQIOBIjPvE5D76H6+Gl99E/ho 6o0jV9D3VmzA/2drEE5/EmRzRsFiR+KtEOXFRjmsCrEvUcjRJtfu4Yii+kiAtTta 1Ir1zS+l2uu/8/BJC8OaQNJeG4XzezzYuQMhV5xmITyALc+GHYfDSjlJBl4upcPb q2mVMmceHAgfiPnRq8tQYdyYG5ssegsjW7j26FSS7cFYxUWTvy/iBNibCslLUJGD OcXLsep1AQEfXXVAlKyhoLwLX9w/K3FU7yEukjLMo0Y8muX9eOm7m51jRnvC3Khr AFqV/XKVz1lWecrUh+1Ow== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1714365147; x= 1714451547; bh=c5X9sc3Zt5b5UZQSiCbWNAlpqM0YI+asugIh/bdaOy8=; b=Y F2Vv2piLDRbYLY9jSgFUuoDE0WKBvkcUWUHuLKeNObK2xaLCmzgjjVsMH3sTTf6+ qOxY5CxbyIGoWMCubMMQQBV0pAMAboPwzmMXU3cJogK4oXcyD8zrFUr3OWlYPJJm wcDJm1oBvv20WZAorQ3TXyX/Zc/17W+1LA7fCEVwMM+JSd2B3Dgc0qYqB6DtZmuH t8a2zc/CjKdTxUvAizTUktNmz6w6zKd7bwPgLGBkXRvOFS6aS42vWGAgj6hmDIrc pwhLNiBrSjOnn9X0HNfwArJGrZrKS/1DMhjjzD5/UgNQb2w8HcHOQTo2pIlxDaZu ZLvgZmG75FqAQI5V1w0HQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddtledgtdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Apr 2024 00:32:26 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 3/5] firewire: core: add tracepoints event for asynchronous inbound response Date: Mon, 29 Apr 2024 13:32:16 +0900 Message-ID: <20240429043218.609398-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240429043218.609398-1-o-takashi@sakamocchi.jp> References: <20240429043218.609398-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3D0xffff955fc6a07a10 generation=3D5 scode=3D2 status=3D1 \ timestamp=3D0x0089 dst_id=3D0xffc1 tlabel=3D54 tcode=3D11 src_id=3D0xffc0= \ rcode=3D0 header=3D{0xffc1d9b0,0xffc00000,0x0,0x40002} data=3D{0x50800080} Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-transaction.c | 55 +++++++++++++++-------------- include/trace/events/firewire.h | 50 ++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 26 deletions(-) diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index c9318024386f..56510d305564 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -1011,32 +1011,10 @@ void fw_core_handle_response(struct fw_card *card, = struct fw_packet *p) source =3D async_header_get_source(p->header); rcode =3D async_header_get_rcode(p->header); =20 - spin_lock_irqsave(&card->lock, flags); - list_for_each_entry(iter, &card->transaction_list, link) { - if (iter->node_id =3D=3D source && iter->tlabel =3D=3D tlabel) { - if (!try_cancel_split_timeout(iter)) { - spin_unlock_irqrestore(&card->lock, flags); - goto timed_out; - } - list_del_init(&iter->link); - card->tlabel_mask &=3D ~(1ULL << iter->tlabel); - t =3D iter; - break; - } - } - spin_unlock_irqrestore(&card->lock, flags); - - if (!t) { - timed_out: - fw_notice(card, "unsolicited response (source %x, tlabel %x)\n", - source, tlabel); - return; - } - - /* - * FIXME: sanity check packet, is length correct, does tcodes - * and addresses match. - */ + // FIXME: sanity check packet, is length correct, does tcodes + // and addresses match to the transaction request queried later. + // + // For the tracepoints event, let us decode the header here against the c= oncern. =20 switch (tcode) { case TCODE_READ_QUADLET_RESPONSE: @@ -1062,6 +1040,31 @@ void fw_core_handle_response(struct fw_card *card, s= truct fw_packet *p) break; } =20 + spin_lock_irqsave(&card->lock, flags); + list_for_each_entry(iter, &card->transaction_list, link) { + if (iter->node_id =3D=3D source && iter->tlabel =3D=3D tlabel) { + if (!try_cancel_split_timeout(iter)) { + spin_unlock_irqrestore(&card->lock, flags); + goto timed_out; + } + list_del_init(&iter->link); + card->tlabel_mask &=3D ~(1ULL << iter->tlabel); + t =3D iter; + break; + } + } + spin_unlock_irqrestore(&card->lock, flags); + + trace_async_response_inbound((uintptr_t)t, p->generation, p->speed, p->ac= k, p->timestamp, + p->header, data, data_length / 4); + + if (!t) { + timed_out: + fw_notice(card, "unsolicited response (source %x, tlabel %x)\n", + source, tlabel); + return; + } + /* * The response handler may be executed while the request handler * is still pending. Cancel the request handler. diff --git a/include/trace/events/firewire.h b/include/trace/events/firewir= e.h index 063695874cfb..2d5f6b196a22 100644 --- a/include/trace/events/firewire.h +++ b/include/trace/events/firewire.h @@ -30,6 +30,9 @@ ((((unsigned long long)((header)[1] & ASYNC_HEADER_Q1_OFFSET_HIGH_MASK)) = >> ASYNC_HEADER_Q1_OFFSET_HIGH_SHIFT) << 32)| \ (header)[2] =20 +#define ASYNC_HEADER_GET_RCODE(header) \ + (((header)[1] & ASYNC_HEADER_Q1_RCODE_MASK) >> ASYNC_HEADER_Q1_RCODE_SHIF= T) + #define QUADLET_SIZE 4 =20 DECLARE_EVENT_CLASS(async_outbound_initiate_template, @@ -94,6 +97,47 @@ DECLARE_EVENT_CLASS(async_outbound_complete_template, ) ); =20 +// The value of status is one of ack codes and rcodes specific to Linux Fi= reWire subsystem. +DECLARE_EVENT_CLASS(async_inbound_template, + TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, un= signed int status, unsigned int timestamp, const u32 *header, const u32 *da= ta, unsigned int data_count), + TP_ARGS(transaction, generation, scode, status, timestamp, header, data, = data_count), + TP_STRUCT__entry( + __field(u64, transaction) + __field(u8, generation) + __field(u8, scode) + __field(u8, status) + __field(u8, timestamp) + __array(u32, header, ASYNC_HEADER_QUADLET_COUNT) + __dynamic_array(u32, data, data_count) + ), + TP_fast_assign( + __entry->transaction =3D transaction; + __entry->generation =3D generation; + __entry->scode =3D scode; + __entry->status =3D status; + __entry->timestamp =3D timestamp; + memcpy(__entry->header, header, QUADLET_SIZE * ASYNC_HEADER_QUADLET_COUN= T); + memcpy(__get_dynamic_array(data), data, __get_dynamic_array_len(data)); + ), + // This format is for the response subaction. + TP_printk( + "transaction=3D0x%llx generation=3D%u scode=3D%u status=3D%u timestamp= =3D0x%04x dst_id=3D0x%04x tlabel=3D%u tcode=3D%u src_id=3D0x%04x rcode=3D%u= header=3D%s data=3D%s", + __entry->transaction, + __entry->generation, + __entry->scode, + __entry->status, + __entry->timestamp, + ASYNC_HEADER_GET_DESTINATION(__entry->header), + ASYNC_HEADER_GET_TLABEL(__entry->header), + ASYNC_HEADER_GET_TCODE(__entry->header), + ASYNC_HEADER_GET_SOURCE(__entry->header), + ASYNC_HEADER_GET_RCODE(__entry->header), + __print_array(__entry->header, ASYNC_HEADER_QUADLET_COUNT, QUADLET_SIZE), + __print_array(__get_dynamic_array(data), + __get_dynamic_array_len(data) / QUADLET_SIZE, QUADLET_SIZE) + ) +); + DEFINE_EVENT(async_outbound_initiate_template, async_request_outbound_init= iate, TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, co= nst u32 *header, const u32 *data, unsigned int data_count), TP_ARGS(transaction, generation, scode, header, data, data_count) @@ -104,11 +148,17 @@ DEFINE_EVENT(async_outbound_complete_template, async_= request_outbound_complete, TP_ARGS(transaction, generation, scode, status, timestamp) ); =20 +DEFINE_EVENT(async_inbound_template, async_response_inbound, + TP_PROTO(u64 transaction, unsigned int generation, unsigned int scode, un= signed int status, unsigned int timestamp, const u32 *header, const u32 *da= ta, unsigned int data_count), + TP_ARGS(transaction, generation, scode, status, timestamp, header, data, = data_count) +); + #undef ASYNC_HEADER_GET_DESTINATION #undef ASYNC_HEADER_GET_TLABEL #undef ASYNC_HEADER_GET_TCODE #undef ASYNC_HEADER_GET_SOURCE #undef ASYNC_HEADER_GET_OFFSET +#undef ASYNC_HEADER_GET_RCODE #undef QUADLET_SIZE =20 #endif // _FIREWIRE_TRACE_EVENT_H --=20 2.43.0