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 961F0454B8; Mon, 24 Jun 2024 03:58:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A09ED4064A; Mon, 24 Jun 2024 03:57:53 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2110.outbound.protection.outlook.com [40.107.101.110]) by mails.dpdk.org (Postfix) with ESMTP id 55C9D402E3 for ; Mon, 24 Jun 2024 03:57:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MfONkfibVL4eiZX40NGRjU6JeivZxSqOwkD7b02vS4s0P9AnLkfAEzdKvRRzlTWtIQ4J/8Gq1GY0PBLFCzj0AG04kvhBwh7UHGbSYa+x0q9vvqMaZf2ljkpg0QKv/znV9S0oqfsFtdyyVZmTI9e7JgSFlc1b4OgFeVEoXVMRTCpTRjUdsqO6CH4rMLdlbgvIRCm16/HgPOyvLVt4Orfj/6yDK54zyuwBstiCh1RMTRBd9E0LGxilZiD4k+IxLNClLF/Ke1y1g7ZHCwnwFmhy0qEn1LLSg6qqmFyNG8ATGUDi92dih73hDNELujLMlPPAlfWlIxm45khrsl3RSajBdw== 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=n/+EjgkKJgDn3yXrPHv6I9o/WoB90i6hBq9TRx3aeGk=; b=c2QObFF4cSzFGBUmiRoV3Yyt/2biv7FSAwFfelM4wKSWFG5NRnwcbEU4/ZrzXlMyc9VKg8XELz4Hn61HwgYmyw98WN7ls6Y5W4soNBKUU0Ag5sshOi+sJ94XsDQq/hjYP8SM/mKKqD9HO1c/M61CEZo4hde8Z+4ayh6dDqxoXTwUiBaGGuw4SC/iOhAwMGJ6bGcuIjax7m3j01L5GI09DZUhML+G4BqDGcbqjlQbZ3W06gcK8Q1liD8pHJanfMYN30JZ6XXZBkSdScDV2DrEhX5nwZIx+NlfJ0jm6gk9I2bbfjVKEm0Yt6dJkhpNDTl4ShxAB42Nny+6umIdNvVjPA== 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=n/+EjgkKJgDn3yXrPHv6I9o/WoB90i6hBq9TRx3aeGk=; b=mLX5BN6l2NqnQKahPPqVkqJ6HZ3uqoAlYRdevGNdTQVda8B4WmBFfManfwTqu6McXlIvsPKs2q4m48WAw7bf/2iBgkIbeVrmrX3UbBMQwn44fUslVFrLoqc1LjVGyw3y/y9B6oc4j8ZTUFViWBlKhfuiQYwT+ozuNVsmHXr++/4= 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:48 +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:47 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Zerun Fu , Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 02/17] net/nfp: refactor device speed update logic Date: Mon, 24 Jun 2024 09:57:08 +0800 Message-Id: <20240624015723.3712898-3-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: 56960c41-f009-410e-fbf1-08dc93f10bef 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?hhqYN9Xm7vyqfdlmPijGW55nJrSG95wY+70slb7C0QboNnbNGtj0qHmYERft?= =?us-ascii?Q?dQQy3DjBqWZLvuEu4ruRd6Xz99MYBjoHEZ2m1q1429z8c6aztYvnGNyTEIyV?= =?us-ascii?Q?3r3gwoTfHYWqK8/60yVsqJ2x5+MVwi+5AVXkBhsDFJpdeEbQj0B0H1etol0X?= =?us-ascii?Q?cR4kG3j9pb9L8CcRsJQBYhnm8dOPXMmYw2RwLrVXFMLUQhgNvpbq4ZixmaJE?= =?us-ascii?Q?a2PXkfMdyWstH0OYBcPdbwso1cLCgNbFdY7sPXUwcA/35Lc+cusKenagE37S?= =?us-ascii?Q?v6z9lc2QKrVpXQ7Pp/NbT3b4n3JkjGVDTbr38oRJ1AvCXXPy/YaVX3Ibfq4S?= =?us-ascii?Q?adlHCf/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MRXJmGqj?= =?us-ascii?Q?KhB/5dn8tAfVGXqudZDuCd3haeRoDELpM41QOPTZuTT2Wbty1NZkU7ujzVer?= =?us-ascii?Q?FdNoQycIzdBx86sx4QUmLm6I7sCPJlitlPxL3ubupDglurvEd1CayH1F0ozl?= =?us-ascii?Q?BEb2fl7DHmORgxmS6rdqWpmPHjw5DdYDmiZPaUb5iAF/SlqdRQ=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?uF8DZJ7Sku1ktKC/1G+vFr6v8xVUpMfBv2vi/95D65xns+LjAbm/mzJf1+AU?= =?us-ascii?Q?euASq1jKKC4FQ5tsOhp0/4E9OUXBC9QiyAt7fi6fwmMpS60gPmIrE1shiV8q?= =?us-ascii?Q?ISeRUL4lP2j/f1Ipxes9f9lbhAbJDeKK5SXrJuBqPu1zQXUKuritOg+4u7np?= =?us-ascii?Q?FqeQrh9mTyQF3WbQk3XTBIqr0yLNwR4lG1ZXrqrx2/7zKqkTYfMT1DBv3uFV?= =?us-ascii?Q?fUy1A+6qgwVCWJMSvX8lfb+bUrEVqtY7IgGCDV7yhA4uucnSnS1Sk9Pd/+eZ?= =?us-ascii?Q?BZMFNWGXf/3hx7/BD8Rlw6cN1/ceq0tF62ivUYrHvkB7He4fkXla6ryui64r?= =?us-ascii?Q?zpK1bXwnNdM+T8KyoE2o4MLjMjQC10BHsnGUais5Vn+VqfA/aMpuAyvoejk7?= =?us-ascii?Q?9E8tty6hYO9pHFaeCxPOghZHYulyYO5sA9svS9zWJjFTZg/jD7oagFfNWRL9?= =?us-ascii?Q?FdSoXiHIQ7fUK+x39t3Dw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FQZj49mk8GtZMSN925aIk5UaKE0T5so2+B6v8g9W2Yr09hhzLDDNLDbCdC?= =?us-ascii?Q?vV1eErJAGVmvUAkR3WzUdCwRZ1L+imqaKFT2Z3z+EpLbb3w14Zt6VBtycs07?= =?us-ascii?Q?t7zqIfgi3RG0cTcWNzbXvdxWlEPxJX3FHooVSQaFfGli0oMHk5vyYgW53/vG?= =?us-ascii?Q?0JJ+LP1Ktd3cg6L6y9dP2k/bv/JJDki1gnjDaMW5gRIOeFWoIlXSaH0RCFJ9?= =?us-ascii?Q?+Q=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56960c41-f009-410e-fbf1-08dc93f10bef 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:47.9071 (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: MvU1bt2sZTEcK1clOUXRIkoYl0JxY3jlo8NYwgRGRwWkwW+es33ryt5MrNDtOYuegs3AvwFFfuP394bHrvWQgmlLhjj3SMt4sIisnUyIlc4= 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 previous logic will call 'nfp_eth_read_ports()' every time when the link status changed, but some of which are not necessary. Refactor this part of logic and only call 'nfp_eth_read_ports()' when the speed is really updated or the device is under auto-negotiation mode. Signed-off-by: Zerun Fu Reviewed-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_ethdev.c | 3 +++ drivers/net/nfp/nfp_net_common.c | 18 ++++++++++++------ drivers/net/nfp/nfp_net_common.h | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index f4fd013a51..9870b2dd33 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -339,6 +339,8 @@ nfp_net_speed_configure(struct rte_eth_dev *dev) } } + hw_priv->pf_dev->speed_updated = true; + return 0; } @@ -2250,6 +2252,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev) pf_dev->nfp_eth_table = nfp_eth_table; pf_dev->sync = sync; pf_dev->total_phyports = nfp_net_get_port_num(pf_dev, nfp_eth_table); + pf_dev->speed_updated = false; ret = nfp_net_speed_cap_get(pf_dev); if (ret != 0) { diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 5616160686..fed8daa188 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -738,22 +738,28 @@ nfp_net_speed_aneg_update(struct rte_eth_dev *dev, { uint32_t i; uint32_t speed; + enum nfp_eth_aneg aneg; + struct nfp_pf_dev *pf_dev; struct nfp_eth_table *nfp_eth_table; struct nfp_eth_table_port *eth_port; + pf_dev = hw_priv->pf_dev; + aneg = pf_dev->nfp_eth_table->ports[hw->idx].aneg; + /* Compare whether the current status has changed. */ - if (dev->data->dev_link.link_status != link->link_status) { - nfp_eth_table = nfp_eth_read_ports(hw_priv->pf_dev->cpp); + if (pf_dev->speed_updated || aneg == NFP_ANEG_AUTO) { + nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp); if (nfp_eth_table == NULL) { PMD_DRV_LOG(DEBUG, "Error reading NFP ethernet table."); return -EIO; + } else { + pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx]; + free(nfp_eth_table); + pf_dev->speed_updated = false; } - - hw_priv->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx]; - free(nfp_eth_table); } - nfp_eth_table = hw_priv->pf_dev->nfp_eth_table; + nfp_eth_table = pf_dev->nfp_eth_table; eth_port = &nfp_eth_table->ports[hw->idx]; speed = eth_port->speed; diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index b43f815951..8e3e219261 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -160,6 +160,9 @@ struct nfp_pf_dev { uint8_t vf_base_id; /** Number of queues per VF */ uint32_t queue_per_vf; + + /** Record the speed uptade */ + bool speed_updated; }; #define NFP_NET_FLOW_LIMIT 1024 -- 2.39.1