net/nfb: remove resources when port is closed

The rte_eth_dev_close() function now handles freeing resources for
devices (e.g., mac_addrs).  To conform with the new close() behaviour we
are asserting the RTE_ETH_DEV_CLOSE_REMOVE flag so that
rte_eth_dev_close() releases all device level dynamic memory.

Signed-off-by: Rastislav Cernay <cernay@netcope.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Jan Remes <remes@netcope.com>
This commit is contained in:
Rastislav Cernay 2019-08-27 22:37:16 +02:00 committed by Ferruh Yigit
parent e5db17a1e5
commit f1d59d3fc8

View File

@ -210,12 +210,16 @@ nfb_eth_dev_info(struct rte_eth_dev *dev,
static void static void
nfb_eth_dev_close(struct rte_eth_dev *dev) nfb_eth_dev_close(struct rte_eth_dev *dev)
{ {
struct pmd_internals *internals = dev->data->dev_private;
uint16_t i; uint16_t i;
uint16_t nb_rx = dev->data->nb_rx_queues; uint16_t nb_rx = dev->data->nb_rx_queues;
uint16_t nb_tx = dev->data->nb_tx_queues; uint16_t nb_tx = dev->data->nb_tx_queues;
nfb_eth_dev_stop(dev); nfb_eth_dev_stop(dev);
nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
for (i = 0; i < nb_rx; i++) { for (i = 0; i < nb_rx; i++) {
nfb_eth_rx_queue_release(dev->data->rx_queues[i]); nfb_eth_rx_queue_release(dev->data->rx_queues[i]);
dev->data->rx_queues[i] = NULL; dev->data->rx_queues[i] = NULL;
@ -226,6 +230,9 @@ nfb_eth_dev_close(struct rte_eth_dev *dev)
dev->data->tx_queues[i] = NULL; dev->data->tx_queues[i] = NULL;
} }
dev->data->nb_tx_queues = 0; dev->data->nb_tx_queues = 0;
rte_free(dev->data->mac_addrs);
dev->data->mac_addrs = NULL;
} }
/** /**
@ -446,6 +453,9 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
rte_kvargs_free(kvlist); rte_kvargs_free(kvlist);
} }
/* Let rte_eth_dev_close() release the port resources */
dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
/* /*
* Get number of available DMA RX and TX queues, which is maximum * Get number of available DMA RX and TX queues, which is maximum
* number of queues that can be created and store it in private device * number of queues that can be created and store it in private device
@ -520,15 +530,10 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)
static int static int
nfb_eth_dev_uninit(struct rte_eth_dev *dev) nfb_eth_dev_uninit(struct rte_eth_dev *dev)
{ {
struct rte_eth_dev_data *data = dev->data;
struct pmd_internals *internals = (struct pmd_internals *)
data->dev_private;
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
struct rte_pci_addr *pci_addr = &pci_dev->addr; struct rte_pci_addr *pci_addr = &pci_dev->addr;
nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac); nfb_eth_dev_close(dev);
nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac);
RTE_LOG(INFO, PMD, "NFB device (" RTE_LOG(INFO, PMD, "NFB device ("
PCI_PRI_FMT ") successfully uninitialized\n", PCI_PRI_FMT ") successfully uninitialized\n",