Commit 653055b9 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin

vhost-vdpa: support get/set backend features

This patch makes userspace can get and set backend features to
vhost-vdpa.
Signed-off-by: default avatarCindy Lu <lulu@redhat.com>
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20200804162048.22587-4-eli@mellanox.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 460f7ce1
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
#include "vhost.h" #include "vhost.h"
enum {
VHOST_VDPA_BACKEND_FEATURES = (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)
};
/* Currently, only network backend w/o multiqueue is supported. */ /* Currently, only network backend w/o multiqueue is supported. */
#define VHOST_VDPA_VQ_MAX 2 #define VHOST_VDPA_VQ_MAX 2
...@@ -347,6 +351,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, ...@@ -347,6 +351,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
struct vdpa_callback cb; struct vdpa_callback cb;
struct vhost_virtqueue *vq; struct vhost_virtqueue *vq;
struct vhost_vring_state s; struct vhost_vring_state s;
u64 __user *featurep = argp;
u64 features;
u32 idx; u32 idx;
long r; long r;
...@@ -369,6 +375,18 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, ...@@ -369,6 +375,18 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
case VHOST_GET_VRING_BASE: case VHOST_GET_VRING_BASE:
vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx); vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx);
break; break;
case VHOST_GET_BACKEND_FEATURES:
features = VHOST_VDPA_BACKEND_FEATURES;
if (copy_to_user(featurep, &features, sizeof(features)))
return -EFAULT;
return 0;
case VHOST_SET_BACKEND_FEATURES:
if (copy_from_user(&features, featurep, sizeof(features)))
return -EFAULT;
if (features & ~VHOST_VDPA_BACKEND_FEATURES)
return -EOPNOTSUPP;
vhost_set_backend_features(&v->vdev, features);
return 0;
} }
r = vhost_vring_ioctl(&v->vdev, cmd, argp); r = vhost_vring_ioctl(&v->vdev, cmd, argp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment