[ofw] patch: [WSD] Add basic support for APM to WSD.

Tzachi Dar tzachid at mellanox.co.il
Wed Sep 16 09:06:01 PDT 2009


This patch allows WSD to use basic support for APM. (no fail back
support)
 
The patch assumes that the two machines that are talking can reach other
on both ports.
 
In order to activate APM one has to set the following environment
variable on both sides:
 
set IBWSD_USE_APM=1
 
Thanks
Tzachi
 
 
 
Index: Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspdll.h
===================================================================
--- Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspdll.h
(revision 4824)
+++ Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspdll.h
(revision 4825)
@@ -66,7 +66,9 @@
 /* Allow users to control SA timeouts behavior - fall back on IPoIB or
fail. */
 extern int   g_connect_err;
 extern uint8_t  g_max_cm_retries;
-extern uint8_t  g_pkt_life_modifier;
+extern int8_t  g_pkt_life_modifier;
 extern uint8_t  g_qp_retries;
+extern uint8_t  g_use_APM;
 
+
 #endif /* IBSPDLL_H */
Index: Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ib_cm.c
===================================================================
--- Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ib_cm.c (revision
4824)
+++ Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ib_cm.c (revision
4825)
@@ -745,7 +745,9 @@
 int
 ib_connect(
  IN    struct ibsp_socket_info  *socket_info,
- IN    ib_path_rec_t    *path_rec )
+ IN    ib_path_rec_t    *path_rec, 
+ IN    ib_path_rec_t    *alt_path_rec )
+
 {
  ib_cm_req_t cm_req;
  ib_api_status_t status;
@@ -773,6 +775,7 @@
  cm_req.svc_id = get_service_id_for_port(
socket_info->peer_addr.sin_port );
  cm_req.max_cm_retries = g_max_cm_retries;
  cm_req.p_primary_path = path_rec;
+ cm_req.p_alt_path = alt_path_rec;
  cm_req.pfn_cm_rep_cb = cm_rep_callback;
 
  cm_req.p_req_pdata = (uint8_t *) & params;
@@ -814,7 +817,6 @@
  cm_req.rnr_nak_timeout = QP_ATTRIB_RNR_NAK_TIMEOUT;
  cm_req.rnr_retry_cnt = QP_ATTRIB_RNR_RETRY;
  cm_req.retry_cnt = g_qp_retries;
- cm_req.p_alt_path = NULL;
  cm_req.pfn_cm_mra_cb = cm_mra_callback;
  cm_req.pfn_cm_rej_cb = cm_rej_callback;
 
@@ -884,7 +886,7 @@
 #endif
  cm_rep.init_depth = QP_ATTRIB_INITIATOR_DEPTH;
  cm_rep.target_ack_delay = 10;
- cm_rep.failover_accepted = IB_FAILOVER_ACCEPT_UNSUPPORTED;
+ cm_rep.failover_accepted = g_use_APM ? IB_FAILOVER_ACCEPT_SUCCESS :
IB_FAILOVER_ACCEPT_UNSUPPORTED;
  cm_rep.flow_ctrl = cm_req_received->flow_ctrl;
  cm_rep.rnr_nak_timeout = QP_ATTRIB_RNR_NAK_TIMEOUT;
  cm_rep.rnr_retry_cnt = cm_req_received->rnr_retry_cnt;
Index: Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibsp_ip.c
===================================================================
--- Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibsp_ip.c
(revision 4824)
+++ Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibsp_ip.c
(revision 4825)
@@ -347,8 +347,9 @@
 /* Synchronously query the SA for a GUID. Return 0 on success. */
 int
 query_pr(
- IN    struct ibsp_port   *port,
+ IN    ib_net64_t     guid,
  IN    ib_net64_t     dest_port_guid,
+ IN    uint16_t     dev_id,
   OUT   ib_path_rec_t    *path_rec )
 {
  ib_gid_pair_t user_query;
@@ -362,14 +363,14 @@
 
  query_req.query_type = IB_QUERY_PATH_REC_BY_GIDS;
  query_req.p_query_input = &user_query;
- query_req.port_guid = port->guid;
+ query_req.port_guid = 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_pr_callback;
 
- ib_gid_set_default( &user_query.src_gid, port->guid );
+ ib_gid_set_default( &user_query.src_gid, guid );
  ib_gid_set_default( &user_query.dest_gid, dest_port_guid );
 
  query_context.path_rec = path_rec;
@@ -379,7 +380,7 @@
 
  IBSP_PRINT(TRACE_LEVEL_INFORMATION, IBSP_DBG_HW,
   ("Query for path from %I64x to %I64x\n",
-  port->guid, dest_port_guid) );
+  guid , dest_port_guid) );
 
  status = ib_query( g_ibsp.al_handle, &query_req, &query_handle );
 
@@ -398,7 +399,7 @@
   goto error;
  }
 
- if( (port->hca->dev_id == 0x5A44) &&
+ if( (dev_id == 0x5A44) &&
   (ib_path_rec_mtu( path_rec ) > IB_MTU_LEN_1024) )
  {
   /* Local endpoint is Tavor - cap MTU to 1K for extra bandwidth. */
@@ -406,7 +407,7 @@
   path_rec->mtu |= IB_MTU_LEN_1024;
  }
 
- pkt_life = ib_path_rec_pkt_life( path_rec ) + g_pkt_life_modifier;
+ pkt_life = ib_path_rec_pkt_life( path_rec )  + g_pkt_life_modifier;
  if( pkt_life > 0x1F )
   pkt_life = 0x1F;
 
Index: Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspproto.h
===================================================================
--- Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspproto.h
(revision 4824)
+++ Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspproto.h
(revision 4825)
@@ -165,9 +165,10 @@
 
 int
 query_pr(
- IN    struct ibsp_port   *port,
+ IN    ib_net64_t     guid,
  IN    ib_net64_t     dest_port_guid,
-  OUT   ib_path_rec_t    *path_rec );
+ IN    uint16_t     dev_id,
+ OUT   ib_path_rec_t     *path_rec );
 
 int
 build_ip_list(
@@ -201,7 +202,8 @@
 int
 ib_connect(
  IN    struct ibsp_socket_info  *socket_info,
- IN    ib_path_rec_t    *path_rec );
+ IN    ib_path_rec_t    *path_rec, 
+ IN    ib_path_rec_t    *alt_path_rec );
 
 void
 ib_disconnect(
@@ -296,3 +298,10 @@
 
 extern void
 release_globals( void );
+
+inline ib_net64_t GetOtherPortGuid(ib_net64_t DestPortGuid)
+{
+ return DestPortGuid ^ 0x300000000000000;
+
+}
+
Index:
Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibsp_duplicate.c
===================================================================
--- Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibsp_duplicate.c
(revision 4824)
+++ Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibsp_duplicate.c
(revision 4825)
@@ -75,6 +75,7 @@
  struct ibsp_duplicate_info *dup_info;
  ib_net64_t dest_port_guid;
  ib_path_rec_t path_rec;
+ ib_path_rec_t alt_path_rec, *palt_path_rec = NULL;
 
  IBSP_ENTER( IBSP_DBG_DUP );
 
@@ -118,7 +119,7 @@
  }
 
  /* Get the path record */
- ret = query_pr( socket_info->port, dest_port_guid, &path_rec );
+ ret = query_pr( socket_info->port->guid, dest_port_guid,
socket_info->port->hca->dev_id, &path_rec );
  if( ret )
  {
   IBSP_ERROR( ("query_pr failed for IP %08x\n",
@@ -126,7 +127,22 @@
   ret = WSAENETDOWN;
   goto err1;
  }
+ /* Get the alternate path record */
+ if (g_use_APM) 
+ {
+  ret = query_pr(GetOtherPortGuid(socket_info->port->guid),
GetOtherPortGuid(dest_port_guid), socket_info->port->hca->dev_id,
&alt_path_rec );
+  if( ret )
+  { 
+   // We can ignore a failure here, since APM is not a MUST
+   IBSP_ERROR( ("QPR for alternate path failed (error ignored)\n") );
+  }
+  else 
+  {
+   palt_path_rec = &alt_path_rec;
+  }
+ }
 
+
  IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DUPLICATING_NEW );
  socket_info->h_event = CreateEvent( NULL, FALSE, FALSE, NULL );
  if( !socket_info->h_event )
@@ -143,7 +159,7 @@
  }
 
  /* Connects the QP. */
