DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs
@ 2021-04-06  0:27 David Harton
  2021-04-06  5:25 ` Michał Krawczyk
  0 siblings, 1 reply; 4+ messages in thread
From: David Harton @ 2021-04-06  0:27 UTC (permalink / raw)
  To: mw, mk, gtzalik, evgenys, igorch; +Cc: dev, David Harton

When ena_tx_queue_release_bufs() frees the mbufs it does not clear
the mbuf pointers.  So, when the device starts and stops multiple
times it can cause the application to receive duplicate mbufs for
two different packets.  Fix the issue by clearing the mbuf pointer.

Also, while tracking down the "double free" issue the ena calls to
allocate and free mbufs in bulk were migrated to the mbuf based APIs
so the common mbuf alloc/free routines are exercised.

Fixes: 79405ee17585 ("net/ena: fix out of order completion")
Fixes: 1173fca25af9 ("ena: add polling-mode driver")

Signed-off-by: David Harton <dharton@cisco.com>
---
 drivers/net/ena/ena_ethdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 9aa51c9dc..f60e843b7 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -767,8 +767,10 @@ static void ena_tx_queue_release_bufs(struct ena_ring *ring)
 	for (i = 0; i < ring->ring_size; ++i) {
 		struct ena_tx_buffer *tx_buf = &ring->tx_buffer_info[i];
 
-		if (tx_buf->mbuf)
+		if (tx_buf->mbuf) {
 			rte_pktmbuf_free(tx_buf->mbuf);
+			tx_buf->mbuf = NULL;
+		}
 	}
 }
 
@@ -1457,7 +1459,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 		"bad ring state\n");
 
 	/* get resources for incoming packets */
-	rc = rte_mempool_get_bulk(rxq->mb_pool, (void **)mbufs, count);
+	rc = rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, count);
 	if (unlikely(rc < 0)) {
 		rte_atomic64_inc(&rxq->adapter->drv_stats->rx_nombuf);
 		++rxq->rx_stats.mbuf_alloc_fail;
@@ -1486,8 +1488,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 	if (unlikely(i < count)) {
 		PMD_DRV_LOG(WARNING, "refilled rx qid %d with only %d "
 			"buffers (from %d)\n", rxq->id, i, count);
-		rte_mempool_put_bulk(rxq->mb_pool, (void **)(&mbufs[i]),
-				     count - i);
+		rte_pktmbuf_free_bulk(&mbufs[i], count - i);
 		++rxq->rx_stats.refill_partial;
 	}
 
-- 
2.26.2.Cisco


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs
  2021-04-06  0:27 [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs David Harton
@ 2021-04-06  5:25 ` Michał Krawczyk
  2021-04-07  8:15   ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Krawczyk @ 2021-04-06  5:25 UTC (permalink / raw)
  To: David Harton
  Cc: Marcin Wojtas, Tzalik, Guy, Schmeilin, Evgeny, Chauskin, Igor, dev

