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: 131078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp163042vqb; Fri, 4 Aug 2023 03:27:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmYHfhzM3yd2ZLtwJPuqojkh9OstrIPUazmhM8Q/tOCt2F7vIqYqrzWDu8visLDSX5FSxl X-Received: by 2002:a17:902:ee82:b0:1b8:e2a:9ede with SMTP id a2-20020a170902ee8200b001b80e2a9edemr855007pld.25.1691144832625; Fri, 04 Aug 2023 03:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691144832; cv=none; d=google.com; s=arc-20160816; b=a0ZGKU7ha5S/zXkO7V12bTnyxF+qyI4ZMyQgP05E08K5Av9U3MQnCPUDdoO0evq/AU oZwMCEk1iHR97n5Ltg9yyDEgrTL/nFUm24ML0LJkCSbx+9YH3MnFtHwMfnRWDn9F6c+Y cx58UQMaY80PxrA9KSTO1gty2a2xJFbKfGWIFyBsxNnt/j3fSYKSWR2B92ttEKiJGlhT 3h03F9z6STjk978aoNnisoYYXODE8ZE7RwmK+nf1uxpPkVtOTecEtpPvUHwyGsqteaQw 7JCgVn+yDvaDhIw+3pisavSuMq9wiZmTuaWJxseoiOPkGNDGPZTu6OvhVmgZQvikOFbJ knpg== 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=xeiux+SGFZRTdqavVrm3my4yOwjAo35uOUm+iOUlTMY=; fh=wc77EpfutEP0n0zOBBdJZHlKlpGafhRmvKP/2XqASX4=; b=mWR0gvZSljXhhgsTdZ/at63xiGgaxJKUDd/Ch4Rim05dHFa8huHYCowFX07zuX47sb VBkHLiHsHb3FjCvKxsUeKpm8AnDpUtpqKMP+WziPVKgAFMGHzGxHPMYRJlQLtj5guThT 7jPMnbaOJNlZA5LJzYWwCjBncmAUomKlgRpDdynIkmrONuN7+FehQ9uDGUpSgfX+fPNZ slVvAaFTupIwkXvHsRwLgpxY9c5mVcmBxLOYerZ31s1vMIsCBca2BS7xlh9pmXBT7yvm wYv6qZnZSeJoRxM/YACD5b+mmHNYIznc82UWl2ZamzTNryD7OgbCP4wRPbycK7c4hjGE xlZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b8UZPIsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a1709028bcb00b001bb324569efsi1407168plo.364.2023.08.04.03.26.59; Fri, 04 Aug 2023 03:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b8UZPIsx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbjHDIr6 (ORCPT + 99 others); Fri, 4 Aug 2023 04:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjHDIrk (ORCPT ); Fri, 4 Aug 2023 04:47:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178EE4EE4; Fri, 4 Aug 2023 01:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691138851; x=1722674851; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kym71JnP46JQRzivmbFD91p1WZYXtds413slM9QU9Oo=; b=b8UZPIsxwYqeGwlqiDK9RNUdzoSAMGDtutBEEZOFxL2DViEi05xC9t3u CKzG2vsRCdmsQ7tWAep8r4UoQsN/CeVKRqFUztl00FUEHnc2XqofMyDWh B3qRYIA/T/mrn2a2Vj7bAQAkM8RjAHqiOUNqzDVo+wJNsditbuQgaHRUu vaIsNWlgNVAVtS9Nr9wuzXjH39EEd4z/qUKrHvPd7GSlKluSbBDKWsJfq 1M8SbAOc880q+pAF5kzkntZROCGV1wDSuvnGob/0y67J7pC3DTXkwcwMs Y9PsC4mUcxNHLduh740HvuTFH01zmJheBEnf8qconsyWIqls1tc0eEYeM g==; X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="456478557" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="456478557" 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-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773292792952399664 X-GMAIL-MSGID: 1773293883948462189 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 */