[WinOF] updated cmtest_main.c to compile under Visual studio 2005.
authorstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 6 Dec 2007 01:06:36 +0000 (01:06 +0000)
committerstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 6 Dec 2007 01:06:36 +0000 (01:06 +0000)
local & remote endpoint (port) LIDs are now specified in host-byte order as displayed by the vstat command.
Help text reworked to mention vstat command output for LID specification.

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

tests/cmtest/user/cmtest_main.c

index e487f8f..a06db1f 100644 (file)
@@ -258,35 +258,37 @@ __show_usage()
        printf( "Options:\n" );\r
        printf( "-s\n"\r
                        "--server\n"\r
-                       "          This option directs cmtest to act as a Server\n" );\r
+                       "          Directs cmtest to act as a Server\n" );\r
        printf( "-l <lid>\n"\r
                        "--local <lid>\n"\r
-                       "          This option specifies the local endpoint.\n" );\r
+                       "          Local endpoint LID; see vstat port_lid value.\n"\r
+                        "          LID Radix [0x Hex, 0 octal, else decimal]\n");\r
        printf( "-r <lid>\n"\r
                        "--remote <lid>\n"\r
-                       "          This option specifies the remote endpoint.\n" );\r
+                       "          Remote endpoint LID\n"\r
+                        "          LID Radix [0x Hex, 0 octal, else decimal]\n" );\r
        printf( "-c <number>\n"\r
                        "--connect <number>\n"\r
-                       "          This option specifies the number of connections to open.\n"\r
+                       "          Total number of connections to open.\n"\r
                        "          Default of 1.\n" );\r
        printf( "-m <bytes>\n"\r
                        "--msize <bytes>\n"\r
-                       "          This option specifies the byte size of each message.\n"\r
+                       "          Byte size of each message.\n"\r
                        "          Default is 100 bytes.\n" );\r
        printf( "-n <number>\n"\r
                        "--nmsgs <number>\n"\r
-                       "          This option specifies the number of messages to send at a time.\n" );\r
+                       "          Number of messages to send at a time.\n" );\r
        printf( "-p\n"\r
                        "--permsg\n"\r
-                       "          This option indicates if a separate buffer should be used per message.\n"\r
+                       "          Specify a separate buffer should be used per message.\n"\r
                        "          Default is one buffer for all messages.\n" );\r
        printf( "-i <number>\n"\r
                        "--iterate <number>\n"\r
-                       "          This option specifies the number of times to loop through 'nmsgs'.\n"\r
+                       "          Set the number of times to loop through 'nmsgs'.\n"\r
                        "          Default of 1.\n" );\r
        printf( "-v\n"\r
                        "--verbose\n"\r
-                       "          This option enables verbosity level to debug console.\n" );\r
+                       "          Set verbosity level to debug console.\n" );\r
        printf( "-h\n"\r
                        "--help\n"\r
                        "          Display this usage info then exit.\n\n" );\r
