From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E62A68DB5 for ; Wed, 9 Sep 2015 04:41:41 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 08 Sep 2015 19:41:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,493,1437462000"; d="scan'208";a="557988724" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by FMSMGA003.fm.intel.com with ESMTP; 08 Sep 2015 19:41:39 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 9 Sep 2015 10:41:38 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.210]) with mapi id 14.03.0224.002; Wed, 9 Sep 2015 10:41:37 +0800 From: "Ouyang, Changchun" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [PATCH 4/4] vhost: define callfd and kickfd as int type Thread-Index: AQHQ3iCPtDbXKS+To0WkMPcOL/s6yJ4zlMNA Date: Wed, 9 Sep 2015 02:41:37 +0000 Message-ID: References: <1440388485-13554-1-git-send-email-yuanhan.liu@linux.intel.com> <1440388485-13554-4-git-send-email-yuanhan.liu@linux.intel.com> In-Reply-To: <1440388485-13554-4-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 4/4] vhost: define callfd and kickfd as int type X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 02:41:42 -0000 > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Monday, August 24, 2015 11:55 AM > To: dev@dpdk.org > Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu > Subject: [PATCH 4/4] vhost: define callfd and kickfd as int type >=20 > So that we can remove the redundant (int) cast. >=20 > Signed-off-by: Yuanhan Liu > --- > examples/vhost/main.c | 6 ++--- > lib/librte_vhost/rte_virtio_net.h | 4 ++-- > lib/librte_vhost/vhost_rxtx.c | 6 ++--- > lib/librte_vhost/vhost_user/virtio-net-user.c | 16 +++++++------- > lib/librte_vhost/virtio-net.c | 32 +++++++++++++--------= ------ > 5 files changed, 32 insertions(+), 32 deletions(-) >=20 > diff --git a/examples/vhost/main.c b/examples/vhost/main.c index > 1b137b9..b090b25 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -1433,7 +1433,7 @@ put_desc_to_used_list_zcp(struct vhost_virtqueue > *vq, uint16_t desc_idx) >=20 > /* Kick the guest if necessary. */ > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > - eventfd_write((int)vq->callfd, 1); > + eventfd_write(vq->callfd, 1); Don't we need type conversion for '1' to eventfd_t here? > } >=20 > /* > @@ -1626,7 +1626,7 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct > vpool *vpool) >=20 > /* Kick guest if required. */ > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > - eventfd_write((int)vq->callfd, 1); > + eventfd_write(vq->callfd, 1); Same as above >=20 > return 0; > } > @@ -1774,7 +1774,7 @@ virtio_dev_rx_zcp(struct virtio_net *dev, struct > rte_mbuf **pkts, >=20 > /* Kick the guest if necessary. */ > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > - eventfd_write((int)vq->callfd, 1); > + eventfd_write(vq->callfd, 1); Same as above >=20 > return count; > } > diff --git a/lib/librte_vhost/rte_virtio_net.h > b/lib/librte_vhost/rte_virtio_net.h > index b9bf320..a037c15 100644 > --- a/lib/librte_vhost/rte_virtio_net.h > +++ b/lib/librte_vhost/rte_virtio_net.h > @@ -87,8 +87,8 @@ struct vhost_virtqueue { > uint16_t vhost_hlen; /**< Vhost header > length (varies depending on RX merge buffers. */ > volatile uint16_t last_used_idx; /**< Last index used > on the available ring */ > volatile uint16_t last_used_idx_res; /**< Used for > multiple devices reserving buffers. */ > - eventfd_t callfd; /**< Used to notify > the guest (trigger interrupt). */ > - eventfd_t kickfd; /**< Currently > unused as polling mode is enabled. */ > + int callfd; /**< Used to notify > the guest (trigger interrupt). */ > + int kickfd; /**< Currently > unused as polling mode is enabled. */ > struct buf_vector buf_vec[BUF_VECTOR_MAX]; /**< for > scatter RX. */ > } __rte_cache_aligned; >=20 > diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.= c > index d412293..887cdb6 100644 > --- a/lib/librte_vhost/vhost_rxtx.c > +++ b/lib/librte_vhost/vhost_rxtx.c > @@ -230,7 +230,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t > queue_id, >=20 > /* Kick the guest if necessary. */ > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > - eventfd_write((int)vq->callfd, 1); > + eventfd_write(vq->callfd, 1); > return count; > } >=20 > @@ -529,7 +529,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t > queue_id, >=20 > /* Kick the guest if necessary. */ > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > - eventfd_write((int)vq->callfd, 1); > + eventfd_write(vq->callfd, 1); > } >=20 > return count; > @@ -752,6 +752,6 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, > uint16_t queue_id, > vq->used->idx +=3D entry_success; > /* Kick guest if required. */ > if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) > - eventfd_write((int)vq->callfd, 1); > + eventfd_write(vq->callfd, 1); > return entry_success; > } > diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c > b/lib/librte_vhost/vhost_user/virtio-net-user.c > index c1ffc38..4689927 100644 > --- a/lib/librte_vhost/vhost_user/virtio-net-user.c > +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c > @@ -214,10 +214,10 @@ virtio_is_ready(struct virtio_net *dev) > rvq =3D dev->virtqueue[VIRTIO_RXQ]; > tvq =3D dev->virtqueue[VIRTIO_TXQ]; > if (rvq && tvq && rvq->desc && tvq->desc && > - (rvq->kickfd !=3D (eventfd_t)-1) && > - (rvq->callfd !=3D (eventfd_t)-1) && > - (tvq->kickfd !=3D (eventfd_t)-1) && > - (tvq->callfd !=3D (eventfd_t)-1)) { > + (rvq->kickfd !=3D -1) && > + (rvq->callfd !=3D -1) && > + (tvq->kickfd !=3D -1) && > + (tvq->callfd !=3D -1)) { > RTE_LOG(INFO, VHOST_CONFIG, > "virtio is now ready for processing.\n"); > return 1; > @@ -290,13 +290,13 @@ user_get_vring_base(struct vhost_device_ctx ctx, > * sent and only sent in vhost_vring_stop. > * TODO: cleanup the vring, it isn't usable since here. > */ > - if (((int)dev->virtqueue[VIRTIO_RXQ]->kickfd) >=3D 0) { > + if ((dev->virtqueue[VIRTIO_RXQ]->kickfd) >=3D 0) { > close(dev->virtqueue[VIRTIO_RXQ]->kickfd); > - dev->virtqueue[VIRTIO_RXQ]->kickfd =3D (eventfd_t)-1; > + dev->virtqueue[VIRTIO_RXQ]->kickfd =3D -1; > } > - if (((int)dev->virtqueue[VIRTIO_TXQ]->kickfd) >=3D 0) { > + if ((dev->virtqueue[VIRTIO_TXQ]->kickfd) >=3D 0) { > close(dev->virtqueue[VIRTIO_TXQ]->kickfd); > - dev->virtqueue[VIRTIO_TXQ]->kickfd =3D (eventfd_t)-1; > + dev->virtqueue[VIRTIO_TXQ]->kickfd =3D -1; > } >=20 > return 0; > diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.= c index > b670992..d0f1764 100644 > --- a/lib/librte_vhost/virtio-net.c > +++ b/lib/librte_vhost/virtio-net.c > @@ -190,14 +190,14 @@ cleanup_device(struct virtio_net *dev) > } >=20 > /* Close any event notifiers opened by device. */ > - if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >=3D 0) > - close((int)dev->virtqueue[VIRTIO_RXQ]->callfd); > - if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >=3D 0) > - close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd); > - if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >=3D 0) > - close((int)dev->virtqueue[VIRTIO_TXQ]->callfd); > - if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >=3D 0) > - close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd); > + if (dev->virtqueue[VIRTIO_RXQ]->callfd >=3D 0) > + close(dev->virtqueue[VIRTIO_RXQ]->callfd); > + if (dev->virtqueue[VIRTIO_RXQ]->kickfd >=3D 0) > + close(dev->virtqueue[VIRTIO_RXQ]->kickfd); > + if (dev->virtqueue[VIRTIO_TXQ]->callfd >=3D 0) > + close(dev->virtqueue[VIRTIO_TXQ]->callfd); > + if (dev->virtqueue[VIRTIO_TXQ]->kickfd >=3D 0) > + close(dev->virtqueue[VIRTIO_TXQ]->kickfd); > } >=20 > /* > @@ -261,10 +261,10 @@ init_device(struct virtio_net *dev) > memset(dev->virtqueue[VIRTIO_RXQ], 0, sizeof(struct > vhost_virtqueue)); > memset(dev->virtqueue[VIRTIO_TXQ], 0, sizeof(struct > vhost_virtqueue)); >=20 > - dev->virtqueue[VIRTIO_RXQ]->kickfd =3D (eventfd_t)-1; > - dev->virtqueue[VIRTIO_RXQ]->callfd =3D (eventfd_t)-1; > - dev->virtqueue[VIRTIO_TXQ]->kickfd =3D (eventfd_t)-1; > - dev->virtqueue[VIRTIO_TXQ]->callfd =3D (eventfd_t)-1; > + dev->virtqueue[VIRTIO_RXQ]->kickfd =3D -1; > + dev->virtqueue[VIRTIO_RXQ]->callfd =3D -1; > + dev->virtqueue[VIRTIO_TXQ]->kickfd =3D -1; > + dev->virtqueue[VIRTIO_TXQ]->callfd =3D -1; >=20 > /* Backends are set to -1 indicating an inactive device. */ > dev->virtqueue[VIRTIO_RXQ]->backend =3D VIRTIO_DEV_STOPPED; > @@ -685,8 +685,8 @@ set_vring_call(struct vhost_device_ctx ctx, struct > vhost_vring_file *file) > /* file->index refers to the queue index. The txq is 1, rxq is 0. */ > vq =3D dev->virtqueue[file->index]; >=20 > - if ((int)vq->callfd >=3D 0) > - close((int)vq->callfd); > + if (vq->callfd >=3D 0) > + close(vq->callfd); >=20 > vq->callfd =3D file->fd; >=20 > @@ -711,8 +711,8 @@ set_vring_kick(struct vhost_device_ctx ctx, struct > vhost_vring_file *file) > /* file->index refers to the queue index. The txq is 1, rxq is 0. */ > vq =3D dev->virtqueue[file->index]; >=20 > - if ((int)vq->kickfd >=3D 0) > - close((int)vq->kickfd); > + if (vq->kickfd >=3D 0) > + close(vq->kickfd); >=20 > vq->kickfd =3D file->fd; >=20 > -- > 1.9.0