ethdev: use constants for link state
[dpdk.git] / drivers / net / vhost / rte_eth_vhost.c
index 4ee10c1..4cc6bec 100644 (file)
@@ -88,6 +88,7 @@ struct vhost_queue {
 struct pmd_internal {
        char *dev_name;
        char *iface_name;
+       uint16_t max_queues;
 
        volatile uint16_t once;
 };
@@ -109,7 +110,7 @@ static pthread_t session_th;
 static struct rte_eth_link pmd_link = {
                .link_speed = 10000,
                .link_duplex = ETH_LINK_FULL_DUPLEX,
-               .link_status = 0
+               .link_status = ETH_LINK_DOWN
 };
 
 struct rte_vhost_vring_state {
@@ -264,7 +265,7 @@ new_device(struct virtio_net *dev)
 
        dev->flags |= VIRTIO_DEV_RUNNING;
        dev->priv = eth_dev;
-       eth_dev->data->dev_link.link_status = 1;
+       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];
@@ -322,7 +323,7 @@ destroy_device(volatile struct virtio_net *dev)
                        rte_pause();
        }
 
-       eth_dev->data->dev_link.link_status = 0;
+       eth_dev->data->dev_link.link_status = ETH_LINK_DOWN;
 
        dev->priv = NULL;
        dev->flags &= ~VIRTIO_DEV_RUNNING;
@@ -554,11 +555,19 @@ static void
 eth_dev_info(struct rte_eth_dev *dev,
             struct rte_eth_dev_info *dev_info)
 {
+       struct pmd_internal *internal;
+
+       internal = dev->data->dev_private;
+       if (internal == NULL) {
+               RTE_LOG(ERR, PMD, "Invalid device specified\n");
+               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 = dev->data->nb_rx_queues;
-       dev_info->max_tx_queues = dev->data->nb_tx_queues;
+       dev_info->max_rx_queues = internal->max_queues;
+       dev_info->max_tx_queues = internal->max_queues;
        dev_info->min_rx_bufsize = 0;
 }
 
@@ -750,6 +759,7 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues,
        memmove(data->name, eth_dev->data->name, sizeof(data->name));
        data->nb_rx_queues = queues;
        data->nb_tx_queues = queues;
+       internal->max_queues = queues;
        data->dev_link = pmd_link;
        data->mac_addrs = eth_addr;