DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com,
	jfreimann@redhat.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [RFC 1/2] vhost: add packed ring support to vring base requests
Date: Wed,  8 Aug 2018 17:23:22 +0200	[thread overview]
Message-ID: <20180808152323.9660-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20180808152323.9660-1-maxime.coquelin@redhat.com>

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>
---
 lib/librte_vhost/vhost_user.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index a2d4c9ffc..31cfdf163 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -648,10 +648,15 @@ static int
 vhost_user_set_vring_base(struct virtio_net *dev,
 			  VhostUserMsg *msg)
 {
-	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 0;
 }
@@ -1083,6 +1088,9 @@ vhost_user_get_vring_base(struct virtio_net *dev,
 	/* 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);
-- 
2.17.1

  reply	other threads:[~2018-08-08 15:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08 15:23 [dpdk-dev] [RFC 0/2] vhost: packed ring support completion Maxime Coquelin
2018-08-08 15:23 ` Maxime Coquelin [this message]
2018-08-10  7:09   ` [dpdk-dev] [RFC 1/2] vhost: add packed ring support to vring base requests Jens Freimann
2018-08-14 12:09     ` Maxime Coquelin
2018-08-08 15:23 ` [dpdk-dev] [RFC 2/2] vhost: advertize packed ring layout support Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180808152323.9660-2-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jfreimann@redhat.com \
    --cc=tiwei.bie@intel.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).