[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/4] move virtqueue_unmap_sg calls from virtqueue_fill to virtqueue_push
Move the two virtqueue_unmap_sg calls from virtqueue_fill to virtqueue_push: most virtio drivers simply call virtqueue_push so they are unaffected. virtio-net calls virtqueue_fill directly, so we need to make the two virtqueue_unmap_sg calls explicitely there. Also replace the virtqueue_push call from virtio_net_handle_ctrl with an open coded version it in place. No functional changes. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> CC: jasowang@xxxxxxxxxx CC: wency@xxxxxxxxxxxxxx CC: mst@xxxxxxxxxx CC: pbonzini@xxxxxxxxxx --- hw/net/virtio-net.c | 7 ++++++- hw/virtio/virtio.c | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2ac6ce5..5035313 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -803,7 +803,10 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) s = iov_from_buf(elem.in_sg, elem.in_num, 0, &status, sizeof(status)); assert(s == sizeof(status)); - virtqueue_push(vq, &elem, sizeof(status)); + virtqueue_unmap_sg(elem.in_sg, elem.in_num, 1, sizeof(status)); + virtqueue_unmap_sg(elem.out_sg, elem.out_num, 0, UINT_MAX); + virtqueue_fill(vq, &elem, sizeof(status), 0); + virtqueue_flush(vq, 1); virtio_notify(vdev, vq); } } @@ -1052,6 +1055,8 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t } /* signal other side */ + virtqueue_unmap_sg(elem.in_sg, elem.in_num, 1, total); + virtqueue_unmap_sg(elem.out_sg, elem.out_num, 0, UINT_MAX); virtqueue_fill(q->rx_vq, &elem, total, i++); } diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 4af31d0..0a6583a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -240,9 +240,6 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem, { trace_virtqueue_fill(vq, elem, len, idx); - virtqueue_unmap_sg(elem->in_sg, elem->in_num, 1, len); - virtqueue_unmap_sg(elem->out_sg, elem->out_num, 0, UINT_MAX); - idx = (idx + vring_used_idx(vq)) % vq->vring.num; /* Get a pointer to the next entry in the used ring. */ @@ -267,6 +264,8 @@ void virtqueue_flush(VirtQueue *vq, unsigned int count) void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len) { + virtqueue_unmap_sg(elem->in_sg, elem->in_num, 1, len); + virtqueue_unmap_sg(elem->out_sg, elem->out_num, 0, UINT_MAX); virtqueue_fill(vq, elem, len, 0); virtqueue_flush(vq, 1); } -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |