From patchwork Fri Aug 4 08:45:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 13341520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34B1EC001DB for ; Fri, 4 Aug 2023 08:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eP4SDYhPfcPYRpwpZLvNRztM8wfwCAXy/2PdwvS6RoQ=; b=KNo/OEFXxATG2a qMuygVyxMJAaiTnfLwSgIp35GVbmb6Ry+JkIHwcDOm67wMwkne71eoFKSmVKE+0xHyIPZxJBqCCun CCtLz58ftxSk1nqnvLaVjBgr+Novoh5ezCUFw58qOKKecruF79XAbX7WStss+ft87MEYgasJd3x/v MFidbwYwj+TokXYNuhi5kcmLVMyb0ToROYibE1HUEkc71oN/ZRy7STVm++P++x6qN4hSjbbjvJzIw tIIufZnNVW0ElJg3GMRrx+bRi5ZoEvz/KDHUHSjMIef9QSKwaCWjAF3VUHjMXCAkXqUzn0Y78TmTw bJ8WYq9MU61zsdZXf8UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRqT6-00BvBS-2N; Fri, 04 Aug 2023 08:47:32 +0000 Received: from mgamail.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRqT3-00BvAL-2r for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2023 08:47:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691138849; x=1722674849; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kym71JnP46JQRzivmbFD91p1WZYXtds413slM9QU9Oo=; b=Y2xgHSumjO3LM5Sig6t6KqyeDiw0HWXoQEYSFkQ0c+rUMafnJNlemvXo db+JPBCVVO4GgBA5qwWhhJm4GZiA9GCd902y/APtuhDKZwfd1Nw1VstmP y0X39Q7zfX5RBWLYXQOG+AyYy4e3VliRgDiCKQs5+y07ZWMhzUUMXqFXY zt+zyHwQhi2jKjy6w8O/6rekRgBoVVQAmf2CEzTgMyV+Ljj1qX+xkJ4Vz HEcMo5Tb/PauBa5yQyau+8CUOqIMq4QS2y1Pa3H22k68qdgE8wzg5juUl /wOZo6eUSwRahJKgTUyS2te14WD/owkrxvL2ALgycr3tIpRBKc2tq5sWB A==; X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="456478539" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="456478539" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 01:47:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="765018164" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="765018164" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by orsmga001.jf.intel.com with ESMTP; 04 Aug 2023 01:47:19 -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_Beh=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: 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 v2 3/5] net: phy: update in-band AN mode when changing interface by PHY driver Date: Fri, 4 Aug 2023 16:45:25 +0800 Message-Id: <20230804084527.2082302-4-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230804084527.2082302-1-yong.liang.choong@linux.intel.com> References: <20230804084527.2082302-1-yong.liang.choong@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230804_014729_950316_D3AD3998 X-CRM114-Status: GOOD ( 18.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Tan, Tee Min" Add cur_link_an_mode into phy_device struct for PHY drivers to communicate the in-band AN mode setting with phylink framework. 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: Tan, Tee Min Signed-off-by: Choong Yong Liang --- drivers/net/phy/marvell10g.c | 6 ++++++ drivers/net/phy/phylink.c | 4 ++++ include/linux/phy.h | 3 +++ 3 files changed, 13 insertions(+) diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c index d4bb90d76881..a9df19278618 100644 --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c @@ -30,6 +30,7 @@ #include #include #include +#include #define MV_PHY_ALASKA_NBT_QUIRK_MASK 0xfffffffe #define MV_PHY_ALASKA_NBT_QUIRK_REV (MARVELL_PHY_ID_88X3310 | 0xa) @@ -946,6 +947,9 @@ static void mv3310_update_interface(struct phy_device *phydev) * xaui / rxaui modes according to the speed. * Florian suggests setting phydev->interface to communicate this to the * MAC. Only do this if we are already in one of the above modes. + * In-band Auto-negotiation is not supported in 2500BASE-X. + * Setting phydev->cur_link_an_mode to communicate this to the + * phylink framework. */ switch (phydev->speed) { case SPEED_10000: @@ -956,11 +960,13 @@ static void mv3310_update_interface(struct phy_device *phydev) break; case SPEED_2500: phydev->interface = PHY_INTERFACE_MODE_2500BASEX; + phydev->cur_link_an_mode = MLO_AN_PHY; break; case SPEED_1000: case SPEED_100: case SPEED_10: phydev->interface = PHY_INTERFACE_MODE_SGMII; + phydev->cur_link_an_mode = MLO_AN_INBAND; break; default: break; diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 4f1c8bb199e9..f9cbb6d7e134 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1720,6 +1720,8 @@ static void phylink_phy_change(struct phy_device *phydev, bool up) pl->phy_state.pause |= MLO_PAUSE_RX; pl->phy_state.interface = phydev->interface; pl->phy_state.link = up; + pl->cur_link_an_mode = phydev->cur_link_an_mode; + pl->cfg_link_an_mode = phydev->cur_link_an_mode; mutex_unlock(&pl->state_mutex); phylink_run_resolve(pl); @@ -1824,6 +1826,8 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy, if (pl->config->mac_managed_pm) phy->mac_managed_pm = true; + pl->phydev->cur_link_an_mode = pl->cur_link_an_mode; + return 0; } diff --git a/include/linux/phy.h b/include/linux/phy.h index ba08b0e60279..4973f2852a79 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -619,6 +619,7 @@ struct macsec_ops; * @link_down_events: Number of times link was lost * @shared: Pointer to private data shared by phys in one package * @priv: Pointer to driver private data + * @cur_link_an_mode: Current AN mode setting with phylink framework * * interrupts currently only supports enabled or disabled, * but could be changed in the future to support enabling @@ -757,6 +758,8 @@ struct phy_device { /* MACsec management functions */ const struct macsec_ops *macsec_ops; #endif + /* For communicate the AN mode setting with phylink framework. */ + u8 cur_link_an_mode; }; /* Generic phy_device::dev_flags */