netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/10] net: stmmac: remove mac_interface
@ 2025-09-17 15:11 Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 01/10] net: stmmac: rework mac_interface and phy_interface documentation Russell King (Oracle)
                   ` (10 more replies)
  0 siblings, 11 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:11 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

The dwmac core supports a range of interfaces, but when it comes to
SerDes interfaces, the core itself does not include the SerDes block.
Consequently, it has to provide an interface suitable to interface such
a block to, and uses TBI for this.

The driver also uses "PCS" for RGMII, even though the dwmac PCS block
is not present for this interface type - it was a convenice for the
code structure as RGMII includes inband signalling of the PHY state,
much like Cisco SGMII does at a high level.

As such, the code refers to RGMII and SGMII modes for the PCS, and
there used to be STMMAC_PCS_TBI and STMMAC_PCS_RTBI constants as well
but these were never set, although they were used in the code.

The selection of the PCS mode was from mac_interface. Thus, it seems
that the original intention was for mac_interface to describe the
interface mode used within the dwmac core, and phy_interface to
describe the external world-accessible interface (e.g. which would
connect to a PHY or SFP cage.)

It appears that many glue drivers misinterpret these. A good exmple
is socfpga. This supports SGMII and 1000BASE-X, but does not include
the dwmac PCS, relying on the Lynx PCS instead. However, it makes use
of mac_interface to configure the dwmac core to its GMII/MII mode.

So, when operating in either of these modes, the dwmac is configured
for GMII mode to communicate with the Lynx PCS which then provides
the SGMII or 1000BASE-X interface mode to the external world.

Given that phy_interface is the external world interface, and
mac_interface is the dwmac core interface, selecting the interface
mode based on mac_interface being 1000BASEX makes no sense.

Moreover, mac_interface is initialised by the stmmac core code. If
the "mac-mode" property is set in DT, this will be used. Otherwise,
it will reflect the "phy-mode" property - meaning that it defaults
to phy_interface. As no in-kernel DT makes reference to a "mac-mode"
property, we can assume that for all in-kernel platforms, these two
interface variables are the same. The exception are those platform
glues which I reviwed and suggested they use phy_interface, setting
mac_interface to PHY_INTERFACE_MODE_NA.

The conclusion to all of this is that mac_interface serves no useful
purpose, and causes confusion as the platform glue code doesn't seem
to know which one should be used.

Thus, let's get rid of mac_interface, which makes all this code more
understandable. It also helps to untangle some of the questions such
as:
- should this be using the interface passed from phylink
- should we set the range of phylink supported interfaces to be
  more than one
- when we get phylink PCS support for the dwmac PCS, should we be
  selecting it based on mac_interface or phy_interface, and how
  should we populate the PCS' supported_interface bitmap.

Having converted socfpga to use phy_interface, this turns out to
feel like "the right way" to do this - convert the external world
"phy_interface" to whatever phy_intf_sel value that the dwmac core
needs to achieve the connection to whatever hardware blocks are
integrated inside the SoC to achieve the requested external world
interface.

As an illustration why - consider that in the case of socfpga, it
_could_ have been implemented such that the dwmac PCS was used for
SGMII, and the Lynx PCS for 1000BASE-X, or vice versa. Only the
platform glue would know which it is.

I will also note that several cores provide their currently configured
interface mode via the ACTPHYIF field of Hardware Feature 0, and thus
can be read back in the platform-independent parts of the driver to
decide whether the internal PCS or the RGMII (or actually SMII) "PCS"
should be used.

This is hot-off-the-press, and has only been build tested. As I have
none of these platforms, this series has not been run-tested, so
please test on your hardware. Thanks.

 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c    | 20 +++++++-------
 .../net/ethernet/stmicro/stmmac/dwmac-ingenic.c    | 25 ++++++++++-------
 .../net/ethernet/stmicro/stmmac/dwmac-loongson.c   |  2 --
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    |  1 -
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-starfive.c   |  6 ++---
 drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c  | 26 +++++++++---------
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c  |  4 +--
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c  | 24 ++++++++---------
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  2 +-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  6 ++++-
 include/linux/stmmac.h                             | 31 ++++++++++++++--------
 12 files changed, 82 insertions(+), 67 deletions(-)

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

* [PATCH net-next 01/10] net: stmmac: rework mac_interface and phy_interface documentation
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 02/10] net: stmmac: use phy_interface in stmmac_check_pcs_mode() Russell King (Oracle)
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

Based on new research, it has come to light that the comment that I
added in a014c35556b9 ("net: stmmac: clarify difference between
"interface" and "phy_interface"") is not fully correct.

Update the comment to properly describe the difference between the two.

All of the DTS files in the kernel tree do not mention the "mac-mode"
property, which results in mac_interface and phy_interface being the
same. Also, none of the platform glue drivers set mac_interface to
anything but PHY_INTERFACE_MODE_NA. This means that for all the
platforms known to mainline, mac_interface is either the same as
phy_interface, or it is PHY_INTERFACE_MODE_NA.

Thus, updating the definition for mac_interface in stmmac.h has no
material effect on current uses known to mainline, but the change opens
the door to cleaning up all uses.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 include/linux/stmmac.h | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index e284f04964bf..f14f34ec6d5e 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -190,18 +190,32 @@ struct plat_stmmacenet_data {
 	int bus_id;
 	int phy_addr;
 	/* MAC ----- optional PCS ----- SerDes ----- optional PHY ----- Media
-	 *       ^                               ^
-	 * mac_interface                   phy_interface
+	 *                          ^            ^
+	 *                    mac_interface phy_interface
 	 *
-	 * mac_interface is the MAC-side interface, which may be the same
-	 * as phy_interface if there is no intervening PCS. If there is a
-	 * PCS, then mac_interface describes the interface mode between the
-	 * MAC and PCS, and phy_interface describes the interface mode
-	 * between the PCS and PHY.
+	 * The Synopsys dwmac core only covers the MAC and an optional
+	 * integrated PCS. Where the integrated PCS is used with a SerDes,
+	 * e.g. for 1000base-X or Cisco SGMII, the connection between the
+	 * PCS and SerDes will be TBI.
+	 *
+	 * Where the Synopsys dwmac core has been instantiated with multiple
+	 * interface modes, these are selected via core-external configuration
+	 * which is sampled when the dwmac core is reset. How this is done is
+	 * platform glue specific, but this defines the interface used from
+	 * the Synopsys dwmac core to the rest of the SoC.
+	 *
+	 * Where PCS other than the optional integrated Synopsys dwmac PCS
+	 * is used, this counts as "the rest of the SoC" in the above
+	 * paragraph.
+	 *
+	 * Thus, mac_interface is of little use inside the stmmac code;
+	 * please do not use unless there is a definite requirement, and
+	 * make sure to gain review feedback first.
 	 */
 	phy_interface_t mac_interface;
 	/* phy_interface is the PHY-side interface - the interface used by
-	 * an attached PHY.
+	 * an attached PHY or SFP etc. This is equivalent to the interface
+	 * that phylink uses.
 	 */
 	phy_interface_t phy_interface;
 	struct stmmac_mdio_bus_data *mdio_bus_data;
-- 
2.47.3


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

* [PATCH net-next 02/10] net: stmmac: use phy_interface in stmmac_check_pcs_mode()
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 01/10] net: stmmac: rework mac_interface and phy_interface documentation Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 03/10] net: stmmac: imx: convert to use phy_interface Russell King (Oracle)
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

In the majority, if not all cases, mac_interface and phy_interface
are the same with the exception of some drivers that I have suggested
only use phy_interface and set mac_interface to PHY_INTERFACE_MODE_NA.

The only two that currently set mac_interface to PHY_INTERFACE_MODE_NA
are dwmac-loongson and dwmac-lpc18xx, neither of which use RGMII nor
SGMII.

In order to phase out the use of mac_interface, we need to have a path
for existing drivers so they can update to only using phy_interface
without causing regressions.

Therefore, in order to keep the "pcs" code working, we need to choose
the STMMAC integrated PCS mode based on phy_interface if mac_interface
is PHY_INTERFACE_MODE_NA.

This will allow more drivers to set mac_interface to
PHY_INTERFACE_MODE_NA without risking regressions.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8c8ca5999bd8..a23017a886f3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1120,6 +1120,9 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
 {
 	int interface = priv->plat->mac_interface;
 
+	if (interface == PHY_INTERFACE_MODE_NA)
+		interface = priv->plat->phy_interface;
+
 	if (priv->dma_cap.pcs) {
 		if ((interface == PHY_INTERFACE_MODE_RGMII) ||
 		    (interface == PHY_INTERFACE_MODE_RGMII_ID) ||
-- 
2.47.3


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

* [PATCH net-next 03/10] net: stmmac: imx: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 01/10] net: stmmac: rework mac_interface and phy_interface documentation Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 02/10] net: stmmac: use phy_interface in stmmac_check_pcs_mode() Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 04/10] net: stmmac: ingenic: " Russell King (Oracle)
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

Checking the IMX8MP documentation, there is no requirement for a
separate mac_interface mode definition. As mac_interface and
phy_interface will be the same, use phy_interface internally rather
than mac_interface.

Also convert the error prints to use phy_modes() so that we get a
meaningful string rather than a number for the interface mode.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-imx.c   | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 80200a6aa0cb..4268b9987237 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -72,7 +72,7 @@ static int imx8mp_set_intf_mode(struct plat_stmmacenet_data *plat_dat)
 	struct imx_priv_data *dwmac = plat_dat->bsp_priv;
 	int val;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		val = GPR_ENET_QOS_INTF_SEL_MII;
 		break;
@@ -88,8 +88,8 @@ static int imx8mp_set_intf_mode(struct plat_stmmacenet_data *plat_dat)
 		      GPR_ENET_QOS_RGMII_EN;
 		break;
 	default:
-		pr_debug("imx dwmac doesn't support %d interface\n",
-			 plat_dat->mac_interface);
+		pr_debug("imx dwmac doesn't support %s interface\n",
+			 phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -112,7 +112,7 @@ static int imx93_set_intf_mode(struct plat_stmmacenet_data *plat_dat)
 	struct imx_priv_data *dwmac = plat_dat->bsp_priv;
 	int val, ret;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		val = MX93_GPR_ENET_QOS_INTF_SEL_MII;
 		break;
@@ -134,8 +134,8 @@ static int imx93_set_intf_mode(struct plat_stmmacenet_data *plat_dat)
 		val = MX93_GPR_ENET_QOS_INTF_SEL_RGMII;
 		break;
 	default:
-		dev_dbg(dwmac->dev, "imx dwmac doesn't support %d interface\n",
-			 plat_dat->mac_interface);
+		dev_dbg(dwmac->dev, "imx dwmac doesn't support %s interface\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -197,7 +197,7 @@ static int imx_dwmac_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
 {
 	struct imx_priv_data *dwmac = bsp_priv;
 
-	interface = dwmac->plat_dat->mac_interface;
+	interface = dwmac->plat_dat->phy_interface;
 	if (interface == PHY_INTERFACE_MODE_RMII ||
 	    interface == PHY_INTERFACE_MODE_MII)
 		return 0;
@@ -215,8 +215,8 @@ static void imx_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
 	plat_dat = dwmac->plat_dat;
 
 	if (dwmac->ops->mac_rgmii_txclk_auto_adj ||
-	    (plat_dat->mac_interface == PHY_INTERFACE_MODE_RMII) ||
-	    (plat_dat->mac_interface == PHY_INTERFACE_MODE_MII))
+	    (plat_dat->phy_interface == PHY_INTERFACE_MODE_RMII) ||
+	    (plat_dat->phy_interface == PHY_INTERFACE_MODE_MII))
 		return;
 
 	rate = rgmii_clock(speed);
@@ -274,7 +274,7 @@ static int imx_dwmac_mx93_reset(struct stmmac_priv *priv, void __iomem *ioaddr)
 	value |= DMA_BUS_MODE_SFT_RESET;
 	writel(value, ioaddr + DMA_BUS_MODE);
 
-	if (plat_dat->mac_interface == PHY_INTERFACE_MODE_RMII) {
+	if (plat_dat->phy_interface == PHY_INTERFACE_MODE_RMII) {
 		usleep_range(100, 200);
 		writel(RMII_RESET_SPEED, ioaddr + MAC_CTRL_REG);
 	}
-- 
2.47.3


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

* [PATCH net-next 04/10] net: stmmac: ingenic: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 03/10] net: stmmac: imx: convert to use phy_interface Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 05/10] net: stmmac: socfpga: " Russell King (Oracle)
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

dwmac-ingenic uses only MII, RMII, GMII or RGMII interface modes, none
of which require any kind of conversion between the MAC and external
world. Thus, mac_interface and phy_interface will be the same.

Convert dwmac-ingenic to use phy_interface when determining the
interface mode that the dwmac core should be configured to at reset,
rather than mac_interface.

Also convert the error prints to use phy_modes() and terminate with a
newline so that we get a human readable string rather than a number for
the interface mode.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-ingenic.c   | 25 +++++++++++--------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
index 15abe214131f..c1670f6bae14 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
@@ -90,7 +90,7 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	struct ingenic_mac *mac = plat_dat->bsp_priv;
 	unsigned int val;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		val = FIELD_PREP(MACPHYC_TXCLK_SEL_MASK, MACPHYC_TXCLK_SEL_INPUT) |
 			  FIELD_PREP(MACPHYC_PHY_INFT_MASK, MACPHYC_PHY_INFT_MII);
@@ -119,7 +119,8 @@ static int jz4775_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 		break;
 
 	default:
-		dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface);
+		dev_err(mac->dev, "Unsupported interface %s\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -131,13 +132,14 @@ static int x1000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 {
 	struct ingenic_mac *mac = plat_dat->bsp_priv;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_RMII:
 		dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n");
 		break;
 
 	default:
-		dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface);
+		dev_err(mac->dev, "Unsupported interface %s\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -150,14 +152,15 @@ static int x1600_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	struct ingenic_mac *mac = plat_dat->bsp_priv;
 	unsigned int val;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_RMII:
 		val = FIELD_PREP(MACPHYC_PHY_INFT_MASK, MACPHYC_PHY_INFT_RMII);
 		dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n");
 		break;
 
 	default:
-		dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface);
+		dev_err(mac->dev, "Unsupported interface %s\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -170,7 +173,7 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	struct ingenic_mac *mac = plat_dat->bsp_priv;
 	unsigned int val;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_RMII:
 		val = FIELD_PREP(MACPHYC_MODE_SEL_MASK, MACPHYC_MODE_SEL_RMII) |
 			  FIELD_PREP(MACPHYC_PHY_INFT_MASK, MACPHYC_PHY_INFT_RMII);
@@ -178,7 +181,8 @@ static int x1830_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 		break;
 
 	default:
-		dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface);
+		dev_err(mac->dev, "Unsupported interface %s\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -191,7 +195,7 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	struct ingenic_mac *mac = plat_dat->bsp_priv;
 	unsigned int val;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_RMII:
 		val = FIELD_PREP(MACPHYC_TX_SEL_MASK, MACPHYC_TX_SEL_ORIGIN) |
 			  FIELD_PREP(MACPHYC_RX_SEL_MASK, MACPHYC_RX_SEL_ORIGIN) |
@@ -221,7 +225,8 @@ static int x2000_mac_set_mode(struct plat_stmmacenet_data *plat_dat)
 		break;
 
 	default:
-		dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface);
+		dev_err(mac->dev, "Unsupported interface %s\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
-- 
2.47.3


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

* [PATCH net-next 05/10] net: stmmac: socfpga: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (3 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 04/10] net: stmmac: ingenic: " Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-21  8:18   ` Maxime Chevallier
  2025-09-17 15:12 ` [PATCH net-next 06/10] net: stmmac: starfive: " Russell King (Oracle)
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

dwmac-socfpga uses MII, RMII, GMII, RGMII, SGMII and 1000BASE-X
interface modes, and supports the Lynx PCS. The Lynx PCS will only be
used for SGMII and 1000BASE-X modes, with the MAC programmed to use
GMII or MII mode to talk to the PCS. This suggests that the Synopsys
optional dwmac PCS is not present.

None of the DTS files set "mac-mode", so mac_interface will be
identical to phy_interface.

Convert dwmac-socfpga to use phy_interface when determining the
interface mode rather than mac_interface.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 01dd0cf0923c..354f01184e6c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -234,7 +234,7 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
 
 static int socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac)
 {
-	return dwmac->plat_dat->mac_interface;
+	return dwmac->plat_dat->phy_interface;
 }
 
 static void socfpga_sgmii_config(struct socfpga_dwmac *dwmac, bool enable)
-- 
2.47.3


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

* [PATCH net-next 06/10] net: stmmac: starfive: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (4 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 05/10] net: stmmac: socfpga: " Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 07/10] net: stmmac: stm32: " Russell King (Oracle)
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

dwmac-starfive uses RMII or RGMII interface modes without any PCS,
and selects the dwmac core accordingly using a register field with
the same bit encoding as the core's phy_intf_sel_i signals.

None of the DTS files set "mac-mode", so mac_interface will be
identical to phy_interface.

Convert dwmac-starfive to use phy_interface when determining the
interface mode rather than mac_interface. Also convert the error
prints to use phy_modes() so that we get a meaningful string rather
than a number for the interface mode.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
index 2013d7477eb7..6938dd2a79b7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
@@ -38,7 +38,7 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 	unsigned int mode;
 	int err;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_RMII:
 		mode = STARFIVE_DWMAC_PHY_INFT_RMII;
 		break;
@@ -51,8 +51,8 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
 		break;
 
 	default:
-		dev_err(dwmac->dev, "unsupported interface %d\n",
-			plat_dat->mac_interface);
+		dev_err(dwmac->dev, "unsupported interface %s\n",
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 
-- 
2.47.3


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

* [PATCH net-next 07/10] net: stmmac: stm32: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (5 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 06/10] net: stmmac: starfive: " Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 08/10] net: stmmac: sun8i: " Russell King (Oracle)
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

dwmac-stm32 supports MII, RMII, GMII and RGMII interface modes,
selecting the dwmac core interface mode via bits 23:21 of the
SYSCFG register. The bit combinations are identical to the
dwmac phy_intf_sel_i signals.

None of the DTS files set "mac-mode", so mac_interface will be
identical to phy_interface.

Convert dwmac-stm32 to use phy_interface when determining the
interface mode rather than mac_interface.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
index 77a04c4579c9..6c179911ef3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c
@@ -171,7 +171,7 @@ static int stm32mp1_select_ethck_external(struct plat_stmmacenet_data *plat_dat)
 {
 	struct stm32_dwmac *dwmac = plat_dat->bsp_priv;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		dwmac->enable_eth_ck = dwmac->ext_phyclk;
 		return 0;
@@ -193,7 +193,7 @@ static int stm32mp1_select_ethck_external(struct plat_stmmacenet_data *plat_dat)
 	default:
 		dwmac->enable_eth_ck = false;
 		dev_err(dwmac->dev, "Mode %s not supported",
-			phy_modes(plat_dat->mac_interface));
+			phy_modes(plat_dat->phy_interface));
 		return -EINVAL;
 	}
 }
@@ -206,7 +206,7 @@ static int stm32mp1_validate_ethck_rate(struct plat_stmmacenet_data *plat_dat)
 	if (!dwmac->enable_eth_ck)
 		return 0;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 	case PHY_INTERFACE_MODE_GMII:
 		if (clk_rate == ETH_CK_F_25M)
@@ -228,7 +228,7 @@ static int stm32mp1_validate_ethck_rate(struct plat_stmmacenet_data *plat_dat)
 	}
 
 	dev_err(dwmac->dev, "Mode %s does not match eth-ck frequency %d Hz",
-		phy_modes(plat_dat->mac_interface), clk_rate);
+		phy_modes(plat_dat->phy_interface), clk_rate);
 	return -EINVAL;
 }
 
@@ -238,7 +238,7 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 	u32 reg = dwmac->mode_reg;
 	int val = 0;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		/*
 		 * STM32MP15xx supports both MII and GMII, STM32MP13xx MII only.
@@ -269,12 +269,12 @@ static int stm32mp1_configure_pmcr(struct plat_stmmacenet_data *plat_dat)
 		break;
 	default:
 		dev_err(dwmac->dev, "Mode %s not supported",
-			phy_modes(plat_dat->mac_interface));
+			phy_modes(plat_dat->phy_interface));
 		/* Do not manage others interfaces */
 		return -EINVAL;
 	}
 
-	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->mac_interface));
+	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
 	/* Shift value at correct ethernet MAC offset in SYSCFG_PMCSETR */
 	val <<= ffs(dwmac->mode_mask) - ffs(SYSCFG_MP1_ETH_MASK);
@@ -294,7 +294,7 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 	u32 reg = dwmac->mode_reg;
 	int val = 0;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		/* ETH_REF_CLK_SEL bit in SYSCFG register is not applicable in MII mode */
 		break;
@@ -319,12 +319,12 @@ static int stm32mp2_configure_syscfg(struct plat_stmmacenet_data *plat_dat)
 		break;
 	default:
 		dev_err(dwmac->dev, "Mode %s not supported",
-			phy_modes(plat_dat->mac_interface));
+			phy_modes(plat_dat->phy_interface));
 		/* Do not manage others interfaces */
 		return -EINVAL;
 	}
 
-	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->mac_interface));
+	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
 	/* Select PTP (IEEE1588) clock selection from RCC (ck_ker_ethxptp) */
 	val |= SYSCFG_ETHCR_ETH_PTP_CLK_SEL;
@@ -359,7 +359,7 @@ static int stm32mcu_set_mode(struct plat_stmmacenet_data *plat_dat)
 	u32 reg = dwmac->mode_reg;
 	int val;
 
-	switch (plat_dat->mac_interface) {
+	switch (plat_dat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		val = SYSCFG_MCU_ETH_SEL_MII;
 		break;
@@ -368,12 +368,12 @@ static int stm32mcu_set_mode(struct plat_stmmacenet_data *plat_dat)
 		break;
 	default:
 		dev_err(dwmac->dev, "Mode %s not supported",
-			phy_modes(plat_dat->mac_interface));
+			phy_modes(plat_dat->phy_interface));
 		/* Do not manage others interfaces */
 		return -EINVAL;
 	}
 
-	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->mac_interface));
+	dev_dbg(dwmac->dev, "Mode %s", phy_modes(plat_dat->phy_interface));
 
 	return regmap_update_bits(dwmac->regmap, reg,
 				 SYSCFG_MCU_ETH_MASK, val << 23);
-- 
2.47.3


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

* [PATCH net-next 08/10] net: stmmac: sun8i: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (6 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 07/10] net: stmmac: stm32: " Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:25   ` Chen-Yu Tsai
  2025-09-17 15:12 ` [PATCH net-next 09/10] net: stmmac: thead: " Russell King (Oracle)
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

dwmac-sun8i supports MII, RMII and RGMII interface modes only. It
is unclear whether the dwmac core interface is different from the
one presented to the outside world.

However, as none of the DTS files set "mac-mode", mac_interface will
be identical to phy_interface.

Convert dwmac-sun8i to use phy_interface when determining the
interface mode rather than mac_interface.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 690f3650f84e..5d871b2cd111 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -974,7 +974,7 @@ static int sun8i_dwmac_set_syscon(struct device *dev,
 		}
 	}
 
-	switch (plat->mac_interface) {
+	switch (plat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		/* default */
 		break;
@@ -989,7 +989,7 @@ static int sun8i_dwmac_set_syscon(struct device *dev,
 		break;
 	default:
 		dev_err(dev, "Unsupported interface mode: %s",
-			phy_modes(plat->mac_interface));
+			phy_modes(plat->phy_interface));
 		return -EINVAL;
 	}
 
-- 
2.47.3


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

* [PATCH net-next 09/10] net: stmmac: thead: convert to use phy_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (7 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 08/10] net: stmmac: sun8i: " Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-17 15:12 ` [PATCH net-next 10/10] net: stmmac: remove mac_interface Russell King (Oracle)
  2025-09-20  0:30 ` [PATCH net-next 00/10] " patchwork-bot+netdevbpf
  10 siblings, 0 replies; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

dwmac-thead supports either MII or RGMII interface modes only.

None of the DTS files set "mac-mode", so mac_interface will be
identical to phy_interface.

Convert dwmac-thead to use phy_interface when determining the
interface mode rather than mac_interface.

Also convert the error prints to use phy_modes() so that we get a
meaningful string rather than a number for the interface mode.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-thead.c | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
index 6c6c49e4b66f..a3378046b061 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
@@ -56,7 +56,7 @@ static int thead_dwmac_set_phy_if(struct plat_stmmacenet_data *plat)
 	struct thead_dwmac *dwmac = plat->bsp_priv;
 	u32 phyif;
 
-	switch (plat->mac_interface) {
+	switch (plat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		phyif = PHY_INTF_MII_GMII;
 		break;
@@ -67,8 +67,8 @@ static int thead_dwmac_set_phy_if(struct plat_stmmacenet_data *plat)
 		phyif = PHY_INTF_RGMII;
 		break;
 	default:
-		dev_err(dwmac->dev, "unsupported phy interface %d\n",
-			plat->mac_interface);
+		dev_err(dwmac->dev, "unsupported phy interface %s\n",
+			phy_modes(plat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -81,7 +81,7 @@ static int thead_dwmac_set_txclk_dir(struct plat_stmmacenet_data *plat)
 	struct thead_dwmac *dwmac = plat->bsp_priv;
 	u32 txclk_dir;
 
-	switch (plat->mac_interface) {
+	switch (plat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		txclk_dir = TXCLK_DIR_INPUT;
 		break;
@@ -92,8 +92,8 @@ static int thead_dwmac_set_txclk_dir(struct plat_stmmacenet_data *plat)
 		txclk_dir = TXCLK_DIR_OUTPUT;
 		break;
 	default:
-		dev_err(dwmac->dev, "unsupported phy interface %d\n",
-			plat->mac_interface);
+		dev_err(dwmac->dev, "unsupported phy interface %s\n",
+			phy_modes(plat->phy_interface));
 		return -EINVAL;
 	}
 
@@ -112,7 +112,7 @@ static int thead_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
 
 	plat = dwmac->plat;
 
-	switch (plat->mac_interface) {
+	switch (plat->phy_interface) {
 	/* For MII, rxc/txc is provided by phy */
 	case PHY_INTERFACE_MODE_MII:
 		return 0;
@@ -143,8 +143,8 @@ static int thead_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
 		return 0;
 
 	default:
-		dev_err(dwmac->dev, "unsupported phy interface %d\n",
-			plat->mac_interface);
+		dev_err(dwmac->dev, "unsupported phy interface %s\n",
+			phy_modes(plat->phy_interface));
 		return -EINVAL;
 	}
 }
@@ -154,7 +154,7 @@ static int thead_dwmac_enable_clk(struct plat_stmmacenet_data *plat)
 	struct thead_dwmac *dwmac = plat->bsp_priv;
 	u32 reg, div;
 
-	switch (plat->mac_interface) {
+	switch (plat->phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		reg = GMAC_RX_CLK_EN | GMAC_TX_CLK_EN;
 		break;
@@ -177,8 +177,8 @@ static int thead_dwmac_enable_clk(struct plat_stmmacenet_data *plat)
 		break;
 
 	default:
-		dev_err(dwmac->dev, "unsupported phy interface %d\n",
-			plat->mac_interface);
+		dev_err(dwmac->dev, "unsupported phy interface %s\n",
+			phy_modes(plat->phy_interface));
 		return -EINVAL;
 	}
 
-- 
2.47.3


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

* [PATCH net-next 10/10] net: stmmac: remove mac_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (8 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 09/10] net: stmmac: thead: " Russell King (Oracle)
@ 2025-09-17 15:12 ` Russell King (Oracle)
  2025-09-18 20:11   ` Vladimir Zapolskiy
  2025-09-20  0:30 ` [PATCH net-next 00/10] " patchwork-bot+netdevbpf
  10 siblings, 1 reply; 15+ messages in thread
