From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 6236B1BB87 for ; Wed, 4 Apr 2018 07:39:42 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2018 22:39:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,405,1517904000"; d="scan'208";a="34105444" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.164]) by fmsmga002.fm.intel.com with ESMTP; 03 Apr 2018 22:39:14 -0700 Date: Wed, 4 Apr 2018 13:37:17 +0800 From: Tiwei Bie To: zhiyong.yang@intel.com Cc: "Tan, Jianfeng" , dev@dpdk.org, maxime.coquelin@redhat.com, thomas@monjalon.net, zhihong.wang@intel.com Message-ID: <20180404053717.trp4pchameeirymv@debian> References: <20180321030343.64399-1-zhiyong.yang@intel.com> <20180403122009.52876-1-zhiyong.yang@intel.com> <20180403122009.52876-2-zhiyong.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v4 1/1] net/virtio-user: add support for server mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2018 05:39:42 -0000 On Tue, Apr 03, 2018 at 11:16:26PM +0800, Tan, Jianfeng wrote: > On 4/3/2018 8:20 PM, zhiyong.yang@intel.com wrote: [...] > > @@ -267,21 +270,27 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) > > dev->vhostfds = NULL; > > dev->tapfds = NULL; > > Add a check here: > if (dev->is_server && !is_vhost_user_by_type(dev->path)) > return error; > > > - if (is_vhost_user_by_type(dev->path)) { > > - dev->ops = &ops_user; > > + if (dev->is_server) { > > + dev->ops = &ops_user;/* server mode only supports vhost user*/ > > } else { > > - dev->ops = &ops_kernel; > > - > > - dev->vhostfds = malloc(dev->max_queue_pairs * sizeof(int)); > > - dev->tapfds = malloc(dev->max_queue_pairs * sizeof(int)); > > - if (!dev->vhostfds || !dev->tapfds) { > > - PMD_INIT_LOG(ERR, "Failed to malloc"); > > - return -1; > > - } > > - > > - for (q = 0; q < dev->max_queue_pairs; ++q) { > > - dev->vhostfds[q] = -1; > > - dev->tapfds[q] = -1; > > + if (is_vhost_user_by_type(dev->path)) { > > + dev->ops = &ops_user; > > + } else { > > + dev->ops = &ops_kernel; > > + > > + dev->vhostfds = malloc(dev->max_queue_pairs * > > + sizeof(int)); > > + dev->tapfds = malloc(dev->max_queue_pairs * > > + sizeof(int)); > > + if (!dev->vhostfds || !dev->tapfds) { > > + PMD_INIT_LOG(ERR, "Failed to malloc"); > > + return -1; > > + } > > + > > + for (q = 0; q < dev->max_queue_pairs; ++q) { > > + dev->vhostfds[q] = -1; > > + dev->tapfds[q] = -1; > > + } > > } > > } Hi Zhiyong, I think we can keep using is_vhost_user_by_type() to determine the ops for dev->ops. And you just need to add a check in the vhost-kernel case. Something like this: --- i/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ w/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -270,6 +270,9 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) if (is_vhost_user_by_type(dev->path)) { dev->ops = &ops_user; } else { + if (dev->is_server) + return -1; + dev->ops = &ops_kernel; dev->vhostfds = malloc(dev->max_queue_pairs * sizeof(int)); Thanks