There's a corner case that all the Rx queue mbufs are allocated but none
of them is used, this patch fixes mbuf free for this case.

Fixes: b6719f8a04bb ("fm10k: release mbuf for vector Rx")
Cc: sta...@dpdk.org

Signed-off-by: Xiao Wang <xiao.w.w...@intel.com>
Signed-off-by: Anna Lukin <an...@silicom.co.il>
---
 drivers/net/fm10k/fm10k_rxtx_vec.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 45542bef3..d76dfd16f 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -359,8 +359,15 @@ fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue 
*rxq)
                return;
 
        /* free all mbufs that are valid in the ring */
-       for (i = rxq->next_dd; i != rxq->rxrearm_start; i = (i + 1) & mask)
-               rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       if (rxq->rxrearm_nb == 0) {
+               for (i = 0; i < rxq->nb_desc; i++)
+                       if (rxq->sw_ring[i] != NULL)
+                               rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       } else {
+               for (i = rxq->next_dd; i != rxq->rxrearm_start;
+                               i = (i + 1) & mask)
+                       rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       }
        rxq->rxrearm_nb = rxq->nb_desc;
 
        /* set all entries to NULL */
-- 
2.15.1

Reply via email to