diff mbox

[v1,17/37] vhost-pci-slave/msg: VHOST_USER_SET_VRING_BASE

Message ID 1481971427-11094-18-git-send-email-wei.w.wang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang, Wei W Dec. 17, 2016, 10:43 a.m. UTC
Update last_avail_idx to the head node in the list.

Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
 hw/virtio/vhost-pci-slave.c         | 10 ++++++++++
 include/hw/virtio/vhost-pci-slave.h |  1 +
 2 files changed, 11 insertions(+)
diff mbox

Patch

diff --git a/hw/virtio/vhost-pci-slave.c b/hw/virtio/vhost-pci-slave.c
index 0deab2d..e33c59e 100644
--- a/hw/virtio/vhost-pci-slave.c
+++ b/hw/virtio/vhost-pci-slave.c
@@ -209,6 +209,13 @@  static void vp_slave_set_vring_num(VhostUserMsg *msg)
     pvq_node->vring_num = msg->payload.u64;
 }
 
+static void vp_slave_set_vring_base(VhostUserMsg *msg)
+{
+    PeerVqNode *pvq_node = QLIST_FIRST(&vp_slave->pvq_list);
+
+    pvq_node->last_avail_idx = msg->payload.u64;
+}
+
 static int vp_slave_can_read(void *opaque)
 {
     return VHOST_USER_HDR_SIZE;
@@ -275,6 +282,9 @@  static void vp_slave_read(void *opaque, const uint8_t *buf, int size)
         vp_slave_alloc_pvq_node();
         vp_slave_set_vring_num(&msg);
         break;
+    case VHOST_USER_SET_VRING_BASE:
+        vp_slave_set_vring_base(&msg);
+        break;
     default:
         error_report("vhost-pci-slave does not support msg request = %d",
                      msg.request);
diff --git a/include/hw/virtio/vhost-pci-slave.h b/include/hw/virtio/vhost-pci-slave.h
index fe4824c..cfe4107 100644
--- a/include/hw/virtio/vhost-pci-slave.h
+++ b/include/hw/virtio/vhost-pci-slave.h
@@ -6,6 +6,7 @@ 
 #include "standard-headers/linux/vhost_pci_net.h"
 
 typedef struct PeerVqNode {
+    uint16_t last_avail_idx;
     uint32_t vring_num;
     QLIST_ENTRY(PeerVqNode) node;
 } PeerVqNode;