[WSD] Add basic support for APM to wsd.
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 24 Sep 2009 09:05:23 +0000 (09:05 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 24 Sep 2009 09:05:23 +0000 (09:05 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2465 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/wsd/user/ib_cm.c
ulp/wsd/user/ibsp_duplicate.c
ulp/wsd/user/ibsp_ip.c
ulp/wsd/user/ibspdll.c
ulp/wsd/user/ibspdll.h
ulp/wsd/user/ibspproto.h

index d883e84..7ecf321 100644 (file)
@@ -745,7 +745,9 @@ ib_listen_cancel(
 int\r
 ib_connect(\r
        IN                              struct ibsp_socket_info         *socket_info,\r
-       IN                              ib_path_rec_t                           *path_rec )\r
+       IN                              ib_path_rec_t                           *path_rec, \r
+       IN                              ib_path_rec_t                           *alt_path_rec )\r
+\r
 {\r
        ib_cm_req_t cm_req;\r
        ib_api_status_t status;\r
@@ -773,6 +775,7 @@ ib_connect(
        cm_req.svc_id = get_service_id_for_port( socket_info->peer_addr.sin_port );\r
        cm_req.max_cm_retries = g_max_cm_retries;\r
        cm_req.p_primary_path = path_rec;\r
+       cm_req.p_alt_path = alt_path_rec;\r
        cm_req.pfn_cm_rep_cb = cm_rep_callback;\r
 \r
        cm_req.p_req_pdata = (uint8_t *) & params;\r
@@ -814,7 +817,6 @@ ib_connect(
        cm_req.rnr_nak_timeout = QP_ATTRIB_RNR_NAK_TIMEOUT;\r
        cm_req.rnr_retry_cnt = QP_ATTRIB_RNR_RETRY;\r
        cm_req.retry_cnt = g_qp_retries;\r
-       cm_req.p_alt_path = NULL;\r
        cm_req.pfn_cm_mra_cb = cm_mra_callback;\r
        cm_req.pfn_cm_rej_cb = cm_rej_callback;\r
 \r
@@ -884,7 +886,7 @@ ib_accept(
 #endif\r
        cm_rep.init_depth = QP_ATTRIB_INITIATOR_DEPTH;\r
        cm_rep.target_ack_delay = 10;\r
-       cm_rep.failover_accepted = IB_FAILOVER_ACCEPT_UNSUPPORTED;\r
+       cm_rep.failover_accepted = g_use_APM ? IB_FAILOVER_ACCEPT_SUCCESS : IB_FAILOVER_ACCEPT_UNSUPPORTED;\r
        cm_rep.flow_ctrl = cm_req_received->flow_ctrl;\r
        cm_rep.rnr_nak_timeout = QP_ATTRIB_RNR_NAK_TIMEOUT;\r
        cm_rep.rnr_retry_cnt = cm_req_received->rnr_retry_cnt;\r
index 6a1e142..0a5d35a 100644 (file)
@@ -75,6 +75,7 @@ setup_duplicate_socket(
        struct ibsp_duplicate_info *dup_info;\r
        ib_net64_t dest_port_guid;\r
        ib_path_rec_t path_rec;\r
+       ib_path_rec_t alt_path_rec, *palt_path_rec = NULL;\r
 \r
        IBSP_ENTER( IBSP_DBG_DUP );\r
 \r
@@ -118,7 +119,7 @@ setup_duplicate_socket(
        }\r
 \r
        /* Get the path record */\r
-       ret = query_pr( socket_info->port, dest_port_guid, &path_rec );\r
+       ret = query_pr( socket_info->port->guid, dest_port_guid, socket_info->port->hca->dev_id, &path_rec );\r
        if( ret )\r
        {\r
                IBSP_ERROR( ("query_pr failed for IP %08x\n",\r
@@ -126,6 +127,21 @@ setup_duplicate_socket(
                ret = WSAENETDOWN;\r
                goto err1;\r
        }\r
+       /* Get the alternate path record */\r
+       if (g_use_APM) \r
+       {\r
+               ret = query_pr(GetOtherPortGuid(socket_info->port->guid), GetOtherPortGuid(dest_port_guid), socket_info->port->hca->dev_id, &alt_path_rec );\r
+               if( ret )\r
+               {       \r
+                       // We can ignore a failure here, since APM is not a MUST\r
+                       IBSP_ERROR( ("QPR for alternate path failed (error ignored)\n") );\r
+               }\r
+               else \r
+               {\r
+                       palt_path_rec = &alt_path_rec;\r
+               }\r
+       }\r
+\r
 \r
        IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DUPLICATING_NEW );\r
        socket_info->h_event = CreateEvent( NULL, FALSE, FALSE, NULL );\r
@@ -143,7 +159,7 @@ setup_duplicate_socket(
        }\r
 \r
        /* Connects the QP. */\r
-       ret = ib_connect( socket_info, &path_rec );\r
+       ret = ib_connect( socket_info, &path_rec, palt_path_rec );\r
        if( ret != WSAEWOULDBLOCK )\r
        {\r
                IBSP_ERROR( ("ib_connect failed (%d)\n", ret) );\r
index 0b47c28..143b5b7 100644 (file)
@@ -347,8 +347,9 @@ query_pr_callback(
 /* Synchronously query the SA for a GUID. Return 0 on success. */\r
 int\r
 query_pr(\r
-       IN                              struct ibsp_port                        *port,\r
+       IN                              ib_net64_t                                      guid,\r
        IN                              ib_net64_t                                      dest_port_guid,\r
+       IN                              uint16_t                                        dev_id,\r
                OUT                     ib_path_rec_t                           *path_rec )\r
 {\r
        ib_gid_pair_t user_query;\r
@@ -362,14 +363,14 @@ query_pr(
 \r
        query_req.query_type = IB_QUERY_PATH_REC_BY_GIDS;\r
        query_req.p_query_input = &user_query;\r
-       query_req.port_guid = port->guid;\r
+       query_req.port_guid = guid;\r
        query_req.timeout_ms = g_sa_timeout;\r
        query_req.retry_cnt = g_sa_retries;\r
        query_req.flags = IB_FLAGS_SYNC;\r
        query_req.query_context = &query_context;\r
        query_req.pfn_query_cb = query_pr_callback;\r
 \r
-       ib_gid_set_default( &user_query.src_gid, port->guid );\r
+       ib_gid_set_default( &user_query.src_gid, guid );\r
        ib_gid_set_default( &user_query.dest_gid, dest_port_guid );\r
 \r
        query_context.path_rec = path_rec;\r
@@ -379,7 +380,7 @@ query_pr(
 \r
        IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
                ("Query for path from %I64x to %I64x\n",\r
-               port->guid, dest_port_guid) );\r
+               guid , dest_port_guid) );\r
 \r
        status = ib_query( g_ibsp.al_handle, &query_req, &query_handle );\r
 \r
@@ -398,7 +399,7 @@ query_pr(
                goto error;\r
        }\r
 \r
-       if( (port->hca->dev_id == 0x5A44) &&\r
+       if( (dev_id == 0x5A44) &&\r
                (ib_path_rec_mtu( path_rec ) > IB_MTU_LEN_1024) )\r
        {\r
                /* Local endpoint is Tavor - cap MTU to 1K for extra bandwidth. */\r
@@ -406,7 +407,7 @@ query_pr(
                path_rec->mtu |= IB_MTU_LEN_1024;\r
        }\r
 \r
-       pkt_life = ib_path_rec_pkt_life( path_rec ) + g_pkt_life_modifier;\r
+       pkt_life = ib_path_rec_pkt_life( path_rec )  + g_pkt_life_modifier;\r
        if( pkt_life > 0x1F )\r
                pkt_life = 0x1F;\r
 \r
index 190249a..15e5447 100644 (file)
@@ -65,8 +65,9 @@ uint32_t              g_sa_timeout = 500;
 uint32_t               g_sa_retries = 4;\r
 int                            g_connect_err = WSAEADDRNOTAVAIL;\r
 uint8_t                        g_max_cm_retries = CM_RETRIES;\r
-uint8_t                        g_pkt_life_modifier = 0;\r
+int8_t                 g_pkt_life_modifier = 0;\r
 uint8_t                        g_qp_retries = QP_ATTRIB_RETRY_COUNT;\r
+uint8_t                        g_use_APM = 0;\r
 DWORD_PTR              g_dwPollThreadAffinityMask = 0;\r
 \r
 uint32_t                               g_ibsp_dbg_level = TRACE_LEVEL_ERROR;\r
@@ -205,7 +206,7 @@ _DllMain(
                i = GetEnvironmentVariable( "IBWSD_PKT_LIFE", env_var, sizeof(env_var) );\r
                if( i && i <= 16 )\r
                {\r
-                       g_pkt_life_modifier = (uint8_t)_tcstoul( env_var, NULL, 0 );\r
+                       g_pkt_life_modifier = (int8_t)_tcstoul( env_var, NULL, 0 );\r
                        if( g_pkt_life_modifier > 0x1F )\r
                                g_pkt_life_modifier = 0x1F;\r
                }\r
@@ -218,6 +219,12 @@ _DllMain(
                                g_qp_retries = 7;\r
                }\r
 \r
+               i = GetEnvironmentVariable( "IBWSD_USE_APM", env_var, sizeof(env_var) );\r
+               if( i && i <= 16 )\r
+               {\r
+                       g_use_APM = (uint8_t)_tcstoul( env_var, NULL, 0 );\r
+               }\r
+\r
                if( init_globals() )\r
                        return FALSE;\r
 \r
@@ -804,6 +811,8 @@ IBSPConnect(
        int ret;\r
        ib_net64_t dest_port_guid;\r
        ib_path_rec_t path_rec;\r
+       ib_path_rec_t alt_path_rec, *palt_path_rec = NULL;\r
+\r
 \r
        IBSP_ENTER( IBSP_DBG_CONN );\r
 \r
@@ -875,7 +884,7 @@ IBSPConnect(
        }\r
 \r
        /* Get the path record */\r
-       ret = query_pr( socket_info->port, dest_port_guid, &path_rec );\r
+       ret = query_pr( socket_info->port->guid, dest_port_guid,socket_info->port->hca->dev_id, &path_rec );\r
        if( ret )\r
        {\r
                IBSP_ERROR_EXIT( (\r
@@ -883,6 +892,21 @@ IBSPConnect(
                *lpErrno = g_connect_err;\r
                return SOCKET_ERROR;\r
        }\r
+               /* Get the alternate path record */\r
+       if (g_use_APM) \r
+       {\r
+               ret = query_pr(GetOtherPortGuid(socket_info->port->guid), GetOtherPortGuid(dest_port_guid), socket_info->port->hca->dev_id, &alt_path_rec );\r
+               if( ret )\r
+               {       \r
+                       // We can ignore a failure here, since APM is not a MUST\r
+                       IBSP_ERROR( ("QPR for alternate path failed (error ignored)\n") );\r
+               }\r
+               else \r
+               {\r
+                       palt_path_rec = &alt_path_rec;\r
+               }\r
+       }\r
+       \r
 \r
        cl_spinlock_acquire( &socket_info->mutex1 );\r
 \r
@@ -924,7 +948,7 @@ IBSPConnect(
        IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CONNECT );\r
 \r
        /* Connect */\r
-       *lpErrno = ib_connect( socket_info, &path_rec );\r
+       *lpErrno = ib_connect( socket_info, &path_rec, palt_path_rec );\r
        if( *lpErrno != WSAEWOULDBLOCK )\r
        {\r
                /* We must be sure none destroyed our socket */\r
index 570a64a..ce3a0af 100644 (file)
@@ -66,7 +66,9 @@ extern DWORD_PTR      g_dwPollThreadAffinityMask;
 /* Allow users to control SA timeouts behavior - fall back on IPoIB or fail. */\r
 extern int                     g_connect_err;\r
 extern uint8_t         g_max_cm_retries;\r
-extern uint8_t         g_pkt_life_modifier;\r
+extern int8_t          g_pkt_life_modifier;\r
 extern uint8_t         g_qp_retries;\r
+extern uint8_t         g_use_APM;\r
+\r
 \r
 #endif /* IBSPDLL_H */\r
index 4df6d7b..4189fd0 100644 (file)
@@ -165,9 +165,10 @@ query_guid_address(
 \r
 int\r
 query_pr(\r
-       IN                              struct ibsp_port                        *port,\r
+       IN                              ib_net64_t                                      guid,\r
        IN                              ib_net64_t                                      dest_port_guid,\r
-               OUT                     ib_path_rec_t                           *path_rec );\r
+       IN                              uint16_t                                        dev_id,\r
+       OUT                     ib_path_rec_t                                   *path_rec );\r
 \r
 int\r
 build_ip_list(\r
@@ -201,7 +202,8 @@ ib_accept(
 int\r
 ib_connect(\r
        IN                              struct ibsp_socket_info         *socket_info,\r
-       IN                              ib_path_rec_t                           *path_rec );\r
+       IN                              ib_path_rec_t                           *path_rec, \r
+       IN                              ib_path_rec_t                           *alt_path_rec );\r
 \r
 void\r
 ib_disconnect(\r
@@ -296,3 +298,10 @@ init_globals( void );
 \r
 extern void\r
 release_globals( void );\r
+\r
+inline ib_net64_t GetOtherPortGuid(ib_net64_t DestPortGuid)\r
+{\r
+       return DestPortGuid ^ 0x300000000000000;\r
+\r
+}\r
+\r