]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
Adding vstat program to tools.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 11 Jul 2005 23:31:17 +0000 (23:31 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 11 Jul 2005 23:31:17 +0000 (23:31 +0000)
Provided by Dafna Levenvirth <dafna@mellanox.co.il>

git-svn-id: svn://openib.tc.cornell.edu/gen1@36 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/tools/dirs
trunk/tools/vstat/dirs [new file with mode: 0644]
trunk/tools/vstat/user/SOURCES [new file with mode: 0644]
trunk/tools/vstat/user/makefile [new file with mode: 0644]
trunk/tools/vstat/user/vstat_main.c [new file with mode: 0644]
trunk/tools/vstat/user/vstat_querycaattr.c [new file with mode: 0644]

index 1c7d60e15f77c9773d4a2fa75baf74544ecb45f5..58b35e996d2a77e5ad7f4d39ff483e50d19c409c 100644 (file)
@@ -1,4 +1,5 @@
 DIRS=\\r
        coinstaller     \\r
        fwupdate        \\r
-       wsdinstall\r
+       wsdinstall      \\r
+       vstat\r
diff --git a/trunk/tools/vstat/dirs b/trunk/tools/vstat/dirs
new file mode 100644 (file)
index 0000000..5a7e8b3
--- /dev/null
@@ -0,0 +1,2 @@
+DIRS=\
+       user
diff --git a/trunk/tools/vstat/user/SOURCES b/trunk/tools/vstat/user/SOURCES
new file mode 100644 (file)
index 0000000..28d7a76
--- /dev/null
@@ -0,0 +1,23 @@
+TARGETNAME=vstat
+TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)
+TARGETTYPE=PROGRAM
+UMTYPE=console
+USE_CRTDLL=1
+
+SOURCES= vstat_querycaattr.c \
+       vstat_main.c
+
+INCLUDES=..\..\..\inc;..\..\..\inc\user;..\..\..\tests\alts;
+
+RCOPTIONS=/I..\..\win\include
+
+TARGETLIBS= \
+!if $(FREEBUILD)
+                       $(TARGETPATH)\*\complib.lib \
+                       $(TARGETPATH)\*\ibal.lib
+!else
+                       $(TARGETPATH)\*\complibd.lib \
+                       $(TARGETPATH)\*\ibald.lib
+!endif
+
+MSC_WARNING_LEVEL= /W3
diff --git a/trunk/tools/vstat/user/makefile b/trunk/tools/vstat/user/makefile
new file mode 100644 (file)
index 0000000..5818975
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
+# file to this component.  This file merely indirects to the real make file
+# that is shared by all the driver components of the Windows NT DDK
+#
+
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/trunk/tools/vstat/user/vstat_main.c b/trunk/tools/vstat/user/vstat_main.c
new file mode 100644 (file)
index 0000000..90a619a
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2005 Mellanox 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: vstat_main.c 01 2005-07-11 14:55:53Z dafna $
+ */
+
+/*
+ * Abstract:
+ *     This is the main c file vstat application
+ *
+ * Environment:
+ *     Linux User Mode
+ *
+ * $Revision:  $
+ */
+
+
+#include "stdio.h"
+#include "string.h"
+#include "stdlib.h"
+
+
+#include <iba/ib_types.h>
+#include "..\..\..\tests\alts\alts_debug.h"
+#include "..\..\..\tests\alts\alts_common.h"
+#include "..\..\..\tests\alts\alts_misc.c"
+#ifndef WIN32
+#include <complib/cl_device.h>
+#endif
+
+//#include <complib/cl_syshelper.h>
+//#include <complib/cl_memory.h>
+
+
+//#define COMPILE_USER_MODE
+#ifdef WIN32
+#define strcasecmp     lstrcmpi
+#define strncasecmp( s1, s2, l )       CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE, s1, strlen(s1), s2, l )
+#endif
+
+#if !defined( FALSE )
+#define FALSE 0
+#endif /* !defined( FALSE ) */
+
+#if !defined( TRUE )
+#define TRUE 1
+#endif /* !defined( TRUE ) */
+
+/*
+ * Global Varables
+ */
+
+//Global Debug level
+uint32_t       alts_dbg_lvl = ALTS_DBG_FULL;
+
+/*
+ * Data structure
+ */
+
+
+/*
+ * Function prototypes
+ */
+
+ib_api_status_t
+alts_ca_attr(
+       boolean_t modify_attr,
+       BOOLEAN fullPrint
+       );
+
+#ifndef CL_KERNEL
+void
+run_ual_test(
+       cmd_line_arg_t *cmd_line_arg
+       );
+#endif
+
+void
+run_kal_test(
+       cmd_line_arg_t *cmd_line_arg
+       );
+
+
+
+/*******************************************************************
+*******************************************************************/
+
+
+int32_t __cdecl
+main(
+       int32_t argc,
+       char* argv[])
+{
+       ib_api_status_t ib_status;
+       BOOLEAN fullPrint = FALSE;
+       if(argc>1){
+               int i = 2;
+               while(i<=argc){
+                       if(!_stricmp(argv[i-1], "-v")){
+                               fullPrint = TRUE;
+                               i+=1;
+                       }else{
+                               i+=2;
+                       }
+               }
+       }
+       ib_status = alts_ca_attr(FALSE, fullPrint);
+       return 0;
+}
+
diff --git a/trunk/tools/vstat/user/vstat_querycaattr.c b/trunk/tools/vstat/user/vstat_querycaattr.c
new file mode 100644 (file)
index 0000000..609a38d
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * Copyright (c) 2005 Mellanox 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: vstat_querycaattr.c 01 2005-07-11 14:55:53Z dafna $
+ */
+
+#include <iba/ib_types.h>
+#include <iba/ib_al.h>
+#include <complib/cl_memory.h>
+#include "..\..\..\tests\alts\alts_debug.h"
+#include "..\..\..\tests\alts\alts_common.h"
+
+/*
+ * Function prototypes
+ */
+
+ib_api_status_t
+alts_ca_attr(
+       boolean_t modify_attr,
+       BOOLEAN fullPrint
+       );
+
+/*
+ * Test Case QueryCaAttributes
+ */
+
+ib_api_status_t
+al_test_modifycaattr(void)
+{
+       boolean_t modify_ca_attr = TRUE;
+
+       return alts_ca_attr(modify_ca_attr, FALSE);
+}
+
+ib_api_status_t
+al_test_querycaattr(void)
+{
+       boolean_t modify_ca_attr = FALSE;
+
+       return alts_ca_attr(modify_ca_attr, FALSE);
+}
+
+void print64bit(ib_net64_t u64, BOOLEAN hexFormat){
+       ib_net64_t mask = 255;
+       ib_net64_t tmp;
+       int i;
+       for(i=0;i<8;i++){
+               tmp = (short)(u64>>(i*8)) & mask;
+               if(hexFormat){
+                       printf("%02x", tmp);
+                       if(i<7){
+                               printf(":");
+                       }
+               }else{
+                       if(tmp<100){
+                               printf("%02d", tmp);
+                       }else{
+                               printf("%03d", tmp);
+                       }
+                       if(i<7){
+                               printf(".");
+                       }
+               }
+       }
+}      
+
+void printGUID(ib_net64_t guid){
+       printf("\tnode_guid=");
+       print64bit(guid, TRUE);
+       printf("        (Node GUID for this hca)\n");
+}
+
+void printPortGID(ib_net64_t subnetPrefix, ib_net64_t portGuid){
+       printf("\t\tGID[  0]= ");
+       print64bit(subnetPrefix, FALSE);
+       printf(".");
+       print64bit(portGuid, FALSE);
+       printf("\n");
+}
+
+
+void printPortLinkState(int portState){ //TODO: check that these are all the options and that they are correct
+       switch(portState){
+               case 1:
+                       printf("\t\tport_state=PORT_DOWN\n");
+                       break;
+               case 2:
+                       printf("\t\tport_state=PORT_INITIALIZE\n");
+                       break;
+               case 4:
+                       printf("\t\tport_state=PORT_ACTIVE\n");
+                       break;
+               default:
+                       printf("\t\tport_state=UNKNOWN\n"); 
+       }
+}
+
+
+void printPortInfo(ib_port_attr_t* portPtr, BOOLEAN fullPrint){
+       printf("\t\tport=%d\n", portPtr->port_num);
+       printPortLinkState(portPtr->link_state);
+       printf("\t\tsm_lid=0x%04x\n", cl_ntoh16(portPtr->sm_lid));
+       printf("\t\tport_lid=0x%04x\n", cl_ntoh16(portPtr->lid));
+       printf("\t\tport_lmc=0x%x\n", portPtr->lmc);
+       printf("\t\tmax_mtu=%d\n", portPtr->mtu);
+       if(fullPrint){
+               printf("\t\tmax_msg_sz=0x%x     (Max message size)\n", portPtr->max_msg_size);
+               printf("\t\tcapability_mask=TBD\n");
+               printf("\t\tmax_vl_num=0x%x     (Maximum number of VL supported by this port)\n", portPtr->max_vls);
+               printf("\t\tbad_pkey_counter=0x%x       (Bad PKey counter)\n", portPtr->pkey_ctr);
+               printf("\t\tqkey_viol_counter=0x%x      (QKey violation counter)\n", portPtr->qkey_ctr);
+               printf("\t\tsm_sl=0x%x  (IB_SL to be used in communication with subnet manager)\n", portPtr->sm_sl);
+               printf("\t\tpkey_tbl_len=0x%x   (Current size of pkey table)\n", portPtr->num_pkeys);
+               printf("\t\tgid_tbl_len=0x%x    (Current size of GID table)\n", portPtr->num_gids);
+               printf("\t\tsubnet_timeout=0x%x (Subnet Timeout for this port (see PortInfo))\n", portPtr->subnet_timeout);
+               printf("\t\tinitTypeReply=0x%x  (optional InitTypeReply value. 0 if not supported)\n", portPtr->init_type_reply);
+               printPortGID(portPtr->p_gid_table->unicast.prefix, portPtr->p_gid_table->unicast.interface_id);
+       }
+       printf("\n");
+}
+
+
+
+
+void vstat_print_ca_attr(ib_ca_attr_t* ca_attr, BOOLEAN fullPrint){
+       int i;
+       
+       printf("\thca_id=%s\n", ca_attr->dev_id==0x5a44?"InfiniHost0":"TBD"); //TODO: all HCAs and hadle multi HCAs 
+       printf("\tpci_location={BUS=TBD,DEV/FUNC=TBD}\n");
+       printf("\tvendor_id=0x%04x\n", ca_attr->vend_id);
+       printf("\tvendor_part_id=0x%04x\n", ca_attr->dev_id);
+       printf("\thw_ver=0x%x\n", ca_attr->revision); //TODO: ???
+       printf("\tfw_ver=TBD\n");
+       printf("\tPSID=TBD\n");
+       if(fullPrint){
+               printf("\tnum_phys_ports=TBD\n");
+               printf("\tmax_num_qp=0x%x       (Maximum Number of QPs supported)\n", ca_attr->max_qps);
+               printf("\tmax_qp_ous_wr=0x%x    (Maximum Number of oustanding WR on any WQ)\n", ca_attr->max_wrs);
+               printf("\tflags==TBD\n");
+               printf("\tmax_num_sg_ent=0x%x   (Max num of scatter/gather entries for WQE other than RD)\n", ca_attr->max_sges);
+               printf("\tmax_num_sg_ent_rd=0x%x        (Max num of scatter/gather entries for RD WQE)\n",  ca_attr->max_rd_sges);
+               printf("\tmax_num_srq=TBD       (Maximum Number of SRQs supported)\n");
+               printf("\tmax_wqe_per_srq=TBD   (Maximum Number of oustanding WR on any SRQ)\n");
+               printf("\tmax_srq_sentries=TDB  (Maximum Number of scatter entries for SRQ WQE)\n");
+               printf("\tsrq_resize_supported=TBD      (SRQ resize supported)\n");
+               printf("\tmax_num_cq=0x%x       (Max num of supported CQs)\n", ca_attr->max_cqs);
+               printf("\tmax_num_ent_cq=0x%x   (Max num of supported entries per CQ)\n", ca_attr->max_cqes);
+               printf("\tmax_num_mr=0x%x       (Maximum number of memory region supported)\n", ca_attr->init_regions);
+               printf("\tmax_mr_size=0x%x      (Largest contigous block of memory region in bytes)\n", ca_attr->init_region_size);
+               printf("\tmax_pd_num=0x%x       (Maximum number of protection domains supported)\n", ca_attr->max_pds);
+               printf("\tpage_size_cap=TBD     (Largest page size supported by this HCA)\n");
+               printf("\tmax_pkeys=TBD (Maximum number of partitions supported)\n");
+               printGUID(ca_attr->ca_guid);
+               printf("\tlocal_ca_ack_delay=0x%x       (Log2 4.096usec Max. RX to ACK or NAK delay)\n", ca_attr->local_ack_delay);
+               printf("\tmax_qp_ous_rd_atom=TBD        (Maximum number of oust. RDMA read/atomic as target)\n");
+               printf("\tmax_ee_ous_rd_atom=TBD        (EE Maximum number of outs. RDMA read/atomic as target)\n");
+               printf("\tmax_res_rd_atom=TBD   (Max. Num. of resources used for RDMA read/atomic as target)\n");
+               printf("\tmax_qp_init_rd_atom=TBD       (Max. Num. of outs. RDMA read/atomic as initiator)\n");
+               printf("\tmax_ee_init_rd_atom=TBD       (EE Max. Num. of outs. RDMA read/atomic as initiator)\n");
+               printf("\tatomic_cap=TBD        (Level of Atomicity supported)\n");
+               printf("\tmax_ee_num=0x0        (Maximum number of EEC supported)\n");
+               printf("\tmax_rdd_num=0x0       (Maximum number of IB_RDD supported)\n");
+               printf("\tmax_mw_num=0x%x       (Maximum Number of memory windows supported)\n", ca_attr->init_windows);
+               printf("\tmax_raw_ipv6_qp=0x%x  (Maximum number of Raw IPV6 QPs supported)\n", ca_attr->max_ipv6_qps);
+               printf("\tmax_raw_ethy_qp=0x%x  (Maximum number of Raw Ethertypes QPs supported)\n", ca_attr->max_ether_qps);
+               printf("\tmax_mcast_grp_num=0x%x        (Maximum Number of multicast groups)\n", ca_attr->max_mcast_grps);
+               printf("\tmax_mcast_qp_attach_num=0x%x  (Maximum number of QP per multicast group)\n", ca_attr->max_qps_per_mcast_grp);
+               printf("\tmax_total_mcast_qp_attach_num=0x%x    (Maximum number of QPs which can be attached to a mcast grp)\n", ca_attr->max_mcast_qps);
+               printf("\tmax_ah_num=0x%x       (Maximum number of address handles)\n", ca_attr->max_addr_handles);
+               printf("\tmax_num_fmr=TBD       (maximum number FMRs)\n");
+               printf("\tmax_num_map_per_fmr=TBD       (Maximum number of (re)maps per FMR before an unmap operation in required)\n");
+       }else{
+               printf("\tnum_phys_ports=%d\n",         ca_attr->num_ports);
+       }
+       for (i = 0; i<ca_attr->num_ports; i++){
+               printPortInfo(ca_attr->p_port_attr+i, fullPrint);
+       }       
+}
+/* Internal Functions */
+
+
+
+ib_api_status_t
+alts_ca_attr(
+       boolean_t modify_attr,
+       BOOLEAN fullPrint
+       )
+{
+       ib_al_handle_t  h_al = NULL;
+       ib_api_status_t ib_status = IB_SUCCESS;
+       ib_api_status_t ret_status = IB_SUCCESS;
+       size_t guid_count;
+       ib_net64_t ca_guid_array[ALTS_MAX_CA];
+       ib_ca_attr_t *alts_ca_attr;
+       uintn_t i;
+       ib_ca_handle_t h_ca = NULL;
+       uint32_t bsize;
+       ib_port_attr_mod_t port_attr_mod;
+
+
+       ALTS_ENTER( ALTS_DBG_VERBOSE );
+
+       while(1)
+       {
+               /*
+                * Open the AL instance
+                */
+               ib_status = ib_open_al(&h_al);
+               if(ib_status != IB_SUCCESS)
+               {
+                       ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_open_al failed status = %d\n", ib_status) );
+                       ret_status = ib_status;
+                       break;
+               }
+
+               //ALTS_PRINT( ALTS_DBG_INFO, ("ib_open_al PASSED.\n") );//xxx
+               CL_ASSERT(h_al);
+
+               /*
+                * Get the Local CA Guids
+                */
+               ib_status = ib_get_ca_guids(h_al, NULL, &guid_count);
+               if(ib_status != IB_INSUFFICIENT_MEMORY)
+               {
+                       ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_get_ca_guids failed status = %d\n", (uint32_t)ib_status) );
+                       ret_status = ib_status;
+                       goto Cleanup1;
+               }
+
+               ALTS_PRINT(ALTS_DBG_INFO,
+                       ("%d HCA found:\n",(uint32_t)guid_count)); //xxx
+
+               /*
+                * If no CA's Present then return
+                */
+
+               if(guid_count == 0)
+                       goto Cleanup1;
+
+               // ca_guid_array holds ALTS_MAX_CA
+               ib_status = ib_get_ca_guids(h_al, ca_guid_array, &guid_count);
+               if(ib_status != IB_SUCCESS)
+               {
+                       ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_get_ca_guids failed with status = %d\n", ib_status) );
+                       ret_status = ib_status;
+                       goto Cleanup1;
+               }
+
+               
+
+               /*
+                * For Each CA Guid found Open the CA,
+                * Query the CA Attribute and close the CA
+                */
+               for(i=0; i < guid_count; i++)
+               {
+                       /*
+                       node_guid=00:02:c9:00:01:2b:72:a0       (Node GUID for this hca) //xxx
+                       */
+                       //printGUID(ca_guid_array[i]);
+                       //xxx
+                       //ALTS_PRINT(ALTS_DBG_INFO, 
+                       //      ("CA[%d] GUID IS 0x%" PRIx64 "\n",i,_byteswap_uint64(ca_guid_array[i])) );
+                       //xxx
+
+
+
+
+                       /* Open the CA */
+                       ib_status = ib_open_ca(h_al,
+                               ca_guid_array[i],
+                               alts_ca_err_cb,
+                               NULL,   //ca_context
+                               &h_ca);
+
+                       if(ib_status != IB_SUCCESS)
+                       {
+                               ALTS_PRINT( ALTS_DBG_ERROR,     ("ib_open_ca failed with status = %d\n", ib_status) );
+                               ret_status = ib_status;
+                               goto Cleanup1;
+                       }
+
+                       //xxx
+                       //ALTS_PRINT(ALTS_DBG_INFO,
+                       //("ib_open_ca passed\n")); 
+                       //xxx
+
+
+                       /* 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) );
+                               ret_status = ib_status;
+                               goto Cleanup2;
+                       }
+                       CL_ASSERT(bsize);
+
+                       /* Allocate the memory needed for query_ca */
+
+                       alts_ca_attr = (ib_ca_attr_t *)cl_zalloc(bsize);
+                       CL_ASSERT(alts_ca_attr);
+
+                       ib_status = ib_query_ca(h_ca, alts_ca_attr, &bsize);
+                       if(ib_status != IB_SUCCESS)
+                       {
+                               ALTS_PRINT( ALTS_DBG_ERROR,
+                                       ("ib_query_ca failed with status = %d\n", ib_status) );
+                               ret_status = ib_status;
+                               goto Cleanup2;
+                       }
+
+                       /* Print_ca_attributes */
+
+                       vstat_print_ca_attr(alts_ca_attr, fullPrint);
+
+                       if(modify_attr)
+                       {
+                               port_attr_mod.pkey_ctr = 10;
+                               port_attr_mod.qkey_ctr = 10;
+
+                               ib_status = ib_modify_ca(h_ca,alts_ca_attr->p_port_attr->port_num,
+                                       IB_CA_MOD_QKEY_CTR | IB_CA_MOD_PKEY_CTR ,
+                                       &port_attr_mod);
+
+                               if(ib_status != IB_SUCCESS)
+                               {
+                                       ALTS_PRINT( ALTS_DBG_ERROR,
+                                       ("ib_modify_ca failed with status = %d\n", ib_status) );
+                                       ret_status = ib_status;
+                               }
+
+                               ib_status = ib_query_ca(h_ca, alts_ca_attr, &bsize);
+
+                               if(ib_status != IB_SUCCESS)
+                               {
+                                       ALTS_PRINT( ALTS_DBG_ERROR,
+                                       ("ib_query_ca failed with status = %d\n", ib_status) );
+                                       goto Cleanup2;
+                               }
+
+                               CL_ASSERT(port_attr_mod.pkey_ctr != \
+                                       alts_ca_attr->p_port_attr->pkey_ctr);
+                               CL_ASSERT(port_attr_mod.qkey_ctr != \
+                                       alts_ca_attr->p_port_attr->qkey_ctr);
+
+                       }
+
+                       /* Free the memory */
+                       cl_free(alts_ca_attr);
+                       alts_ca_attr = NULL;
+                       /* Close the current open CA */
+                       ib_status = ib_close_ca(h_ca, alts_ca_destroy_cb);
+                       if(ib_status != IB_SUCCESS)
+                       {
+                               ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_close_ca failed status = %d", ib_status));
+                       }
+                       h_ca = NULL;
+
+               }
+
+Cleanup2:
+               if(h_ca != NULL)
+               {
+                       ib_status = ib_close_ca(h_ca, alts_ca_destroy_cb);
+                       if(ib_status != IB_SUCCESS)
+                       {
+                               ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_close_ca failed status = %d", ib_status));
+                       }
+               }
+
+Cleanup1:
+               ib_status = ib_close_al(h_al);
+
+               if(ib_status != IB_SUCCESS)
+               {
+                       ALTS_PRINT( ALTS_DBG_ERROR,
+                               ("ib_close_al failed status = %d", ib_status));
+               }
+
+               break;
+
+       } //End of while(1)
+
+       ALTS_EXIT( ALTS_DBG_VERBOSE );
+       return ret_status;
+}
+