X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fvhost%2Frte_eth_vhost.c;h=e98cffdf4b7a01158f5036fabce86d259c616682;hb=954820dc7d9eeef76274adcc55d5b9ca4f425ec2;hp=98a47351d617a64c2d5b70c3eaf153af093061a9;hpb=d857736110e507eb3864698bbe271908e2875b95;p=dpdk.git diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 98a47351d6..e98cffdf4b 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -801,6 +801,32 @@ eth_dev_stop(struct rte_eth_dev *dev) update_queuing_status(dev); } +static void +eth_dev_close(struct rte_eth_dev *dev) +{ + struct pmd_internal *internal; + struct internal_list *list; + + internal = dev->data->dev_private; + if (!internal) + return; + + rte_vhost_driver_unregister(internal->iface_name); + + list = find_internal_resource(internal->iface_name); + if (!list) + return; + + pthread_mutex_lock(&internal_list_lock); + TAILQ_REMOVE(&internal_list, list, next); + pthread_mutex_unlock(&internal_list_lock); + rte_free(list); + + free(internal->dev_name); + free(internal->iface_name); + rte_free(internal); +} + static int eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, uint16_t nb_rx_desc __rte_unused, @@ -968,6 +994,7 @@ rte_eth_vhost_feature_get(void) static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop, + .dev_close = eth_dev_close, .dev_configure = eth_dev_configure, .dev_infos_get = eth_dev_info, .rx_queue_setup = eth_rx_queue_setup, @@ -982,6 +1009,8 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, }; +static struct rte_vdev_driver pmd_vhost_drv; + static int eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues, const unsigned numa_node, uint64_t flags) @@ -1066,7 +1095,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues, data->dev_flags = RTE_ETH_DEV_DETACHABLE | RTE_ETH_DEV_INTR_LSC; data->kdrv = RTE_KDRV_NONE; - data->drv_name = internal->dev_name; + data->drv_name = pmd_vhost_drv.driver.name; data->numa_node = numa_node; /* finally assign rx and tx ops */ @@ -1193,8 +1222,6 @@ static int rte_pmd_vhost_remove(const char *name) { struct rte_eth_dev *eth_dev = NULL; - struct pmd_internal *internal; - struct internal_list *list; unsigned int i; RTE_LOG(INFO, PMD, "Un-Initializing pmd_vhost for %s\n", name); @@ -1204,22 +1231,9 @@ rte_pmd_vhost_remove(const char *name) if (eth_dev == NULL) return -ENODEV; - internal = eth_dev->data->dev_private; - if (internal == NULL) - return -ENODEV; - - list = find_internal_resource(internal->iface_name); - if (list == NULL) - return -ENODEV; - - pthread_mutex_lock(&internal_list_lock); - TAILQ_REMOVE(&internal_list, list, next); - pthread_mutex_unlock(&internal_list_lock); - rte_free(list); - eth_dev_stop(eth_dev); - rte_vhost_driver_unregister(internal->iface_name); + eth_dev_close(eth_dev); if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0) vhost_driver_session_stop(); @@ -1227,9 +1241,6 @@ rte_pmd_vhost_remove(const char *name) rte_free(vring_states[eth_dev->data->port_id]); vring_states[eth_dev->data->port_id] = NULL; - free(internal->dev_name); - free(internal->iface_name); - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) rte_free(eth_dev->data->rx_queues[i]); for (i = 0; i < eth_dev->data->nb_tx_queues; i++) @@ -1237,7 +1248,6 @@ rte_pmd_vhost_remove(const char *name) rte_free(eth_dev->data->mac_addrs); rte_free(eth_dev->data); - rte_free(internal); rte_eth_dev_release_port(eth_dev);