patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode
@ 2018-05-09  9:49 zhiyong.yang
  2018-05-09 14:48 ` Ferruh Yigit
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: zhiyong.yang @ 2018-05-09  9:49 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, lei.a.yao, stable, Zhiyong Yang

This patch fixes multiple queues failure when virtio-user works in
server mode.

Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
Cc: stable@dpdk.org
Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---
 drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a6df97a00..a9e53d7b5 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
 
 	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
 
+	if (vhostfd < 0)
+		return -1;
+
 	msg.request = req;
 	msg.flags = VHOST_USER_VERSION;
 	msg.size = 0;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 38b8bc90d..e988dc3f4 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev *dev)
 	features &= ~(1ull << VIRTIO_NET_F_MAC);
 	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
 	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
+	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ */
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
 	features &= ~(1ull << VIRTIO_NET_F_STATUS);
 	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES, &features);
 	if (ret < 0)
@@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
 	}
+	/* Server mode can't enable queue pairs if vhostfd is not connected,
+	 * we suppose that status always returns 0 in this case.
+	 * /
+	if (dev->is_server && dev->vhostfd < 0)
+		status = 0;
 
 	/* Update status */
 	*(virtio_net_ctrl_ack *)(uintptr_t)vring->desc[idx_status].addr = status;
-- 
2.14.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-09  9:49 [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode zhiyong.yang
@ 2018-05-09 14:48 ` Ferruh Yigit
  2018-05-10  0:48   ` Tiwei Bie
  2018-05-10  1:28   ` Yang, Zhiyong
  2018-05-10  2:47 ` [dpdk-stable] [dpdk-dev] " Tiwei Bie
  2018-05-10  9:36 ` [dpdk-stable] [PATCH v2] " zhiyong.yang
  2 siblings, 2 replies; 17+ messages in thread
From: Ferruh Yigit @ 2018-05-09 14:48 UTC (permalink / raw)
  To: zhiyong.yang, dev; +Cc: maxime.coquelin, lei.a.yao, stable, Tiwei Bie

On 5/9/2018 10:49 AM, zhiyong.yang@intel.com wrote:
> This patch fixes multiple queues failure when virtio-user works in
> server mode.
> 
> Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> Cc: stable@dpdk.org

Hi Zhiyong,

Is this for rc3?

Hi Tiwei,

Since Maxime is out this week, can you please review this patch?

Thanks,
ferruh

> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
> index a6df97a00..a9e53d7b5 100644
> --- a/drivers/net/virtio/virtio_user/vhost_user.c
> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
>  
>  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
>  
> +	if (vhostfd < 0)
> +		return -1;
> +
>  	msg.request = req;
>  	msg.flags = VHOST_USER_VERSION;
>  	msg.size = 0;
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 38b8bc90d..e988dc3f4 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev *dev)
>  	features &= ~(1ull << VIRTIO_NET_F_MAC);
>  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
>  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ */
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
>  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
>  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES, &features);
>  	if (ret < 0)
> @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
>  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
>  		status = virtio_user_handle_mq(dev, queues);
>  	}
> +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> +	 * we suppose that status always returns 0 in this case.
> +	 * /

There is a typo here causing comment block not ended.

