From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by dpdk.org (Postfix) with ESMTP id 19E3E2C6A for ; Mon, 14 Mar 2016 09:31:30 +0100 (CET) Received: by mail-pa0-f44.google.com with SMTP id fe3so135987838pab.1 for ; Mon, 14 Mar 2016 01:31:30 -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-transfer-encoding; bh=aZo08hM00r5f+QyJqZ2BDZThmux6rgAfOgAF/+wmFgQ=; b=gjgLShw0h2gxhaggzlbfO5ZEdZkgtxM7zoylQR1utO3ABbz2RHbD3tqETeKE1tEEQg xpgHUPmNU+HP7olQy/FSinUN/VvZWdM7nuG5XC5oBYY6zbz7CY1FcTnFidkuEzbegk2L UNmM5wsc55UO3GMh3UFC/f8NHSEHlzADhjCN94nI+97UhmHyPm+Nxy7NQodpaq99NlVD vpmLA9OulgpnzuAfzrG4LdHvD2y/O9Hd7b4WcbriTx29wWfPu2hKN3+X1DoQL1WRx4dF zb7OKsx3uBfWTX13gQ09A8P/Jck4iB2EfTYjE1UpGkYzEb2tisgNcigPzpvkChGWRCHX 9z7w== 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=aZo08hM00r5f+QyJqZ2BDZThmux6rgAfOgAF/+wmFgQ=; b=T9l6xY/tcnp6UcpKrID61fAVhqee6lEXyCWMscJ3p8Ca2dqFyprf6GeV+apM4xLcuQ iwaWTjIKwiOS+Yh8tl0BUD89y9ichS2veVd8SAkEvmFFNUlpGhH4TFokCIUgR43fX7dG cIgy95lHWkC15wAQzp1909qbSSFBGdsjQwSIegWe+v8LAQUEUVF81hokVv7w1ZYkhBW4 d4KBQMgKX/6mR0JwjIbB3w2bC9btmB/zZF2b0RjgTYzXGnwcp/DeDqfRZ2xQ3Hdf2fQ0 Qzl4wUw6wPh1ewT+WvFd4/znfNRMW2tMm5qMwIaQ2Y8yOa8p1crCarwJZikWaxXW7sXN /QRQ== X-Gm-Message-State: AD7BkJK8YymFhfnFJOmWu2yKcaqYvT5ZTwMeb4KVA65YYw7y2/DNXP0tahMStmBLZm5Vmw== X-Received: by 10.66.146.39 with SMTP id sz7mr36497430pab.76.1457944289518; Mon, 14 Mar 2016 01:31:29 -0700 (PDT) Received: from [10.16.129.101] (napt.igel.co.jp. [219.106.231.132]) by smtp.googlemail.com with ESMTPSA id ah10sm30173602pad.23.2016.03.14.01.31.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 Mar 2016 01:31:29 -0700 (PDT) To: Yuanhan Liu References: <1457590462-3680-1-git-send-email-mukawa@igel.co.jp> <1457593565-16240-1-git-send-email-mukawa@igel.co.jp> <20160311071907.GI979@yliu-dev.sh.intel.com> <56E619C6.6060809@igel.co.jp> <20160314020858.GJ979@yliu-dev.sh.intel.com> <56E66E18.4000700@igel.co.jp> <20160314082125.GM979@yliu-dev.sh.intel.com> Cc: dev@dpdk.org, jianfeng.tan@intel.com, huawei.xie@intel.com From: Tetsuya Mukawa Message-ID: <56E676DE.10407@igel.co.jp> Date: Mon, 14 Mar 2016 17:31:26 +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: <20160314082125.GM979@yliu-dev.sh.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] 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: Mon, 14 Mar 2016 08:31:30 -0000 On 2016/03/14 17:21, Yuanhan Liu wrote: > On Mon, Mar 14, 2016 at 04:54:00PM +0900, Tetsuya Mukawa wrote: >> On 2016/03/14 11:08, Yuanhan Liu wrote: >>> On Mon, Mar 14, 2016 at 10:54:14AM +0900, Tetsuya Mukawa wrote: >>>> On 2016/03/11 16:19, Yuanhan Liu wrote: >>>>> On Thu, Mar 10, 2016 at 04:06:05PM +0900, Tetsuya Mukawa wrote: >>>>>> Currently, default values of kickfd and callfd are -1. >>>>>> If the values are -1, current code guesses kickfd and callfd haven'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 values to -2. And the >>>>>> patch defines -2 as VIRTIO_UNINITIALIZED_EVENTFD. >>>>> This looks more like a workaround to me. >>>> Hi Yuanhan, >>>> >>>> Sorry for late reply. >>>> I have checked QEMU documentation, and found below. >>>> >>>> ---------- >>>> * VHOST_USER_SET_VRING_CALL >>>> >>>> Id: 14 >>>> Equivalent ioctl: VHOST_SET_VRING_CALL >>>> Master payload: u64 >>>> >>>> Set the event file descriptor to signal when buffers are used. It >>>> is passed in the ancillary data. >>>> Bits (0-7) of the payload contain the vring index. Bit 8 is the >>>> invalid FD flag. >>>> ---------- >>>> >>>> VHOST_USER_SET_VRING_KICK has almost same description. >>>> I will check this invalid flag, and if it works for our case, then will >>>> use it. >>>> How about it? >>> Yeah, that indeed sounds much better. >> I've checked current dpdk code. >> It seems we've already checked invalid flag like below. >> >> if (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK) >> file.fd = -1; >> else >> file.fd = pmsg->fds[0]; >> >> So how about adding below macros or enum? >> >> #define VIRTIO_UNINITIALIZED_EVENTFD (-2) >> #define VIRTIO_INVALID_EVENTFD (-1) >> >> I am still not sure whether using enum is better or not. > Both are Okay to me; I have no preference on that. > >> But here is one of example patch. >> What do you think? > Looks okay to me > >> diff --git a/lib/librte_vhost/rte_virtio_net.h >> b/lib/librte_vhost/rte_virtio_net.h >> index 7d1fde2..2a7566d 100644 >> --- a/lib/librte_vhost/rte_virtio_net.h >> +++ b/lib/librte_vhost/rte_virtio_net.h >> @@ -89,6 +89,8 @@ 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) >> +#define VIRTIO_INVALID_EVENTFD (-1) > One nit: you may keep it in order. Thanks for your comments, will change it. Tetsuya > --yliu