Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2463945rdb; Thu, 21 Sep 2023 21:58:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCWJxdocq9t0qLEagKHN89pOZh7eB6dCzhOm1Q2/ZXw4JQ//8QNyojkr/6lTxyVr2vbohW X-Received: by 2002:a05:6808:1496:b0:3ab:8ae5:e7c6 with SMTP id e22-20020a056808149600b003ab8ae5e7c6mr8625013oiw.1.1695358692530; Thu, 21 Sep 2023 21:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695358692; cv=none; d=google.com; s=arc-20160816; b=RT3XjkR5+NUhzPYY08zHvDeQ18C2O4G4yhXo7uPC/LPZXwTnYyEtoXYYq6Z60wLBDQ xGHComNKXyCLXvPq/ZojZRFNNpuKekFVX8AijHz47/hxHLdupOTm4WvWcVy+yATKGmrf 0ePftUP5bAm9O6DKrqMsrXH1sWR3y6gvoQjY/I5yvP8oJPD1M34HCZ0ImSuCSCuNel8u r3MVPoEcYSrcnh/fi97Eb5YLnv5qnaXLZb4vjJUVPGdv4mF8R16S00EumZJR127/qLR4 6RPMrOjSceJTdpXLIUHcxXdl5ljZT4yuQlWeJKgrIAsjJ29dUhEXHIdR2LRT+IRkb/aO bS/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5nBXgLxdjWJjAy0WR0VUxx/DOG46db7BYvmlXeAs6p4=; fh=eopC7/l+nVuh6mxtuaUTGuElFjyXo3EdPF+w+AmilC8=; b=Av0ZxBiSZjF9q7eIXvAMnZvpQCSF7L3NcI1KoI5wJaHI/wIyHMum2lR6AQL9emy3EP ioEY0wILxyUUiEamDS+9AEYbyLx4hge607QZsNXdzxXUqi/DFWgPggeCZiQfJQOYmz7N H29tN7P8gV3imDR/NK90xok3JMYK/2gqawacWiDusE7AF06KImUUPwLleEBZOZLQTuBy Pj4NpcMBxhOiAuiT1Z4DYyAMUXnISvgiVyvdbLYvU4bzL5H7WWNIZutdh9G/4ob6i/0o GrGQrAfGCG5h1hhud7Aq3nZcQud61NmOBcSmre0QuxsAaj9QpmTYxKP1/YVDPmz4GwZt dq4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KRDmTtOp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x27-20020a056a00189b00b006901a3cc55csi3200533pfh.180.2023.09.21.21.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 21:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KRDmTtOp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 133B98245A6C; Thu, 21 Sep 2023 13:01:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231420AbjIUUBD (ORCPT + 99 others); Thu, 21 Sep 2023 16:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjIUUAm (ORCPT ); Thu, 21 Sep 2023 16:00:42 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46BE751F7B; Thu, 21 Sep 2023 10:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695316628; x=1726852628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lTXXgtikZK8fOV2paXgb9h3Lt1o9zA5yS/eHowFJJOE=; b=KRDmTtOpSMmjsqzHqliaUmm1/gPNKHP9zItXGpAmm3GSIo190LktVyMS MFX+oi4UUxD/tcunceT50U5RjLrV8tAaSv1Z6P8VkiYRtIu731xR3Az8T rUx5ozMX+yj8aehngSm4fuE4u7vbINM+5ZnmxjuLXltnU+QcbWaFtoGXF uUtzUMlNM4C92ZoO1BbqKl2DCzmU2tke41q3asfKGXF/7d+49Yob3kYRb 7l+NH4DQowtbGOLKStDdHoPcl68w8b3voNcgpcTKzQqE7zTQWJxib5GXW W24uGTchsFLgpv7Ys2OQstkOaW83HA4cDQqHjOoX4t5m6l/duXBlavBiP w==; X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="444608265" X-IronPort-AV: E=Sophos;i="6.03,165,1694761200"; d="scan'208";a="444608265" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2023 05:20:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="862441935" X-IronPort-AV: E=Sophos;i="6.03,165,1694761200"; d="scan'208";a="862441935" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmsmga002.fm.intel.com with ESMTP; 21 Sep 2023 05:20:48 -0700 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Jean Delvare , Guenter Roeck , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Philipp Zabel , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Wong Vee Khee , Jon Hunter , Jesse Brandeburg , Revanth Kumar Uppala , Shenwei Wang , Andrey Konovalov , Jochen Henneberg Cc: David E Box , Andrew Halaney , Simon Horman , Bartosz Golaszewski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Tan Tee Min , Michael Sit Wei Hong , Lai Peter Jun Ann Subject: [PATCH net-next v3 3/5] net: phy: update in-band AN mode when changing interface by PHY driver Date: Thu, 21 Sep 2023 20:19:44 +0800 Message-Id: <20230921121946.3025771-4-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230921121946.3025771-1-yong.liang.choong@linux.intel.com> References: <20230921121946.3025771-1-yong.liang.choong@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:01:12 -0700 (PDT) As there is a mechanism in PHY drivers to switch the PHY interface between SGMII and 2500BaseX according to link speed. In this case, the in-band AN mode should be switching based on the PHY interface as well, if the PHY interface has been changed/updated by PHY driver. For e.g., disable in-band AN in 2500BaseX mode, or enable in-band AN back for SGMII mode (10/100/1000Mbps). Signed-off-by: Choong Yong Liang --- drivers/net/phy/phylink.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 0d7354955d62..5811c8086149 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1723,6 +1723,34 @@ bool phylink_expects_phy(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_expects_phy); +/** + * phylink_interface_change() - update both cfg_link_an_mode and + * cur_link_an_mode when there is a change in the interface. + * @phydev: pointer to &struct phy_device + * + * When the PHY interface switches between SGMII and 2500BaseX in + * accordance with the link speed, the in-band AN mode should also switch + * based on the PHY interface + */ +static void phylink_interface_change(struct phy_device *phydev) +{ + struct phylink *pl = phydev->phylink; + + if (pl->phy_state.interface != phydev->interface) { + /* Fallback to the correct AN mode. */ + if (phy_interface_mode_is_8023z(phydev->interface) && + pl->cfg_link_an_mode == MLO_AN_INBAND) { + pl->cfg_link_an_mode = MLO_AN_PHY; + pl->cur_link_an_mode = MLO_AN_PHY; + } else if (pl->config->ovr_an_inband) { + pl->cfg_link_an_mode = MLO_AN_INBAND; + pl->cur_link_an_mode = MLO_AN_INBAND; + } + + pl->phy_state.interface = phydev->interface; + } +} + static void phylink_phy_change(struct phy_device *phydev, bool up) { struct phylink *pl = phydev->phylink; @@ -1739,7 +1767,7 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) pl->phy_state.pause |= MLO_PAUSE_TX; if (rx_pause) pl->phy_state.pause |= MLO_PAUSE_RX; - pl->phy_state.interface = phydev->interface; + phylink_interface_change(phydev); pl->phy_state.link = up; mutex_unlock(&pl->state_mutex); -- 2.25.1