|
@@ -896,19 +896,41 @@ static int vhost_vdpa_get_vq_index(struct vhost_dev *dev, int idx)
|
|
|
return idx;
|
|
|
}
|
|
|
|
|
|
-int vhost_vdpa_set_vring_ready(struct vhost_vdpa *v, unsigned idx)
|
|
|
+static int vhost_vdpa_set_vring_enable_one(struct vhost_vdpa *v, unsigned idx,
|
|
|
+ int enable)
|
|
|
{
|
|
|
struct vhost_dev *dev = v->dev;
|
|
|
struct vhost_vring_state state = {
|
|
|
.index = idx,
|
|
|
- .num = 1,
|
|
|
+ .num = enable,
|
|
|
};
|
|
|
int r = vhost_vdpa_call(dev, VHOST_VDPA_SET_VRING_ENABLE, &state);
|
|
|
|
|
|
- trace_vhost_vdpa_set_vring_ready(dev, idx, r);
|
|
|
+ trace_vhost_vdpa_set_vring_enable_one(dev, idx, enable, r);
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
+static int vhost_vdpa_set_vring_enable(struct vhost_dev *dev, int enable)
|
|
|
+{
|
|
|
+ struct vhost_vdpa *v = dev->opaque;
|
|
|
+ unsigned int i;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ for (i = 0; i < dev->nvqs; ++i) {
|
|
|
+ ret = vhost_vdpa_set_vring_enable_one(v, i, enable);
|
|
|
+ if (ret < 0) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int vhost_vdpa_set_vring_ready(struct vhost_vdpa *v, unsigned idx)
|
|
|
+{
|
|
|
+ return vhost_vdpa_set_vring_enable_one(v, idx, 1);
|
|
|
+}
|
|
|
+
|
|
|
static int vhost_vdpa_set_config_call(struct vhost_dev *dev,
|
|
|
int fd)
|
|
|
{
|
|
@@ -1536,6 +1558,7 @@ const VhostOps vdpa_ops = {
|
|
|
.vhost_set_features = vhost_vdpa_set_features,
|
|
|
.vhost_reset_device = vhost_vdpa_reset_device,
|
|
|
.vhost_get_vq_index = vhost_vdpa_get_vq_index,
|
|
|
+ .vhost_set_vring_enable = vhost_vdpa_set_vring_enable,
|
|
|
.vhost_get_config = vhost_vdpa_get_config,
|
|
|
.vhost_set_config = vhost_vdpa_set_config,
|
|
|
.vhost_requires_shm_log = NULL,
|