From dac41cb2e2ba60dbfeffd298a12cf466983c66e6 Mon Sep 17 00:00:00 2001
From: Steve Welch <welch@hpe.com>
Date: Wed, 8 Jan 2025 14:37:25 -0600
Subject: [PATCH] prov/cxi: cxi EQ do not support wait objects

Make sure wait objects are not allowed for cxi EQs.

NETCASSINI-6964

Signed-off-by: Steve Welch <welch@hpe.com>
---
 prov/cxi/src/cxip_eq.c | 12 +++++++++++-
 prov/cxi/test/eq.c     | 27 ++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/prov/cxi/src/cxip_eq.c b/prov/cxi/src/cxip_eq.c
index 010fdcc7183..6c1dec45319 100644
--- a/prov/cxi/src/cxip_eq.c
+++ b/prov/cxi/src/cxip_eq.c
@@ -29,6 +29,8 @@
 
 #include "cxip.h"
 
+#define CXIP_WARN(...) _CXIP_WARN(FI_LOG_EQ, __VA_ARGS__)
+
 static int cxip_eq_close(struct fid *fid)
 {
 	struct cxip_eq *cxi_eq;
@@ -104,7 +106,7 @@ static struct fi_ops cxi_eq_fi_ops = {
 static struct fi_eq_attr cxip_eq_def_attr = {
 	.size = CXIP_EQ_DEF_SZ,
 	.flags = 0,
-	.wait_obj = FI_WAIT_FD,
+	.wait_obj = FI_WAIT_NONE,
 	.signaling_vector = 0,
 	.wait_set = NULL
 };
@@ -124,6 +126,14 @@ int cxip_eq_open(struct fid_fabric *fabric, struct fi_eq_attr *attr,
 	else
 		cxi_eq->attr = *attr;
 
+	if (cxi_eq->attr.wait_obj != FI_WAIT_NONE) {
+		CXIP_WARN("Unsupported EQ attribute wait obj %d\n",
+			  cxi_eq->attr.wait_obj);
+		ret = -FI_ENOSYS;
+
+		goto err0;
+	}
+
 	ret = ofi_eq_init(fabric, &cxi_eq->attr, &cxi_eq->util_eq.eq_fid,
 			  context);
 	if (ret != FI_SUCCESS)
diff --git a/prov/cxi/test/eq.c b/prov/cxi/test/eq.c
index 00730982b22..1d31bd4bf9e 100644
--- a/prov/cxi/test/eq.c
+++ b/prov/cxi/test/eq.c
@@ -27,7 +27,7 @@
 TestSuite(eq, .init = cxit_setup_eq, .fini = cxit_teardown_eq,
 	  .timeout = CXIT_DEFAULT_TIMEOUT);
 
-/* Test basic CQ creation */
+/* Test basic EQ creation */
 Test(eq, simple)
 {
 	cxit_create_eq();
@@ -35,3 +35,28 @@ Test(eq, simple)
 	cxit_destroy_eq();
 }
 
+void eq_bad_wait_obj(enum fi_wait_obj wait_obj)
+
+{
+	struct fi_eq_attr attr = {
+		.size = 32,
+		.flags = FI_WRITE,
+		.wait_obj = wait_obj,
+	};
+	int ret;
+
+	ret = fi_eq_open(cxit_fabric, &attr, &cxit_eq, NULL);
+	cr_assert(ret == -FI_ENOSYS, "fi_eq_open unexpected success");
+	cr_assert(cxit_eq == NULL, "cxit_eq not NULL on bad wait_obj");
+}
+
+Test(eq, bad_wait_obj_unspec)
+{
+	eq_bad_wait_obj(FI_WAIT_UNSPEC);
+}
+
+Test(eq, bad_wait_obj_wait_fd)
+{
+	eq_bad_wait_obj(FI_WAIT_UNSPEC);
+}
+