[02/10] net/bnxt: free default completion ring before VF configuration

Message ID 20191004050246.90165-3-ajit.khaparde@broadcom.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series bnxt patchset with bug fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ajit Khaparde Oct. 4, 2019, 5:02 a.m. UTC
  From: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>

If the VF resources need to be reconfigured using the
bnxt_hwrm_func_reserve_vf_resc, make sure that the default completion
ring is freed first before the resources are reserved.

Reallocate the ring once the VF resources are configured.

Signed-off-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 533c6a07fd..2a9b7e5459 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -662,11 +662,28 @@  static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 			return -ENOSPC;
 		}
 
+		/* If a resource has already been allocated - in this case
+		 * it is the async completion ring, free it. Reallocate it after
+		 * resource reservation. This will ensure the resource counts
+		 * are calculated correctly.
+		 */
+		if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
+			bnxt_disable_int(bp);
+			bnxt_free_cp_ring(bp, bp->async_cp_ring);
+		}
+
 		rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
 		if (rc) {
 			PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
 			return -ENOSPC;
 		}
+
+		if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
+			rc = bnxt_alloc_async_cp_ring(bp);
+			if (rc)
+				return rc;
+			bnxt_enable_int(bp);
+		}
 	} else {
 		/* legacy driver needs to get updated values */
 		rc = bnxt_hwrm_func_qcaps(bp);