public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP
@ 2026-01-20 20:30 Stefan Eichenberger
  2026-01-20 20:30 ` [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd Stefan Eichenberger
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Stefan Eichenberger @ 2026-01-20 20:30 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini
  Cc: netdev, linux-arm-kernel, imx, linux-kernel

This series adds a new phy_device flag PHY_F_KEEP_PREAMBLE_BEFORE_SFD
that allows a MAC driver to request to keep the preamble bytes before
the start frame delimiter (SFD) when receiving frames from the PHY.

This flag is set in the stmmac driver for the i.MX8MP SoC due to errata
(ERR050694), which causes it to drop frames without a preamble.

The Micrel KSZ9131 PHY supports keeping the preamble before SFD by
setting an undocumented flag, that was confirmed by NXP and Micrel. This
new feature has been added to the Micrel PHY driver for the KSZ9131 PHY.

Changes since v2:
- Instead of using phy_register_fixup add a new phy_device::dev_flags
  flag PHY_F_KEEP_PREAMBLE_BEFORE_SFD so that a MAC can request to keep
  the preamble before SFD if needed (Russell)
- Link to v2: https://lore.kernel.org/all/20260105100245.19317-1-eichest@gmail.com/

Changes since v1:
- Use phy_register_fixup_for_uid() instead of adding a new device tree
  property
- I will send the conversion of the micrel.txt binding as a separate
  patch series
- Link to v1: https://lore.kernel.org/all/20251212084657.29239-1-eichest@gmail.com/

Stefan Eichenberger (3):
  net: phy: add a new phy_device flag to keep preamble before sfd
  net: phy: micrel: add option to keep the preamble before sfd for
    KSZ9131
  net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP

 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c   |  6 +++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  8 +++++++-
 drivers/net/phy/micrel.c                          | 14 +++++++++++++-
 include/linux/phy.h                               |  5 +++--
 include/linux/stmmac.h                            |  1 +
 5 files changed, 29 insertions(+), 5 deletions(-)

-- 
2.51.0


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

* [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd
  2026-01-20 20:30 [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Stefan Eichenberger
@ 2026-01-20 20:30 ` Stefan Eichenberger
  2026-01-22 11:37   ` Paolo Abeni
  2026-01-22 13:08   ` Andrew Lunn
  2026-01-20 20:30 ` [PATCH net-next v3 2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131 Stefan Eichenberger
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Stefan Eichenberger @ 2026-01-20 20:30 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini
  Cc: netdev, linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

Add a new flag, PHY_F_KEEP_PREAMBLE_BEFORE_SFD, to indicate that the PHY
shall not remove the preamble before the SFD if it supports it. MACs
that do not support receiving frames without a preamble can set this
flag.

Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 include/linux/phy.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index fbbe028cc4b7b..a978173c0e2a1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -802,8 +802,9 @@ struct phy_device {
 };
 
 /* Generic phy_device::dev_flags */
-#define PHY_F_NO_IRQ		0x80000000
-#define PHY_F_RXC_ALWAYS_ON	0x40000000
+#define PHY_F_NO_IRQ			0x80000000
+#define PHY_F_RXC_ALWAYS_ON		0x40000000
+#define PHY_F_KEEP_PREAMBLE_BEFORE_SFD	0x20000000
 
 #define to_phy_device(__dev)	container_of_const(to_mdio_device(__dev), struct phy_device, mdio)
 
-- 
2.51.0


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

* [PATCH net-next v3 2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131
  2026-01-20 20:30 [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Stefan Eichenberger
  2026-01-20 20:30 ` [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd Stefan Eichenberger
@ 2026-01-20 20:30 ` Stefan Eichenberger
  2026-01-22 13:08   ` Andrew Lunn
  2026-01-20 20:30 ` [PATCH net-next v3 3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP Stefan Eichenberger
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Stefan Eichenberger @ 2026-01-20 20:30 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini
  Cc: netdev, linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

If the PHY_F_KEEP_PREAMBLE_BEFORE_SFD flag is set in the
phy_device::dev_flags field, the preamble will be kept before the start
frame delimiter (SFD) on the KSZ9131 PHY. This flag is not officially
documented by Micrel. However, information provided by NXP and Micrel
indicates that this flag ensures the PHY sends the full preamble instead
of removing it. The full discussion can be found on the NXP forum:
https://community.nxp.com/t5/i-MX-Processors/iMX8MP-eqos-not-working-for-10base-t/m-p/2151032

Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 drivers/net/phy/micrel.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 05de68b9f7191..a51bfe4a8d7b5 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -101,6 +101,14 @@
 #define LAN8814_CABLE_DIAG_VCT_DATA_MASK	GENMASK(7, 0)
 #define LAN8814_PAIR_BIT_SHIFT			12
 
+/* KSZ9x31 remote loopback register */
+#define KSZ9x31_REMOTE_LOOPBACK			0x11
+/* This is an undocumented bit of the KSZ9131RNX.
+ * It was reported by NXP in cooperation with Micrel.
+ */
+#define KSZ9x31_REMOTE_LOOPBACK_KEEP_PREAMBLE	BIT(2)
+#define KSZ9x31_REMOTE_LOOPBACK_EN		BIT(8)
+
 #define LAN8814_SKUS				0xB
 
 #define LAN8814_WIRE_PAIR_MASK			0xF
@@ -1500,7 +1508,11 @@ static int ksz9131_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
-	return 0;
+	if (phydev->dev_flags & PHY_F_KEEP_PREAMBLE_BEFORE_SFD)
+		ret = phy_modify(phydev, KSZ9x31_REMOTE_LOOPBACK, 0,
+				 KSZ9x31_REMOTE_LOOPBACK_KEEP_PREAMBLE);
+
+	return ret;
 }
 
 #define MII_KSZ9131_AUTO_MDIX		0x1C
-- 
2.51.0


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

* [PATCH net-next v3 3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP
  2026-01-20 20:30 [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Stefan Eichenberger
  2026-01-20 20:30 ` [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd Stefan Eichenberger
  2026-01-20 20:30 ` [PATCH net-next v3 2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131 Stefan Eichenberger
@ 2026-01-20 20:30 ` Stefan Eichenberger
  2026-01-22 13:09   ` Andrew Lunn
  2026-01-21 10:07 ` [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Maxime Chevallier
  2026-01-23  2:40 ` patchwork-bot+netdevbpf
  4 siblings, 1 reply; 11+ messages in thread
From: Stefan Eichenberger @ 2026-01-20 20:30 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini
  Cc: netdev, linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

The stmmac implementation used by NXP for the i.MX8MP SoC is subject to
errata ERR050694. According to this errata, when no preamble byte is
transferred before the SFD from the PHY to the MAC, the MAC will discard
the frame.

Setting the PHY_F_KEEP_PREAMBLE_BEFORE_SFD flag instructs PHYs that
support it to keep the preamble byte before the SFD. This ensures that
the MAC successfully receives frames.

As this is an issue in the MAC implementation, only enable the flag for
the i.MX8MP SoC where the errata applies but not for other SoCs using a
working stmmac implementation.

The exact wording of the errata ERR050694 from NXP:
The IEEE 802.3 standard states that, in MII/GMII modes, the byte
preceding the SFD (0xD5), SMD-S (0xE6,0x4C, 0x7F, or 0xB3), or SMD-C
(0x61, 0x52, 0x9E, or 0x2A) byte can be a non-PREAMBLE byte or there can
be no preceding preamble byte. The MAC receiver must successfully
receive a packet without any preamble(0x55) byte preceding the SFD,
SMD-S, or SMD-C byte.
However due to the defect, in configurations where frame preemption is
enabled, when preamble byte does not precede the SFD, SMD-S, or SMD-C
byte, the received packet is discarded by the MAC receiver. This is
because, the start-of-packet detection logic of the MAC receiver
incorrectly checks for a preamble byte.

NXP refers to IEEE 802.3 where in clause 35.2.3.2.2 Receive case (GMII)
they show two tables one where the preamble is preceding the SFD and one
where it is not. The text says:
The operation of 1000 Mb/s PHYs can result in shrinkage of the preamble
between transmission at the source GMII and reception at the destination
GMII. Table 35-3 depicts the case where no preamble bytes are conveyed
across the GMII. This case may not be possible with a specific PHY, but
illustrates the minimum preamble with which MAC shall be able to
operate. Table 35-4 depicts the case where the entire preamble is
conveyed across the GMII.

This workaround was tested on a Verdin iMX8MP by enforcing 10 MBit/s:
ethtool -s end0 speed 10
Without keeping the preamble, no packet were received. With keeping the
preamble, everything worked as expected.

Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c   | 6 +++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++++-
 include/linux/stmmac.h                            | 1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index db288fbd5a4df..c722ff2dc1fcb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -320,6 +320,9 @@ static int imx_dwmac_probe(struct platform_device *pdev)
 	if (data->flags & STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY)
 		plat_dat->flags |= STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY;
 
+	if (data->flags & STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD)
+		plat_dat->flags |= STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD;
+
 	/* Default TX Q0 to use TSO and rest TXQ for TBS */
 	for (int i = 1; i < plat_dat->tx_queues_to_use; i++)
 		plat_dat->tx_queues_cfg[i].tbs_en = 1;
@@ -355,7 +358,8 @@ static struct imx_dwmac_ops imx8mp_dwmac_data = {
 	.addr_width = 34,
 	.mac_rgmii_txclk_auto_adj = false,
 	.set_intf_mode = imx8mp_set_intf_mode,
-	.flags = STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY,
+	.flags = STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY |
+		 STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD,
 };
 
 static struct imx_dwmac_ops imx8dxl_dwmac_data = {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index da206b24aaed9..08a6082fc0c02 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1205,6 +1205,7 @@ static int stmmac_init_phy(struct net_device *dev)
 	struct fwnode_handle *phy_fwnode;
 	struct fwnode_handle *fwnode;
 	struct ethtool_keee eee;
+	u32 dev_flags = 0;
 	int ret;
 
 	if (!phylink_expects_phy(priv->phylink))
@@ -1223,6 +1224,9 @@ static int stmmac_init_phy(struct net_device *dev)
 	else
 		phy_fwnode = NULL;
 
+	if (priv->plat->flags & STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD)
+		dev_flags |= PHY_F_KEEP_PREAMBLE_BEFORE_SFD;
+
 	/* Some DT bindings do not set-up the PHY handle. Let's try to
 	 * manually parse it
 	 */
@@ -1241,10 +1245,12 @@ static int stmmac_init_phy(struct net_device *dev)
 			return -ENODEV;
 		}
 
+		phydev->dev_flags |= dev_flags;
+
 		ret = phylink_connect_phy(priv->phylink, phydev);
 	} else {
 		fwnode_handle_put(phy_fwnode);
-		ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0);
+		ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, dev_flags);
 	}
 
 	if (ret) {
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index f1054b9c2d8ac..e308c98c7bd33 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -191,6 +191,7 @@ enum dwmac_core_type {
 #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
 #define STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP	BIT(12)
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(13)
+#define STMMAC_FLAG_KEEP_PREAMBLE_BEFORE_SFD	BIT(14)
 
 struct mac_device_info;
 
-- 
2.51.0


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

* Re: [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP
  2026-01-20 20:30 [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Stefan Eichenberger
                   ` (2 preceding siblings ...)
  2026-01-20 20:30 ` [PATCH net-next v3 3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP Stefan Eichenberger
@ 2026-01-21 10:07 ` Maxime Chevallier
  2026-01-23  2:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 11+ messages in thread
From: Maxime Chevallier @ 2026-01-21 10:07 UTC (permalink / raw)
  To: Stefan Eichenberger, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, shawnguo, s.hauer, kernel,
	festevam, hkallweit1, linux, linux-stm32, francesco.dolcini
  Cc: netdev, linux-arm-kernel, imx, linux-kernel

Hi Stefan,

On 20/01/2026 21:30, Stefan Eichenberger wrote:
> This series adds a new phy_device flag PHY_F_KEEP_PREAMBLE_BEFORE_SFD
> that allows a MAC driver to request to keep the preamble bytes before
> the start frame delimiter (SFD) when receiving frames from the PHY.
> 
> This flag is set in the stmmac driver for the i.MX8MP SoC due to errata
> (ERR050694), which causes it to drop frames without a preamble.
> 
> The Micrel KSZ9131 PHY supports keeping the preamble before SFD by
> setting an undocumented flag, that was confirmed by NXP and Micrel. This
> new feature has been added to the Micrel PHY driver for the KSZ9131 PHY.
> 
> Changes since v2:
> - Instead of using phy_register_fixup add a new phy_device::dev_flags
>   flag PHY_F_KEEP_PREAMBLE_BEFORE_SFD so that a MAC can request to keep
>   the preamble before SFD if needed (Russell)
> - Link to v2: https://lore.kernel.org/all/20260105100245.19317-1-eichest@gmail.com/
> 
> Changes since v1:
> - Use phy_register_fixup_for_uid() instead of adding a new device tree
>   property
> - I will send the conversion of the micrel.txt binding as a separate
>   patch series
> - Link to v1: https://lore.kernel.org/all/20251212084657.29239-1-eichest@gmail.com/
> 
> Stefan Eichenberger (3):
>   net: phy: add a new phy_device flag to keep preamble before sfd
>   net: phy: micrel: add option to keep the preamble before sfd for
>     KSZ9131
>   net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP
> 
>  drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c   |  6 +++++-
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  8 +++++++-
>  drivers/net/phy/micrel.c                          | 14 +++++++++++++-
>  include/linux/phy.h                               |  5 +++--
>  include/linux/stmmac.h                            |  1 +
>  5 files changed, 29 insertions(+), 5 deletions(-)
> 

Thank you for that. The code looks fine to me. I've tested in on a custom baord
I have that happens to have an iMX8MP and a KSZ9131, it fixes the issue for
10M links ! Thank you :)

For the series,

Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime

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

* Re: [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd
  2026-01-20 20:30 ` [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd Stefan Eichenberger
@ 2026-01-22 11:37   ` Paolo Abeni
  2026-01-22 12:13     ` Russell King (Oracle)
  2026-01-22 13:08   ` Andrew Lunn
  1 sibling, 1 reply; 11+ messages in thread
From: Paolo Abeni @ 2026-01-22 11:37 UTC (permalink / raw)
  To: Stefan Eichenberger, andrew+netdev, davem, edumazet, kuba,
	mcoquelin.stm32, alexandre.torgue, shawnguo, s.hauer, kernel,
	festevam, hkallweit1, linux, linux-stm32, maxime.chevallier,
	francesco.dolcini
  Cc: netdev, linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

On 1/20/26 9:30 PM, Stefan Eichenberger wrote:
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> Add a new flag, PHY_F_KEEP_PREAMBLE_BEFORE_SFD, to indicate that the PHY
> shall not remove the preamble before the SFD if it supports it. MACs
> that do not support receiving frames without a preamble can set this
> flag.
> 
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>

I understand this has been suggested by Russell, and LGTM, but still it
would be nice explicit ack from the phy lib crew to ensure it matches
expectations.

Thanks,

Paolo


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

* Re: [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd
  2026-01-22 11:37   ` Paolo Abeni
@ 2026-01-22 12:13     ` Russell King (Oracle)
  0 siblings, 0 replies; 11+ messages in thread
From: Russell King (Oracle) @ 2026-01-22 12:13 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Stefan Eichenberger, andrew+netdev, davem, edumazet, kuba,
	mcoquelin.stm32, alexandre.torgue, shawnguo, s.hauer, kernel,
	festevam, hkallweit1, linux-stm32, maxime.chevallier,
	francesco.dolcini, netdev, linux-arm-kernel, imx, linux-kernel,
	Stefan Eichenberger

On Thu, Jan 22, 2026 at 12:37:17PM +0100, Paolo Abeni wrote:
> On 1/20/26 9:30 PM, Stefan Eichenberger wrote:
> > From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> > 
> > Add a new flag, PHY_F_KEEP_PREAMBLE_BEFORE_SFD, to indicate that the PHY
> > shall not remove the preamble before the SFD if it supports it. MACs
> > that do not support receiving frames without a preamble can set this
> > flag.
> > 
> > Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> I understand this has been suggested by Russell, and LGTM, but still it
> would be nice explicit ack from the phy lib crew to ensure it matches
> expectations.

Since I suggested it, I feel it would only be right for Andrew to ack
it to show his agreement with my suggestion.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd
  2026-01-20 20:30 ` [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd Stefan Eichenberger
  2026-01-22 11:37   ` Paolo Abeni
@ 2026-01-22 13:08   ` Andrew Lunn
  1 sibling, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2026-01-22 13:08 UTC (permalink / raw)
  To: Stefan Eichenberger
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini, netdev,
	linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

On Tue, Jan 20, 2026 at 09:30:02PM +0100, Stefan Eichenberger wrote:
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> Add a new flag, PHY_F_KEEP_PREAMBLE_BEFORE_SFD, to indicate that the PHY
> shall not remove the preamble before the SFD if it supports it. MACs
> that do not support receiving frames without a preamble can set this
> flag.
> 
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v3 2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131
  2026-01-20 20:30 ` [PATCH net-next v3 2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131 Stefan Eichenberger
@ 2026-01-22 13:08   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2026-01-22 13:08 UTC (permalink / raw)
  To: Stefan Eichenberger
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini, netdev,
	linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

On Tue, Jan 20, 2026 at 09:30:03PM +0100, Stefan Eichenberger wrote:
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> If the PHY_F_KEEP_PREAMBLE_BEFORE_SFD flag is set in the
> phy_device::dev_flags field, the preamble will be kept before the start
> frame delimiter (SFD) on the KSZ9131 PHY. This flag is not officially
> documented by Micrel. However, information provided by NXP and Micrel
> indicates that this flag ensures the PHY sends the full preamble instead
> of removing it. The full discussion can be found on the NXP forum:
> https://community.nxp.com/t5/i-MX-Processors/iMX8MP-eqos-not-working-for-10base-t/m-p/2151032
> 
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v3 3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP
  2026-01-20 20:30 ` [PATCH net-next v3 3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP Stefan Eichenberger
@ 2026-01-22 13:09   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2026-01-22 13:09 UTC (permalink / raw)
  To: Stefan Eichenberger
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini, netdev,
	linux-arm-kernel, imx, linux-kernel, Stefan Eichenberger

On Tue, Jan 20, 2026 at 09:30:04PM +0100, Stefan Eichenberger wrote:
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> 
> The stmmac implementation used by NXP for the i.MX8MP SoC is subject to
> errata ERR050694. According to this errata, when no preamble byte is
> transferred before the SFD from the PHY to the MAC, the MAC will discard
> the frame.
> 
> Setting the PHY_F_KEEP_PREAMBLE_BEFORE_SFD flag instructs PHYs that
> support it to keep the preamble byte before the SFD. This ensures that
> the MAC successfully receives frames.
> 
> As this is an issue in the MAC implementation, only enable the flag for
> the i.MX8MP SoC where the errata applies but not for other SoCs using a
> working stmmac implementation.
> 
> The exact wording of the errata ERR050694 from NXP:
> The IEEE 802.3 standard states that, in MII/GMII modes, the byte
> preceding the SFD (0xD5), SMD-S (0xE6,0x4C, 0x7F, or 0xB3), or SMD-C
> (0x61, 0x52, 0x9E, or 0x2A) byte can be a non-PREAMBLE byte or there can
> be no preceding preamble byte. The MAC receiver must successfully
> receive a packet without any preamble(0x55) byte preceding the SFD,
> SMD-S, or SMD-C byte.
> However due to the defect, in configurations where frame preemption is
> enabled, when preamble byte does not precede the SFD, SMD-S, or SMD-C
> byte, the received packet is discarded by the MAC receiver. This is
> because, the start-of-packet detection logic of the MAC receiver
> incorrectly checks for a preamble byte.
> 
> NXP refers to IEEE 802.3 where in clause 35.2.3.2.2 Receive case (GMII)
> they show two tables one where the preamble is preceding the SFD and one
> where it is not. The text says:
> The operation of 1000 Mb/s PHYs can result in shrinkage of the preamble
> between transmission at the source GMII and reception at the destination
> GMII. Table 35-3 depicts the case where no preamble bytes are conveyed
> across the GMII. This case may not be possible with a specific PHY, but
> illustrates the minimum preamble with which MAC shall be able to
> operate. Table 35-4 depicts the case where the entire preamble is
> conveyed across the GMII.
> 
> This workaround was tested on a Verdin iMX8MP by enforcing 10 MBit/s:
> ethtool -s end0 speed 10
> Without keeping the preamble, no packet were received. With keeping the
> preamble, everything worked as expected.
> 
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP
  2026-01-20 20:30 [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Stefan Eichenberger
                   ` (3 preceding siblings ...)
  2026-01-21 10:07 ` [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Maxime Chevallier
@ 2026-01-23  2:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-23  2:40 UTC (permalink / raw)
  To: Stefan Eichenberger
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
	alexandre.torgue, shawnguo, s.hauer, kernel, festevam, hkallweit1,
	linux, linux-stm32, maxime.chevallier, francesco.dolcini, netdev,
	linux-arm-kernel, imx, linux-kernel

Hello:

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

On Tue, 20 Jan 2026 21:30:01 +0100 you wrote:
> This series adds a new phy_device flag PHY_F_KEEP_PREAMBLE_BEFORE_SFD
> that allows a MAC driver to request to keep the preamble bytes before
> the start frame delimiter (SFD) when receiving frames from the PHY.
> 
> This flag is set in the stmmac driver for the i.MX8MP SoC due to errata
> (ERR050694), which causes it to drop frames without a preamble.
> 
> [...]

Here is the summary with links:
  - [net-next,v3,1/3] net: phy: add a new phy_device flag to keep preamble before sfd
    https://git.kernel.org/netdev/net-next/c/2153e151c27c
  - [net-next,v3,2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131
    https://git.kernel.org/netdev/net-next/c/fa1197a09496
  - [net-next,v3,3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP
    https://git.kernel.org/netdev/net-next/c/dc6597fab3e3

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] 11+ messages in thread

end of thread, other threads:[~2026-01-23  2:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20 20:30 [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Stefan Eichenberger
2026-01-20 20:30 ` [PATCH net-next v3 1/3] net: phy: add a new phy_device flag to keep preamble before sfd Stefan Eichenberger
2026-01-22 11:37   ` Paolo Abeni
2026-01-22 12:13     ` Russell King (Oracle)
2026-01-22 13:08   ` Andrew Lunn
2026-01-20 20:30 ` [PATCH net-next v3 2/3] net: phy: micrel: add option to keep the preamble before sfd for KSZ9131 Stefan Eichenberger
2026-01-22 13:08   ` Andrew Lunn
2026-01-20 20:30 ` [PATCH net-next v3 3/3] net: stmmac: dwmac-imx: keep preamble before sfd on i.MX8MP Stefan Eichenberger
2026-01-22 13:09   ` Andrew Lunn
2026-01-21 10:07 ` [PATCH net-next v3 0/3] net: stmmac: dwmac: enforce preamble before SFD for i.MX8MP Maxime Chevallier
2026-01-23  2:40 ` 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