From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 493A39406 for ; Thu, 22 Oct 2015 11:50:03 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 22 Oct 2015 02:50:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,181,1444719600"; d="scan'208";a="669427964" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 22 Oct 2015 02:50:03 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Oct 2015 02:50:01 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Oct 2015 02:50:01 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.96]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.47]) with mapi id 14.03.0248.002; Thu, 22 Oct 2015 17:49:59 +0800 From: "Xie, Huawei" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [PATCH v7 3/8] vhost: vring queue setup for multiple queue support Thread-Index: AdEMrwNY9Oub1SqqROWCh55lxkbRvg== Date: Thu, 22 Oct 2015 09:49:58 +0000 Message-ID: References: <1445399294-18826-1-git-send-email-yuanhan.liu@linux.intel.com> <1445399294-18826-4-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "marcel@redhat.com" , "Michael S. Tsirkin" Subject: Re: [dpdk-dev] [PATCH v7 3/8] vhost: vring queue setup for multiple queue support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2015 09:50:03 -0000 On 10/21/2015 11:48 AM, Yuanhan Liu wrote:=0A= > All queue pairs, including the default (the first) queue pair,=0A= > are allocated dynamically, when a vring_call message is received=0A= > first time for a specific queue pair.=0A= >=0A= > This is a refactor work for enabling vhost-user multiple queue;=0A= > it should not break anything as it does no functional changes:=0A= > we don't support mq set, so there is only one mq at max.=0A= >=0A= > This patch is based on Changchun's patch.=0A= >=0A= [...]=0A= > =0A= > void=0A= > @@ -290,13 +298,9 @@ user_get_vring_base(struct vhost_device_ctx ctx,=0A= > * sent and only sent in vhost_vring_stop.=0A= > * TODO: cleanup the vring, it isn't usable since here.=0A= > */=0A= > - if ((dev->virtqueue[VIRTIO_RXQ]->kickfd) >=3D 0) {=0A= > - close(dev->virtqueue[VIRTIO_RXQ]->kickfd);=0A= > - dev->virtqueue[VIRTIO_RXQ]->kickfd =3D -1;=0A= > - }=0A= > - if ((dev->virtqueue[VIRTIO_TXQ]->kickfd) >=3D 0) {=0A= > - close(dev->virtqueue[VIRTIO_TXQ]->kickfd);=0A= > - dev->virtqueue[VIRTIO_TXQ]->kickfd =3D -1;=0A= > + if ((dev->virtqueue[state->index]->kickfd) >=3D 0) {=0A= > + close(dev->virtqueue[state->index]->kickfd);=0A= > + dev->virtqueue[state->index]->kickfd =3D -1;=0A= > }=0A= Since we change the behavior here, better list in the commit message as=0A= well.=0A= =0A= > =0A= > =0A= > @@ -680,13 +704,21 @@ set_vring_call(struct vhost_device_ctx ctx, struct = vhost_vring_file *file)=0A= > {=0A= > struct virtio_net *dev;=0A= > struct vhost_virtqueue *vq;=0A= > + uint32_t cur_qp_idx =3D file->index / VIRTIO_QNUM;=0A= > =0A= > dev =3D get_device(ctx);=0A= > if (dev =3D=3D NULL)=0A= > return -1;=0A= > =0A= > + /* alloc vring queue pair if it is a new queue pair */=0A= > + if (cur_qp_idx + 1 > dev->virt_qp_nb) {=0A= > + if (alloc_vring_queue_pair(dev, cur_qp_idx) < 0)=0A= > + return -1;=0A= > + }=0A= > +=0A= Here we rely on the fact that this set_vring_call message is sent in the=0A= continuous ascending order of queue idx 0, 1, 2, ...=0A= =0A= > /* file->index refers to the queue index. The txq is 1, rxq is 0. */=0A= > vq =3D dev->virtqueue[file->index];=0A= > + assert(vq !=3D NULL);=0A= > =0A= If we allocate the queue until the we receive the first vring message,=0A= better add comment that we rely on this fact.=0A= Could we add the vhost-user message to tell us the queue number QEMU=0A= allocates before vring message?=0A= > if (vq->callfd >=3D 0)=0A= > close(vq->callfd);=0A= =0A=