[ofw] [PATCH] Make WSD use new IBAT library
Fab Tillier
ftillier at windows.microsoft.com
Wed Jul 2 12:01:12 PDT 2008
This patch obviously depends on the IBAT library patch.
It removes the dependency of WSD on DAPL ATS, and reduces connection establishment SA queries from 2 (ATS query + PR query) to 1 (PR query).
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
diff -up -N -r -X trunk\docs\dontdiff.txt -I \$Id: old\ulp\wsd\user\ibsp_duplicate.c trunk\ulp\wsd\user\ibsp_duplicate.c
--- old\ulp\wsd\user\ibsp_duplicate.c Thu Jun 26 20:35:13 2008
+++ trunk\ulp\wsd\user\ibsp_duplicate.c Wed Jul 02 11:57:30 2008
@@ -104,8 +104,10 @@ setup_duplicate_socket(
}
/* Get the GUID for the remote IP address. */
- ret = query_guid_address( socket_info->port,
- socket_info->peer_addr.sin_addr.S_un.S_addr, &dest_port_guid );
+ ret = query_guid_address(
+ (struct sockaddr*)&socket_info->local_addr,
+ (struct sockaddr*)&socket_info->peer_addr,
+ &dest_port_guid );
if( ret )
{
IBSP_ERROR( ("query_guid_address failed for IP %08x\n",
diff -up -N -r -X trunk\docs\dontdiff.txt -I \$Id: old\ulp\wsd\user\ibsp_ip.c trunk\ulp\wsd\user\ibsp_ip.c
--- old\ulp\wsd\user\ibsp_ip.c Mon Jun 30 11:07:49 2008
+++ trunk\ulp\wsd\user\ibsp_ip.c Wed Jul 02 11:57:30 2008
@@ -43,6 +43,7 @@
#endif
#include "ibspdll.h"
+#include "iba/ibat.h"
/*--------------------------------------------------------------------------*/
@@ -257,123 +258,42 @@ update_ip_addresses(
/*--------------------------------------------------------------------------*/
-/*
- * Query a GUID from an IP address
- */
-
-struct query_guid_context
-{
- ib_api_status_t status;
- ib_net64_t guid;
-};
-
-static void AL_API
-query_guid_callback(
- ib_query_rec_t *p_query_rec )
-{
- struct query_guid_context *query_context =
- (struct query_guid_context *)p_query_rec->query_context;
- ib_service_record_t *service_record;
-
- IBSP_ENTER( IBSP_DBG_HW );
- IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,
- ("status is %d, count is %d\n", p_query_rec->status,
- p_query_rec->result_cnt) );
-
- if( p_query_rec->status == IB_SUCCESS && p_query_rec->result_cnt )
- {
- query_context->status = IB_SUCCESS;
-
- service_record = ib_get_query_svc_rec( p_query_rec->p_result_mad, 0 );
-
- CL_ASSERT( service_record != NULL );
-
- query_context->guid = ib_gid_get_guid( &service_record->service_gid );
- }
- else
- {
- query_context->status = IB_ERROR;
- }
-
- if( p_query_rec->p_result_mad )
- ib_put_mad( p_query_rec->p_result_mad );
-
- IBSP_EXIT( IBSP_DBG_HW );
-}
-
/* Synchronously query the SA for a GUID. Return 0 on success. */
int
query_guid_address(
- IN struct ibsp_port *port,
- IN ib_net32_t ip_addr,
+ IN const struct sockaddr *p_src_addr,
+ IN const struct sockaddr *p_dest_addr,
OUT ib_net64_t *port_guid )
{
- ib_user_query_t user_query;
- struct query_guid_context query_context;
- ib_service_record_t service_record;
- ib_query_handle_t query_handle;
- ib_query_req_t query_req;
- ib_api_status_t status;
+ ib_gid_pair_t gids;
+ uint16_t pkey;
+ HRESULT hr;
IBSP_ENTER( IBSP_DBG_HW );
- query_req.query_type = IB_QUERY_USER_DEFINED;
- query_req.p_query_input = &user_query;
- query_req.port_guid = port->guid;
- query_req.timeout_ms = g_sa_timeout;
- query_req.retry_cnt = g_sa_retries;
- query_req.flags = IB_FLAGS_SYNC;
- query_req.query_context = &query_context;
- query_req.pfn_query_cb = query_guid_callback;
-
- /* TODO: which method one is correct? */
- user_query.method = IB_MAD_METHOD_GETTABLE;
- //user_query.method = IB_MAD_METHOD_GET;
- user_query.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- user_query.attr_size = sizeof(ib_service_record_t);
- user_query.comp_mask =
- IB_SR_COMPMASK_SPKEY |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SNAME |
- IB_SR_COMPMASK_SDATA8_12 |
- IB_SR_COMPMASK_SDATA8_13 | IB_SR_COMPMASK_SDATA8_14 | IB_SR_COMPMASK_SDATA8_15;
-
- user_query.p_attr = &service_record;
-
- memset( &service_record, 0, sizeof(service_record) );
- service_record.service_pkey = cl_hton16( IB_DEFAULT_PKEY );
- service_record.service_data8[12] = (uint8_t) (ip_addr >> 0);
- service_record.service_data8[13] = (uint8_t) (ip_addr >> 8);
- service_record.service_data8[14] = (uint8_t) (ip_addr >> 16);
- service_record.service_data8[15] = (uint8_t) (ip_addr >> 24);
- service_record.service_lease = 0xFFFFFFFF;
- strcpy( (void*)service_record.service_name, ATS_NAME );
-
- status = ib_query( g_ibsp.al_handle, &query_req, &query_handle );
-
- if( status != IB_SUCCESS )
+ for(;;)
{
- IBSP_ERROR( ("ib_query failed (%d)\n", status) );
- goto error;
- }
+ hr = IbatResolve(
+ p_src_addr,
+ p_dest_addr,
+ (IN6_ADDR*)&gids.src_gid,
+ (IN6_ADDR*)&gids.dest_gid,
+ &pkey
+ );
- if( query_context.status != IB_SUCCESS )
- {
- IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,
- ("query success, but no GUID for IP address %x (query status %d)\n",
- ip_addr, query_context.status) );
- goto error;
- }
+ if( hr != E_PENDING )
+ break;
- *port_guid = query_context.guid;
+ Sleep( 100 );
+ }
+ if( hr == S_OK )
+ *port_guid = gids.dest_gid.unicast.interface_id;
- IBSP_EXIT( IBSP_DBG_HW );
- return 0;
+ IBSP_ERROR( ("IBAT::Resolve failed for IP %08x\n",
+ ((struct sockaddr_in*)p_dest_addr)->sin_addr.s_addr) );
-error:
- IBSP_ERROR_EXIT( ("query_ip_address failed\n") );
- return 1;
+ return hr;
}
/*--------------------------------------------------------------------------*/
diff -up -N -r -X trunk\docs\dontdiff.txt -I \$Id: old\ulp\wsd\user\ibspdll.c trunk\ulp\wsd\user\ibspdll.c
--- old\ulp\wsd\user\ibspdll.c Mon Jun 30 11:07:49 2008
+++ trunk\ulp\wsd\user\ibspdll.c Wed Jul 02 11:57:30 2008
@@ -854,7 +854,8 @@ IBSPConnect(
}
/* Get the GUID for that IP address. */
- ret = query_guid_address( socket_info->port, addr->sin_addr.s_addr, &dest_port_guid );
+ ret = query_guid_address(
+ (struct sockaddr*)&socket_info->local_addr, name, &dest_port_guid );
if( ret )
{
IBSP_ERROR_EXIT( ("query_guid_address failed for IP %08x\n",
diff -up -N -r -X trunk\docs\dontdiff.txt -I \$Id: old\ulp\wsd\user\ibspproto.h trunk\ulp\wsd\user\ibspproto.h
--- old\ulp\wsd\user\ibspproto.h Mon Jun 30 11:07:49 2008
+++ trunk\ulp\wsd\user\ibspproto.h Wed Jul 02 11:57:30 2008
@@ -159,8 +159,8 @@ ip_cmp(
int
query_guid_address(
- IN struct ibsp_port *port,
- IN ib_net32_t ip_addr,
+ IN const struct sockaddr *p_src_addr,
+ IN const struct sockaddr *p_dest_addr,
OUT ib_net64_t *port_guid );
int
diff -up -N -r -X trunk\docs\dontdiff.txt -I \$Id: old\ulp\wsd\user\SOURCES trunk\ulp\wsd\user\SOURCES
--- old\ulp\wsd\user\SOURCES Thu Jun 26 20:35:13 2008
+++ trunk\ulp\wsd\user\SOURCES Wed Jul 02 11:57:30 2008
@@ -32,10 +32,12 @@ USER_C_FLAGS=$(USER_C_FLAGS) -DCL_NO_TRA
TARGETLIBS=\
$(SDK_LIB_PATH)\kernel32.lib \
+ $(SDK_LIB_PATH)\Advapi32.lib \
$(SDK_LIB_PATH)\ws2_32.lib \
+ $(SDK_LIB_PATH)\iphlpapi.lib \
$(SDK_LIB_PATH)\rpcrt4.lib \
- $(SDK_LIB_PATH)\Advapi32.lib \
$(SDK_LIB_PATH)\LoadPerf.lib \
+ $(TARGETPATH)\*\ibat.lib \
!if $(FREEBUILD)
$(TARGETPATH)\*\complib.lib \
$(TARGETPATH)\*\ibal.lib
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wsd_ibat.patch
Type: application/octet-stream
Size: 7051 bytes
Desc: wsd_ibat.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080702/d49340b2/attachment.obj>
More information about the ofw
mailing list