DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: zhihong.wang@intel.com, jfreimann@redhat.com, dev@dpdk.org,
	mst@redhat.com, jasowang@redhat.com, wexu@redhat.com
Subject: Re: [dpdk-dev] [PATCH v5 09/15] vhost: add shadow used ring support for packed rings
Date: Sat, 30 Jun 2018 00:08:05 +0800	[thread overview]
Message-ID: <20180629160805.GD31010@debian> (raw)
In-Reply-To: <20180622134327.18973-10-maxime.coquelin@redhat.com>

On Fri, Jun 22, 2018 at 03:43:21PM +0200, Maxime Coquelin wrote:
[...]
> index 671b4b3bf..62d49f238 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -80,6 +80,12 @@ struct log_cache_entry {
>  	unsigned long val;
>  };
>  
> +struct vring_used_elem_packed {
> +	uint32_t id;

Id in packed ring is 16 bits long. Maybe it's better
to define it as uint16_t here.

> +	uint32_t len;
> +	uint32_t count;
> +};
> +
[...]
> +
> +static __rte_always_inline void
> +flush_shadow_used_ring_packed(struct virtio_net *dev,
> +			struct vhost_virtqueue *vq)
> +{
> +	int i;
> +	uint16_t used_idx = vq->last_used_idx;
> +
> +	/* Split loop in two to save memory barriers */
> +	for (i = 0; i < vq->shadow_used_idx; i++) {
> +		vq->desc_packed[used_idx].index = vq->shadow_used_packed[i].id;
> +		vq->desc_packed[used_idx].len = vq->shadow_used_packed[i].len;
> +
> +		used_idx += vq->shadow_used_packed[i].count;

used_idx may wrap.

> +	}
> +
> +	rte_smp_wmb();
> +
> +	for (i = 0; i < vq->shadow_used_idx; i++) {
> +		uint16_t flags;
> +
> +		if (vq->shadow_used_packed[i].len)
> +			flags = VRING_DESC_F_WRITE;
> +		else
> +			flags = 0;
> +
> +		if (vq->used_wrap_counter) {
> +			flags |= VRING_DESC_F_USED;
> +			flags |= VRING_DESC_F_AVAIL;
> +		} else {
> +			flags &= ~VRING_DESC_F_USED;
> +			flags &= ~VRING_DESC_F_AVAIL;
> +		}
> +
> +		vq->desc_packed[vq->last_used_idx].flags = flags;
> +
> +		vhost_log_cache_used_vring(dev, vq,
> +					vq->last_used_idx *
> +					sizeof(struct vring_desc_packed),
> +					sizeof(struct vring_desc_packed));
> +
> +		vq->last_used_idx += vq->shadow_used_packed[i].count;
> +		if (vq->last_used_idx >= vq->size) {
> +			vq->used_wrap_counter ^= 1;
> +			vq->last_used_idx -= vq->size;
> +		}
> +	}
> +
> +	rte_smp_wmb();
> +	vq->shadow_used_idx = 0;
> +	vhost_log_cache_sync(dev, vq);
> +}
> +
> +static __rte_always_inline void
> +update_shadow_used_ring_packed(struct vhost_virtqueue *vq,
> +			 uint16_t desc_idx, uint16_t len, uint16_t count)
> +{
> +	uint16_t i = vq->shadow_used_idx++;
> +
> +	vq->shadow_used_packed[i].id  = desc_idx;
> +	vq->shadow_used_packed[i].len = len;
> +	vq->shadow_used_packed[i].count = count;
>  }
>  
>  static inline void
> -- 
> 2.14.4
> 

  reply	other threads:[~2018-06-29 16:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 13:43 [dpdk-dev] [PATCH v5 00/15] Vhost: add support to packed ring layout Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 01/15] vhost: add virtio packed virtqueue defines Maxime Coquelin
2018-06-29 15:47   ` Tiwei Bie
2018-06-29 16:20     ` Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 02/15] vhost: add helpers for packed virtqueues Maxime Coquelin
2018-06-29 15:51   ` Tiwei Bie
2018-06-29 16:21     ` Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 03/15] vhost: vring address setup for packed queues Maxime Coquelin
2018-06-29 15:59   ` Tiwei Bie
2018-06-29 16:34     ` Maxime Coquelin
2018-06-30  2:18       ` Tiwei Bie
2018-07-01  9:58     ` Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 04/15] vhost: clear shadow used table index at flush time Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 05/15] vhost: make indirect desc table copy desc type agnostic Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 06/15] vhost: clear batch copy index at copy time Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 07/15] vhost: extract split ring handling from Rx and Tx functions Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 08/15] vhost: append shadow used ring function names with split Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 09/15] vhost: add shadow used ring support for packed rings Maxime Coquelin
2018-06-29 16:08   ` Tiwei Bie [this message]
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 10/15] vhost: create descriptor mapping function Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 11/15] vhost: add vector filling support for packed ring Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 12/15] vhost: add Rx " Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 13/15] vhost: add Tx " Maxime Coquelin
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 14/15] vhost: add notification " Maxime Coquelin
2018-06-29 16:22   ` Tiwei Bie
2018-06-22 13:43 ` [dpdk-dev] [PATCH v5 15/15] vhost: advertize packed ring layout support Maxime Coquelin

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=20180629160805.GD31010@debian \
    --to=tiwei.bie@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasowang@redhat.com \
    --cc=jfreimann@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mst@redhat.com \
    --cc=wexu@redhat.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

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

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