DPDK patches and discussions
 help / color / mirror / Atom feed
From: Victor Kaplansky <victork@redhat.com>
To: dev@dpdk.org
Cc: Marcel Apfelbaum <mapfelba@redhat.com>,
	Marc-Andre Lureau <mlureau@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [dpdk-dev] [PATCH] vhost-user: fix enabling of queue pair
Date: Fri, 20 Nov 2015 17:17:45 +0200	[thread overview]
Message-ID: <20151120171725-mutt-send-email-victork@redhat.com> (raw)
In-Reply-To: <1448026465-27460-1-git-send-email-victork@redhat.com>

On Fri, Nov 20, 2015 at 03:45:00PM +0200, Victor Kaplansky wrote:
> The VHOST_USER_SET_VRING_ENABLE request is sent for each queue in
> queue-pair separately. So, a queue-pair should be considered
> enabled only when both RX and TX queues are enabled.
> 
> The old code caused segfault when last TX queue was enabled.

Since the problem causes segfault, it's important to review this
soon before QEMU 2.5 is out.

Thanks,
-- Victor

> 
> Signed-off-by: Victor Kaplansky <victork@redhat.com>
> ---
>  lib/librte_vhost/vhost_user/virtio-net-user.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
> index d07452a..c06e53e 100644
> --- a/lib/librte_vhost/vhost_user/virtio-net-user.c
> +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
> @@ -317,21 +317,25 @@ user_set_vring_enable(struct vhost_device_ctx ctx,
>  		      struct vhost_vring_state *state)
>  {
>  	struct virtio_net *dev = get_device(ctx);
> -	uint16_t base_idx = state->index;
> +	uint16_t idx = state->index;
> +	uint16_t base_idx = (idx / VIRTIO_QNUM) * VIRTIO_QNUM;
>  	int enable = (int)state->num;
> +	int qpair_enabled;
>  
>  	RTE_LOG(INFO, VHOST_CONFIG,
>  		"set queue enable: %d to qp idx: %d\n",
>  		enable, state->index);
>  
> +	dev->virtqueue[idx]->enabled = enable;
> +	qpair_enabled =
> +		dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled &&
> +		dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled;
> +
>  	if (notify_ops->vring_state_changed) {
>  		notify_ops->vring_state_changed(dev, base_idx / VIRTIO_QNUM,
> -						enable);
> +						qpair_enabled);
>  	}
>  
> -	dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled = enable;
> -	dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled = enable;
> -
>  	return 0;
>  }
>  
> -- 
> --Victor

  reply	other threads:[~2015-11-20 15:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 13:45 Victor Kaplansky
2015-11-20 15:17 ` Victor Kaplansky [this message]
2015-11-23  3:22 ` Yuanhan Liu
2015-11-24  7:25 ` [dpdk-dev] [PATCH v2] " Yuanhan Liu
2015-11-24  7:43   ` Victor Kaplansky
2015-11-24 20:29     ` Thomas Monjalon

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=20151120171725-mutt-send-email-victork@redhat.com \
    --to=victork@redhat.com \
    --cc=dev@dpdk.org \
    --cc=mapfelba@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=mst@redhat.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).