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 EDF76425A3; Fri, 15 Sep 2023 11:17:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1C1BA40F16; Fri, 15 Sep 2023 11:16:34 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2134.outbound.protection.outlook.com [40.107.237.134]) by mails.dpdk.org (Postfix) with ESMTP id C417340ED0 for ; Fri, 15 Sep 2023 11:16:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WFy0nTTLXDgqWNUs3UUJwvUaUHRCXapd1OxaoUzR75HVygvdhSd60+bRdKp+6dT07h20VlPkKcUK4AcnHK+YUlRhCRsmMrS3smC1GimHsOn7tbrb9jQIVzQuqbdgyFwy8iPT9FhZ/NdNMQ+1pvu4R5yH3UYwFiLqqZBwW216YbiZvYfVBvUJIkZJecULHT9DLtkTLT5Jc4xcbs1c+00y3MYeB7263O55rpgtIN25ohsh/USZ/ej+3Jy1HWcWON7UOsgmzH27PM8SSTybkj9IhxOVvQQkTreGtYQOCynAJA4H9xJXXBaV2n92FaCcwQD5knniXzkLTLHm3eMn2dv+9A== 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=1QO+/bA8b3vVyBy1OcEPk70fJqxGMTQFMHHRNGBS6yQ=; b=W2oobZubAsWXvneI9DECsmGVXI8rDMq63Ogw9n2FfvfqANTCA6mcKOXaPBqe3yiJoIKVj1xAPgMATe9SlvZJgpjsfqUfxQBoDCE1RMFqlrDgSgnjI8EzvSYgc9/xMrleVxQ+W4yxMhVRrkRWY5mVV6fB2hXtlaB+u9YmuzoCDjGffe/ZIHmSSDqrRJYmnhEdCYqav5ak1BLxakmKIcikJN6H+2DZa5eDQ5C5RtXtL5/Z32OFil9qhE+E3rRh+G/h1UeEez+3Xqz/a3oOqqRw4N1aI1BjcXzB92Ew2dOt8B1nOc3YX41FFzw9nLx3KOaV1S+1c0xbV3xGwI0klWJ9DA== 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=1QO+/bA8b3vVyBy1OcEPk70fJqxGMTQFMHHRNGBS6yQ=; b=COg3LK3EVLVUyYp7BLEGTCpNorHrSJn35TRcE5ka5PQGCDuGlXwunuLnyZ4j3mHPh+jmDXC/JlXmuZf/N4q+xOPPizAoLlOdqkaAhAxAha8OBjncjGGOlEYLwKQeG6k5TyPGpnWzpQZQQuRc0GMsIcIdkRZfgULki43a9YdPQcw= 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 CO1PR13MB4773.namprd13.prod.outlook.com (2603:10b6:303:fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 15 Sep 2023 09:16:30 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4%7]) with mapi id 15.20.6768.029; Fri, 15 Sep 2023 09:16:30 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v3 08/27] net/nfp: using the DPDK memory management API Date: Fri, 15 Sep 2023 17:15:32 +0800 Message-Id: <20230915091551.1459606-9-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230915091551.1459606-1-chaoyong.he@corigine.com> References: <20230830021457.2064750-1-chaoyong.he@corigine.com> <20230915091551.1459606-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH7PR10CA0017.namprd10.prod.outlook.com (2603:10b6:510:23d::10) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO1PR13MB4773:EE_ X-MS-Office365-Filtering-Correlation-Id: db552e30-078b-4ab5-12d9-08dbb5cc728b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 34rLlRbeDmFAshNXoLVcECEh7yIMznBp0lgd+raqvCt/M4RuYFB65NQg7hPdHN6ZG7j+AG+sHUVqgNBmq+POXs4wrvmkG0GNbZq+JCsBFeCfFfjaaRedHZi6Pf6EnMnQWUtMEuWetENSpzPJE0Qlrc15JBu8SzDQ3ruR1d/jF6EyVQOIFLJt4oD3V5LsB+nAhPCnLqxjJV1btpjQIxaXwgtQFXln0O3oToTIcwztD39aaRs+5AYpmiBY9bHAbecmVIoDthNkPfYs/2cVRPd8CIXSvXSX1OuMr9Alo+1r26/34EQyBlv4W0h3yo/Nxrv+39jTJKsUU12dgTOnCOPuha4s3uFdUzSG4qrl/RHo9mUtwaGjhFnAOfxS5AXc3nOfh4OD+mbyP5XHaWtR3qxb63fCYfX56YMB0vfXctA0oDHLQBxxzFUgd+ubkXrUu/VukE2vO5WzWIRqF6LywWtxQmSm9djTOKCPOTJF3BzR/SWJh/aaOyV5x9ejCjiUN3KKtHQE08nfgq24Auhka/oVo1tLRQHvn8crOvOuCQPt3XRfuw3BikO4riofGpJBzwiR1phMlpFw4RYgbhZkdcqnLVi4TOeP395jdg+Wn8kH785tLBJgvU3BuM0kG5XslaesDoOOjT6wCgtY/Ukale5sxAozVn46X8n3R+sEerIfuso= 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)(39840400004)(346002)(136003)(376002)(396003)(366004)(451199024)(186009)(1800799009)(6512007)(107886003)(1076003)(2616005)(52116002)(6506007)(6486002)(66946007)(26005)(316002)(41300700001)(66476007)(66556008)(6916009)(54906003)(5660300002)(4326008)(8676002)(38350700002)(8936002)(38100700002)(478600001)(66574015)(83380400001)(36756003)(44832011)(30864003)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MUdNY0ZFWE9laU9wdVRaK2ZTYWlNemdaT3N3bDVzd3orMjNZdFNNMUFTbXdv?= =?utf-8?B?M0pSS003S3lINjRQOFJnOXlta0RhdUM2dVhVelBQNTAvWm14a2tSSXc0TGJi?= =?utf-8?B?NnloTUJ6MmxzcEVSZVRvVFhSNjhxREdTWWtLbkdVbmR1ZXNDY3JYVjByVmQ1?= =?utf-8?B?VzJ4Smt0dlVJWEJoTXhUc0FvTXQ5aEo1VFVRSlp6eUJRcFZsMmw3VVQvOVN0?= =?utf-8?B?Mkx1UVJGT3RUSnFUd0hFSHJRdEJjNDRES1pGOWtsc0FzcWVSVTBIZ0c0RzRl?= =?utf-8?B?bWQ1WUh1Y2ZjTnpOMUZTZEVVMXNhZ3hFb2pQTE8wM2JEUGJFOTg4THRYK3Zv?= =?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TTdTVjZOTGY1WVBtYzluL25nbFZmNnY5TjN0dG5M?= =?utf-8?B?aEE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: db552e30-078b-4ab5-12d9-08dbb5cc728b X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 09:16:30.5942 (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: h2qxbPt4XJ1+kXjpx5KKPRQOE9vYFW0ut30Ys8YxnkytJChiiMhp9frzqKep2gu/bL0/lFsKE+AClEOiY/LT3JnDRNTtvvw/qWFUSHeHLrs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR13MB4773 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 0e8372576e..37906c6f35 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 5f004e3b21..038f19c261 100644 --- a/drivers/net/nfp/nfpcore/nfp_nffw.c +++ b/drivers/net/nfp/nfpcore/nfp_nffw.c @@ -129,12 +129,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"); @@ -167,7 +165,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; } @@ -181,7 +179,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 cb090d2a47..a56ea4e068 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c @@ -253,11 +253,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); @@ -287,11 +286,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; @@ -305,12 +303,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; } @@ -349,14 +347,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; } @@ -376,7 +373,7 @@ nfp_eth_config_start(struct nfp_cpp *cpp, err: nfp_nsp_close(nsp); - free(entries); + rte_free(entries); return NULL; } @@ -388,7 +385,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