From: Selvamani Rajagopal via B4 Relay <devnull+Selvamani.Rajagopal.onsemi.com@kernel.org>
To: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Parthiban Veerasooran <parthiban.veerasooran@microchip.com>,
Selva Rajagopal <selvamani.rajagopal@onsemi.com>,
Richard Cochran <richardcochran@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Simon Horman <horms@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Eric Dumazet <edumazet@kernel.org>,
Piergiorgio Beruto <piergiorgio.beruto@gmail.com>,
Eric Dumazet <edumazet@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
Jerry Ray <jerry.ray@microchip.com>,
Ciprian Regus <ciprian.regus@analog.com>,
Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
Subject: [PATCH net-next v12 10/15] net: ethernet: oa_tc6: APIs to customize CONFIG0 settings
Date: Tue, 24 Nov 2026 14:09:58 -0800 [thread overview]
Message-ID: <20261124-s2500-mac-phy-support-v12-10-3575855d99f9@onsemi.com> (raw)
In-Reply-To: <20261124-s2500-mac-phy-support-v12-0-3575855d99f9@onsemi.com>
From: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>
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 <Selvamani.Rajagopal@onsemi.com>
---
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 | 62 +++++++++++++++++++++++++++
drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 1 +
include/linux/oa_tc6.h | 7 +++
4 files changed, 90 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 228cc2a3dc2d..c078f22c32d6 100644
--- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
+++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
@@ -289,9 +289,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)
{
@@ -1618,6 +1638,36 @@ 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.
+ *
+ * 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.
@@ -1779,6 +1829,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 cc7cda673f1b..245a1b316395 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
next prev parent reply other threads:[~2026-11-24 22:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 22:09 [PATCH net-next v12 00/15] Support for onsemi's S2500 10BASE-T1S MAC-PHY Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 01/15] dt-bindings: net: add onsemi's S2500 Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 02/15] Documentation: networking: Add timestamp related APIs to OA TC6 framework Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 03/15] net: ethernet: oa_tc6: Move oa_tc6.c to its own directory Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 04/15] net: ethernet: oa_tc6: Move constant definitions to header file Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 05/15] net: ethernet: microchip: lan865x: Depends on PTP_1588_CLOCK_OPTIONAL Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 06/15] net: ethernet: adi: adin1140: " Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 07/15] net: ethernet: oa_tc6: Support for hardware timestamp Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 08/15] net: ethernet: oa_tc6: Drop frames if footer has FD bit set Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 09/15] net: ethernet: oa_tc6: Support for vendor specific MMS Selvamani Rajagopal via B4 Relay
2026-11-24 22:37 ` Selvamani Rajagopal
2026-11-24 22:09 ` Selvamani Rajagopal via B4 Relay [this message]
2026-11-24 22:09 ` [PATCH net-next v12 11/15] net: phy: ncn26000: Enable enhanced noise immunity Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 12/15] net: phy: Add helper to modify only the PHY loopback bit Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 13/15] net: phy: ncn26000: Support for onsemi's S2500 internal phy Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 14/15] net: phy: dp83867: Use genphy_loopback_no_speed() Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500 Selvamani Rajagopal via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124-s2500-mac-phy-support-v12-10-3575855d99f9@onsemi.com \
--to=devnull+selvamani.rajagopal.onsemi.com@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=ciprian.regus@analog.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=jerry.ray@microchip.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parthiban.veerasooran@microchip.com \
--cc=piergiorgio.beruto@gmail.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=selvamani.rajagopal@onsemi.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®