Change order of initialiazation to match Linux kernel. Don't blow away control queue by doing reset when stopped. Signed-off-by: Stephen Hemminger --- lib/librte_pmd_virtio/virtio_ethdev.c | 50 ++++++++++------------------------ lib/librte_pmd_virtio/virtio_rxtx.c | 2 + 2 files changed, 18 insertions(+), 34 deletions(-) --- a/lib/librte_pmd_virtio/virtio_ethdev.c 2014-08-25 19:00:11.062556360 -0700 +++ b/lib/librte_pmd_virtio/virtio_ethdev.c 2014-08-25 19:00:12.122562032 -0700 @@ -394,9 +394,11 @@ virtio_dev_cq_queue_setup(struct rte_eth static void virtio_dev_close(struct rte_eth_dev *dev) { - PMD_INIT_LOG(DEBUG, "virtio_dev_close"); + struct virtio_hw *hw = dev->data->dev_private; - virtio_dev_stop(dev); + vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR); + vtpci_reset(hw); + virtio_dev_free_mbufs(dev); } /* @@ -811,6 +813,9 @@ eth_virtio_dev_init(__rte_unused struct if (rte_eal_process_type() == RTE_PROC_SECONDARY) return 0; + /* Tell the host we've noticed this device. */ + vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); + pci_dev = eth_dev->pci_dev; if (virtio_resource_init(pci_dev) < 0) return -1; @@ -821,9 +826,6 @@ eth_virtio_dev_init(__rte_unused struct /* Reset the device although not necessary at startup */ vtpci_reset(hw); - /* Tell the host we've noticed this device. */ - vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); - /* Tell the host we've known how to drive the device. */ vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER); virtio_negotiate_features(hw); @@ -912,6 +914,9 @@ eth_virtio_dev_init(__rte_unused struct /* Setup interrupt callback */ rte_intr_callback_register(&pci_dev->intr_handle, virtio_interrupt_handler, eth_dev); + + virtio_dev_cq_start(eth_dev); + return 0; } @@ -982,19 +987,8 @@ virtio_dev_configure(struct rte_eth_dev static int virtio_dev_start(struct rte_eth_dev *dev) { - uint16_t nb_queues, i; struct virtio_hw *hw = dev->data->dev_private; - - /* Tell the host we've noticed this device. */ - vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); - - /* Tell the host we've known how to drive the device. */ - vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER); - - virtio_dev_cq_start(dev); - - /* Do final configuration before rx/tx engine starts */ - virtio_dev_rxtx_start(dev); + uint16_t nb_queues; /* check if lsc interrupt feature is enabled */ if (dev->data->dev_conf.intr_conf.lsc) { @@ -1024,18 +1018,8 @@ virtio_dev_start(struct rte_eth_dev *dev return -EINVAL; } - PMD_INIT_LOG(DEBUG, "nb_queues=%d", nb_queues); - - for (i = 0; i < nb_queues; i++) - virtqueue_notify(dev->data->rx_queues[i]); - - PMD_INIT_LOG(DEBUG, "Notified backend at initialization"); - - for (i = 0; i < dev->data->nb_rx_queues; i++) - VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]); - - for (i = 0; i < dev->data->nb_tx_queues; i++) - VIRTQUEUE_DUMP((struct virtqueue *)dev->data->tx_queues[i]); + /* Do final configuration before rx/tx engine starts */ + virtio_dev_rxtx_start(dev); return 0; } @@ -1089,12 +1073,10 @@ static void virtio_dev_free_mbufs(struct static void virtio_dev_stop(struct rte_eth_dev *dev) { - struct virtio_hw *hw = dev->data->dev_private; + if (dev->data->dev_conf.intr_conf.lsc) + rte_intr_disable(&dev->pci_dev->intr_handle); - /* reset the NIC */ - vtpci_irq_config(hw, 0); - vtpci_reset(hw); - virtio_dev_free_mbufs(dev); + memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link)); } static int --- a/lib/librte_pmd_virtio/virtio_rxtx.c 2014-08-25 19:00:11.062556360 -0700 +++ b/lib/librte_pmd_virtio/virtio_rxtx.c 2014-08-25 19:00:11.062556360 -0700 @@ -350,6 +350,8 @@ virtio_dev_rxtx_start(struct rte_eth_dev for (i = 0; i < dev->data->nb_rx_queues; i++) { virtio_dev_vring_start(dev->data->rx_queues[i], VTNET_RQ); VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]); + + virtqueue_notify(dev->data->rx_queues[i]); } /* Start tx vring. */