From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 239F2A0524;
	Mon, 27 Jul 2020 10:54:19 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F15651C02E;
	Mon, 27 Jul 2020 10:54:18 +0200 (CEST)
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 305EC1C025
 for <dev@dpdk.org>; Mon, 27 Jul 2020 10:54:00 +0200 (CEST)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 dekelp@mellanox.com) with SMTP; 27 Jul 2020 11:53:58 +0300
Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx
 [10.228.134.250])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 06R8rwiK004347;
 Mon, 27 Jul 2020 11:53:58 +0300
From: Dekel Peled <dekelp@mellanox.com>
To: matan@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com
Cc: dev@dpdk.org
Date: Mon, 27 Jul 2020 11:50:47 +0300
Message-Id: <a5cc987ab3838b97511683a4808385e2335a65f8.1595839884.git.dekelp@mellanox.com>
X-Mailer: git-send-email 1.7.1
Subject: [dpdk-dev] [PATCH] net/mlx5: fix CQ interrupt handling and cleanup
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
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>

Recent patch added creation of Rx CQ using DevX API.
The reading of events from DevX channel was not done correctly.
This patch fixes the event reading, using the correct data structure.
Cleanup after CQ creation, in case of error, is also updated.

Fixes: 08d1838f645a ("net/mlx5: implement CQ for Rx using DevX API")

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index c78e522..79eb8f8 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1193,12 +1193,16 @@
 		mlx5_glue->ack_cq_events(rxq_obj->ibv_cq, 1);
 	} else if (rxq_obj->type == MLX5_RXQ_OBJ_TYPE_DEVX_RQ) {
 #ifdef HAVE_IBV_DEVX_EVENT
-		struct mlx5dv_devx_async_event_hdr *event_data = NULL;
+		union {
+			struct mlx5dv_devx_async_event_hdr event_resp;
+			uint8_t buf[sizeof(struct mlx5dv_devx_async_event_hdr)
+				    + 128];
+		} out;
 
 		ret = mlx5_glue->devx_get_event
-				(rxq_obj->devx_channel, event_data,
-				 sizeof(struct mlx5dv_devx_async_event_hdr));
-		if (ret < 0 || event_data->cookie !=
+				(rxq_obj->devx_channel, &out.event_resp,
+				 sizeof(out.buf));
+		if (ret < 0 || out.event_resp.cookie !=
 				(uint64_t)(uintptr_t)rxq_obj->devx_cq)
 			goto exit;
 #endif /* HAVE_IBV_DEVX_EVENT */
@@ -1646,6 +1650,8 @@
 	memset((void *)(uintptr_t)rxq_data->cqes, 0xFF, cq_size);
 	return cq_obj;
 error:
+	if (cq_obj)
+		mlx5_devx_cmd_destroy(cq_obj);
 	rxq_release_devx_cq_resources(rxq_ctrl);
 	return NULL;
 }
-- 
1.8.3.1