Skip to contentSkip to conversation

net/bnx2x: fix read VF id

PATCH In review Rasesh Mody 2 participants 4 messages Jul 3, 2019 – Jul 9, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 net/bnx2x: fix read VF id

The logic, to read vf_id used by ACQUIRE/TEARDOWN_Q/RELEASE TLVs, multiplexed return value to convey vf_id value and status of read vf_id API. This lets to segfault at dev_start() as resources are not properly cleaned and re-allocated.

Fix read vf_id API to differentiate between vf_id value and return status. Adjust the status checking accordingly.
Added bnx2x_vf_teardown_queue() API and moved relevant code from bnx2x_vf_unload() to new API.

Fixes 540a211084a7 ("bnx2x: driver core")
---
 drivers/net/bnx2x/bnx2x.c      |   2 +
 drivers/net/bnx2x/bnx2x_vfpf.c | 140 ++++++++++++++++++++-------------
 drivers/net/bnx2x/bnx2x_vfpf.h |   1 +
 3 files changed, 87 insertions(+), 56 deletions(-)
drivers/net/bnx2x/bnx2x.c +2 -0
index d523f4f2c..877f5b73d 100644
@@ -2015,6 +2015,8 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link
 	uint8_t global = FALSE;
 	uint32_t val;
 
+	PMD_INIT_FUNC_TRACE(sc);
+
 	PMD_DRV_LOG(DEBUG, sc, "Starting NIC unload...");
 
 	/* mark driver as unloaded in shmem2 */
drivers/net/bnx2x/bnx2x_vfpf.c +84 -56

206 lines not on this page · raw message

drivers/net/bnx2x/bnx2x_vfpf.h +1 -0
index 6964c9d98..ce0259adf 100644
@@ -328,6 +328,7 @@ struct bnx2x_vf_mbx_msg {
 	union resp_tlvs resp;
 };
 
+int bnx2x_vf_teardown_queue(struct bnx2x_softc *sc, int qid);
 int bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set);
 int bnx2x_vf_config_rss(struct bnx2x_softc *sc, struct ecore_config_rss_params *params);
 
Signature · 1 line
2.18.0
#1 lore raw

PATCH 2/3 net/bnx2x: fix link events polling for SRIOV

We do not need to schedule periodic poll for slowpath link events for SRIOV. The link events are handled by the PF driver.

Fixes 6041aa619f9a ("net/bnx2x: fix poll link status")
---
 drivers/net/bnx2x/bnx2x_ethdev.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/bnx2x/bnx2x_ethdev.c +12 -7
index 10b4fdb8e..127811b92 100644
@@ -218,9 +218,12 @@ bnx2x_dev_start(struct rte_eth_dev *dev)
 	PMD_INIT_FUNC_TRACE(sc);
 
 	/* start the periodic callout */
-	if (atomic_load_acq_long(&sc->periodic_flags) == PERIODIC_STOP) {
-		bnx2x_periodic_start(dev);
-		PMD_DRV_LOG(DEBUG, sc, "Periodic poll re-started");
+	if (IS_PF(sc)) {
+		if (atomic_load_acq_long(&sc->periodic_flags) ==
+		    PERIODIC_STOP) {
+			bnx2x_periodic_start(dev);
+			PMD_DRV_LOG(DEBUG, sc, "Periodic poll re-started");
+		}
 	}
 
 	ret = bnx2x_init(sc);
@@ -258,10 +261,10 @@ bnx2x_dev_stop(struct rte_eth_dev *dev)
 		rte_intr_disable(&sc->pci_dev->intr_handle);
 		rte_intr_callback_unregister(&sc->pci_dev->intr_handle,
 				bnx2x_interrupt_handler, (void *)dev);
-	}
 
-	/* stop the periodic callout */
-	bnx2x_periodic_stop(dev);
+		/* stop the periodic callout */
+		bnx2x_periodic_stop(dev);
+	}
 
 	ret = bnx2x_nic_unload(sc, UNLOAD_NORMAL, FALSE);
 	if (ret) {
@@ -680,7 +683,9 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
 	return 0;
 
 out:
-	bnx2x_periodic_stop(eth_dev);
+	if (IS_PF(sc))
+		bnx2x_periodic_stop(eth_dev);
+
 	return ret;
 }
 
Signature · 1 line
2.18.0
#2 lore raw

PATCH 3/3 net/bnx2x: fix fastpath SB allocation for SRIOV

In reply to Rasesh Mody

