]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[VSTAT] Code cleanup to remove dependency on ALTS and removing unneeded files.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Sep 2005 18:35:03 +0000 (18:35 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Sep 2005 18:35:03 +0000 (18:35 +0000)
Signed-off-by: Yossi Leybovich (sleybo@mellanox.co.il)
git-svn-id: svn://openib.tc.cornell.edu/gen1@77 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/tools/vstat/user/SOURCES
trunk/tools/vstat/user/vstat_main.c
trunk/tools/vstat/user/vstat_querycaattr.c [deleted file]

index 4e2b4e5ebddbc97e7889def3218b108b0bd25a35..20475d69c19ab0650cf18f1fd8fae9f042371c3a 100644 (file)
@@ -1,24 +1,23 @@
-TARGETNAME=vstat
-TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)
-TARGETTYPE=PROGRAM
-UMTYPE=console
-USE_CRTDLL=1
-
-SOURCES=vstat.rc \
-       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
+TARGETNAME=vstat\r
+TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR)\r
+TARGETTYPE=PROGRAM\r
+UMTYPE=console\r
+USE_CRTDLL=1\r
+\r
+SOURCES=vstat.rc \\r
+       vstat_main.c\r
+\r
+INCLUDES=..\..\..\inc;..\..\..\inc\user;\r
+\r
+RCOPTIONS=/I..\..\win\include\r
+\r
+TARGETLIBS= \\r
+!if $(FREEBUILD)\r
+                       $(TARGETPATH)\*\complib.lib \\r
+                       $(TARGETPATH)\*\ibal.lib\r
+!else\r
+                       $(TARGETPATH)\*\complibd.lib \\r
+                       $(TARGETPATH)\*\ibald.lib\r
+!endif\r
+\r
+MSC_WARNING_LEVEL= /W3\r
index 1ad8f135471253bad7d7cb2aae676feab7a34548..93eb64a0583a677a72d1a3061c48d81d2791c469 100644 (file)
-/*
- * 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$
- */
-
-/*
- * 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;
-}
-
+/*\r
+ * Copyright (c) 2005 Mellanox Technologies.  All rights reserved.\r
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. \r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ * $Id$\r
+ */\r
+\r
+\r
+\r
+#include "stdio.h"\r
+#include "string.h"\r
+#include "stdlib.h"\r
+\r
+\r
+#include <iba/ib_types.h>\r
+#include <iba/ib_al.h>\r
+#ifndef WIN32\r
+#include <complib/cl_device.h>\r
+#endif\r
+\r
+\r
+\r
+\r
+/*******************************************************************\r
+*******************************************************************/\r
+\r
+\r
+void print64bit(ib_net64_t u64, BOOLEAN hexFormat){\r
+       ib_net64_t mask = 255;\r
+       ib_net64_t tmp;\r
+       int i;\r
+       for(i=0;i<8;i++){\r
+               tmp = (short)(u64>>(i*8)) & mask;\r
+               if(hexFormat){\r
+                       printf("%02x", tmp);\r
+                       if(i<7){\r
+                               printf(":");\r
+                       }\r
+               }else{\r
+                       if(tmp<100){\r
+                               printf("%02d", tmp);\r
+                       }else{\r
+                               printf("%03d", tmp);\r
+                       }\r
+                       if(i<7){\r
+                               printf(".");\r
+                       }\r
+               }\r
+       }\r
+}      \r
+\r
+void printGUID(ib_net64_t guid){\r
+       printf("\tnode_guid=");\r
+       print64bit(guid, TRUE);\r
+       printf("        (Node GUID for this hca)\n");\r
+}\r
+\r
+void printPortGID(ib_net64_t subnetPrefix, ib_net64_t portGuid){\r
+       printf("\t\tGID[  0]= ");\r
+       print64bit(subnetPrefix, FALSE);\r
+       printf(".");\r
+       print64bit(portGuid, FALSE);\r
+       printf("\n");\r
+}\r
+\r
+\r
+void printPortLinkState(int portState){ //TODO: check that these are all the options and that they are correct\r
+       switch(portState){\r
+               case 1:\r
+                       printf("\t\tport_state=PORT_DOWN\n");\r
+                       break;\r
+               case 2:\r
+                       printf("\t\tport_state=PORT_INITIALIZE\n");\r
+                       break;\r
+               case 4:\r
+                       printf("\t\tport_state=PORT_ACTIVE\n");\r
+                       break;\r
+               default:\r
+                       printf("\t\tport_state=UNKNOWN\n"); \r
+       }\r
+}\r
+\r
+\r
+void printPortInfo(ib_port_attr_t* portPtr, BOOLEAN fullPrint){\r
+       printf("\t\tport=%d\n", portPtr->port_num);\r
+       printPortLinkState(portPtr->link_state);\r
+       printf("\t\tsm_lid=0x%04x\n", cl_ntoh16(portPtr->sm_lid));\r
+       printf("\t\tport_lid=0x%04x\n", cl_ntoh16(portPtr->lid));\r
+       printf("\t\tport_lmc=0x%x\n", portPtr->lmc);\r
+       printf("\t\tmax_mtu=%d\n", portPtr->mtu);\r
+       if(fullPrint){\r
+               printf("\t\tmax_msg_sz=0x%x     (Max message size)\n", portPtr->max_msg_size);\r
+               printf("\t\tcapability_mask=TBD\n");\r
+               printf("\t\tmax_vl_num=0x%x     (Maximum number of VL supported by this port)\n", portPtr->max_vls);\r
+               printf("\t\tbad_pkey_counter=0x%x       (Bad PKey counter)\n", portPtr->pkey_ctr);\r
+               printf("\t\tqkey_viol_counter=0x%x      (QKey violation counter)\n", portPtr->qkey_ctr);\r
+               printf("\t\tsm_sl=0x%x  (IB_SL to be used in communication with subnet manager)\n", portPtr->sm_sl);\r
+               printf("\t\tpkey_tbl_len=0x%x   (Current size of pkey table)\n", portPtr->num_pkeys);\r
+               printf("\t\tgid_tbl_len=0x%x    (Current size of GID table)\n", portPtr->num_gids);\r
+               printf("\t\tsubnet_timeout=0x%x (Subnet Timeout for this port (see PortInfo))\n", portPtr->subnet_timeout);\r
+               printf("\t\tinitTypeReply=0x%x  (optional InitTypeReply value. 0 if not supported)\n", portPtr->init_type_reply);\r
+               printPortGID(portPtr->p_gid_table->unicast.prefix, portPtr->p_gid_table->unicast.interface_id);\r
+       }\r
+       printf("\n");\r
+}\r
+\r
+\r
+\r
+\r
+void vstat_print_ca_attr(ib_ca_attr_t* ca_attr, BOOLEAN fullPrint){\r
+       int i;\r
+       \r
+       printf("\thca_id=%s\n", ca_attr->dev_id==0x5a44?"InfiniHost0":"TBD"); //TODO: all HCAs and hadle multi HCAs \r
+       printf("\tpci_location={BUS=TBD,DEV/FUNC=TBD}\n");\r
+       printf("\tvendor_id=0x%04x\n", ca_attr->vend_id);\r
+       printf("\tvendor_part_id=0x%04x\n", ca_attr->dev_id);\r
+       printf("\thw_ver=0x%x\n", ca_attr->revision); //TODO: ???\r
+       printf("\tfw_ver=TBD\n");\r
+       printf("\tPSID=TBD\n");\r
+       if(fullPrint){\r
+               printf("\tnum_phys_ports =      TBD\n");\r
+               printf("\tmax_num_qp = 0x%x             (Maximum Number of QPs supported)\n", ca_attr->max_qps);\r
+               printf("\tmax_qp_ous_wr = 0x%x  (Maximum Number of oustanding WR on any WQ)\n", ca_attr->max_wrs);\r
+               printf("\tflags== TBD\n");\r
+               printf("\tmax_num_sg_ent = 0x%x         (Max num of scatter/gather entries for WQE other than RD)\n", ca_attr->max_sges);\r
+               printf("\tmax_num_sg_ent_rd =   0x%x    (Max num of scatter/gather entries for RD WQE)\n",  ca_attr->max_rd_sges);\r
+               printf("\tmax_num_srq = TBD             (Maximum Number of SRQs supported)\n");\r
+               printf("\tmax_wqe_per_srq = TBD (Maximum Number of oustanding WR on any SRQ)\n");\r
+               printf("\tmax_srq_sentries = TBD        (Maximum Number of scatter entries for SRQ WQE)\n");\r
+               printf("\tsrq_resize_supported = TBD    (SRQ resize supported)\n");\r
+               printf("\tmax_num_cq = 0x%x     (Max num of supported CQs)\n", ca_attr->max_cqs);\r
+               printf("\tmax_num_ent_cq = 0x%x (Max num of supported entries per CQ)\n", ca_attr->max_cqes);\r
+               printf("\tmax_num_mr = 0x%x     (Maximum number of memory region supported)\n", ca_attr->init_regions);\r
+               printf("\tmax_mr_size = 0x%x    (Largest contigous block of memory region in bytes)\n", ca_attr->init_region_size);\r
+               printf("\tmax_pd_num = 0x%x     (Maximum number of protection domains supported)\n", ca_attr->max_pds);\r
+               printf("\tpage_size_cap = TBD   (Largest page size supported by this HCA)\n");\r
+               printf("\tmax_pkeys = TBD               (Maximum number of partitions supported)\n");\r
+               printGUID(ca_attr->ca_guid);\r
+               printf("\tlocal_ca_ack_delay = 0x%x     (Log2 4.096usec Max. RX to ACK or NAK delay)\n", ca_attr->local_ack_delay);\r
+               printf("\tmax_qp_ous_rd_atom = TBD      (Maximum number of oust. RDMA read/atomic as target)\n");\r
+               printf("\tmax_ee_ous_rd_atom = TBD      (EE Maximum number of outs. RDMA read/atomic as target)\n");\r
+               printf("\tmax_res_rd_atom = TBD (Max. Num. of resources used for RDMA read/atomic as target)\n");\r
+               printf("\tmax_qp_init_rd_atom = TBD     (Max. Num. of outs. RDMA read/atomic as initiator)\n");\r
+               printf("\tmax_ee_init_rd_atom = TBD     (EE Max. Num. of outs. RDMA read/atomic as initiator)\n");\r
+               printf("\tatomic_cap = TBD              (Level of Atomicity supported)\n");\r
+               printf("\tmax_ee_num = 0x0              (Maximum number of EEC supported)\n");\r
+               printf("\tmax_rdd_num = 0x0             (Maximum number of IB_RDD supported)\n");\r
+               printf("\tmax_mw_num = 0x%x     (Maximum Number of memory windows supported)\n", ca_attr->init_windows);\r
+               printf("\tmax_raw_ipv6_qp = 0x%x        (Maximum number of Raw IPV6 QPs supported)\n", ca_attr->max_ipv6_qps);\r
+               printf("\tmax_raw_ethy_qp = 0x%x        (Maximum number of Raw Ethertypes QPs supported)\n", ca_attr->max_ether_qps);\r
+               printf("\tmax_mcast_grp_num = 0x%x      (Maximum Number of multicast groups)\n", ca_attr->max_mcast_grps);\r
+               printf("\tmax_mcast_qp_attach_num = 0x%x(Maximum number of QP per multicast group)\n", ca_attr->max_qps_per_mcast_grp);\r
+               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);\r
+               printf("\tmax_ah_num = 0x%x     (Maximum number of address handles)\n", ca_attr->max_addr_handles);\r
+               printf("\tmax_num_fmr = TBD             (maximum number FMRs)\n");\r
+               printf("\tmax_num_map_per_fmr = TBD     (Maximum number of (re)maps per FMR before an unmap operation in required)\n");\r
+       }else{\r
+               printf("\tnum_phys_ports=%d\n",         ca_attr->num_ports);\r
+       }\r
+       for (i = 0; i<ca_attr->num_ports; i++){\r
+               printPortInfo(ca_attr->p_port_attr+i, fullPrint);\r
+       }       \r
+}\r
+/* Internal Functions */\r
+\r
+\r
+\r
+ib_api_status_t\r
+vstat_ca_attr(\r
+       boolean_t modify_attr,\r
+       BOOLEAN fullPrint\r
+       )\r
+{\r
+       ib_al_handle_t          h_al = NULL;\r
+       ib_api_status_t         ib_status = IB_SUCCESS;\r
+       ib_api_status_t         ret_status = IB_SUCCESS;\r
+       size_t                  guid_count;\r
+       ib_net64_t              *ca_guid_array;\r
+       ib_ca_attr_t            *vstat_ca_attr;\r
+       uintn_t                         i;\r
+       ib_ca_handle_t  h_ca = NULL;\r
+       uint32_t                        bsize;\r
+       ib_port_attr_mod_t port_attr_mod;\r
+\r
+\r
+\r
+\r
+       while(1)\r
+       {\r
+               /*\r
+                * Open the AL instance\r
+                */\r
+               ib_status = ib_open_al(&h_al);\r
+               if(ib_status != IB_SUCCESS)\r
+               {\r
+                       printf("ib_open_al failed status = %d\n", ib_status);\r
+                       ret_status = ib_status;                 \r
+                       break;\r
+               }\r
+               //xxxx\r
+               //printf("ib_open_al PASSED.\n");\r
+               //xxx\r
+               CL_ASSERT(h_al);\r
+\r
+               /*\r
+                * Get the Local CA Guids\r
+                */\r
+               ib_status = ib_get_ca_guids(h_al, NULL, &guid_count);\r
+               if(ib_status != IB_INSUFFICIENT_MEMORY)\r
+               {\r
+                       printf("ib_get_ca_guids1 failed status = %d\n", (uint32_t)ib_status);\r
+                       ret_status = ib_status;                 \r
+                       goto Cleanup1;\r
+               }\r
+\r
+               \r
+\r
+               /*\r
+                * If no CA's Present then return\r
+                */\r
+\r
+               if(guid_count == 0)\r
+                       goto Cleanup1;\r
+\r
+               \r
+               ca_guid_array = (ib_net64_t*)cl_malloc(sizeof(ib_net64_t) * guid_count);\r
+               CL_ASSERT(ca_guid_array);\r
+               \r
+               ib_status = ib_get_ca_guids(h_al, ca_guid_array, &guid_count);\r
+               if(ib_status != IB_SUCCESS)\r
+               {\r
+                       printf("ib_get_ca_guids2 failed with status = %d\n", ib_status);\r
+                       ret_status = ib_status;                 \r
+                       goto Cleanup1;\r
+               }\r
+\r
+               \r
+\r
+               /*\r
+                * For Each CA Guid found Open the CA,\r
+                * Query the CA Attribute and close the CA\r
+                */\r
+               for(i=0; i < guid_count; i++)\r
+               {\r
+\r
+                       /* Open the CA */\r
+                       ib_status = ib_open_ca(h_al,\r
+                               ca_guid_array[i],\r
+                               NULL,\r
+                               NULL,   //ca_context\r
+                               &h_ca);\r
+\r
+                       if(ib_status != IB_SUCCESS)\r
+                       {\r
+                               printf("ib_open_ca failed with status = %d\n", ib_status);\r
+                               ret_status = ib_status;                         \r
+                               goto Cleanup1;\r
+                       }\r
+\r
+                       //xxx\r
+                       //printf("ib_open_ca passed i=%d\n",i); \r
+                       //xxx\r
+\r
+\r
+                       /* Query the CA */\r
+                       bsize = 0;\r
+                       ib_status = ib_query_ca(h_ca, NULL, &bsize);\r
+                       if(ib_status != IB_INSUFFICIENT_MEMORY)\r
+                       {\r
+                               printf("ib_query_ca failed with status = %d\n", ib_status);\r
+                               ret_status = ib_status;\r
+                               goto Cleanup2;\r
+                       }\r
+                       CL_ASSERT(bsize);\r
+                       //xxxx\r
+                       //printf("ib_query_ca PASSED bsize = 0x%x.\n",bsize);\r
+                       //xxx\r
+                       /* Allocate the memory needed for query_ca */\r
+\r
+                       vstat_ca_attr = (ib_ca_attr_t *)cl_zalloc(bsize);\r
+                       CL_ASSERT(vstat_ca_attr);\r
+\r
+                       ib_status = ib_query_ca(h_ca, vstat_ca_attr, &bsize);\r
+                       if(ib_status != IB_SUCCESS)\r
+                       {\r
+                               printf("ib_query_ca failed with status = %d\n", ib_status);\r
+                               ret_status = ib_status;\r
+                               goto Cleanup2;\r
+                       }\r
+\r
+                       /* Print_ca_attributes */\r
+\r
+                       vstat_print_ca_attr(vstat_ca_attr, fullPrint);\r
+\r
+\r
+                       /* Free the memory */\r
+                       cl_free(vstat_ca_attr);\r
+                       vstat_ca_attr = NULL;\r
+                       /* Close the current open CA */\r
+                       ib_status = ib_close_ca(h_ca, NULL);\r
+                       if(ib_status != IB_SUCCESS)\r
+                       {\r
+                               printf("ib_close_ca failed status = %d", ib_status);\r
+                               ret_status = ib_status;\r
+                       }\r
+                       h_ca = NULL;\r
+\r
+               }\r
+\r
+Cleanup2:\r
+               if(h_ca != NULL)\r
+               {\r
+                       ib_status = ib_close_ca(h_ca, NULL);\r
+                       if(ib_status != IB_SUCCESS)\r
+                       {\r
+                               printf("ib_close_ca failed status = %d", ib_status);\r
+                       }\r
+               }\r
+\r
+Cleanup1:\r
+               ib_status = ib_close_al(h_al);\r
+\r
+               if(ib_status != IB_SUCCESS)\r
+               {\r
+                       printf("ib_close_al failed status = %d", ib_status);\r
+               }\r
+\r
+               break;\r
+\r
+       } //End of while(1)\r
+\r
+       \r
+       return ret_status;\r
+}\r
+\r
+\r
+\r
+int32_t __cdecl\r
+main(\r
+       int32_t argc,\r
+       char* argv[])\r
+{\r
+       ib_api_status_t ib_status;\r
+       BOOLEAN fullPrint = FALSE;\r
+       if(argc>1){\r
+               int i = 2;\r
+               while(i<=argc){\r
+                       if(!_stricmp(argv[i-1], "-v")){\r
+                               fullPrint = TRUE;\r
+                               i+=1;\r
+                       }else{\r
+                               i+=2;\r
+                       }\r
+               }\r
+       }\r
+       ib_status = vstat_ca_attr(FALSE, fullPrint);\r
+       return 0;\r
+}\r
+\r
diff --git a/trunk/tools/vstat/user/vstat_querycaattr.c b/trunk/tools/vstat/user/vstat_querycaattr.c
deleted file mode 100644 (file)
index ff118cd..0000000
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * 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$
- */
-
-#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;
-}
-