summaryrefslogtreecommitdiff
path: root/lib/librte_vhost
diff options
context:
space:
mode:
authorMaxime Coquelin <maxime.coquelin@redhat.com>2018-10-31 11:26:39 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2018-11-05 15:01:25 +0100
commit2ce8b8973d2173ba23f54afb9f4122847e6bb1b5 (patch)
tree7070018e11c597cd2bfc364b47439d11255d587a /lib/librte_vhost
parent2a821d81f355a40508c81c006f1e3002a1ba2494 (diff)
downloaddpdk-2ce8b8973d2173ba23f54afb9f4122847e6bb1b5.zip
dpdk-2ce8b8973d2173ba23f54afb9f4122847e6bb1b5.tar.gz
dpdk-2ce8b8973d2173ba23f54afb9f4122847e6bb1b5.tar.xz
vhost: add packed ring support to vring base requests
For packed ring layout, we need save avail index and its wrap counter value. At restore time, the used index and its wrap counter are set to available's ones, as the ring procressing is stopped at vring base get time. Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> Reviewed-by: Jens Freimann <jfreimann@redhat.com> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Diffstat (limited to 'lib/librte_vhost')
-rw-r--r--lib/librte_vhost/vhost_user.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 508228a..cc154f3 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -696,10 +696,27 @@ vhost_user_set_vring_base(struct virtio_net **pdev,
int main_fd __rte_unused)
{
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];
+ uint64_t val = msg->payload.state.num;
+
+ if (vq_is_packed(dev)) {
+ /*
+ * Bit[0:14]: avail index
+ * Bit[15]: avail wrap counter
+ */
+ vq->last_avail_idx = val & 0x7fff;
+ vq->avail_wrap_counter = !!(val & (0x1 << 15));
+ /*
+ * Set used index to same value as available one, as
+ * their values should be the same since ring processing
+ * was stopped at get time.
+ */
+ vq->last_used_idx = vq->last_avail_idx;
+ vq->used_wrap_counter = vq->avail_wrap_counter;
+ } else {
+ vq->last_used_idx = msg->payload.state.num;
+ vq->last_avail_idx = msg->payload.state.num;
+ }
return VH_RESULT_OK;
}
@@ -1208,6 +1225,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
{
struct virtio_net *dev = *pdev;
struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];
+ uint64_t val;
/* We have to stop the queue (virtio) if it is running. */
vhost_destroy_device_notify(dev);
@@ -1215,8 +1233,18 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
dev->flags &= ~VIRTIO_DEV_READY;
dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
- /* Here we are safe to get the last avail index */
- msg->payload.state.num = vq->last_avail_idx;
+ /* Here we are safe to get the indexes */
+ if (vq_is_packed(dev)) {
+ /*
+ * Bit[0:14]: avail index
+ * Bit[15]: avail wrap counter
+ */
+ val = vq->last_avail_idx & 0x7fff;
+ val |= vq->avail_wrap_counter << 15;
+ msg->payload.state.num = val;
+ } else {
+ msg->payload.state.num = vq->last_avail_idx;
+ }
RTE_LOG(INFO, VHOST_CONFIG,
"vring base idx:%d file:%d\n", msg->payload.state.index,