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 39F86A0A02; Tue, 6 Apr 2021 02:27:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A9D70406A2; Tue, 6 Apr 2021 02:27:25 +0200 (CEST) Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89]) by mails.dpdk.org (Postfix) with ESMTP id 03A824068B for ; Tue, 6 Apr 2021 02:27:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2087; q=dns/txt; s=iport; t=1617668844; x=1618878444; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5gJmsE2tjrpmHPm9QnN8VnkL0XHr5jvJGIGw6xCj7Ps=; b=b5nQ6mZI8bH9JAY1XgYRC0TMMyreaecuXPZv7Us6AHTj5OeLq0X1gTrT Dk5s1DjEMrPsD0PT54j8dkn41FpXM+ktW3HRp74xeX5VeYC24GtdgnSyN mq55B8o0TsJp20AwQUc4r2RaYu4vOMehLHEbspm8xa/3HRU/vC4dHPgZG 4=; X-IronPort-AV: E=Sophos;i="5.81,308,1610409600"; d="scan'208";a="696743633" Received: from rcdn-core-8.cisco.com ([173.37.93.144]) by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 06 Apr 2021 00:27:22 +0000 Received: from eng-rtp-bld-01.cisco.com (eng-rtp-bld-01.cisco.com [172.18.47.31]) by rcdn-core-8.cisco.com (8.15.2/8.15.2) with ESMTPS id 1360RMCj021668 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 6 Apr 2021 00:27:22 GMT Received: by eng-rtp-bld-01.cisco.com (Postfix, from userid 140087) id 3EB5B2A1652; Mon, 5 Apr 2021 20:27:22 -0400 (EDT) From: David Harton To: mw@semihalf.com, mk@semihalf.com, gtzalik@amazon.com, evgenys@amazon.com, igorch@amazon.com Cc: dev@dpdk.org, David Harton Date: Mon, 5 Apr 2021 20:27:19 -0400 Message-Id: <20210406002719.2556501-1-dharton@cisco.com> X-Mailer: git-send-email 2.26.2.Cisco MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-SMTP-Client: 172.18.47.31, eng-rtp-bld-01.cisco.com X-Outbound-Node: rcdn-core-8.cisco.com Subject: [dpdk-dev] [PATCH] net/ena: fix releasing Tx ring mbufs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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