From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795993585; b=qVv5DJVlYZYJ+ampZJC7AtEQAFhihQZvT4UpeJsURK3tjLZIPADDAuhf3ojQHtABsQel Ema8ju8H7dJLH9I9HSFWOCOcj2IeUVGyW1B29DlSAcZ+7GQQr+QnWyxJ2+NoNf9p5HU9S 8nMpkIYx6TO1+4i3gae7SFtuEKZlhlzBQeKXcV6DpYiRpJDTIGbz3ohUGngFy+faCgiJe IKkD6k/p8PhrQuYd0PAUEzXAkhT6GDK4Yz51Fc0uRKcHLHd0gMVQoH89nOVsMNZZ/gSKK Su2Pj7phGz+sgLyLk820EEUazDBXKJYC1aYk+kXt7+E+VzPp4oc/sKBcSOG3LYQrADw== 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=vtaWtHB7cYYn/bVlQ6C3PDZA3VW4WZOULDhAYmETCa9wEGFlbwSXGtTr+YUQfu0Nd4Py iE99o1n+RRJPkuG9lYlp9cf8NaidCrhVKDI9cKfAzWhCKNPSRy2bOfZwBhTy8iqI2CTML YVMaItm5C3FEDLhKC7xGbrQ0yr/XWAqooudK7F7+FQMjEMxPZGI1yHmse99KIeGgNA4yU yygE7DR9DCapc+Y7EP1UtiO/LCvTCYCM+jDbcLrumvibh+UO549Qjr6wrdTPLIHdwvAGh rjBLytzRBvypGNG+QKN4aoAQC1FrKixOdqXfM2UbLMjNrtrwo16DAprwnW3F6LkBivg== 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.50 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 E1771606A6A2 for ; Sun, 29 Nov 2026 23:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E1771606A6A2 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-f50.google.com with SMTP id ffacd0b85a97d-492f0a1b685so7096774f8f.0 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=C1PDC5FKDEb2VKLmVMaZSWwwQrg7zD94AFdjGktrUJGjH9nNYhZ3ZW4aN/ZBiYFQia o2NIqSkvXR0B6M1PmADOvio61CRpvxPIfw2ClebaHcMp5v3Q1uHQSSoxFs7WGygTgY79 1vLmlGOB/xHNIAjNtewj7TMWVU8QjITwumzI8tRx2UP8VLwwtczVzDt3DLSd3w2j0S81 tdJJMC8lg85hIeATnb2wyx+juTF8DlaQIiKoEp1W3IpxZtD4quWuzxWRRTWTPBJz2Ay4 ecbWj4VhabZlTD+JptTwrheWQSAVe5jFK8iiToXPhZnHqtrTnGhib9/dhGQIaatCkfcp f1IQ== X-Forwarded-Encrypted: i=1; AL+hErE47j8JcVlntkmWnFsQIHhGk4t3WiN5wqtbHBHRMs5WkqNpiR4bW/Jffp2Ht3X97E1/66K7KsE=@vger.kernel.org X-Gm-Message-State: APuU4Z90vtooaodLUtUj3Q08ZMRSssWAEwTOQRWRWdoBZ19I+f5kMOdI Ta5LHHdok2BY4P8ezuMhQjclkUUSG0FDKkteB4yiYKPQFtPl+B1XaKxF X-Gm-Gg: AZFdTZehLiOSxqlmH3awPmQ/rw6Eo8L6m5JcA+64LaNbgFur1RJaKW6rmWhS+A4L/Ob FKU6HhrCKUJGl4xp4NPJRN9SFC5IPA5/YBQ0gDJvNaieciZ7pLfjAiOSUKzcO5MCebPgxPFwhXB YwGv8Z10/O/jfZ9v4eo8Ju0cKfZtpUc0PMtarFwsbegYzMsyf9QOEwsgMHwAUcoR1xQ6K4AX/MI 70Qz0TeXxRkT+5vrc8IAEqyFX9kQdXanCNu427lLNKEHS01N3buNDAxVdf04zhvRL04Mev7RZP4 9AHI6UXJkRvuI0uYgShClCwcXO8pzhmquAMzAYvDnBPTNB3ccqYOKNwJy3pN8n1jja9e2xdx9E8 Zh4T9Caf11pVuEkvx6S0+tM5zQ64TooUHBhSNEnil8V68byrPMGSXZU5L5YmCqCYoBTM1PLHjZG AECI88udyF0L7XrxkBfHlLRTbfKkHppphmMvq0T7nyWqsIc5LDckrI4AQC4NbZJeGU88e6XM28Y kTYGH8eaj/bgBifair4uwBPczLCJmIdW1FLAJHj7FNr+MskFI47Yy01WuQ+tMagtKb3R2rMexI+ dlGRIVN60lL3C5QntPtBbYo3gZkIlGnvHqjandQsGxJkO13bV9C6CgvDmXHrdklyhuZJradsGEN Ze0N2KSXg6zDiEcypEQ== 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: netdev@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