For SRIOV, fastpath status blocks are not allocated resulting in segfault. Separate out fastpath DMA allocation/free from rest of memory allocation/free. It is now done as part of NIC load/unload.

Comment indentation changes in bnx2x_alloc_hsi_mem() and bnx2x_free_hsi_mem() APIs.

Fixes f0219d98defd ("net/bnx2x: fix interrupt flood")
---
 drivers/net/bnx2x/bnx2x.c | 117 +++++++++++++++++++-------------------
 1 file changed, 60 insertions(+), 57 deletions(-)
drivers/net/bnx2x/bnx2x.c +60 -57
index 877f5b73d..1a088269f 100644
@@ -2120,6 +2120,9 @@ bnx2x_nic_unload(struct bnx2x_softc *sc, uint32_t unload_mode, uint8_t keep_link
 		bnx2x_free_mem(sc);
 	}
 
+	/* free the host hardware/software hsi structures */
+	bnx2x_free_hsi_mem(sc);
+
 	bnx2x_free_fw_stats_mem(sc);
 
 	sc->state = BNX2X_STATE_CLOSED;
@@ -2403,9 +2406,6 @@ static void bnx2x_free_mem(struct bnx2x_softc *sc)
 	ecore_ilt_mem_op(sc, ILT_MEMOP_FREE);
 
 	bnx2x_free_ilt_lines_mem(sc);
-
-	/* free the host hardware/software hsi structures */
-	bnx2x_free_hsi_mem(sc);
 }
 
 static int bnx2x_alloc_mem(struct bnx2x_softc *sc)
@@ -2456,13 +2456,6 @@ static int bnx2x_alloc_mem(struct bnx2x_softc *sc)
 		return -1;
 	}
 
-	/* allocate the host hardware/software hsi structures */
-	if (bnx2x_alloc_hsi_mem(sc) != 0) {
-		PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_hsi_mem was failed");
-		bnx2x_free_mem(sc);
-		return -ENXIO;
-	}
-
 	return 0;
 }
 
@@ -7242,6 +7235,14 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
 		}
 	}
 