> +	if (dev->is_server && dev->vhostfd < 0)
> +		status = 0;
>  
>  	/* Update status */
>  	*(virtio_net_ctrl_ack *)(uintptr_t)vring->desc[idx_status].addr = status;
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-09 14:48 ` Ferruh Yigit
@ 2018-05-10  0:48   ` Tiwei Bie
  2018-05-10  1:28   ` Yang, Zhiyong
  1 sibling, 0 replies; 17+ messages in thread
From: Tiwei Bie @ 2018-05-10  0:48 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: zhiyong.yang, dev, maxime.coquelin, lei.a.yao, stable

On Wed, May 09, 2018 at 03:48:58PM +0100, Ferruh Yigit wrote:
> On 5/9/2018 10:49 AM, zhiyong.yang@intel.com wrote:
> > This patch fixes multiple queues failure when virtio-user works in
> > server mode.
> > 
> > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> > Cc: stable@dpdk.org
> 
> Hi Zhiyong,
> 
> Is this for rc3?
> 
> Hi Tiwei,
> 
> Since Maxime is out this week, can you please review this patch?

Sure. Will do it!

Thanks

> 
> Thanks,
> ferruh
> 
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > ---
> >  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
> >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
> >  2 files changed, 12 insertions(+)
> > 
> > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
> > index a6df97a00..a9e53d7b5 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
> >  
> >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> >  
> > +	if (vhostfd < 0)
> > +		return -1;
> > +
> >  	msg.request = req;
> >  	msg.flags = VHOST_USER_VERSION;
> >  	msg.size = 0;
> > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > index 38b8bc90d..e988dc3f4 100644
> > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev *dev)
> >  	features &= ~(1ull << VIRTIO_NET_F_MAC);
> >  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
> >  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> > +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ */
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> >  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> >  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES, &features);
> >  	if (ret < 0)
> > @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
> >  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
> >  		status = virtio_user_handle_mq(dev, queues);
> >  	}
> > +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> > +	 * we suppose that status always returns 0 in this case.
> > +	 * /
> 
> There is a typo here causing comment block not ended.
> 
> > +	if (dev->is_server && dev->vhostfd < 0)
> > +		status = 0;
> >  
> >  	/* Update status */
> >  	*(virtio_net_ctrl_ack *)(uintptr_t)vring->desc[idx_status].addr = status;
> > 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-09 14:48 ` Ferruh Yigit
  2018-05-10  0:48   ` Tiwei Bie
@ 2018-05-10  1:28   ` Yang, Zhiyong
  2018-05-10  1:38     ` Yang, Zhiyong
  1 sibling, 1 reply; 17+ messages in thread
From: Yang, Zhiyong @ 2018-05-10  1:28 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: maxime.coquelin, Yao, Lei A, stable, Bie, Tiwei



> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, May 9, 2018 10:49 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>; dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Yao, Lei A <lei.a.yao@intel.com>;
> stable@dpdk.org; Bie, Tiwei <tiwei.bie@intel.com>
> Subject: Re: [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in
> server mode
> 
> On 5/9/2018 10:49 AM, zhiyong.yang@intel.com wrote:
> > This patch fixes multiple queues failure when virtio-user works in
> > server mode.
> >
> > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> > Cc: stable@dpdk.org
> 
> Hi Zhiyong,
> 
> Is this for rc3?
> 

Right. 

> Hi Tiwei,
> 
> Since Maxime is out this week, can you please review this patch?
> 
> Thanks,
> ferruh
> 
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > ---
> >  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
> >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> > b/drivers/net/virtio/virtio_user/vhost_user.c
> > index a6df97a00..a9e53d7b5 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
> >
> >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> >
> > +	if (vhostfd < 0)
> > +		return -1;
> > +
Since virtio-user server mode need to start firstly before vhost user, So, In this case, 
the socket connection is not setup, So, we add to check validation of vhostfd here. 

> >  	msg.request = req;
> >  	msg.flags = VHOST_USER_VERSION;
> >  	msg.size = 0;
> > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > index 38b8bc90d..e988dc3f4 100644
> > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev
> *dev)
> >  	features &= ~(1ull << VIRTIO_NET_F_MAC);
> >  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to
> know */
> >  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> > +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ
> */
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> >  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> >  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES,
> &features);
> >  	if (ret < 0)
> > @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct
> virtio_user_dev *dev, struct vring *vring,
> >  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
> >  		status = virtio_user_handle_mq(dev, queues);
> >  	}
> > +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> > +	 * we suppose that status always returns 0 in this case.
> > +	 * /
> 
> There is a typo here causing comment block not ended.
> 

Thanks so much for your pointing out, Ferruh,  fix it in next version.

Thanks
zhiyong

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10  1:28   ` Yang, Zhiyong
@ 2018-05-10  1:38     ` Yang, Zhiyong
  0 siblings, 0 replies; 17+ messages in thread
From: Yang, Zhiyong @ 2018-05-10  1:38 UTC (permalink / raw)
  To: Yang, Zhiyong, Yigit, Ferruh, dev
  Cc: maxime.coquelin, Yao, Lei A, stable, Bie, Tiwei



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yang, Zhiyong
> Sent: Thursday, May 10, 2018 9:29 AM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Yao, Lei A <lei.a.yao@intel.com>;
> stable@dpdk.org; Bie, Tiwei <tiwei.bie@intel.com>
> Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] net/virtio-user: fix multiple
> queues fail in server mode
> 
> 
> 
> > -----Original Message-----
> > From: Yigit, Ferruh
> > Sent: Wednesday, May 9, 2018 10:49 PM
> > To: Yang, Zhiyong <zhiyong.yang@intel.com>; dev@dpdk.org
> > Cc: maxime.coquelin@redhat.com; Yao, Lei A <lei.a.yao@intel.com>;
> > stable@dpdk.org; Bie, Tiwei <tiwei.bie@intel.com>
> > Subject: Re: [dpdk-stable] [PATCH] net/virtio-user: fix multiple
> > queues fail in server mode
> >
> > On 5/9/2018 10:49 AM, zhiyong.yang@intel.com wrote:
> > > This patch fixes multiple queues failure when virtio-user works in
> > > server mode.
> > >
> > > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> > > Cc: stable@dpdk.org
> >
> > Hi Zhiyong,
> >
> > Is this for rc3?
> >
> 
> Right.
> 
> > Hi Tiwei,
> >
> > Since Maxime is out this week, can you please review this patch?
> >
> > Thanks,
> > ferruh
> >
> > > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > > ---
> > >  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
> > >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
> > >  2 files changed, 12 insertions(+)
> > >
> > > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> > > b/drivers/net/virtio/virtio_user/vhost_user.c
> > > index a6df97a00..a9e53d7b5 100644
> > > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > > @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
> > >
> > >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> > >
> > > +	if (vhostfd < 0)
> > > +		return -1;
> > > +
> Since virtio-user server mode need to start firstly before vhost user, So, In
> this case, the socket connection is not setup, So, we add to check validation
> of vhostfd here.
> 
> > >  	msg.request = req;
> > >  	msg.flags = VHOST_USER_VERSION;
> > >  	msg.size = 0;
> > > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > index 38b8bc90d..e988dc3f4 100644
> > > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev
> > *dev)
> > >  	features &= ~(1ull << VIRTIO_NET_F_MAC);
> > >  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to
> > know */
> > >  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> > > +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ
> > */
> > > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> > > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> > >  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> > >  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES,
> > &features);
> > >  	if (ret < 0)
> > > @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct
> > virtio_user_dev *dev, struct vring *vring,
> > >  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
> > >  		status = virtio_user_handle_mq(dev, queues);
> > >  	}
> > > +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> > > +	 * we suppose that status always returns 0 in this case.
> > > +	 * /
> >
> > There is a typo here causing comment block not ended.
> >
> 
> Thanks so much for your pointing out, Ferruh,  fix it in next version.

My bad, I remember I was aware of this issue yesterday, but sent out the wrong version by mistake.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-09  9:49 [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode zhiyong.yang
  2018-05-09 14:48 ` Ferruh Yigit
@ 2018-05-10  2:47 ` Tiwei Bie
  2018-05-10  3:04   ` Yang, Zhiyong
  2018-05-10  9:36 ` [dpdk-stable] [PATCH v2] " zhiyong.yang
  2 siblings, 1 reply; 17+ messages in thread
From: Tiwei Bie @ 2018-05-10  2:47 UTC (permalink / raw)
  To: zhiyong.yang; +Cc: dev, maxime.coquelin, lei.a.yao, stable

On Wed, May 09, 2018 at 05:49:36PM +0800, zhiyong.yang@intel.com wrote:
> This patch fixes multiple queues failure when virtio-user works in
> server mode.
> 
> Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> Cc: stable@dpdk.org
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
> index a6df97a00..a9e53d7b5 100644
> --- a/drivers/net/virtio/virtio_user/vhost_user.c
> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
>  
>  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
>  
> +	if (vhostfd < 0)
> +		return -1;

I think this is just a workaround to avoid printing
error messages in server mode.

Ideally, vhost_user_sock() shouldn't be called with
vhostfd < 0.

If we want this workaround, we should only allow
this in server mode. I.e. do the check like this:

	if (dev->is_server && vhostfd < 0)
		return -1;

> +
>  	msg.request = req;
>  	msg.flags = VHOST_USER_VERSION;
>  	msg.size = 0;
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 38b8bc90d..e988dc3f4 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev *dev)
>  	features &= ~(1ull << VIRTIO_NET_F_MAC);
>  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
>  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ */
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);

Is this really related to this fix?

>  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
>  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES, &features);
>  	if (ret < 0)
> @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
>  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
>  		status = virtio_user_handle_mq(dev, queues);
>  	}
> +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> +	 * we suppose that status always returns 0 in this case.
> +	 * /

As Ferruh pointed, a typo here.

> +	if (dev->is_server && dev->vhostfd < 0)
> +		status = 0;

When the connection to the backend isn't established in
server mode, what virtio_user_handle_mq() can't do is to
enable the queue pairs. But other checks in that function
are still valid. So I would suggest moving above code to
virtio_user_handle_mq().

Thanks

>  
>  	/* Update status */
>  	*(virtio_net_ctrl_ack *)(uintptr_t)vring->desc[idx_status].addr = status;
> -- 
> 2.14.3
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10  2:47 ` [dpdk-stable] [dpdk-dev] " Tiwei Bie
@ 2018-05-10  3:04   ` Yang, Zhiyong
  2018-05-10  4:42     ` Tiwei Bie
  0 siblings, 1 reply; 17+ messages in thread
