Skip to content

Commit 142b02c

Browse files
committed
Merge branch 'fix-iet-verification-implementation-for-cpsw-driver'
Aksh Garg says: ==================== Fix IET verification implementation for CPSW driver 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. ==================== Link: https://patch.msgid.link/20251106092305.1437347-1-a-garg7@ti.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 3072f00 + d4b00d1 commit 142b02c

1 file changed

Lines changed: 37 additions & 14 deletions

File tree

drivers/net/ethernet/ti/am65-cpsw-qos.c

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,31 @@ static int am65_cpsw_iet_set_verify_timeout_count(struct am65_cpsw_port *port)
276276
/* The number of wireside clocks contained in the verify
277277
* timeout counter. The default is 0x1312d0
278278
* (10ms at 125Mhz in 1G mode).
279+
* The frequency of the clock depends on the link speed
280+
* and the PHY interface.
279281
*/
280-
val = 125 * HZ_PER_MHZ; /* assuming 125MHz wireside clock */
282+
switch (port->slave.phy_if) {
283+
case PHY_INTERFACE_MODE_RGMII:
284+
case PHY_INTERFACE_MODE_RGMII_ID:
285+
case PHY_INTERFACE_MODE_RGMII_RXID:
286+
case PHY_INTERFACE_MODE_RGMII_TXID:
287+
if (port->qos.link_speed == SPEED_1000)
288+
val = 125 * HZ_PER_MHZ; /* 125 MHz at 1000Mbps*/
289+
else if (port->qos.link_speed == SPEED_100)
290+
val = 25 * HZ_PER_MHZ; /* 25 MHz at 100Mbps*/
291+
else
292+
val = (25 * HZ_PER_MHZ) / 10; /* 2.5 MHz at 10Mbps*/
293+
break;
294+
295+
case PHY_INTERFACE_MODE_QSGMII:
296+
case PHY_INTERFACE_MODE_SGMII:
297+
val = 125 * HZ_PER_MHZ; /* 125 MHz */
298+
break;
281299

300+
default:
301+
netdev_err(port->ndev, "selected mode does not supported IET\n");
302+
return -EOPNOTSUPP;
303+
}
282304
val /= MILLIHZ_PER_HZ; /* count per ms timeout */
283305
val *= verify_time_ms; /* count for timeout ms */
284306

@@ -295,20 +317,21 @@ static int am65_cpsw_iet_verify_wait(struct am65_cpsw_port *port)
295317
u32 ctrl, status;
296318
int try;
297319

298-
try = 20;
299-
do {
300-
/* Reset the verify state machine by writing 1
301-
* to LINKFAIL
302-
*/
303-
ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
304-
ctrl |= AM65_CPSW_PN_IET_MAC_LINKFAIL;
305-
writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
320+
try = 3;
306321

307-
/* Clear MAC_LINKFAIL bit to start Verify. */
308-
ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
309-
ctrl &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL;
310-
writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
322+
/* Reset the verify state machine by writing 1
323+
* to LINKFAIL
324+
*/
325+
ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
326+
ctrl |= AM65_CPSW_PN_IET_MAC_LINKFAIL;
327+
writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
311328

329+
/* Clear MAC_LINKFAIL bit to start Verify. */
330+
ctrl = readl(port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
331+
ctrl &= ~AM65_CPSW_PN_IET_MAC_LINKFAIL;
332+
writel(ctrl, port->port_base + AM65_CPSW_PN_REG_IET_CTRL);
333+
334+
do {
312335
msleep(port->qos.iet.verify_time_ms);
313336

314337
status = readl(port->port_base + AM65_CPSW_PN_REG_IET_STATUS);
@@ -330,7 +353,7 @@ static int am65_cpsw_iet_verify_wait(struct am65_cpsw_port *port)
330353
netdev_dbg(port->ndev, "MAC Merge verify error\n");
331354
return -ENODEV;
332355
}
333-
} while (try-- > 0);
356+
} while (--try > 0);
334357

335358
netdev_dbg(port->ndev, "MAC Merge verify timeout\n");
336359
return -ETIMEDOUT;

0 commit comments

Comments
 (0)