[IBDIAGS] support latest ibdiags mods for ibdiag_common.[hc]. x86 main declaration...
authorstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 27 Jan 2009 18:49:40 +0000 (18:49 +0000)
committerstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 27 Jan 2009 18:49:40 +0000 (18:49 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1894 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

23 files changed:
tools/infiniband_diags/include/grouping.h
tools/infiniband_diags/include/ibdiag_common.h
tools/infiniband_diags/src/dirs
tools/infiniband_diags/src/grouping.c
tools/infiniband_diags/src/ibaddr.c
tools/infiniband_diags/src/ibaddr/SOURCES
tools/infiniband_diags/src/ibdiag_common.c
tools/infiniband_diags/src/ibnetdiscover.c
tools/infiniband_diags/src/ibnetdiscover/SOURCES
tools/infiniband_diags/src/ibping.c
tools/infiniband_diags/src/ibping/SOURCES
tools/infiniband_diags/src/ibstat.c
tools/infiniband_diags/src/ibstat/SOURCES
tools/infiniband_diags/src/perfquery.c
tools/infiniband_diags/src/perfquery/SOURCES
tools/infiniband_diags/src/saquery.c
tools/infiniband_diags/src/saquery/SOURCES
tools/infiniband_diags/src/sminfo.c
tools/infiniband_diags/src/sminfo/SOURCES
tools/infiniband_diags/src/smpdump.c
tools/infiniband_diags/src/smpquery.c
tools/infiniband_diags/src/vendstat.c
tools/infiniband_diags/src/vendstat/SOURCES

index 1044f3a..22b2e5f 100644 (file)
@@ -91,6 +91,7 @@ struct AllChassisList {
 #define VTR_DEVID_ISR2012              0x5a39\r
 #define VTR_DEVID_SFB2004              0x5a40\r
 #define VTR_DEVID_ISR2004              0x5a41\r
+#define VTR_DEVID_SRB2004              0x5a42\r
 \r
 enum ChassisType { UNRESOLVED_CT, ISR9288_CT, ISR9096_CT, ISR2012_CT, ISR2004_CT };\r
 enum ChassisSlot { UNRESOLVED_CS, LINE_CS, SPINE_CS, SRBD_CS };\r
index 1ed5758..9a0645d 100644 (file)
 #define _IBDIAG_COMMON_H_\r
 \r
 #include <stdio.h>\r
-\r
-#if !defined( __cplusplus )\r
-#define inline __inline\r
-#endif\r
+#include <ibdiag_common_osd.h>\r
 \r
 extern char *argv0;\r
 extern int   ibdebug;\r
@@ -48,17 +45,16 @@ extern int   ibdebug;
 /*                External interface                      */\r
 /*========================================================*/\r
 \r
-void  iberror(const char *fn, char *msg, ...);\r
-\r
 #undef DEBUG\r
 #define        DEBUG   if (ibdebug || verbose) IBWARN\r
 #define        VERBOSE if (ibdebug || verbose > 1) IBWARN\r
 #define IBERROR(fmt, ...) iberror(__FUNCTION__, fmt, ## __VA_ARGS__)\r
+void  iberror(const char *fn, char *msg, ...);\r
 \r
 #include <ibdiag_version.h>\r
 \r
-static inline const char* get_build_version(void) \r
-{ \r
+static inline const char* get_build_version(void)\r
+{\r
        return "BUILD VERSION: " IBDIAG_VERSION " Build date: " __DATE__ " " __TIME__ ;\r
 }\r
 \r
index 23d2382..afaa359 100644 (file)
@@ -1,13 +1,12 @@
-DIRS =                 \\r
-       sminfo          \\r
-       ibstat          \\r
-       perfquery       \\r
-       vendstat        \\r
-       ibaddr\r
+DIRS = \\r
+       sminfo \\r
+       ibstat \\r
+       perfquery \\r
+       ibaddr \\r
+       ibnetdiscover \\r
+       vendstat \r
        \r
        \r
        \r
        \r
-       \r
-       \r
-               
\ No newline at end of file
+               \r
index 93b6f09..667c5c2 100644 (file)
 \r
 #include <stdlib.h>\r
 \r
-#if defined(_WIN32) || defined(_WIN64)\r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include "..\ibdiag_common.c"\r
-#else\r
+#if !defined(_WIN32)\r
 #include <stdint.h>\r
 #include <inttypes.h>\r
 #endif\r
 \r
-#include <infiniband/common.h>\r
 #include <infiniband/mad.h>\r
 \r
 #include "ibnetdiscover.h"\r
@@ -249,7 +244,8 @@ static int is_spine(Node *node)
 static int is_line_24(Node *node)\r
 {\r
        return (node->devid == VTR_DEVID_SLB24 ||\r
-               node->devid == VTR_DEVID_SLB24_DDR);\r
+               node->devid == VTR_DEVID_SLB24_DDR ||\r
+               node->devid == VTR_DEVID_SRB2004);\r
 }\r
 \r
 static int is_line_8(Node *node)\r
@@ -273,19 +269,19 @@ int is_chassis_switch(Node *node)
 }\r
 \r
 /* these structs help find Line (Anafa) slot number while using spine portnum */\r
-int line_slot_2_sfb4[25]        = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };\r
-int anafa_line_slot_2_sfb4[25]  = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };\r
-int line_slot_2_sfb12[25]       = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };\r
-int anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };\r
+uint8_t line_slot_2_sfb4[25]        = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };\r
+uint8_t anafa_line_slot_2_sfb4[25]  = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };\r
+uint8_t line_slot_2_sfb12[25]       = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };\r
+uint8_t anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };\r
 \r
 /* IPR FCR modules connectivity while using sFB4 port as reference */\r
-int ipr_slot_2_sfb4_port[25]    = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };\r
+uint8_t ipr_slot_2_sfb4_port[25]    = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };\r
 \r
 /* these structs help find Spine (Anafa) slot number while using spine portnum */\r
-int spine12_slot_2_slb[25]      = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
-int anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
-int spine4_slot_2_slb[25]       = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
-int anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
+uint8_t spine12_slot_2_slb[25]      = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
+uint8_t anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
+uint8_t spine4_slot_2_slb[25]       = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
+uint8_t anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };\r
 /*     reference                     { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */\r
 \r
 static void get_sfb_slot(Node *node, Port *lineport)\r
@@ -317,7 +313,7 @@ static void get_sfb_slot(Node *node, Port *lineport)
 static void get_router_slot(Node *node, Port *spineport)\r
 {\r
        ChassisRecord *ch = node->chrecord;\r
-       int guessnum = 0;\r
+       uint64_t guessnum = 0;\r
 \r
        if (!ch) {\r
                if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))\r
@@ -468,7 +464,7 @@ static void insert_line_router(Node *node, ChassisList *chassislist)
                return;         /* already filled slot */\r
 \r
        chassislist->linenode[i] = node;\r
-       node->chrecord->chassisnum = chassislist->chassisnum;\r
+       node->chrecord->chassisnum = (uint8_t)chassislist->chassisnum;\r
 }\r
 \r
 static void insert_spine(Node *node, ChassisList *chassislist)\r
@@ -479,7 +475,7 @@ static void insert_spine(Node *node, ChassisList *chassislist)
                return;         /* already filled slot */\r
 \r
        chassislist->spinenode[i] = node;\r
-       node->chrecord->chassisnum = chassislist->chassisnum;\r
+       node->chrecord->chassisnum = (uint8_t)chassislist->chassisnum;\r
 }\r
 \r
 static void pass_on_lines_catch_spines(ChassisList *chassislist)\r
@@ -778,7 +774,7 @@ ChassisList *group_nodes()
                                        if (!node->chrecord) {\r
                                                if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))\r
                                                        IBPANIC("out of mem");\r
-                                               node->chrecord->chassisnum = chassis->chassisnum;\r
+                                               node->chrecord->chassisnum = (uint8_t)chassis->chassisnum;\r
                                        }\r
                                }\r
                        }\r
index 65e0308..3b72ae4 100644 (file)
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
-#if defined(_WIN32) \r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include <ws2tcpip.h> \r
-#include "..\..\..\..\etc\user\getopt.c"\r
-#else\r
-#include <unistd.h>\r
-#include <stdarg.h>\r
-#include <getopt.h>\r
-#include <arpa/inet.h>\r
-#endif\r
 \r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
@@ -116,7 +105,7 @@ usage(void)
        exit(-1);\r
 }\r
 \r
-int __cdecl\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};\r
@@ -130,8 +119,8 @@ main(int argc, char **argv)
        char *ca = 0;\r
        int ca_port = 0;\r
 \r
-       static char str_opts[] = "C:P:t:s:dDGglLVhu";\r
-       static struct option long_opts[] = {\r
+       static char const str_opts[] = "C:P:t:s:dDGglLVhu";\r
+       static const struct option long_opts[] = {\r
                { "C", 1, 0, 'C'},\r
                { "P", 1, 0, 'P'},\r
                { "debug", 0, 0, 'd'},\r
index cbaf51c..948c310 100644 (file)
@@ -10,7 +10,7 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\ibaddr.c ..\ibdiag_common.c\r
+SOURCES = ..\ibaddr.c ..\ibdiag_common.c ..\ibdiag_osd.c\r
        \r
 INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
index a78e4e1..7c6bdae 100644 (file)
 #include <stdio.h>\r
 #include <stdlib.h>\r
 \r
-#if defined(_WIN32) || defined(_WIN64)\r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include <ws2tcpip.h>\r
-#if !defined(getpid)\r
-    #define getpid GetCurrentProcessId\r
-#endif\r
-#else\r
-#define _GNU_SOURCE\r
-#include <errno.h>\r
-#include <string.h>\r
-#include <stdarg.h>\r
-#include <sys/types.h>\r
-#include <unistd.h>\r
-#include <ctype.h>\r
-#include <config.h>\r
-#endif\r
-\r
 #include "ibdiag_common.h"\r
 \r
 int ibdebug;\r
index faf89ec..158e2f8 100644 (file)
 #define _GNU_SOURCE\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
+#if defined(_WIN32)\r
+#include <time.h>\r
+#include <string.h>\r
+#include <getopt.h>\r
+#else\r
 #include <unistd.h>\r
 #include <stdarg.h>\r
 #include <time.h>\r
@@ -46,8 +51,8 @@
 #include <getopt.h>\r
 #include <errno.h>\r
 #include <inttypes.h>\r
+#endif\r
 \r
-#include <infiniband/common.h>\r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
 #include <infiniband/complib/cl_nodenamemap.h>\r
@@ -218,7 +223,7 @@ extend_dpath(ib_dr_path_t *path, int nextport)
        ++path->cnt;\r
        if (path->cnt > maxhops_discovered)\r
                maxhops_discovered = path->cnt;\r
-       path->p[path->cnt] = nextport;\r
+       path->p[path->cnt] = (uint8_t)nextport;\r
        return path->cnt;\r
 }\r
 \r
@@ -523,7 +528,7 @@ out_chassis(int chassisnum)
        uint64_t guid;\r
 \r
        fprintf(f, "\nChassis %d", chassisnum);\r
-       guid = get_chassis_guid(chassisnum);\r
+       guid = get_chassis_guid((uint8_t)chassisnum);\r
        if (guid)\r
                fprintf(f, " (guid 0x%" PRIx64 ")", guid);\r
        fprintf(f, "\n");\r
@@ -930,7 +935,7 @@ usage(void)
        exit(-1);\r
 }\r
 \r
-int\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[2] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS};\r
@@ -960,7 +965,7 @@ main(int argc, char **argv)
                { "Version", 0, 0, 'V'},\r
                { "help", 0, 0, 'h'},\r
                { "usage", 0, 0, 'u'},\r
-               { }\r
+               { NULL }\r
        };\r
 \r
        f = stdout;\r
index 849db8e..78c765f 100644 (file)
@@ -10,9 +10,14 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\ibnetdiscover.c ..\ibdiag_common.c\r
+SOURCES = ibnetdiscover.rc     \\r
+       ..\ibnetdiscover.c              \\r
+       ..\grouping.c                   \\r
+       ..\ibdiag_common.c              \\r
+       ..\cl_nodenamemap.c             \\r
+       ..\ibdiag_osd.c\r
        \r
-INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
+INCLUDES = ..;..\..\include;..\..\include\Infiniband;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
 TARGETLIBS =   \\r
        $(SDK_LIB_PATH)\kernel32.lib    \\r
@@ -21,9 +26,11 @@ TARGETLIBS = \
        $(SDK_LIB_PATH)\ole32.lib       \\r
        $(SDK_LIB_PATH)\ws2_32.lib      \\r
 !if $(FREEBUILD)\r
+       $(TARGETPATH)\*\complib.lib     \\r
        $(TARGETPATH)\*\libibmad.lib    \\r
        $(TARGETPATH)\*\libibumad.lib   \r
 !else\r
+       $(TARGETPATH)\*\complibd.lib    \\r
        $(TARGETPATH)\*\libibmadd.lib   \\r
        $(TARGETPATH)\*\libibumadd.lib  \r
 !endif\r
index 767436b..2ade15a 100644 (file)
 #include <stdio.h>\r
 #include <stdlib.h>\r
 \r
-#if defined(_WIN32) \r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include <ws2tcpip.h> \r
-#include "..\..\..\..\etc\user\getopt.c"\r
-#else\r
-#include <unistd.h>\r
-#include <stdarg.h>\r
-#include <time.h>\r
-#include <string.h>\r
-#include <signal.h>\r
-#include <getopt.h>\r
-#endif\r
-\r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
 \r
@@ -137,7 +123,7 @@ ibping(ib_portid_t *portid, int quiet)
        memset(&call.rmpp, 0, sizeof call.rmpp);\r
 \r
        if (!ib_vendor_call(data, portid, &call))\r
-               return ~0llu;\r
+               return ~0ULL;\r
 \r
        rtt = getcurrenttime() - start;\r
 \r
@@ -146,7 +132,7 @@ ibping(ib_portid_t *portid, int quiet)
 \r
        if (!quiet)\r
                printf("Pong from %s (%s): time %" PRIu64 ".%03" PRIu64 " ms\n",\r
-                       data, portid2str(portid), rtt/1000, rtt%1000);\r
+                       data, portid2str(portid), rtt/1000ULL, rtt%1000ULL);\r
 \r
        return rtt;\r
 }\r
@@ -192,7 +178,7 @@ report(int sig)
        exit(0);\r
 }\r
 \r
-int\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};\r
@@ -201,14 +187,14 @@ main(int argc, char **argv)
        int timeout = 0, udebug = 0, server = 0, flood = 0;\r
        int oui = IB_OPENIB_OUI;\r
        uint64_t rtt;\r
-       uint count = ~0;\r
+       unsigned int count = ~0;\r
        extern int ibdebug;\r
        char *err;\r
        char *ca = 0;\r
        int ca_port = 0;\r
 \r
-       static char str_opts[] = "C:P:t:s:c:o:devGfSVhu";\r
-       static struct option long_opts[] = {\r
+       static char const str_opts[] = "C:P:t:s:c:o:devGfSVhu";\r
+       static const struct option long_opts[] = {\r
                { "C", 1, 0, 'C'},\r
                { "P", 1, 0, 'P'},\r
                { "debug", 0, 0, 'd'},\r
index 0d9d896..2ae919c 100644 (file)
@@ -10,7 +10,7 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\ibping.c ..\ibdiag_common.c\r
+SOURCES = ..\ibping.c ..\ibdiag_common.c ..\ibdiag_osd.c\r
        \r
 INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
index 8825277..5c48c5e 100644 (file)
 #include <stdio.h>\r
 #include <stdlib.h>\r
 \r
-#if !defined(_WIN32) \r
-#define _GNU_SOURCE\r
-\r
-#if HAVE_CONFIG_H\r
-#  include <config.h>\r
-#endif /* HAVE_CONFIG_H */\r
-\r
-#include <inttypes.h>\r
-#include <string.h>\r
-#include <errno.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <unistd.h>\r
-#include <stdarg.h>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <fcntl.h>\r
-#include <sys/ioctl.h>\r
-#include <unistd.h>\r
-#include <string.h>\r
-#include <getopt.h>\r
-#include <endian.h>\r
-#include <byteswap.h>\r
-#include <sys/poll.h>\r
-#include <syslog.h>\r
-#include <netinet/in.h>\r
-#else\r
-#include "..\..\..\..\etc\user\getopt.c"\r
-#endif\r
-\r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
 #include <ibdiag_common.h>\r
@@ -203,16 +173,16 @@ usage(void)
        exit(-1);\r
 }\r
 \r
-int __cdecl\r
+int _CDECL\r
 main(int argc, char *argv[])\r
 {\r
-       char names[20][UMAD_CA_NAME_LEN];\r
+       char names[UMAD_MAX_DEVICES][UMAD_CA_NAME_LEN];\r
        int dev_port = -1;\r
        int list_only = 0, short_format = 0, list_ports = 0;\r
        int n, i;\r
 \r
-       static char str_opts[] = "dlspVhu";\r
-       static struct option long_opts[] = {\r
+       static char const str_opts[] = "dlspVhu";\r
+       static const struct option long_opts[] = {\r
                { "debug", 0, 0, 'd'},\r
                { "list_of_cas", 0, 0, 'l'},\r
                { "short", 0, 0, 's'},\r
@@ -259,7 +229,7 @@ main(int argc, char *argv[])
        if (umad_init() < 0)\r
                IBPANIC("can't init UMAD library");\r
 \r
-       if ((n = umad_get_cas_names((void *)names, UMAD_CA_NAME_LEN)) < 0)\r
+       if ((n = umad_get_cas_names(names, UMAD_MAX_DEVICES)) < 0)\r
                IBPANIC("can't list IB device names");\r
 \r
        if (argc) {\r
index 4fc625f..9bf3fd5 100644 (file)
@@ -10,7 +10,7 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\ibstat.c ..\ibdiag_common.c\r
+SOURCES = ..\ibstat.c ..\ibdiag_common.c ..\ibdiag_osd.c\r
        \r
 INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
index 641e03a..c441151 100644 (file)
  *\r
  */\r
 \r
-#if defined(_WIN32) \r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include "..\..\..\..\etc\user\getopt.c"\r
-#else\r
-\r
 #if HAVE_CONFIG_H\r
 #  include <config.h>\r
 #endif /* HAVE_CONFIG_H */\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
-#include <unistd.h>\r
-#include <stdarg.h>\r
-#include <getopt.h>\r
-#include <netinet/in.h>\r
-#endif\r
 \r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
@@ -74,6 +63,7 @@ struct perf_count {
        uint32_t rcvdata;\r
        uint32_t xmtpkts;\r
        uint32_t rcvpkts;\r
+       uint32_t xmtwait;\r
 };\r
 \r
 struct perf_count_ext {\r
@@ -182,40 +172,42 @@ static void aggregate_perfcounters(void)
 \r
        mad_decode_field(pc, IB_PC_PORT_SELECT_F, &val);\r
        perf_count.portselect = val;\r
-        mad_decode_field(pc, IB_PC_COUNTER_SELECT_F, &val);\r
+       mad_decode_field(pc, IB_PC_COUNTER_SELECT_F, &val);\r
        perf_count.counterselect = val;\r
-        mad_decode_field(pc, IB_PC_ERR_SYM_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_SYM_F, &val);\r
        aggregate_16bit(&perf_count.symbolerrors, val);\r
-        mad_decode_field(pc, IB_PC_LINK_RECOVERS_F, &val);\r
+       mad_decode_field(pc, IB_PC_LINK_RECOVERS_F, &val);\r
        aggregate_8bit(&perf_count.linkrecovers, val);\r
-        mad_decode_field(pc, IB_PC_LINK_DOWNED_F, &val);\r
+       mad_decode_field(pc, IB_PC_LINK_DOWNED_F, &val);\r
        aggregate_8bit(&perf_count.linkdowned, val);\r
-        mad_decode_field(pc, IB_PC_ERR_RCV_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_RCV_F, &val);\r
        aggregate_16bit(&perf_count.rcverrors, val);\r
-        mad_decode_field(pc, IB_PC_ERR_PHYSRCV_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_PHYSRCV_F, &val);\r
        aggregate_16bit(&perf_count.rcvremotephyerrors, val);\r
-        mad_decode_field(pc, IB_PC_ERR_SWITCH_REL_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_SWITCH_REL_F, &val);\r
        aggregate_16bit(&perf_count.rcvswrelayerrors, val);\r
-        mad_decode_field(pc, IB_PC_XMT_DISCARDS_F, &val);\r
+       mad_decode_field(pc, IB_PC_XMT_DISCARDS_F, &val);\r
        aggregate_16bit(&perf_count.xmtdiscards, val);\r
-        mad_decode_field(pc, IB_PC_ERR_XMTCONSTR_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_XMTCONSTR_F, &val);\r
        aggregate_8bit(&perf_count.xmtconstrainterrors, val);\r
-        mad_decode_field(pc, IB_PC_ERR_RCVCONSTR_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_RCVCONSTR_F, &val);\r
        aggregate_8bit(&perf_count.rcvconstrainterrors, val);\r
-        mad_decode_field(pc, IB_PC_ERR_LOCALINTEG_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_LOCALINTEG_F, &val);\r
        aggregate_4bit(&perf_count.linkintegrityerrors, val);\r
-        mad_decode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &val);\r
+       mad_decode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &val);\r
        aggregate_4bit(&perf_count.excbufoverrunerrors, val);\r
-        mad_decode_field(pc, IB_PC_VL15_DROPPED_F, &val);\r
+       mad_decode_field(pc, IB_PC_VL15_DROPPED_F, &val);\r
        aggregate_16bit(&perf_count.vl15dropped, val);\r
-        mad_decode_field(pc, IB_PC_XMT_BYTES_F, &val);\r
+       mad_decode_field(pc, IB_PC_XMT_BYTES_F, &val);\r
        aggregate_32bit(&perf_count.xmtdata, val);\r
-        mad_decode_field(pc, IB_PC_RCV_BYTES_F, &val);\r
+       mad_decode_field(pc, IB_PC_RCV_BYTES_F, &val);\r
        aggregate_32bit(&perf_count.rcvdata, val);\r
-        mad_decode_field(pc, IB_PC_XMT_PKTS_F, &val);\r
+       mad_decode_field(pc, IB_PC_XMT_PKTS_F, &val);\r
        aggregate_32bit(&perf_count.xmtpkts, val);\r
-        mad_decode_field(pc, IB_PC_RCV_PKTS_F, &val);\r
+       mad_decode_field(pc, IB_PC_RCV_PKTS_F, &val);\r
        aggregate_32bit(&perf_count.rcvpkts, val);\r
+       mad_decode_field(pc, IB_PC_XMT_WAIT_F, &val);\r
+       aggregate_32bit(&perf_count.xmtwait, val);\r
 }\r
 \r
 static void output_aggregate_perfcounters(ib_portid_t *portid)\r
@@ -242,6 +234,7 @@ static void output_aggregate_perfcounters(ib_portid_t *portid)
        mad_encode_field(pc, IB_PC_RCV_BYTES_F, &perf_count.rcvdata);\r
        mad_encode_field(pc, IB_PC_XMT_PKTS_F, &perf_count.xmtpkts);\r
        mad_encode_field(pc, IB_PC_RCV_PKTS_F, &perf_count.rcvpkts);\r
+       mad_encode_field(pc, IB_PC_XMT_WAIT_F, &perf_count.xmtwait);\r
 \r
        mad_dump_perfcounters(buf, sizeof buf, pc, sizeof pc);\r
 \r
@@ -280,8 +273,8 @@ static void output_aggregate_perfcounters_ext(ib_portid_t *portid)
        char buf[1024];\r
        uint32_t val = ALL_PORTS;\r
 \r
-        /* set port_select to 255 to emulate AllPortSelect */\r
-        mad_encode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val);\r
+       /* set port_select to 255 to emulate AllPortSelect */\r
+       mad_encode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val);\r
        mad_encode_field(pc, IB_PC_EXT_COUNTER_SELECT_F, &perf_count_ext.counterselect);\r
        mad_encode_field(pc, IB_PC_EXT_XMT_BYTES_F, &perf_count_ext.portxmitdata);\r
        mad_encode_field(pc, IB_PC_EXT_RCV_BYTES_F, &perf_count_ext.portrcvdata);\r
@@ -305,6 +298,11 @@ static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, ib_p
        if (extended != 1) {\r
                if (!port_performance_query(pc, portid, port, timeout))\r
                        IBERROR("perfquery");\r
+               if (!(cap_mask & 0x1000)) {\r
+                       /* if PortCounters:PortXmitWait not suppported clear this counter */\r
+                       perf_count.xmtwait = 0;\r
+                       mad_encode_field(pc, IB_PC_XMT_WAIT_F, &perf_count.xmtwait);\r
+               }\r
                if (aggregate)\r
                        aggregate_perfcounters();\r
                else\r
@@ -336,7 +334,7 @@ static void reset_counters(int extended, int timeout, int mask, ib_portid_t *por
        }\r
 }\r
 \r
-int __cdecl\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[4] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS, IB_PERFORMANCE_CLASS};\r
@@ -361,8 +359,8 @@ main(int argc, char **argv)
        int enhancedport0;\r
        int i;\r
 \r
-       static char str_opts[] = "C:P:s:t:dGealrRVhu";\r
-       static struct option long_opts[] = {\r
+       static char const str_opts[] = "C:P:s:t:dGealrRVhu";\r
+       static const struct option long_opts[] = {\r
                { "C", 1, 0, 'C'},\r
                { "P", 1, 0, 'P'},\r
                { "debug", 0, 0, 'd'},\r
@@ -457,7 +455,7 @@ main(int argc, char **argv)
        if (!perf_classportinfo_query(pc, &portid, port, timeout))\r
                IBERROR("classportinfo query");\r
        /* ClassPortInfo should be supported as part of libibmad */\r
-       memcpy(&cap_mask, pc+2, sizeof(cap_mask));      /* CapabilityMask */\r
+       memcpy(&cap_mask, pc + 2, sizeof(cap_mask));    /* CapabilityMask */\r
        cap_mask = ntohs(cap_mask);\r
        if (!(cap_mask & 0x100)) { /* bit 8 is AllPortSelect */\r
                if (!all_ports && port == ALL_PORTS)\r
@@ -507,6 +505,9 @@ main(int argc, char **argv)
 \r
 do_reset:\r
 \r
+       if (argc <= 2 && !extended && (cap_mask & 0x1000))\r
+               mask |= (1<<16); /* reset portxmitwait */\r
+\r
        if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {\r
                for (i = start_port; i <= num_ports; i++)\r
                        reset_counters(extended, timeout, mask, &portid, i);\r
index 30ebc33..65c137f 100644 (file)
@@ -10,7 +10,7 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\perfquery.c ..\ibdiag_common.c\r
+SOURCES = ..\perfquery.c ..\ibdiag_common.c ..\ibdiag_osd.c\r
        \r
 INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
index fa895bb..d4fb416 100644 (file)
  *\r
  */\r
 \r
-#if defined(_WIN32) || defined(_WIN64)\r
-\r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include <ws2tcpip.h> \r
-#include <complib/cl_debug.h>\r
-#include <opensm/osm_log.h>\r
-#include <vendor/osm_vendor_api.h>\r
-#include <vendor/osm_vendor_sa_api.h>\r
-#include <opensm/osm_mad_pool.h>\r
-\r
-#else\r
-\r
+#if !defined(_WIN32)\r
 #include <unistd.h>\r
 #include <stdio.h>\r
 #include <sys/types.h>\r
 #include <arpa/inet.h>\r
 #include <assert.h>\r
 #include <ctype.h>\r
+#else\r
+#include <stdio.h>\r
+#endif\r
 #include <string.h>\r
 \r
 #define _GNU_SOURCE\r
 #include <getopt.h>\r
+\r
+#include <infiniband/mad.h>\r
 #include <infiniband/opensm/osm_log.h>\r
 #include <infiniband/vendor/osm_vendor_api.h>\r
 #include <infiniband/vendor/osm_vendor_sa_api.h>\r
 #include <infiniband/complib/cl_debug.h>\r
 #include <infiniband/complib/cl_nodenamemap.h>\r
 \r
-#endif\r
-\r
 #include "ibdiag_common.h"\r
 \r
 struct query_cmd {\r
        const char *name, *alias;\r
        ib_net16_t query_type;\r
        const char *usage;\r
-       int (*handler)(const struct query_cmd *q, osm_bind_handle_t bind_handle,\r
-                      int argc, char *argv[]);\r
+       int (*handler) (const struct query_cmd * q, osm_bind_handle_t h,\r
+                       int argc, char *argv[]);\r
 };\r
 \r
 char *argv0 = "saquery";\r
@@ -91,14 +82,14 @@ static ib_net64_t smkey = OSM_DEFAULT_SA_KEY;
  */\r
 #define MAX_PORTS (8)\r
 #define DEFAULT_SA_TIMEOUT_MS (1000)\r
-osmv_query_res_t   result;\r
-osm_log_t          log_osm;\r
-osm_mad_pool_t     mad_pool;\r
-osm_vendor_t      *vendor = NULL;\r
-int                osm_debug = 0;\r
-uint32_t           sa_timeout_ms = DEFAULT_SA_TIMEOUT_MS;\r
-char             *sa_hca_name = NULL;\r
-uint32_t           sa_port_num = 0;\r
+osmv_query_res_t result;\r
+osm_log_t log_osm;\r
+osm_mad_pool_t mad_pool;\r
+osm_vendor_t *vendor = NULL;\r
+int osm_debug = 0;\r
+uint32_t sa_timeout_ms = DEFAULT_SA_TIMEOUT_MS;\r
+char *sa_hca_name = NULL;\r
+uint32_t sa_port_num = 0;\r
 \r
 enum {\r
        ALL,\r
@@ -110,44 +101,53 @@ enum {
        NAME_OF_GUID,\r
 } node_print_desc = ALL;\r
 \r
-char              *requested_name = NULL;\r
-ib_net16_t         requested_lid = 0;\r
-int                requested_lid_flag = 0;\r
-ib_net64_t         requested_guid = 0;\r
-int                requested_guid_flag = 0;\r
+char *requested_name = NULL;\r
+ib_net16_t requested_lid = 0;\r
+int requested_lid_flag = 0;\r
+ib_net64_t requested_guid = 0;\r
+int requested_guid_flag = 0;\r
+\r
+static void format_buf(char *in, char *out, unsigned size)\r
+{\r
+       unsigned i;\r
+\r
+       for (i = 0; i < size - 3 && *in; i++) {\r
+               *out++ = *in;\r
+               if (*in++ == '\n' && *in) {\r
+                       *out++ = '\t';\r
+                       *out++ = '\t';\r
+               }\r
+       }\r
+       *out = '\0';\r
+}\r
 \r
 /**\r
  * Call back for the various record requests.\r
  */\r
-static void\r
-query_res_cb(osmv_query_res_t *res)\r
+static void query_res_cb(osmv_query_res_t * res)\r
 {\r
        result = *res;\r
 }\r
 \r
-static void\r
-print_node_desc(ib_node_record_t *node_record)\r
+static void print_node_desc(ib_node_record_t * node_record)\r
 {\r
        ib_node_info_t *p_ni = &(node_record->node_info);\r
        ib_node_desc_t *p_nd = &(node_record->node_desc);\r
 \r
-       if (p_ni->node_type == IB_NODE_TYPE_CA)\r
-       {\r
-               printf("%6d  \"%s\"\n",\r
-                      cl_ntoh16(node_record->lid),\r
+       if (p_ni->node_type == IB_NODE_TYPE_CA) {\r
+               printf("%6d  \"%s\"\n", cl_ntoh16(node_record->lid),\r
                       clean_nodedesc((char *)p_nd->description));\r
        }\r
 }\r
 \r
-static void\r
-print_node_record(ib_node_record_t *node_record)\r
+static void print_node_record(ib_node_record_t * node_record)\r
 {\r
        ib_node_info_t *p_ni = NULL;\r
        ib_node_desc_t *p_nd = NULL;\r
        char *name;\r
 \r
        p_ni = &(node_record->node_info);\r
-        p_nd = &(node_record->node_desc);\r
+       p_nd = &(node_record->node_desc);\r
 \r
        switch (node_print_desc) {\r
        case LID_ONLY:\r
@@ -160,15 +160,15 @@ print_node_record(ib_node_record_t *node_record)
        case NAME_OF_LID:\r
        case NAME_OF_GUID:\r
                name = remap_node_name(node_name_map,\r
-                                         cl_ntoh64(p_ni->node_guid),\r
-                                         (char *)p_nd->description);\r
+                                      cl_ntoh64(p_ni->node_guid),\r
+                                      (char *)p_nd->description);\r
                printf("%s\n", name);\r
                free(name);\r
                return;\r
        case ALL:\r
        default:\r
                break;\r
-        }\r
+       }\r
 \r
        printf("NodeRecord dump:\n"\r
               "\t\tlid.....................0x%X\n"\r
@@ -185,24 +185,16 @@ print_node_record(ib_node_record_t *node_record)
               "\t\trevision................0x%X\n"\r
               "\t\tport_num................0x%X\n"\r
               "\t\tvendor_id...............0x%X\n"\r
-              "\t\tNodeDescription.........%s\n"\r
-              "",\r
-              cl_ntoh16(node_record->lid),\r
-              cl_ntoh16(node_record->resv),\r
-              p_ni->base_version,\r
-              p_ni->class_version,\r
-              ib_get_node_type_str( p_ni->node_type ),\r
-              p_ni->num_ports,\r
-              cl_ntoh64( p_ni->sys_guid ),\r
-              cl_ntoh64( p_ni->node_guid ),\r
-              cl_ntoh64( p_ni->port_guid ),\r
-              cl_ntoh16( p_ni->partition_cap ),\r
-              cl_ntoh16( p_ni->device_id ),\r
-              cl_ntoh32( p_ni->revision ),\r
-              ib_node_info_get_local_port_num( p_ni ),\r
-              cl_ntoh32( ib_node_info_get_vendor_id( p_ni )),\r
-              clean_nodedesc((char *)node_record->node_desc.description)\r
-              );\r
+              "\t\tNodeDescription.........%s\n",\r
+              cl_ntoh16(node_record->lid), cl_ntoh16(node_record->resv),\r
+              p_ni->base_version, p_ni->class_version,\r
+              ib_get_node_type_str(p_ni->node_type), p_ni->num_ports,\r
+              cl_ntoh64(p_ni->sys_guid), cl_ntoh64(p_ni->node_guid),\r
+              cl_ntoh64(p_ni->port_guid), cl_ntoh16(p_ni->partition_cap),\r
+              cl_ntoh16(p_ni->device_id), cl_ntoh32(p_ni->revision),\r
+              ib_node_info_get_local_port_num(p_ni),\r
+              cl_ntoh32(ib_node_info_get_vendor_id(p_ni)),\r
+              clean_nodedesc((char *)node_record->node_desc.description));\r
 }\r
 \r
 static void dump_path_record(void *data)\r
@@ -227,32 +219,22 @@ static void dump_path_record(void *data)
               "\t\tpkt_life................0x%X\n"\r
               "\t\tpreference..............0x%X\n"\r
               "\t\tresv2...................0x%X\n"\r
-              "\t\tresv3...................0x%X\n"\r
-              "",\r
-              cl_ntoh64( p_pr->service_id ),\r
+              "\t\tresv3...................0x%X\n",\r
+              cl_ntoh64(p_pr->service_id),\r
               inet_ntop(AF_INET6, p_pr->dgid.raw, gid_str, sizeof gid_str),\r
               inet_ntop(AF_INET6, p_pr->sgid.raw, gid_str2, sizeof gid_str2),\r
-              cl_ntoh16( p_pr->dlid ),\r
-              cl_ntoh16( p_pr->slid ),\r
-              cl_ntoh32( p_pr->hop_flow_raw ),\r
-              p_pr->tclass,\r
-              p_pr->num_path,\r
-              cl_ntoh16( p_pr->pkey ),\r
-              ib_path_rec_qos_class( p_pr ),\r
-              ib_path_rec_sl( p_pr ),\r
-              p_pr->mtu,\r
-              p_pr->rate,\r
-              p_pr->pkt_life,\r
+              cl_ntoh16(p_pr->dlid), cl_ntoh16(p_pr->slid),\r
+              cl_ntoh32(p_pr->hop_flow_raw), p_pr->tclass, p_pr->num_path,\r
+              cl_ntoh16(p_pr->pkey), ib_path_rec_qos_class(p_pr),\r
+              ib_path_rec_sl(p_pr), p_pr->mtu, p_pr->rate, p_pr->pkt_life,\r
               p_pr->preference,\r
-              *(uint32_t*)&p_pr->resv2,\r
-              *((uint16_t*)&p_pr->resv2 + 2)\r
-              );\r
+              *(uint32_t *) & p_pr->resv2, *((uint16_t *) & p_pr->resv2 + 2));\r
 }\r
 \r
 static void dump_class_port_info(void *data)\r
 {\r
-       char   gid_str[INET6_ADDRSTRLEN];\r
-       char   gid_str2[INET6_ADDRSTRLEN];\r
+       char gid_str[INET6_ADDRSTRLEN];\r
+       char gid_str2[INET6_ADDRSTRLEN];\r
        ib_class_port_info_t *class_port_info = data;\r
 \r
        printf("SA ClassPortInfo:\n"\r
@@ -272,53 +254,65 @@ static void dump_class_port_info(void *data)
               "\t\tTrap LID.................0x%04X\n"\r
               "\t\tTrap PKey................0x%04X\n"\r
               "\t\tTrap HL/QP...............0x%08X\n"\r
-              "\t\tTrap QKey................0x%08X\n"\r
-              "",\r
-              class_port_info->base_ver,\r
-              class_port_info->class_ver,\r
+              "\t\tTrap QKey................0x%08X\n",\r
+              class_port_info->base_ver, class_port_info->class_ver,\r
               cl_ntoh16(class_port_info->cap_mask),\r
               ib_class_cap_mask2(class_port_info),\r
               ib_class_resp_time_val(class_port_info),\r
               inet_ntop(AF_INET6, &(class_port_info->redir_gid), gid_str,\r
-                       sizeof gid_str),\r
+                        sizeof gid_str),\r
               cl_ntoh32(class_port_info->redir_tc_sl_fl),\r
               cl_ntoh16(class_port_info->redir_lid),\r
               cl_ntoh16(class_port_info->redir_pkey),\r
               cl_ntoh32(class_port_info->redir_qp),\r
               cl_ntoh32(class_port_info->redir_qkey),\r
               inet_ntop(AF_INET6, &(class_port_info->trap_gid), gid_str2,\r
-                       sizeof gid_str2),\r
+                        sizeof gid_str2),\r
               cl_ntoh32(class_port_info->trap_tc_sl_fl),\r
               cl_ntoh16(class_port_info->trap_lid),\r
               cl_ntoh16(class_port_info->trap_pkey),\r
               cl_ntoh32(class_port_info->trap_hop_qp),\r
-              cl_ntoh32(class_port_info->trap_qkey)\r
-             );\r
+              cl_ntoh32(class_port_info->trap_qkey));\r
 }\r
 \r
 static void dump_portinfo_record(void *data)\r
 {\r
        ib_portinfo_record_t *p_pir = data;\r
-       const ib_port_info_t * const p_pi = &p_pir->port_info;\r
+       const ib_port_info_t *const p_pi = &p_pir->port_info;\r
 \r
-        printf("PortInfoRecord dump:\n"\r
+       printf("PortInfoRecord dump:\n"\r
               "\t\tEndPortLid..............0x%X\n"\r
               "\t\tPortNum.................0x%X\n"\r
               "\t\tbase_lid................0x%X\n"\r
               "\t\tmaster_sm_base_lid......0x%X\n"\r
-              "\t\tcapability_mask.........0x%X\n"\r
-              "",\r
-              cl_ntoh16(p_pir->lid),\r
-              p_pir->port_num,\r
-              cl_ntoh16( p_pi->base_lid ),\r
-              cl_ntoh16( p_pi->master_sm_base_lid ),\r
-              cl_ntoh32( p_pi->capability_mask )\r
-               );\r
+              "\t\tcapability_mask.........0x%X\n",\r
+              cl_ntoh16(p_pir->lid), p_pir->port_num,\r
+              cl_ntoh16(p_pi->base_lid), cl_ntoh16(p_pi->master_sm_base_lid),\r
+              cl_ntoh32(p_pi->capability_mask));\r
+}\r
+\r
+static void dump_one_portinfo_record(void *data)\r
+{\r
+       char buf[2048], buf2[4096];\r
+       ib_portinfo_record_t *pir = data;\r
+       ib_port_info_t *pi = &pir->port_info;\r
+\r
+       mad_dump_portinfo(buf, sizeof(buf), pi, sizeof(*pi));\r
+\r
+       format_buf(buf, buf2, sizeof(buf2));\r
+\r
+       printf("PortInfoRecord dump:\n"\r
+               "\tRID:\n"\r
+               "\t\tEndPortLid..............%u\n"\r
+               "\t\tPortNum.................0x%x\n"\r
+               "\t\tReserved................0x%x\n"\r
+               "\tPortInfo dump:\n\t\t%s",\r
+               cl_ntoh16(pir->lid), pir->port_num, pir->resv, buf2);\r
 }\r
 \r
 static void dump_multicast_group_record(void *data)\r
 {\r
-       char   gid_str[INET6_ADDRSTRLEN];\r
+       char gid_str[INET6_ADDRSTRLEN];\r
        ib_member_rec_t *p_mcmr = data;\r
        uint8_t sl;\r
        ib_member_get_sl_flow_hop(p_mcmr->sl_flow_hop, &sl, NULL, NULL);\r
@@ -328,24 +322,19 @@ static void dump_multicast_group_record(void *data)
               "\t\tMtu.....................0x%X\n"\r
               "\t\tpkey....................0x%X\n"\r
               "\t\tRate....................0x%X\n"\r
-              "\t\tSL......................0x%X\n"\r
-              "",\r
+              "\t\tSL......................0x%X\n",\r
               inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str, sizeof gid_str),\r
-              cl_ntoh16( p_mcmr->mlid ),\r
-              p_mcmr->mtu,\r
-              cl_ntoh16( p_mcmr->pkey ),\r
-              p_mcmr->rate,\r
-              sl\r
-              );\r
+              cl_ntoh16(p_mcmr->mlid),\r
+              p_mcmr->mtu, cl_ntoh16(p_mcmr->pkey), p_mcmr->rate, sl);\r
 }\r
 \r
 static void dump_multicast_member_record(void *data)\r
 {\r
-       char   gid_str[INET6_ADDRSTRLEN];\r
-       char   gid_str2[INET6_ADDRSTRLEN];\r
+       char gid_str[INET6_ADDRSTRLEN];\r
+       char gid_str2[INET6_ADDRSTRLEN];\r
        ib_member_rec_t *p_mcmr = data;\r
-       uint16_t mlid = cl_ntoh16( p_mcmr->mlid );\r
-       int      i = 0;\r
+       uint16_t mlid = cl_ntoh16(p_mcmr->mlid);\r
+       int i = 0;\r
        char *node_name = "<unknown>";\r
 \r
        /* go through the node records searching for a port guid which matches\r
@@ -353,9 +342,12 @@ static void dump_multicast_member_record(void *data)
         * This gives us a node name to print, if available.\r
         */\r
        for (i = 0; i < result.result_cnt; i++) {\r
-               ib_node_record_t *nr = osmv_get_query_node_rec(result.p_result_madw, i);\r
-               if (nr->node_info.port_guid == p_mcmr->port_gid.unicast.interface_id) {\r
-                       node_name = clean_nodedesc((char *)nr->node_desc.description);\r
+               ib_node_record_t *nr =\r
+                   osmv_get_query_node_rec(result.p_result_madw, i);\r
+               if (nr->node_info.port_guid ==\r
+                   p_mcmr->port_gid.unicast.interface_id) {\r
+                       node_name =\r
+                           clean_nodedesc((char *)nr->node_desc.description);\r
                        break;\r
                }\r
        }\r
@@ -363,10 +355,8 @@ static void dump_multicast_member_record(void *data)
        if (requested_name) {\r
                if (strtol(requested_name, NULL, 0) == mlid) {\r
                        printf("\t\tPortGid.................%s (%s)\n",\r
-                               inet_ntop(AF_INET6, p_mcmr->port_gid.raw,\r
-                                       gid_str, sizeof gid_str),\r
-                              node_name\r
-                             );\r
+                              inet_ntop(AF_INET6, p_mcmr->port_gid.raw,\r
+                                        gid_str, sizeof gid_str), node_name);\r
                }\r
        } else {\r
                printf("MCMemberRecord member dump:\n"\r
@@ -375,45 +365,33 @@ static void dump_multicast_member_record(void *data)
                       "\t\tPortGid.................%s\n"\r
                       "\t\tScopeState..............0x%X\n"\r
                       "\t\tProxyJoin...............0x%X\n"\r
-                      "\t\tNodeDescription.........%s\n"\r
-                      "",\r
+                      "\t\tNodeDescription.........%s\n",\r
                       inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,\r
-                               sizeof gid_str),\r
-                      cl_ntoh16( p_mcmr->mlid ),\r
+                                sizeof gid_str),\r
+                      cl_ntoh16(p_mcmr->mlid),\r
                       inet_ntop(AF_INET6, p_mcmr->port_gid.raw,\r
-                               gid_str2, sizeof gid_str2),\r
-                      p_mcmr->scope_state,\r
-                      p_mcmr->proxy_join,\r
-                      node_name\r
-                     );\r
+                                gid_str2, sizeof gid_str2),\r
+                      p_mcmr->scope_state, p_mcmr->proxy_join, node_name);\r
        }\r
 }\r
 \r
 static void dump_service_record(void *data)\r
 {\r
-       char   gid_str[INET6_ADDRSTRLEN];\r
+       char gid_str[INET6_ADDRSTRLEN];\r
        char buf_service_key[35];\r
        char buf_service_name[65];\r
        ib_service_record_t *p_sr = data;\r
 \r
        sprintf(buf_service_key,\r
                "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",\r
-               p_sr->service_key[0],\r
-               p_sr->service_key[1],\r
-               p_sr->service_key[2],\r
-               p_sr->service_key[3],\r
-               p_sr->service_key[4],\r
-               p_sr->service_key[5],\r
-               p_sr->service_key[6],\r
-               p_sr->service_key[7],\r
-               p_sr->service_key[8],\r
-               p_sr->service_key[9],\r
-               p_sr->service_key[10],\r
-               p_sr->service_key[11],\r
-               p_sr->service_key[12],\r
-               p_sr->service_key[13],\r
-               p_sr->service_key[14],\r
-               p_sr->service_key[15]);\r
+               p_sr->service_key[0], p_sr->service_key[1],\r
+               p_sr->service_key[2], p_sr->service_key[3],\r
+               p_sr->service_key[4], p_sr->service_key[5],\r
+               p_sr->service_key[6], p_sr->service_key[7],\r
+               p_sr->service_key[8], p_sr->service_key[9],\r
+               p_sr->service_key[10], p_sr->service_key[11],\r
+               p_sr->service_key[12], p_sr->service_key[13],\r
+               p_sr->service_key[14], p_sr->service_key[15]);\r
        strncpy(buf_service_name, (char *)p_sr->service_name, 64);\r
        buf_service_name[64] = '\0';\r
 \r
@@ -453,15 +431,12 @@ static void dump_service_record(void *data)
               "\t\tServiceData32.3.........0x%X\n"\r
               "\t\tServiceData32.4.........0x%X\n"\r
               "\t\tServiceData64.1.........0x%016" PRIx64 "\n"\r
-              "\t\tServiceData64.2.........0x%016" PRIx64 "\n"\r
-              "",\r
-              cl_ntoh64( p_sr->service_id ),\r
+              "\t\tServiceData64.2.........0x%016" PRIx64 "\n",\r
+              cl_ntoh64(p_sr->service_id),\r
               inet_ntop(AF_INET6, p_sr->service_gid.raw, gid_str,\r
-                       sizeof gid_str),\r
-              cl_ntoh16( p_sr->service_pkey ),\r
-              cl_ntoh32( p_sr->service_lease ),\r
-              buf_service_key,\r
-              buf_service_name,\r
+                        sizeof gid_str),\r
+              cl_ntoh16(p_sr->service_pkey), cl_ntoh32(p_sr->service_lease),\r
+              buf_service_key, buf_service_name,\r
               p_sr->service_data8[0], p_sr->service_data8[1],\r
               p_sr->service_data8[2], p_sr->service_data8[3],\r
               p_sr->service_data8[4], p_sr->service_data8[5],\r
@@ -470,32 +445,33 @@ static void dump_service_record(void *data)
               p_sr->service_data8[10], p_sr->service_data8[11],\r
               p_sr->service_data8[12], p_sr->service_data8[13],\r
               p_sr->service_data8[14], p_sr->service_data8[15],\r
-              cl_ntoh16( p_sr->service_data16[0] ),\r
-              cl_ntoh16( p_sr->service_data16[1] ),\r
-              cl_ntoh16( p_sr->service_data16[2] ),\r
-              cl_ntoh16( p_sr->service_data16[3] ),\r
-              cl_ntoh16( p_sr->service_data16[4] ),\r
-              cl_ntoh16( p_sr->service_data16[5] ),\r
-              cl_ntoh16( p_sr->service_data16[6] ),\r
-              cl_ntoh16( p_sr->service_data16[7] ),\r
-              cl_ntoh32( p_sr->service_data32[0] ),\r
-              cl_ntoh32( p_sr->service_data32[1] ),\r
-              cl_ntoh32( p_sr->service_data32[2] ),\r
-              cl_ntoh32( p_sr->service_data32[3] ),\r
-              cl_ntoh64( p_sr->service_data64[0] ),\r
-              cl_ntoh64( p_sr->service_data64[1] )\r
-             );\r
+              cl_ntoh16(p_sr->service_data16[0]),\r
+              cl_ntoh16(p_sr->service_data16[1]),\r
+              cl_ntoh16(p_sr->service_data16[2]),\r
+              cl_ntoh16(p_sr->service_data16[3]),\r
+              cl_ntoh16(p_sr->service_data16[4]),\r
+              cl_ntoh16(p_sr->service_data16[5]),\r
+              cl_ntoh16(p_sr->service_data16[6]),\r
+              cl_ntoh16(p_sr->service_data16[7]),\r
+              cl_ntoh32(p_sr->service_data32[0]),\r
+              cl_ntoh32(p_sr->service_data32[1]),\r
+              cl_ntoh32(p_sr->service_data32[2]),\r
+              cl_ntoh32(p_sr->service_data32[3]),\r
+              cl_ntoh64(p_sr->service_data64[0]),\r
+              cl_ntoh64(p_sr->service_data64[1]));\r
 }\r
 \r
 static void dump_inform_info_record(void *data)\r
 {\r
-       char   gid_str[INET6_ADDRSTRLEN];\r
-       char   gid_str2[INET6_ADDRSTRLEN];\r
+       char gid_str[INET6_ADDRSTRLEN];\r
+       char gid_str2[INET6_ADDRSTRLEN];\r
        ib_inform_info_record_t *p_iir = data;\r
        uint32_t qpn;\r
-       uint8_t  resp_time_val;\r
+       uint8_t resp_time_val;\r
 \r
-       ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.generic.qpn_resp_time_val, &qpn, &resp_time_val);\r
+       ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.generic.\r
+                                        qpn_resp_time_val, &qpn,\r
+                                        &resp_time_val);\r
 \r
        if (p_iir->inform_info.is_generic) {\r
                printf("InformInfoRecord dump:\n"\r
@@ -512,23 +488,21 @@ static void dump_inform_info_record(void *data)
                       "\t\ttrap_num................%u\n"\r
                       "\t\tqpn.....................0x%06X\n"\r
                       "\t\tresp_time_val...........0x%X\n"\r
-                      "\t\tnode_type...............0x%06X\n"\r
-                      "",\r
+                      "\t\tnode_type...............0x%06X\n",\r
                       inet_ntop(AF_INET6, p_iir->subscriber_gid.raw, gid_str,\r
-                               sizeof gid_str),\r
-                      cl_ntoh16( p_iir->subscriber_enum ),\r
+                                sizeof gid_str),\r
+                      cl_ntoh16(p_iir->subscriber_enum),\r
                       inet_ntop(AF_INET6, p_iir->inform_info.gid.raw, gid_str2,\r
-                               sizeof gid_str2),\r
-                      cl_ntoh16( p_iir->inform_info.lid_range_begin ),\r
-                      cl_ntoh16( p_iir->inform_info.lid_range_end ),\r
+                                sizeof gid_str2),\r
+                      cl_ntoh16(p_iir->inform_info.lid_range_begin),\r
+                      cl_ntoh16(p_iir->inform_info.lid_range_end),\r
                       p_iir->inform_info.is_generic,\r
                       p_iir->inform_info.subscribe,\r
-                      cl_ntoh16( p_iir->inform_info.trap_type ),\r
-                      cl_ntoh16( p_iir->inform_info.g_or_v.generic.trap_num ),\r
-                      cl_ntoh32( qpn ),\r
-                      resp_time_val,\r
-                      cl_ntoh32(ib_inform_info_get_prod_type( &p_iir->inform_info ))\r
-                     );\r
+                      cl_ntoh16(p_iir->inform_info.trap_type),\r
+                      cl_ntoh16(p_iir->inform_info.g_or_v.generic.trap_num),\r
+                      cl_ntoh32(qpn), resp_time_val,\r
+                      cl_ntoh32(ib_inform_info_get_prod_type\r
+                                (&p_iir->inform_info)));\r
        } else {\r
                printf("InformInfoRecord dump:\n"\r
                       "\t\tRID\n"\r
@@ -544,23 +518,21 @@ static void dump_inform_info_record(void *data)
                       "\t\tdev_id..................0x%X\n"\r
                       "\t\tqpn.....................0x%06X\n"\r
                       "\t\tresp_time_val...........0x%X\n"\r
-                      "\t\tvendor_id...............0x%06X\n"\r
-                      "",\r
+                      "\t\tvendor_id...............0x%06X\n",\r
                       inet_ntop(AF_INET6, p_iir->subscriber_gid.raw, gid_str,\r
-                               sizeof gid_str),\r
-                      cl_ntoh16( p_iir->subscriber_enum ),\r
+                                sizeof gid_str),\r
+                      cl_ntoh16(p_iir->subscriber_enum),\r
                       inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,\r
-                               gid_str2, sizeof gid_str2),\r
-                      cl_ntoh16( p_iir->inform_info.lid_range_begin ),\r
-                      cl_ntoh16( p_iir->inform_info.lid_range_end ),\r
+                                gid_str2, sizeof gid_str2),\r
+                      cl_ntoh16(p_iir->inform_info.lid_range_begin),\r
+                      cl_ntoh16(p_iir->inform_info.lid_range_end),\r
                       p_iir->inform_info.is_generic,\r
                       p_iir->inform_info.subscribe,\r
-                      cl_ntoh16( p_iir->inform_info.trap_type ),\r
-                      cl_ntoh16( p_iir->inform_info.g_or_v.vend.dev_id ),\r
-                      cl_ntoh32( qpn ),\r
-                      resp_time_val,\r
-                      cl_ntoh32(ib_inform_info_get_prod_type( &p_iir->inform_info ))\r
-                     );\r
+                      cl_ntoh16(p_iir->inform_info.trap_type),\r
+                      cl_ntoh16(p_iir->inform_info.g_or_v.vend.dev_id),\r
+                      cl_ntoh32(qpn), resp_time_val,\r
+                      cl_ntoh32(ib_inform_info_get_prod_type\r
+                                (&p_iir->inform_info)));\r
        }\r
 }\r
 \r
@@ -608,7 +580,7 @@ static void dump_one_vlarb_record(void *data)
               "\t\tPort.......................%u\n"\r
               "\t\tBlock......................%u\n",\r
               cl_ntoh16(vlarb->lid), vlarb->port_num, vlarb->block_num);\r
-       for (i = 0; i < 32 ; i += 16) {\r
+       for (i = 0; i < 32; i += 16) {\r
                printf("\t\tVL    :%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|"\r
                       "%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|",\r
                       e[i + 0].vl, e[i + 1].vl, e[i + 2].vl, e[i + 3].vl,\r
@@ -638,7 +610,7 @@ static void dump_one_pkey_tbl_record(void *data)
               "\t\tBlock......................%u\n"\r
               "\t\tPKey Table:\n",\r
               cl_ntoh16(pktr->lid), pktr->port_num, pktr->block_num);\r
-       for (i = 0; i < 32 ; i += 8)\r
+       for (i = 0; i < 32; i += 8)\r
                printf("\t\t0x%04x 0x%04x 0x%04x 0x%04x"\r
                       " 0x%04x 0x%04x 0x%04x 0x%04x\n",\r
                       cl_ntoh16(p[i + 0]), cl_ntoh16(p[i + 1]),\r
@@ -656,10 +628,9 @@ static void dump_one_lft_record(void *data)
        printf("LFT Record dump:\n"\r
               "\t\tLID........................%u\n"\r
               "\t\tBlock......................%u\n"\r
-              "\t\tLFT:\n\t\tLID\tPort Number\n",\r
-              cl_ntoh16(lftr->lid), block);\r
-       for (i = 0; i < 64 ; i++)\r
-               printf("\t\t%u\t%u\n", block*64 + i, lftr->lft[i]);\r
+              "\t\tLFT:\n\t\tLID\tPort Number\n", cl_ntoh16(lftr->lid), block);\r
+       for (i = 0; i < 64; i++)\r
+               printf("\t\t%u\t%u\n", block * 64 + i, lftr->lft[i]);\r
        printf("\n");\r
 }\r
 \r
@@ -668,20 +639,21 @@ static void dump_one_mft_record(void *data)
        ib_mft_record_t *mftr = data;\r
        unsigned position = cl_ntoh16(mftr->position_block_num) >> 12;\r
        unsigned block = cl_ntoh16(mftr->position_block_num) &\r
-                        IB_MCAST_BLOCK_ID_MASK_HO;\r
+           IB_MCAST_BLOCK_ID_MASK_HO;\r
        int i;\r
        printf("MFT Record dump:\n"\r
               "\t\tLID........................%u\n"\r
               "\t\tPosition...................%u\n"\r
               "\t\tBlock......................%u\n"\r
-               "\t\tMFT:\n\t\tMLID\tPort Mask\n",\r
+              "\t\tMFT:\n\t\tMLID\tPort Mask\n",\r
               cl_ntoh16(mftr->lid), position, block);\r
        for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)\r
-               printf("\t\t0x%x\t0x%x\n", IB_LID_MCAST_START_HO + block*64 + i,\r
+               printf("\t\t0x%x\t0x%x\n",\r
+                      IB_LID_MCAST_START_HO + block * 64 + i,\r
                       cl_ntoh16(mftr->mft[i]));\r
        printf("\n");\r
 }\r
-static void dump_results(osmv_query_res_t *r, void (*dump_func)(void *))\r
+static void dump_results(osmv_query_res_t * r, void (*dump_func) (void *))\r
 {\r
        int i;\r
        for (i = 0; i < r->result_cnt; i++) {\r
@@ -690,8 +662,7 @@ static void dump_results(osmv_query_res_t *r, void (*dump_func)(void *))
        }\r
 }\r
 \r
-static void\r
-return_mad(void)\r
+static void return_mad(void)\r
 {\r
        /*\r
         * Return the IB query MAD to the pool as necessary.\r
@@ -706,13 +677,12 @@ return_mad(void)
  * Get any record(s)\r
  */\r
 static ib_api_status_t\r
-get_any_records(osm_bind_handle_t bind_handle,\r
+get_any_records(osm_bind_handle_t h,\r
                ib_net16_t attr_id, ib_net32_t attr_mod, ib_net64_t comp_mask,\r
-               void *attr, ib_net16_t attr_offset,\r
-               ib_net64_t sm_key)\r
+               void *attr, ib_net16_t attr_offset, ib_net64_t sm_key)\r
 {\r
-       ib_api_status_t   status;\r
-       osmv_query_req_t  req;\r
+       ib_api_status_t status;\r
+       osmv_query_req_t req;\r
        osmv_user_query_t user;\r
 \r
        memset(&req, 0, sizeof(req));\r
@@ -733,7 +703,7 @@ get_any_records(osm_bind_handle_t bind_handle,
        req.p_query_input = &user;\r
        req.sm_key = sm_key;\r
 \r
-       if ((status = osmv_query_sa(bind_handle, &req)) != IB_SUCCESS) {\r
+       if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {\r
                fprintf(stderr, "Query SA failed: %s\n",\r
                        ib_get_err_str(status));\r
                return status;\r
@@ -751,13 +721,9 @@ get_any_records(osm_bind_handle_t bind_handle,
 /**\r
  * Get all the records available for requested query type.\r
  */\r
-static ib_api_status_t\r
-get_all_records(osm_bind_handle_t bind_handle,\r
-               ib_net16_t query_id,\r
-               ib_net16_t attr_offset,\r
-               int trusted)\r
+static ib_api_status_t get_all_records(osm_bind_handle_t h, ib_net16_t query_id,                                      ib_net16_t attr_offset, int trusted)\r
 {\r
-       return get_any_records(bind_handle, query_id, 0, 0, NULL, attr_offset,\r
+       return get_any_records(h, query_id, 0, 0, NULL, attr_offset,\r
                               trusted ? smkey : 0);\r
 }\r
 \r
@@ -765,23 +731,25 @@ get_all_records(osm_bind_handle_t bind_handle,
  * return the lid from the node descriptor (name) supplied\r
  */\r
 static ib_api_status_t\r
-get_lid_from_name(osm_bind_handle_t bind_handle, const char *name, ib_net16_t *lid)\r
+get_lid_from_name(osm_bind_handle_t h, const char *name, ib_net16_t * lid)\r
 {\r
-       int               i = 0;\r
+       int i = 0;\r
        ib_node_record_t *node_record = NULL;\r
-       ib_node_info_t   *p_ni = NULL;\r
-       ib_net16_t        attr_offset = ib_get_attr_offset(sizeof(*node_record));\r
-       ib_api_status_t   status;\r
+       ib_node_info_t *p_ni = NULL;\r
+       ib_net16_t attr_offset = ib_get_attr_offset(sizeof(*node_record));\r
+       ib_api_status_t status;\r
 \r
-       status = get_all_records(bind_handle, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);\r
+       status = get_all_records(h, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
        for (i = 0; i < result.result_cnt; i++) {\r
                node_record = osmv_get_query_node_rec(result.p_result_madw, i);\r
                p_ni = &(node_record->node_info);\r
-               if (name && strncmp(name, (char *)node_record->node_desc.description,\r
-                                   sizeof(node_record->node_desc.description)) == 0) {\r
+               if (name\r
+                   && strncmp(name, (char *)node_record->node_desc.description,\r
+                              sizeof(node_record->node_desc.description)) ==\r
+                   0) {\r
                        *lid = cl_ntoh16(node_record->lid);\r
                        break;\r
                }\r
@@ -790,40 +758,43 @@ get_lid_from_name(osm_bind_handle_t bind_handle, const char *name, ib_net16_t *l
        return (status);\r
 }\r
 \r
-static ib_net16_t\r
-get_lid(osm_bind_handle_t bind_handle, const char * name)\r
+static ib_net16_t get_lid(osm_bind_handle_t h, const char *name)\r
 {\r
        ib_net16_t rc_lid = 0;\r
 \r
        if (!name)\r
-               return(0);\r
+               return (0);\r
        if (isalpha(name[0]))\r
-               assert(get_lid_from_name(bind_handle, name, &rc_lid) == IB_SUCCESS);\r
+               assert(get_lid_from_name(h, name, &rc_lid) == IB_SUCCESS);\r
        else\r
                rc_lid = atoi(name);\r
        if (rc_lid == 0)\r
                fprintf(stderr, "Failed to find lid for \"%s\"\n", name);\r
-        return (rc_lid);\r
+       return (rc_lid);\r
 }\r
 \r
-static int parse_lid_and_ports(osm_bind_handle_t bind_handle,\r
+static int parse_lid_and_ports(osm_bind_handle_t h,\r
                               char *str, int *lid, int *port1, int *port2)\r
 {\r
        char *p, *e;\r
 \r
-       if (port1) *port1 = -1;\r
-       if (port2) *port2 = -1;\r
+       if (port1)\r
+               *port1 = -1;\r
+       if (port2)\r
+               *port2 = -1;\r
 \r
        p = strchr(str, '/');\r
-       if (p) *p = '\0';\r
+       if (p)\r
+               *p = '\0';\r
        if (lid)\r
-               *lid = get_lid(bind_handle, str);\r
+               *lid = get_lid(h, str);\r
 \r
        if (!p)\r
                return 0;\r
        str = p + 1;\r
        p = strchr(str, '/');\r
-       if (p) *p = '\0';\r
+       if (p)\r
+               *p = '\0';\r
        if (port1) {\r
                *port1 = strtoul(str, &e, 0);\r
                if (e == str)\r
@@ -845,30 +816,29 @@ static int parse_lid_and_ports(osm_bind_handle_t bind_handle,
 /*\r
  * Get the portinfo records available with IsSM or IsSMdisabled CapabilityMask bit on.\r
  */\r
-static ib_api_status_t\r
-get_issm_records(osm_bind_handle_t bind_handle, ib_net32_t capability_mask)\r
+static ib_api_status_t get_issm_records(osm_bind_handle_t h,\r
+                                       ib_net32_t capability_mask)\r
 {\r
        ib_portinfo_record_t attr;\r
 \r
-       memset( &attr, 0, sizeof ( attr ) );\r
+       memset(&attr, 0, sizeof(attr));\r
        attr.port_info.capability_mask = capability_mask;\r
 \r
-       return get_any_records(bind_handle, IB_MAD_ATTR_PORTINFO_RECORD,\r
+       return get_any_records(h, IB_MAD_ATTR_PORTINFO_RECORD,\r
                               cl_hton32(1 << 31), IB_PIR_COMPMASK_CAPMASK,\r
                               &attr,\r
                               ib_get_attr_offset(sizeof(ib_portinfo_record_t)),\r
                               0);\r
 }\r
 \r
-static ib_api_status_t\r
-print_node_records(osm_bind_handle_t bind_handle)\r
+static ib_api_status_t print_node_records(osm_bind_handle_t h)\r
 {\r
-       int               i = 0;\r
+       int i = 0;\r
        ib_node_record_t *node_record = NULL;\r
-       ib_net16_t        attr_offset = ib_get_attr_offset(sizeof(*node_record));\r
-       ib_api_status_t   status;\r
+       ib_net16_t attr_offset = ib_get_attr_offset(sizeof(*node_record));\r
+       ib_api_status_t status;\r
 \r
-       status  = get_all_records(bind_handle, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);\r
+       status = get_all_records(h, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -894,7 +864,8 @@ print_node_records(osm_bind_handle_t bind_handle)
                        if (!requested_name ||\r
                            (strncmp(requested_name,\r
                                     (char *)node_record->node_desc.description,\r
-                                    sizeof(node_record->node_desc.description)) == 0)) {\r
+                                    sizeof(node_record->node_desc.\r
+                                           description)) == 0)) {\r
                                print_node_record(node_record);\r
                                if (node_print_desc == UNIQUE_LID_ONLY) {\r
                                        return_mad();\r
@@ -908,18 +879,17 @@ print_node_records(osm_bind_handle_t bind_handle)
 }\r
 \r
 static ib_api_status_t\r
-get_print_path_rec_lid(osm_bind_handle_t bind_handle,\r
-                      ib_net16_t src_lid,\r
-                      ib_net16_t dst_lid)\r
+get_print_path_rec_lid(osm_bind_handle_t h,\r
+                      ib_net16_t src_lid, ib_net16_t dst_lid)\r
 {\r
-       osmv_query_req_t      req;\r
-       osmv_lid_pair_t       lid_pair;\r
-       ib_api_status_t       status;\r
+       osmv_query_req_t req;\r
+       osmv_lid_pair_t lid_pair;\r
+       ib_api_status_t status;\r
 \r
        lid_pair.src_lid = cl_hton16(src_lid);\r
        lid_pair.dest_lid = cl_hton16(dst_lid);\r
 \r
-       memset( &req, 0, sizeof( req ) );\r
+       memset(&req, 0, sizeof(req));\r
 \r
        req.query_type = OSMV_QUERY_PATH_REC_BY_LIDS;\r
        req.timeout_ms = sa_timeout_ms;\r
@@ -930,7 +900,7 @@ get_print_path_rec_lid(osm_bind_handle_t bind_handle,
        req.p_query_input = (void *)&lid_pair;\r
        req.sm_key = 0;\r
 \r
-       if ((status = osmv_query_sa(bind_handle, &req)) != IB_SUCCESS) {\r
+       if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {\r
                fprintf(stderr, "ERROR: Query SA failed: %s\n",\r
                        ib_get_err_str(status));\r
                return (status);\r
@@ -947,18 +917,17 @@ get_print_path_rec_lid(osm_bind_handle_t bind_handle,
 }\r
 \r
 static ib_api_status_t\r
-get_print_path_rec_gid(osm_bind_handle_t bind_handle,\r
-                      const ib_gid_t *src_gid,\r
-                      const ib_gid_t *dst_gid)\r
+get_print_path_rec_gid(osm_bind_handle_t h,\r
+                      const ib_gid_t * src_gid, const ib_gid_t * dst_gid)\r
 {\r
-       osmv_query_req_t      req;\r
-       osmv_gid_pair_t       gid_pair;\r
-       ib_api_status_t       status;\r
+       osmv_query_req_t req;\r
+       osmv_gid_pair_t gid_pair;\r
+       ib_api_status_t status;\r
 \r
        gid_pair.src_gid = *src_gid;\r
        gid_pair.dest_gid = *dst_gid;\r
 \r
-       memset( &req, 0, sizeof( req ) );\r
+       memset(&req, 0, sizeof(req));\r
 \r
        req.query_type = OSMV_QUERY_PATH_REC_BY_GIDS;\r
        req.timeout_ms = sa_timeout_ms;\r
@@ -969,7 +938,7 @@ get_print_path_rec_gid(osm_bind_handle_t bind_handle,
        req.p_query_input = (void *)&gid_pair;\r
        req.sm_key = 0;\r
 \r
-       if ((status = osmv_query_sa(bind_handle, &req)) != IB_SUCCESS) {\r
+       if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {\r
                fprintf(stderr, "ERROR: Query SA failed: %s\n",\r
                        ib_get_err_str(status));\r
                return (status);\r
@@ -985,13 +954,12 @@ get_print_path_rec_gid(osm_bind_handle_t bind_handle,
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-get_print_class_port_info(osm_bind_handle_t bind_handle)\r
+static ib_api_status_t get_print_class_port_info(osm_bind_handle_t h)\r
 {\r
-       osmv_query_req_t      req;\r
-       ib_api_status_t       status;\r
+       osmv_query_req_t req;\r
+       ib_api_status_t status;\r
 \r
-       memset( &req, 0, sizeof( req ) );\r
+       memset(&req, 0, sizeof(req));\r
 \r
        req.query_type = OSMV_QUERY_CLASS_PORT_INFO;\r
        req.timeout_ms = sa_timeout_ms;\r
@@ -1002,7 +970,7 @@ get_print_class_port_info(osm_bind_handle_t bind_handle)
        req.p_query_input = NULL;\r
        req.sm_key = 0;\r
 \r
-       if ((status = osmv_query_sa(bind_handle, &req)) != IB_SUCCESS) {\r
+       if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {\r
                fprintf(stderr, "ERROR: Query SA failed: %s\n",\r
                        ib_get_err_str(status));\r
                return (status);\r
@@ -1018,13 +986,13 @@ get_print_class_port_info(osm_bind_handle_t bind_handle)
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_path_records(osm_bind_handle_t bind_handle)\r
+static int query_path_records(const struct query_cmd *q,\r
+                             osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_net16_t attr_offset = ib_get_attr_offset(sizeof(ib_path_rec_t));\r
        ib_api_status_t status;\r
 \r
-       status = get_all_records(bind_handle, IB_MAD_ATTR_PATH_RECORD, attr_offset, 0);\r
+       status = get_all_records(h, IB_MAD_ATTR_PATH_RECORD, attr_offset, 0);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -1033,13 +1001,12 @@ print_path_records(osm_bind_handle_t bind_handle)
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_portinfo_records(osm_bind_handle_t bind_handle)\r
+static ib_api_status_t print_issm_records(osm_bind_handle_t h)\r
 {\r
-       ib_api_status_t       status;\r
+       ib_api_status_t status;\r
 \r
        /* First, get IsSM records */\r
-       status = get_issm_records(bind_handle, IB_PORT_CAP_IS_SM);\r
+       status = get_issm_records(h, IB_PORT_CAP_IS_SM);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -1048,7 +1015,7 @@ print_portinfo_records(osm_bind_handle_t bind_handle)
        return_mad();\r
 \r
        /* Now, get IsSMdisabled records */\r
-       status = get_issm_records(bind_handle, IB_PORT_CAP_SM_DISAB);\r
+       status = get_issm_records(h, IB_PORT_CAP_SM_DISAB);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -1059,21 +1026,22 @@ print_portinfo_records(osm_bind_handle_t bind_handle)
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_multicast_member_records(osm_bind_handle_t bind_handle)\r
+static ib_api_status_t print_multicast_member_records(osm_bind_handle_t h)\r
 {\r
-       osmv_query_res_t  mc_group_result;\r
-       ib_api_status_t   status;\r
+       osmv_query_res_t mc_group_result;\r
+       ib_api_status_t status;\r
 \r
-       status = get_all_records(bind_handle, IB_MAD_ATTR_MCMEMBER_RECORD,\r
-                                ib_get_attr_offset(sizeof(ib_member_rec_t)), 1);\r
+       status = get_all_records(h, IB_MAD_ATTR_MCMEMBER_RECORD,\r
+                                ib_get_attr_offset(sizeof(ib_member_rec_t)),\r
+                                1);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
        mc_group_result = result;\r
 \r
-       status  = get_all_records(bind_handle, IB_MAD_ATTR_NODE_RECORD,\r
-                                 ib_get_attr_offset(sizeof(ib_node_record_t)), 0);\r
+       status = get_all_records(h, IB_MAD_ATTR_NODE_RECORD,\r
+                                ib_get_attr_offset(sizeof(ib_node_record_t)),\r
+                                0);\r
        if (status != IB_SUCCESS)\r
                goto return_mc;\r
 \r
@@ -1090,13 +1058,13 @@ return_mc:
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_multicast_group_records(osm_bind_handle_t bind_handle)\r
+static ib_api_status_t print_multicast_group_records(osm_bind_handle_t h)\r
 {\r
-       ib_api_status_t   status;\r
+       ib_api_status_t status;\r
 \r
-       status = get_all_records(bind_handle, IB_MAD_ATTR_MCMEMBER_RECORD,\r
-                                ib_get_attr_offset(sizeof(ib_member_rec_t)), 0);\r
+       status = get_all_records(h, IB_MAD_ATTR_MCMEMBER_RECORD,\r
+                                ib_get_attr_offset(sizeof(ib_member_rec_t)),\r
+                                0);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -1105,13 +1073,67 @@ print_multicast_group_records(osm_bind_handle_t bind_handle)
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_service_records(osm_bind_handle_t bind_handle)\r
+static int query_class_port_info(const struct query_cmd *q,\r
+                                osm_bind_handle_t h, int argc, char *argv[])\r
+{\r
+       return get_print_class_port_info(h);\r
+}\r
+\r
+static int query_node_records(const struct query_cmd *q,\r
+                             osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
-       ib_net16_t attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));\r
+       return print_node_records(h);\r
+}\r
+\r
+static int query_portinfo_records(const struct query_cmd *q,\r
+                                 osm_bind_handle_t h, int argc, char *argv[])\r
+{\r
+       ib_portinfo_record_t pir;\r
+       ib_net64_t comp_mask = 0;\r
+       int lid = 0, port = -1;\r
+       ib_api_status_t status;\r
+\r
+       if (argc > 0)\r
+               parse_lid_and_ports(h, argv[0], &lid, &port, NULL);\r
+\r
+       memset(&pir, 0, sizeof(pir));\r
+\r
+       if (lid > 0) {\r
+               pir.lid = cl_hton16(lid);\r
+               comp_mask |= IB_PIR_COMPMASK_LID;\r
+       }\r
+       if (port >= 0) {\r
+               pir.port_num = cl_hton16(port);\r
+               comp_mask |= IB_PIR_COMPMASK_PORTNUM;\r
+       }\r
+\r
+       status = get_any_records(h, IB_MAD_ATTR_PORTINFO_RECORD, 0,\r
+                                comp_mask, &pir,\r
+                                ib_get_attr_offset(sizeof(pir)), 0);\r
+\r
+       if (status != IB_SUCCESS)\r
+               return status;\r
+\r
+       dump_results(&result, dump_one_portinfo_record);\r
+       return_mad();\r
+\r
+       return 0;\r
+}\r
+\r
+static int query_mcmember_records(const struct query_cmd *q,\r
+                                  osm_bind_handle_t h, int argc, char *argv[])\r
+{\r
+       return print_multicast_member_records(h);\r
+}\r
+\r
+static int query_service_records(const struct query_cmd *q,\r
+                                osm_bind_handle_t h, int argc, char *argv[])\r
+{\r
+       ib_net16_t attr_offset =\r
+           ib_get_attr_offset(sizeof(ib_service_record_t));\r
        ib_api_status_t status;\r
 \r
-       status = get_all_records(bind_handle, IB_MAD_ATTR_SERVICE_RECORD, attr_offset, 0);\r
+       status = get_all_records(h, IB_MAD_ATTR_SERVICE_RECORD, attr_offset, 0);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -1120,13 +1142,15 @@ print_service_records(osm_bind_handle_t bind_handle)
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_inform_info_records(osm_bind_handle_t bind_handle)\r
+static int query_informinfo_records(const struct query_cmd *q,\r
+                                   osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
-       ib_net16_t attr_offset = ib_get_attr_offset(sizeof(ib_inform_info_record_t));\r
+       ib_net16_t attr_offset =\r
+           ib_get_attr_offset(sizeof(ib_inform_info_record_t));\r
        ib_api_status_t status;\r
 \r
-       status = get_all_records(bind_handle, IB_MAD_ATTR_INFORM_INFO_RECORD, attr_offset, 0);\r
+       status =\r
+           get_all_records(h, IB_MAD_ATTR_INFORM_INFO_RECORD, attr_offset, 0);\r
        if (status != IB_SUCCESS)\r
                return (status);\r
 \r
@@ -1135,8 +1159,8 @@ print_inform_info_records(osm_bind_handle_t bind_handle)
        return (status);\r
 }\r
 \r
-static ib_api_status_t\r
-print_link_records(osm_bind_handle_t bind_handle, int argc, char *argv[])\r
+static int query_link_records(const struct query_cmd *q,\r
+                             osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_link_record_t lr;\r
        ib_net64_t comp_mask = 0;\r
@@ -1144,12 +1168,10 @@ print_link_records(osm_bind_handle_t bind_handle, int argc, char *argv[])
        ib_api_status_t status;\r
 \r
        if (argc > 0)\r
-               parse_lid_and_ports(bind_handle, argv[0],\r
-                                   &from_lid, &from_port, NULL);\r
+               parse_lid_and_ports(h, argv[0], &from_lid, &from_port, NULL);\r
 \r
        if (argc > 1)\r
-               parse_lid_and_ports(bind_handle, argv[1],\r
-                                   &to_lid, &to_port, NULL);\r
+               parse_lid_and_ports(h, argv[1], &to_lid, &to_port, NULL);\r
 \r
        memset(&lr, 0, sizeof(lr));\r
 \r
@@ -1170,7 +1192,7 @@ print_link_records(osm_bind_handle_t bind_handle, int argc, char *argv[])
                comp_mask |= IB_LR_COMPMASK_TO_PORT;\r
        }\r
 \r
-       status = get_any_records(bind_handle, IB_MAD_ATTR_LINK_RECORD, 0,\r
+       status = get_any_records(h, IB_MAD_ATTR_LINK_RECORD, 0,\r
                                 comp_mask, &lr,\r
                                 ib_get_attr_offset(sizeof(lr)), 0);\r
        if (status != IB_SUCCESS)\r
@@ -1181,9 +1203,8 @@ print_link_records(osm_bind_handle_t bind_handle, int argc, char *argv[])
        return status;\r
 }\r
 \r
-static int\r
-print_sl2vl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,\r
-                   int argc, char *argv[])\r
+static int query_sl2vl_records(const struct query_cmd *q,\r
+                              osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_slvl_table_record_t slvl;\r
        ib_net64_t comp_mask = 0;\r
@@ -1191,8 +1212,7 @@ print_sl2vl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        ib_api_status_t status;\r
 \r
        if (argc > 0)\r
-               parse_lid_and_ports(bind_handle, argv[0],\r
-                                   &lid, &in_port, &out_port);\r
+               parse_lid_and_ports(h, argv[0], &lid, &in_port, &out_port);\r
 \r
        memset(&slvl, 0, sizeof(slvl));\r
 \r
@@ -1209,7 +1229,7 @@ print_sl2vl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
                comp_mask |= IB_SLVL_COMPMASK_OUT_PORT;\r
        }\r
 \r
-       status = get_any_records(bind_handle, IB_MAD_ATTR_SLVL_RECORD, 0,\r
+       status = get_any_records(h, IB_MAD_ATTR_SLVL_RECORD, 0,\r
                                 comp_mask, &slvl,\r
                                 ib_get_attr_offset(sizeof(slvl)), 0);\r
        if (status != IB_SUCCESS)\r
@@ -1220,9 +1240,8 @@ print_sl2vl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        return status;\r
 }\r
 \r
-static int\r
-print_vlarb_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,\r
-                   int argc, char *argv[])\r
+static int query_vlarb_records(const struct query_cmd *q,\r
+                              osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_vl_arb_table_record_t vlarb;\r
        ib_net64_t comp_mask = 0;\r
@@ -1230,8 +1249,7 @@ print_vlarb_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        ib_api_status_t status;\r
 \r
        if (argc > 0)\r
-               parse_lid_and_ports(bind_handle, argv[0],\r
-                                   &lid, &port, &block);\r
+               parse_lid_and_ports(h, argv[0], &lid, &port, &block);\r
 \r
        memset(&vlarb, 0, sizeof(vlarb));\r
 \r
@@ -1248,7 +1266,7 @@ print_vlarb_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
                comp_mask |= IB_VLA_COMPMASK_BLOCK;\r
        }\r
 \r
-       status = get_any_records(bind_handle, IB_MAD_ATTR_VLARB_RECORD, 0,\r
+       status = get_any_records(h, IB_MAD_ATTR_VLARB_RECORD, 0,\r
                                 comp_mask, &vlarb,\r
                                 ib_get_attr_offset(sizeof(vlarb)), 0);\r
        if (status != IB_SUCCESS)\r
@@ -1259,9 +1277,8 @@ print_vlarb_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        return status;\r
 }\r
 \r
-static int\r
-print_pkey_tbl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,\r
-                      int argc, char *argv[])\r
+static int query_pkey_tbl_records(const struct query_cmd *q,\r
+                                 osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_pkey_table_record_t pktr;\r
        ib_net64_t comp_mask = 0;\r
@@ -1269,8 +1286,7 @@ print_pkey_tbl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        ib_api_status_t status;\r
 \r
        if (argc > 0)\r
-               parse_lid_and_ports(bind_handle, argv[0],\r
-                                   &lid, &port, &block);\r
+               parse_lid_and_ports(h, argv[0], &lid, &port, &block);\r
 \r
        memset(&pktr, 0, sizeof(pktr));\r
 \r
@@ -1287,7 +1303,7 @@ print_pkey_tbl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
                comp_mask |= IB_PKEY_COMPMASK_BLOCK;\r
        }\r
 \r
-       status = get_any_records(bind_handle, IB_MAD_ATTR_PKEY_TBL_RECORD, 0,\r
+       status = get_any_records(h, IB_MAD_ATTR_PKEY_TBL_RECORD, 0,\r
                                 comp_mask, &pktr,\r
                                 ib_get_attr_offset(sizeof(pktr)), smkey);\r
        if (status != IB_SUCCESS)\r
@@ -1298,9 +1314,8 @@ print_pkey_tbl_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        return status;\r
 }\r
 \r
-static int\r
-print_lft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,\r
-                 int argc, char *argv[])\r
+static int query_lft_records(const struct query_cmd *q,\r
+                            osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_lft_record_t lftr;\r
        ib_net64_t comp_mask = 0;\r
@@ -1308,8 +1323,7 @@ print_lft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        ib_api_status_t status;\r
 \r
        if (argc > 0)\r
-               parse_lid_and_ports(bind_handle, argv[0],\r
-                                   &lid, &block, NULL);\r
+               parse_lid_and_ports(h, argv[0], &lid, &block, NULL);\r
 \r
        memset(&lftr, 0, sizeof(lftr));\r
 \r
@@ -1322,7 +1336,7 @@ print_lft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
                comp_mask |= IB_LFTR_COMPMASK_BLOCK;\r
        }\r
 \r
-       status = get_any_records(bind_handle, IB_MAD_ATTR_LFT_RECORD, 0,\r
+       status = get_any_records(h, IB_MAD_ATTR_LFT_RECORD, 0,\r
                                 comp_mask, &lftr,\r
                                 ib_get_attr_offset(sizeof(lftr)), 0);\r
        if (status != IB_SUCCESS)\r
@@ -1333,9 +1347,8 @@ print_lft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        return status;\r
 }\r
 \r
-static int\r
-print_mft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,\r
-                 int argc, char *argv[])\r
+static int query_mft_records(const struct query_cmd *q,\r
+                            osm_bind_handle_t h, int argc, char *argv[])\r
 {\r
        ib_mft_record_t mftr;\r
        ib_net64_t comp_mask = 0;\r
@@ -1343,8 +1356,7 @@ print_mft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        ib_api_status_t status;\r
 \r
        if (argc > 0)\r
-               parse_lid_and_ports(bind_handle, argv[0],\r
-                                  &lid, &position, &block);\r
+               parse_lid_and_ports(h, argv[0], &lid, &position, &block);\r
 \r
        memset(&mftr, 0, sizeof(mftr));\r
 \r
@@ -1357,11 +1369,12 @@ print_mft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
                comp_mask |= IB_MFTR_COMPMASK_POSITION;\r
        }\r
        if (block >= 0) {\r
-               mftr.position_block_num |= cl_hton16(block & IB_MCAST_BLOCK_ID_MASK_HO);\r
+               mftr.position_block_num |=\r
+                   cl_hton16(block & IB_MCAST_BLOCK_ID_MASK_HO);\r
                comp_mask |= IB_MFTR_COMPMASK_BLOCK;\r
        }\r
 \r
-       status = get_any_records(bind_handle, IB_MAD_ATTR_MFT_RECORD, 0,\r
+       status = get_any_records(h, IB_MAD_ATTR_MFT_RECORD, 0,\r
                                 comp_mask, &mftr,\r
                                 ib_get_attr_offset(sizeof(mftr)), 0);\r
        if (status != IB_SUCCESS)\r
@@ -1372,16 +1385,15 @@ print_mft_records(const struct query_cmd *q, osm_bind_handle_t bind_handle,
        return status;\r
 }\r
 \r
-static osm_bind_handle_t\r
-get_bind_handle(void)\r
+static osm_bind_handle_t get_bind_handle(void)\r
 {\r
-       uint32_t           i = 0;\r
-       uint64_t           port_guid = (uint64_t)-1;\r
-       osm_bind_handle_t  bind_handle;\r
-       ib_api_status_t    status;\r
-       ib_port_attr_t     attr_array[MAX_PORTS];\r
-       uint32_t           num_ports = MAX_PORTS;\r
-       uint32_t           ca_name_index = 0;\r
+       uint32_t i = 0;\r
+       uint64_t port_guid = (uint64_t) - 1;\r
+       osm_bind_handle_t h;\r
+       ib_api_status_t status;\r
+       ib_port_attr_t attr_array[MAX_PORTS];\r
+       uint32_t num_ports = MAX_PORTS;\r
+       uint32_t ca_name_index = 0;\r
 \r
        complib_init();\r
 \r
@@ -1396,7 +1408,7 @@ get_bind_handle(void)
        if (osm_debug)\r
                osm_log_set_level(&log_osm, OSM_LOG_DEFAULT_LEVEL);\r
 \r
-        vendor = osm_vendor_new(&log_osm, sa_timeout_ms);\r
+       vendor = osm_vendor_new(&log_osm, sa_timeout_ms);\r
        osm_mad_pool_construct(&mad_pool);\r
        if ((status = osm_mad_pool_init(&mad_pool)) != IB_SUCCESS) {\r
                fprintf(stderr, "Failed to init mad pool: %s\n",\r
@@ -1404,7 +1416,9 @@ get_bind_handle(void)
                exit(-1);\r
        }\r
 \r
-       if ((status = osm_vendor_get_all_port_attr(vendor, attr_array, &num_ports)) != IB_SUCCESS) {\r
+       if ((status =\r
+            osm_vendor_get_all_port_attr(vendor, attr_array,\r
+                                         &num_ports)) != IB_SUCCESS) {\r
                fprintf(stderr, "Failed to get port attributes: %s\n",\r
                        ib_get_err_str(status));\r
                exit(-1);\r
@@ -1412,12 +1426,13 @@ get_bind_handle(void)
 \r
        for (i = 0; i < num_ports; i++) {\r
                if (i > 1 && cl_ntoh64(attr_array[i].port_guid)\r
-                               != (cl_ntoh64(attr_array[i-1].port_guid) + 1))\r
+                   != (cl_ntoh64(attr_array[i - 1].port_guid) + 1))\r
                        ca_name_index++;\r
                if (sa_port_num && sa_port_num != attr_array[i].port_num)\r
                        continue;\r
                if (sa_hca_name\r
-                && strcmp(sa_hca_name, vendor->ca_names[ca_name_index]) != 0)\r
+                   && strcmp(sa_hca_name,\r
+                             vendor->ca_names[ca_name_index]) != 0)\r
                        continue;\r
                if (attr_array[i].link_state == IB_LINK_ACTIVE) {\r
                        port_guid = attr_array[i].port_guid;\r
@@ -1425,52 +1440,55 @@ get_bind_handle(void)
                }\r
        }\r
 \r
-       if (port_guid == (uint64_t)-1) {\r
-               fprintf(stderr, "Failed to find active port, check port status with \"ibstat\"\n");\r
+       if (port_guid == (uint64_t) - 1) {\r
+               fprintf(stderr,\r
+                       "Failed to find active port, check port status with \"ibstat\"\n");\r
                exit(-1);\r
        }\r
 \r
-       bind_handle = osmv_bind_sa(vendor, &mad_pool, port_guid);\r
+       h = osmv_bind_sa(vendor, &mad_pool, port_guid);\r
 \r
-       if (bind_handle == OSM_BIND_INVALID_HANDLE) {\r
+       if (h == OSM_BIND_INVALID_HANDLE) {\r
                fprintf(stderr, "Failed to bind to SA\n");\r
                exit(-1);\r
        }\r
-       return (bind_handle);\r
+       return h;\r
 }\r
 \r
-static void\r
-clean_up(void)\r
+static void clean_up(void)\r
 {\r
        osm_mad_pool_destroy(&mad_pool);\r
        osm_vendor_delete(&vendor);\r
 }\r
 \r
 static const struct query_cmd query_cmds[] = {\r
-       { "ClassPortInfo", "CPI", IB_MAD_ATTR_CLASS_PORT_INFO, },\r
-       { "NodeRecord", "NR", IB_MAD_ATTR_NODE_RECORD, },\r
-       { "PortInfoRecord", "PIR", IB_MAD_ATTR_PORTINFO_RECORD, },\r
-       { "SL2VLTableRecord", "SL2VL", IB_MAD_ATTR_SLVL_RECORD,\r
-         "[[lid]/[in_port]/[out_port]]",\r
-          print_sl2vl_records },\r
-       { "PKeyTableRecord", "PKTR", IB_MAD_ATTR_PKEY_TBL_RECORD,\r
-         "[[lid]/[port]/[block]]",\r
-          print_pkey_tbl_records },\r
-       { "VLArbitrationTableRecord", "VLAR", IB_MAD_ATTR_VLARB_RECORD,\r
-         "[[lid]/[port]/[block]]",\r
-          print_vlarb_records },\r
-       { "InformInfoRecord", "IIR", IB_MAD_ATTR_INFORM_INFO_RECORD, },\r
-       { "LinkRecord", "LR", IB_MAD_ATTR_LINK_RECORD,\r
-         "[[from_lid]/[from_port]] [[to_lid]/[to_port]]", },\r
-       { "ServiceRecord", "SR", IB_MAD_ATTR_SERVICE_RECORD, },\r
-       { "PathRecord", "PR", IB_MAD_ATTR_PATH_RECORD, },\r
-       { "MCMemberRecord", "MCMR", IB_MAD_ATTR_MCMEMBER_RECORD, },\r
-       { "LFTRecord", "LFTR", IB_MAD_ATTR_LFT_RECORD, "[[lid]/[block]]",\r
-         print_lft_records },\r
-       { "MFTRecord", "MFTR", IB_MAD_ATTR_MFT_RECORD,\r
-         "[[mlid]/[position]/[block]]",\r
-         print_mft_records },\r
-       { 0 }\r
+       {"ClassPortInfo", "CPI", IB_MAD_ATTR_CLASS_PORT_INFO,\r
+        NULL, query_class_port_info},\r
+       {"NodeRecord", "NR", IB_MAD_ATTR_NODE_RECORD,\r
+        NULL, query_node_records},\r
+       {"PortInfoRecord", "PIR", IB_MAD_ATTR_PORTINFO_RECORD,\r
+        "[[lid]/[port]]", query_portinfo_records},\r
+       {"SL2VLTableRecord", "SL2VL", IB_MAD_ATTR_SLVL_RECORD,\r
+        "[[lid]/[in_port]/[out_port]]", query_sl2vl_records},\r
+       {"PKeyTableRecord", "PKTR", IB_MAD_ATTR_PKEY_TBL_RECORD,\r
+        "[[lid]/[port]/[block]]", query_pkey_tbl_records},\r
+       {"VLArbitrationTableRecord", "VLAR", IB_MAD_ATTR_VLARB_RECORD,\r
+        "[[lid]/[port]/[block]]", query_vlarb_records},\r
+       {"InformInfoRecord", "IIR", IB_MAD_ATTR_INFORM_INFO_RECORD,\r
+        NULL, query_informinfo_records},\r
+       {"LinkRecord", "LR", IB_MAD_ATTR_LINK_RECORD,\r
+        "[[from_lid]/[from_port]] [[to_lid]/[to_port]]", query_link_records},\r
+       {"ServiceRecord", "SR", IB_MAD_ATTR_SERVICE_RECORD,\r
+        NULL, query_service_records},\r
+       {"PathRecord", "PR", IB_MAD_ATTR_PATH_RECORD,\r
+        NULL, query_path_records},\r
+       {"MCMemberRecord", "MCMR", IB_MAD_ATTR_MCMEMBER_RECORD,\r
+        NULL, query_mcmember_records},\r
+       {"LFTRecord", "LFTR", IB_MAD_ATTR_LFT_RECORD,\r
+        "[[lid]/[block]]", query_lft_records},\r
+       {"MFTRecord", "MFTR", IB_MAD_ATTR_MFT_RECORD,\r
+        "[[mlid]/[position]/[block]]", query_mft_records},\r
+       {0}\r
 };\r
 \r
 static const struct query_cmd *find_query(const char *name)\r
@@ -1486,8 +1504,18 @@ static const struct query_cmd *find_query(const char *name)
        return NULL;\r
 }\r
 \r
-static void\r
-usage(void)\r
+static const struct query_cmd *find_query_by_type(ib_net16_t type)\r
+{\r
+       const struct query_cmd *q;\r
+\r
+       for (q = query_cmds; q->name; q++)\r
+               if (q->query_type == type)\r
+                       return q;\r
+\r
+       return NULL;\r
+}\r
+\r
+static void usage(void)\r
 {\r
        const struct query_cmd *q;\r
 \r
@@ -1509,29 +1537,29 @@ usage(void)
        fprintf(stderr, "   -U return name for the Guid specified\n");\r
        fprintf(stderr, "   -c get the SA's class port info\n");\r
        fprintf(stderr, "   -s return the PortInfoRecords with isSM or "\r
-                               "isSMdisabled capability mask bit on\n");\r
+               "isSMdisabled capability mask bit on\n");\r
        fprintf(stderr, "   -g get multicast group info\n");\r
        fprintf(stderr, "   -m get multicast member info\n");\r
        fprintf(stderr, "      (if multicast group specified, list member GIDs"\r
-                               " only for group specified\n");\r
+               " only for group specified\n");\r
        fprintf(stderr, "      specified, for example 'saquery -m 0xC000')\n");\r
        fprintf(stderr, "   -x get LinkRecord info\n");\r
        fprintf(stderr, "   --src-to-dst get a PathRecord for <src:dst>\n"\r
-                       "                where src and dst are either node "\r
-                               "names or LIDs\n");\r
+               "                where src and dst are either node "\r
+               "names or LIDs\n");\r
        fprintf(stderr, "   --sgid-to-dgid get a PathRecord for <sgid-dgid>\n"\r
-                       "                where sgid and dgid are addresses in "\r
-                               "IPv6 format\n");\r
+               "                where sgid and dgid are addresses in "\r
+               "IPv6 format\n");\r
        fprintf(stderr, "   -C <ca_name> specify the SA query HCA\n");\r
        fprintf(stderr, "   -P <ca_port> specify the SA query port\n");\r
        fprintf(stderr, "   --smkey <val> specify SM_Key value for the query."\r
-                       " If non-numeric value \n"\r
-                       "                 (like 'x') is specified then "\r
-                       "saquery will prompt for a value\n");\r
+               " If non-numeric value \n"\r
+               "                 (like 'x') is specified then "\r
+               "saquery will prompt for a value\n");\r
        fprintf(stderr, "   -t | --timeout <msec> specify the SA query "\r
-                               "response timeout (default %u msec)\n",\r
-                       DEFAULT_SA_TIMEOUT_MS);\r
-       fprintf(stderr, "   --node-name-map <node-name-map> specify a node name map\n");\r
+               "response timeout (default %u msec)\n", DEFAULT_SA_TIMEOUT_MS);\r
+       fprintf(stderr,\r
+               "   --node-name-map <node-name-map> specify a node name map\n");\r
        fprintf(stderr, "\n   Supported query names (and aliases):\n");\r
        for (q = query_cmds; q->name; q++)\r
                fprintf(stderr, "      %s (%s) %s\n", q->name,\r
@@ -1541,92 +1569,99 @@ usage(void)
        exit(-1);\r
 }\r
 \r
-int\r
+enum saquery_command {\r
+       SAQUERY_CMD_QUERY,\r
+       SAQUERY_CMD_NODE_RECORD,\r
+       SAQUERY_CMD_PATH_RECORD,\r
+       SAQUERY_CMD_CLASS_PORT_INFO,\r
+       SAQUERY_CMD_ISSM,\r
+       SAQUERY_CMD_MCGROUPS,\r
+       SAQUERY_CMD_MCMEMBERS,\r
+};\r
+\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
-       int                ch = 0;\r
-       int                members = 0;\r
-       osm_bind_handle_t  bind_handle;\r
+       int ch = 0;\r
+       osm_bind_handle_t h;\r
+       enum saquery_command command = SAQUERY_CMD_QUERY;\r
        const struct query_cmd *q = NULL;\r
-       char              *src = NULL;\r
-       char              *dst = NULL;\r
-       char              *sgid = NULL;\r
-       char              *dgid = NULL;\r
-       ib_net16_t         query_type = 0;\r
-       ib_net16_t         src_lid;\r
-       ib_net16_t         dst_lid;\r
-       ib_api_status_t    status;\r
+       char *src = NULL, *dst = NULL;\r
+       char *sgid = NULL, *dgid = NULL;\r
+       ib_net16_t query_type = 0;\r
+       ib_net16_t src_lid, dst_lid;\r
+       ib_api_status_t status;\r
 \r
        static char const str_opts[] = "pVNDLlGOUcSIsgmxdhP:C:t:";\r
-       static const struct option long_opts [] = {\r
-          {"p", 0, 0, 'p'},\r
-          {"Version", 0, 0, 'V'},\r
-          {"N", 0, 0, 'N'},\r
-          {"L", 0, 0, 'L'},\r
-          {"l", 0, 0, 'l'},\r
-          {"G", 0, 0, 'G'},\r
-          {"O", 0, 0, 'O'},\r
-          {"U", 0, 0, 'U'},\r
-          {"s", 0, 0, 's'},\r
-          {"g", 0, 0, 'g'},\r
-          {"m", 0, 0, 'm'},\r
-          {"x", 0, 0, 'x'},\r
-          {"d", 0, 0, 'd'},\r
-          {"c", 0, 0, 'c'},\r
-          {"S", 0, 0, 'S'},\r
-          {"I", 0, 0, 'I'},\r
-          {"P", 1, 0, 'P'},\r
-          {"C", 1, 0, 'C'},\r
-          {"help", 0, 0, 'h'},\r
-          {"list", 0, 0, 'D'},\r
-          {"src-to-dst", 1, 0, 1},\r
-          {"sgid-to-dgid", 1, 0, 2},\r
-          {"timeout", 1, 0, 't'},\r
-          {"node-name-map", 1, 0, 3},\r
-          {"smkey", 1, 0, 4},\r
-          }\r
+       static const struct option long_opts[] = {\r
+               {"p", 0, 0, 'p'},\r
+               {"Version", 0, 0, 'V'},\r
+               {"N", 0, 0, 'N'},\r
+               {"L", 0, 0, 'L'},\r
+               {"l", 0, 0, 'l'},\r
+               {"G", 0, 0, 'G'},\r
+               {"O", 0, 0, 'O'},\r
+               {"U", 0, 0, 'U'},\r
+               {"s", 0, 0, 's'},\r
+               {"g", 0, 0, 'g'},\r
+               {"m", 0, 0, 'm'},\r
+               {"x", 0, 0, 'x'},\r
+               {"d", 0, 0, 'd'},\r
+               {"c", 0, 0, 'c'},\r
+               {"S", 0, 0, 'S'},\r
+               {"I", 0, 0, 'I'},\r
+               {"P", 1, 0, 'P'},\r
+               {"C", 1, 0, 'C'},\r
+               {"help", 0, 0, 'h'},\r
+               {"list", 0, 0, 'D'},\r
+               {"src-to-dst", 1, 0, 1},\r
+               {"sgid-to-dgid", 1, 0, 2},\r
+               {"timeout", 1, 0, 't'},\r
+               {"node-name-map", 1, 0, 3},\r
+               {"smkey", 1, 0, 4},\r
+               {}\r
        };\r
 \r
        argv0 = argv[0];\r
 \r
-       while ((ch = getopt_long_only(argc, argv, str_opts, long_opts, NULL)) != -1) {\r
+       while ((ch = getopt_long(argc, argv, str_opts, long_opts, NULL)) != -1) {\r
                switch (ch) {\r
                case 1:\r
-               {\r
-                       char *opt  = strdup(optarg);\r
-                       char *ch = strchr(opt, ':');\r
-                       if (!ch) {\r
-                               fprintf(stderr,\r
-                                       "ERROR: --src-to-dst <node>:<node>\n");\r
-                               usage();\r
+                       {\r
+                               char *opt = strdup(optarg);\r
+                               char *ch = strchr(opt, ':');\r
+                               if (!ch) {\r
+                                       fprintf(stderr,\r
+                                               "ERROR: --src-to-dst <node>:<node>\n");\r
+                                       usage();\r
+                               }\r
+                               *ch++ = '\0';\r
+                               if (*opt)\r
+                                       src = strdup(opt);\r
+                               if (*ch)\r
+                                       dst = strdup(ch);\r
+                               free(opt);\r
+                               command = SAQUERY_CMD_PATH_RECORD;\r
+                               break;\r
                        }\r
-                       *ch++ = '\0';\r
-                       if (*opt)\r
-                               src = strdup(opt);\r
-                       if (*ch)\r
-                               dst = strdup(ch);\r
-                       free(opt);\r
-                       query_type = IB_MAD_ATTR_PATH_RECORD;\r
-                       break;\r
-               }\r
                case 2:\r
-               {\r
-                       char *opt  = strdup(optarg);\r
-                       char *tok1 = strtok(opt, "-");\r
-                       char *tok2 = strtok(NULL, "\0");\r
-\r
-                       if (tok1 && tok2) {\r
-                               sgid = strdup(tok1);\r
-                               dgid = strdup(tok2);\r
-                       } else {\r
-                               fprintf(stderr,\r
-                                       "ERROR: --sgid-to-dgid <GID>-<GID>\n");\r
-                               usage();\r
+                       {\r
+                               char *opt = strdup(optarg);\r
+                               char *tok1 = strtok(opt, "-");\r
+                               char *tok2 = strtok(NULL, "\0");\r
+\r
+                               if (tok1 && tok2) {\r
+                                       sgid = strdup(tok1);\r
+                                       dgid = strdup(tok2);\r
+                               } else {\r
+                                       fprintf(stderr,\r
+                                               "ERROR: --sgid-to-dgid <GID>-<GID>\n");\r
+                                       usage();\r
+                               }\r
+                               free(opt);\r
+                               command = SAQUERY_CMD_PATH_RECORD;\r
+                               break;\r
                        }\r
-                       free(opt);\r
-                       query_type = IB_MAD_ATTR_PATH_RECORD;\r
-                       break;\r
-               }\r
                case 3:\r
                        node_name_map_file = strdup(optarg);\r
                        break;\r
@@ -1639,7 +1674,7 @@ main(int argc, char **argv)
                        smkey = cl_hton64(strtoull(optarg, NULL, 0));\r
                        break;\r
                case 'p':\r
-                       query_type = IB_MAD_ATTR_PATH_RECORD;\r
+                       command = SAQUERY_CMD_PATH_RECORD;\r
                        break;\r
                case 'V':\r
                        fprintf(stderr, "%s %s\n", argv0, get_build_version());\r
@@ -1648,7 +1683,7 @@ main(int argc, char **argv)
                        node_print_desc = ALL_DESC;\r
                        break;\r
                case 'c':\r
-                       query_type = IB_MAD_ATTR_CLASS_PORT_INFO;\r
+                       command = SAQUERY_CMD_CLASS_PORT_INFO;\r
                        break;\r
                case 'S':\r
                        query_type = IB_MAD_ATTR_SERVICE_RECORD;\r
@@ -1657,7 +1692,7 @@ main(int argc, char **argv)
                        query_type = IB_MAD_ATTR_INFORM_INFO_RECORD;\r
                        break;\r
                case 'N':\r
-                       query_type = IB_MAD_ATTR_NODE_RECORD;\r
+                       command = SAQUERY_CMD_NODE_RECORD;\r
                        break;\r
                case 'L':\r
                        node_print_desc = LID_ONLY;\r
@@ -1675,14 +1710,13 @@ main(int argc, char **argv)
                        node_print_desc = NAME_OF_GUID;\r
                        break;\r
                case 's':\r
-                       query_type = IB_MAD_ATTR_PORTINFO_RECORD;\r
+                       command = SAQUERY_CMD_ISSM;\r
                        break;\r
                case 'g':\r
-                       query_type = IB_MAD_ATTR_MCMEMBER_RECORD;\r
+                       command = SAQUERY_CMD_MCGROUPS;\r
                        break;\r
                case 'm':\r
-                       query_type = IB_MAD_ATTR_MCMEMBER_RECORD;\r
-                       members = 1;\r
+                       command = SAQUERY_CMD_MCMEMBERS;\r
                        break;\r
                case 'x':\r
                        query_type = IB_MAD_ATTR_LINK_RECORD;\r
@@ -1719,10 +1753,10 @@ main(int argc, char **argv)
 \r
        if (argc) {\r
                if (node_print_desc == NAME_OF_LID) {\r
-                       requested_lid = (ib_net16_t)strtoul(argv[0], NULL, 0);\r
+                       requested_lid = (ib_net16_t) strtoul(argv[0], NULL, 0);\r
                        requested_lid_flag++;\r
                } else if (node_print_desc == NAME_OF_GUID) {\r
-                       requested_guid = (ib_net64_t)strtoul(argv[0], NULL, 0);\r
+                       requested_guid = (ib_net64_t) strtoul(argv[0], NULL, 0);\r
                        requested_guid_flag++;\r
                } else {\r
                        requested_name = argv[0];\r
@@ -1731,8 +1765,7 @@ main(int argc, char **argv)
 \r
        if ((node_print_desc == LID_ONLY ||\r
             node_print_desc == UNIQUE_LID_ONLY ||\r
-            node_print_desc == GUID_ONLY) &&\r
-            !requested_name) {\r
+            node_print_desc == GUID_ONLY) && !requested_name) {\r
                fprintf(stderr, "ERROR: name not specified\n");\r
                usage();\r
        }\r
@@ -1753,22 +1786,23 @@ main(int argc, char **argv)
                usage();\r
        }\r
 \r
-       bind_handle = get_bind_handle();\r
+       h = get_bind_handle();\r
        node_name_map = open_node_name_map(node_name_map_file);\r
 \r
-       switch (query_type) {\r
-       case IB_MAD_ATTR_NODE_RECORD:\r
-               status = print_node_records(bind_handle);\r
+       switch (command) {\r
+       case SAQUERY_CMD_NODE_RECORD:\r
+               status = print_node_records(h);\r
                break;\r
-       case IB_MAD_ATTR_PATH_RECORD:\r
+       case SAQUERY_CMD_PATH_RECORD:\r
                if (src && dst) {\r
-                       src_lid = get_lid(bind_handle, src);\r
-                       dst_lid = get_lid(bind_handle, dst);\r
+                       src_lid = get_lid(h, src);\r
+                       dst_lid = get_lid(h, dst);\r
                        printf("Path record for %s -> %s\n", src, dst);\r
                        if (src_lid == 0 || dst_lid == 0) {\r
-                               status = IB_UNKNOWN_ERROR;\r
+                               status = IB_UNKNOWN_ERROR;\r
                        } else {\r
-                               status = get_print_path_rec_lid(bind_handle, src_lid, dst_lid);\r
+                               status =\r
+                                   get_print_path_rec_lid(h, src_lid, dst_lid);\r
                        }\r
                } else if (sgid && dgid) {\r
                        struct in6_addr src_addr, dst_addr;\r
@@ -1781,42 +1815,33 @@ main(int argc, char **argv)
                                fprintf(stderr, "invalid dst gid: %s\n", dgid);\r
                                exit(-1);\r
                        }\r
-                       status = get_print_path_rec_gid(\r
-                               bind_handle,\r
-                               (ib_gid_t *) &src_addr.s6_addr,\r
-                               (ib_gid_t *) &dst_addr.s6_addr);\r
+                       status = get_print_path_rec_gid(h,\r
+                                       (ib_gid_t *) & src_addr.s6_addr,\r
+                                       (ib_gid_t *) & dst_addr.s6_addr);\r
                } else {\r
-                       status = print_path_records(bind_handle);\r
+                       status = query_path_records(q, h, 0, NULL);\r
                }\r
                break;\r
-       case IB_MAD_ATTR_CLASS_PORT_INFO:\r
-               status = get_print_class_port_info(bind_handle);\r
-               break;\r
-       case IB_MAD_ATTR_PORTINFO_RECORD:\r
-               status = print_portinfo_records(bind_handle);\r
+       case SAQUERY_CMD_CLASS_PORT_INFO:\r
+               status = get_print_class_port_info(h);\r
                break;\r
-       case IB_MAD_ATTR_MCMEMBER_RECORD:\r
-               if (members)\r
-                       status = print_multicast_member_records(bind_handle);\r
-               else\r
-                       status = print_multicast_group_records(bind_handle);\r
+       case SAQUERY_CMD_ISSM:\r
+               status = print_issm_records(h);\r
                break;\r
-       case IB_MAD_ATTR_SERVICE_RECORD:\r
-               status = print_service_records(bind_handle);\r
+       case SAQUERY_CMD_MCGROUPS:\r
+               status = print_multicast_group_records(h);\r
                break;\r
-       case IB_MAD_ATTR_INFORM_INFO_RECORD:\r
-               status = print_inform_info_records(bind_handle);\r
-               break;\r
-       case IB_MAD_ATTR_LINK_RECORD:\r
-               status = print_link_records(bind_handle, argc, argv);\r
+       case SAQUERY_CMD_MCMEMBERS:\r
+               status = print_multicast_member_records(h);\r
                break;\r
        default:\r
-               if (q && q->handler)\r
-                       status = q->handler(q, bind_handle, argc, argv);\r
-               else {\r
-                       fprintf(stderr, "Unknown query type %d\n", query_type);\r
+               if ((!q && !(q = find_query_by_type(query_type)))\r
+                   || !q->handler) {\r
+                       fprintf(stderr, "Unknown query type %d\n",\r
+                               ntohs(query_type));\r
                        status = IB_UNKNOWN_ERROR;\r
-               }\r
+               } else\r
+                       status = q->handler(q, h, argc, argv);\r
                break;\r
        }\r
 \r
index 07378a6..eb0d99f 100644 (file)
@@ -12,12 +12,7 @@ USE_IOSTREAM = 1
 \r
 SOURCES = ..\saquery.c ..\ibdiag_common.c\r
        \r
-INCLUDES = ..;..\..\include;\r
-       ..\..\..\..\ulp\opensm\user\include;\r
-       ..\..\..\..\ulp\libibmad\include;\r
-       ..\..\..\..\ulp\libibumad\include;\r
-       ..\..\..\..\inc;\r
-       ..\..\..\..\inc\user;\r
+INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
 TARGETLIBS =   \\r
        $(SDK_LIB_PATH)\kernel32.lib    \\r
index 18ae875..331b59c 100644 (file)
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
-#include <stdarg.h>\r
-\r
-#if !defined(_WIN32) \r
-#include <unistd.h>\r
-#include <inttypes.h>\r
-#include <getopt.h>\r
-#else\r
-#include "..\..\..\..\etc\user\getopt.c"\r
-#endif\r
 \r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
@@ -84,7 +75,7 @@ char *statestr[] = {
 \r
 #define STATESTR(s)    (((unsigned int)(s)) < SMINFO_STATE_LAST ? statestr[s] : "???")\r
 \r
-int __cdecl\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};\r
@@ -101,8 +92,8 @@ main(int argc, char **argv)
        char *ca = 0;\r
        int ca_port = 0;\r
 \r
-       static char str_opts[] = "C:P:t:s:p:a:deDGVhu";\r
-       static struct option long_opts[] = {\r
+       static char const str_opts[] = "C:P:t:s:p:a:deDGVhu";\r
+       static const struct option long_opts[] = {\r
                { "C", 1, 0, 'C'},\r
                { "P", 1, 0, 'P'},\r
                { "debug", 0, 0, 'd'},\r
index 133f267..aa8cf80 100644 (file)
@@ -10,7 +10,7 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\sminfo.c ..\ibdiag_common.c \r
+SOURCES = ..\sminfo.c ..\ibdiag_common.c ..\ibdiag_osd.c\r
        \r
 INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r
index 2272db0..fc89200 100644 (file)
 #include <errno.h>\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
-#include <unistd.h>\r
-#include <stdarg.h>\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <fcntl.h>\r
-#include <sys/ioctl.h>\r
-#include <unistd.h>\r
 #include <getopt.h>\r
-#include <endian.h>\r
-#include <byteswap.h>\r
-#include <sys/poll.h>\r
-#include <syslog.h>\r
 #include <netinet/in.h>\r
 \r
 #include <infiniband/common.h>\r
index 2e8d369..0e5b7fd 100644 (file)
@@ -420,7 +420,7 @@ usage(void)
        exit(-1);\r
 }\r
 \r
-int\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};\r
index 4bbd704..c6979a2 100644 (file)
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
-#if defined(_WIN32) \r
-#include <windows.h>\r
-#include <winsock2.h>\r
-#include "..\..\..\..\etc\user\getopt.c"\r
-#else\r
-#include <unistd.h>\r
-#include <stdarg.h>\r
-#include <getopt.h>\r
-#include <netinet/in.h>\r
-#endif\r
 \r
 #include <infiniband/umad.h>\r
 #include <infiniband/mad.h>\r
@@ -131,7 +121,7 @@ usage(void)
        exit(-1);\r
 }\r
 \r
-int __cdecl\r
+int _CDECL\r
 main(int argc, char **argv)\r
 {\r
        int mgmt_classes[4] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS, IB_MLX_VENDOR_CLASS};\r
@@ -152,8 +142,8 @@ main(int argc, char **argv)
        int xmit_wait = 0;\r
        int i;\r
 \r
-       static char str_opts[] = "C:P:s:t:dNwGVhu";\r
-       static struct option long_opts[] = {\r
+       static char const str_opts[] = "C:P:s:t:dNwGVhu";\r
+       static const struct option long_opts[] = {\r
                { "C", 1, 0, 'C'},\r
                { "P", 1, 0, 'P'},\r
                { "N", 1, 0, 'N'},\r
index c61861f..225fd2f 100644 (file)
@@ -10,7 +10,7 @@ USE_STL = 1
 USE_NATIVE_EH = 1\r
 USE_IOSTREAM = 1\r
 \r
-SOURCES = ..\vendstat.c ..\ibdiag_common.c\r
+SOURCES = ..\vendstat.c ..\ibdiag_common.c ..\ibdiag_osd.c\r
        \r
 INCLUDES = ..;..\..\include;..\..\..\..\ulp\libibmad\include;..\..\..\..\ulp\libibumad\include;..\..\..\..\inc;..\..\..\..\inc\user;\r
 \r