[DAPL2] synchronize with OFED 1.4 DAT/DAPL code base.
authorstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 11 Jul 2008 19:05:54 +0000 (19:05 +0000)
committerstansmith <stansmith@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 11 Jul 2008 19:05:54 +0000 (19:05 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1370 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

52 files changed:
ulp/dapl2/dapl/common/dapl_adapter_util.h
ulp/dapl2/dapl/common/dapl_cookie.c
ulp/dapl2/dapl/common/dapl_cookie.h
ulp/dapl2/dapl/common/dapl_cr_callback.c
ulp/dapl2/dapl/common/dapl_cr_reject.c
ulp/dapl2/dapl/common/dapl_debug.c
ulp/dapl2/dapl/common/dapl_ep_connect.c
ulp/dapl2/dapl/common/dapl_ep_disconnect.c
ulp/dapl2/dapl/common/dapl_ep_get_status.c
ulp/dapl2/dapl/common/dapl_ep_modify.c
ulp/dapl2/dapl/common/dapl_ep_post_recv.c
ulp/dapl2/dapl/common/dapl_ep_util.c
ulp/dapl2/dapl/common/dapl_evd_connection_callb.c
ulp/dapl2/dapl/common/dapl_evd_util.c
ulp/dapl2/dapl/common/dapl_ia_query.c
ulp/dapl2/dapl/common/dapl_rmr_bind.c
ulp/dapl2/dapl/common/dapl_srq_post_recv.c
ulp/dapl2/dapl/ibal-scm/dapl_ibal-scm_cm.c
ulp/dapl2/dapl/ibal-scm/dapl_ibal-scm_util.c
ulp/dapl2/dapl/ibal/dapl_ibal_cm.c
ulp/dapl2/dapl/ibal/dapl_ibal_extensions.c
ulp/dapl2/dapl/ibal/dapl_ibal_name_service.h
ulp/dapl2/dapl/ibal/dapl_ibal_util.c
ulp/dapl2/dapl/ibal/dapl_ibal_util.h
ulp/dapl2/dapl/include/dapl.h
ulp/dapl2/dapl/include/dapl_debug.h
ulp/dapl2/dapl/include/dapl_vendor.h
ulp/dapl2/dapl/udapl/dapl_init.c
ulp/dapl2/dapl/udapl/linux/dapl_osd.h
ulp/dapl2/dapl/udapl/windows/dapl_osd.h
ulp/dapl2/dat/common/dat_api.c
ulp/dapl2/dat/common/dat_dr.c
ulp/dapl2/dat/common/dat_init.c
ulp/dapl2/dat/common/dat_init.h
ulp/dapl2/dat/common/dat_sr.c
ulp/dapl2/dat/include/dat/dat.h
ulp/dapl2/dat/udat/linux/dat_osd.c
ulp/dapl2/dat/udat/linux/dat_osd.h
ulp/dapl2/dat/udat/udat.c
ulp/dapl2/dat/udat/udat_api.c
ulp/dapl2/dat/udat/udat_exports.src
ulp/dapl2/dat/udat/udat_sr_parser.c
ulp/dapl2/test/dapltest/cmd/dapl_main.c
ulp/dapl2/test/dapltest/cmd/dapl_netaddr.c
ulp/dapl2/test/dapltest/mdep/windows/dapl_mdep_user.h
ulp/dapl2/test/dtest/GETOPT.C [deleted file]
ulp/dapl2/test/dtest/GETOPT.H [deleted file]
ulp/dapl2/test/dtest/SOURCES
ulp/dapl2/test/dtest/common.c [new file with mode: 0644]
ulp/dapl2/test/dtest/dtc.bat [new file with mode: 0644]
ulp/dapl2/test/dtest/dtest.c
ulp/dapl2/test/dtest/dts.bat [new file with mode: 0644]

index a962a88..bf8ae08 100644 (file)
@@ -112,8 +112,10 @@ DAT_RETURN dapls_ib_accept_connection (
        IN  const DAT_PVOID             private_data);\r
 \r
 DAT_RETURN dapls_ib_reject_connection (\r
-       IN  dp_ib_cm_handle_t   cm_handle,\r
-       IN  int                         reject_reason);\r
+       IN  dp_ib_cm_handle_t           cm_handle,\r
+       IN  int                         reject_reason,\r
+       IN  DAT_COUNT                   private_data_size,\r
+       IN  const DAT_PVOID             private_data);\r
 \r
 DAT_RETURN dapls_ib_setup_async_callback (\r
        IN  DAPL_IA                     *ia_ptr,\r
@@ -239,7 +241,8 @@ DAT_RETURN dapls_ib_cm_remote_addr (
 \r
 int dapls_ib_private_data_size (\r
        IN  DAPL_PRIVATE                *prd_ptr,\r
-       IN  DAPL_PDATA_OP               conn_op);\r
+       IN  DAPL_PDATA_OP               conn_op,\r
+       IN  DAPL_HCA                    *hca_ptr);\r
 \r
 void \r
 dapls_query_provider_specific_attr(\r
index f941abb..a5200e4 100644 (file)
@@ -260,6 +260,34 @@ dapls_cb_put (
     return DAT_SUCCESS;\r
 }\r
 \r
+/*\r
+ * dapls_cb_pending\r
+ *\r
+ * snapshot of active entries on cookie ring buffer \r
+ *\r
+ * Input:\r
+ *     buffer          pointer to DAPL_COOKIE_BUFFER\r
+ *\r
+ * Returns:\r
+ *     DAT_COUNT       number of active/pending cookies\r
+ *\r
+ */\r
+extern DAT_COUNT \r
+dapls_cb_pending (\r
+    DAPL_COOKIE_BUFFER *buffer )\r
+{\r
+       DAT_COUNT head, tail;\r
+\r
+       head = dapl_os_atomic_read(&buffer->head);\r
+       tail = dapl_os_atomic_read(&buffer->tail);\r
+\r
+       if (head == tail)\r
+               return 0;\r
+       else if (head > tail)\r
+               return (head - tail);\r
+       else \r
+               return ((buffer->pool_size - tail) + head);\r
+}\r
 \r
 /*\r
  * dapls_rmr_cookie_alloc\r
index 7aa4457..0b8ed1a 100644 (file)
@@ -50,6 +50,10 @@ extern void
 dapls_cb_free (\r
     DAPL_COOKIE_BUFFER         *buffer );\r
 \r
+extern DAT_COUNT \r
+dapls_cb_pending (\r
+    DAPL_COOKIE_BUFFER         *buffer );\r
+\r
 extern DAT_RETURN\r
 dapls_rmr_cookie_alloc (\r
     IN  DAPL_COOKIE_BUFFER     *buffer,\r
index 16db708..6e35079 100644 (file)
@@ -173,7 +173,8 @@ dapls_cr_callback (
                dapl_dbg_log (DAPL_DBG_TYPE_CM,\r
                          "---> dapls_cr_callback: conn event on down SP\n");\r
                (void)dapls_ib_reject_connection (ib_cm_handle,\r
-                                                 DAT_CONNECTION_EVENT_UNREACHABLE );\r
+                                                 DAT_CONNECTION_EVENT_UNREACHABLE,\r
+                                                 0, NULL);\r
 \r
                return;\r
            }\r
@@ -300,7 +301,8 @@ dapls_cr_callback (
     {\r
        /* The event post failed; take appropriate action.  */\r
        (void)dapls_ib_reject_connection ( ib_cm_handle,\r
-                                          DAT_CONNECTION_EVENT_BROKEN);\r
+                                          DAT_CONNECTION_EVENT_BROKEN,\r
+                                          0, NULL);\r
 \r
        return;\r
     }\r
