From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id EA00A1094 for ; Tue, 3 Jan 2017 09:27:29 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP; 03 Jan 2017 00:27:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,451,1477983600"; d="scan'208";a="49497617" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga006.fm.intel.com with ESMTP; 03 Jan 2017 00:27:25 -0800 Date: Tue, 3 Jan 2017 16:29:13 +0800 From: Yuanhan Liu To: "Charles (Chas) Williams" Cc: dev@dpdk.org, mtetsuyah@gmail.com Message-ID: <20170103082913.GD21228@yliu-dev.sh.intel.com> References: <1483297317-20315-1-git-send-email-ciwillia@brocade.com> <1483297317-20315-2-git-send-email-ciwillia@brocade.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1483297317-20315-2-git-send-email-ciwillia@brocade.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v3 2/2] net/vhost: emulate device start/stop behavior 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: Tue, 03 Jan 2017 08:27:30 -0000 On Sun, Jan 01, 2017 at 02:01:57PM -0500, Charles (Chas) Williams wrote: > .dev_start()/.dev_stop() roughly corresponds to the local device's > port being up or down. This is different from the remote client being > connected which is roughtly link up or down. Emulate the behavior by > separately tracking the local start/stop state to determine if we should > allow packets to be queued to the remote client. > > Signed-off-by: Chas Williams > --- > drivers/net/vhost/rte_eth_vhost.c | 65 ++++++++++++++++++++++++++++++++------- > 1 file changed, 54 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c > index 6b11e40..d5a4540 100644 > --- a/drivers/net/vhost/rte_eth_vhost.c > +++ b/drivers/net/vhost/rte_eth_vhost.c > @@ -100,7 +100,8 @@ struct vhost_stats { > > struct vhost_queue { > int vid; > - rte_atomic32_t allow_queuing; > + rte_atomic32_t connected; > + rte_atomic32_t ready; > rte_atomic32_t while_queuing; > struct pmd_internal *internal; > struct rte_mempool *mb_pool; > @@ -383,18 +384,25 @@ vhost_update_packet_xstats(struct vhost_queue *vq, > } > } > > +static inline bool > +queuing_stopped(struct vhost_queue *r) > +{ > + return unlikely(rte_atomic32_read(&r->connected) == 0 || > + rte_atomic32_read(&r->ready) == 0); > +} That's one more check comparing to the old code, meaning a bit more expensive than before. I think we could maintain the same effort by: - introduce per-device "started" flag: set/unset on dev_start/stop, respectively. - introduce per-device "dev_attached" flag: set/unset on new/destory_device(), respectively. On update of each flag, setting "allow_queuing" properly. Okay to you? --yliu