From patchwork Wed Jan 11 17:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raju Rangoju X-Patchwork-Id: 13097051 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C011C46467 for ; Wed, 11 Jan 2023 17:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234573AbjAKRdp (ORCPT ); Wed, 11 Jan 2023 12:33:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235327AbjAKRdS (ORCPT ); Wed, 11 Jan 2023 12:33:18 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54128637B for ; Wed, 11 Jan 2023 09:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YH3MV4oUfgKN0Kvy9ujeEvMVO/7EjQcBNMzqIA11/mKadWtYp/IbpY0fjFuHfW8PSlsgn86q8kAcAgT8YRUeJkOj7MqrnfvkkaAC7KH3cuOw1dNE+ZlMlKj5pY25/s5Om2WjcN1HYMKa3dRWN2QNhXfVStnLgKvDf5mstYI9X4kV5l188q+Fr7RST818yIB6N7Mn7kErq9wvcp1pOUcCzHSJHBzVtFxSBdhylIfxgI/gn2ZcN0oofxvF/bjuhpYcU2DaWiutgC5PtIbnqEHf0MKC6GZs8+AqJwL4lNdw7FVbicHDtyWE6C2XJZZbLN9YFuh6qmbJLg/8K+0LlDc6FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JTV+lVQERvElOO3HNHW8P6RJTYAmZ2QrYeIvR4Pidc0=; b=TeBkIWp7jP9g9PAb4smgCWftyxqzFNmSFh+7XrH0ShVca+O9hLKCDcoBOGcmU6VQmMyG1UDgA0KST4MOkYAlbvf+K8wxV50Syh7soe72oS+K/c5L8bRwkBtxAkxvmLZ2xQx9/08gvr1hzJ82QgSP3Bu4aGdsEOQTcRDlTCu33N2NC+VMNHeSYZ62csdpWjG4qUEEPm+4Pme5bTCDs/1FtJOg+Z6Ht6hCeXp7DJnhdVqb4TCqlmmP6T1icLFyG7BGbzsoqGJ3vyw/rJKbPezTLPe7j9c/5cwu8SPpO5knqeb9GGB8WruO1OenSaUFI/EYbSbel5W00cQxxL1u9VtplQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JTV+lVQERvElOO3HNHW8P6RJTYAmZ2QrYeIvR4Pidc0=; b=iSqNFD7PZOAAq53+r7r2gSzKDPougqmRKS3LXs3/L4qDhDqjpq0zx7xEqPC5PYEQ/pS96njyAwkxcrM46gg3St4rNHZ+PbWIUHN42nPdYA3W0Hey3lzhsjvVpiY+A8dpU6RIbtiuEl2GI13qnurz1hegZ42K8J1noTD7U0uZqoA= Received: from MW4PR03CA0341.namprd03.prod.outlook.com (2603:10b6:303:dc::16) by DM4PR12MB5277.namprd12.prod.outlook.com (2603:10b6:5:390::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 17:31:00 +0000 Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::80) by MW4PR03CA0341.outlook.office365.com (2603:10b6:303:dc::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 17:31:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT038.mail.protection.outlook.com (10.13.174.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 17:30:59 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 11:30:00 -0600 From: Raju Rangoju To: CC: , , , , , , Ajith Nayak Subject: [PATCH net 1/2] amd-xgbe: TX Flow Ctrl Registers are h/w ver dependent Date: Wed, 11 Jan 2023 22:58:51 +0530 Message-ID: <20230111172852.1875384-2-Raju.Rangoju@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230111172852.1875384-1-Raju.Rangoju@amd.com> References: <20230111172852.1875384-1-Raju.Rangoju@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT038:EE_|DM4PR12MB5277:EE_ X-MS-Office365-Filtering-Correlation-Id: 59f55df7-a38f-49c1-e983-08daf3f99b12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9DeAs4vqnyv5G+maU0E4KI4a+4XOHq1+O20ddxpRpXALKJHrh/kkwaeIkGihhXfVynFvhMulSoe8ydLOy5Txd/Z5FM6sKwE+/EMDUQk+gRy64jzR7KPqAEWYPG52cr3j1joNUZ+qCNWlIawgh1fMTDVJr+CGhW5zVriAOuL6KAwwRiu0WbvaTjDHDtlu6hlcKRkO3U2HKkva8SKu6O/+UQCYlYIhT7rLh7CDWEm9JNDwcz/xt+djsbU3qKdHPjY26IWBYymjsfWJShOcIyVsOgnLbu5sjlayCw0WODUW18J6xfiku+hv0H2AM4AIq7Z2hnow6xHOPRUIzyCiUwZQombW6ni87FBkSW2PafJTjB6HMvx4ENsSxz2Xj/2iFYwj8OUGZ+zJqQ7XG/YmtzyogNVOS10YYHdp96D/43Z4/NijUTG4J/fpXA46CWMUDFTJWbPPRCwySUNc7GipL5/y5wE5HGbNIi7rHlA5Z7YAMz4ZQ8NSSG5saDnXNIXT9rghQ0ma5NmPlRI2cGKZGMe7WaNE7BJLnmMoxMN7tHEYRCZunjfuc3FNfPt4gzkT1n3N8fwkPERHr1NBwSZkNVgHbl9w5cErecJwbBNMAi/wpx+b9iZyGEGq3bZGmq+V8MDMOS0BicjVCErLVLv2YMFvDUSYa2AOV4RyUhloyPn1X5yC+lzqmPk8UFsEYSIPoHNOuOJnA+ee5zjzIPfuYzNjUizg6N5RtUUdNpOQWZ0FfCc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(36860700001)(82740400003)(6666004)(81166007)(356005)(2906002)(478600001)(2616005)(1076003)(16526019)(7696005)(26005)(186003)(5660300002)(40480700001)(316002)(83380400001)(8936002)(40460700003)(82310400005)(36756003)(86362001)(426003)(47076005)(41300700001)(6916009)(8676002)(336012)(70586007)(54906003)(70206006)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 17:30:59.9054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59f55df7-a38f-49c1-e983-08daf3f99b12 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5277 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is difference in the TX Flow Control registers (TFCR) between the revisions of the hardware. The older revisions of hardware used to have single register per queue. Whereas, the newer revision of hardware (from ver 30H onwards) have one register per priority. Update the driver to use the TFCR based on the reported version of the hardware. Fixes: c5aa9e3b8156 ("amd-xgbe: Initial AMD 10GbE platform driver") Co-developed-by: Ajith Nayak Signed-off-by: Ajith Nayak Signed-off-by: Raju Rangoju Acked-by: Shyam Sundar S K --- drivers/net/ethernet/amd/xgbe/xgbe-dev.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c index 3936543a74d8..4030d619e84f 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c @@ -524,19 +524,28 @@ static void xgbe_disable_vxlan(struct xgbe_prv_data *pdata) netif_dbg(pdata, drv, pdata->netdev, "VXLAN acceleration disabled\n"); } +static unsigned int xgbe_get_fc_queue_count(struct xgbe_prv_data *pdata) +{ + unsigned int max_q_count = XGMAC_MAX_FLOW_CONTROL_QUEUES; + + /* From MAC ver 30H the TFCR is per priority, instead of per queue */ + if (XGMAC_GET_BITS(pdata->hw_feat.version, MAC_VR, SNPSVER) >= 0x30) + return max_q_count; + else + return min_t(unsigned int, pdata->tx_q_count, max_q_count); +} + static int xgbe_disable_tx_flow_control(struct xgbe_prv_data *pdata) { - unsigned int max_q_count, q_count; unsigned int reg, reg_val; - unsigned int i; + unsigned int i, q_count; /* Clear MTL flow control */ for (i = 0; i < pdata->rx_q_count; i++) XGMAC_MTL_IOWRITE_BITS(pdata, i, MTL_Q_RQOMR, EHFC, 0); /* Clear MAC flow control */ - max_q_count = XGMAC_MAX_FLOW_CONTROL_QUEUES; - q_count = min_t(unsigned int, pdata->tx_q_count, max_q_count); + q_count = xgbe_get_fc_queue_count(pdata); reg = MAC_Q0TFCR; for (i = 0; i < q_count; i++) { reg_val = XGMAC_IOREAD(pdata, reg); @@ -553,9 +562,8 @@ static int xgbe_enable_tx_flow_control(struct xgbe_prv_data *pdata) { struct ieee_pfc *pfc = pdata->pfc; struct ieee_ets *ets = pdata->ets; - unsigned int max_q_count, q_count; unsigned int reg, reg_val; - unsigned int i; + unsigned int i, q_count; /* Set MTL flow control */ for (i = 0; i < pdata->rx_q_count; i++) { @@ -579,8 +587,7 @@ static int xgbe_enable_tx_flow_control(struct xgbe_prv_data *pdata) } /* Set MAC flow control */ - max_q_count = XGMAC_MAX_FLOW_CONTROL_QUEUES; - q_count = min_t(unsigned int, pdata->tx_q_count, max_q_count); + q_count = xgbe_get_fc_queue_count(pdata); reg = MAC_Q0TFCR; for (i = 0; i < q_count; i++) { reg_val = XGMAC_IOREAD(pdata, reg); From patchwork Wed Jan 11 17:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raju Rangoju X-Patchwork-Id: 13097052 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC31C54EBC for ; Wed, 11 Jan 2023 17:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234813AbjAKRdr (ORCPT ); Wed, 11 Jan 2023 12:33:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233049AbjAKRdS (ORCPT ); Wed, 11 Jan 2023 12:33:18 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2053.outbound.protection.outlook.com [40.107.102.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 542DB64DA for ; Wed, 11 Jan 2023 09:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iE0ZU26eurI7XcPqNnMhJMXKAYLQbKGnIrR7DrVs+Hc//ijibEP/JY0ijkYYiGwo5ltA6YGcZcnyJQmPgBH1uyntK7Z/k4iEFR/7VGCriOkP28n7eJqeA2bCUD8JN6s+hx6jDvv21gfmH8pY4xbBOettBe9X3dco1T2M2cgKwAmlYyx2Wn09o8T/+8AMv+NB1Gpte/WxEi1KpyyHG7taJuaXG+SVEVfC6R1D2aG5/d8P1tqaix9sBQJazrWChidWLz3iDzVb26E1XsfveB/FP7MDsb++g6RKaQhaPSfRV6Dc305Vj3Y2tp8H1QnJ613JqBkVkzwTmgVBzwvovegWTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3nMgDf7WUQnkdRSR1/gJhF3mV2jgIA96szQzdvXEZv4=; b=jfj5IbGiKQcS+2Mf+vsIvN96lUVJ9S68mDuX4qDpqsctWR+r/KyBvbaUo4aSz3PFppR53ivwnD3aEsbfjX3Q4GAOTtgBIfUMTK2uGNdMHoy3/DvK+HKeteRgg6BDPPJQCq1NULuyTGXFeSeJ0Pec4hErtDEPSK9EXpBZtZlKj1sm27XfqzXl8rx5DmcXKDYASSQYXTlJOV8asl8bnd+g40ChGyfVsHGBtoVNfdyxsDe+Dve3Vrcw6yzZ01hBPYG9YCYYUdMwob46VnCf/NDffn2Po1DqwqRflzJ2iFXOqLXX1NH7V0xvMY6RUOFtN/EDbDTQUwxM1RfM8tZjGAFzmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3nMgDf7WUQnkdRSR1/gJhF3mV2jgIA96szQzdvXEZv4=; b=QQNgvazLKk4R5DB3OrQQqHPZ987birNnEgl8vQBKA6u2SxWGSMEDlb8HqTRxpuxGrvyJr0Gk3rn0tKS0yFTXxLAjIpzSYsKqnfRQrHH4KTrWY8NgjJ8lw1n8g93NOd+fAPSijFXf0A4fhNlrVYXjKkS/oKF6pbgZeyoqX+JQhBk= Received: from MW4PR03CA0200.namprd03.prod.outlook.com (2603:10b6:303:b8::25) by SJ1PR12MB6100.namprd12.prod.outlook.com (2603:10b6:a03:45d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Wed, 11 Jan 2023 17:30:59 +0000 Received: from CO1NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b8:cafe::e6) by MW4PR03CA0200.outlook.office365.com (2603:10b6:303:b8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Wed, 11 Jan 2023 17:30:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT028.mail.protection.outlook.com (10.13.175.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Wed, 11 Jan 2023 17:30:59 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 11 Jan 2023 11:30:19 -0600 From: Raju Rangoju To: CC: , , , , , , Sudheesh Mavila Subject: [PATCH net 2/2] amd-xgbe: Delay AN timeout during KR training Date: Wed, 11 Jan 2023 22:58:52 +0530 Message-ID: <20230111172852.1875384-3-Raju.Rangoju@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230111172852.1875384-1-Raju.Rangoju@amd.com> References: <20230111172852.1875384-1-Raju.Rangoju@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT028:EE_|SJ1PR12MB6100:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f21d6bc-4683-43d7-220e-08daf3f99a89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RsFtkTaW0fqcBMbQu1aXYBsQg7nUfvqoeS3DgtC0j+E0/jSXLJX9/Z4hqxQ8lqMED38Pk9KrBwRQN9hjALdmvsh886baiBFRsMtCRNWC7RmJsWK4CqAWgcT3CNNO5X8whHEewvDWcjW9S6P+U/VvO5xOgQoZaop/1xaFTmjZpvsICnk4AaYyddE6+p6sZdtP3cRKJf3zt7cuOoW9PXdFAxcXN9fXUFw4+Gd/YuFJNPligLnd81HSSaxkuFE/l4TRas4tfc6+YQ4FLrCSp00zURPPhLaHHqE+ZpEoNTwGb3Q+aAyPGwurnAY2KiqOVjb8om3/VC9JZkzPb0+kQgp5IEasS+t9DgK9dtGpafMn8Ux7Htn+/kpNmr5LWbQmKDiijUFGyqAsFq0b2SL1b6sfgfZ9plE6Q46UYxkJAc3RyILv/kAQTLjlklAu6XX/KSIfOkFX/i5GQK+ir6CpJ121YOCUILar9l9jw7cwXOzH7l/ntxIbnd/LgSCPxod8mepUpaOR46aKqUNGwlHkzBdWhuMvLOSXsXDcACEyXxhWZpwE0RdUA+UKTJRfLfY9VUnVtKECLQzijBW9fGWo8hRV9qig1vVIw4n+cYrNcuDau5o6DPWsdu1LyamSckrBmUzSooAZBFhDo5ZQjdTN0TbXghPNxWrPDlVYqHx4N4lja0Z6Xp2MbTccU8WhuAP4HIfaTByTnZ4Sd6sepSutXWczHQCbuuvMP63jfbESAlELCLE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199015)(46966006)(36840700001)(40470700004)(82740400003)(426003)(41300700001)(356005)(81166007)(478600001)(47076005)(86362001)(1076003)(40460700003)(316002)(54906003)(2616005)(70586007)(336012)(26005)(40480700001)(7696005)(82310400005)(186003)(8676002)(4326008)(6916009)(16526019)(36756003)(70206006)(5660300002)(6666004)(36860700001)(2906002)(8936002)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 17:30:59.0025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f21d6bc-4683-43d7-220e-08daf3f99a89 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6100 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org AN restart triggered during KR training not only aborts the KR training process but also move the HW to unstable state. Driver has to wait upto 500ms or until the KR training is completed before restarting AN cycle. Fixes: 7c12aa08779c ("amd-xgbe: Move the PHY support into amd-xgbe") Co-developed-by: Sudheesh Mavila Signed-off-by: Sudheesh Mavila Signed-off-by: Raju Rangoju Acked-by: Shyam Sundar S K --- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 24 +++++++++++++++++++++++ drivers/net/ethernet/amd/xgbe/xgbe.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c index 0c5c1b155683..43fdd111235a 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c @@ -496,6 +496,7 @@ static enum xgbe_an xgbe_an73_tx_training(struct xgbe_prv_data *pdata, reg |= XGBE_KR_TRAINING_ENABLE; reg |= XGBE_KR_TRAINING_START; XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg); + pdata->kr_start_time = jiffies; netif_dbg(pdata, link, pdata->netdev, "KR training initiated\n"); @@ -632,6 +633,8 @@ static enum xgbe_an xgbe_an73_incompat_link(struct xgbe_prv_data *pdata) xgbe_switch_mode(pdata); + pdata->an_result = XGBE_AN_READY; + xgbe_an_restart(pdata); return XGBE_AN_INCOMPAT_LINK; @@ -1275,9 +1278,30 @@ static bool xgbe_phy_aneg_done(struct xgbe_prv_data *pdata) static void xgbe_check_link_timeout(struct xgbe_prv_data *pdata) { unsigned long link_timeout; + unsigned long kr_time; + int wait; link_timeout = pdata->link_check + (XGBE_LINK_TIMEOUT * HZ); if (time_after(jiffies, link_timeout)) { + if ((xgbe_cur_mode(pdata) == XGBE_MODE_KR) && + pdata->phy.autoneg == AUTONEG_ENABLE) { + /* AN restart should not happen while KR training is in progress. + * The while loop ensures no AN restart during KR training, + * waits up to 500ms and AN restart is triggered only if KR + * training is failed. + */ + wait = XGBE_KR_TRAINING_WAIT_ITER; + while (wait--) { + kr_time = pdata->kr_start_time + + msecs_to_jiffies(XGBE_AN_MS_TIMEOUT); + if (time_after(jiffies, kr_time)) + break; + /* AN restart is not required, if AN result is COMPLETE */ + if (pdata->an_result == XGBE_AN_COMPLETE) + return; + usleep_range(10000, 11000); + } + } netif_dbg(pdata, link, pdata->netdev, "AN link timeout\n"); xgbe_phy_config_aneg(pdata); } diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h index 71f24cb47935..7a41367c437d 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe.h +++ b/drivers/net/ethernet/amd/xgbe/xgbe.h @@ -290,6 +290,7 @@ /* Auto-negotiation */ #define XGBE_AN_MS_TIMEOUT 500 #define XGBE_LINK_TIMEOUT 5 +#define XGBE_KR_TRAINING_WAIT_ITER 50 #define XGBE_SGMII_AN_LINK_STATUS BIT(1) #define XGBE_SGMII_AN_LINK_SPEED (BIT(2) | BIT(3)) @@ -1280,6 +1281,7 @@ struct xgbe_prv_data { unsigned int parallel_detect; unsigned int fec_ability; unsigned long an_start; + unsigned long kr_start_time; enum xgbe_an_mode an_mode; /* I2C support */