From patchwork Wed Jan 30 11:12:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 216899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B385E2C008E for ; Wed, 30 Jan 2013 23:50:33 +1100 (EST) Received: from localhost ([::1]:39005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0X7X-00088Q-Tb for incoming@patchwork.ozlabs.org; Wed, 30 Jan 2013 07:50:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0X7Q-00087m-0a for qemu-devel@nongnu.org; Wed, 30 Jan 2013 07:50:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U0X7L-0005xT-4t for qemu-devel@nongnu.org; Wed, 30 Jan 2013 07:50:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U0Vlr-0005dd-VB for qemu-devel@nongnu.org; Wed, 30 Jan 2013 06:24:04 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0UBNtah030178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Jan 2013 06:23:55 -0500 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0UBLHRi018213; Wed, 30 Jan 2013 06:23:47 -0500 From: Jason Wang To: aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org, blauwirbel@gmail.com, shajnocz@redhat.com Date: Wed, 30 Jan 2013 19:12:37 +0800 Message-Id: <1359544361-5089-19-git-send-email-jasowang@redhat.com> In-Reply-To: <1359544361-5089-1-git-send-email-jasowang@redhat.com> References: <1359544361-5089-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: krkumar2@in.ibm.com, kvm@vger.kernel.org, mprivozn@redhat.com, Jason Wang , rusty@rustcorp.com.au, shiyer@redhat.com, jwhan@filewood.snu.ac.kr, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH V4 18/22] virtio: add a queue_index to VirtQueue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a queue_index to VirtQueue and a helper to fetch it, this could be used by multiqueue supported device. Signed-off-by: Jason Wang --- hw/virtio.c | 8 ++++++++ hw/virtio.h | 1 + 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index d8c77b0..e259348 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -73,6 +73,8 @@ struct VirtQueue /* Notification enabled? */ bool notification; + uint16_t queue_index; + int inuse; uint16_t vector; @@ -931,6 +933,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) { vdev->vq[i].vector = VIRTIO_NO_VECTOR; vdev->vq[i].vdev = vdev; + vdev->vq[i].queue_index = i; } vdev->name = name; @@ -1018,6 +1021,11 @@ VirtQueue *virtio_get_queue(VirtIODevice *vdev, int 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) { VirtQueue *vq = container_of(n, VirtQueue, guest_notifier); diff --git a/hw/virtio.h b/hw/virtio.h index d3da1d2..a29a54d 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -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); void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx); VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n); +uint16_t virtio_get_queue_index(VirtQueue *vq); int virtio_queue_get_id(VirtQueue *vq); EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq); void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,