From nobody Mon Feb 9 05:52:08 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50924225788; Sun, 1 Feb 2026 15:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769958819; cv=none; b=G0w3dgwuAUgBNc8EYw23Ecw+obINw14rloFqplPhhWo3jHtFkCLdrXUQwnbpYDbWf5YIDX85voSgUZIZ4O2c7QrsoPJYOg/u4gpiXMto9xchOCYDtd3RKT9f/s5HZPiL97ghAraHqN4OqBlqTHtpijJVxVONA2aOP9cbSj4RyQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769958819; c=relaxed/simple; bh=Jc94vYLV/GsipNh1CGN+2SzM3QQD66FflqMe2kzRESQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZhfgnI0QxHRMLhNlGp0khXMhZK2g22VafKkFF7iJAllev9DBLgIipmM063UzYUxzRAqHkqZXqRoMj8jgapWwRd28tmammjVxw2PvKTqtU7mzVoWS9KakfsDRhMTtM3VB4PrQYC8dft6BF6TMARZ3XmKvCQ3DoPiLJNOjLQIQWkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jYY/qK3D; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jYY/qK3D" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 334FC1A2B83; Sun, 1 Feb 2026 15:13:31 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0514360720; Sun, 1 Feb 2026 15:13:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 85627119A88FB; Sun, 1 Feb 2026 16:13:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769958809; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=kChgYsFtpHJQ5CpF9yNytQY0bGT41kNRddXfgSxnAew=; b=jYY/qK3DB42Ah/DNeRFFPdgbNqsV4ggpfX7g9t2E2N2mZSRS/l1252ffgNRYqMsew5T9/D vPhgHvFWzmQH6vTvh1trRrMTsWur6jNdG/pSnEMg2KM6i6jQEU66bM0Syk68DV9drbhtW4 X7MRzTqw7ATCsJmixlfjpEpPNJMAOaSqbHFBnEKh0GFgZna5vQXwQyN7oW9TwTTm2ALKJR zqepe3RGAEakyGJCpxjMiGdEoLYI6324vFJWaMTZJZzuqNKHOr0FpQ9j/qzqBrElDhekJk CKionkf5+d5FLzrlAHSVexl+8uNagwCnKlX2IuwzevkjFImEQCihWMf84EMoJg== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Christophe Leroy , Herve Codina , Florian Fainelli , Vladimir Oltean , =?UTF-8?q?K=C3=B6ry=20Maincent?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org, Romain Gantois , Daniel Golle , Dimitri Fedrau Subject: [PATCH net-next v3 08/11] net: phy: phy_port: Store information about a MII port's vacant state Date: Sun, 1 Feb 2026 16:12:45 +0100 Message-ID: <20260201151249.642015-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260201151249.642015-1-maxime.chevallier@bootlin.com> References: <20260201151249.642015-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" 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 "vacant" bit to know whether or not a MII port is currently vacant (i.e. there's no module in the SFP cage), or not (i.e. there's an SFP module). Signed-off-by: Maxime Chevallier --- drivers/net/phy/phy_device.c | 11 +++++++++-- drivers/net/phy/phylink.c | 6 ++++++ include/linux/phy_port.h | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 37efde56e54a..2a3d24310235 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1580,6 +1580,8 @@ static int phy_sfp_module_insert(void *upstream, cons= t struct sfp_eeprom_id *id) if (port->ops && port->ops->configure_mii) return port->ops->configure_mii(port, true, iface); =20 + port->vacant =3D false; + return 0; } =20 @@ -1588,8 +1590,12 @@ static void phy_sfp_module_remove(void *upstream) struct phy_device *phydev =3D upstream; struct phy_port *port =3D phy_get_sfp_port(phydev); =20 - if (port && port->ops && port->ops->configure_mii) - port->ops->configure_mii(port, false, PHY_INTERFACE_MODE_NA); + if (port) { + if (port->ops && port->ops->configure_mii) + port->ops->configure_mii(port, false, + PHY_INTERFACE_MODE_NA); + port->vacant =3D true; + } =20 if (phydev->n_ports =3D=3D 1) phydev->port =3D PORT_NONE; @@ -1755,6 +1761,7 @@ static struct phy_port *phy_setup_sfp_port(struct phy= _device *phydev) */ port->is_mii =3D true; port->is_sfp =3D true; + port->vacant =3D true; =20 /* The port->supported and port->interfaces list will be populated * when attaching the port to the phydev. diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index d65fa6cd1ebb..95bd86d43f19 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3924,6 +3924,9 @@ static int phylink_sfp_module_insert(void *upstream, pl->sfp_may_have_phy =3D caps->may_have_phy; pl->sfp_port =3D caps->port; =20 + if (pl->sfp_bus_port) + pl->sfp_bus_port->vacant =3D false; + /* If this module may have a PHY connecting later, defer until later */ if (pl->sfp_may_have_phy) return 0; @@ -3935,6 +3938,9 @@ static void phylink_sfp_module_remove(void *upstream) { struct phylink *pl =3D upstream; =20 + if (pl->sfp_bus_port) + pl->sfp_bus_port->vacant =3D true; + phy_interface_zero(pl->sfp_interfaces); } =20 diff --git a/include/linux/phy_port.h b/include/linux/phy_port.h index 4e2a3fdd2f2e..b0b1fa6a67a9 100644 --- a/include/linux/phy_port.h +++ b/include/linux/phy_port.h @@ -51,6 +51,9 @@ 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. + * @vacant: For MII ports, indicates whether or not the port has a connect= ion to + * another device (e.g. for SFP ports, indicates the absence or presen= ce + * of an SFP module) */ struct phy_port { u32 id; @@ -71,6 +74,7 @@ struct phy_port { unsigned int active:1; unsigned int is_mii:1; unsigned int is_sfp:1; + unsigned int vacant:1; }; =20 struct phy_port *phy_port_alloc(void); --=20 2.49.0