From patchwork Mon Nov 14 14:55:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 125548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AC729B7207 for ; Tue, 15 Nov 2011 01:56:42 +1100 (EST) Received: from localhost ([::1]:53472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPxxb-0005QZ-Rc for incoming@patchwork.ozlabs.org; Mon, 14 Nov 2011 09:56:35 -0500 Received: from eggs.gnu.org ([140.186.70.92]:50885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPxwq-000376-5B for qemu-devel@nongnu.org; Mon, 14 Nov 2011 09:55:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPxwj-00044h-Q9 for qemu-devel@nongnu.org; Mon, 14 Nov 2011 09:55:48 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:59592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPxwj-00041k-If for qemu-devel@nongnu.org; Mon, 14 Nov 2011 09:55:41 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RPxwW-0004y3-Fx; Mon, 14 Nov 2011 14:55:28 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 14 Nov 2011 14:55:25 +0000 Message-Id: <1321282528-19070-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1321282528-19070-1-git-send-email-peter.maydell@linaro.org> References: <1321282528-19070-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Anthony Liguori , Pawel Moll , patches@linaro.org Subject: [Qemu-devel] [RFC 1/4] virtio: Add support for guest setting of queue size 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 The MMIO virtio transport spec allows the guest to tell the host how large the queue size is. Add virtio_queue_set_num() function which implements this in the QEMU common virtio support code. Signed-off-by: Peter Maydell --- hw/virtio.c | 6 ++++++ hw/virtio.h | 1 + 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 7011b5b..5bd43a1 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -619,6 +619,12 @@ target_phys_addr_t virtio_queue_get_addr(VirtIODevice *vdev, int n) return vdev->vq[n].pa; } +void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) +{ + vdev->vq[n].vring.num = num; + virtqueue_init(&vdev->vq[n]); +} + int virtio_queue_get_num(VirtIODevice *vdev, int n) { return vdev->vq[n].vring.num; diff --git a/hw/virtio.h b/hw/virtio.h index 2d18209..352aba6 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -178,6 +178,7 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_queue_set_addr(VirtIODevice *vdev, int n, target_phys_addr_t addr); target_phys_addr_t virtio_queue_get_addr(VirtIODevice *vdev, int n); +void virtio_queue_set_num(VirtIODevice *vdev, int n, int num); int virtio_queue_get_num(VirtIODevice *vdev, int n); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n);