[dpdk-stable] patch 'net/bnxt: fix memory allocation for command response' has been queued to stable release 20.11.2

Xueming Li xuemingl at nvidia.com
Mon May 10 18:00:45 CEST 2021


Hi,

FYI, your patch has been queued to stable release 20.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/75f780af8b8e931756c5943d38a6789525e4e078

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 75f780af8b8e931756c5943d38a6789525e4e078 Mon Sep 17 00:00:00 2001
From: Kalesh AP <kalesh-anakkur.purayil at broadcom.com>
Date: Sat, 20 Mar 2021 12:19:17 +0530
Subject: [PATCH] net/bnxt: fix memory allocation for command response
Cc: Luca Boccassi <bluca at debian.org>

[ upstream commit 4f1d8fdc3f4234857c1e78af564fcfd92f602f70 ]

Driver re-allocates memory for the command response buffer
when the installed firmware version is newer (and has a larger
max response length) than the version of HWRM that was used to
build the PMD.

This change helps to avoid the re-allocation by allocating the
memory for the command response buffer with PAGE_SIZE.

Coverity issue: 366256, 366204, 366180
Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil at broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur at broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson at broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c   | 27 ++++-----------------------
 2 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e97a3ab8f6..85c711b71f 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -5363,7 +5363,7 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
 	rc = bnxt_alloc_hwrm_resources(bp);
 	if (rc) {
 		PMD_DRV_LOG(ERR,
-			    "Failed to allocate hwrm resource rc: %x\n", rc);
+			    "Failed to allocate response buffer rc: %x\n", rc);
 		return rc;
 	}
 	rc = bnxt_alloc_leds_info(bp);
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 284699b2dc..2e2460b71a 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1160,28 +1160,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
 	max_resp_len = rte_le_to_cpu_16(resp->max_resp_len);
 	dev_caps_cfg = rte_le_to_cpu_32(resp->dev_caps_cfg);
 
-	if (bp->max_resp_len != max_resp_len) {
-		sprintf(type, "bnxt_hwrm_" PCI_PRI_FMT,
-			bp->pdev->addr.domain, bp->pdev->addr.bus,
-			bp->pdev->addr.devid, bp->pdev->addr.function);
-
-		rte_free(bp->hwrm_cmd_resp_addr);
-
-		bp->hwrm_cmd_resp_addr = rte_malloc(type, max_resp_len, 0);
-		if (bp->hwrm_cmd_resp_addr == NULL) {
-			rc = -ENOMEM;
-			goto error;
-		}
-		bp->hwrm_cmd_resp_dma_addr =
-			rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr);
-		if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
-			PMD_DRV_LOG(ERR,
-			"Unable to map response buffer to physical memory.\n");
-			rc = -ENOMEM;
-			goto error;
-		}
-		bp->max_resp_len = max_resp_len;
-	}
+	RTE_VERIFY(max_resp_len <= bp->max_resp_len);
+	bp->max_resp_len = max_resp_len;
 
 	if ((dev_caps_cfg &
 		HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
@@ -2667,7 +2647,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
 
 	sprintf(type, "bnxt_hwrm_" PCI_PRI_FMT, pdev->addr.domain,
 		pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
-	bp->max_resp_len = HWRM_MAX_RESP_LEN;
+	bp->max_resp_len = BNXT_PAGE_SIZE;
 	bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0);
 	if (bp->hwrm_cmd_resp_addr == NULL)
 		return -ENOMEM;
@@ -5842,6 +5822,7 @@ int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
 	int rc = 0;
 
 	bp->max_req_len = HWRM_MAX_REQ_LEN;
+	bp->max_resp_len = BNXT_PAGE_SIZE;
 	bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
 
 	HWRM_PREP(&req, HWRM_VER_GET, BNXT_USE_CHIMP_MB);
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-05-10 23:59:29.103375900 +0800
+++ 0097-net-bnxt-fix-memory-allocation-for-command-response.patch	2021-05-10 23:59:26.460000000 +0800
@@ -1 +1 @@
-From 4f1d8fdc3f4234857c1e78af564fcfd92f602f70 Mon Sep 17 00:00:00 2001
+From 75f780af8b8e931756c5943d38a6789525e4e078 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Luca Boccassi <bluca at debian.org>
+
+[ upstream commit 4f1d8fdc3f4234857c1e78af564fcfd92f602f70 ]
@@ -16 +18,0 @@
-Cc: stable at dpdk.org
@@ -28 +30 @@
-index 372475231d..ed2ae45757 100644
+index e97a3ab8f6..85c711b71f 100644
@@ -31 +33 @@
-@@ -5608,7 +5608,7 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
+@@ -5363,7 +5363,7 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev)
@@ -41 +43 @@
-index e3a07314f8..6a70b6e663 100644
+index 284699b2dc..2e2460b71a 100644
@@ -44 +46 @@
-@@ -1284,28 +1284,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
+@@ -1160,28 +1160,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout)
@@ -75 +77 @@
-@@ -2804,7 +2784,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
+@@ -2667,7 +2647,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
@@ -84 +86 @@
-@@ -6057,6 +6037,7 @@ int bnxt_hwrm_poll_ver_get(struct bnxt *bp)
+@@ -5842,6 +5822,7 @@ int bnxt_hwrm_poll_ver_get(struct bnxt *bp)


More information about the stable mailing list