From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795993585; b=n1wZofHurzLb+2u3kVrVeDsZiuHzikfgPh/9XwrIB6SjmP42303pdFTwUYqzhebSbKvU 1GtV7GluuV48DtGA85/UdGxYxcxbaSiK7+xr380n0sIrJDXW7VPCEDtKLMkzx36X/qz6q Py5b6LDO1ZrkUB0/9Q2s14oLIiGRkB7PLbD1i5U9ymu6vEMy6b8y14jM8x72dCmnYZOwp i2nHoOb9MZ8M+Vs624aQEbw+ketNBXYE7/P6ILeCbb1ps6hC7nFN3fiz85hLm20+Qvmgl Rd3dwRxQoKdfx3PvqdKsSNig346mt0SNq7ThK84Ff7BEc9U0gjmC6rVAHnh/UeYJosQ== 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=JVWkCfpAagoc1TqweB11vexpPrmbG4D19Kbm8Y3nD2M+RY6ALyNAsrRvcmiE2tjDrmlk F4O1G5EuArT6Bp78TbV1zZRlF7G8TJRKVbTo8RiGreUigd/6eh0yNB3YrknrzhLAoMqNm 2KkUXK9W5gObEgWyfOI2c8f3wp+TDTmwn1mNcF56ingwZ8jU6Cf9yhtWxvwoetcAKoS/A bI3qsOiGrSfVVv3VWA7JsYfiKNUWHLtK0GHMmitRdj7CN+VZi8bTZ6v5cn8dvp2eGep+5 qQ1R/xqenZTjQSh05B45ZaDOXKHd4tyXLonON26qZtNdKDMA9ma9fa0vZJFH3zrYKfg== 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.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 D48EA606A68A for ; Sun, 29 Nov 2026 23:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D48EA606A68A 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-f43.google.com with SMTP id ffacd0b85a97d-4a42b34e930so8694162f8f.2 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=MXgAkkCUpZbaMYkYJoVd/fkXUGAoy8QUSQTNg2dvG2WMaIxay5vTCSTpVg6Pwf4kk/ 9f12XrTk0epHuuvDR0OuNIadn5NeX+O8iniCnDj1jHlXPDPuWPVCxY8StXbYVzk/YnNH cmOHoq4z6Lr0yUd5Ds1q40XPAkcxYH9IeOEfnou0X/Pi8F6MjqX1O3n3Alciitd8GaNn CugxN6iR2/Jh5GgigOfFPkoxoOxandRDUX4Tb/26PL3sZkEnKEkVJJJLx0jb2sYSpjxw umIhZPpVXNNG10inbbhBlft+JwwoeKtnTBUZKxRR+rbEPGiMhyQPlbQueRMqa66h47I5 7uDw== X-Forwarded-Encrypted: i=1; AL+hErGEtsNAmlDABArg8t6l/MDHw5aQJvV+JjkZ256r8wsEPMe32qCvAwwjZFirzX+vxnz+QVBh29kMpww=@vger.kernel.org X-Gm-Message-State: APuU4Z8TNl5W3ZYo8fhX6jTGbkjgzf7CA8/NUz3uBnGh8JuzjYh8Ot0X CncZ+wR7SDGZmKZZ1haMEsRucnfUlgcnBXw/POzWXEkzwfhylDgtMqO3 X-Gm-Gg: AZFdTZe6HfX0csyljfEGA5B6Hb7bp612bYVz6Z/Z2mJBhrIQiMowkj92MdL0e7ZuOJb InT6VrbhjZGc7emu2/UoF8ysfsotlgMo1gDsT7sDIxAN0g/bLSXJg/J8e/dDy40mePsTQoZEcQ9 BE04PmISX7jGpngC3t3Wl8HCBqCYvDqkYnVVJFxWnszi9HKZDYSWCjCrvWKcd0CShH/SfKd4qXd k7JwMguzwwICy3fUq3SapvS+IQg6NmgpK7sQfOB0/guAd513QjULAv6lqWMnIkZwecNbD7AgIoZ +ubrF1FIqZyvmNrxnfT/Mr6gmBgB0MHLH4UGPsE7CH1rK8lnVfoZrH9iRWrVFwFf2EF3onQy400 jJvj8R2/OnGk/WsWva3jfAEjoYtNmVwqiaAUekW3tAnh65A64HBhWA7UJ2kYekfNsoSb7xmKdiZ uug59eChkGgYJDjQ4IJ9P2y/6zLLTnxJt6Vj4g9D5Bueihlj4q1qf4kXWq9fZq1ljPp8jxWUAQK J4pb3gv8Q40H9FKQyo9vNtBS9FCC3rwFlD9Q/fjr7fB996hlv2teox/UAN01OSNfsEur/aVO8BH TAxJj1kdwb2Z0YxMak3F9uwED0yHc4beEGDm0IFBym/Dd+rb8HjLvmSFLatHZtN5+oXEk9edc0M 7r7LfxPFl5JV0m7jGTw== 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: linux-doc@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