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 4EE4545B01; Thu, 10 Oct 2024 11:18:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02A654065F; Thu, 10 Oct 2024 11:17:49 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2132.outbound.protection.outlook.com [40.107.223.132]) by mails.dpdk.org (Postfix) with ESMTP id 956C540657 for ; Thu, 10 Oct 2024 11:17:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EeKnVL1f/h8eDPXldAmyP/NnXUf0Hx8SgEFjuecxuYBziuBwR2SNUUV4MhV6EpFe+ogeqPQV/CdliI/Wcw8GwvSIeqeX841NbhlqqQvXAzSp7HZSwKPYrBuWd6XjgnNERyqGLuO/4C5LVsGL/kUv/aXHQbQhEM5xOp/rCr8JDYUCKfQs7VZk/8ScehkbrN1DN7Jh3d7n9HwY9CojCiaPB0Ui7qEZmQtjn8jDh0PkP3LXBNYsgkShXmGwShDYIWsOihAzdxAArbi6a9E1DIk7fVrfxXXqQJ+1ikEEpwZx2TgPRqqsOhrx8rDuHZKz5tDRakVe31q1cg14SURkFOtE6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=WbgaHOrBFPcD1b90icegQ4yaee/z7noTTLbZNLhVEB0=; b=hmQ5O8bP8kxviFu5z0+uNgLKv6Zwp04AwAFgj43vwc3lTZLW5g5+gCGjxGZr9EL+/7RfIu8ECyXcTLYNj/+hVLJDaPtS9hAO1Y25hMAyGDuE8plo2Uv3p3SCRgv8MSLUMN7ndi0xWPHcxotRaahLAg2pqIIHuN+h4vDSqinqWWpba/y1JP4Ky0sIT30oamLVD+0A02EjJoUejwcBYgEGFfXG0/NF2K8PK7NAtFpFuqlPvB1EGqOzlnWia6V3i2vgtSMhyrw9sD6ZgvBPFttmaJR37W/s7iXEwnIhfqa6AVkPj9IRMCnyNTjEshRuMDOwY0CqJaceGCgyA7wSuEFikQ== 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=WbgaHOrBFPcD1b90icegQ4yaee/z7noTTLbZNLhVEB0=; b=ubdVJXQk7otOrIqI69OwBfHsrcMM8x0H36pYVx/DoYs3JX+JTtkA+SpM1ECXfr/PBi0aJDdvYDZ+b8OS6V1KaTZeLRYpybgNMhCCFfpgfQuOZOtb9OptQJEfbHRgyBPVVYFxoyD+yA9QxWzPpq+IAt6m89RHMQA04VkPQMt1Jss= 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 MW3PR13MB3980.namprd13.prod.outlook.com (2603:10b6:303:5c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 09:17: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%5]) with mapi id 15.20.8026.020; Thu, 10 Oct 2024 09:17:44 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , Long Wu , Peng Zhang Subject: [PATCH 04/10] net/nfp: improve the logic readability Date: Thu, 10 Oct 2024 17:17:10 +0800 Message-Id: <20241010091716.3631747-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20241010091716.3631747-1-chaoyong.he@corigine.com> References: <20241010091716.3631747-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TP0P295CA0060.TWNP295.PROD.OUTLOOK.COM (2603:1096:910:3::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_|MW3PR13MB3980:EE_ X-MS-Office365-Filtering-Correlation-Id: 89da3e1f-c212-4d42-4f95-08dce90c666f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?I30/83vNRj+iRvi8A29UGxWYQ6bu/XzW5eELffyeAmYL6ASignm5CErw69bU?= =?us-ascii?Q?9ZtjSFlYXQYdFLGxKQDwYMTkzV9NfOAiZVaWqKpWKXO5dpvBCMdZrUa+i5e3?= =?us-ascii?Q?MzdRdkXfmeOqHlbYMPjhrGk4ipWn6M+CiCx3ATM07DeScv/k+izP6bliL1Fi?= =?us-ascii?Q?/e+BfwCuaHWOW/XalnK9dxg+OTwvo6+7vrPwEr2567ImjO8B73t/CuOmUvP9?= =?us-ascii?Q?ldGGQzgYBIOTY+aIEY8FX3W8VJ9aNcf+Si7Sghk0W1CUTacx6GBeHyHIDHu/?= =?us-ascii?Q?tYhSOTP63Dc7qKgfDVf2o7gp+1oHxo+bnADjVAj0TZsOgflGjAhlHqj5WF2+?= =?us-ascii?Q?xENDo4yhGo6ofon0dB/fA2b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ii?Q?qfcePnmWQtb40pkzDzOPzyR4DzEaTOtp1sWzN8Kc+tQayQf0PeSlIWy9QR88?= =?us-ascii?Q?98/DP8lZjFIB2lfL2+70KkHlUU+Q5vVaphX9HqCyafI4wg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Xytcc/Hc6DxKoUpGmDID4q4C44ngFVtyFs65P33GK/I3mI6tsxtguN1odKrp?= =?us-ascii?Q?xThgkSzbDklTEWZvW2380rp63SKN6GfXGFYx0VLUj4U+G9FvzgpNJe4FVTqg?= =?us-ascii?Q?5oxn6sEOsF6IGQe8AhYKZziDhOA0ZMMU067hzHQJk6IAcUGjR3UXDm/zLIf1?= =?us-ascii?Q?gPo6mtLFiNrhAuR1WTyuAtc7e8yNdJOby4QKrAtenFYtOPQTyOHCudNuYTBZ?= =?us-ascii?Q?CIUmw/LhOkyNoZJ9cXBffyh8ESM9tkgXPucC+Y43i73Dv9m4kwEr0tdEs+AC?= =?us-ascii?Q?ZkLyczz3/qjrqOqpxfkcdzJf6ttoPNddfDl1oyDy9nPV7yVTJz8E0uEUtbjo?= =?us-ascii?Q?BL6WbysoPyEWwcDeNhBF3gKGqMnxr0LG0+6YkwtLxxaoWiseqZ97pB8zsWn7?= =?us-ascii?Q?HzS17XL2lWzboInuV7ydGWxyan0BYP8UOj6pvb5LH0lybYeJRSzId6Jg8bqZ?= =?us-ascii?Q?fsv7Ubt5g1t40zbS6ntPJ5wM3ZiQ3AkSISbPn+uasitzEHCFt3DS6EobydfC?= =?us-ascii?Q?TnGJT87od0J5iwzYM0m3hg0UIPut569SeWBKGcWdmTanP80s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LIEo8w/bKjjZldPSMmf1TIfGuN9fMvt8ePxOkvlknfm6EMf5oO?= =?us-ascii?Q?/jR8RS4TxetHZN3iWRAxci0MuFnv0xHPiy1R41nMl9i7K1mJxkhkDHWmcr0v?= =?us-ascii?Q?vfie3tfSRh4CvcXVJ3GMR36cQVp6geTKVLAqIn+ajsLf+OfG2fQcW1MJK+pG?= =?us-ascii?Q?Jw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89da3e1f-c212-4d42-4f95-08dce90c666f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 09:17:44.9046 (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: labTKU5KaINgOuyLjkLsN67R6sedNY/NVK6boxczTUiQK12G3ihOKr4aYbwEaeShMCvU3Qc1DCxmrkubfHcg/OKsQBcNEjwx/rauTnXxxK8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB3980 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 Try our best to make the logic in secondary proess the same with the primary process and improve the readability, by add helper functions and rename function. Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfp_ethdev.c | 86 +++++++++++++++----------------- drivers/net/nfp/nfp_net_common.c | 22 +++++++- drivers/net/nfp/nfp_net_common.h | 3 +- 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 121f82af6d..405386e882 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -1764,19 +1764,9 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev) static bool nfp_app_fw_nic_total_phyports_check(struct nfp_pf_dev *pf_dev) { - int ret; - uint8_t id; uint8_t total_phyports; - char vnic_name[RTE_ETH_NAME_MAX_LEN]; - /* Read the number of vNIC's created for the PF */ - id = nfp_function_id_get(pf_dev, 0); - snprintf(vnic_name, sizeof(vnic_name), "nfd_cfg_pf%u_num_ports", id); - total_phyports = nfp_rtsym_read_le(pf_dev->sym_tbl, vnic_name, &ret); - if (ret != 0 || total_phyports == 0 || total_phyports > 8) { - PMD_INIT_LOG(ERR, "%s symbol with wrong value", vnic_name); - return false; - } + total_phyports = nfp_net_get_phyports_from_fw(pf_dev); if (pf_dev->multi_pf.enabled) { if (!nfp_check_multi_pf_from_fw(total_phyports)) { @@ -1797,6 +1787,20 @@ nfp_app_fw_nic_total_phyports_check(struct nfp_pf_dev *pf_dev) return true; } +static void +nfp_port_name_generate(char *port_name, + size_t length, + int port_id, + struct nfp_pf_dev *pf_dev) +{ + const char *name = pf_dev->pci_dev->device.name; + + if (pf_dev->multi_pf.enabled) + snprintf(port_name, length, "%s", name); + else + snprintf(port_name, length, "%s_port%u", name, port_id); +} + static int nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) { @@ -1849,12 +1853,7 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) /* Loop through all physical ports on PF */ for (i = 0; i < pf_dev->total_phyports; i++) { - if (pf_dev->multi_pf.enabled) - snprintf(port_name, sizeof(port_name), "%s", - pf_dev->pci_dev->device.name); - else - snprintf(port_name, sizeof(port_name), "%s_port%u", - pf_dev->pci_dev->device.name, i); + nfp_port_name_generate(port_name, sizeof(port_name), i, pf_dev); id = nfp_function_id_get(pf_dev, i); hw_init.idx = id; @@ -1870,15 +1869,10 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) return 0; port_cleanup: - for (i = 0; i < pf_dev->total_phyports; i++) { + for (uint32_t j = 0; j < i; j++) { struct rte_eth_dev *eth_dev; - if (pf_dev->multi_pf.enabled) - snprintf(port_name, sizeof(port_name), "%s", - pf_dev->pci_dev->device.name); - else - snprintf(port_name, sizeof(port_name), "%s_port%u", - pf_dev->pci_dev->device.name, i); + nfp_port_name_generate(port_name, sizeof(port_name), j, pf_dev); eth_dev = rte_eth_dev_get_by_name(port_name); if (eth_dev != NULL) rte_eth_dev_destroy(eth_dev, nfp_net_uninit); @@ -2369,7 +2363,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev) pf_dev->nfp_eth_table = nfp_eth_table; pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_nsp(pci_dev, cpp); pf_dev->multi_pf.function_id = function_id; - pf_dev->total_phyports = nfp_net_get_port_num(pf_dev); + pf_dev->total_phyports = nfp_net_get_phyports_from_nsp(pf_dev); ret = nfp_net_force_port_down(pf_dev); if (ret != 0) { @@ -2547,42 +2541,37 @@ static int nfp_secondary_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv) { uint32_t i; - int err = 0; int ret = 0; - uint8_t function_id; uint32_t total_vnics; - char pf_name[RTE_ETH_NAME_MAX_LEN]; + char port_name[RTE_ETH_NAME_MAX_LEN]; struct nfp_pf_dev *pf_dev = hw_priv->pf_dev; - /* Read the number of vNIC's created for the PF */ - function_id = (pf_dev->pci_dev->addr.function) & 0x07; - snprintf(pf_name, sizeof(pf_name), "nfd_cfg_pf%u_num_ports", function_id); - total_vnics = nfp_rtsym_read_le(pf_dev->sym_tbl, pf_name, &err); - if (err != 0 || total_vnics == 0 || total_vnics > 8) { - PMD_INIT_LOG(ERR, "%s symbol with wrong value", pf_name); - return -ENODEV; - } + total_vnics = nfp_net_get_phyports_from_fw(pf_dev); for (i = 0; i < total_vnics; i++) { - char port_name[RTE_ETH_NAME_MAX_LEN]; - - if (nfp_check_multi_pf_from_fw(total_vnics)) - snprintf(port_name, sizeof(port_name), "%s", - pf_dev->pci_dev->device.name); - else - snprintf(port_name, sizeof(port_name), "%s_port%u", - pf_dev->pci_dev->device.name, i); + nfp_port_name_generate(port_name, sizeof(port_name), i, pf_dev); PMD_INIT_LOG(DEBUG, "Secondary attaching to port %s", port_name); ret = rte_eth_dev_create(&pf_dev->pci_dev->device, port_name, 0, NULL, NULL, nfp_secondary_net_init, hw_priv); if (ret != 0) { PMD_INIT_LOG(ERR, "Secondary process attach to port %s failed", port_name); - ret = -ENODEV; - break; + goto port_cleanup; } } + return 0; + +port_cleanup: + for (uint32_t j = 0; j < i; j++) { + struct rte_eth_dev *eth_dev; + + nfp_port_name_generate(port_name, sizeof(port_name), j, pf_dev); + eth_dev = rte_eth_dev_get_by_name(port_name); + if (eth_dev != NULL) + rte_eth_dev_destroy(eth_dev, NULL); + } + return ret; } @@ -2714,6 +2703,11 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) pf_dev->sym_tbl = sym_tbl; + /* Read the number of physical ports from firmware */ + pf_dev->multi_pf.function_id = function_id; + pf_dev->total_phyports = nfp_net_get_phyports_from_fw(pf_dev); + pf_dev->multi_pf.enabled = nfp_check_multi_pf_from_fw(pf_dev->total_phyports); + /* Read the app ID of the firmware loaded */ snprintf(app_name, sizeof(app_name), "_pf%u_net_app_id", function_id); app_fw_id = nfp_rtsym_read_le(sym_tbl, app_name, &ret); diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 99f6b61947..86a1fbfaf2 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -14,6 +14,7 @@ #include "nfdk/nfp_nfdk.h" #include "nfpcore/nfp_mip.h" #include "nfpcore/nfp_nsp.h" +#include "nfpcore/nfp_rtsym.h" #include "nfp_logs.h" #include "nfp_net_meta.h" @@ -2724,7 +2725,7 @@ nfp_net_fec_set(struct rte_eth_dev *dev, } uint32_t -nfp_net_get_port_num(struct nfp_pf_dev *pf_dev) +nfp_net_get_phyports_from_nsp(struct nfp_pf_dev *pf_dev) { if (pf_dev->multi_pf.enabled) return 1; @@ -2732,6 +2733,25 @@ nfp_net_get_port_num(struct nfp_pf_dev *pf_dev) return pf_dev->nfp_eth_table->count; } +uint32_t +nfp_net_get_phyports_from_fw(struct nfp_pf_dev *pf_dev) +{ + int ret = 0; + uint8_t total_phyports; + char pf_name[RTE_ETH_NAME_MAX_LEN]; + + /* Read the number of vNIC's created for the PF */ + snprintf(pf_name, sizeof(pf_name), "nfd_cfg_pf%u_num_ports", + pf_dev->multi_pf.function_id); + total_phyports = nfp_rtsym_read_le(pf_dev->sym_tbl, pf_name, &ret); + if (ret != 0 || total_phyports == 0 || total_phyports > 8) { + PMD_INIT_LOG(ERR, "%s symbol with wrong value", pf_name); + return 0; + } + + return total_phyports; +} + uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev, uint8_t port_id) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index fb244383b7..8429db68f0 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -374,7 +374,8 @@ void nfp_net_get_fw_version(struct nfp_cpp *cpp, uint32_t *fw_version); int nfp_net_txrwb_alloc(struct rte_eth_dev *eth_dev); void nfp_net_txrwb_free(struct rte_eth_dev *eth_dev); -uint32_t nfp_net_get_port_num(struct nfp_pf_dev *pf_dev); +uint32_t nfp_net_get_phyports_from_nsp(struct nfp_pf_dev *pf_dev); +uint32_t nfp_net_get_phyports_from_fw(struct nfp_pf_dev *pf_dev); uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev, uint8_t port_id); int nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw, -- 2.39.1