From mboxrd@z Thu Jan 1 00:00:00 1970 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 51AAF2874E1 for ; Wed, 13 May 2026 13:05:54 +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=1778677556; cv=none; b=lV2acQthsSlT4bukrZxnAnbjxiDmQPRpQz+Eo2WA7KCKhFvz+Ubiy3Bb7b4JC5iT3S+FJpvn9Dd9hOAmif6FoslyZNjedZrQyHXYWdnqVCzv7avx8XJgQ0uCK2zmc7E+Cvvt1Enodm1g+Y15Oyb4LmYGM56SzYxF9qDWJJc7pj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778677556; c=relaxed/simple; bh=fWAbBkVP6OrsCofxTRh6Ti7m8xmHUcfzVvxDe6uBViY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DYyx8nF60p9JnZf/K/nhrggJ3sUbH5WHmWCh+C3ZgqMXvqSzzN/r8lpqOwa8i/dNEBWZhh4QPsNWeKzXLOr23dfPGq1zexvuEg+2tQXum+PtdYVmKtKVucT0QxjTkvQoRpH4wvREXwB0xjzjATFGFi1DY6YOwZGpx2u+2U4Uk7o= 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=rWvYlcOQ; 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="rWvYlcOQ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0A5281A359B; Wed, 13 May 2026 13:05:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D33C75FE21; Wed, 13 May 2026 13:05:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 831C011AF9025; Wed, 13 May 2026 15:05:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778677551; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Uf2F6gZp9+WSVu3i+q90UcOD4hXZuyR5rp+CEI+Nu5A=; b=rWvYlcOQClxBN1QaajN7BpC4tqjJdk5bNX+hCw8QCZR2d/ZGantmv+XGW2L1LOkNQfTyw0 0ESaF7v/N/hgDo60nq6+U2T6kZxAafxuVWx6ZnCRuG8IaxLhJCW4cXAMXiike5kIaYtb0W xGPcF+/StQvZU/ZPzSjFE0MoTgzPOGl29p+MK9YekLiMQRRCZMI6ThwOq+gmz7lSSlTX6L T69fP+AhjCm26+TkJnfmcOZ5Vl3Osza9vr7D4X9ZyASYINtotcOKcJQM6v0odwfjl/Ib7+ nfn4Gf95+jNsE3H6arGk3rgZXvN3jYTQrEveQSbJJvWNoRNZ2cd90NmAu0r6fQ== 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 Subject: [PATCH net-next v10 7/9] net: phy: phy_link_topology: Add a helper to retrieve ports Date: Wed, 13 May 2026 15:05:18 +0200 Message-ID: <20260513130521.1064094-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513130521.1064094-1-maxime.chevallier@bootlin.com> References: <20260513130521.1064094-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. 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 66bceff72b19..ac2f5c80f1a6 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; @@ -66,6 +67,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, @@ -95,6 +110,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.54.0