]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/spdk/lib/vhost/rte_vhost/vhost.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / lib / vhost / rte_vhost / vhost.c
index 9d4ae71b3cf062f46324f959deba7545c48c44cf..61cbb1209464f35c1f26019ca27e3d8c45b9d15f 100644 (file)
@@ -181,7 +181,7 @@ reset_device(struct virtio_net *dev)
  * there is a new virtio device being attached).
  */
 int
-vhost_new_device(uint64_t features)
+vhost_new_device(uint64_t features, struct vhost_device_ops const *ops)
 {
        struct virtio_net *dev;
        int i;
@@ -207,6 +207,7 @@ vhost_new_device(uint64_t features)
        vhost_devices[i] = dev;
        dev->vid = i;
        dev->features = features;
+       dev->notify_ops = ops;
 
        return i;
 }
@@ -386,9 +387,6 @@ rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx,
        vring->kickfd  = vq->kickfd;
        vring->size    = vq->size;
 
-       vring->last_avail_idx = vq->last_avail_idx;
-       vring->last_used_idx = vq->last_used_idx;
-
        return 0;
 }
 
@@ -459,8 +457,9 @@ rte_vhost_log_used_vring(int vid, uint16_t vring_idx,
 }
 
 int
-rte_vhost_set_vhost_vring_last_idx(int vid, uint16_t vring_idx,
-                             uint16_t last_avail_idx, uint16_t last_used_idx) {
+rte_vhost_set_vring_base(int vid, uint16_t vring_idx,
+               uint16_t last_avail_idx, uint16_t last_used_idx)
+{
        struct virtio_net *dev;
        struct vhost_virtqueue *vq;
 
@@ -480,3 +479,52 @@ rte_vhost_set_vhost_vring_last_idx(int vid, uint16_t vring_idx,
 
        return 0;
 }
+
+int
+rte_vhost_get_vring_base(int vid, uint16_t vring_idx,
+               uint16_t *last_avail_idx, uint16_t *last_used_idx)
+{
+       struct virtio_net *dev;
+       struct vhost_virtqueue *vq;
+
+       dev = get_device(vid);
+       if (!dev)
+               return -1;
+
+       if (vring_idx >= VHOST_MAX_VRING)
+               return -1;
+
+       vq = dev->virtqueue[vring_idx];
+       if (!vq)
+               return -1;
+
+       *last_avail_idx = vq->last_avail_idx;
+       *last_used_idx = vq->last_used_idx;
+
+       return 0;
+}
+
+int
+rte_vhost_vring_call(int vid, uint16_t vring_idx)
+{
+       struct virtio_net *dev;
+       struct vhost_virtqueue *vq;
+
+       dev = get_device(vid);
+       if(!dev)
+               return -1;
+
+       if (vring_idx >= VHOST_MAX_VRING)
+               return -1;
+
+       vq = dev->virtqueue[vring_idx];
+       if (!vq)
+               return -1;
+
+       if (vq->callfd != -1) {
+               eventfd_write(vq->callfd, (eventfd_t)1);
+               return 0;
+       }
+
+       return -1;
+}