static void
virtio_dev_close(struct rte_eth_dev *dev)
{
+ struct virtio_hw *hw = dev->data->dev_private;
+
PMD_INIT_LOG(DEBUG, "virtio_dev_close");
- virtio_dev_stop(dev);
+ /* reset the NIC */
+ vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
+ vtpci_reset(hw);
+ hw->started = 0;
+ virtio_dev_free_mbufs(dev);
}
static void
/* Setup interrupt callback */
rte_intr_callback_register(&pci_dev->intr_handle,
virtio_interrupt_handler, eth_dev);
+
+ virtio_dev_cq_start(eth_dev);
+
return 0;
}
{
const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
struct virtio_hw *hw = dev->data->dev_private;
- int ret;
PMD_INIT_LOG(DEBUG, "configure");
hw->vlan_strip = rxmode->hw_vlan_strip;
- ret = vtpci_irq_config(hw, 0);
- if (ret != 0)
+ if (vtpci_irq_config(hw, 0) == VIRTIO_MSI_NO_VECTOR) {
PMD_DRV_LOG(ERR, "failed to set config vector");
+ return -EBUSY;
+ }
- return ret;
+ return 0;
}
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);
-
/* check if lsc interrupt feature is enabled */
if (dev->data->dev_conf.intr_conf.lsc) {
if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {
/* Initialize Link state */
virtio_dev_link_update(dev, 0);
+ /* On restart after stop do not touch queues */
+ if (hw->started)
+ return 0;
+
+ /* Do final configuration before rx/tx engine starts */
+ virtio_dev_rxtx_start(dev);
vtpci_reinit_complete(hw);
+ hw->started = 1;
+
/*Notify the backend
*Otherwise the tap backend might already stop its queue due to fullness.
*vhost backend will have no chance to be waked up
}
/*
- * Stop device: disable rx and tx functions to allow for reconfiguring.
+ * Stop device: disable interrupt and mark link down
*/
static void
virtio_dev_stop(struct rte_eth_dev *dev)
{
- struct virtio_hw *hw = dev->data->dev_private;
+ struct rte_eth_link link;
- /* reset the NIC */
- vtpci_irq_config(hw, 0);
- vtpci_reset(hw);
- virtio_dev_free_mbufs(dev);
+ PMD_INIT_LOG(DEBUG, "stop");
+
+ if (dev->data->dev_conf.intr_conf.lsc)
+ rte_intr_disable(&dev->pci_dev->intr_handle);
+
+ memset(&link, 0, sizeof(link));
+ virtio_dev_atomic_write_link_status(dev, &link);
}
static int