public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] Fix IET verification implementation for CPSW driver
@ 2025-11-06  9:23 Aksh Garg
  2025-11-06  9:23 ` [PATCH net 1/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout Aksh Garg
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aksh Garg @ 2025-11-06  9:23 UTC (permalink / raw)
  To: netdev, davem, kuba, pabeni, andrew+netdev, edumazet
  Cc: linux-kernel, c-vankar, s-vadapalli, danishanwar, Aksh Garg

The CPSW module supports Intersperse Express Traffic (IET) and allows
the MAC layer to verify whether the peer supports IET through its MAC
merge sublayer, by sending a verification packet and waiting for its
response until the timeout. As defined in IEEE 802.3 Clause 99, the
verification process involves up to 3 verification attempts to
establish support.

This patch series fixes issues in the implementation of this IET
verification process. 

Aksh Garg (2):
  net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout
  net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism

 drivers/net/ethernet/ti/am65-cpsw-qos.c | 51 ++++++++++++++++++-------
 1 file changed, 37 insertions(+), 14 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout
  2025-11-06  9:23 [PATCH net 0/2] Fix IET verification implementation for CPSW driver Aksh Garg
@ 2025-11-06  9:23 ` Aksh Garg
  2025-11-06  9:23 ` [PATCH net 2/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism Aksh Garg
  2025-11-11  2:10 ` [PATCH net 0/2] Fix IET verification implementation for CPSW driver patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Aksh Garg @ 2025-11-06  9:23 UTC (permalink / raw)
  To: netdev, davem, kuba, pabeni, andrew+netdev, edumazet
  Cc: linux-kernel, c-vankar, s-vadapalli, danishanwar, Aksh Garg

The CPSW module uses the MAC_VERIFY_CNT bit field in the
CPSW_PN_IET_VERIFY_REG_k register to set the verify/response timeout
count. This register specifies the number of clock cycles to wait before
resending a verify packet if the verification fails.

The verify/response timeout count, as being set by the function
am65_cpsw_iet_set_verify_timeout_count() is hardcoded for 125MHz
clock frequency, which varies based on PHY mode and link speed.

The respective clock frequencies are as follows:
- RGMII mode:
  * 1000 Mbps: 125 MHz
  * 100 Mbps: 25 MHz
  * 10 Mbps: 2.5 MHz
- QSGMII/SGMII mode: 125 MHz (all speeds)

Fix this by adding logic to calculate the correct timeout counts
based on the actual PHY interface mode and link speed.

Fixes: 49a2eb9068246 ("net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support")
Signed-off-by: Aksh Garg <a-garg7@ti.com>
---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-qos.c b/drivers/net/ethernet/ti/am65-cpsw-qos.c
index fa96db7c1a13..ff68a56796a7 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-qos.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-qos.c
@@ -276,9 +276,31 @@ static int am65_cpsw_iet_set_verify_timeout_count(struct am65_cpsw_port *port)
 	/* The number of wireside clocks contained in the verify
 	 * timeout counter. The default is 0x1312d0
 	 * (10ms at 125Mhz in 1G mode).
+	 * The frequency of the clock depends on the link speed
+	 * and the PHY interface.
 	 */
