Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795993585; b=4l8JRaYAbeBavVG5UiqDsIl9t16ZrgHCnm/8TklrLfuc8qMXl5sGJ6Ie7plg3liYp4fa 1hh5+voDEQCsEKXFy5xeJfyeOaGd6HX947Jm4Jbhi8n6C8ciUowcAGERWq4KSIybqNI2y NMWFKF8e/rekF9FW9bD+Ok0LvRT9Mq/onqJ+iCQpKsHpbL6bAwiAfhTuc0wX+TsbWpRnQ UKjycG1O8CaRJAoU+VkGhQ/OeC4TF25+lz/g4JZowJ/K5nCU6OtB9dCOFpqulSZfmtLDs qRkyiuoJmDa9eLttRoOkDtNmIJhDfWYK0caYOp0T8p93zK6T7wRzt4BDflQg1ox2HDA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795993585; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=WkkPuq5tNr+TLMvQhiW+fzQBO0e76WILHXlkwAiGW7s=; b=jPQAUuCGt5a01uilpddLfBXeW2B7TybejQl9A8MN7gM44ByJ3UJJSzBiKy3uoRzSZO3t 2vtXLjuiq6md81czGO5HMvhhcqEtH2Zt0w5Opt/WsUy6/3a7ISbYYtY4x5vVo9Lyz6QyL 27hXxS9/p8KeRWrpGfOeILUfmWGeAdzMR7t8PFNw6MoayPoFARfBWWr/zQ32Q0J81bS8V Sqry3aOJZa6lywBzwXUmthl2sIiMVLb5NXksj+qT0cEIZmSaCgPK0+ph/BSL1jUtKjXpE jbH4FomksZvrrNJhDjkHjVTxHMOPlwabZDlges0u8GhTY1Okiev32BLx5n0531un0Vw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ImwFxREU; arc=none smtp.remote-ip=209.85.221.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D12B3606A327 for ; Sun, 29 Nov 2026 23:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D12B3606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ImwFxREU Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-491846221ffso8661448f8f.3 for ; Sun, 29 Nov 2026 15:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795993583; x=1796598383; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=WkkPuq5tNr+TLMvQhiW+fzQBO0e76WILHXlkwAiGW7s=; b=ImwFxREUTCUjnio6QHq/Mk+vXom2O5pi7W3V92qXr4p+Cs15kUb88DLOk4xO4GBcKB tt6iEtfbw0vtyIBVUmhBl4HBKBV+k1zSnu4PPWcYPtaFWPeqQBn5rspvB9fTGHt01h9h mCS3ifCJR4LRrFqwsk9P18c7maR4n00SAnRBRiMZl9gDrv6coFI38o4VvYhR7o7uT/+Q SpqSxKkkRkn/yrVy+MZXku9Ak+Mv10wnA1b7ZrHLrctC2WM0UnBz9T9W32lLHjpz7fj1 1hNLh/SLr1JnhW3VNCGUJlk408DSdEof8Nhvh0qWz4ZVZo2aUxlu9/6PToY54VrM3mE2 944g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795993583; x=1796598383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=WkkPuq5tNr+TLMvQhiW+fzQBO0e76WILHXlkwAiGW7s=; b=GCyLh3WV5MjlZD8XF9x50J0Cwwp581AwyqfiR4enEsk1cu/WkKiBVvH4wffhZbRtEX OtGwHvo1M3sNonLzRbJUbnRm+9+jF6TkBpK+7bpytU1BHZ+AUueXIbivS1+i6EDmqv3r s6LP9xZ2TjiUQ2Pet6qnyMgQ/jZ8tkiSbOOwGQqvFSLHzK97ndjw3DLSAJ+40UWu8jEN gy7Ker+ct7m8dGCxeZl3cRgVA2BmNCFvgnIN8r9su1xXXnx+NCPozvqWt8P0pI/+sPWb VbeCQkflZML3cTl1QdyaHiMB3o1SVEd+LZHuAIDeWrLw1aAPFDrMpnkRGpLT6TPPdOb4 9F4g== X-Forwarded-Encrypted: i=1; AL+hErGslO0VLtPXdVerUd8FZ+JRVbvhfVBL+IsHkHOmDQEFNBKJHJoPAHWToPJZEAEzD3JisvVbYXph2p9z@vger.kernel.org X-Gm-Message-State: APuU4Z+8PEgMtPLrE5ud2tz4g11HLQhI82BqGe7Mh8GvkyqgTpuB7YpD 5+UWpY2PLaJacLx/4ImXBJH1NN84JpRvFlwGWNShuccF51EmAyek0/Rq X-Gm-Gg: AZFdTZeG8xIJ2czL+Gxgh2cFLkmfWJrO/6jewLidrd17EcLgmx5b+ST2vFFHPSsuUNv vxEkNwAQB+v//+IAtHhZCtd5GI7j/5QI0nA3CcaA4+XBecoeVzIyzEHDjnsA4qqiCGPQyiu8fvo vOdydIa5eSZ9xKswk2wYNREK3H6JwrZKXci0IEJCgZk5QubnkH+unTp4ZIr9f6+Bb0RaA9CjFy4 Z1CskkicvBDiKMspIxay30HYSQAXkyXbx6UWrQ2ee86iGBhklIdihw8GXNCCV+c/MJC5kZKqXj5 t/2mPVk5XHN1pN7HNtmzINbfuMAcpmOGMo+ARBxZPXKrxqmCA9YcYsrHrA2PHiHJmWqaGrfyLpF nB5GwLUOMP/3EvEq2/z+y/2ofIk+Arq2ml8X0ZvWjwz5IIED4wMQMG4Kbwm0BEZF7z3rGC+5mBQ z0N+IfXGpBEDKJgTkZC5QVvIemmbEzmSWQ/IjWVm2iVpcGFDJZO6Rn/u4rK5xXdSOGYH2JcHtT3 j9vLPcSZx6fiHhnYR33T9HoGYR/h3ovxeAJP5YB7zydZdhf+680/z6hpUvttaBSdRzML9nbYl3J Rt8Ae6qgRUroo1PJxzmJFPbqD1uRJl+hx/PofOm1tdmRJ0/MbUDjv4qjeB0Wx6Y0hqiCHu/wrcA gr8QGhSQ+k/CObAY0FQ== X-Received: by 2002:a05:6000:290b:b0:4b7:8363:682 with SMTP id ffacd0b85a97d-4b7836306d3mr38286419f8f.16.1795993583234; Sun, 29 Nov 2026 15:06:23 -0800 (PST) Received: from Ansuel-XPS24 (93-34-92-103.ip49.fastwebnet.it. [93.34.92.103]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4ab6c4353d6sm58448894f8f.56.2026.11.29.15.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 15:06:22 -0800 (PST) From: Christian Marangi To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Willem de Bruijn , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , Christian Marangi , Lorenzo Bianconi , Heiner Kallweit , Russell King , Maxime Chevallier , Philipp Zabel , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , "Russell King (Oracle)" , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev Subject: [PATCH net-next v23 02/15] net: phylink: keep and use MAC supported_interfaces in phylink struct Date: Mon, 30 Nov 2026 00:05:32 +0100 Message-ID: <20261129230558.612526-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261129230558.612526-1-ansuelsmth@gmail.com> References: <20261129230558.612526-1-ansuelsmth@gmail.com> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add in phylink struct a copy of supported_interfaces from phylink_config and make use of that instead of relying on phylink_config value. This in preparation for support of PCS handling internally to phylink where a PCS can be removed or added after the phylink is created and we need both a reference of the supported_interfaces value from phylink_config and an internal value that can be updated with the new PCS info. Tested-by: Maxime Chevallier Reviewed-by: Maxime Chevallier Signed-off-by: Christian Marangi --- drivers/net/phy/phylink.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index d736604b86f4..20759fe47eaa 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -63,6 +63,12 @@ struct phylink { /* The link configuration settings */ struct phylink_link_state link_config; + /* + * What interface are supported by the current link. + * Can change on removal or addition of new PCS. + */ + DECLARE_PHY_INTERFACE_MASK(supported_interfaces); + /* The current settings */ phy_interface_t cur_interface; @@ -633,7 +639,7 @@ static int phylink_validate_mask(struct phylink *pl, struct phy_device *phy, static int phylink_validate(struct phylink *pl, unsigned long *supported, struct phylink_link_state *state) { - const unsigned long *interfaces = pl->config->supported_interfaces; + const unsigned long *interfaces = pl->supported_interfaces; if (state->interface == PHY_INTERFACE_MODE_NA) return phylink_validate_mask(pl, NULL, supported, state, @@ -1808,7 +1814,7 @@ static int phylink_create_sfp_cage_port(struct phylink *pl) port->is_mii = true; port->active = true; - phy_interface_and(port->interfaces, pl->config->supported_interfaces, + phy_interface_and(port->interfaces, pl->supported_interfaces, phylink_sfp_interfaces); phy_port_update_supported(port); @@ -2111,6 +2117,9 @@ struct phylink *phylink_create(struct phylink_config *config, __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); timer_setup(&pl->link_poll, phylink_fixed_poll, 0); + phy_interface_copy(pl->supported_interfaces, + pl->config->supported_interfaces); + linkmode_fill(pl->supported); linkmode_copy(pl->link_config.advertising, pl->supported); phylink_validate(pl, pl->supported, &pl->link_config); @@ -2243,7 +2252,7 @@ static int phylink_validate_phy(struct phylink *pl, struct phy_device *phy, * those which the host supports. */ phy_interface_and(interfaces, phy->possible_interfaces, - pl->config->supported_interfaces); + pl->supported_interfaces); if (phy_interface_empty(interfaces)) { phylink_err(pl, "PHY has no common interfaces\n"); @@ -3062,12 +3071,12 @@ static phy_interface_t phylink_sfp_select_interface(struct phylink *pl, return interface; } - if (!test_bit(interface, pl->config->supported_interfaces)) { + if (!test_bit(interface, pl->supported_interfaces)) { phylink_err(pl, "selection of interface failed, SFP selected %s (%u) but MAC supports %*pbl\n", phy_modes(interface), interface, (int)PHY_INTERFACE_MODE_MAX, - pl->config->supported_interfaces); + pl->supported_interfaces); return PHY_INTERFACE_MODE_NA; } @@ -3946,14 +3955,14 @@ static int phylink_sfp_config_optical(struct phylink *pl) phylink_dbg(pl, "optical SFP: interfaces=[mac=%*pbl, sfp=%*pbl]\n", (int)PHY_INTERFACE_MODE_MAX, - pl->config->supported_interfaces, + pl->supported_interfaces, (int)PHY_INTERFACE_MODE_MAX, pl->sfp_interfaces); /* Find the union of the supported interfaces by the PCS/MAC and * the SFP module. */ - phy_interface_and(pl->sfp_interfaces, pl->config->supported_interfaces, + phy_interface_and(pl->sfp_interfaces, pl->supported_interfaces, pl->sfp_interfaces); if (phy_interface_empty(pl->sfp_interfaces)) { phylink_err(pl, "unsupported SFP module: no common interface modes\n"); @@ -4191,7 +4200,7 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) /* Set the PHY's host supported interfaces */ phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces, - pl->config->supported_interfaces); + pl->supported_interfaces); phy_set_upstream_port(phy, pl->sfp_cage_port); -- 2.55.0