DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: Tiwei Bie <tiwei.bie@intel.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 v7 14/15] vhost: add notification for packed ring
Date: Thu, 5 Jul 2018 09:20:37 +0200	[thread overview]
Message-ID: <6e3e160a-7276-dc34-7188-c6334b3d04d5@redhat.com> (raw)
In-Reply-To: <20180705051241.GA20322@debian>



On 07/05/2018 07:12 AM, Tiwei Bie wrote:
> On Wed, Jul 04, 2018 at 11:54:37PM +0200, Maxime Coquelin wrote:
> [...]
>> @@ -225,6 +231,15 @@ struct vring_desc_packed {
>>   	uint16_t index;
>>   	uint16_t flags;
>>   };
>> +
>> +#define VRING_EVENT_F_ENABLE 0x0
>> +#define VRING_EVENT_F_DISABLE 0x1
>> +#define VRING_EVENT_F_DESC 0x2
>> +
>> +struct vring_packed_desc_event {
>> +	uint16_t desc_event_off_wrap;
>> +	uint16_t desc_event_flags;
>> +};
> 
> As all above types (including struct vring_desc_packed)
> and macros are being protected by VIRTIO_F_RING_PACKED,
> and they won't be defined if VIRTIO_F_RING_PACKED is
> defined in kernel header. We may want to unify the names.
> 
> For the types, we may have below types defined in
> linux uapi:
> 
> struct vring_packed;
> struct vring_packed_desc;
> struct vring_packed_desc_event;
> 
> They can also be named as:
> 
> struct vring_packed;
> struct vring_desc_packed;
> struct vring_packed_desc_event;
> 
> We need to choose one of them or something else.
> 
> For the `struct vring_packed_desc_event`, it can
> be defined as:
> 
> struct vring_packed_desc_event {
> 	uint16_t off_wrap;
> 	uint16_t flags;
> };
> 
> or
> 
> struct vring_packed_desc_event {
> 	uint16_t desc_event_off_wrap;
> 	uint16_t desc_event_flags;
> };
> 
> We need to choose one of them or something else.
> 
> For the `struct vring_packed_desc`, it can be
> defined as:
> 
> struct vring_packed_desc {
> 	uint64_t addr;
> 	uint32_t len;
> 	uint16_t index;
> 	uint16_t flags;
> };
> 
> or
> 
> struct vring_packed_desc {
> 	uint64_t addr;
> 	uint32_t len;
> 	uint16_t id;		// index -> id
> 	uint16_t flags;
> };
> 
> We need to choose one of them or something else.
> 

I will align on Kernel header.

>>   #endif
>>   
> [...]
>> +static __rte_always_inline void
>> +vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)
>> +{
>> +	uint16_t old, new, off, off_wrap;
>> +	bool kick = false;
>> +
>> +	/* Flush used desc update. */
>> +	rte_smp_mb();
>> +
>> +	if (!(dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))) {
>> +		if (vq->driver_event->desc_event_flags !=
>> +				VRING_EVENT_F_DISABLE)
>> +			kick = true;
>> +		goto kick;
>> +	}
>> +
>> +	old = vq->signalled_used;
> 
> We also need to check whether vq->signalled_used is valid?

Yes, thanks for pointing this out.

So if not valid, I'll kick if desc_event_flags != VRING_EVENT_F_DISABLE.

>> +	new = vq->last_used_idx;
>> +	vq->signalled_used = new;
>> +
>> +	if (vq->driver_event->desc_event_flags != VRING_EVENT_F_DESC) {
>> +		if (vq->driver_event->desc_event_flags !=
>> +				VRING_EVENT_F_DISABLE)
>> +			kick = true;
>> +		goto kick;
>> +	}
>> +
>> +	rte_smp_rmb();
>> +
>> +	off_wrap = vq->driver_event->desc_event_off_wrap;
>> +	off = off_wrap & ~(1 << 15);
>> +
>> +	if (vq->used_wrap_counter != off_wrap >> 15)
>> +		off -= vq->size;
>> +
>> +	if (vhost_need_event(off, new, old))
>> +		kick = true;
> 
> If new <= old, old needs to -= vq->size?

Right, I'll fix it in next version.

Thanks!
Maxime
>> +kick:
>> +	if (kick)
>> +		eventfd_write(vq->callfd, (eventfd_t)1);
>> +}
>> +
> [...]
> 

  reply	other threads:[~2018-07-05  7:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 21:54 [dpdk-dev] [PATCH v7 00/15] Vhost: add support to packed ring layout Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 01/15] vhost: add virtio packed virtqueue defines Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 02/15] vhost: add helpers for packed virtqueues Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 03/15] vhost: vring address setup for packed queues Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 04/15] vhost: clear shadow used table index at flush time Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 05/15] vhost: make indirect desc table copy desc type agnostic Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 06/15] vhost: clear batch copy index at copy time Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 07/15] vhost: extract split ring handling from Rx and Tx functions Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 08/15] vhost: append shadow used ring function names with split Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 09/15] vhost: add shadow used ring support for packed rings Maxime Coquelin
2018-07-05  7:15   ` Tiwei Bie
2018-07-05 12:49     ` Maxime Coquelin
2018-07-05 14:03       ` Tiwei Bie
2018-07-05 14:28         ` Maxime Coquelin
2018-07-05 14:36           ` Tiwei Bie
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 10/15] vhost: create descriptor mapping function Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 11/15] vhost: add vector filling support for packed ring Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 12/15] vhost: add Rx " Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 13/15] vhost: add Tx " Maxime Coquelin
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 14/15] vhost: add notification " Maxime Coquelin
2018-07-05  5:12   ` Tiwei Bie
2018-07-05  7:20     ` Maxime Coquelin [this message]
2018-07-04 21:54 ` [dpdk-dev] [PATCH v7 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=6e3e160a-7276-dc34-7188-c6334b3d04d5@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jasowang@redhat.com \
    --cc=jfreimann@redhat.com \
    --cc=mst@redhat.com \
    --cc=tiwei.bie@intel.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).