DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Jianfeng Tan <jianfeng.tan@intel.com>
Cc: dev@dpdk.org, zhihong.wang@intel.com, lining18@jd.com
Subject: Re: [dpdk-dev] [PATCH 1/3] net/virtio_user: fix queue pair not enabled
Date: Tue, 6 Sep 2016 14:30:49 +0800	[thread overview]
Message-ID: <20160906063049.GP30752@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1470397003-5782-2-git-send-email-jianfeng.tan@intel.com>

On Fri, Aug 05, 2016 at 11:36:41AM +0000, Jianfeng Tan wrote:
> When virtio_user is used with OVS-DPDK (with mq disabled), it cannot
> receive any packets.
> 
> It's because when vhost provides VHOST_USER_GET_PROTOCOL_FEATURES,
> all queue pairs are initialized in the disabled state. Quote
> QEMU/docs/specs/vhost-user.txt:
>     If VHOST_USER_F_PROTOCOL_FEATURES has not been negotiated, the
>     ring is initialized in an enabled state.
>     If VHOST_USER_F_PROTOCOL_FEATURES has been negotiated, the ring
>     is initialized in a disabled state.
> 
> In OVS-DPDK, all queue pairs are in the disabled state by default.
> When used with QEMU, QEMU will set it as enabled in the process of
> initialization. So the fix here is to include similar logic in
> virtio_user.

The behaviour is actually defined by virtio spec; the vhost-user just
follows it (5.1.6.5.5 Automatic receive steering in multiqueue mode):

    Multiqueue is disabled by default. The driver enables multiqueue by
    executing the VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command, specifying
    the number of the transmit and receive queues to be used up to
    max_virtqueue_pairs ....

That is to say, it has nothing to do with OVS-DPDK; yet it's not caused
by vhost-user. For QEMU, as the the virtio-net device emulator, it just
follows the spec: it enables the 1st queue pair whenever MQ is enabled
or not. Even the MQ __feature__ is enabled and queue=2 is given, only
the 1st queue pair will be enabled. For linux virtio-net driver, you
have to use ethtool to enable more queues if you want.

However, for virtio-user, the yet another virtio-net device emulator,
it didn't follow the rule, thus something went wrong.

Put simply, you need make sure the 1st queue pair is enabled by default
and the rest (if any, say when queues=2 is given) are disabled in the
virtio-user initial stage (say, at virtio_user_dev_init()).

	--yliu
> 
> Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer")
> 
> Reported-by: Ning Li <lining18@jd.com>
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 376c9cf..2c4e999 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -131,6 +131,13 @@ virtio_user_start_device(struct virtio_user_dev *dev)
>  		}
>  	}
>  
> +	/* As this feature is negotiated from the vhost, all queues are
> +	 * initialized in the disabled state. For non-mq case, we enable
> +	 * the 1st queue pair by default.
> +	 */
> +	if (dev->features & (1ull << VHOST_USER_GET_PROTOCOL_FEATURES))
> +		vhost_user_enable_queue_pair(dev->vhostfd, 0, 1);
> +
>  	/* After setup all virtqueues, we need to set_features so that these
>  	 * features can be set into each virtqueue in vhost side. And before
>  	 * that, make sure VHOST_USER_F_PROTOCOL_FEATURES is added if mq is
> -- 
> 2.7.4

  reply	other threads:[~2016-09-06  6:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 11:36 [dpdk-dev] [PATCH 0/3] fix virtio_user issues Jianfeng Tan
2016-08-05 11:36 ` [dpdk-dev] [PATCH 1/3] net/virtio_user: fix queue pair not enabled Jianfeng Tan
2016-09-06  6:30   ` Yuanhan Liu [this message]
2016-08-05 11:36 ` [dpdk-dev] [PATCH 2/3] net/virtio_user: fix wrong sequence of messages Jianfeng Tan
2016-08-05 16:36   ` Stephen Hemminger
2016-08-08  1:19     ` Tan, Jianfeng
2016-09-06  6:42   ` Yuanhan Liu
2016-09-06  7:54     ` Tan, Jianfeng
2016-09-06  8:20       ` Yuanhan Liu
2016-09-08  8:53         ` Tan, Jianfeng
2016-09-08 12:18           ` Yuanhan Liu
2016-09-09  3:59             ` Tan, Jianfeng
2016-09-09  4:19               ` Yuanhan Liu
2016-09-09  5:50                 ` Tan, Jianfeng
2016-09-09  6:03                   ` Yuanhan Liu
2016-09-09  6:24                     ` Tan, Jianfeng
2016-09-09  6:31                       ` Yuanhan Liu
2016-08-05 11:36 ` [dpdk-dev] [PATCH 3/3] net/virtio_user: fix dev not freed after init error Jianfeng Tan
2016-08-05 16:34   ` Stephen Hemminger
2016-08-08  1:07     ` Tan, Jianfeng
2016-08-29  7:01 ` [dpdk-dev] [PATCH 0/3] fix virtio_user issues Christian Ehrhardt
2016-09-27 19:11 ` [dpdk-dev] [PATCH v2 " Jianfeng Tan
2016-09-27 19:11   ` [dpdk-dev] [PATCH v2 1/3] net/virtio_user: fix queue pair not enabled Jianfeng Tan
2016-09-28  0:05     ` Yuanhan Liu
2016-09-27 19:11   ` [dpdk-dev] [PATCH v2 2/3] net/virtio_user: fix wrong sequence of messages Jianfeng Tan
2016-09-27 19:11   ` [dpdk-dev] [PATCH v2 3/3] net/virtio_user: fix dev not freed after init error Jianfeng Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160906063049.GP30752@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    --cc=lining18@jd.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).