From patchwork Fri Jul 12 20:36:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18346 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f199.google.com (mail-ye0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 51D1625E05 for ; Fri, 12 Jul 2013 20:37:11 +0000 (UTC) Received: by mail-ye0-f199.google.com with SMTP id l8sf10507715yen.2 for ; Fri, 12 Jul 2013 13:37:11 -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=Lqqmnad4EJ9dba9LOuAmmnDOBPG9UG34mFv23wlh/G1NuaVSHyn61XISrQjmKPlyCD aJJHgpV3A7fU758D70+sgHgrM1X8nuk6CvXOahe6mQeGh/iX3LMIX1bdRbyuHLjQB5PK oP8V1mBKR/HrgHILdyXHkx5bXOadJSE+sZ9zVkVVHuUCfWp7DZ4SAySdaGd1KmwQnqBv e9PCsatu7ntzevHvlHQPQaFooO5pRPo9mzGgJLf0DjN5/Mw1mj5hSSO2AfgHIteuCH0k UxREunpi4BQ0WcK07XUS21/m948sjeRkyhft22/8h3HHoJuTpU288s27i9svEmCmN0TQ 1Wzg== X-Received: by 10.236.54.8 with SMTP id h8mr23138189yhc.11.1373661431115; Fri, 12 Jul 2013 13:37:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.162 with SMTP id v2ls3427603qef.8.gmail; Fri, 12 Jul 2013 13:37:11 -0700 (PDT) X-Received: by 10.58.227.198 with SMTP id sc6mr25635834vec.59.1373661431014; Fri, 12 Jul 2013 13:37:11 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id zw14si12678028veb.102.2013.07.12.13.37.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Jul 2013 13:37:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ia10so7998504vcb.14 for ; Fri, 12 Jul 2013 13:37:10 -0700 (PDT) X-Received: by 10.52.91.202 with SMTP id cg10mr21428120vdb.85.1373661430913; Fri, 12 Jul 2013 13:37:10 -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 s13csp147880vcv; Fri, 12 Jul 2013 13:37:10 -0700 (PDT) X-Received: by 10.112.143.162 with SMTP id sf2mr19681698lbb.1.1373661427417; Fri, 12 Jul 2013 13:37:07 -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 u4si16463930lae.108.2013.07.12.13.37.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 12 Jul 2013 13:37:07 -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 1Uxk5P-00069P-6p; Fri, 12 Jul 2013 21:37:03 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori , Alexander Graf , David Gibson , kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 3/8] virtio: Add support for guest setting of queue size Date: Fri, 12 Jul 2013 21:36:57 +0100 Message-Id: <1373661422-23606-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373661422-23606-1-git-send-email-peter.maydell@linaro.org> References: <1373661422-23606-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQnUH74ln25ArHtB4DCnJ02rQH3Uf1rf2xGsgW3SaP7h33qvfJdOUBmIt25RvUEufd5T3sXG X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 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);