patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
To: stable@dpdk.org
Cc: christian.ehrhardt@canonical.com, ajit.khaparde@broadcom.com
Subject: [PATCH 19.11 5/8] net/bnxt: fix memzone allocation per VNIC
Date: Mon,  7 Mar 2022 20:40:33 +0530	[thread overview]
Message-ID: <20220307151036.7116-6-kalesh-anakkur.purayil@broadcom.com> (raw)
In-Reply-To: <20220307151036.7116-1-kalesh-anakkur.purayil@broadcom.com>

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 5b8b248c9679b9571f73a75e1905d7cef39e6c6e ]

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")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_vnic.c | 67 +++++++++++++++++++-------------------------
 drivers/net/bnxt/bnxt_vnic.h |  1 +
 2 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 9bcf385..d64c413 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,37 @@ 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_%04x:%02x:%02x:%02x_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_%04x:%02x:%02x:%02x_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 = (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_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 a9818b1..6fb5ec2 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -25,6 +25,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


  parent reply	other threads:[~2022-03-07 15:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 15:10 [PATCH 19.11 0/8] bnxt fixes backport to 19.11 Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 1/8] net/bnxt: fix queue stop operation Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 2/8] net/bnxt: cap maximum number of unicast MAC addresses Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 3/8] net/bnxt: fix multicast address set Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 4/8] net/bnxt: restore RSS configuration after reset recovery Kalesh A P
2022-03-07 15:10 ` Kalesh A P [this message]
2022-03-07 15:10 ` [PATCH 19.11 6/8] net/bnxt: fix handling of VF configuration change Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 7/8] net/bnxt: get maximum supported multicast filters count Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 8/8] net/bnxt: fix xstats names query overrun Kalesh A P
2022-03-09  8:02 ` [PATCH 19.11 0/8] bnxt fixes backport to 19.11 Christian Ehrhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220307151036.7116-6-kalesh-anakkur.purayil@broadcom.com \
    --to=kalesh-anakkur.purayil@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=christian.ehrhardt@canonical.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).