[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <762dd1dd-0170-4f7d-b418-1997c48e7f95@lunn.ch>
Date: Sat, 26 Jul 2025 23:05:33 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Maxime Chevallier <maxime.chevallier@...tlin.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
thomas.petazzoni@...tlin.com, Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Russell King <linux@...linux.org.uk>,
linux-arm-kernel@...ts.infradead.org,
Christophe Leroy <christophe.leroy@...roup.eu>,
Herve Codina <herve.codina@...tlin.com>,
Florian Fainelli <f.fainelli@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Vladimir Oltean <vladimir.oltean@....com>,
Köry Maincent <kory.maincent@...tlin.com>,
Marek Behún <kabel@...nel.org>,
Oleksij Rempel <o.rempel@...gutronix.de>,
Nicolò Veronese <nicveronese@...il.com>,
Simon Horman <horms@...nel.org>, mwojtas@...omium.org,
Antoine Tenart <atenart@...nel.org>, devicetree@...r.kernel.org,
Conor Dooley <conor+dt@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Rob Herring <robh@...nel.org>,
Romain Gantois <romain.gantois@...tlin.com>,
Daniel Golle <daniel@...rotopia.org>,
Dimitri Fedrau <dimitri.fedrau@...bherr.com>
Subject: Re: [PATCH net-next v10 07/15] net: phy: Introduce generic SFP
handling for PHY drivers
On Tue, Jul 22, 2025 at 02:16:12PM +0200, 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
> - Optionnaly perform some configuration to make sure the PHY outputs
Too man n's.
> +static int phy_sfp_module_insert(void *upstream, const struct sfp_eeprom_id *id)
> +{
> + struct phy_device *phydev = upstream;
> + struct phy_port *port = phy_get_sfp_port(phydev);
Strictly speeding, this is not allowed, reverse Christmas tree...
The assignment needs to move into the body of the function.
> + if (linkmode_empty(sfp_support)) {
> + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
> + return -EINVAL;
> + }
> +
> + iface = sfp_select_interface(phydev->sfp_bus, sfp_support);
> +
> + /* Check that this interface is supported */
> + if (!test_bit(iface, port->interfaces)) {
> + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
Maybe make this string different to the previous one, so somebody
debugging issues knows which happened?
> +/**
> + * phy_get_sfp_port() - Returns the first valid SFP port of a PHY
> + * @phydev: pointer to the PHY device to get the SFP port from
> + *
> + * Returns: The first active SFP (serdes) port of a PHY device, NULL if none
> + * exist.
> + */
> +struct phy_port *phy_get_sfp_port(struct phy_device *phydev)
> +{
> + struct phy_port *port;
> +
> + list_for_each_entry(port, &phydev->ports, head)
> + if (port->active && port->is_mii)
Naming is hard, but this actually returns the first mii port. Is
there a clear 1:1 mapping? I don't think i've ever seen it, but such a
SERDES port could be connected to a Ethernet switch? And when you get
further, add support for a MUX, could it be connected to a MUX?
Andrew
Powered by blists - more mailing lists