aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_ring.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2012-08-28 07:54:13 -0400
committerRusty Russell <rusty@rustcorp.com.au>2012-09-28 01:35:15 -0400
commit17bb6d40880d4178f5f8a75900ed8c9ff47d3fb2 (patch)
treef9888385b33c144f909eff14713a328dc72296f2 /drivers/virtio/virtio_ring.c
parent7a23eb28fa645f1f0c2ec38274c11bc78c50c047 (diff)
virtio-ring: move queue_index to vring_virtqueue
Instead of storing the queue index in transport-specific virtio structs, this patch moves them to vring_virtqueue and introduces an helper to get the value. This lets drivers simplify their management and tracing of virtqueues. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio_ring.c')
-rw-r--r--drivers/virtio/virtio_ring.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 5aa43c3392a2..e639584b2dbd 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -106,6 +106,9 @@ struct vring_virtqueue
106 /* How to notify other side. FIXME: commonalize hcalls! */ 106 /* How to notify other side. FIXME: commonalize hcalls! */
107 void (*notify)(struct virtqueue *vq); 107 void (*notify)(struct virtqueue *vq);
108 108
109 /* Index of the queue */
110 int queue_index;
111
109#ifdef DEBUG 112#ifdef DEBUG
110 /* They're supposed to lock for us. */ 113 /* They're supposed to lock for us. */
111 unsigned int in_use; 114 unsigned int in_use;
@@ -171,6 +174,13 @@ static int vring_add_indirect(struct vring_virtqueue *vq,
171 return head; 174 return head;
172} 175}
173 176
177int virtqueue_get_queue_index(struct virtqueue *_vq)
178{
179 struct vring_virtqueue *vq = to_vvq(_vq);
180 return vq->queue_index;
181}
182EXPORT_SYMBOL_GPL(virtqueue_get_queue_index);
183
174/** 184/**
175 * virtqueue_add_buf - expose buffer to other end 185 * virtqueue_add_buf - expose buffer to other end
176 * @vq: the struct virtqueue we're talking about. 186 * @vq: the struct virtqueue we're talking about.
@@ -616,7 +626,8 @@ irqreturn_t vring_interrupt(int irq, void *_vq)
616} 626}
617EXPORT_SYMBOL_GPL(vring_interrupt); 627EXPORT_SYMBOL_GPL(vring_interrupt);
618 628
619struct virtqueue *vring_new_virtqueue(unsigned int num, 629struct virtqueue *vring_new_virtqueue(unsigned int index,
630 unsigned int num,
620 unsigned int vring_align, 631 unsigned int vring_align,
621 struct virtio_device *vdev, 632 struct virtio_device *vdev,
622 bool weak_barriers, 633 bool weak_barriers,
@@ -647,6 +658,7 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
647 vq->broken = false; 658 vq->broken = false;
648 vq->last_used_idx = 0; 659 vq->last_used_idx = 0;
649 vq->num_added = 0; 660 vq->num_added = 0;
661 vq->queue_index = index;
650 list_add_tail(&vq->vq.list, &vdev->vqs); 662 list_add_tail(&vq->vq.list, &vdev->vqs);
651#ifdef DEBUG 663#ifdef DEBUG
652 vq->in_use = false; 664 vq->in_use = false;