net/virtio: add Rx interrupt enable/disable functions
[dpdk.git] / drivers / net / virtio / virtio_ethdev.c
index dfd7e9f..f356cf1 100644 (file)
@@ -489,7 +489,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
         * virtual address. And we need properly set _offset_, please see
         * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information.
         */
-       if (hw->dev)
+       if (!hw->virtio_user_dev)
                vq->offset = offsetof(struct rte_mbuf, buf_physaddr);
        else {
                vq->vq_ring_mem = (uintptr_t)mz->addr;
@@ -602,7 +602,7 @@ virtio_dev_close(struct rte_eth_dev *dev)
 
        /* reset the NIC */
        if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-               vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
+               VTPCI_OPS(hw)->set_config_irq(hw, VIRTIO_MSI_NO_VECTOR);
        vtpci_reset(hw);
        virtio_dev_free_mbufs(dev);
        virtio_free_queues(hw);
@@ -717,6 +717,26 @@ virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
        return 0;
 }
 
+static int
+virtio_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
+{
+       struct virtnet_rx *rxvq = dev->data->rx_queues[queue_id];
+       struct virtqueue *vq = rxvq->vq;
+
+       virtqueue_enable_intr(vq);
+       return 0;
+}
+
+static int
+virtio_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
+{
+       struct virtnet_rx *rxvq = dev->data->rx_queues[queue_id];
+       struct virtqueue *vq = rxvq->vq;
+
+       virtqueue_disable_intr(vq);
+       return 0;
+}
+
 /*
  * dev_ops for virtio, bare necessities for basic operation
  */
@@ -738,7 +758,10 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
        .xstats_reset            = virtio_dev_stats_reset,
        .link_update             = virtio_dev_link_update,
        .rx_queue_setup          = virtio_dev_rx_queue_setup,
+       .rx_queue_intr_enable    = virtio_dev_rx_queue_intr_enable,
+       .rx_queue_intr_disable   = virtio_dev_rx_queue_intr_disable,
        .rx_queue_release        = virtio_dev_queue_release,
+       .rx_descriptor_done      = virtio_dev_rx_queue_done,
        .tx_queue_setup          = virtio_dev_tx_queue_setup,
        .tx_queue_release        = virtio_dev_queue_release,
        /* collect stats per queue */
@@ -1194,7 +1217,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
        struct virtio_hw *hw = eth_dev->data->dev_private;
        struct virtio_net_config *config;
        struct virtio_net_config local_config;
-       struct rte_pci_device *pci_dev = hw->dev;
+       struct rte_pci_device *pci_dev = NULL;
        int ret;
 
        /* Reset the device although not necessary at startup */
@@ -1208,17 +1231,17 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
        if (virtio_negotiate_features(hw, req_features) < 0)
                return -1;
 
+       if (eth_dev->device) {
+               pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
+               rte_eth_copy_pci_info(eth_dev, pci_dev);
+       }
+
        /* If host does not support status then disable LSC */
        if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))
                eth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
        else
                eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
 
-       if (pci_dev) {
-               rte_eth_copy_pci_info(eth_dev, pci_dev);
-               eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
-       }
-
        rx_func_get(eth_dev);
 
        /* Setting up rx_header size for the device */
@@ -1408,8 +1431,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
-       struct virtio_hw *hw = eth_dev->data->dev_private;
-
        PMD_INIT_FUNC_TRACE();
 
        if (rte_eal_process_type() == RTE_PROC_SECONDARY)
@@ -1430,8 +1451,8 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
                rte_intr_callback_unregister(eth_dev->intr_handle,
                                                virtio_interrupt_handler,
                                                eth_dev);
-       if (hw->dev)
-               rte_eal_pci_unmap_device(hw->dev);
+       if (eth_dev->device)
+               rte_eal_pci_unmap_device(RTE_DEV_TO_PCI(eth_dev->device));
 
        PMD_INIT_LOG(DEBUG, "dev_uninit completed");
 
@@ -1522,7 +1543,9 @@ virtio_dev_configure(struct rte_eth_dev *dev)
        }
 
        if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-               if (vtpci_irq_config(hw, 0) == VIRTIO_MSI_NO_VECTOR) {
+               /* Enable vector (0) for Link State Intrerrupt */
+               if (VTPCI_OPS(hw)->set_config_irq(hw, 0) ==
+                               VIRTIO_MSI_NO_VECTOR) {
                        PMD_DRV_LOG(ERR, "failed to set config vector");
                        return -EBUSY;
                }
@@ -1689,7 +1712,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        uint64_t tso_mask;
        struct virtio_hw *hw = dev->data->dev_private;
 
-       dev_info->pci_dev = hw->dev;
+       dev_info->pci_dev = dev->device ? RTE_DEV_TO_PCI(dev->device) : NULL;
        dev_info->max_rx_queues =
                RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES);
        dev_info->max_tx_queues =