From: Yang, Zhiyong @ 2018-05-10  3:04 UTC (permalink / raw)
  To: Bie, Tiwei; +Cc: dev, maxime.coquelin, Yao, Lei A, stable

Hi  Tiwei,

> -----Original Message-----
> From: Bie, Tiwei
> Sent: Thursday, May 10, 2018 10:47 AM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>
> Cc: dev@dpdk.org; maxime.coquelin@redhat.com; Yao, Lei A
> <lei.a.yao@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/virtio-user: fix multiple queues fail in
> server mode
> 
> On Wed, May 09, 2018 at 05:49:36PM +0800, zhiyong.yang@intel.com wrote:
> > This patch fixes multiple queues failure when virtio-user works in
> > server mode.
> >
> > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> > Cc: stable@dpdk.org
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > ---
> >  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
> >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> > b/drivers/net/virtio/virtio_user/vhost_user.c
> > index a6df97a00..a9e53d7b5 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
> >
> >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> >
> > +	if (vhostfd < 0)
> > +		return -1;
> 
> I think this is just a workaround to avoid printing error messages in server
> mode.
> 
> Ideally, vhost_user_sock() shouldn't be called with vhostfd < 0.
> 
> If we want this workaround, we should only allow this in server mode. I.e. do
> the check like this:
> 
> 	if (dev->is_server && vhostfd < 0)
> 		return -1;
 
Ok. 

> > +
> >  	msg.request = req;
> >  	msg.flags = VHOST_USER_VERSION;
> >  	msg.size = 0;
> > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > index 38b8bc90d..e988dc3f4 100644
> > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev
> *dev)
> >  	features &= ~(1ull << VIRTIO_NET_F_MAC);
> >  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to
> know */
> >  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> > +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ
> */
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> 
> Is this really related to this fix?
> 

Yes.  if vhost user side receives these feature bits and  
Vhost user doesn’t  support these features and will close the socket connection.
If we have disable ctrl_VQ,  also should disable them.


> >  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> >  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES,
> &features);
> >  	if (ret < 0)
> > @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct
> virtio_user_dev *dev, struct vring *vring,
> >  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
> >  		status = virtio_user_handle_mq(dev, queues);
> >  	}
> > +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> > +	 * we suppose that status always returns 0 in this case.
> > +	 * /
> 
> As Ferruh pointed, a typo here.
Ok. fix it.

> 
> > +	if (dev->is_server && dev->vhostfd < 0)
> > +		status = 0;
> 
> When the connection to the backend isn't established in server mode, what
> virtio_user_handle_mq() can't do is to enable the queue pairs. But other
> checks in that function are still valid. So I would suggest moving above code
> to virtio_user_handle_mq().
Ok. 

Thanks
Zhiyong

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10  3:04   ` Yang, Zhiyong
@ 2018-05-10  4:42     ` Tiwei Bie
  0 siblings, 0 replies; 17+ messages in thread
From: Tiwei Bie @ 2018-05-10  4:42 UTC (permalink / raw)
  To: Yang, Zhiyong; +Cc: dev, maxime.coquelin, Yao, Lei A, stable

On Thu, May 10, 2018 at 11:04:59AM +0800, Yang, Zhiyong wrote:
> Hi  Tiwei,
> 
> > -----Original Message-----
> > From: Bie, Tiwei
> > Sent: Thursday, May 10, 2018 10:47 AM
> > To: Yang, Zhiyong <zhiyong.yang@intel.com>
> > Cc: dev@dpdk.org; maxime.coquelin@redhat.com; Yao, Lei A
> > <lei.a.yao@intel.com>; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] net/virtio-user: fix multiple queues fail in
> > server mode
> > 
> > On Wed, May 09, 2018 at 05:49:36PM +0800, zhiyong.yang@intel.com wrote:
> > > This patch fixes multiple queues failure when virtio-user works in
> > > server mode.
> > >
> > > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> > > Cc: stable@dpdk.org
> > > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > > ---
> > >  drivers/net/virtio/virtio_user/vhost_user.c      | 3 +++
> > >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 9 +++++++++
> > >  2 files changed, 12 insertions(+)
> > >
> > > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> > > b/drivers/net/virtio/virtio_user/vhost_user.c
> > > index a6df97a00..a9e53d7b5 100644
> > > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > > @@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
> > >
> > >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> > >
> > > +	if (vhostfd < 0)
> > > +		return -1;
> > 
> > I think this is just a workaround to avoid printing error messages in server
> > mode.
> > 
> > Ideally, vhost_user_sock() shouldn't be called with vhostfd < 0.
> > 
> > If we want this workaround, we should only allow this in server mode. I.e. do
> > the check like this:
> > 
> > 	if (dev->is_server && vhostfd < 0)
> > 		return -1;
>  
> Ok. 
> 
> > > +
> > >  	msg.request = req;
> > >  	msg.flags = VHOST_USER_VERSION;
> > >  	msg.size = 0;
> > > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > index 38b8bc90d..e988dc3f4 100644
> > > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > @@ -126,6 +126,10 @@ virtio_user_start_device(struct virtio_user_dev *dev)
> > >  	features &= ~(1ull << VIRTIO_NET_F_MAC);
> > >  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know */
> > >  	features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
> > > +	/* Also disable features which depend on VIRTIO_NET_F_CTRL_VQ */
> > > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
> > > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> > 
> > Is this really related to this fix?
> > 
> 
> Yes.  if vhost user side receives these feature bits and  
> Vhost user doesn’t  support these features and will close the socket connection.
> If we have disable ctrl_VQ,  also should disable them.
> 

If cq is disabled, all the related features (including
VIRTIO_NET_F_MQ) should have been disabled.

The features in this function should already be a subset
of the features supported by the vhost backend. The thing
that's not right is that, in server mode, virtio-user
doesn't do GET_FEATURES. And we need to do it.

Thanks

