diff mbox

[dpdk-dev] lib/librte_pmd_virtio fix can't receive packets after rx_q is empty If failed to alloc mbuf ring_size times the rx_q may be empty and can't receive any packets forever because nb_used is 0 forever.

Message ID 1426842609-26700-1-git-send-email-haifeng.lin@huawei.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Linhaifeng March 20, 2015, 9:10 a.m. UTC
From: Linhaifeng <haifeng.lin@huawei.com>

so we should try to refill when nb_used is 0.After otherone free mbuf
we can restart to receive packets.

Signed-off-by: Linhaifeng <haifeng.lin@huawei.com>
---
 lib/librte_pmd_virtio/virtio_rxtx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Linhaifeng March 20, 2015, 9:45 a.m. UTC | #1
Sorry for my wrong title. Please ignore it.

On 2015/3/20 17:10, linhaifeng wrote:
> From: Linhaifeng <haifeng.lin@huawei.com>
> 
> so we should try to refill when nb_used is 0.After otherone free mbuf
> we can restart to receive packets.
> 
> Signed-off-by: Linhaifeng <haifeng.lin@huawei.com>
> ---
>  lib/librte_pmd_virtio/virtio_rxtx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c
> index 1d74b34..5c7e0cd 100644
> --- a/lib/librte_pmd_virtio/virtio_rxtx.c
> +++ b/lib/librte_pmd_virtio/virtio_rxtx.c
> @@ -495,7 +495,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
>  		num = num - ((rxvq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);
>  
>  	if (num == 0)
> -		return 0;
> +		goto refill;
>  
>  	num = virtqueue_dequeue_burst_rx(rxvq, rcv_pkts, len, num);
>  	PMD_RX_LOG(DEBUG, "used:%d dequeue:%d", nb_used, num);
> @@ -536,6 +536,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
>  
>  	rxvq->packets += nb_rx;
>  
> +refill:
>  	/* Allocate new mbuf for the used descriptor */
>  	error = ENOSPC;
>  	while (likely(!virtqueue_full(rxvq))) {
>
diff mbox

Patch

diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c
index 1d74b34..5c7e0cd 100644
--- a/lib/librte_pmd_virtio/virtio_rxtx.c
+++ b/lib/librte_pmd_virtio/virtio_rxtx.c
@@ -495,7 +495,7 @@  virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		num = num - ((rxvq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);
 
 	if (num == 0)
-		return 0;
+		goto refill;
 
 	num = virtqueue_dequeue_burst_rx(rxvq, rcv_pkts, len, num);
 	PMD_RX_LOG(DEBUG, "used:%d dequeue:%d", nb_used, num);
@@ -536,6 +536,7 @@  virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
 	rxvq->packets += nb_rx;
 
+refill:
 	/* Allocate new mbuf for the used descriptor */
 	error = ENOSPC;
 	while (likely(!virtqueue_full(rxvq))) {