DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Somnath Kotur <somnath.kotur@broadcom.com>,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Subject: [PATCH v3 05/14] net/bnxt: refactor mem zone allocation
Date: Mon, 11 Dec 2023 09:11:00 -0800	[thread overview]
Message-ID: <20231211171109.89716-6-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20231211171109.89716-1-ajit.khaparde@broadcom.com>

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

Currently we are allocating memzone for VNIC attributes per VNIC.
In cases where the firmware supports a higher VNIC count, this could
lead to a higher number of memzone segments than supported.

Move the memzone for VNIC attributes per function instead of per
VNIC. Divide the memzone per VNIC as needed.

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

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 542ef13f7c..6af668e92f 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -772,6 +772,7 @@ struct bnxt {
 
 	struct bnxt_vnic_info	*vnic_info;
 	STAILQ_HEAD(, bnxt_vnic_info)	free_vnic_list;
+	const struct rte_memzone *vnic_rss_mz;
 
 	struct bnxt_filter_info	*filter_info;
 	STAILQ_HEAD(, bnxt_filter_info)	free_filter_list;
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index f86d27fd79..d40daf631e 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -123,13 +123,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_mz != NULL) {
-			rte_memzone_free(vnic->rss_mz);
-			vnic->rss_mz = NULL;
-			vnic->rss_hash_key = NULL;
-			vnic->rss_table = NULL;
-		}
+		vnic->rss_hash_key = NULL;
+		vnic->rss_table = NULL;
 	}
+	rte_memzone_free(bp->vnic_rss_mz);
+	bp->vnic_rss_mz = NULL;
 }
 
 int bnxt_alloc_vnic_attributes(struct bnxt *bp, bool reconfig)
@@ -153,31 +151,35 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp, bool reconfig)
 
 	entry_length = RTE_CACHE_LINE_ROUNDUP(entry_length + rss_table_size);
 
-	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,
+	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 == NULL) {
+		mz = rte_memzone_reserve_aligned(mz_name,
+						 entry_length * bp->max_vnics,
 						 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;
-			}
+						 RTE_MEMZONE_IOVA_CONTIG,
+						 BNXT_PAGE_SIZE);
+		if (mz == NULL) {
+			PMD_DRV_LOG(ERR,
+				    "Cannot allocate vnic_attributes memory\n");
+			return -ENOMEM;
 		}
-		vnic->rss_mz = mz;
-		mz_phys_addr = mz->iova;
+	}
+	bp->vnic_rss_mz = mz;
+	for (i = 0; i < bp->max_vnics; i++) {
+		uint32_t offset = entry_length * i;
+
+		vnic = &bp->vnic_info[i];
+
+		mz_phys_addr = mz->iova + offset;
 
 		/* Allocate rss table and hash key */
-		vnic->rss_table = (void *)((char *)mz->addr);
+		vnic->rss_table = (void *)((char *)mz->addr + offset);
 		vnic->rss_table_dma_addr = mz_phys_addr;
 		memset(vnic->rss_table, -1, entry_length);
 
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index 4396d95bda..7a6a0aa739 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -47,7 +47,6 @@ struct bnxt_vnic_info {
 	uint16_t	hash_type;
 	uint8_t		hash_mode;
 	uint8_t		prev_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.39.2 (Apple Git-143)


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]

  parent reply	other threads:[~2023-12-11 17:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 17:10 [PATCH v3 00/14] support new 5760X P7 devices Ajit Khaparde
2023-12-11 17:10 ` [PATCH v3 01/14] net/bnxt: refactor epoch setting Ajit Khaparde
2023-12-11 17:10 ` [PATCH v3 02/14] net/bnxt: update HWRM API Ajit Khaparde
2023-12-11 17:10 ` [PATCH v3 03/14] net/bnxt: log a message when multicast promisc mode changes Ajit Khaparde
2023-12-11 17:10 ` [PATCH v3 04/14] net/bnxt: use the correct COS queue for Tx Ajit Khaparde
2023-12-11 17:11 ` Ajit Khaparde [this message]
2023-12-11 17:11 ` [PATCH v3 06/14] net/bnxt: add support for p7 device family Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 07/14] net/bnxt: refactor code to support P7 devices Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 08/14] net/bnxt: fix array overflow Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 09/14] net/bnxt: add support for backing store v2 Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 10/14] net/bnxt: refactor the ulp initialization Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 11/14] net/bnxt: modify sending new HWRM commands to firmware Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 12/14] net/bnxt: retry HWRM ver get if the command fails Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 13/14] net/bnxt: cap ring resources for P7 devices Ajit Khaparde
2023-12-11 17:11 ` [PATCH v3 14/14] net/bnxt: add support for v3 Rx completion Ajit Khaparde

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=20231211171109.89716-6-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=somnath.kotur@broadcom.com \
    /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).