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 11E99A0C56; Wed, 8 Sep 2021 07:07:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3DBB411B2; Wed, 8 Sep 2021 07:07:11 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp10.broadcom.com [192.19.11.229]) by mails.dpdk.org (Postfix) with ESMTP id 03F2B41195 for ; Wed, 8 Sep 2021 07:07:07 +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 D39137DA4; Tue, 7 Sep 2021 22:07:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com D39137DA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1631077626; bh=uKjCWByzVKWQwTJW0KxDbU/lq2rGU9u7xH9eNrKNpeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mg4Ncu9Bvm3g5L8n4b21onk6Fvo1uMk/usPKyiJ1uBrK/u3g5baZ92BIsq9H7MRn9 poD0lazIK/lQWFB/2DyMjYtyt+4v3zOzgLi1Ut/P8k9tMzLRb5mRH43mMqHSljM+8G ZeMcV0Y2vMh4NgQ1+Q8X2Ph2nmFPKA3NYVYiCdnQ= From: Venkat Duvvuru To: dev@dpdk.org Cc: Randy Schacher Date: Wed, 8 Sep 2021 10:36:41 +0530 Message-Id: <20210908050643.9989-12-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210908050643.9989-1-venkatkumar.duvvuru@broadcom.com> References: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> <20210908050643.9989-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH v2 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