From patchwork Tue Jul 16 12:25:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18381 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 556DC2397D for ; Tue, 16 Jul 2013 12:54:22 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 13sf958352lba.1 for ; Tue, 16 Jul 2013 05:54:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=5VlDHueoeWjpWuFg3hKOEjlHhMjyKMQP8dUHkXYvWZk=; b=CcwHxWNSkVvVGYJ/3rZoLsw09YqFAXAH+APqn0kRyXIsbp7oi/hUiURa+5HSq1wFj4 JvdGKQP//GHIfZVNpnqc25jOYrdmOM4SiAX2PEa1ghGNhVZFU7k8LhZjxgct726+4lA8 yQWfSI55KvdqHSMbaLGg/47zMf4YUB6i5ZnDih0S9gwknV+PuRlJmFXs9QtORSwU2cUU /as1CEtDHRvy5qWeoTLjpoZRchkDhIA3Z8k0v1pS+9ha39iJrZxzye+/UHriJ5KA2G01 ceQ8Ybhaq06LG+cDCGIMYBTVWzQ7d/ZBLHu2SSoB7aspQbiN1un2CaD6mNbgbz5pkmGo EtzQ== X-Received: by 10.180.185.132 with SMTP id fc4mr822673wic.7.1373979260517; Tue, 16 Jul 2013 05:54:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.181.12.5 with SMTP id em5ls528519wid.28.canary; Tue, 16 Jul 2013 05:54:20 -0700 (PDT) X-Received: by 10.180.9.242 with SMTP id d18mr12198680wib.18.1373979260326; Tue, 16 Jul 2013 05:54:20 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id mw5si554914wib.24.2013.07.16.05.54.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Jul 2013 05:54:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id pa12so444737veb.25 for ; Tue, 16 Jul 2013 05:54:19 -0700 (PDT) X-Received: by 10.52.164.16 with SMTP id ym16mr337763vdb.32.1373979259241; Tue, 16 Jul 2013 05:54:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.149.77 with SMTP id s13csp118525vcv; Tue, 16 Jul 2013 05:54:18 -0700 (PDT) X-Received: by 10.15.27.195 with SMTP id p43mr1616702eeu.5.1373979257716; Tue, 16 Jul 2013 05:54:17 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id j47si1180285eeg.198.2013.07.16.05.54.16 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 16 Jul 2013 05:54:17 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Uz4Jd-0007XJ-7H; Tue, 16 Jul 2013 13:25:13 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvmarm@lists.cs.columbia.edu, Anthony Liguori , Alexander Graf , KONRAD Frederic , David Gibson , Peter Crosthwaite Subject: [PATCH v3 3/8] virtio: Add support for guest setting of queue size Date: Tue, 16 Jul 2013 13:25:07 +0100 Message-Id: <1373977512-28932-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373977512-28932-1-git-send-email-peter.maydell@linaro.org> References: <1373977512-28932-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQlYMc+hNdFJlRAwzKKpTWATv5HlSeTNW5J8REL3gv0K4fouCtgmzhf4yNStGO2yT0yQlLH8 X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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/virtio.c | 8 ++++++++ include/hw/virtio/virtio.h | 1 + 2 files changed, 9 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8176c14..01b05f3 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -667,6 +667,14 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n) return vdev->vq[n].pa; } +void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) +{ + if (num <= VIRTQUEUE_MAX_SIZE) { + 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/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index a6c5c53..95c4772 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -198,6 +198,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, hwaddr addr); hwaddr 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);