> 
> > >  	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> > >  	ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES,
> > &features);
> > >  	if (ret < 0)
> > > @@ -488,6 +492,11 @@ virtio_user_handle_ctrl_msg(struct
> > virtio_user_dev *dev, struct vring *vring,
> > >  		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
> > >  		status = virtio_user_handle_mq(dev, queues);
> > >  	}
> > > +	/* Server mode can't enable queue pairs if vhostfd is not connected,
> > > +	 * we suppose that status always returns 0 in this case.
> > > +	 * /
> > 
> > As Ferruh pointed, a typo here.
> Ok. fix it.
> 
> > 
> > > +	if (dev->is_server && dev->vhostfd < 0)
> > > +		status = 0;
> > 
> > When the connection to the backend isn't established in server mode, what
> > virtio_user_handle_mq() can't do is to enable the queue pairs. But other
> > checks in that function are still valid. So I would suggest moving above code
> > to virtio_user_handle_mq().
> Ok. 
> 
> Thanks
> Zhiyong

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-stable] [PATCH v2] net/virtio-user: fix multiple queues fail in server mode
  2018-05-09  9:49 [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode zhiyong.yang
  2018-05-09 14:48 ` Ferruh Yigit
  2018-05-10  2:47 ` [dpdk-stable] [dpdk-dev] " Tiwei Bie
@ 2018-05-10  9:36 ` zhiyong.yang
  2018-05-10 10:23   ` Tiwei Bie
  2018-05-11  2:12   ` [dpdk-stable] [PATCH v3] " zhiyong.yang
  2 siblings, 2 replies; 17+ messages in thread
From: zhiyong.yang @ 2018-05-10  9:36 UTC (permalink / raw)
  To: dev, stable; +Cc: tiwei.bie, maxime.coquelin, ferruh.yigit, Zhiyong Yang

This patch fixes multiple queues failure when virtio-user works in
server mode.

This patch adds feature negotiation in the processing of virtio-user
reccnnection.

Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---

Changes in V2:
1. fix a comment typo.
2. add feature negotiation in the processing of reconnection.

 drivers/net/virtio/virtio_user/vhost_user.c      |  3 +++
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 14 ++++++++++----
 drivers/net/virtio/virtio_user_ethdev.c          | 20 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a6df97a..93e4d92 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -263,6 +263,9 @@ struct hugepage_file_info {
 
 	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
 
+	if (dev->is_server && vhostfd < 0)
+		return -1;
+
 	msg.request = req;
 	msg.flags = VHOST_USER_VERSION;
 	msg.size = 0;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 38b8bc9..b7e1915 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -447,10 +447,16 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		return -1;
 	}
 
-	for (i = 0; i < q_pairs; ++i)
-		ret |= dev->ops->enable_qp(dev, i, 1);
-	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
-		ret |= dev->ops->enable_qp(dev, i, 0);
+	/* Server mode can't enable queue pairs if vhostfd is invalid,
+	 * always return 0 in this case.
+	 */
+	if (dev->vhostfd >= 0)  {
+		for (i = 0; i < q_pairs; ++i)
+			ret |= dev->ops->enable_qp(dev, i, 1);
+		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
+			ret |= dev->ops->enable_qp(dev, i, 0);
+	} else if (!dev->is_server)
+		ret = ~0;
 
 	dev->queue_pairs = q_pairs;
 
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 4e7b3c3..91a0c44 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -30,6 +30,7 @@
 	int ret;
 	int flag;
 	int connectfd;
+	uint64_t features = dev->device_features, status;
 	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
 
 	connectfd = accept(dev->listenfd, NULL, NULL);
@@ -37,6 +38,25 @@
 		return -1;
 
 	dev->vhostfd = connectfd;
+	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
+				   &dev->device_features) < 0) {
+		PMD_INIT_LOG(ERR, "get_features failed: %s",
+			     strerror(errno));
+		return -1;
+	}
+
+	status = features & ~dev->device_features;
+	/* For following bits, vhost-user doesn't really need to know */
+	status &= ~(1ull << VIRTIO_NET_F_MAC);
+	status &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
+	status &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
+	status &= ~(1ull << VIRTIO_NET_F_STATUS);
+	if (status)
+		PMD_INIT_LOG(ERR, "WARNING: Some features (0x%lx) are not supported by vhost-user!",
+			     status);
+
+	dev->features &= dev->device_features;
+
 	flag = fcntl(connectfd, F_GETFD);
 	fcntl(connectfd, F_SETFL, flag | O_NONBLOCK);
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH v2] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10  9:36 ` [dpdk-stable] [PATCH v2] " zhiyong.yang
@ 2018-05-10 10:23   ` Tiwei Bie
  2018-05-10 14:01     ` Yang, Zhiyong
  2018-05-11  2:12   ` [dpdk-stable] [PATCH v3] " zhiyong.yang
  1 sibling, 1 reply; 17+ messages in thread
From: Tiwei Bie @ 2018-05-10 10:23 UTC (permalink / raw)
  To: zhiyong.yang; +Cc: dev, stable, maxime.coquelin, ferruh.yigit

On Thu, May 10, 2018 at 05:36:23PM +0800, zhiyong.yang@intel.com wrote:
> This patch fixes multiple queues failure when virtio-user works in
> server mode.
> 
> This patch adds feature negotiation in the processing of virtio-user
> reccnnection.

typo: reccnnection

> 
> Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> 
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> ---
> 
> Changes in V2:
> 1. fix a comment typo.
> 2. add feature negotiation in the processing of reconnection.
> 
>  drivers/net/virtio/virtio_user/vhost_user.c      |  3 +++
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 14 ++++++++++----
>  drivers/net/virtio/virtio_user_ethdev.c          | 20 ++++++++++++++++++++
>  3 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
> index a6df97a..93e4d92 100644
> --- a/drivers/net/virtio/virtio_user/vhost_user.c
> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> @@ -263,6 +263,9 @@ struct hugepage_file_info {
>  
>  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
>  
> +	if (dev->is_server && vhostfd < 0)
> +		return -1;
> +
>  	msg.request = req;
>  	msg.flags = VHOST_USER_VERSION;
>  	msg.size = 0;
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 38b8bc9..b7e1915 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -447,10 +447,16 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
>  		return -1;
>  	}
>  
> -	for (i = 0; i < q_pairs; ++i)
> -		ret |= dev->ops->enable_qp(dev, i, 1);
> -	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> -		ret |= dev->ops->enable_qp(dev, i, 0);
> +	/* Server mode can't enable queue pairs if vhostfd is invalid,
> +	 * always return 0 in this case.
> +	 */
> +	if (dev->vhostfd >= 0)  {
> +		for (i = 0; i < q_pairs; ++i)
> +			ret |= dev->ops->enable_qp(dev, i, 1);
> +		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> +			ret |= dev->ops->enable_qp(dev, i, 0);
> +	} else if (!dev->is_server)
> +		ret = ~0;

You need to find a chance to enable these queue pairs
when the connection is established.

