From nobody Mon Feb 9 04:14:11 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 EB13D394474 for ; Thu, 5 Feb 2026 09:24:01 +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=1770283442; cv=none; b=lWCUd7aO/b+E1AV3SGur+vnrAjY2qKKiEz38h38xsqUYi29k9e3+zo+EAbL/VH154byqHTx7C6/aeW1zj2AoeOHOcBmdhkvnOmk0ndkT4dYEgQjK61pAtqMmIPTujjBo8LdqEGS1Vp4JRChgcZG3j9vFRwq4KzOpwdI37LyVY+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770283442; c=relaxed/simple; bh=f0/3/mrCPrJHqIVyCbu48EYwHwbuoZwmfW42AbHjWH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=slxBfzq/lPoXtejF4JyljNRBeR9uNxwsaZ1BeAYvNVBFDGzYJ3OgvZ/26QVK4FxbLMsLInCLymcGlZ6pbasibu7lK/PGAM2A+bgykRocsDDX0ArQrUg3et4S/RQqlLMx1f0Oy1O3v/yUsUU8/+D4Y/onGP1KIOHSgvzgXdjsk+4= 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=qH8ncLSs; 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="qH8ncLSs" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id C4FFA4E42414; Thu, 5 Feb 2026 09:24:00 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 97B14606FD; Thu, 5 Feb 2026 09:24:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4B70A119A88FE; Thu, 5 Feb 2026 10:23:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770283439; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=oE3YHgEOb7zMldz7W5UEO4lNk/cteuFmDnyVlbi0dJs=; b=qH8ncLSsYvdTadRoMZyjjg0gRYIzJKMHnLkQQqNxdKXlHl+jQY5qAGdt5N/1Rz7+liBc2D XWjxUx0chyyCXrvR0QjWVoyXvxdYdfhwbuuGdVoQSxE1eIpCI0AM8Wc40pyHQL3RIpDfH2 AYlF4TRdh9g9ZIiTvDmzUJeTScs5wEBwcp0EjaL6NifZrDG2yisxfDclSIQRBKtArBM6c3 MaWksKhioFfv/O4HBvZ/8jo9mkw1Iz/FNWnNfJ7upeofvDY95O2hr/Kpd9qejZyAbTnWrX 56Q4nqui8q2xjrxWZ9mvZc5vfxqDMICcz2HnNJmvLp9sNHYhN2XsWMvY0b0RDw== 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 11/13] net: phy: phy_link_topology: Add a helper to retrieve ports Date: Thu, 5 Feb 2026 10:23:14 +0100 Message-ID: <20260205092317.755906-12-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" In order to allow netlink access to phy_ports, let's add a helper to retrieve them. When handling a port coming from phy_link_topology, the caller must hold rtnl until it's done with it. Signed-off-by: Maxime Chevallier --- include/linux/phy_link_topology.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/phy_link_topology.h b/include/linux/phy_link_top= ology.h index 66bceff72b19..ac2f5c80f1a6 100644 --- a/include/linux/phy_link_topology.h +++ b/include/linux/phy_link_topology.h @@ -13,6 +13,7 @@ =20 #include #include +#include =20 struct xarray; struct phy_device; @@ -66,6 +67,20 @@ phy_link_topo_get_phy(struct net_device *dev, u32 phyind= ex) return NULL; } =20 +static inline struct phy_port * +phy_link_topo_get_port(struct net_device *dev, u32 port_id) +{ + struct phy_link_topology *topo =3D dev->link_topo; + + ASSERT_RTNL(); + + if (!topo) + return NULL; + + /* Caller must hold RTNL while handling the phy_port */ + return xa_load(&topo->ports, port_id); +} + #else static inline int phy_link_topo_add_phy(struct net_device *dev, struct phy_device *phy, @@ -95,6 +110,12 @@ phy_link_topo_get_phy(struct net_device *dev, u32 phyin= dex) { return NULL; } + +static inline struct phy_port * +phy_link_topo_get_port(struct net_device *dev, u32 port_id) +{ + return NULL; +} #endif =20 #endif /* __PHY_LINK_TOPOLOGY_H */ --=20 2.49.0