[dpdk-dev] net/virtio-user: fix multiple queues fail in server mode
Checks
Commit Message
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(+)
Comments
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;
>
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;
> >
>
> -----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
> -----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.
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
>
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
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
@@ -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;
@@ -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;