From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: dev@dpdk.org, jfreimann@redhat.com, tiwei.bie@intel.com,
zhihong.wang@intel.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [dpdk-dev] [PATCH 1/2] vhost: add packed ring support to vring base requests
Date: Tue, 2 Oct 2018 15:30:25 +0200 [thread overview]
Message-ID: <20181002133026.21527-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20181002133026.21527-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>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
---
lib/librte_vhost/vhost_user.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
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);
--
2.17.1
next prev parent reply other threads:[~2018-10-02 13:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-02 13:30 [dpdk-dev] [PATCH 0/2] vhost: packed ring support completion Maxime Coquelin
2018-10-02 13:30 ` Maxime Coquelin [this message]
2018-10-02 13:30 ` [dpdk-dev] [PATCH 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=20181002133026.21527-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).