@@ -378,7 +380,8 @@ dapli_connection_request (
     else\r
     {\r
        cr_ptr->param.private_data_size = \r
-               dapls_ib_private_data_size (prd_ptr, DAPL_PDATA_CONN_REQ);\r
+               dapls_ib_private_data_size(prd_ptr, DAPL_PDATA_CONN_REQ,\r
+                                          sp_ptr->header.owner_ia->hca_ptr);\r
     }\r
     if (cr_ptr->param.private_data_size > 0)\r
     {\r
@@ -455,7 +458,8 @@ dapli_connection_request (
     {\r
        dapls_cr_free (cr_ptr);\r
        (void)dapls_ib_reject_connection (ib_cm_handle,\r
-                                         DAT_CONNECTION_EVENT_BROKEN);\r
+                                         DAT_CONNECTION_EVENT_BROKEN,\r
+                                         0, NULL);\r
 \r
        /* Take the CR off the list, we can't use it */\r
        dapl_os_lock (&sp_ptr->header.lock);\r
index 37efe49..0940827 100644 (file)
@@ -97,7 +97,8 @@ dapl_cr_reject (
     }\r
 \r
     dat_status =  dapls_ib_reject_connection ( cr_ptr->ib_cm_handle,\r
-                                              IB_CM_REJ_REASON_CONSUMER_REJ );\r
+                                              IB_CM_REJ_REASON_CONSUMER_REJ,\r
+                                              pdata_size, pdata );\r
 \r
     if ( dat_status != DAT_SUCCESS)\r
     {\r
index cb9429a..59d1253 100644 (file)
 \r
 #include "dapl_debug.h"\r
 #include "dapl.h"\r
-\r
 #if !defined(__KDAPL__)\r
 #include <stdarg.h>\r
 #include <stdlib.h>\r
 #endif /* __KDAPL__ */\r
 \r
-#ifdef DAPL_DBG\r
 DAPL_DBG_TYPE g_dapl_dbg_type;         /* initialized in dapl_init.c */\r
 DAPL_DBG_DEST g_dapl_dbg_dest;         /* initialized in dapl_init.c */\r
 \r
 static char *_ptr_host_ = NULL;\r
-static char _hostname_[ 128 ];\r
+static char _hostname_[128];\r
 \r
 void dapl_internal_dbg_log ( DAPL_DBG_TYPE type, const char *fmt, ...)\r
 {\r
@@ -46,8 +44,8 @@ void dapl_internal_dbg_log ( DAPL_DBG_TYPE type, const char *fmt, ...)
 \r
     if ( _ptr_host_ == NULL )\r
     {\r
-       gethostname(_hostname_, sizeof(_hostname_));\r
-       _ptr_host_ = _hostname_;\r
+       gethostname(_hostname_, sizeof(_hostname_));\r
+       _ptr_host_ = _hostname_;\r
     }\r
 \r
     if ( type & g_dapl_dbg_type )\r
@@ -55,7 +53,7 @@ void dapl_internal_dbg_log ( DAPL_DBG_TYPE type, const char *fmt, ...)
        if ( DAPL_DBG_DEST_STDOUT & g_dapl_dbg_dest )\r
        {\r
            va_start (args, fmt);\r
-           fprintf(stdout, "%s:%d: ", _ptr_host_, dapl_osd_getpid());\r
+            fprintf(stdout, "%s:%d: ", _ptr_host_, dapl_os_getpid());\r
            dapl_os_vprintf (fmt, args);\r
            va_end (args);\r
        }\r
@@ -118,5 +116,4 @@ void dapl_dump_cntr( int cntr )
 }\r
 \r
 #endif /* DAPL_COUNTERS */\r
-#endif\r
 \r
index 7e44bd9..3a502e3 100644 (file)
@@ -258,7 +258,9 @@ dapl_ep_connect (
      */\r
     req_hdr_size = (sizeof (DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);\r
 \r
-    max_req_pdata_size = dapls_ib_private_data_size (NULL, DAPL_PDATA_CONN_REQ);\r
+    max_req_pdata_size = dapls_ib_private_data_size(\r
+                               NULL, DAPL_PDATA_CONN_REQ,\r
+                               ep_ptr->header.owner_ia->hca_ptr);\r
 \r
     if (private_data_size + req_hdr_size > (DAT_COUNT)max_req_pdata_size) \r
     {\r
index df22437..58730b8 100644 (file)
@@ -75,7 +75,6 @@ dapl_ep_disconnect (
                 "dapl_ep_disconnect (%p, %x)\n",\r
                  ep_handle,\r
                  disconnect_flags);\r
-\r
     DAPL_CNTR(DCNT_EP_DISCONNECT);\r
 \r
     ep_ptr = (DAPL_EP *) ep_handle;\r
@@ -175,7 +174,7 @@ dapl_ep_disconnect (
 \r
 bail:\r
     dapl_dbg_log (DAPL_DBG_TYPE_RTN | DAPL_DBG_TYPE_CM,\r
-                 "dapl_ep_disconnect EP %p %s rc %x\n",\r
+                 "dapl_ep_disconnect (EP %p) %s returns 0x%x\n",\r
                  ep_ptr,dapl_get_ep_state_str(ep_ptr->param.ep_state),\r
                  dat_status);\r
 \r
index b3da206..32687e4 100644 (file)
@@ -98,12 +98,12 @@ dapl_ep_get_status (
 \r
     if ( in_dto_idle != NULL )\r
     {\r
-       *in_dto_idle = (dapl_os_atomic_read (&ep_ptr->recv_count)) ? DAT_FALSE : DAT_TRUE;\r
+       *in_dto_idle = (dapls_cb_pending(&ep_ptr->recv_buffer)) ? DAT_FALSE : DAT_TRUE;\r
     }\r
 \r
     if ( out_dto_idle != NULL )\r
     {\r
-       *out_dto_idle = (dapl_os_atomic_read (&ep_ptr->req_count)) ? DAT_FALSE : DAT_TRUE;\r
+       *out_dto_idle = (dapls_cb_pending(&ep_ptr->req_buffer)) ? DAT_FALSE : DAT_TRUE;\r
     }\r
 \r
  bail:\r
index 59742e0..270758d 100644 (file)
@@ -95,15 +95,11 @@ dapl_ep_modify (
     DAT_BOOLEAN                                qp_allocated = DAT_FALSE;\r
     DAT_BOOLEAN                                rqst_cb_allocated = DAT_FALSE;\r
     DAT_BOOLEAN                                recv_cb_allocated = DAT_FALSE;\r
-    DAT_BOOLEAN                                rqst_iov_allocated = DAT_FALSE;\r
-    DAT_BOOLEAN                                recv_iov_allocated = DAT_FALSE;\r
 \r
     /* Flag indicating we've used (assigned to QP) a new one of these.  */\r
     DAT_BOOLEAN                                qp_used = DAT_FALSE;\r
     DAT_BOOLEAN                                rqst_cb_used = DAT_FALSE;\r
     DAT_BOOLEAN                                recv_cb_used = DAT_FALSE;\r
-    DAT_BOOLEAN                                rqst_iov_used = DAT_FALSE;\r
-    DAT_BOOLEAN                                recv_iov_used = DAT_FALSE;\r
 \r
     dat_status = dapli_ep_modify_validate_parameters ( ep_handle,\r
                                                      ep_param_mask,\r
@@ -171,39 +167,6 @@ dapl_ep_modify (
     }\r
     recv_cb_allocated = DAT_TRUE;\r
 \r
-    alloc_ep.send_iov_num = ep_attr1.max_request_iov;\r
-\r
-    /*\r
-     * Ensure that send_iov_num is big enough for all types\r
-     * of send requests.\r
-     */\r
-    if (ep_attr1.max_rdma_read_iov > alloc_ep.send_iov_num)\r
-    {\r
-        alloc_ep.send_iov_num = ep_attr1.max_rdma_read_iov;\r
-    }\r
-    if (ep_attr1.max_rdma_write_iov > alloc_ep.send_iov_num)\r
-    {\r
-        alloc_ep.send_iov_num = ep_attr1.max_rdma_write_iov;\r
-    }\r
-    alloc_ep.send_iov = dapl_os_alloc (alloc_ep.send_iov_num\r
-                                       * sizeof (ib_data_segment_t));\r
-    if ( alloc_ep.send_iov == NULL )\r
-    {\r
-       dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);\r
-       goto bail;\r
-    }\r
-    rqst_iov_allocated = DAT_TRUE;\r
-\r
-    alloc_ep.recv_iov_num = ep_attr1.max_recv_iov;\r
-    alloc_ep.recv_iov = dapl_os_alloc (ep_attr1.max_recv_iov\r
-                                       * sizeof (ib_data_segment_t));\r
-    if ( alloc_ep.recv_iov == NULL )\r
-    {\r
-       dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);\r
-       goto bail;\r
-    }\r
-    recv_iov_allocated = DAT_TRUE;\r
-\r
     dat_status = dapls_ib_qp_alloc ( ia, &alloc_ep, ep1 );\r
     if ( dat_status != DAT_SUCCESS )\r
     {\r
@@ -281,20 +244,6 @@ dapl_ep_modify (
        rqst_cb_used = DAT_TRUE;\r
     }\r
 \r
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV\r
-        && new_ep.recv_iov_num != ep2->recv_iov_num )\r
-    {\r
-       new_ep.recv_iov = alloc_ep.recv_iov;\r
-       recv_iov_used = DAT_TRUE;\r
-    }\r
-\r
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV\r
-        && new_ep.send_iov_num != ep2->send_iov_num )\r
-    {\r
-       new_ep.send_iov = alloc_ep.send_iov;\r
-       recv_iov_used = DAT_TRUE;\r
-    }\r
-\r
     /*\r
      * We need to change the QP only if there already was a QP\r
      * (leave things the way you found them!) and one of the\r
@@ -439,37 +388,6 @@ bail:
        }\r
     }\r
 \r
-    if ( rqst_iov_allocated )\r
-    {\r
-       if ( dat_status != DAT_SUCCESS || !rqst_iov_used )\r
-       {\r
-           dapl_os_free ( alloc_ep.send_iov,\r
-                          (alloc_ep.send_iov_num\r
-                           * sizeof (ib_data_segment_t)));\r
-       }\r
-       else\r
-       {\r
-           dapl_os_free ( copy_of_old_ep.send_iov,\r
-                          (copy_of_old_ep.send_iov_num\r
-                           * sizeof (ib_data_segment_t)));\r
-       }\r
-    }\r
-\r
-    if ( recv_iov_allocated )\r
-    {\r
-       if ( dat_status != DAT_SUCCESS || !recv_iov_used )\r
-       {\r
-           dapl_os_free ( alloc_ep.recv_iov,\r
-                          (alloc_ep.recv_iov_num\r
-                           * sizeof (ib_data_segment_t)));\r
-       }\r
-       else\r
-       {\r
-           dapl_os_free ( copy_of_old_ep.recv_iov,\r
-                          (copy_of_old_ep.recv_iov_num\r
-                           * sizeof (ib_data_segment_t)));\r
-       }\r
-    }\r
     return dat_status;\r
 }\r
 \r
index 77a684a..d8ceb81 100644 (file)
@@ -108,12 +108,6 @@ dapl_ep_post_recv (
        goto bail;\r
     }\r
 \r
-    /*\r
-     * Take reference before posting to avoid race conditions with\r
-     * completions\r
-     */\r
-    dapl_os_atomic_inc (&ep_ptr->recv_count);\r
-\r
     /*\r
      * Invoke provider specific routine to post DTO\r
      */\r
@@ -121,7 +115,6 @@ dapl_ep_post_recv (
 \r
     if ( dat_status != DAT_SUCCESS )\r
     {\r
-       dapl_os_atomic_dec (&ep_ptr->recv_count);\r
        dapls_cookie_dealloc (&ep_ptr->recv_buffer, cookie);\r
     }\r
 \r
index 8d06302..cc8f890 100644 (file)
@@ -162,9 +162,6 @@ dapl_ep_alloc (
     ep_ptr->qp_state  = DAPL_QP_STATE_UNATTACHED;\r
     ep_ptr->cm_handle = IB_INVALID_HANDLE;\r
 \r
-    dapl_os_atomic_set (&ep_ptr->req_count, 0);\r
-    dapl_os_atomic_set (&ep_ptr->recv_count, 0);\r
-\r
     if ( DAT_SUCCESS != dapls_cb_create (\r
             &ep_ptr->req_buffer,\r
             ep_ptr,\r
@@ -185,42 +182,6 @@ dapl_ep_alloc (
        goto bail;\r
     }\r
 \r
-    ep_ptr->recv_iov_num = ep_ptr->param.ep_attr.max_recv_iov;\r
-    ep_ptr->send_iov_num = ep_ptr->param.ep_attr.max_request_iov;\r
-\r
-    /*\r
-     * Ensure that send_iov_num is big enough for all types\r
-     * of send requests.\r
-     */\r
-    if (ep_ptr->param.ep_attr.max_rdma_read_iov > ep_ptr->send_iov_num)\r
-    {\r
-        ep_ptr->send_iov_num = ep_ptr->param.ep_attr.max_rdma_read_iov;\r
-    }\r
-    if (ep_ptr->param.ep_attr.max_rdma_write_iov > ep_ptr->send_iov_num)\r
-    {\r
-        ep_ptr->send_iov_num = ep_ptr->param.ep_attr.max_rdma_write_iov;\r
-    }\r
-\r
-    ep_ptr->recv_iov = dapl_os_alloc (\r
-       ep_ptr->recv_iov_num * sizeof (ib_data_segment_t));\r
-\r
-    if ( NULL == ep_ptr->recv_iov )\r
-    {\r
-       dapl_ep_dealloc (ep_ptr);\r
-       ep_ptr = NULL;\r
-       goto bail;\r
-    }\r
-\r
-    ep_ptr->send_iov = dapl_os_alloc (\r
-       ep_ptr->send_iov_num * sizeof (ib_data_segment_t));\r
-\r
-    if ( NULL == ep_ptr->send_iov )\r
-    {\r
-       dapl_ep_dealloc (ep_ptr);\r
-       ep_ptr = NULL;\r
-       goto bail;\r
-    }\r
-\r
     dapls_io_trc_alloc (ep_ptr);\r
 \r
 bail:\r
@@ -249,22 +210,11 @@ dapl_ep_dealloc (
 {\r
     dapl_os_assert (ep_ptr->header.magic == DAPL_MAGIC_EP);\r
 \r
-    /* reset magic to prevent reuse */\r
-    ep_ptr->header.magic = DAPL_MAGIC_INVALID;\r
+    ep_ptr->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */\r
 \r
     dapls_cb_free ( &ep_ptr->req_buffer );\r
     dapls_cb_free ( &ep_ptr->recv_buffer );\r
 \r
-    if ( NULL != ep_ptr->recv_iov )\r
-    {\r
-       dapl_os_free (ep_ptr->recv_iov, ep_ptr->recv_iov_num * sizeof (ib_data_segment_t));\r
-    }\r
-\r
-    if ( NULL != ep_ptr->send_iov )\r
-    {\r
-       dapl_os_free (ep_ptr->send_iov, ep_ptr->send_iov_num * sizeof (ib_data_segment_t));\r
-    }\r
-\r
     if ( NULL != ep_ptr->cxn_timer )\r
     {\r
        dapl_os_free ( ep_ptr->cxn_timer, sizeof ( DAPL_OS_TIMER ) );\r
@@ -433,17 +383,19 @@ dapl_ep_post_send_req (
                 dto_type,\r
                 user_cookie,\r
                 &cookie );\r
-    if ( dat_status != DAT_SUCCESS )\r
-    {\r
+    if (dat_status != DAT_SUCCESS) {\r
+       dapl_log(DAPL_DBG_TYPE_ERR,\r
+                " dapl_post_req resource ERR:"\r
+                " dtos pending = %d, max_dtos %d, max_cb %d hd %d tl %d\n",\r
+                dapls_cb_pending(&ep_ptr->req_buffer),\r
+                ep_ptr->param.ep_attr.max_request_dtos,\r
+                ep_ptr->req_buffer.pool_size,\r
+                ep_ptr->req_buffer.head,\r
+                ep_ptr->req_buffer.tail);\r
+\r
        goto bail;\r
     }\r
 \r
-    /*\r
-     * Take reference before posting to avoid race conditions with\r
-     * completions\r
-     */\r
-    dapl_os_atomic_inc (&ep_ptr->req_count);\r
-\r
     /*\r
      * Invoke provider specific routine to post DTO\r
      */\r
@@ -457,7 +409,6 @@ dapl_ep_post_send_req (
 \r
     if ( dat_status != DAT_SUCCESS )\r
     {\r
-       dapl_os_atomic_dec (&ep_ptr->req_count);\r
        dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);\r
     }\r
 \r
index c7faa68..100d77e 100644 (file)
@@ -148,7 +148,9 @@ dapl_evd_connection_callback (
            else\r
            {\r
                private_data_size  = \r
-                   dapls_ib_private_data_size (prd_ptr, DAPL_PDATA_CONN_REP);\r
+                   dapls_ib_private_data_size(\r
+                                       prd_ptr, DAPL_PDATA_CONN_REP,\r
+                                       ep_ptr->header.owner_ia->hca_ptr);\r
            }\r
 \r
            if (private_data_size > 0)\r
@@ -162,8 +164,26 @@ dapl_evd_connection_callback (
 \r
            break;\r
        }\r
-       case DAT_CONNECTION_EVENT_DISCONNECTED:\r
        case DAT_CONNECTION_EVENT_PEER_REJECTED:\r
+       {\r
+           /* peer reject may include private data */\r
+           if (prd_ptr != NULL) \r
+               private_data_size  = \r
+                   dapls_ib_private_data_size(\r
+                                       prd_ptr, DAPL_PDATA_CONN_REJ,\r
+                                       ep_ptr->header.owner_ia->hca_ptr);\r
+\r
+           if (private_data_size > 0) \r
+               dapl_os_memcpy (ep_ptr->private.private_data,\r
+                               prd_ptr->private_data,\r
+                               DAPL_MIN (private_data_size, \r
+                                          DAPL_MAX_PRIVATE_DATA_SIZE));\r
+\r
+            dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,\r
+                        "dapl_evd_connection_callback PEER REJ pd=%p sz=%d\n",\r
+                        prd_ptr, private_data_size);\r
+       }\r
+       case DAT_CONNECTION_EVENT_DISCONNECTED:\r
        case DAT_CONNECTION_EVENT_UNREACHABLE:\r
        case DAT_CONNECTION_EVENT_NON_PEER_REJECTED:\r
        {\r
@@ -203,7 +223,7 @@ dapl_evd_connection_callback (
                        evd_ptr,\r
                        dat_event_num,\r
                        (DAT_HANDLE) ep_ptr,\r
-                       private_data_size, /* 0 except for CONNECTED */\r
+                       private_data_size, /* CONNECTED or REJECT */\r
                        ep_ptr->private.private_data );\r
 \r
        if (dat_status != DAT_SUCCESS && \r
index 94504b4..ea72ee8 100644 (file)
 #include "dapl_cookie.h"\r
 #include "dapl.h"\r
 \r
+#ifdef __linux__\r
+#include <sys/socket.h>\r
+#include <netinet/in.h>\r
+#include <arpa/inet.h>\r
+#endif\r
+\r
 STATIC _INLINE_ void dapli_evd_eh_print_cqe (\r
        IN  ib_work_completion_t        *cqe);\r
 \r
@@ -301,6 +307,11 @@ dapls_evd_alloc (
            ((evd_flags & ~ (DAT_EVD_DTO_FLAG|DAT_EVD_RMR_BIND_FLAG)) == 0 ))\r
     {\r
         dapls_ib_wait_object_create (evd_ptr, &evd_ptr->cq_wait_obj_handle);\r
+       if (evd_ptr->cq_wait_obj_handle == NULL) {\r
+               dapl_os_free(evd_ptr, sizeof (DAPL_EVD));\r
+               evd_ptr = NULL;\r
+               goto bail;\r
+       }\r
     }\r
 #endif\r
 \r
@@ -538,9 +549,24 @@ bail:
     return dat_status;\r
 }\r
 \r
-#if defined(DAPL_DBG) && !defined(DAPL_GET_CQE_OP_STR)\r
+STATIC _INLINE_ char * DAPL_GET_DTO_OP_STR(int op)\r
+{\r
+    static char *dto_ops[] =\r
+    {\r
+        "OP_SEND",\r
+        "OP_RECEIVE",\r
+        "OP_RDMA_WRITE",\r
+        "OP_RDMA_READ"\r
+    };\r
+    return ((op < 0 || op > 3) ? "Invalid DTO OP?" : dto_ops[op]);\r
+}\r
+\r
+#if !defined(DAPL_GET_CQE_OP_STR)\r
 #define DAPL_GET_CQE_OP_STR(e) "Unknown CEQ OP String?"\r
 #endif\r
+#if !defined(DAPL_GET_CQE_VENDOR_ERR)\r
+#define DAPL_GET_CQE_VENDOR_ERR(e) 0\r
+#endif\r
 \r
 /*\r
  * dapli_evd_eh_print_cqe\r
@@ -560,7 +586,6 @@ dapli_evd_eh_print_cqe (
     IN         ib_work_completion_t    *cqe_ptr)\r
 {\r
 #ifdef DAPL_DBG\r
-\r
     dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,\r
                  "\t >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<\n");\r
     dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,\r
@@ -578,8 +603,9 @@ dapli_evd_eh_print_cqe (
                  DAPL_GET_CQE_BYTESNUM (cqe_ptr));\r
     }\r
     dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,\r
-                 "\t\t status %d\n",\r
-                 DAPL_GET_CQE_STATUS (cqe_ptr));\r
+                 "\t\t status %d vendor_err 0x%x\n",\r
+                 DAPL_GET_CQE_STATUS(cqe_ptr),\r
+                 DAPL_GET_CQE_VENDOR_ERR(cqe_ptr));\r
     dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,\r
                  "\t >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<\n");\r
 #endif\r
@@ -1083,25 +1109,19 @@ dapli_evd_cqe_to_event (
                DAPL_GET_CQE_OPTYPE(cqe_ptr) !=  OP_RECEIVE))\r
            {\r
                dapls_cqe_to_event_extension (ep_ptr, cookie, cqe_ptr, event_ptr);\r
-               if (cookie->val.dto.type == DAPL_DTO_TYPE_RECV)\r
-                       dapls_cookie_dealloc (&ep_ptr->recv_buffer, cookie);\r
-               else\r
-                       dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);\r
+                if (cookie->val.dto.type == DAPL_DTO_TYPE_RECV)\r
+                        dapls_cookie_dealloc (&ep_ptr->recv_buffer, cookie);\r
+                else\r
+                        dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);\r
                break;\r
            }\r
 #endif\r
 \r
-           if ( DAPL_DTO_TYPE_RECV == cookie->val.dto.type )\r
-           {\r
-               dapl_os_atomic_dec (&ep_ptr->recv_count);\r
-               buffer = &ep_ptr->recv_buffer;\r
-           }\r
+           if (DAPL_DTO_TYPE_RECV == cookie->val.dto.type)\r
+               buffer = &ep_ptr->recv_buffer;\r
            else\r
-           {\r
-               dapl_os_atomic_dec (&ep_ptr->req_count);\r
-               buffer = &ep_ptr->req_buffer;\r
-           }\r
-\r
+               buffer = &ep_ptr->req_buffer;\r
+           \r
            event_ptr->event_number = DAT_DTO_COMPLETION_EVENT;\r
            event_ptr->event_data.dto_completion_event_data.ep_handle =\r
                cookie->ep;\r
@@ -1128,8 +1148,6 @@ dapli_evd_cqe_to_event (
 \r
        case DAPL_COOKIE_TYPE_RMR:\r
        {\r
-           dapl_os_atomic_dec (&ep_ptr->req_count);\r
-\r
            event_ptr->event_number = DAT_RMR_BIND_COMPLETION_EVENT;\r
 \r
            event_ptr->event_data.rmr_completion_event_data.rmr_handle =\r
@@ -1209,10 +1227,12 @@ dapli_evd_cqe_to_event (
            dapl_os_unlock ( &ep_ptr->header.lock );\r
        }\r
 \r
-       dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,\r
-                     " DTO completion ERROR: %d: op %#x (ep disconnected)\n",\r
-                     DAPL_GET_CQE_STATUS (cqe_ptr),\r
-                     DAPL_GET_CQE_OPTYPE (cqe_ptr));\r
+       dapl_log(DAPL_DBG_TYPE_ERR,\r
+                "DTO completion ERR: status %d, op %s, vendor_err 0x%x - %s\n",\r
+                DAPL_GET_CQE_STATUS(cqe_ptr),\r
+                DAPL_GET_DTO_OP_STR(cookie->val.dto.type),\r
+                DAPL_GET_CQE_VENDOR_ERR(cqe_ptr),\r
+                inet_ntoa(((struct sockaddr_in *)&ep_ptr->remote_ia_address)->sin_addr));\r
     }\r
 }\r
 \r
index 05938ed..64a778d 100644 (file)
@@ -156,8 +156,9 @@ dapl_ia_query (
         *      to 0 unless IBHOSTS_NAMING is enabled.\r
         */\r
        provider_attr->max_private_data_size      = \r
-           dapls_ib_private_data_size (NULL, DAPL_PDATA_CONN_REQ) -\r
-           (sizeof (DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);\r
+           dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,\r
+                       ia_ptr->hca_ptr) -\r
+                       (sizeof(DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE); \r
        provider_attr->supports_multipath         = DAT_FALSE;\r
        provider_attr->ep_creator                 = DAT_PSP_CREATES_EP_NEVER;\r
        provider_attr->optimal_buffer_alignment   = DAT_OPTIMAL_ALIGNMENT;\r
index f783911..a8637df 100644 (file)
@@ -151,12 +151,6 @@ dapli_rmr_bind_fuse (
 \r
     is_signaled = (completion_flags & DAT_COMPLETION_SUPPRESS_FLAG) ? DAT_FALSE : DAT_TRUE;\r
 \r
-    /*\r
-     * Take reference before posting to avoid race conditions with\r
-     * completions\r
-     */\r
-    dapl_os_atomic_inc (&ep_ptr->req_count);\r
-\r
     dat_status = dapls_ib_mw_bind (rmr,\r
                                   lmr,\r
                                   ep_ptr,\r
@@ -167,7 +161,6 @@ dapli_rmr_bind_fuse (
                                   is_signaled);\r
     if ( DAT_SUCCESS != dat_status )\r
     {\r
-       dapl_os_atomic_dec (&ep_ptr->req_count);\r
        dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);\r
        goto bail;\r
     }\r
@@ -255,19 +248,12 @@ dapli_rmr_bind_unfuse (
 \r
     is_signaled = (completion_flags & DAT_COMPLETION_UNSIGNALLED_FLAG) ? DAT_FALSE : DAT_TRUE;\r
 \r
-    /*\r
-     * Take reference before posting to avoid race conditions with \r
-     * completions \r
-     */\r
-    dapl_os_atomic_inc (&ep_ptr->req_count);\r
-\r
     dat_status = dapls_ib_mw_unbind (rmr,\r
                                     ep_ptr,\r
                                     cookie,\r
                                     is_signaled);\r
     if ( DAT_SUCCESS != dat_status )\r
     {\r
-       dapl_os_atomic_dec (&ep_ptr->req_count);\r
        dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);\r
        goto bail1;\r
     }\r
index d25001e..72c07fb 100644 (file)
@@ -117,8 +117,7 @@ dapl_srq_post_recv (
      * Invoke provider specific routine to post DTO\r
      */\r
     /* XXX Put code here XXX */\r
-    /* XXX */\r
-    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);\r
+    /* XXX */    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);\r
 \r
     if ( dat_status != DAT_SUCCESS )\r
     {\r
index 7f1de18..fa3d453 100644 (file)
 #include <ws2tcpip.h>\r
 #include <io.h>\r
 \r
+extern int g_scm_pipe[2];\r
+\r
+extern DAT_RETURN\r
+dapls_ib_query_gid( IN  DAPL_HCA       *hca_ptr,\r
+                   IN  GID             *gid );\r
+\r
+\r
+static struct ib_cm_handle * dapli_cm_create(void)\r
+{ \r
+       struct ib_cm_handle *cm_ptr;\r
+\r
+       /* Allocate CM, init lock, and initialize */\r
+       if ((cm_ptr = dapl_os_alloc(sizeof(*cm_ptr))) == NULL) \r
+               return NULL;\r
+\r
+        if (dapl_os_lock_init(&cm_ptr->lock)) \r
+               goto bail;\r
+\r
+       (void)dapl_os_memzero(cm_ptr, sizeof(*cm_ptr));\r
+       cm_ptr->dst.ver = htons(DSCM_VER);\r
+       cm_ptr->socket = -1;\r
+       cm_ptr->l_socket = -1;\r
+       return cm_ptr;\r
+bail:\r
+       dapl_os_free(cm_ptr, sizeof(*cm_ptr));\r
+       return NULL;\r
+}\r
+\r
+\r
+/* mark for destroy, remove all references, schedule cleanup */\r
+\r
+static void dapli_cm_destroy(struct ib_cm_handle *cm_ptr)\r
+{\r
+       dapl_dbg_log(DAPL_DBG_TYPE_CM, \r
+                    " cm_destroy: cm %p ep %p\n", cm_ptr,cm_ptr->ep);\r
+       \r
+       /* cleanup, never made it to work queue */\r
+       if (cm_ptr->state == SCM_INIT) {\r
+               if (cm_ptr->socket >= 0)  \r
+                       closesocket(cm_ptr->socket);\r
+               if (cm_ptr->l_socket >= 0)  \r
+                       closesocket(cm_ptr->l_socket);\r
+               dapl_os_free(cm_ptr, sizeof(*cm_ptr));\r
+               return;\r
+       }\r
+\r
+       dapl_os_lock(&cm_ptr->lock);\r
+       cm_ptr->state = SCM_DESTROY;\r
+       if (cm_ptr->ep) \r
+               cm_ptr->ep->cm_handle = IB_INVALID_HANDLE;\r
+\r
+       /* close socket if still active */\r
+       if (cm_ptr->socket >= 0) {\r
+               closesocket(cm_ptr->socket);\r
+               cm_ptr->socket = -1;\r
+       }\r
+       if (cm_ptr->l_socket >= 0) {\r
+               closesocket(cm_ptr->l_socket);\r
+               cm_ptr->l_socket = -1;\r
+       }\r
+       dapl_os_unlock(&cm_ptr->lock);\r
+\r
+       /* wakeup work thread */\r
+       _write(g_scm_pipe[1], "w", sizeof "w");\r
+}\r
+\r
+\r
+/* queue socket for processing CM work */\r
+static void dapli_cm_queue(struct ib_cm_handle *cm_ptr)\r
+{\r
+       /* add to work queue for cr thread processing */\r
+       dapl_llist_init_entry((DAPL_LLIST_ENTRY*)&cm_ptr->entry);\r
+       dapl_os_lock( &cm_ptr->hca->ib_trans.lock );\r
+       dapl_llist_add_tail((DAPL_LLIST_HEAD*)&cm_ptr->hca->ib_trans.list, \r
+                           (DAPL_LLIST_ENTRY*)&cm_ptr->entry, (void*)cm_ptr);\r
+       dapl_os_unlock(&cm_ptr->hca->ib_trans.lock);\r
+\r
+        /* wakeup CM work thread */\r
+        _write(g_scm_pipe[1], "w", sizeof "w");\r
+}\r
+\r
+\r
 \r
 static uint16_t\r
 dapli_get_lid(IN DAPL_HCA *hca, IN int port)\r
@@ -122,6 +204,263 @@ dapli_get_lid(IN DAPL_HCA *hca, IN int port)
 }\r
 \r
 \r
+/*\r
+ * ACTIVE/PASSIVE: called from CR thread or consumer via ep_disconnect\r
+ */\r
+static DAT_RETURN \r
+dapli_socket_disconnect(dp_ib_cm_handle_t cm_ptr)\r
+{\r
+       DAPL_EP *ep_ptr = cm_ptr->ep;\r
+       DAT_UINT32 disc_data = htonl(0xdead);\r
+\r
+       if (ep_ptr == NULL)\r
+               return DAT_SUCCESS;\r
+       \r
+       dapl_os_lock(&cm_ptr->lock);\r
+       if ((cm_ptr->state == SCM_INIT) ||\r
+           (cm_ptr->state == SCM_DISCONNECTED)) {\r
+               dapl_os_unlock(&cm_ptr->lock);\r
+               return DAT_SUCCESS;\r
+       } else {\r
+               /* send disc date, close socket, schedule destroy */\r
+               if (cm_ptr->socket >= 0) { \r
+                       send(cm_ptr->socket, (const char *)&disc_data,\r
+                               sizeof(disc_data), 0);\r
+                       closesocket(cm_ptr->socket);\r
+                       cm_ptr->socket = -1;\r
+               }\r
+               cm_ptr->state = SCM_DISCONNECTED;\r
+               _write(g_scm_pipe[1], "w", sizeof "w");\r
+       }\r
+       dapl_os_unlock(&cm_ptr->lock);\r
+\r
+\r
+       if (ep_ptr->cr_ptr) {\r
+               dapls_cr_callback(cm_ptr,\r
+                                 IB_CME_DISCONNECTED,\r
+                                 NULL,\r
+                                 ((DAPL_CR *)ep_ptr->cr_ptr)->sp_ptr);\r
+       } else {\r
+               dapl_evd_connection_callback(ep_ptr->cm_handle,\r
+                                            IB_CME_DISCONNECTED,\r
+                                            NULL,\r
+                                            ep_ptr);\r
+       }       \r
+\r
+       /* remove reference from endpoint */\r
+       ep_ptr->cm_handle = NULL;\r
+       \r
+       /* schedule destroy */\r
+\r
+\r
+       return DAT_SUCCESS;\r
+}\r
+\r
+\r
+\r
+/*\r
+ * PASSIVE: consumer accept, send local QP information, private data, \r
+ * queue on work thread to receive RTU information to avoid blocking\r
+ * user thread. \r
+ */\r
+static DAT_RETURN \r
+dapli_socket_accept_usr( DAPL_EP       *ep_ptr,\r
+                        DAPL_CR        *cr_ptr,\r
+                        DAT_COUNT      p_size,\r
+                        DAT_PVOID      p_data )\r
+{\r
+       DAPL_IA         *ia_ptr = ep_ptr->header.owner_ia;\r
+       dp_ib_cm_handle_t cm_ptr = cr_ptr->ib_cm_handle;\r
+       WSABUF          iovec[2];\r
+       int             len, rc;\r
+       short           rtu_data = 0;\r
+       ib_api_status_t ibs;\r
+       ib_qp_attr_t    qpa;\r
+       dapl_ibal_port_t *p_port;\r
+       dapl_ibal_ca_t  *p_ca;\r
+\r
+       dapl_dbg_log (DAPL_DBG_TYPE_EP, "%s() p_sz %d sock %d port 0x%x\n",\r
+                       __FUNCTION__,p_size,cm_ptr->socket,\r
+                       ia_ptr->hca_ptr->port_num);\r
+\r
+       if (p_size >  IB_MAX_REP_PDATA_SIZE) \r
+               return DAT_LENGTH_ERROR;\r
+\r
+       /* must have a accepted socket */\r
+       if ( cm_ptr->socket < 0 ) {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_EP, \r
+                    "%s() Not accepted socket? remote port=0x%x lid=0x%x"\r
+                    " qpn=0x%x psize=%d\n",\r
+                    cm_ptr->dst.port, cm_ptr->dst.lid,\r
+                    ntohs(cm_ptr->dst.qpn), cm_ptr->dst.p_size); \r
+               return DAT_INTERNAL_ERROR;\r
+       }\r
+       \r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP, \r
+                    " accept_usr: remote port=0x%x lid=0x%x"\r
+                    " qpn=0x%x psize=%d\n",\r
+                    cm_ptr->dst.port, cm_ptr->dst.lid,\r
+                    ntohs(cm_ptr->dst.qpn), cm_ptr->dst.p_size); \r
+\r
+       /* modify QP to RTR and then to RTS with remote info already read */\r
+\r
+       p_ca = (dapl_ibal_ca_t *) ia_ptr->hca_ptr->ib_hca_handle;\r
+       p_port = dapli_ibal_get_port (p_ca, (uint8_t)ia_ptr->hca_ptr->port_num);\r
+       if (!p_port)\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
+                       "%s() dapli_ibal_get_port() failed @ line #%d\n",\r
+                       __FUNCTION__,__LINE__);\r
+               goto bail;\r
+       }\r
+\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP,\r
+                       "%s() DST: qpn 0x%x port 0x%x lid %x psize %d\n",\r
+                       __FUNCTION__,\r
+                       cl_ntoh32(cm_ptr->dst.qpn),\r
+                       cm_ptr->dst.port,\r
+                       cl_ntoh16(cm_ptr->dst.lid), cm_ptr->dst.p_size);\r
+\r
+       /* modify QP to RTR and then to RTS with remote info */\r
+\r
+       ibs = dapls_modify_qp_state_to_rtr( ep_ptr->qp_handle, \r
+                                           cm_ptr->dst.qpn,\r
+                                           cm_ptr->dst.lid,\r
+                                           p_port );\r
+       if (ibs != IB_SUCCESS)\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
+                               "%s() QP --> RTR failed @ line #%d\n",\r
+                               __FUNCTION__,__LINE__);\r
+               goto bail;\r
+       }\r
+\r
+       if ( dapls_modify_qp_state_to_rts( ep_ptr->qp_handle ) )\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
+                               "%s() QP --> RTS failed @ line #%d\n",\r
+                               __FUNCTION__,__LINE__);\r
+               goto bail;\r
+       }\r
+\r
+       ep_ptr->qp_state = IB_QP_STATE_RTS;\r
+       \r
+       /* save remote address information */\r
+       dapl_os_memcpy( &ep_ptr->remote_ia_address, \r
+                       &cm_ptr->dst.ia_address, \r
+                       sizeof(ep_ptr->remote_ia_address));\r
+\r
+       /* determine QP & port numbers */\r
+       ibs = ib_query_qp(ep_ptr->qp_handle, &qpa);\r
+       if (ibs != IB_SUCCESS)\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
+                            " ib_query_qp() ERR %s\n", ib_get_err_str(ibs)); \r
+               goto bail;\r
+       }\r
+\r
+       /* Send our QP info, IA address, and private data */\r
+       cm_ptr->dst.qpn = qpa.num; /* ib_net32_t */\r
+       cm_ptr->dst.port = ia_ptr->hca_ptr->port_num;\r
+       cm_ptr->dst.lid = dapli_get_lid(ia_ptr->hca_ptr, ia_ptr->hca_ptr->port_num);\r
+       /* set gid in network order */\r
+       ibs = dapls_ib_query_gid( ia_ptr->hca_ptr, &cm_ptr->dst.gid );\r
+       if ( ibs != IB_SUCCESS )\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
+                       "%s() dapls_ib_query_gid() returns '%s'\n",\r
+                       __FUNCTION__,ib_get_err_str(ibs)); \r
+               goto bail;\r
+       }\r
+\r
+       cm_ptr->dst.ia_address = ia_ptr->hca_ptr->hca_address;\r
+       cm_ptr->dst.p_size = p_size;\r
+\r
+       dapl_dbg_log(DAPL_DBG_TYPE_CM,\r
+               "%s()\n  Tx QP info: qpn %x port 0x%x lid 0x%x p_sz %d IP %s\n",\r
+               __FUNCTION__, cl_ntoh32(cm_ptr->dst.qpn), cm_ptr->dst.port,\r
+               cl_ntoh16(cm_ptr->dst.lid), cm_ptr->dst.p_size,\r
+               dapli_get_ip_addr_str(&cm_ptr->dst.ia_address,NULL));\r
+\r
+       /* network byte-ordering - QPN & LID already are */\r
+       cm_ptr->dst.p_size = cl_hton32(cm_ptr->dst.p_size);\r
+       cm_ptr->dst.port = cl_hton16(cm_ptr->dst.port);\r
+\r
+       iovec[0].buf = (char*)&cm_ptr->dst;\r
+       iovec[0].len  = sizeof(ib_qp_cm_t);\r
+       if (p_size) {\r
+               iovec[1].buf = p_data;\r
+               iovec[1].len  = p_size;\r
+       }\r
+       rc = WSASend( cm_ptr->socket, iovec, (p_size ? 2:1), &len, 0, 0, 0 );\r
+       if (rc || len != (p_size + sizeof(ib_qp_cm_t))) {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
+                            " accept_usr: ERR %d, wcnt=%d\n",\r
+                            WSAGetLastError(), len); \r
+               goto bail;\r
+       }\r
+       dapl_dbg_log(DAPL_DBG_TYPE_CM, \r
+                    " accept_usr: local port=0x%x lid=0x%x"\r
+                    " qpn=0x%x psize=%d\n",\r
+                    ntohs(cm_ptr->dst.port), ntohs(cm_ptr->dst.lid), \r
+                    ntohl(cm_ptr->dst.qpn), ntohl(cm_ptr->dst.p_size)); \r
+       \r
+       /* save state and reference to EP, queue for RTU data */\r
+       cm_ptr->ep = ep_ptr;\r
+       cm_ptr->hca = ia_ptr->hca_ptr;\r
+       cm_ptr->state = SCM_ACCEPTED;\r
+\r
+       /* restore remote address information for query */\r
+       dapl_os_memcpy( &cm_ptr->dst.ia_address, \r
+                       &ep_ptr->remote_ia_address,\r
+                       sizeof(cm_ptr->dst.ia_address));\r
+\r
+       dapl_dbg_log( DAPL_DBG_TYPE_EP," PASSIVE: accepted!\n" ); \r
+       dapli_cm_queue(cm_ptr);\r
+\r
+       return DAT_SUCCESS;\r
+\r
+bail:\r
+       dapl_dbg_log( DAPL_DBG_TYPE_ERR," accept_usr: ERR !QP_RTR_RTS \n"); \r
+       dapli_cm_destroy(cm_ptr);\r
+       dapls_ib_reinit_ep( ep_ptr ); /* reset QP state */\r
+\r
+       return DAT_INTERNAL_ERROR;\r
+}\r
+\r
+\r
+/*\r
+ * PASSIVE: read RTU from active peer, post CONN event\r
+ */\r
+void \r
+dapli_socket_accept_rtu(dp_ib_cm_handle_t cm_ptr)\r
+{\r
+       int             len;\r
+       short           rtu_data = 0;\r
+\r
+       /* complete handshake after final QP state change */\r
+       len = recv(cm_ptr->socket, (char*)&rtu_data, sizeof(rtu_data), 0);\r
+       if ( len != sizeof(rtu_data) || ntohs(rtu_data) != 0x0e0f ) {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
+                            " accept_rtu: ERR %d, rcnt=%d rdata=%x\n",\r
+                            WSAGetLastError(), len, ntohs(rtu_data) ); \r
+               goto bail;\r
+       }\r
+\r
+       /* save state and reference to EP, queue for disc event */\r
+       cm_ptr->state = SCM_CONNECTED;\r
+\r
+       /* final data exchange if remote QP state is good to go */\r
+       dapl_dbg_log( DAPL_DBG_TYPE_EP," PASSIVE: connected!\n" ); \r
+       dapls_cr_callback(cm_ptr, IB_CME_CONNECTED, NULL, cm_ptr->sp);\r
+       return;\r
+bail:\r
+       dapls_ib_reinit_ep(cm_ptr->ep); /* reset QP state */\r
+       dapli_cm_destroy(cm_ptr);\r
+       dapls_cr_callback(cm_ptr, IB_CME_DESTINATION_REJECT, NULL, cm_ptr->sp);\r
+}\r
+\r
+\r
 /*\r
  * ACTIVE: Create socket, connect, and exchange QP information \r
  */\r
@@ -143,21 +482,16 @@ dapli_socket_connect (    DAPL_EP                 *ep_ptr,
        dapl_ibal_port_t *p_port;\r
        dapl_ibal_ca_t  *p_ca;\r
        \r
-       dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: r_qual %d\n", r_qual);\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: r_qual %d psize %d\n",\r
+                    r_qual, p_size);\r
                        \r
-       /*\r
-        *  Allocate CM and initialize\r
-        */\r
-       if ((cm_ptr = dapl_os_alloc(sizeof(*cm_ptr))) == NULL ) {\r
+       cm_ptr = dapli_cm_create();\r
+       if (cm_ptr == NULL)\r
                return DAT_INSUFFICIENT_RESOURCES;\r
-       }\r
-\r
-       (void) dapl_os_memzero( cm_ptr, sizeof(*cm_ptr) );\r
-       cm_ptr->socket = -1;\r
 \r
        /* create, connect, sockopt, and exchange QP information */\r
        if ((cm_ptr->socket = socket(AF_INET,SOCK_STREAM,0)) < 0 ) {\r
-               dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );\r
+               dapli_cm_destroy(cm_ptr);\r
                return DAT_INSUFFICIENT_RESOURCES;\r
        }\r
 \r
@@ -166,7 +500,7 @@ dapli_socket_connect (      DAPL_EP                 *ep_ptr,
        if (connect(cm_ptr->socket, r_addr, sizeof(*r_addr)) == SOCKET_ERROR) {\r
                dapl_dbg_log(DAPL_DBG_TYPE_ERR, " connect: %d on r_qual %d\n",\r
                             WSAGetLastError(), (unsigned int)r_qual);\r
-               dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );\r
+               dapli_cm_destroy(cm_ptr);\r
                return DAT_INVALID_ADDRESS;\r
        }\r
 \r
@@ -175,6 +509,8 @@ dapli_socket_connect (      DAPL_EP                 *ep_ptr,
                          (const char*)&opt,\r
                          sizeof(opt) );\r
        \r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP, " socket connected!\n");\r
