net/virtio-user: fix Rx interrupts with multi-queue
[dpdk.git] / drivers / net / virtio / virtio_user / vhost_kernel.c
index 768db55..d65f89e 100644 (file)
@@ -101,9 +101,20 @@ vhost_kernel_ioctl(int fd, uint64_t request, void *arg)
 static int
 vhost_kernel_set_owner(struct virtio_user_dev *dev)
 {
+       int ret;
+       uint32_t i;
        struct vhost_kernel_data *data = dev->backend_data;
 
-       return vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_OWNER, NULL);
+       for (i = 0; i < dev->max_queue_pairs; ++i) {
+               if (data->vhostfds[i] < 0)
+                       continue;
+
+               ret = vhost_kernel_ioctl(data->vhostfds[i], VHOST_SET_OWNER, NULL);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
 }
 
 static int
@@ -147,6 +158,8 @@ static int
 vhost_kernel_set_features(struct virtio_user_dev *dev, uint64_t features)
 {
        struct vhost_kernel_data *data = dev->backend_data;
+       uint32_t i;
+       int ret;
 
        /* We don't need memory protection here */
        features &= ~(1ULL << VIRTIO_F_IOMMU_PLATFORM);
@@ -155,7 +168,16 @@ vhost_kernel_set_features(struct virtio_user_dev *dev, uint64_t features)
        features &= ~VHOST_KERNEL_HOST_OFFLOADS_MASK;
        features &= ~(1ULL << VIRTIO_NET_F_MQ);
 
-       return vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_FEATURES, &features);
+       for (i = 0; i < dev->max_queue_pairs; ++i) {
+               if (data->vhostfds[i] < 0)
+                       continue;
+
+               ret = vhost_kernel_ioctl(data->vhostfds[i], VHOST_SET_FEATURES, &features);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
 }
 
 static int
@@ -195,6 +217,7 @@ add_memseg_list(const struct rte_memseg_list *msl, void *arg)
 static int
 vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
 {
+       uint32_t i;
        struct vhost_kernel_data *data = dev->backend_data;
        struct vhost_memory_kernel *vm;
        int ret;
@@ -216,9 +239,14 @@ vhost_kernel_set_memory_table(struct virtio_user_dev *dev)
        if (ret < 0)
                goto err_free;
 
-       ret = vhost_kernel_ioctl(data->vhostfds[0], VHOST_SET_MEM_TABLE, vm);
-       if (ret < 0)
-               goto err_free;
+       for (i = 0; i < dev->max_queue_pairs; ++i) {
+               if (data->vhostfds[i] < 0)
+                       continue;
+
+               ret = vhost_kernel_ioctl(data->vhostfds[i], VHOST_SET_MEM_TABLE, vm);
+               if (ret < 0)
+                       goto err_free;
+       }
 
        free(vm);