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 488F141FC8; Wed, 30 Aug 2023 04:16:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF7FA402A3; Wed, 30 Aug 2023 04:15:42 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2101.outbound.protection.outlook.com [40.107.243.101]) by mails.dpdk.org (Postfix) with ESMTP id 5C1194027D for ; Wed, 30 Aug 2023 04:15:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HVNonZ3nTktgJ6/b2SySklhNzuPHI/xeQPFFKhJ4nIOumGtAclGa4f79PNrKFVL5kcYkduSgQdGGU+uBLBjdMBg6ZANyVDBwHex5dNBe75q5RYx5jlevzc2ULQJboIKTw72Ll2E37aNhioFsVURuJhpLx8gFYcD8NN9/ofORtUqYap+jaRx9o0XHOWzlRcvPzifhNYNoZaFF3lvC3kHqVqtvwL8sWZp9Sn5NXBhC0mJHjUn7wbp79kLOM4JoO9fG52m70AO3PXjI62Rhn4iAURNz3ZC7q8WSIn2ZTfHSkMs5HmzizuCPdbCDtaLlhsxrn58k8BASLa6ZOHCGViae4Q== 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=N1TZ/bBWRv4An4P2brZ54m85MvHsjC8EZ3+c9P/89rQ=; b=NHYyVlxm9U+moirfF4H3z6M96NKNEn4tZ4DbmuJSzXr1zUFAg0nNX0+S9oWRTF5gEF5G3lX8pm5fMbZ+7DD9XA8hQCy0WWQCF2w7uONIRcbZOC1h9ZTE5Nz0N7GOl28a/fklHuH4emOoQygkw+b06OywcNDJjQOyvHptHcqTBNU/8rJWy5w/Xl9vfCsVJGGC9lgXWQAnZCFl2vE/ruwoqdXkke8eKtoq3RbAuB0p2e1leWi6QJibunU6BSRWMmF/KEm6K0qBWILji2vloKpnMCJIAKCcTdln7Mgdn5xW4YEc0ms3stQNRty6DSucyNMqA+UtTmHLEwzYNfSduIlTKw== 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=N1TZ/bBWRv4An4P2brZ54m85MvHsjC8EZ3+c9P/89rQ=; b=cC3O7fCMSpXCkReGqt/3R8m47aTCt43Hl3X8ieyWeSdI7YaUVwk7zC3+d/3JHXZUQtgJcaV4RixCZaI5WAXeMQemEGepuQMDdIDAZTuh88U7l/9IFe8PHlE0DHap3BqwlgwCqgBN/qAiYcac9GUUJmxm6lKgCJJ19ThYLhdPtNw= 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 SJ0PR13MB5548.namprd13.prod.outlook.com (2603:10b6:a03:421::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Wed, 30 Aug 2023 02:15:39 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c0f3:c2cc:b5bb:4192]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c0f3:c2cc:b5bb:4192%4]) with mapi id 15.20.6699.034; Wed, 30 Aug 2023 02:15:39 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 08/27] net/nfp: using the DPDK memory management API Date: Wed, 30 Aug 2023 10:14:38 +0800 Message-Id: <20230830021457.2064750-9-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230830021457.2064750-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> <20230830021457.2064750-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH0PR07CA0113.namprd07.prod.outlook.com (2603:10b6:510:4::28) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SJ0PR13MB5548:EE_ X-MS-Office365-Filtering-Correlation-Id: 39630f4f-a323-4e8b-e4e8-08dba8ff0109 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LPAGwdZST4rEH3IH2zN2NU8cTN9gFzrxUkuKjmRrou4o3//sTlAqTOFhUCzqm9jCJjjibZmY5YBR7EFCRFhuL++orLc9O8MGDlPJFFIrzBY9LVK/pI328kAvPzY7Pb+lVhObA0xRXFwmpAhJ0JJCKB5pUR/3t2jgXzFh+8aTPZFP0blJXLaKA7OfIf37wVtwhscCBcgWCHt9b3SwTg2PjgQxR+OMI6whGjxc0k+j0cGksl3rHUekJXxKXCwLaNRv9Vl23qI2ZAy0QPkYcsQJ4sXvuvetnjDtUfGFqEE4QJBWjXyTrp6ry2evuxKZtAYReycyUaATDNcmbzSoBl2BAVJsWJI6VomsUBiEPO9aHV+c58BFSyngjXPyCrGzN2HktgLgWD0g7+ohbMBee1X1mhbSeToflzU7id5uBmcpHrQC2NLUJwS1N7rTYWZUdCw7kEGwE68or5XGGwmOoFtZRjBurPQjeUcnO0ku/HNpSwUSNMn6/P9un2K4XY1+qB/N5J9H4CIVthCaRjP1C6FF5AJ7+3rnTmU5bL1khHnv8OiZoTTIiPefEaDsPD1hCgG0lQx37q0YWGyZfw5XOAGeZIFadtzrv7UB1wKo2aS9shJYlJdYD+fNixqRfWcc0MC8ISF7j7+iKgQjV4Adg2zm8pmjYJJFkNitdyqde6QjH2o= 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:(13230031)(346002)(396003)(136003)(39830400003)(376002)(366004)(1800799009)(451199024)(186009)(44832011)(4326008)(66556008)(6916009)(2906002)(66476007)(36756003)(66946007)(5660300002)(316002)(8936002)(8676002)(41300700001)(6506007)(6486002)(52116002)(1076003)(26005)(107886003)(6512007)(66574015)(30864003)(2616005)(38350700002)(38100700002)(478600001)(83380400001)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UGNSK2M3Z1VBNGxqbFQxZVBXeW5jUTBobk03cGI5ekxkMnAvZ3JreXkwS3do?= =?utf-8?B?eDNEZWhPblZkdW5uOHFiMVJqWlhSMHp5aU5sYTQwaFJ2Q3V3dCsrb25EVDVJ?= =?utf-8?B?anRIT3VYK1REaWZYcDZxQU9IQW9ZTFdDUlJoYzNDMUhaTm41VDZ3Qzg0SGVY?= =?utf-8?B?M3ZONm1ab1cyVlFQQVZKUkQ2VEI4QWNFd01USU1UUXVFb0xMeFVFVmZFZ1BR?= =?utf-8?B?SVFIQlRXazRMaWlsb01xZUlRZmxVcGhYejZlYVBLdXZnNnhlcFJuMldmK2gx?= =?utf-8?B?RFVmUU9wYTZEWkFTYjg1WUE2UUp3TjNydG84TmxteUU1M1dMREJXbHBkekhJ?= =?utf-8?B?ZmdIWkNXbD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mdy?= =?utf-8?B?eEE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39630f4f-a323-4e8b-e4e8-08dba8ff0109 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2023 02:15:39.4070 (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: yl+lQNKLtuxwgR8xMVMBzFvJWGzdx/Wi1r+8DQWMlTtTip22ih7OThbxKVEraO+3Sv9nYS1Seue4O2eG2nnkApWm8dvQyYB1oJ22wwr3v1c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR13MB5548 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 Revise the logic, using the DPDK memory management API to replace the malloc()/free(). Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 8 ++++---- drivers/net/nfp/nfpcore/nfp_cppcore.c | 10 +++++----- drivers/net/nfp/nfpcore/nfp_hwinfo.c | 6 +++--- drivers/net/nfp/nfpcore/nfp_mip.c | 6 +++--- drivers/net/nfp/nfpcore/nfp_mutex.c | 4 ++-- drivers/net/nfp/nfpcore/nfp_nffw.c | 8 +++----- drivers/net/nfp/nfpcore/nfp_nsp.c | 6 +++--- drivers/net/nfp/nfpcore/nfp_nsp_cmds.c | 8 +++----- drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 19 ++++++++----------- drivers/net/nfp/nfpcore/nfp_resource.c | 10 ++++------ 11 files changed, 39 insertions(+), 48 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 77dab864f3..37895e8355 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -225,7 +225,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev) PMD_DRV_LOG(INFO, "Freeing PF resources"); nfp_cpp_area_free(pf_dev->ctrl_area); nfp_cpp_area_free(pf_dev->hwqueues_area); - free(pf_dev->hwinfo); + rte_free(pf_dev->hwinfo); free(pf_dev->sym_tbl); nfp_cpp_free(pf_dev->cpp); rte_free(app_fw_flower); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index e3ff3d8087..2e43055fd5 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -47,7 +47,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, int port) rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr); - free(nfp_eth_table); + rte_free(nfp_eth_table); return 0; } @@ -312,7 +312,7 @@ nfp_net_close(struct rte_eth_dev *dev) PMD_INIT_LOG(INFO, "Freeing PF resources"); nfp_cpp_area_free(pf_dev->ctrl_area); nfp_cpp_area_free(pf_dev->hwqueues_area); - free(pf_dev->hwinfo); + rte_free(pf_dev->hwinfo); free(pf_dev->sym_tbl); nfp_cpp_free(pf_dev->cpp); rte_free(app_fw_nic); @@ -1047,9 +1047,9 @@ nfp_pf_init(struct rte_pci_device *pci_dev) sym_tbl_cleanup: free(sym_tbl); eth_table_cleanup: - free(nfp_eth_table); + rte_free(nfp_eth_table); hwinfo_cleanup: - free(hwinfo); + rte_free(hwinfo); cpp_cleanup: nfp_cpp_free(cpp); diff --git a/drivers/net/nfp/nfpcore/nfp_cppcore.c b/drivers/net/nfp/nfpcore/nfp_cppcore.c index f601907673..1e0608a8e4 100644 --- a/drivers/net/nfp/nfpcore/nfp_cppcore.c +++ b/drivers/net/nfp/nfpcore/nfp_cppcore.c @@ -866,7 +866,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, if (ops == NULL || ops->init == NULL) return NULL; - cpp = calloc(1, sizeof(*cpp)); + cpp = rte_zmalloc(NULL, sizeof(*cpp), 0); if (cpp == NULL) return NULL; @@ -876,7 +876,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, if (cpp->op->init) { err = cpp->op->init(cpp, dev); if (err < 0) { - free(cpp); + rte_free(cpp); return NULL; } } @@ -891,7 +891,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, err = nfp_xpb_readl(cpp, xpbaddr, (uint32_t *)&cpp->imb_cat_table[tgt]); if (err < 0) { - free(cpp); + rte_free(cpp); return NULL; } } @@ -900,7 +900,7 @@ nfp_cpp_alloc(struct rte_pci_device *dev, err = nfp_cpp_set_mu_locality_lsb(cpp); if (err < 0) { PMD_DRV_LOG(ERR, "Can't calculate MU locality bit offset"); - free(cpp); + rte_free(cpp); return NULL; } @@ -922,7 +922,7 @@ nfp_cpp_free(struct nfp_cpp *cpp) if (cpp->serial_len != 0) free(cpp->serial); - free(cpp); + rte_free(cpp); } /** diff --git a/drivers/net/nfp/nfpcore/nfp_hwinfo.c b/drivers/net/nfp/nfpcore/nfp_hwinfo.c index f5579ab60f..7abf9c7700 100644 --- a/drivers/net/nfp/nfpcore/nfp_hwinfo.c +++ b/drivers/net/nfp/nfpcore/nfp_hwinfo.c @@ -109,7 +109,7 @@ nfp_hwinfo_try_fetch(struct nfp_cpp *cpp, if (*cpp_size < HWINFO_SIZE_MIN) return NULL; - db = malloc(*cpp_size + 1); + db = rte_zmalloc(NULL, *cpp_size + 1, 0); if (db == NULL) return NULL; @@ -134,7 +134,7 @@ nfp_hwinfo_try_fetch(struct nfp_cpp *cpp, return (void *)db; exit_free: - free(db); + rte_free(db); return NULL; } @@ -175,7 +175,7 @@ nfp_hwinfo_read(struct nfp_cpp *cpp) err = nfp_hwinfo_db_validate(db, hwdb_size); if (err != 0) { - free(db); + rte_free(db); return NULL; } return db; diff --git a/drivers/net/nfp/nfpcore/nfp_mip.c b/drivers/net/nfp/nfpcore/nfp_mip.c index 0892c99e96..3c59582846 100644 --- a/drivers/net/nfp/nfpcore/nfp_mip.c +++ b/drivers/net/nfp/nfpcore/nfp_mip.c @@ -104,14 +104,14 @@ nfp_mip_open(struct nfp_cpp *cpp) int err; struct nfp_mip *mip; - mip = malloc(sizeof(*mip)); + mip = rte_zmalloc(NULL, sizeof(*mip), 0); if (mip == NULL) return NULL; err = nfp_mip_read_resource(cpp, mip); if (err != 0) { PMD_DRV_LOG(ERR, "Failed to read MIP resource"); - free(mip); + rte_free(mip); return NULL; } @@ -123,7 +123,7 @@ nfp_mip_open(struct nfp_cpp *cpp) void nfp_mip_close(struct nfp_mip *mip) { - free(mip); + rte_free(mip); } const char * diff --git a/drivers/net/nfp/nfpcore/nfp_mutex.c b/drivers/net/nfp/nfpcore/nfp_mutex.c index 404d4fa938..5392924cf0 100644 --- a/drivers/net/nfp/nfpcore/nfp_mutex.c +++ b/drivers/net/nfp/nfpcore/nfp_mutex.c @@ -163,7 +163,7 @@ nfp_cpp_mutex_alloc(struct nfp_cpp *cpp, if (tmp != key) return NULL; - mutex = calloc(sizeof(*mutex), 1); + mutex = rte_zmalloc(NULL, sizeof(*mutex), 0); if (mutex == NULL) return NULL; @@ -209,7 +209,7 @@ nfp_cpp_mutex_free(struct nfp_cpp_mutex *mutex) if (mutex->cpp && mutex == mutex->cpp->mutex_cache) mutex->cpp->mutex_cache = mutex->next; - free(mutex); + rte_free(mutex); } /** diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.c b/drivers/net/nfp/nfpcore/nfp_nffw.c index af55671a88..a635239b30 100644 --- a/drivers/net/nfp/nfpcore/nfp_nffw.c +++ b/drivers/net/nfp/nfpcore/nfp_nffw.c @@ -128,12 +128,10 @@ nfp_nffw_info_open(struct nfp_cpp *cpp) struct nfp_nffw_info *state; struct nfp_nffw_info_data *fwinf; - state = malloc(sizeof(*state)); + state = rte_zmalloc(NULL, sizeof(*state), 0); if (state == NULL) return NULL; - memset(state, 0, sizeof(*state)); - state->res = nfp_resource_acquire(cpp, NFP_RESOURCE_NFP_NFFW); if (state->res == NULL) { PMD_DRV_LOG(ERR, "NFFW - acquire resource failed"); @@ -166,7 +164,7 @@ nfp_nffw_info_open(struct nfp_cpp *cpp) err_release: nfp_resource_release(state->res); err_free: - free(state); + rte_free(state); return NULL; } @@ -180,7 +178,7 @@ void nfp_nffw_info_close(struct nfp_nffw_info *state) { nfp_resource_release(state->res); - free(state); + rte_free(state); } /** diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c index 039e4729bd..dd2d19936d 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp.c @@ -128,12 +128,12 @@ nfp_nsp_open(struct nfp_cpp *cpp) return NULL; } - state = malloc(sizeof(*state)); + state = rte_zmalloc(NULL, sizeof(*state), 0); if (state == NULL) { nfp_resource_release(res); return NULL; } - memset(state, 0, sizeof(*state)); + state->cpp = cpp; state->res = res; @@ -157,7 +157,7 @@ void nfp_nsp_close(struct nfp_nsp *state) { nfp_resource_release(state->res); - free(state); + rte_free(state); } uint16_t diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c index 3081e22dad..54e1e2215d 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_cmds.c @@ -33,22 +33,20 @@ __nfp_nsp_identify(struct nfp_nsp *nsp) if (nfp_nsp_get_abi_ver_minor(nsp) < 15) return NULL; - ni = malloc(sizeof(*ni)); + ni = rte_zmalloc(NULL, sizeof(*ni), 0); if (ni == NULL) return NULL; - memset(ni, 0, sizeof(*ni)); ret = nfp_nsp_read_identify(nsp, ni, sizeof(*ni)); if (ret < 0) { PMD_DRV_LOG(ERR, "reading bsp version failed %d", ret); goto exit_free; } - nspi = malloc(sizeof(*nspi)); + nspi = rte_zmalloc(NULL, sizeof(*nspi), 0); if (nspi == NULL) goto exit_free; - memset(nspi, 0, sizeof(*nspi)); memcpy(nspi->version, ni->version, sizeof(nspi->version)); nspi->version[sizeof(nspi->version) - 1] = '\0'; nspi->flags = ni->flags; @@ -61,7 +59,7 @@ __nfp_nsp_identify(struct nfp_nsp *nsp) nspi->sensor_mask = rte_le_to_cpu_64(ni->sensor_mask); exit_free: - free(ni); + rte_free(ni); return nspi; } diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c index e32884e7d3..1906fcd385 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c @@ -252,11 +252,10 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp) union eth_table_entry *entries; const struct rte_ether_addr *mac; - entries = malloc(NSP_ETH_TABLE_SIZE); + entries = rte_zmalloc(NULL, NSP_ETH_TABLE_SIZE, 0); if (entries == NULL) return NULL; - memset(entries, 0, NSP_ETH_TABLE_SIZE); ret = nfp_nsp_read_eth_table(nsp, entries, NSP_ETH_TABLE_SIZE); if (ret < 0) { PMD_DRV_LOG(ERR, "Reading port table failed %d", ret); @@ -286,11 +285,10 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp) } table_sz = sizeof(*table) + sizeof(struct nfp_eth_table_port) * cnt; - table = malloc(table_sz); + table = rte_zmalloc(NULL, table_sz, 0); if (table == NULL) goto err; - memset(table, 0, table_sz); table->count = cnt; for (i = 0, j = 0; i < NSP_ETH_MAX_COUNT; i++) { mac = (const struct rte_ether_addr *)entries[i].mac_addr; @@ -304,12 +302,12 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp) for (i = 0; i < table->count; i++) nfp_eth_calc_port_type(&table->ports[i]); - free(entries); + rte_free(entries); return table; err: - free(entries); + rte_free(entries); return NULL; } @@ -348,14 +346,13 @@ nfp_eth_config_start(struct nfp_cpp *cpp, struct nfp_nsp *nsp; union eth_table_entry *entries; - entries = malloc(NSP_ETH_TABLE_SIZE); + entries = rte_zmalloc(NULL, NSP_ETH_TABLE_SIZE, 0); if (entries == NULL) return NULL; - memset(entries, 0, NSP_ETH_TABLE_SIZE); nsp = nfp_nsp_open(cpp); if (nsp == NULL) { - free(entries); + rte_free(entries); return nsp; } @@ -375,7 +372,7 @@ nfp_eth_config_start(struct nfp_cpp *cpp, err: nfp_nsp_close(nsp); - free(entries); + rte_free(entries); return NULL; } @@ -387,7 +384,7 @@ nfp_eth_config_cleanup_end(struct nfp_nsp *nsp) nfp_nsp_config_set_modified(nsp, 0); nfp_nsp_config_clear_state(nsp); nfp_nsp_close(nsp); - free(entries); + rte_free(entries); } /** diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c index bdebf5c3aa..8ba3784f8a 100644 --- a/drivers/net/nfp/nfpcore/nfp_resource.c +++ b/drivers/net/nfp/nfpcore/nfp_resource.c @@ -161,19 +161,17 @@ nfp_resource_acquire(struct nfp_cpp *cpp, struct nfp_resource *res; struct nfp_cpp_mutex *dev_mutex; - res = malloc(sizeof(*res)); + res = rte_zmalloc(NULL, sizeof(*res), 0); if (res == NULL) return NULL; - memset(res, 0, sizeof(*res)); - strncpy(res->name, name, NFP_RESOURCE_ENTRY_NAME_SZ); dev_mutex = nfp_cpp_mutex_alloc(cpp, NFP_RESOURCE_TBL_TARGET, NFP_RESOURCE_TBL_BASE, NFP_RESOURCE_TBL_KEY); if (dev_mutex == NULL) { PMD_DRV_LOG(ERR, "RESOURCE - CPP mutex alloc failed"); - free(res); + rte_free(res); return NULL; } @@ -204,7 +202,7 @@ nfp_resource_acquire(struct nfp_cpp *cpp, err_free: nfp_cpp_mutex_free(dev_mutex); - free(res); + rte_free(res); return NULL; } @@ -221,7 +219,7 @@ nfp_resource_release(struct nfp_resource *res) { nfp_cpp_mutex_unlock(res->mutex); nfp_cpp_mutex_free(res->mutex); - free(res); + rte_free(res); } /** -- 2.39.1