+\r
        /* determine QP & port numbers */\r
        ibs = ib_query_qp(ep_ptr->qp_handle, &qpa);\r
        if (ibs != IB_SUCCESS)\r
@@ -187,7 +523,6 @@ dapli_socket_connect (      DAPL_EP                 *ep_ptr,
        /* Send QP info, IA address and private data */\r
        cm_ptr->dst.qpn = qpa.num; /* ib_net32_t */\r
        cm_ptr->dst.port = cl_hton16(ia_ptr->hca_ptr->port_num);\r
-\r
        cm_ptr->dst.lid = dapli_get_lid( ia_ptr->hca_ptr, \r
                                         ia_ptr->hca_ptr->port_num );\r
        if (cm_ptr->dst.lid == 0)\r
@@ -197,6 +532,17 @@ dapli_socket_connect (     DAPL_EP                 *ep_ptr,
                                __FUNCTION__, __LINE__); \r
                goto bail;\r
        }\r
+\r
+       /* set gid in network order */\r
+       ibs = dapls_ib_query_gid( ia_ptr->hca_ptr, &cm_ptr->dst.gid );\r
+       if ( ibs != IB_SUCCESS )\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
+                       "%s() dapls_ib_query_gid() returns '%s'\n",\r
+                       __FUNCTION__,ib_get_err_str(ibs)); \r
+               goto bail;\r
+       }\r
+\r
        cm_ptr->dst.ia_address = ia_ptr->hca_ptr->hca_address;\r
        cm_ptr->dst.p_size = cl_hton32(p_size);\r
 \r
@@ -213,6 +559,8 @@ dapli_socket_connect (      DAPL_EP                 *ep_ptr,
                iovec[1].buf = p_data;\r
                iovec[1].len  = p_size;\r
        }\r
+\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," socket connected, write QP and private data\n"); \r
        rc = WSASend (cm_ptr->socket, iovec, (p_size ? 2:1), &len, 0, 0, NULL);\r
        if ( rc || len != (p_size + sizeof(ib_qp_cm_t)) ) {\r
                dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
@@ -225,17 +573,65 @@ dapli_socket_connect (    DAPL_EP                 *ep_ptr,
                     cm_ptr->dst.port, cm_ptr->dst.lid, \r
                     cm_ptr->dst.qpn, cm_ptr->dst.p_size ); \r
 \r
+       /* queue up to work thread to avoid blocking consumer */\r
+       cm_ptr->state = SCM_CONN_PENDING;\r
+       cm_ptr->hca = ia_ptr->hca_ptr;\r
+       cm_ptr->ep = ep_ptr;\r
+       dapli_cm_queue(cm_ptr);\r
+       return DAT_SUCCESS;\r
+bail:\r
+       /* close socket, free cm structure */\r
+       dapli_cm_destroy(cm_ptr);\r
+       return DAT_INTERNAL_ERROR;\r
+}\r
+\r
+\r
+/*\r
+ * ACTIVE: exchange QP information, called from CR thread\r
+ */\r
+void \r
+dapli_socket_connect_rtu(dp_ib_cm_handle_t cm_ptr)\r
+{\r
+       DAPL_EP         *ep_ptr = cm_ptr->ep;\r
+       DAPL_IA         *ia_ptr = cm_ptr->ep->header.owner_ia;\r
+       int             len, rc;\r
+       DWORD           ioflags;\r
+       WSABUF          iovec[1];\r
+       short           rtu_data = htons(0x0E0F);\r
+       ib_cm_events_t  event = IB_CME_DESTINATION_REJECT;\r
+       ib_api_status_t ibs;\r
+       dapl_ibal_port_t *p_port;\r
+       dapl_ibal_ca_t  *p_ca;\r
+\r
        /* read DST information into cm_ptr, overwrite SRC info */\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," connect_rtu: recv peer QP data\n"); \r
+\r
+       iovec[0].buf = (char*)&cm_ptr->dst;\r
+       iovec[0].len  = sizeof(ib_qp_cm_t);\r
        ioflags = len = 0;\r
        rc = WSARecv (cm_ptr->socket, iovec, 1, &len, &ioflags, 0, 0);\r
-       if ( rc == SOCKET_ERROR || len != sizeof(ib_qp_cm_t) ) {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR,"connect read: ERR %d rcnt=%d\n",\r
-                            WSAGetLastError(), len); \r
+       if ( rc == SOCKET_ERROR || len != sizeof(ib_qp_cm_t) ||\r
+                                       ntohs(cm_ptr->dst.ver) != DSCM_VER )\r
+       {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
+                            "connect_rtu read: ERR %d rcnt=%d ver=%d\n",\r
+                            WSAGetLastError(), len, cm_ptr->dst.ver); \r
                goto bail;\r
        }\r
 \r
-       /* revert back to host byte ordering */\r
+       /* check for consumer reject */\r
+       if (cm_ptr->dst.rej) {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_CM, \r
+                            " connect_rtu read: PEER REJ reason=0x%x\n",\r
+                            ntohs(cm_ptr->dst.rej)); \r
+               event = IB_CME_DESTINATION_REJECT_PRIVATE_DATA;\r
+               goto bail;\r
+       }\r
+\r
+       /* convert peer response values to host order */\r
        cm_ptr->dst.port = cl_ntoh16(cm_ptr->dst.port);\r
+       cm_ptr->dst.lid = ntohs(cm_ptr->dst.lid);\r
+       cm_ptr->dst.qpn = cm_ptr->dst.qpn;\r
        cm_ptr->dst.p_size = cl_ntoh32(cm_ptr->dst.p_size);\r
 \r
        dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: Rx DST: qpn %x port %d "\r
@@ -245,15 +641,27 @@ dapli_socket_connect (    DAPL_EP                 *ep_ptr,
                        cm_ptr->dst.p_size,\r
                        dapli_get_ip_addr_str(&cm_ptr->dst.ia_address,NULL));\r
 \r
+       /* save remote address information */\r
+       dapl_os_memcpy( &ep_ptr->remote_ia_address, \r
+                       &cm_ptr->dst.ia_address, \r
+                       sizeof(ep_ptr->remote_ia_address));\r
+\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP, \r
+                    " connect_rtu: DST %s port=0x%x lid=0x%x, qpn=0x%x, psize=%d\n",\r
+                    inet_ntoa(((struct sockaddr_in *)&cm_ptr->dst.ia_address)->sin_addr),\r
+                    cm_ptr->dst.port, cm_ptr->dst.lid, \r
+                    cm_ptr->dst.qpn, cm_ptr->dst.p_size); \r
+\r
        /* validate private data size before reading */\r
-       if ( cm_ptr->dst.p_size > IB_MAX_REP_PDATA_SIZE ) {\r
+       if (cm_ptr->dst.p_size > IB_MAX_REP_PDATA_SIZE) {\r
                dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
-                            " connect read: psize (%d) wrong\n",\r
+                            " connect_rtu read: psize (%d) wrong\n",\r
                             cm_ptr->dst.p_size ); \r
                goto bail;\r
        }\r
 \r
        /* read private data into cm_handle if any present */\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," socket connected, read private data\n"); \r
        if ( cm_ptr->dst.p_size ) {\r
                iovec[0].buf = cm_ptr->p_data;\r
                iovec[0].len  = cm_ptr->dst.p_size;\r
@@ -300,32 +708,29 @@ dapli_socket_connect (    DAPL_EP                 *ep_ptr,
                 \r
        ep_ptr->qp_state = IB_QP_STATE_RTS;\r
 \r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," connect_rtu: send RTU\n"); \r
+\r
        /* complete handshake after final QP state change */\r
        send(cm_ptr->socket, (const char *)&rtu_data, sizeof(rtu_data), 0);\r
 \r
        /* init cm_handle and post the event with private data */\r
        ep_ptr->cm_handle = cm_ptr;\r
+       cm_ptr->state = SCM_CONNECTED;\r
        dapl_dbg_log( DAPL_DBG_TYPE_EP," ACTIVE: connected!\n" ); \r
 \r
        dapl_evd_connection_callback(   ep_ptr->cm_handle, \r
                                        IB_CME_CONNECTED, \r
                                        cm_ptr->p_data, \r
                                        ep_ptr );       \r
-       return DAT_SUCCESS;\r
-\r
+       return;\r
 bail:\r
        /* close socket, free cm structure and post error event */\r
-       if ( cm_ptr->socket >= 0 ) \r
-               closesocket(cm_ptr->socket);\r
-\r
-       dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );\r
-       dapls_ib_reinit_ep( ep_ptr ); /* reset QP state */\r
-\r
-       dapl_evd_connection_callback(   ep_ptr->cm_handle, \r
-                                       IB_CME_LOCAL_FAILURE, \r
+       dapli_cm_destroy(cm_ptr);\r
+       dapls_ib_reinit_ep(ep_ptr); /* reset QP state */\r
+       dapl_evd_connection_callback(   NULL /*ep_ptr->cm_handle*/, \r
+                                       event, \r
                                        NULL, \r
                                        ep_ptr );\r
-       return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -347,15 +752,13 @@ dapli_socket_listen (     DAPL_IA         *ia_ptr,
                        ia_ptr, serviceID, sp_ptr);\r
 \r
        /* Allocate CM and initialize */\r
-       if ((cm_ptr = dapl_os_alloc(sizeof(*cm_ptr))) == NULL) \r
+       cm_ptr = dapli_cm_create();\r
+       if (cm_ptr == NULL)\r
                return DAT_INSUFFICIENT_RESOURCES;\r
 \r
-       (void) dapl_os_memzero( cm_ptr, sizeof( *cm_ptr ) );\r
-       \r
-       cm_ptr->socket = cm_ptr->l_socket = -1;\r
        cm_ptr->sp = sp_ptr;\r
-       cm_ptr->hca_ptr = ia_ptr->hca_ptr;\r
-       \r
+       cm_ptr->hca = ia_ptr->hca_ptr;\r
+\r
        /* bind, listen, set sockopt, accept, exchange data */\r
        if ((cm_ptr->l_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {\r
                dapl_dbg_log (DAPL_DBG_TYPE_ERR, \r
@@ -406,12 +809,9 @@ dapli_socket_listen (      DAPL_IA         *ia_ptr,
        /* set cm_handle for this service point, save listen socket */\r
        sp_ptr->cm_srvc_handle = cm_ptr;\r
 \r
-       /* add to SP->CR thread list */\r
-       dapl_llist_init_entry((DAPL_LLIST_ENTRY*)&cm_ptr->entry);\r
-       dapl_os_lock( &cm_ptr->hca_ptr->ib_trans.lock );\r
-       dapl_llist_add_tail((DAPL_LLIST_HEAD*)&cm_ptr->hca_ptr->ib_trans.list, \r
-                           (DAPL_LLIST_ENTRY*)&cm_ptr->entry, (void*)cm_ptr);\r
-       dapl_os_unlock(&cm_ptr->hca_ptr->ib_trans.lock);\r
+       /* queue up listen socket to process inbound CR's */\r
+       cm_ptr->state = SCM_LISTEN;\r
+       dapli_cm_queue(cm_ptr);\r
 \r
        dapl_dbg_log( DAPL_DBG_TYPE_CM,\r
                        " listen: qual 0x%x cr %p s_fd %d\n",\r
@@ -421,10 +821,7 @@ dapli_socket_listen (      DAPL_IA         *ia_ptr,
 bail:\r
        dapl_dbg_log( DAPL_DBG_TYPE_CM,\r
                        " listen: ERROR on conn_qual 0x%x\n",serviceID); \r
-       if ( cm_ptr->l_socket >= 0 )\r
-               closesocket( cm_ptr->l_socket );\r
-\r
-       dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );\r
+       dapli_cm_destroy(cm_ptr);\r
        return dat_status;\r
 }\r
 \r
@@ -441,6 +838,8 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
        int             len;\r
        DAT_RETURN      dat_status = DAT_SUCCESS;\r
                \r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," socket_accept\n");\r
+\r
        /* Allocate accept CM and initialize */\r
        if ((acm_ptr = dapl_os_alloc(sizeof(*acm_ptr))) == NULL) \r
                return DAT_INSUFFICIENT_RESOURCES;\r
@@ -448,8 +847,9 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
        (void) dapl_os_memzero( acm_ptr, sizeof( *acm_ptr ) );\r
        \r
        acm_ptr->socket = -1;\r
+       acm_ptr->l_socket = -1;\r
        acm_ptr->sp = cm_ptr->sp;\r
-       acm_ptr->hca_ptr = cm_ptr->hca_ptr;\r
+       acm_ptr->hca = cm_ptr->hca;\r
 \r
        len = sizeof(acm_ptr->dst.ia_address);\r
        acm_ptr->socket = accept(cm_ptr->l_socket, \r
@@ -464,27 +864,32 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
                goto bail;\r
        }\r
 \r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," socket accepted, read QP data\n"); \r
+\r
        /* read in DST QP info, IA address. check for private data */\r
        len = recv(acm_ptr->socket,(char*)&acm_ptr->dst,sizeof(ib_qp_cm_t),0);\r
-       if ( len != sizeof(ib_qp_cm_t) ) {\r
+       if ( len != sizeof(ib_qp_cm_t) || ntohs(acm_ptr->dst.ver) != DSCM_VER )\r
+       {\r
                dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
-                       " accept read: ERR %d, rcnt=%d\n",\r
-                       WSAGetLastError(), len); \r
+                       " accept read: ERR %d, rcnt=%d ver=%d\n",\r
+                       WSAGetLastError(), len, acm_ptr->dst.ver); \r
                dat_status = DAT_INTERNAL_ERROR;\r
                goto bail;\r
 \r
        }\r
-       /* revert back to host byte ordering */\r
+       /* convert accepted values to host byte ordering */\r
        acm_ptr->dst.port = cl_ntoh16(acm_ptr->dst.port);\r
+       acm_ptr->dst.lid = ntohs(acm_ptr->dst.lid);\r
+       acm_ptr->dst.qpn = acm_ptr->dst.qpn;\r
        acm_ptr->dst.p_size = cl_ntoh32(acm_ptr->dst.p_size);\r
 \r
-       dapl_dbg_log(DAPL_DBG_TYPE_EP, " accept: DST sizeof(ib_cm_t) %d qpn %x "\r
-               "port %d lid 0x%x psize %d IP %s\n",\r
-               sizeof(ib_qp_cm_t),\r
-               cl_ntoh32(acm_ptr->dst.qpn), acm_ptr->dst.port,\r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP, " accept: DST %s port 0x%x "\r
+               "lid 0x%x qpn 0x%x psize %d\n",\r
+               dapli_get_ip_addr_str(&acm_ptr->dst.ia_address,NULL),\r
+               acm_ptr->dst.port,\r
                cl_ntoh16(acm_ptr->dst.lid),\r
-               acm_ptr->dst.p_size,\r
-               dapli_get_ip_addr_str(&acm_ptr->dst.ia_address,NULL));\r
+               cl_ntoh32(acm_ptr->dst.qpn),\r
+               acm_ptr->dst.p_size);\r
 \r
        /* validate private data size before reading */\r
        if ( acm_ptr->dst.p_size > IB_MAX_REQ_PDATA_SIZE ) {\r
@@ -495,6 +900,8 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
                goto bail;\r
        }\r
 \r
+       dapl_dbg_log(DAPL_DBG_TYPE_EP," socket accepted, read private data\n");\r
+\r
        /* read private data into cm_handle if any present */\r
        if ( acm_ptr->dst.p_size ) {\r
                len = recv( acm_ptr->socket, \r
@@ -514,6 +921,8 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
                p_data = acm_ptr->p_data;\r
        }\r
        \r
+       acm_ptr->state = SCM_ACCEPTING;\r
+\r
        /* trigger CR event and return SUCCESS */\r
        dapls_cr_callback(  acm_ptr,\r
                            IB_CME_CONNECTION_REQUEST_PENDING,\r
@@ -521,153 +930,8 @@ dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
                            acm_ptr->sp );\r
 \r
        return DAT_SUCCESS;\r
-\r
-bail:\r
-       if ( acm_ptr->socket >= 0 )\r
-               closesocket( acm_ptr->socket );\r
-\r
-       dapl_os_free( acm_ptr, sizeof( *acm_ptr ) );\r
-       return DAT_INTERNAL_ERROR;\r
-}\r
-\r
-\r
-static DAT_RETURN \r
-dapli_socket_accept_final( DAPL_EP             *ep_ptr,\r
-                          DAPL_CR              *cr_ptr,\r
-                          DAT_COUNT            p_size,\r
-                          DAT_PVOID            p_data )\r
-{\r
-       DAPL_IA         *ia_ptr = ep_ptr->header.owner_ia;\r
-       dp_ib_cm_handle_t cm_ptr = cr_ptr->ib_cm_handle;\r
-       ib_qp_cm_t      qp_cm;\r
-       WSABUF          iovec[2];\r
-       int             len, rc;\r
-       short           rtu_data = 0;\r
-       ib_api_status_t ibs;\r
-       ib_qp_attr_t    qpa;\r
-       dapl_ibal_port_t *p_port;\r
-       dapl_ibal_ca_t  *p_ca;\r
-\r
-       dapl_dbg_log (DAPL_DBG_TYPE_EP, "%s() p_sz %d sock %d port %d\n",\r
-                       __FUNCTION__,p_size,cm_ptr->socket,\r
-                       ia_ptr->hca_ptr->port_num);\r
-\r
-       if (p_size >  IB_MAX_REP_PDATA_SIZE) \r
-               return DAT_LENGTH_ERROR;\r
-\r
-       /* must have a accepted socket */\r
-       if ( cm_ptr->socket < 0 )\r
-               return DAT_INTERNAL_ERROR;\r
-       \r
-       /* modify QP to RTR and then to RTS with remote info already read */\r
-\r
-       p_ca = (dapl_ibal_ca_t *) ia_ptr->hca_ptr->ib_hca_handle;\r
-       p_port = dapli_ibal_get_port (p_ca, (uint8_t)ia_ptr->hca_ptr->port_num);\r
-       if (!p_port)\r
-       {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
-                       "%s() dapli_ibal_get_port() failed @ line #%d\n",\r
-                       __FUNCTION__,__LINE__);\r
-               goto bail;\r
-       }\r
-\r
-       dapl_dbg_log(DAPL_DBG_TYPE_EP, "%s() DST: qpn %x port %d lid %x\n",\r
-                       __FUNCTION__,\r
-                       cl_ntoh32(cm_ptr->dst.qpn),\r
-                       cm_ptr->dst.port,\r
-                       cl_ntoh16(cm_ptr->dst.lid));\r
-\r
-       /* modify QP to RTR and then to RTS with remote info */\r
-\r
-       ibs = dapls_modify_qp_state_to_rtr( ep_ptr->qp_handle, \r
-                                           cm_ptr->dst.qpn,\r
-                                           cm_ptr->dst.lid,\r
-                                           p_port );\r
-       if (ibs != IB_SUCCESS)\r
-       {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
-                               "%s() QP --> RTR failed @ line #%d\n",\r
-                               __FUNCTION__,__LINE__);\r
-               goto bail;\r
-       }\r
-\r
-       if ( dapls_modify_qp_state_to_rts( ep_ptr->qp_handle ) )\r
-       {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
-                               "%s() QP --> RTS failed @ line #%d\n",\r
-                               __FUNCTION__,__LINE__);\r
-               goto bail;\r
-       }\r
-\r
-       ep_ptr->qp_state = IB_QP_STATE_RTS;\r
-       \r
-       /* determine QP & port numbers */\r
-       ibs = ib_query_qp(ep_ptr->qp_handle, &qpa);\r
-       if (ibs != IB_SUCCESS)\r
-       {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
-                            " ib_query_qp() ERR %s\n", ib_get_err_str(ibs)); \r
-               goto bail;\r
-       }\r
-\r
-       /* Send QP info, IA address, and private data */\r
-       qp_cm.qpn = qpa.num; /* ib_net32_t */\r
-       qp_cm.port = ia_ptr->hca_ptr->port_num;\r
-       qp_cm.lid = dapli_get_lid( ia_ptr->hca_ptr, ia_ptr->hca_ptr->port_num );\r
-       qp_cm.ia_address = ia_ptr->hca_ptr->hca_address;\r
-       qp_cm.p_size = p_size;\r
-\r
-       dapl_dbg_log(DAPL_DBG_TYPE_CM,\r
-               "%s()\n  Tx QP info: qpn %x port %d lid 0x%x p_sz %d IP %s\n",\r
-               __FUNCTION__, cl_ntoh32(qp_cm.qpn), qp_cm.port,\r
-               cl_ntoh16(qp_cm.lid), qp_cm.p_size,\r
-               dapli_get_ip_addr_str(&qp_cm.ia_address,NULL));\r
-\r
-       /* network byte-ordering - QPN & LID already are */\r
-       qp_cm.p_size = cl_hton32(qp_cm.p_size);\r
-       qp_cm.port = cl_hton16(qp_cm.port);\r
-\r
-       iovec[0].buf = (char*)&qp_cm;\r
-       iovec[0].len  = sizeof(ib_qp_cm_t);\r
-       if (p_size) {\r
-               iovec[1].buf = p_data;\r
-               iovec[1].len  = p_size;\r
-       }\r
-       rc = WSASend( cm_ptr->socket, iovec, (p_size ? 2:1), &len, 0, 0, 0 );\r
-       if (rc || len != (p_size + sizeof(ib_qp_cm_t))) {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
-                            " accept_final: ERR %d, wcnt=%d\n",\r
-                            WSAGetLastError(), len); \r
-               goto bail;\r
-       }\r
-       dapl_dbg_log(DAPL_DBG_TYPE_EP, \r
-                    " accept_final: SRC qpn %x port %d lid 0x%x psize %d\n",\r
-                    qp_cm.qpn, qp_cm.port, qp_cm.lid, qp_cm.p_size ); \r
-       \r
-       /* complete handshake after final QP state change */\r
-       len = recv(cm_ptr->socket, (char*)&rtu_data, sizeof(rtu_data), 0);\r
-       if ( len != sizeof(rtu_data) || ntohs(rtu_data) != 0x0e0f ) {\r
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
-                            " accept_final: ERR %d, rcnt=%d rdata=%x\n",\r
-                            WSAGetLastError(), len, ntohs(rtu_data) ); \r
-               goto bail;\r
-       }\r
-\r
-       /* final data exchange if remote QP state is good to go */\r
-       dapl_dbg_log( DAPL_DBG_TYPE_EP," PASSIVE: connected!\n" ); \r
-\r
-       dapls_cr_callback ( cm_ptr, IB_CME_CONNECTED, NULL, cm_ptr->sp );\r
-\r
-       return DAT_SUCCESS;\r
-\r
 bail:\r
-       dapl_dbg_log( DAPL_DBG_TYPE_ERR," accept_final: ERR !QP_RTR_RTS \n"); \r
-       if ( cm_ptr->socket >= 0 )\r
-               closesocket( cm_ptr->socket );\r
-\r
-       dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );\r
-       dapls_ib_reinit_ep( ep_ptr ); /* reset QP state */\r
-\r
+       dapli_cm_destroy(acm_ptr);\r
        return DAT_INTERNAL_ERROR;\r
 }\r
 \r
@@ -747,11 +1011,7 @@ dapls_ib_disconnect (
        dapl_dbg_log (DAPL_DBG_TYPE_EP,\r
                        "dapls_ib_disconnect(ep_handle %p ....)\n", ep_ptr);\r
 \r
-       if ( cm_ptr->socket >= 0 ) {\r
-               closesocket( cm_ptr->socket );\r
-               cm_ptr->socket = -1;\r
-       }\r
-       \r
+#if 0 // XXX\r
        /* disconnect QP ala transition to RESET state */\r
        ib_status = dapls_modify_qp_state_to_reset (ep_ptr->qp_handle);\r
 \r
@@ -776,15 +1036,18 @@ dapls_ib_disconnect (
                                                NULL,\r
                                                ep_ptr );\r
                ep_ptr->cm_handle = NULL;\r
-               dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );\r
        }       \r
-\r
+#endif\r
        /* modify QP state --> INIT */\r
        dapls_ib_reinit_ep(ep_ptr);\r
 \r
-       return DAT_SUCCESS;\r
+       if (cm_ptr == NULL)\r
+               return DAT_SUCCESS;\r
+       else\r
+               return dapli_socket_disconnect(cm_ptr);\r
 }\r
 \r
+\r
 /*\r
  * dapls_ib_disconnect_clean\r
  *\r
@@ -819,7 +1082,7 @@ dapls_ib_disconnect_clean (
  *\r
  * Input:\r
  *     ibm_hca_handle          HCA handle\r
- *     qp_handle                       QP handle\r
+ *     qp_handle               QP handle\r
  *\r
  * Output:\r
  *     none\r
@@ -874,14 +1137,20 @@ dapls_ib_remove_conn_listener (
        if ( cm_ptr != NULL ) {\r
                if ( cm_ptr->l_socket >= 0 ) {\r
                        closesocket( cm_ptr->l_socket );\r
+                       cm_ptr->l_socket = -1;\r
+               }\r
+               if ( cm_ptr->socket >= 0 ) {\r
+                       closesocket( cm_ptr->socket );\r
                        cm_ptr->socket = -1;\r
                }\r
                /* cr_thread will free */\r
                sp_ptr->cm_srvc_handle = NULL;\r
+               _write(g_scm_pipe[1], "w", sizeof "w");\r
        }\r
        return DAT_SUCCESS;\r
 }\r
 \r
+\r
 /*\r
  * dapls_ib_accept_connection\r
  *\r
@@ -928,7 +1197,7 @@ dapls_ib_accept_connection (
                        return status;\r
        }\r
     \r
-       return ( dapli_socket_accept_final(ep_ptr, cr_ptr, p_size, p_data) );\r
+       return ( dapli_socket_accept_usr(ep_ptr, cr_ptr, p_size, p_data) );\r
 }\r
 \r
 \r
@@ -948,25 +1217,39 @@ dapls_ib_accept_connection (
  *     DAT_INTERNAL_ERROR\r
  *\r
  */\r
