net/nfp: free HW rings memzone on queue release

Message ID 20220119114800.6900-1-heinrich.kuhn@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfp: free HW rings memzone on queue release |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

heinrich.kuhn@corigine.com Jan. 19, 2022, 11:48 a.m. UTC
  From: Heinrich Kuhn <heinrich.kuhn@corigine.com>

During rx/tx queue setup, memory is reserved for the hardware rings.
This memory zone should subsequently be freed in the queue release
logic. This commit also adds a call to the release logic in the
dev_close() callback so that the ring memzone may be freed during port
close too.

Fixes: b812daadad0d ("nfp: add Rx and Tx")
Cc: stable@dpdk.org

Signed-off-by: Heinrich Kuhn <heinrich.kuhn@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c    | 2 ++
 drivers/net/nfp/nfp_ethdev_vf.c | 2 ++
 drivers/net/nfp/nfp_rxtx.c      | 2 ++
 3 files changed, 6 insertions(+)
  

Comments

Ferruh Yigit Jan. 26, 2022, 4:53 p.m. UTC | #1
On 1/19/2022 11:48 AM, heinrich.kuhn@corigine.com wrote:
> From: Heinrich Kuhn <heinrich.kuhn@corigine.com>
> 
> During rx/tx queue setup, memory is reserved for the hardware rings.
> This memory zone should subsequently be freed in the queue release
> logic. This commit also adds a call to the release logic in the
> dev_close() callback so that the ring memzone may be freed during port
> close too.
> 
> Fixes: b812daadad0d ("nfp: add Rx and Tx")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Heinrich Kuhn <heinrich.kuhn@corigine.com>
> Signed-off-by: Simon Horman <simon.horman@corigine.com>

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

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 8e81cc498f..9166f65da3 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -302,11 +302,13 @@  nfp_net_close(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
 		nfp_net_reset_tx_queue(this_tx_q);
+		nfp_net_tx_queue_release(dev, i);
 	}
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
 		nfp_net_reset_rx_queue(this_rx_q);
+		nfp_net_rx_queue_release(dev, i);
 	}
 
 	/* Cancel possible impending LSC work here before releasing the port*/
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 303ef72b1b..0034d68ea6 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -219,11 +219,13 @@  nfp_netvf_close(struct rte_eth_dev *dev)
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		this_tx_q =  (struct nfp_net_txq *)dev->data->tx_queues[i];
 		nfp_net_reset_tx_queue(this_tx_q);
+		nfp_net_tx_queue_release(dev, i);
 	}
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		this_rx_q =  (struct nfp_net_rxq *)dev->data->rx_queues[i];
 		nfp_net_reset_rx_queue(this_rx_q);
+		nfp_net_rx_queue_release(dev, i);
 	}
 
 	rte_intr_disable(pci_dev->intr_handle);
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 0fe1415596..335a90b2c9 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -470,6 +470,7 @@  nfp_net_rx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx)
 
 	if (rxq) {
 		nfp_net_rx_queue_release_mbufs(rxq);
+		rte_eth_dma_zone_free(dev, "rx_ring", queue_idx);
 		rte_free(rxq->rxbufs);
 		rte_free(rxq);
 	}
@@ -660,6 +661,7 @@  nfp_net_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx)
 
 	if (txq) {
 		nfp_net_tx_queue_release_mbufs(txq);
+		rte_eth_dma_zone_free(dev, "tx_ring", queue_idx);
 		rte_free(txq->txbufs);
 		rte_free(txq);
 	}