From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9C6C83250 for ; Fri, 5 Jan 2018 06:25:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jan 2018 21:25:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,317,1511856000"; d="scan'208";a="7559518" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 04 Jan 2018 21:25:27 -0800 Received: from fmsmsx126.amr.corp.intel.com (10.18.125.43) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 4 Jan 2018 21:25:27 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX126.amr.corp.intel.com (10.18.125.43) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 4 Jan 2018 21:25:26 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.159]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Fri, 5 Jan 2018 13:25:25 +0800 From: "Wang, Xiao W" To: "Chen, Junjie J" , "yliu@fridaylinux.org" , "maxime.coquelin@redhat.com" , "Bie, Tiwei" CC: "dev@dpdk.org" Thread-Topic: [PATCH v6] vhost: support virtqueue interrupt/notification suppression Thread-Index: AQHTfjC41F8EJS7Zn06Rqnezonu+QaNkzkHQ Date: Fri, 5 Jan 2018 05:25:24 +0000 Message-ID: References: <1514048153-82959-1-git-send-email-junjie.j.chen@intel.com> <1514310190-140916-1-git-send-email-junjie.j.chen@intel.com> In-Reply-To: <1514310190-140916-1-git-send-email-junjie.j.chen@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTljMDVkYjQtNmEwMS00YjM2LTgyZWMtNGRiZDc3MjIwOTBiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJSWXprMGJNaVlPajVxMVwvOU85bzNWT1NUK1wvWExuXC8rU2tRQ2lnQ3paUXF5ZUw0ZFZGQXBWdDI1MkZ5TmFzeTdmIn0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v6] vhost: support virtqueue interrupt/notification suppression 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: Fri, 05 Jan 2018 05:25:29 -0000 Hi, > -----Original Message----- > From: Chen, Junjie J > Sent: Wednesday, December 27, 2017 1:43 AM > To: Wang, Xiao W ; yliu@fridaylinux.org; > maxime.coquelin@redhat.com; Bie, Tiwei > Cc: dev@dpdk.org; Chen, Junjie J > Subject: [PATCH v6] vhost: support virtqueue interrupt/notification > suppression >=20 > The driver can suppress interrupt when VIRTIO_F_EVENT_IDX feature bit is > negotiated. The driver set vring flags to 0, and MAY use used_event in > available ring to advise device interrupt util reach an index specified > by used_event. The device ignore the lower bit of vring flags, and send > an interrupt when index reach used_event. >=20 > The device can suppress notification in a manner analogous to the ways > driver suppress interrupt. The device manipulates flags or avail_event in > the used ring in the same way the driver manipulates flags or used_event = in > available ring. >=20 > This patch is to enable this feature in vhost. >=20 > Signed-off-by: Junjie Chen >=20 > v6: > Use volatile qualifier to access avail event idx. >=20 > v5: > Remove updating avail event index in backend. >=20 > v2-v4: > Use definition of VIRTIO_F_EVENT_IDX from kernel. >=20 > --- > lib/librte_vhost/vhost.h | 3 +++ > lib/librte_vhost/virtio_net.c | 46 +++++++++++++++++++++++++++++--------= ----- > - > 2 files changed, 34 insertions(+), 15 deletions(-) >=20 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > index 1cc81c1..fc41c20 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -103,6 +103,8 @@ struct vhost_virtqueue { >=20 > uint16_t last_avail_idx; > uint16_t last_used_idx; > + /* Last used index we notify to front end. */ > + uint16_t signalled_used; > #define VIRTIO_INVALID_EVENTFD (-1) > #define VIRTIO_UNINITIALIZED_EVENTFD (-2) >=20 > @@ -211,6 +213,7 @@ struct vhost_msg { > (1ULL << VIRTIO_NET_F_GUEST_TSO4) | \ > (1ULL << VIRTIO_NET_F_GUEST_TSO6) | \ > (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \ > + (1ULL << VIRTIO_RING_F_EVENT_IDX) | \ > (1ULL << VIRTIO_NET_F_MTU) | \ > (1ULL << VIRTIO_F_IOMMU_PLATFORM)) >=20 > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c > index 6fee16e..f5777fc 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -52,6 +52,34 @@ >=20 > #define MAX_BATCH_LEN 256 >=20 > +#define vhost_used_event(vr) \ > + (*(volatile uint16_t*)&(vr)->avail->ring[(vr)->size]) > + > +static __rte_always_inline void > +vhost_notify(struct virtio_net *dev, struct vhost_virtqueue *vq) > +{ > + /* Don't notify guest if we don't reach index specified by guest. */ > + if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) { > + uint16_t old =3D vq->signalled_used; > + uint16_t new =3D vq->last_used_idx; > + > + LOG_DEBUG(VHOST_DATA, "%s: used_event_idx=3D%d, old=3D%d, > new=3D%d\n", > + __func__, > + vhost_used_event(vq), > + old, new); > + if (vring_need_event(vhost_used_event(vq), new, old) > + && (vq->callfd >=3D 0)) { > + vq->signalled_used =3D vq->last_used_idx; > + eventfd_write(vq->callfd, (eventfd_t) 1); > + } > + } else { > + /* Kick the guest if necessary. */ > + if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) > + && (vq->callfd >=3D 0)) > + eventfd_write(vq->callfd, (eventfd_t)1); > + } > +} > + > static bool > is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring) > { > @@ -410,11 +438,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t > queue_id, >=20 > /* flush used->idx update before we read avail->flags. */ > rte_mb(); > - > - /* Kick the guest if necessary. */ > - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) > - && (vq->callfd >=3D 0)) > - eventfd_write(vq->callfd, (eventfd_t)1); > + vhost_notify(dev, vq); > out: > if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > vhost_user_iotlb_rd_unlock(vq); > @@ -704,11 +728,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t > queue_id, >=20 > /* flush used->idx update before we read avail->flags. */ > rte_mb(); > - > - /* Kick the guest if necessary. */ > - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) > - && (vq->callfd >=3D 0)) > - eventfd_write(vq->callfd, (eventfd_t)1); > + vhost_notify(dev, vq); > } >=20 > out: > @@ -1106,11 +1126,7 @@ update_used_idx(struct virtio_net *dev, struct > vhost_virtqueue *vq, > vq->used->idx +=3D count; > vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx), > sizeof(vq->used->idx)); > - > - /* Kick guest if required. */ > - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) > - && (vq->callfd >=3D 0)) > - eventfd_write(vq->callfd, (eventfd_t)1); > + vhost_notify(dev, vq); > } >=20 > static __rte_always_inline struct zcopy_mbuf * > -- > 2.0.1 Reviewed-by: Xiao Wang