>  
>  	dev->queue_pairs = q_pairs;
>  
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
> index 4e7b3c3..91a0c44 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -30,6 +30,7 @@
>  	int ret;
>  	int flag;
>  	int connectfd;
> +	uint64_t features = dev->device_features, status;
>  	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
>  
>  	connectfd = accept(dev->listenfd, NULL, NULL);
> @@ -37,6 +38,25 @@
>  		return -1;
>  
>  	dev->vhostfd = connectfd;
> +	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
> +				   &dev->device_features) < 0) {
> +		PMD_INIT_LOG(ERR, "get_features failed: %s",
> +			     strerror(errno));
> +		return -1;
> +	}
> +
> +	status = features & ~dev->device_features;

There is no need to introduce `status`.

> +	/* For following bits, vhost-user doesn't really need to know */
> +	status &= ~(1ull << VIRTIO_NET_F_MAC);
> +	status &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> +	status &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> +	status &= ~(1ull << VIRTIO_NET_F_STATUS);
> +	if (status)
> +		PMD_INIT_LOG(ERR, "WARNING: Some features (0x%lx) are not supported by vhost-user!",

You will want to use PRIx64 here.

Thanks

> +			     status);
> +
> +	dev->features &= dev->device_features;
> +
>  	flag = fcntl(connectfd, F_GETFD);
>  	fcntl(connectfd, F_SETFL, flag | O_NONBLOCK);
>  
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH v2] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10 10:23   ` Tiwei Bie
@ 2018-05-10 14:01     ` Yang, Zhiyong
  2018-05-10 14:19       ` Tiwei Bie
  0 siblings, 1 reply; 17+ messages in thread
From: Yang, Zhiyong @ 2018-05-10 14:01 UTC (permalink / raw)
  To: Bie, Tiwei; +Cc: dev, stable, maxime.coquelin, Yigit, Ferruh

Hi tiwei,

Thanks for your review firstly.  Reply inline.

> -----Original Message-----
> From: Bie, Tiwei
> Sent: Thursday, May 10, 2018 6:23 PM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; maxime.coquelin@redhat.com; Yigit,
> Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [PATCH v2] net/virtio-user: fix multiple queues fail in server
> mode
> 
> On Thu, May 10, 2018 at 05:36:23PM +0800, zhiyong.yang@intel.com wrote:
> > This patch fixes multiple queues failure when virtio-user works in
> > server mode.
> >
> > This patch adds feature negotiation in the processing of virtio-user
> > reccnnection.
> 
> typo: reccnnection
> 

Fix it.

> >
> > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> >
> > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > ---
> >
> > Changes in V2:
> > 1. fix a comment typo.
> > 2. add feature negotiation in the processing of reconnection.
> >
> >  drivers/net/virtio/virtio_user/vhost_user.c      |  3 +++
> >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 14 ++++++++++----
> >  drivers/net/virtio/virtio_user_ethdev.c          | 20
> ++++++++++++++++++++
> >  3 files changed, 33 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> > b/drivers/net/virtio/virtio_user/vhost_user.c
> > index a6df97a..93e4d92 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > @@ -263,6 +263,9 @@ struct hugepage_file_info {
> >
> >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> >
> > +	if (dev->is_server && vhostfd < 0)
> > +		return -1;
> > +
> >  	msg.request = req;
> >  	msg.flags = VHOST_USER_VERSION;
> >  	msg.size = 0;
> > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > index 38b8bc9..b7e1915 100644
> > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > @@ -447,10 +447,16 @@ int virtio_user_stop_device(struct
> virtio_user_dev *dev)
> >  		return -1;
> >  	}
> >
> > -	for (i = 0; i < q_pairs; ++i)
> > -		ret |= dev->ops->enable_qp(dev, i, 1);
> > -	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> > -		ret |= dev->ops->enable_qp(dev, i, 0);
> > +	/* Server mode can't enable queue pairs if vhostfd is invalid,
> > +	 * always return 0 in this case.
> > +	 */
> > +	if (dev->vhostfd >= 0)  {
> > +		for (i = 0; i < q_pairs; ++i)
> > +			ret |= dev->ops->enable_qp(dev, i, 1);
> > +		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> > +			ret |= dev->ops->enable_qp(dev, i, 0);
> > +	} else if (!dev->is_server)
> > +		ret = ~0;
> 
> You need to find a chance to enable these queue pairs when the connection
> is established.
> 
Enable only one queue pairs in virtio_user_start_device.
 I want to call virtio_user_handle_mq after virtio_user_start_device in virtio_user_server_reconnect. How about ?

> >
> >  	dev->queue_pairs = q_pairs;
> >
> > diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> > b/drivers/net/virtio/virtio_user_ethdev.c
> > index 4e7b3c3..91a0c44 100644
> > --- a/drivers/net/virtio/virtio_user_ethdev.c
> > +++ b/drivers/net/virtio/virtio_user_ethdev.c
> > @@ -30,6 +30,7 @@
> >  	int ret;
> >  	int flag;
> >  	int connectfd;
> > +	uint64_t features = dev->device_features, status;
> >  	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
> >
> >  	connectfd = accept(dev->listenfd, NULL, NULL); @@ -37,6 +38,25
> @@
> >  		return -1;
> >
> >  	dev->vhostfd = connectfd;
> > +	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
> > +				   &dev->device_features) < 0) {
> > +		PMD_INIT_LOG(ERR, "get_features failed: %s",
> > +			     strerror(errno));
> > +		return -1;
> > +	}
> > +
> > +	status = features & ~dev->device_features;
> 
> There is no need to introduce `status`.
> 
Ok, remove it.

> > +	/* For following bits, vhost-user doesn't really need to know */
> > +	status &= ~(1ull << VIRTIO_NET_F_MAC);
> > +	status &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > +	status &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> > +	status &= ~(1ull << VIRTIO_NET_F_STATUS);
> > +	if (status)
> > +		PMD_INIT_LOG(ERR, "WARNING: Some features (0x%lx) are
> not supported
> > +by vhost-user!",
> 
> You will want to use PRIx64 here.
> 
Ok.

Thanks
Zhiyong

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH v2] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10 14:01     ` Yang, Zhiyong
@ 2018-05-10 14:19       ` Tiwei Bie
  0 siblings, 0 replies; 17+ messages in thread
From: Tiwei Bie @ 2018-05-10 14:19 UTC (permalink / raw)
  To: Yang, Zhiyong; +Cc: dev, stable, maxime.coquelin, Yigit, Ferruh

On Thu, May 10, 2018 at 10:01:55PM +0800, Yang, Zhiyong wrote:
> Hi tiwei,
> 
> Thanks for your review firstly.  Reply inline.
> 
> > -----Original Message-----
> > From: Bie, Tiwei
> > Sent: Thursday, May 10, 2018 6:23 PM
> > To: Yang, Zhiyong <zhiyong.yang@intel.com>
> > Cc: dev@dpdk.org; stable@dpdk.org; maxime.coquelin@redhat.com; Yigit,
> > Ferruh <ferruh.yigit@intel.com>
> > Subject: Re: [PATCH v2] net/virtio-user: fix multiple queues fail in server
> > mode
> > 
> > On Thu, May 10, 2018 at 05:36:23PM +0800, zhiyong.yang@intel.com wrote:
> > > This patch fixes multiple queues failure when virtio-user works in
> > > server mode.
> > >
> > > This patch adds feature negotiation in the processing of virtio-user
> > > reccnnection.
> > 
> > typo: reccnnection
> > 
> 
> Fix it.
> 
> > >
> > > Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> > >
> > > Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> > > ---
> > >
> > > Changes in V2:
> > > 1. fix a comment typo.
> > > 2. add feature negotiation in the processing of reconnection.
> > >
> > >  drivers/net/virtio/virtio_user/vhost_user.c      |  3 +++
> > >  drivers/net/virtio/virtio_user/virtio_user_dev.c | 14 ++++++++++----
> > >  drivers/net/virtio/virtio_user_ethdev.c          | 20
> > ++++++++++++++++++++
> > >  3 files changed, 33 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> > > b/drivers/net/virtio/virtio_user/vhost_user.c
> > > index a6df97a..93e4d92 100644
> > > --- a/drivers/net/virtio/virtio_user/vhost_user.c
> > > +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> > > @@ -263,6 +263,9 @@ struct hugepage_file_info {
> > >
> > >  	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
> > >
> > > +	if (dev->is_server && vhostfd < 0)
> > > +		return -1;
> > > +
> > >  	msg.request = req;
> > >  	msg.flags = VHOST_USER_VERSION;
> > >  	msg.size = 0;
> > > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > index 38b8bc9..b7e1915 100644
> > > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> > > @@ -447,10 +447,16 @@ int virtio_user_stop_device(struct
> > virtio_user_dev *dev)
> > >  		return -1;
> > >  	}
> > >
> > > -	for (i = 0; i < q_pairs; ++i)
> > > -		ret |= dev->ops->enable_qp(dev, i, 1);
> > > -	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> > > -		ret |= dev->ops->enable_qp(dev, i, 0);
> > > +	/* Server mode can't enable queue pairs if vhostfd is invalid,
> > > +	 * always return 0 in this case.
> > > +	 */
> > > +	if (dev->vhostfd >= 0)  {
> > > +		for (i = 0; i < q_pairs; ++i)
> > > +			ret |= dev->ops->enable_qp(dev, i, 1);
> > > +		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> > > +			ret |= dev->ops->enable_qp(dev, i, 0);
> > > +	} else if (!dev->is_server)
> > > +		ret = ~0;
> > 
> > You need to find a chance to enable these queue pairs when the connection
> > is established.
> > 
> Enable only one queue pairs in virtio_user_start_device.
>  I want to call virtio_user_handle_mq after virtio_user_start_device in virtio_user_server_reconnect. How about ?

Sound good.

Thanks

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-stable] [PATCH v3] net/virtio-user: fix multiple queues fail in server mode
  2018-05-10  9:36 ` [dpdk-stable] [PATCH v2] " zhiyong.yang
  2018-05-10 10:23   ` Tiwei Bie
@ 2018-05-11  2:12   ` zhiyong.yang
  2018-05-11  2:49     ` Tiwei Bie
  2018-05-11  3:31     ` [dpdk-stable] [PATCH v4] " zhiyong.yang
  1 sibling, 2 replies; 17+ messages in thread
