From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cornelia Huck Subject: Re: [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout Date: Tue, 2 Dec 2014 15:54:44 +0100 Message-ID: <20141202155444.0731c48f.cornelia.huck@de.ibm.com> References: <1417525227-14051-1-git-send-email-cornelia.huck@de.ibm.com> <1417525227-14051-8-git-send-email-cornelia.huck@de.ibm.com> <20141202144628.GA2974@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: thuth@linux.vnet.ibm.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org To: "Michael S. Tsirkin" Return-path: In-Reply-To: <20141202144628.GA2974@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Id: kvm.vger.kernel.org On Tue, 2 Dec 2014 16:46:28 +0200 "Michael S. Tsirkin" wrote: > On Tue, Dec 02, 2014 at 02:00:15PM +0100, Cornelia Huck wrote: > > For virtio-1 devices, we allow a more complex queue layout that doesn't > > require descriptor table and rings on a physically-contigous memory area: > > add virtio_queue_set_rings() to allow transports to set this up. > > > > Signed-off-by: Cornelia Huck > > --- > > hw/virtio/virtio.c | 16 ++++++++++++++++ > > include/hw/virtio/virtio.h | 2 ++ > > 2 files changed, 18 insertions(+) > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > index 8f69ffa..508dccf 100644 > > --- a/hw/virtio/virtio.c > > +++ b/hw/virtio/virtio.c > > @@ -96,6 +96,13 @@ static void virtqueue_init(VirtQueue *vq) > > { > > hwaddr pa = vq->pa; > > > > + if (pa == -1ULL) { > > + /* > > + * This is a virtio-1 style vq that has already been setup > > + * in virtio_queue_set. > > + */ > > + return; > > + } > > vq->vring.desc = pa; > > vq->vring.avail = pa + vq->vring.num * sizeof(VRingDesc); > > vq->vring.used = vring_align(vq->vring.avail + > > @@ -717,6 +724,15 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n) > > return vdev->vq[n].pa; > > } > > > > +void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc, > > + hwaddr avail, hwaddr used) > > +{ > > + vdev->vq[n].pa = -1ULL; > > + vdev->vq[n].vring.desc = desc; > > + vdev->vq[n].vring.avail = avail; > > + vdev->vq[n].vring.used = used; > > +} > > + > > void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) > > { > > /* Don't allow guest to flip queue between existent and > > pa == -1ULL tricks look quite ugly. > Can't we set desc/avail/used unconditionally, and drop > the pa value? And have virtio_queue_get_addr() return desc? Let me see if I can come up with a patch. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xvor0-0008MX-Q5 for qemu-devel@nongnu.org; Tue, 02 Dec 2014 09:55:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xvoqr-0006G0-Oe for qemu-devel@nongnu.org; Tue, 02 Dec 2014 09:55:02 -0500 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:57264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xvoqr-0006Fa-Fl for qemu-devel@nongnu.org; Tue, 02 Dec 2014 09:54:53 -0500 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Dec 2014 14:54:51 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 24B3C1B0804B for ; Tue, 2 Dec 2014 14:55:08 +0000 (GMT) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sB2Esogp62652434 for ; Tue, 2 Dec 2014 14:54:50 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sB2EsnKH003424 for ; Tue, 2 Dec 2014 07:54:50 -0700 Date: Tue, 2 Dec 2014 15:54:44 +0100 From: Cornelia Huck Message-ID: <20141202155444.0731c48f.cornelia.huck@de.ibm.com> In-Reply-To: <20141202144628.GA2974@redhat.com> References: <1417525227-14051-1-git-send-email-cornelia.huck@de.ibm.com> <1417525227-14051-8-git-send-email-cornelia.huck@de.ibm.com> <20141202144628.GA2974@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC v5 07/19] virtio: allow virtio-1 queue layout List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: thuth@linux.vnet.ibm.com, rusty@rustcorp.com.au, qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org On Tue, 2 Dec 2014 16:46:28 +0200 "Michael S. Tsirkin" wrote: > On Tue, Dec 02, 2014 at 02:00:15PM +0100, Cornelia Huck wrote: > > For virtio-1 devices, we allow a more complex queue layout that doesn't > > require descriptor table and rings on a physically-contigous memory area: > > add virtio_queue_set_rings() to allow transports to set this up. > > > > Signed-off-by: Cornelia Huck > > --- > > hw/virtio/virtio.c | 16 ++++++++++++++++ > > include/hw/virtio/virtio.h | 2 ++ > > 2 files changed, 18 insertions(+) > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > index 8f69ffa..508dccf 100644 > > --- a/hw/virtio/virtio.c > > +++ b/hw/virtio/virtio.c > > @@ -96,6 +96,13 @@ static void virtqueue_init(VirtQueue *vq) > > { > > hwaddr pa = vq->pa; > > > > + if (pa == -1ULL) { > > + /* > > + * This is a virtio-1 style vq that has already been setup > > + * in virtio_queue_set. > > + */ > > + return; > > + } > > vq->vring.desc = pa; > > vq->vring.avail = pa + vq->vring.num * sizeof(VRingDesc); > > vq->vring.used = vring_align(vq->vring.avail + > > @@ -717,6 +724,15 @@ hwaddr virtio_queue_get_addr(VirtIODevice *vdev, int n) > > return vdev->vq[n].pa; > > } > > > > +void virtio_queue_set_rings(VirtIODevice *vdev, int n, hwaddr desc, > > + hwaddr avail, hwaddr used) > > +{ > > + vdev->vq[n].pa = -1ULL; > > + vdev->vq[n].vring.desc = desc; > > + vdev->vq[n].vring.avail = avail; > > + vdev->vq[n].vring.used = used; > > +} > > + > > void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) > > { > > /* Don't allow guest to flip queue between existent and > > pa == -1ULL tricks look quite ugly. > Can't we set desc/avail/used unconditionally, and drop > the pa value? And have virtio_queue_get_addr() return desc? Let me see if I can come up with a patch.