+\r
 DAT_RETURN\r
 dapls_ib_reject_connection (\r
-       IN  dp_ib_cm_handle_t   ib_cm_handle,\r
-       IN  int                 reject_reason )\r
+       IN  dp_ib_cm_handle_t   cm_ptr,\r
+       IN  int                 reject_reason,\r
+       IN  DAT_COUNT           psize,\r
+       IN  const DAT_PVOID     pdata)\r
 {\r
-       ib_cm_srvc_handle_t     cm_ptr = ib_cm_handle;\r
+       WSABUF  iovec[1];\r
+       int     len;\r
 \r
        dapl_dbg_log (DAPL_DBG_TYPE_EP,\r
-                     "dapls_ib_reject_connection(cm_handle %p reason %x)\n",\r
-                     ib_cm_handle, reject_reason );\r
-\r
-       /* just close the socket and return */\r
-       if ( cm_ptr->socket > 0 ) {\r
-               closesocket( cm_ptr->socket );\r
+                     " reject(cm %p reason %x pdata %p psize %d)\n",\r
+                     cm_ptr, reject_reason, pdata, psize );\r
+\r
+       /* write reject data to indicate reject */\r
+       if (cm_ptr->socket >= 0) {\r
+               cm_ptr->dst.rej = (uint16_t)reject_reason;\r
+               cm_ptr->dst.rej = cl_hton16(cm_ptr->dst.rej);\r
+               iovec[0].buf = (char*)&cm_ptr->dst;\r
+               iovec[0].len  = sizeof(ib_qp_cm_t);\r
+               (void) WSASend (cm_ptr->socket, iovec, 1, &len, 0, 0, NULL);\r
+               closesocket(cm_ptr->socket);\r
                cm_ptr->socket = -1;\r
        }\r
+\r
+       /* cr_thread will destroy CR */\r
+       cm_ptr->state = SCM_REJECTED;\r
+        _write(g_scm_pipe[1], "w", sizeof "w");\r
        return DAT_SUCCESS;\r
 }\r
 \r
+\r
 /*\r
  * dapls_ib_cm_remote_addr\r
  *\r
@@ -1019,6 +1302,7 @@ dapls_ib_cm_remote_addr (
  * Input:\r
  *     prd_ptr         private data pointer\r
  *     conn_op         connection operation type\r
+ *      hca_ptr         hca pointer, needed for transport type\r
  *\r
  * If prd_ptr is NULL, this is a query for the max size supported by\r
  * the provider, otherwise it is the actual size of the private data\r
@@ -1034,7 +1318,8 @@ dapls_ib_cm_remote_addr (
  */\r
 int dapls_ib_private_data_size (\r
        IN      DAPL_PRIVATE    *prd_ptr,\r
-       IN      DAPL_PDATA_OP   conn_op)\r
+       IN      DAPL_PDATA_OP   conn_op,\r
+       IN      DAPL_HCA        *hca_ptr)\r
 {\r
        int  size;\r
 \r
@@ -1153,7 +1438,7 @@ dapls_ib_get_dat_event (
 \r
 \r
 /*\r
- * dapls_ib_get_dat_event\r
+ * dapls_ib_get_cm_event\r
  *\r
  * Return a DAT connection event given a provider CM event.\r
  * \r
@@ -1185,12 +1470,16 @@ dapls_ib_get_cm_event (
 }\r
 #endif /* NOT_USED */\r
 \r
-/* async CR processing thread to avoid blocking applications */\r
+/* outbound/inbound CR processing thread to avoid blocking applications */\r
+\r
+#define SCM_MAX_CONN (8 * sizeof(fd_set))\r
+\r
 void cr_thread(void *arg) \r
 {\r
     struct dapl_hca    *hca_ptr = arg;\r
     ib_cm_srvc_handle_t        cr, next_cr;\r
     int                        max_fd, rc;\r
+    char               rbuf[2];\r
     fd_set             rfd, rfds;\r
     struct timeval     to;\r
      \r
@@ -1198,10 +1487,12 @@ void cr_thread(void *arg)
 \r
     dapl_os_lock( &hca_ptr->ib_trans.lock );\r
     hca_ptr->ib_trans.cr_state = IB_THREAD_RUN;\r
+\r
     while (hca_ptr->ib_trans.cr_state == IB_THREAD_RUN) {\r
        \r
        FD_ZERO( &rfds ); \r
-       max_fd = -1;\r
+       FD_SET(g_scm_pipe[0], &rfds);\r
+       max_fd = g_scm_pipe[0];\r
        \r
        if (!dapl_llist_is_empty((DAPL_LLIST_HEAD*)&hca_ptr->ib_trans.list))\r
             next_cr = dapl_llist_peek_head((DAPL_LLIST_HEAD*)\r
@@ -1226,32 +1517,46 @@ void cr_thread(void *arg)
                continue;\r
            }\r
                  \r
-           FD_SET( cr->l_socket, &rfds ); /* add to select set */\r
-           if ( cr->l_socket > max_fd )\r
+           if (cr->socket > SCM_MAX_CONN-1) {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_ERR, \r
+                            "SCM ERR: cr->socket(%d) exceeded FD_SETSIZE %d\n",\r
+                               cr->socket,SCM_MAX_CONN-1);\r
+               continue;\r
+           }\r
+           FD_SET( cr->socket, &rfds ); /* add to select SET */\r
+           if ( cr->socket > max_fd )\r
                max_fd = cr->l_socket;\r
 \r
            /* individual select poll to check for work */\r
            FD_ZERO(&rfd);\r
-           FD_SET(cr->l_socket, &rfd);\r
+           FD_SET(cr->socket, &rfd);\r
            dapl_os_unlock(&hca_ptr->ib_trans.lock);    \r
 \r
            to.tv_sec  = 0;\r
            to.tv_usec = 0; /* wakeup and check destroy */\r
 \r
            /* block waiting for Rx data */\r
-           if (select(cr->l_socket+1,&rfd,NULL,NULL,&to) == SOCKET_ERROR) {\r
+           if (select(cr->socket+1,&rfd,NULL,NULL,&to) == SOCKET_ERROR) {\r
                rc = WSAGetLastError();\r
                if ( rc != SOCKET_ERROR /*WSAENOTSOCK*/ )\r
                {\r
                    dapl_dbg_log (DAPL_DBG_TYPE_ERR/*CM*/,\r
                                " thread: select(sock %d) ERR %d on cr %p\n",\r
-                               cr->l_socket, rc, cr);\r
+                               cr->socket, rc, cr);\r
+               }\r
+               closesocket(cr->socket);\r
+               cr->socket = -1;\r
+           } else if (FD_ISSET(cr->socket,&rfd)) {\r
+               if (cr->socket > 0) {\r
+                       if (cr->state == SCM_LISTEN) \r
+                               dapli_socket_accept(cr);\r
+                       else if (cr->state == SCM_ACCEPTED)\r
+                               dapli_socket_accept_rtu(cr);\r
+                       else if (cr->state == SCM_CONN_PENDING)\r
+                               dapli_socket_connect_rtu(cr);\r
+                       else if (cr->state == SCM_CONNECTED)\r
+                               dapli_socket_disconnect(cr);\r
                }\r
-               closesocket(cr->l_socket);\r
-               cr->l_socket = -1;\r
-           } else if (FD_ISSET(cr->l_socket,&rfd) && dapli_socket_accept(cr)) {\r
-               closesocket(cr->l_socket);\r
-               cr->l_socket = -1;\r
            }\r
            dapl_os_lock( &hca_ptr->ib_trans.lock );\r
            next_cr =  dapl_llist_next_entry((DAPL_LLIST_HEAD*)\r
@@ -1259,9 +1564,19 @@ void cr_thread(void *arg)
                                             (DAPL_LLIST_ENTRY*)&cr->entry );\r
        }\r
        dapl_os_unlock( &hca_ptr->ib_trans.lock );\r
+\r
        to.tv_sec  = 0;\r
        to.tv_usec = 100000; /* wakeup and check destroy */\r
+\r
        (void) select(max_fd+1, &rfds, NULL, NULL, &to);\r
+\r
+       /* if pipe data consume - used to wake this thread up */\r
+       if (FD_ISSET(g_scm_pipe[0],&rfds)) {\r
+               dapl_dbg_log(DAPL_DBG_TYPE_CM," cr_thread() read pipe data\n");\r
+printf(" cr_thread() read pipe data\n");\r
+               _read(g_scm_pipe[0], rbuf, 2);\r
+printf(" cr_thread() Finished read pipe data\n");\r
+       }\r
        dapl_os_lock( &hca_ptr->ib_trans.lock );\r
     }\r
     dapl_os_unlock( &hca_ptr->ib_trans.lock ); \r
index 1595004..f8e7077 100644 (file)
@@ -61,9 +61,11 @@ static const char rcsid[] = "$Id:  $";
 #include <winsock2.h>\r
 #include <ws2tcpip.h>\r
 #include <io.h>\r
+#include <fcntl.h>\r
 \r
 \r
 int g_dapl_loopback_connection = 0;\r
+int g_scm_pipe[2];\r
 \r
 #ifdef NOT_USED\r
 \r
@@ -132,22 +134,55 @@ DAT_RETURN dapli_init_sock_cm ( IN DAPL_HCA  *hca_ptr )
 \r
        dapl_dbg_log (DAPL_DBG_TYPE_UTIL, " %s(): %p\n",__FUNCTION__,hca_ptr );\r
 \r
-       /* set inline max with enviroment or default */\r
+       /* set RC tunables via enviroment or default */\r
        hca_ptr->ib_trans.max_inline_send = \r
-               dapl_os_get_env_val ( "DAPL_MAX_INLINE", INLINE_SEND_DEFAULT );\r
+               dapl_os_get_env_val("DAPL_MAX_INLINE", INLINE_SEND_DEFAULT);\r
+#if 0\r
+       hca_ptr->ib_trans.ack_retry = \r
+               dapl_os_get_env_val("DAPL_ACK_RETRY", SCM_ACK_RETRY);\r
+       hca_ptr->ib_trans.ack_timer =\r
+               dapl_os_get_env_val("DAPL_ACK_TIMER", SCM_ACK_TIMER);\r
+       hca_ptr->ib_trans.rnr_retry = \r
+               dapl_os_get_env_val("DAPL_RNR_RETRY", SCM_RNR_RETRY);\r
+       hca_ptr->ib_trans.rnr_timer = \r
+               dapl_os_get_env_val("DAPL_RNR_TIMER", SCM_RNR_TIMER);\r
+       hca_ptr->ib_trans.global =\r
+               dapl_os_get_env_val("DAPL_GLOBAL_ROUTING", SCM_GLOBAL);\r
+       hca_ptr->ib_trans.hop_limit =\r
+               dapl_os_get_env_val("DAPL_HOP_LIMIT", SCM_HOP_LIMIT);\r
+       hca_ptr->ib_trans.tclass =\r
+               dapl_os_get_env_val("DAPL_TCLASS", SCM_TCLASS);\r
+#endif\r
 \r
        /* initialize cr_list lock */\r
        dat_status = dapl_os_lock_init(&hca_ptr->ib_trans.lock);\r
        if (dat_status != DAT_SUCCESS)\r
        {\r
                dapl_dbg_log (DAPL_DBG_TYPE_ERR, \r
-                               " open_hca: failed to init lock\n");\r
+                       "%s() failed to init cr_list lock\n", __FUNCTION__);\r
                return DAT_INTERNAL_ERROR;\r
        }\r
 \r
+#if 0\r
+       /* initialize cq_lock */\r
+       dat_status = dapl_os_lock_init(&hca_ptr->ib_trans.cq_lock);\r
+       if (dat_status != DAT_SUCCESS) {\r
+               dapl_log(DAPL_DBG_TYPE_ERR, \r
+                        "%s() failed to init cq_lock\n", __FUNCTION__);\r
+               return DAT_INTERNAL_ERROR;\r
+       }\r
+#endif\r
+\r
        /* initialize CM list for listens on this HCA */\r
        dapl_llist_init_head((DAPL_LLIST_HEAD*)&hca_ptr->ib_trans.list);\r
 \r
