From mboxrd@z Thu Jan 1 00:00:00 1970 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 BA34B47D936; Mon, 20 Jul 2026 17:48:44 +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=1784569733; cv=none; b=FxqK5IXHd8yekxxoAzCE+SNExSNXz4e7Px4m25Hory9OmSw4TKO7uU/3bTCyeCgKAQX/oy8GXCc97i3w/guoT0OghuTieqkvDn/H+OF9U6+isOfvXIywva7DhRCS9DJIGfkgslEfMbw64MLQbIosmFVHTQVmGni1KJUxmIUs72g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784569733; c=relaxed/simple; bh=uwYdefI6vrBB3k3CswAK0XOYBwFo6YjmPb2RPkHAeM0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qtktvcfJM6iixt1kY4Raah+xNpweN/2p/M6R1dgdfsewx7NqJum4CxJOf1JBPoyvjbd8U0jW63l+BeQgWVDraDVGw1Bjxc0diAc/BzDU3+bID48U4P9WaX9CzYlZWco4JkmLC0CRbHm8QxQ02MBscpaRvVtl1fpGU1Ejaxk4Tvo= 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=RTQIfeBB; 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="RTQIfeBB" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 0081F4E40E81; Mon, 20 Jul 2026 17:48:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C8A0060360; Mon, 20 Jul 2026 17:48:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 72C6811BD3A20; Mon, 20 Jul 2026 19:48:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1784569720; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=LZFFDFY7b8tvGOT7HRCR/0tyYdKAfwl1SH9WhKumBIg=; b=RTQIfeBB//TmoMGO9bWg3/cZ3YV0brbMbwVXJwb+dCDLnTM2NcqLckelyqQVfSc1HHszkI 1Fpdzbaz02ofySnkE8RPB8jZzfWVXlZNr3LpUpDYCHXkYIls9RFCu6Dt5Rlgf2J40j/ypj TvW3IZ+5h8bNJuCzhkGTWJJSwvaMaVQcdEe1Wq4kT71rbDces9bj4WmTcua7i0uEvVeZhk jD4XMdtMeeP7apx1W+4XHBt7FD6JDZINHRB1HHtXsHSfBE9looT177JG7r0fTBfm9T5WTX b7LdvfVatc2Za8b53UT5EVyAIpMNCva1pQ961NFH+IJ++WtdiVluNBRKBo/VpA== 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 , Frank Wunderlich , Pietro Ameruoso Subject: [PATCH net-next v14 07/10] net: phy: phy_link_topology: Add a helper to retrieve ports Date: Mon, 20 Jul 2026 19:48:04 +0200 Message-ID: <20260720174808.139573-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260720174808.139573-1-maxime.chevallier@bootlin.com> References: <20260720174808.139573-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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. Reviewed-by: Andrew Lunn 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_topology.h index 296ee514ba46..95629112204e 100644 --- a/include/linux/phy_link_topology.h +++ b/include/linux/phy_link_topology.h @@ -13,6 +13,7 @@ #include #include +#include struct xarray; struct phy_device; @@ -71,6 +72,20 @@ phy_link_topo_get_phy(struct net_device *dev, u32 phyindex) return NULL; } +static inline struct phy_port * +phy_link_topo_get_port(struct net_device *dev, u32 port_id) +{ + struct phy_link_topology *topo = 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, @@ -100,6 +115,12 @@ phy_link_topo_get_phy(struct net_device *dev, u32 phyindex) { return NULL; } + +static inline struct phy_port * +phy_link_topo_get_port(struct net_device *dev, u32 port_id) +{ + return NULL; +} #endif #endif /* __PHY_LINK_TOPOLOGY_H */ -- 2.55.0