From nobody Thu Feb 12 20:31:07 2026 Received: from wfhigh4-smtp.messagingengine.com (wfhigh4-smtp.messagingengine.com [64.147.123.155]) (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 3A35B13E05C for ; Thu, 6 Jun 2024 23:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717717904; cv=none; b=h6GNOkU3PplIqC4SvIUDm/cJC6jEO2eoF/9kYwZ/Qps4q1jwunpa9G13gws9iovAWRtoRh9Q7EZdvO5H03L00s7vVK86l+mqRkZRtq4uWZ3jOmrVSf5bZWRVSsZggliyspHuMfKsV/FYBsFeD2EQSep0QN2dPcjMFB9symS2wAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717717904; c=relaxed/simple; bh=Kmj+i0v+DFwKiujBpyuW7KQ0Fg35R84W8KNYnly7maw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kiPUNYhP8oZRQl3nVsEd54DlaxyW78jNymSRWRTQhOtZZXfGG8vBxRkP4PtrGNZBOq/EBDDRMNbJU8Ffvj0SZPeBZEuFdcaFWvnbP48VOmFIDsOFnrzYTJpdLwZ270/NgG+shDnKo7vh8QdZuHU0dsHpN1aC2zA0x30fIB2E3AU= 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=fXI0rXUH; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=qwsTcpzn; arc=none smtp.client-ip=64.147.123.155 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="fXI0rXUH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qwsTcpzn" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.west.internal (Postfix) with ESMTP id 5AE0118000BA; Thu, 6 Jun 2024 19:51:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 06 Jun 2024 19:51:41 -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=fm1; t=1717717901; x= 1717804301; bh=hgIseeRWLwrqaDf1AxemlHyL2UEM6IH/z/P6IZmSF1k=; b=f XI0rXUHUHazDHTPrgaB3xJ8mqp52t2aR3/wRZ4YQjLAfr1gIlPOAxxGaDqqPDr4t dIU6rHKnBa/b9CDVzkC/ZpZwMk4RXj7zidJvSzY45T++l5TkYTvtRVQDZtYKqiOB CxFIJR/AmqwfMpd1R9Ue6uWoqgmr66sZ5qrXl9XFyO/Va1T3+BrozV8PTJ4pSzQD lC9RG3J5mLpIwQ5gbz2ibyCUaunVlWZqHPlnNdGyxAUKr5nV4hJ8P033fYDGzWZs kftG/rZiCGaPm/NsjDLh1rJmi/+uZ4Wzxm9CFuLRP8w9ctGVhnlvs3CRdqiWRzJw tZr7YyUe8Wy80FsywWHLg== 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=fm1; t=1717717901; x= 1717804301; bh=hgIseeRWLwrqaDf1AxemlHyL2UEM6IH/z/P6IZmSF1k=; b=q wsTcpznBs+woSy2dl1UTr1YDYgDDwDCoRiDa5vmXcmQf//DhrNREzsfKCttmm4Gl CKNuN1oMGx1F7TvlES3fqGdZJAeOdSrTi6ZONHBRDNOwPFqO5HNtTgenyCn0WdA3 QI2ROKm92gUH9Fq/HgWtKPJtT6isJTtS4PrcOh49WE6SF4UMHC/RSDaunb1mVGvq lBTNeALsuPfjRZNbo9HZsfOsPQphqrKDvDdtmQ4ojc7agRQaxpk+rKf7uEO5pZKb u/DvAwi9k6d+KuaAhRxgIbPtZFczfO0I4lFkjjI1NHEh2kyF2ERE8lFuR6RK915N u12tLR39gMyzXjUbSraTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelledgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Jun 2024 19:51:39 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] firewire: core: add tests for serialization/deserialization of phy config packet Date: Fri, 7 Jun 2024 08:51:32 +0900 Message-ID: <20240606235133.231543-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606235133.231543-1-o-takashi@sakamocchi.jp> References: <20240606235133.231543-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 protocol of IEEE 1394, phy configuration packet is broadcasted to the bus to configure all PHYs residing on the bus. It includes two purposes; selecting root node and optimizing gap count. This commit adds some helper function to serialize/deserialize the content of phy configuration packet, as well as some KUnit tests for it. Signed-off-by: Takashi Sakamoto --- drivers/firewire/packet-serdes-test.c | 79 +++++++++++++++++++++++ drivers/firewire/phy-packet-definitions.h | 55 ++++++++++++++++ 2 files changed, 134 insertions(+) diff --git a/drivers/firewire/packet-serdes-test.c b/drivers/firewire/packe= t-serdes-test.c index 65cfbf1baee7..35b966eec8a5 100644 --- a/drivers/firewire/packet-serdes-test.c +++ b/drivers/firewire/packet-serdes-test.c @@ -248,6 +248,29 @@ static void deserialize_phy_packet_self_id_extended(u3= 2 quadlet, unsigned int *p *has_more_packets =3D phy_packet_self_id_get_more_packets(quadlet); } =20 +static void serialize_phy_packet_phy_config(u32 *quadlet, unsigned int pac= ket_identifier, + unsigned int root_id, bool has_force_root_node, + bool has_gap_count_optimization, unsigned int gap_count) +{ + phy_packet_set_packet_identifier(quadlet, packet_identifier); + phy_packet_phy_config_set_root_id(quadlet, root_id); + phy_packet_phy_config_set_force_root_node(quadlet, has_force_root_node); + phy_packet_phy_config_set_gap_count_optimization(quadlet, has_gap_count_o= ptimization); + phy_packet_phy_config_set_gap_count(quadlet, gap_count); +} + +static void deserialize_phy_packet_phy_config(u32 quadlet, unsigned int *p= acket_identifier, + unsigned int *root_id, bool *has_force_root_node, + bool *has_gap_count_optimization, + unsigned int *gap_count) +{ + *packet_identifier =3D phy_packet_get_packet_identifier(quadlet); + *root_id =3D phy_packet_phy_config_get_root_id(quadlet); + *has_force_root_node =3D phy_packet_phy_config_get_force_root_node(quadle= t); + *has_gap_count_optimization =3D phy_packet_phy_config_get_gap_count_optim= ization(quadlet); + *gap_count =3D phy_packet_phy_config_get_gap_count(quadlet); +} + static void test_async_header_write_quadlet_request(struct kunit *test) { static const u32 expected[ASYNC_HEADER_QUADLET_COUNT] =3D { @@ -811,6 +834,60 @@ static void test_phy_packet_self_id_zero_and_one(struc= t kunit *test) KUNIT_EXPECT_MEMEQ(test, quadlets, expected, sizeof(expected)); } =20 +static void test_phy_packet_phy_config_force_root_node(struct kunit *test) +{ + const u32 expected =3D 0x02800000; + u32 quadlet =3D 0; + + unsigned int packet_identifier; + unsigned int root_id; + bool has_force_root_node; + bool has_gap_count_optimization; + unsigned int gap_count; + + deserialize_phy_packet_phy_config(expected, &packet_identifier, &root_id, + &has_force_root_node, &has_gap_count_optimization, + &gap_count); + + KUNIT_EXPECT_EQ(test, PHY_PACKET_PACKET_IDENTIFIER_PHY_CONFIG, packet_ide= ntifier); + KUNIT_EXPECT_EQ(test, 0x02, root_id); + KUNIT_EXPECT_TRUE(test, has_force_root_node); + KUNIT_EXPECT_FALSE(test, has_gap_count_optimization); + KUNIT_EXPECT_EQ(test, 0, gap_count); + + serialize_phy_packet_phy_config(&quadlet, packet_identifier, root_id, has= _force_root_node, + has_gap_count_optimization, gap_count); + + KUNIT_EXPECT_EQ(test, quadlet, expected); +} + +static void test_phy_packet_phy_config_gap_count_optimization(struct kunit= *test) +{ + const u32 expected =3D 0x034f0000; + u32 quadlet =3D 0; + + unsigned int packet_identifier; + unsigned int root_id; + bool has_force_root_node; + bool has_gap_count_optimization; + unsigned int gap_count; + + deserialize_phy_packet_phy_config(expected, &packet_identifier, &root_id, + &has_force_root_node, &has_gap_count_optimization, + &gap_count); + + KUNIT_EXPECT_EQ(test, PHY_PACKET_PACKET_IDENTIFIER_PHY_CONFIG, packet_ide= ntifier); + KUNIT_EXPECT_EQ(test, 0x03, root_id); + KUNIT_EXPECT_FALSE(test, has_force_root_node); + KUNIT_EXPECT_TRUE(test, has_gap_count_optimization); + KUNIT_EXPECT_EQ(test, 0x0f, gap_count); + + serialize_phy_packet_phy_config(&quadlet, packet_identifier, root_id, has= _force_root_node, + has_gap_count_optimization, gap_count); + + KUNIT_EXPECT_EQ(test, quadlet, expected); +} + static struct kunit_case packet_serdes_test_cases[] =3D { KUNIT_CASE(test_async_header_write_quadlet_request), KUNIT_CASE(test_async_header_write_block_request), @@ -825,6 +902,8 @@ static struct kunit_case packet_serdes_test_cases[] =3D= { KUNIT_CASE(test_phy_packet_self_id_zero_case0), KUNIT_CASE(test_phy_packet_self_id_zero_case1), KUNIT_CASE(test_phy_packet_self_id_zero_and_one), + KUNIT_CASE(test_phy_packet_phy_config_force_root_node), + KUNIT_CASE(test_phy_packet_phy_config_gap_count_optimization), {} }; =20 diff --git a/drivers/firewire/phy-packet-definitions.h b/drivers/firewire/p= hy-packet-definitions.h index 8f78494ad371..03c7c606759f 100644 --- a/drivers/firewire/phy-packet-definitions.h +++ b/drivers/firewire/phy-packet-definitions.h @@ -21,6 +21,61 @@ static inline void phy_packet_set_packet_identifier(u32 = *quadlet, unsigned int p *quadlet |=3D (packet_identifier << PACKET_IDENTIFIER_SHIFT) & PACKET_IDE= NTIFIER_MASK; } =20 +#define PHY_PACKET_PACKET_IDENTIFIER_PHY_CONFIG 0 + +#define PHY_CONFIG_ROOT_ID_MASK 0x3f000000 +#define PHY_CONFIG_ROOT_ID_SHIFT 24 +#define PHY_CONFIG_FORCE_ROOT_NODE_MASK 0x00800000 +#define PHY_CONFIG_FORCE_ROOT_NODE_SHIFT 23 +#define PHY_CONFIG_GAP_COUNT_OPTIMIZATION_MASK 0x00400000 +#define PHY_CONFIG_GAP_COUNT_OPTIMIZATION_SHIFT 22 +#define PHY_CONFIG_GAP_COUNT_MASK 0x003f0000 +#define PHY_CONFIG_GAP_COUNT_SHIFT 16 + +static inline unsigned int phy_packet_phy_config_get_root_id(u32 quadlet) +{ + return (quadlet & PHY_CONFIG_ROOT_ID_MASK) >> PHY_CONFIG_ROOT_ID_SHIFT; +} + +static inline void phy_packet_phy_config_set_root_id(u32 *quadlet, unsigne= d int root_id) +{ + *quadlet &=3D ~PHY_CONFIG_ROOT_ID_MASK; + *quadlet |=3D (root_id << PHY_CONFIG_ROOT_ID_SHIFT) & PHY_CONFIG_ROOT_ID_= MASK; +} + +static inline bool phy_packet_phy_config_get_force_root_node(u32 quadlet) +{ + return (quadlet & PHY_CONFIG_FORCE_ROOT_NODE_MASK) >> PHY_CONFIG_FORCE_RO= OT_NODE_SHIFT; +} + +static inline void phy_packet_phy_config_set_force_root_node(u32 *quadlet,= bool has_force_root_node) +{ + *quadlet &=3D ~PHY_CONFIG_FORCE_ROOT_NODE_MASK; + *quadlet |=3D (has_force_root_node << PHY_CONFIG_FORCE_ROOT_NODE_SHIFT) &= PHY_CONFIG_FORCE_ROOT_NODE_MASK; +} + +static inline bool phy_packet_phy_config_get_gap_count_optimization(u32 qu= adlet) +{ + return (quadlet & PHY_CONFIG_GAP_COUNT_OPTIMIZATION_MASK) >> PHY_CONFIG_G= AP_COUNT_OPTIMIZATION_SHIFT; +} + +static inline void phy_packet_phy_config_set_gap_count_optimization(u32 *q= uadlet, bool has_gap_count_optimization) +{ + *quadlet &=3D ~PHY_CONFIG_GAP_COUNT_OPTIMIZATION_MASK; + *quadlet |=3D (has_gap_count_optimization << PHY_CONFIG_GAP_COUNT_OPTIMIZ= ATION_SHIFT) & PHY_CONFIG_GAP_COUNT_OPTIMIZATION_MASK; +} + +static inline unsigned int phy_packet_phy_config_get_gap_count(u32 quadlet) +{ + return (quadlet & PHY_CONFIG_GAP_COUNT_MASK) >> PHY_CONFIG_GAP_COUNT_SHIF= T; +} + +static inline void phy_packet_phy_config_set_gap_count(u32 *quadlet, unsig= ned int gap_count) +{ + *quadlet &=3D ~PHY_CONFIG_GAP_COUNT_MASK; + *quadlet |=3D (gap_count << PHY_CONFIG_GAP_COUNT_SHIFT) & PHY_CONFIG_GAP_= COUNT_MASK; +} + #define PHY_PACKET_PACKET_IDENTIFIER_SELF_ID 2 =20 #define SELF_ID_PHY_ID_MASK 0x3f000000 --=20 2.43.0 From nobody Thu Feb 12 20:31:07 2026 Received: from wfout1-smtp.messagingengine.com (wfout1-smtp.messagingengine.com [64.147.123.144]) (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 7CF7C140368 for ; Thu, 6 Jun 2024 23:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717717906; cv=none; b=VNH/G3+XTx1wQsIeih89ozooAlENLMZ2TWFiqenFzLKpeGFYcoM0USgqI6L0DCeW9m3lQhRAxH2S+RQ4Sg3Km0kB8GZT7ykVIOBCZEHi+joljSDrzILpq2dah80eIGv/5Q5RbvXVXVPMAWwTQVSUiSntTqmOxanRYdxwUprFiQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717717906; c=relaxed/simple; bh=6wRulUaHbNwcxXaYzornt+OKK480U+ChQB+7e/cV+Tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QPQ3Mo1OySU2v6jb/KY3Zb9VKq8lx0ejWaP72gU7W33o0Dc+3/4wLnfSTOV5u9KbO+JO52EUJRuuvHtebayHZbQEWwNfdX6GgSkx6W/v+CLa6VjsJDFUqOo+7fQ90JCw+rx2Npd6zikTpb0+eMVfNaIaui4k/hHmvsnOURJB2SI= 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=YoTiKpUs; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=A6Xot6D9; arc=none smtp.client-ip=64.147.123.144 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="YoTiKpUs"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="A6Xot6D9" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id ACF691C000A6; Thu, 6 Jun 2024 19:51:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 06 Jun 2024 19:51:43 -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=fm1; t=1717717903; x= 1717804303; bh=rc+1mBnu6UDgWW1vu+fZekW80szq7fBM/FdiSLXLXbw=; b=Y oTiKpUslqABHDtoTz3Q7VWHYR/RWX1/8kV21pLQu0MDy+BYc6dgVd2ACVvIVm79K rf2r2pgNEDpF5p6lDmlXSGxduFcDT+VniWM8fDwUG018dO1MPyIb8GcjqGa6HkNK tHiBMF4SwkTuiFK+Wkfw6YbP4Va2GbqLYWAxqxONRAJ60MBzBcrAqriem4c7FTVn ZjSK63jsJU+4YLdgN7vRx4XVlnEFyDQwyZXcsjPlubUoohIhT/BsEeccxOCo5MeA 1QlGNE71Wg6PuIOnCMw87unz1qJSSSIPr33vF+IZuu1tyiRCtlygsOg3kj9I1CQA 0js2ojOotK1LwHnlJhcOg== 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=fm1; t=1717717903; x= 1717804303; bh=rc+1mBnu6UDgWW1vu+fZekW80szq7fBM/FdiSLXLXbw=; b=A 6Xot6D92xdN2RvVoe/JJR/8VnavaDrsL9u37RgPFjOf7zk+Hqce+gokzUdu57wrX x36yvGWGjCmMqh9NmZZiWneUOGJy2t7iBuc3CstjAmK0HJSiZI2rd3+hkE4FmG8n WaEfl7FgGFnFmNklHPuetiudRDnjHl1pbaCZlvcCWNgi+zstANPtWZXMawF1hnq1 WSflNS5U57lhhRA95MzNOkCooQzFrSgl5zu3gM4teeCKAVbVQ4ZGcDL5Zixm/5eD SB3PRFnXAWd5l0sD84FIancKOmvdkQyrHTIxBSdURlHafABO8PUYq6o1897y8dPh l5oVBzPeYXFEqptNHM/EA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelledgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedvjefgje euvdfguddukeelveetgfdtvefhtdfffeeigfevueetffeivdffkedvtdenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Jun 2024 19:51:41 -0400 (EDT) From: Takashi Sakamoto To: linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] firewire: core: use inline helper functions to serialize phy config packet Date: Fri, 7 Jun 2024 08:51:33 +0900 Message-ID: <20240606235133.231543-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606235133.231543-1-o-takashi@sakamocchi.jp> References: <20240606235133.231543-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" This commit uses the added helper functions to obsolete the existing implementation for phy configuration packet. Signed-off-by: Takashi Sakamoto --- drivers/firewire/core-transaction.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-tr= ansaction.c index 6868ff17dc10..5b80ca9d6230 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c @@ -30,19 +30,12 @@ =20 #include "core.h" #include "packet-header-definitions.h" +#include "phy-packet-definitions.h" #include =20 #define HEADER_DESTINATION_IS_BROADCAST(header) \ ((async_header_get_destination(header) & 0x3f) =3D=3D 0x3f) =20 -#define PHY_PACKET_CONFIG 0x0 -#define PHY_PACKET_LINK_ON 0x1 -#define PHY_PACKET_SELF_ID 0x2 - -#define PHY_CONFIG_GAP_COUNT(gap_count) (((gap_count) << 16) | (1 << 22)) -#define PHY_CONFIG_ROOT_ID(node_id) ((((node_id) & 0x3f) << 24) | (1 << 23= )) -#define PHY_IDENTIFIER(id) ((id) << 30) - /* returns 0 if the split timeout handler is already running */ static int try_cancel_split_timeout(struct fw_transaction *t) { @@ -480,10 +473,14 @@ void fw_send_phy_config(struct fw_card *card, int node_id, int generation, int gap_count) { long timeout =3D DIV_ROUND_UP(HZ, 10); - u32 data =3D PHY_IDENTIFIER(PHY_PACKET_CONFIG); + u32 data =3D 0; =20 - if (node_id !=3D FW_PHY_CONFIG_NO_NODE_ID) - data |=3D PHY_CONFIG_ROOT_ID(node_id); + phy_packet_set_packet_identifier(&data, PHY_PACKET_PACKET_IDENTIFIER_PHY_= CONFIG); + + if (node_id !=3D FW_PHY_CONFIG_NO_NODE_ID) { + phy_packet_phy_config_set_root_id(&data, node_id); + phy_packet_phy_config_set_force_root_node(&data, true); + } =20 if (gap_count =3D=3D FW_PHY_CONFIG_CURRENT_GAP_COUNT) { gap_count =3D card->driver->read_phy_reg(card, 1); @@ -494,7 +491,8 @@ void fw_send_phy_config(struct fw_card *card, if (gap_count =3D=3D 63) return; } - data |=3D PHY_CONFIG_GAP_COUNT(gap_count); + phy_packet_phy_config_set_gap_count(&data, gap_count); + phy_packet_phy_config_set_gap_count_optimization(&data, true); =20 mutex_lock(&phy_config_mutex); =20 --=20 2.43.0