[Openib-windows] [PATCH] alts create destroy QP

Yossi Leybovich sleybo at mellanox.co.il
Tue Sep 6 09:56:30 PDT 2005


Fab

This is a little addition for alts .
Its basic test that create and destroy QP ( you can reproduce the invalid CQ
with it)

Thanks
Yossi 

Singed-off-by: Yossi Leybovich (sleybo at mellanox.co.il)

Index: alts_common.h
===================================================================
--- alts_common.h	(revision 346)
+++ alts_common.h	(working copy)
@@ -157,6 +157,9 @@
 					IOCTL_CODE(ALDEV_KEY, CmTests)
 
 
+#define ALTS_CQ_SIZE 0x50
+
+
 /*
  * Function Prototypes for the above test cases
  */
@@ -187,7 +190,15 @@
 ib_api_status_t
 al_test_query_modify_cq( void );
 
+
 ib_api_status_t
+al_test_create_destroy_qp( void );
+
+ib_api_status_t
+al_test_query_modify_qp( void );
+
+
+ib_api_status_t
 al_test_create_destroy_eec( void );
 
 ib_api_status_t
@@ -253,4 +264,30 @@
 alts_print_ca_attr( ib_ca_attr_t *alts_ca_attr );
 
 
+void
+alts_qp_err_cb(
+	ib_async_event_rec_t				*p_err_rec );
+
+void
+alts_qp_destroy_cb(
+	void	*context );
+
+
+
+void
+alts_cq_comp_cb(
+	IN		const	ib_cq_handle_t
h_cq,
+	IN				void
*cq_context );
+
+void
+alts_cq_err_cb(
+	ib_async_event_rec_t				*p_err_rec );
+
+void
+alts_cq_destroy_cb(
+	void	*context );
+
+
+
+
 #endif // __ALTS_COMMON_H__
Index: createanddestroycq.c
===================================================================
--- createanddestroycq.c	(revision 346)
+++ createanddestroycq.c	(working copy)
@@ -38,11 +38,7 @@
 #include <alts_common.h>
 
 
-/*
- * //NoteNote parameter that can be changed to test CQ functionality
- */
 
-#define ALTS_CQ_SIZE 0x50
 
 /*
  * Function prototypes
@@ -52,21 +48,6 @@
 	boolean_t modify_cq_attr
 	);
 
-void
-alts_cq_comp_cb(
-	IN		const	ib_cq_handle_t
h_cq,
-	IN				void
*cq_context );
-
-void
-alts_cq_err_cb(
-	ib_async_event_rec_t				*p_err_rec );
-
-void
-alts_cq_destroy_cb(
-	void	*context );
-
-
-
 /*
  * Test Case CrateDestroyCQ
  */
@@ -210,8 +191,8 @@
 			}
 			CL_ASSERT(h_cq);
 			ALTS_PRINT( ALTS_DBG_INFO,\
-				("ib_create_cq successful status = %s\n",
-				ib_get_err_str(ib_status)) );
+				("ib_create_cq successful size = 0x%x status
= %s\n",
+				cq_create.size, ib_get_err_str(ib_status))
);
 
 			while( modify_cq_attr == TRUE )
 			{
@@ -229,10 +210,20 @@
 						ib_get_err_str(ib_status))
);
 					break;
 				}
+
+				if(cq_size != cq_create.size)
+				{
+					ALTS_PRINT( ALTS_DBG_ERROR,
+						("ib_query_cq failed
cq_size=0x%x cq_create.cq_size=0x%x\n",
+						cq_size,cq_create.size));
+					ib_status = IB_INVALID_CQ_SIZE;
+					break;
+				}
+				
 				ALTS_PRINT( ALTS_DBG_INFO,
-					("ib_query_cq cq_size = %d\n",
cq_size) );
+					("ib_query_cq cq_size = 0x%x\n",
cq_size) );
 
-				cq_size = 0x50;
+				cq_size = 0x90;
 
 				ib_status = ib_modify_cq(h_cq,&cq_size);
 				if(ib_status != IB_SUCCESS)
@@ -243,8 +234,8 @@
 					break;
 				}
 
