[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260127134202.8208-10-maxime.chevallier@bootlin.com>
Date: Tue, 27 Jan 2026 14:41:57 +0100
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: davem@...emloft.net,
Andrew Lunn <andrew@...n.ch>,
Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Russell King <linux@...linux.org.uk>,
Heiner Kallweit <hkallweit1@...il.com>
Cc: Maxime Chevallier <maxime.chevallier@...tlin.com>,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
thomas.petazzoni@...tlin.com,
Christophe Leroy <christophe.leroy@...roup.eu>,
Herve Codina <herve.codina@...tlin.com>,
Florian Fainelli <f.fainelli@...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,
Romain Gantois <romain.gantois@...tlin.com>,
Daniel Golle <daniel@...rotopia.org>,
Dimitri Fedrau <dimitri.fedrau@...bherr.com>
Subject: [PATCH net-next 09/13] net: phy: phy_port: Store information about a MII port's occupancy
MII phy_ports are not meant to be connected directly to a link partner.
They are meant to feed into some media converter devices, so far we only
support SFP modules for that.
We have information about what MII they can handle, however we don't
store anything about whether they are currently connected to an SFP
module or not. As phy_port aims at listing the front-facing ports, let's
store an "occupied" bit to know whether or not a MII port is currently
front-facing (i.e. there's no module in the SFP cage), or occupied (i.e.
there's an SFP module).
Signed-off-by: Maxime Chevallier <maxime.chevallier@...tlin.com>
---
drivers/net/phy/phy_device.c | 4 ++++
drivers/net/phy/phylink.c | 4 ++++
include/linux/phy_port.h | 3 +++
3 files changed, 11 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 12c8c2ff2c06..1dba5f06124f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1636,6 +1636,8 @@ static int phy_sfp_connect_nophy(void *upstream)
}
}
+ phydev->sfp_bus_port->occupied = true;
+
/* we don't use phy_add_port() here as the module port isn't a direct
* interface from the PHY, but rather an extension to the sfp-bus, that
* is already represented by its own phy_port
@@ -1649,6 +1651,8 @@ static void phy_sfp_disconnect_nophy(void *upstream)
{
struct phy_device *phydev = upstream;
+ phydev->sfp_bus_port->occupied = false;
+
if (phydev->attached_dev)
phy_link_topo_del_port(phydev->attached_dev, phydev->mod_port);
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 6c62604b00a6..3f76b1bbb627 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -4044,6 +4044,8 @@ static int phylink_sfp_connect_nophy(void *upstream)
}
}
+ pl->sfp_bus_port->occupied = true;
+
pl->mod_port = port;
return 0;
@@ -4053,6 +4055,8 @@ static void phylink_sfp_disconnect_nophy(void *upstream)
{
struct phylink *pl = upstream;
+ pl->sfp_bus_port->occupied = false;
+
if (pl->netdev)
phy_link_topo_del_port(pl->netdev, pl->mod_port);
diff --git a/include/linux/phy_port.h b/include/linux/phy_port.h
index 4e2a3fdd2f2e..8d4f20bfd9dd 100644
--- a/include/linux/phy_port.h
+++ b/include/linux/phy_port.h
@@ -51,6 +51,8 @@ struct phy_port_ops {
* @is_mii: Indicates if this port is MII (Media Independent Interface),
* or MDI (Media Dependent Interface).
* @is_sfp: Indicates if this port drives an SFP cage.
+ * @occupied: Indicates if this port feeds into an another component that has
+ * a front-facing interface.
*/
struct phy_port {
u32 id;
@@ -71,6 +73,7 @@ struct phy_port {
unsigned int active:1;
unsigned int is_mii:1;
unsigned int is_sfp:1;
+ unsigned int occupied:1;
};
struct phy_port *phy_port_alloc(void);
--
2.49.0
Powered by blists - more mailing lists