#include "virtio_logs.h"
#include "virtqueue.h"
#include "virtio_rxtx.h"
+#include "virtio_user/virtio_user_dev.h"
static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
static int virtio_dev_configure(struct rte_eth_dev *dev);
vtpci_reset(hw);
virtio_dev_free_mbufs(dev);
virtio_free_queues(hw);
+
+#ifdef RTE_VIRTIO_USER
+ if (hw->virtio_user_dev)
+ virtio_user_dev_uninit(hw->virtio_user_dev);
+ else
+#endif
+ if (dev->device) {
+ rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(dev));
+ if (!hw->modern)
+ rte_pci_ioport_unmap(VTPCI_IO(hw));
+ }
}
static void
hw->weak_barriers = !vtpci_with_feature(hw, VIRTIO_F_ORDER_PLATFORM);
- if (!hw->virtio_user_dev) {
+ if (!hw->virtio_user_dev)
pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
- rte_eth_copy_pci_info(eth_dev, pci_dev);
- }
/* If host does not support both status and MSI-X then disable LSC */
if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS) &&
return 0;
}
+ /*
+ * Pass the information to the rte_eth_dev_close() that it should also
+ * release the private port resources.
+ */
+ eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
/* Allocate memory for storing MAC addresses */
eth_dev->data->mac_addrs = rte_zmalloc("virtio",
VIRTIO_MAX_MAC_ADDRS * RTE_ETHER_ADDR_LEN, 0);
if (ret < 0)
goto err_virtio_init;
+ hw->opened = true;
+
return 0;
err_virtio_init:
static int
eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
{
- struct virtio_hw *hw = eth_dev->data->dev_private;
-
PMD_INIT_FUNC_TRACE();
if (rte_eal_process_type() == RTE_PROC_SECONDARY)
eth_dev->tx_pkt_burst = NULL;
eth_dev->rx_pkt_burst = NULL;
- if (eth_dev->device) {
- rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev));
- if (!hw->modern)
- rte_pci_ioport_unmap(VTPCI_IO(hw));
- }
-
PMD_INIT_LOG(DEBUG, "dev_uninit completed");
return 0;
static int eth_virtio_pci_remove(struct rte_pci_device *pci_dev)
{
- return rte_eth_dev_pci_generic_remove(pci_dev, eth_virtio_dev_uninit);
+ int ret;
+
+ ret = rte_eth_dev_pci_generic_remove(pci_dev, eth_virtio_dev_uninit);
+ /* Port has already been released by close. */
+ if (ret == -ENODEV)
+ ret = 0;
+ return ret;
}
static struct rte_pci_driver rte_virtio_pmd = {
DEV_RX_OFFLOAD_VLAN_STRIP))
hw->use_simple_rx = 0;
- hw->opened = true;
-
return 0;
}
#include "virtqueue.h"
#include "virtio_rxtx.h"
#include "virtio_user/virtio_user_dev.h"
+#include "virtio_user/vhost.h"
#define virtio_user_get_dev(hw) \
((struct virtio_user_dev *)(hw)->virtio_user_dev)
{
const char *name;
struct rte_eth_dev *eth_dev;
- struct virtio_hw *hw;
- struct virtio_user_dev *dev;
if (!vdev)
return -EINVAL;
name = rte_vdev_device_name(vdev);
PMD_DRV_LOG(INFO, "Un-Initializing %s", name);
eth_dev = rte_eth_dev_allocated(name);
+ /* Port has already been released by close. */
if (!eth_dev)
- return -ENODEV;
+ return 0;
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return rte_eth_dev_release_port(eth_dev);
/* make sure the device is stopped, queues freed */
rte_eth_dev_close(eth_dev->data->port_id);
- hw = eth_dev->data->dev_private;
- dev = hw->virtio_user_dev;
- virtio_user_dev_uninit(dev);
-
- rte_eth_dev_release_port(eth_dev);
-
return 0;
}