From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3A19458F1 for ; Tue, 6 Sep 2016 08:30:42 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 05 Sep 2016 23:30:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,290,1470726000"; d="scan'208";a="757523940" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by FMSMGA003.fm.intel.com with ESMTP; 05 Sep 2016 23:30:41 -0700 Date: Tue, 6 Sep 2016 14:42:46 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, zhihong.wang@intel.com, lining18@jd.com Message-ID: <20160906064246.GQ30752@yliu-dev.sh.intel.com> References: <1470397003-5782-1-git-send-email-jianfeng.tan@intel.com> <1470397003-5782-3-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1470397003-5782-3-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH 2/3] net/virtio_user: fix wrong sequence of messages 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: Tue, 06 Sep 2016 06:30:42 -0000 On Fri, Aug 05, 2016 at 11:36:42AM +0000, Jianfeng Tan wrote: > When virtio_user is used with VPP's native vhost user, it cannot > send/receive any packets. > > The root cause is that vpp-vhost-user translates the message > VHOST_USER_SET_FEATURES as puting this device into init state, > aka, zero all related structures. However, previous code > puts this message at last in the whole initialization process, > which leads to all previous information are zeroed. > > To fix this issue, we rearrange the sequence of those messages. > - step 0, send VHOST_USER_SET_VRING_CALL so that vhost allocates > virtqueue structures; Yes, it is. However, it's not that right to do that (you see there is a FIXME in vhost_user_set_vring_call()). That means it need be fixed: we should not rely on fact that it's the first per-vring message we will get in the current QEMU implementation as the truth. That also means, naming a function like virtio_user_create_queue() based on above behaviour is wrong. > - step 1, send VHOST_USER_SET_FEATURES to confirm the features; > - step 2, send VHOST_USER_SET_MEM_TABLE to share mem regions; > - step 3, send VHOST_USER_SET_VRING_NUM, VHOST_USER_SET_VRING_BASE, > VHOST_USER_SET_VRING_ADDR, VHOST_USER_SET_VRING_KICK for each > queue; > - ... > > Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") > > Reported-by: Zhihong Wang > Signed-off-by: Jianfeng Tan > --- > drivers/net/virtio/virtio_user/virtio_user_dev.c | 120 ++++++++++++++--------- > 1 file changed, 72 insertions(+), 48 deletions(-) That's too much of code for a bug fix. I'm wondering how about just moving VHOST_USER_GET_PROTOCOL_FEATURES ahead, to the begining of virtio_user_start_device()? It should fix this issue. --yliu