-	val = 125 * HZ_PER_MHZ;	/* assuming 125MHz wireside clock */
+	switch (port->slave.phy_if) {
+	case PHY_INTERFACE_MODE_RGMII:
+	case PHY_INTERFACE_MODE_RGMII_ID:
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+		if (port->qos.link_speed == SPEED_1000)
+			val = 125 * HZ_PER_MHZ;	/* 125 MHz at 1000Mbps*/
+		else if (port->qos.link_speed == SPEED_100)
+			val = 25 * HZ_PER_MHZ;	/* 25 MHz at 100Mbps*/
+		else
+			val = (25 * HZ_PER_MHZ) / 10;	/* 2.5 MHz at 10Mbps*/
+		break;
+
+	case PHY_INTERFACE_MODE_QSGMII:
+	case PHY_INTERFACE_MODE_SGMII:
+		val = 125 * HZ_PER_MHZ;	/* 125 MHz */
+		break;
 
+	default:
+		netdev_err(port->ndev, "selected mode does not supported IET\n");
+		return -EOPNOTSUPP;
+	}
 	val /= MILLIHZ_PER_HZ;		/* count per ms timeout */
 	val *= verify_time_ms;		/* count for timeout ms */
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism
  2025-11-06  9:23 [PATCH net 0/2] Fix IET verification implementation for CPSW driver Aksh Garg
  2025-11-06  9:23 ` [PATCH net 1/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout Aksh Garg
@ 2025-11-06  9:23 ` Aksh Garg
  2025-11-11  2:10 ` [PATCH net 0/2] Fix IET verification implementation for CPSW driver patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Aksh Garg @ 2025-11-06  9:23 UTC (permalink / raw)
  To: netdev, davem, kuba, pabeni, andrew+netdev, edumazet
  Cc: linux-kernel, c-vankar, s-vadapalli, danishanwar, Aksh Garg

The am65_cpsw_iet_verify_wait() function attempts verification 20 times,
toggling the AM65_CPSW_PN_IET_MAC_LINKFAIL bit in each iteration. When
the LINKFAIL bit transitions from 1 to 0, the MAC merge layer initiates
the verification process and waits for the timeout configured in
MAC_VERIFY_CNT before automatically retransmitting. The MAC_VERIFY_CNT
register is configured according to the user-defined verify/response
timeout in am65_cpsw_iet_set_verify_timeout_count(). As per IEEE 802.3
Clause 99, the hardware performs this automatic retry up to 3 times.

Current implementation toggles LINKFAIL after the user-configured
verify/response timeout in each iteration, forcing the hardware to
restart verification instead of respecting the MAC_VERIFY_CNT timeout.
This bypasses the hardware's automatic retry mechanism.

Fix this by moving the LINKFAIL bit toggle outside the retry loop and
reducing the retry count from 20 to 3. The software now only monitors
the status register while the hardware autonomously handles the 3
verification attempts at proper MAC_VERIFY_CNT intervals.

Fixes: 49a2eb9068246 ("net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support")
Signed-off-by: Aksh Garg <a-garg7@ti.com>
---
 drivers/net/ethernet/ti/am65-cpsw-qos.c | 27 +++++++++++++------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-qos.c b/drivers/net/ethernet/ti/am65-cpsw-qos.c
index ff68a56796a7..22530eec4953 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-qos.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-qos.c
@@ -317,20 +317,21 @@ static int am65_cpsw_iet_verify_wait(struct am65_cpsw_port *port)
 	u32 ctrl, status;
 	int try;
 
-	try = 20;
-	do {
-		/* Reset the verify state machine by writing 1
-		 * to LINKFAIL
-		 */
-		ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
-		ctrl |= AM65_CPSW_PN_IET_MAC_LINKFAIL;
-		writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	try = 3;
 
-		/* Clear MAC_LINKFAIL bit to start Verify. */
-		ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
-		ctrl &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL;
-		writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	/* Reset the verify state machine by writing 1
+	 * to LINKFAIL
+	 */
+	ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	ctrl |= AM65_CPSW_PN_IET_MAC_LINKFAIL;
+	writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
 
+	/* Clear MAC_LINKFAIL bit to start Verify. */
+	ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+	ctrl &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL;
+	writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
+
+	do {
 		msleep(port->qos.iet.verify_time_ms);
 
 		status = readl(port->port_base + AM65_CPSW_PN_REG_IET_STATUS);
@@ -352,7 +353,7 @@ static int am65_cpsw_iet_verify_wait(struct am65_cpsw_port *port)
 			netdev_dbg(port->ndev, "MAC Merge verify error\n");
 			return -ENODEV;
 		}
-	} while (try-- > 0);
+	} while (--try > 0);
 
 	netdev_dbg(port->ndev, "MAC Merge verify timeout\n");
 	return -ETIMEDOUT;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] Fix IET verification implementation for CPSW driver
  2025-11-06  9:23 [PATCH net 0/2] Fix IET verification implementation for CPSW driver Aksh Garg
  2025-11-06  9:23 ` [PATCH net 1/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout Aksh Garg
  2025-11-06  9:23 ` [PATCH net 2/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism Aksh Garg
@ 2025-11-11  2:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-11  2:10 UTC (permalink / raw)
  To: Aksh Garg
  Cc: netdev, davem, kuba, pabeni, andrew+netdev, edumazet,
	linux-kernel, c-vankar, s-vadapalli, danishanwar

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 6 Nov 2025 14:53:03 +0530 you wrote:
> The CPSW module supports Intersperse Express Traffic (IET) and allows
> the MAC layer to verify whether the peer supports IET through its MAC
> merge sublayer, by sending a verification packet and waiting for its
> response until the timeout. As defined in IEEE 802.3 Clause 99, the
> verification process involves up to 3 verification attempts to
> establish support.
> 
> [...]

Here is the summary with links:
  - [net,1/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout
    https://git.kernel.org/netdev/net/c/49b391646517
  - [net,2/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism
    https://git.kernel.org/netdev/net/c/d4b00d132d7c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-11  2:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06  9:23 [PATCH net 0/2] Fix IET verification implementation for CPSW driver Aksh Garg
2025-11-06  9:23 ` [PATCH net 1/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify/response timeout Aksh Garg
2025-11-06  9:23 ` [PATCH net 2/2] net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism Aksh Garg
2025-11-11  2:10 ` [PATCH net 0/2] Fix IET verification implementation for CPSW driver patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox