From 5a0c365529af93ab7b59e06954ed30c904720b0b Mon Sep 17 00:00:00 2001 From: ftillier Date: Mon, 19 Sep 2005 18:35:03 +0000 Subject: [PATCH] [VSTAT] Code cleanup to remove dependency on ALTS and removing unneeded files. 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 | 47 +- trunk/tools/vstat/user/vstat_main.c | 520 +++++++++++++++------ trunk/tools/vstat/user/vstat_querycaattr.c | 420 ----------------- 3 files changed, 407 insertions(+), 580 deletions(-) delete mode 100644 trunk/tools/vstat/user/vstat_querycaattr.c diff --git a/trunk/tools/vstat/user/SOURCES b/trunk/tools/vstat/user/SOURCES index 4e2b4e5e..20475d69 100644 --- a/trunk/tools/vstat/user/SOURCES +++ b/trunk/tools/vstat/user/SOURCES @@ -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 +TARGETPATH=..\..\..\bin\user\obj$(BUILD_ALT_DIR) +TARGETTYPE=PROGRAM +UMTYPE=console +USE_CRTDLL=1 + +SOURCES=vstat.rc \ + vstat_main.c + +INCLUDES=..\..\..\inc;..\..\..\inc\user; + +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/vstat_main.c b/trunk/tools/vstat/user/vstat_main.c index 1ad8f135..93eb64a0 100644 --- a/trunk/tools/vstat/user/vstat_main.c +++ b/trunk/tools/vstat/user/vstat_main.c @@ -1,136 +1,384 @@ -/* - * 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 -#include "..\..\..\tests\alts\alts_debug.h" -#include "..\..\..\tests\alts\alts_common.h" -#include "..\..\..\tests\alts\alts_misc.c" -#ifndef WIN32 -#include -#endif - -//#include -//#include - - -//#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; -} - +/* + * 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 "stdio.h" +#include "string.h" +#include "stdlib.h" + + +#include +#include +#ifndef WIN32 +#include +#endif + + + + +/******************************************************************* +*******************************************************************/ + + +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 = TBD (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; inum_ports; i++){ + printPortInfo(ca_attr->p_port_attr+i, fullPrint); + } +} +/* Internal Functions */ + + + +ib_api_status_t +vstat_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; + ib_ca_attr_t *vstat_ca_attr; + uintn_t i; + ib_ca_handle_t h_ca = NULL; + uint32_t bsize; + ib_port_attr_mod_t port_attr_mod; + + + + + while(1) + { + /* + * Open the AL instance + */ + ib_status = ib_open_al(&h_al); + if(ib_status != IB_SUCCESS) + { + printf("ib_open_al failed status = %d\n", ib_status); + ret_status = ib_status; + break; + } + //xxxx + //printf("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) + { + printf("ib_get_ca_guids1 failed status = %d\n", (uint32_t)ib_status); + ret_status = ib_status; + goto Cleanup1; + } + + + + /* + * If no CA's Present then return + */ + + if(guid_count == 0) + goto Cleanup1; + + + ca_guid_array = (ib_net64_t*)cl_malloc(sizeof(ib_net64_t) * guid_count); + CL_ASSERT(ca_guid_array); + + ib_status = ib_get_ca_guids(h_al, ca_guid_array, &guid_count); + if(ib_status != IB_SUCCESS) + { + printf("ib_get_ca_guids2 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++) + { + + /* Open the CA */ + ib_status = ib_open_ca(h_al, + ca_guid_array[i], + NULL, + NULL, //ca_context + &h_ca); + + if(ib_status != IB_SUCCESS) + { + printf("ib_open_ca failed with status = %d\n", ib_status); + ret_status = ib_status; + goto Cleanup1; + } + + //xxx + //printf("ib_open_ca passed i=%d\n",i); + //xxx + + + /* Query the CA */ + bsize = 0; + ib_status = ib_query_ca(h_ca, NULL, &bsize); + if(ib_status != IB_INSUFFICIENT_MEMORY) + { + printf("ib_query_ca failed with status = %d\n", ib_status); + ret_status = ib_status; + goto Cleanup2; + } + CL_ASSERT(bsize); + //xxxx + //printf("ib_query_ca PASSED bsize = 0x%x.\n",bsize); + //xxx + /* Allocate the memory needed for query_ca */ + + vstat_ca_attr = (ib_ca_attr_t *)cl_zalloc(bsize); + CL_ASSERT(vstat_ca_attr); + + ib_status = ib_query_ca(h_ca, vstat_ca_attr, &bsize); + if(ib_status != IB_SUCCESS) + { + printf("ib_query_ca failed with status = %d\n", ib_status); + ret_status = ib_status; + goto Cleanup2; + } + + /* Print_ca_attributes */ + + vstat_print_ca_attr(vstat_ca_attr, fullPrint); + + + /* Free the memory */ + cl_free(vstat_ca_attr); + vstat_ca_attr = NULL; + /* Close the current open CA */ + ib_status = ib_close_ca(h_ca, NULL); + if(ib_status != IB_SUCCESS) + { + printf("ib_close_ca failed status = %d", ib_status); + ret_status = ib_status; + } + h_ca = NULL; + + } + +Cleanup2: + if(h_ca != NULL) + { + ib_status = ib_close_ca(h_ca, NULL); + if(ib_status != IB_SUCCESS) + { + printf("ib_close_ca failed status = %d", ib_status); + } + } + +Cleanup1: + ib_status = ib_close_al(h_al); + + if(ib_status != IB_SUCCESS) + { + printf("ib_close_al failed status = %d", ib_status); + } + + break; + + } //End of while(1) + + + return ret_status; +} + + + +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 = vstat_ca_attr(FALSE, fullPrint); + return 0; +} + diff --git a/trunk/tools/vstat/user/vstat_querycaattr.c b/trunk/tools/vstat/user/vstat_querycaattr.c deleted file mode 100644 index ff118cd5..00000000 --- a/trunk/tools/vstat/user/vstat_querycaattr.c +++ /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 -#include -#include -#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; inum_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; -} - -- 2.41.0