dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Tetsuya Mukawa <mukawa@igel.co.jp>
Cc: dev@dpdk.org
Subject: Re: [PATCH 1/3] vhost: Fix return value of GET_VRING_BASE message
Date: Thu, 8 Oct 2015 13:54:52 +0800	[thread overview]
Message-ID: <20151008055452.GB3115@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1439977869-28091-1-git-send-email-mukawa@igel.co.jp>

On Wed, Aug 19, 2015 at 06:51:07PM +0900, Tetsuya Mukawa wrote:
> When vhost-user frontend sends GET_VRING_BASE, last used index of vring
> should be returned. In DPDK vhost library, 'last_used_idx' represents it.
> But the value can be over max index value.

That's true, and I guess it's a design. If you look at the linux
kernel vhost code, you will find that there is no such wrap, either.

> To return correct value to
> vhost frontend, it's needed to be masked.

So, it's the frontend job to get the right value, by wrapping it
within vring size.

	--yliu
> 
> Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> ---
>  lib/librte_vhost/virtio-net.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
> index b520ec5..144f301 100644
> --- a/lib/librte_vhost/virtio-net.c
> +++ b/lib/librte_vhost/virtio-net.c
> @@ -661,7 +661,8 @@ get_vring_base(struct vhost_device_ctx ctx, uint32_t index,
>  
>  	state->index = index;
>  	/* State->index refers to the queue index. The txq is 1, rxq is 0. */
> -	state->num = dev->virtqueue[state->index]->last_used_idx;
> +	state->num = dev->virtqueue[state->index]->last_used_idx
> +			& (dev->virtqueue[state->index]->size - 1);
>  
>  	return 0;
>  }
> -- 
> 2.1.4

      parent reply	other threads:[~2015-10-08  5:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-19  9:51 [PATCH 1/3] vhost: Fix return value of GET_VRING_BASE message Tetsuya Mukawa
2015-08-19  9:51 ` [PATCH 2/3] vhost: Fix RESET_OWNER handling not to close callfd Tetsuya Mukawa
2015-10-08  6:19   ` Yuanhan Liu
2015-08-19  9:51 ` [PATCH 3/3] vhost: Fix RESET_OWNER handling not to free virtqueue Tetsuya Mukawa
2015-09-25 13:12 ` [PATCH 1/3] vhost: Fix return value of GET_VRING_BASE message Thomas Monjalon
2015-09-28  6:38   ` Xie, Huawei
2015-10-08  5:54 ` Yuanhan Liu [this message]

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=20151008055452.GB3115@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=mukawa@igel.co.jp \
    /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).