+       /* create pipe communication endpoints */\r
+       if (_pipe(g_scm_pipe, 256, O_TEXT)) {\r
+               dapl_dbg_log (DAPL_DBG_TYPE_ERR, \r
+                       "%s() failed to create thread\n", __FUNCTION__);\r
+               return DAT_INTERNAL_ERROR;\r
+       }\r
+\r
        /* create thread to process inbound connect request */\r
        hca_ptr->ib_trans.cr_state = IB_THREAD_INIT;\r
        dat_status = dapl_os_thread_create(cr_thread, \r
@@ -199,6 +234,7 @@ DAT_RETURN dapli_close_sock_cm ( IN DAPL_HCA  *hca_ptr )
 \r
        /* destroy cr_thread and lock */\r
        hca_ptr->ib_trans.cr_state = IB_THREAD_CANCEL;\r
+\r
        while (hca_ptr->ib_trans.cr_state != IB_THREAD_EXIT) {\r
                dapl_dbg_log(DAPL_DBG_TYPE_UTIL, \r
                             " close_hca: waiting for cr_thread\n");\r
@@ -208,4 +244,4 @@ DAT_RETURN dapli_close_sock_cm ( IN DAPL_HCA  *hca_ptr )
 \r
        return (DAT_SUCCESS);\r
 }\r
-  \r
\r
index fdfe362..e2c5b43 100644 (file)
@@ -145,7 +145,7 @@ dapli_ib_cm_dreq_cb (
            && ep_ptr->sent_discreq == DAT_TRUE)*/ )\r
     {\r
         dapl_os_unlock (&ep_ptr->header.lock);\r
-        dapl_dbg_log (DAPL_DBG_TYPE_ERR/*CM*/\r
+        dapl_dbg_log (DAPL_DBG_TYPE_CM\r
                       "--> DiCDcb: EP %lx QP %lx already Disconnected\n",\r
                       ep_ptr, ep_ptr->qp_handle);\r
         return;\r
@@ -159,11 +159,11 @@ dapli_ib_cm_dreq_cb (
 \r
     /* Could fail if we received reply from other side, no need to retry */\r
     /* Wait for any send ops in process holding reference */\r
-    while ( dapl_os_atomic_read(&ep_ptr->req_count) && bail-- > 0 )\r
+    while (dapls_cb_pending(&ep_ptr->req_buffer) && bail-- > 0 )\r
     {\r
        dapl_dbg_log (DAPL_DBG_TYPE_CM, \r
                   "--> DiCDcb: WAIT for EP=%lx req_count(%d) != 0\n", \r
-                  ep_ptr, dapl_os_atomic_read(&ep_ptr->req_count));\r
+                  ep_ptr, dapls_cb_pending(&ep_ptr->req_buffer));\r
        dapl_os_sleep_usec (100);\r
     }\r
 \r
@@ -316,7 +316,7 @@ dapli_ib_cm_rep_cb (
         cm_cb_op = IB_CME_CONNECTED;\r
         dapl_dbg_log (DAPL_DBG_TYPE_CM, \r
                   "--> DiCRpcb: EP %lx Connected req_count %d\n", \r
-                  ep_ptr, dapl_os_atomic_read(&ep_ptr->req_count));\r
+                  ep_ptr, dapls_cb_pending(&ep_ptr->req_buffer));\r
     }\r
     else\r
     {\r
@@ -1264,7 +1264,9 @@ dapls_ib_remove_conn_listener (
  */\r
 DAT_RETURN\r
 dapls_ib_reject_connection ( IN  dp_ib_cm_handle_t   ib_cm_handle,\r
-                             IN  int                 reject_reason )\r
+                             IN  int                 reject_reason,\r
+                             IN  DAT_COUNT           private_data_size,\r
+                             IN  const DAT_PVOID     private_data)\r
 {\r
     ib_api_status_t        ib_status;\r
     ib_cm_rej_t            cm_rej;\r
@@ -1290,8 +1292,8 @@ dapls_ib_reject_connection ( IN  dp_ib_cm_handle_t   ib_cm_handle,
     cm_rej.rej_status   = IB_REJ_USER_DEFINED;\r
     cm_rej.p_ari        = (ib_ari_t *)&rej_table[reject_reason]; \r
     cm_rej.ari_length   = (uint8_t)strlen (rej_table[reject_reason]);\r
-    cm_rej.p_rej_pdata  = NULL;\r
-    cm_rej.rej_length   = 0;\r
+    cm_rej.p_rej_pdata  = private_data;\r
+    cm_rej.rej_length   = private_data_size;\r
 \r
     ib_status = ib_cm_rej ( *ib_cm_handle, &cm_rej);\r
 \r
@@ -1303,7 +1305,6 @@ dapls_ib_reject_connection ( IN  dp_ib_cm_handle_t   ib_cm_handle,
     }\r
 \r
     return ( dapl_ib_status_convert ( ib_status ) );\r
-\r
 }\r
 \r
 \r
@@ -1507,7 +1508,7 @@ dapls_ib_accept_connection (
     dapl_dbg_log (DAPL_DBG_TYPE_CM,\r
                  "--> DsIBAC: cm_rep: acc %x init %d qp_type %x req_count %d\n",\r
                 cm_rep.access_ctrl, cm_rep.init_depth,cm_rep.qp_type,\r
-                 dapl_os_atomic_read(&ep_ptr->req_count));\r
+                 dapls_cb_pending(&ep_ptr->req_buffer));\r
 \r
     ib_status = ib_cm_rep ( *ep_ptr->cm_handle, &cm_rep );\r
 \r
@@ -1715,6 +1716,7 @@ dapls_ib_cr_handoff (
  * Input:\r
  *     prd_ptr         private data pointer\r
  *     conn_op         connection operation type\r
+ *     hca_ptr         hca pointer, needed for transport type\r
  *\r
  * If prd_ptr is NULL, this is a query for the max size supported by\r
  * the provider, otherwise it is the actual size of the private data\r
@@ -1732,11 +1734,13 @@ dapls_ib_cr_handoff (
 int\r
 dapls_ib_private_data_size (\r
        IN      DAPL_PRIVATE            *prd_ptr,\r
-       IN      DAPL_PDATA_OP           conn_op)\r
+       IN      DAPL_PDATA_OP           conn_op,\r
+       IN      DAPL_HCA                *hca_ptr)\r
 {\r
     int  size;\r
 \r
     UNUSED_PARAM( prd_ptr );\r
+    UNUSED_PARAM( hca_ptr );\r
 \r
     switch (conn_op)\r
     {\r
index f6c3bba..618cbae 100644 (file)
@@ -172,7 +172,7 @@ dapli_post_ext( IN       DAT_EP_HANDLE              ep_handle,
 {\r
        DAPL_EP         *ep_ptr;\r
        ib_qp_handle_t  qp_ptr;\r
-       DAPL_COOKIE     *cookie=NULL;\r
+       DAPL_COOKIE     *cookie;\r
        DAT_RETURN      dat_status = DAT_SUCCESS;\r
 \r
        dapl_dbg_log(DAPL_DBG_TYPE_API,\r
@@ -210,12 +210,6 @@ dapli_post_ext( IN       DAT_EP_HANDLE             ep_handle,
                goto bail;\r
        }\r
                \r
-       /*\r
-        * Take reference before posting to avoid race conditions with\r
-        * completions\r
-        */\r
-       dapl_os_atomic_inc(&ep_ptr->req_count);\r
-\r
        /*\r
         * Invoke provider specific routine to post DTO\r
         */\r
@@ -232,7 +226,6 @@ dapli_post_ext( IN       DAT_EP_HANDLE              ep_handle,
 \r
        if (dat_status != DAT_SUCCESS)\r
        {\r
-               dapl_os_atomic_dec(&ep_ptr->req_count);\r
                dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);\r
 #ifdef DAPL_DBG\r
                dapl_dbg_log(DAPL_DBG_TYPE_ERR,\r
index 098a13f..7ab121c 100644 (file)
@@ -58,8 +58,6 @@ dapli_ib_sa_query_cb (
         IN    ib_query_rec_t       *p_query_rec );\r
 \r
 \r
-//DAT_RETURN dapls_ns_init (void);\r
-\r
 #ifdef NO_NAME_SERVICE\r
 \r
 DAT_RETURN dapls_ns_lookup_address (\r
index 7d327e0..b09573d 100644 (file)
@@ -1541,6 +1541,63 @@ dapls_ib_setup_async_callback (
 }\r
 \r
 \r
+/*\r
+ * dapls_ib_query_gid\r
+ *\r
+ * Query the hca for the gid of the 1st active port.\r
+ *\r
+ * Input:\r
+ *     hca_handl               hca handle      \r
+ *     ep_attr                 attribute of the ep\r
+ *\r
+ * Output:\r
+ *     none\r
+ *\r
+ * Returns:\r
+ *     DAT_SUCCESS\r
+ *     DAT_INVALID_HANDLE\r
+ *     DAT_INVALID_PARAMETER\r
+ */\r
+\r
+DAT_RETURN\r
+dapls_ib_query_gid( IN  DAPL_HCA       *hca_ptr,\r
+                   IN  GID             *gid )\r
+{\r
+    dapl_ibal_ca_t    *p_ca;\r
+    ib_ca_attr_t      *p_hca_attr;\r
+    ib_api_status_t   ib_status;\r
+    ib_hca_port_t     port_num;\r
+\r
+    p_ca = (dapl_ibal_ca_t *) hca_ptr->ib_hca_handle;\r
+\r
+    if (p_ca == NULL)\r
+    {\r
+        dapl_dbg_log ( DAPL_DBG_TYPE_ERR,\r
+                       "%s() invalid hca_ptr %p", __FUNCTION__, hca_ptr);\r
+        return DAT_INVALID_HANDLE;\r
+    }\r
+\r
+    ib_status = ib_query_ca (\r
+                          p_ca->h_ca,\r
+                          p_ca->p_ca_attr,\r
+                          &p_ca->ca_attr_size);\r
+    if (ib_status != IB_SUCCESS)\r
+    {\r
+        dapl_dbg_log ( DAPL_DBG_TYPE_ERR,\r
+                       "%s() ib_query_ca returned failed status = %s\n", \r
+                       ib_get_err_str(ib_status));\r
+        return dapl_ib_status_convert (ib_status);\r
+    }\r
+\r
+    p_hca_attr = p_ca->p_ca_attr;\r
+    port_num = hca_ptr->port_num - 1;\r
+\r
+    gid->gid_prefix = p_hca_attr->p_port_attr[port_num].p_gid_table->unicast.prefix;\r
+    gid->guid = p_hca_attr->p_port_attr[port_num].p_gid_table->unicast.interface_id;\r
+    return DAT_SUCCESS;\r
+}\r
+\r
+\r
 /*\r
  * dapls_ib_query_hca\r
  *\r
index e33afeb..7c0a469 100644 (file)
@@ -398,6 +398,7 @@ struct ib_llist_entry
 };\r
 \r
 #ifdef SOCK_CM\r
+\r
 typedef enum\r
 {\r
        IB_THREAD_INIT,\r
@@ -406,7 +407,22 @@ typedef enum
        IB_THREAD_EXIT\r
 \r
 } ib_thread_state_t;\r
-#endif\r
+\r
+typedef enum scm_state \r
+{\r
+       SCM_INIT,\r
+       SCM_LISTEN,\r
+       SCM_CONN_PENDING,\r
+       SCM_ACCEPTING,\r
+       SCM_ACCEPTED,\r
+       SCM_REJECTED,\r
+       SCM_CONNECTED,\r
+       SCM_DISCONNECTED,\r
+       SCM_DESTROY\r
+\r
+} SCM_STATE;\r
+\r
+#endif /* SOCK_CM */\r
 \r
 typedef struct _ib_hca_transport\r
 { \r
@@ -437,30 +453,38 @@ typedef uint32_t ib_shm_transport_t;
 \r
 /* CM mappings use SOCKETS */\r
 \r
-/* destination info to exchange until real IB CM shows up */\r
+/* destination info exchanged between dapl, define wire protocol version */\r
+#define DSCM_VER 2\r
+\r
 typedef struct _ib_qp_cm\r
 { \r
-       GID                             gid;\r
-       ib_net32_t              qpn;\r
-       ib_net16_t              lid;\r
-       ib_net16_t              port;\r
-       ib_net32_t              p_size;\r
-       DAT_SOCK_ADDR6          ia_address;\r
+       ib_net16_t      ver;\r
+       ib_net16_t      rej;\r
+       ib_net16_t      lid;\r
+       ib_net16_t      port;\r
+       ib_net32_t      qpn;\r
+       ib_net32_t      p_size;\r
+       DAT_SOCK_ADDR6  ia_address;\r
+       GID             gid;\r
 \r
 } ib_qp_cm_t;\r
 \r
 struct ib_cm_handle\r
 { \r
        struct ib_llist_entry   entry;\r
+       DAPL_OS_LOCK            lock;\r
+       SCM_STATE               state;\r
        int                     socket;\r
        int                     l_socket; \r
-       struct dapl_hca         *hca_ptr;\r
-       DAT_HANDLE              cr;\r
+       struct dapl_hca         *hca;\r
        DAT_HANDLE              sp;     \r
+       DAT_HANDLE              cr;\r
+       struct dapl_ep          *ep;\r
        ib_qp_cm_t              dst;\r
        unsigned char           p_data[256];\r
 };\r
-#endif\r
+\r
+#endif /* SOCK_CM */\r
 \r
 /*\r
  * Prototype\r
index 17b6840..4264863 100644 (file)
@@ -458,18 +458,9 @@ struct dapl_ep
     /* private data container */\r
     DAPL_PRIVATE               private;\r
 \r
-    /* DTO data */\r
-    DAPL_ATOMIC                        req_count;\r
-    DAPL_ATOMIC                        recv_count;\r
-\r
     DAPL_COOKIE_BUFFER req_buffer;\r
     DAPL_COOKIE_BUFFER recv_buffer;\r
 \r
-    ib_data_segment_t  *recv_iov;\r
-    DAT_COUNT                  recv_iov_num;\r
-\r
-    ib_data_segment_t  *send_iov;\r
-    DAT_COUNT                  send_iov_num;\r
 #ifdef DAPL_DBG_IO_TRC\r
     int                        ibt_dumped;\r
     struct io_buf_track *ibt_base;\r
index b096fdb..c7ade44 100644 (file)
@@ -75,14 +75,16 @@ typedef enum
     DAPL_DBG_DEST_SYSLOG       = 0x0002,\r
 } DAPL_DBG_DEST;\r
 \r
-\r
-#if defined(DAPL_DBG)\r
-\r
 extern DAPL_DBG_TYPE   g_dapl_dbg_type;\r
 extern DAPL_DBG_DEST   g_dapl_dbg_dest;\r
 \r
+extern void dapl_internal_dbg_log(DAPL_DBG_TYPE type,  const char *fmt,  ...);\r
+\r
+#define dapl_log g_dapl_dbg_type==0 ? (void) 1 : dapl_internal_dbg_log\r
+\r
+#if defined(DAPL_DBG)\r
+\r
 #define dapl_dbg_log g_dapl_dbg_type==0 ? (void) 1 : dapl_internal_dbg_log\r
-extern void dapl_internal_dbg_log ( DAPL_DBG_TYPE type,  const char *fmt,  ...);\r
 \r
 #else  /* !DAPL_DBG */\r
 \r
index 533ba37..ae68af4 100644 (file)
  * Product name of the adapter.\r
  * Returned in DAT_IA_ATTR.adapter_name\r
  */\r
-#define VN_ADAPTER_NAME                "Generic InfiniBand HCA"\r
+#define VN_ADAPTER_NAME                "Generic OpenFabrics HCA"\r
 \r
 \r
 /*\r
  * Vendor name\r
  * Returned in DAT_IA_ATTR.vendor_name\r
  */\r
-#define VN_VENDOR_NAME         "DAPL Reference Implementation"\r
+#define VN_VENDOR_NAME         "DAPL OpenFabrics Implementation"\r
 \r
 \r
 /**********************************************************************\r
index 6c538ff..d8e9c28 100644 (file)
@@ -70,16 +70,21 @@ void dapl_init ( void )
 {\r
     DAT_RETURN         dat_status;\r
 \r
-#if defined(DAPL_DBG)\r
-    dapl_dbg_log (DAPL_DBG_TYPE_UTIL, "DAPL:  (dapl_init)\n");\r
-\r
     /* set up debug type */\r
     g_dapl_dbg_type = dapl_os_get_env_val ( "DAPL_DBG_TYPE", \r
                                            DAPL_DBG_TYPE_ERR | DAPL_DBG_TYPE_WARN);\r
     /* set up debug destination */\r
     g_dapl_dbg_dest = dapl_os_get_env_val ( "DAPL_DBG_DEST", \r
                                            DAPL_DBG_DEST_STDOUT );\r
-#endif /* DAPL_DBG */\r
+\r
+#ifdef __linux__\r
+    /* open log file on first logging call if necessary */\r
+    if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)\r
+       openlog("libdapl", LOG_ODELAY|LOG_PID|LOG_CONS, LOG_USER);\r
+#endif\r
+       \r
+    dapl_log (DAPL_DBG_TYPE_UTIL, "dapl_init: dbg_type=0x%x,dbg_dest=0x%x\n",\r
+             g_dapl_dbg_type, g_dapl_dbg_dest);\r
 \r
     /* See if the user is on a loopback setup */\r
     g_dapl_loopback_connection = dapl_os_get_env_bool ( "DAPL_LOOPBACK" );\r
index 90676fc..1ac8adf 100644 (file)
@@ -54,7 +54,7 @@
 #endif\r
 \r
 \r
-#include <dat/udat.h>\r
+#include <dat2/udat.h>\r
 #include <assert.h>\r
 #include <errno.h>\r
 #include <pthread.h>\r
@@ -541,8 +541,9 @@ dapl_os_strtol(const char *nptr, char **endptr, int base)
 #define dapl_os_assert(expression)     assert(expression)\r
 #define dapl_os_printf(...)            printf(__VA_ARGS__)\r
 #define dapl_os_vprintf(fmt,args)      vprintf(fmt,args)\r
-#define dapl_os_syslog(fmt,args)       vsyslog (LOG_USER | LOG_DEBUG,fmt,args)\r
+#define dapl_os_syslog(fmt,args)       vsyslog(LOG_USER|LOG_WARNING,fmt,args)\r
 \r
+#define dapl_os_getpid getpid\r
 \r
 \r
 #endif /*  _DAPL_OSD_H_ */\r
index 20dec48..d0c5a07 100644 (file)
@@ -463,6 +463,10 @@ STATIC __inline void dapl_os_sleep_usec (int sleep_time)
     Sleep(sleep_time/1000); // convert to milliseconds\r
 }\r
 \r
+STATIC __inline DAPL_OS_TICKS dapl_os_get_ticks (void);\r
+\r
+STATIC __inline int dapl_os_ticks_to_seconds (DAPL_OS_TICKS ticks);\r
+\r
 DAT_RETURN dapl_os_get_time (DAPL_OS_TIMEVAL *);\r
 /* timer functions */\r
 \r
@@ -511,7 +515,7 @@ dapl_os_strtol(const char *nptr, char **endptr, int base)
 }\r
 \r
 STATIC __inline int\r
-dapl_osd_getpid(void)\r
+dapl_os_getpid(void)\r
 {\r
        return (int)GetCurrentProcessId();\r
 }\r
index 0bf0d22..8380385 100644 (file)
  * $Id: dat_api.c 1326 2005-05-20 22:25:31Z jlentini $\r
  **********************************************************************/\r
 \r
+#include <dat/udat.h>\r
+#include <dat/dat_registry.h>\r
 #include "dat_osd.h"\r
 #include "dat_init.h"\r
-#include <dat/dat_registry.h>\r
 \r
 /*\r
  * structure to deal with IA handles\r
@@ -177,14 +178,14 @@ dats_set_ia_handle (
  *\r
  * Get a handle from a handle vector and return it in an OUT parameter\r
  ***********************************************************************/\r
-DAT_RETURN\r
+DAT_RETURN DAT_API\r
 dats_get_ia_handle(\r
        IN  DAT_IA_HANDLE               handle,\r
        OUT DAT_IA_HANDLE               *ia_handle_p )\r
 {\r
     DAT_RETURN         dat_status;\r
 \r
-    if (DAT_IA_HANDLE_TO_UL(handle) > g_hv.handle_max)\r
+    if (DAT_IA_HANDLE_TO_UL(handle) >= g_hv.handle_max)\r
     {\r
        dat_status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);\r
        goto bail;\r
@@ -217,7 +218,7 @@ dats_get_ia_handle(
  * The current implementation assumes that any value for which an IA \r
  * handle exists is a DAT_IA_HANDLE. Unfortunately this will result in \r
  * false positives. In particular it may identify a NULL pointer as IA \r
- * handle 0. An implmenetation that does not have this deficiency would \r
+ * handle 0. An implementation that does not have this deficiency would \r
  * be preferable.\r
  *\r
  ***********************************************************************/\r
@@ -227,7 +228,7 @@ dats_is_ia_handle (
 {\r
     unsigned long handle = DAT_IA_HANDLE_TO_UL((DAT_IA_HANDLE)dat_handle);\r
 \r
-    if (g_hv.handle_max < handle )\r
+    if (g_hv.handle_max <= handle )\r
     {\r
        return DAT_FALSE;\r
     }\r
@@ -253,7 +254,7 @@ dats_free_ia_handle (
 {\r
     DAT_RETURN         dat_status;\r
 \r
-    if (DAT_IA_HANDLE_TO_UL(handle) > g_hv.handle_max)\r
+    if (DAT_IA_HANDLE_TO_UL(handle) >= g_hv.handle_max)\r
     {\r
        dat_status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);\r
        goto bail;\r
index 4a86f19..46be3c4 100644 (file)
@@ -37,9 +37,8 @@
  * $Id: dat_dr.c,v 1.17 2005/03/24 05:58:27 jlentini Exp $\r
  **********************************************************************/\r
 \r
-\r
+#include <dat/dat_platform_specific.h>\r
 #include "dat_dr.h"\r
-\r
 #include "dat_dictionary.h"\r
 \r
 \r
@@ -120,7 +119,7 @@ dat_dr_insert (
     IN  DAT_DR_ENTRY           *entry )\r
 {\r
     DAT_RETURN                         status;\r
-    DAT_DICTIONARY_ENTRY       dict_entry;\r
+    DAT_DICTIONARY_ENTRY       dict_entry = NULL;\r
     DAT_DR_ENTRY               *data;\r
 \r
     data = dat_os_alloc (sizeof (DAT_DR_ENTRY));\r
@@ -132,7 +131,6 @@ dat_dr_insert (
 \r
     *data = *entry;\r
 \r
-    dict_entry = NULL;\r
     status = dat_dictionary_entry_create (&dict_entry);\r
     if ( DAT_SUCCESS != status )\r
     {\r
index 4bdaf0d..5fa78c5 100644 (file)
@@ -38,8 +38,8 @@
  * $Id: dat_init.c,v 1.18 2005/03/24 05:58:27 jlentini Exp $\r
  **********************************************************************/\r
 \r
+#include <dat/dat_platform_specific.h>\r
 #include "dat_init.h"\r
-\r
 #include "dat_dr.h"\r
 #include "dat_osd.h"\r
 \r
index c3b1786..d2aa168 100644 (file)
@@ -90,7 +90,7 @@ extern DAT_IA_HANDLE
 dats_set_ia_handle (\r
        IN  DAT_IA_HANDLE               ia_handle);\r
 \r
-extern DAT_RETURN \r
+extern DAT_RETURN DAT_API\r
 dats_get_ia_handle(\r
        IN      DAT_IA_HANDLE           handle,\r
        OUT     DAT_IA_HANDLE           *ia_handle_p);\r
index e97a725..f26b518 100644 (file)
@@ -142,6 +142,8 @@ dat_sr_insert (
        goto bail;\r
     }\r
 \r
+    dat_os_memset (data, '\0', sizeof (DAT_SR_ENTRY));\r
+\r
     lib_path_len = strlen (entry->lib_path);\r
     lib_path_size = (lib_path_len + 1) * sizeof (char);\r
 \r
index 8e0cca8..1c3fde0 100644 (file)
@@ -1367,6 +1367,13 @@ extern DAT_RETURN DAT_API dat_strerror (
        OUT     const char ** ,         /* major message string */\r
        OUT     const char ** );        /* minor message string */\r
 \r
+\r
+extern DAT_RETURN DAT_API\r
+dats_get_ia_handle(\r
+       IN      DAT_IA_HANDLE           handle,\r
+       OUT     DAT_IA_HANDLE           *ia_handle_p);\r
+\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index 8eee5e8..bbe137c 100644 (file)
@@ -76,7 +76,7 @@ typedef enum
  *                                                                   *\r
  *********************************************************************/\r
 \r
-static DAT_OS_DBG_TYPE_VAL     g_dbg_type = 0;\r
+static DAT_OS_DBG_TYPE_VAL     g_dbg_type = DAT_OS_DBG_TYPE_ERROR;\r
 static DAT_OS_DBG_DEST                 g_dbg_dest = DAT_OS_DBG_DEST_STDOUT;\r
 \r
 \r
@@ -156,7 +156,7 @@ dat_os_library_load (
     }\r
     else\r
     {\r
-       dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,\r
+       dat_os_dbg_print (DAT_OS_DBG_TYPE_ERROR,\r
                         "DAT: library load failure: %s\n",\r
                         dlerror ());\r
        return DAT_INTERNAL_ERROR;\r
index 80a803c..586d452 100644 (file)
@@ -52,7 +52,7 @@
 #error "UNDEFINED OS TYPE"\r
 #endif /* __linux__ */\r
 \r
-#include <dat/udat.h>\r
+#include <dat2/udat.h>\r
 \r
 #include <assert.h>\r
 #include <ctype.h>\r
index a27618c..c86f5b9 100644 (file)
@@ -184,7 +184,7 @@ dat_ia_openv (
 \r
     len = dat_os_strlen (name);\r
 \r
-    if ( DAT_NAME_MAX_LENGTH < len )\r
+    if ( DAT_NAME_MAX_LENGTH <= len )\r
     {\r
        return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);\r
     }\r
@@ -199,8 +199,7 @@ dat_ia_openv (
        return DAT_ERROR (DAT_INVALID_STATE, 0);\r
     }\r
 \r
-    dat_os_strncpy (info.ia_name, name, len);\r
-    info.ia_name[len] = '\0';\r
+    dat_os_strncpy (info.ia_name, name, len+1);\r
 \r
     info.dapl_version_major = dapl_major;\r
     info.dapl_version_minor = dapl_minor;\r
@@ -324,10 +323,9 @@ dat_ia_close (
 \r
        len = dat_os_strlen (ia_name);\r
 \r
-       dat_os_assert ( len <= DAT_NAME_MAX_LENGTH );\r
+       dat_os_assert ( len < DAT_NAME_MAX_LENGTH );\r
 \r
-       dat_os_strncpy (info.ia_name, ia_name, len);\r
-       info.ia_name[len] = '\0';\r
+       dat_os_strncpy (info.ia_name, ia_name, len+1);\r
 \r
        info.dapl_version_major = provider_attr.dapl_version_major;\r
        info.dapl_version_minor = provider_attr.dapl_version_minor;\r
index c11bbd9..552538a 100644 (file)
@@ -46,8 +46,9 @@
  * $Id: udat_api.c 1301 2005-03-24 05:58:55Z jlentini $\r
  **********************************************************************/\r
 \r
-#include "dat_osd.h"\r
+#include <dat/udat.h>\r
 #include <dat/dat_registry.h>\r
+#include "dat_osd.h"\r
 #include "dat_init.h"\r
 \r
 #define UDAT_IS_BAD_HANDLE(h) ( NULL == (p) )\r
index 0a68ff6..ffb5e48 100644 (file)
@@ -42,6 +42,7 @@ dat_pz_free
 dat_pz_query\r
 dat_registry_add_provider\r
 dat_registry_remove_provider\r
+dat_registry_list_providers\r
 dat_rmr_bind\r
 dat_rmr_create\r
 dat_rmr_free\r
@@ -50,6 +51,7 @@ dat_rsp_create
 dat_rsp_free\r
 dat_rsp_query\r
 dat_strerror\r
+dats_get_ia_handle\r
 #ifdef DAT_EXTENSIONS\r
 dat_extension_op\r
 #endif\r
index 7ab5cbc..c7ccef7 100644 (file)
@@ -37,7 +37,7 @@
  * $Id: udat_sr_parser.c,v 1.6 2005/03/24 05:58:36 jlentini Exp $\r
  **********************************************************************/\r
 \r
-\r
+#include <dat/udat.h>\r
 #include "udat_sr_parser.h"\r
 #include "dat_sr.h"\r
 \r
@@ -297,7 +297,7 @@ dat_sr_load (void)
     sr_file = dat_os_fopen (sr_path);\r
     if ( sr_file == NULL )\r
     {\r
-       return DAT_INTERNAL_ERROR;\r
+       goto bail;\r
     }\r
 \r
     for (;;)\r
@@ -312,17 +312,22 @@ dat_sr_load (void)
        }\r
        else\r
        {\r
-           dat_os_assert (!"unable to parse static registry file");\r
-           break;\r
+            goto cleanup;\r
        }\r
     }\r
 \r
-    if ( 0 != dat_os_fclose (sr_file) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
+    if (0 != dat_os_fclose (sr_file))\r
+       goto bail;\r
 \r
     return DAT_SUCCESS;\r
+\r
+cleanup:\r
+    dat_os_fclose(sr_file);    \r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    "ERROR: unable to parse static registry file, dat.conf\n");\r
+    return DAT_INTERNAL_ERROR;\r
+\r
 }\r
 \r
 \r
@@ -574,33 +579,19 @@ dat_sr_parse_ia_name (
     DAT_SR_CONF_ENTRY  *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
 \r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
-\r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       entry->ia_name = token.value;\r
-\r
-       status = DAT_SUCCESS;\r
-    }\r
-\r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
+    if (DAT_SR_TOKEN_STRING != token.type) {\r
+       dat_sr_put_token (file, &token);\r
+       goto bail;\r
     }\r
+    entry->ia_name = token.value;\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+bail:\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -614,39 +605,26 @@ dat_sr_parse_api (
     DAT_SR_CONF_ENTRY  *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
-\r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
-\r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else if ( DAT_SUCCESS != dat_sr_convert_api (\r
-                 token.value, &entry->api_version) )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       dat_os_free (token.value,\r
-                   (sizeof (char) * dat_os_strlen (token.value)) + 1);\r
 \r
-       status = DAT_SUCCESS;\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
+    if (DAT_SR_TOKEN_STRING != token.type)\r
+       goto cleanup;\r
 \r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_convert_api(token.value, &entry->api_version))\r
+       goto cleanup;\r
+    \r
+    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+cleanup:\r
+    dat_sr_put_token (file, &token);\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " api_ver, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -660,39 +638,27 @@ dat_sr_parse_thread_safety (
     DAT_SR_CONF_ENTRY  *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
 \r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else if ( DAT_SUCCESS != dat_sr_convert_thread_safety (\r
-                 token.value, &entry->is_thread_safe) )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       dat_os_free (token.value,\r
-                   (sizeof (char) * dat_os_strlen (token.value)) + 1);\r
-\r
-       status = DAT_SUCCESS;\r
-    }\r
-\r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
+    if (DAT_SR_TOKEN_STRING != token.type)\r
+       goto cleanup;\r
 \r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_convert_thread_safety(\r
+                       token.value, &entry->is_thread_safe))\r
+       goto cleanup;\r
+    \r
+    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+cleanup:\r
+    dat_sr_put_token (file, &token);\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " thread_safety, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -706,39 +672,26 @@ dat_sr_parse_default (
     DAT_SR_CONF_ENTRY  *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
 \r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
-\r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else if ( DAT_SUCCESS != dat_sr_convert_default (\r
-                 token.value, &entry->is_default) )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       dat_os_free (token.value,\r
-                   (sizeof (char) * dat_os_strlen (token.value)) + 1);\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-       status = DAT_SUCCESS;\r
-    }\r
-\r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
+    if (DAT_SR_TOKEN_STRING != token.type)\r
+       goto cleanup;\r
 \r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_convert_default(token.value, &entry->is_default))\r
+       goto cleanup;\r
+    \r
+    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+cleanup:\r
+    dat_sr_put_token (file, &token);\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " default section, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -752,33 +705,22 @@ dat_sr_parse_lib_path (
     DAT_SR_CONF_ENTRY  *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
 \r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
-\r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       entry->lib_path = token.value;\r
-\r
-       status = DAT_SUCCESS;\r
-    }\r
-\r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
+    if (DAT_SUCCESS != dat_sr_get_token(file, &token))\r
+       goto bail;\r
 \r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
+    if (DAT_SR_TOKEN_STRING != token.type) {\r
+       dat_sr_put_token (file, &token);\r
+       goto bail;\r
     }\r
+    entry->lib_path = token.value;\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " lib_path, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 /***********************************************************************\r
@@ -791,42 +733,29 @@ dat_sr_parse_provider_version (
     DAT_SR_CONF_ENTRY  *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
 \r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else if ( DAT_SUCCESS != dat_sr_convert_provider_version (\r
-                 token.value, &entry->provider_version) )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       dat_os_free (token.value,\r
-                   (sizeof (char) * dat_os_strlen (token.value)) + 1);\r
-\r
-       status = DAT_SUCCESS;\r
-    }\r
+    if (DAT_SR_TOKEN_STRING != token.type)\r
+       goto cleanup;\r
 \r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
-\r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
-    }\r
+    if (DAT_SUCCESS != dat_sr_convert_provider_version(\r
+                       token.value, &entry->provider_version))\r
+       goto cleanup;\r
+    \r
+    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+cleanup:\r
+    dat_sr_put_token (file, &token);\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " provider_ver, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
-\r
 /***********************************************************************\r
  * Function: dat_sr_parse_ia_params\r
  ***********************************************************************/\r
@@ -837,33 +766,23 @@ dat_sr_parse_ia_params (
     DAT_SR_CONF_ENTRY *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
-\r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
 \r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       entry->ia_params = token.value;\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-       status = DAT_SUCCESS;\r
+    if (DAT_SR_TOKEN_STRING != token.type) {\r
+       dat_sr_put_token (file, &token);\r
+       goto bail;\r
     }\r
 \r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
-\r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
-    }\r
+    entry->ia_params = token.value;\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " ia_params, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -877,33 +796,23 @@ dat_sr_parse_platform_params (
     DAT_SR_CONF_ENTRY *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
-\r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
 \r
-    if ( DAT_SR_TOKEN_STRING != token.type )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       entry->platform_params = token.value;\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-       status = DAT_SUCCESS;\r
+    if (DAT_SR_TOKEN_STRING != token.type) {\r
+       dat_sr_put_token (file, &token);\r
+       goto bail;\r
     }\r
 \r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
-\r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
-    }\r
+    entry->platform_params = token.value;\r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " platform_params, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -917,32 +826,23 @@ dat_sr_parse_eoe (
     DAT_SR_CONF_ENTRY *entry)\r
 {\r
     DAT_SR_TOKEN       token;\r
-    DAT_RETURN                 status;\r
-\r
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )\r
-    {\r
-       return DAT_INTERNAL_ERROR;\r
-    }\r
-\r
-    if ( (DAT_SR_TOKEN_EOF != token.type) &&\r
-        (DAT_SR_TOKEN_EOR != token.type) )\r
-    {\r
-       status = DAT_INTERNAL_ERROR;\r
-    }\r
-    else\r
-    {\r
-       status = DAT_SUCCESS;\r
-    }\r
 \r
-    if ( DAT_SUCCESS != status )\r
-    {\r
-       DAT_RETURN      status_success;\r
+    if (DAT_SUCCESS != dat_sr_get_token (file, &token))\r
+       goto bail;\r
 \r
-       status_success = dat_sr_put_token (file, &token);\r
-       dat_os_assert ( DAT_SUCCESS == status_success);\r
+    if ((DAT_SR_TOKEN_EOF != token.type) &&\r
+       (DAT_SR_TOKEN_EOR != token.type)) {\r
+       dat_sr_put_token (file, &token);\r
+       goto bail;\r
     }\r
+    \r
+    return DAT_SUCCESS;\r
 \r
-    return status;\r
+bail:\r
+    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, \r
+                    " ERR: corrupt dat.conf entry field:"\r
+                    " EOR, EOF, file offset=%ld\n", ftell(file));\r
+    return DAT_INTERNAL_ERROR;\r
 }\r
 \r
 \r
@@ -958,7 +858,8 @@ dat_sr_convert_api (
     int i;\r
     int minor_i;\r
 \r
-    dat_os_assert ( 0 < dat_os_strlen (str) );\r
+    if (dat_os_strlen(str) <= 0)\r
+       return DAT_INTERNAL_ERROR;\r
 \r
     if ( 'u' == str[0] )\r
     {\r
@@ -1082,8 +983,8 @@ dat_sr_convert_provider_version (
     int                i;\r
     int                decimal_i;\r
 \r
-    dat_os_assert ( 0 < dat_os_strlen (str) );\r
-    dat_os_assert ( NULL == provider_version->id );\r
+    if ((dat_os_strlen(str) <= 0) || (NULL != provider_version->id))\r
+       return DAT_INTERNAL_ERROR;\r
 \r
     status = DAT_SUCCESS;\r
 \r
index f10818d..9849a26 100644 (file)
@@ -125,7 +125,7 @@ void
 Dapltest_Main_Usage (void)\r
 {\r
     DT_Mdep_printf ("USAGE:\n");\r
-    DT_Mdep_printf ("USAGE:     dapltest -T <Test_Type> [test-specific args]\n");\r
+    DT_Mdep_printf ("USAGE:     dapltest -T <Test_Type> [-D IA_name] [test-specific args]\n");\r
     DT_Mdep_printf ("USAGE:         where <Test_Type>\n");\r
     DT_Mdep_printf ("USAGE:         S = Run as a server\n");\r
     DT_Mdep_printf ("USAGE:         T = Transaction Test\n");\r
@@ -134,7 +134,9 @@ Dapltest_Main_Usage (void)
     DT_Mdep_printf ("USAGE:         L = Limit Test\n");\r
     DT_Mdep_printf ("USAGE:         F = FFT Test\n");\r
     DT_Mdep_printf ("USAGE:\n");\r
-    DT_Mdep_printf ("NOTE:\tRun as server taking defaults (dapltest -T S)\n");\r
+    DT_Mdep_printf ("USAGE:         -D Interface_Adapter {default ibnic0v2}\n");\r
+    DT_Mdep_printf ("USAGE:\n");\r
+    DT_Mdep_printf ("NOTE:\tRun as server taking defaults (dapltest -T S [-D ibnic0v2])\n");\r
     DT_Mdep_printf ("NOTE:         dapltest\n");\r
     DT_Mdep_printf ("NOTE:\n");\r
     DT_Mdep_printf ("NOTE:\tdapltest arguments may be supplied in a script file\n");\r
index f7e38d3..087417c 100644 (file)
@@ -137,7 +137,6 @@ DT_NetAddrLookupHostAddress (DAT_IA_ADDRESS_PTR     to_netaddr,
                    inet_ntoa(((struct sockaddr_in *)target->ai_addr)->sin_addr));\r
 \r
     *to_netaddr = * ((DAT_IA_ADDRESS_PTR) target->ai_addr);\r
-\r
     freeaddrinfo(target);\r
 \r
     return ( DAT_TRUE );\r
index 451bef8..98889a0 100644 (file)
@@ -48,7 +48,7 @@
 # include <ws2tcpip.h>\r
 \r
 /* Default Device Name */\r
-#define DT_MdepDeviceName    "ibnic0"\r
+#define DT_MdepDeviceName    "ibnic0v2"\r
 \r
 /* Boolean */\r
 typedef int     bool;\r
diff --git a/ulp/dapl2/test/dtest/GETOPT.C b/ulp/dapl2/test/dtest/GETOPT.C
deleted file mode 100644 (file)
index 9de14fb..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*------------------------------------------------------------------------\r
-**\r
-**     Copyright (c) 1996,  Intel Corp.  All rights reserved.\r
-**\r
-**     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF\r
-**     Intel Corp.\r
-**     The copyright notice above does not evidence any\r
-**     actual or intended publication of such source code.\r
-**\r
-**\r
-**     Module: getopt.c\r
-**\r
-**     Source: PAL, Intel Corp.        Mike Ripley\r
-**\r
-**     Abstract:\r
-**             This is source for the standard getopt() library.\r
-**             Original source was obtained from the public domain,\r
-**             and modified to better suit DOS and Win32 environments.\r
-**\r
-**      Environment:\r
-**              Microsoft Win32\r
-**             Microsoft Visual C++ 4.0\r
-\r
-\r
----------------------------------------------------------------------\r
-\r
-              LIMITATION OF LIABILITY AND DISCLAIMER\r
-                                OF\r
-                      WARRANTY FOR SOFTWARE\r
-\r
-\r
-\r
-\r
-\r
-THE SOFTWARE THAT YOU ARE RECEIVING IS LICENSED FREE OF CHARGE. THE SOFTWARE\r
-IS PROVIDED "AS IS."  INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE\r
-SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  INTEL WILL NOT\r
-PROVIDE ANY INSTALLATION OR TECHNICAL SUPPORT, OR ANY  OTHER KIND OF\r
-ASSISTANCE TO YOU REGARDING YOUR USE OF THE SOFTWARE.  IF THE SOFTWARE PROVES\r
-DEFECTIVE ANYWAY, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR\r
-CORRECTION.  INTEL WILL NOT PROVIDE ANY UPDATES, ENHANCEMENTS OR EXTENSIONS\r
-TO THE SOFTWARE.\r
-\r
-ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED\r
-WARRANTIES MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE EXCLUDED,\r
-AND DO NOT APPLY TO THE SOFTWARE YOU ARE RECEIVING.\r
-\r
-IN ADDITION TO ANY OTHER DISCLAIMER SET FORTH HEREIN, INTEL WILL NOT HAVE ANY\r
-LIABILITY TO YOU FOR:\r
-\r
-   a)   any defects in the software you are receiving; or\r
-\r
-   b)   any inability by you to operate the software you are receiving to any\r
-        performance specification; or\r
-\r
-   c)   any claim by you or any third party with respect to, or arising out\r
-        of, the use of the software.\r
-\r
-\r
-INTEL DOES NOT MAKE ANY WARRANTIES OF ANY KIND THAT THE SOFTWARE DOES NOT OR\r
-WILL NOT INFRINGE ANY COPYRIGHT, PATENT, TRADE SECRET OR ANY OTHER\r
-INTELLECTUAL PROPERTY RIGHT OF ANY THIRD PARTY IN ANY COUNTRY.\r
-\r
-IN NO EVENT, SHALL INTEL BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY INDIRECT,\r
-SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING BUT NOT\r
-LIMITED TO LOSS OF PROFITS, LOSS OF USE OF DATA, OR INTERRUPTION OF BUSINESS,\r
-EVEN IF ADVISED OF THE POSSIBILITIES OF SUCH DAMAGES.\r
-\r
-\r
--------------------------------------------------------------------------*/\r
-\r
-\r
-\r
-/*    Comment header from original:\r
- *\r
- * Here's something you've all been waiting for:  the AT&T public domain\r
- * source for getopt(3).  It is the code which was given out at the 1985\r
- * UNIFORUM conference in Dallas.  I obtained it by electronic mail\r
- * directly from AT&T.  The people there assure me that it is indeed\r
- * in the public domain.\r
- * \r
- * There is no manual page.  That is because the one they gave out at\r
- * UNIFORUM was slightly different from the current System V Release 2\r
- * manual page.  The difference apparently involved a note about the\r
- * famous rules 5 and 6, recommending using white space between an option\r
- * and its first argument, and not grouping options that have arguments.\r
- * Getopt itself is currently lenient about both of these things.  White\r
- * space is allowed, but not mandatory, and the last option in a group can\r
- * have an argument.  That particular version of the man page evidently\r
- * has no official existence, and my source at AT&T did not send a copy.\r
- * The current SVR2 man page reflects the actual behavor of this getopt.\r
- * However, I am not about to post a copy of anything licensed by AT&T.\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-int    opterr = 1;\r
-int    optind = 1;\r
-int    optopt;\r
-char   *optarg;\r
-\r
-int getopt(int argc, char **argv, char *opts)\r
-{\r
-       static int sp = 1;\r
-       register int c;\r
-       register char *cp;\r
-\r
-       if(sp == 1)\r
-               if(optind >= argc ||\r
-                  argv[optind][0] != '-' || argv[optind][1] == '\0')\r
-                       return(EOF);\r
-               else if(strcmp(argv[optind], "--") == 0) {\r
-                       optind++;\r
-                       return(EOF);\r
-               }\r
-       optopt = c = argv[optind][sp];\r
-       if(c == ':' || (cp=strchr(opts, c)) == NULL) {\r
-               if (opterr)\r
-                       fprintf(stderr,"%s: illegal option -- %c\n",argv[0],c);\r
-               if(argv[optind][++sp] == '\0') {\r
-                       optind++;\r
-                       sp = 1;\r
-               }\r
-               return('?');\r
-       }\r
-       if(*++cp == ':') {\r
-               if(argv[optind][sp+1] != '\0')\r
-                       optarg = &argv[optind++][sp+1];\r
-               else if(++optind >= argc) {\r
-                       if (opterr)\r
-                               fprintf(stderr,\r
-                                       "%s: option requires argument -- %c\n",\r
-                                       argv[0], c);\r
-                       sp = 1;\r
-                       return('?');\r
-               } else\r
-                       optarg = argv[optind++];\r
-               sp = 1;\r
-       } else {\r
-               if(argv[optind][++sp] == '\0') {\r
-                       sp = 1;\r
-                       optind++;\r
-               }\r
-               optarg = NULL;\r
-       }\r
-       return(c);\r
-}\r
diff --git a/ulp/dapl2/test/dtest/GETOPT.H b/ulp/dapl2/test/dtest/GETOPT.H
deleted file mode 100644 (file)
index b159cbb..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*------------------------------------------------------------------------\r
-**\r
-**     Copyright (c) 1994,  Intel Corp.  All rights reserved.\r
-**\r
-**     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Intel Corp.\r
-**     The copyright notice above does not evidence any\r
-**     actual or intended publication of such source code.\r
-**\r
-**\r
-**     Module: getopt.h\r
-**\r
-**     Source: PAL, Intel Corp.        Mike Ripley\r
-**\r
-**     Abstract:\r
-**             This an include file for the standard getopt() library.\r
-**\r
-**      Environment:\r
-**              Microsoft Win32\r
-**             Microsoft Visual C++ 4.0\r
-**\r
----------------------------------------------------------------------\r
-\r
-              LIMITATION OF LIABILITY AND DISCLAIMER\r
-                                OF\r
-                      WARRANTY FOR SOFTWARE\r
-\r
-\r
-\r
-\r
-\r
-THE SOFTWARE THAT YOU ARE RECEIVING IS LICENSED FREE OF CHARGE. THE SOFTWARE\r
-IS PROVIDED "AS IS."  INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE\r
-SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  INTEL WILL NOT\r
-PROVIDE ANY INSTALLATION OR TECHNICAL SUPPORT, OR ANY  OTHER KIND OF\r
-ASSISTANCE TO YOU REGARDING YOUR USE OF THE SOFTWARE.  IF THE SOFTWARE PROVES\r
-DEFECTIVE ANYWAY, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR\r
-CORRECTION.  INTEL WILL NOT PROVIDE ANY UPDATES, ENHANCEMENTS OR EXTENSIONS\r
-TO THE SOFTWARE.\r
-\r
-ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED\r
-WARRANTIES MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE EXCLUDED,\r
-AND DO NOT APPLY TO THE SOFTWARE YOU ARE RECEIVING.\r
-\r
-IN ADDITION TO ANY OTHER DISCLAIMER SET FORTH HEREIN, INTEL WILL NOT HAVE ANY\r
-LIABILITY TO YOU FOR:\r
-\r
-   a)   any defects in the software you are receiving; or\r
-\r
-   b)   any inability by you to operate the software you are receiving to any\r
-        performance specification; or\r
-\r
-   c)   any claim by you or any third party with respect to, or arising out\r
-        of, the use of the software.\r
-\r
-\r
-INTEL DOES NOT MAKE ANY WARRANTIES OF ANY KIND THAT THE SOFTWARE DOES NOT OR\r
-WILL NOT INFRINGE ANY COPYRIGHT, PATENT, TRADE SECRET OR ANY OTHER\r
-INTELLECTUAL PROPERTY RIGHT OF ANY THIRD PARTY IN ANY COUNTRY.\r
-\r
-IN NO EVENT, SHALL INTEL BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY INDIRECT,\r
-SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING BUT NOT\r
-LIMITED TO LOSS OF PROFITS, LOSS OF USE OF DATA, OR INTERRUPTION OF BUSINESS,\r
-EVEN IF ADVISED OF THE POSSIBILITIES OF SUCH DAMAGES.\r
-\r
-\r
--------------------------------------------------------------------------*/\r
-\r
-#ifndef        _GETOPT_H_\r
-#define        _GETOPT_H_\r
-\r
-extern int     getopt(int argc, char **argv, char *opts);\r
-\r
-extern int             optind;\r
-extern int             optopt;\r
-extern char    *optarg;\r
-extern int             opterr;\r
-\r
-#endif // _GETOPT_H_\r
index 2071175..eca9f83 100644 (file)
@@ -10,9 +10,9 @@ USE_MSVCRT=1
 \r
 SOURCES=dtest.rc       \\r
        dtest.c         \\r
-       getopt.c\r
+       common.c\r
 \r
-INCLUDES=.;..\..\dat\include;../../../../inc;..\..\..\..\inc\user;\r
+INCLUDES=.;..\..\dat\include;../../../../inc;..\..\..\..\inc\user;..\..\..\..\tools\perftests\user;\r
 \r
 RCOPTIONS=/I..\..\..\..\inc;\r
 \r
diff --git a/ulp/dapl2/test/dtest/common.c b/ulp/dapl2/test/dtest/common.c
new file mode 100644 (file)
index 0000000..bc0ed36
--- /dev/null
@@ -0,0 +1,4 @@
+\r
+// get common getopt code from ..\..\..\..\tools\perftests\user\r
+\r
+#include "getopt.c"\r
diff --git a/ulp/dapl2/test/dtest/dtc.bat b/ulp/dapl2/test/dtest/dtc.bat
new file mode 100644 (file)
index 0000000..7c2c0fc
--- /dev/null
@@ -0,0 +1,42 @@
+@echo off\r
+rem\r
+rem Sample dtest2 client invocation - usage: dtc {hostname}\r
+rem\r
+\r
+SETLOCAL\r
+\r
+rem socket CM testing\r
+rem   set DAT_OVERRIDE=C:\dapl2\dat.conf\r
+rem   set P=ibnic0v2_scm\r
+rem   set DT=dtest2.exe\r
+\r
+rem IBAL CM testing\r
+rem   set DAT_OVERRIDE=C:\dapl2\dat.conf\r
+rem   set P=ibnic0v2\r
+rem   set DT=dtest2.exe\r
+rem set X=0xfffff\r
+\r
+set X=\r
+\r
+if not "%X%" == "" (\r
+    set DAT_DBG_LEVEL=%X%\r
+    set DAT_DBG_TYPE=%X%\r
+    set DAT_OS_DBG_TYPE=%X%\r
+    set DAPL_DBG_TYPE=%X%\r
+)\r
+\r
+IF "%1" == "" (\r
+  set H=10.10.4.201\r
+) ELSE (\r
+  set H=%1\r
+)\r
+\r
+echo %DT% -P %P% -h %H%\r
+\r
+%DT% -P %P% -h %H%\r
+\r
+echo %0 - dtest client exit...\r
+\r
+ENDLOCAL\r
+\r
+@echo on\r
index f10bd7d..351fdc0 100644 (file)
@@ -49,7 +49,7 @@
 #include <getopt.h>\r
 #include <complib/cl_types.h>\r
 \r
-#define getpid GetCurrentProcessId\r
+#define dapl_os_getpid GetCurrentProcessId\r
 \r
 #define F64x "%I64x" \r
 \r
@@ -273,17 +273,17 @@ main(int argc, char **argv)
                                break;\r
                        case 'c':\r
                                use_cno = 1;\r
-                               printf("%d Creating CNO for DTO EVD's\n",getpid());\r
+                               printf("%d Creating CNO for DTO EVD's\n",dapl_os_getpid());\r
                                fflush(stdout);\r
                                break;\r
                        case 'v':\r
                                verbose = 1;\r
-                               printf("%d Verbose\n",getpid());\r
+                               printf("%d Verbose\n",dapl_os_getpid());\r
                                fflush(stdout);\r
                                break;\r
                        case 'p':\r
                                polling = 1;\r
-                               printf("%d Polling\n",getpid());\r
+                               printf("%d Polling\n",dapl_os_getpid());\r
                                fflush(stdout);\r
                                break;\r
                        case 'B':\r
@@ -322,9 +322,9 @@ main(int argc, char **argv)
 #endif\r
 \r
     if (!server) {\r
-            printf("%d Running as client - %s\n",getpid(),provider);\r
+            printf("%d Running as client - %s\n",dapl_os_getpid(),provider);\r
     } else {\r
-            printf("%d Running as server - %s\n",getpid(),provider);\r
+            printf("%d Running as server - %s\n",dapl_os_getpid(),provider);\r
     }\r
     fflush(stdout);\r
 \r
@@ -336,7 +336,7 @@ main(int argc, char **argv)
     }\r
     memset( &time, 0, sizeof(struct dt_time) );\r
     LOGPRINTF("%d Allocated RDMA buffers (r:%p,s:%p) len %d \n",\r
-                       getpid(), rbuf, sbuf, buf_len);\r
+                       dapl_os_getpid(), rbuf, sbuf, buf_len);\r
 \r
     /* dat_ia_open, dat_pz_create */\r
     h_async_evd = DAT_HANDLE_NULL;\r
@@ -346,42 +346,42 @@ main(int argc, char **argv)
     time.open += ((stop - start)*1.0e6);\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d: Error Adaptor open: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
          exit(1);\r
     } else\r
-       LOGPRINTF("%d Opened Interface Adaptor\n",getpid());\r
+       LOGPRINTF("%d Opened Interface Adaptor\n",dapl_os_getpid());\r
 \r
     /* Create Protection Zone */\r
     start = get_time();\r
-    LOGPRINTF("%d Create Protection Zone\n",getpid());\r
+    LOGPRINTF("%d Create Protection Zone\n",dapl_os_getpid());\r
     ret = dat_pz_create(h_ia, &h_pz);\r
     stop = get_time();\r
     time.pzc += ((stop - start)*1.0e6);\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error creating Protection Zone: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
          exit(1);\r
     } else\r
-         LOGPRINTF("%d Created Protection Zone\n",getpid());\r
+         LOGPRINTF("%d Created Protection Zone\n",dapl_os_getpid());\r
 \r
     /* Register memory */\r
-    LOGPRINTF("%d Register RDMA memory\n", getpid());\r
+    LOGPRINTF("%d Register RDMA memory\n", dapl_os_getpid());\r
     ret = register_rdma_memory();\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error registering RDMA memory: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else\r
-         LOGPRINTF("%d Register RDMA memory done\n", getpid());\r
+         LOGPRINTF("%d Register RDMA memory done\n", dapl_os_getpid());\r
 \r
-    LOGPRINTF("%d Create events\n", getpid());\r
+    LOGPRINTF("%d Create events\n", dapl_os_getpid());\r
     ret = create_events();\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error creating events: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else {\r
-         LOGPRINTF("%d Create events done\n", getpid());\r
+         LOGPRINTF("%d Create events done\n", dapl_os_getpid());\r
     }\r
 \r
     /* create EP */\r
@@ -410,10 +410,10 @@ main(int argc, char **argv)
     time.total += time.epc;\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error dat_ep_create: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else\r
-         LOGPRINTF("%d EP created %p \n", getpid(), h_ep);\r
+         LOGPRINTF("%d EP created %p \n", dapl_os_getpid(), h_ep);\r
 \r
     /*\r
      * register message buffers, establish connection, and\r
@@ -422,21 +422,21 @@ main(int argc, char **argv)
     ret = connect_ep( hostname, SERVER_CONN_QUAL );\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error connect_ep: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else\r
-         LOGPRINTF("%d connect_ep complete\n", getpid());\r
+         LOGPRINTF("%d connect_ep complete\n", dapl_os_getpid());\r
 \r
     /* Query EP for local and remote address information, print */\r
     ret = dat_ep_query(h_ep, DAT_EP_FIELD_ALL, &ep_param);\r
     if(ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d Error dat_ep_query: %s\n",\r
-                getpid(),DT_RetToString(ret));\r
+                dapl_os_getpid(),DT_RetToString(ret));\r
         goto cleanup;\r
     } else\r
-        LOGPRINTF("%d EP queried %p \n", getpid(), h_ep);\r
+        LOGPRINTF("%d EP queried %p \n", dapl_os_getpid(), h_ep);\r
 #if defined(_WIN32)\r
-    printf("\n%d Query EP: LOCAL addr %s port %lld\n", getpid(),\r
+    printf("\n%d Query EP: LOCAL addr %s port %lld\n", dapl_os_getpid(),\r
          inet_ntoa(((struct sockaddr_in *)\r
                     ep_param.local_ia_address_ptr)->sin_addr),\r
          (ep_param.local_port_qual));\r
@@ -444,11 +444,11 @@ main(int argc, char **argv)
     inet_ntop(AF_INET,\r
          &((struct sockaddr_in *)ep_param.local_ia_address_ptr)->sin_addr,\r
          addr_str, sizeof(addr_str));\r
-    printf("\n%d Query EP: LOCAL addr %s port %lld\n", getpid(),\r
+    printf("\n%d Query EP: LOCAL addr %s port %lld\n", dapl_os_getpid(),\r
          addr_str, (ep_param.local_port_qual));\r
 #endif\r
 #if defined(_WIN32)\r
-    printf("%d Query EP: REMOTE addr %s port %lld\n", getpid(),\r
+    printf("%d Query EP: REMOTE addr %s port %lld\n", dapl_os_getpid(),\r
          inet_ntoa(((struct sockaddr_in *)\r
                     ep_param.local_ia_address_ptr)->sin_addr),\r
          (ep_param.remote_port_qual));\r
@@ -456,7 +456,7 @@ main(int argc, char **argv)
     inet_ntop(AF_INET,\r
         &((struct sockaddr_in *)ep_param.remote_ia_address_ptr)->sin_addr,\r
         addr_str, sizeof(addr_str));\r
-    printf("%d Query EP: REMOTE addr %s port %lld\n", getpid(),\r
+    printf("%d Query EP: REMOTE addr %s port %lld\n", dapl_os_getpid(),\r
            addr_str, (ep_param.remote_port_qual));\r
 #endif\r
     fflush(stdout);\r
@@ -474,28 +474,28 @@ main(int argc, char **argv)
     ret = do_rdma_write_with_msg();\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error do_rdma_write_with_msg: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else\r
-         LOGPRINTF("%d do_rdma_write_with_msg complete\n", getpid());\r
+         LOGPRINTF("%d do_rdma_write_with_msg complete\n", dapl_os_getpid());\r
 \r
     /*********** RDMA read data *************/\r
     ret = do_rdma_read_with_msg();\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error do_rdma_read_with_msg: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else\r
-         LOGPRINTF("%d do_rdma_read_with_msg complete\n", getpid());\r
+         LOGPRINTF("%d do_rdma_read_with_msg complete\n", dapl_os_getpid());\r
 \r
     /*********** PING PING messages ************/\r
     ret = do_ping_pong_msg();\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error do_ping_pong_msg: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
          goto cleanup;\r
     } else {\r
-         LOGPRINTF("%d do_ping_pong_msg complete\n", getpid());\r
+         LOGPRINTF("%d do_ping_pong_msg complete\n", dapl_os_getpid());\r
         goto complete;\r
     }\r
 \r
@@ -506,11 +506,11 @@ complete:
     /* disconnect and free EP resources */\r
     if ( h_ep != DAT_HANDLE_NULL ) {\r
          /* unregister message buffers and tear down connection */\r
-         LOGPRINTF("%d Disconnect and Free EP %p \n",getpid(),h_ep);\r
+         LOGPRINTF("%d Disconnect and Free EP %p \n",dapl_os_getpid(),h_ep);\r
          disconnect_ep();\r
     \r
         /* free EP */\r
-        LOGPRINTF("%d Free EP %p \n",getpid(),h_ep);\r
+        LOGPRINTF("%d Free EP %p \n",dapl_os_getpid(),h_ep);\r
         start = get_time();\r
         ret = dat_ep_free( h_ep );\r
         stop = get_time();\r
@@ -518,98 +518,97 @@ complete:
         time.total += time.epf;\r
         if(ret != DAT_SUCCESS) {\r
             fprintf(stderr, "%d Error freeing EP: %s\n",\r
-                    getpid(), DT_RetToString(ret));\r
+                    dapl_os_getpid(), DT_RetToString(ret));\r
         } else {\r
-            LOGPRINTF("%d Freed EP\n",getpid());\r
+            LOGPRINTF("%d Freed EP\n",dapl_os_getpid());\r
             h_ep = DAT_HANDLE_NULL;\r
         }   \r
     }\r
     \r
     /* free EVDs */\r
-    LOGPRINTF("%d destroy events\n", getpid());\r
+    LOGPRINTF("%d destroy events\n", dapl_os_getpid());\r
     ret = destroy_events();\r
     if(ret != DAT_SUCCESS)\r
          fprintf(stderr, "%d Error destroy_events: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
     else\r
-         LOGPRINTF("%d destroy events done\n", getpid());\r
+         LOGPRINTF("%d destroy events done\n", dapl_os_getpid());\r
 \r
 \r
     ret = unregister_rdma_memory();\r
-    LOGPRINTF("%d unregister_rdma_memory \n", getpid());\r
+    LOGPRINTF("%d unregister_rdma_memory \n", dapl_os_getpid());\r
     if(ret != DAT_SUCCESS)\r
          fprintf(stderr, "%d Error unregister_rdma_memory: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
     else\r
-         LOGPRINTF("%d unregister_rdma_memory done\n", getpid());\r
+         LOGPRINTF("%d unregister_rdma_memory done\n", dapl_os_getpid());\r
 \r
     /* Free protection domain */\r
-    LOGPRINTF("%d Freeing pz\n",getpid());\r
+    LOGPRINTF("%d Freeing pz\n",dapl_os_getpid());\r
     start = get_time();\r
     ret = dat_pz_free( h_pz );\r
     stop = get_time();\r
     time.pzf += ((stop - start)*1.0e6);\r
     if (ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error freeing PZ: %s\n",\r
-               getpid(), DT_RetToString(ret));\r
+               dapl_os_getpid(), DT_RetToString(ret));\r
     } else {\r
-         LOGPRINTF("%d Freed pz\n",getpid());\r
+         LOGPRINTF("%d Freed pz\n",dapl_os_getpid());\r
          h_pz = NULL;\r
     }\r
 \r
     /* close the device */\r
-    LOGPRINTF("%d Closing Interface Adaptor\n",getpid());\r
+    LOGPRINTF("%d Closing Interface Adaptor\n",dapl_os_getpid());\r
     start = get_time();\r
-    //ret = dat_ia_close( h_ia, DAT_CLOSE_ABRUPT_FLAG );\r
-    ret = dat_ia_close( h_ia, DAT_CLOSE_GRACEFUL_FLAG );\r
+    ret = dat_ia_close( h_ia, DAT_CLOSE_ABRUPT_FLAG );\r
     stop = get_time();\r
     time.close += ((stop - start)*1.0e6);\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d: Error Adaptor close: %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
          exit(1);\r
     } else\r
-         LOGPRINTF("%d Closed Interface Adaptor\n",getpid());\r
+         LOGPRINTF("%d Closed Interface Adaptor\n",dapl_os_getpid());\r
 \r
     /* free rdma buffers */\r
     free(rbuf);\r
     free(sbuf);\r
 \r
     printf("\n%d: DAPL Test Complete. %s\n\n",\r
-           getpid(), failed?"FAILED":"PASSED");\r
+           dapl_os_getpid(), failed?"FAILED":"PASSED");\r
     \r
     if (!performance_times) \r
         exit(0);\r
 \r
-    printf( "\n%d: DAPL Test Complete.\n\n",getpid());\r
+    printf( "\n%d: DAPL Test Complete.\n\n",dapl_os_getpid());\r
     printf( "%d: Message RTT: Total=%10.2lf usec, %d bursts, itime=%10.2lf"\r
                " usec, pc=%d\n", \r
-               getpid(), time.rtt, burst, time.rtt/burst, poll_count );\r
+               dapl_os_getpid(), time.rtt, burst, time.rtt/burst, poll_count );\r
     printf( "%d: RDMA write:  Total=%10.2lf usec, %d bursts, itime=%10.2lf"\r
                " usec, pc=%d\n", \r
-               getpid(), time.rdma_wr, burst, \r
+               dapl_os_getpid(), time.rdma_wr, burst, \r
                time.rdma_wr/burst, rdma_wr_poll_count );\r
     for(i=0;i<MAX_RDMA_RD;i++) {\r
            printf( "%d: RDMA read:   Total=%10.2lf usec,   %d bursts, "\r
                    "itime=%10.2lf usec, pc=%d\n", \r
-                  getpid(),time.rdma_rd_total,MAX_RDMA_RD,\r
+                  dapl_os_getpid(),time.rdma_rd_total,MAX_RDMA_RD,\r
                   time.rdma_rd[i],rdma_rd_poll_count[i] );\r
     }\r
-    printf( "%d: open:      %10.2lf usec\n", getpid(), time.open  );\r
-    printf( "%d: close:     %10.2lf usec\n", getpid(), time.close );\r
-    printf( "%d: PZ create: %10.2lf usec\n", getpid(), time.pzc );\r
-    printf( "%d: PZ free:   %10.2lf usec\n", getpid(), time.pzf );\r
-    printf( "%d: LMR create:%10.2lf usec\n", getpid(), time.reg );\r
-    printf( "%d: LMR free:  %10.2lf usec\n", getpid(), time.unreg );\r
-    printf( "%d: EVD create:%10.2lf usec\n", getpid(), time.evdc );\r
-    printf( "%d: EVD free:  %10.2lf usec\n", getpid(), time.evdf );\r
+    printf( "%d: open:      %10.2lf usec\n", dapl_os_getpid(), time.open  );\r
+    printf( "%d: close:     %10.2lf usec\n", dapl_os_getpid(), time.close );\r
+    printf( "%d: PZ create: %10.2lf usec\n", dapl_os_getpid(), time.pzc );\r
+    printf( "%d: PZ free:   %10.2lf usec\n", dapl_os_getpid(), time.pzf );\r
+    printf( "%d: LMR create:%10.2lf usec\n", dapl_os_getpid(), time.reg );\r
+    printf( "%d: LMR free:  %10.2lf usec\n", dapl_os_getpid(), time.unreg );\r
+    printf( "%d: EVD create:%10.2lf usec\n", dapl_os_getpid(), time.evdc );\r
+    printf( "%d: EVD free:  %10.2lf usec\n", dapl_os_getpid(), time.evdf );\r
     if (use_cno) {\r
-       printf( "%d: CNO create:  %10.2lf usec\n", getpid(), time.cnoc );\r
-       printf( "%d: CNO free:    %10.2lf usec\n", getpid(), time.cnof );\r
+       printf( "%d: CNO create:  %10.2lf usec\n", dapl_os_getpid(), time.cnoc );\r
+       printf( "%d: CNO free:    %10.2lf usec\n", dapl_os_getpid(), time.cnof );\r
     }\r
-    printf( "%d: EP create: %10.2lf usec\n",getpid(), time.epc );\r
-    printf( "%d: EP free:   %10.2lf usec\n",getpid(), time.epf );\r
-    printf( "%d: TOTAL:     %10.2lf usec\n",getpid(), time.total );\r
+    printf( "%d: EP create: %10.2lf usec\n",dapl_os_getpid(), time.epc );\r
+    printf( "%d: EP free:   %10.2lf usec\n",dapl_os_getpid(), time.epf );\r
+    printf( "%d: TOTAL:     %10.2lf usec\n",dapl_os_getpid(), time.total );\r
 \r
 #if defined(_WIN32) || defined(_WIN64)\r
     WSACleanup();\r
@@ -664,7 +663,7 @@ send_msg(  void                   *data,
 #endif\r
     iov.segment_length  = size;\r
     \r
-    LOGPRINTF("%d calling post_send\n", getpid());\r
+    LOGPRINTF("%d calling post_send\n", dapl_os_getpid());\r
     cookie.as_64 = 0xaaaa;\r
     ret = dat_ep_post_send( h_ep,\r
                            1,\r
@@ -674,25 +673,25 @@ send_msg(  void                   *data,
 \r
     if (ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d: ERROR: dat_ep_post_send() %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
         return ret;\r
     }\r
 \r
     if (!(flags & DAT_COMPLETION_SUPPRESS_FLAG)) {\r
        if ( polling ) {\r
-           printf("%d Polling post send completion...\n",getpid());\r
+           printf("%d Polling post send completion...\n",dapl_os_getpid());\r
            while (dat_evd_dequeue(h_dto_req_evd, &event) == DAT_QUEUE_EMPTY) ;\r
        }\r
        else {\r
-           LOGPRINTF("%d waiting for post_send completion event\n", getpid());\r
+           LOGPRINTF("%d waiting for post_send completion event\n", dapl_os_getpid());\r
            if (use_cno) {\r
                DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;\r
                ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );\r
-               LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);\r
+               LOGPRINTF("%d cno wait return evd_handle=%p\n", dapl_os_getpid(),evd);\r
                if ( evd != h_dto_req_evd ) {\r
                    fprintf(stderr,\r
                        "%d Error waiting on h_dto_cno: evd != h_dto_req_evd\n",\r
-                       getpid());\r
+                       dapl_os_getpid());\r
                    return( DAT_ABORT );\r
                }\r
            }\r
@@ -700,7 +699,7 @@ send_msg(  void                   *data,
            ret = dat_evd_wait( h_dto_req_evd, DTO_TIMEOUT, 1, &event, &nmore );\r
            if (ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",\r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
                return ret;\r
            }\r
        }\r
@@ -708,14 +707,14 @@ send_msg(  void                   *data,
        /* validate event number, len, cookie, and status */\r
        if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {\r
            fprintf(stderr, "%d: ERROR: DTO event number %s\n",\r
-                   getpid(),DT_EventToSTr(event.event_number));\r
+                   dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
        }\r
 \r
        if ((event.event_data.dto_completion_event_data.transfered_length != size ) ||\r
            (event.event_data.dto_completion_event_data.user_cookie.as_64 != 0xaaaa )) {\r
            fprintf(stderr, "%d: ERROR: DTO len %d or cookie "F64x" \n",\r
-               getpid(),\r
+               dapl_os_getpid(),\r
                event.event_data.dto_completion_event_data.transfered_length,\r
                event.event_data.dto_completion_event_data.user_cookie.as_64 );\r
            return( DAT_ABORT );\r
@@ -723,7 +722,7 @@ send_msg(  void                   *data,
        }\r
        if (event.event_data.dto_completion_event_data.status != DAT_SUCCESS) {\r
            fprintf(stderr, "%d: ERROR: DTO event status %s\n",\r
-                   getpid(),DT_RetToString(ret));\r
+                   dapl_os_getpid(),DT_RetToString(ret));\r
            return( DAT_ABORT );\r
        }\r
     }\r
@@ -731,7 +730,6 @@ send_msg(  void                   *data,
     return DAT_SUCCESS;\r
 }\r
 \r
-\r
 DAT_RETURN\r
 connect_ep( char *hostname, DAT_CONN_QUAL conn_id )\r
 {\r
@@ -744,10 +742,13 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
     DAT_RMR_TRIPLET         r_iov;\r
     DAT_DTO_COOKIE          cookie;\r
     int                     i;\r
+    unsigned char           *buf;\r
+    DAT_CR_PARAM            cr_param = { 0 };\r
+    unsigned char          pdata[48] = { 0 };\r
     \r
      /* Register send message buffer */\r
     LOGPRINTF("%d Registering send Message Buffer %p, len %d\n",\r
-               getpid(), &rmr_send_msg, sizeof(DAT_RMR_TRIPLET) );\r
+               dapl_os_getpid(), &rmr_send_msg, sizeof(DAT_RMR_TRIPLET) );\r
     region.for_va = &rmr_send_msg;\r
     ret = dat_lmr_create(  h_ia,\r
                            DAT_MEM_TYPE_VIRTUAL,\r
@@ -764,16 +765,16 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
 \r
      if (ret != DAT_SUCCESS) {\r
        fprintf(stderr, "%d Error registering send msg buffer: %s\n",\r
-               getpid(),DT_RetToString(ret));\r
+               dapl_os_getpid(),DT_RetToString(ret));\r
        return(ret);\r
     }\r
     else\r
        LOGPRINTF("%d Registered send Message Buffer %p \n",\r
-               getpid(),region.for_va );\r
+               dapl_os_getpid(),region.for_va );\r
 \r
     /* Register Receive buffers */\r
     LOGPRINTF("%d Registering Receive Message Buffer %p\n",\r
-               getpid(), rmr_recv_msg );\r
+               dapl_os_getpid(), rmr_recv_msg );\r
     region.for_va = rmr_recv_msg;\r
     ret = dat_lmr_create(  h_ia,\r
                            DAT_MEM_TYPE_VIRTUAL,\r
@@ -789,12 +790,12 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
                            &registered_addr_recv_msg );\r
     if(ret != DAT_SUCCESS) {\r
        fprintf(stderr, "%d Error registering recv msg buffer: %s\n",\r
-               getpid(),DT_RetToString(ret));\r
+               dapl_os_getpid(),DT_RetToString(ret));\r
        return(ret);\r
     }\r
     else\r
        LOGPRINTF("%d Registered Receive Message Buffer %p\n",\r
-               getpid(),region.for_va);\r
+               dapl_os_getpid(),region.for_va);\r
 \r
     for ( i = 0; i < MSG_BUF_COUNT; i++ ) {\r
        cookie.as_64          = i;\r
@@ -807,7 +808,7 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
        l_iov.segment_length  = sizeof(DAT_RMR_TRIPLET);\r
 \r
        LOGPRINTF("%d Posting Receive Message Buffer %p\n",\r
-                   getpid(), &rmr_recv_msg[ i ]);\r
+                   dapl_os_getpid(), &rmr_recv_msg[ i ]);\r
        ret = dat_ep_post_recv( h_ep,\r
                                1,\r
                                &l_iov,\r
@@ -816,12 +817,12 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
 \r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error registering recv msg buffer: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
         }\r
        else\r
            LOGPRINTF("%d Registered Receive Message Buffer %p\n",\r
-                                   getpid(),region.for_va);\r
+                                   dapl_os_getpid(),region.for_va);\r
 \r
     }\r
 \r
