From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2780DA0A02 for ; Mon, 17 May 2021 18:13:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 222AE40041; Mon, 17 May 2021 18:13:56 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 40F04410E2 for ; Mon, 17 May 2021 18:13:54 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifsP-0007zX-7z; Mon, 17 May 2021 16:13:53 +0000 From: Christian Ehrhardt To: David Harton Cc: Michal Krawczyk , dpdk stable Date: Mon, 17 May 2021 18:08:34 +0200 Message-Id: <20210517161039.3132619-85-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/ena: fix releasing Tx ring mbufs' has been queued to stable release 19.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/03de5b658b9af034dd1d590ff3690873d5c316f9 Thanks. Christian Ehrhardt --- >From 03de5b658b9af034dd1d590ff3690873d5c316f9 Mon Sep 17 00:00:00 2001 From: David Harton Date: Mon, 5 Apr 2021 20:27:19 -0400 Subject: [PATCH] net/ena: fix releasing Tx ring mbufs [ upstream commit 3c8bc29fd07006338e3460b03655a772cd36a9e7 ] 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 Acked-by: Michal Krawczyk --- 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 d098387a8c..2adf461a3c 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -733,8 +733,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; + } } } @@ -1376,7 +1378,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) ena_assert_msg(((in_use + count) < ring_size), "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; @@ -1415,8 +1417,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.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:32.830711062 +0200 +++ 0085-net-ena-fix-releasing-Tx-ring-mbufs.patch 2021-05-17 17:40:29.263810201 +0200 @@ -1 +1 @@ -From 3c8bc29fd07006338e3460b03655a772cd36a9e7 Mon Sep 17 00:00:00 2001 +From 03de5b658b9af034dd1d590ff3690873d5c316f9 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 3c8bc29fd07006338e3460b03655a772cd36a9e7 ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -26 +27 @@ -index 9aa51c9dcf..f60e843b7f 100644 +index d098387a8c..2adf461a3c 100644 @@ -29 +30 @@ -@@ -767,8 +767,10 @@ static void ena_tx_queue_release_bufs(struct ena_ring *ring) +@@ -733,8 +733,10 @@ static void ena_tx_queue_release_bufs(struct ena_ring *ring) @@ -41,2 +42,2 @@ -@@ -1457,7 +1459,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) - "bad ring state\n"); +@@ -1376,7 +1378,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) + ena_assert_msg(((in_use + count) < ring_size), "bad ring state\n"); @@ -50 +51 @@ -@@ -1486,8 +1488,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count) +@@ -1415,8 +1417,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)