[dpdk-dev] [PATCH v3 2/2] net/vhost: emulate device start/stop behavior

Yuanhan Liu yuanhan.liu at linux.intel.com
Tue Jan 3 09:29:13 CET 2017


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 <ciwillia at brocade.com>
> ---
>  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


More information about the dev mailing list