From nobody Mon Feb 9 04:14:12 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 9746E3A4F2F for ; Thu, 5 Feb 2026 09:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770283439; cv=none; b=tDECiom6d11dVaufxCpuk5JMI4q8I07lCHTMrxNjrdcrMCYAKBjiUJz2Xdylwh0/UCQK8xPs3XvGVeisF1AIS0J6mMx1Op+w3ltpbrNt+4RdKM0upR4rdVi8G5llDq6t8KzMRZboOUnJOMZQh/nekF9NtUWYuvdsKGeUsWYxjvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770283439; c=relaxed/simple; bh=XuD9XVnfKD2QhNJOtOO0uD9i4JYrx1qqI1maL1kgSxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tvUMDd3ijoo5fnFvVVJXKgXyHjTR950yCpBLR+163AAr01Oc9iD0dFVjLhMFXDtD+gP0cpyz/wPnX0cCfj/i2NON7HaOxNTM/WMSgc8pzSBOtvWIQY9MbDEY6gx31DDYQo/VsSyQEsokR4hMDAWofnp3yu27udl69qv2CB4NEi4= 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=bgnv3mho; arc=none smtp.client-ip=185.246.85.4 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="bgnv3mho" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 570B94E4240F; Thu, 5 Feb 2026 09:23:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2D217606FD; Thu, 5 Feb 2026 09:23:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E2508119A88FD; Thu, 5 Feb 2026 10:23:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770283436; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=AKWPF4/lQBEiNWS/oYcnux6E2kWU0lE9deAv3AQANag=; b=bgnv3mhoSn7qIZhknVglwpHeAOiouNdJlCjhtoeyW3YPVBV7QZ8r+u4kEbkAbWT/Iib1WH 6cy+ObTtdHgSSLWFcDmE9aBdPjlgwV8KU7e4fh6ViuuHtIOojMM3Ru4S5mbwVYyL06VbI0 Z9Kg7SMzu0O4KFkVAA54sMjwLRKAY4PJgmfNrSJdkBYzwwcmJkVifZzYVQkQsmDqpgpqn2 qhIzwcHbEkU6uc16HAd8VMgdanBtUQgxnVsaOXlRv52s+qrUPQVZ5e3JqTKGgke00NMIu9 aZMPAKp0edWnsAtDHVwPhJtzvel9syFhPFVfrnAlI/pdr9oyErUXc1Iw3b5vbA== 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 v5 10/13] net: phy: phy_port: Store information about a MII port's vacant state Date: Thu, 5 Feb 2026 10:23:13 +0100 Message-ID: <20260205092317.755906-11-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260205092317.755906-1-maxime.chevallier@bootlin.com> References: <20260205092317.755906-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 | 17 +++++++++++++---- drivers/net/phy/phylink.c | 6 ++++++ include/linux/phy_port.h | 4 ++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 0daa87413c66..35051ebe4d6b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1550,6 +1550,7 @@ static int phy_sfp_module_insert(void *upstream, cons= t struct sfp_eeprom_id *id) struct phy_device *phydev =3D upstream; const struct sfp_module_caps *caps; struct phy_port *port; + int ret =3D 0; =20 phy_interface_t iface; =20 @@ -1578,9 +1579,12 @@ static int phy_sfp_module_insert(void *upstream, con= st struct sfp_eeprom_id *id) phydev->port =3D caps->port; =20 if (port->ops && port->ops->configure_mii) - return port->ops->configure_mii(port, true, iface); + ret =3D port->ops->configure_mii(port, true, iface); =20 - return 0; + if (!ret) + port->vacant =3D false; + + return ret; } =20 static void phy_sfp_module_remove(void *upstream) @@ -1588,8 +1592,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 +1763,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 f26037ec7ba3..8a22cdc4e60b 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3925,6 +3925,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; @@ -3936,6 +3939,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