diff options
author | Jason Wang <jasowang@redhat.com> | 2015-09-25 13:21:29 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-10-01 16:16:52 +0300 |
commit | 29b9f5efd78ae0f9cc02dd169b6e80d2c404bade (patch) | |
tree | 61adbcab5d9a55d6ee79959d06763bffb5d40193 /hw | |
parent | ce317461573bac12b10d67699b4ddf1f97cf066c (diff) |
virtio: introduce virtqueue_discard()
This patch introduces virtqueue_discard() to discard a descriptor and
unmap the sgs. This will be used by the patch that will discard
descriptor when packet is truncated.
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio/virtio.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6f2b96cc7b..d0bc72e0e4 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -267,6 +267,13 @@ static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem, 0, elem->out_sg[i].iov_len); } +void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem, + unsigned int len) +{ + vq->last_avail_idx--; + virtqueue_unmap_sg(vq, elem, len); +} + void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len, unsigned int idx) { |