Blob Blame History Raw
From fd10f4c26b1ff052ea3b893247d1b6d06d01e36a Mon Sep 17 00:00:00 2001
From: Kamal Heib <kamalheib1@gmail.com>
Date: Tue, 10 Nov 2020 16:59:59 +0200
Subject: [PATCH] libqedr: Set XRC functions only in RoCE mode

As libqedr support both RoCE and iWarp, make sure to set the XRC
functions only in RoCE mode, also change the assignment of the XRC
functions to use verbs_set_ops().

Fixes: cae4a99ae679 ("libqedr: add support for XRC-SRQ's.")
Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
---
 providers/qedr/qelr_main.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/providers/qedr/qelr_main.c b/providers/qedr/qelr_main.c
index bdfaa930f0c6..e31cd452906f 100644
--- a/providers/qedr/qelr_main.c
+++ b/providers/qedr/qelr_main.c
@@ -113,6 +113,14 @@ static const struct verbs_context_ops qelr_ctx_ops = {
 	.free_context = qelr_free_context,
 };
 
+static const struct verbs_context_ops qelr_ctx_roce_ops = {
+	.close_xrcd = qelr_close_xrcd,
+	.create_qp_ex = qelr_create_qp_ex,
+	.create_srq_ex = qelr_create_srq_ex,
+	.get_srq_num = qelr_get_srq_num,
+	.open_xrcd = qelr_open_xrcd,
+};
+
 static void qelr_uninit_device(struct verbs_device *verbs_device)
 {
 	struct qelr_device *dev = get_qelr_dev(&verbs_device->device);
@@ -171,7 +179,6 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
 						int cmd_fd,
 						void *private_data)
 {
-	struct verbs_context *v_ctx;
 	struct qelr_devctx *ctx;
 	struct qelr_alloc_context cmd = {};
 	struct qelr_alloc_context_resp resp;
@@ -181,7 +188,6 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
 	if (!ctx)
 		return NULL;
 
-	v_ctx = &ctx->ibv_ctx;
 	memset(&resp, 0, sizeof(resp));
 
 	qelr_open_debug_file(ctx);
@@ -194,6 +200,8 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
 		goto cmd_err;
 
 	verbs_set_ops(&ctx->ibv_ctx, &qelr_ctx_ops);
+	if (IS_ROCE(ibdev))
+		verbs_set_ops(&ctx->ibv_ctx, &qelr_ctx_roce_ops);
 
 	ctx->srq_table = calloc(QELR_MAX_SRQ_ID, sizeof(*ctx->srq_table));
 	if (!ctx->srq_table) {
@@ -252,12 +260,6 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
 		goto cmd_err;
 	}
 
-	v_ctx->create_qp_ex = qelr_create_qp_ex;
-	v_ctx->open_xrcd = qelr_open_xrcd;
-	v_ctx->close_xrcd = qelr_close_xrcd;
-	v_ctx->create_srq_ex = qelr_create_srq_ex;
-	v_ctx->get_srq_num = qelr_get_srq_num;
-
 	return &ctx->ibv_ctx;
 
 cmd_err:
-- 
2.25.4