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 10077A0548; Mon, 20 Sep 2021 09:43:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 07B1841143; Mon, 20 Sep 2021 09:42:57 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 2A8FD410EF for ; Mon, 20 Sep 2021 09:42:42 +0200 (CEST) Received: from S60.dhcp.broadcom.net (unknown [10.123.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id A7A7E46C67; Mon, 20 Sep 2021 00:42:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com A7A7E46C67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1632123761; bh=6vPfEYkmzH9zp9adDjxLcAj+uEDuwEOHdJHCuVIe6mU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WghoanujSAX5UhnZwGt5qlm0Wrswgin/VsQUwqRJgKsU+NPYYzvPx6vCTTIwxoh78 PYLdZr4YOMqwe0xnPpcIf26DsKzUo2swaFdn84LkmKcIwIgzszSlEiqHW22u6NfA9A 6w8ABQLW+UAw5p5m71mx4Uxf2F2pq8zhMrmjNg8Y= From: Venkat Duvvuru To: dev@dpdk.org Cc: Randy Schacher Date: Mon, 20 Sep 2021 13:12:12 +0530 Message-Id: <20210920074214.23747-12-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210920074214.23747-1-venkatkumar.duvvuru@broadcom.com> References: <20210908050643.9989-1-venkatkumar.duvvuru@broadcom.com> <20210920074214.23747-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v4 11/13] net/bnxt: dynamically allocate space for EM defrag function 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 Sender: "dev" From: Randy Schacher The dynamic pool allocation defrag function currently uses stack allocation. To improve use of stack space, dynamically allocate and deallocate memory for use to defragment the dynamic pool of EM resources. Signed-off-by: Randy Schacher Reviewed-by: Peter Spreadborough Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_core/dpool.c | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/net/bnxt/tf_core/dpool.c b/drivers/net/bnxt/tf_core/dpool.c index 145efa486f..5c03f775a5 100644 --- a/drivers/net/bnxt/tf_core/dpool.c +++ b/drivers/net/bnxt/tf_core/dpool.c @@ -7,9 +7,6 @@ #include #include #include - -#include - #include "tfp.h" #include "dpool.h" @@ -84,13 +81,13 @@ static int dpool_move(struct dpool *dpool, return 0; } - int dpool_defrag(struct dpool *dpool, uint32_t entry_size, uint8_t defrag) { struct dpool_free_list *free_list; struct dpool_adj_list *adj_list; + struct tfp_calloc_parms parms; uint32_t count; uint32_t index; uint32_t used; @@ -103,15 +100,31 @@ int dpool_defrag(struct dpool *dpool, uint32_t max_size = 0; int rc; - free_list = rte_zmalloc("dpool_free_list", - sizeof(struct dpool_free_list), 0); + parms.nitems = 1; + parms.size = sizeof(struct dpool_free_list); + parms.alignment = 0; + + rc = tfp_calloc(&parms); + + if (rc) + return rc; + + free_list = (struct dpool_free_list *)parms.mem_va; if (free_list == NULL) { TFP_DRV_LOG(ERR, "dpool free list allocation failed\n"); return -ENOMEM; } - adj_list = rte_zmalloc("dpool_adjacent_list", - sizeof(struct dpool_adj_list), 0); + parms.nitems = 1; + parms.size = sizeof(struct dpool_adj_list); + parms.alignment = 0; + + rc = tfp_calloc(&parms); + + if (rc) + return rc; + + adj_list = (struct dpool_adj_list *)parms.mem_va; if (adj_list == NULL) { TFP_DRV_LOG(ERR, "dpool adjacent list allocation failed\n"); return -ENOMEM; @@ -239,8 +252,8 @@ int dpool_defrag(struct dpool *dpool, free_list->entry[largest_free_index].index, max_index); if (rc) { - rte_free(free_list); - rte_free(adj_list); + tfp_free(free_list); + tfp_free(adj_list); return rc; } } else { @@ -249,12 +262,11 @@ int dpool_defrag(struct dpool *dpool, } done: - rte_free(free_list); - rte_free(adj_list); + tfp_free(free_list); + tfp_free(adj_list); return largest_free_size; } - uint32_t dpool_alloc(struct dpool *dpool, uint32_t size, uint8_t defrag) -- 2.17.1