+	/* allocate the host hardware/software hsi structures */
+	if (bnx2x_alloc_hsi_mem(sc) != 0) {
+		PMD_DRV_LOG(ERR, sc, "bnx2x_alloc_hsi_mem was failed");
+		sc->state = BNX2X_STATE_CLOSED;
+		rc = -ENOMEM;
+		goto bnx2x_nic_load_error0;
+	}
+
 	if (bnx2x_alloc_fw_stats_mem(sc) != 0) {
 		sc->state = BNX2X_STATE_CLOSED;
 		rc = -ENOMEM;
@@ -7457,6 +7458,7 @@ int bnx2x_nic_load(struct bnx2x_softc *sc)
 bnx2x_nic_load_error0:
 
 	bnx2x_free_fw_stats_mem(sc);
+	bnx2x_free_hsi_mem(sc);
 	bnx2x_free_mem(sc);
 
 	return rc;
@@ -8902,9 +8904,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 	uint32_t i;
 
 	if (IS_PF(sc)) {
-/************************/
-/* DEFAULT STATUS BLOCK */
-/************************/
+		/************************/
+		/* DEFAULT STATUS BLOCK */
+		/************************/
 
 		if (bnx2x_dma_alloc(sc, sizeof(struct host_sp_status_block),
 				  &sc->def_sb_dma, "def_sb",
@@ -8914,9 +8916,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
 		sc->def_sb =
 		    (struct host_sp_status_block *)sc->def_sb_dma.vaddr;
-/***************/
-/* EVENT QUEUE */
-/***************/
+		/***************/
+		/* EVENT QUEUE */
+		/***************/
 
 		if (bnx2x_dma_alloc(sc, BNX2X_PAGE_SIZE,
 				  &sc->eq_dma, "ev_queue",
@@ -8927,9 +8929,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
 		sc->eq = (union event_ring_elem *)sc->eq_dma.vaddr;
 
-/*************/
-/* SLOW PATH */
-/*************/
+		/*************/
+		/* SLOW PATH */
+		/*************/
 
 		if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_slowpath),
 				  &sc->sp_dma, "sp",
@@ -8941,9 +8943,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
 		sc->sp = (struct bnx2x_slowpath *)sc->sp_dma.vaddr;
 
-/*******************/
-/* SLOW PATH QUEUE */
-/*******************/
+		/*******************/
+		/* SLOW PATH QUEUE */
+		/*******************/
 
 		if (bnx2x_dma_alloc(sc, BNX2X_PAGE_SIZE,
 				  &sc->spq_dma, "sp_queue",
@@ -8956,9 +8958,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 
 		sc->spq = (struct eth_spe *)sc->spq_dma.vaddr;
 
-/***************************/
-/* FW DECOMPRESSION BUFFER */
-/***************************/
+		/***************************/
+		/* FW DECOMPRESSION BUFFER */
+		/***************************/
 
 		if (bnx2x_dma_alloc(sc, FW_BUF_SIZE, &sc->gz_buf_dma,
 				  "fw_buf", RTE_CACHE_LINE_SIZE) != 0) {
@@ -8982,9 +8984,9 @@ int bnx2x_alloc_hsi_mem(struct bnx2x_softc *sc)
 		fp->sc = sc;
 		fp->index = i;
 
-/*******************/
-/* FP STATUS BLOCK */
-/*******************/
+		/*******************/
+		/* FP STATUS BLOCK */
+		/*******************/
 
 		snprintf(buf, sizeof(buf), "fp_%d_sb", i);
 		if (bnx2x_dma_alloc(sc, sizeof(union bnx2x_host_hc_status_block),
@@ -9015,49 +9017,50 @@ void bnx2x_free_hsi_mem(struct bnx2x_softc *sc)
 	for (i = 0; i < sc->num_queues; i++) {
 		fp = &sc->fp[i];
 
-/*******************/
-/* FP STATUS BLOCK */
-/*******************/
+		/*******************/
+		/* FP STATUS BLOCK */
+		/*******************/
 
 		memset(&fp->status_block, 0, sizeof(fp->status_block));
 		bnx2x_dma_free(&fp->sb_dma);
 	}
 
-	/***************************/
-	/* FW DECOMPRESSION BUFFER */
-	/***************************/
-
-	bnx2x_dma_free(&sc->gz_buf_dma);
-	sc->gz_buf = NULL;
+	if (IS_PF(sc)) {
+		/***************************/
+		/* FW DECOMPRESSION BUFFER */
+		/***************************/
 
-	/*******************/
-	/* SLOW PATH QUEUE */
-	/*******************/
+		bnx2x_dma_free(&sc->gz_buf_dma);
+		sc->gz_buf = NULL;
 
-	bnx2x_dma_free(&sc->spq_dma);
-	sc->spq = NULL;
+		/*******************/
+		/* SLOW PATH QUEUE */
+		/*******************/
 
-	/*************/
-	/* SLOW PATH */
-	/*************/
+		bnx2x_dma_free(&sc->spq_dma);
+		sc->spq = NULL;
 
-	bnx2x_dma_free(&sc->sp_dma);
-	sc->sp = NULL;
+		/*************/
+		/* SLOW PATH */
+		/*************/
 
-	/***************/
-	/* EVENT QUEUE */
-	/***************/
+		bnx2x_dma_free(&sc->sp_dma);
+		sc->sp = NULL;
 
-	bnx2x_dma_free(&sc->eq_dma);
-	sc->eq = NULL;
+		/***************/
+		/* EVENT QUEUE */
+		/***************/
 
-	/************************/
-	/* DEFAULT STATUS BLOCK */
-	/************************/
+		bnx2x_dma_free(&sc->eq_dma);
+		sc->eq = NULL;
 
-	bnx2x_dma_free(&sc->def_sb_dma);
-	sc->def_sb = NULL;
+		/************************/
+		/* DEFAULT STATUS BLOCK */
+		/************************/
 
+		bnx2x_dma_free(&sc->def_sb_dma);
+		sc->def_sb = NULL;
+	}
 }
 
 /*
Signature · 1 line
2.18.0
#3 lore raw
In reply to Rasesh Mody
Quoted 18 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Rasesh Mody
Sent: Thursday, July 4, 2019 5:13 AM
To: [email protected]
Cc: Rasesh Mody <[email protected]>; [email protected]; GR- Everest-DPDK-Dev <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH 1/3] net/bnx2x: fix read VF id

The logic, to read vf_id used by ACQUIRE/TEARDOWN_Q/RELEASE TLVs, multiplexed return value to convey vf_id value and status of read vf_id API. This lets to segfault at dev_start() as resources are not properly cleaned and re-allocated.

Fix read vf_id API to differentiate between vf_id value and return status. Adjust the status checking accordingly.
Added bnx2x_vf_teardown_queue() API and moved relevant code from bnx2x_vf_unload() to new API.

Quoted 4 lines
Fixes 540a211084a7 ("bnx2x: driver core")

Series applied to dpdk-next-net-mrvl/master. Thanks.