Skip to content

Commit b76889f

Browse files
Yannick Vignonkuba-moo
authored andcommitted
net: stmmac: fix taprio schedule configuration
When configuring a 802.1Qbv schedule through the tc taprio qdisc on an NXP i.MX8MPlus device, the effective cycle time differed from the requested one by N*96ns, with N number of entries in the Qbv Gate Control List. This is because the driver was adding a 96ns margin to each interval of the GCL, apparently to account for the IPG. The problem was observed on NXP i.MX8MPlus devices but likely affected all devices relying on the same configuration callback (dwmac 4.00, 4.10, 5.10 variants). Fix the issue by removing the margins, and simply setup the MAC with the provided cycle time value. This is the behavior expected by the user-space API, as altering the Qbv schedule timings would break standards conformance. This is also the behavior of several other Ethernet MAC implementations supporting taprio, including the dwxgmac variant of stmmac. Fixes: 504723a ("net: stmmac: Add basic EST support for GMAC5+") Signed-off-by: Yannick Vignon <yannick.vignon@nxp.com> Link: https://lore.kernel.org/r/20210113131557.24651-1-yannick.vignon@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2576477 commit b76889f

1 file changed

Lines changed: 4 additions & 48 deletions

File tree

  • drivers/net/ethernet/stmicro/stmmac

‎drivers/net/ethernet/stmicro/stmmac/dwmac5.c‎

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -568,68 +568,24 @@ static int dwmac5_est_write(void __iomem *ioaddr, u32 reg, u32 val, bool gcl)
568568
int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg,
569569
unsigned int ptp_rate)
570570
{
571-
u32 speed, total_offset, offset, ctrl, ctr_low;
572-
u32 extcfg = readl(ioaddr + GMAC_EXT_CONFIG);
573-
u32 mac_cfg = readl(ioaddr + GMAC_CONFIG);
574571
int i, ret = 0x0;
575-
u64 total_ctr;
576-
577-
if (extcfg & GMAC_CONFIG_EIPG_EN) {
578-
offset = (extcfg & GMAC_CONFIG_EIPG) >> GMAC_CONFIG_EIPG_SHIFT;
579-
offset = 104 + (offset * 8);
580-
} else {
581-
offset = (mac_cfg & GMAC_CONFIG_IPG) >> GMAC_CONFIG_IPG_SHIFT;
582-
offset = 96 - (offset * 8);
583-
}
584-
585-
speed = mac_cfg & (GMAC_CONFIG_PS | GMAC_CONFIG_FES);
586-
speed = speed >> GMAC_CONFIG_FES_SHIFT;
587-
588-
switch (speed) {
589-
case 0x0:
590-
offset = offset * 1000; /* 1G */
591-
break;
592-
case 0x1:
593-
offset = offset * 400; /* 2.5G */
594-
break;
595-
case 0x2:
596-
offset = offset * 100000; /* 10M */
597-
break;
598-
case 0x3:
599-
offset = offset * 10000; /* 100M */
600-
break;
601-
default:
602-
return -EINVAL;
603-
}
604-
605-
offset = offset / 1000;
572+
u32 ctrl;
606573

607574
ret |= dwmac5_est_write(ioaddr, BTR_LOW, cfg->btr[0], false);
608575
ret |= dwmac5_est_write(ioaddr, BTR_HIGH, cfg->btr[1], false);
609576
ret |= dwmac5_est_write(ioaddr, TER, cfg->ter, false);
610577
ret |= dwmac5_est_write(ioaddr, LLR, cfg->gcl_size, false);
578+
ret |= dwmac5_est_write(ioaddr, CTR_LOW, cfg->ctr[0], false);
579+
ret |= dwmac5_est_write(ioaddr, CTR_HIGH, cfg->ctr[1], false);
611580
if (ret)
612581
return ret;
613582

614-
total_offset = 0;
615583
for (i = 0; i < cfg->gcl_size; i++) {
616-
ret = dwmac5_est_write(ioaddr, i, cfg->gcl[i] + offset, true);
584+
ret = dwmac5_est_write(ioaddr, i, cfg->gcl[i], true);
617585
if (ret)
618586
return ret;
619-
620-
total_offset += offset;
621587
}
622588

623-
total_ctr = cfg->ctr[0] + cfg->ctr[1] * 1000000000ULL;
624-
total_ctr += total_offset;
625-
626-
ctr_low = do_div(total_ctr, 1000000000);
627-
628-
ret |= dwmac5_est_write(ioaddr, CTR_LOW, ctr_low, false);
629-
ret |= dwmac5_est_write(ioaddr, CTR_HIGH, total_ctr, false);
630-
if (ret)
631-
return ret;
632-
633589
ctrl = readl(ioaddr + MTL_EST_CONTROL);
634590
ctrl &= ~PTOV;
635591
ctrl |= ((1000000000 / ptp_rate) * 6) << PTOV_SHIFT;

0 commit comments

Comments
 (0)