[WSD] This patch removes the dependency of WSD on DAPL ATS, and reduces connection...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 3 Jul 2008 08:31:57 +0000 (08:31 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 3 Jul 2008 08:31:57 +0000 (08:31 +0000)
Signed-off-by: Fab Tillier <ftillier@microsoft.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1332 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

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

index 9da1354..8672f54 100644 (file)
@@ -32,10 +32,12 @@ USER_C_FLAGS=$(USER_C_FLAGS) -DCL_NO_TRACK_MEM -DPERFMON_ENABLED -DWPP_OLDCC
 \r
 TARGETLIBS=\\r
                        $(SDK_LIB_PATH)\kernel32.lib \\r
+                       $(SDK_LIB_PATH)\Advapi32.lib \\r
                        $(SDK_LIB_PATH)\ws2_32.lib \\r
+                       $(SDK_LIB_PATH)\iphlpapi.lib \\r
                        $(SDK_LIB_PATH)\rpcrt4.lib \\r
-                       $(SDK_LIB_PATH)\Advapi32.lib \\r
                        $(SDK_LIB_PATH)\LoadPerf.lib \\r
+                       $(TARGETPATH)\*\ibat.lib \\r
 !if $(FREEBUILD)\r
                        $(TARGETPATH)\*\complib.lib \\r
                        $(TARGETPATH)\*\ibal.lib\r
index 3deaf89..3b34fed 100644 (file)
@@ -104,8 +104,10 @@ setup_duplicate_socket(
        }\r
 \r
        /* Get the GUID for the remote IP address. */\r
-       ret = query_guid_address( socket_info->port,\r
-               socket_info->peer_addr.sin_addr.S_un.S_addr, &dest_port_guid );\r
+       ret = query_guid_address(\r
+        (struct sockaddr*)&socket_info->local_addr,\r
+        (struct sockaddr*)&socket_info->peer_addr,\r
+        &dest_port_guid );\r
        if( ret )\r
        {\r
                IBSP_ERROR( ("query_guid_address failed for IP %08x\n",\r
index 5581b05..97d1410 100644 (file)
@@ -43,6 +43,7 @@
 #endif\r
 \r
 #include "ibspdll.h"\r
+#include "iba/ibat.h"\r
 \r
 /*--------------------------------------------------------------------------*/\r
 \r
@@ -257,123 +258,42 @@ update_ip_addresses(
 \r
 /*--------------------------------------------------------------------------*/\r
 \r
-/* \r
- * Query a GUID from an IP address\r
- */\r
-\r
-struct query_guid_context\r
-{\r
-       ib_api_status_t status;\r
-       ib_net64_t guid;\r
-};\r
-\r
-static void AL_API\r
-query_guid_callback(\r
-                                       ib_query_rec_t                          *p_query_rec )\r
-{\r
-       struct query_guid_context *query_context =\r
-               (struct query_guid_context *)p_query_rec->query_context;\r
-       ib_service_record_t *service_record;\r
-\r
-       IBSP_ENTER( IBSP_DBG_HW );\r
-       IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
-               ("status is %d, count is %d\n", p_query_rec->status,\r
-               p_query_rec->result_cnt) );\r
-\r
-       if( p_query_rec->status == IB_SUCCESS && p_query_rec->result_cnt )\r
-       {\r
-               query_context->status = IB_SUCCESS;\r
-\r
-               service_record = ib_get_query_svc_rec( p_query_rec->p_result_mad, 0 );\r
-\r
-               CL_ASSERT( service_record != NULL );\r
-\r
-               query_context->guid = ib_gid_get_guid( &service_record->service_gid );\r
-       }\r
-       else\r
-       {\r
-               query_context->status = IB_ERROR;\r
-       }\r
-\r
-       if( p_query_rec->p_result_mad )\r
-               ib_put_mad( p_query_rec->p_result_mad );\r
-\r
-       IBSP_EXIT( IBSP_DBG_HW );\r
-}\r
-\r
 \r
 /* Synchronously query the SA for a GUID. Return 0 on success. */\r
 int\r
 query_guid_address(\r
-       IN                              struct ibsp_port                        *port,\r
-       IN                              ib_net32_t                                      ip_addr,\r
+       IN                              const struct sockaddr           *p_src_addr,\r
+       IN                              const struct sockaddr           *p_dest_addr,\r
                OUT                     ib_net64_t                                      *port_guid )\r
 {\r
-       ib_user_query_t user_query;\r
-       struct query_guid_context query_context;\r
-       ib_service_record_t service_record;\r
-       ib_query_handle_t query_handle;\r
-       ib_query_req_t query_req;\r
-       ib_api_status_t status;\r
+       ib_gid_pair_t gids;\r
+       uint16_t pkey;\r
+       HRESULT hr;\r
 \r
        IBSP_ENTER( IBSP_DBG_HW );\r
 \r
-       query_req.query_type = IB_QUERY_USER_DEFINED;\r
-       query_req.p_query_input = &user_query;\r
-       query_req.port_guid = port->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_guid_callback;\r
-\r
-       /* TODO: which method one is correct? */\r
-       user_query.method = IB_MAD_METHOD_GETTABLE;\r
-       //user_query.method = IB_MAD_METHOD_GET;\r
-       user_query.attr_id = IB_MAD_ATTR_SERVICE_RECORD;\r
-       user_query.attr_size = sizeof(ib_service_record_t);\r
-       user_query.comp_mask =\r
-               IB_SR_COMPMASK_SPKEY |\r
-               IB_SR_COMPMASK_SLEASE |\r
-               IB_SR_COMPMASK_SNAME |\r
-               IB_SR_COMPMASK_SDATA8_12 |\r
-               IB_SR_COMPMASK_SDATA8_13 | IB_SR_COMPMASK_SDATA8_14 | IB_SR_COMPMASK_SDATA8_15;\r
-\r
-       user_query.p_attr = &service_record;\r
-\r
-       memset( &service_record, 0, sizeof(service_record) );\r
-       service_record.service_pkey = cl_hton16( IB_DEFAULT_PKEY );\r
-       service_record.service_data8[12] = (uint8_t) (ip_addr >> 0);\r
-       service_record.service_data8[13] = (uint8_t) (ip_addr >> 8);\r
-       service_record.service_data8[14] = (uint8_t) (ip_addr >> 16);\r
-       service_record.service_data8[15] = (uint8_t) (ip_addr >> 24);\r
-       service_record.service_lease = 0xFFFFFFFF;\r
-       strcpy( (void*)service_record.service_name, ATS_NAME );\r
-\r
-       status = ib_query( g_ibsp.al_handle, &query_req, &query_handle );\r
-\r
-       if( status != IB_SUCCESS )\r
+       for(;;)\r
        {\r
-               IBSP_ERROR( ("ib_query failed (%d)\n", status) );\r
-               goto error;\r
-       }\r
+               hr = IbatResolve(\r
+                       p_src_addr,\r
+                       p_dest_addr,\r
+                       (IN6_ADDR*)&gids.src_gid,\r
+                       (IN6_ADDR*)&gids.dest_gid,\r
+                       &pkey\r
+                       );\r
+\r
+               if( hr != E_PENDING )\r
+                       break;\r
 \r
-       if( query_context.status != IB_SUCCESS )\r
-       {\r
-               IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,\r
-                       ("query success, but no GUID for IP address %x (query status %d)\n",\r
-                       ip_addr, query_context.status) );\r
-               goto error;\r
+                       Sleep( 100 );\r
        }\r
+       if( hr == S_OK )\r
+               *port_guid = gids.dest_gid.unicast.interface_id;\r
 \r
-       *port_guid = query_context.guid;\r
-\r
-       IBSP_EXIT( IBSP_DBG_HW );\r
-       return 0;\r
+       IBSP_ERROR( ("IBAT::Resolve failed for IP %08x\n",\r
+               ((struct sockaddr_in*)p_dest_addr)->sin_addr.s_addr) );\r
 \r
-error:\r
-       IBSP_ERROR_EXIT( ("query_ip_address failed\n") );\r
-       return 1;\r
+       return hr;\r
 }\r
 \r
 /*--------------------------------------------------------------------------*/\r
index 74467cc..190249a 100644 (file)
@@ -854,7 +854,8 @@ IBSPConnect(
        }\r
 \r
        /* Get the GUID for that IP address. */\r
-       ret = query_guid_address( socket_info->port, addr->sin_addr.s_addr, &dest_port_guid );\r
+       ret = query_guid_address(\r
+        (struct sockaddr*)&socket_info->local_addr, name, &dest_port_guid );\r
        if( ret )\r
        {\r
                IBSP_ERROR_EXIT( ("query_guid_address failed for IP %08x\n",\r
index d2f67dc..4df6d7b 100644 (file)
@@ -159,8 +159,8 @@ ip_cmp(
 \r
 int\r
 query_guid_address(\r
-       IN                              struct ibsp_port                        *port,\r
-       IN                              ib_net32_t                                      ip_addr,\r
+       IN                              const struct sockaddr           *p_src_addr,\r
+       IN                              const struct sockaddr           *p_dest_addr,\r
                OUT                     ib_net64_t                                      *port_guid );\r
 \r
 int\r