From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 228B2A0546;
	Fri, 30 Apr 2021 14:58:17 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id CAB6241196;
	Fri, 30 Apr 2021 14:57:49 +0200 (CEST)
Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com
 [209.85.221.53]) by mails.dpdk.org (Postfix) with ESMTP id 78C6141133
 for <dev@dpdk.org>; Fri, 30 Apr 2021 14:57:43 +0200 (CEST)
Received: by mail-wr1-f53.google.com with SMTP id x5so20210880wrv.13
 for <dev@dpdk.org>; Fri, 30 Apr 2021 05:57:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=semihalf-com.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=wK9lnbUtPPWgBXMq8GI68UORweb9S1GInEg0anWbVsE=;
 b=VQrGqUHvbow1EvPIEoJ+IPmr30vu+vBw4EbODPZLCaJnM5D34dVleSkmAgvohT0/Id
 efWE5sjKAAlImCjPBia/CWJeeQl+8eypNWW4g67FvI6Us1z66oJURZnaKbN+J85zbLCL
 /CT/8VzwqLtAhxO2jSIigF0BGLjP/uV0COkiQ85OWdqHlEVv4vINCKBjlVwS3GUW91l8
 qdmBEcC7x48MqdnuDyIGCEIggeVZGZr+NyLW3cEbjVbjcLXeV0eg478GBLkA8KVFGvjz
 9se6BKDq16oO7AmP9AK9NoFgaoutuC9nLCOnU/0qDUAChRjzb/sR4gUQiX5Jw9fbbDzz
 /AJw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=wK9lnbUtPPWgBXMq8GI68UORweb9S1GInEg0anWbVsE=;
 b=p28T8SSvnmR+dgzBWy33rcBZyDuPcKal4wLSyAaqFcqjHMLeJ+mE6cjueU7EXAYTCf
 +D04bHSpap42UUeUVjp1B4yy50K7VUkXifK1jis+Y4YYtJQ4OZZPZ+7f2IeKoV67RwLU
 BB32n3FwUBQRpYbnl9R3Jz7PVU584k3jQE62LSw5h3tTIQXNfrzApBKxFDAEgiCmFrVz
 3uNGHhLpzHtFNcI/lqRD/8BPpZOqKZ0QRZ/yEYFqtCt9XGGP60QtDeEIVrQ3pU0td/5r
 fLg5YsiAmtiLWzQ0uC7sRLcg0Y02TleoMnFrZHqDDRLkFaIdn/fIgIMQmd1tuQTAxviE
 Az8w==
X-Gm-Message-State: AOAM5322Xsw5LUFEXiqtQmK6Euwla5wPuUV64SWTEkcWymU7+Uq/l4I9
 f/HHicEL8KVMs3dVOTdQLYlt52QDTEUvWxuV
X-Google-Smtp-Source: ABdhPJw3yUZ8qLyOV2WnBqwvvI0/0oSw+Ljx5cY1jutA+yU2BZUOuNz7F+S/ebisMo5y9/kTum6+vQ==
X-Received: by 2002:adf:f4c4:: with SMTP id h4mr6691298wrp.309.1619787462970; 
 Fri, 30 Apr 2021 05:57:42 -0700 (PDT)
Received: from DESKTOP-U5LNN3J.localdomain (89-79-189-199.dynamic.chello.pl.
 [89.79.189.199])
 by smtp.gmail.com with ESMTPSA id l13sm13476245wmj.3.2021.04.30.05.57.41
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 30 Apr 2021 05:57:42 -0700 (PDT)
From: Michal Krawczyk <mk@semihalf.com>
To: dev@dpdk.org
Cc: ndagan@amazom.com, gtzalik@amazon.com, igorch@amazon.com, mw@semihalf.com,
 Michal Krawczyk <mk@semihalf.com>
Date: Fri, 30 Apr 2021 14:57:09 +0200
Message-Id: <20210430125725.28796-7-mk@semihalf.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20210430125725.28796-1-mk@semihalf.com>
References: <20210430125725.28796-1-mk@semihalf.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH 06/22] net/ena/base: destroy multiple "wait
 events"
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Although the ENA DPDK PMD doesn't have to perform any actions for
destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to
"ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for
that was moved to a separate function for better readability.

Fixes: 3adcba9a8987 ("net/ena: update HAL to the newer version")

Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Igor Chauskin <igorch@amazon.com>
Reviewed-by: Guy Tzalik <gtzalik@amazon.com>
---
 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  4 ++--
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ena/base/ena_com.c b/drivers/net/ena/base/ena_com.c
index 0cdeb1a2d9..d025c9cee1 100644
--- a/drivers/net/ena/base/ena_com.c
+++ b/drivers/net/ena/base/ena_com.c
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 	return 0;
 }
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+				      struct ena_com_admin_queue *admin_queue)
+
+{
+	if (!admin_queue->comp_ctx)
+		return;
+
+	ENA_WAIT_EVENTS_DESTROY(admin_queue);
+	ENA_MEM_FREE(ena_dev->dmadev,
+		     admin_queue->comp_ctx,
+		     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+	admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
 	struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u16 size;
 
-	if (admin_queue->comp_ctx) {
-		ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-		ENA_MEM_FREE(ena_dev->dmadev,
-			     admin_queue->comp_ctx,
-			     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-	}
+	ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-	admin_queue->comp_ctx = NULL;
 	size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 	if (sq->entries)
 		ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 9d69190c83..bfc0a658ef 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -163,7 +163,7 @@ extern int ena_logtype_com;
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
 
 #define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
@@ -295,7 +295,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define ENA_TIME_EXPIRE(timeout)  (timeout < rte_get_timer_cycles())
 #define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				\
     (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
-- 
2.25.1