netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: move marking PHY on SFP module into SFP code
@ 2023-08-03 15:56 Russell King (Oracle)
  2023-08-05  1:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King (Oracle) @ 2023-08-03 15:56 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Frank Wunderlich, David S. Miller, Eric Dumazet, Eric Woudstra,
	Jakub Kicinski, Paolo Abeni, netdev

Move marking the PHY as being on a SFP module into the SFP code between
getting the PHY device (and thus initialising the phy_device structure)
and registering the discovered device.

This means that PHY drivers can use phy_on_sfp() in their match and
get_features methods.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
Eric Woudstra has a SFP module that has a realtek PHY on that could
be driven by the realtek PHY driver - except that the PHY is behind
a Rollball access implementation that only supports clause 45 access.

This is a work in progress, but it seems useful in these situations
that drivers should know whether the PHY is on a module very early on,
so that a particular PHY driver instance can choose whether or not to
drive the instance, or maybe use a different PHY driver instance to
drive it - thus allowing a separate set of function pointers for the
clause-45 only accessable PHY.

Some experimental patches can be found at:

https://gist.github.com/ericwoud/d912301a93cd41b39621a65cc372a5c0#file-0000-oem-sfp-2-5g-t-patches-realtek-short-c

and onward discussion prompted this patch. Ignore the first non-patch
C file!

Tested on Armada 388 Clearfog (with additional code in phy_probe() to
print the state of phy_on_sfp().)

 drivers/net/phy/phy_device.c | 2 --
 drivers/net/phy/sfp.c        | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 61921d4dbb13..da544faf1661 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1487,8 +1487,6 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 
 		if (phydev->sfp_bus_attached)
 			dev->sfp_bus = phydev->sfp_bus;
-		else if (dev->sfp_bus)
-			phydev->is_on_sfp_module = true;
 	}
 
 	/* Some Ethernet drivers try to connect to a PHY device before
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index d855a18308d7..4ecfac227865 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -1763,6 +1763,9 @@ static int sfp_sm_probe_phy(struct sfp *sfp, int addr, bool is_c45)
 		return PTR_ERR(phy);
 	}
 
+	/* Mark this PHY as being on a SFP module */
+	phy->is_on_sfp_module = true;
+
 	err = phy_device_register(phy);
 	if (err) {
 		phy_device_free(phy);
-- 
2.30.2


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

* Re: [PATCH net-next] net: phy: move marking PHY on SFP module into SFP code
  2023-08-03 15:56 [PATCH net-next] net: phy: move marking PHY on SFP module into SFP code Russell King (Oracle)
@ 2023-08-05  1:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-05  1:30 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, hkallweit1, frank-w, davem, edumazet, ericwouds, kuba,
	pabeni, netdev

Hello:

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

On Thu, 03 Aug 2023 16:56:24 +0100 you wrote:
> Move marking the PHY as being on a SFP module into the SFP code between
> getting the PHY device (and thus initialising the phy_device structure)
> and registering the discovered device.
> 
> This means that PHY drivers can use phy_on_sfp() in their match and
> get_features methods.
> 
> [...]

Here is the summary with links:
  - [net-next] net: phy: move marking PHY on SFP module into SFP code
    https://git.kernel.org/netdev/net-next/c/f4bf467883f2

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

end of thread, other threads:[~2023-08-05  1:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 15:56 [PATCH net-next] net: phy: move marking PHY on SFP module into SFP code Russell King (Oracle)
2023-08-05  1:30 ` 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).