@@ -443,13 +445,15 @@ __parse_options(
                        break;\r
 \r
                case 'l':\r
-                       g_root.l_lid = cl_ntoh16( (uint16_t)strtoull( optarg, NULL, 0 ) );\r
-                       printf( "\tlocal lid....: x%x\n", g_root.l_lid );\r
+                       g_root.l_lid = (uint16_t)strtoull( optarg, NULL, 0 );\r
+                       printf( "\tlocal lid....: 0x%x\n", g_root.l_lid );\r
+                       g_root.l_lid = cl_hton16( g_root.l_lid );\r
                        break;\r
 \r
                case 'r':\r
-                       g_root.r_lid = cl_ntoh16( (uint16_t)strtoull( optarg, NULL, 0 ) );\r
-                       printf( "\tremote lid...: x%x\n", g_root.r_lid );\r
+                       g_root.r_lid = (uint16_t)strtoull( optarg, NULL, 0 );\r
+                       printf( "\tremote lid...: 0x%x\n", g_root.r_lid );\r
+                       g_root.r_lid = cl_hton16( g_root.r_lid );\r
                        break;\r
 \r
                case 'm':\r
@@ -508,7 +512,7 @@ __init_conn_info()
        g_root.cm_req.svc_id = CMT_BASE_SVC_ID + g_root.inst_id;\r
        g_root.cm_req.max_cm_retries = 5;\r
        g_root.cm_req.p_primary_path = &g_root.path_rec;\r
-       g_root.cm_req.pfn_cm_rep_cb = __rep_cb;\r
+       g_root.cm_req.pfn_cm_rep_cb = (ib_pfn_cm_rep_cb_t)__rep_cb;\r
        g_root.cm_req.qp_type = IB_QPT_RELIABLE_CONN;\r
        g_root.cm_req.resp_res = 3;\r
        g_root.cm_req.init_depth = 1;\r
@@ -518,8 +522,8 @@ __init_conn_info()
        g_root.cm_req.rnr_nak_timeout = 6;\r
        g_root.cm_req.rnr_retry_cnt = 3;\r
        g_root.cm_req.retry_cnt = 5;\r
-       g_root.cm_req.pfn_cm_mra_cb = __mra_cb;\r
-       g_root.cm_req.pfn_cm_rej_cb = __rej_cb;\r
+       g_root.cm_req.pfn_cm_mra_cb = (ib_pfn_cm_mra_cb_t)__mra_cb;\r
+       g_root.cm_req.pfn_cm_rej_cb = (ib_pfn_cm_rej_cb_t)__rej_cb;\r
 \r
        /* Initialize connection reply parameters. */\r
        g_root.cm_rep.qp_type = IB_QPT_RELIABLE_CONN;\r
@@ -532,18 +536,18 @@ __init_conn_info()
        g_root.cm_rep.flow_ctrl = TRUE;\r
        g_root.cm_rep.rnr_nak_timeout = 7;\r
        g_root.cm_rep.rnr_retry_cnt = 6;\r
-       g_root.cm_rep.pfn_cm_rej_cb = __rej_cb;\r
-       g_root.cm_rep.pfn_cm_mra_cb = __mra_cb;\r
-       g_root.cm_rep.pfn_cm_rtu_cb = __rtu_cb;\r
-       g_root.cm_rep.pfn_cm_lap_cb = __lap_cb;\r
-       g_root.cm_rep.pfn_cm_dreq_cb = __dreq_cb;\r
+       g_root.cm_rep.pfn_cm_rej_cb = (ib_pfn_cm_rej_cb_t)__rej_cb;\r
+       g_root.cm_rep.pfn_cm_mra_cb = (ib_pfn_cm_mra_cb_t)__mra_cb;\r
+       g_root.cm_rep.pfn_cm_rtu_cb = (ib_pfn_cm_rtu_cb_t)__rtu_cb;\r
+       g_root.cm_rep.pfn_cm_lap_cb = (ib_pfn_cm_lap_cb_t)__lap_cb;\r
+       g_root.cm_rep.pfn_cm_dreq_cb = (ib_pfn_cm_dreq_cb_t)__dreq_cb;\r
 \r
        /* Initialize connection RTU parameters. */\r
-       g_root.cm_rtu.pfn_cm_apr_cb = __apr_cb;\r
-       g_root.cm_rtu.pfn_cm_dreq_cb = __dreq_cb;\r
+       g_root.cm_rtu.pfn_cm_apr_cb = (ib_pfn_cm_apr_cb_t)__apr_cb;\r
+       g_root.cm_rtu.pfn_cm_dreq_cb = (ib_pfn_cm_dreq_cb_t)__dreq_cb;\r
 \r
        /* Initialize disconnection request parameters. */\r
-       g_root.cm_dreq.pfn_cm_drep_cb = __drep_cb;\r
+       g_root.cm_dreq.pfn_cm_drep_cb = (ib_pfn_cm_drep_cb_t)__drep_cb;\r
        g_root.cm_dreq.qp_type = IB_QPT_RELIABLE_CONN;\r
 \r
        /* Disconnection reply parameters are all zero. */\r
@@ -771,7 +775,7 @@ __rep_cb(
        CL_ENTER( CMT_DBG_VERBOSE, cmt_dbg_lvl );\r
        CL_ASSERT( p_cm_rep_rec );\r
        \r
-       p_node = (ib_node_t*)p_cm_rep_rec->qp_context;\r
+       p_node = (ib_node_t *)p_cm_rep_rec->qp_context;\r
        CL_ASSERT( p_node );\r
 \r
        mra.p_mra_pdata = NULL;\r
@@ -1066,7 +1070,7 @@ __init_node(
        else\r
                cq_create.size = 1;     /* minimal of one entry */\r
 \r
-       cq_create.pfn_comp_cb = __cq_cb;\r
+       cq_create.pfn_comp_cb = (ib_pfn_comp_cb_t)__cq_cb;\r
        status = ib_create_cq( g_root.h_ca, &cq_create, p_node, NULL,\r
                &p_node->h_send_cq );\r
        if( status != IB_SUCCESS )\r
@@ -1255,7 +1259,7 @@ __query_for_path()
        query_rec.retry_cnt = 2;\r
        query_rec.flags = IB_FLAGS_SYNC;\r
        query_rec.query_context = &g_root;\r
-       query_rec.pfn_query_cb = __sa_query_cb;\r
+       query_rec.pfn_query_cb = (ib_pfn_query_cb_t)__sa_query_cb;\r
 \r
        status = ib_query( g_root.h_al, &query_rec, NULL );\r
        if( ( status != IB_SUCCESS ) || ( !g_root.path_rec.dlid ) )\r
@@ -1285,7 +1289,7 @@ __create_messages()
                buf_size = (g_root.num_nodes * g_root.num_msgs * g_root.msg_size) << 1;\r
        else\r
                buf_size = g_root.msg_size;\r
-       g_root.p_mem = cl_zalloc( buf_size );\r
+       g_root.p_mem = (uint8_t*)cl_zalloc( buf_size );\r
        if( !g_root.p_mem )\r
        {\r
                printf( "Not enough memory for transfers!\n" );\r
@@ -1349,7 +1353,7 @@ __pnp_cb(
 \r
        /* Record the PKEYs available on the active port. */\r
        size = sizeof( ib_net16_t ) * p_port_rec->p_port_attr->num_pkeys;\r
-       g_root.p_pkey_table = cl_zalloc( size );\r
+       g_root.p_pkey_table = (ib_net16_t *)cl_zalloc( size );\r
        if( !g_root.p_pkey_table )\r
                return IB_SUCCESS;\r
        g_root.num_pkeys = p_port_rec->p_port_attr->num_pkeys;\r
@@ -1375,7 +1379,7 @@ __reg_pnp()
        cl_memclr( &pnp_req, sizeof( ib_pnp_req_t ) );\r
        pnp_req.pnp_class = IB_PNP_PORT;\r
        pnp_req.pnp_context = &g_root;\r
-       pnp_req.pfn_pnp_cb = __pnp_cb;\r
+       pnp_req.pfn_pnp_cb = (ib_pfn_pnp_cb_t)__pnp_cb;\r
 \r
        /* Register for PnP events. */\r
        status = ib_reg_pnp( g_root.h_al, &pnp_req, &h_pnp );\r
@@ -1421,8 +1425,11 @@ __init_root()
                return FALSE;\r
 \r
        /* Open the CA. */\r
-       status = ib_open_ca( g_root.h_al, g_root.ca_guid,\r
-               __ca_async_event_cb, &g_root, &g_root.h_ca );\r
+       status = ib_open_ca( g_root.h_al,\r
+                                                g_root.ca_guid,\r
+                                                (ib_pfn_event_cb_t)__ca_async_event_cb,\r
+                                                &g_root,\r
+                                                &g_root.h_ca );\r
        if( status != IB_SUCCESS )\r
        {\r
                printf( "ib_open_ca failed [%s]!\n", ib_get_err_str(status) );\r
@@ -1471,7 +1478,7 @@ static void
 __cleanup()\r
 {\r
        if( g_root.h_listen )\r
-               ib_cm_cancel( g_root.h_listen, __cancel_listen_cb );\r
+               ib_cm_cancel( g_root.h_listen, (ib_pfn_destroy_cb_t)__cancel_listen_cb );\r
 \r
        /* Close AL if it was opened. */\r
        if( g_root.h_al )\r
@@ -1506,12 +1513,15 @@ __listen()
        /* The server side listens. */\r
        cm_listen.svc_id = CMT_BASE_SVC_ID + g_root.inst_id;\r
 \r
-       cm_listen.pfn_cm_req_cb = __req_cb;\r
+       cm_listen.pfn_cm_req_cb = (ib_pfn_cm_req_cb_t)__req_cb;\r
 \r
        cm_listen.qp_type = IB_QPT_RELIABLE_CONN;\r
 \r
-       status = ib_cm_listen( g_root.h_al, &cm_listen, \r
-               __cm_listen_err_cb, &g_root, &g_root.h_listen );\r
+       status = ib_cm_listen( g_root.h_al,\r
+                                                  &cm_listen, \r
+                                                  (ib_pfn_listen_err_cb_t)__cm_listen_err_cb,\r
+                                                  &g_root,\r
+                                                  &g_root.h_listen );\r
        if( status != IB_SUCCESS )\r
        {\r
                printf( "ib_cm_listen failed [%s]!\n", ib_get_err_str(status) );\r
@@ -1696,7 +1706,8 @@ __disconnect()
 \r
        if( g_root.h_listen )\r
        {\r
-               ib_cm_cancel( g_root.h_listen, __cancel_listen_cb );\r
+               ib_cm_cancel( g_root.h_listen,\r
+                                         (const ib_pfn_destroy_cb_t)__cancel_listen_cb );\r
                g_root.h_listen = NULL;\r
        }\r
        /* Calculate the total connection time. */\r
@@ -1919,6 +1930,7 @@ __poll_recv_cqs()
 \r
 /**********************************************************************\r
  **********************************************************************/\r
+\r
 int __cdecl\r
 main(\r
        int                                                     argc,\r
@@ -2014,8 +2026,16 @@ main(
                g_root.state = test_idle;\r
 \r
                printf( "Data transfer time: %"PRId64" ms, %d messages/conn, "\r
-                       "%"PRId64" total bytes\n", total_time/1000,\r
+                       "%"PRId64" total bytes", total_time/1000,\r
                        g_root.num_msgs, total_xfer );\r
+               if ( total_xfer > (4*1024*1024) )\r
+               {\r
+                       double mb;\r
+                       mb = ((double)total_xfer / (1024.0*1024.0))\r
+                               / ((double)total_time / 1000000.0);\r
+                       printf(" %4.2f MB/s",mb);\r
+               }\r
+               printf("\n");\r
 \r
                /* Disconnect all connections. */\r
                __disconnect();\r