|
|
b448bf |
From: Jason Wang <jasowang@redhat.com>
|
|
|
b448bf |
Date: Fri, 25 Sep 2015 13:21:29 +0800
|
|
|
b448bf |
Subject: [PATCH] virtio: introduce virtqueue_discard()
|
|
|
b448bf |
|
|
|
b448bf |
This patch introduces virtqueue_discard() to discard a descriptor and
|
|
|
b448bf |
unmap the sgs. This will be used by the patch that will discard
|
|
|
b448bf |
descriptor when packet is truncated.
|
|
|
b448bf |
|
|
|
b448bf |
Cc: Michael S. Tsirkin <mst@redhat.com>
|
|
|
b448bf |
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
|
b448bf |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
b448bf |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
b448bf |
|
|
|
b448bf |
(cherry picked from commit 29b9f5efd78ae0f9cc02dd169b6e80d2c404bade)
|
|
|
b448bf |
---
|
|
|
b448bf |
hw/virtio/virtio.c | 7 +++++++
|
|
|
b448bf |
include/hw/virtio/virtio.h | 2 ++
|
|
|
b448bf |
2 files changed, 9 insertions(+)
|
|
|
b448bf |
|
|
|
b448bf |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
b448bf |
index 242aecb..b1f4e16 100644
|
|
|
b448bf |
--- a/hw/virtio/virtio.c
|
|
|
b448bf |
+++ b/hw/virtio/virtio.c
|
|
|
b448bf |
@@ -266,6 +266,13 @@ static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
b448bf |
0, elem->out_sg[i].iov_len);
|
|
|
b448bf |
}
|
|
|
b448bf |
|
|
|
b448bf |
+void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
b448bf |
+ unsigned int len)
|
|
|
b448bf |
+{
|
|
|
b448bf |
+ vq->last_avail_idx--;
|
|
|
b448bf |
+ virtqueue_unmap_sg(vq, elem, len);
|
|
|
b448bf |
+}
|
|
|
b448bf |
+
|
|
|
b448bf |
void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
b448bf |
unsigned int len, unsigned int idx)
|
|
|
b448bf |
{
|
|
|
b448bf |
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
|
|
|
b448bf |
index cccae89..8023bde 100644
|
|
|
b448bf |
--- a/include/hw/virtio/virtio.h
|
|
|
b448bf |
+++ b/include/hw/virtio/virtio.h
|
|
|
b448bf |
@@ -146,6 +146,8 @@ void virtio_del_queue(VirtIODevice *vdev, int n);
|
|
|
b448bf |
void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
b448bf |
unsigned int len);
|
|
|
b448bf |
void virtqueue_flush(VirtQueue *vq, unsigned int count);
|
|
|
b448bf |
+void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
b448bf |
+ unsigned int len);
|
|
|
b448bf |
void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
|
|
|
b448bf |
unsigned int len, unsigned int idx);
|
|
|
b448bf |
|