Commit 23750e39 authored by Eli Cohen's avatar Eli Cohen Committed by Michael S. Tsirkin
Browse files

vdpa: Modify get_vq_state() to return error code



Modify get_vq_state() so it returns an error code. In case of hardware
acceleration, the available index may be retrieved from the device, an
operation that can possibly fail.

Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Link: https://lore.kernel.org/r/20200804162048.22587-9-eli@mellanox.com


Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent aac50c0b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -237,12 +237,13 @@ static u16 ifcvf_vdpa_get_vq_num_max(struct vdpa_device *vdpa_dev)
	return IFCVF_QUEUE_MAX;
}

static void ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
static int ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
				   struct vdpa_vq_state *state)
{
	struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);

	state->avail_index = ifcvf_get_vq_state(vf, qid);
	return 0;
}

static int ifcvf_vdpa_set_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
+3 −2
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ static int vdpasim_set_vq_state(struct vdpa_device *vdpa, u16 idx,
	return 0;
}

static void vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
static int vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
				struct vdpa_vq_state *state)
{
	struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
@@ -472,6 +472,7 @@ static void vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
	struct vringh *vrh = &vq->vring;

	state->avail_index = vrh->last_avail_idx;
	return 0;
}

static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)
+4 −1
Original line number Diff line number Diff line
@@ -375,7 +375,10 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
		ops->set_vq_ready(vdpa, idx, s.num);
		return 0;
	case VHOST_GET_VRING_BASE:
		ops->get_vq_state(v->vdpa, idx, &vq_state);
		r = ops->get_vq_state(v->vdpa, idx, &vq_state);
		if (r)
			return r;

		vq->last_avail_idx = vq_state.avail_index;
		break;
	case VHOST_GET_BACKEND_FEATURES:
+2 −2
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ struct vdpa_config_ops {
	bool (*get_vq_ready)(struct vdpa_device *vdev, u16 idx);
	int (*set_vq_state)(struct vdpa_device *vdev, u16 idx,
			    const struct vdpa_vq_state *state);
	void (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
	int (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
			    struct vdpa_vq_state *state);
	struct vdpa_notification_area
	(*get_vq_notification)(struct vdpa_device *vdev, u16 idx);