net/nfp: fix representor port release queue problem

Message ID 20240319070754.398799-1-chaoyong.he@corigine.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers
Series net/nfp: fix representor port release queue problem |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Chaoyong He March 19, 2024, 7:07 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

The PF representor port's queue is different from the VF/physical
representor port. So the release process in close port should
be different too.

Fixes: 39b3951 ("net/nfp: fix resource leak for exit of flower firmware")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 .../net/nfp/flower/nfp_flower_representor.c   | 69 ++++++++++++++-----
 1 file changed, 50 insertions(+), 19 deletions(-)
  

Comments

Ferruh Yigit March 19, 2024, 11:11 a.m. UTC | #1
On 3/19/2024 7:07 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> The PF representor port's queue is different from the VF/physical
> representor port. So the release process in close port should
> be different too.
> 
> Fixes: 39b3951 ("net/nfp: fix resource leak for exit of flower firmware")
> Cc: chaoyong.he@corigine.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
>

Hi Chaoyong,

Can you please clarify the impact of the issue?
As we are post -rc3, is this something we can consider for next release?
  
Chaoyong He March 19, 2024, 11:14 a.m. UTC | #2
> On 3/19/2024 7:07 AM, Chaoyong He wrote:
> > From: Long Wu <long.wu@corigine.com>
> >
> > The PF representor port's queue is different from the VF/physical
> > representor port. So the release process in close port should be
> > different too.
> >
> > Fixes: 39b3951 ("net/nfp: fix resource leak for exit of flower
> > firmware")
> > Cc: chaoyong.he@corigine.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Long Wu <long.wu@corigine.com>
> > Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> > Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> >
> 
> Hi Chaoyong,
> 
> Can you please clarify the impact of the issue?
> As we are post -rc3, is this something we can consider for next release?

Okay, we can delay it for next release.
Thanks.
  
Ferruh Yigit April 12, 2024, 10:12 a.m. UTC | #3
On 3/19/2024 7:07 AM, Chaoyong He wrote:
> From: Long Wu <long.wu@corigine.com>
> 
> The PF representor port's queue is different from the VF/physical
> representor port. So the release process in close port should
> be different too.
> 
> Fixes: a256a1227dbe ("net/nfp: fix resource leak for exit of flower firmware")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index f26bf83edb..c4f33cbb2e 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -304,6 +304,54 @@  nfp_flower_repr_tx_burst(void *tx_queue,
 	return sent;
 }
 
+static void
+nfp_flower_repr_free_queue(struct nfp_flower_representor *repr)
+{
+	uint16_t i;
+	struct rte_eth_dev *eth_dev = repr->eth_dev;
+
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+		rte_free(eth_dev->data->tx_queues[i]);
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+		rte_free(eth_dev->data->rx_queues[i]);
+}
+
+static void
+nfp_flower_pf_repr_close_queue(struct nfp_flower_representor *repr)
+{
+	struct rte_eth_dev *eth_dev = repr->eth_dev;
+
+	/*
+	 * We assume that the DPDK application is stopping all the
+	 * threads/queues before calling the device close function.
+	 */
+	nfp_net_disable_queues(eth_dev);
+
+	/* Clear queues */
+	nfp_net_close_tx_queue(eth_dev);
+	nfp_net_close_rx_queue(eth_dev);
+}
+
+static void
+nfp_flower_repr_close_queue(struct nfp_flower_representor *repr)
+{
+	switch (repr->repr_type) {
+	case NFP_REPR_TYPE_PHYS_PORT:
+		nfp_flower_repr_free_queue(repr);
+		break;
+	case NFP_REPR_TYPE_PF:
+		nfp_flower_pf_repr_close_queue(repr);
+		break;
+	case NFP_REPR_TYPE_VF:
+		nfp_flower_repr_free_queue(repr);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unsupported repr port type.");
+		break;
+	}
+}
+
 static int
 nfp_flower_repr_uninit(struct rte_eth_dev *eth_dev)
 {
@@ -348,8 +396,6 @@  nfp_flower_repr_dev_close(struct rte_eth_dev *dev)
 	uint16_t i;
 	struct nfp_net_hw *hw;
 	struct nfp_pf_dev *pf_dev;
-	struct nfp_net_txq *this_tx_q;
-	struct nfp_net_rxq *this_rx_q;
 	struct nfp_flower_representor *repr;
 	struct nfp_app_fw_flower *app_fw_flower;
 
@@ -361,26 +407,11 @@  nfp_flower_repr_dev_close(struct rte_eth_dev *dev)
 	hw = app_fw_flower->pf_hw;
 	pf_dev = hw->pf_dev;
 
-	/*
-	 * We assume that the DPDK application is stopping all the
-	 * threads/queues before calling the device close function.
-	 */
-	nfp_net_disable_queues(dev);
-
-	/* Clear queues */
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		this_tx_q = dev->data->tx_queues[i];
-		nfp_net_reset_tx_queue(this_tx_q);
-	}
-
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		this_rx_q = dev->data->rx_queues[i];
-		nfp_net_reset_rx_queue(this_rx_q);
-	}
-
 	if (pf_dev->app_fw_id != NFP_APP_FW_FLOWER_NIC)
 		return -EINVAL;
 
+	nfp_flower_repr_close_queue(repr);
+
 	nfp_flower_repr_free(repr, repr->repr_type);
 
 	for (i = 0; i < MAX_FLOWER_VFS; i++) {