- if (vhostfd == -1) {
- for (i = 0; i < dev->max_queue_pairs; ++i) {
- if (dev->vhostfds[i] < 0)
- continue;
-
- ret = ioctl(dev->vhostfds[i], req_kernel, arg);
- if (ret < 0)
- break;
- }
- } else {
- ret = ioctl(vhostfd, req_kernel, arg);
+
+ /* restore index back to queue index */
+ file->index = index;
+
+ return 0;
+}
+
+static int
+vhost_kernel_set_vring_kick(struct virtio_user_dev *dev, struct vhost_vring_file *file)
+{
+ return vhost_kernel_set_vring_file(dev, VHOST_SET_VRING_KICK, file);
+}
+
+static int
+vhost_kernel_set_vring_call(struct virtio_user_dev *dev, struct vhost_vring_file *file)
+{
+ return vhost_kernel_set_vring_file(dev, VHOST_SET_VRING_CALL, file);
+}
+
+static int
+vhost_kernel_set_vring_addr(struct virtio_user_dev *dev, struct vhost_vring_addr *addr)
+{
+ int ret, fd;
+ unsigned int index = addr->index;
+ struct vhost_kernel_data *data = dev->backend_data;
+
+ /* Convert from queue index to queue-pair & offset */
+ fd = data->vhostfds[addr->index / 2];
+ addr->index %= 2;
+
+ ret = vhost_kernel_ioctl(fd, VHOST_SET_VRING_ADDR, addr);
+ if (ret < 0) {
+ PMD_DRV_LOG(ERR, "Failed to set vring address");
+ return -1;