]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ethernet: ti: am65-cpsw-qos: fix IET verify retry mechanism
authorAksh Garg <a-garg7@ti.com>
Thu, 6 Nov 2025 09:23:05 +0000 (14:53 +0530)
committerJakub Kicinski <kuba@kernel.org>
Tue, 11 Nov 2025 02:00:40 +0000 (18:00 -0800)
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>
Link: https://patch.msgid.link/20251106092305.1437347-3-a-garg7@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ti/am65-cpsw-qos.c

index ad06942ce461ae2429f25a4e005e447550dc247a..66e8b224827b66464df4e2d5d682ded68e9a8f87 100644 (file)
@@ -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;