From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796233104; b=ejxyfxv6mWTvExg/VkWtDmAlfL5Zl1Dw9f2sgUNSRQwuEphakuSUiqoLfNlaxjWBEMBY rKhCPfMFlAHofRj5k+VzOZG9noTXvtOx9Eyk4FoRfLlNcII05AC1mKCv8yyRotW0fE1cd +LTdM6jgjGCMl4LXyzOaKh2XyXwpJitzXZzZ3s7hpYTcNny5aOD24LDtJcJZrj2Pnkiro wDouVubpqeObXWXLI1YHXWRemz+uYak2J9KqIo3myWUFrtE2QUV/s8EUvGRwCG91WDNXO X4IveJGV5+PnzhHPYIK7NRZNKWbQKsBlaW1mgA17G5AplZdsBXyBHdzIAGsk+0uz8Dg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796233104; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Xb+MryPic9AR1cRzOpHWZVN6Kz9eH9mt4uUME/4uG2c=; b=B2FyHCUhrIl3XsNyA1ItPXniU+rLwoipxMtwAsWaHQyzfpqdT80Z6OVYhUIF+b+wUWdO KOoLtBsdTXnytThXEl/X1Rjm2hJcw5VjFS01Kusf8ZSbCJ+3nhWBqLY+wGVfDcbr5a7e9 ESF+TYz0k+myvmttbh+6JLTZmATUnTreS9yXcyryxeO/D4Ang6gRVPYtPcY1KKxazbyu9 jBM1/p6PvwWXxT5uvgWUNhSZmB97gPvcf5cTVsFFe1jEagpD8B4tR9FKVfOLYYom9O55l YT0RLKTu3cbet90ckQ3jXh/KXFn2Cm2birPk0vMuAtnuNlohsE677KvSqOccTekde0Q== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Zve0k/VK"; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6495260A3812; Wed, 2 Dec 2026 17:38:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Zve0k/VK Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796233104; b=zWbz4BF9/lJc1Hwf5R+CfDKn7wMqW5EhlEE4SPb/km4Dw6TXuNWwTzzh26I7bGUIM+in Uak1D+pQNeg+G31rXNVfgRdOttQmdYyujJoRCK7wucyoO0XHS27DRye9vrkrf5acD0EaG rSnYYf4ytiPtFQjobRnlTBV+8bmwFShKr3kOgKYrSPMHP/UBWsTzxn/EP5HMMMmbXEBZC q67DE1+yBkqdfVlcimnnynN5keFllBozNu/DFEup53HSMiElOAzzeXUENSpdQ52YKp9Yk W/9JzCae84MRm0QpfGuVfFS8RcxJs5pQxY0vLQCw9pUxwP1jIm06z0CfAOjc5oqXulA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796233104; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=Xb+MryPic9AR1cRzOpHWZVN6Kz9eH9mt4uUME/4uG2c=; b=kMNUgQ+hCo9DFPPDA6d83Q2klphzD3tRDGycINaJu9+A0IbtJO7kDCvWeCSl32xw+2Zw xuhogQGqubWJ/nnuvdvUuyoMKBaKVrzcysEoqXgAmXtSKi+ifg8xjG4dELKdLcpaeXEzH dIzoh/VkZelMEKZvq/iwYczMQApuOXtapd1L6AJDgnYnqJDE2GrniCKUEA3sFdR3VWrn4 UsgxdtHZy9KzZ57/qltOVnqP5nbxbuiglIVdN582RjFOmDM6lh64dnpLX/ewuouYKg1No MaIft4tJ/nv56+G1JvCmyfINRp+OJ2fZSO6r+bMTTbVmPCs7m0x2ulIIeXBgFrM5Uxg== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 102CD1F00893; Wed, 2 Dec 2026 17:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796233104; bh=Xb+MryPic9AR1cRzOpHWZVN6Kz9eH9mt4uUME/4uG2c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=Zve0k/VKiM+TqHlPJToGpunljCbZS3oDyhRMI/YtgOuoxIf5+IxE3KmkLZsnQFJu/ K+F1t34se8q7f4rKPPPYJSZXvVydfzFTTj/++CR7ZggbBcZ4zC1szah72mrW3xaEeQ s41qwkkWJND0m1rLt2ClOPpJj3YLZv1UXWAHFvnUiHW9GNyPfOj/N8iWp/J65FZKpG bRCHiJ31+HpA64oAxiGLg44z/OcWJMDXmM5Uonwbycv6FvG7r9iXRWITACmAGBgzHv Hgi/TLewAyfLjPnN9N0c40HP1IlHnNUBkTuR2aKd6YpkCPz+qtDkyGW6MGCxtLnI0n DfhLh5HIfvlJg== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id EEA1D4F5AC; Wed, 2 Dec 2026 17:37:52 +0000 (UTC) From: Selvamani Rajagopal via B4 Relay Date: Wed, 02 Dec 2026 09:37:53 -0800 Subject: [PATCH net-next v13 10/15] net: ethernet: oa_tc6: APIs to customize CONFIG0 settings X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261202-s2500-mac-phy-support-v13-10-a2908fad2693@onsemi.com> References: <20261202-s2500-mac-phy-support-v13-0-a2908fad2693@onsemi.com> In-Reply-To: <20261202-s2500-mac-phy-support-v13-0-a2908fad2693@onsemi.com> To: Selva Rajagopal , Andrew Lunn , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Parthiban Veerasooran , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Eric Dumazet , Piergiorgio Beruto , Willem de Bruijn , Eric Dumazet Cc: Selva Rajagopal , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jerry Ray , Ciprian Regus X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796233066; l=8041; i=Selvamani.Rajagopal@onsemi.com; s=20260531; h=from:subject:message-id; bh=K4aMB5PMEnhFzas8zAU3unf6gGY4F4BR6SWFfiNec3o=; b=hky6bHmMzNj/ZDLAvYtJYJa0MKs+isMy2VQejDkEpFZVsLw9GrrDsYi9xpG6gh9ayiHDlKD4o HAkW2Ms+h5+AL+vfWhv8S6Jwq2BtTQ8wxSLgWrIrleePDkV3IwIjxXa X-Developer-Key: i=Selvamani.Rajagopal@onsemi.com; a=ed25519; pk=5QRdM0HS/LGWWcUZZ9hVfZ+qbPQGZCumcTXOiN7Fyug= X-Endpoint-Received: by B4 Relay for Selvamani.Rajagopal@onsemi.com/20260531 with auth_id=803 X-Original-From: Selvamani Rajagopal Reply-To: Selvamani.Rajagopal@onsemi.com Content-Transfer-Encoding: 7bit From: Selvamani Rajagopal Add oa_tc6_tx_credit_threshold_set() to let a vendor driver set the minimum transmit credits the MAC-PHY needs before it asserts the interrupt. Add the OA_TC6_CONFIG_RX_CUT_THROUGH quirk flag. When set, oa_tc6_init() enables receive cut-through before the SYNC bit is set. This can't be done after oa_tc6_init(), which sets the SYNC bit. The flag is ignored if the MAC-PHY does not report cut-through capability. Existing drivers are not affected: the default credit threshold is unchanged and cut-through stays disabled unless the quirk is set. Signed-off-by: Selvamani Rajagopal --- changes in v13 - No change changes in v12 - Moved the TX credit threshold API and the RX cut-through quirk out of the S2500 driver patch. - New patch in v12. --- Documentation/networking/oa-tc6-framework.rst | 20 +++++++++ drivers/net/ethernet/oa_tc6/oa_tc6_main.c | 65 +++++++++++++++++++++++++++ drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 1 + include/linux/oa_tc6.h | 7 +++ 4 files changed, 93 insertions(+) diff --git a/Documentation/networking/oa-tc6-framework.rst b/Documentation/networking/oa-tc6-framework.rst index 558dc25038d3..2ce95ae58923 100644 --- a/Documentation/networking/oa-tc6-framework.rst +++ b/Documentation/networking/oa-tc6-framework.rst @@ -476,6 +476,9 @@ The quirk_flags field supports: - OA_TC6_BROKEN_PHY: Leave MDIO bus registration and PHY connection to the vendor driver instead of the framework. +- OA_TC6_CONFIG_RX_CUT_THROUGH: Enable receive cut-through in the CONFIG0 + register. It is ignored if the MAC-PHY does not report cut-through + capability. A zero value for vend1_mms means no Clause 45 ``MDIO_MMD_VEND1`` mapping is requested; it does not select MMS 0. For any nonzero value @@ -519,6 +522,23 @@ Zero align receive frame feature can be enabled to align all receive ethernet frames data to start at the beginning of any receive data chunk payload with a start word offset (SWO) of zero. +.. c:function:: int oa_tc6_tx_credit_threshold_set(struct oa_tc6 *tc6, \ + u8 thresh) + +Sets the minimum number of free transmit credits that must be available +before the MAC-PHY asserts the interrupt. The default is one credit +according to OPEN Alliance 10BASE-T1x MAC-PHY Serial Interface specification. + +The thresh argument is the encoded TXCTHRESH field value of the CONFIG0 +register, not the credit count: + +- 0: one or more credits (default) +- 1: four or more credits +- 2: eight or more credits (OA_TC6_CONFIG0_TXCTHRESH_8) +- 3: sixteen or more credits + +A value above 3 does not fit the field and fails with -EINVAL. + .. c:function:: int oa_tc6_ptp_register(struct oa_tc6 *tc6, \ struct ptp_clock_info *info) diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c index e9e7b4ad3b2c..a60bdb857fa4 100644 --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c @@ -275,9 +275,29 @@ static int oa_tc6_update_standard_capability(struct oa_tc6 *tc6) return ret; if (regval & OA_TC6_STDCAP_FTSC_CAPABILITY) /* Timestamp */ tc6->ftsc_capable = true; + if (regval & OA_TC6_STDCAP_CTC_CAPABILITY) /* Cut-through */ + tc6->ctc_capable = true; return 0; } +static int oa_tc6_rx_cut_through_enable(struct oa_tc6 *tc6) +{ + u32 regval; + int ret; + + if (!tc6->ctc_capable) + return 0; + + ret = oa_tc6_read_register(tc6, OA_TC6_REG_CONFIG0, ®val); + if (ret) + return ret; + + /* Set Receive Cut-Through Enable */ + regval |= OA_TC6_CONFIG0_RXCTE; + + return oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, regval); +} + static __be32 oa_tc6_prepare_ctrl_header(u32 addr, u8 length, enum oa_tc6_register_op reg_op) { @@ -1629,6 +1649,39 @@ int oa_tc6_zero_align_receive_frame_enable(struct oa_tc6 *tc6) } EXPORT_SYMBOL_GPL(oa_tc6_zero_align_receive_frame_enable); +/** + * oa_tc6_tx_credit_threshold_set - function to set the minimum number of + * free transmit credits needed before the MAC-PHY asserts the interrupt. + * @tc6: oa_tc6 struct. + * @thresh: transmit credit threshold field value, e.g. + * OA_TC6_CONFIG0_TXCTHRESH_8. + * + * Calling from probe is recommended to avoid concurrent CONFIG0 updates + * during the read-modify-write operation. + * + * Return: 0 on success, -EINVAL if @thresh does not fit the TXCTHRESH + * field, otherwise a negative error code from the register access. + */ +int oa_tc6_tx_credit_threshold_set(struct oa_tc6 *tc6, u8 thresh) +{ + u32 regval; + int ret; + + if (thresh > OA_TC6_CONFIG0_TXCTHRESH_16) + return -EINVAL; + + ret = oa_tc6_read_register(tc6, OA_TC6_REG_CONFIG0, ®val); + if (ret) + return ret; + + /* Set Transmit Credit Threshold */ + regval &= ~OA_TC6_CONFIG0_TXCTHRESH_MASK; + regval |= FIELD_PREP(OA_TC6_CONFIG0_TXCTHRESH_MASK, thresh); + + return oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, regval); +} +EXPORT_SYMBOL_GPL(oa_tc6_tx_credit_threshold_set); + /** * oa_tc6_start_xmit - function for sending the tx skb which consists ethernet * frame. @@ -1790,6 +1843,18 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, return ERR_PTR(ret); } + /* Cut-through bits must be configured before SYNC bit is set + * in CONFIG0 register. + */ + if (tc6->quirks.quirk_flags & OA_TC6_CONFIG_RX_CUT_THROUGH) { + ret = oa_tc6_rx_cut_through_enable(tc6); + if (ret) { + dev_err(&tc6->spi->dev, + "Failed to enable RX cut-through: %d\n", ret); + return ERR_PTR(ret); + } + } + ret = oa_tc6_unmask_macphy_error_interrupts(tc6); if (ret) { dev_err(&tc6->spi->dev, diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h index cbc4fd661113..f952322c9f17 100644 --- a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h @@ -140,6 +140,7 @@ struct oa_tc6 { struct list_head ttsc_skb_list; struct ptp_clock *ptp_clock; bool ftsc_capable; /* Timestamp capability */ + bool ctc_capable; /* cut-through capability */ u64 tx_hwtstamp_pkts; u64 tx_hwtstamp_lost; u64 tx_hwtstamp_err; diff --git a/include/linux/oa_tc6.h b/include/linux/oa_tc6.h index f34ed8218a7c..35b536741d01 100644 --- a/include/linux/oa_tc6.h +++ b/include/linux/oa_tc6.h @@ -20,6 +20,7 @@ /* Standard Capabilities Register */ #define OA_TC6_REG_STDCAP 0x0002 #define OA_TC6_STDCAP_DIRECT_PHY_REG_ACCESS BIT(8) +#define OA_TC6_STDCAP_CTC_CAPABILITY BIT(7) #define OA_TC6_STDCAP_FTSC_CAPABILITY BIT(6) /* Reset Control and Status Register */ @@ -30,6 +31,10 @@ #define OA_TC6_REG_CONFIG0 0x0004 #define OA_TC6_CONFIG0_SYNC BIT(15) #define OA_TC6_CONFIG0_ZARFE_ENABLE BIT(12) +#define OA_TC6_CONFIG0_TXCTHRESH_MASK GENMASK(11, 10) +#define OA_TC6_CONFIG0_TXCTHRESH_8 2 /* 0b10: >=8 credits */ +#define OA_TC6_CONFIG0_TXCTHRESH_16 3 /* 0b11: >=16 credits */ +#define OA_TC6_CONFIG0_RXCTE BIT(8) #define OA_TC6_CONFIG0_FTSE_ENABLE BIT(7) #define OA_TC6_CONFIG0_FTSS_64BIT_TSTAMP BIT(6) #define OA_TC6_CONFIG0_PROTE BIT(5) @@ -82,6 +87,7 @@ struct oa_tc6; enum oa_tc6_quirk_flag { OA_TC6_BROKEN_PHY = BIT(0), + OA_TC6_CONFIG_RX_CUT_THROUGH = BIT(1), }; struct oa_tc6_quirks { @@ -104,6 +110,7 @@ int oa_tc6_read_registers(struct oa_tc6 *tc6, u32 address, u32 value[], u8 length); netdev_tx_t oa_tc6_start_xmit(struct oa_tc6 *tc6, struct sk_buff *skb); int oa_tc6_zero_align_receive_frame_enable(struct oa_tc6 *tc6); +int oa_tc6_tx_credit_threshold_set(struct oa_tc6 *tc6, u8 thresh); int oa_tc6_mdiobus_read_c45(struct mii_bus *bus, int addr, int devnum, int regnum); int oa_tc6_mdiobus_write_c45(struct mii_bus *bus, int addr, int devnum, -- 2.43.0