@@ -831,7 +832,7 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
     if ( server ) {  /* SERVER */\r
 \r
         /* create the service point for server listen */\r
-        LOGPRINTF("%d Creating service point for listen\n",getpid());\r
+        LOGPRINTF("%d Creating service point for listen\n",dapl_os_getpid());\r
        ret = dat_psp_create(   h_ia,\r
                                conn_id,\r
                                h_cr_evd,\r
@@ -839,33 +840,33 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
                                &h_psp );\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_psp_create: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
        }\r
        else\r
-           LOGPRINTF("%d dat_psp_created for server listen\n", getpid());\r
+           LOGPRINTF("%d dat_psp_created for server listen\n", dapl_os_getpid());\r
 \r
        printf("%d Server waiting for connect request on port %lld\n", \r
-               getpid(),conn_id);\r
+               dapl_os_getpid(),conn_id);\r
        \r
        ret = dat_evd_wait( h_cr_evd, SERVER_TIMEOUT, 1, &event, &nmore );\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_evd_wait: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
        }\r
        else\r
-           LOGPRINTF("%d dat_evd_wait for cr_evd completed\n", getpid());\r
+           LOGPRINTF("%d dat_evd_wait for cr_evd completed\n", dapl_os_getpid());\r
 \r
        if ( event.event_number != DAT_CONNECTION_REQUEST_EVENT ) {\r
             fprintf(stderr, "%d Error unexpected cr event : %s\n",\r
-                                   getpid(),DT_EventToSTr(event.event_number));\r
+                                   dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
        }\r
        if ( (event.event_data.cr_arrival_event_data.conn_qual != SERVER_CONN_QUAL) ||\r
             (event.event_data.cr_arrival_event_data.sp_handle.psp_handle != h_psp) ) {\r
             fprintf(stderr, "%d Error wrong cr event data : %s\n",\r
-                   getpid(),DT_EventToSTr(event.event_number));\r
+                   dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
        }\r
 \r
