From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by dpdk.org (Postfix) with ESMTP id 7FFE92B9B for ; Thu, 10 Mar 2016 07:42:13 +0100 (CET) Received: by mail-pa0-f54.google.com with SMTP id fl4so59551280pad.0 for ; Wed, 09 Mar 2016 22:42:13 -0800 (PST) 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-transfer-encoding; bh=1s+1oFi4xZrmDWIQ76uFvkirtnRSVisHRwPucniqI9s=; b=RV2aoO1lw82wNyW8NGlo8Y3PPasUfOBcLkG7pfa9cfLCYWVkNp225uhiOY3totaKYa kAJxa5MIJEyc9gcBG9gk6yuzBEEUqRAflTWuJKRQuW9ez9EyzMnAQzmU02XkoP2M1veS DBNh7et4nOKVd86OQf2olXmsUAeBGX4OkULv0uJiyscJWjEMD0qlWe1pvtSvMhI6wDS1 jKiHLgsF6szPrVF7SsQWh/sPO2E0/WhWoEAEjTnTsfZ/UlaAEgjp6vSlS6cwoz/bfX+q YCnDk++K/Y1V7Ds48XL3qySJzT2BCRgu38eKbrwWTZkrwKoaF9R1Rt671/PjcumDqWy8 cFvw== 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-transfer-encoding; bh=1s+1oFi4xZrmDWIQ76uFvkirtnRSVisHRwPucniqI9s=; b=fJPhl1iKXc+OwWRoXQ9/bKp5jwR7TYbt7Litzzj873L1kznkyMu/k0TVOp8G9dFn5g jz86bU4f4vSeY+zktnf5/KRM5qpEgob6g1jiUPt47qiPq9EN2hOFlz0GHF9ZnkcusIBr QV2CHyv/euSQRpfvWLDIdbh044439jxzknlt+eQ0GRbQ9QZnjaF2KVVC3EiF6drDkt6b TyG7BNaMOtfEs/2Z5ai1rSEvj03+2itmsdhWVkC0cAYW2oCi+wsSC79vm7WcEwE4kC0Z nwn+ilbVwovsjms1yVOnpz/cbVhGJ8T+uvd+MLSN6ux6vJUCLE0w8mH+26Ck+n4pWha9 Yr0w== X-Gm-Message-State: AD7BkJLg9OrdAT3QK1QUIWdAEU3Imo5GRKdW30cVZsvY1SfbV3tNCmUF5Hg/GgNM33TN1g== X-Received: by 10.66.124.167 with SMTP id mj7mr2568854pab.153.1457592132916; Wed, 09 Mar 2016 22:42:12 -0800 (PST) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by smtp.googlemail.com with ESMTPSA id g23sm2644234pfg.35.2016.03.09.22.42.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Mar 2016 22:42:12 -0800 (PST) To: "Tan, Jianfeng" , dev@dpdk.org References: <1457590462-3680-1-git-send-email-mukawa@igel.co.jp> <56E11345.7030404@intel.com> <56E1155F.30201@igel.co.jp> <56E116A5.40501@intel.com> From: Tetsuya Mukawa Message-ID: <56E11741.7050608@igel.co.jp> Date: Thu, 10 Mar 2016 15:42:09 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56E116A5.40501@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] vhost: Fix default value of kickfd and callfd 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, 10 Mar 2016 06:42:14 -0000 On 2016/03/10 15:39, Tan, Jianfeng wrote: > > On 3/10/2016 2:34 PM, Tetsuya Mukawa wrote: >> On 2016/03/10 15:25, Tan, Jianfeng wrote: >>> >>> On 3/10/2016 2:14 PM, Tetsuya Mukawa wrote: >>>> Currently, default value of kickfd and callfd is -1. >>>> If the value is -1, current code guess kickfd and callfd hasn't been >>>> initialized yet. And vhost library will guess the virtqueue isn't >>>> ready >>>> for processing. >>>> But callfd and kickfd will be set as -1 when "--enable-kvm" >>>> isn't specified in QEMU command line. It means we cannot treat -1 as >>>> uninitialized state. The patch changes default value to -2. And the >>>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD. >>>> >>>> Signed-off-by: Tetsuya Mukawa >>>> --- >>>> lib/librte_vhost/rte_virtio_net.h | 1 + >>>> lib/librte_vhost/vhost_user/virtio-net-user.c | 7 ++++--- >>>> lib/librte_vhost/virtio-net.c | 4 ++-- >>>> 3 files changed, 7 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/lib/librte_vhost/rte_virtio_net.h >>>> b/lib/librte_vhost/rte_virtio_net.h >>>> index 7d1fde2..d745707 100644 >>>> --- a/lib/librte_vhost/rte_virtio_net.h >>>> +++ b/lib/librte_vhost/rte_virtio_net.h >>>> @@ -89,6 +89,7 @@ struct vhost_virtqueue { >>>> uint16_t vhost_hlen; /**< Vhost header length >>>> (varies depending on RX merge buffers. */ >>>> volatile uint16_t last_used_idx; /**< Last index used >>>> on the available ring */ >>>> volatile uint16_t last_used_idx_res; /**< Used for >>>> multiple devices reserving buffers. */ >>>> +#define VIRTIO_UNINITIALIZED_EVENTFD (-2) >>>> int callfd; /**< Used to notify the guest >>>> (trigger interrupt). */ >>>> int kickfd; /**< Currently unused as >>>> polling mode is enabled. */ >>>> int enabled; >>>> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c >>>> b/lib/librte_vhost/vhost_user/virtio-net-user.c >>>> index 65b5652..591f9bf 100644 >>>> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c >>>> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c >>>> @@ -225,8 +225,8 @@ static int >>>> vq_is_ready(struct vhost_virtqueue *vq) >>>> { >>>> return vq && vq->desc && >>>> - vq->kickfd != -1 && >>>> - vq->callfd != -1; >>>> + vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD && >>>> + vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD; >>>> } >>>> static int >>>> @@ -318,7 +318,8 @@ user_get_vring_base(struct vhost_device_ctx ctx, >>>> */ >>>> if (dev->virtqueue[state->index]->kickfd >= 0) { >>>> close(dev->virtqueue[state->index]->kickfd); >>> Then -1 will be a valid value, need to check if it's not -1 to >>> close()? Nevertheless, close(-1) brings no big problem. >>> >> We did it in above 'if' condition checking, then close(-1) will not be >> called. > > Sorry, missed that. So when kickfd == -1, need to be set to > VIRTIO_UNINITIALIZED_EVENTFD? > Aha, I've got it. Will change it. Thanks, Tetsuya > Thanks, > Jianfeng > >> >> Thanks, >> Tetsuya >> >>> Thanks, >>> Jianfeng >>> >>>> - dev->virtqueue[state->index]->kickfd = -1; >>>> + dev->virtqueue[state->index]->kickfd = >>>> + VIRTIO_UNINITIALIZED_EVENTFD; >>>> } >>>> return 0; >>>> diff --git a/lib/librte_vhost/virtio-net.c >>>> b/lib/librte_vhost/virtio-net.c >>>> index fe1a77e..3498e9d 100644 >>>> --- a/lib/librte_vhost/virtio-net.c >>>> +++ b/lib/librte_vhost/virtio-net.c >>>> @@ -263,8 +263,8 @@ init_vring_queue(struct vhost_virtqueue *vq, int >>>> qp_idx) >>>> { >>>> memset(vq, 0, sizeof(struct vhost_virtqueue)); >>>> - vq->kickfd = -1; >>>> - vq->callfd = -1; >>>> + vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD; >>>> + vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD; >>>> /* Backends are set to -1 indicating an inactive device. */ >>>> vq->backend = -1; >