From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795993585; b=4a2XK6HAsWEcSxcacvRXubycfVc4iKh07MTjTdFCQCHoVCUK5LE+4l3h9enh8KV1k81p gH9pooQpPHI/V7QhLvY186HMn3BksM9yIO4xfwmVMXezTM2ocUZJAztKfNB+fr15G4OfZ HokVvgcZhACjTcjUobZnCRDYlwoliu5DaB3dzWyuvu0C0vcRtjg32n0qhaWqfYjgUrLN2 txuuwA+hKVT0qympHY7Qr9+O/KdU1MvRjhvCb6bmLi1VaY8Ds7TT3N+3iMKtsan+MeDNl ZuRiPy597KCoAtVQGeIKhcx4vvCptlDfJy3k+SMMKC4S+2dFl2/TrN9PG/w0q95a/JA== 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=geSQ1oMEYboCNbYtU9XMeCnQF6wd7qy/DsSCHyOhrrva6h6G7BQBQSpbaN8wa90wl62E 2wvyhXBBjfwrd0KaIHY8fxWB0hMf8jwSFrUDdGC9+Wbhm/E3+BtgeRHmh1X4XGh7aTKJz V0bDsavrsiyUpEWGK500rajSIubHTdBjzF3UhD0X7LKPacM3wGsEw0jh/hLGD37f975XN wTMiZpTwTVsgO8zrSaiKqYnKpTWXyRc4KNYhJipKkkdYwAiAS9K1O4DHWtpaSLY/XRHSO ZHyTCVBfAKyTrajsKgdi4+ITn1WW4D/5eRhoAhgSTo5Rx8G5s5KKDJVOtfQ7/4qCc+A== 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=neGiyr7Q; arc=none smtp.remote-ip=209.85.221.49 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 E3159606A6A3 for ; Sun, 29 Nov 2026 23:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3159606A6A3 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=neGiyr7Q Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4a42b34e930so8694168f8f.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=lists.linux.dev; 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=neGiyr7QMCx7ff6weo0M/22mmnw4MF/gdBYYtVPwXyXYK2dnnVuuXX6tN08ahssH46 DG5cehATEUN+5xMTeYHffu5nUlp+rx9XM3nx94oVYp3gm2SotdKWZhn3PX+REWXqDhJC V4nThMbVQY56C1XJbmQKNqNP7RQv8dfZWOSLFgDNEnnxtGj4N1LMy6t7K/wnVeBTzrKd pC3rIyRY+HNhOj/FE+sscGuXXork0uT3PMdWmCb8pF59OI5sIjWo0l/ICzXqlG5AWhA4 gaGK43rxG8TE5qvWxY4SzWugO2GdzG5LJlZvt8t1b/mj9iXzdUH1iiPbT5J6I5Bi1nP0 FY+Q== 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=MUX+vVnRKV8OaRfE6E0T4DEfopFLWpSfgBYCbpeWG+Z3lD4y+PaSR825FrO8ijred9 4qPC8iIW/ddzXO4bmXKA+3O/mfgtA8ut6m59OYp9l+Zb3FPeep5yFhVDjVL3UcAWbH8z WGwpBmX4qOgdRwygChMsF2EXq9eIcU1vB7axOypo+Xu/be215gkPWE7wUnu7Nx8N2Zqw 12LPbAiswUcUh8RWwOYX0ouSzcPlIqJY7U+45b64TYD/wWDsN3wnAb78QxuueX4SPdmS O/FxF9T+/c0bP/ouyP2LwudIHHehN9hChIXJKrNavyToNNiPOiXdD/YPUqzY92PzboAp Xg7Q== X-Forwarded-Encrypted: i=1; AL+hErEACOtGGbIkzl8rxbBZBIWyFhXLjkDTJfoqaeR/KCyt3BD/UZb8LTQTKHf+xFvAD0gB6HTn@lists.linux.dev X-Gm-Message-State: APuU4Z+k8mZfsoeK0STl0zDWL6TEwwnQPuCk7RXID7F6B0plta9pVdtz CfZ58mi9mWx9NVnE5uuKSdDIl0w7kqQIzW34NgJ+2BNc258vzQ7peaus X-Gm-Gg: AZFdTZcku64Mh5CZhZIY8SVkT6INVmXoI0zS29D3g/0o075OMleglw+4m5kIG8jCmqU OyP0gV0ZKm6MaN35cM6XRWq74PxHnsr06VbFT0pXYzfprtEudbJoaKzQU2N9t0rDyiXWyUtVrAY QhgooZAqqZk9NnnC7Nbvw1+JR7IHQ5ibmaWd3QxRARvHbmxXfu09S0c5uaiuMo1V8G1ZFdcFbQ8 OjYHji5hMkB0F/O9dr15re65oRWGCyp9DAet+4NBRjiFoIQNLL6S+eq7m+kj4QLE+/IujC7B8SW OhO3daZEnf+hAoyLPC3bzeiSh7gzcHFoLmZ86uf2+YORpdzRo15yY80wEqac5cZditGu2jGlrsU iR9DH+KeukjJ1cdM/n+M37+j26dmKQeeCLbEW4h9rpWMuMeG1J7WkJcMEF/LEYq2W1TWK5UqFnh ENFjDr1DnO2PAFiRkZUdDzc2QOiIB5kR1cbiVr5u9dvlMeyPhHQApf2RIOnyXkghMFr/5AIgGd2 xz/mcy38G0T8AnrH81oFXOrfars7PXjzeCaXCMbKbKrBQIhP4ubAne4INiP3jipqtk62MHiC6Ln 5AIvLh0MElj/r/W1q9ZYzeYOVVk99gaN9pV9hzR6eI7o/yozIFVCRu/EhNBMP3tdY8uuQgIQgPv LacgL+HA8eytYp7MWuA== 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: llvm@lists.linux.dev 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