From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 412C0C433ED for ; Mon, 5 Apr 2021 18:57:45 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id B65FC61359 for ; Mon, 5 Apr 2021 18:57:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B65FC61359 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=cisco.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 178604068C; Mon, 5 Apr 2021 20:57:44 +0200 (CEST) Received: from alln-iport-6.cisco.com (alln-iport-6.cisco.com [173.37.142.93]) by mails.dpdk.org (Postfix) with ESMTP id 001614014E for ; Mon, 5 Apr 2021 20:57:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2106; q=dns/txt; s=iport; t=1617649062; x=1618858662; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6Z0AJkS/fDJ71KHXgn5GnN0zkprydJ2sbMD+uhpz2G8=; b=VOaG06x576qPHNNyxwg4Oac+y8/UwBYNQWWemrysXoscyL1ZHM/IlaQk JI1uh6RvgIJHuzh+3PS7VtmE4AxUX1f7zOhGA+YzifbhmJ4tQQ9EyIqcs rlLum7+RWIiEM3e6f3K7rXsh3R/f+mN+f22pKg2SoCDKHdvBES0VQzDim s=; X-IronPort-AV: E=Sophos;i="5.81,307,1610409600"; d="scan'208";a="715101417" Received: from rcdn-core-1.cisco.com ([173.37.93.152]) by alln-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 05 Apr 2021 18:57:41 +0000 Received: from eng-rtp-bld-01.cisco.com (eng-rtp-bld-01.cisco.com [172.18.47.31]) by rcdn-core-1.cisco.com (8.15.2/8.15.2) with ESMTPS id 135IveSf009199 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 5 Apr 2021 18:57:40 GMT Received: by eng-rtp-bld-01.cisco.com (Postfix, from userid 140087) id 55B662A1652; Mon, 5 Apr 2021 14:57:40 -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 14:57:24 -0400 Message-Id: <20210405185724.976625-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-1.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 | 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