net/mlx5: prefix all functions with mlx5
[dpdk.git] / lib / librte_vhost / vhost.c
index 1dd9adb..f6f12a0 100644 (file)
@@ -42,7 +42,9 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
        if (tmp_size == size)
                return vva;
 
-       if (!vhost_user_iotlb_pending_miss(vq, iova + tmp_size, perm)) {
+       iova += tmp_size;
+
+       if (!vhost_user_iotlb_pending_miss(vq, iova, perm)) {
                /*
                 * iotlb_lock is read-locked for a full burst,
                 * but it only protects the iotlb cache.
@@ -52,8 +54,13 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
                 */
                vhost_user_iotlb_rd_unlock(vq);
 
-               vhost_user_iotlb_pending_insert(vq, iova + tmp_size, perm);
-               vhost_user_iotlb_miss(dev, iova + tmp_size, perm);
+               vhost_user_iotlb_pending_insert(vq, iova, perm);
+               if (vhost_user_iotlb_miss(dev, iova, perm)) {
+                       RTE_LOG(ERR, VHOST_CONFIG,
+                               "IOTLB miss req failed for IOVA 0x%" PRIx64 "\n",
+                               iova);
+                       vhost_user_iotlb_pending_remove(vq, iova, 1, perm);
+               }
 
                vhost_user_iotlb_rd_lock(vq);
        }
@@ -61,19 +68,6 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
        return 0;
 }
 
-struct virtio_net *
-get_device(int vid)
-{
-       struct virtio_net *dev = vhost_devices[vid];
-
-       if (unlikely(!dev)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%d) device not found.\n", vid);
-       }
-
-       return dev;
-}
-
 void
 cleanup_vq(struct vhost_virtqueue *vq, int destroy)
 {
@@ -251,7 +245,7 @@ reset_device(struct virtio_net *dev)
 
        dev->features = 0;
        dev->protocol_features = 0;
-       dev->flags = 0;
+       dev->flags &= VIRTIO_DEV_BUILTIN_VIRTIO_NET;
 
        for (i = 0; i < dev->nr_vring; i++)
                reset_vring_queue(dev, i);
@@ -287,6 +281,7 @@ vhost_new_device(void)
 
        vhost_devices[i] = dev;
        dev->vid = i;
+       dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
        dev->slave_req_fd = -1;
 
        return i;
@@ -343,6 +338,20 @@ vhost_enable_dequeue_zero_copy(int vid)
        dev->dequeue_zero_copy = 1;
 }
 
+void
+vhost_set_builtin_virtio_net(int vid, bool enable)
+{
+       struct virtio_net *dev = get_device(vid);
+
+       if (dev == NULL)
+               return;
+
+       if (enable)
+               dev->flags |= VIRTIO_DEV_BUILTIN_VIRTIO_NET;
+       else
+               dev->flags &= ~VIRTIO_DEV_BUILTIN_VIRTIO_NET;
+}
+
 int
 rte_vhost_get_mtu(int vid, uint16_t *mtu)
 {