public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state
@ 2026-03-19 18:17 Maxime Chevallier
  2026-03-20 17:32 ` Simon Horman
  2026-03-21  2:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Maxime Chevallier @ 2026-03-19 18:17 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Woojung Huh, Vladimir Oltean, UNGLinuxDriver
  Cc: Maxime Chevallier, thomas.petazzoni, netdev, linux-kernel

The KSZ9477 maintains the SGMII port's state for speed, duplex and link
status to be able to fixup the accesses to its internal older version of
the Designware XPCS. However, it does so by embedding a full instance of
struct phy_device, only to use the 'speed', 'link' and 'duplex' fields.

This is also only used for the SGMII port, it's otherwise unused for all
other regular ports.

Replace that with simple int/bool values.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/dsa/microchip/ksz9477.c    | 17 ++++++++---------
 drivers/net/dsa/microchip/ksz_common.c |  2 +-
 drivers/net/dsa/microchip/ksz_common.h |  4 +++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 5facffbb9c9a..5416016b33e0 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -224,14 +224,13 @@ static int ksz9477_pcs_read(struct mii_bus *bus, int phy, int mmd, int reg)
 				else
 					duplex = DUPLEX_HALF;
 
-				if (!p->phydev.link ||
-				    p->phydev.speed != speed ||
-				    p->phydev.duplex != duplex) {
+				if (!p->link || p->speed != speed ||
+				    p->duplex != duplex) {
 					u16 ctrl;
 
-					p->phydev.link = 1;
-					p->phydev.speed = speed;
-					p->phydev.duplex = duplex;
+					p->link = true;
+					p->speed = speed;
+					p->duplex = duplex;
 					port_sgmii_r(dev, port, mmd, MII_BMCR,
 						     &ctrl);
 					ctrl &= BMCR_ANENABLE;
@@ -241,10 +240,10 @@ static int ksz9477_pcs_read(struct mii_bus *bus, int phy, int mmd, int reg)
 						     ctrl);
 				}
 			} else {
-				p->phydev.link = 0;
+				p->link = false;
 			}
 		} else if (reg == MII_BMSR) {
-			p->phydev.link = !!(val & BMSR_LSTATUS);
+			p->link = !!(val & BMSR_LSTATUS);
 		}
 	}
 
@@ -557,7 +556,7 @@ int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data)
 			val = 0x0700;
 			break;
 		case MII_STAT1000:
-			if (p->phydev.speed == SPEED_1000)
+			if (p->speed == SPEED_1000)
 				val = 0x3800;
 			else
 				val = 0;
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index c517478cc476..144373e13bea 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3983,7 +3983,7 @@ static void ksz9477_phylink_mac_link_up(struct phylink_config *config,
 	if (dev->info->internal_phy[port])
 		return;
 
-	p->phydev.speed = speed;
+	p->speed = speed;
 
 	ksz_port_set_xmii_speed(dev, port, speed);
 
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 929aff4c55de..18f13ee9c7b6 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -129,7 +129,9 @@ struct ksz_port {
 	bool learning;
 	bool isolated;
 	int stp_state;
-	struct phy_device phydev;
+	int speed;
+	int duplex;
+	bool link;
 
 	u32 fiber:1;			/* port is fiber */
 	u32 force:1;
-- 
2.49.0


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

* Re: [PATCH net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state
  2026-03-19 18:17 [PATCH net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state Maxime Chevallier
@ 2026-03-20 17:32 ` Simon Horman
  2026-03-21  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-03-20 17:32 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Woojung Huh, Vladimir Oltean, UNGLinuxDriver, thomas.petazzoni,
	netdev, linux-kernel

On Thu, Mar 19, 2026 at 07:17:04PM +0100, Maxime Chevallier wrote:
> The KSZ9477 maintains the SGMII port's state for speed, duplex and link
> status to be able to fixup the accesses to its internal older version of
> the Designware XPCS. However, it does so by embedding a full instance of
> struct phy_device, only to use the 'speed', 'link' and 'duplex' fields.
> 
> This is also only used for the SGMII port, it's otherwise unused for all
> other regular ports.
> 
> Replace that with simple int/bool values.
> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state
  2026-03-19 18:17 [PATCH net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state Maxime Chevallier
  2026-03-20 17:32 ` Simon Horman
@ 2026-03-21  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-21  2:50 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: andrew, kuba, davem, edumazet, pabeni, horms, woojung.huh,
	olteanv, UNGLinuxDriver, thomas.petazzoni, netdev, linux-kernel

Hello:

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

On Thu, 19 Mar 2026 19:17:04 +0100 you wrote:
> The KSZ9477 maintains the SGMII port's state for speed, duplex and link
> status to be able to fixup the accesses to its internal older version of
> the Designware XPCS. However, it does so by embedding a full instance of
> struct phy_device, only to use the 'speed', 'link' and 'duplex' fields.
> 
> This is also only used for the SGMII port, it's otherwise unused for all
> other regular ports.
> 
> [...]

Here is the summary with links:
  - [net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state
    https://git.kernel.org/netdev/net-next/c/2e69e55897dc

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

end of thread, other threads:[~2026-03-21  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 18:17 [PATCH net-next] net: dsa: microchip: Don't embed struct phy_device to maintain the port state Maxime Chevallier
2026-03-20 17:32 ` Simon Horman
2026-03-21  2:50 ` 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