From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by dpdk.org (Postfix) with ESMTP id CCB4D4A63 for ; Mon, 26 Oct 2015 06:24:11 +0100 (CET) Received: by pacfv9 with SMTP id fv9so184906555pac.3 for ; Sun, 25 Oct 2015 22:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel_co_jp.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=Rrsg41MWhR6nZOhDa15LaZ71JZvyt0NPZ6X90mm+6ds=; b=Uw06/fPmDpmyL0xMpQcMVh3Jq3uDH6lO24auSlXAqV8223ieVGnNdL/YN+kSYuN44S 61daLeW5sZIMsTdvcDaXR6UXBuJblRwSBDd4w9qKzqMq44n4WYKWJM8OWcL4VmQ6Hczb fV/kVWK0RTG79RQM4WfzscnS9ow7h94BWUh+ew1LsEsuSklsBf8kXa9glCVywba/Nw1L PinD4TvQ3lPq3wOC6uGyr/lOvnthwZw33CWhOr5Fzub9MNVxcio5OmY9lt8b2yPW1/RB f3wlMMmuUT9NCsZjEVwmxYqyMsLuAfRzw33XTOSZnQ07hlRwHBJqxxqtoVguHu2CaYMU tNTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=Rrsg41MWhR6nZOhDa15LaZ71JZvyt0NPZ6X90mm+6ds=; b=YCND6evhCcbyJvf+pqZArjeA2HQJIND0k5pLp+nbe5Y1yprO1Uxr+P0lDp8AsfL+HD PaEYgBXoPz8cslJ1+4Jv6gGNDCAIxV/MRADSLWx2B9O9HQIN7SNVGf4vX8JTrrfPwGeT SWdb63OmatDLiRvNAmdqAM9wD7VE9Ri4V7jO0hRAiiM+QmnbuaV9G/drrtnvEmWExoXn Alkt9KYIOK2hOahYVbRtF+QHmbO0OmCnJ4waM53+WC50/BU/3NefdcOHtC/eZA37rBXN tDls9efCNnfMywmV/zMfdaDJKaHc/aJt8c5ocwv9YjBMAUCtABsLx2a5r31yTsUvT3/P jynw== X-Gm-Message-State: ALoCoQmisRzzsEVmja/bE9lxsWT19g67fguWSrROg4pGoDJklXJxMNMkXYdtnCjFWbZou4rPRZwG X-Received: by 10.66.144.169 with SMTP id sn9mr19675256pab.15.1445837051074; Sun, 25 Oct 2015 22:24:11 -0700 (PDT) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by smtp.googlemail.com with ESMTPSA id eg5sm31492026pac.30.2015.10.25.22.24.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Oct 2015 22:24:10 -0700 (PDT) To: Yuanhan Liu , dev@dpdk.org References: <1445399294-18826-1-git-send-email-yuanhan.liu@linux.intel.com> <1445517356-19780-1-git-send-email-yuanhan.liu@linux.intel.com> <1445517356-19780-4-git-send-email-yuanhan.liu@linux.intel.com> From: Tetsuya Mukawa X-Enigmail-Draft-Status: N1110 Message-ID: <562DB8F8.4050707@igel.co.jp> Date: Mon, 26 Oct 2015 14:24:08 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1445517356-19780-4-git-send-email-yuanhan.liu@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: marcel@redhat.com, "Michael S. Tsirkin" Subject: Re: [dpdk-dev] [PATCH v8 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: Mon, 26 Oct 2015 05:24:12 -0000 On 2015/10/22 21:35, Yuanhan Liu wrote: > All queue pairs, including the default (the first) queue pair, > are allocated dynamically, when a vring_call message is received > first time for a specific queue pair. > > This is a refactor work for enabling vhost-user multiple queue; > it should not break anything as it does no functional changes: > we don't support mq set, so there is only one mq at max. > > This patch is based on Changchun's patch. > > Signed-off-by: Ouyang Changchun > Signed-off-by: Yuanhan Liu > Acked-by: Flavio Leitner > > --- > > v8: - move virtuque field to the end of `virtio_net' struct. > > - Add a FIXME at set_vring_call() for doing vring queue pair > allocation. > --- > lib/librte_vhost/rte_virtio_net.h | 3 +- > lib/librte_vhost/vhost_user/virtio-net-user.c | 46 ++++---- > lib/librte_vhost/virtio-net.c | 156 ++++++++++++++++---------- > 3 files changed, 123 insertions(+), 82 deletions(-) > > diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h > index e3a21e5..9a32a95 100644 > --- a/lib/librte_vhost/rte_virtio_net.h > +++ b/lib/librte_vhost/rte_virtio_net.h > @@ -96,7 +96,6 @@ struct vhost_virtqueue { > * Device structure contains all configuration information relating to the device. > */ > struct virtio_net { > - struct vhost_virtqueue *virtqueue[VIRTIO_QNUM]; /**< Contains all virtqueue information. */ > struct virtio_memory *mem; /**< QEMU memory and memory region information. */ > uint64_t features; /**< Negotiated feature set. */ > uint64_t protocol_features; /**< Negotiated protocol feature set. */ > @@ -104,7 +103,9 @@ struct virtio_net { > uint32_t flags; /**< Device flags. Only used to check if device is running on data core. */ > #define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ) > char ifname[IF_NAME_SZ]; /**< Name of the tap device or socket path. */ > + uint32_t virt_qp_nb; /**< number of queue pair we have allocated */ > void *priv; /**< private context */ > + struct vhost_virtqueue *virtqueue[VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX]; /**< Contains all virtqueue information. */ > } __rte_cache_aligned; > > /** > diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c > index 6da729d..d62f3d7 100644 > --- a/lib/librte_vhost/vhost_user/virtio-net-user.c > +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c > @@ -206,25 +206,33 @@ err_mmap: > } > > static int > +vq_is_ready(struct vhost_virtqueue *vq) > +{ > + return vq && vq->desc && > + vq->kickfd != -1 && > + vq->callfd != -1; > +} > + > +static int > virtio_is_ready(struct virtio_net *dev) > { > struct vhost_virtqueue *rvq, *tvq; > + uint32_t i; > > - /* mq support in future.*/ > - rvq = dev->virtqueue[VIRTIO_RXQ]; > - tvq = dev->virtqueue[VIRTIO_TXQ]; > - if (rvq && tvq && rvq->desc && tvq->desc && > - (rvq->kickfd != -1) && > - (rvq->callfd != -1) && > - (tvq->kickfd != -1) && > - (tvq->callfd != -1)) { > - RTE_LOG(INFO, VHOST_CONFIG, > - "virtio is now ready for processing.\n"); > - return 1; > + for (i = 0; i < dev->virt_qp_nb; i++) { > + rvq = dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_RXQ]; > + tvq = dev->virtqueue[i * VIRTIO_QNUM + VIRTIO_TXQ]; > + > + if (!vq_is_ready(rvq) || !vq_is_ready(tvq)) { > + RTE_LOG(INFO, VHOST_CONFIG, > + "virtio is not ready for processing.\n"); > + return 0; > + } > } > + > RTE_LOG(INFO, VHOST_CONFIG, > - "virtio isn't ready for processing.\n"); > - return 0; > + "virtio is now ready for processing.\n"); > + return 1; > } > > void > @@ -292,13 +300,13 @@ user_get_vring_base(struct vhost_device_ctx ctx, > * sent and only sent in vhost_vring_stop. > * TODO: cleanup the vring, it isn't usable since here. > */ > - if ((dev->virtqueue[VIRTIO_RXQ]->kickfd) >= 0) { > - close(dev->virtqueue[VIRTIO_RXQ]->kickfd); > - dev->virtqueue[VIRTIO_RXQ]->kickfd = -1; > + if ((dev->virtqueue[state->index]->kickfd + VIRTIO_RXQ) >= 0) { > + close(dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd); > + dev->virtqueue[state->index + VIRTIO_RXQ]->kickfd = -1; > } Hi Yuanhan, Please let me make sure whether below is correct. if ((dev->virtqueue[state->index]->kickfd + VIRTIO_RXQ) >= 0) { > - if ((dev->virtqueue[VIRTIO_TXQ]->kickfd) >= 0) { > - close(dev->virtqueue[VIRTIO_TXQ]->kickfd); > - dev->virtqueue[VIRTIO_TXQ]->kickfd = -1; > + if ((dev->virtqueue[state->index]->kickfd + VIRTIO_TXQ) >= 0) { > + close(dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd); > + dev->virtqueue[state->index + VIRTIO_TXQ]->kickfd = -1; Also, same question here. Thanks, Tetsuya