vmxnet3: support port hotplug
authorBernard Iremonger <bernard.iremonger@intel.com>
Tue, 27 Oct 2015 17:12:26 +0000 (17:12 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 3 Nov 2015 18:26:31 +0000 (19:26 +0100)
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Yong Wang <yongwang@vmware.com>
doc/guides/rel_notes/release_2_2.rst
drivers/net/vmxnet3/vmxnet3_ethdev.c

index 16fcc89..b39a78a 100644 (file)
@@ -77,6 +77,8 @@ New Features
 
 * **Added vhost-user multiple queue support.**
 
+* **Added port hotplug support to vmxnet3.**
+
 * **Added port hotplug support to xenvirt.**
 
 
index bcb4c9d..c363bf6 100644 (file)
@@ -70,6 +70,7 @@
 #define PROCESS_SYS_EVENTS 0
 
 static int eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev);
+static int eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev);
 static int vmxnet3_dev_configure(struct rte_eth_dev *dev);
 static int vmxnet3_dev_start(struct rte_eth_dev *dev);
 static void vmxnet3_dev_stop(struct rte_eth_dev *dev);
@@ -296,13 +297,37 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
        return 0;
 }
 
+static int
+eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+       struct vmxnet3_hw *hw = eth_dev->data->dev_private;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
+       if (hw->adapter_stopped == 0)
+               vmxnet3_dev_close(eth_dev);
+
+       eth_dev->dev_ops = NULL;
+       eth_dev->rx_pkt_burst = NULL;
+       eth_dev->tx_pkt_burst = NULL;
+
+       rte_free(eth_dev->data->mac_addrs);
+       eth_dev->data->mac_addrs = NULL;
+
+       return 0;
+}
+
 static struct eth_driver rte_vmxnet3_pmd = {
        .pci_drv = {
                .name = "rte_vmxnet3_pmd",
                .id_table = pci_id_vmxnet3_map,
-               .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+               .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
        },
        .eth_dev_init = eth_vmxnet3_dev_init,
+       .eth_dev_uninit = eth_vmxnet3_dev_uninit,
        .dev_private_size = sizeof(struct vmxnet3_hw),
 };
 
@@ -581,7 +606,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev)
 
        PMD_INIT_FUNC_TRACE();
 
-       if (hw->adapter_stopped == TRUE) {
+       if (hw->adapter_stopped == 1) {
                PMD_INIT_LOG(DEBUG, "Device already closed.");
                return;
        }
@@ -597,7 +622,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev)
        /* reset the device */
        VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV);
        PMD_INIT_LOG(DEBUG, "Device reset.");
-       hw->adapter_stopped = FALSE;
+       hw->adapter_stopped = 0;
 
        vmxnet3_dev_clear_queues(dev);
 
@@ -617,7 +642,7 @@ vmxnet3_dev_close(struct rte_eth_dev *dev)
        PMD_INIT_FUNC_TRACE();
 
        vmxnet3_dev_stop(dev);
-       hw->adapter_stopped = TRUE;
+       hw->adapter_stopped = 1;
 }
 
 static void