@@ -875,17 +876,45 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
 #else\r
        if (delay) sleep(delay);\r
 #endif\r
+\r
         /* accept connect request from client */\r
        h_cr = event.event_data.cr_arrival_event_data.cr_handle;\r
-       LOGPRINTF("%d Accepting connect request from client\n",getpid());\r
-       ret = dat_cr_accept( h_cr, h_ep, 0, (DAT_PVOID)0 );\r
+       LOGPRINTF("%d Accepting connect request from client\n",dapl_os_getpid());\r
+\r
+       /* private data - check and send it back */\r
+       dat_cr_query( h_cr, DAT_CSP_FIELD_ALL, &cr_param); \r
+\r
+       buf = (unsigned char*)cr_param.private_data;\r
+       LOGPRINTF("%d CONN REQUEST Private Data %p[0]=%d [47]=%d\n",\r
+                 dapl_os_getpid(),buf,buf[0],buf[47]);\r
+       for (i=0;i<48;i++) {\r
+           if (buf[i] != i+1) {\r
+               fprintf(stderr, "%d Error with CONNECT REQUEST"\r
+                       " private data: %p[%d]=%d s/be %d\n",\r
+                       dapl_os_getpid(), buf, i, buf[i], i+1);\r
+               dat_cr_reject(h_cr, 0, NULL);\r
+               return(DAT_ABORT);\r
+           }\r
+          buf[i]++; /* change for trip back */\r
+       }       \r
+\r
+#ifdef TEST_REJECT_WITH_PRIVATE_DATA\r
+       printf("%d REJECT request with 48 bytes of private data\n", dapl_os_getpid());\r
+       ret = dat_cr_reject(h_cr, 48, cr_param.private_data);\r
+       printf("\n%d: DAPL Test Complete. %s\n\n",\r
+             dapl_os_getpid(), ret?"FAILED":"PASSED");\r
+       exit(0);\r
+#endif\r
+\r
+       ret = dat_cr_accept(h_cr, h_ep, 48, cr_param.private_data);\r
+\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_cr_accept: %s\n",\r
-                   getpid(),DT_RetToString(ret));\r
+                   dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
        }\r
        else\r
-           LOGPRINTF("%d dat_cr_accept completed\n", getpid());\r
+           LOGPRINTF("%d dat_cr_accept completed\n", dapl_os_getpid());\r
     }\r
     else {  /* CLIENT */\r
        struct addrinfo *target;\r
@@ -904,49 +933,94 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
        }\r
        rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;\r
 #endif\r
-       printf ("%d Server Name: %s \n", getpid(), hostname);\r
-       printf ("%d Server Net Address: %d.%d.%d.%d port %lld\n", getpid(),\r
+       printf ("%d Server Name: %s \n", dapl_os_getpid(), hostname);\r
+       printf ("%d Server Net Address: %d.%d.%d.%d port %lld\n", dapl_os_getpid(),\r
                (rval >>  0) & 0xff, (rval >>  8) & 0xff,\r
                (rval >> 16) & 0xff, (rval >> 24) & 0xff, conn_id);\r
 \r
        remote_addr = *((DAT_IA_ADDRESS_PTR)target->ai_addr);\r
        freeaddrinfo(target);\r
 \r
-       LOGPRINTF("%d Connecting to server\n",getpid());\r
+       for (i=0;i<48;i++) /* simple pattern in private data */\r
+           pdata[i]=i+1;\r
+\r
+       LOGPRINTF("%d Connecting to server\n",dapl_os_getpid());\r
        ret = dat_ep_connect(   h_ep,\r
                                &remote_addr,\r
                                conn_id,\r
                                CONN_TIMEOUT,\r
-                               0,\r
-                               (DAT_PVOID)0,\r
+                               48,\r
+                               (DAT_PVOID)pdata,\r
                                0,\r
                                DAT_CONNECT_DEFAULT_FLAG  );\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_ep_connect: %s\n",\r
-                               getpid(), DT_RetToString(ret));\r
+                               dapl_os_getpid(), DT_RetToString(ret));\r
            return(ret);\r
        }\r
        else\r
-           LOGPRINTF("%d dat_ep_connect completed\n", getpid());\r
+           LOGPRINTF("%d dat_ep_connect completed\n", dapl_os_getpid());\r
     }\r
 \r
-    printf("%d Waiting for connect response\n",getpid());\r
+    printf("%d Waiting for connect response\n",dapl_os_getpid());\r
 \r
     ret = dat_evd_wait( h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore );\r
     if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_evd_wait: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
     }\r
     else\r
-           LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n", getpid());\r
+           LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n", dapl_os_getpid());\r
+\r
+#ifdef TEST_REJECT_WITH_PRIVATE_DATA\r
+    if (event.event_number != DAT_CONNECTION_EVENT_PEER_REJECTED) {\r
+           fprintf(stderr, "%d expected conn reject event : %s\n",\r
+                               dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
+           return( DAT_ABORT );\r
+    }\r
+    /* get the reject private data and validate */\r
+    buf = (unsigned char*)event.event_data.connect_event_data.private_data;\r
+    printf("%d Received REJECT with private data %p[0]=%d [47]=%d\n",\r
+           dapl_os_getpid(),buf,buf[0],buf[47]);\r
+    for (i=0;i<48;i++) {\r
+        if (buf[i] != i+2) {\r
+            fprintf(stderr, "%d client: Error with REJECT event"\r
+                    " private data: %p[%d]=%d s/be %d\n",\r
+                    dapl_os_getpid(), buf, i, buf[i], i+2);\r
+            dat_ep_disconnect( h_ep, DAT_CLOSE_ABRUPT_FLAG);\r
+            return(DAT_ABORT);\r
+        }\r
+    }\r
+    printf("\n%d: DAPL Test Complete. PASSED\n\n", dapl_os_getpid());\r
+    exit(0);\r
+#endif\r
 \r
     if ( event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED ) {\r
            fprintf(stderr, "%d Error unexpected conn event : %s\n",\r
-                               getpid(),DT_EventToSTr(event.event_number));\r
+                               dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
     }\r
-    printf("\n%d CONNECTED!\n\n",getpid());\r
+\r
+    /* check private data back from server  */\r
+    if (!server) {\r
+        buf = (unsigned char*)event.event_data.connect_event_data.private_data;\r
+        LOGPRINTF("%d CONN Private Data %p[0]=%d [47]=%d\n",\r
+                  dapl_os_getpid(),buf,buf[0],buf[47]);\r
+        for (i=0;i<48;i++) {\r
+            if (buf[i] != i+2) {\r
+                fprintf(stderr, "%d Error with CONNECT event"\r
+                        " private data: %p[%d]=%d s/be %d\n",\r
+                        dapl_os_getpid(), buf, i, buf[i], i+2);\r
+                dat_ep_disconnect(h_ep, DAT_CLOSE_ABRUPT_FLAG);\r
+                LOGPRINTF("%d waiting for disconnect event...\n", dapl_os_getpid());\r
+                dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore);\r
+                return(DAT_ABORT);\r
+            }\r
+        }\r
+    }\r
+\r
+    printf("\n%d CONNECTED!\n\n",dapl_os_getpid());\r
     connected = 1;\r
 \r
 #if CONNECT_ONLY\r
@@ -961,7 +1035,7 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
     rmr_send_msg.rmr_context     = hton32(rmr_context_recv);\r
 \r
     printf("%d Send RMR msg to remote: r_key_ctx=0x%x,va=%p,len=0x%x\n",\r
-           getpid(), rmr_context_recv, rbuf, RDMA_BUFFER_SIZE );\r
+           dapl_os_getpid(), rmr_context_recv, rbuf, RDMA_BUFFER_SIZE );\r
 \r
     ret = send_msg(&rmr_send_msg,\r
                    sizeof( DAT_RMR_TRIPLET ),\r
@@ -971,30 +1045,30 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
 \r
     if(ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d Error send_msg: %s\n",\r
-               getpid(),DT_RetToString(ret));\r
+               dapl_os_getpid(),DT_RetToString(ret));\r
        return(ret);\r
     }\r
     else\r
-       LOGPRINTF("%d send_msg completed\n", getpid());\r
+       LOGPRINTF("%d send_msg completed\n", dapl_os_getpid());\r
 \r
     /*\r
      *  Wait for remote RMR information for RDMA\r
      */\r
     if ( polling ) {\r
-       printf("%d Polling for remote to send RMR data\n",getpid());\r
+       printf("%d Polling for remote to send RMR data\n",dapl_os_getpid());\r
        while (  dat_evd_dequeue( h_dto_rcv_evd, &event ) == DAT_QUEUE_EMPTY );\r
     }\r
     else  {\r
-       printf("%d Waiting for remote to send RMR data\n",getpid());\r
+       printf("%d Waiting for remote to send RMR data\n",dapl_os_getpid());\r
        if (use_cno)\r
        {\r
            DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;\r
            ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );\r
-           LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);\r
+           LOGPRINTF("%d cno wait return evd_handle=%p\n", dapl_os_getpid(),evd);\r
            if ( evd != h_dto_rcv_evd ) {\r
                fprintf(stderr,\r
                        "%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",\r
-                       getpid());\r
+                       dapl_os_getpid());\r
                return( DAT_ABORT );\r
            }\r
        }\r
@@ -1002,19 +1076,19 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
        ret = dat_evd_wait( h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore );\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error waiting on h_dto_rcv_evd: %s\n",\r
-                   getpid(),DT_RetToString(ret));\r
+                   dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d dat_evd_wait h_dto_rcv_evd completed\n", getpid());\r
+           LOGPRINTF("%d dat_evd_wait h_dto_rcv_evd completed\n", dapl_os_getpid());\r
        }\r
     }\r
 \r
-    printf("%d remote RMR data arrived!\n",getpid());\r
+    printf("%d remote RMR data arrived!\n",dapl_os_getpid());\r
 \r
     if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {\r
         fprintf(stderr, "%d Error unexpected DTO event : %s\n",\r
-               getpid(),DT_EventToSTr(event.event_number));\r
+               dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
         return( DAT_ABORT );\r
     }\r
     if ((event.event_data.dto_completion_event_data.transfered_length !=\r
@@ -1039,7 +1113,7 @@ connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
 \r
     printf("%d Received RMR from remote: "\r
            "r_iov: r_key_ctx=%x,va="F64x",len=0x%x\n",\r
-           getpid(), rmr_recv_msg[recv_msg_index].rmr_context,\r
+           dapl_os_getpid(), rmr_recv_msg[recv_msg_index].rmr_context,\r
            rmr_recv_msg[recv_msg_index].virtual_address,\r
            rmr_recv_msg[recv_msg_index].segment_length );\r
 \r
@@ -1063,27 +1137,27 @@ disconnect_ep( void )
         * disconnect request and then exit.\r
         */\r
        if ( !server ) {\r
-           LOGPRINTF("%d dat_ep_disconnect\n", getpid());\r
+           LOGPRINTF("%d dat_ep_disconnect\n", dapl_os_getpid());\r
            ret = dat_ep_disconnect( h_ep, DAT_CLOSE_DEFAULT );\r
            if(ret != DAT_SUCCESS)  {\r
                    fprintf(stderr, "%d Error dat_ep_disconnect: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            }\r
            else {\r
-               LOGPRINTF("%d dat_ep_disconnect completed\n", getpid());\r
+               LOGPRINTF("%d dat_ep_disconnect completed\n", dapl_os_getpid());\r
            }\r
        }\r
        else {\r
-           LOGPRINTF("%d Server waiting for disconnect...\n", getpid());\r
+           LOGPRINTF("%d Server waiting for disconnect...\n", dapl_os_getpid());\r
        }\r
 \r
        ret = dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore);\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_evd_wait: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
        }\r
        else {\r
-           LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n", getpid());\r
+           LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n", dapl_os_getpid());\r
        }\r
     }\r
 \r
@@ -1092,35 +1166,35 @@ disconnect_ep( void )
        ret = dat_psp_free( h_psp );\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_psp_free: %s\n",\r
-                   getpid(),DT_RetToString(ret));\r
+                   dapl_os_getpid(),DT_RetToString(ret));\r
        }\r
        else {\r
-           LOGPRINTF("%d dat_psp_free completed\n", getpid());\r
+           LOGPRINTF("%d dat_psp_free completed\n", dapl_os_getpid());\r
        }\r
     }\r
 \r
     /* Unregister Send message Buffer */\r
     if ( h_lmr_send_msg != DAT_HANDLE_NULL ) {\r
-       LOGPRINTF("%d Unregister send message h_lmr %p \n",getpid(),h_lmr_send_msg);\r
+       LOGPRINTF("%d Unregister send message h_lmr %p \n",dapl_os_getpid(),h_lmr_send_msg);\r
        ret = dat_lmr_free(h_lmr_send_msg);\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error deregistering send msg mr: %s\n",\r
-           getpid(), DT_RetToString(ret));\r
+           dapl_os_getpid(), DT_RetToString(ret));\r
        } else {\r
-           LOGPRINTF("%d Unregistered send message Buffer\n",getpid());\r
+           LOGPRINTF("%d Unregistered send message Buffer\n",dapl_os_getpid());\r
            h_lmr_send_msg = NULL;\r
        }\r
     }\r
 \r
     /* Unregister recv message Buffer */\r
     if ( h_lmr_recv_msg != DAT_HANDLE_NULL ) {\r
-       LOGPRINTF("%d Unregister recv message h_lmr %p \n",getpid(),h_lmr_recv_msg);\r
+       LOGPRINTF("%d Unregister recv message h_lmr %p \n",dapl_os_getpid(),h_lmr_recv_msg);\r
        ret = dat_lmr_free(h_lmr_recv_msg);\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error deregistering recv msg mr: %s\n",\r
-                           getpid(), DT_RetToString(ret));\r
+                           dapl_os_getpid(), DT_RetToString(ret));\r
        } else {\r
-           LOGPRINTF("%d Unregistered recv message Buffer\n",getpid());\r
+           LOGPRINTF("%d Unregistered recv message Buffer\n",dapl_os_getpid());\r
            h_lmr_recv_msg = NULL;\r
        }\r
     }\r
@@ -1139,7 +1213,7 @@ do_rdma_write_with_msg( void )
        DAT_RETURN              ret;\r
        int                     i;\r
 \r
-       printf("\n %d RDMA WRITE DATA with SEND MSG\n\n",getpid());\r
+       printf("\n %d RDMA WRITE DATA with SEND MSG\n\n",dapl_os_getpid());\r
 \r
        cookie.as_64 = 0x5555;\r
 \r
@@ -1161,7 +1235,7 @@ do_rdma_write_with_msg( void )
                                        (&sbuf[l_iov[i].segment_length*i]);\r
 \r
           LOGPRINTF("%d rdma_write iov[%d] buf=%p,len=%d\n", \r
-                       getpid(), i, &sbuf[l_iov[i].segment_length*i],\r
+                       dapl_os_getpid(), i, &sbuf[l_iov[i].segment_length*i],\r
                        l_iov[i].segment_length);\r
        }\r
 \r
@@ -1176,17 +1250,17 @@ do_rdma_write_with_msg( void )
                                            DAT_COMPLETION_SUPPRESS_FLAG );\r
            if (ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d: ERROR: dat_ep_post_rdma_write() %s\n",\r
-                                       getpid(),DT_RetToString(ret));\r
+                                       dapl_os_getpid(),DT_RetToString(ret));\r
                return( DAT_ABORT );\r
            }\r
-           LOGPRINTF("%d rdma_write # %d completed\n", getpid(),i+1);\r
+           LOGPRINTF("%d rdma_write # %d completed\n", dapl_os_getpid(),i+1);\r
        }\r
 \r
        /*\r
         *  Send RMR information a 2nd time to indicate completion\r
         *  NOTE: already swapped to network order in connect_ep\r
         */\r
-       printf("%d Sending RDMA WRITE completion message\n",getpid());\r
+       printf("%d Sending RDMA WRITE completion message\n",dapl_os_getpid());\r
 \r
        ret = send_msg( &rmr_send_msg,\r
                        sizeof( DAT_RMR_TRIPLET ),\r
@@ -1196,10 +1270,10 @@ do_rdma_write_with_msg( void )
 \r
        if(ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d Error send_msg: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
                return(ret);\r
        } else {\r
-               LOGPRINTF("%d send_msg completed\n", getpid());\r
+               LOGPRINTF("%d send_msg completed\n", dapl_os_getpid());\r
        }\r
 \r
        /*\r
@@ -1210,16 +1284,16 @@ do_rdma_write_with_msg( void )
                rdma_wr_poll_count++;\r
        }\r
        else {\r
-           LOGPRINTF("%d waiting for message receive event\n", getpid());\r
+           LOGPRINTF("%d waiting for message receive event\n", dapl_os_getpid());\r
            if (use_cno)  {\r
                    DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;\r
                    ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );\r
                    LOGPRINTF("%d cno wait return evd_handle=%p\n",\r
-                               getpid(),evd);\r
+                               dapl_os_getpid(),evd);\r
                    if ( evd != h_dto_rcv_evd ) {\r
                            fprintf(stderr, "%d Error waiting on h_dto_cno: "\r
                                   "evd != h_dto_rcv_evd\n",\r
-                                   getpid());\r
+                                   dapl_os_getpid());\r
                            return( ret );\r
                    }\r
            }\r
@@ -1227,7 +1301,7 @@ do_rdma_write_with_msg( void )
            ret = dat_evd_wait(h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore);\r
            if (ret != DAT_SUCCESS) {\r
                    fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",\r
-                                           getpid(),DT_RetToString(ret));\r
+                                           dapl_os_getpid(),DT_RetToString(ret));\r
                    return( ret );\r
            }\r
        }\r
@@ -1235,10 +1309,10 @@ do_rdma_write_with_msg( void )
        time.rdma_wr = ((stop - start)*1.0e6);\r
 \r
        /* validate event number and status */\r
-       printf("%d inbound rdma_write; send message arrived!\n",getpid());\r
+       printf("%d inbound rdma_write; send message arrived!\n",dapl_os_getpid());\r
        if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {\r
            fprintf(stderr, "%d Error unexpected DTO event : %s\n",\r
-                               getpid(),DT_EventToSTr(event.event_number));\r
+                               dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
        }\r
 \r
@@ -1263,15 +1337,15 @@ do_rdma_write_with_msg( void )
 \r
        printf("%d Received RMR from remote: "\r
               "r_iov: r_key_ctx=%x,va="F64x",len=0x%x\n",\r
-              getpid(), rmr_recv_msg[recv_msg_index].rmr_context,\r
+              dapl_os_getpid(), rmr_recv_msg[recv_msg_index].rmr_context,\r
               rmr_recv_msg[recv_msg_index].virtual_address,\r
               rmr_recv_msg[recv_msg_index].segment_length);\r
 \r
        LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",\r
-                getpid());\r
+                dapl_os_getpid());\r
 \r
        printf("%d %s RDMA write buffer contains: %s\n",\r
-                       getpid(),\r
+                       dapl_os_getpid(),\r
                        server ? "SERVER:" : "CLIENT:",\r
                        rbuf );\r
 \r
