* [dpdk-dev] [PATCH] net/ena: remove resources when port is being closed
@ 2018-10-31 14:53 Michal Krawczyk
2018-11-02 20:35 ` Ferruh Yigit
0 siblings, 1 reply; 2+ messages in thread
From: Michal Krawczyk @ 2018-10-31 14:53 UTC (permalink / raw)
To: mw, matua, gtzalik, zorik; +Cc: dev, Michal Krawczyk
The new API introduced in 18.11 is suggesting, that the driver should
release all it's resources at the dev_close routine.
All resources previously released in uninit routine during PCI removal,
are now being released at the dev_close and the PMD is indicating that
it is supporting API changes by setting RTE_ETH_DEV_CLOSE_REMOVE flag.
As the device is not allocating MAC addresses dynamically, it is setting
mac_addrs field to NULL, so it wouldn't be released by the
rte_eth_dev_release_port().
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
---
drivers/net/ena/ena_ethdev.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 0c0ed9302..abe1e7bd0 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -509,6 +509,8 @@ static void ena_config_debug_area(struct ena_adapter *adapter)
static void ena_close(struct rte_eth_dev *dev)
{
+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct ena_adapter *adapter =
(struct ena_adapter *)(dev->data->dev_private);
@@ -518,6 +520,25 @@ static void ena_close(struct rte_eth_dev *dev)
ena_rx_queue_release_all(dev);
ena_tx_queue_release_all(dev);
+
+ rte_free(adapter->drv_stats);
+ adapter->drv_stats = NULL;
+
+ rte_intr_disable(intr_handle);
+ rte_intr_callback_unregister(intr_handle,
+ ena_interrupt_handler_rte,
+ adapter);
+
+ /*
+ * Pass the information to the rte_eth_dev_close() that it should also
+ * release the private port resources.
+ */
+ dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+ /*
+ * MAC is not allocated dynamically. Setting NULL should prevent from
+ * release of the resource in the rte_eth_dev_release_port().
+ */
+ dev->data->mac_addrs = NULL;
}
static int
@@ -1683,8 +1704,6 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
static int eth_ena_dev_uninit(struct rte_eth_dev *eth_dev)
{
- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct ena_adapter *adapter =
(struct ena_adapter *)(eth_dev->data->dev_private);
@@ -1699,14 +1718,6 @@ static int eth_ena_dev_uninit(struct rte_eth_dev *eth_dev)
eth_dev->tx_pkt_burst = NULL;
eth_dev->tx_pkt_prepare = NULL;
- rte_free(adapter->drv_stats);
- adapter->drv_stats = NULL;
-
- rte_intr_disable(intr_handle);
- rte_intr_callback_unregister(intr_handle,
- ena_interrupt_handler_rte,
- adapter);
-
adapter->state = ENA_ADAPTER_STATE_FREE;
return 0;
--
2.14.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] net/ena: remove resources when port is being closed
2018-10-31 14:53 [dpdk-dev] [PATCH] net/ena: remove resources when port is being closed Michal Krawczyk
@ 2018-11-02 20:35 ` Ferruh Yigit
0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2018-11-02 20:35 UTC (permalink / raw)
To: Michal Krawczyk, mw, matua, gtzalik, zorik; +Cc: dev
On 10/31/2018 2:53 PM, Michal Krawczyk wrote:
> The new API introduced in 18.11 is suggesting, that the driver should
> release all it's resources at the dev_close routine.
>
> All resources previously released in uninit routine during PCI removal,
> are now being released at the dev_close and the PMD is indicating that
> it is supporting API changes by setting RTE_ETH_DEV_CLOSE_REMOVE flag.
>
> As the device is not allocating MAC addresses dynamically, it is setting
> mac_addrs field to NULL, so it wouldn't be released by the
> rte_eth_dev_release_port().
>
> Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-02 20:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 14:53 [dpdk-dev] [PATCH] net/ena: remove resources when port is being closed Michal Krawczyk
2018-11-02 20:35 ` Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).