提交 e78a2b42 编写于 作者: J Jason Wang 提交者: Anthony Liguori

virtio: add a queue_index to VirtQueue

Add a queue_index to VirtQueue and a helper to fetch it, this could be used by
multiqueue supported device.
Signed-off-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 f23fd811
...@@ -73,6 +73,8 @@ struct VirtQueue ...@@ -73,6 +73,8 @@ struct VirtQueue
/* Notification enabled? */ /* Notification enabled? */
bool notification; bool notification;
uint16_t queue_index;
int inuse; int inuse;
uint16_t vector; uint16_t vector;
...@@ -931,6 +933,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, ...@@ -931,6 +933,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) { for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
vdev->vq[i].vector = VIRTIO_NO_VECTOR; vdev->vq[i].vector = VIRTIO_NO_VECTOR;
vdev->vq[i].vdev = vdev; vdev->vq[i].vdev = vdev;
vdev->vq[i].queue_index = i;
} }
vdev->name = name; vdev->name = name;
...@@ -1018,6 +1021,11 @@ VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n) ...@@ -1018,6 +1021,11 @@ VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n)
return vdev->vq + n; return vdev->vq + n;
} }
uint16_t virtio_get_queue_index(VirtQueue *vq)
{
return vq->queue_index;
}
static void virtio_queue_guest_notifier_read(EventNotifier *n) static void virtio_queue_guest_notifier_read(EventNotifier *n)
{ {
VirtQueue *vq = container_of(n, VirtQueue, guest_notifier); VirtQueue *vq = container_of(n, VirtQueue, guest_notifier);
......
...@@ -280,6 +280,7 @@ hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n); ...@@ -280,6 +280,7 @@ hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n);
uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n); uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n);
void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx); void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n); VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n);
uint16_t virtio_get_queue_index(VirtQueue *vq);
int virtio_queue_get_id(VirtQueue *vq); int virtio_queue_get_id(VirtQueue *vq);
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq); EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign, void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册