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 26B67454B8; Mon, 24 Jun 2024 03:57:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CEB3402EB; Mon, 24 Jun 2024 03:57:50 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2131.outbound.protection.outlook.com [40.107.101.131]) by mails.dpdk.org (Postfix) with ESMTP id D8A2B4027B for ; Mon, 24 Jun 2024 03:57:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nzTZYnDGu1qO6OCgfVu0MGqmhzU+9qxtG0VfDy1PgdokYZKjY+IyLkKFGzxE0uGZ1WXn0TTbDQvdW6KNy8cAE4LxUHhIVPzgscbhXfaYgtQXukv1Mp55HLvuB34YzbFouUsh+I9ruc1gJhp78TTu4fp8pydpBpHVmo4SeBZuZO1V2hc0jnZ7e1vijwya/o+rKaQan90iQGmCM3HPWHZcKxYD3MwcrL8C3CkTiXv4IjP05Jux7c0ycUrTc0Brpzyqjdg2V4Hww0CGYdUu0c5V+4Ix5Z8j7VOqWh1KpsusQZT0WuW0CdikjzE0p404qUbQY5kgLAzaa3ST7vLml7CASA== 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=hfugJc8UHh5SnwVs+dUyn1gb3f3BG5VRc2kdSqZQBjY=; b=WrdPyJrIfb5dNog0gVQq9gGxOJDtFc9Q3PWDmz2A563RP4I86RL8nRDrHkeweljIjSnumQ3gEEKhLcHxkda7siR0E+fClUeNukk6i3iKmkx7MEsG/nw2L1tvcHATMt1RtrlkxBlljOtBKDNQIQ0s5tfG7Wh3NmlH7G4dwNxHKCVdPEqQoSOD9if6fMmbMEcjACsx12zlzN/91w9OaFL9axBFj/6/Foh0hP0dGKydVU05u4EhvUS/bUVEIW47EOANDJTPSuLZ3CbGD+20e7lNQhotYUMG83hdz/cMUd2v5yCg7bd+i61jBGF+daJufYbkma0Up54cP9HXAmV7tuPwJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hfugJc8UHh5SnwVs+dUyn1gb3f3BG5VRc2kdSqZQBjY=; b=hDgkAE51KwKwXTD6aQ6QRcSmKx/jOsUzvHnnNdOcCVrhHv+SlH0qm+Qc/No/6blG/wC98BuMJeixgGB6q5+dSYswrdWo21u0M228rdt5Hg5sRsgc5LdmiCydQcypYich7/8sNM8YH/nx//4nWiV5Ca7aidjV0cxK9r5zQRPYAmU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by SA1PR13MB5443.namprd13.prod.outlook.com (2603:10b6:806:232::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.37; Mon, 24 Jun 2024 01:57:45 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7698.024; Mon, 24 Jun 2024 01:57:45 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Zerun Fu , Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 01/17] net/nfp: refactor speed configuration logic Date: Mon, 24 Jun 2024 09:57:07 +0800 Message-Id: <20240624015723.3712898-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240624015723.3712898-1-chaoyong.he@corigine.com> References: <20240624015723.3712898-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0070.namprd13.prod.outlook.com (2603:10b6:a03:2c4::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB5443:EE_ X-MS-Office365-Filtering-Correlation-Id: c668a834-f845-4e89-8fa8-08dc93f10ab5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|52116011|376011|1800799021|366013|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GCJoCtCU0AR6iS+yDdrY2U4UKAOMecX8vXkneDT3MHkhylixEiD/N0CNTyL8?= =?us-ascii?Q?ZRQA79ycufl5Y0czvi33oEziLiRLTerVirGEyqGRDen9bQ35+OmChtDf3Peo?= =?us-ascii?Q?oT1pAhIh2QJxlhsFpAfajJBUr5L3kurcb+kpzc0veYlwB+Um0j328Gra8B4G?= =?us-ascii?Q?cuvYN7NpNutMMOvQp8a6yUC6ceSOFQuWm3JAsPN7l6oCx1r12r3J5MEXK72V?= =?us-ascii?Q?byH0jMM+9xhWBvE678kntdTp9M4syPZdnSOxuVDe7gqnmCYufXXwOn/eSzWe?= =?us-ascii?Q?QLIK6Z98nHzILbKPDTvwsBX/rfYKtk+j7HK4j5kHdIGGQqZh/yRs9E3+dCnU?= =?us-ascii?Q?jffLHK+bKbn/oJniIQYrqRtvdc4kPPdwj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V9+ZaS6psbCI2Wii0SEwYa/SUscBZvxpaVUg+2+tzIk2Rb?= =?us-ascii?Q?kNIVXCJSY83ejlFhWA193Ngu9H3o3B3d740My8SUvP/8X0cmTg2n2ona18St?= =?us-ascii?Q?MsDoI88+H6yaRmUefjb3HnRv3T9IlyfOo9gis9DqtXmEqwsTUA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(52116011)(376011)(1800799021)(366013)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FuZjOHavgqAbolWBM5Br+If8GpE986e9eVx+zIxKU3fNnAaqpCMQxWarTt7x?= =?us-ascii?Q?J9qMNZ7sBy9FI+PO1+9wQKRCyJiBW6c8WCfzm6dZ1rActlbnh3hjnwdVa4HL?= =?us-ascii?Q?HRD/wPZQ+a0cHd6qAj9pa/bWrhzfvyV8rBaSPR8MAMQV5KQFGD/mMFzSnYOB?= =?us-ascii?Q?NkYuFJSzszdxzAH1hlj5LyHlElOwBL24irxqmIoZZtwXCUPlNmhVVKU59+y1?= =?us-ascii?Q?p8HZY9lZi6ZiKQwrOryqxlyjlOBpSyHTaMVn1oeOsmBSgsjCoKV4A3FeN4V5?= =?us-ascii?Q?THlIhmeDwHUovTX6uNtD+zlEvzW+bH7dHv32ej7bmY5ExKcNjHSCZgfQyUTS?= =?us-ascii?Q?KnyrZAPu3U46VjNG9rRbxB8EHuPjbdHzCPrR+O6pWDuGbn3WztMymnXcTTtR?= =?us-ascii?Q?RzhLhiC2SqK6P0RofNvBG0LKjE55vTu7AT7zNOld/i/j2BpbeS1dP5xBxbQd?= =?us-ascii?Q?U2nEyVdf3cFpqv7Lv6fkc9kuepvDwzJoMiTQt2SCqeQ1uaXSTVhgE+8z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Z+8P3Hg/4vn0WJrBzF5InCe6gcuVOxaK?= =?us-ascii?Q?Mzf4Vd3gBf7H+hivDF4/BaWw6aFjsLhlOV5BNXLSnxgnP1yHlq8xDfhAL5v4?= =?us-ascii?Q?6H5htgznL3TFe39AcTZ8lLqkUQe/ezUAjg8Rz92VcK1prSdxF6YJX4lrqAca?= =?us-ascii?Q?hUJoy1CgS+1+yOr/Ww0bgr+Fb3/j8efVQRUBLLanoTWmqAvMnkGjbCL85rGo?= =?us-ascii?Q?Vg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c668a834-f845-4e89-8fa8-08dc93f10ab5 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 01:57:45.8799 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FEyzvKPRWTMOKcHEorGaTkIfKm+mQW3Pf84ozb9FMxWCQ5OLnzaTb1ByywR4Co1kHuELqs7yIgUiLHEGCHjRW7kszo3MAopvIoQSRCw+Luk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB5443 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 From: Zerun Fu The speed configuration logic will execute every time the device start, even if the speed is not changed. Refactor this part of logic to make sure it only executes when the speed is really need to be changed. Signed-off-by: Zerun Fu Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_ethdev.c | 100 +++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index b04bc955b5..f4fd013a51 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -220,12 +220,68 @@ nfp_net_nfp4000_speed_configure_check(uint16_t port_id, return 0; } +static int +nfp_net_speed_autoneg_set(struct nfp_net_hw_priv *hw_priv, + struct nfp_eth_table_port *eth_port) +{ + int ret; + struct nfp_nsp *nsp; + + nsp = nfp_eth_config_start(hw_priv->pf_dev->cpp, eth_port->index); + if (nsp == NULL) { + PMD_DRV_LOG(ERR, "Could not get NSP."); + return -EIO; + } + + ret = nfp_eth_set_aneg(nsp, NFP_ANEG_AUTO); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to set ANEG enable."); + nfp_eth_config_cleanup_end(nsp); + return ret; + } + + return nfp_eth_config_commit_end(nsp); +} + +static int +nfp_net_speed_fixed_set(struct nfp_net_hw_priv *hw_priv, + struct nfp_eth_table_port *eth_port, + uint32_t configure_speed) +{ + int ret; + struct nfp_nsp *nsp; + + nsp = nfp_eth_config_start(hw_priv->pf_dev->cpp, eth_port->index); + if (nsp == NULL) { + PMD_DRV_LOG(ERR, "Could not get NSP."); + return -EIO; + } + + ret = nfp_eth_set_aneg(nsp, NFP_ANEG_DISABLED); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to set ANEG disable."); + goto config_cleanup; + } + + ret = nfp_eth_set_speed(nsp, configure_speed); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to set speed."); + goto config_cleanup; + } + + return nfp_eth_config_commit_end(nsp); + +config_cleanup: + nfp_eth_config_cleanup_end(nsp); + + return ret; +} + static int nfp_net_speed_configure(struct rte_eth_dev *dev) { int ret; uint32_t speed_capa; - struct nfp_nsp *nsp; uint32_t link_speeds; uint32_t configure_speed; struct nfp_eth_table_port *eth_port; @@ -260,40 +316,30 @@ nfp_net_speed_configure(struct rte_eth_dev *dev) } } - nsp = nfp_eth_config_start(hw_priv->pf_dev->cpp, eth_port->index); - if (nsp == NULL) { - PMD_DRV_LOG(ERR, "Couldn't get NSP."); - return -EIO; - } + if (configure_speed == RTE_ETH_LINK_SPEED_AUTONEG) { + if (!eth_port->supp_aneg) + return 0; - if (link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) { - if (eth_port->supp_aneg) { - ret = nfp_eth_set_aneg(nsp, NFP_ANEG_AUTO); - if (ret != 0) { - PMD_DRV_LOG(ERR, "Failed to set ANEG enable."); - goto config_cleanup; - } - } - } else { - ret = nfp_eth_set_aneg(nsp, NFP_ANEG_DISABLED); + if (eth_port->aneg == NFP_ANEG_AUTO) + return 0; + + ret = nfp_net_speed_autoneg_set(hw_priv, eth_port); if (ret != 0) { - PMD_DRV_LOG(ERR, "Failed to set ANEG disable."); - goto config_cleanup; + PMD_DRV_LOG(ERR, "Failed to set speed autoneg."); + return ret; } + } else { + if (eth_port->aneg == NFP_ANEG_DISABLED && configure_speed == eth_port->speed) + return 0; - ret = nfp_eth_set_speed(nsp, configure_speed); + ret = nfp_net_speed_fixed_set(hw_priv, eth_port, configure_speed); if (ret != 0) { - PMD_DRV_LOG(ERR, "Failed to set speed."); - goto config_cleanup; + PMD_DRV_LOG(ERR, "Failed to set speed fixed."); + return ret; } } - return nfp_eth_config_commit_end(nsp); - -config_cleanup: - nfp_eth_config_cleanup_end(nsp); - - return ret; + return 0; } static int -- 2.39.1