virtio: Fix vring entry number issue
PATCH v2 1/1 virtio: Fix vring entry number issue
-- V1 change:
Fix one issue in virtio TX: it needs one more vring descriptor to hold the virtio header when transmitting packets, it is used later to determine whether to free more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the circumstance of only 1 descriptor in the vring free list.
-- V2 change:
Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtio header) to put packets to transmit queue.
--- lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/librte_pmd_virtio/virtio_rxtx.c +8 -2
@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t )(likely (nb_used <VIRTIO_MBUF_BURST_SZ ) ? nb_used :VIRTIO_MBUF_BURST_SZ );while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt +1 ;int deq_cnt =RTE_MIN (need, (int )num); num -= (deq_cnt >0 ) ? deq_cnt :0 ;
@@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) deq_cnt--; } -if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int )tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt +1 ; +/* +* Zero or negative value indicates it has enough free +* decriptors to transmit. +*/ +if (need <=0 ) { txm = tx_pkts[nb_tx];/* Enqueue Packet buffers */ error =virtqueue_enqueue_xmit (txvq, txm);
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1413014735-24693-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH v3 1/1 virtio: Fix vring entry number issue
-- V1 change:
Fix one issue in virtio TX: it needs one more vring descriptor to hold the virtio header when transmitting packets, it is used later to determine whether to free more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the circumstance of only 1 descriptor in the vring free list.
-- V2 change:
Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtio header) to put packets to transmit queue.
-- V3 change:
Resolve compilation issue due to mbuf re-structure.
--- lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/librte_pmd_virtio/virtio_rxtx.c +8 -2
@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t )(likely (nb_used <VIRTIO_MBUF_BURST_SZ ) ? nb_used :VIRTIO_MBUF_BURST_SZ );while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ;int deq_cnt =RTE_MIN (need, (int )num); num -= (deq_cnt >0 ) ? deq_cnt :0 ;
@@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) deq_cnt--; } -if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int )tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ; +/* +* Zero or negative value indicates it has enough free +* decriptors to transmit. +*/ +if (need <=0 ) { txm = tx_pkts[nb_tx];/* Enqueue Packet buffers */ error =virtqueue_enqueue_xmit (txvq, txm);
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1413299561-31263-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Hi Olivier,
Any other comments for this v3 patch?
Thanks and regards,
Changchun
Quoted 68 lines
-----Original Message-----
From: Ouyang, Changchun
Sent: Tuesday, October 14, 2014 11:13 PM
To: [email protected]
Cc: Cao, Waterman; Ouyang, Changchun
Subject: [PATCH v3] virtio: Fix vring entry number issue-- V1 change:
Fix one issue in virtio TX: it needs one more vring descriptor to hold the
virtio
header when transmitting packets, it is used later to determine whether to
free
more entries from used vring.It fixes failing to transmit any packet with 1 segment in the circumstance of
only
1 descriptor in the vring free list.-- V2 change:
Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtio
header) to
put packets to transmit queue.-- V3 change:
Resolve compilation issue due to mbuf re-structure.Signed-off-by Changchun Ouyang <[email protected]>--- lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)lib/librte_pmd_virtio/virtio_rxtx.c +2
-1@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t )(likely (nb_used <VIRTIO_MBUF_BURST_SZ ) ? nb_used :VIRTIO_MBUF_BURST_SZ );while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq- >vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ;lib/librte_pmd_virtio/virtio_rxtx.c +6
-1int deq_cnt =RTE_MIN (need, (int )num); num -= (deq_cnt >0 ) ? deq_cnt :0 ;@@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) deq_cnt--; } -if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int )tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ; +/* +* Zero or negative value indicates it has enough free +* decriptors to transmit. +*/ +if (need <=0 ) { txm = tx_pkts[nb_tx];lib/librte_pmd_virtio/virtio_rxtx.c +0
-1/* Enqueue Packet buffers */ error =virtqueue_enqueue_xmit (txvq, txm); --1.8.4.2
PATCH v4 1/1 virtio: Fix vring entry number issue
In reply to a message not in the archive Fix one issue in virtio TX: it needs one more vring descriptor to hold the virtio header when transmitting packets, it is used later to determine whether to free more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the circumstance of only 1 descriptor in the vring free list.
---
-V4 change:
Relocate those changelog and annotation here.
-V3 change:
Resolve compilation issue due to mbuf re-structure.
-V2 change:
Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtio header) to put packets to transmit queue.
-V1 change:
Fix the vring descriptor issue in virtio TX, it needs one more vring descriptor to hold the virtio header.
lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/librte_pmd_virtio/virtio_rxtx.c +8 -2
@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t )(likely (nb_used <VIRTIO_MBUF_BURST_SZ ) ? nb_used :VIRTIO_MBUF_BURST_SZ );while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ;int deq_cnt =RTE_MIN (need, (int )num); num -= (deq_cnt >0 ) ? deq_cnt :0 ;
@@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) deq_cnt--; } -if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int )tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ; +/* +* Zero or negative value indicates it has enough free +* decriptors to transmit. +*/ +if (need <=0 ) { txm = tx_pkts[nb_tx];/* Enqueue Packet buffers */ error =virtqueue_enqueue_xmit (txvq, txm);
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1413302634-848-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Quoted 57 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ouyang Changchun
Sent: Tuesday, October 14, 2014 9:04 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4] virtio: Fix vring entry number issueFix one issue in virtio TX: it needs one more vring descriptor to hold the virtio header when transmitting packets, it is used later to determine whether to free more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the circumstance of
only
1 descriptor in the vring free list.Signed-off-by Changchun Ouyang <[email protected]>Reviewed-by Olivier Matz <[email protected]>---
(quoted diff) +0
-3-V4 change: Relocate those changelog and annotation here. -V3 change: Resolve compilation issue due to mbuf re-structure. -V2 change: Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtioheader) to
put packets to transmit queue.-V1 change:
Fix the vring descriptor issue in virtio TX, it needs one more vring descriptor to
hold the
virtio header.lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)lib/librte_pmd_virtio/virtio_rxtx.c +2
-1@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t )(likely (nb_used <VIRTIO_MBUF_BURST_SZ ) ? nb_used :VIRTIO_MBUF_BURST_SZ );while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ;int deq_cnt =RTE_MIN (need, (int )num);lib/librte_pmd_virtio/virtio_rxtx.c +0
-0num -= (deq_cnt >0 ) ? deq_cnt :0 ;@@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
lib/librte_pmd_virtio/virtio_rxtx.c virtio_xmit_pkts(void *tx_queue, struct rte_mbuf · line 718
Quoted 10 lines
lib/librte_pmd_virtio/virtio_rxtx.c +6
-1deq_cnt--; } -if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int )tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ; +/* +* Zero or negative value indicates it has enough free +* decriptors to transmit. +*/ +if (need <=0 ) {
Could we put a branch hint to favor the fast path?
Quoted 5 lines
lib/librte_pmd_virtio/virtio_rxtx.c +0
-0txm = tx_pkts[nb_tx];/* Enqueue Packet buffers */ error =
virtqueue_enqueue_xmit(txvq, txm);
--
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): C37D651A908B024F974696C65296B57B0F2BCA95-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Hi Huawei,
I have v5 patch for this comment.
Thanks,
Changchun
Quoted 85 lines
-----Original Message-----
From: Xie, Huawei
Sent: Wednesday, October 15, 2014 12:26 AM
To: Ouyang, Changchun; [email protected]
Subject: RE: [dpdk-dev] [PATCH v4] virtio: Fix vring entry number issueQuoted 2 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of OuyangChangchun
Quoted 5 lines
Sent: Tuesday, October 14, 2014 9:04 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4] virtio: Fix vring entry number issueFix one issue in virtio TX: it needs one more vring descriptor to hold the
virtio
Quoted 1 line
header when transmitting packets, it is used later to determine whether
to free
Quoted 35 lines
more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the
circumstance of only
1 descriptor in the vring free list.Signed-off-by Changchun Ouyang <[email protected]>Reviewed-by Olivier Matz <[email protected]>---
(quoted diff) +0
-3-V4 change: Relocate those changelog and annotation here. -V3 change: Resolve compilation issue due to mbuf re-structure. -V2 change: Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor forvirtio
header) to
put packets to transmit queue.-V1 change:
Fix the vring descriptor issue in virtio TX, it needs one more vring
descriptor to hold the
virtio header.lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)lib/librte_pmd_virtio/virtio_rxtx.c +0
-0lib/librte_pmd_virtio/virtio_rxtx.c virtio_xmit_pkts(void *tx_queue, struct rte_mbuf · line 700
Quoted 2 lines
lib/librte_pmd_virtio/virtio_rxtx.c +0
-0@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t)(likely(nb_used < VIRTIO_MBUF_BURST_SZ) ?
nb_used:Quoted 11 lines
lib/librte_pmd_virtio/virtio_rxtx.c +2
-1VIRTIO_MBUF_BURST_SZ);while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->pkt.nb_segs - txvq->vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ;int deq_cnt =RTE_MIN (need, (int )num);num -= (
deq_cnt> 0) ?deq_cnt: 0; @@ -708,7 +709,12 @@virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)lib/librte_pmd_virtio/virtio_rxtx.c virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
Quoted 5 lines
lib/librte_pmd_virtio/virtio_rxtx.c +1
-1deq_cnt--; } -if (tx_pkts[nb_tx]->pkt.nb_segs <= txvq->vq_free_cnt) { + need = (int)tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1;
lib/librte_pmd_virtio/virtio_rxtx.c virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 717
Quoted 5 lines
lib/librte_pmd_virtio/virtio_rxtx.c +5
-0+/* +* Zero or negative value indicates it has enough free +* decriptors to transmit. +*/ +if (need <=0 ) {Could we put a branch hint to favor the fast path?
Quoted 5 lines
lib/librte_pmd_virtio/virtio_rxtx.c +0
-1txm = tx_pkts[nb_tx];/* Enqueue Packet buffers */ error =virtqueue_enqueue_xmit (txvq, txm); --1.8.4.2
PATCH v5 1/1 virtio: Fix vring entry number issue
In reply to a message not in the archive Fix one issue in virtio TX: it needs one more vring descriptor to hold the virtio header when transmitting packets, it is used later to determine whether to free more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the circumstance of only 1 descriptor in the vring free list.
---
-V5 change:
Use 'likely' to hint compiler to generate favorable codes.
-V4 change:
Relocate those changelog and annotation here.
-V3 change:
Resolve compilation issue due to mbuf re-structure.
-V2 change:
Refine description, 'vring descriptor' is more accurate than 'vring entry'; Accordingly update test condition (it needs one more descriptor for virtio header) to put packets to transmit queue.
-V1 change:
Fix the vring descriptor issue in virtio TX, it needs one more vring descriptor to hold the virtio header.
lib/librte_pmd_virtio/virtio_rxtx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/librte_pmd_virtio/virtio_rxtx.c +8 -2
@@ -699,7 +699,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) num = (uint16_t )(likely (nb_used <VIRTIO_MBUF_BURST_SZ ) ? nb_used :VIRTIO_MBUF_BURST_SZ );while (nb_tx < nb_pkts) { -int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt; +/* Need one more descriptor for virtio header. */ +int need = tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ;int deq_cnt =RTE_MIN (need, (int )num); num -= (deq_cnt >0 ) ? deq_cnt :0 ;
@@ -708,7 +709,12 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) deq_cnt--; } -if (tx_pkts[nb_tx]->nb_segs <= txvq->vq_free_cnt) { + need = (int )tx_pkts[nb_tx]->nb_segs - txvq->vq_free_cnt +1 ; +/* +* Zero or negative value indicates it has enough free +* descriptors to use for transmitting. +*/ +if (likely (need <=0 )) { txm = tx_pkts[nb_tx];/* Enqueue Packet buffers */ error =virtqueue_enqueue_xmit (txvq, txm);
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1413342660-17894-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Thomas Monjalon
Applied2014-10-15 11:11, Ouyang Changchun:
Quoted 8 lines
Fix one issue in virtio TX: it needs one more vring descriptor to hold the virtio header when transmitting packets, it is used later to determine whether to free more entries from used vring.
It fixes failing to transmit any packet with 1 segment in the circumstance of only 1 descriptor in the vring free list.Signed-off-by Changchun Ouyang <[email protected]>Reviewed-by Olivier Matz <[email protected]>
Applied
Thanks
Signature · 1 line
Thomas