net/virtio: make interrupt handling more generic
[dpdk.git] / drivers / net / virtio / virtio_user_ethdev.c
index ed069a3..add9774 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "virtio_ethdev.h"
 #include "virtio_logs.h"
-#include "virtio_pci.h"
+#include "virtio.h"
 #include "virtqueue.h"
 #include "virtio_rxtx.h"
 #include "virtio_user/virtio_user_dev.h"
@@ -79,11 +79,11 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
        dev->vhostfd = connectfd;
        old_status = dev->status;
 
-       vtpci_reset(hw);
+       virtio_reset(hw);
 
-       vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
+       virtio_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
 
-       vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
+       virtio_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
 
        if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
                                   &dev->device_features) < 0) {
@@ -122,17 +122,17 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
        dev->features &= dev->device_features;
 
        /* For packed ring, resetting queues is required in reconnection. */
-       if (vtpci_packed_queue(hw) &&
+       if (virtio_with_packed_queue(hw) &&
           (old_status & VIRTIO_CONFIG_STATUS_DRIVER_OK)) {
                PMD_INIT_LOG(NOTICE, "Packets on the fly will be dropped"
                                " when packed ring reconnecting.");
                virtio_user_reset_queues_packed(eth_dev);
        }
 
-       vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_FEATURES_OK);
+       virtio_set_status(hw, VIRTIO_CONFIG_STATUS_FEATURES_OK);
 
        /* Start the device */
-       vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER_OK);
+       virtio_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER_OK);
        if (!dev->started)
                return -1;
 
@@ -339,7 +339,7 @@ virtio_user_get_isr(struct virtio_hw *hw __rte_unused)
        /* rxq interrupts and config interrupt are separated in virtio-user,
         * here we only report config change.
         */
-       return VIRTIO_PCI_ISR_CONFIG;
+       return VIRTIO_ISR_CONFIG;
 }
 
 static uint16_t
@@ -423,7 +423,7 @@ virtio_user_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
        struct virtio_user_dev *dev = virtio_user_get_dev(hw);
 
-       if (vtpci_packed_queue(hw))
+       if (virtio_with_packed_queue(hw))
                virtio_user_setup_queue_packed(vq, dev);
        else
                virtio_user_setup_queue_split(vq, dev);
@@ -456,7 +456,7 @@ virtio_user_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
        struct virtio_user_dev *dev = virtio_user_get_dev(hw);
 
        if (hw->cvq && (hw->cvq->vq == vq)) {
-               if (vtpci_packed_queue(vq->hw))
+               if (virtio_with_packed_queue(vq->hw))
                        virtio_user_handle_cq_packed(dev, vq->vq_queue_index);
                else
                        virtio_user_handle_cq(dev, vq->vq_queue_index);
@@ -478,7 +478,7 @@ virtio_user_dev_close(struct virtio_hw *hw)
        return 0;
 }
 
-const struct virtio_pci_ops virtio_user_ops = {
+const struct virtio_ops virtio_user_ops = {
        .read_dev_cfg   = virtio_user_read_dev_config,
        .write_dev_cfg  = virtio_user_write_dev_config,
        .get_status     = virtio_user_get_status,
@@ -635,13 +635,9 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev)
 
        hw->port_id = data->port_id;
        dev->port_id = data->port_id;
-       virtio_hw_internal[hw->port_id].vtpci_ops = &virtio_user_ops;
-       /*
-        * MSIX is required to enable LSC (see virtio_init_device).
-        * Here just pretend that we support msix.
-        */
-       hw->use_msix = 1;
-       hw->bus_type = VIRTIO_BUS_USER;
+       VIRTIO_OPS(hw) = &virtio_user_ops;
+
+       hw->intr_lsc = 1;
        hw->use_vec_rx = 0;
        hw->use_vec_tx = 0;
        hw->use_inorder_rx = 0;
@@ -691,6 +687,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)
                        return -1;
                }
 
+               dev = eth_dev->data->dev_private;
+               hw = &dev->hw;
+               VIRTIO_OPS(hw) = &virtio_user_ops;
+
                if (eth_virtio_dev_init(eth_dev) < 0) {
                        PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails");
                        rte_eth_dev_release_port(eth_dev);