net: remove dead driver names
[dpdk.git] / drivers / net / vhost / rte_eth_vhost.c
index 86c7a4d..98a4735 100644 (file)
@@ -53,8 +53,6 @@
 #define ETH_VHOST_CLIENT_ARG           "client"
 #define ETH_VHOST_DEQUEUE_ZERO_COPY    "dequeue-zero-copy"
 
-static const char *drivername = "VHOST PMD";
-
 static const char *valid_arguments[] = {
        ETH_VHOST_IFACE_ARG,
        ETH_VHOST_QUEUES_ARG,
@@ -112,12 +110,11 @@ struct vhost_queue {
 };
 
 struct pmd_internal {
+       rte_atomic32_t dev_attached;
        char *dev_name;
        char *iface_name;
        uint16_t max_queues;
-       uint64_t flags;
-
-       volatile uint16_t once;
+       rte_atomic32_t started;
 };
 
 struct internal_list {
@@ -324,6 +321,7 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
                                *(uint64_t *)(((char *)vq)
                                + vhost_rxport_stat_strings[t].offset);
                }
+               xstats[count].id = count;
                count++;
        }
        for (t = 0; t < VHOST_NB_XSTATS_TXPORT; t++) {
@@ -336,6 +334,7 @@ vhost_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
                                *(uint64_t *)(((char *)vq)
                                + vhost_txport_stat_strings[t].offset);
                }
+               xstats[count].id = count;
                count++;
        }
        return count;
@@ -495,6 +494,38 @@ find_internal_resource(char *ifname)
        return list;
 }
 
+static void
+update_queuing_status(struct rte_eth_dev *dev)
+{
+       struct pmd_internal *internal = dev->data->dev_private;
+       struct vhost_queue *vq;
+       unsigned int i;
+       int allow_queuing = 1;
+
+       if (rte_atomic32_read(&internal->started) == 0 ||
+           rte_atomic32_read(&internal->dev_attached) == 0)
+               allow_queuing = 0;
+
+       /* Wait until rx/tx_pkt_burst stops accessing vhost device */
+       for (i = 0; i < dev->data->nb_rx_queues; i++) {
+               vq = dev->data->rx_queues[i];
+               if (vq == NULL)
+                       continue;
+               rte_atomic32_set(&vq->allow_queuing, allow_queuing);
+               while (rte_atomic32_read(&vq->while_queuing))
+                       rte_pause();
+       }
+
+       for (i = 0; i < dev->data->nb_tx_queues; i++) {
+               vq = dev->data->tx_queues[i];
+               if (vq == NULL)
+                       continue;
+               rte_atomic32_set(&vq->allow_queuing, allow_queuing);
+               while (rte_atomic32_read(&vq->while_queuing))
+                       rte_pause();
+       }
+}
+
 static int
 new_device(int vid)
 {
@@ -546,22 +577,12 @@ new_device(int vid)
 
        eth_dev->data->dev_link.link_status = ETH_LINK_UP;
 
-       for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
-               vq = eth_dev->data->rx_queues[i];
-               if (vq == NULL)
-                       continue;
-               rte_atomic32_set(&vq->allow_queuing, 1);
-       }
-       for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
-               vq = eth_dev->data->tx_queues[i];
-               if (vq == NULL)
-                       continue;
-               rte_atomic32_set(&vq->allow_queuing, 1);
-       }
+       rte_atomic32_set(&internal->dev_attached, 1);
+       update_queuing_status(eth_dev);
 
        RTE_LOG(INFO, PMD, "New connection established\n");
 
-       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC);
+       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 
        return 0;
 }
@@ -570,6 +591,7 @@ static void
 destroy_device(int vid)
 {
        struct rte_eth_dev *eth_dev;
+       struct pmd_internal *internal;
        struct vhost_queue *vq;
        struct internal_list *list;
        char ifname[PATH_MAX];
@@ -583,24 +605,10 @@ destroy_device(int vid)
                return;
        }
        eth_dev = list->eth_dev;
+       internal = eth_dev->data->dev_private;
 
-       /* Wait until rx/tx_pkt_burst stops accessing vhost device */
-       for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
-               vq = eth_dev->data->rx_queues[i];
-               if (vq == NULL)
-                       continue;
-               rte_atomic32_set(&vq->allow_queuing, 0);
-               while (rte_atomic32_read(&vq->while_queuing))
-                       rte_pause();
-       }
-       for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
-               vq = eth_dev->data->tx_queues[i];
-               if (vq == NULL)
-                       continue;
-               rte_atomic32_set(&vq->allow_queuing, 0);
-               while (rte_atomic32_read(&vq->while_queuing))
-                       rte_pause();
-       }
+       rte_atomic32_set(&internal->dev_attached, 0);
+       update_queuing_status(eth_dev);
 
        eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 
