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 D2536A0C45; Wed, 1 Sep 2021 16:26:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 279BA4118C; Wed, 1 Sep 2021 16:25:07 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 8B3A34117D for ; Wed, 1 Sep 2021 16:25:05 +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 25FD32E5C7; Wed, 1 Sep 2021 07:25:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 25FD32E5C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1630506305; bh=uKjCWByzVKWQwTJW0KxDbU/lq2rGU9u7xH9eNrKNpeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChvA1Ez75O0tttyZU2o7+EtROALAGh9hQqaOyd1j0Fxmt/SUmvacFMeSc1JKo9DvQ m7JK91m5ckmogXKCdwyFRwvJOImxdGo+N1hlMrRKnZkC6WXk+/2F8r/v8XKZBZoQQl ktsU1Dv8LcxpGfLBVUtx1yo7pw+oWakOVaheX6Vs= From: Venkat Duvvuru To: dev@dpdk.org Cc: Randy Schacher Date: Wed, 1 Sep 2021 19:54:30 +0530 Message-Id: <20210901142433.8444-12-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> References: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 11/14] 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