From: zhiyong.yang @ 2018-05-11  2:12 UTC (permalink / raw)
  To: dev; +Cc: tiwei.bie, ferruh.yigit, maxime.coquelin, stable, Zhiyong Yang

This patch fixes multiple queues failure when virtio-user works in
server mode.

This patch adds feature negotiation in the processing of virtio-user
connection and enables multiple-queue pairs.

Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
Cc: stable@dpdk.org

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
---

Changes in V3:
1. virtio_user_handle_mq is redefined as extern instead of static.
2. add to call virtio_user_handle_mq in virtio_user_server_reconnect. 

Changes in V2:
1. fix a comment typo.
2. add feature negotiation in the processing of reconnection.

 drivers/net/virtio/virtio_user/vhost_user.c      |  3 +++
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 18 ++++++++++------
 drivers/net/virtio/virtio_user/virtio_user_dev.h |  1 +
 drivers/net/virtio/virtio_user_ethdev.c          | 27 ++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a6df97a00..93e4d9213 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
 
 	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
 
+	if (dev->is_server && vhostfd < 0)
+		return -1;
+
 	msg.request = req;
 	msg.flags = VHOST_USER_VERSION;
 	msg.size = 0;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 38b8bc90d..505f2ea5e 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -435,7 +435,7 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
 		unlink(dev->path);
 }
 
-static uint8_t
+uint8_t
 virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
 {
 	uint16_t i;
@@ -447,11 +447,17 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
 		return -1;
 	}
 
-	for (i = 0; i < q_pairs; ++i)
-		ret |= dev->ops->enable_qp(dev, i, 1);
-	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
-		ret |= dev->ops->enable_qp(dev, i, 0);
-
+	/* Server mode can't enable queue pairs if vhostfd is invalid,
+	 * always return 0 in this case.
+	 */
+	if (dev->vhostfd >= 0)  {
+		for (i = 0; i < q_pairs; ++i)
+			ret |= dev->ops->enable_qp(dev, i, 1);
+		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
+			ret |= dev->ops->enable_qp(dev, i, 0);
+	} else if (!dev->is_server) {
+		ret = ~0;
+	}
 	dev->queue_pairs = q_pairs;
 
 	return ret;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index ade727e46..784f4752e 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -48,4 +48,5 @@ int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 			 int cq, int queue_size, const char *mac, char **ifname);
 void virtio_user_dev_uninit(struct virtio_user_dev *dev);
 void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
+uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);
 #endif
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 4e7b3c34f..e53d8f996 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -30,6 +30,7 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 	int ret;
 	int flag;
 	int connectfd;
+	uint64_t features = dev->device_features;
 	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
 
 	connectfd = accept(dev->listenfd, NULL, NULL);
@@ -37,6 +38,25 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 		return -1;
 
 	dev->vhostfd = connectfd;
+	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
+				   &dev->device_features) < 0) {
+		PMD_INIT_LOG(ERR, "get_features failed: %s",
+			     strerror(errno));
+		return -1;
+	}
+
+	features &= ~dev->device_features;
+	/* For following bits, vhost-user doesn't really need to know */
+	features &= ~(1ull << VIRTIO_NET_F_MAC);
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
+	features &= ~(1ull << VIRTIO_NET_F_STATUS);
+	if (features)
+		PMD_INIT_LOG(ERR, "WARNING: Some features 0x%" PRIx64 "are not supported by vhost-user!",
+			     features);
+
+	dev->features &= dev->device_features;
+
 	flag = fcntl(connectfd, F_GETFD);
 	fcntl(connectfd, F_SETFL, flag | O_NONBLOCK);
 
