vhost: remove redundant ;
PATCH 1/4 vhost: remove redundant ;
--- lib/librte_vhost/vhost_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_vhost/vhost_rxtx.c +1 -1
@@ -185,7 +185,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, } } len_to_cpy =RTE_MIN (data_len - offset, desc->len - vb_offset); - }; + }/* Update used ring with desc information */ vq->used->ring[res_cur_idx & (vq->size - 1)].id =
Signature · 1 line
1.9.0
PATCH 2/4 vhost: fix typo
_det => _dev
--- lib/librte_vhost/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_vhost/virtio-net.c +1 -1
@@ -485,7 +485,7 @@ set_vring_num(struct vhost_device_ctx ctx, struct vhost_vring_state *state) }/* -* Reallocate virtio_det and vhost_virtqueue data structure to make them on the +* Reallocate virtio_dev and vhost_virtqueue data structure to make them on the * same numa node as the memory of vring descriptor. */ #ifdef RTE_LIBRTE_VHOST_NUMA
Signature · 1 line
1.9.0
PATCH 3/4 vhost: get rid of duplicate code
In reply to Yuanhan Liu--- lib/librte_vhost/vhost_user/vhost-net-user.c | 36 ++++++++-------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
lib/librte_vhost/vhost_user/vhost-net-user.c +10 -26
@@ -329,32 +329,16 @@ vserver_message_handler(int connfd, void *dat, int *remove) ctx.fh = cfd_ctx->fh; ret =read_vhost_message (connfd, &msg); -if (ret <0 ) { -RTE_LOG (ERR ,VHOST_CONFIG , -"vhost read message failed\n" ); - -close (connfd); - *remove =1 ; -free (cfd_ctx); -user_destroy_device (ctx); - ops->destroy_device (ctx); - -return ; - }else if (ret ==0 ) { -RTE_LOG (INFO ,VHOST_CONFIG , -"vhost peer closed\n" ); - -close (connfd); - *remove =1 ; -free (cfd_ctx); -user_destroy_device (ctx); - ops->destroy_device (ctx); - -return ; - } -if (msg.request >VHOST_USER_MAX ) { -RTE_LOG (ERR ,VHOST_CONFIG , -"vhost read incorrect message\n" ); +if (ret <=0 || msg.request >VHOST_USER_MAX ) { +if (ret <0 ) +RTE_LOG (ERR ,VHOST_CONFIG , +"vhost read message failed\n" ); +else if (ret ==0 ) +RTE_LOG (INFO ,VHOST_CONFIG , +"vhost peer closed\n" ); +else +RTE_LOG (ERR ,VHOST_CONFIG , +"vhost read incorrect message\n" );close (connfd); *remove =1 ;
Signature · 1 line
1.9.0
PATCH 4/4 vhost: define callfd and kickfd as int type
In reply to Yuanhan LiuSo that we can remove the redundant (int) cast.
--- 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(-)
examples/vhost/main.c +3 -3
@@ -1433,7 +1433,7 @@ put_desc_to_used_list_zcp(struct vhost_virtqueue *vq, uint16_t desc_idx)/* 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 ); }/*
@@ -1626,7 +1626,7 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool)/* 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 0 ; }
@@ -1774,7 +1774,7 @@ virtio_dev_rx_zcp(struct virtio_net *dev, struct rte_mbuf **pkts,/* 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; }
lib/librte_vhost/rte_virtio_net.h +2 -2
@@ -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;
lib/librte_vhost/vhost_rxtx.c +3 -3
@@ -230,7 +230,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,/* 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; }
@@ -529,7 +529,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,/* 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;
@@ -752,6 +752,6 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, vq->used->idx += 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; }
lib/librte_vhost/vhost_user/virtio-net-user.c +8 -8
@@ -214,10 +214,10 @@ virtio_is_ready(struct virtio_net *dev) rvq = dev->virtqueue[VIRTIO_RXQ ]; tvq = dev->virtqueue[VIRTIO_TXQ ];if (rvq && tvq && rvq->desc && tvq->desc && - (rvq->kickfd != (eventfd_t)-1 ) && - (rvq->callfd != (eventfd_t)-1 ) && - (tvq->kickfd != (eventfd_t)-1 ) && - (tvq->callfd != (eventfd_t)-1 )) { + (rvq->kickfd !=-1 ) && + (rvq->callfd !=-1 ) && + (tvq->kickfd !=-1 ) && + (tvq->callfd !=-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) >=0 ) { +if ((dev->virtqueue[VIRTIO_RXQ ]->kickfd) >=0 ) {close (dev->virtqueue[VIRTIO_RXQ ]->kickfd); - dev->virtqueue[VIRTIO_RXQ ]->kickfd = (eventfd_t)-1 ; + dev->virtqueue[VIRTIO_RXQ ]->kickfd =-1 ; } -if (((int )dev->virtqueue[VIRTIO_TXQ ]->kickfd) >=0 ) { +if ((dev->virtqueue[VIRTIO_TXQ ]->kickfd) >=0 ) {close (dev->virtqueue[VIRTIO_TXQ ]->kickfd); - dev->virtqueue[VIRTIO_TXQ ]->kickfd = (eventfd_t)-1 ; + dev->virtqueue[VIRTIO_TXQ ]->kickfd =-1 ; }return 0 ;
lib/librte_vhost/virtio-net.c +16 -16
@@ -190,14 +190,14 @@ cleanup_device(struct virtio_net *dev) }/* Close any event notifiers opened by device. */ -if ((int )dev->virtqueue[VIRTIO_RXQ ]->callfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_RXQ ]->callfd); -if ((int )dev->virtqueue[VIRTIO_RXQ ]->kickfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_RXQ ]->kickfd); -if ((int )dev->virtqueue[VIRTIO_TXQ ]->callfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_TXQ ]->callfd); -if ((int )dev->virtqueue[VIRTIO_TXQ ]->kickfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_TXQ ]->kickfd); +if (dev->virtqueue[VIRTIO_RXQ ]->callfd >=0 ) +close (dev->virtqueue[VIRTIO_RXQ ]->callfd); +if (dev->virtqueue[VIRTIO_RXQ ]->kickfd >=0 ) +close (dev->virtqueue[VIRTIO_RXQ ]->kickfd); +if (dev->virtqueue[VIRTIO_TXQ ]->callfd >=0 ) +close (dev->virtqueue[VIRTIO_TXQ ]->callfd); +if (dev->virtqueue[VIRTIO_TXQ ]->kickfd >=0 ) +close (dev->virtqueue[VIRTIO_TXQ ]->kickfd); }/*
@@ -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 )); - dev->virtqueue[VIRTIO_RXQ ]->kickfd = (eventfd_t)-1 ; - dev->virtqueue[VIRTIO_RXQ ]->callfd = (eventfd_t)-1 ; - dev->virtqueue[VIRTIO_TXQ ]->kickfd = (eventfd_t)-1 ; - dev->virtqueue[VIRTIO_TXQ ]->callfd = (eventfd_t)-1 ; + dev->virtqueue[VIRTIO_RXQ ]->kickfd =-1 ; + dev->virtqueue[VIRTIO_RXQ ]->callfd =-1 ; + dev->virtqueue[VIRTIO_TXQ ]->kickfd =-1 ; + dev->virtqueue[VIRTIO_TXQ ]->callfd =-1 ;/* Backends are set to -1 indicating an inactive device. */ dev->virtqueue[VIRTIO_RXQ ]->backend =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 = dev->virtqueue[file->index]; -if ((int )vq->callfd >=0 ) -close ((int )vq->callfd); +if (vq->callfd >=0 ) +close (vq->callfd); vq->callfd = file->fd;
@@ -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 = dev->virtqueue[file->index]; -if ((int )vq->kickfd >=0 ) -close ((int )vq->kickfd); +if (vq->kickfd >=0 ) +close (vq->kickfd); vq->kickfd = file->fd;
Signature · 1 line
1.9.0
Re: [PATCH 2/4] vhost: fix typo
In reply to Yuanhan LiuQuoted 9 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 2/4] vhost: fix typo
Quoted 3 lines
_det=>_devSigned-off-by Yuanhan Liu <[email protected]>
Re: [PATCH 3/4] vhost: get rid of duplicate code
In reply to Yuanhan LiuQuoted 10 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 3/4] vhost: get rid of duplicate codeSigned-off-by Yuanhan Liu <[email protected]>
Re: [PATCH 4/4] vhost: define callfd and kickfd as int type
In reply to Yuanhan LiuQuoted 33 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 4/4] vhost: define callfd and kickfd as int typeSo that we can remove the redundant (int) cast.
Signed-off-by Yuanhan Liu <[email protected]>---
lib/librte_vhost/rte_virtio_net.h +0
-0@@ -87,8 +87,8 @@ struct vhost_virtqueue {uint16_t vhost_hlen;/**< Vhost header length (varies depending on RX merge buffers. */
volatileuint16_tlast_used_idx; /**< Last index used
on the available ring */
volatileuint16_tlast_used_idx_res; /**< Used for
multiple devices reserving buffers. */lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t kickfd;/**< Currently unused as polling mode is enabled. */
lib/librte_vhost/rte_virtio_net.h +1
-0+int callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +1
-0+int kickfd;/**< Currently
Quoted 1 line
unused as polling mode is enabled. */
I don't think we have to change it from 8B(eventfd_t is defined as uint64_t) to 4B, Any benefit for this change?
Quoted 10 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 1/4] vhost: remove redundant ;Signed-off-by Yuanhan Liu <[email protected]>
Quoted 21 lines
--- lib/librte_vhost/vhost_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_vhost/vhost_rxtx.c +1
-1@@ -185,7 +185,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, } } len_to_cpy =RTE_MIN (data_len - offset, desc->len - vb_offset); - }; + }lib/librte_vhost/vhost_rxtx.c +0
-1/* Update used ring with desc information */ vq->used->ring[res_cur_idx & (vq->size - 1)].id = --1.9.0
Re: [PATCH 4/4] vhost: define callfd and kickfd as int type
In reply to Ouyang, ChangchunQuoted 29 lines · Changchun
Quoted 29 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 4/4] vhost: define callfd and kickfd as int typeSo that we can remove the redundant (int) cast.
Signed-off-by Yuanhan Liu <[email protected]>---
lib/librte_vhost/rte_virtio_net.h +0
-0@@ -87,8 +87,8 @@ struct vhost_virtqueue {uint16_t vhost_hlen;/**< Vhost header length (varies depending on RX merge buffers. */
volatileuint16_tlast_used_idx; /**< Last index used
on the available ring */
volatileuint16_tlast_used_idx_res; /**< Used for
multiple devices reserving buffers. */lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t kickfd;/**< Currently
Quoted 8 lines
Quoted 5 lines
unused as polling mode is enabled. */
lib/librte_vhost/rte_virtio_net.h +1
-0+int callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +1
-0+int kickfd;/**< Currently unused as polling mode is enabled. */
I don't think we have to change it from 8B(eventfd_t is defined as
uint64_t) to 4B, Any benefit for this change?
As I stated in the commit log, to remove the redundant (int) cast. Casts like following are a bit ugly:
if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0)
close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);On the other hand, why it has to be uint64_t? The caller side sends the message(be more precisely, qemu) actually uses int type.
--yliu
Re: [PATCH 4/4] vhost: define callfd and kickfd as int type
Quoted 48 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Wednesday, September 9, 2015 9:55 AM
To: Ouyang, Changchun
Cc: [email protected]; Xie, Huawei
Subject: Re: [PATCH 4/4] vhost: define callfd and kickfd as int typeQuoted 29 lines · Changchun
Quoted 29 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 4/4] vhost: define callfd and kickfd as int typeSo that we can remove the redundant (int) cast.
Signed-off-by Yuanhan Liu <[email protected]>---
lib/librte_vhost/rte_virtio_net.h +0
-0@@ -87,8 +87,8 @@ struct vhost_virtqueue {uint16_t vhost_hlen;/**< Vhost header length (varies depending on RX merge buffers. */
volatileuint16_tlast_used_idx; /**< Last index used
on the available ring */
volatileuint16_tlast_used_idx_res; /**< Used for
multiple devices reserving buffers. */lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t kickfd;/**< Currently Quoted 8 lines
Quoted 5 lines
unused as polling mode is enabled. */
lib/librte_vhost/rte_virtio_net.h +1
-0+int callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +1
-0+int kickfd;/**< Currently unused as polling mode is enabled. */
I don't think we have to change it from 8B(eventfd_t is defined as
uint64_t) to 4B, Any benefit for this change?
Quoted 9 lines
As I stated in the commit log, to remove the redundant (int) cast. Casts like following are a bit ugly:
if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0) close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);On the other hand, why it has to be
uint64_t? The caller side sends themessage(be more precisely, qemu)actually uses int type.
Agree, qemu use 32 bit for the callfd and kickfd.
It could use int.
Well, there is another comment in other place in this patch, I will send out soon.
Quoted 1 line
--yliu
Re: [PATCH 4/4] vhost: define callfd and kickfd as int type
In reply to Yuanhan LiuQuoted 25 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 4/4] vhost: define callfd and kickfd as int typeSo that we can remove the redundant (int) cast.
Signed-off-by Yuanhan Liu <[email protected]>--- 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(-)examples/vhost/main.c index renamed from examples/vhost/main.c +0
-01b137b9..b090b25 100644
examples/vhost/main.c put_desc_to_used_list_zcp(struct vhost_virtqueue · line 1437
Quoted 6 lines
examples/vhost/main.c +1
-1@@ -1433,7 +1433,7 @@ put_desc_to_used_list_zcp(struct vhost_virtqueue *vq, uint16_t desc_idx)/* 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?
examples/vhost/main.c txmbuf_clean_zcp(struct virtio_net *dev, struct · line 1630
Quoted 10 lines
examples/vhost/main.c +0
-0}/*
examples/vhost/main.c +1
-1@@ -1626,7 +1626,7 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool)/* 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
examples/vhost/main.c virtio_dev_rx_zcp(struct virtio_net *dev, struct · line 1778
Quoted 10 lines
examples/vhost/main.c +1
-1return 0 ; }@@ -1774,7 +1774,7 @@ virtio_dev_rx_zcp(struct virtio_net *dev, struct rte_mbuf **pkts,/* 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
Quoted 168 lines
examples/vhost/main.c +0
-0return count; }lib/librte_vhost/rte_virtio_net.h +0
-0@@ -87,8 +87,8 @@ struct vhost_virtqueue {uint16_t vhost_hlen;/**< Vhost header length (varies depending on RX merge buffers. */
volatileuint16_tlast_used_idx; /**< Last index used
on the available ring */
volatileuint16_tlast_used_idx_res; /**< Used for
multiple devices reserving buffers. */lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +0
-1-eventfd_t kickfd;/**< Currently unused as polling mode is enabled. */
lib/librte_vhost/rte_virtio_net.h +1
-0+int callfd;/**< Used to notify the guest (trigger interrupt). */
lib/librte_vhost/rte_virtio_net.h +1
-0+int kickfd;/**< Currently unused as polling mode is enabled. */
structbuf_vectorbuf_vec[BUF_VECTOR_MAX]; /**< for
scatter RX. */
}__rte_cache_aligned;lib/librte_vhost/vhost_rxtx.c +2
-2@@ -230,7 +230,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,/* 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; }@@ -529,7 +529,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,/* 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 ); }lib/librte_vhost/vhost_rxtx.c +1
-1return count;@@ -752,6 +752,6 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,uint16_t queue_id, vq->used->idx += 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;}
lib/librte_vhost/vhost_user/virtio-net-user.c +8
-8@@ -214,10 +214,10 @@ virtio_is_ready(struct virtio_net *dev) rvq = dev->virtqueue[VIRTIO_RXQ ]; tvq = dev->virtqueue[VIRTIO_TXQ ];if (rvq && tvq && rvq->desc && tvq->desc && - (rvq->kickfd != (eventfd_t)-1 ) && - (rvq->callfd != (eventfd_t)-1 ) && - (tvq->kickfd != (eventfd_t)-1 ) && - (tvq->callfd != (eventfd_t)-1 )) { + (rvq->kickfd !=-1 ) && + (rvq->callfd !=-1 ) && + (tvq->kickfd !=-1 ) && + (tvq->callfd !=-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) >=0 ) { +if ((dev->virtqueue[VIRTIO_RXQ ]->kickfd) >=0 ) {close (dev->virtqueue[VIRTIO_RXQ ]->kickfd); - dev->virtqueue[VIRTIO_RXQ ]->kickfd = (eventfd_t)-1 ; + dev->virtqueue[VIRTIO_RXQ ]->kickfd =-1 ; } -if (((int )dev->virtqueue[VIRTIO_TXQ ]->kickfd) >=0 ) { +if ((dev->virtqueue[VIRTIO_TXQ ]->kickfd) >=0 ) {close (dev->virtqueue[VIRTIO_TXQ ]->kickfd); - dev->virtqueue[VIRTIO_TXQ ]->kickfd = (eventfd_t)-1 ; + dev->virtqueue[VIRTIO_TXQ ]->kickfd =-1 ; }return 0 ;lib/librte_vhost/virtio-net.c index renamed from lib/librte_vhost/virtio-net.c +0
-0b670992..d0f1764 100644
lib/librte_vhost/virtio-net.c +12
-12@@ -190,14 +190,14 @@ cleanup_device(struct virtio_net *dev) }/* Close any event notifiers opened by device. */ -if ((int )dev->virtqueue[VIRTIO_RXQ ]->callfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_RXQ ]->callfd); -if ((int )dev->virtqueue[VIRTIO_RXQ ]->kickfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_RXQ ]->kickfd); -if ((int )dev->virtqueue[VIRTIO_TXQ ]->callfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_TXQ ]->callfd); -if ((int )dev->virtqueue[VIRTIO_TXQ ]->kickfd >=0 ) -close ((int )dev->virtqueue[VIRTIO_TXQ ]->kickfd); +if (dev->virtqueue[VIRTIO_RXQ ]->callfd >=0 ) +close (dev->virtqueue[VIRTIO_RXQ ]->callfd); +if (dev->virtqueue[VIRTIO_RXQ ]->kickfd >=0 ) +close (dev->virtqueue[VIRTIO_RXQ ]->kickfd); +if (dev->virtqueue[VIRTIO_TXQ ]->callfd >=0 ) +close (dev->virtqueue[VIRTIO_TXQ ]->callfd); +if (dev->virtqueue[VIRTIO_TXQ ]->kickfd >=0 ) +close (dev->virtqueue[VIRTIO_TXQ ]->kickfd); }/* @@ -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 )); - dev->virtqueue[VIRTIO_RXQ ]->kickfd = (eventfd_t)-1 ; - dev->virtqueue[VIRTIO_RXQ ]->callfd = (eventfd_t)-1 ; - dev->virtqueue[VIRTIO_TXQ ]->kickfd = (eventfd_t)-1 ; - dev->virtqueue[VIRTIO_TXQ ]->callfd = (eventfd_t)-1 ; + dev->virtqueue[VIRTIO_RXQ ]->kickfd =-1 ; + dev->virtqueue[VIRTIO_RXQ ]->callfd =-1 ; + dev->virtqueue[VIRTIO_TXQ ]->kickfd =-1 ; + dev->virtqueue[VIRTIO_TXQ ]->callfd =-1 ;lib/librte_vhost/virtio-net.c +4
-5/* Backends are set to -1 indicating an inactive device. */ dev->virtqueue[VIRTIO_RXQ ]->backend =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 = dev->virtqueue[file->index]; -if ((int )vq->callfd >=0 ) -close ((int )vq->callfd); +if (vq->callfd >=0 ) +close (vq->callfd); vq->callfd = file->fd;@@ -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 = dev->virtqueue[file->index]; -if ((int )vq->kickfd >=0 ) -close ((int )vq->kickfd); +if (vq->kickfd >=0 ) +close (vq->kickfd); vq->kickfd = file->fd; --1.9.0
Re: [PATCH 4/4] vhost: define callfd and kickfd as int type
Quoted 27 lines · Changchun
Quoted 27 lines
-----Original Message-----
From: Yuanhan Liu [mailto:[email protected]]
Sent: Monday, August 24, 2015 11:55 AM
To: [email protected]
Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
Subject: [PATCH 4/4] vhost: define callfd and kickfd as int typeSo that we can remove the redundant (int) cast.
Signed-off-by Yuanhan Liu <[email protected]>--- 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(-)examples/vhost/main.c index renamed from examples/vhost/main.c +0
-01b137b9..b090b25 100644
examples/vhost/main.c +0
-0@@ -1433,7 +1433,7 @@ put_desc_to_used_list_zcp(struct vhost_virtqueue *vq, uint16_t desc_idx)
Quoted 6 lines
examples/vhost/main.c put_desc_to_used_list_zcp(struct vhost_virtqueue *vq, uint16_t desc_idx) · line 1436
Quoted 4 lines
examples/vhost/main.c +1
-1/* 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_there?
Nope. See eventfd_write man page:
int eventfd_read(int fd, eventfd_t *value); int eventfd_write(int fd, eventfd_t value);
--yliu
Re: [PATCH 3/4] vhost: get rid of duplicate code
In reply to Yuanhan LiuQuoted 1 line · Yuanhan Liu
Signed-off-by Yuanhan Liu <[email protected]>
Quoted 5 lines
--- lib/librte_vhost/vhost_user/vhost-net-user.c | 36 ++++++++-------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
Re: [PATCH 2/4] vhost: fix typo
In reply to Yuanhan LiuQuoted 3 lines · Yuanhan Liu
_det=>_devSigned-off-by Yuanhan Liu <[email protected]>
Quoted 17 lines
--- lib/librte_vhost/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_vhost/virtio-net.c +1
-1@@ -485,7 +485,7 @@ set_vring_num(struct vhost_device_ctx ctx, struct vhost_vring_state *state) }/* -* Reallocate virtio_det and vhost_virtqueue data structure to make them on the +* Reallocate virtio_dev and vhost_virtqueue data structure to make them on the * same numa node as the memory of vring descriptor. */ #ifdef RTE_LIBRTE_VHOST_NUMA
Quoted 1 line · Yuanhan Liu
Signed-off-by Yuanhan Liu <[email protected]>
Quoted 17 lines
--- lib/librte_vhost/vhost_rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_vhost/vhost_rxtx.c +1
-1@@ -185,7 +185,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, } } len_to_cpy =RTE_MIN (data_len - offset, desc->len - vb_offset); - }; + }/* Update used ring with desc information */ vq->used->ring[res_cur_idx & (vq->size - 1)].id =