From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 0BF7E1B293 for ; Thu, 5 Jul 2018 09:20:46 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FE6E87A72; Thu, 5 Jul 2018 07:20:46 +0000 (UTC) Received: from [10.36.112.37] (ovpn-112-37.ams2.redhat.com [10.36.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93D78111AF05; Thu, 5 Jul 2018 07:20:39 +0000 (UTC) To: Tiwei Bie Cc: zhihong.wang@intel.com, jfreimann@redhat.com, dev@dpdk.org, mst@redhat.com, jasowang@redhat.com, wexu@redhat.com References: <20180704215438.5579-1-maxime.coquelin@redhat.com> <20180704215438.5579-15-maxime.coquelin@redhat.com> <20180705051241.GA20322@debian> From: Maxime Coquelin Message-ID: <6e3e160a-7276-dc34-7188-c6334b3d04d5@redhat.com> Date: Thu, 5 Jul 2018 09:20:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180705051241.GA20322@debian> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Jul 2018 07:20:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Jul 2018 07:20:46 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' Subject: Re: [dpdk-dev] [PATCH v7 14/15] vhost: add notification for packed ring X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2018 07:20:47 -0000 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); >> +} >> + > [...] >