Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp212240rdb; Wed, 14 Feb 2024 19:09:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVog8+FBAF0UOPxQwbJEuTT4hRAEESP3gNOAEMsjcVoxHUR3hX/wrnhDCJRNq6IHcgQl9TslNFQVLwu/m5DmbW1S16ZLo9VAW+wELBz3Q== X-Google-Smtp-Source: AGHT+IGwIxD2Y/1x2S05aGKgYMYNtD+MMorKpD5omKeLvoBGCdycegJQnnrpOv1o7UqXHjm8e88O X-Received: by 2002:a0c:f387:0:b0:68f:1aa5:fb3d with SMTP id i7-20020a0cf387000000b0068f1aa5fb3dmr30689qvk.50.1707966555039; Wed, 14 Feb 2024 19:09:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707966555; cv=pass; d=google.com; s=arc-20160816; b=qRacd1TXAoAJtVBQTo1nWehvVgTolhRtUCJeJZY+NDCyCqDi5bCX+BRXjRvlfCn1tS WoU3He1coH1Jz3PXrLdyKGR2aYGcevvsNHuh/oRU49nL/3dR5ADK0iz6h3KHpghpjvOK 8KSx9+Q/y57m8raLkL2QVUJMXTNFESazMfbAMv12C72o4c882dqWY6dwWssOAlyzw68i 5uKd+/wcn33nayLf9HEUfrMEWT3igyp+RWRyPJirIAGbY8xj8NnU0fTJkJbDXlLH4t5+ wDQjT/bVKiSKehRL86Wou5ZSSzrVPA8IXF504t/bcKM7+P65Xu/KNF4LyUNJtjDYUy4W GE4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rYzxDIVTt4KsEJZQwSjnMZPhzk3vtEW92o6eFqXyAy0=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=yxbpwa9OxTbi9szhpe6b8rURaCrpREeCKsPGKyTo6QijqBsPcQbOTTEMYotsCNIBUd a10SHtXGO0T/s+6xTGUjbWUq3G0unLIOBDVUjKJAkTVavbFu0aYr5xRJAgFaMbfv8FEt uGz2+N+4/JlGEhdncIrjRrXwc5Zdpts/tjXbhTiAFNe6VpEXHCPQnUbHSCUx6ljyTOvo mjHibIr1zBh+xdKlT84LX8TP/buRxYOzs8IcpMe4O9fl5Va9mYxk8LkACtAJUrooliQG /IBRGMZ7Qwc9P5zIROtioRN2Jfb+c9CtDE7jdSK1rx1PEZS+mhYkfoJaPn40sKdzbBau M0WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iDsRkvRQ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66255-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t6-20020a0562140c6600b0068c7251fe66si472453qvj.568.2024.02.14.19.09.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 19:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iDsRkvRQ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66255-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 876031C29AA0 for ; Thu, 15 Feb 2024 03:09:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F20A312B87; Thu, 15 Feb 2024 03:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iDsRkvRQ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A4EA12B7C; Thu, 15 Feb 2024 03:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966484; cv=none; b=cA2m/k5lWD/ZDiIVbxCvSWG0TTt8NnDn6a/CK1YHmfSs6be1RJ8zMmqLFGgWwu8jN8mndUANyoCnb0NcnKkfKRV+vJpjstEc7Yz3WCwt+EIr8C4/twOJRqm+Yp3J3MJPpK2nJCgdZ2r6MGlWh/7rqgbbsDuQPAvnzqKsAvCjivw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966484; c=relaxed/simple; bh=N38loWFo7GWrJwwLm4tKbNOCG6/JHGqNKZcHVjVV0zo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DES4+nRyxsLDhAjSqpjc7v0WK/j6/inkJT74npSl6yBq2TJ9YJhsvxy1UpWtwbWTbP3SHbPJ7SCi3NMkP2dQACANaX9ewBdoJdETFtl4LPZFBkOsNQy2vCgB7U9g9zzQ3C20mdvCaMPeT5cpT81DmMiMAIOEGg1EdKc8NBwE1Co= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iDsRkvRQ; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966483; x=1739502483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N38loWFo7GWrJwwLm4tKbNOCG6/JHGqNKZcHVjVV0zo=; b=iDsRkvRQMDRa+uQ6VV67mkQvEDkDeEbnAasWg8LIEFnDvPvhOsmNl7XA b377T/RuiCJ9vJlPTN33zoHKaaAnOpz5hGhRwn1DfoVxVIBfFfLl/Kbwx nCkn5sZgYIkbYYQMzZ2vPxFClkul/KcqKgFJRf9bTzYFcH2vqx41/HsJP 6dSXI4YQd6Z5YR0b8hPaDLk0vNgip0DflIaCsqRWmEhfloBUgLiOiB6J0 optO2e/GOD3uioY3j4oE7t+KVaJ/qcjD8XXeZiRf8KRe3aBhQ/YyEufAR 94I6Soow2ECfXsNqkYghonej4M/QqOYCmRGBO6YSjoxxfWAwLzM+VUEfW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461309" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461309" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385742" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:07:54 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , 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 , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 4/9] net: pcs: xpcs: re-initiate clause 37 Auto-negotiation Date: Thu, 15 Feb 2024 11:04:54 +0800 Message-Id: <20240215030500.3067426-5-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit According to the XPCS datasheet, a soft reset is required to initiate Clause 37 auto-negotiation when the XPCS switches interface modes. When the interface mode is set to 2500BASE-X, Clause 37 Auto-Negotiation is turned off. Subsequently, when the interface mode switches from 2500BASE-X to SGMII, re-initiating Clause 37 auto-negotiation is required for the SGMII interface mode to function properly. Signed-off-by: Choong Yong Liang --- drivers/net/pcs/pcs-xpcs.c | 62 +++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 52a7757ee419..cf1ed89d6418 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -848,6 +848,60 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs) return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, ret); } +static int xpcs_switch_to_aneg_c37_sgmii(const struct xpcs_compat *compat, + struct dw_xpcs *xpcs, + unsigned int neg_mode) +{ + bool an_c37_enabled; + int ret, mdio_ctrl; + + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { + mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL); + if (mdio_ctrl < 0) + return mdio_ctrl; + + an_c37_enabled = mdio_ctrl & AN_CL37_EN; + if (!an_c37_enabled) { + //Perform soft reset to initiate C37 auto-negotiation + ret = xpcs_soft_reset(xpcs, compat); + if (ret) + return ret; + } + } + return 0; +} + +static int xpcs_switch_interface_mode(const struct xpcs_compat *compat, + struct dw_xpcs *xpcs, + phy_interface_t interface, + unsigned int neg_mode) +{ + int ret; + + if (xpcs->dev_flag == DW_DEV_TXGBE) { + ret = txgbe_xpcs_switch_mode(xpcs, interface); + if (ret) + return ret; + } else { + if (xpcs->interface != interface) { + xpcs->interface = interface; + + switch (compat->an_mode) { + case DW_AN_C37_SGMII: + ret = xpcs_switch_to_aneg_c37_sgmii(compat, + xpcs, + neg_mode); + if (ret) + return ret; + break; + default: + return 0; + } + } + } + return 0; +} + int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, const unsigned long *advertising, unsigned int neg_mode) { @@ -858,11 +912,9 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, if (!compat) return -ENODEV; - if (xpcs->dev_flag == DW_DEV_TXGBE) { - ret = txgbe_xpcs_switch_mode(xpcs, interface); - if (ret) - return ret; - } + ret = xpcs_switch_interface_mode(compat, xpcs, interface, neg_mode); + if (ret) + return ret; switch (compat->an_mode) { case DW_10GBASER: -- 2.34.1