From nobody Mon Feb 9 01:21:04 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 E66D7374187 for ; Wed, 28 Jan 2026 20:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769633165; cv=none; b=GOUuoejyDysaGWkG262XNB1eB/tixUGxIlvLIYCPZuZfgNZ7JmMJKRQHvAPlzc7RrSn4bt3PjpW8fmZ9WJluzykLCMRAY5g+JYsOHLNV6EKRq4soO0U5RFZo3AckkuroVVUz/ZqLyzxgPe+w8q1WmZeXyXEt/zjyPpz7ZGBeAS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769633165; c=relaxed/simple; bh=8TVyC6x+LERylINnEFufkxpsszyKPPCV4NogcQE1PX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e++w2jVeifqmJMYsYvJJ4ClPWgB2RIhLpgl3BIO+6ubu983id1N1oa3vRW+3QtOifhDRHwSgy81AfVZZrfp+wfaJ4MizaEWjUnhMLYDcHPOfF9Fja0IYQm/M96xHx5zs17uWtneZpS83O//KnJyDg5xg5CnsxGv1OTrSHAX+yXY= 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=SEUmTiLu; arc=none smtp.client-ip=185.171.202.116 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="SEUmTiLu" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 38B4DC211F0; Wed, 28 Jan 2026 20:46:03 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8CE816071F; Wed, 28 Jan 2026 20:46:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A3FDC119A883A; Wed, 28 Jan 2026 21:45:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769633159; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=EfrB/TlHWZaN3FYrouByYYSXCqEx7CiilkYmV+/LR/M=; b=SEUmTiLugsrDI5cguJIBFmA3WAP1z80mXBa5V1pSDuxhEmMkjXUJF+NcZIH01LH6pKcU1X NnfW5FvT3hZEqS4rQ3k1VGJW33eghjxABpS6vvYa2Qq6a+cV3J5oQWBEEkiiqTepsE5xNe FTCjHOMG/IH7MeZupe/4GTFczmUIRw/YQ3xkAo7Q6f1q5HBUu+uX1yp0xJOJioiw1zl/hu 9TYolcCn9EDOQAkhp7EDOHPPl4szbjbmrZwglwb+Zt0+rccWRwdYWsHAXfrP9bGFOzyViK mfWbnP3bShfpZpquLZSbElzO72Z5nsOZWaWlrWMEdjdhstCmP24Ok1t1X9aZyA== 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 v2 09/12] net: phy: phy_port: Store information about a MII port's occupancy Date: Wed, 28 Jan 2026 21:45:22 +0100 Message-ID: <20260128204526.170927-10-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260128204526.170927-1-maxime.chevallier@bootlin.com> References: <20260128204526.170927-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 "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 --- 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 b3125cf30bf3..9dba31b9cb86 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) } } =20 + phydev->sfp_bus_port->occupied =3D 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 =3D upstream; =20 + phydev->sfp_bus_port->occupied =3D false; + if (phydev->attached_dev) phy_link_topo_del_port(phydev->attached_dev, phydev->mod_port); =20 diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 21af1dffa837..bb257e91cdf6 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -4047,6 +4047,8 @@ static int phylink_sfp_connect_nophy(void *upstream) } } =20 + pl->sfp_bus_port->occupied =3D true; + pl->mod_port =3D port; =20 return 0; @@ -4056,6 +4058,8 @@ static void phylink_sfp_disconnect_nophy(void *upstre= am) { struct phylink *pl =3D upstream; =20 + pl->sfp_bus_port->occupied =3D false; + if (pl->netdev) phy_link_topo_del_port(pl->netdev, pl->mod_port); =20 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; }; =20 struct phy_port *phy_port_alloc(void); --=20 2.49.0