Re: [PATCH net-next v15 07/15] net: phy: Introduce generic SFP handling for PHY drivers

Andrew Lunn
2025-11-11T03:58:53Z

On Thu, Nov 06, 2025 at 10:47:32AM +0100, Maxime Chevallier wrote:
> There are currently 4 PHY drivers that can drive downstream SFPs:
> marvell.c, marvell10g.c, at803x.c and marvell-88x2222.c. Most of the
> logic is boilerplate, either calling into generic phylib helpers (for
> SFP PHY attach, bus attach, etc.) or performing the same tasks with a
> bit of validation :
> - Getting the module's expected interface mode
> - Making sure the PHY supports it
> - Optionaly perform some configuration to make sure the PHY outputs
> the right mode
>
> This can be made more generic by leveraging the phy_port, and its
> configure_mii() callback which allows setting a port's interfaces when
> the port is a serdes.
>
> Introduce a generic PHY SFP support. If a driver doesn't probe the SFP
> bus itself, but an SFP phandle is found in devicetree/firmware, then the
> generic PHY SFP support will be used, relying on port ops.
>
> PHY driver need to :
> - Register a .attach_port() callback
> - When a serdes port is registered to the PHY, drivers must set
> port->interfaces to the set of PHY_INTERFACE_MODE the port can output
> - If the port has limitations regarding speed, duplex and aneg, the
> port can also fine-tune the final linkmodes that can be supported
> - The port may register a set of ops, including .configure_mii(), that
> will be called at module_insert time to adjust the interface based on
> the module detected.
>
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

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

Andrew