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 70885430EF; Thu, 24 Aug 2023 13:11:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91C9A43284; Thu, 24 Aug 2023 13:11:03 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2096.outbound.protection.outlook.com [40.107.220.96]) by mails.dpdk.org (Postfix) with ESMTP id 8DF4F4327B for ; Thu, 24 Aug 2023 13:11:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lIoVTTmO3eDC2qDT85N9OX9qRjEjnLIBPGRuB6jqnG/Hi8pEbwHMYJp3qpXwz1ktQbykdaOoce9j4lp15JgcAmG7AdccFgSWJD4Prbwn3SdIHWgHXJ8XbX9CRhanFJPhhDCGrjuHvuKzf3s5iJz4piVkLyAJk/Aj2JhMm3kp3Q4rXe8K0msOP9IEOet41RCbJPp2UEyQn0zv3fhAuttWlVWo687If/z+ebMr3A4GrOlp46c5iTDwK0UBYA2oj61GNPg6dEuvWY7NcvCHKYQwPXp8lqjlj0gzVw0RpU9JZd5R5m9oNZO65M6AcLt3ocVqSRWZz+dYMnhePVOVbwi7xQ== 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=GRtHPaV8rZas+vF4NvzYP+ZLZ10C2DRSXPGskPDNkEWJTgjbhEceTNKDOhGTFIrdcbxmBBzT3mcQzXFOupyeuHb4LTTlxBD6pTVSMBewQ4Q9o1mrIb/9NtT76scgDmHCJ8Hl/1nL4ZMVogPxnWC94TcVWWjMbbJvOSrdQWMKPQsZZalP+8Lt/4RS8/1Ss80Wsvrym3NkEwD2mn42vvMeT/HBWbH9/3R5kv+e++/M/6vxN82MRWrLsipRB/NPSsGh/veoqw/m9wW8G/R7bicg2Ja3POyV3BWv+PjBSV9j1+U65sKHJa0WPRZjvntUQHe7SC9vpB+sPJ4bgme664+SVw== 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=DwicirwblTQdqkP02Y/eSgG0zdXUPAAhAwGrM21KkmCqvYBC8CcGw/ZsKhQvT9klUsyT2goUlJJPeBP/uJ8ddC6JvlV1MCo72Erc9QJqJYz8FZ5EwxaI79tAxDYPesi1yk+JohDDSYqOcq+O6eEjnG1fH1A33UH2romNqv9mFPo= 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 PH0PR13MB6134.namprd13.prod.outlook.com (2603:10b6:510:295::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Thu, 24 Aug 2023 11:11:00 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace%3]) with mapi id 15.20.6699.020; Thu, 24 Aug 2023 11:11:00 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 08/27] net/nfp: using the DPDK memory management API Date: Thu, 24 Aug 2023 19:09:37 +0800 Message-Id: <20230824110956.1943559-9-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230824110956.1943559-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR05CA0005.namprd05.prod.outlook.com (2603:10b6:a03:33b::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_|PH0PR13MB6134:EE_ X-MS-Office365-Filtering-Correlation-Id: 4587bbab-31f2-4593-5576-08dba492cc5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IvshjGfs06otnDPOU4pQd1Wq6/TGDXMve7uoV4Kae5M7i+PNtOWXNULdzANXqIR4MVadKr2ZHKlbyzHRXGmHYQnqp9lBY+gti27CHwR0eWDCtqStKxDV/hW8Wr8BjPUTl2BCWMVUHrENhXWUNKzuQ6W2fW//OuCMBAtaFksRM7MBSWmpgEprLm1DkJeAt4jiqyrpuNHzENGmm8vDSi9QqzMrXQzhud7t9s5vrh5O0Q8aGEMc7t95hr65IN/JolJlc4oveJOEiMCwSCl++zebGpuHFX5s6aKq63Zha1HhaMoLalRTgljOXh5ypkP7/mC9leY/Y5mwfmDw3YNSK5lSx/4P2By7OdIG1K+bO3qAYFKnxTS1k0fE1strZuh0RV3+FTbL3sCzRplI0Q1WPlG50rxcUTN91Rvk3GCTr9IJjwyr+/CiVkUQbjzodSjnNzREhdlsoq6Zj4nGBE0lOp7kDgf7umwFnbx1+36cRu+Ja80QsZVhZRf9TxKYlniMawmMjpXmQu3hgT4IbhSX4T+wd9tgRx2lI56hKbGpZ06v1Vx9oakE1VCl/7onj3AHhgWHwBUB8qOZ92X7c8faMrvY/4+o310zwKRWlCo4sZ62ftn40eCEnfs3Z8MNMGr/4x1YOzw9xFp+XrUG2ZAe3nx5Sw410DOh037Fvw1HXn3mdsVZIbvs8fekObitlIF/Pb1n3IQfpetFhB9lllEjjPcr1A== 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)(366004)(136003)(376002)(39830400003)(1800799009)(451199024)(186009)(316002)(66556008)(6916009)(66946007)(66476007)(12101799020)(41300700001)(44832011)(5660300002)(8936002)(8676002)(38100700002)(66574015)(38350700002)(4326008)(30864003)(2906002)(83380400001)(26005)(86362001)(478600001)(107886003)(52116002)(36756003)(6506007)(6666004)(6512007)(6486002)(2616005)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eEgvbWJscG9uTFBCczFUbWxZVnJyelJyNkpOMWQ0cVhyZG96LzhjZDhVcUxL?= =?utf-8?B?cnZZUUxSajJ5V1hJTVEyRmdUMW01R3ZoZkJaWGFRelNMWGlmOFNZbDNDSUF3?= =?utf-8?B?azR1bUNEbVRNQW5kckM1ZG9rT0JsaGFCOFZIVms3M3JOT3I2SzR3UWUrQWd2?= =?utf-8?B?VGp1VGtOSDNFRGVTNm1CM1R6NHVmN1BUUTZscUY5VEt4QnZNMExEMEpVR3pW?= =?utf-8?B?ZWdrSkJXNTg0aVc1cDFLRFBaT3ZBTmlrUDROV1RvOGJib2Q4ek1TNEVZNTFr?= =?utf-8?B?MG5pWXNPM1F4bklPb09BbWxackhYWDh3Mng3a1N0clMxeGhpaFFEVStPMW45?= =?utf-8?B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ZSnVyNWxXcUVhRktFNkFSckQx?= =?utf-8?B?S0E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4587bbab-31f2-4593-5576-08dba492cc5b X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 11:11:00.7312 (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: E4gJKE3ELsLUk3K40ar74SD5UhVd4ZzKpIGPNIFl3raKJhSgmyYfytXBmMpgXGo5rCfh23yPj/ZBiJjCOJwPMed5yBBkHhIBgXntXoz/ttQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6134 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