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 995E3A00C3; Thu, 20 Jan 2022 09:53:39 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82AE8426E3; Thu, 20 Jan 2022 09:53:30 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 3BAE2426DC for ; Thu, 20 Jan 2022 09:53:28 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 79478C000C74; Thu, 20 Jan 2022 00:53:26 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 79478C000C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1642668807; bh=2Gyr5UQbwZdM0E9hZipcrqj1A/vgtX9vdTlBZ8qKs6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVMN2JEML+n3CN4VpZhtnGrWNGGO/Lm4ibdLyoHIv/rxiPg/xGBNBAK76e3xgXt7m ly5w+dn4dPrd6vy/tzfFgDnzxwwAW3/MiB6wgtXHDvobfCfgYyMuOvtbNabYWQ4Bs/ sf82u1Ty2PLlafEb1oWtji3zWeGYW7usPG8mONtU= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Subject: [dpdk-dev] [PATCH 3/4] net/bnxt: fix to alloc the memzone per VNIC Date: Thu, 20 Jan 2022 14:42:27 +0530 Message-Id: <20220120091228.7076-4-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20220120091228.7076-1-kalesh-anakkur.purayil@broadcom.com> References: <20220120091228.7076-1-kalesh-anakkur.purayil@broadcom.com> 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 From: Kalesh AP In case of Thor RSS table size is too big. This could result in memory allocation failure when the supported vnic count is high. Instead of allocating the memzone for all VNICs in one shot, allocate for each VNIC individually. Also, fixed to free the memzone in the uninit path. Fixes: 9738793f28ec ("net/bnxt: add VNIC functions and structs") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_vnic.c | 68 +++++++++++++++++++------------------------- drivers/net/bnxt/bnxt_vnic.h | 1 + 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index 09d67ef..b3c03a2 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -98,18 +98,11 @@ void bnxt_free_vnic_attributes(struct bnxt *bp) for (i = 0; i < bp->max_vnics; i++) { vnic = &bp->vnic_info[i]; - if (vnic->rss_table) { - /* 'Unreserve' the rss_table */ - /* N/A */ - - vnic->rss_table = NULL; - } - - if (vnic->rss_hash_key) { - /* 'Unreserve' the rss_hash_key */ - /* N/A */ - + if (vnic->rss_mz != NULL) { + rte_memzone_free(vnic->rss_mz); + vnic->rss_mz = NULL; vnic->rss_hash_key = NULL; + vnic->rss_table = NULL; } } } @@ -122,7 +115,6 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp, bool reconfig) char mz_name[RTE_MEMZONE_NAMESIZE]; uint32_t entry_length; size_t rss_table_size; - uint16_t max_vnics; int i; rte_iova_t mz_phys_addr; @@ -136,38 +128,36 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp, bool reconfig) entry_length = RTE_CACHE_LINE_ROUNDUP(entry_length + rss_table_size); - max_vnics = bp->max_vnics; - snprintf(mz_name, RTE_MEMZONE_NAMESIZE, - "bnxt_" PCI_PRI_FMT "_vnicattr", pdev->addr.domain, - pdev->addr.bus, pdev->addr.devid, pdev->addr.function); - mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; - mz = rte_memzone_lookup(mz_name); - if (!mz) { - mz = rte_memzone_reserve(mz_name, - entry_length * max_vnics, - bp->eth_dev->device->numa_node, - RTE_MEMZONE_2MB | - RTE_MEMZONE_SIZE_HINT_ONLY | - RTE_MEMZONE_IOVA_CONTIG); - if (!mz) - return -ENOMEM; - } - mz_phys_addr = mz->iova; - - for (i = 0; i < max_vnics; i++) { + for (i = 0; i < bp->max_vnics; i++) { vnic = &bp->vnic_info[i]; + snprintf(mz_name, RTE_MEMZONE_NAMESIZE, + "bnxt_" PCI_PRI_FMT "_vnicattr_%d", pdev->addr.domain, + pdev->addr.bus, pdev->addr.devid, pdev->addr.function, i); + mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0; + mz = rte_memzone_lookup(mz_name); + if (mz == NULL) { + mz = rte_memzone_reserve(mz_name, + entry_length, + bp->eth_dev->device->numa_node, + RTE_MEMZONE_2MB | + RTE_MEMZONE_SIZE_HINT_ONLY | + RTE_MEMZONE_IOVA_CONTIG); + if (mz == NULL) { + PMD_DRV_LOG(ERR, "Cannot allocate bnxt vnic_attributes memory\n"); + return -ENOMEM; + } + } + vnic->rss_mz = mz; + mz_phys_addr = mz->iova; + /* Allocate rss table and hash key */ - vnic->rss_table = - (void *)((char *)mz->addr + (entry_length * i)); + vnic->rss_table = (void *)((char *)mz->addr); + vnic->rss_table_dma_addr = mz_phys_addr; memset(vnic->rss_table, -1, entry_length); - vnic->rss_table_dma_addr = mz_phys_addr + (entry_length * i); - vnic->rss_hash_key = (void *)((char *)vnic->rss_table + - rss_table_size); - - vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + - rss_table_size; + vnic->rss_hash_key = (void *)((char *)vnic->rss_table + rss_table_size); + vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + rss_table_size; if (!reconfig) { bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE); memcpy(bp->rss_conf.rss_key, vnic->rss_hash_key, HW_HASH_KEY_SIZE); diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h index 25481fc..9055b93 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -28,6 +28,7 @@ struct bnxt_vnic_info { uint16_t mru; uint16_t hash_type; uint8_t hash_mode; + const struct rte_memzone *rss_mz; rte_iova_t rss_table_dma_addr; uint16_t *rss_table; rte_iova_t rss_hash_key_dma_addr; -- 2.10.1