@@ -44,6 +64,13 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 	if (ret < 0)
 		return -1;
 
+	if (dev->queue_pairs > 1) {
+		ret = virtio_user_handle_mq(dev, dev->queue_pairs);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Fails to enable multi-queue pairs!");
+			return -1;
+		}
+	}
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
 		if (rte_intr_disable(eth_dev->intr_handle) < 0) {
 			PMD_DRV_LOG(ERR, "interrupt disable failed");
-- 
2.14.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH v3] net/virtio-user: fix multiple queues fail in server mode
  2018-05-11  2:12   ` [dpdk-stable] [PATCH v3] " zhiyong.yang
@ 2018-05-11  2:49     ` Tiwei Bie
  2018-05-11  3:01       ` Yang, Zhiyong
  2018-05-11  3:31     ` [dpdk-stable] [PATCH v4] " zhiyong.yang
  1 sibling, 1 reply; 17+ messages in thread
From: Tiwei Bie @ 2018-05-11  2:49 UTC (permalink / raw)
  To: zhiyong.yang; +Cc: dev, ferruh.yigit, maxime.coquelin, stable

On Fri, May 11, 2018 at 10:12:47AM +0800, zhiyong.yang@intel.com wrote:
[...]
> @@ -447,11 +447,17 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
>  		return -1;
>  	}
>  
> -	for (i = 0; i < q_pairs; ++i)
> -		ret |= dev->ops->enable_qp(dev, i, 1);
> -	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> -		ret |= dev->ops->enable_qp(dev, i, 0);
> -
> +	/* Server mode can't enable queue pairs if vhostfd is invalid,
> +	 * always return 0 in this case.
> +	 */
> +	if (dev->vhostfd >= 0)  {

There are two spaces between ')' and '{'.

> +		for (i = 0; i < q_pairs; ++i)
> +			ret |= dev->ops->enable_qp(dev, i, 1);
> +		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> +			ret |= dev->ops->enable_qp(dev, i, 0);
> +	} else if (!dev->is_server) {
> +		ret = ~0;
> +	}
>  	dev->queue_pairs = q_pairs;
>  
>  	return ret;
[...]
> @@ -37,6 +38,25 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
>  		return -1;
>  
>  	dev->vhostfd = connectfd;
> +	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
> +				   &dev->device_features) < 0) {
> +		PMD_INIT_LOG(ERR, "get_features failed: %s",
> +			     strerror(errno));
> +		return -1;
> +	}
> +
> +	features &= ~dev->device_features;
> +	/* For following bits, vhost-user doesn't really need to know */
> +	features &= ~(1ull << VIRTIO_NET_F_MAC);
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> +	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> +	if (features)
> +		PMD_INIT_LOG(ERR, "WARNING: Some features 0x%" PRIx64 "are not supported by vhost-user!",

A space is missing before "are not ...". Should be: " are not ..."


Other than above small typos,

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH v3] net/virtio-user: fix multiple queues fail in server mode
  2018-05-11  2:49     ` Tiwei Bie
@ 2018-05-11  3:01       ` Yang, Zhiyong
  0 siblings, 0 replies; 17+ messages in thread
From: Yang, Zhiyong @ 2018-05-11  3:01 UTC (permalink / raw)
  To: Bie, Tiwei; +Cc: dev, Yigit, Ferruh, maxime.coquelin, stable



> -----Original Message-----
> From: Bie, Tiwei
> Sent: Friday, May 11, 2018 10:50 AM
> To: Yang, Zhiyong <zhiyong.yang@intel.com>
> Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>;
> maxime.coquelin@redhat.com; stable@dpdk.org
> Subject: Re: [PATCH v3] net/virtio-user: fix multiple queues fail in server
> mode
> 
> On Fri, May 11, 2018 at 10:12:47AM +0800, zhiyong.yang@intel.com wrote:
> [...]
> > @@ -447,11 +447,17 @@ virtio_user_handle_mq(struct virtio_user_dev
> *dev, uint16_t q_pairs)
> >  		return -1;
> >  	}
> >
> > -	for (i = 0; i < q_pairs; ++i)
> > -		ret |= dev->ops->enable_qp(dev, i, 1);
> > -	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> > -		ret |= dev->ops->enable_qp(dev, i, 0);
> > -
> > +	/* Server mode can't enable queue pairs if vhostfd is invalid,
> > +	 * always return 0 in this case.
> > +	 */
> > +	if (dev->vhostfd >= 0)  {
> 
> There are two spaces between ')' and '{'.
> 
> > +		for (i = 0; i < q_pairs; ++i)
> > +			ret |= dev->ops->enable_qp(dev, i, 1);
> > +		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
> > +			ret |= dev->ops->enable_qp(dev, i, 0);
> > +	} else if (!dev->is_server) {
> > +		ret = ~0;
> > +	}
> >  	dev->queue_pairs = q_pairs;
> >
> >  	return ret;
> [...]
> > @@ -37,6 +38,25 @@ virtio_user_server_reconnect(struct virtio_user_dev
> *dev)
> >  		return -1;
> >
> >  	dev->vhostfd = connectfd;
> > +	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
> > +				   &dev->device_features) < 0) {
> > +		PMD_INIT_LOG(ERR, "get_features failed: %s",
> > +			     strerror(errno));
> > +		return -1;
> > +	}
> > +
> > +	features &= ~dev->device_features;
> > +	/* For following bits, vhost-user doesn't really need to know */
> > +	features &= ~(1ull << VIRTIO_NET_F_MAC);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
> > +	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
> > +	features &= ~(1ull << VIRTIO_NET_F_STATUS);
> > +	if (features)
> > +		PMD_INIT_LOG(ERR, "WARNING: Some features 0x%"
> PRIx64 "are not supported by vhost-user!",
> 
> A space is missing before "are not ...". Should be: " are not ..."
> 
> 
> Other than above small typos,
> 
> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

Thanks Tiwei,  will send a new version to fix the typoes.
Thanks
Zhiyong

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-stable] [PATCH v4] net/virtio-user: fix multiple queues fail in server mode
  2018-05-11  2:12   ` [dpdk-stable] [PATCH v3] " zhiyong.yang
  2018-05-11  2:49     ` Tiwei Bie
@ 2018-05-11  3:31     ` zhiyong.yang
  2018-05-11 11:33       ` Ferruh Yigit
  1 sibling, 1 reply; 17+ messages in thread
From: zhiyong.yang @ 2018-05-11  3:31 UTC (permalink / raw)
  To: dev; +Cc: stable, tiwei.bie, ferruh.yigit, maxime.coquelin, Zhiyong Yang