@@ -1291,7 +1365,7 @@ do_rdma_read_with_msg( void )
        DAT_RETURN              ret;\r
        int                     i;\r
 \r
-       printf("\n %d RDMA READ DATA with SEND MSG\n\n",getpid());\r
+       printf("\n %d RDMA READ DATA with SEND MSG\n\n",dapl_os_getpid());\r
 \r
        if (recv_msg_index >= MSG_BUF_COUNT)\r
                return( DAT_ABORT );\r
@@ -1322,7 +1396,7 @@ do_rdma_read_with_msg( void )
                                        DAT_COMPLETION_DEFAULT_FLAG );\r
            if (ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d: ERROR: dat_ep_post_rdma_read() %s\n", \r
-                                       getpid(),DT_RetToString(ret));\r
+                                       dapl_os_getpid(),DT_RetToString(ret));\r
                return(DAT_ABORT);\r
            }\r
            \r
@@ -1331,15 +1405,15 @@ do_rdma_read_with_msg( void )
                        rdma_rd_poll_count[i]++;\r
            } \r
            else {\r
-               LOGPRINTF("%d waiting for rdma_read completion event\n", getpid());\r
+               LOGPRINTF("%d waiting for rdma_read completion event\n", dapl_os_getpid());\r
                if (use_cno) {\r
                        DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;\r
                        ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );\r
-                       LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);\r
+                       LOGPRINTF("%d cno wait return evd_handle=%p\n", dapl_os_getpid(),evd);\r
                        if ( evd != h_dto_req_evd ) {\r
                                fprintf(stderr, \r
                                "%d Error waiting on h_dto_cno: evd != h_dto_req_evd\n", \r
-                               getpid());\r
+                               dapl_os_getpid());\r
                                return( DAT_ABORT );\r
                        }\r
                }\r
@@ -1347,41 +1421,41 @@ do_rdma_read_with_msg( void )
                ret = dat_evd_wait( h_dto_req_evd, DTO_TIMEOUT, 1, &event, &nmore );\r
                if (ret != DAT_SUCCESS) {\r
                        fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n", \r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
                        return ret;\r
                }\r
            }\r
            /* validate event number, len, cookie, and status */\r
            if (event.event_number != DAT_DTO_COMPLETION_EVENT) {\r
                fprintf(stderr, "%d: ERROR: DTO event number %s\n", \r
-                       getpid(),DT_EventToSTr(event.event_number));\r
+                       dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
                return( DAT_ABORT );\r
            }\r
            if ((event.event_data.dto_completion_event_data.transfered_length != buf_len ) ||\r
                (event.event_data.dto_completion_event_data.user_cookie.as_64 != 0x9999 )) {\r
                fprintf(stderr, "%d: ERROR: DTO len %d or cookie "F64x"\n", \r
-                       getpid(),\r
+                       dapl_os_getpid(),\r
                        event.event_data.dto_completion_event_data.transfered_length,\r
                        event.event_data.dto_completion_event_data.user_cookie.as_64 );\r
                return( DAT_ABORT );\r
            }\r
            if (event.event_data.dto_completion_event_data.status != DAT_SUCCESS) {\r
                fprintf(stderr, "%d: ERROR: DTO event status %s\n", \r
-                       getpid(),DT_RetToString(ret));\r
+                       dapl_os_getpid(),DT_RetToString(ret));\r
                return( DAT_ABORT );\r
            }\r
            stop = get_time();\r
            time.rdma_rd[i] = ((stop - start)*1.0e6);\r
            time.rdma_rd_total += time.rdma_rd[i];\r
 \r
-           LOGPRINTF("%d rdma_read # %d completed\n", getpid(),i+1);\r
+           LOGPRINTF("%d rdma_read # %d completed\n", dapl_os_getpid(),i+1);\r
        }\r
 \r
        /*\r
         *  Send RMR information a 3rd time to indicate completion\r
         *  NOTE: already swapped to network order in connect_ep\r
         */\r
-       printf("%d Sending RDMA read completion message\n",getpid());\r
+       printf("%d Sending RDMA read completion message\n",dapl_os_getpid());\r
 \r
        ret = send_msg( &rmr_send_msg,\r
                        sizeof( DAT_RMR_TRIPLET ),\r
@@ -1391,29 +1465,29 @@ do_rdma_read_with_msg( void )
 \r
        if(ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d Error send_msg: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
                return(ret);\r
        } else {\r
-               LOGPRINTF("%d send_msg completed\n", getpid());\r
+               LOGPRINTF("%d send_msg completed\n", dapl_os_getpid());\r
        }\r
 \r
        /*\r
         *  Collect first event, write completion or the inbound recv with immed\r
         */\r
-       printf("%d Waiting for inbound message....\n",getpid());\r
+       printf("%d Waiting for inbound message....\n",dapl_os_getpid());\r
        if ( polling ) {\r
            while (  dat_evd_dequeue( h_dto_rcv_evd, &event ) == DAT_QUEUE_EMPTY );\r
        }\r
        else {\r
-           LOGPRINTF("%d waiting for message receive event\n", getpid());\r
+           LOGPRINTF("%d waiting for message receive event\n", dapl_os_getpid());\r
            if (use_cno) {\r
                    DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;\r
                    ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );\r
-                   LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);\r
+                   LOGPRINTF("%d cno wait return evd_handle=%p\n", dapl_os_getpid(),evd);\r
                    if ( evd != h_dto_rcv_evd ) {\r
                            fprintf(stderr, \r
                                   "%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",\r
-                                   getpid());\r
+                                   dapl_os_getpid());\r
                            return( ret );\r
                    }\r
            }\r
@@ -1421,16 +1495,16 @@ do_rdma_read_with_msg( void )
            ret = dat_evd_wait( h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore );\r
            if (ret != DAT_SUCCESS) {\r
                    fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",\r
-                                           getpid(),DT_RetToString(ret));\r
+                                           dapl_os_getpid(),DT_RetToString(ret));\r
                    return( ret );\r
            }\r
        }\r
 \r
        /* validate event number and status */\r
-       printf("%d inbound rdma_read; send message arrived!\n",getpid());\r
+       printf("%d inbound rdma_read; send message arrived!\n",dapl_os_getpid());\r
        if (event.event_number != DAT_DTO_COMPLETION_EVENT ) {\r
            fprintf(stderr, "%d Error unexpected DTO event : %s\n",\r
-                               getpid(),DT_EventToSTr(event.event_number));\r
+                               dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
        }\r
 \r
@@ -1456,14 +1530,14 @@ do_rdma_read_with_msg( void )
 \r
        printf("%d Received RMR from remote: "\r
               "r_iov: r_key_ctx=%x,va="F64x",len=0x%x\n",\r
-              getpid(), rmr_recv_msg[recv_msg_index].rmr_context,\r
+              dapl_os_getpid(), rmr_recv_msg[recv_msg_index].rmr_context,\r
               rmr_recv_msg[recv_msg_index].virtual_address,\r
               rmr_recv_msg[recv_msg_index].segment_length);\r
 \r
-       LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",getpid());\r
+       LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",dapl_os_getpid());\r
 \r
        printf("%d %s RCV RDMA read buffer contains: %s\n",\r
-                       getpid(),\r
+                       dapl_os_getpid(),\r
                        server ? "SERVER:" : "CLIENT:",\r
                        sbuf );\r
 \r
@@ -1485,7 +1559,7 @@ do_ping_pong_msg( )
     char               *snd_buf;\r
     char               *rcv_buf;\r
 \r
-    printf("\n %d PING DATA with SEND MSG\n\n",getpid());\r
+    printf("\n %d PING DATA with SEND MSG\n\n",dapl_os_getpid());\r
 \r
     snd_buf = sbuf;\r
     rcv_buf = rbuf;\r
@@ -1499,7 +1573,7 @@ do_ping_pong_msg( )
        l_iov.segment_length  = buf_len;\r
 \r
        LOGPRINTF("%d Pre-posting Receive Message Buffers %p\n",\r
-                   getpid(), rcv_buf );\r
+                   dapl_os_getpid(), rcv_buf );\r
 \r
        ret = dat_ep_post_recv( h_ep,\r
                                1,\r
@@ -1509,11 +1583,11 @@ do_ping_pong_msg( )
 \r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error posting recv msg buffer: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            return(ret);\r
         }\r
        else {\r
-           LOGPRINTF("%d Posted Receive Message Buffer %p\n",getpid(),rcv_buf);\r
+           LOGPRINTF("%d Posted Receive Message Buffer %p\n",dapl_os_getpid(),rcv_buf);\r
         }\r
 \r
        /* next buffer */\r
@@ -1537,7 +1611,7 @@ do_ping_pong_msg( )
            *snd_buf = 0x55;\r
 \r
            LOGPRINTF("%d %s SND buffer %p contains: 0x%x len=%d\n",\r
-                   getpid(), server ? "SERVER:" : "CLIENT:",\r
+                   dapl_os_getpid(), server ? "SERVER:" : "CLIENT:",\r
                    snd_buf, *snd_buf, buf_len );\r
 \r
            ret = send_msg( snd_buf,\r
@@ -1548,32 +1622,32 @@ do_ping_pong_msg( )
 \r
            if(ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d Error send_msg: %s\n",\r
-                                   getpid(),DT_RetToString(ret));\r
+                                   dapl_os_getpid(),DT_RetToString(ret));\r
                return(ret);\r
            }\r
            else {\r
-               LOGPRINTF("%d send_msg completed\n", getpid());\r
+               LOGPRINTF("%d send_msg completed\n", dapl_os_getpid());\r
            }\r
        }\r
 \r
        /* Wait for recv message */\r
        if ( polling ) {\r
            poll_count=0;\r
-           LOGPRINTF("%d Polling for message receive event\n", getpid());\r
+           LOGPRINTF("%d Polling for message receive event\n", dapl_os_getpid());\r
            while (  dat_evd_dequeue( h_dto_rcv_evd, &event ) == DAT_QUEUE_EMPTY )\r
                poll_count++;\r
        }\r
        else {\r
-           LOGPRINTF("%d waiting for message receive event\n", getpid());\r
+           LOGPRINTF("%d waiting for message receive event\n", dapl_os_getpid());\r
            if (use_cno) {\r
                DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;\r
                ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );\r
-               LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);\r
+               LOGPRINTF("%d cno wait return evd_handle=%p\n", dapl_os_getpid(),evd);\r
                if ( evd != h_dto_rcv_evd )\r
                {\r
                    fprintf(stderr, \r
                           "%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",\r
-                           getpid());\r
+                           dapl_os_getpid());\r
                    return( ret );\r
                }\r
            }\r
@@ -1581,7 +1655,7 @@ do_ping_pong_msg( )
            ret = dat_evd_wait( h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore );\r
            if (ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",\r
-                                       getpid(),DT_RetToString(ret));\r
+                                       dapl_os_getpid(),DT_RetToString(ret));\r
                return( ret );\r
            }\r
        }\r
@@ -1590,10 +1664,10 @@ do_ping_pong_msg( )
            start = get_time();\r
        }\r
        /* validate event number and status */\r
-       LOGPRINTF("%d inbound message; message arrived!\n",getpid());\r
+       LOGPRINTF("%d inbound message; message arrived!\n",dapl_os_getpid());\r
        if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {\r
            fprintf(stderr, "%d Error unexpected DTO event : %s\n",\r
-                   getpid(),DT_EventToSTr(event.event_number));\r
+                   dapl_os_getpid(),DT_EventToSTr(event.event_number));\r
            return( DAT_ABORT );\r
        }\r
        if ((event.event_data.dto_completion_event_data.transfered_length\r
@@ -1609,7 +1683,7 @@ do_ping_pong_msg( )
        }\r
 \r
        LOGPRINTF("%d %s RCV buffer %p contains: 0x%x len=%d\n",\r
-                   getpid(), server ? "SERVER:" : "CLIENT:",\r
+                   dapl_os_getpid(), server ? "SERVER:" : "CLIENT:",\r
                    rcv_buf, *rcv_buf, buf_len );\r
 \r
        burst_msg_index++;\r
@@ -1619,7 +1693,7 @@ do_ping_pong_msg( )
            *snd_buf = 0xaa;\r
 \r
            LOGPRINTF("%d %s SND buffer %p contains: 0x%x len=%d\n",\r
-                   getpid(), server ? "SERVER:" : "CLIENT:",\r
+                   dapl_os_getpid(), server ? "SERVER:" : "CLIENT:",\r
                    snd_buf, *snd_buf, buf_len );\r
 \r
            ret = send_msg( snd_buf,\r
@@ -1630,11 +1704,11 @@ do_ping_pong_msg( )
 \r
            if(ret != DAT_SUCCESS) {\r
                fprintf(stderr, "%d Error send_msg: %s\n",\r
-                                   getpid(),DT_RetToString(ret));\r
+                                   dapl_os_getpid(),DT_RetToString(ret));\r
                return(ret);\r
            }\r
            else {\r
-               LOGPRINTF("%d send_msg completed\n", getpid());\r
+               LOGPRINTF("%d send_msg completed\n", dapl_os_getpid());\r
            }\r
        }\r
 \r
@@ -1675,11 +1749,11 @@ register_rdma_memory(void)
 \r
     if(ret != DAT_SUCCESS) {\r
        fprintf(stderr, "%d Error registering Receive RDMA buffer: %s\n",\r
-               getpid(),DT_RetToString(ret));\r
+               dapl_os_getpid(),DT_RetToString(ret));\r
        return (ret);\r
     } else {\r
            LOGPRINTF("%d Registered Receive RDMA Buffer %p\n",\r
-                       getpid(),region.for_va);\r
+                       dapl_os_getpid(),region.for_va);\r
     }\r
 \r
     /* Register RDMA Send buffer */\r
@@ -1698,11 +1772,11 @@ register_rdma_memory(void)
                            &registered_addr_send );\r
     if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error registering send RDMA buffer: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
            return (ret);\r
     } else {\r
            LOGPRINTF("%d Registered Send RDMA Buffer %p\n",\r
-                   getpid(),region.for_va);\r
+                   dapl_os_getpid(),region.for_va);\r
     }\r
 \r
     return DAT_SUCCESS;\r
@@ -1719,7 +1793,7 @@ unregister_rdma_memory(void)
     /* Unregister Recv Buffer */\r
     if ( h_lmr_recv != DAT_HANDLE_NULL )\r
     {\r
-       LOGPRINTF("%d Unregister h_lmr %p \n",getpid(),h_lmr_recv);\r
+       LOGPRINTF("%d Unregister h_lmr %p \n",dapl_os_getpid(),h_lmr_recv);\r
         start = get_time();\r
        ret = dat_lmr_free(h_lmr_recv);\r
         stop = get_time();\r
@@ -1727,26 +1801,26 @@ unregister_rdma_memory(void)
        time.total += time.unreg;\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error deregistering recv mr: %s\n",\r
-                       getpid(), DT_RetToString(ret));\r
+                       dapl_os_getpid(), DT_RetToString(ret));\r
            return (ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d Unregistered Recv Buffer\n",getpid());\r
+           LOGPRINTF("%d Unregistered Recv Buffer\n",dapl_os_getpid());\r
            h_lmr_recv = NULL;\r
        }\r
     }\r
 \r
     /* Unregister Send Buffer */\r
     if ( h_lmr_send != DAT_HANDLE_NULL ) {\r
-       LOGPRINTF("%d Unregister h_lmr %p \n",getpid(),h_lmr_send);\r
+       LOGPRINTF("%d Unregister h_lmr %p \n",dapl_os_getpid(),h_lmr_send);\r
        ret = dat_lmr_free(h_lmr_send);\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error deregistering send mr: %s\n",\r
-                           getpid(), DT_RetToString(ret));\r
+                           dapl_os_getpid(), DT_RetToString(ret));\r
            return (ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d Unregistered send Buffer\n",getpid());\r
+           LOGPRINTF("%d Unregistered send Buffer\n",dapl_os_getpid());\r
            h_lmr_send = NULL;\r
        }\r
     }\r
@@ -1777,11 +1851,11 @@ create_events(void)
        time.total += time.cnoc;\r
        if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error dat_cno_create: %s\n",\r
-                               getpid(),DT_RetToString(ret));\r
+                               dapl_os_getpid(),DT_RetToString(ret));\r
            return (ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d cr_evd created, %p\n", getpid(), h_dto_cno);\r
+           LOGPRINTF("%d cr_evd created, %p\n", dapl_os_getpid(), h_dto_cno);\r
        }\r
     }\r
 \r
@@ -1793,11 +1867,11 @@ create_events(void)
     time.total += time.evdc;\r
     if(ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d Error dat_evd_create: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
         return (ret);\r
     }\r
     else {\r
-        LOGPRINTF("%d cr_evd created %p\n", getpid(),h_cr_evd);\r
+        LOGPRINTF("%d cr_evd created %p\n", dapl_os_getpid(),h_cr_evd);\r
     }\r
 \r
     /* create conn EVD */\r
@@ -1808,11 +1882,11 @@ create_events(void)
                           &h_conn_evd );\r
     if(ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d Error dat_evd_create: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
         return (ret);\r
     }\r
     else {\r
-        LOGPRINTF("%d con_evd created %p\n", getpid(),h_conn_evd);\r
+        LOGPRINTF("%d con_evd created %p\n", dapl_os_getpid(),h_conn_evd);\r
     }\r
 \r
     /* create dto SND EVD, with CNO if use_cno was set */\r
@@ -1823,11 +1897,11 @@ create_events(void)
                          &h_dto_req_evd  );\r
     if(ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d Error dat_evd_create REQ: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
         return (ret);\r
     }\r
     else {\r
-        LOGPRINTF("%d dto_req_evd created %p\n", getpid(), h_dto_req_evd );\r
+        LOGPRINTF("%d dto_req_evd created %p\n", dapl_os_getpid(), h_dto_req_evd );\r
     }\r
 \r
     /* create dto RCV EVD, with CNO if use_cno was set */\r
@@ -1838,11 +1912,11 @@ create_events(void)
                          &h_dto_rcv_evd  );\r
     if(ret != DAT_SUCCESS) {\r
         fprintf(stderr, "%d Error dat_evd_create RCV: %s\n",\r
-                           getpid(),DT_RetToString(ret));\r
+                           dapl_os_getpid(),DT_RetToString(ret));\r
         return (ret);\r
     }\r
     else {\r
-        LOGPRINTF("%d dto_rcv_evd created %p\n", getpid(), h_dto_rcv_evd );\r
+        LOGPRINTF("%d dto_rcv_evd created %p\n", dapl_os_getpid(), h_dto_rcv_evd );\r
     }\r
 \r
     /* query DTO req EVD and check size */\r
@@ -1851,18 +1925,18 @@ create_events(void)
                           &param  );\r
     if(ret != DAT_SUCCESS) {\r
          fprintf(stderr, "%d Error dat_evd_query request evd: %s\n",\r
-                            getpid(),DT_RetToString(ret));\r
+                            dapl_os_getpid(),DT_RetToString(ret));\r
          return (ret);\r
     }\r
     else if (param.evd_qlen < (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2) {\r
          fprintf(stderr, "%d Error dat_evd qsize too small: %d < %d\n",\r
-                 getpid(), param.evd_qlen, \r
+                 dapl_os_getpid(), param.evd_qlen, \r
                  (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2);\r
          return (ret);\r
     }\r
   \r
     LOGPRINTF("%d dto_req_evd QLEN - requested %d and actual %d\n", \r
-              getpid(), (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2,\r
+              dapl_os_getpid(), (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2,\r
               param.evd_qlen);\r
 \r
     return DAT_SUCCESS;\r
@@ -1879,36 +1953,36 @@ destroy_events(void)
 \r
        /* free cr EVD */\r
     if ( h_cr_evd != DAT_HANDLE_NULL ) {\r
-        LOGPRINTF("%d Free cr EVD %p \n",getpid(),h_cr_evd);\r
+        LOGPRINTF("%d Free cr EVD %p \n",dapl_os_getpid(),h_cr_evd);\r
         ret = dat_evd_free( h_cr_evd );\r
         if(ret != DAT_SUCCESS) {\r
                    fprintf(stderr, "%d Error freeing cr EVD: %s\n",\r
-                           getpid(), DT_RetToString(ret));\r
+                           dapl_os_getpid(), DT_RetToString(ret));\r
                        return (ret);\r
            } else {\r
-                   LOGPRINTF("%d Freed cr EVD\n",getpid());\r
+                   LOGPRINTF("%d Freed cr EVD\n",dapl_os_getpid());\r
             h_cr_evd = DAT_HANDLE_NULL;\r
            }\r
     }\r
 \r
     /* free conn EVD */\r
     if ( h_conn_evd != DAT_HANDLE_NULL ) {\r
-        LOGPRINTF("%d Free conn EVD %p \n",getpid(),h_conn_evd);\r
+        LOGPRINTF("%d Free conn EVD %p \n",dapl_os_getpid(),h_conn_evd);\r
         ret = dat_evd_free( h_conn_evd );\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error freeing conn EVD: %s\n",\r
-                       getpid(), DT_RetToString(ret));\r
+                       dapl_os_getpid(), DT_RetToString(ret));\r
            return (ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d Freed conn EVD\n",getpid());\r
+           LOGPRINTF("%d Freed conn EVD\n",dapl_os_getpid());\r
            h_conn_evd = DAT_HANDLE_NULL;\r
        }\r
     }\r
 \r
     /* free RCV dto EVD */\r
     if ( h_dto_rcv_evd != DAT_HANDLE_NULL ) {\r
-        LOGPRINTF("%d Free RCV dto EVD %p \n",getpid(),h_dto_rcv_evd);\r
+        LOGPRINTF("%d Free RCV dto EVD %p \n",dapl_os_getpid(),h_dto_rcv_evd);\r
         start = get_time();\r
         ret = dat_evd_free( h_dto_rcv_evd );\r
         stop = get_time();\r
@@ -1916,33 +1990,33 @@ destroy_events(void)
         time.total += time.evdf;\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error freeing dto EVD: %s\n",\r
-                           getpid(), DT_RetToString(ret));\r
+                           dapl_os_getpid(), DT_RetToString(ret));\r
            return (ret);\r
         }\r
         else {\r
-           LOGPRINTF("%d Freed dto EVD\n",getpid());\r
+           LOGPRINTF("%d Freed dto EVD\n",dapl_os_getpid());\r
             h_dto_rcv_evd = DAT_HANDLE_NULL;\r
         }\r
      }\r
 \r
     /* free REQ dto EVD */\r
     if ( h_dto_req_evd != DAT_HANDLE_NULL ) {\r
-        LOGPRINTF("%d Free REQ dto EVD %p \n",getpid(),h_dto_req_evd);\r
+        LOGPRINTF("%d Free REQ dto EVD %p \n",dapl_os_getpid(),h_dto_req_evd);\r
         ret = dat_evd_free( h_dto_req_evd );\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error freeing dto EVD: %s\n",\r
-                           getpid(), DT_RetToString(ret));\r
+                           dapl_os_getpid(), DT_RetToString(ret));\r
            return (ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d Freed dto EVD\n",getpid());\r
+           LOGPRINTF("%d Freed dto EVD\n",dapl_os_getpid());\r
             h_dto_req_evd = DAT_HANDLE_NULL;\r
        }\r
     }\r
 \r
     /* free CNO */\r
     if ( h_dto_cno != DAT_HANDLE_NULL ) {\r
-        LOGPRINTF("%d Free dto CNO %p \n",getpid(),h_dto_cno);\r
+        LOGPRINTF("%d Free dto CNO %p \n",dapl_os_getpid(),h_dto_cno);\r
         start = get_time();\r
         ret = dat_cno_free( h_dto_cno );\r
         stop = get_time();\r
@@ -1950,11 +2024,11 @@ destroy_events(void)
         time.total += time.cnof;\r
         if(ret != DAT_SUCCESS) {\r
            fprintf(stderr, "%d Error freeing dto CNO: %s\n",\r
-                   getpid(), DT_RetToString(ret));\r
+                   dapl_os_getpid(), DT_RetToString(ret));\r
            return (ret);\r
        }\r
        else {\r
-           LOGPRINTF("%d Freed dto CNO\n",getpid());\r
+           LOGPRINTF("%d Freed dto CNO\n",dapl_os_getpid());\r
             h_dto_cno = DAT_HANDLE_NULL;\r
        }\r
     }\r
diff --git a/ulp/dapl2/test/dtest/dts.bat b/ulp/dapl2/test/dtest/dts.bat
new file mode 100644 (file)
index 0000000..3e80207
--- /dev/null
@@ -0,0 +1,47 @@
+@echo off\r
+rem\r
+rem dtest2 server invocation - usage: dts {-D {0x?}}\r
+rem\r
+\r
+SETLOCAL\r
+\r
+rem Socket CM testing\r
+rem   set DAT_OVERRIDE=C:\dapl2\dat.conf\r
+rem   set DT=dtest2.exe\r
+rem   set P=ibnic0v2_scm\r
+\r
+rem IBAL CM testing\r
+rem   set DAT_OVERRIDE=C:\dapl2\dat.conf\r
+set DT=dtest2.exe\r
+set P=ibnic0v2\r
+\r
+\r
+if "%1" == "-D" (\r
+  if "%2" == "" (\r
+    set X=0xfffff\r
+    rem set X=0x48\r
+  ) else (\r
+    set X=%2\r
+  )\r
+) else (\r
+  set X=\r
+)\r
+\r
+if not "%X%" == "" (\r
+    set DAT_DBG_LEVEL=%X%\r
+    set DAT_DBG_TYPE=%X%\r
+    set DAT_OS_DBG_TYPE=%X%\r
+    set DAPL_DBG_TYPE=%X%\r
+    set DAPL_DBG_LEVEL=%X%\r
+)\r
+\r
+echo %DT% -s -P %P%\r
+\r
+%DT% -s -P %P%\r
+\r
+echo %0 - %DT% server exit...\r
+\r
+ENDLOCAL\r
+\r
+@echo on\r
+exit /B\r