From nobody Tue Feb 10 14:31:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E56C7EE2C for ; Thu, 25 May 2023 10:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241002AbjEYKS3 (ORCPT ); Thu, 25 May 2023 06:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240760AbjEYKRp (ORCPT ); Thu, 25 May 2023 06:17:45 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95363E51 for ; Thu, 25 May 2023 03:16:46 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 11DCA5C0073; Thu, 25 May 2023 06:16:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 25 May 2023 06:16:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1685009806; x= 1685096206; bh=CwMQ3mRgLz5XKiLhS8Bwc8Qm3NwjUti4uZQkCUexV3s=; b=X 6ADm6VmVdvfMbXrcDmvKQF75wkZM1Y9gmHEjaOdUk0zeZ7sXuBp4j+V7/qjWut30 ULMvUTP/Yx3X5oh2AZn98pzXFuAzqq2WzHMjZI5629/Z/XCq6+6igd1piOgHsImS LKAfrTkk9c3yiWoKGKMHwRF0XlsB49wOnlXZ+cg2cig5zyqbYxbPHh9E9w7U8p6V C8Ckk+WJue2suAlhCNn48uG2PRRajJGu8imzvuw79irtIgaJpNJmEmuCCQVZArvP 1sr8eYZhOo6yrMF9cxrlzBKvqWlsudQ793uzKlZ6Y4w4fek4D72iYySDQIljLsWU o1Wkj6O1qtU8KuLVcLr8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1685009806; x=1685096206; bh=C wMQ3mRgLz5XKiLhS8Bwc8Qm3NwjUti4uZQkCUexV3s=; b=DY+SVeD85NeZ9wveQ L5SDs4ppqzV8x53QxsZi23SPlWTe084qAu/tQQR8oGjkDPjbODW8F+NHxACAW0zB z0Ns7A5m1wewrclY7Do388+MQzbFCmhwp/uau9uX5UpgD2EFbNzJ3dAhOLrnkeNW 15j48ZbOwImtewdA1hhFe2N8WRf99w4nViz+kWfaghIuRE0kxKcVMzoQVqShd8zs zGYIs9u/pNPd+e9V+m5kbZSU8YHxWOXMoOR67u1J1eh7kWK6H1D6gVVB6QS5jaT7 CHz74ZsgcYU1/zPLdqFLchuRyuBoyuUxbBfV9E+tunSG4leWiMr6Bxq0ES1v9vtl Ks+yw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecuvehluhhsthgv rhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 06:16:44 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2 12/12] firewire: cdev: implement new event relevant to phy packet with time stamp Date: Thu, 25 May 2023 19:16:25 +0900 Message-Id: <20230525101625.888906-13-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525101625.888906-1-o-takashi@sakamocchi.jp> References: <20230525101625.888906-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In 1394 OHCI, the OUTPUT_LAST descriptor of Asynchronous Transmit (AT) context has timeStamp field, in which 1394 OHCI controller record the isochronous cycle when the packet was sent for the request subaction. Additionally, the trailing quadlet of Asynchronous Receive (AR) context has timeStamp field as well in which 1394 OHCI controller record the isochronous cycle when the packet arrived. The time stamps are also available for the cases to send and receive phy packet. This commit implements new events with time stamp field for user space. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-cdev.c | 90 +++++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 22 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 2220de3c945e..6274b86eb943 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -206,6 +206,7 @@ struct outbound_phy_packet_event { struct fw_packet p; union { struct fw_cdev_event_phy_packet without_tstamp; + struct fw_cdev_event_phy_packet2 with_tstamp; } phy_packet; }; =20 @@ -213,6 +214,7 @@ struct inbound_phy_packet_event { struct event event; union { struct fw_cdev_event_phy_packet without_tstamp; + struct fw_cdev_event_phy_packet2 with_tstamp; } phy_packet; }; =20 @@ -1555,7 +1557,6 @@ static void outbound_phy_packet_callback(struct fw_pa= cket *packet, container_of(packet, struct outbound_phy_packet_event, p); struct client *e_client =3D e->client; u32 rcode; - struct fw_cdev_event_phy_packet *pp; =20 switch (status) { // expected: @@ -1583,10 +1584,31 @@ static void outbound_phy_packet_callback(struct fw_= packet *packet, break; } =20 - pp =3D &e->phy_packet.without_tstamp; - pp->rcode =3D rcode; - pp->data[0] =3D packet->timestamp; - queue_event(e->client, &e->event, &e->phy_packet, sizeof(*pp) + pp->lengt= h, NULL, 0); + switch (e->phy_packet.without_tstamp.type) { + case FW_CDEV_EVENT_PHY_PACKET_SENT: + { + struct fw_cdev_event_phy_packet *pp =3D &e->phy_packet.without_tstamp; + + pp->rcode =3D rcode; + pp->data[0] =3D packet->timestamp; + queue_event(e->client, &e->event, &e->phy_packet, sizeof(*pp) + pp->leng= th, + NULL, 0); + break; + } + case FW_CDEV_EVENT_PHY_PACKET_SENT2: + { + struct fw_cdev_event_phy_packet2 *pp =3D &e->phy_packet.with_tstamp; + + pp->rcode =3D rcode; + pp->tstamp =3D packet->timestamp; + queue_event(e->client, &e->event, &e->phy_packet, sizeof(*pp) + pp->leng= th, + NULL, 0); + break; + } + default: + WARN_ON(1); + break; + } =20 client_put(e_client); } @@ -1596,13 +1618,12 @@ static int ioctl_send_phy_packet(struct client *cli= ent, union ioctl_arg *arg) struct fw_cdev_send_phy_packet *a =3D &arg->send_phy_packet; struct fw_card *card =3D client->device->card; struct outbound_phy_packet_event *e; - struct fw_cdev_event_phy_packet *pp; =20 /* Access policy: Allow this ioctl only on local nodes' device files. */ if (!client->device->is_local) return -ENOSYS; =20 - e =3D kzalloc(sizeof(*e) + 4, GFP_KERNEL); + e =3D kzalloc(sizeof(*e) + sizeof(a->data), GFP_KERNEL); if (e =3D=3D NULL) return -ENOMEM; =20 @@ -1616,11 +1637,23 @@ static int ioctl_send_phy_packet(struct client *cli= ent, union ioctl_arg *arg) e->p.header_length =3D 12; e->p.callback =3D outbound_phy_packet_callback; =20 - pp =3D &e->phy_packet.without_tstamp; - pp->closure =3D a->closure; - pp->type =3D FW_CDEV_EVENT_PHY_PACKET_SENT; - if (is_ping_packet(a->data)) - pp->length =3D 4; + if (client->version < FW_CDEV_VERSION_EVENT_ASYNC_TSTAMP) { + struct fw_cdev_event_phy_packet *pp =3D &e->phy_packet.without_tstamp; + + pp->closure =3D a->closure; + pp->type =3D FW_CDEV_EVENT_PHY_PACKET_SENT; + if (is_ping_packet(a->data)) + pp->length =3D 4; + } else { + struct fw_cdev_event_phy_packet2 *pp =3D &e->phy_packet.with_tstamp; + + pp->closure =3D a->closure; + pp->type =3D FW_CDEV_EVENT_PHY_PACKET_SENT2; + // Keep the data field so that application can match the response event = to the + // request. + pp->length =3D sizeof(a->data); + memcpy(pp->data, a->data, sizeof(a->data)); + } =20 card->driver->send_request(card, &e->p); =20 @@ -1655,20 +1688,33 @@ void fw_cdev_handle_phy_packet(struct fw_card *card= , struct fw_packet *p) spin_lock_irqsave(&card->lock, flags); =20 list_for_each_entry(client, &card->phy_receiver_list, phy_receiver_link) { - struct fw_cdev_event_phy_packet *pp; - e =3D kmalloc(sizeof(*e) + 8, GFP_ATOMIC); if (e =3D=3D NULL) break; =20 - pp =3D &e->phy_packet.without_tstamp; - pp->closure =3D client->phy_receiver_closure; - pp->type =3D FW_CDEV_EVENT_PHY_PACKET_RECEIVED; - pp->rcode =3D RCODE_COMPLETE; - pp->length =3D 8; - pp->data[0] =3D p->header[1]; - pp->data[1] =3D p->header[2]; - queue_event(client, &e->event, &e->phy_packet, sizeof(*pp) + 8, NULL, 0); + if (client->version < FW_CDEV_VERSION_EVENT_ASYNC_TSTAMP) { + struct fw_cdev_event_phy_packet *pp =3D &e->phy_packet.without_tstamp; + + pp->closure =3D client->phy_receiver_closure; + pp->type =3D FW_CDEV_EVENT_PHY_PACKET_RECEIVED; + pp->rcode =3D RCODE_COMPLETE; + pp->length =3D 8; + pp->data[0] =3D p->header[1]; + pp->data[1] =3D p->header[2]; + queue_event(client, &e->event, &e->phy_packet, sizeof(*pp) + 8, NULL, 0= ); + } else { + struct fw_cdev_event_phy_packet2 *pp =3D &e->phy_packet.with_tstamp; + + pp =3D &e->phy_packet.with_tstamp; + pp->closure =3D client->phy_receiver_closure; + pp->type =3D FW_CDEV_EVENT_PHY_PACKET_RECEIVED2; + pp->rcode =3D RCODE_COMPLETE; + pp->length =3D 8; + pp->tstamp =3D p->timestamp; + pp->data[0] =3D p->header[1]; + pp->data[1] =3D p->header[2]; + queue_event(client, &e->event, &e->phy_packet, sizeof(*pp) + 8, NULL, 0= ); + } } =20 spin_unlock_irqrestore(&card->lock, flags); --=20 2.39.2