wt., 6 kwi 2021 o 02:27 David Harton <dharton@cisco.com> napisał(a):
>
> When ena_tx_queue_release_bufs() frees the mbufs it does not clear
> the mbuf pointers.  So, when the device starts and stops multiple
> times it can cause the application to receive duplicate mbufs for
> two different packets.  Fix the issue by clearing the mbuf pointer.
>
> Also, while tracking down the "double free" issue the ena calls to
> allocate and free mbufs in bulk were migrated to the mbuf based APIs
> so the common mbuf alloc/free routines are exercised.
>
> Fixes: 79405ee17585 ("net/ena: fix out of order completion")
> Fixes: 1173fca25af9 ("ena: add polling-mode driver")
>
> Signed-off-by: David Harton <dharton@cisco.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
> ---
>  drivers/net/ena/ena_ethdev.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index 9aa51c9dc..f60e843b7 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -767,8 +767,10 @@ static void ena_tx_queue_release_bufs(struct ena_ring *ring)
>         for (i = 0; i < ring->ring_size; ++i) {
>                 struct ena_tx_buffer *tx_buf = &ring->tx_buffer_info[i];
>
> -               if (tx_buf->mbuf)
> +               if (tx_buf->mbuf) {
>                         rte_pktmbuf_free(tx_buf->mbuf);
> +                       tx_buf->mbuf = NULL;
> +               }
>         }
>  }
>
> @@ -1457,7 +1459,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
>                 "bad ring state\n");
>
>         /* get resources for incoming packets */
> -       rc = rte_mempool_get_bulk(rxq->mb_pool, (void **)mbufs, count);
> +       rc = rte_pktmbuf_alloc_bulk(rxq->mb_pool, mbufs, count);
>         if (unlikely(rc < 0)) {
>                 rte_atomic64_inc(&rxq->adapter->drv_stats->rx_nombuf);
>                 ++rxq->rx_stats.mbuf_alloc_fail;
> @@ -1486,8 +1488,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
>         if (unlikely(i < count)) {
>                 PMD_DRV_LOG(WARNING, "refilled rx qid %d with only %d "
>                         "buffers (from %d)\n", rxq->id, i, count);
> -               rte_mempool_put_bulk(rxq->mb_pool, (void **)(&mbufs[i]),
> -                                    count - i);
> +               rte_pktmbuf_free_bulk(&mbufs[i], count - i);
>                 ++rxq->rx_stats.refill_partial;
>         }
>
> --
> 2.26.2.Cisco
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs
  2021-04-06  5:25 ` Michał Krawczyk
@ 2021-04-07  8:15   ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2021-04-07  8:15 UTC (permalink / raw)
  To: Michał Krawczyk, David Harton
  Cc: Marcin Wojtas, Tzalik, Guy, Schmeilin, Evgeny, Chauskin, Igor, dev

On 4/6/2021 6:25 AM, Michał Krawczyk wrote:
> wt., 6 kwi 2021 o 02:27 David Harton <dharton@cisco.com> napisał(a):
>>
>> When ena_tx_queue_release_bufs() frees the mbufs it does not clear
>> the mbuf pointers.  So, when the device starts and stops multiple
>> times it can cause the application to receive duplicate mbufs for
>> two different packets.  Fix the issue by clearing the mbuf pointer.
>>
>> Also, while tracking down the "double free" issue the ena calls to
>> allocate and free mbufs in bulk were migrated to the mbuf based APIs
>> so the common mbuf alloc/free routines are exercised.
>>
>> Fixes: 79405ee17585 ("net/ena: fix out of order completion")
>> Fixes: 1173fca25af9 ("ena: add polling-mode driver")
>>
>> Signed-off-by: David Harton <dharton@cisco.com>
> Acked-by: Michal Krawczyk <mk@semihalf.com>

Applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs
@ 2021-04-05 18:57 David Harton
  0 siblings, 0 replies; 4+ messages in thread
From: David Harton @ 2021-04-05 18:57 UTC (permalink / raw)
  To: mw, mk, gtzalik, evgenys, igorch; +Cc: dev, David Harton

When ena_tx_queue_release_bufs() frees the mbufs it does not clear
the mbuf pointers.  So, when the device starts and stops multiple
times it can cause the application to receive duplicate mbufs for
two different packets.  Fix the issue by clearing the mbuf pointer.

Also, while tracking down the "double free" issue the ena calls to
allocate and free mbufs in bulk were migrated to the mbuf based APIs
so the common mbuf alloc/free routines are exercised.

Fixes: 79405ee17585 ("net/ena: fix out of order completion")
Fixes: 1173fca25af9 ("ena: add polling-mode driver")

Signed-off-by: David Harton <dharton@cisco.com>
---
 drivers/net/ena/ena_ethdev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 9aa51c9dc..222f2510e 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -767,8 +767,10 @@ static void ena_tx_queue_release_bufs(struct ena_ring *ring)
 	for (i = 0; i < ring->ring_size; ++i) {
 		struct ena_tx_buffer *tx_buf = &ring->tx_buffer_info[i];
 
-		if (tx_buf->mbuf)
+		if (tx_buf->mbuf) {
 			rte_pktmbuf_free(tx_buf->mbuf);
+			tx_buf->mbuf = NULL;
+		}
 	}
 }
 
@@ -1457,7 +1459,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 		"bad ring state\n");
 
 	/* get resources for incoming packets */
-	rc = rte_mempool_get_bulk(rxq->mb_pool, (void **)mbufs, count);
+	rc = rte_pktmbuf_alloc_bulk(rxq->mb_pool, (void **)mbufs, count);
 	if (unlikely(rc < 0)) {
 		rte_atomic64_inc(&rxq->adapter->drv_stats->rx_nombuf);
 		++rxq->rx_stats.mbuf_alloc_fail;
@@ -1486,7 +1488,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 	if (unlikely(i < count)) {
 		PMD_DRV_LOG(WARNING, "refilled rx qid %d with only %d "
 			"buffers (from %d)\n", rxq->id, i, count);
-		rte_mempool_put_bulk(rxq->mb_pool, (void **)(&mbufs[i]),
+		rte_pktmbuf_alloc_bulk(rxq->mb_pool, (void **)(&mbufs[i]),
 				     count - i);
 		++rxq->rx_stats.refill_partial;
 	}
-- 
2.26.2.Cisco


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-07  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  0:27 [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs David Harton
2021-04-06  5:25 ` Michał Krawczyk
2021-04-07  8:15   ` Ferruh Yigit
  -- strict thread matches above, loose matches on Subject: below --
2021-04-05 18:57 David Harton

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git