From 02ffd3a5b575d088cb25722425a769c4a3e3a58a Mon Sep 17 00:00:00 2001 From: ftillier Date: Tue, 6 Sep 2005 19:30:32 +0000 Subject: [PATCH] ALTS: Add create/destroy QP test case Submitted by Yossi Leybovich git-svn-id: svn://openib.tc.cornell.edu/gen1@61 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/tests/alts/alts_common.h | 37 ++++ trunk/tests/alts/createanddestroycq.c | 41 ++-- trunk/tests/alts/createanddestroyqp.c | 283 ++++++++++++++++++++++++++ trunk/tests/alts/user/SOURCES | 1 + trunk/tests/alts/user/alts_main.c | 4 +- trunk/tests/alts/user/alts_sources.c | 49 ----- 6 files changed, 338 insertions(+), 77 deletions(-) create mode 100644 trunk/tests/alts/createanddestroyqp.c delete mode 100644 trunk/tests/alts/user/alts_sources.c diff --git a/trunk/tests/alts/alts_common.h b/trunk/tests/alts/alts_common.h index dc355b60..fce87c22 100644 --- a/trunk/tests/alts/alts_common.h +++ b/trunk/tests/alts/alts_common.h @@ -157,6 +157,9 @@ typedef enum alts_dev_ops IOCTL_CODE(ALDEV_KEY, CmTests) +#define ALTS_CQ_SIZE 0x50 + + /* * Function Prototypes for the above test cases */ @@ -187,6 +190,14 @@ al_test_create_destroy_cq( void ); 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 ); @@ -253,4 +264,30 @@ void 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__ diff --git a/trunk/tests/alts/createanddestroycq.c b/trunk/tests/alts/createanddestroycq.c index ef0a1ebb..778033c1 100644 --- a/trunk/tests/alts/createanddestroycq.c +++ b/trunk/tests/alts/createanddestroycq.c @@ -38,11 +38,7 @@ #include -/* - * //NoteNote parameter that can be changed to test CQ functionality - */ -#define ALTS_CQ_SIZE 0x50 /* * Function prototypes @@ -52,21 +48,6 @@ alts_cq( 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 @@ alts_cq( } 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 @@ alts_cq( 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 @@ alts_cq( 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 } diff --git a/trunk/tests/alts/createanddestroyqp.c b/trunk/tests/alts/createanddestroyqp.c new file mode 100644 index 00000000..a7c72e03 --- /dev/null +++ b/trunk/tests/alts/createanddestroyqp.c @@ -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$ + */ + + +#include +#include +#include +#include +#include + + + + +/* + * 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); +} + + + + diff --git a/trunk/tests/alts/user/SOURCES b/trunk/tests/alts/user/SOURCES index 69031874..499a534b 100644 --- a/trunk/tests/alts/user/SOURCES +++ b/trunk/tests/alts/user/SOURCES @@ -9,6 +9,7 @@ SOURCES=alts_main.c \ ..\alts_misc.c \ ..\cmtests.c \ ..\createanddestroycq.c \ + ..\createanddestroyqp.c \ ..\createdestroyav.c \ ..\creatememwindow.c \ ..\ibquery.c \ diff --git a/trunk/tests/alts/user/alts_main.c b/trunk/tests/alts/user/alts_main.c index 3213edf7..ef97cc39 100644 --- a/trunk/tests/alts/user/alts_main.c +++ b/trunk/tests/alts/user/alts_main.c @@ -182,9 +182,7 @@ ib_api_status_t ib_status = IB_ERROR; 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, diff --git a/trunk/tests/alts/user/alts_sources.c b/trunk/tests/alts/user/alts_sources.c deleted file mode 100644 index bc33fcf4..00000000 --- a/trunk/tests/alts/user/alts_sources.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2005 SilverStorm Technologies. 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$ - */ - -/* - * Include all files that are not in the current directory. - */ - -#include "../../shared/alts/allocdeallocpd.c" -#include "../../shared/alts/alts_misc.c" -#include "../../shared/alts/cmtests.c" -#include "../../shared/alts/createanddestroycq.c" -#include "../../shared/alts/createdestroyav.c" -#include "../../shared/alts/creatememwindow.c" -#include "../../shared/alts/ibquery.c" -#include "../../shared/alts/madtests.c" -#include "../../shared/alts/multisendrecv.c" -#include "../../shared/alts/openclose.c" -#include "../../shared/alts/querycaattr.c" -#include "../../shared/alts/registermemregion.c" -#include "../../shared/alts/registerpnp.c" -#include "../../shared/alts/smatests.c" -- 2.41.0