- ret = ib_connect( socket_info, &path_rec );
+ ret = ib_connect( socket_info, &path_rec, palt_path_rec );
  if( ret != WSAEWOULDBLOCK )
  {
   IBSP_ERROR( ("ib_connect failed (%d)\n", ret) );
Index: Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspdll.c
===================================================================
--- Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspdll.c
(revision 4824)
+++ Q:/projMLNX_WinOF_2.0/MLNX_WinOF_2-0/ulp/wsd/user/ibspdll.c
(revision 4825)
@@ -65,8 +65,9 @@
 uint32_t  g_sa_retries = 4;
 int    g_connect_err = WSAEADDRNOTAVAIL;
 uint8_t   g_max_cm_retries = CM_RETRIES;
-uint8_t   g_pkt_life_modifier = 0;
+int8_t   g_pkt_life_modifier = 0;
 uint8_t   g_qp_retries = QP_ATTRIB_RETRY_COUNT;
+uint8_t   g_use_APM = 0;
 DWORD_PTR  g_dwPollThreadAffinityMask = 0;
 
 uint32_t    g_ibsp_dbg_level = TRACE_LEVEL_ERROR;
@@ -205,7 +206,7 @@
   i = GetEnvironmentVariable( "IBWSD_PKT_LIFE", env_var,
sizeof(env_var) );
   if( i && i <= 16 )
   {
-   g_pkt_life_modifier = (uint8_t)_tcstoul( env_var, NULL, 0 );
+   g_pkt_life_modifier = (int8_t)_tcstoul( env_var, NULL, 0 );
    if( g_pkt_life_modifier > 0x1F )
     g_pkt_life_modifier = 0x1F;
   }
@@ -218,6 +219,12 @@
     g_qp_retries = 7;
   }
 
+  i = GetEnvironmentVariable( "IBWSD_USE_APM", env_var, sizeof(env_var)
);
+  if( i && i <= 16 )
+  {
+   g_use_APM = (uint8_t)_tcstoul( env_var, NULL, 0 );
+  }
+
   if( init_globals() )
    return FALSE;
 
@@ -804,7 +811,9 @@
  int ret;
  ib_net64_t dest_port_guid;
  ib_path_rec_t path_rec;
+ ib_path_rec_t alt_path_rec, *palt_path_rec = NULL;
 
+
  IBSP_ENTER( IBSP_DBG_CONN );
 
  UNUSED_PARAM( lpCalleeData );
@@ -875,7 +884,7 @@
  }
 
  /* Get the path record */
- ret = query_pr( socket_info->port, dest_port_guid, &path_rec );
+ ret = query_pr( socket_info->port->guid,
dest_port_guid,socket_info->port->hca->dev_id, &path_rec );
  if( ret )
  {
   IBSP_ERROR_EXIT( (
@@ -883,6 +892,21 @@
   *lpErrno = g_connect_err;
   return SOCKET_ERROR;
  }
+  /* Get the alternate path record */
+ if (g_use_APM) 
+ {
+  ret = query_pr(GetOtherPortGuid(socket_info->port->guid),
GetOtherPortGuid(dest_port_guid), socket_info->port->hca->dev_id,
&alt_path_rec );
+  if( ret )
+  { 
+   // We can ignore a failure here, since APM is not a MUST
+   IBSP_ERROR( ("QPR for alternate path failed (error ignored)\n") );
+  }
+  else 
+  {
+   palt_path_rec = &alt_path_rec;
+  }
+ }
+ 
 
  cl_spinlock_acquire( &socket_info->mutex1 );
 
@@ -924,7 +948,7 @@
  IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CONNECT );
 
  /* Connect */
- *lpErrno = ib_connect( socket_info, &path_rec );
+ *lpErrno = ib_connect( socket_info, &path_rec, palt_path_rec );
  if( *lpErrno != WSAEWOULDBLOCK )
  {
   /* We must be sure none destroyed our socket */

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090916/c61b918f/attachment.html>


More information about the ofw mailing list