From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2419643FC9; Tue, 7 May 2024 14:45:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E361C433EA; Tue, 7 May 2024 14:44:17 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.66]) by mails.dpdk.org (Postfix) with ESMTP id 4838C433EA for ; Tue, 7 May 2024 14:44:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PvrF0k7MW1bRASc3Q3yGWIY3N+oAvTgc/7vSTPVlXQAinpHYzxWw3mMI31Qpw2mKgGfUvdzF/mvV+BAvtb4ycOiTOiQQ7VH83UP35JbRhr6Dt1xETHy4k0gj4Y6fJgau6JSySdzy0L9TBHR2KHIno2sIN5hatRwsy+oAXLPTDnuP3CdvAszEKd0IfykrVgcCqcq3ISsgfG0v3yPgjac5hp/HPJSVI9Gko6EyLSobnvotUN0Gr99jhjCuuWlb7b2jUsvuLJxyCqyP/FH/SEdL3jC9NkZMoYJ+jjsb2EiuLjpmb3nNbx6YVgwfWCjS8+Z0xrEGBlAdlrAxDUYZXGpBKw== 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=61Xr1pG0e0X9HzcfKz7U3h5J/chS/sP0zZq7vf5oGDE=; b=V78OC/ZD9+B6F9yTd+zGClWvUQc9t195WFjb/aKjm/CS2ZsLeEngfHCK2d5TG20XpVq3/Wzzc24gUz1NntpE+0T2VyQSsFZICjyj81VUgXkyKvQwMowhP8sl/BA0EJ55UQEgGlZzBuL5qwlbXSXoaS36aVWEjNBf7F/sanWH28KDdCFNvxvj/OGda8swp76KUVXyoRE4e4VMd3hON/8xVWkIFjfw2nNuAasJvF3Ox2Ymc4DqcDJOfa6SbnJh82nusbKTkxaqgM5m6tl0pdBcKXTwRAu+3KGYFR+/pEoz02c/CIWoO+1fqWXYNElsigC6BGP9wOLmD/ij4TPVrTuEzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.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 (0) 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=61Xr1pG0e0X9HzcfKz7U3h5J/chS/sP0zZq7vf5oGDE=; b=0DtqLo4GE129Yfc7UHYiEI1XQ2rcKjWSrMIMFxz7GeIhxS3YgJ33eDrKUNMZayUIk6DNkiomNznBRWjvyOhvDNpVY7xWuxzfVfG1U8eA6KZq01grPSgzA03maS6+Tslfl0GUKmYRijHOXZXl6nH36EiC3tRHWC+sLS4lBrB0Uo8= Received: from PR2P264CA0023.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::35) by DM6PR12MB4156.namprd12.prod.outlook.com (2603:10b6:5:218::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.43; Tue, 7 May 2024 12:44:14 +0000 Received: from SN1PEPF00036F42.namprd05.prod.outlook.com (2603:10a6:101:0:cafe::29) by PR2P264CA0023.outlook.office365.com (2603:10a6:101::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.41 via Frontend Transport; Tue, 7 May 2024 12:44:13 +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 SN1PEPF00036F42.mail.protection.outlook.com (10.167.248.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Tue, 7 May 2024 12:44:13 +0000 Received: from cae-Lilac-RMB.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.2507.35; Tue, 7 May 2024 07:44:09 -0500 From: Venkat Kumar Ande To: CC: , Venkat Kumar Ande Subject: [PATCH v2 15/25] net/axgbe: improve SFP 100Mbps auto-negotiation Date: Tue, 7 May 2024 18:12:55 +0530 Message-ID: <20240507124305.2318-15-venkatkumar.ande@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507124305.2318-1-venkatkumar.ande@amd.com> References: <20240412125013.10498-1-VenkatKumar.Ande@amd.com> <20240507124305.2318-1-venkatkumar.ande@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00036F42:EE_|DM6PR12MB4156:EE_ X-MS-Office365-Filtering-Correlation-Id: e06bc73b-b806-421b-b326-08dc6e93661d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rfrM8YmaRewijgy1WVPFRbFweLY4wzrGIzScMN1S+SkP68C4bk9hEFd5CTXK?= =?us-ascii?Q?HJ4EKwRWBTAf9TOiV3b2y7QOUwL4ejkRrDgdLIEuYrrIldtewype2NtkyEhY?= =?us-ascii?Q?KMRbXvRfC6y4aLGhAsRQjQVpX7itM21+4ytQsVxUU83v64b3fu8rnP7ZSsRE?= =?us-ascii?Q?FQwBv7wVEhyJD9t8NQInRPc6SCGkuY2ElPiAdSbwjZNvkhQcGEOkG2dg0mOz?= =?us-ascii?Q?UgSPkavznSQXebLz5gYOwBu1dTlLxnnqaxxmE81ByXz4BjV2I6aMWHD00LwL?= =?us-ascii?Q?4ojhTQ4cnBSwDNA3BFFX6QzJ/56M5Hs+2s2EBg51/fJVLpURsVXot+PNT0ub?= =?us-ascii?Q?sucWfO9ee3YoinPvYpDAjKGC7QnFQtLa9k+SDdZe6YRQXNpEC88HyaxcHxO2?= =?us-ascii?Q?14gqhaFysWs8wIipN/uwXhzPZ974clL2I90ZtOve0irYmh/Pv42Tj0D3J6Ok?= =?us-ascii?Q?N0DtRAJV9Q+Jqx71C+VEwGTLc+qAwT5aFWPCMZ70xeqcmdzlwgGo9mteZrvq?= =?us-ascii?Q?2hsx/B0+8vUUbwf0e9jFEh4qXJLMppc+DzOFJChq/hvatLXK+9wkeg+DPUzn?= =?us-ascii?Q?CAe37Z+kHd4EXQfZS3fClWCElDzJX3lMu7mv0UmpQT3Pvw3q8AGbae2Zvnb7?= =?us-ascii?Q?tbBjRPDKQ2Pqm4ZgUNjqk7q0ZqCZw26FHUgmffae7yP1ZcLXQYiyIrwIMqjs?= =?us-ascii?Q?P23VwBECkDkuFmYVhUXqTKGICnTaLoRQ3WAIp7DhcJvcVcyy+ZshL0WEnFKI?= =?us-ascii?Q?o1vvi44ByFFqRRd23esQzYXaZ/27YPGhGEA0IA4ktgydy0I2IXk70h+r6CPR?= =?us-ascii?Q?T5t0FLHsEdQoKoVFQfeKe/K7cLMSd0vwYsYoaFCFAqyIWB5NNIaaoeGjK9/J?= =?us-ascii?Q?dOgD7oCpmItmb1BW1hfegkDq02iZQBvQgmVVqroYEKWZmcNu4D2H9BdtqM34?= =?us-ascii?Q?5VqE4l79a+2mI+gYl5jMpf39ciVHYWFWmDqEKLlfpqzrYqDgeez30IWd1p0X?= =?us-ascii?Q?ZWp3OTk+Ng56dBSWKhZrTUYlu6wmXYbaZFBGvH6kF6sUNhUPKHsio2jzjAIP?= =?us-ascii?Q?Jqs48ezKskn1C92HS5S69eq4h7UpfZ0zBDh8UqbTIp98L1f8tXRg3EKKtZvv?= =?us-ascii?Q?7Jh6tsAHD/bLEhH4GmBnIMMoStLR2wBYJXjn6h3KNrdpF9ex8eD29JInC+dN?= =?us-ascii?Q?1yZEOunrGiVnRKm+33BOTD0gq2NYFYT5qT+AFWNrf8Er3tHUfIftueXJ2+EH?= =?us-ascii?Q?MXxNlKoPeWnSHNFubvvS7JG4KDTaZtTQi1FByXsQYquQE7WcX5HW8+b51+J6?= =?us-ascii?Q?FzTScEXMSceQ42gGe3uCg0mHk4Xh71eTOKd6pghL3eALAZZHOGmCRKtQzuqM?= =?us-ascii?Q?Pofb5Uj7bxNM9fmlO+1GFjOC35eL?= 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:(13230031)(376005)(1800799015)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 12:44:13.1613 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e06bc73b-b806-421b-b326-08dc6e93661d 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: SN1PEPF00036F42.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4156 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org After changing speed to 100Mbps as a result of auto-negotiation (AN), some 10/100/1000Mbps SFPs indicate a successful link (no faults or loss of signal), but cannot successfully transmit or receive data. These SFPs required an extra auto-negotiation (AN) after the speed change in order to operate properly. Add a quirk for these SFPs so that if the outcome of the AN actually results in changing to a new speed, re-initiate AN at that new speed. Signed-off-by: Venkat Kumar Ande --- drivers/net/axgbe/axgbe_ethdev.h | 1 + drivers/net/axgbe/axgbe_mdio.c | 73 ++++++++++++++++-------------- drivers/net/axgbe/axgbe_phy_impl.c | 5 ++ 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h index d1fac667c2..b9d8a4e74f 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -658,6 +658,7 @@ struct axgbe_port { enum axgbe_an an_state; enum axgbe_rx kr_state; enum axgbe_rx kx_state; + unsigned int an_again; unsigned int an_supported; unsigned int parallel_detect; unsigned int fec_ability; diff --git a/drivers/net/axgbe/axgbe_mdio.c b/drivers/net/axgbe/axgbe_mdio.c index e1a737cf62..faa7cdbf0a 100644 --- a/drivers/net/axgbe/axgbe_mdio.c +++ b/drivers/net/axgbe/axgbe_mdio.c @@ -200,13 +200,14 @@ static void axgbe_switch_mode(struct axgbe_port *pdata) axgbe_change_mode(pdata, pdata->phy_if.phy_impl.switch_mode(pdata)); } -static void axgbe_set_mode(struct axgbe_port *pdata, +static bool axgbe_set_mode(struct axgbe_port *pdata, enum axgbe_mode mode) { if (mode == axgbe_cur_mode(pdata)) - return; + return false; axgbe_change_mode(pdata, mode); + return true; } static bool axgbe_use_mode(struct axgbe_port *pdata, @@ -882,21 +883,22 @@ static int axgbe_phy_config_fixed(struct axgbe_port *pdata) return 0; } -static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) +static int __axgbe_phy_config_aneg(struct axgbe_port *pdata, bool set_mode) { int ret; + pthread_mutex_lock(&pdata->an_mutex); rte_bit_relaxed_set32(AXGBE_LINK_INIT, &pdata->dev_state); pdata->link_check = rte_get_timer_cycles(); ret = pdata->phy_if.phy_impl.an_config(pdata); if (ret) - return ret; + goto out; if (pdata->phy.autoneg != AUTONEG_ENABLE) { ret = axgbe_phy_config_fixed(pdata); if (ret || !pdata->kr_redrv) - return ret; + goto out; PMD_DRV_LOG(DEBUG, "AN redriver support\n"); } else { PMD_DRV_LOG(DEBUG, "AN PHY configuration\n"); @@ -906,23 +908,26 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) rte_intr_disable(pdata->pci_dev->intr_handle); /* Start auto-negotiation in a supported mode */ - if (axgbe_use_mode(pdata, AXGBE_MODE_KR)) { - axgbe_set_mode(pdata, AXGBE_MODE_KR); - } else if (axgbe_use_mode(pdata, AXGBE_MODE_KX_2500)) { - axgbe_set_mode(pdata, AXGBE_MODE_KX_2500); - } else if (axgbe_use_mode(pdata, AXGBE_MODE_KX_1000)) { - axgbe_set_mode(pdata, AXGBE_MODE_KX_1000); - } else if (axgbe_use_mode(pdata, AXGBE_MODE_SFI)) { - axgbe_set_mode(pdata, AXGBE_MODE_SFI); - } else if (axgbe_use_mode(pdata, AXGBE_MODE_X)) { - axgbe_set_mode(pdata, AXGBE_MODE_X); - } else if (axgbe_use_mode(pdata, AXGBE_MODE_SGMII_1000)) { - axgbe_set_mode(pdata, AXGBE_MODE_SGMII_1000); - } else if (axgbe_use_mode(pdata, AXGBE_MODE_SGMII_100)) { - axgbe_set_mode(pdata, AXGBE_MODE_SGMII_100); - } else { - rte_intr_enable(pdata->pci_dev->intr_handle); - return -EINVAL; + if (set_mode) { + if (axgbe_use_mode(pdata, AXGBE_MODE_KR)) { + axgbe_set_mode(pdata, AXGBE_MODE_KR); + } else if (axgbe_use_mode(pdata, AXGBE_MODE_KX_2500)) { + axgbe_set_mode(pdata, AXGBE_MODE_KX_2500); + } else if (axgbe_use_mode(pdata, AXGBE_MODE_KX_1000)) { + axgbe_set_mode(pdata, AXGBE_MODE_KX_1000); + } else if (axgbe_use_mode(pdata, AXGBE_MODE_SFI)) { + axgbe_set_mode(pdata, AXGBE_MODE_SFI); + } else if (axgbe_use_mode(pdata, AXGBE_MODE_X)) { + axgbe_set_mode(pdata, AXGBE_MODE_X); + } else if (axgbe_use_mode(pdata, AXGBE_MODE_SGMII_1000)) { + axgbe_set_mode(pdata, AXGBE_MODE_SGMII_1000); + } else if (axgbe_use_mode(pdata, AXGBE_MODE_SGMII_100)) { + axgbe_set_mode(pdata, AXGBE_MODE_SGMII_100); + } else { + rte_intr_enable(pdata->pci_dev->intr_handle); + ret = -EINVAL; + goto out; + } } /* Disable and stop any in progress auto-negotiation */ @@ -940,16 +945,7 @@ static int __axgbe_phy_config_aneg(struct axgbe_port *pdata) axgbe_an_init(pdata); axgbe_an_restart(pdata); - return 0; -} - -static int axgbe_phy_config_aneg(struct axgbe_port *pdata) -{ - int ret; - - pthread_mutex_lock(&pdata->an_mutex); - - ret = __axgbe_phy_config_aneg(pdata); +out: if (ret) rte_bit_relaxed_set32(AXGBE_LINK_ERR, &pdata->dev_state); else @@ -960,6 +956,16 @@ static int axgbe_phy_config_aneg(struct axgbe_port *pdata) return ret; } +static int axgbe_phy_config_aneg(struct axgbe_port *pdata) +{ + return __axgbe_phy_config_aneg(pdata, true); +} + +static int axgbe_phy_reconfig_aneg(struct axgbe_port *pdata) +{ + return __axgbe_phy_config_aneg(pdata, false); +} + static bool axgbe_phy_aneg_done(struct axgbe_port *pdata) { return pdata->an_result == AXGBE_AN_COMPLETE; @@ -1041,7 +1047,8 @@ static void axgbe_phy_status_result(struct axgbe_port *pdata) pdata->phy.duplex = DUPLEX_FULL; - axgbe_set_mode(pdata, mode); + if (axgbe_set_mode(pdata, mode) && pdata->an_again) + axgbe_phy_reconfig_aneg(pdata); } static int autoneg_time_out(unsigned long autoneg_start_time) diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c index 4dab2ccad0..87ef8b6048 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -556,6 +556,8 @@ static bool axgbe_phy_belfuse_parse_quirks(struct axgbe_port *pdata) if (memcmp(&sfp_eeprom->base[AXGBE_SFP_BASE_VENDOR_NAME], AXGBE_BEL_FUSE_VENDOR, strlen(AXGBE_BEL_FUSE_VENDOR))) return false; + /* For Bel-Fuse, use the extra AN flag */ + pdata->an_again = 1; /* Reset PHY - wait for self-clearing reset bit to clear */ pdata->phy_if.phy_impl.reset(pdata); @@ -797,6 +799,9 @@ static void axgbe_phy_sfp_detect(struct axgbe_port *pdata) struct axgbe_phy_data *phy_data = pdata->phy_data; int ret; + /* Clear the extra AN flag */ + pdata->an_again = 0; + /* Reset the SFP signals and info */ axgbe_phy_sfp_reset(phy_data); -- 2.34.1