This patch fixes multiple queues failure when virtio-user works in
server mode.

This patch adds feature negotiation in the processing of virtio-user
connection and enables multiple-queue pairs.

Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
Cc: stable@dpdk.org
Cc: tiwei.bie@intel.com
Cc: ferruh.yigit@intel.com
Cc: maxime.coquelin@redhat.com

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
---

Changes in V4:
1. fix two typoes.

Changes in V3:
1. virtio_user_handle_mq is redefined as extern instead of static.
2. add to call virtio_user_handle_mq in virtio_user_server_reconnect. 

Changes in V2:
1. fix a comment typo.
2. add feature negotiation in the processing of reconnection.

 drivers/net/virtio/virtio_user/vhost_user.c      |  3 +++
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 18 ++++++++++------
 drivers/net/virtio/virtio_user/virtio_user_dev.h |  1 +
 drivers/net/virtio/virtio_user_ethdev.c          | 27 ++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c
index a6df97a00..93e4d9213 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -263,6 +263,9 @@ vhost_user_sock(struct virtio_user_dev *dev,
 
 	PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
 
+	if (dev->is_server && vhostfd < 0)
+		return -1;
+
 	msg.request = req;
 	msg.flags = VHOST_USER_VERSION;
 	msg.size = 0;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 38b8bc90d..d50f98b36 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -435,7 +435,7 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
 		unlink(dev->path);
 }
 
-static uint8_t
+uint8_t
 virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
 {
 	uint16_t i;
@@ -447,11 +447,17 @@ virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
 		return -1;
 	}
 
-	for (i = 0; i < q_pairs; ++i)
-		ret |= dev->ops->enable_qp(dev, i, 1);
-	for (i = q_pairs; i < dev->max_queue_pairs; ++i)
-		ret |= dev->ops->enable_qp(dev, i, 0);
-
+	/* Server mode can't enable queue pairs if vhostfd is invalid,
+	 * always return 0 in this case.
+	 */
+	if (dev->vhostfd >= 0) {
+		for (i = 0; i < q_pairs; ++i)
+			ret |= dev->ops->enable_qp(dev, i, 1);
+		for (i = q_pairs; i < dev->max_queue_pairs; ++i)
+			ret |= dev->ops->enable_qp(dev, i, 0);
+	} else if (!dev->is_server) {
+		ret = ~0;
+	}
 	dev->queue_pairs = q_pairs;
 
 	return ret;
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index ade727e46..784f4752e 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -48,4 +48,5 @@ int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
 			 int cq, int queue_size, const char *mac, char **ifname);
 void virtio_user_dev_uninit(struct virtio_user_dev *dev);
 void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
+uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs);
 #endif
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 4e7b3c34f..f35fa8d27 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -30,6 +30,7 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 	int ret;
 	int flag;
 	int connectfd;
+	uint64_t features = dev->device_features;
 	struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
 
 	connectfd = accept(dev->listenfd, NULL, NULL);
@@ -37,6 +38,25 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 		return -1;
 
 	dev->vhostfd = connectfd;
+	if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES,
+				   &dev->device_features) < 0) {
+		PMD_INIT_LOG(ERR, "get_features failed: %s",
+			     strerror(errno));
+		return -1;
+	}
+
+	features &= ~dev->device_features;
+	/* For following bits, vhost-user doesn't really need to know */
+	features &= ~(1ull << VIRTIO_NET_F_MAC);
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
+	features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
+	features &= ~(1ull << VIRTIO_NET_F_STATUS);
+	if (features)
+		PMD_INIT_LOG(ERR, "WARNING: Some features 0x%" PRIx64 " are not supported by vhost-user!",
+			     features);
+
+	dev->features &= dev->device_features;
+
 	flag = fcntl(connectfd, F_GETFD);
 	fcntl(connectfd, F_SETFL, flag | O_NONBLOCK);
 
@@ -44,6 +64,13 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
 	if (ret < 0)
 		return -1;
 
+	if (dev->queue_pairs > 1) {
+		ret = virtio_user_handle_mq(dev, dev->queue_pairs);
+		if (ret != 0) {
+			PMD_INIT_LOG(ERR, "Fails to enable multi-queue pairs!");
+			return -1;
+		}
+	}
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
 		if (rte_intr_disable(eth_dev->intr_handle) < 0) {
 			PMD_DRV_LOG(ERR, "interrupt disable failed");
-- 
2.14.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-stable] [PATCH v4] net/virtio-user: fix multiple queues fail in server mode
  2018-05-11  3:31     ` [dpdk-stable] [PATCH v4] " zhiyong.yang
@ 2018-05-11 11:33       ` Ferruh Yigit
  0 siblings, 0 replies; 17+ messages in thread
From: Ferruh Yigit @ 2018-05-11 11:33 UTC (permalink / raw)
  To: zhiyong.yang, dev; +Cc: stable, tiwei.bie, maxime.coquelin

On 5/11/2018 4:31 AM, zhiyong.yang@intel.com wrote:
> This patch fixes multiple queues failure when virtio-user works in
> server mode.
> 
> This patch adds feature negotiation in the processing of virtio-user
> connection and enables multiple-queue pairs.
> 
> Fixes: bd8f50a45d0f ("net/virtio-user: support server mode")
> Cc: stable@dpdk.org
> Cc: tiwei.bie@intel.com
> Cc: ferruh.yigit@intel.com
> Cc: maxime.coquelin@redhat.com
> 
> Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-05-11 11:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09  9:49 [dpdk-stable] [PATCH] net/virtio-user: fix multiple queues fail in server mode zhiyong.yang
2018-05-09 14:48 ` Ferruh Yigit
2018-05-10  0:48   ` Tiwei Bie
2018-05-10  1:28   ` Yang, Zhiyong
2018-05-10  1:38     ` Yang, Zhiyong
2018-05-10  2:47 ` [dpdk-stable] [dpdk-dev] " Tiwei Bie
2018-05-10  3:04   ` Yang, Zhiyong
2018-05-10  4:42     ` Tiwei Bie
2018-05-10  9:36 ` [dpdk-stable] [PATCH v2] " zhiyong.yang
2018-05-10 10:23   ` Tiwei Bie
2018-05-10 14:01     ` Yang, Zhiyong
2018-05-10 14:19       ` Tiwei Bie
2018-05-11  2:12   ` [dpdk-stable] [PATCH v3] " zhiyong.yang
2018-05-11  2:49     ` Tiwei Bie
2018-05-11  3:01       ` Yang, Zhiyong
2018-05-11  3:31     ` [dpdk-stable] [PATCH v4] " zhiyong.yang
2018-05-11 11:33       ` Ferruh Yigit

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).