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 D6825A034F; Sat, 11 Sep 2021 17:32:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC48041147; Sat, 11 Sep 2021 17:31:10 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.228]) by mails.dpdk.org (Postfix) with ESMTP id A108C40E32 for ; Sat, 11 Sep 2021 17:31:04 +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 3634680FA; Sat, 11 Sep 2021 08:31:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 3634680FA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1631374264; bh=uKjCWByzVKWQwTJW0KxDbU/lq2rGU9u7xH9eNrKNpeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VeXebimcjpC+iu9ookBK/qd3FOTe7ambmk298R8/LXxkin3gkcmi2NxZhg+u6+t7z Ckf3l/c2LimbjsdawvD0QPRPhEYVmwBuGLa568aA5E7tbNxmB792PvsxpsLnCOSUNg YIrthJizdE5oEugbrxiTLJHmuEXcZNrGa0CSUhx0= From: Venkat Duvvuru To: dev@dpdk.org Cc: Randy Schacher Date: Sat, 11 Sep 2021 21:00:39 +0530 Message-Id: <20210911153041.28510-12-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210911153041.28510-1-venkatkumar.duvvuru@broadcom.com> References: <20210908050643.9989-1-venkatkumar.duvvuru@broadcom.com> <20210911153041.28510-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v3 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 Alter defrag function to dynamically allocate and delete free_list and adj_list buffers. Signed-off-by: Randy Schacher Reviewed-by: Peter Spreadborough --- 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