-			ALTS_PRINT( ALTS_DBG_INFO,
-				("ib_modify_cq passed for cq_size = %d\n",
cq_size) );
+				ALTS_PRINT( ALTS_DBG_INFO,
+					("ib_modify_cq passed for cq_size =
0x%x\n", cq_size) );
 
 				break; //Break for the while
 			}
Index: createanddestroyqp.c
===================================================================
--- createanddestroyqp.c	(revision 0)
+++ createanddestroyqp.c	(revision 0)
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: createanddestroycq.c 46 2005-05-30 17:55:53Z sleybo $
+ */
+
+
+#include <iba/ib_types.h>
+#include <iba/ib_al.h>
+#include <complib/cl_memory.h>
+#include <alts_debug.h>
+#include <alts_common.h>
+
+
+
+
+/*
+ * Function prototypes
+ */
+ib_api_status_t
+alts_qp(
+	boolean_t modify_cq_attr
+	);
+
+
+
+/*
+ * Test Case CrateDestroyQP
+ */
+
+
+ib_api_status_t
+al_test_create_destroy_qp(void)
+{
+	boolean_t modify_qp_attr = FALSE;
+
+	return alts_qp(modify_qp_attr);
+}
+
+ib_api_status_t
+al_test_query_modify_qp(void)
+{
+	boolean_t modify_qp_attr = TRUE;
+
+	return alts_qp(modify_qp_attr);
+}
+
+
+/* Internal Functions */
+
+ib_api_status_t
+alts_qp(
+	boolean_t modify_cq_attr
+	)
+{
+	ib_api_status_t	ib_status = IB_SUCCESS;
+	ib_al_handle_t		h_al = NULL;
+	ib_ca_handle_t	h_ca;
+	ib_cq_handle_t	h_cq = NULL;
+	ib_qp_handle_t	h_qp = NULL;	
+	ib_pd_handle_t	h_pd;	
+	cl_status_t		cl_status;
+	ib_cq_create_t	cq_create;
+	ib_qp_create_t	qp_create;	
+	uint32_t			bsize; 
+	ib_ca_attr_t		*p_ca_attr = NULL;
+	ib_qp_attr_t		p_qp_attr;
+
+
+	ALTS_ENTER( ALTS_DBG_VERBOSE );
+
+	while(1)
+	{
+		/* Open AL */
+		ib_status = alts_open_al(&h_al);
+
+		if(ib_status != IB_SUCCESS)
+			break;
+
+		CL_ASSERT(h_al);
+
+		/* Open CA */
+		ib_status = alts_open_ca(h_al,&h_ca);
+		if(ib_status != IB_SUCCESS)
+			break;
+
+		CL_ASSERT(h_ca);
+
+		/*
+		 * Allocate a PD required for CQ
+		 */
+		ib_status = ib_alloc_pd(h_ca, IB_PDT_NORMAL, NULL, &h_pd);
//passing null context
+
+		if(ib_status != IB_SUCCESS)
+		{
+			ALTS_PRINT( ALTS_DBG_ERROR,
+				("\tib_alloc_pd failed status = %s\n",
ib_get_err_str(ib_status)) );
+			alts_close_ca(h_ca);
+			break;
+		}
+		ALTS_PRINT( ALTS_DBG_ERROR,
+			("\tib_pd handle = %p\n",h_pd));
+
+		/*
+		 * Get the CA Attributest
+		 * Check for two active ports
+		 */
+
+		/*
+		 * Query the CA
+		 */
+		bsize = 0;
+		ib_status = ib_query_ca(h_ca, NULL, &bsize);
+		if(ib_status != IB_INSUFFICIENT_MEMORY)
+		{
+			ALTS_PRINT(ALTS_DBG_ERROR,
+				("ib_query_ca failed with status = %d\n",
ib_status) );
+			break;
+		}
+		CL_ASSERT(bsize);
+
+
+
+		p_ca_attr = (ib_ca_attr_t *)cl_zalloc(bsize);
+		if (!p_ca_attr)
+		{
+			ALTS_PRINT( ALTS_DBG_ERROR,
+				("zalloc() failed for p_ca_attr!\n") );
+			break;
+		}
+
+		ib_status = ib_query_ca(h_ca, p_ca_attr, &bsize);
+		if(ib_status != IB_SUCCESS)
+		{
+			ALTS_PRINT( ALTS_DBG_ERROR,
+				("ib_query_ca failed with status = %d\n",
ib_status) );
+			break;
+		}
+
+
+
+
+		/*
+		 * Create CQ Attributes
+		 */
+		cq_create.size = ALTS_CQ_SIZE;
+		cq_create.pfn_comp_cb = alts_cq_comp_cb;
+		cq_create.h_wait_obj = NULL;
+
+		ib_status = ib_create_cq(
+								h_ca,
+								&cq_create,
+								NULL,
+
alts_cq_err_cb,
+								&h_cq );
+		CL_ASSERT(ib_status == IB_SUCCESS);
+
+
+	
+		/*
+		 * Create QP Attributes
+		 */
+		qp_create.sq_depth= 1;
+		qp_create.rq_depth= 1;
+		qp_create.sq_sge	= 1;
+		qp_create.rq_sge	= 1;
+		qp_create.h_sq_cq	= h_cq; //NULL
+		qp_create.h_rq_cq	= h_cq;
+
+		qp_create.sq_signaled = TRUE;
+
+		qp_create.qp_type = IB_QPT_RELIABLE_CONN;
+
+		
+		ib_status = ib_create_qp(
+			h_pd,
+			&qp_create,
+			NULL,
+			alts_qp_err_cb,
+			&h_qp);
+
+		if (ib_status != IB_SUCCESS)
+		{
+			ALTS_PRINT(ALTS_DBG_ERROR,
+				("Error in ib_create_qp()! %s\n",
+				ib_get_err_str(ib_status)));
+			ALTS_EXIT(ALTS_DBG_VERBOSE);
+			return (ib_status);
+		}
+
+		ib_status = ib_query_qp(h_qp,
+							&p_qp_attr);
+
+		if (ib_status != IB_SUCCESS)
+		{
+			ALTS_PRINT(ALTS_DBG_ERROR,
+				("Error in query_qp()! %s\n",
+				ib_get_err_str(ib_status)));
+
+			ib_destroy_qp(h_qp,alts_qp_destroy_cb);
+			ALTS_EXIT(ALTS_DBG_VERBOSE);
+			return (ib_status);
+		}
+
+		ib_status = ib_destroy_qp(h_qp, alts_qp_destroy_cb);
+
+		if (h_cq)
+			ib_status = ib_destroy_cq(h_cq, alts_qp_destroy_cb);
+
+
+		ib_status = ib_dealloc_pd(h_pd,alts_pd_destroy_cb);
+		if(ib_status != IB_SUCCESS)
+		{
+			ALTS_PRINT( ALTS_DBG_ERROR,
+				("ib_dealloc_pd failed status = %s\n",
+				ib_get_err_str(ib_status)) );
+		}
+
+		alts_close_ca(h_ca);
+
+		break; //End of while
+	}
+
+	/* Close AL */
+	if(h_al)
+		alts_close_al(h_al);
+
+	ALTS_EXIT( ALTS_DBG_VERBOSE);
+	return ib_status;
+}
+
+void
+alts_qp_err_cb(
+	ib_async_event_rec_t				*p_err_rec )
+{
+	ALTS_ENTER( ALTS_DBG_VERBOSE );
+
+	UNUSED_PARAM( p_err_rec );
+
+	ALTS_EXIT( ALTS_DBG_VERBOSE);
+}
+
+void
+alts_qp_destroy_cb(
+	void	*context
+	)
+{
+	ALTS_ENTER( ALTS_DBG_VERBOSE );
+
+	UNUSED_PARAM( context );
+
+	ALTS_EXIT( ALTS_DBG_VERBOSE);
+}
+
+
+
+
Index: user/alts_main.c
===================================================================
--- user/alts_main.c	(revision 346)
+++ user/alts_main.c	(working copy)
@@ -182,9 +182,7 @@
 		ib_status = al_test_query_modify_av();
 		break;
 	case CreateDestroyQP:
-		CL_PRINT( ALTS_DBG_VERBOSE, alts_dbg_lvl,
-			("altsapp: CreateDestroyQP not implemented.\n") );
-		ib_status = IB_SUCCESS;
+		ib_status = al_test_create_destroy_qp();
 		break;
 	case QueryAndModifyQP:
 		CL_PRINT( ALTS_DBG_VERBOSE, alts_dbg_lvl,
Index: user/alts_sources.c
===================================================================
--- user/alts_sources.c	(revision 346)
+++ user/alts_sources.c	(working copy)
@@ -37,6 +37,7 @@
 #include "../../shared/alts/alts_misc.c"
 #include "../../shared/alts/cmtests.c"
 #include "../../shared/alts/createanddestroycq.c"
+#include "../../shared/alts/createanddestroyqp.c"
 #include "../../shared/alts/createdestroyav.c"
 #include "../../shared/alts/creatememwindow.c"
 #include "../../shared/alts/ibquery.c"
Index: user/SOURCES
===================================================================
--- user/SOURCES	(revision 346)
+++ user/SOURCES	(working copy)
@@ -9,6 +9,7 @@
 	..\alts_misc.c			\
 	..\cmtests.c			\
 	..\createanddestroycq.c	\
+	..\createanddestroyqp.c	\
 	..\createdestroyav.c	\
 	..\creatememwindow.c	\
 	..\ibquery.c			\

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20050906/f989c046/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: create_qp.patch
Type: application/octet-stream
Size: 10215 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20050906/f989c046/attachment.obj>


More information about the ofw mailing list