On Mon, Jun 04, 2018 at 04:54:45AM +0300, Michael S. Tsirkin wrote:
> On Mon, Jun 04, 2018 at 09:34:35AM +0800, Wei Xu wrote:
> > On Tue, Apr 10, 2018 at 03:32:53PM +0800, Jason Wang wrote:
> > > 
> > > 
> > > On 2018年04月04日 20:54, w...@redhat.com wrote:
> > > >From: Wei Xu <w...@redhat.com>
> > > >
> > > >helper for packed ring
> > > 
> > > It's odd and hard to review if you put detach patch first. I think this
> > > patch needs to be reordered after the implementation of pop/map.
> > 
> > This patch is not necessary after sync to tiwei's v5, so we can skip it.
> > 
> > Wei
> 
> I suspect we will need to bring detach back eventually but yes,
> it can wait.

Sure, I reuse the code for 1.0 for now.

Wei

> 
> > > 
> > > Thanks
> > > 
> > > >Signed-off-by: Wei Xu <w...@redhat.com>
> > > >---
> > > >  hw/virtio/virtio.c | 21 +++++++++++++++++++--
> > > >  1 file changed, 19 insertions(+), 2 deletions(-)
> > > >
> > > >diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > > >index 478df3d..fdee40f 100644
> > > >--- a/hw/virtio/virtio.c
> > > >+++ b/hw/virtio/virtio.c
> > > >@@ -561,6 +561,20 @@ static void virtqueue_unmap_sg(VirtQueue *vq, const 
> > > >VirtQueueElement *elem,
> > > >                           elem->out_sg[i].iov_len);
> > > >  }
> > > >+static void virtqueue_detach_element_split(VirtQueue *vq,
> > > >+                            const VirtQueueElement *elem, unsigned int 
> > > >len)
> > > >+{
> > > >+    vq->inuse--;
> > > >+    virtqueue_unmap_sg(vq, elem, len);
> > > >+}
> > > >+
> > > >+static void virtqueue_detach_element_packed(VirtQueue *vq,
> > > >+                            const VirtQueueElement *elem, unsigned int 
> > > >len)
> > > >+{
> > > >+    vq->inuse -= elem->count;
> > > >+    virtqueue_unmap_sg(vq, elem, len);
> > > >+}
> > > >+
> > > >  /* virtqueue_detach_element:
> > > >   * @vq: The #VirtQueue
> > > >   * @elem: The #VirtQueueElement
> > > >@@ -573,8 +587,11 @@ static void virtqueue_unmap_sg(VirtQueue *vq, const 
> > > >VirtQueueElement *elem,
> > > >  void virtqueue_detach_element(VirtQueue *vq, const VirtQueueElement 
> > > > *elem,
> > > >                                unsigned int len)
> > > >  {
> > > >-    vq->inuse--;
> > > >-    virtqueue_unmap_sg(vq, elem, len);
> > > >+    if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) {
> > > >+        virtqueue_detach_element_packed(vq, elem, len);
> > > >+    } else {
> > > >+        virtqueue_detach_element_split(vq, elem, len);
> > > >+    }
> > > >  }
> > > >  /* virtqueue_unpop:
> > > 
> 

Reply via email to