From: Russell King (Oracle) @ 2025-09-17 15:12 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

mac_interface has served little purpose, and has only caused confusion.
Now that we have cleaned up all platform glue drivers which should not
have been using mac_interface, there are no users remaining. Remove
mac_interface.

This results in the special dwmac specific "mac-mode" DT property
becoming redundant, and an in case, no DTS files in the kernel make use
of this property. Add a warning if the property is set, and it is
different from the "phy-mode".

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c  |  2 --
 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c   |  1 -
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c     |  5 +----
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c |  6 +++++-
 include/linux/stmmac.h                                | 11 +++--------
 5 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index dd82dc2189e9..592aa9d636e5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -98,8 +98,6 @@ static void loongson_default_data(struct pci_dev *pdev,
 	/* Set default value for multicast hash bins */
 	plat->multicast_filter_bins = 256;
 
-	plat->mac_interface = PHY_INTERFACE_MODE_NA;
-
 	/* Set default value for unicast filter entries */
 	plat->unicast_filter_entries = 1;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
index c0c44916f849..2562a6d036a2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
@@ -41,7 +41,6 @@ static int lpc18xx_dwmac_probe(struct platform_device *pdev)
 	if (IS_ERR(plat_dat))
 		return PTR_ERR(plat_dat);
 
-	plat_dat->mac_interface = PHY_INTERFACE_MODE_NA;
 	plat_dat->has_gmac = true;
 
 	reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a23017a886f3..d17820d9e7f1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1118,10 +1118,7 @@ static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
  */
 static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
 {
-	int interface = priv->plat->mac_interface;
-
-	if (interface == PHY_INTERFACE_MODE_NA)
-		interface = priv->plat->phy_interface;
+	int interface = priv->plat->phy_interface;
 
 	if (priv->dma_cap.pcs) {
 		if ((interface == PHY_INTERFACE_MODE_RGMII) ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index a3e077f225d1..712ef235f0f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -453,8 +453,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
 		return ERR_PTR(phy_mode);
 
 	plat->phy_interface = phy_mode;
+
 	rc = stmmac_of_get_mac_mode(np);
-	plat->mac_interface = rc < 0 ? plat->phy_interface : rc;
+	if (rc >= 0 && rc != phy_mode)
+		dev_warn(&pdev->dev,
+			 "\"mac-mode\" property used for %s but differs to \"phy-mode\" of %s, and will be ignored. Please report.\n",
+			 phy_modes(rc), phy_modes(phy_mode));
 
 	/* Some wrapper drivers still rely on phy_node. Let's save it while
 	 * they are not converted to phylink. */
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index f14f34ec6d5e..fa1318bac06c 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -190,8 +190,8 @@ struct plat_stmmacenet_data {
 	int bus_id;
 	int phy_addr;
 	/* MAC ----- optional PCS ----- SerDes ----- optional PHY ----- Media
-	 *                          ^            ^
-	 *                    mac_interface phy_interface
+	 *                                       ^
+	 *                                  phy_interface
 	 *
 	 * The Synopsys dwmac core only covers the MAC and an optional
 	 * integrated PCS. Where the integrated PCS is used with a SerDes,
@@ -208,12 +208,7 @@ struct plat_stmmacenet_data {
 	 * is used, this counts as "the rest of the SoC" in the above
 	 * paragraph.
 	 *
-	 * Thus, mac_interface is of little use inside the stmmac code;
-	 * please do not use unless there is a definite requirement, and
-	 * make sure to gain review feedback first.
-	 */
-	phy_interface_t mac_interface;
-	/* phy_interface is the PHY-side interface - the interface used by
+	 * phy_interface is the PHY-side interface - the interface used by
 	 * an attached PHY or SFP etc. This is equivalent to the interface
 	 * that phylink uses.
 	 */
-- 
2.47.3


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

* Re: [PATCH net-next 08/10] net: stmmac: sun8i: convert to use phy_interface
  2025-09-17 15:12 ` [PATCH net-next 08/10] net: stmmac: sun8i: " Russell King (Oracle)
@ 2025-09-17 15:25   ` Chen-Yu Tsai
  0 siblings, 0 replies; 15+ messages in thread
From: Chen-Yu Tsai @ 2025-09-17 15:25 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
	David S. Miller, Drew Fustini, Emil Renner Berthing, Eric Dumazet,
	Fabio Estevam, Fu Wei, Guo Ren, imx, Jakub Kicinski,
	Jernej Skrabec, linux-arm-kernel, linux-riscv, linux-stm32,
	linux-sunxi, Maxime Chevallier, Maxime Coquelin, Minda Chen,
	Mohd Ayaan Anwar, netdev, Paolo Abeni, Pengutronix Kernel Team,
	Samuel Holland, Sascha Hauer, Shawn Guo, Vladimir Zapolskiy

On Wed, Sep 17, 2025 at 11:13 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> dwmac-sun8i supports MII, RMII and RGMII interface modes only. It
> is unclear whether the dwmac core interface is different from the
> one presented to the outside world.
>
> However, as none of the DTS files set "mac-mode", mac_interface will
> be identical to phy_interface.
>
> Convert dwmac-sun8i to use phy_interface when determining the
> interface mode rather than mac_interface.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Acked-by: Chen-Yu Tsai <wens@csie.org>

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

* Re: [PATCH net-next 10/10] net: stmmac: remove mac_interface
  2025-09-17 15:12 ` [PATCH net-next 10/10] net: stmmac: remove mac_interface Russell King (Oracle)
@ 2025-09-18 20:11   ` Vladimir Zapolskiy
  0 siblings, 0 replies; 15+ messages in thread
From: Vladimir Zapolskiy @ 2025-09-18 20:11 UTC (permalink / raw)
  To: Russell King (Oracle), Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jernej Skrabec,
	linux-arm-kernel, linux-riscv, linux-stm32, linux-sunxi,
	Maxime Chevallier, Maxime Coquelin, Minda Chen, Mohd Ayaan Anwar,
	netdev, Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo

On 9/17/25 18:12, Russell King (Oracle) wrote:
> mac_interface has served little purpose, and has only caused confusion.
> Now that we have cleaned up all platform glue drivers which should not
> have been using mac_interface, there are no users remaining. Remove
> mac_interface.
> 
> This results in the special dwmac specific "mac-mode" DT property
> becoming redundant, and an in case, no DTS files in the kernel make use
> of this property. Add a warning if the property is set, and it is
> different from the "phy-mode".
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Acked-by: Vladimir Zapolskiy <vz@mleia.com>

-- 
Best wishes,
Vladimir

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

* Re: [PATCH net-next 00/10] net: stmmac: remove mac_interface
  2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
                   ` (9 preceding siblings ...)
  2025-09-17 15:12 ` [PATCH net-next 10/10] net: stmmac: remove mac_interface Russell King (Oracle)
@ 2025-09-20  0:30 ` patchwork-bot+netdevbpf
  10 siblings, 0 replies; 15+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-20  0:30 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, wens, davem,
	fustini, kernel, edumazet, festevam, wefu, guoren, imx, kuba,
	jernej.skrabec, linux-arm-kernel, linux-riscv, linux-stm32,
	linux-sunxi, maxime.chevallier, mcoquelin.stm32, minda.chen,
	mohd.anwar, netdev, pabeni, kernel, samuel, s.hauer, shawnguo, vz

Hello:

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

On Wed, 17 Sep 2025 16:11:33 +0100 you wrote:
> The dwmac core supports a range of interfaces, but when it comes to
> SerDes interfaces, the core itself does not include the SerDes block.
> Consequently, it has to provide an interface suitable to interface such
> a block to, and uses TBI for this.
> 
> The driver also uses "PCS" for RGMII, even though the dwmac PCS block
> is not present for this interface type - it was a convenice for the
> code structure as RGMII includes inband signalling of the PHY state,
> much like Cisco SGMII does at a high level.
> 
> [...]

Here is the summary with links:
  - [net-next,01/10] net: stmmac: rework mac_interface and phy_interface documentation
    https://git.kernel.org/netdev/net-next/c/32a8d2a197c1
  - [net-next,02/10] net: stmmac: use phy_interface in stmmac_check_pcs_mode()
    https://git.kernel.org/netdev/net-next/c/0522f152a2c9
  - [net-next,03/10] net: stmmac: imx: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/db1948da6860
  - [net-next,04/10] net: stmmac: ingenic: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/9ff682b4a28f
  - [net-next,05/10] net: stmmac: socfpga: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/de696c63c1dc
  - [net-next,06/10] net: stmmac: starfive: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/6cb2b69c3419
  - [net-next,07/10] net: stmmac: stm32: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/0ca60c26f655
  - [net-next,08/10] net: stmmac: sun8i: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/0fe080fa884e
  - [net-next,09/10] net: stmmac: thead: convert to use phy_interface
    https://git.kernel.org/netdev/net-next/c/3a94ecdf1afb
  - [net-next,10/10] net: stmmac: remove mac_interface
    https://git.kernel.org/netdev/net-next/c/6b0ed6a3a89c

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

* Re: [PATCH net-next 05/10] net: stmmac: socfpga: convert to use phy_interface
  2025-09-17 15:12 ` [PATCH net-next 05/10] net: stmmac: socfpga: " Russell King (Oracle)
@ 2025-09-21  8:18   ` Maxime Chevallier
  0 siblings, 0 replies; 15+ messages in thread
From: Maxime Chevallier @ 2025-09-21  8:18 UTC (permalink / raw)
  To: Russell King (Oracle), Andrew Lunn, Heiner Kallweit
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	netdev, Paolo Abeni

Hi Russell,

On 17/09/2025 20:42, Russell King (Oracle) wrote:
> dwmac-socfpga uses MII, RMII, GMII, RGMII, SGMII and 1000BASE-X
> interface modes, and supports the Lynx PCS. The Lynx PCS will only be
> used for SGMII and 1000BASE-X modes, with the MAC programmed to use
> GMII or MII mode to talk to the PCS. This suggests that the Synopsys
> optional dwmac PCS is not present.
> 
> None of the DTS files set "mac-mode", so mac_interface will be
> identical to phy_interface.
> 
> Convert dwmac-socfpga to use phy_interface when determining the
> interface mode rather than mac_interface.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

I know this has been merged, but FWIW this looks good to me. sorry for 
not having had time to test this or the Marvell PTP stuff lately, I'm 
juggling between too many work and non-work related things and barely 
have time to work on phy_port :(

Thanks for this cleanup,

Maxime

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

end of thread, other threads:[~2025-09-21  8:18 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 15:11 [PATCH net-next 00/10] net: stmmac: remove mac_interface Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 01/10] net: stmmac: rework mac_interface and phy_interface documentation Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 02/10] net: stmmac: use phy_interface in stmmac_check_pcs_mode() Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 03/10] net: stmmac: imx: convert to use phy_interface Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 04/10] net: stmmac: ingenic: " Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 05/10] net: stmmac: socfpga: " Russell King (Oracle)
2025-09-21  8:18   ` Maxime Chevallier
2025-09-17 15:12 ` [PATCH net-next 06/10] net: stmmac: starfive: " Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 07/10] net: stmmac: stm32: " Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 08/10] net: stmmac: sun8i: " Russell King (Oracle)
2025-09-17 15:25   ` Chen-Yu Tsai
2025-09-17 15:12 ` [PATCH net-next 09/10] net: stmmac: thead: " Russell King (Oracle)
2025-09-17 15:12 ` [PATCH net-next 10/10] net: stmmac: remove mac_interface Russell King (Oracle)
2025-09-18 20:11   ` Vladimir Zapolskiy
2025-09-20  0:30 ` [PATCH net-next 00/10] " 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;
as well as URLs for NNTP newsgroup(s).