@@ -628,7 +636,7 @@ destroy_device(int vid)
 
        RTE_LOG(INFO, PMD, "Connection closed\n");
 
-       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC);
+       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
 static int
@@ -657,7 +665,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
        RTE_LOG(INFO, PMD, "vring%u is %s\n",
                        vring, enable ? "enabled" : "disabled");
 
-       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE);
+       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE, NULL);
 
        return 0;
 }
@@ -777,20 +785,11 @@ static int
 eth_dev_start(struct rte_eth_dev *dev)
 {
        struct pmd_internal *internal = dev->data->dev_private;
-       int ret = 0;
 
-       if (rte_atomic16_cmpset(&internal->once, 0, 1)) {
-               ret = rte_vhost_driver_register(internal->iface_name,
-                                               internal->flags);
-               if (ret)
-                       return ret;
-       }
-
-       /* We need only one message handling thread */
-       if (rte_atomic16_add_return(&nb_started_ports, 1) == 1)
-               ret = vhost_driver_session_start();
+       rte_atomic32_set(&internal->started, 1);
+       update_queuing_status(dev);
 
-       return ret;
+       return 0;
 }
 
 static void
@@ -798,11 +797,8 @@ eth_dev_stop(struct rte_eth_dev *dev)
 {
        struct pmd_internal *internal = dev->data->dev_private;
 
-       if (rte_atomic16_cmpset(&internal->once, 1, 0))
-               rte_vhost_driver_unregister(internal->iface_name);
-
-       if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0)
-               vhost_driver_session_stop();
+       rte_atomic32_set(&internal->started, 0);
+       update_queuing_status(dev);
 }
 
 static int
@@ -861,7 +857,6 @@ eth_dev_info(struct rte_eth_dev *dev,
                return;
        }
 
-       dev_info->driver_name = drivername;
        dev_info->max_mac_addrs = 1;
        dev_info->max_rx_pktlen = (uint32_t)-1;
        dev_info->max_rx_queues = internal->max_queues;
@@ -1032,8 +1027,6 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
        if (vring_state == NULL)
                goto error;
 
-       TAILQ_INIT(&eth_dev->link_intr_cbs);
-
        /* now put it all together
         * - store queue data in internal,
         * - store numa_node info in ethdev data
@@ -1046,7 +1039,6 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
        internal->iface_name = strdup(iface_name);
        if (internal->iface_name == NULL)
                goto error;
-       internal->flags = flags;
 
        list->eth_dev = eth_dev;
        pthread_mutex_lock(&internal_list_lock);
@@ -1081,6 +1073,15 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
        eth_dev->rx_pkt_burst = eth_vhost_rx;
        eth_dev->tx_pkt_burst = eth_vhost_tx;
 
+       if (rte_vhost_driver_register(iface_name, flags))
+               goto error;
+
+       /* We need only one message handling thread */
+       if (rte_atomic16_add_return(&nb_started_ports, 1) == 1) {
+               if (vhost_driver_session_start())
+                       goto error;
+       }
+
        return data->port_id;
 
 error:
@@ -1218,6 +1219,11 @@ rte_pmd_vhost_remove(const char *name)
 
        eth_dev_stop(eth_dev);
 
+       rte_vhost_driver_unregister(internal->iface_name);
+
+       if (rte_atomic16_sub_return(&nb_started_ports, 1) == 0)
+               vhost_driver_session_stop();
+
        rte_free(vring_states[eth_dev->data->port_id]);
        vring_states[eth_dev->data->port_id] = NULL;
 
@@ -1243,7 +1249,8 @@ static struct rte_vdev_driver pmd_vhost_drv = {
        .remove = rte_pmd_vhost_remove,
 };
 
-DRIVER_REGISTER_VDEV(net_vhost, pmd_vhost_drv);
-DRIVER_REGISTER_PARAM_STRING(net_vhost,
+RTE_PMD_REGISTER_VDEV(net_vhost, pmd_vhost_drv);
+RTE_PMD_REGISTER_ALIAS(net_vhost, eth_vhost);
+RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
        "iface=<ifc> "
        "queues=<int>");