diff mbox series

[1/2] vhost: add packed ring support to vring base requests

Message ID 20181002133026.21527-2-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: packed ring support completion | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Maxime Coquelin Oct. 2, 2018, 1:30 p.m. UTC
For consistency with Vhost kernel backend, save the wrap
counter value into bit 31 of num's vring state field.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
---
 lib/librte_vhost/vhost_user.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 7ef3fb4a4..e671ed0ba 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -677,10 +677,16 @@  vhost_user_set_vring_base(struct virtio_net **pdev,
 			  struct VhostUserMsg *msg)
 {
 	struct virtio_net *dev = *pdev;
-	dev->virtqueue[msg->payload.state.index]->last_used_idx  =
-			msg->payload.state.num;
-	dev->virtqueue[msg->payload.state.index]->last_avail_idx =
-			msg->payload.state.num;
+	struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];
+
+	if (dev->features & (1ULL << VIRTIO_F_RING_PACKED)) {
+		vq->avail_wrap_counter = msg->payload.state.num >> 31;
+		vq->used_wrap_counter = vq->avail_wrap_counter;
+		msg->payload.state.num &= ~(1 << 31);
+	}
+
+	vq->last_used_idx = msg->payload.state.num;
+	vq->last_avail_idx = msg->payload.state.num;
 
 	return VH_RESULT_OK;
 }
@@ -1128,6 +1134,9 @@  vhost_user_get_vring_base(struct virtio_net **pdev,
 	/* Here we are safe to get the last avail index */
 	msg->payload.state.num = vq->last_avail_idx;
 
+	if (dev->features & (1ULL << VIRTIO_F_RING_PACKED))
+		msg->payload.state.num |= vq->avail_wrap_counter << 31;
+
 	RTE_LOG(INFO, VHOST_CONFIG,
 		"vring base idx:%d file:%d\n", msg->payload.state.index,
 		msg->payload.state.num);