dapl: update to 2f185c6b5e464c4fc9e84ad3e90cc2b86aebf9aa
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 27 May 2009 18:13:45 +0000 (18:13 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 27 May 2009 18:13:45 +0000 (18:13 +0000)
commit 2f185c6b5e464c4fc9e84ad3e90cc2b86aebf9aa
Author: Arlin Davis <arlin.r.davis@intel.com>
Date:   Mon May 18 14:00:02 2009 -0700

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2209 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

188 files changed:
ulp/dapl2/ChangeLog
ulp/dapl2/configure.in
ulp/dapl2/dapl.spec.in
ulp/dapl2/dapl/common/dapl_cno_util.c
ulp/dapl2/dapl/common/dapl_cookie.c
ulp/dapl2/dapl/common/dapl_cr_accept.c
ulp/dapl2/dapl/common/dapl_cr_callback.c
ulp/dapl2/dapl/common/dapl_cr_handoff.c
ulp/dapl2/dapl/common/dapl_cr_query.c
ulp/dapl2/dapl/common/dapl_cr_reject.c
ulp/dapl2/dapl/common/dapl_cr_util.c
ulp/dapl2/dapl/common/dapl_csp.c
ulp/dapl2/dapl/common/dapl_debug.c
ulp/dapl2/dapl/common/dapl_ep_connect.c
ulp/dapl2/dapl/common/dapl_ep_create.c
ulp/dapl2/dapl/common/dapl_ep_create_with_srq.c
ulp/dapl2/dapl/common/dapl_ep_disconnect.c
ulp/dapl2/dapl/common/dapl_ep_dup_connect.c
ulp/dapl2/dapl/common/dapl_ep_free.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_rdma_read.c
ulp/dapl2/dapl/common/dapl_ep_post_rdma_read_to_rmr.c
ulp/dapl2/dapl/common/dapl_ep_post_rdma_write.c
ulp/dapl2/dapl/common/dapl_ep_post_recv.c
ulp/dapl2/dapl/common/dapl_ep_post_send.c
ulp/dapl2/dapl/common/dapl_ep_post_send_invalidate.c
ulp/dapl2/dapl/common/dapl_ep_query.c
ulp/dapl2/dapl/common/dapl_ep_recv_query.c
ulp/dapl2/dapl/common/dapl_ep_reset.c
ulp/dapl2/dapl/common/dapl_ep_set_watermark.c
ulp/dapl2/dapl/common/dapl_ep_util.c
ulp/dapl2/dapl/common/dapl_evd_connection_callb.c
ulp/dapl2/dapl/common/dapl_evd_cq_async_error_callb.c
ulp/dapl2/dapl/common/dapl_evd_dequeue.c
ulp/dapl2/dapl/common/dapl_evd_dto_callb.c
ulp/dapl2/dapl/common/dapl_evd_free.c
ulp/dapl2/dapl/common/dapl_evd_post_se.c
ulp/dapl2/dapl/common/dapl_evd_qp_async_error_callb.c
ulp/dapl2/dapl/common/dapl_evd_resize.c
ulp/dapl2/dapl/common/dapl_evd_un_async_error_callb.c
ulp/dapl2/dapl/common/dapl_evd_util.c
ulp/dapl2/dapl/common/dapl_get_consumer_context.c
ulp/dapl2/dapl/common/dapl_get_handle_type.c
ulp/dapl2/dapl/common/dapl_hash.c
ulp/dapl2/dapl/common/dapl_hca_util.c
ulp/dapl2/dapl/common/dapl_ia_close.c
ulp/dapl2/dapl/common/dapl_ia_ha.c
ulp/dapl2/dapl/common/dapl_ia_open.c
ulp/dapl2/dapl/common/dapl_ia_query.c
ulp/dapl2/dapl/common/dapl_ia_util.c
ulp/dapl2/dapl/common/dapl_llist.c
ulp/dapl2/dapl/common/dapl_lmr_free.c
ulp/dapl2/dapl/common/dapl_lmr_query.c
ulp/dapl2/dapl/common/dapl_lmr_sync_rdma_read.c
ulp/dapl2/dapl/common/dapl_lmr_sync_rdma_write.c
ulp/dapl2/dapl/common/dapl_lmr_util.c
ulp/dapl2/dapl/common/dapl_mr_util.c
ulp/dapl2/dapl/common/dapl_name_service.c
ulp/dapl2/dapl/common/dapl_provider.c
ulp/dapl2/dapl/common/dapl_psp_create.c
ulp/dapl2/dapl/common/dapl_psp_create_any.c
ulp/dapl2/dapl/common/dapl_psp_free.c
ulp/dapl2/dapl/common/dapl_psp_query.c
ulp/dapl2/dapl/common/dapl_pz_create.c
ulp/dapl2/dapl/common/dapl_pz_free.c
ulp/dapl2/dapl/common/dapl_pz_query.c
ulp/dapl2/dapl/common/dapl_pz_util.c
ulp/dapl2/dapl/common/dapl_ring_buffer_util.c
ulp/dapl2/dapl/common/dapl_rmr_bind.c
ulp/dapl2/dapl/common/dapl_rmr_create.c
ulp/dapl2/dapl/common/dapl_rmr_free.c
ulp/dapl2/dapl/common/dapl_rmr_query.c
ulp/dapl2/dapl/common/dapl_rmr_util.c
ulp/dapl2/dapl/common/dapl_rsp_create.c
ulp/dapl2/dapl/common/dapl_rsp_free.c
ulp/dapl2/dapl/common/dapl_rsp_query.c
ulp/dapl2/dapl/common/dapl_set_consumer_context.c
ulp/dapl2/dapl/common/dapl_sp_util.c
ulp/dapl2/dapl/common/dapl_srq_create.c
ulp/dapl2/dapl/common/dapl_srq_free.c
ulp/dapl2/dapl/common/dapl_srq_post_recv.c
ulp/dapl2/dapl/common/dapl_srq_query.c
ulp/dapl2/dapl/common/dapl_srq_resize.c
ulp/dapl2/dapl/common/dapl_srq_set_lw.c
ulp/dapl2/dapl/common/dapl_srq_util.c
ulp/dapl2/dapl/common/dapl_timer_util.c
ulp/dapl2/dapl/openib_cma/dapl_ib_cm.c
ulp/dapl2/dapl/openib_cma/dapl_ib_cq.c
ulp/dapl2/dapl/openib_cma/dapl_ib_dto.h
ulp/dapl2/dapl/openib_cma/dapl_ib_extensions.c
ulp/dapl2/dapl/openib_cma/dapl_ib_mem.c
ulp/dapl2/dapl/openib_cma/dapl_ib_qp.c
ulp/dapl2/dapl/openib_cma/dapl_ib_util.c
ulp/dapl2/dapl/openib_cma/dapl_ib_util.h
ulp/dapl2/dapl/openib_scm/dapl_ib_cm.c
ulp/dapl2/dapl/openib_scm/dapl_ib_cq.c
ulp/dapl2/dapl/openib_scm/dapl_ib_dto.h
ulp/dapl2/dapl/openib_scm/dapl_ib_extensions.c
ulp/dapl2/dapl/openib_scm/dapl_ib_mem.c
ulp/dapl2/dapl/openib_scm/dapl_ib_qp.c
ulp/dapl2/dapl/openib_scm/dapl_ib_util.c
ulp/dapl2/dapl/openib_scm/dapl_ib_util.h
ulp/dapl2/dapl/udapl/dapl_cno_create.c
ulp/dapl2/dapl/udapl/dapl_cno_free.c
ulp/dapl2/dapl/udapl/dapl_cno_modify_agent.c
ulp/dapl2/dapl/udapl/dapl_cno_query.c
ulp/dapl2/dapl/udapl/dapl_cno_wait.c
ulp/dapl2/dapl/udapl/dapl_evd_clear_unwaitable.c
ulp/dapl2/dapl/udapl/dapl_evd_create.c
ulp/dapl2/dapl/udapl/dapl_evd_disable.c
ulp/dapl2/dapl/udapl/dapl_evd_enable.c
ulp/dapl2/dapl/udapl/dapl_evd_modify_cno.c
ulp/dapl2/dapl/udapl/dapl_evd_query.c
ulp/dapl2/dapl/udapl/dapl_evd_set_unwaitable.c
ulp/dapl2/dapl/udapl/dapl_evd_wait.c
ulp/dapl2/dapl/udapl/dapl_init.c
ulp/dapl2/dapl/udapl/dapl_lmr_create.c
ulp/dapl2/dapl/udapl/linux/dapl_osd.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_dictionary.c
ulp/dapl2/dat/common/dat_dr.c
ulp/dapl2/dat/common/dat_init.c
ulp/dapl2/dat/common/dat_sr.c
ulp/dapl2/dat/common/dat_strerror.c
ulp/dapl2/dat/udat/udat.c
ulp/dapl2/dat/udat/udat_api.c
ulp/dapl2/dat/udat/udat_sr_parser.c
ulp/dapl2/test/dapltest/cmd/dapl_fft_cmd.c
ulp/dapl2/test/dapltest/cmd/dapl_getopt.c
ulp/dapl2/test/dapltest/cmd/dapl_limit_cmd.c
ulp/dapl2/test/dapltest/cmd/dapl_main.c
ulp/dapl2/test/dapltest/cmd/dapl_netaddr.c
ulp/dapl2/test/dapltest/cmd/dapl_params.c
ulp/dapl2/test/dapltest/cmd/dapl_performance_cmd.c
ulp/dapl2/test/dapltest/cmd/dapl_qos_util.c
ulp/dapl2/test/dapltest/cmd/dapl_quit_cmd.c
ulp/dapl2/test/dapltest/cmd/dapl_server_cmd.c
ulp/dapl2/test/dapltest/cmd/dapl_test_data.c
ulp/dapl2/test/dapltest/cmd/dapl_transaction_cmd.c
ulp/dapl2/test/dapltest/common/dapl_endian.c
ulp/dapl2/test/dapltest/common/dapl_global.c
ulp/dapl2/test/dapltest/common/dapl_performance_cmd_util.c
ulp/dapl2/test/dapltest/common/dapl_quit_cmd_util.c
ulp/dapl2/test/dapltest/common/dapl_transaction_cmd_util.c
ulp/dapl2/test/dapltest/dt_cmd.c
ulp/dapl2/test/dapltest/dt_mdep.c
ulp/dapl2/test/dapltest/dt_udapl.c
ulp/dapl2/test/dapltest/mdep/linux/dapl_mdep_kernel.c
ulp/dapl2/test/dapltest/mdep/linux/dapl_mdep_user.c
ulp/dapl2/test/dapltest/scripts/dt-cli.bat
ulp/dapl2/test/dapltest/scripts/dt-svr.bat
ulp/dapl2/test/dapltest/test/dapl_bpool.c
ulp/dapl2/test/dapltest/test/dapl_client.c
ulp/dapl2/test/dapltest/test/dapl_client_info.c
ulp/dapl2/test/dapltest/test/dapl_cnxn.c
ulp/dapl2/test/dapltest/test/dapl_execute.c
ulp/dapl2/test/dapltest/test/dapl_fft_connmgt.c
ulp/dapl2/test/dapltest/test/dapl_fft_dataxfer.c
ulp/dapl2/test/dapltest/test/dapl_fft_dataxfer_client.c
ulp/dapl2/test/dapltest/test/dapl_fft_endpoint.c
ulp/dapl2/test/dapltest/test/dapl_fft_hwconn.c
ulp/dapl2/test/dapltest/test/dapl_fft_mem.c
ulp/dapl2/test/dapltest/test/dapl_fft_pz.c
ulp/dapl2/test/dapltest/test/dapl_fft_queryinfo.c
ulp/dapl2/test/dapltest/test/dapl_fft_test.c
ulp/dapl2/test/dapltest/test/dapl_fft_util.c
ulp/dapl2/test/dapltest/test/dapl_limit.c
ulp/dapl2/test/dapltest/test/dapl_memlist.c
ulp/dapl2/test/dapltest/test/dapl_performance_client.c
ulp/dapl2/test/dapltest/test/dapl_performance_server.c
ulp/dapl2/test/dapltest/test/dapl_performance_stats.c
ulp/dapl2/test/dapltest/test/dapl_performance_util.c
ulp/dapl2/test/dapltest/test/dapl_quit_util.c
ulp/dapl2/test/dapltest/test/dapl_server.c
ulp/dapl2/test/dapltest/test/dapl_server_info.c
ulp/dapl2/test/dapltest/test/dapl_test_data.c
ulp/dapl2/test/dapltest/test/dapl_test_util.c
ulp/dapl2/test/dapltest/test/dapl_thread.c
ulp/dapl2/test/dapltest/test/dapl_transaction_stats.c
ulp/dapl2/test/dapltest/test/dapl_transaction_test.c
ulp/dapl2/test/dapltest/test/dapl_transaction_util.c
ulp/dapl2/test/dapltest/test/dapl_util.c
ulp/dapl2/test/dapltest/udapl/udapl_tdep.c
ulp/dapl2/test/dtest/dtest.c
ulp/dapl2/test/dtest/dtestx.c

index 64b7b60..7b86f8e 100644 (file)
@@ -1,3 +1,106 @@
+commit 0ef94459e0a0175233b43b3fcbaaac2596e1042d
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Wed Apr 29 14:33:28 2009 -0700
+
+    scm, cma: dat max_lmr_block_size is 32 bit, verbs max_mr_size is 64 bit
+    
+    mismatch of device attribute size restricts max_lmr_block_size to 32 bit
+    value. Add check, if larger then limit to 4G-1 until DAT v2 spec changes.
+    
+    Consumers should use max_lmr_virtual_address for actual max
+    registration block size until attribute interface changes.
+    
+    Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
+
+commit f91f27eaaab28b13a631adf75b933b7be3afbc0f
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Wed Apr 29 10:51:03 2009 -0700
+
+    scm: increase default MTU size from 1024 to 2048
+    
+    Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
+
+commit 8d6846056f4c86b6a06346147df55d37c4ba9933
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Wed Apr 29 10:49:09 2009 -0700
+
+    openib_scm, cma: use direct SGE mappings from dat_lmr_triplet to ibv_sge
+    
+    no need to rebuild scatter gather list given that DAT v2.0
+    is now aligned with verbs ibv_sge. Fix ib_send_op_type_t typedef.
+    
+    Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
+
+commit c61f75b3412935e7d4a7a1acc9c495dcb4ac7e24
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Wed Apr 29 08:39:37 2009 -0700
+
+    dtest: add flush EVD call after data transfer errors
+    
+    Flush and print entries on async, request, and receive
+    queues after any data transfer error. Will help
+    identify failing operation during operations
+    without completion events requested.
+    Fix -B0 so burst size of 0 works.
+    
+    Signed-off-by: Arlin Davis <arlin.r.davis@intel.com>
+
+commit c88a191c7a408b0fb3dfb418a77a5b3b5afc778e
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Wed Apr 22 13:16:19 2009 -0700
+
+    dtest/dapltest: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
+commit 8699a9f1bd2bb45b04b87f887698707ba7b62d0a
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Tue Apr 21 15:51:24 2009 -0700
+
+    ibal-scm: remove, obsolete
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
+commit 67ddd6bfba46f1f7a61b772257132f1257d05c96
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Tue Apr 21 15:44:15 2009 -0700
+
+    scm, cma provider: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
+commit d0898091090ff19be7929fed0d14f1ca696d5e53
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Tue Apr 21 15:39:01 2009 -0700
+
+    udapl: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
+commit a688d1cfb52fde256c5bfd95a27f940dd17e7ced
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Tue Apr 21 15:31:20 2009 -0700
+
+    dapl common: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
+commit 2bded73c7f68cfb870e432ab3ebae7427d595cbe
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Tue Apr 21 12:52:29 2009 -0700
+
+    dat: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
+commit 31e7b9210fc5334ff3be62558e74e3fdf01d6cbd
+Author: Arlin Davis <arlin.r.davis@intel.com>
+Date:   Mon Apr 20 12:28:08 2009 -0700
+
+    Release 2.0.18
+    
+    Signed-off-by: Arlin Davis <ardavis@ichips.intel.com>
+
 commit 29bf0a24f54c45d2742026756f31f1a1f26fb6f3
 Author: Arlin Davis <arlin.r.davis@intel.com>
 Date:   Thu Apr 16 14:35:18 2009 -0700
index 16d877f..930d67b 100644 (file)
@@ -1,11 +1,11 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT(dapl, 2.0.18, general@lists.openfabrics.org)
+AC_INIT(dapl, 2.0.19, general@lists.openfabrics.org)
 AC_CONFIG_SRCDIR([dat/udat/udat.c])
 AC_CONFIG_AUX_DIR(config)
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(dapl, 2.0.18)
+AM_INIT_AUTOMAKE(dapl, 2.0.19)
 
 AM_PROG_LIBTOOL
 
index e108219..432785b 100644 (file)
@@ -136,6 +136,9 @@ fi
 %{_mandir}/man5/*.5*
 
 %changelog
+* Thu Apr 30 2009 Arlin Davis <ardavis@ichips.intel.com> - 2.0.19
+- DAT/DAPL Version 2.0.19 Release 1, OFED 1.4.1 GA Final 
+
 * Fri Apr 17 2009 Arlin Davis <ardavis@ichips.intel.com> - 2.0.18
 - DAT/DAPL Version 2.0.18 Release 1, OFED 1.4.1 GA 
 
index 9de7add..2215f29 100644 (file)
@@ -38,8 +38,6 @@
 #include "dapl_cno_util.h"
 #include "dapl_adapter_util.h"
 
-
-
 /*
  * dapl_cno_alloc
  *
  *     cno_ptr, or null on failure.
  */
 #if defined(__KDAPL__)
-DAPL_CNO *
-dapl_cno_alloc (
-    IN DAPL_IA                         *ia_ptr,
-    IN const DAT_UPCALL_OBJECT         *upcall)
+DAPL_CNO *dapl_cno_alloc(IN DAPL_IA * ia_ptr,
+                        IN const DAT_UPCALL_OBJECT * upcall)
 #else
-DAPL_CNO *
-dapl_cno_alloc (
-    IN DAPL_IA                         *ia_ptr,
-    IN DAT_OS_WAIT_PROXY_AGENT         wait_agent)
-#endif /* defined(__KDAPL__) */
+DAPL_CNO *dapl_cno_alloc(IN DAPL_IA * ia_ptr,
+                        IN DAT_OS_WAIT_PROXY_AGENT wait_agent)
+#endif                         /* defined(__KDAPL__) */
 {
-    DAPL_CNO *cno_ptr;
+       DAPL_CNO *cno_ptr;
 
-    cno_ptr = (DAPL_CNO *) dapl_os_alloc (sizeof (DAPL_CNO));
-    if (!cno_ptr)
-    {
-       return NULL;
-    }
+       cno_ptr = (DAPL_CNO *) dapl_os_alloc(sizeof(DAPL_CNO));
+       if (!cno_ptr) {
+               return NULL;
+       }
 
-    /* zero the structure */
-    dapl_os_memzero (cno_ptr, sizeof (DAPL_CNO));
+       /* zero the structure */
+       dapl_os_memzero(cno_ptr, sizeof(DAPL_CNO));
 
-    /*
-     * Initialize the header.
-     */
-    cno_ptr->header.provider            = ia_ptr->header.provider;
-    cno_ptr->header.magic               = DAPL_MAGIC_CNO;
+       /*
+        * Initialize the header.
+        */
+       cno_ptr->header.provider = ia_ptr->header.provider;
+       cno_ptr->header.magic = DAPL_MAGIC_CNO;
 #if !defined(__KDAPL__)
-    cno_ptr->header.handle_type         = DAT_HANDLE_TYPE_CNO;
-#endif /* defined(__KDAPL__) */
-    cno_ptr->header.owner_ia            = ia_ptr;
-    cno_ptr->header.user_context.as_64  = 0;
-    cno_ptr->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&cno_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&cno_ptr->header.lock);
+       cno_ptr->header.handle_type = DAT_HANDLE_TYPE_CNO;
+#endif                         /* defined(__KDAPL__) */
+       cno_ptr->header.owner_ia = ia_ptr;
+       cno_ptr->header.user_context.as_64 = 0;
+       cno_ptr->header.user_context.as_ptr = NULL;
+       dapl_llist_init_entry(&cno_ptr->header.ia_list_entry);
+       dapl_os_lock_init(&cno_ptr->header.lock);
 
-    /*
-     * Initialize the body
-     */
-    cno_ptr->cno_waiters = 0;
-    dapl_os_atomic_set (&cno_ptr->cno_ref_count, 0);
-    cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
-    cno_ptr->cno_evd_triggered = NULL;
+       /*
+        * Initialize the body
+        */
+       cno_ptr->cno_waiters = 0;
+       dapl_os_atomic_set(&cno_ptr->cno_ref_count, 0);
+       cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
+       cno_ptr->cno_evd_triggered = NULL;
 #if defined(__KDAPL__)
-    cno_ptr->cno_upcall = *upcall;
+       cno_ptr->cno_upcall = *upcall;
 #else
-    cno_ptr->cno_wait_agent = wait_agent;
-#endif /* defined(__KDAPL__) */
-    dapl_os_wait_object_init (&cno_ptr->cno_wait_object);
+       cno_ptr->cno_wait_agent = wait_agent;
+#endif                         /* defined(__KDAPL__) */
+       dapl_os_wait_object_init(&cno_ptr->cno_wait_object);
 
-    return cno_ptr;
+       return cno_ptr;
 }
 
 /*
@@ -120,23 +113,20 @@ dapl_cno_alloc (
  *     none
  *
  */
-void
-dapl_cno_dealloc (
-    IN DAPL_CNO *cno_ptr)
+void dapl_cno_dealloc(IN DAPL_CNO * cno_ptr)
 {
-    dapl_os_assert (cno_ptr->header.magic == DAPL_MAGIC_CNO);
-    dapl_os_assert (dapl_os_atomic_read (&cno_ptr->cno_ref_count) == 0);
+       dapl_os_assert(cno_ptr->header.magic == DAPL_MAGIC_CNO);
+       dapl_os_assert(dapl_os_atomic_read(&cno_ptr->cno_ref_count) == 0);
 
-    /*
-     * deinitialize the header
-     */
-    cno_ptr->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */
+       /*
+        * deinitialize the header
+        */
+       cno_ptr->header.magic = DAPL_MAGIC_INVALID;     /* reset magic to prevent reuse */
 
-    dapl_os_wait_object_destroy (&cno_ptr->cno_wait_object);
-    dapl_os_free (cno_ptr, sizeof (DAPL_CNO));
+       dapl_os_wait_object_destroy(&cno_ptr->cno_wait_object);
+       dapl_os_free(cno_ptr, sizeof(DAPL_CNO));
 }
 
-
 /*
  * dapl_internal_cno_trigger
  *
@@ -155,110 +145,101 @@ dapl_cno_dealloc (
  * Returns:
  *     None
  */
-void
-dapl_internal_cno_trigger (
-    IN DAPL_CNO                *cno_ptr,
-    IN DAPL_EVD                *evd_ptr)
+void dapl_internal_cno_trigger(IN DAPL_CNO * cno_ptr, IN DAPL_EVD * evd_ptr)
 {
-    DAT_RETURN         dat_status;
+       DAT_RETURN dat_status;
 #if defined(__KDAPL__)
-    DAT_EVENT          event;
-#endif /* defined(__KDAPL__) */
+       DAT_EVENT event;
+#endif                         /* defined(__KDAPL__) */
 
-    dat_status = DAT_SUCCESS;
+       dat_status = DAT_SUCCESS;
 
-    dapl_os_assert (cno_ptr->header.magic == DAPL_MAGIC_CNO);
-    /* The spec allows NULL EVDs. kDAPL doesn't have CNOs, they
-     * are strictly used behind the scenes
-     */
-    dapl_os_assert (evd_ptr == NULL || evd_ptr->header.magic == DAPL_MAGIC_EVD);
+       dapl_os_assert(cno_ptr->header.magic == DAPL_MAGIC_CNO);
+       /* The spec allows NULL EVDs. kDAPL doesn't have CNOs, they
+        * are strictly used behind the scenes
+        */
+       dapl_os_assert(evd_ptr == NULL
+                      || evd_ptr->header.magic == DAPL_MAGIC_EVD);
 
-    dapl_os_lock (&cno_ptr->header.lock);
+       dapl_os_lock(&cno_ptr->header.lock);
 
-    /* Maybe I should just return, but this really shouldn't happen.  */
-    dapl_os_assert (cno_ptr->cno_state != DAPL_CNO_STATE_DEAD);
+       /* Maybe I should just return, but this really shouldn't happen.  */
+       dapl_os_assert(cno_ptr->cno_state != DAPL_CNO_STATE_DEAD);
 
-    if (cno_ptr->cno_state == DAPL_CNO_STATE_UNTRIGGERED)
-    {
+       if (cno_ptr->cno_state == DAPL_CNO_STATE_UNTRIGGERED) {
 #if !defined(__KDAPL__)
-       DAT_OS_WAIT_PROXY_AGENT agent;
+               DAT_OS_WAIT_PROXY_AGENT agent;
 
-       /* Squirrel away wait agent, and delete link.  */
-       agent = cno_ptr->cno_wait_agent;
-#endif /* !defined(__KDAPL__) */
+               /* Squirrel away wait agent, and delete link.  */
+               agent = cno_ptr->cno_wait_agent;
+#endif                         /* !defined(__KDAPL__) */
 
-       /* Separate assignments for windows compiler.  */
+               /* Separate assignments for windows compiler.  */
 #ifndef _WIN32
 #if defined(__KDAPL__)
-       cno_ptr->cno_upcall = DAT_UPCALL_NULL;
+               cno_ptr->cno_upcall = DAT_UPCALL_NULL;
 #else
-       cno_ptr->cno_wait_agent = DAT_OS_WAIT_PROXY_AGENT_NULL;
-#endif /* defined(__KDAPL__) */
+               cno_ptr->cno_wait_agent = DAT_OS_WAIT_PROXY_AGENT_NULL;
+#endif                         /* defined(__KDAPL__) */
 #else
-       cno_ptr->cno_wait_agent.instance_data    = NULL;
-       cno_ptr->cno_wait_agent.proxy_agent_func = NULL;
+               cno_ptr->cno_wait_agent.instance_data = NULL;
+               cno_ptr->cno_wait_agent.proxy_agent_func = NULL;
 #endif
 
-       cno_ptr->cno_evd_triggered = evd_ptr;
+               cno_ptr->cno_evd_triggered = evd_ptr;
 
-       /*
-        * Must set to triggerred and let waiter untrigger to handle
-        * timeout of waiter.
-        */
-       cno_ptr->cno_state = DAPL_CNO_STATE_TRIGGERED;
-       if (cno_ptr->cno_waiters > 0)
-       {
-           dapl_os_wait_object_wakeup (&cno_ptr->cno_wait_object);
-       }
+               /*
+                * Must set to triggerred and let waiter untrigger to handle
+                * timeout of waiter.
+                */
+               cno_ptr->cno_state = DAPL_CNO_STATE_TRIGGERED;
+               if (cno_ptr->cno_waiters > 0) {
+                       dapl_os_wait_object_wakeup(&cno_ptr->cno_wait_object);
+               }
 
-       dapl_os_unlock (&cno_ptr->header.lock);
+               dapl_os_unlock(&cno_ptr->header.lock);
 
-       /* Trigger the OS proxy wait agent, if one exists.  */
+               /* Trigger the OS proxy wait agent, if one exists.  */
 #if defined(__KDAPL__)
-       dat_status = dapl_evd_dequeue ( (DAT_EVD_HANDLE)evd_ptr,
-                                      &event );
-       while (dat_status == DAT_SUCCESS )
-       {
-           if (cno_ptr->cno_upcall.upcall_func != (DAT_UPCALL_FUNC) NULL)
-           {
-               cno_ptr->cno_upcall.upcall_func (
-                                       cno_ptr->cno_upcall.instance_data,
-                                       &event,
-                                       DAT_FALSE);
-           }
-           dat_status = dapl_evd_dequeue ( (DAT_EVD_HANDLE)evd_ptr,
-                                          &event );
-       }
+               dat_status = dapl_evd_dequeue((DAT_EVD_HANDLE) evd_ptr, &event);
+               while (dat_status == DAT_SUCCESS) {
+                       if (cno_ptr->cno_upcall.upcall_func !=
+                           (DAT_UPCALL_FUNC) NULL) {
+                               cno_ptr->cno_upcall.upcall_func(cno_ptr->
+                                                               cno_upcall.
+                                                               instance_data,
+                                                               &event,
+                                                               DAT_FALSE);
+                       }
+                       dat_status = dapl_evd_dequeue((DAT_EVD_HANDLE) evd_ptr,
+                                                     &event);
+               }
 #else
-       if (agent.proxy_agent_func != (DAT_AGENT_FUNC) NULL)
-       {
-           agent.proxy_agent_func (
-               agent.instance_data, (DAT_EVD_HANDLE) evd_ptr );
-       }
-#endif /* defined(__KDAPL__) */
-    }
-    else
-    {
-       dapl_os_unlock (&cno_ptr->header.lock);
+               if (agent.proxy_agent_func != (DAT_AGENT_FUNC) NULL) {
+                       agent.proxy_agent_func(agent.instance_data,
+                                              (DAT_EVD_HANDLE) evd_ptr);
+               }
+#endif                         /* defined(__KDAPL__) */
+       } else {
+               dapl_os_unlock(&cno_ptr->header.lock);
 #if defined(__KDAPL__)
-       dat_status = dapl_evd_dequeue ( (DAT_EVD_HANDLE)evd_ptr,
-                                      &event );
-       while (dat_status == DAT_SUCCESS )
-       {
-           if (cno_ptr->cno_upcall.upcall_func != (DAT_UPCALL_FUNC) NULL)
-           {
-               cno_ptr->cno_upcall.upcall_func (
-                                       cno_ptr->cno_upcall.instance_data,
-                                       &event,
-                                       DAT_FALSE);
-           }
-           dat_status = dapl_evd_dequeue ( (DAT_EVD_HANDLE)evd_ptr,
-                                          &event );
+               dat_status = dapl_evd_dequeue((DAT_EVD_HANDLE) evd_ptr, &event);
+               while (dat_status == DAT_SUCCESS) {
+                       if (cno_ptr->cno_upcall.upcall_func !=
+                           (DAT_UPCALL_FUNC) NULL) {
+                               cno_ptr->cno_upcall.upcall_func(cno_ptr->
+                                                               cno_upcall.
+                                                               instance_data,
+                                                               &event,
+                                                               DAT_FALSE);
+                       }
+                       dat_status = dapl_evd_dequeue((DAT_EVD_HANDLE) evd_ptr,
+                                                     &event);
+               }
+#endif                         /* defined(__KDAPL__) */
        }
-#endif /* defined(__KDAPL__) */
-    }
 
-    return;
+       return;
 }
 
 /*
@@ -292,12 +273,10 @@ dapl_internal_cno_trigger (
  *     DAT_PRIVILEGES_VIOLATION
  *     DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN DAT_API
-dapl_cno_fd_create (
-       IN      DAT_IA_HANDLE ia_handle,        /* ia_handle            */
-       OUT     DAT_FD *fd,                     /* file_descriptor      */
-       OUT     DAT_CNO_HANDLE *cno_handle)     /* cno_handle           */
-{
+DAT_RETURN DAT_API dapl_cno_fd_create(IN DAT_IA_HANDLE ia_handle,      /* ia_handle            */
+                                     OUT DAT_FD * fd,  /* file_descriptor      */
+                                     OUT DAT_CNO_HANDLE * cno_handle)
+{                              /* cno_handle           */
        return DAT_MODEL_NOT_SUPPORTED;
 }
 
@@ -320,9 +299,7 @@ dapl_cno_fd_create (
  *     DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_cno_trigger(
-    IN  DAT_CNO_HANDLE cno_handle,
-    OUT DAT_EVD_HANDLE *evd_handle)
+dapl_cno_trigger(IN DAT_CNO_HANDLE cno_handle, OUT DAT_EVD_HANDLE * evd_handle)
 {
        return DAT_MODEL_NOT_SUPPORTED;
 }
index 1462fe9..990ff66 100644 (file)
 #include "dapl_cookie.h"
 #include "dapl_ring_buffer_util.h"
 
-
 /*********************************************************************
  *                                                                   *
  * Function Prototypes                                               *
  *                                                                   *
  *********************************************************************/
 
-DAT_RETURN 
-dapls_cb_get (
-    DAPL_COOKIE_BUFFER         *buffer,
-    DAPL_COOKIE                **cookie_ptr );
-
-DAT_RETURN 
-dapls_cb_put (
-    DAPL_COOKIE_BUFFER         *buffer,
-    DAPL_COOKIE                *cookie );
+DAT_RETURN dapls_cb_get(DAPL_COOKIE_BUFFER * buffer, DAPL_COOKIE ** cookie_ptr);
 
+DAT_RETURN dapls_cb_put(DAPL_COOKIE_BUFFER * buffer, DAPL_COOKIE * cookie);
 
 /*********************************************************************
  *                                                                   *
@@ -105,7 +97,6 @@ dapls_cb_put (
  *                                                                   *
  *********************************************************************/
 
-
 /*
  * dapls_cb_create
  *
@@ -126,41 +117,34 @@ dapls_cb_put (
  *
  */
 DAT_RETURN
-dapls_cb_create (
-    IN  DAPL_COOKIE_BUFFER     *buffer,
-    IN         DAPL_EP                 *ep,
-    IN  DAT_COUNT              size )
+dapls_cb_create(IN DAPL_COOKIE_BUFFER * buffer,
+               IN DAPL_EP * ep, IN DAT_COUNT size)
 {
-    DAT_COUNT                  i;
-
-    /*
-     * allocate one additional entry so that the tail 
-     * can always point at an empty location
-     */
-    size++; 
-
-    buffer->pool = dapl_os_alloc (size * sizeof (DAPL_COOKIE));
-    if ( NULL != buffer->pool )
-    {
-       buffer->pool_size = size;
-       dapl_os_atomic_set(&buffer->head, 0);
-       dapl_os_atomic_set(&buffer->tail, 0);
-
-        for ( i = 0; i < size; i++ )
-        {
-            buffer->pool[i].index = i;
-            buffer->pool[i].ep = ep;
-        }
-
-        return (DAT_SUCCESS);
-    }
-    else
-    {
-       return (DAT_INSUFFICIENT_RESOURCES);
-    }
+       DAT_COUNT i;
+
+       /*
+        * allocate one additional entry so that the tail 
+        * can always point at an empty location
+        */
+       size++;
+
+       buffer->pool = dapl_os_alloc(size * sizeof(DAPL_COOKIE));
+       if (NULL != buffer->pool) {
+               buffer->pool_size = size;
+               dapl_os_atomic_set(&buffer->head, 0);
+               dapl_os_atomic_set(&buffer->tail, 0);
+
+               for (i = 0; i < size; i++) {
+                       buffer->pool[i].index = i;
+                       buffer->pool[i].ep = ep;
+               }
+
+               return (DAT_SUCCESS);
+       } else {
+               return (DAT_INSUFFICIENT_RESOURCES);
+       }
 }
 
-
 /*
  * dapls_cb_free
  *
@@ -176,18 +160,15 @@ dapls_cb_create (
  *     none
  *
  */
-void
-dapls_cb_free (
-    IN  DAPL_COOKIE_BUFFER     *buffer )
+void dapls_cb_free(IN DAPL_COOKIE_BUFFER * buffer)
 {
-    if ( NULL != buffer->pool )
-    {
-        dapl_os_free (buffer->pool, buffer->pool_size * sizeof (DAPL_COOKIE));
-        buffer->pool = NULL;
-    }
+       if (NULL != buffer->pool) {
+               dapl_os_free(buffer->pool,
+                            buffer->pool_size * sizeof(DAPL_COOKIE));
+               buffer->pool = NULL;
+       }
 }
 
-
 /*
  * dapls_cb_get
  *
@@ -205,34 +186,28 @@ dapls_cb_free (
  *     DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN 
-dapls_cb_get (
-    IN  DAPL_COOKIE_BUFFER     *buffer,
-    OUT DAPL_COOKIE            **cookie_ptr )
+DAT_RETURN
+dapls_cb_get(IN DAPL_COOKIE_BUFFER * buffer, OUT DAPL_COOKIE ** cookie_ptr)
 {
-    DAT_RETURN                 dat_status;
-    DAT_COUNT                  new_head;
-
-    dapl_os_assert(NULL != cookie_ptr);
-
-    new_head = (dapl_os_atomic_read (&buffer->head) + 1) % buffer->pool_size;
-
-    if ( new_head == dapl_os_atomic_read (&buffer->tail) )
-    {
-        dat_status = DAT_INSUFFICIENT_RESOURCES;
-       goto bail;
-    }
-    else
-    {
-        dapl_os_atomic_set (&buffer->head, new_head);
-       *cookie_ptr = &buffer->pool[dapl_os_atomic_read (&buffer->head)];
-       dat_status = DAT_SUCCESS;
-    }
-bail:
-    return dat_status;
+       DAT_RETURN dat_status;
+       DAT_COUNT new_head;
+
+       dapl_os_assert(NULL != cookie_ptr);
+
+       new_head = (dapl_os_atomic_read(&buffer->head) + 1) % buffer->pool_size;
+
+       if (new_head == dapl_os_atomic_read(&buffer->tail)) {
+               dat_status = DAT_INSUFFICIENT_RESOURCES;
+               goto bail;
+       } else {
+               dapl_os_atomic_set(&buffer->head, new_head);
+               *cookie_ptr = &buffer->pool[dapl_os_atomic_read(&buffer->head)];
+               dat_status = DAT_SUCCESS;
+       }
+      bail:
+       return dat_status;
 }
 
-
 /*
  * dapls_cb_put
  *
@@ -250,14 +225,11 @@ bail:
  *     DAT_INSUFFICIENT_EMPTY
  *
  */
-DAT_RETURN 
-dapls_cb_put (
-    IN  DAPL_COOKIE_BUFFER     *buffer,
-    IN  DAPL_COOKIE            *cookie )
+DAT_RETURN dapls_cb_put(IN DAPL_COOKIE_BUFFER * buffer, IN DAPL_COOKIE * cookie)
 {
-    dapl_os_atomic_set (&buffer->tail, cookie->index);
+       dapl_os_atomic_set(&buffer->tail, cookie->index);
 
-    return DAT_SUCCESS;
+       return DAT_SUCCESS;
 }
 
 /*
@@ -272,9 +244,7 @@ dapls_cb_put (
  *     DAT_COUNT       number of active/pending cookies
  *
  */
-extern DAT_COUNT 
-dapls_cb_pending (
-    DAPL_COOKIE_BUFFER *buffer )
+extern DAT_COUNT dapls_cb_pending(DAPL_COOKIE_BUFFER * buffer)
 {
        DAT_COUNT head, tail;
 
@@ -285,7 +255,7 @@ dapls_cb_pending (
                return 0;
        else if (head > tail)
                return (head - tail);
-       else 
+       else
                return ((buffer->pool_size - tail) + head);
 }
 
@@ -308,33 +278,31 @@ dapls_cb_pending (
  *
  */
 DAT_RETURN
-dapls_rmr_cookie_alloc (
-    IN  DAPL_COOKIE_BUFFER     *buffer,
-    IN         DAPL_RMR                *rmr,
-    IN         DAT_RMR_COOKIE          user_cookie,
-    OUT DAPL_COOKIE            **cookie_ptr )
+dapls_rmr_cookie_alloc(IN DAPL_COOKIE_BUFFER * buffer,
+                      IN DAPL_RMR * rmr,
+                      IN DAT_RMR_COOKIE user_cookie,
+                      OUT DAPL_COOKIE ** cookie_ptr)
 {
-    DAPL_COOKIE                *cookie;
-    DAT_RETURN                 dat_status;
-
-    if ( DAT_SUCCESS != dapls_cb_get (buffer, &cookie) )
-    {
-        *cookie_ptr = NULL;
-        dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-       goto bail;
-    }
-    
-    dat_status = DAT_SUCCESS;
-    cookie->type           = DAPL_COOKIE_TYPE_RMR;
-    cookie->val.rmr.rmr    = rmr;
-    cookie->val.rmr.cookie = user_cookie;
-
-    *cookie_ptr =  cookie;
-
- bail:
-    return dat_status;
-}
+       DAPL_COOKIE *cookie;
+       DAT_RETURN dat_status;
 
+       if (DAT_SUCCESS != dapls_cb_get(buffer, &cookie)) {
+               *cookie_ptr = NULL;
+               dat_status =
+                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+               goto bail;
+       }
+
+       dat_status = DAT_SUCCESS;
+       cookie->type = DAPL_COOKIE_TYPE_RMR;
+       cookie->val.rmr.rmr = rmr;
+       cookie->val.rmr.cookie = user_cookie;
+
+       *cookie_ptr = cookie;
+
+      bail:
+       return dat_status;
+}
 
 /*
  * dapls_dto_cookie_alloc
@@ -355,38 +323,34 @@ dapls_rmr_cookie_alloc (
  *
  */
 DAT_RETURN
-dapls_dto_cookie_alloc (
-    IN  DAPL_COOKIE_BUFFER     *buffer,
-    IN  DAPL_DTO_TYPE          type,
-    IN         DAT_DTO_COOKIE          user_cookie,
-    OUT DAPL_COOKIE            **cookie_ptr )
+dapls_dto_cookie_alloc(IN DAPL_COOKIE_BUFFER * buffer,
+                      IN DAPL_DTO_TYPE type,
+                      IN DAT_DTO_COOKIE user_cookie,
+                      OUT DAPL_COOKIE ** cookie_ptr)
 {
-    DAPL_COOKIE                *cookie;
-
-    if ( DAT_SUCCESS != dapls_cb_get (buffer, &cookie) )
-    {
-        *cookie_ptr = NULL;
-        return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-    }
-    
-    cookie->type = DAPL_COOKIE_TYPE_DTO;
-    cookie->val.dto.type = type;
-    cookie->val.dto.cookie = user_cookie;
-    cookie->val.dto.size = 0;
-
-    *cookie_ptr = cookie;
-    return DAT_SUCCESS;
+       DAPL_COOKIE *cookie;
+
+       if (DAT_SUCCESS != dapls_cb_get(buffer, &cookie)) {
+               *cookie_ptr = NULL;
+               return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+                                DAT_RESOURCE_MEMORY);
+       }
+
+       cookie->type = DAPL_COOKIE_TYPE_DTO;
+       cookie->val.dto.type = type;
+       cookie->val.dto.cookie = user_cookie;
+       cookie->val.dto.size = 0;
+
+       *cookie_ptr = cookie;
+       return DAT_SUCCESS;
 }
 
 void
-dapls_cookie_dealloc (
-    IN  DAPL_COOKIE_BUFFER     *buffer,
-    IN         DAPL_COOKIE             *cookie)
+dapls_cookie_dealloc(IN DAPL_COOKIE_BUFFER * buffer, IN DAPL_COOKIE * cookie)
 {
-    dapls_cb_put (buffer, cookie);
+       dapls_cb_put(buffer, cookie);
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4
index 1059e0c..76a841e 100644 (file)
  *     DAT_INVALID_ATTRIBUTE
  */
 DAT_RETURN DAT_API
-dapl_cr_accept (
-       IN      DAT_CR_HANDLE           cr_handle,
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_COUNT               private_data_size,
-       IN      const DAT_PVOID         private_data )
+dapl_cr_accept(IN DAT_CR_HANDLE cr_handle,
+              IN DAT_EP_HANDLE ep_handle,
+              IN DAT_COUNT private_data_size, IN const DAT_PVOID private_data)
 {
-    DAPL_EP            *ep_ptr;
-    DAT_RETURN         dat_status;
-    DAPL_CR            *cr_ptr;
-    DAT_EP_STATE       entry_ep_state;
-    DAT_EP_HANDLE      entry_ep_handle;
-
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                  "dapl_cr_accept (CR %p EP %p, PDsz %d PD %p)\n",
-                   cr_handle, 
-                   ep_handle, 
-                   private_data_size,
-                    private_data);
-
-    if ( DAPL_BAD_HANDLE (cr_handle, DAPL_MAGIC_CR) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CR);
-       goto bail;
-    }
-
-    cr_ptr = (DAPL_CR *) cr_handle;
-    /*
-     * Return an error if we have an ep_handle and the CR already has an
-     * EP, indicating this is an RSP connection or PSP_PROVIDER_FLAG was
-     * specified.
-     */
-    if ( ep_handle != NULL &&
-        ( DAPL_BAD_HANDLE (ep_handle, DAPL_MAGIC_EP) ||
-          cr_ptr->param.local_ep_handle != NULL ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-    /* Make sure we have an EP handle in one place or another */
-    if ( ep_handle == NULL && cr_ptr->param.local_ep_handle == NULL )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-    
-    if ( (0 != private_data_size) && (NULL == private_data) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG4);
-       goto bail;
-    }
-
-    /*
-     * ep_handle is NULL if the user specified DAT_PSP_PROVIDER_FLAG
-     * OR this is an RSP connection; retrieve it from the cr.
-     */
-    if ( ep_handle == NULL )
-    {
-        ep_handle = cr_ptr->param.local_ep_handle;
-       if ( ((((DAPL_EP *) ep_handle)->param.ep_state != DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING)
-            && (((DAPL_EP *)ep_handle)->param.ep_state != DAT_EP_STATE_PASSIVE_CONNECTION_PENDING)) &&
-            (((DAPL_EP *)ep_handle)->param.ep_attr.service_type == DAT_SERVICE_TYPE_RC))
-       {
-           return DAT_INVALID_STATE;
+       DAPL_EP *ep_ptr;
+       DAT_RETURN dat_status;
+       DAPL_CR *cr_ptr;
+       DAT_EP_STATE entry_ep_state;
+       DAT_EP_HANDLE entry_ep_handle;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_cr_accept (CR %p EP %p, PDsz %d PD %p)\n",
+                    cr_handle, ep_handle, private_data_size, private_data);
+
+       if (DAPL_BAD_HANDLE(cr_handle, DAPL_MAGIC_CR)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+               goto bail;
        }
-    } else
-    {
-        /* ensure this EP isn't connected or in use*/
-       if ( (((DAPL_EP *)ep_handle)->param.ep_state != DAT_EP_STATE_UNCONNECTED) &&
-            (((DAPL_EP *)ep_handle)->param.ep_attr.service_type == DAT_SERVICE_TYPE_RC))
-       {
-           return DAT_INVALID_STATE;
+
+       cr_ptr = (DAPL_CR *) cr_handle;
+
+       /*
+        * Return an error if we have an ep_handle and the CR already has an
+        * EP, indicating this is an RSP connection or PSP_PROVIDER_FLAG was
+        * specified.
+        */
+       if (ep_handle != NULL &&
+           (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP) ||
+            cr_ptr->param.local_ep_handle != NULL)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
+
+       /* Make sure we have an EP handle in one place or another */
+       if (ep_handle == NULL && cr_ptr->param.local_ep_handle == NULL) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
        }
-    }
-
-    ep_ptr = (DAPL_EP *) ep_handle;
-
-    /*
-     * Verify the attributes of the EP handle before we connect it. Test
-     * all of the handles to make sure they are currently valid.
-     * Specifically:
-     *   pz_handle             required
-     *   recv_evd_handle       optional, but must be valid
-     *   request_evd_handle    optional, but must be valid
-     *   connect_evd_handle    required
-     * We do all verification and state change under lock, at which
-     * point the EP state should protect us from most races.
-     */
-    dapl_os_lock ( &ep_ptr->header.lock );
-    if ( ep_ptr->param.pz_handle == NULL
-        ||  DAPL_BAD_HANDLE (ep_ptr->param.pz_handle, DAPL_MAGIC_PZ)
-        /* test connect handle */
-        || ep_ptr->param.connect_evd_handle == NULL
-        || DAPL_BAD_HANDLE (ep_ptr->param.connect_evd_handle, DAPL_MAGIC_EVD)
-        || ! (((DAPL_EVD *)ep_ptr->param.connect_evd_handle)->evd_flags & DAT_EVD_CONNECTION_FLAG)
-        /* test optional completion handles */
-        || (ep_ptr->param.recv_evd_handle != DAT_HANDLE_NULL &&
-            (DAPL_BAD_HANDLE (ep_ptr->param.recv_evd_handle, DAPL_MAGIC_EVD)))
-
-        || (ep_ptr->param.request_evd_handle != DAT_HANDLE_NULL &&
-            (DAPL_BAD_HANDLE (ep_ptr->param.request_evd_handle, DAPL_MAGIC_EVD))))
-    {
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-
-    /* The qp must be attached by this point! */
-    if ( ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED )
-    {
-        dapl_os_unlock ( &ep_ptr->header.lock );
-        dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EP);
-        goto bail;
-    }
-
-    entry_ep_state         = ep_ptr->param.ep_state;
-    entry_ep_handle        = cr_ptr->param.local_ep_handle;
-    ep_ptr->param.ep_state = DAT_EP_STATE_COMPLETION_PENDING;
-    ep_ptr->cm_handle      = cr_ptr->ib_cm_handle;
-    ep_ptr->cr_ptr         = cr_ptr;
-    ep_ptr->param.remote_ia_address_ptr = cr_ptr->param.remote_ia_address_ptr;
-    cr_ptr->param.local_ep_handle       = ep_handle;
-
-    dapl_os_unlock ( &ep_ptr->header.lock );
-
-    dat_status = dapls_ib_accept_connection ( cr_handle,
-                                             ep_handle,
-                                             private_data_size,
-                                             private_data );
-
-    /*
-     * If the provider failed, unwind the damage so we are back at
-     * the initial state.
-     */
-    if ( dat_status != DAT_SUCCESS)
-    {
-       if ( DAT_GET_TYPE(dat_status) == DAT_INVALID_ADDRESS )
-       {
-           /* The remote connection request has disappeared; timeout,
-            * system error, app termination, perhaps other reasons.
-            */
-           dat_status = dapls_evd_post_connection_event (
-               ep_ptr->param.connect_evd_handle,
-               DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR,
-               (DAT_HANDLE) ep_ptr,
-               0,
-               0 );
-
-           cr_ptr->header.magic = DAPL_MAGIC_CR_DESTROYED;
-       } 
-       else
-       {
-           ep_ptr->param.ep_state        = entry_ep_state;
-           cr_ptr->param.local_ep_handle = entry_ep_handle;
-           ep_ptr->cr_ptr                = NULL;
-           ep_ptr->param.remote_ia_address_ptr = NULL;
+
+       if ((0 != private_data_size) && (NULL == private_data)) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+               goto bail;
        }
 
        /*
-        * After restoring values above, we now check if we need
-        * to translate the error
+        * ep_handle is NULL if the user specified DAT_PSP_PROVIDER_FLAG
+        * OR this is an RSP connection; retrieve it from the cr.
         */
-       if ( DAT_GET_TYPE(dat_status) == DAT_LENGTH_ERROR )
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+       if (ep_handle == NULL) {
+               ep_handle = cr_ptr->param.local_ep_handle;
+               if (((((DAPL_EP *) ep_handle)->param.ep_state !=
+                     DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING)
+                    && (((DAPL_EP *) ep_handle)->param.ep_state !=
+                        DAT_EP_STATE_PASSIVE_CONNECTION_PENDING))
+                   && (((DAPL_EP *) ep_handle)->param.ep_attr.service_type ==
+                       DAT_SERVICE_TYPE_RC)) {
+                       return DAT_INVALID_STATE;
+               }
+       } else {
+               /* ensure this EP isn't connected or in use */
+               if ((((DAPL_EP *) ep_handle)->param.ep_state !=
+                    DAT_EP_STATE_UNCONNECTED)
+                   && (((DAPL_EP *) ep_handle)->param.ep_attr.service_type ==
+                       DAT_SERVICE_TYPE_RC)) {
+                       return DAT_INVALID_STATE;
+               }
        }
 
-    }
-    else
-    {
-       /* Make this CR invalid. We need to hang on to it until
-        * the connection terminates, but it's destroyed from
-        * the app point of view.
+       ep_ptr = (DAPL_EP *) ep_handle;
+
+       /*
+        * Verify the attributes of the EP handle before we connect it. Test
+        * all of the handles to make sure they are currently valid.
+        * Specifically:
+        *   pz_handle              required
+        *   recv_evd_handle        optional, but must be valid
+        *   request_evd_handle     optional, but must be valid
+        *   connect_evd_handle     required
+        * We do all verification and state change under lock, at which
+        * point the EP state should protect us from most races.
         */
-       cr_ptr->header.magic = DAPL_MAGIC_CR_DESTROYED;
-    }
+       dapl_os_lock(&ep_ptr->header.lock);
+       if (ep_ptr->param.pz_handle == NULL
+           || DAPL_BAD_HANDLE(ep_ptr->param.pz_handle, DAPL_MAGIC_PZ)
+           /* test connect handle */
+           || ep_ptr->param.connect_evd_handle == NULL
+           || DAPL_BAD_HANDLE(ep_ptr->param.connect_evd_handle, DAPL_MAGIC_EVD)
+           || !(((DAPL_EVD *) ep_ptr->param.connect_evd_handle)->
+                evd_flags & DAT_EVD_CONNECTION_FLAG)
+           /* test optional completion handles */
+           || (ep_ptr->param.recv_evd_handle != DAT_HANDLE_NULL &&
+               (DAPL_BAD_HANDLE
+                (ep_ptr->param.recv_evd_handle, DAPL_MAGIC_EVD)))
+
+           || (ep_ptr->param.request_evd_handle != DAT_HANDLE_NULL &&
+               (DAPL_BAD_HANDLE
+                (ep_ptr->param.request_evd_handle, DAPL_MAGIC_EVD)))) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
+
+       /* The qp must be attached by this point! */
+       if (ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
+
+       entry_ep_state = ep_ptr->param.ep_state;
+       entry_ep_handle = cr_ptr->param.local_ep_handle;
+       ep_ptr->param.ep_state = DAT_EP_STATE_COMPLETION_PENDING;
+       ep_ptr->cm_handle = cr_ptr->ib_cm_handle;
+       ep_ptr->cr_ptr = cr_ptr;
+       ep_ptr->param.remote_ia_address_ptr =
+           cr_ptr->param.remote_ia_address_ptr;
+       cr_ptr->param.local_ep_handle = ep_handle;
+
+       dapl_os_unlock(&ep_ptr->header.lock);
+
+       dat_status = dapls_ib_accept_connection(cr_handle,
+                                               ep_handle,
+                                               private_data_size,
+                                               private_data);
+
+       /*
+        * If the provider failed, unwind the damage so we are back at
+        * the initial state.
+        */
+       if (dat_status != DAT_SUCCESS) {
+               if (DAT_GET_TYPE(dat_status) == DAT_INVALID_ADDRESS) {
+                       /* The remote connection request has disappeared; timeout,
+                        * system error, app termination, perhaps other reasons.
+                        */
+                       dat_status =
+                           dapls_evd_post_connection_event(ep_ptr->param.
+                                                           connect_evd_handle,
+                                                           DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR,
+                                                           (DAT_HANDLE) ep_ptr,
+                                                           0, 0);
+
+                       cr_ptr->header.magic = DAPL_MAGIC_CR_DESTROYED;
+               } else {
+                       ep_ptr->param.ep_state = entry_ep_state;
+                       cr_ptr->param.local_ep_handle = entry_ep_handle;
+                       ep_ptr->cr_ptr = NULL;
+                       ep_ptr->param.remote_ia_address_ptr = NULL;
+               }
+
+               /*
+                * After restoring values above, we now check if we need
+                * to translate the error
+                */
+               if (DAT_GET_TYPE(dat_status) == DAT_LENGTH_ERROR) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+               }
+
+       } else {
+               /* Make this CR invalid. We need to hang on to it until
+                * the connection terminates, but it's destroyed from
+                * the app point of view.
+                */
+               cr_ptr->header.magic = DAPL_MAGIC_CR_DESTROYED;
+       }
 
- bail:
-    return dat_status;
     bail:
+       return dat_status;
 }
 
 /*
index aafdbfb..2340489 100644 (file)
 #include "dapl_ep_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * Prototypes
  */
-DAT_RETURN dapli_connection_request (
-       IN  dp_ib_cm_handle_t   ib_cm_handle,
-       IN  DAPL_SP             *sp_ptr,
-       IN  DAPL_PRIVATE        *prd_ptr,
-       IN  DAPL_EVD            *evd_ptr);
-
-DAPL_EP * dapli_get_sp_ep (
-       IN  dp_ib_cm_handle_t   ib_cm_handle,
-       IN  DAPL_SP             *sp_ptr,
-       IN  DAT_EVENT_NUMBER    dat_event_num);
+DAT_RETURN dapli_connection_request(IN dp_ib_cm_handle_t ib_cm_handle,
+                                   IN DAPL_SP * sp_ptr,
+                                   IN DAPL_PRIVATE * prd_ptr,
+                                   IN DAPL_EVD * evd_ptr);
 
+DAPL_EP *dapli_get_sp_ep(IN dp_ib_cm_handle_t ib_cm_handle,
+                        IN DAPL_SP * sp_ptr,
+                        IN DAT_EVENT_NUMBER dat_event_num);
 
 /*
  * dapls_cr_callback
@@ -78,237 +74,216 @@ DAPL_EP * dapli_get_sp_ep (
  *     None
  *
  */
-void
-dapls_cr_callback (
-    IN    dp_ib_cm_handle_t     ib_cm_handle,
-    IN    const ib_cm_events_t  ib_cm_event,
-    IN   const void            *private_data_ptr,     /* event data */
-    IN    const void           *context)
+void dapls_cr_callback(IN dp_ib_cm_handle_t ib_cm_handle, IN const ib_cm_events_t ib_cm_event, IN const void *private_data_ptr,        /* event data */
+                      IN const void *context)
 {
-    DAPL_EP            *ep_ptr;
-    DAPL_EVD           *evd_ptr;
-    DAPL_SP            *sp_ptr;
-    DAPL_PRIVATE       *prd_ptr;
-    DAT_EVENT_NUMBER   dat_event_num;
-    DAT_RETURN         dat_status;
-
-    dapl_dbg_log (DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
-                 "--> dapl_cr_callback! context: %p event: %x cm_handle %p\n",
-                 context,
-                 ib_cm_event,
-                 (void *) ib_cm_handle);
-
-    /*
-     * Passive side of the connection, context is a SP and
-     * we need to look up the EP.
-     */
-    sp_ptr = (DAPL_SP *) context;
-    /*
-     * The context pointer could have been cleaned up in a racing
-     * CM callback, check to see if we should just exit here
-     */
-    if (sp_ptr->header.magic == DAPL_MAGIC_INVALID)
-    {
-       return;
-    }
-    dapl_os_assert ( sp_ptr->header.magic == DAPL_MAGIC_PSP ||
-                    sp_ptr->header.magic == DAPL_MAGIC_RSP );
-
-    /* Obtain the event number from the provider layer */
-    dat_event_num = dapls_ib_get_dat_event (ib_cm_event, DAT_FALSE);
-
-    /*
-     * CONNECT_REQUEST events create an event on the PSP
-     * EVD, which will trigger connection processing. The
-     * sequence is:
-     *    CONNECT_REQUEST         Event to SP
-     *    CONNECTED              Event to EP
-     *    DISCONNECT             Event to EP
-     *
-     * Obtain the EP if required and set an event up on the correct
-     * EVD.
-     */
-    if (dat_event_num == DAT_CONNECTION_REQUEST_EVENT)
-    {
-       ep_ptr = NULL;
-       evd_ptr = sp_ptr->evd_handle;
-    }
-    else
-    {
-       /* see if there is an EP connected with this CM handle */
-       ep_ptr = dapli_get_sp_ep ( ib_cm_handle,
-                                   sp_ptr,
-                                   dat_event_num );
-
-       /* if we lost a race with the CM just exit. */
-       if (ep_ptr == NULL)
-       {
-           return;
-       }
-
-       evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
-       /* if something has happened to our EVD, bail. */
-       if (evd_ptr == NULL)
-       {
-           return;
-       }
-    }
+       DAPL_EP *ep_ptr;
+       DAPL_EVD *evd_ptr;
+       DAPL_SP *sp_ptr;
+       DAPL_PRIVATE *prd_ptr;
+       DAT_EVENT_NUMBER dat_event_num;
+       DAT_RETURN dat_status;
 
-    prd_ptr = (DAPL_PRIVATE *)private_data_ptr;
-
-    dat_status = DAT_INTERNAL_ERROR;   /* init to ERR */
-
-    switch (dat_event_num)
-    {
-       case DAT_CONNECTION_REQUEST_EVENT:
-       {
-           /*
-            * Requests arriving on a disabled SP are immediatly rejected
-            */
-
-           dapl_os_lock (&sp_ptr->header.lock);
-           if ( sp_ptr->listening == DAT_FALSE )
-           {
-               dapl_os_unlock (&sp_ptr->header.lock);
-               dapl_dbg_log (DAPL_DBG_TYPE_CM,
-                         "---> dapls_cr_callback: conn event on down SP\n");
-               (void)dapls_ib_reject_connection (ib_cm_handle,
-                                                 DAT_CONNECTION_EVENT_UNREACHABLE,
-                                                 0, NULL);
+       dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
+                    "--> dapl_cr_callback! context: %p event: %x cm_handle %p\n",
+                    context, ib_cm_event, (void *)ib_cm_handle);
 
+       /*
+        * Passive side of the connection, context is a SP and
+        * we need to look up the EP.
+        */
+       sp_ptr = (DAPL_SP *) context;
+       /*
+        * The context pointer could have been cleaned up in a racing
+        * CM callback, check to see if we should just exit here
+        */
+       if (sp_ptr->header.magic == DAPL_MAGIC_INVALID) {
                return;
-           }
+       }
+       dapl_os_assert(sp_ptr->header.magic == DAPL_MAGIC_PSP ||
+                      sp_ptr->header.magic == DAPL_MAGIC_RSP);
 
-           if ( sp_ptr->header.handle_type == DAT_HANDLE_TYPE_RSP )
-           {
-               /*
-                * RSP connections only allow a single connection. Close
-                * it down NOW so we reject any further connections.
-                */
-               sp_ptr->listening = DAT_FALSE;
-           }
-           dapl_os_unlock (&sp_ptr->header.lock);
-
-           /*
-            * Only occurs on the passive side of a connection
-            * dapli_connection_request will post the connection
-            * event if appropriate.
-            */
-           dat_status = dapli_connection_request ( ib_cm_handle,
-                                                   sp_ptr,
-                                                   prd_ptr,
-                                                   evd_ptr );
-           /* Set evd_ptr = NULL so we don't generate an event below */
-           evd_ptr = NULL;
-
-           break;
+       /* Obtain the event number from the provider layer */
+       dat_event_num = dapls_ib_get_dat_event(ib_cm_event, DAT_FALSE);
+
+       /*
+        * CONNECT_REQUEST events create an event on the PSP
+        * EVD, which will trigger connection processing. The
+        * sequence is:
+        *    CONNECT_REQUEST         Event to SP
+        *    CONNECTED               Event to EP
+        *    DISCONNECT              Event to EP
+        *
+        * Obtain the EP if required and set an event up on the correct
+        * EVD.
+        */
+       if (dat_event_num == DAT_CONNECTION_REQUEST_EVENT) {
+               ep_ptr = NULL;
+               evd_ptr = sp_ptr->evd_handle;
+       } else {
+               /* see if there is an EP connected with this CM handle */
+               ep_ptr = dapli_get_sp_ep(ib_cm_handle, sp_ptr, dat_event_num);
+
+               /* if we lost a race with the CM just exit. */
+               if (ep_ptr == NULL) {
+                       return;
+               }
+
+               evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
+               /* if something has happened to our EVD, bail. */
+               if (evd_ptr == NULL) {
+                       return;
+               }
        }
-       case DAT_CONNECTION_EVENT_ESTABLISHED:
-       {
-           /* This is just a notification the connection is now
-            * established, there isn't any private data to deal with.
-            *
-            * Update the EP state and cache a copy of the cm handle,
-            * then let the user know we are ready to go.
-            */
-           dapl_os_lock ( &ep_ptr->header.lock );
-           if (ep_ptr->header.magic != DAPL_MAGIC_EP ||
-               ep_ptr->param.ep_state != DAT_EP_STATE_COMPLETION_PENDING)
-           {
-               /* If someone pulled the plug on the EP or connection,
-                * just exit
-                */
-               dapl_os_unlock ( &ep_ptr->header.lock );
-               dat_status = DAT_SUCCESS;
-               /* Set evd_ptr = NULL so we don't generate an event below */
-               evd_ptr = NULL;
 
-               break;
-           }
+       prd_ptr = (DAPL_PRIVATE *) private_data_ptr;
 
-           ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
-           ep_ptr->cm_handle      = ib_cm_handle;
-           dapl_os_unlock ( &ep_ptr->header.lock );
+       dat_status = DAT_INTERNAL_ERROR;        /* init to ERR */
 
-           break;
-       }
+       switch (dat_event_num) {
+       case DAT_CONNECTION_REQUEST_EVENT:
+               {
+                       /*
+                        * Requests arriving on a disabled SP are immediatly rejected
+                        */
+
+                       dapl_os_lock(&sp_ptr->header.lock);
+                       if (sp_ptr->listening == DAT_FALSE) {
+                               dapl_os_unlock(&sp_ptr->header.lock);
+                               dapl_dbg_log(DAPL_DBG_TYPE_CM,
+                                            "---> dapls_cr_callback: conn event on down SP\n");
+                               (void)dapls_ib_reject_connection(ib_cm_handle,
+                                                                DAT_CONNECTION_EVENT_UNREACHABLE,
+                                                                0, NULL);
+
+                               return;
+                       }
+
+                       if (sp_ptr->header.handle_type == DAT_HANDLE_TYPE_RSP) {
+                               /*
+                                * RSP connections only allow a single connection. Close
+                                * it down NOW so we reject any further connections.
+                                */
+                               sp_ptr->listening = DAT_FALSE;
+                       }
+                       dapl_os_unlock(&sp_ptr->header.lock);
+
+                       /*
+                        * Only occurs on the passive side of a connection
+                        * dapli_connection_request will post the connection
+                        * event if appropriate.
+                        */
+                       dat_status = dapli_connection_request(ib_cm_handle,
+                                                             sp_ptr,
+                                                             prd_ptr, evd_ptr);
+                       /* Set evd_ptr = NULL so we don't generate an event below */
+                       evd_ptr = NULL;
+
+                       break;
+               }
+       case DAT_CONNECTION_EVENT_ESTABLISHED:
+               {
+                       /* This is just a notification the connection is now
+                        * established, there isn't any private data to deal with.
+                        *
+                        * Update the EP state and cache a copy of the cm handle,
+                        * then let the user know we are ready to go.
+                        */
+                       dapl_os_lock(&ep_ptr->header.lock);
+                       if (ep_ptr->header.magic != DAPL_MAGIC_EP ||
+                           ep_ptr->param.ep_state !=
+                           DAT_EP_STATE_COMPLETION_PENDING) {
+                               /* If someone pulled the plug on the EP or connection,
+                                * just exit
+                                */
+                               dapl_os_unlock(&ep_ptr->header.lock);
+                               dat_status = DAT_SUCCESS;
+                               /* Set evd_ptr = NULL so we don't generate an event below */
+                               evd_ptr = NULL;
+
+                               break;
+                       }
+
+                       ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
+                       ep_ptr->cm_handle = ib_cm_handle;
+                       dapl_os_unlock(&ep_ptr->header.lock);
+
+                       break;
+               }
        case DAT_CONNECTION_EVENT_DISCONNECTED:
-       {
-           /*
-            * EP is now fully disconnected; initiate any post processing
-            * to reset the underlying QP and get the EP ready for
-            * another connection
-            */
-           dapl_os_lock ( &ep_ptr->header.lock );
-           if (ep_ptr->param.ep_state  == DAT_EP_STATE_DISCONNECTED)
-           {
-               /* The disconnect has already occurred, we are now
-                * cleaned up and ready to exit
-                */
-               dapl_os_unlock ( &ep_ptr->header.lock );
-               return;
-           }
-           ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
-           dapls_ib_disconnect_clean (ep_ptr, DAT_FALSE, ib_cm_event);
-           dapl_os_unlock ( &ep_ptr->header.lock );
-
-           break;
-       }
+               {
+                       /*
+                        * EP is now fully disconnected; initiate any post processing
+                        * to reset the underlying QP and get the EP ready for
+                        * another connection
+                        */
+                       dapl_os_lock(&ep_ptr->header.lock);
+                       if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED) {
+                               /* The disconnect has already occurred, we are now
+                                * cleaned up and ready to exit
+                                */
+                               dapl_os_unlock(&ep_ptr->header.lock);
+                               return;
+                       }
+                       ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+                       dapls_ib_disconnect_clean(ep_ptr, DAT_FALSE,
+                                                 ib_cm_event);
+                       dapl_os_unlock(&ep_ptr->header.lock);
+
+                       break;
+               }
        case DAT_CONNECTION_EVENT_NON_PEER_REJECTED:
        case DAT_CONNECTION_EVENT_PEER_REJECTED:
        case DAT_CONNECTION_EVENT_UNREACHABLE:
-       {
-           /*
-            * After posting an accept the requesting node has
-            * stopped talking.
-            */
-           dapl_os_lock ( &ep_ptr->header.lock );
-           ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
-           ep_ptr->cm_handle       = IB_INVALID_HANDLE;
-           dapls_ib_disconnect_clean (ep_ptr, DAT_FALSE, ib_cm_event);
-           dapl_os_unlock ( &ep_ptr->header.lock );
-
-           break;
-       }
+               {
+                       /*
+                        * After posting an accept the requesting node has
+                        * stopped talking.
+                        */
+                       dapl_os_lock(&ep_ptr->header.lock);
+                       ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+                       ep_ptr->cm_handle = IB_INVALID_HANDLE;
+                       dapls_ib_disconnect_clean(ep_ptr, DAT_FALSE,
+                                                 ib_cm_event);
+                       dapl_os_unlock(&ep_ptr->header.lock);
+
+                       break;
+               }
        case DAT_CONNECTION_EVENT_BROKEN:
-       {
-           dapl_os_lock ( &ep_ptr->header.lock );
-           ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
-           dapls_ib_disconnect_clean (ep_ptr, DAT_FALSE, ib_cm_event);
-           dapl_os_unlock ( &ep_ptr->header.lock );
+               {
+                       dapl_os_lock(&ep_ptr->header.lock);
+                       ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+                       dapls_ib_disconnect_clean(ep_ptr, DAT_FALSE,
+                                                 ib_cm_event);
+                       dapl_os_unlock(&ep_ptr->header.lock);
+
+                       break;
+               }
+       default:
+               {
+                       evd_ptr = NULL;
+                       dapl_os_assert(0);      /* shouldn't happen */
+                       break;
+               }
+       }
 
-           break;
+       if (evd_ptr != NULL) {
+               dat_status = dapls_evd_post_connection_event(evd_ptr,
+                                                            dat_event_num,
+                                                            (DAT_HANDLE)
+                                                            ep_ptr, 0, NULL);
        }
-       default:
-       {
-           evd_ptr = NULL;
-           dapl_os_assert (0);         /* shouldn't happen */
-           break;
+
+       if (dat_status != DAT_SUCCESS) {
+               /* The event post failed; take appropriate action.  */
+               (void)dapls_ib_reject_connection(ib_cm_handle,
+                                                DAT_CONNECTION_EVENT_BROKEN,
+                                                0, NULL);
+
+               return;
        }
-    }
-
-    if (evd_ptr != NULL )
-    {
-       dat_status = dapls_evd_post_connection_event (
-                               evd_ptr,
-                               dat_event_num,
-                               (DAT_HANDLE) ep_ptr,
-                               0,
-                               NULL);
-    }
-
-    if (dat_status != DAT_SUCCESS)
-    {
-       /* The event post failed; take appropriate action.  */
-       (void)dapls_ib_reject_connection ( ib_cm_handle,
-                                          DAT_CONNECTION_EVENT_BROKEN,
-                                          0, NULL);
-
-       return;
-    }
 }
 
-
 /*
  * dapli_connection_request
  *
@@ -331,147 +306,135 @@ dapls_cr_callback (
  *
  */
 DAT_RETURN
-dapli_connection_request (
-       IN  dp_ib_cm_handle_t   ib_cm_handle,
-       IN  DAPL_SP             *sp_ptr,
-       IN  DAPL_PRIVATE        *prd_ptr,
-       IN  DAPL_EVD            *evd_ptr)
+dapli_connection_request(IN dp_ib_cm_handle_t ib_cm_handle,
+                        IN DAPL_SP * sp_ptr,
+                        IN DAPL_PRIVATE * prd_ptr, IN DAPL_EVD * evd_ptr)
 {
-    DAT_RETURN         dat_status;
-
-    DAPL_CR            *cr_ptr;
-    DAPL_EP            *ep_ptr;
-    DAPL_IA            *ia_ptr;
-    DAT_SP_HANDLE      sp_handle;
-
-    cr_ptr = dapls_cr_alloc (sp_ptr->header.owner_ia);
-    if ( cr_ptr == NULL )
-    {
-       /* Invoking function will call dapls_ib_cm_reject() */
-       return DAT_INSUFFICIENT_RESOURCES;
-    }
-
-    /*
-     * Set up the CR
-     */
-    cr_ptr->sp_ptr = sp_ptr;           /* maintain sp_ptr in case of reject */
-    cr_ptr->param.remote_port_qual = 0;
-    cr_ptr->ib_cm_handle = ib_cm_handle;
+       DAT_RETURN dat_status;
+
+       DAPL_CR *cr_ptr;
+       DAPL_EP *ep_ptr;
+       DAPL_IA *ia_ptr;
+       DAT_SP_HANDLE sp_handle;
+
+       cr_ptr = dapls_cr_alloc(sp_ptr->header.owner_ia);
+       if (cr_ptr == NULL) {
+               /* Invoking function will call dapls_ib_cm_reject() */
+               return DAT_INSUFFICIENT_RESOURCES;
+       }
+
+       /*
+        * Set up the CR
+        */
+       cr_ptr->sp_ptr = sp_ptr;        /* maintain sp_ptr in case of reject */
+       cr_ptr->param.remote_port_qual = 0;
+       cr_ptr->ib_cm_handle = ib_cm_handle;
 #ifdef IBHOSTS_NAMING
-    /*
-     * Special case: pull the remote HCA address from the private data
-     * prefix. This is a spec violation as it introduces a protocol, but
-     * some implementations may find it necessary for a time.
-     */
-    cr_ptr->remote_ia_address = prd_ptr->hca_address;
-#endif /* IBHOSTS_NAMING */
-    cr_ptr->param.remote_ia_address_ptr = (DAT_IA_ADDRESS_PTR)&cr_ptr->remote_ia_address;
-    /*
-     * Copy the remote address and private data out of the private_data
-     * payload and put them in a local structure
-     */
-
-    /* Private data size will be determined by the provider layer */
-    cr_ptr->param.private_data      = cr_ptr->private_data;
-    if (prd_ptr == NULL)
-    {
-       cr_ptr->param.private_data_size = 0;
-    }
-    else
-    {
-       cr_ptr->param.private_data_size = 
-               dapls_ib_private_data_size(prd_ptr, DAPL_PDATA_CONN_REQ,
-                                          sp_ptr->header.owner_ia->hca_ptr);
-    }
-    if (cr_ptr->param.private_data_size > 0)
-    {
-       dapl_os_memcpy (cr_ptr->private_data,
-                       prd_ptr->private_data,
-                       DAPL_MIN(cr_ptr->param.private_data_size,
-                                DAPL_MAX_PRIVATE_DATA_SIZE));
-    }
-
-    /* EP will be NULL unless RSP service point */
-    ep_ptr = (DAPL_EP *) sp_ptr->ep_handle;
-
-    if ( sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG )
-    {
        /*
-        * Never true for RSP connections
-        *
-        * Create an EP for the user. If we can't allocate an
-        * EP we are out of resources and need to tell the
-        * requestor that we cant help them.
+        * Special case: pull the remote HCA address from the private data
+        * prefix. This is a spec violation as it introduces a protocol, but
+        * some implementations may find it necessary for a time.
+        */
+       cr_ptr->remote_ia_address = prd_ptr->hca_address;
+#endif                         /* IBHOSTS_NAMING */
+       cr_ptr->param.remote_ia_address_ptr =
+           (DAT_IA_ADDRESS_PTR) & cr_ptr->remote_ia_address;
+       /*
+        * Copy the remote address and private data out of the private_data
+        * payload and put them in a local structure
         */
-       ia_ptr = sp_ptr->header.owner_ia;
-       ep_ptr = dapl_ep_alloc (ia_ptr, NULL);
-       if ( ep_ptr == NULL )
-       {
-           dapls_cr_free (cr_ptr);
-           /* Invoking function will call dapls_ib_cm_reject() */
-           return DAT_INSUFFICIENT_RESOURCES;
+
+       /* Private data size will be determined by the provider layer */
+       cr_ptr->param.private_data = cr_ptr->private_data;
+       if (prd_ptr == NULL) {
+               cr_ptr->param.private_data_size = 0;
+       } else {
+               cr_ptr->param.private_data_size =
+                   dapls_ib_private_data_size(prd_ptr, DAPL_PDATA_CONN_REQ,
+                                              sp_ptr->header.owner_ia->
+                                              hca_ptr);
        }
-       ep_ptr->param.ia_handle           = ia_ptr;
-       ep_ptr->param.local_ia_address_ptr= (DAT_IA_ADDRESS_PTR) &ia_ptr->hca_ptr->hca_address;
-
-       /* Link the EP onto the IA */
-       dapl_ia_link_ep (ia_ptr, ep_ptr);
-    }
-
-    cr_ptr->param.local_ep_handle = ep_ptr;
-
-    if ( ep_ptr != NULL )
-    {
-       /* Assign valid EP fields: RSP and PSP_PROVIDER_FLAG only */
-       if ( sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG )
-       {
-           ep_ptr->param.ep_state =
-               DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING;
+       if (cr_ptr->param.private_data_size > 0) {
+               dapl_os_memcpy(cr_ptr->private_data,
+                              prd_ptr->private_data,
+                              DAPL_MIN(cr_ptr->param.private_data_size,
+                                       DAPL_MAX_PRIVATE_DATA_SIZE));
        }
-       else
-       {
-           /* RSP */
-           dapl_os_assert (sp_ptr->header.handle_type == DAT_HANDLE_TYPE_RSP);
-           ep_ptr->param.ep_state =
-               DAT_EP_STATE_PASSIVE_CONNECTION_PENDING;
+
+       /* EP will be NULL unless RSP service point */
+       ep_ptr = (DAPL_EP *) sp_ptr->ep_handle;
+
+       if (sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG) {
+               /*
+                * Never true for RSP connections
+                *
+                * Create an EP for the user. If we can't allocate an
+                * EP we are out of resources and need to tell the
+                * requestor that we cant help them.
+                */
+               ia_ptr = sp_ptr->header.owner_ia;
+               ep_ptr = dapl_ep_alloc(ia_ptr, NULL);
+               if (ep_ptr == NULL) {
+                       dapls_cr_free(cr_ptr);
+                       /* Invoking function will call dapls_ib_cm_reject() */
+                       return DAT_INSUFFICIENT_RESOURCES;
+               }
+               ep_ptr->param.ia_handle = ia_ptr;
+               ep_ptr->param.local_ia_address_ptr =
+                   (DAT_IA_ADDRESS_PTR) & ia_ptr->hca_ptr->hca_address;
+
+               /* Link the EP onto the IA */
+               dapl_ia_link_ep(ia_ptr, ep_ptr);
+       }
+
+       cr_ptr->param.local_ep_handle = ep_ptr;
+
+       if (ep_ptr != NULL) {
+               /* Assign valid EP fields: RSP and PSP_PROVIDER_FLAG only */
+               if (sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG) {
+                       ep_ptr->param.ep_state =
+                           DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING;
+               } else {
+                       /* RSP */
+                       dapl_os_assert(sp_ptr->header.handle_type ==
+                                      DAT_HANDLE_TYPE_RSP);
+                       ep_ptr->param.ep_state =
+                           DAT_EP_STATE_PASSIVE_CONNECTION_PENDING;
+               }
+               ep_ptr->cm_handle = ib_cm_handle;
+       }
+
+       /* link the CR onto the SP so we can pick it up later */
+       dapl_sp_link_cr(sp_ptr, cr_ptr);
+
+       /* Post the event.  */
+       /* assign sp_ptr to union to avoid typecast errors from some compilers */
+       sp_handle.psp_handle = (DAT_PSP_HANDLE) sp_ptr;
+
+       dat_status = dapls_evd_post_cr_arrival_event(evd_ptr,
+                                                    DAT_CONNECTION_REQUEST_EVENT,
+                                                    sp_handle,
+                                                    (DAT_IA_ADDRESS_PTR)
+                                                    & sp_ptr->header.owner_ia->
+                                                    hca_ptr->hca_address,
+                                                    sp_ptr->conn_qual,
+                                                    (DAT_CR_HANDLE) cr_ptr);
+
+       if (dat_status != DAT_SUCCESS) {
+               dapls_cr_free(cr_ptr);
+               (void)dapls_ib_reject_connection(ib_cm_handle,
+                                                DAT_CONNECTION_EVENT_BROKEN,
+                                                0, NULL);
+
+               /* Take the CR off the list, we can't use it */
+               dapl_os_lock(&sp_ptr->header.lock);
+               dapl_sp_remove_cr(sp_ptr, cr_ptr);
+               dapl_os_unlock(&sp_ptr->header.lock);
+               return DAT_INSUFFICIENT_RESOURCES;
        }
-       ep_ptr->cm_handle       = ib_cm_handle;
-    }
-
-    /* link the CR onto the SP so we can pick it up later */
-    dapl_sp_link_cr (sp_ptr, cr_ptr);
-
-    /* Post the event.  */
-    /* assign sp_ptr to union to avoid typecast errors from some compilers */
-    sp_handle.psp_handle = (DAT_PSP_HANDLE)sp_ptr;
-
-    dat_status = dapls_evd_post_cr_arrival_event (
-                               evd_ptr,
-                               DAT_CONNECTION_REQUEST_EVENT,
-                               sp_handle,
-                               (DAT_IA_ADDRESS_PTR)
-                               &sp_ptr->header.owner_ia->hca_ptr->hca_address,
-                               sp_ptr->conn_qual,
-                               (DAT_CR_HANDLE)cr_ptr);
-
-    if (dat_status != DAT_SUCCESS)
-    {
-       dapls_cr_free (cr_ptr);
-       (void)dapls_ib_reject_connection (ib_cm_handle,
-                                         DAT_CONNECTION_EVENT_BROKEN,
-                                         0, NULL);
-
-       /* Take the CR off the list, we can't use it */
-       dapl_os_lock (&sp_ptr->header.lock);
-       dapl_sp_remove_cr (sp_ptr, cr_ptr);
-       dapl_os_unlock (&sp_ptr->header.lock);
-       return DAT_INSUFFICIENT_RESOURCES;
-    }
-
-
-    return DAT_SUCCESS;
-}
 
+       return DAT_SUCCESS;
+}
 
 /*
  * dapli_get_sp_ep
@@ -492,100 +455,89 @@ dapli_connection_request (
  *     ep_ptr
  *
  */
-DAPL_EP *
-dapli_get_sp_ep (
-       IN  dp_ib_cm_handle_t   ib_cm_handle,
-       IN  DAPL_SP             *sp_ptr,
-       IN  DAT_EVENT_NUMBER    dat_event_num)
+DAPL_EP *dapli_get_sp_ep(IN dp_ib_cm_handle_t ib_cm_handle,
+                        IN DAPL_SP * sp_ptr, IN DAT_EVENT_NUMBER dat_event_num)
 {
-    DAPL_CR            *cr_ptr;
-    DAPL_EP            *ep_ptr;
-
-    /*
-     * acquire the lock, we may be racing with other threads here
-     */
-    dapl_os_lock (&sp_ptr->header.lock);
-
-    /* Verify under lock that the SP is still valid */
-    if (sp_ptr->header.magic == DAPL_MAGIC_INVALID)
-    {
-       dapl_os_unlock (&sp_ptr->header.lock);
-       return NULL;
-    }
-    /*
-     * There are potentially multiple connections in progress. Need to
-     * go through the list and find the one we are interested
-     * in. There is no guarantee of order. dapl_sp_search_cr
-     * leaves the CR on the SP queue.
-     */
-    cr_ptr = dapl_sp_search_cr (sp_ptr, ib_cm_handle);
-    if ( cr_ptr == NULL )
-    {
-       dapl_os_unlock (&sp_ptr->header.lock);
-       return NULL;
-    }
-
-    ep_ptr = (DAPL_EP *)cr_ptr->param.local_ep_handle;
-
-
-    /* Quick check to ensure our EP is still valid */
-    if ( (DAPL_BAD_HANDLE (ep_ptr, DAPL_MAGIC_EP )) )
-    {
-       ep_ptr = NULL;
-    }
-
-    /* The CR record is discarded in all except for the CONNECTED case,
-     * as it will have no further relevance.
-     */
-    if (dat_event_num != DAT_CONNECTION_EVENT_ESTABLISHED)
-    {
-       /* Remove the CR from the queue */
-       dapl_sp_remove_cr (sp_ptr, cr_ptr);
-
-       if (ep_ptr != NULL)
-       {
-           ep_ptr->cr_ptr = NULL;
-       }
+       DAPL_CR *cr_ptr;
+       DAPL_EP *ep_ptr;
 
        /*
-        * If this SP has been removed from service, free it
-        * up after the last CR is removed
+        * acquire the lock, we may be racing with other threads here
         */
-       if ( sp_ptr->listening != DAT_TRUE && sp_ptr->cr_list_count == 0 &&
-            sp_ptr->state != DAPL_SP_STATE_FREE )
-       {
-           dapl_dbg_log (DAPL_DBG_TYPE_CM,
-                 "--> dapli_get_sp_ep! disconnect dump sp: %p \n", sp_ptr);
-           /* Decrement the ref count on the EVD */
-           if (sp_ptr->evd_handle)
-           {
-               dapl_os_atomic_dec (& ((DAPL_EVD *)sp_ptr->evd_handle)->evd_ref_count);
-               sp_ptr->evd_handle = NULL;
-           }
-           sp_ptr->state = DAPL_SP_STATE_FREE;
-           dapl_os_unlock (&sp_ptr->header.lock);
-           (void)dapls_ib_remove_conn_listener ( sp_ptr->header.owner_ia,
-                                                 sp_ptr );
-           dapls_ia_unlink_sp ( (DAPL_IA *)sp_ptr->header.owner_ia,
-                                sp_ptr );
-           dapls_sp_free_sp ( sp_ptr );
-           dapls_cr_free (cr_ptr);
-           goto skip_unlock;
+       dapl_os_lock(&sp_ptr->header.lock);
+
+       /* Verify under lock that the SP is still valid */
+       if (sp_ptr->header.magic == DAPL_MAGIC_INVALID) {
+               dapl_os_unlock(&sp_ptr->header.lock);
+               return NULL;
+       }
+       /*
+        * There are potentially multiple connections in progress. Need to
+        * go through the list and find the one we are interested
+        * in. There is no guarantee of order. dapl_sp_search_cr
+        * leaves the CR on the SP queue.
+        */
+       cr_ptr = dapl_sp_search_cr(sp_ptr, ib_cm_handle);
+       if (cr_ptr == NULL) {
+               dapl_os_unlock(&sp_ptr->header.lock);
+               return NULL;
        }
 
-       dapl_os_unlock (&sp_ptr->header.lock);
-       /* free memory outside of the lock */
-       dapls_cr_free (cr_ptr);
-    }
-    else
-    {
-       dapl_os_unlock (&sp_ptr->header.lock);
-    }
-
-skip_unlock:
-    return ep_ptr;
-}
+       ep_ptr = (DAPL_EP *) cr_ptr->param.local_ep_handle;
+
+       /* Quick check to ensure our EP is still valid */
+       if ((DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP))) {
+               ep_ptr = NULL;
+       }
+
+       /* The CR record is discarded in all except for the CONNECTED case,
+        * as it will have no further relevance.
+        */
+       if (dat_event_num != DAT_CONNECTION_EVENT_ESTABLISHED) {
+               /* Remove the CR from the queue */
+               dapl_sp_remove_cr(sp_ptr, cr_ptr);
 
+               if (ep_ptr != NULL) {
+                       ep_ptr->cr_ptr = NULL;
+               }
+
+               /*
+                * If this SP has been removed from service, free it
+                * up after the last CR is removed
+                */
+               if (sp_ptr->listening != DAT_TRUE && sp_ptr->cr_list_count == 0
+                   && sp_ptr->state != DAPL_SP_STATE_FREE) {
+                       dapl_dbg_log(DAPL_DBG_TYPE_CM,
+                                    "--> dapli_get_sp_ep! disconnect dump sp: %p \n",
+                                    sp_ptr);
+                       /* Decrement the ref count on the EVD */
+                       if (sp_ptr->evd_handle) {
+                               dapl_os_atomic_dec(&
+                                                  ((DAPL_EVD *) sp_ptr->
+                                                   evd_handle)->evd_ref_count);
+                               sp_ptr->evd_handle = NULL;
+                       }
+                       sp_ptr->state = DAPL_SP_STATE_FREE;
+                       dapl_os_unlock(&sp_ptr->header.lock);
+                       (void)dapls_ib_remove_conn_listener(sp_ptr->header.
+                                                           owner_ia, sp_ptr);
+                       dapls_ia_unlink_sp((DAPL_IA *) sp_ptr->header.owner_ia,
+                                          sp_ptr);
+                       dapls_sp_free_sp(sp_ptr);
+                       dapls_cr_free(cr_ptr);
+                       goto skip_unlock;
+               }
+
+               dapl_os_unlock(&sp_ptr->header.lock);
+               /* free memory outside of the lock */
+               dapls_cr_free(cr_ptr);
+       } else {
+               dapl_os_unlock(&sp_ptr->header.lock);
+       }
+
+      skip_unlock:
+       return ep_ptr;
+}
 
 /*
  * Local variables:
index 1899360..fe1b3b5 100644 (file)
@@ -59,9 +59,7 @@
  *     DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_cr_handoff (
-       IN      DAT_CR_HANDLE      cr_handle,
-       IN      DAT_CONN_QUAL      cr_handoff )         /* handoff */
-{
-    return DAT_ERROR (DAT_NOT_IMPLEMENTED,0);
+dapl_cr_handoff(IN DAT_CR_HANDLE cr_handle, IN DAT_CONN_QUAL cr_handoff)
+{                              /* handoff */
+       return DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
 }
index d458782..7332639 100644 (file)
  *     DAT_INVALID_HANDLE
  */
 DAT_RETURN DAT_API
-dapl_cr_query (
-       IN      DAT_CR_HANDLE           cr_handle,
-       IN      DAT_CR_PARAM_MASK       cr_param_mask,
-       OUT     DAT_CR_PARAM            *cr_param)
+dapl_cr_query(IN DAT_CR_HANDLE cr_handle,
+             IN DAT_CR_PARAM_MASK cr_param_mask, OUT DAT_CR_PARAM * cr_param)
 {
-    DAPL_CR    *cr_ptr;
-    DAT_RETURN dat_status;
+       DAPL_CR *cr_ptr;
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_cr_query (%p, %x, %p)\n",
-                 cr_handle, 
-                 cr_param_mask, 
-                 cr_param);
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_cr_query (%p, %x, %p)\n",
+                    cr_handle, cr_param_mask, cr_param);
 
-    dat_status = DAT_SUCCESS;
-    if ( DAPL_BAD_HANDLE (cr_handle, DAPL_MAGIC_CR) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CR);
-       goto bail;
-    }
+       dat_status = DAT_SUCCESS;
+       if (DAPL_BAD_HANDLE(cr_handle, DAPL_MAGIC_CR)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+               goto bail;
+       }
 
-    if (NULL == cr_param)
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-       goto bail;
-    }
+       if (NULL == cr_param) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+               goto bail;
+       }
 
-    cr_ptr = (DAPL_CR *) cr_handle;
+       cr_ptr = (DAPL_CR *) cr_handle;
 
-    /* obtain the remote IP address */
-    if (cr_param_mask & DAT_CR_FIELD_REMOTE_IA_ADDRESS_PTR)
-    {
-       dat_status = dapls_ib_cm_remote_addr ((DAT_HANDLE)cr_handle,
-                                             &cr_ptr->remote_ia_address );
-    }
+       /* obtain the remote IP address */
+       if (cr_param_mask & DAT_CR_FIELD_REMOTE_IA_ADDRESS_PTR) {
+               dat_status = dapls_ib_cm_remote_addr((DAT_HANDLE) cr_handle,
+                                                    &cr_ptr->
+                                                    remote_ia_address);
+       }
 
-    /* since the arguments are easily accessible, ignore the mask */
-    dapl_os_memcpy (cr_param, &cr_ptr->param, sizeof (DAT_CR_PARAM));
+       /* since the arguments are easily accessible, ignore the mask */
+       dapl_os_memcpy(cr_param, &cr_ptr->param, sizeof(DAT_CR_PARAM));
 
- bail:
-    return dat_status;
     bail:
+       return dat_status;
 }
-
index 029cdfa..edac95c 100644 (file)
  *     DAT_SUCCESS
  *     DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API
-dapl_cr_reject (
-       IN      DAT_CR_HANDLE cr_handle,/* cr_handle            */
-       IN      DAT_COUNT pdata_size,   /* private_data_size    */
-       IN      const DAT_PVOID pdata ) /* private_data         */
-{
-    DAPL_CR            *cr_ptr;
-    DAPL_EP            *ep_ptr;
-    DAT_EP_STATE       entry_ep_state;
-    DAT_EP_HANDLE      entry_ep_handle;
-    DAPL_SP            *sp_ptr;
-    DAT_RETURN         dat_status;
+DAT_RETURN DAT_API dapl_cr_reject(IN DAT_CR_HANDLE cr_handle,  /* cr_handle            */
+                                 IN DAT_COUNT pdata_size,      /* private_data_size    */
+                                 IN const DAT_PVOID pdata)
+{                              /* private_data         */
+       DAPL_CR *cr_ptr;
+       DAPL_EP *ep_ptr;
+       DAT_EP_STATE entry_ep_state;
+       DAT_EP_HANDLE entry_ep_handle;
+       DAPL_SP *sp_ptr;
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_cr_reject (%p)\n", cr_handle);
+       dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_cr_reject (%p)\n", cr_handle);
 
-    if ( DAPL_BAD_HANDLE (cr_handle, DAPL_MAGIC_CR) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CR);
-       goto bail;
-    }
-
-    cr_ptr = (DAPL_CR *)cr_handle;
-
-    /*
-     * Clean up provider created EP if there is one: only if
-     * DAT_PSP_PROVIDER_FLAG was set on the PSP
-     */
-    ep_ptr = (DAPL_EP *)cr_ptr->param.local_ep_handle;
-    entry_ep_handle = cr_ptr->param.local_ep_handle;
-    entry_ep_state  = 0;
-    if ( ep_ptr != NULL )
-    {
-       entry_ep_state                = ep_ptr->param.ep_state;
-       ep_ptr->param.ep_state        = DAT_EP_STATE_UNCONNECTED;
-       cr_ptr->param.local_ep_handle = NULL;
-    }
+       if (DAPL_BAD_HANDLE(cr_handle, DAPL_MAGIC_CR)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+               goto bail;
+       }
 
-    dat_status =  dapls_ib_reject_connection ( cr_ptr->ib_cm_handle,
-                                              IB_CM_REJ_REASON_CONSUMER_REJ,
-                                              pdata_size, pdata );
+       cr_ptr = (DAPL_CR *) cr_handle;
 
-    if ( dat_status != DAT_SUCCESS)
-    {
-       if ( ep_ptr != NULL )
-       {
-           /* Revert our state to the beginning */
-           ep_ptr->param.ep_state        = entry_ep_state;
-           cr_ptr->param.local_ep_handle = entry_ep_handle;
-           cr_ptr->param.local_ep_handle = (DAT_EP_HANDLE)ep_ptr;
-       }
-    }
-    else
-    {
-       /* 
-        * If this EP has been allocated by the provider, clean it up;
-        * see DAT 1.1 spec, page 100, lines 3-4 (section 6.4.3.1.1.1).
-        * RSP and user-provided EPs are in the control of the user.
+       /*
+        * Clean up provider created EP if there is one: only if
+        * DAT_PSP_PROVIDER_FLAG was set on the PSP
         */
-       sp_ptr = cr_ptr->sp_ptr;
-       if ( ep_ptr != NULL &&
-            sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG )
-       {
-           (void)dapl_ep_free (ep_ptr);
+       ep_ptr = (DAPL_EP *) cr_ptr->param.local_ep_handle;
+       entry_ep_handle = cr_ptr->param.local_ep_handle;
+       entry_ep_state = 0;
+       if (ep_ptr != NULL) {
+               entry_ep_state = ep_ptr->param.ep_state;
+               ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+               cr_ptr->param.local_ep_handle = NULL;
        }
 
-       /* Remove the CR from the queue, then free it */
-       dapl_os_lock (&sp_ptr->header.lock);
-       dapl_sp_remove_cr ( sp_ptr, cr_ptr );
-       dapl_os_unlock (&sp_ptr->header.lock);
+       dat_status = dapls_ib_reject_connection(cr_ptr->ib_cm_handle,
+                                               IB_CM_REJ_REASON_CONSUMER_REJ,
+                                               pdata_size, pdata);
 
-       dapls_cr_free ( cr_ptr );
-    }
+       if (dat_status != DAT_SUCCESS) {
+               if (ep_ptr != NULL) {
+                       /* Revert our state to the beginning */
+                       ep_ptr->param.ep_state = entry_ep_state;
+                       cr_ptr->param.local_ep_handle = entry_ep_handle;
+                       cr_ptr->param.local_ep_handle = (DAT_EP_HANDLE) ep_ptr;
+               }
+       } else {
+               /* 
+                * If this EP has been allocated by the provider, clean it up;
+                * see DAT 1.1 spec, page 100, lines 3-4 (section 6.4.3.1.1.1).
+                * RSP and user-provided EPs are in the control of the user.
+                */
+               sp_ptr = cr_ptr->sp_ptr;
+               if (ep_ptr != NULL &&
+                   sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG) {
+                       (void)dapl_ep_free(ep_ptr);
+               }
+
+               /* Remove the CR from the queue, then free it */
+               dapl_os_lock(&sp_ptr->header.lock);
+               dapl_sp_remove_cr(sp_ptr, cr_ptr);
+               dapl_os_unlock(&sp_ptr->header.lock);
+
+               dapls_cr_free(cr_ptr);
+       }
 
- bail:
-    return dat_status;
     bail:
+       return dat_status;
 }
 
 /*
index 1d29d7a..39b61ad 100644 (file)
  *
  */
 
-DAPL_CR        *
-dapls_cr_alloc (
-       DAPL_IA         *ia_ptr )
+DAPL_CR *dapls_cr_alloc(DAPL_IA * ia_ptr)
 {
-    DAPL_CR    *cr_ptr;
+       DAPL_CR *cr_ptr;
 
-    /* Allocate EP */
-    cr_ptr = (DAPL_CR *)dapl_os_alloc (sizeof (DAPL_CR));
-    if ( cr_ptr == NULL )
-    {
-       return (NULL);
-    }
+       /* Allocate EP */
+       cr_ptr = (DAPL_CR *) dapl_os_alloc(sizeof(DAPL_CR));
+       if (cr_ptr == NULL) {
+               return (NULL);
+       }
 
-    /* zero the structure */
-    dapl_os_memzero (cr_ptr, sizeof (DAPL_CR));
+       /* zero the structure */
+       dapl_os_memzero(cr_ptr, sizeof(DAPL_CR));
 
-    /*
-     * initialize the header
-     */
-    cr_ptr->header.provider            = ia_ptr->header.provider;
-    cr_ptr->header.magic               = DAPL_MAGIC_CR;
-    cr_ptr->header.handle_type         = DAT_HANDLE_TYPE_CR;
-    cr_ptr->header.owner_ia            = ia_ptr;
-    cr_ptr->header.user_context.as_64  = 0;
-    cr_ptr->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&cr_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&cr_ptr->header.lock);
+       /*
+        * initialize the header
+        */
+       cr_ptr->header.provider = ia_ptr->header.provider;
+       cr_ptr->header.magic = DAPL_MAGIC_CR;
+       cr_ptr->header.handle_type = DAT_HANDLE_TYPE_CR;
+       cr_ptr->header.owner_ia = ia_ptr;
+       cr_ptr->header.user_context.as_64 = 0;
+       cr_ptr->header.user_context.as_ptr = NULL;
+       dapl_llist_init_entry(&cr_ptr->header.ia_list_entry);
+       dapl_os_lock_init(&cr_ptr->header.lock);
 
-    return (cr_ptr);
+       return (cr_ptr);
 }
 
-
 /*
  * dapls_cr_free
  *
@@ -97,14 +93,11 @@ dapls_cr_alloc (
  *     none
  *
  */
-void
-dapls_cr_free (
-       IN DAPL_CR              *cr_ptr )
+void dapls_cr_free(IN DAPL_CR * cr_ptr)
 {
-    dapl_os_assert (cr_ptr->header.magic == DAPL_MAGIC_CR ||
-                   cr_ptr->header.magic == DAPL_MAGIC_CR_DESTROYED );
+       dapl_os_assert(cr_ptr->header.magic == DAPL_MAGIC_CR ||
+                      cr_ptr->header.magic == DAPL_MAGIC_CR_DESTROYED);
 
-    cr_ptr->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */
-    dapl_os_free (cr_ptr, sizeof (DAPL_CR));
+       cr_ptr->header.magic = DAPL_MAGIC_INVALID;      /* reset magic to prevent reuse */
+       dapl_os_free(cr_ptr, sizeof(DAPL_CR));
 }
-
index 678ca79..ce7c015 100644 (file)
  *     DAT_CONN_QUAL_IN_USE
  *     DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN DAT_API
-dapl_csp_create (
-       IN      DAT_IA_HANDLE ia_handle,          /* ia_handle      */
-       IN      DAT_COMM *comm,                   /* communicator   */
-       IN      DAT_IA_ADDRESS_PTR addr,          /* address        */
-       IN      DAT_EVD_HANDLE evd_handle,        /* evd_handle     */
-       OUT     DAT_CSP_HANDLE *csp_handle )      /* csp_handle     */
-{
+DAT_RETURN DAT_API dapl_csp_create(IN DAT_IA_HANDLE ia_handle, /* ia_handle      */
+                                  IN DAT_COMM * comm,  /* communicator   */
+                                  IN DAT_IA_ADDRESS_PTR addr,  /* address        */
+                                  IN DAT_EVD_HANDLE evd_handle,        /* evd_handle     */
+                                  OUT DAT_CSP_HANDLE * csp_handle)
+{                              /* csp_handle     */
        return DAT_MODEL_NOT_SUPPORTED;
 }
 
-DAT_RETURN DAT_API
-dapl_csp_query (
-       IN      DAT_CSP_HANDLE csp_handle,         /* csp_handle     */
-       IN      DAT_CSP_PARAM_MASK param_mask,     /* csp_param_mask */
-       OUT     DAT_CSP_PARAM *param )             /* csp_param      */
-{
+DAT_RETURN DAT_API dapl_csp_query(IN DAT_CSP_HANDLE csp_handle,        /* csp_handle     */
+                                 IN DAT_CSP_PARAM_MASK param_mask,     /* csp_param_mask */
+                                 OUT DAT_CSP_PARAM * param)
+{                              /* csp_param      */
        return DAT_MODEL_NOT_SUPPORTED;
 }
 
-DAT_RETURN DAT_API
-dapl_csp_free (
-       IN      DAT_CSP_HANDLE csp_handle )        /* csp_handle     */
-{
+DAT_RETURN DAT_API dapl_csp_free(IN DAT_CSP_HANDLE csp_handle)
+{                              /* csp_handle     */
        return DAT_MODEL_NOT_SUPPORTED;
 }
 
index 7601fc8..6723217 100644 (file)
 #if !defined(__KDAPL__)
 #include <stdarg.h>
 #include <stdlib.h>
-#endif /* __KDAPL__ */
+#endif                         /* __KDAPL__ */
 
-DAPL_DBG_TYPE g_dapl_dbg_type;         /* initialized in dapl_init.c */
-DAPL_DBG_DEST g_dapl_dbg_dest;         /* initialized in dapl_init.c */
+DAPL_DBG_TYPE g_dapl_dbg_type; /* initialized in dapl_init.c */
+DAPL_DBG_DEST g_dapl_dbg_dest; /* initialized in dapl_init.c */
 
 static char *_ptr_host_ = NULL;
 static char _hostname_[128];
 
-void dapl_internal_dbg_log ( DAPL_DBG_TYPE type, const char *fmt, ...)
+void dapl_internal_dbg_log(DAPL_DBG_TYPE type, const char *fmt, ...)
 {
-    va_list args;
-
-    if ( _ptr_host_ == NULL )
-    {
-       gethostname(_hostname_, sizeof(_hostname_));
-       _ptr_host_ = _hostname_;
-    }
-
-    if ( type & g_dapl_dbg_type )
-    {
-       if ( DAPL_DBG_DEST_STDOUT & g_dapl_dbg_dest )
-       {
-           va_start (args, fmt);
-            fprintf(stdout, "%s:%d: ", _ptr_host_, dapl_os_getpid());
-           dapl_os_vprintf (fmt, args);
-           va_end (args);
+       va_list args;
+
+       if (_ptr_host_ == NULL) {
+               gethostname(_hostname_, sizeof(_hostname_));
+               _ptr_host_ = _hostname_;
        }
 
-       if ( DAPL_DBG_DEST_SYSLOG & g_dapl_dbg_dest )
-       {
-           va_start (args, fmt);
-           dapl_os_syslog(fmt, args);
-           va_end (args);
+       if (type & g_dapl_dbg_type) {
+               if (DAPL_DBG_DEST_STDOUT & g_dapl_dbg_dest) {
+                       va_start(args, fmt);
+                       fprintf(stdout, "%s:%x: ", _ptr_host_,
+                               dapl_os_gettid());
+                       dapl_os_vprintf(fmt, args);
+                       va_end(args);
+               }
+
+               if (DAPL_DBG_DEST_SYSLOG & g_dapl_dbg_dest) {
+                       va_start(args, fmt);
+                       dapl_os_syslog(fmt, args);
+                       va_end(args);
+               }
        }
-    }
 }
 
 #ifdef DAPL_COUNTERS
@@ -140,64 +137,63 @@ static char *evd_cntr_names[] = {
        "DCNT_EVD_DTO_CALLBACK",
 };
 
-DAT_RETURN dapl_query_counter(DAT_HANDLE dh, 
-                             int counter, 
-                             void *p_cntrs_out,
-                             int reset) 
+DAT_RETURN dapl_query_counter(DAT_HANDLE dh,
+                             int counter, void *p_cntrs_out, int reset)
 {
        int i, max;
        DAT_UINT64 *p_cntrs;
        DAT_HANDLE_TYPE type = 0;
-               
+
        dat_get_handle_type(dh, &type);
 
-       switch(type) {
-               case DAT_HANDLE_TYPE_IA:
-                       max = DCNT_IA_ALL_COUNTERS;
-                       p_cntrs = ((DAPL_IA*)dh)->cntrs;
-                       break;
-               case DAT_HANDLE_TYPE_EP:
-                       max = DCNT_EP_ALL_COUNTERS;
-                       p_cntrs = ((DAPL_EP*)dh)->cntrs;
-                       break;
-               case DAT_HANDLE_TYPE_EVD:
-                       max = DCNT_EVD_ALL_COUNTERS;
-                       p_cntrs = ((DAPL_EVD*)dh)->cntrs;
-                       break;
-               default:
-                       return DAT_INVALID_HANDLE;
+       switch (type) {
+       case DAT_HANDLE_TYPE_IA:
+               max = DCNT_IA_ALL_COUNTERS;
+               p_cntrs = ((DAPL_IA *) dh)->cntrs;
+               break;
+       case DAT_HANDLE_TYPE_EP:
+               max = DCNT_EP_ALL_COUNTERS;
+               p_cntrs = ((DAPL_EP *) dh)->cntrs;
+               break;
+       case DAT_HANDLE_TYPE_EVD:
+               max = DCNT_EVD_ALL_COUNTERS;
+               p_cntrs = ((DAPL_EVD *) dh)->cntrs;
+               break;
+       default:
+               return DAT_INVALID_HANDLE;
        }
-                              
-       for (i=0; i < max; i++) {
+
+       for (i = 0; i < max; i++) {
                if ((counter == i) || (counter == max)) {
-                       ((DAT_UINT64*)p_cntrs_out)[i] = p_cntrs[i];
-                       if (reset) p_cntrs[i]=0;
+                       ((DAT_UINT64 *) p_cntrs_out)[i] = p_cntrs[i];
+                       if (reset)
+                               p_cntrs[i] = 0;
                }
        }
        return DAT_SUCCESS;
 }
 
-char *dapl_query_counter_name(DAT_HANDLE dh, int counter) 
+char *dapl_query_counter_name(DAT_HANDLE dh, int counter)
 {
        DAT_HANDLE_TYPE type = 0;
-               
+
        dat_get_handle_type(dh, &type);
 
-       switch(type) {
-               case DAT_HANDLE_TYPE_IA:
-                       if (counter < DCNT_IA_ALL_COUNTERS)
-                               return ia_cntr_names[counter];
-                       break;
-               case DAT_HANDLE_TYPE_EP:
-                       if (counter < DCNT_EP_ALL_COUNTERS)
-                               return ep_cntr_names[counter];
-                       break;
-               case DAT_HANDLE_TYPE_EVD:
-                       if (counter < DCNT_EVD_ALL_COUNTERS)
-                               return evd_cntr_names[counter];
-                       break;
-               default:
-                       return NULL;
+       switch (type) {
+       case DAT_HANDLE_TYPE_IA:
+               if (counter < DCNT_IA_ALL_COUNTERS)
+                       return ia_cntr_names[counter];
+               break;
+       case DAT_HANDLE_TYPE_EP:
+               if (counter < DCNT_EP_ALL_COUNTERS)
+                       return ep_cntr_names[counter];
+               break;
+       case DAT_HANDLE_TYPE_EVD:
+               if (counter < DCNT_EVD_ALL_COUNTERS)
+                       return evd_cntr_names[counter];
+               break;
+       default:
+               return NULL;
        }
        return NULL;
 }
@@ -208,36 +204,35 @@ void dapl_print_counter(DAT_HANDLE dh, int counter, int reset)
        int i, max;
        DAT_UINT64 *p_cntrs;
        DAT_HANDLE_TYPE type = 0;
-               
+
        dat_get_handle_type(dh, &type);
 
-       switch(type) {
-               case DAT_HANDLE_TYPE_IA:
-                       max = DCNT_IA_ALL_COUNTERS;
-                       p_cntrs = ((DAPL_IA*)dh)->cntrs;
-                       break;
-               case DAT_HANDLE_TYPE_EP:
-                       max = DCNT_EP_ALL_COUNTERS;
-                       p_cntrs = ((DAPL_EP*)dh)->cntrs;
-                       break;
-               case DAT_HANDLE_TYPE_EVD:
-                       max = DCNT_EVD_ALL_COUNTERS;
-                       p_cntrs = ((DAPL_EVD*)dh)->cntrs;
-                       break;
-               default:
-                       return;
+       switch (type) {
+       case DAT_HANDLE_TYPE_IA:
+               max = DCNT_IA_ALL_COUNTERS;
+               p_cntrs = ((DAPL_IA *) dh)->cntrs;
+               break;
+       case DAT_HANDLE_TYPE_EP:
+               max = DCNT_EP_ALL_COUNTERS;
+               p_cntrs = ((DAPL_EP *) dh)->cntrs;
+               break;
+       case DAT_HANDLE_TYPE_EVD:
+               max = DCNT_EVD_ALL_COUNTERS;
+               p_cntrs = ((DAPL_EVD *) dh)->cntrs;
+               break;
+       default:
+               return;
        }
-                              
-       for (i=0; i < max; i++) {
+
+       for (i = 0; i < max; i++) {
                if ((counter == i) || (counter == max)) {
-                       printf( " %s = " F64u " \n",
-                               dapl_query_counter_name(dh, i),
-                               p_cntrs[i] );
-                       if (reset) p_cntrs[i]=0;
+                       printf(" %s = " F64u " \n",
+                              dapl_query_counter_name(dh, i), p_cntrs[i]);
+                       if (reset)
+                               p_cntrs[i] = 0;
                }
-        }
+       }
        return;
 }
 
-#endif /* DAPL_COUNTERS */
-
+#endif                         /* DAPL_COUNTERS */
index 9a72531..5e4dc41 100644 (file)
  *     DAT_MODLE_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_ep_connect (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_IA_ADDRESS_PTR      remote_ia_address,
-       IN      DAT_CONN_QUAL           remote_conn_qual,
-       IN      DAT_TIMEOUT             timeout,
-       IN      DAT_COUNT               private_data_size,
-       IN      const DAT_PVOID         private_data,
-       IN      DAT_QOS                 qos,
-       IN      DAT_CONNECT_FLAGS       connect_flags )
+dapl_ep_connect(IN DAT_EP_HANDLE ep_handle,
+               IN DAT_IA_ADDRESS_PTR remote_ia_address,
+               IN DAT_CONN_QUAL remote_conn_qual,
+               IN DAT_TIMEOUT timeout,
+               IN DAT_COUNT private_data_size,
+               IN const DAT_PVOID private_data,
+               IN DAT_QOS qos, IN DAT_CONNECT_FLAGS connect_flags)
 {
-    DAPL_EP            *ep_ptr;
-    DAPL_EP            alloc_ep;
-    DAT_RETURN         dat_status;
-    DAT_COUNT          req_hdr_size;
-    DAT_UINT32         max_req_pdata_size;
-    void               *private_data_ptr;
-
-    dapl_dbg_log (DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
-               "dapl_ep_connect (%p, {%u.%u.%u.%u}, %X, %d, %d, %p, %x, %x)\n",
-               ep_handle,
-               remote_ia_address->sa_data[2],
-               remote_ia_address->sa_data[3],
-               remote_ia_address->sa_data[4],
-               remote_ia_address->sa_data[5],
-               remote_conn_qual,
-               timeout,
-               private_data_size,
-               private_data,
-               qos,
-               connect_flags);
-
-    dat_status = DAT_SUCCESS;
-    ep_ptr = (DAPL_EP *) ep_handle;
-
-    /*
-     * Verify parameter & state. The connection handle must be good
-     * at this point.
-     */
-    if ( DAPL_BAD_HANDLE (ep_ptr, DAPL_MAGIC_EP ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-
-    if ( DAPL_BAD_HANDLE (ep_ptr->param.connect_evd_handle, DAPL_MAGIC_EVD) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CONN);
-       goto bail;
-    }
-
-    /* Can't do a connection in 0 time, reject outright */
-    if ( timeout == 0 )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-       goto bail;
-    }
-    DAPL_CNTR (ep_ptr, DCNT_EP_CONNECT);
-
-    /*
-     * If the endpoint needs a QP, associated the QP with it.
-     * This needs to be done carefully, in order to:
-     * * Avoid allocating under a lock.
-     *  * Not step on data structures being altered by
-     *    routines with which we are racing.
-     * So we:
-     *  * Confirm that a new QP is needed and is not forbidden by the
-     *    current state.
-     *  * Allocate it into a separate EP.
-     *  * Take the EP lock.
-     *  * Reconfirm that the EP is in a state where it needs a QP.
-     *  * Assign the QP and release the lock.
-     */
-    if ( ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED )
-    {
-       if ( ep_ptr->param.pz_handle == NULL
-            ||  DAPL_BAD_HANDLE (ep_ptr->param.pz_handle, DAPL_MAGIC_PZ) )
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_EP_NOTREADY);
-           goto bail;
+       DAPL_EP *ep_ptr;
+       DAPL_EP alloc_ep;
+       DAT_RETURN dat_status;
+       DAT_COUNT req_hdr_size;
+       DAT_UINT32 max_req_pdata_size;
+       void *private_data_ptr;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
+                    "dapl_ep_connect (%p, {%u.%u.%u.%u}, %X, %d, %d, %p, %x, %x)\n",
+                    ep_handle,
+                    remote_ia_address->sa_data[2],
+                    remote_ia_address->sa_data[3],
+                    remote_ia_address->sa_data[4],
+                    remote_ia_address->sa_data[5],
+                    remote_conn_qual,
+                    timeout,
+                    private_data_size, private_data, qos, connect_flags);
+
+       dat_status = DAT_SUCCESS;
+       ep_ptr = (DAPL_EP *) ep_handle;
+
+       /*
+        * Verify parameter & state. The connection handle must be good
+        * at this point.
+        */
+       if (DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
        }
-       alloc_ep = *ep_ptr;
-
-       dat_status = dapls_ib_qp_alloc ( ep_ptr->header.owner_ia,
-                                        &alloc_ep,
-                                        ep_ptr );
-       if ( dat_status != DAT_SUCCESS )
-       {
-           dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-           goto bail;
+
+       if (DAPL_BAD_HANDLE(ep_ptr->param.connect_evd_handle, DAPL_MAGIC_EVD)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CONN);
+               goto bail;
        }
 
-       dapl_os_lock ( &ep_ptr->header.lock );
+       /* Can't do a connection in 0 time, reject outright */
+       if (timeout == 0) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+               goto bail;
+       }
+       DAPL_CNTR(ep_ptr, DCNT_EP_CONNECT);
+
        /*
-        * PZ shouldn't have changed since we're only racing with
-        * dapl_cr_accept()
+        * If the endpoint needs a QP, associated the QP with it.
+        * This needs to be done carefully, in order to:
+        *  * Avoid allocating under a lock.
+        *  * Not step on data structures being altered by
+        *    routines with which we are racing.
+        * So we:
+        *  * Confirm that a new QP is needed and is not forbidden by the
+        *    current state.
+        *  * Allocate it into a separate EP.
+        *  * Take the EP lock.
+        *  * Reconfirm that the EP is in a state where it needs a QP.
+        *  * Assign the QP and release the lock.
         */
-       if ( ep_ptr->qp_state != DAPL_QP_STATE_UNATTACHED )
-       {
-           /* Bail, cleaning up.  */
-           dapl_os_unlock ( &ep_ptr->header.lock );
-           dat_status = dapls_ib_qp_free ( ep_ptr->header.owner_ia,
-                                           &alloc_ep );
-           if (dat_status != DAT_SUCCESS)
-           {
-               dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-                             "ep_connect: ib_qp_free failed with %x\n",
-                             dat_status);
-           }
-           dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep_ptr));
-           goto bail;
+       if (ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED) {
+               if (ep_ptr->param.pz_handle == NULL
+                   || DAPL_BAD_HANDLE(ep_ptr->param.pz_handle, DAPL_MAGIC_PZ))
+               {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_STATE,
+                                     DAT_INVALID_STATE_EP_NOTREADY);
+                       goto bail;
+               }
+               alloc_ep = *ep_ptr;
+
+               dat_status = dapls_ib_qp_alloc(ep_ptr->header.owner_ia,
+                                              &alloc_ep, ep_ptr);
+               if (dat_status != DAT_SUCCESS) {
+                       dat_status =
+                           DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+                                     DAT_RESOURCE_MEMORY);
+                       goto bail;
+               }
+
+               dapl_os_lock(&ep_ptr->header.lock);
+               /*
+                * PZ shouldn't have changed since we're only racing with
+                * dapl_cr_accept()
+                */
+               if (ep_ptr->qp_state != DAPL_QP_STATE_UNATTACHED) {
+                       /* Bail, cleaning up.  */
+                       dapl_os_unlock(&ep_ptr->header.lock);
+                       dat_status = dapls_ib_qp_free(ep_ptr->header.owner_ia,
+                                                     &alloc_ep);
+                       if (dat_status != DAT_SUCCESS) {
+                               dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+                                            "ep_connect: ib_qp_free failed with %x\n",
+                                            dat_status);
+                       }
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_STATE,
+                                     dapls_ep_state_subtype(ep_ptr));
+                       goto bail;
+               }
+
+               ep_ptr->qp_handle = alloc_ep.qp_handle;
+               ep_ptr->qpn = alloc_ep.qpn;
+               ep_ptr->qp_state = alloc_ep.qp_state;
+
+               dapl_os_unlock(&ep_ptr->header.lock);
        }
 
-       ep_ptr->qp_handle = alloc_ep.qp_handle;
-       ep_ptr->qpn = alloc_ep.qpn;
-       ep_ptr->qp_state = alloc_ep.qp_state;
-
-       dapl_os_unlock ( &ep_ptr->header.lock );
-    }
-
-    /*
-     * We do state checks and transitions under lock.
-     * The only code we're racing against is dapl_cr_accept.
-     */
-    dapl_os_lock ( &ep_ptr->header.lock );
-
-    /*
-     * Verify the attributes of the EP handle before we connect it. Test
-     * all of the handles to make sure they are currently valid.
-     * Specifically:
-     *   pz_handle             required
-     *   recv_evd_handle       optional, but must be valid
-     *   request_evd_handle    optional, but must be valid
-     *   connect_evd_handle    required
-     */
-    if ( ep_ptr->param.pz_handle == NULL
-        ||  DAPL_BAD_HANDLE (ep_ptr->param.pz_handle, DAPL_MAGIC_PZ)
-        /* test connect handle */
-        || ep_ptr->param.connect_evd_handle == NULL
-        || DAPL_BAD_HANDLE (ep_ptr->param.connect_evd_handle, DAPL_MAGIC_EVD)
-        || ! (((DAPL_EVD *)ep_ptr->param.connect_evd_handle)->evd_flags & DAT_EVD_CONNECTION_FLAG)
-        /* test optional completion handles */
-        || (ep_ptr->param.recv_evd_handle != DAT_HANDLE_NULL &&
-            (DAPL_BAD_HANDLE (ep_ptr->param.recv_evd_handle, DAPL_MAGIC_EVD)))
-        || (ep_ptr->param.request_evd_handle != DAT_HANDLE_NULL &&
-            (DAPL_BAD_HANDLE (ep_ptr->param.request_evd_handle, DAPL_MAGIC_EVD))))
-    {
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_EP_NOTREADY);
-       goto bail;
-    }
-
-    /* Check both the EP state and the QP state: if we don't have a QP
-     *  we need to attach one now.
-     */
-    if ( ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED )
-    {
-       dat_status = dapls_ib_qp_alloc ( ep_ptr->header.owner_ia,
-                                        ep_ptr, ep_ptr );
-
-       if ( dat_status != DAT_SUCCESS)
-       {
-           dapl_os_unlock ( &ep_ptr->header.lock );
-           dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_TEP);
-           goto bail;
-       }
-    }
-
-    if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
-       ep_ptr->param.ep_attr.service_type == DAT_SERVICE_TYPE_RC)
-    {
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep_ptr));
-       goto bail;
-    }
-
-    if ( qos != DAT_QOS_BEST_EFFORT ||
-        connect_flags != DAT_CONNECT_DEFAULT_FLAG )
-    {
        /*
-        * At this point we only support one QOS level
+        * We do state checks and transitions under lock.
+        * The only code we're racing against is dapl_cr_accept.
         */
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_MODEL_NOT_SUPPORTED, 0);
-       goto bail;
-    }
-
-    /*
-     * Verify the private data size doesn't exceed the max
-     * req_hdr_size will evaluate to 0 unless IBHOSTS_NAMING is enabled.
-     */
-    req_hdr_size = (sizeof (DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);
-
-    max_req_pdata_size = dapls_ib_private_data_size(
-                               NULL, DAPL_PDATA_CONN_REQ,
-                               ep_ptr->header.owner_ia->hca_ptr);
-
-    if (private_data_size + req_hdr_size > (DAT_COUNT)max_req_pdata_size) 
-    {
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
-       goto bail;
-    }
-
-    /* transition the state before requesting a connection to avoid
-     * race conditions
-     */
-    ep_ptr->param.ep_state = DAT_EP_STATE_ACTIVE_CONNECTION_PENDING;
-
-    /*
-     * At this point we're committed, and done with the endpoint
-     * except for the connect, so we can drop the lock.
-     */
-    dapl_os_unlock ( &ep_ptr->header.lock );
+       dapl_os_lock(&ep_ptr->header.lock);
 
-#ifdef IBHOSTS_NAMING
-    /*
-     * Special case: put the remote HCA address into the private data
-     * prefix. This is a spec violation as it introduces a protocol, but
-     * some implementations may find it necessary for a time.
-     * Copy the private data into the EP area so the data is contiguous.
-     * If the provider needs to pad the buffer with NULLs, it happens at
-     * the provider layer.
-     */
-    dapl_os_memcpy (&ep_ptr->hca_address,
-                   &ep_ptr->header.owner_ia->hca_ptr->hca_address,
-                   sizeof (DAT_SOCK_ADDR));
-    dapl_os_memcpy (ep_ptr->private.private_data, private_data, private_data_size);
-    private_data_ptr = (void *)&ep_ptr->private.private_data;
-#else
-    private_data_ptr = private_data;
-#endif /* IBHOSTS_NAMING */
+       /*
+        * Verify the attributes of the EP handle before we connect it. Test
+        * all of the handles to make sure they are currently valid.
+        * Specifically:
+        *   pz_handle              required
+        *   recv_evd_handle        optional, but must be valid
+        *   request_evd_handle     optional, but must be valid
+        *   connect_evd_handle     required
+        */
+       if (ep_ptr->param.pz_handle == NULL
+           || DAPL_BAD_HANDLE(ep_ptr->param.pz_handle, DAPL_MAGIC_PZ)
+           /* test connect handle */
+           || ep_ptr->param.connect_evd_handle == NULL
+           || DAPL_BAD_HANDLE(ep_ptr->param.connect_evd_handle, DAPL_MAGIC_EVD)
+           || !(((DAPL_EVD *) ep_ptr->param.connect_evd_handle)->
+                evd_flags & DAT_EVD_CONNECTION_FLAG)
+           /* test optional completion handles */
+           || (ep_ptr->param.recv_evd_handle != DAT_HANDLE_NULL &&
+               (DAPL_BAD_HANDLE
+                (ep_ptr->param.recv_evd_handle, DAPL_MAGIC_EVD)))
+           || (ep_ptr->param.request_evd_handle != DAT_HANDLE_NULL
+               &&
+               (DAPL_BAD_HANDLE
+                (ep_ptr->param.request_evd_handle, DAPL_MAGIC_EVD)))) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_EP_NOTREADY);
+               goto bail;
+       }
 
-    /* Copy the connection qualifiers */
-    dapl_os_memcpy ( ep_ptr->param.remote_ia_address_ptr,
-                    remote_ia_address,
-                    sizeof ( DAT_SOCK_ADDR) );
-    ep_ptr->param.remote_port_qual = remote_conn_qual;
+       /* Check both the EP state and the QP state: if we don't have a QP
+        *  we need to attach one now.
+        */
+       if (ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED) {
+               dat_status = dapls_ib_qp_alloc(ep_ptr->header.owner_ia,
+                                              ep_ptr, ep_ptr);
+
+               if (dat_status != DAT_SUCCESS) {
+                       dapl_os_unlock(&ep_ptr->header.lock);
+                       dat_status =
+                           DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+                                     DAT_RESOURCE_TEP);
+                       goto bail;
+               }
+       }
 
-    dat_status =  dapls_ib_connect ( ep_handle,
-                                    remote_ia_address,
-                                    remote_conn_qual,
-                                    private_data_size + req_hdr_size,
-                                    private_data_ptr );
+       if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
+           ep_ptr->param.ep_attr.service_type == DAT_SERVICE_TYPE_RC) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_STATE,
+                             dapls_ep_state_subtype(ep_ptr));
+               goto bail;
+       }
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-       ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+       if (qos != DAT_QOS_BEST_EFFORT ||
+           connect_flags != DAT_CONNECT_DEFAULT_FLAG) {
+               /*
+                * At this point we only support one QOS level
+                */
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status = DAT_ERROR(DAT_MODEL_NOT_SUPPORTED, 0);
+               goto bail;
+       }
 
        /*
-        * Some implementations provide us with an error code that the
-        * remote destination is unreachable, but DAT doesn't have a
-        * synchronous error code to communicate this. So the provider
-        * layer generates an INTERNAL_ERROR with a subtype; when
-        * this happens, return SUCCESS and generate the event
+        * Verify the private data size doesn't exceed the max
+        * req_hdr_size will evaluate to 0 unless IBHOSTS_NAMING is enabled.
         */
-       if (dat_status == DAT_ERROR (DAT_INTERNAL_ERROR, 1) )
-       {
-           dapls_evd_post_connection_event (
-                       (DAPL_EVD *)ep_ptr->param.connect_evd_handle,
-                       DAT_CONNECTION_EVENT_UNREACHABLE,
-                       (DAT_HANDLE) ep_ptr,
-                       0,
-                       0);
-           dat_status = DAT_SUCCESS;
+       req_hdr_size = (sizeof(DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);
+
+       max_req_pdata_size =
+           dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,
+                                      ep_ptr->header.owner_ia->hca_ptr);
+
+       if (private_data_size + req_hdr_size > (DAT_COUNT) max_req_pdata_size) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
+               goto bail;
        }
-    }
-    else
-    {
+
+       /* transition the state before requesting a connection to avoid
+        * race conditions
+        */
+       ep_ptr->param.ep_state = DAT_EP_STATE_ACTIVE_CONNECTION_PENDING;
+
        /*
-        * Acquire the lock and recheck the state of the EP; this
-        * thread could have been descheduled after issuing the connect
-        * request and the EP is now connected. Set up a timer if
-        * necessary.
+        * At this point we're committed, and done with the endpoint
+        * except for the connect, so we can drop the lock.
         */
-       dapl_os_lock ( &ep_ptr->header.lock );
-       if (ep_ptr->param.ep_state == DAT_EP_STATE_ACTIVE_CONNECTION_PENDING &&
-           timeout != DAT_TIMEOUT_INFINITE )
-       {
-           ep_ptr->cxn_timer =
-               (DAPL_OS_TIMER *)dapl_os_alloc (sizeof (DAPL_OS_TIMER));
-
-           dapls_timer_set ( ep_ptr->cxn_timer,
-                             dapls_ep_timeout,
-                             ep_ptr,
-                             timeout );
+       dapl_os_unlock(&ep_ptr->header.lock);
+
+#ifdef IBHOSTS_NAMING
+       /*
+        * Special case: put the remote HCA address into the private data
+        * prefix. This is a spec violation as it introduces a protocol, but
+        * some implementations may find it necessary for a time.
+        * Copy the private data into the EP area so the data is contiguous.
+        * If the provider needs to pad the buffer with NULLs, it happens at
+        * the provider layer.
+        */
+       dapl_os_memcpy(&ep_ptr->hca_address,
+                      &ep_ptr->header.owner_ia->hca_ptr->hca_address,
+                      sizeof(DAT_SOCK_ADDR));
+       dapl_os_memcpy(ep_ptr->private.private_data, private_data,
+                      private_data_size);
+       private_data_ptr = (void *)&ep_ptr->private.private_data;
+#else
+       private_data_ptr = private_data;
+#endif                         /* IBHOSTS_NAMING */
+
+       /* Copy the connection qualifiers */
+       dapl_os_memcpy(ep_ptr->param.remote_ia_address_ptr,
+                      remote_ia_address, sizeof(DAT_SOCK_ADDR));
+       ep_ptr->param.remote_port_qual = remote_conn_qual;
+
+       dat_status = dapls_ib_connect(ep_handle,
+                                     remote_ia_address,
+                                     remote_conn_qual,
+                                     private_data_size + req_hdr_size,
+                                     private_data_ptr);
+
+       if (dat_status != DAT_SUCCESS) {
+               ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+
+               /*
+                * Some implementations provide us with an error code that the
+                * remote destination is unreachable, but DAT doesn't have a
+                * synchronous error code to communicate this. So the provider
+                * layer generates an INTERNAL_ERROR with a subtype; when
+                * this happens, return SUCCESS and generate the event
+                */
+               if (dat_status == DAT_ERROR(DAT_INTERNAL_ERROR, 1)) {
+                       dapls_evd_post_connection_event((DAPL_EVD *) ep_ptr->
+                                                       param.
+                                                       connect_evd_handle,
+                                                       DAT_CONNECTION_EVENT_UNREACHABLE,
+                                                       (DAT_HANDLE) ep_ptr, 0,
+                                                       0);
+                       dat_status = DAT_SUCCESS;
+               }
+       } else {
+               /*
+                * Acquire the lock and recheck the state of the EP; this
+                * thread could have been descheduled after issuing the connect
+                * request and the EP is now connected. Set up a timer if
+                * necessary.
+                */
+               dapl_os_lock(&ep_ptr->header.lock);
+               if (ep_ptr->param.ep_state ==
+                   DAT_EP_STATE_ACTIVE_CONNECTION_PENDING
+                   && timeout != DAT_TIMEOUT_INFINITE) {
+                       ep_ptr->cxn_timer =
+                           (DAPL_OS_TIMER *)
+                           dapl_os_alloc(sizeof(DAPL_OS_TIMER));
+
+                       dapls_timer_set(ep_ptr->cxn_timer,
+                                       dapls_ep_timeout, ep_ptr, timeout);
+               }
+               dapl_os_unlock(&ep_ptr->header.lock);
        }
-       dapl_os_unlock ( &ep_ptr->header.lock );
-    }
 
-bail:
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN | DAPL_DBG_TYPE_CM,
-                 "dapl_ep_connect () returns 0x%x\n",
-                 dat_status);
+      bail:
+       dapl_dbg_log(DAPL_DBG_TYPE_RTN | DAPL_DBG_TYPE_CM,
+                    "dapl_ep_connect () returns 0x%x\n", dat_status);
 
-    return dat_status;
+       return dat_status;
 }
 
 /*
@@ -406,14 +398,12 @@ bail:
  *     DAT_INVALID_STATE
  *     DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN DAT_API
-dapl_ep_common_connect (
-       IN      DAT_EP_HANDLE ep,               /* ep_handle            */
-       IN      DAT_IA_ADDRESS_PTR remote_addr, /* remote_ia_address    */
-       IN      DAT_TIMEOUT timeout,            /* timeout              */
-       IN      DAT_COUNT pdata_size,           /* private_data_size    */
-       IN      const DAT_PVOID pdata   )       /* private_data         */
-{
+DAT_RETURN DAT_API dapl_ep_common_connect(IN DAT_EP_HANDLE ep, /* ep_handle            */
+                                         IN DAT_IA_ADDRESS_PTR remote_addr,    /* remote_ia_address    */
+                                         IN DAT_TIMEOUT timeout,       /* timeout              */
+                                         IN DAT_COUNT pdata_size,      /* private_data_size    */
+                                         IN const DAT_PVOID pdata)
+{                              /* private_data         */
        return DAT_MODEL_NOT_SUPPORTED;
 }
 
index 8982876..e154b8d 100644 (file)
@@ -39,7 +39,6 @@
 #include "dapl_ep_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * dapl_ep_create
  *
  *     DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_ep_create (
-    IN  DAT_IA_HANDLE           ia_handle,
-    IN  DAT_PZ_HANDLE           pz_handle,
-    IN  DAT_EVD_HANDLE          recv_evd_handle,
-    IN  DAT_EVD_HANDLE          request_evd_handle,
-    IN  DAT_EVD_HANDLE          connect_evd_handle,
-    IN  const DAT_EP_ATTR       *ep_attr,
-    OUT DAT_EP_HANDLE           *ep_handle )
+dapl_ep_create(IN DAT_IA_HANDLE ia_handle,
+              IN DAT_PZ_HANDLE pz_handle,
+              IN DAT_EVD_HANDLE recv_evd_handle,
+              IN DAT_EVD_HANDLE request_evd_handle,
+              IN DAT_EVD_HANDLE connect_evd_handle,
+              IN const DAT_EP_ATTR * ep_attr, OUT DAT_EP_HANDLE * ep_handle)
 {
-    DAPL_IA                     *ia_ptr;
-    DAPL_EP                     *ep_ptr;
-    DAT_EP_ATTR                 ep_attr_limit;
-    DAPL_EVD                    *evd_ptr;
-    DAT_RETURN                  dat_status;
-
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_create (%p, %p, %p, %p, %p, %p, %p)\n",
-                 ia_handle, 
-                 pz_handle, 
-                 recv_evd_handle, 
-                 request_evd_handle,
-                 connect_evd_handle, 
-                 ep_attr, 
-                 ep_handle);
-
-    ia_ptr = (DAPL_IA *)ia_handle;
-    dat_status = DAT_SUCCESS;
+       DAPL_IA *ia_ptr;
+       DAPL_EP *ep_ptr;
+       DAT_EP_ATTR ep_attr_limit;
+       DAPL_EVD *evd_ptr;
+       DAT_RETURN dat_status;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_create (%p, %p, %p, %p, %p, %p, %p)\n",
+                    ia_handle,
+                    pz_handle,
+                    recv_evd_handle,
+                    request_evd_handle,
+                    connect_evd_handle, ep_attr, ep_handle);
+
+       ia_ptr = (DAPL_IA *) ia_handle;
+       dat_status = DAT_SUCCESS;
 
-    /*
-     * Verify parameters
-     */
-    if ( DAPL_BAD_HANDLE (ia_ptr, DAPL_MAGIC_IA) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-       goto bail;
-    }
-    DAPL_CNTR(ia_ptr, DCNT_IA_EP_CREATE);
+       /*
+        * Verify parameters
+        */
+       if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+               goto bail;
+       }
+       DAPL_CNTR(ia_ptr, DCNT_IA_EP_CREATE);
 
-    /*
-     * Verify non-required parameters.
-     * N.B. Assumption: any parameter that can be
-     *      modified by dat_ep_modify() is not strictly
-     *      required when the EP is created
-     */
-    if ( pz_handle != DAT_HANDLE_NULL && 
-        DAPL_BAD_HANDLE (pz_handle, DAPL_MAGIC_PZ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-       goto bail;
-    }
+       /*
+        * Verify non-required parameters.
+        * N.B. Assumption: any parameter that can be
+        *      modified by dat_ep_modify() is not strictly
+        *      required when the EP is created
+        */
+       if (pz_handle != DAT_HANDLE_NULL &&
+           DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+               goto bail;
+       }
 
-    /* If connect handle is !NULL verify handle is good  */
-    if (connect_evd_handle != DAT_HANDLE_NULL &&
-       (DAPL_BAD_HANDLE (connect_evd_handle, DAPL_MAGIC_EVD) ||
-        ! (((DAPL_EVD *)connect_evd_handle)->evd_flags & DAT_EVD_CONNECTION_FLAG)) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CONN);
-       goto bail;
-    }
+       /* If connect handle is !NULL verify handle is good  */
+       if (connect_evd_handle != DAT_HANDLE_NULL &&
+           (DAPL_BAD_HANDLE(connect_evd_handle, DAPL_MAGIC_EVD) ||
+            !(((DAPL_EVD *) connect_evd_handle)->
+              evd_flags & DAT_EVD_CONNECTION_FLAG))) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CONN);
+               goto bail;
+       }
 
-    /* If recv_evd is !NULL, verify handle is good and flags are valid */
-    if (recv_evd_handle != DAT_HANDLE_NULL &&
-       (DAPL_BAD_HANDLE (recv_evd_handle, DAPL_MAGIC_EVD) ||
-        ! (((DAPL_EVD *)recv_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG) ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_RECV);
-       goto bail;
-    }
+       /* If recv_evd is !NULL, verify handle is good and flags are valid */
+       if (recv_evd_handle != DAT_HANDLE_NULL &&
+           (DAPL_BAD_HANDLE(recv_evd_handle, DAPL_MAGIC_EVD) ||
+            !(((DAPL_EVD *) recv_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG))) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_RECV);
+               goto bail;
+       }
 
-    /* If req_evd is !NULL, verify handle is good and flags are valid */
-    if (request_evd_handle != DAT_HANDLE_NULL && 
-       (DAPL_BAD_HANDLE (request_evd_handle, DAPL_MAGIC_EVD) ||
-        ! (((DAPL_EVD *)request_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG) ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-       goto bail;
-    }
+       /* If req_evd is !NULL, verify handle is good and flags are valid */
+       if (request_evd_handle != DAT_HANDLE_NULL &&
+           (DAPL_BAD_HANDLE(request_evd_handle, DAPL_MAGIC_EVD) ||
+            !(((DAPL_EVD *) request_evd_handle)->
+              evd_flags & DAT_EVD_DTO_FLAG))) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE,
+                             DAT_INVALID_HANDLE_EVD_REQUEST);
+               goto bail;
+       }
 
-    if ( ep_handle == NULL )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
-       goto bail;
-    }
-    if (DAPL_BAD_PTR(ep_attr))
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
-       goto bail;
-    }
+       if (ep_handle == NULL) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
+               goto bail;
+       }
+       if (DAPL_BAD_PTR(ep_attr)) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
+               goto bail;
+       }
 
-    /*
-     * Qualify EP Attributes are legal and make sense.  Note that if one
-     * or both of the DTO handles are NULL, then the corresponding
-     * max_*_dtos must 0 as the user will not be able to post dto ops on
-     * the respective queue.
-     */
-    if (ep_attr != NULL && (
+       /*
+        * Qualify EP Attributes are legal and make sense.  Note that if one
+        * or both of the DTO handles are NULL, then the corresponding
+        * max_*_dtos must 0 as the user will not be able to post dto ops on
+        * the respective queue.
+        */
+       if (ep_attr != NULL && (
 #ifndef DAT_EXTENSIONS
-         ep_attr->service_type != DAT_SERVICE_TYPE_RC ||
+                                      ep_attr->service_type !=
+                                      DAT_SERVICE_TYPE_RC ||
 #endif
-        (recv_evd_handle == DAT_HANDLE_NULL && ep_attr->max_recv_dtos != 0) ||
-        (recv_evd_handle != DAT_HANDLE_NULL && ep_attr->max_recv_dtos == 0) ||
-        (request_evd_handle == DAT_HANDLE_NULL && ep_attr->max_request_dtos != 0) ||
-        (request_evd_handle != DAT_HANDLE_NULL && ep_attr->max_request_dtos == 0) ||
-        (recv_evd_handle != DAT_HANDLE_NULL && ep_attr->max_recv_iov == 0) ||
-        ep_attr->max_request_iov == 0 ||
-         (DAT_SUCCESS != dapl_ep_check_recv_completion_flags (
-             ep_attr->recv_completion_flags)) ))
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
-       goto bail;
-    }
-
-    /* Verify the attributes against the transport */
-    if (ep_attr != NULL)
-    {
-       dapl_os_memzero (&ep_attr_limit, sizeof (DAT_EP_ATTR));
-       dat_status = dapls_ib_query_hca (ia_ptr->hca_ptr, 
-                                        NULL, &ep_attr_limit, NULL);
-       if (dat_status != DAT_SUCCESS)
-       {
-           goto bail;
+                                      (recv_evd_handle == DAT_HANDLE_NULL
+                                       && ep_attr->max_recv_dtos != 0)
+                                      || (recv_evd_handle != DAT_HANDLE_NULL
+                                          && ep_attr->max_recv_dtos == 0)
+                                      || (request_evd_handle == DAT_HANDLE_NULL
+                                          && ep_attr->max_request_dtos != 0)
+                                      || (request_evd_handle != DAT_HANDLE_NULL
+                                          && ep_attr->max_request_dtos == 0)
+                                      || (recv_evd_handle != DAT_HANDLE_NULL
+                                          && ep_attr->max_recv_iov == 0)
+                                      || ep_attr->max_request_iov == 0
+                                      || (DAT_SUCCESS !=
+                                          dapl_ep_check_recv_completion_flags
+                                          (ep_attr->recv_completion_flags)))) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
+               goto bail;
        }
-       if ( ep_attr->max_mtu_size     > ep_attr_limit.max_mtu_size       ||
-            ep_attr->max_rdma_size    > ep_attr_limit.max_rdma_size      ||
-            ep_attr->max_recv_dtos    > ep_attr_limit.max_recv_dtos      ||
-            ep_attr->max_request_dtos > ep_attr_limit.max_request_dtos   ||
-            ep_attr->max_recv_iov     > ep_attr_limit.max_recv_iov       ||
-            ep_attr->max_request_iov  > ep_attr_limit.max_request_iov    ||
-            ep_attr->max_rdma_read_in > ep_attr_limit.max_rdma_read_in   ||
-            ep_attr->max_rdma_read_out> ep_attr_limit.max_rdma_read_out )
 
-       {
-           dat_status = DAT_INVALID_PARAMETER | DAT_INVALID_ARG6;
-           goto bail;
+       /* Verify the attributes against the transport */
+       if (ep_attr != NULL) {
+               dapl_os_memzero(&ep_attr_limit, sizeof(DAT_EP_ATTR));
+               dat_status = dapls_ib_query_hca(ia_ptr->hca_ptr,
+                                               NULL, &ep_attr_limit, NULL);
+               if (dat_status != DAT_SUCCESS) {
+                       goto bail;
+               }
+               if (ep_attr->max_mtu_size > ep_attr_limit.max_mtu_size ||
+                   ep_attr->max_rdma_size > ep_attr_limit.max_rdma_size ||
+                   ep_attr->max_recv_dtos > ep_attr_limit.max_recv_dtos ||
+                   ep_attr->max_request_dtos > ep_attr_limit.max_request_dtos
+                   || ep_attr->max_recv_iov > ep_attr_limit.max_recv_iov
+                   || ep_attr->max_request_iov > ep_attr_limit.max_request_iov
+                   || ep_attr->max_rdma_read_in >
+                   ep_attr_limit.max_rdma_read_in
+                   || ep_attr->max_rdma_read_out >
+                   ep_attr_limit.max_rdma_read_out)
+               {
+                       dat_status = DAT_INVALID_PARAMETER | DAT_INVALID_ARG6;
+                       goto bail;
+               }
        }
-    }
 
-    /*
-     * Verify the completion flags for the EVD and the EP
-     */
-    /*
-     * XXX FIXME
-     * XXX Need to make assign the EVD to the right completion type
-     * XXX depending on the EP attributes. Fail if the types don't
-     * XXX match, they are mutually exclusive.
-     */
-    evd_ptr = (DAPL_EVD *)recv_evd_handle;
-    if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT)
-    {
-       if (ep_attr != NULL && 
-           ep_attr->recv_completion_flags == DAT_COMPLETION_DEFAULT_FLAG)
-       {
-           evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
-       }
-       else
-       {
-           evd_ptr->completion_type = ep_attr->recv_completion_flags;
+       /*
+        * Verify the completion flags for the EVD and the EP
+        */
+       /*
+        * XXX FIXME
+        * XXX Need to make assign the EVD to the right completion type
+        * XXX depending on the EP attributes. Fail if the types don't
+        * XXX match, they are mutually exclusive.
+        */
+       evd_ptr = (DAPL_EVD *) recv_evd_handle;
+       if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT) {
+               if (ep_attr != NULL &&
+                   ep_attr->recv_completion_flags ==
+                   DAT_COMPLETION_DEFAULT_FLAG) {
+                       evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
+               } else {
+                       evd_ptr->completion_type =
+                           ep_attr->recv_completion_flags;
+               }
        }
-    }
 
-    evd_ptr = (DAPL_EVD *)request_evd_handle;
-    if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT)
-    {
-       if (ep_attr != NULL && 
-           ep_attr->recv_completion_flags == DAT_COMPLETION_DEFAULT_FLAG)
-       {
-           evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
-       }
-       else
-       {
-           evd_ptr->completion_type = ep_attr->recv_completion_flags;
+       evd_ptr = (DAPL_EVD *) request_evd_handle;
+       if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT) {
+               if (ep_attr != NULL &&
+                   ep_attr->recv_completion_flags ==
+                   DAT_COMPLETION_DEFAULT_FLAG) {
+                       evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
+               } else {
+                       evd_ptr->completion_type =
+                           ep_attr->recv_completion_flags;
+               }
        }
-    }
-
-
-    /* Allocate EP */
-    ep_ptr = dapl_ep_alloc ( ia_ptr, ep_attr );
-    if ( ep_ptr == NULL )
-    {
-       dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-       goto bail;
-    }
 
-    /*
-     * Fill in the EP
-     */
-    ep_ptr->param.ia_handle           = ia_handle;
-    ep_ptr->param.ep_state           = DAT_EP_STATE_UNCONNECTED;
-    ep_ptr->param.local_ia_address_ptr=
-       (DAT_IA_ADDRESS_PTR)&ia_ptr->hca_ptr->hca_address;
-    /* Set the remote address pointer to the end of the EP struct */
-    ep_ptr->param.remote_ia_address_ptr = (DAT_IA_ADDRESS_PTR) (ep_ptr + 1);
-
-    ep_ptr->param.pz_handle           = pz_handle;
-    ep_ptr->param.recv_evd_handle     = recv_evd_handle;
-    ep_ptr->param.request_evd_handle  = request_evd_handle;
-    ep_ptr->param.connect_evd_handle  = connect_evd_handle;
+       /* Allocate EP */
+       ep_ptr = dapl_ep_alloc(ia_ptr, ep_attr);
+       if (ep_ptr == NULL) {
+               dat_status =
+                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+               goto bail;
+       }
 
-    /*
-     * Make sure we handle the NULL DTO EVDs
-     */
-    if ( recv_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL )
-    {
-       ep_ptr->param.ep_attr.max_recv_dtos = 0;
-    }
+       /*
+        * Fill in the EP
+        */
+       ep_ptr->param.ia_handle = ia_handle;
+       ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+       ep_ptr->param.local_ia_address_ptr =
+           (DAT_IA_ADDRESS_PTR) & ia_ptr->hca_ptr->hca_address;
+       /* Set the remote address pointer to the end of the EP struct */
+       ep_ptr->param.remote_ia_address_ptr = (DAT_IA_ADDRESS_PTR) (ep_ptr + 1);
+
+       ep_ptr->param.pz_handle = pz_handle;
+       ep_ptr->param.recv_evd_handle = recv_evd_handle;
+       ep_ptr->param.request_evd_handle = request_evd_handle;
+       ep_ptr->param.connect_evd_handle = connect_evd_handle;
 
-    if ( request_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL )
-    {
-       ep_ptr->param.ep_attr.max_request_dtos = 0;
-    }
+       /*
+        * Make sure we handle the NULL DTO EVDs
+        */
+       if (recv_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL) {
+               ep_ptr->param.ep_attr.max_recv_dtos = 0;
+       }
 
-    /*
-     * If the user has specified a PZ handle we allocate a QP for
-     * this EP; else we defer until it is assigned via ep_modify().
-     * As much as possible we try to keep QP creation out of the
-     * connect path to avoid resource errors in strange places.
-     */
-    if (pz_handle != DAT_HANDLE_NULL )
-    {
-       /* Take a reference on the PZ handle */
-       dapl_os_atomic_inc (& ((DAPL_PZ *)pz_handle)->pz_ref_count);
+       if (request_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL) {
+               ep_ptr->param.ep_attr.max_request_dtos = 0;
+       }
 
        /*
-        * Get a QP from the IB provider
+        * If the user has specified a PZ handle we allocate a QP for
+        * this EP; else we defer until it is assigned via ep_modify().
+        * As much as possible we try to keep QP creation out of the
+        * connect path to avoid resource errors in strange places.
         */
-       dat_status = dapls_ib_qp_alloc ( ia_ptr, ep_ptr, ep_ptr );
-
-       if ( dat_status != DAT_SUCCESS)
-       {
-           dapl_os_atomic_dec (& ((DAPL_PZ *)pz_handle)->pz_ref_count);
-           dapl_ep_dealloc ( ep_ptr );
-           goto bail;
+       if (pz_handle != DAT_HANDLE_NULL) {
+               /* Take a reference on the PZ handle */
+               dapl_os_atomic_inc(&((DAPL_PZ *) pz_handle)->pz_ref_count);
+
+               /*
+                * Get a QP from the IB provider
+                */
+               dat_status = dapls_ib_qp_alloc(ia_ptr, ep_ptr, ep_ptr);
+
+               if (dat_status != DAT_SUCCESS) {
+                       dapl_os_atomic_dec(&((DAPL_PZ *) pz_handle)->
+                                          pz_ref_count);
+                       dapl_ep_dealloc(ep_ptr);
+                       goto bail;
+               }
+       } else {
+               ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
        }
-    }
-    else
-    {
-       ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
-    }
 
-    /*
-     * Update ref counts. See the spec where the endpoint marks
-     * a data object as 'in use'
-     *   pz_handle: dat_pz_free, uDAPL Document, 6.6.1.2
-     *   evd_handles:
-     *
-     * N.B. This should really be done by a util routine.
-     */
-    if (connect_evd_handle != DAT_HANDLE_NULL)
-    {
-       dapl_os_atomic_inc (& ((DAPL_EVD *)connect_evd_handle)->evd_ref_count);
-    }
-    /* Optional handles */
-    if (recv_evd_handle != DAT_HANDLE_NULL)
-    {
-       dapl_os_atomic_inc (& ((DAPL_EVD *)recv_evd_handle)->evd_ref_count);
-    }
-    if (request_evd_handle != DAT_HANDLE_NULL)
-    {
-       dapl_os_atomic_inc (& ((DAPL_EVD *)request_evd_handle)->evd_ref_count);
-    }
+       /*
+        * Update ref counts. See the spec where the endpoint marks
+        * a data object as 'in use'
+        *   pz_handle: dat_pz_free, uDAPL Document, 6.6.1.2
+        *   evd_handles:
+        *
+        * N.B. This should really be done by a util routine.
+        */
+       if (connect_evd_handle != DAT_HANDLE_NULL) {
+               dapl_os_atomic_inc(&((DAPL_EVD *) connect_evd_handle)->
+                                  evd_ref_count);
+       }
+       /* Optional handles */
+       if (recv_evd_handle != DAT_HANDLE_NULL) {
+               dapl_os_atomic_inc(&((DAPL_EVD *) recv_evd_handle)->
+                                  evd_ref_count);
+       }
+       if (request_evd_handle != DAT_HANDLE_NULL) {
+               dapl_os_atomic_inc(&((DAPL_EVD *) request_evd_handle)->
+                                  evd_ref_count);
+       }
 
-    /* Link it onto the IA */
-    dapl_ia_link_ep (ia_ptr, ep_ptr);
+       /* Link it onto the IA */
+       dapl_ia_link_ep(ia_ptr, ep_ptr);
 
-    *ep_handle = ep_ptr;
+       *ep_handle = ep_ptr;
 
-bail:
-    return dat_status;
+      bail:
+       return dat_status;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4
index e288670..b85abfd 100644 (file)
@@ -41,7 +41,6 @@
 #include "dapl_ep_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * dapl_ep_create_with_srq
  *
  *     DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_ep_create_with_srq (
-       IN      DAT_IA_HANDLE           ia_handle,
-       IN      DAT_PZ_HANDLE           pz_handle,
-       IN      DAT_EVD_HANDLE          recv_evd_handle,
-       IN      DAT_EVD_HANDLE          request_evd_handle,
-       IN      DAT_EVD_HANDLE          connect_evd_handle,
-       IN      DAT_SRQ_HANDLE          srq_handle,
-       IN      const DAT_EP_ATTR       *ep_attr,
-       OUT     DAT_EP_HANDLE           *ep_handle )
+dapl_ep_create_with_srq(IN DAT_IA_HANDLE ia_handle,
+                       IN DAT_PZ_HANDLE pz_handle,
+                       IN DAT_EVD_HANDLE recv_evd_handle,
+                       IN DAT_EVD_HANDLE request_evd_handle,
+                       IN DAT_EVD_HANDLE connect_evd_handle,
+                       IN DAT_SRQ_HANDLE srq_handle,
+                       IN const DAT_EP_ATTR * ep_attr,
+                       OUT DAT_EP_HANDLE * ep_handle)
 {
-    DAPL_IA            *ia_ptr;
-    DAPL_EP            *ep_ptr;
-    DAT_EP_ATTR                ep_attr_limit;
-    DAPL_EVD           *evd_ptr;
-    DAT_RETURN         dat_status;
-
-    dat_status = DAT_SUCCESS;
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_create_with_srq (%p, %p, %p, %p, %p, %p, %p %p)\n",
-                 ia_handle,
-                 pz_handle,
-                 recv_evd_handle,
-                 request_evd_handle,
-                 connect_evd_handle,
-                 srq_handle,
-                 ep_attr,
-                 ep_handle);
-
-    ia_ptr = (DAPL_IA *)ia_handle;
-
-    /*
-     * Verify parameters
-     */
-    if ( DAPL_BAD_HANDLE (ia_ptr, DAPL_MAGIC_IA) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-       goto bail;
-    }
-
-    /*
-     * Verify non-required parameters.
-     * N.B. Assumption: any parameter that can be
-     *      modified by dat_ep_modify() is not strictly
-     *      required when the EP is created
-     */
-    if ( pz_handle != NULL && 
-        DAPL_BAD_HANDLE (pz_handle, DAPL_MAGIC_PZ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-       goto bail;
-    }
-
-    /* If connect handle is !NULL verify handle is good  */
-    if (connect_evd_handle != DAT_HANDLE_NULL &&
-       (DAPL_BAD_HANDLE (connect_evd_handle, DAPL_MAGIC_EVD) ||
-        ! (((DAPL_EVD *)connect_evd_handle)->evd_flags & DAT_EVD_CONNECTION_FLAG)) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CONN);
-       goto bail;
-    }
-    /* If recv_evd is !NULL, verify handle is good and flags are valid */
-    if (recv_evd_handle != DAT_HANDLE_NULL &&
-       (DAPL_BAD_HANDLE (recv_evd_handle, DAPL_MAGIC_EVD) ||
-        ! (((DAPL_EVD *)recv_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG) ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_RECV);
-       goto bail;
-    }
-
-    /* If req_evd is !NULL, verify handle is good and flags are valid */
-    if (request_evd_handle != DAT_HANDLE_NULL && 
-       (DAPL_BAD_HANDLE (request_evd_handle, DAPL_MAGIC_EVD) ||
-        ! (((DAPL_EVD *)request_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG) ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-       goto bail;
-    }
-
-    /*
-     * Verify the SRQ handle. It is an error to invoke this call with
-     * a NULL handle
-     */
-    if (DAPL_BAD_HANDLE (srq_handle, DAPL_MAGIC_SRQ))
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-       goto bail;
-    }
+       DAPL_IA *ia_ptr;
+       DAPL_EP *ep_ptr;
+       DAT_EP_ATTR ep_attr_limit;
+       DAPL_EVD *evd_ptr;
+       DAT_RETURN dat_status;
+
+       dat_status = DAT_SUCCESS;
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_create_with_srq (%p, %p, %p, %p, %p, %p, %p %p)\n",
+                    ia_handle,
+                    pz_handle,
+                    recv_evd_handle,
+                    request_evd_handle,
+                    connect_evd_handle, srq_handle, ep_attr, ep_handle);
+
+       ia_ptr = (DAPL_IA *) ia_handle;
 
-    if ( ep_handle == NULL )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
-       goto bail;
-    }
+       /*
+        * Verify parameters
+        */
+       if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+               goto bail;
+       }
 
-    if ( DAPL_BAD_PTR(ep_attr) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
-       goto bail;
-    }
-
-    /*
-     * Qualify EP Attributes are legal and make sense.  Note that if one
-     * or both of the DTO handles are NULL, then the corresponding
-     * max_*_dtos must 0 as the user will not be able to post dto ops on
-     * the respective queue.
-     */
-    if (ep_attr != NULL && 
-       (ep_attr->service_type != DAT_SERVICE_TYPE_RC ||
-        (recv_evd_handle == DAT_HANDLE_NULL && ep_attr->max_recv_dtos != 0) ||
-        (recv_evd_handle != DAT_HANDLE_NULL && ep_attr->max_recv_dtos == 0) ||
-        (request_evd_handle == DAT_HANDLE_NULL && ep_attr->max_request_dtos != 0) ||
-        (request_evd_handle != DAT_HANDLE_NULL && ep_attr->max_request_dtos == 0) ||
-        ep_attr->max_recv_iov == 0 ||
-        ep_attr->max_request_iov == 0 ||
-         (DAT_SUCCESS != dapl_ep_check_recv_completion_flags (
-             ep_attr->recv_completion_flags)) ))
-    {
-       dat_status = DAT_INVALID_PARAMETER | DAT_INVALID_ARG6;
-       goto bail;
-    }
-
-    /* Verify the attributes against the transport */
-    if (ep_attr != NULL)
-    {
-       dapl_os_memzero (&ep_attr_limit, sizeof (DAT_EP_ATTR));
-       dat_status = dapls_ib_query_hca (ia_ptr->hca_ptr, 
-                                        NULL, &ep_attr_limit, NULL);
-       if (dat_status != DAT_SUCCESS)
-       {
-           goto bail;
+       /*
+        * Verify non-required parameters.
+        * N.B. Assumption: any parameter that can be
+        *      modified by dat_ep_modify() is not strictly
+        *      required when the EP is created
+        */
+       if (pz_handle != NULL && DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+               goto bail;
        }
-       if ( ep_attr->max_mtu_size     > ep_attr_limit.max_mtu_size       ||
-            ep_attr->max_rdma_size    > ep_attr_limit.max_rdma_size      ||
-            ep_attr->max_recv_dtos    > ep_attr_limit.max_recv_dtos      ||
-            ep_attr->max_request_dtos > ep_attr_limit.max_request_dtos   ||
-            ep_attr->max_recv_iov     > ep_attr_limit.max_recv_iov       ||
-            ep_attr->max_request_iov  > ep_attr_limit.max_request_iov    ||
-            ep_attr->max_rdma_read_in > ep_attr_limit.max_rdma_read_in   ||
-            ep_attr->max_rdma_read_out> ep_attr_limit.max_rdma_read_out )
-
-       {
-           dat_status = DAT_INVALID_PARAMETER | DAT_INVALID_ARG6;
-           goto bail;
+
+       /* If connect handle is !NULL verify handle is good  */
+       if (connect_evd_handle != DAT_HANDLE_NULL &&
+           (DAPL_BAD_HANDLE(connect_evd_handle, DAPL_MAGIC_EVD) ||
+            !(((DAPL_EVD *) connect_evd_handle)->
+              evd_flags & DAT_EVD_CONNECTION_FLAG))) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CONN);
+               goto bail;
        }
-    }
-
-    /*
-     * Verify the completion flags for the EVD and the EP
-     */
-    /*
-     * XXX FIXME
-     * XXX Need to make assign the EVD to the right completion type
-     * XXX depending on the EP attributes. Fail if the types don't
-     * XXX match, they are mutually exclusive.
-     */
-    evd_ptr = (DAPL_EVD *)recv_evd_handle;
-    if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT)
-    {
-       if (ep_attr != NULL && 
-           ep_attr->recv_completion_flags == DAT_COMPLETION_DEFAULT_FLAG)
-       {
-           evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
+       /* If recv_evd is !NULL, verify handle is good and flags are valid */
+       if (recv_evd_handle != DAT_HANDLE_NULL &&
+           (DAPL_BAD_HANDLE(recv_evd_handle, DAPL_MAGIC_EVD) ||
+            !(((DAPL_EVD *) recv_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG))) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_RECV);
+               goto bail;
        }
-       else
-       {
-           evd_ptr->completion_type = ep_attr->recv_completion_flags;
+
+       /* If req_evd is !NULL, verify handle is good and flags are valid */
+       if (request_evd_handle != DAT_HANDLE_NULL &&
+           (DAPL_BAD_HANDLE(request_evd_handle, DAPL_MAGIC_EVD) ||
+            !(((DAPL_EVD *) request_evd_handle)->
+              evd_flags & DAT_EVD_DTO_FLAG))) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE,
+                             DAT_INVALID_HANDLE_EVD_REQUEST);
+               goto bail;
        }
-    }
-
-    evd_ptr = (DAPL_EVD *)request_evd_handle;
-    if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT)
-    {
-       if (ep_attr != NULL && 
-           ep_attr->recv_completion_flags == DAT_COMPLETION_DEFAULT_FLAG)
-       {
-           evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
+
+       /*
+        * Verify the SRQ handle. It is an error to invoke this call with
+        * a NULL handle
+        */
+       if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+               goto bail;
        }
-       else
-       {
-           evd_ptr->completion_type = ep_attr->recv_completion_flags;
+
+       if (ep_handle == NULL) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
+               goto bail;
        }
-    }
 
-    dat_status = DAT_NOT_IMPLEMENTED;
+       if (DAPL_BAD_PTR(ep_attr)) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
+               goto bail;
+       }
 
-    /*
-     * XXX The rest of the EP code is useful in this case too,
-     * XXX but need to complete the SRQ implementation before
-     * XXX committing resources
-     */
-    *ep_handle = ep_ptr = NULL;
-    goto bail;
-#ifdef notdef
+       /*
+        * Qualify EP Attributes are legal and make sense.  Note that if one
+        * or both of the DTO handles are NULL, then the corresponding
+        * max_*_dtos must 0 as the user will not be able to post dto ops on
+        * the respective queue.
+        */
+       if (ep_attr != NULL &&
+           (ep_attr->service_type != DAT_SERVICE_TYPE_RC ||
+            (recv_evd_handle == DAT_HANDLE_NULL && ep_attr->max_recv_dtos != 0)
+            || (recv_evd_handle != DAT_HANDLE_NULL
+                && ep_attr->max_recv_dtos == 0)
+            || (request_evd_handle == DAT_HANDLE_NULL
+                && ep_attr->max_request_dtos != 0)
+            || (request_evd_handle != DAT_HANDLE_NULL
+                && ep_attr->max_request_dtos == 0)
+            || ep_attr->max_recv_iov == 0 || ep_attr->max_request_iov == 0
+            || (DAT_SUCCESS !=
+                dapl_ep_check_recv_completion_flags(ep_attr->
+                                                    recv_completion_flags)))) {
+               dat_status = DAT_INVALID_PARAMETER | DAT_INVALID_ARG6;
+               goto bail;
+       }
+
+       /* Verify the attributes against the transport */
+       if (ep_attr != NULL) {
+               dapl_os_memzero(&ep_attr_limit, sizeof(DAT_EP_ATTR));
+               dat_status = dapls_ib_query_hca(ia_ptr->hca_ptr,
+                                               NULL, &ep_attr_limit, NULL);
+               if (dat_status != DAT_SUCCESS) {
+                       goto bail;
+               }
+               if (ep_attr->max_mtu_size > ep_attr_limit.max_mtu_size ||
+                   ep_attr->max_rdma_size > ep_attr_limit.max_rdma_size ||
+                   ep_attr->max_recv_dtos > ep_attr_limit.max_recv_dtos ||
+                   ep_attr->max_request_dtos > ep_attr_limit.max_request_dtos
+                   || ep_attr->max_recv_iov > ep_attr_limit.max_recv_iov
+                   || ep_attr->max_request_iov > ep_attr_limit.max_request_iov
+                   || ep_attr->max_rdma_read_in >
+                   ep_attr_limit.max_rdma_read_in
+                   || ep_attr->max_rdma_read_out >
+                   ep_attr_limit.max_rdma_read_out)
+               {
+                       dat_status = DAT_INVALID_PARAMETER | DAT_INVALID_ARG6;
+                       goto bail;
+               }
+       }
+
+       /*
+        * Verify the completion flags for the EVD and the EP
+        */
+       /*
+        * XXX FIXME
+        * XXX Need to make assign the EVD to the right completion type
+        * XXX depending on the EP attributes. Fail if the types don't
+        * XXX match, they are mutually exclusive.
+        */
+       evd_ptr = (DAPL_EVD *) recv_evd_handle;
+       if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT) {
+               if (ep_attr != NULL &&
+                   ep_attr->recv_completion_flags ==
+                   DAT_COMPLETION_DEFAULT_FLAG) {
+                       evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
+               } else {
+                       evd_ptr->completion_type =
+                           ep_attr->recv_completion_flags;
+               }
+       }
 
-    /* Allocate EP */
-    ep_ptr = dapl_ep_alloc ( ia_ptr, ep_attr );
-    if ( ep_ptr == NULL )
-    {
-       dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+       evd_ptr = (DAPL_EVD *) request_evd_handle;
+       if (evd_ptr != NULL && evd_ptr->completion_type == DAPL_EVD_STATE_INIT) {
+               if (ep_attr != NULL &&
+                   ep_attr->recv_completion_flags ==
+                   DAT_COMPLETION_DEFAULT_FLAG) {
+                       evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;
+               } else {
+                       evd_ptr->completion_type =
+                           ep_attr->recv_completion_flags;
+               }
+       }
+
+       dat_status = DAT_NOT_IMPLEMENTED;
+
+       /*
+        * XXX The rest of the EP code is useful in this case too,
+        * XXX but need to complete the SRQ implementation before
+        * XXX committing resources
+        */
+       *ep_handle = ep_ptr = NULL;
        goto bail;
-    }
-
-    /*
-     * Fill in the EP
-     */
-    ep_ptr->param.ia_handle           = ia_handle;
-    ep_ptr->param.ep_state           = DAT_EP_STATE_UNCONNECTED;
-    ep_ptr->param.local_ia_address_ptr=
-       (DAT_IA_ADDRESS_PTR)&ia_ptr->hca_ptr->hca_address;
-    /* Set the remote address pointer to the end of the EP struct */
-    ep_ptr->param.remote_ia_address_ptr = (DAT_IA_ADDRESS_PTR) (ep_ptr + 1);
-
-    ep_ptr->param.pz_handle           = pz_handle;
-    ep_ptr->param.recv_evd_handle     = recv_evd_handle;
-    ep_ptr->param.request_evd_handle  = request_evd_handle;
-    ep_ptr->param.connect_evd_handle  = connect_evd_handle;
-
-    /*
-     * Make sure we handle the NULL DTO EVDs
-     */
-    if ( recv_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL )
-    {
-       ep_ptr->param.ep_attr.max_recv_dtos = 0;
-    }
-
-    if ( request_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL )
-    {
-       ep_ptr->param.ep_attr.max_request_dtos = 0;
-    }
-
-    /*
-     * If the user has specified a PZ handle we allocate a QP for
-     * this EP; else we defer until it is assigned via ep_modify().
-     * As much as possible we try to keep QP creation out of the
-     * connect path to avoid resource errors in strange places.
-     */
-    if (pz_handle != DAT_HANDLE_NULL )
-    {
-       /* Take a reference on the PZ handle */
-       dapl_os_atomic_inc (& ((DAPL_PZ *)pz_handle)->pz_ref_count);
+#ifdef notdef
+
+       /* Allocate EP */
+       ep_ptr = dapl_ep_alloc(ia_ptr, ep_attr);
+       if (ep_ptr == NULL) {
+               dat_status =
+                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+               goto bail;
+       }
 
        /*
-        * Get a QP from the IB provider
+        * Fill in the EP
         */
-       dat_status = dapls_ib_qp_alloc ( ia_ptr, ep_ptr, ep_ptr );
+       ep_ptr->param.ia_handle = ia_handle;
+       ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+       ep_ptr->param.local_ia_address_ptr =
+           (DAT_IA_ADDRESS_PTR) & ia_ptr->hca_ptr->hca_address;
+       /* Set the remote address pointer to the end of the EP struct */
+       ep_ptr->param.remote_ia_address_ptr = (DAT_IA_ADDRESS_PTR) (ep_ptr + 1);
+
+       ep_ptr->param.pz_handle = pz_handle;
+       ep_ptr->param.recv_evd_handle = recv_evd_handle;
+       ep_ptr->param.request_evd_handle = request_evd_handle;
+       ep_ptr->param.connect_evd_handle = connect_evd_handle;
 
-       if ( dat_status != DAT_SUCCESS)
-       {
-           dapl_os_atomic_dec (& ((DAPL_PZ *)pz_handle)->pz_ref_count);
-           dapl_ep_dealloc ( ep_ptr );
-           goto bail;
+       /*
+        * Make sure we handle the NULL DTO EVDs
+        */
+       if (recv_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL) {
+               ep_ptr->param.ep_attr.max_recv_dtos = 0;
        }
-    }
-    else
-    {
-       ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
-    }
-
-    /*
-     * Update ref counts. See the spec where the endpoint marks
-     * a data object as 'in use'
-     *   pz_handle: dat_pz_free, uDAPL Document, 6.6.1.2
-     *   evd_handles:
-     *
-     * N.B. This should really be done by a util routine.
-     */
-    dapl_os_atomic_inc (& ((DAPL_EVD *)connect_evd_handle)->evd_ref_count);
-    /* Optional handles */
-    if (recv_evd_handle != DAT_HANDLE_NULL)
-    {
-       dapl_os_atomic_inc (& ((DAPL_EVD *)recv_evd_handle)->evd_ref_count);
-    }
-    if (request_evd_handle != DAT_HANDLE_NULL)
-    {
-       dapl_os_atomic_inc (& ((DAPL_EVD *)request_evd_handle)->evd_ref_count);
-    }
-
-    /* Link it onto the IA */
-    dapl_ia_link_ep (ia_ptr, ep_ptr);
-
-    *ep_handle = ep_ptr;
-
-#endif /* notdef */
-
-bail:
-    return dat_status;
-}
 
+       if (request_evd_handle == DAT_HANDLE_NULL && ep_attr == NULL) {
+               ep_ptr->param.ep_attr.max_request_dtos = 0;
+       }
+
+       /*
+        * If the user has specified a PZ handle we allocate a QP for
+        * this EP; else we defer until it is assigned via ep_modify().
+        * As much as possible we try to keep QP creation out of the
+        * connect path to avoid resource errors in strange places.
+        */
+       if (pz_handle != DAT_HANDLE_NULL) {
+               /* Take a reference on the PZ handle */
+               dapl_os_atomic_inc(&((DAPL_PZ *) pz_handle)->pz_ref_count);
+
+               /*
+                * Get a QP from the IB provider
+                */
+               dat_status = dapls_ib_qp_alloc(ia_ptr, ep_ptr, ep_ptr);
+
+               if (dat_status != DAT_SUCCESS) {
+                       dapl_os_atomic_dec(&((DAPL_PZ *) pz_handle)->
+                                          pz_ref_count);
+                       dapl_ep_dealloc(ep_ptr);
+                       goto bail;
+               }
+       } else {
+               ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
+       }
+
+       /*
+        * Update ref counts. See the spec where the endpoint marks
+        * a data object as 'in use'
+        *   pz_handle: dat_pz_free, uDAPL Document, 6.6.1.2
+        *   evd_handles:
+        *
+        * N.B. This should really be done by a util routine.
+        */
+       dapl_os_atomic_inc(&((DAPL_EVD *) connect_evd_handle)->evd_ref_count);
+       /* Optional handles */
+       if (recv_evd_handle != DAT_HANDLE_NULL) {
+               dapl_os_atomic_inc(&((DAPL_EVD *) recv_evd_handle)->
+                                  evd_ref_count);
+       }
+       if (request_evd_handle != DAT_HANDLE_NULL) {
+               dapl_os_atomic_inc(&((DAPL_EVD *) request_evd_handle)->
+                                  evd_ref_count);
+       }
+
+       /* Link it onto the IA */
+       dapl_ia_link_ep(ia_ptr, ep_ptr);
+
+       *ep_handle = ep_ptr;
+
+#endif                         /* notdef */
+
+      bail:
+       return dat_status;
+}
 
 /*
  * Local variables:
index 631d809..72da620 100644 (file)
  *     DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_ep_disconnect (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_CLOSE_FLAGS         disconnect_flags)
+dapl_ep_disconnect(IN DAT_EP_HANDLE ep_handle,
+                  IN DAT_CLOSE_FLAGS disconnect_flags)
 {
-    DAPL_EP            *ep_ptr;
-    DAPL_EVD           *evd_ptr;
-    DAT_RETURN         dat_status;
-
-    dapl_dbg_log (DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
-                "dapl_ep_disconnect (%p, %x)\n",
-                 ep_handle,
-                 disconnect_flags);
-
-    ep_ptr = (DAPL_EP *) ep_handle;
-
-    /*
-     * Verify parameter & state
-     */
-    if ( DAPL_BAD_HANDLE (ep_ptr, DAPL_MAGIC_EP ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-    DAPL_CNTR(ep_ptr, DCNT_EP_DISCONNECT);
-
-    /*
-     * Do the verification of parameters and the state change
-     * atomically.
-     */
-    dapl_os_lock ( &ep_ptr->header.lock );
-
-    /* Disconnecting a disconnected EP is a no-op. */
-    if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED ||
-       ep_ptr->param.ep_attr.service_type != DAT_SERVICE_TYPE_RC)
-    {
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_SUCCESS;
-       goto bail;
-    }
-
-    /* Check the EP state to ensure we are queiscent. Note that
-     * we may get called in UNCONNECTED state in order to remove
-     * RECV requests from the queue prior to destroying an EP.
-     * See the states in the spec at 6.5.1 Endpont Lifecycle
-     */
-    if ( ep_ptr->param.ep_state != DAT_EP_STATE_CONNECTED &&
-        ep_ptr->param.ep_state != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING &&
-        ep_ptr->param.ep_state != DAT_EP_STATE_COMPLETION_PENDING &&
-        ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECT_PENDING )
-    {
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep_ptr));
-       goto bail;
-    }
-
-    if ( ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING &&
-        disconnect_flags != DAT_CLOSE_ABRUPT_FLAG)
-    {
+       DAPL_EP *ep_ptr;
+       DAPL_EVD *evd_ptr;
+       DAT_RETURN dat_status;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
+                    "dapl_ep_disconnect (%p, %x)\n",
+                    ep_handle, disconnect_flags);
+
+       ep_ptr = (DAPL_EP *) ep_handle;
+
        /*
-        * If in state DISCONNECT_PENDING then this must be an
-        * ABRUPT disconnect
+        * Verify parameter & state
         */
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-       goto bail;
-    }
-
-    if ( ep_ptr->param.ep_state == DAT_EP_STATE_ACTIVE_CONNECTION_PENDING ||
-        ep_ptr->param.ep_state == DAT_EP_STATE_COMPLETION_PENDING )
-    {
+       if (DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
+       DAPL_CNTR(ep_ptr, DCNT_EP_DISCONNECT);
+
        /*
-        * Beginning or waiting on a connection: abort and reset the
-        * state
+        * Do the verification of parameters and the state change
+        * atomically.
         */
-       ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
-
-       dapl_os_unlock ( &ep_ptr->header.lock );
-       /* disconnect and make sure we get no callbacks */
-       (void) dapls_ib_disconnect (ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
-
-       /* clean up connection state */
-       dapl_sp_remove_ep (ep_ptr);
-
-       evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
-       dapls_evd_post_connection_event (evd_ptr,
-                                       DAT_CONNECTION_EVENT_DISCONNECTED,
-                                       (DAT_HANDLE) ep_ptr,
-                                       0,
-                                       0);
-       dat_status = DAT_SUCCESS;
-       goto bail;
-    }
-
-    /*
-     * Transition the EP state to DISCONNECT_PENDING if we are
-     * CONNECTED. Otherwise we do not get a disconnect event and will be
-     * stuck in DISCONNECT_PENDING.
-     *
-     * If the user specifies a graceful disconnect, the underlying
-     * provider should complete all DTOs before disconnecting; in IB
-     * terms, this means setting the QP state to SQD before completing
-     * the disconnect state transitions.
-     */
-    if ( ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED )
-    {
-       ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECT_PENDING;
-    }
-    dapl_os_unlock ( &ep_ptr->header.lock );
-    dat_status =  dapls_ib_disconnect ( ep_ptr, disconnect_flags );
-
-bail:
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN | DAPL_DBG_TYPE_CM,
-                 "dapl_ep_disconnect (EP %p) returns 0x%x\n",
-                 ep_ptr, dat_status);
-
-    return dat_status;
-}
+       dapl_os_lock(&ep_ptr->header.lock);
+
+       /* Disconnecting a disconnected EP is a no-op. */
+       if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED ||
+           ep_ptr->param.ep_attr.service_type != DAT_SERVICE_TYPE_RC) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status = DAT_SUCCESS;
+               goto bail;
+       }
+
+       /* Check the EP state to ensure we are queiscent. Note that
+        * we may get called in UNCONNECTED state in order to remove
+        * RECV requests from the queue prior to destroying an EP.
+        * See the states in the spec at 6.5.1 Endpont Lifecycle
+        */
+       if (ep_ptr->param.ep_state != DAT_EP_STATE_CONNECTED &&
+           ep_ptr->param.ep_state != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING &&
+           ep_ptr->param.ep_state != DAT_EP_STATE_COMPLETION_PENDING &&
+           ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECT_PENDING) {
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_STATE,
+                             dapls_ep_state_subtype(ep_ptr));
+               goto bail;
+       }
+
+       if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING &&
+           disconnect_flags != DAT_CLOSE_ABRUPT_FLAG) {
+               /*
+                * If in state DISCONNECT_PENDING then this must be an
+                * ABRUPT disconnect
+                */
+               dapl_os_unlock(&ep_ptr->header.lock);
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+               goto bail;
+       }
+
+       if (ep_ptr->param.ep_state == DAT_EP_STATE_ACTIVE_CONNECTION_PENDING ||
+           ep_ptr->param.ep_state == DAT_EP_STATE_COMPLETION_PENDING) {
+               /*
+                * Beginning or waiting on a connection: abort and reset the
+                * state
+                */
+               ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+
+               dapl_os_unlock(&ep_ptr->header.lock);
+               /* disconnect and make sure we get no callbacks */
+               (void)dapls_ib_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
+
+               /* clean up connection state */
+               dapl_sp_remove_ep(ep_ptr);
+
+               evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
+               dapls_evd_post_connection_event(evd_ptr,
+                                               DAT_CONNECTION_EVENT_DISCONNECTED,
+                                               (DAT_HANDLE) ep_ptr, 0, 0);
+               dat_status = DAT_SUCCESS;
+               goto bail;
+       }
 
+       /*
+        * Transition the EP state to DISCONNECT_PENDING if we are
+        * CONNECTED. Otherwise we do not get a disconnect event and will be
+        * stuck in DISCONNECT_PENDING.
+        *
+        * If the user specifies a graceful disconnect, the underlying
+        * provider should complete all DTOs before disconnecting; in IB
+        * terms, this means setting the QP state to SQD before completing
+        * the disconnect state transitions.
+        */
+       if (ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED) {
+               ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECT_PENDING;
+       }
+       dapl_os_unlock(&ep_ptr->header.lock);
+       dat_status = dapls_ib_disconnect(ep_ptr, disconnect_flags);
+
+      bail:
+       dapl_dbg_log(DAPL_DBG_TYPE_RTN | DAPL_DBG_TYPE_CM,
+                    "dapl_ep_disconnect (EP %p) returns 0x%x\n",
+                    ep_ptr, dat_status);
+
+       return dat_status;
+}
 
 /*
  * Local variables:
index d853ddd..799cdb4 100644 (file)
  *     DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_ep_dup_connect (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_EP_HANDLE           ep_dup_handle,
-       IN      DAT_TIMEOUT             timeout,
-       IN      DAT_COUNT               private_data_size,
-       IN      const DAT_PVOID         private_data,
-       IN      DAT_QOS                 qos)
+dapl_ep_dup_connect(IN DAT_EP_HANDLE ep_handle,
+                   IN DAT_EP_HANDLE ep_dup_handle,
+                   IN DAT_TIMEOUT timeout,
+                   IN DAT_COUNT private_data_size,
+                   IN const DAT_PVOID private_data, IN DAT_QOS qos)
 {
-    DAPL_EP            *ep_dup_ptr;
-    DAT_RETURN         dat_status;
-    DAT_IA_ADDRESS_PTR remote_ia_address_ptr;
-    DAT_CONN_QUAL      remote_conn_qual;
+       DAPL_EP *ep_dup_ptr;
+       DAT_RETURN dat_status;
+       DAT_IA_ADDRESS_PTR remote_ia_address_ptr;
+       DAT_CONN_QUAL remote_conn_qual;
 
-    ep_dup_ptr = (DAPL_EP *) ep_dup_handle;
+       ep_dup_ptr = (DAPL_EP *) ep_dup_handle;
 
-    /*
-     * Verify the dup handle, which must be connected. All other
-     * parameters will be verified by dapl_ep_connect
-     */
-    if (  DAPL_BAD_HANDLE (ep_dup_handle, DAPL_MAGIC_EP ) )
-    {
-           dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EP);
-           goto bail;
-    }
+       /*
+        * Verify the dup handle, which must be connected. All other
+        * parameters will be verified by dapl_ep_connect
+        */
+       if (DAPL_BAD_HANDLE(ep_dup_handle, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
 
-    /* Can't do a connection in 0 time, reject outright */
-    if ( timeout == 0 )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-       goto bail;
-    }
+       /* Can't do a connection in 0 time, reject outright */
+       if (timeout == 0) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+               goto bail;
+       }
 
-    /* Check both the EP state and the QP state: if we don't have a QP
-     *  there is a problem.  Do this under a lock and pull out
-     * the connection parameters for atomicity.
-     */
-    dapl_os_lock ( &ep_dup_ptr->header.lock );
-    if ( ep_dup_ptr->param.ep_state != DAT_EP_STATE_CONNECTED )
-    {
-       dapl_os_unlock ( &ep_dup_ptr->header.lock );
-       dat_status = DAT_ERROR (DAT_INVALID_STATE,dapls_ep_state_subtype (ep_dup_ptr));
-       goto bail;
-    }
-    remote_ia_address_ptr = ep_dup_ptr->param.remote_ia_address_ptr;
-    remote_conn_qual = ep_dup_ptr->param.remote_port_qual;
-    dapl_os_unlock ( &ep_dup_ptr->header.lock );
+       /* Check both the EP state and the QP state: if we don't have a QP
+        *  there is a problem.  Do this under a lock and pull out
+        * the connection parameters for atomicity.
+        */
+       dapl_os_lock(&ep_dup_ptr->header.lock);
+       if (ep_dup_ptr->param.ep_state != DAT_EP_STATE_CONNECTED) {
+               dapl_os_unlock(&ep_dup_ptr->header.lock);
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_STATE,
+                             dapls_ep_state_subtype(ep_dup_ptr));
+               goto bail;
+       }
+       remote_ia_address_ptr = ep_dup_ptr->param.remote_ia_address_ptr;
+       remote_conn_qual = ep_dup_ptr->param.remote_port_qual;
+       dapl_os_unlock(&ep_dup_ptr->header.lock);
 
-    dat_status = dapl_ep_connect ( ep_handle,
-                                  remote_ia_address_ptr, 
-                                  remote_conn_qual, 
-                                  timeout,
-                                  private_data_size,
-                                  private_data,
-                                  qos,
-                                  DAT_CONNECT_DEFAULT_FLAG );
- bail:
-    return dat_status;
+       dat_status = dapl_ep_connect(ep_handle,
+                                    remote_ia_address_ptr,
+                                    remote_conn_qual,
+                                    timeout,
+                                    private_data_size,
+                                    private_data,
+                                    qos, DAT_CONNECT_DEFAULT_FLAG);
+      bail:
+       return dat_status;
 }
index 76b34f0..fd9fcc7 100644 (file)
  *     DAT_INVALID_PARAMETER
  *     DAT_INVALID_STATE
  */
-DAT_RETURN DAT_API
-dapl_ep_free (
-       IN      DAT_EP_HANDLE      ep_handle)
+DAT_RETURN DAT_API dapl_ep_free(IN DAT_EP_HANDLE ep_handle)
 {
-    DAPL_EP            *ep_ptr;
-    DAPL_IA            *ia_ptr;
-    DAT_EP_PARAM       *param;
-    ib_qp_state_t      save_qp_state;
-    DAT_RETURN         dat_status = DAT_SUCCESS;
-
-    dapl_dbg_log (DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
-                  "dapl_ep_free (%p)\n", ep_handle);
-
-    ep_ptr = (DAPL_EP *) ep_handle;
-    param = &ep_ptr->param;
-
-    /*
-     * Verify parameter & state
-     */
-    if ( DAPL_BAD_HANDLE (ep_ptr, DAPL_MAGIC_EP ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-    DAPL_CNTR(ep_ptr->header.owner_ia, DCNT_IA_EP_FREE);
-
-    if ( ep_ptr->param.ep_state == DAT_EP_STATE_RESERVED ||
-        ep_ptr->param.ep_state == DAT_EP_STATE_PASSIVE_CONNECTION_PENDING ||
-        ep_ptr->param.ep_state == DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING )
-    {
-       dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-                     "--> dapl_ep_free: invalid state: %x, ep %p\n",
-                     ep_ptr->param.ep_state,
-                     ep_ptr);
-       dat_status = DAT_ERROR (DAT_INVALID_STATE,
-                               dapls_ep_state_subtype (ep_ptr));
-       goto bail;
-    }
-
-    ia_ptr = ep_ptr->header.owner_ia;
-
-    /* If we are connected, issue a disconnect. If we are in the
-     * disconnect_pending state, disconnect with the ABRUPT flag
-     * set.
-     */
-
-    /*
-     * Invoke ep_disconnect to clean up outstanding connections
-     */
-    (void) dapl_ep_disconnect (ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
-
-    /*
-     * Do verification of parameters and the state change atomically.
-     */
-    dapl_os_lock ( &ep_ptr->header.lock );
+       DAPL_EP *ep_ptr;
+       DAPL_IA *ia_ptr;
+       DAT_EP_PARAM *param;
+       ib_qp_state_t save_qp_state;
+       DAT_RETURN dat_status = DAT_SUCCESS;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
+                    "dapl_ep_free (%p)\n", ep_handle);
+
+       ep_ptr = (DAPL_EP *) ep_handle;
+       param = &ep_ptr->param;
+
+       /*
+        * Verify parameter & state
+        */
+       if (DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
+       DAPL_CNTR(ep_ptr->header.owner_ia, DCNT_IA_EP_FREE);
+
+       if (ep_ptr->param.ep_state == DAT_EP_STATE_RESERVED ||
+           ep_ptr->param.ep_state == DAT_EP_STATE_PASSIVE_CONNECTION_PENDING ||
+           ep_ptr->param.ep_state == DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING)
+       {
+               dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+                            "--> dapl_ep_free: invalid state: %x, ep %p\n",
+                            ep_ptr->param.ep_state, ep_ptr);
+               dat_status = DAT_ERROR(DAT_INVALID_STATE,
+                                      dapls_ep_state_subtype(ep_ptr));
+               goto bail;
+       }
+
+       ia_ptr = ep_ptr->header.owner_ia;
+
+       /* If we are connected, issue a disconnect. If we are in the
+        * disconnect_pending state, disconnect with the ABRUPT flag
+        * set.
+        */
+
+       /*
+        * Invoke ep_disconnect to clean up outstanding connections
+        */
+       (void)dapl_ep_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
+
+       /*
+        * Do verification of parameters and the state change atomically.
+        */
+       dapl_os_lock(&ep_ptr->header.lock);
 
 #ifdef DAPL_DBG
-    /* check if event pending and warn, don't assert, state is valid */
-    if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING) {
-        dapl_dbg_log (DAPL_DBG_TYPE_WARN, " dat_ep_free WARNING: "
-                      "EVENT PENDING on ep %p, disconnect "
-                      "and wait before calling dat_ep_free\n",
-                      ep_ptr);
-    }
+       /* check if event pending and warn, don't assert, state is valid */
+       if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING) {
+               dapl_dbg_log(DAPL_DBG_TYPE_WARN, " dat_ep_free WARNING: "
+                            "EVENT PENDING on ep %p, disconnect "
+                            "and wait before calling dat_ep_free\n", ep_ptr);
+       }
 #endif
 
-    if (ep_ptr->cxn_timer != NULL)
-    {
-       dapls_timer_cancel ( ep_ptr->cxn_timer );
-       dapl_os_free ( ep_ptr->cxn_timer, sizeof ( DAPL_OS_TIMER ) );
-       ep_ptr->cxn_timer = NULL;
-    }
-
-    /* Remove the EP from the IA */
-    dapl_ia_unlink_ep ( ia_ptr, ep_ptr );
-
-    /*
-     * Update ref counts. Note the user may have used ep_modify
-     * to set handles to NULL. Set handles to NULL so this routine
-     * is idempotent.
-     */
-    if ( param->pz_handle != NULL )
-    {
-       dapl_os_atomic_dec (& ((DAPL_PZ *)param->pz_handle)->pz_ref_count);
-       param->pz_handle = NULL;
-    }
-    if ( param->recv_evd_handle != NULL )
-    {
-       dapl_os_atomic_dec (& ((DAPL_EVD *)param->recv_evd_handle)->evd_ref_count);
-       param->recv_evd_handle = NULL;
-    }
-    if ( param->request_evd_handle != NULL )
-    {
-       dapl_os_atomic_dec (& ((DAPL_EVD *)param->request_evd_handle)->evd_ref_count);
-       param->request_evd_handle = NULL;
-    }
-    if ( param->connect_evd_handle != NULL )
-    {
-       dapl_os_atomic_dec (& ((DAPL_EVD *)param->connect_evd_handle)->evd_ref_count);
-       param->connect_evd_handle = NULL;
-    }
-
-    /*
-     * Finish tearing everything down.
-     */
-    dapl_dbg_log (DAPL_DBG_TYPE_EP | DAPL_DBG_TYPE_CM,
-                 "dapl_ep_free: Free EP: %x, ep %p qp_state %x qp_handle %x\n",
-                 ep_ptr->param.ep_state,
-                 ep_ptr,
-                 ep_ptr->qp_state,
-                 ep_ptr->qp_handle);
-    /*
-     * Take care of the transport resource. Make a copy of the qp_state
-     * to prevent race conditions when we exit the lock.
-     */
-    save_qp_state     = ep_ptr->qp_state;
-    ep_ptr->qp_state  = DAPL_QP_STATE_UNATTACHED;
-    dapl_os_unlock (&ep_ptr->header.lock);
-
-    /* Free the QP. If the EP has never been used, the QP is invalid */
-    if ( save_qp_state != DAPL_QP_STATE_UNATTACHED )
-    {
-       dat_status = dapls_ib_qp_free (ia_ptr, ep_ptr);
-       /* This should always succeed, but report to the user if
-        * there is a problem. The qp_state must be restored so
-        * they can try it again in the face of EINTR or similar
-        * where the QP is OK but the call couldn't complete.
+       if (ep_ptr->cxn_timer != NULL) {
+               dapls_timer_cancel(ep_ptr->cxn_timer);
+               dapl_os_free(ep_ptr->cxn_timer, sizeof(DAPL_OS_TIMER));
+               ep_ptr->cxn_timer = NULL;
+       }
+
+       /* Remove the EP from the IA */
+       dapl_ia_unlink_ep(ia_ptr, ep_ptr);
+
+       /*
+        * Update ref counts. Note the user may have used ep_modify
+        * to set handles to NULL. Set handles to NULL so this routine
+        * is idempotent.
         */
-       if (dat_status != DAT_SUCCESS)
-       {
-           ep_ptr->qp_state = save_qp_state;
-           goto bail;
+       if (param->pz_handle != NULL) {
+               dapl_os_atomic_dec(&((DAPL_PZ *) param->pz_handle)->
+                                  pz_ref_count);
+               param->pz_handle = NULL;
+       }
+       if (param->recv_evd_handle != NULL) {
+               dapl_os_atomic_dec(&((DAPL_EVD *) param->recv_evd_handle)->
+                                  evd_ref_count);
+               param->recv_evd_handle = NULL;
+       }
+       if (param->request_evd_handle != NULL) {
+               dapl_os_atomic_dec(&((DAPL_EVD *) param->request_evd_handle)->
+                                  evd_ref_count);
+               param->request_evd_handle = NULL;
+       }
+       if (param->connect_evd_handle != NULL) {
+               dapl_os_atomic_dec(&((DAPL_EVD *) param->connect_evd_handle)->
+                                  evd_ref_count);
+               param->connect_evd_handle = NULL;
+       }
+
+       /*
+        * Finish tearing everything down.
+        */
+       dapl_dbg_log(DAPL_DBG_TYPE_EP | DAPL_DBG_TYPE_CM,
+                    "dapl_ep_free: Free EP: %x, ep %p qp_state %x qp_handle %x\n",
+                    ep_ptr->param.ep_state,
+                    ep_ptr, ep_ptr->qp_state, ep_ptr->qp_handle);
+       /*
+        * Take care of the transport resource. Make a copy of the qp_state
+        * to prevent race conditions when we exit the lock.
+        */
+       save_qp_state = ep_ptr->qp_state;
+       ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
+       dapl_os_unlock(&ep_ptr->header.lock);
+
+       /* Free the QP. If the EP has never been used, the QP is invalid */
+       if (save_qp_state != DAPL_QP_STATE_UNATTACHED) {
+               dat_status = dapls_ib_qp_free(ia_ptr, ep_ptr);
+               /* This should always succeed, but report to the user if
+                * there is a problem. The qp_state must be restored so
+                * they can try it again in the face of EINTR or similar
+                * where the QP is OK but the call couldn't complete.
+                */
+               if (dat_status != DAT_SUCCESS) {
+                       ep_ptr->qp_state = save_qp_state;
+                       goto bail;
+               }
        }
-    }
 
-    /* Free the resource */
-    dapl_ep_dealloc (ep_ptr);
+       /* Free the resource */
+       dapl_ep_dealloc(ep_ptr);
 
-bail:
-    return dat_status;
+      bail:
+       return dat_status;
 
 }
 
index 3f856d3..6880f6f 100644 (file)
  *     DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_ep_get_status (
-       IN      DAT_EP_HANDLE      ep_handle,
-       OUT     DAT_EP_STATE       *ep_state,
-       OUT     DAT_BOOLEAN        *in_dto_idle,
-       OUT     DAT_BOOLEAN        *out_dto_idle)
+dapl_ep_get_status(IN DAT_EP_HANDLE ep_handle,
+                  OUT DAT_EP_STATE * ep_state,
+                  OUT DAT_BOOLEAN * in_dto_idle,
+                  OUT DAT_BOOLEAN * out_dto_idle)
 {
-    DAPL_EP            *ep_ptr;
-    DAT_RETURN         dat_status;
+       DAPL_EP *ep_ptr;
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_get_status (%p, %p, %p, %p)\n",
-                 ep_handle, 
-                 ep_state, 
-                 in_dto_idle, 
-                 out_dto_idle);
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_get_status (%p, %p, %p, %p)\n",
+                    ep_handle, ep_state, in_dto_idle, out_dto_idle);
 
-    ep_ptr = (DAPL_EP *) ep_handle;
-    dat_status = DAT_SUCCESS;
+       ep_ptr = (DAPL_EP *) ep_handle;
+       dat_status = DAT_SUCCESS;
 
-    /*
-     * Verify parameter & state
-     */
-    if ( DAPL_BAD_HANDLE (ep_ptr, DAPL_MAGIC_EP ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
+       /*
+        * Verify parameter & state
+        */
+       if (DAPL_BAD_HANDLE(ep_ptr, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
 
-    /*
-     * Gather state info for user
-     */
-    if ( ep_state != NULL )
-    {
-       *ep_state = ep_ptr->param.ep_state;
-    }
+       /*
+        * Gather state info for user
+        */
+       if (ep_state != NULL) {
+               *ep_state = ep_ptr->param.ep_state;
+       }
 
-    if ( in_dto_idle != NULL )
-    {
-       *in_dto_idle = dapls_cb_pending(&ep_ptr->recv_buffer);
-    }
+       if (in_dto_idle != NULL) {
+               *in_dto_idle = dapls_cb_pending(&ep_ptr->recv_buffer);
+       }
 
-    if ( out_dto_idle != NULL )
-    {
-       *out_dto_idle = dapls_cb_pending(&ep_ptr->req_buffer);
-    }
+       if (out_dto_idle != NULL) {
+               *out_dto_idle = dapls_cb_pending(&ep_ptr->req_buffer);
+       }
 
- bail:
-    return dat_status;
     bail:
+       return dat_status;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4
index fff21a0..9f0095f 100644 (file)
  */
 
 static _INLINE_ DAT_RETURN
-dapli_ep_modify_validate_parameters (
-    IN         DAT_EP_HANDLE                   ep_handle,
-    IN         DAT_EP_PARAM_MASK               ep_param_mask,
-    IN         const DAT_EP_PARAM              *ep_param,
-    OUT DAPL_IA                                **ia_ptr,
-    OUT DAPL_EP                                **ep_ptr,
-    OUT DAT_EP_ATTR                    *ep_attr_ptr );
-
+dapli_ep_modify_validate_parameters(IN DAT_EP_HANDLE ep_handle,
+                                   IN DAT_EP_PARAM_MASK ep_param_mask,
+                                   IN const DAT_EP_PARAM * ep_param,
+                                   OUT DAPL_IA ** ia_ptr,
+                                   OUT DAPL_EP ** ep_ptr,
+                                   OUT DAT_EP_ATTR * ep_attr_ptr);
 
 /*
  * dapl_ep_modify
@@ -77,320 +75,279 @@ dapli_ep_modify_validate_parameters (
  *     DAT_INVALID_STATE
  */
 DAT_RETURN DAT_API
-dapl_ep_modify (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_EP_PARAM_MASK       ep_param_mask,
-       IN      const DAT_EP_PARAM      *ep_param )
+dapl_ep_modify(IN DAT_EP_HANDLE ep_handle,
+              IN DAT_EP_PARAM_MASK ep_param_mask,
+              IN const DAT_EP_PARAM * ep_param)
 {
-    DAPL_IA                            *ia;
-    DAPL_EP                            *ep1, *ep2;
-    DAT_EP_ATTR                                ep_attr1 = {0}, ep_attr2 = {0};
-    DAPL_EP                            new_ep, copy_of_old_ep;
-    DAPL_EP                            alloc_ep; /* Holder for resources.  */
-    DAPL_PZ                            *tmp_pz;
-    DAPL_EVD                           *tmp_evd;
-    DAT_RETURN                         dat_status;
-
-    /* Flag indicating we've allocated a new one of these.  */
-    DAT_BOOLEAN                                qp_allocated = DAT_FALSE;
-    DAT_BOOLEAN                                rqst_cb_allocated = DAT_FALSE;
-    DAT_BOOLEAN                                recv_cb_allocated = DAT_FALSE;
-
-    /* Flag indicating we've used (assigned to QP) a new one of these.  */
-    DAT_BOOLEAN                                qp_used = DAT_FALSE;
-    DAT_BOOLEAN                                rqst_cb_used = DAT_FALSE;
-    DAT_BOOLEAN                                recv_cb_used = DAT_FALSE;
-
-    dat_status = dapli_ep_modify_validate_parameters ( ep_handle,
-                                                     ep_param_mask,
-                                                     ep_param,
-                                                     &ia,
-                                                     &ep1,
-                                                     &ep_attr1);
-    if ( DAT_SUCCESS != dat_status)
-    {
-       goto bail;
-    }
-
-    /*
-     * Setup the alloc_ep with the appropriate parameters (primarily
-     * for allocating the QP.
-     */
-    alloc_ep = *ep1;
-    alloc_ep.param.ep_attr = ep_attr1;
-    if ( ep_param_mask & DAT_EP_FIELD_PZ_HANDLE )
-    {
-       alloc_ep.param.pz_handle = ep_param->pz_handle;
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_RECV_EVD_HANDLE )
-    {
-       alloc_ep.param.recv_evd_handle = ep_param->recv_evd_handle;
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_REQUEST_EVD_HANDLE )
-    {
-       alloc_ep.param.request_evd_handle = ep_param->request_evd_handle;
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_CONNECT_EVD_HANDLE )
-    {
-       alloc_ep.param.connect_evd_handle = ep_param->connect_evd_handle;
-    }
-
-    /*
-     * Allocate everything that might be needed.
-     * We allocate separately, and into a different "holding"
-     * ep, since we a) want the copy of the old ep into the new ep to
-     * be atomic with the assignment back (under lock), b) want the
-     * assignment of the allocated materials to be after the copy of the
-     * old ep into the new ep, and c) don't want the allocation done
-     * under lock.
-     */
-    dat_status = dapls_cb_create (
-       &alloc_ep.req_buffer,
-       ep1,                    /* For pointer in buffer bool.  */
-       ep_attr1.max_request_dtos );
-    if ( DAT_SUCCESS != dat_status )
-    {
-       goto bail;
-    }
-    rqst_cb_allocated = DAT_TRUE;
-
-    dat_status = dapls_cb_create (
-       &alloc_ep.recv_buffer,
-       ep1,                    /* For pointer in buffer bool.  */
-       ep_attr1.max_recv_dtos );
-    if ( DAT_SUCCESS != dat_status )
-    {
-       goto bail;
-    }
-    recv_cb_allocated = DAT_TRUE;
-
-    dat_status = dapls_ib_qp_alloc ( ia, &alloc_ep, ep1 );
-    if ( dat_status != DAT_SUCCESS )
-    {
-       goto bail;
-    }
-    qp_allocated = DAT_TRUE;
-
-    /*
-     * Now we atomically modify the EP, under lock
-     * There's a lot of work done here, but there should be no
-     * allocation or blocking.
-     */
-    dapl_os_lock ( &ep1->header.lock );
-
-    /*
-     * Revalidate parameters; make sure that races haven't
-     * changed anything important.
-     */
-    dat_status = dapli_ep_modify_validate_parameters ( ep_handle,
-                                                      ep_param_mask,
-                                                      ep_param,
-                                                      &ia,
-                                                      &ep2,
-                                                      &ep_attr2 );
-    if ( DAT_SUCCESS != dat_status )
-    {
-       dapl_os_unlock ( &ep2->header.lock );
-       goto bail;
-    }
-
-    /*
-     * All of the following should be impossible, if validation
-     * occurred.  But they're important to the logic of this routine,
-     * so we check.
-     */
-    dapl_os_assert ( ep1 == ep2 );
-    dapl_os_assert ( ep_attr2.max_recv_dtos == ep_attr1.max_recv_dtos );
-    dapl_os_assert ( ep_attr2.max_request_dtos == ep_attr1.max_request_dtos );
-    dapl_os_assert ( ep_attr2.max_recv_iov == ep_attr1.max_recv_iov );
-    dapl_os_assert ( ep_attr2.max_request_iov == ep_attr1.max_request_iov );
-
-    copy_of_old_ep = *ep2;
-
-    /*
-     * Setup new ep.
-     */
-    new_ep = *ep2;
-    new_ep.param.ep_attr = ep_attr2;
-
-    /*
-     * We can initialize the PZ and EVD handles from the alloc_ep because
-     * the only thing that could have changed since we setup the alloc_ep
-     * is stuff changed by dapl_cr_accept, and neither PZ nor EVD is in that
-     * list.
-     */
-    new_ep.param.pz_handle = alloc_ep.param.pz_handle;
-    new_ep.param.recv_evd_handle = alloc_ep.param.recv_evd_handle;
-    new_ep.param.request_evd_handle = alloc_ep.param.request_evd_handle;
-    new_ep.param.connect_evd_handle = alloc_ep.param.connect_evd_handle;
-
-    /* Deal with each of the allocation fields.  */
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS
-        && (ep_param->ep_attr.max_recv_dtos
-            != ep2->param.ep_attr.max_recv_dtos) )
-    {
-       new_ep.recv_buffer = alloc_ep.recv_buffer;
-       recv_cb_used = DAT_TRUE;
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS
-        && (ep_param->ep_attr.max_request_dtos
-            != ep2->param.ep_attr.max_request_dtos) )
-    {
-       new_ep.req_buffer = alloc_ep.req_buffer;
-       rqst_cb_used = DAT_TRUE;
-    }
-
-    /*
-     * We need to change the QP only if there already was a QP
-     * (leave things the way you found them!) and one of the
-     * following has changed: send/recv EVD, send/recv reqs/IOV max.
-     */
-    if ( DAPL_QP_STATE_UNATTACHED != new_ep.qp_state
-        && (ep_param_mask
-            & (DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV
-               | DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV
-               | DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS
-               | DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS
-               | DAT_EP_FIELD_RECV_EVD_HANDLE
-               | DAT_EP_FIELD_REQUEST_EVD_HANDLE)) )
-    {
+       DAPL_IA *ia;
+       DAPL_EP *ep1, *ep2;
+       DAT_EP_ATTR ep_attr1 = { 0 }, ep_attr2 = {
+       0};
+       DAPL_EP new_ep, copy_of_old_ep;
+       DAPL_EP alloc_ep;       /* Holder for resources.  */
+       DAPL_PZ *tmp_pz;
+       DAPL_EVD *tmp_evd;
+       DAT_RETURN dat_status;
+
+       /* Flag indicating we've allocated a new one of these.  */
+       DAT_BOOLEAN qp_allocated = DAT_FALSE;
+       DAT_BOOLEAN rqst_cb_allocated = DAT_FALSE;
+       DAT_BOOLEAN recv_cb_allocated = DAT_FALSE;
+
+       /* Flag indicating we've used (assigned to QP) a new one of these.  */
+       DAT_BOOLEAN qp_used = DAT_FALSE;
+       DAT_BOOLEAN rqst_cb_used = DAT_FALSE;
+       DAT_BOOLEAN recv_cb_used = DAT_FALSE;
+
+       dat_status = dapli_ep_modify_validate_parameters(ep_handle,
+                                                        ep_param_mask,
+                                                        ep_param,
+                                                        &ia, &ep1, &ep_attr1);
+       if (DAT_SUCCESS != dat_status) {
+               goto bail;
+       }
+
        /*
-        * We shouldn't be racing with connection establishment
-        * because the parameter validate routine should protect us,
-        * but it's an important enough point that we assert it.
+        * Setup the alloc_ep with the appropriate parameters (primarily
+        * for allocating the QP.
         */
-       dapl_os_assert ( (ep2->param.ep_state
-                         != DAT_EP_STATE_PASSIVE_CONNECTION_PENDING)
-                        && (ep2->param.ep_state
-                            != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING) );
-
-       new_ep.qp_handle = alloc_ep.qp_handle;
-       new_ep.qpn = alloc_ep.qpn;
-    }
-
-    /*
-     * The actual assignment, including modifying QP parameters.
-     * Modifying QP parameters needs to come first, as if it fails
-     * we need to exit. 
-     */
-    if ( DAPL_QP_STATE_UNATTACHED != new_ep.qp_state )
-    {
-       dat_status = dapls_ib_qp_modify ( ia, ep2, &ep_attr2 );
-       if ( dat_status != DAT_SUCCESS )
-       {
-           dapl_os_unlock ( & ep2->header.lock );
-           goto bail;
-       }
-    }
-    *ep2 = new_ep;
-
-    dapl_os_unlock ( &ep2->header.lock );
-
-    /*
-     * Modify reference counts, incrementing new ones
-     * and then decrementing old ones (so if they're the same
-     * the refcount never drops to zero).
-     */
-    tmp_pz = (DAPL_PZ *) new_ep.param.pz_handle;
-    if ( NULL != tmp_pz )
-    {
-       dapl_os_atomic_inc (&tmp_pz->pz_ref_count);
-    }
-
-    tmp_evd = (DAPL_EVD *) new_ep.param.recv_evd_handle;
-    if ( NULL != tmp_evd )
-    {
-       dapl_os_atomic_inc (&tmp_evd->evd_ref_count);
-    }
-
-    tmp_evd = (DAPL_EVD *) new_ep.param.request_evd_handle;
-    if ( NULL != tmp_evd )
-    {
-       dapl_os_atomic_inc (&tmp_evd->evd_ref_count);
-    }
-
-    tmp_evd = (DAPL_EVD *) new_ep.param.connect_evd_handle;
-    if ( NULL != tmp_evd )
-    {
-       dapl_os_atomic_inc (&tmp_evd->evd_ref_count);
-    }
-
-    /* decreament the old reference counts */
-    tmp_pz = (DAPL_PZ *) copy_of_old_ep.param.pz_handle;
-    if ( NULL != tmp_pz )
-    {
-       dapl_os_atomic_dec (&tmp_pz->pz_ref_count);
-    }
-
-    tmp_evd = (DAPL_EVD *) copy_of_old_ep.param.recv_evd_handle;
-    if ( NULL != tmp_evd )
-    {
-       dapl_os_atomic_dec (&tmp_evd->evd_ref_count);
-    }
-
-    tmp_evd = (DAPL_EVD *) copy_of_old_ep.param.request_evd_handle;
-    if ( NULL != tmp_evd )
-    {
-       dapl_os_atomic_dec (&tmp_evd->evd_ref_count);
-    }
-
-    tmp_evd = (DAPL_EVD *) copy_of_old_ep.param.connect_evd_handle;
-    if ( NULL != tmp_evd )
-    {
-       dapl_os_atomic_dec (&tmp_evd->evd_ref_count);
-    }
-
-bail:
-    if ( qp_allocated )
-    {
-       DAT_RETURN local_dat_status;
-       if ( dat_status != DAT_SUCCESS || !qp_used )
-       {
-           local_dat_status = dapls_ib_qp_free (ia, &alloc_ep );
-       }
-       else
-       {
-           local_dat_status = dapls_ib_qp_free (ia, &copy_of_old_ep );
-       }
-       if (local_dat_status != DAT_SUCCESS)
-       {
-           dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-                         "ep_modify: Failed to free QP; status %x\n",
-                         local_dat_status);
-       }
-    }
-
-    if ( rqst_cb_allocated )
-    {
-       if ( dat_status != DAT_SUCCESS || !rqst_cb_used )
-       {
-           dapls_cb_free ( &alloc_ep.req_buffer );
-       }
-       else
-       {
-           dapls_cb_free ( &copy_of_old_ep.req_buffer );
-       }
-    }
-
-    if ( recv_cb_allocated )
-    {
-       if ( dat_status != DAT_SUCCESS || !recv_cb_used )
-       {
-           dapls_cb_free ( &alloc_ep.recv_buffer );
-       }
-       else
-       {
-           dapls_cb_free ( &copy_of_old_ep.recv_buffer );
-       }
-    }
-
-    return dat_status;
-}
+       alloc_ep = *ep1;
+       alloc_ep.param.ep_attr = ep_attr1;
+       if (ep_param_mask & DAT_EP_FIELD_PZ_HANDLE) {
+               alloc_ep.param.pz_handle = ep_param->pz_handle;
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_RECV_EVD_HANDLE) {
+               alloc_ep.param.recv_evd_handle = ep_param->recv_evd_handle;
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_REQUEST_EVD_HANDLE) {
+               alloc_ep.param.request_evd_handle =
+                   ep_param->request_evd_handle;
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_CONNECT_EVD_HANDLE) {
+               alloc_ep.param.connect_evd_handle =
+                   ep_param->connect_evd_handle;
+       }
+
+       /*
+        * Allocate everything that might be needed.
+        * We allocate separately, and into a different "holding"
+        * ep, since we a) want the copy of the old ep into the new ep to
+        * be atomic with the assignment back (under lock), b) want the
+        * assignment of the allocated materials to be after the copy of the
+        * old ep into the new ep, and c) don't want the allocation done
+        * under lock.
+        */
+       dat_status = dapls_cb_create(&alloc_ep.req_buffer, ep1, /* For pointer in buffer bool.  */
+                                    ep_attr1.max_request_dtos);
+       if (DAT_SUCCESS != dat_status) {
+               goto bail;
+       }
+       rqst_cb_allocated = DAT_TRUE;
+
+       dat_status = dapls_cb_create(&alloc_ep.recv_buffer, ep1,        /* For pointer in buffer bool.  */
+                                    ep_attr1.max_recv_dtos);
+       if (DAT_SUCCESS != dat_status) {
+               goto bail;
+       }
+       recv_cb_allocated = DAT_TRUE;
+
+       dat_status = dapls_ib_qp_alloc(ia, &alloc_ep, ep1);
+       if (dat_status != DAT_SUCCESS) {
+               goto bail;
+       }
+       qp_allocated = DAT_TRUE;
+
+       /*
+        * Now we atomically modify the EP, under lock
+        * There's a lot of work done here, but there should be no
+        * allocation or blocking.
+        */
+       dapl_os_lock(&ep1->header.lock);
+
+       /*
+        * Revalidate parameters; make sure that races haven't
+        * changed anything important.
+        */
+       dat_status = dapli_ep_modify_validate_parameters(ep_handle,
+                                                        ep_param_mask,
+                                                        ep_param,
+                                                        &ia, &ep2, &ep_attr2);
+       if (DAT_SUCCESS != dat_status) {
+               dapl_os_unlock(&ep2->header.lock);
+               goto bail;
+       }
+
+       /*
+        * All of the following should be impossible, if validation
+        * occurred.  But they're important to the logic of this routine,
+        * so we check.
+        */
+       dapl_os_assert(ep1 == ep2);
+       dapl_os_assert(ep_attr2.max_recv_dtos == ep_attr1.max_recv_dtos);
+       dapl_os_assert(ep_attr2.max_request_dtos == ep_attr1.max_request_dtos);
+       dapl_os_assert(ep_attr2.max_recv_iov == ep_attr1.max_recv_iov);
+       dapl_os_assert(ep_attr2.max_request_iov == ep_attr1.max_request_iov);
+
+       copy_of_old_ep = *ep2;
+
+       /*
+        * Setup new ep.
+        */
+       new_ep = *ep2;
+       new_ep.param.ep_attr = ep_attr2;
+
+       /*
+        * We can initialize the PZ and EVD handles from the alloc_ep because
+        * the only thing that could have changed since we setup the alloc_ep
+        * is stuff changed by dapl_cr_accept, and neither PZ nor EVD is in that
+        * list.
+        */
+       new_ep.param.pz_handle = alloc_ep.param.pz_handle;
+       new_ep.param.recv_evd_handle = alloc_ep.param.recv_evd_handle;
+       new_ep.param.request_evd_handle = alloc_ep.param.request_evd_handle;
+       new_ep.param.connect_evd_handle = alloc_ep.param.connect_evd_handle;
+
+       /* Deal with each of the allocation fields.  */
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS
+           && (ep_param->ep_attr.max_recv_dtos
+               != ep2->param.ep_attr.max_recv_dtos)) {
+               new_ep.recv_buffer = alloc_ep.recv_buffer;
+               recv_cb_used = DAT_TRUE;
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS
+           && (ep_param->ep_attr.max_request_dtos
+               != ep2->param.ep_attr.max_request_dtos)) {
+               new_ep.req_buffer = alloc_ep.req_buffer;
+               rqst_cb_used = DAT_TRUE;
+       }
+
+       /*
+        * We need to change the QP only if there already was a QP
+        * (leave things the way you found them!) and one of the
+        * following has changed: send/recv EVD, send/recv reqs/IOV max.
+        */
+       if (DAPL_QP_STATE_UNATTACHED != new_ep.qp_state
+           && (ep_param_mask
+               & (DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV
+                  | DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV
+                  | DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS
+                  | DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS
+                  | DAT_EP_FIELD_RECV_EVD_HANDLE
+                  | DAT_EP_FIELD_REQUEST_EVD_HANDLE))) {
+               /*
+                * We shouldn't be racing with connection establishment
+                * because the parameter validate routine should protect us,
+                * but it's an important enough point that we assert it.
+                */
+               dapl_os_assert((ep2->param.ep_state
+                               != DAT_EP_STATE_PASSIVE_CONNECTION_PENDING)
+                              && (ep2->param.ep_state
+                                  != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING));
+
+               new_ep.qp_handle = alloc_ep.qp_handle;
+               new_ep.qpn = alloc_ep.qpn;
+       }
+
+       /*
+        * The actual assignment, including modifying QP parameters.
+        * Modifying QP parameters needs to come first, as if it fails
+        * we need to exit. 
+        */
+       if (DAPL_QP_STATE_UNATTACHED != new_ep.qp_state) {
+               dat_status = dapls_ib_qp_modify(ia, ep2, &ep_attr2);
+               if (dat_status != DAT_SUCCESS) {
+                       dapl_os_unlock(&ep2->header.lock);
+                       goto bail;
+               }
+       }
+       *ep2 = new_ep;
+
+       dapl_os_unlock(&ep2->header.lock);
 
+       /*
+        * Modify reference counts, incrementing new ones
+        * and then decrementing old ones (so if they're the same
+        * the refcount never drops to zero).
+        */
+       tmp_pz = (DAPL_PZ *) new_ep.param.pz_handle;
+       if (NULL != tmp_pz) {
+               dapl_os_atomic_inc(&tmp_pz->pz_ref_count);
+       }
+
+       tmp_evd = (DAPL_EVD *) new_ep.param.recv_evd_handle;
+       if (NULL != tmp_evd) {
+               dapl_os_atomic_inc(&tmp_evd->evd_ref_count);
+       }
+
+       tmp_evd = (DAPL_EVD *) new_ep.param.request_evd_handle;
+       if (NULL != tmp_evd) {
+               dapl_os_atomic_inc(&tmp_evd->evd_ref_count);
+       }
+
+       tmp_evd = (DAPL_EVD *) new_ep.param.connect_evd_handle;
+       if (NULL != tmp_evd) {
+               dapl_os_atomic_inc(&tmp_evd->evd_ref_count);
+       }
+
+       /* decreament the old reference counts */
+       tmp_pz = (DAPL_PZ *) copy_of_old_ep.param.pz_handle;
+       if (NULL != tmp_pz) {
+               dapl_os_atomic_dec(&tmp_pz->pz_ref_count);
+       }
+
+       tmp_evd = (DAPL_EVD *) copy_of_old_ep.param.recv_evd_handle;
+       if (NULL != tmp_evd) {
+               dapl_os_atomic_dec(&tmp_evd->evd_ref_count);
+       }
+
+       tmp_evd = (DAPL_EVD *) copy_of_old_ep.param.request_evd_handle;
+       if (NULL != tmp_evd) {
+               dapl_os_atomic_dec(&tmp_evd->evd_ref_count);
+       }
+
+       tmp_evd = (DAPL_EVD *) copy_of_old_ep.param.connect_evd_handle;
+       if (NULL != tmp_evd) {
+               dapl_os_atomic_dec(&tmp_evd->evd_ref_count);
+       }
+
+      bail:
+       if (qp_allocated) {
+               DAT_RETURN local_dat_status;
+               if (dat_status != DAT_SUCCESS || !qp_used) {
+                       local_dat_status = dapls_ib_qp_free(ia, &alloc_ep);
+               } else {
+                       local_dat_status =
+                           dapls_ib_qp_free(ia, &copy_of_old_ep);
+               }
+               if (local_dat_status != DAT_SUCCESS) {
+                       dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+                                    "ep_modify: Failed to free QP; status %x\n",
+                                    local_dat_status);
+               }
+       }
+
+       if (rqst_cb_allocated) {
+               if (dat_status != DAT_SUCCESS || !rqst_cb_used) {
+                       dapls_cb_free(&alloc_ep.req_buffer);
+               } else {
+                       dapls_cb_free(&copy_of_old_ep.req_buffer);
+               }
+       }
+
+       if (recv_cb_allocated) {
+               if (dat_status != DAT_SUCCESS || !recv_cb_used) {
+                       dapls_cb_free(&alloc_ep.recv_buffer);
+               } else {
+                       dapls_cb_free(&copy_of_old_ep.recv_buffer);
+               }
+       }
+
+       return dat_status;
+}
 
 /*
  * dapli_ep_modify_validate_parameters
@@ -404,301 +361,277 @@ bail:
  */
 
 static DAT_RETURN
-dapli_ep_modify_validate_parameters (
-    IN         DAT_EP_HANDLE                   ep_handle,
-    IN         DAT_EP_PARAM_MASK               ep_param_mask,
-    IN         const DAT_EP_PARAM              *ep_param,
-    OUT DAPL_IA                                **ia_ptr,
-    OUT DAPL_EP                                **ep_ptr,
-    OUT DAT_EP_ATTR                    *ep_attr_ptr )
+dapli_ep_modify_validate_parameters(IN DAT_EP_HANDLE ep_handle,
+                                   IN DAT_EP_PARAM_MASK ep_param_mask,
+                                   IN const DAT_EP_PARAM * ep_param,
+                                   OUT DAPL_IA ** ia_ptr,
+                                   OUT DAPL_EP ** ep_ptr,
+                                   OUT DAT_EP_ATTR * ep_attr_ptr)
 {
-    DAPL_IA                            *ia;
-    DAPL_EP                            *ep;
-    DAT_EP_ATTR                                ep_attr;
-    DAT_EP_ATTR                                ep_attr_limit;
-    DAT_EP_ATTR                                ep_attr_request;
-    DAT_RETURN                         dat_status;
-
-    *ia_ptr = NULL;
-    *ep_ptr = NULL;
-    dat_status = DAT_SUCCESS;
-
-    if ( DAPL_BAD_HANDLE (ep_handle, DAPL_MAGIC_EP ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
-
-    ep = (DAPL_EP *) ep_handle;
-    ia = ep->header.owner_ia;
-
-    /*
-     * Verify parameters valid in current EP state
-     */
-    if ( ep_param_mask & (DAT_EP_FIELD_IA_HANDLE |
-                          DAT_EP_FIELD_EP_STATE |
-                          DAT_EP_FIELD_LOCAL_IA_ADDRESS_PTR |
-                          DAT_EP_FIELD_LOCAL_PORT_QUAL |
-                          DAT_EP_FIELD_REMOTE_IA_ADDRESS_PTR |
-                          DAT_EP_FIELD_REMOTE_PORT_QUAL) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-       goto bail;
-    }
-
-    /*
-     * Can only change the PZ handle if we are UNCONNECTED or
-     * TENTATIVE_CONNECTION_PENDING (psp PROVIDER allocated EP)
-     */
-    if ( (ep_param_mask & DAT_EP_FIELD_PZ_HANDLE)  &&
-        ( ep->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
-          ep->param.ep_state != DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep));
-       goto bail;
-    }
-
-    if ( (ep_param_mask & (DAT_EP_FIELD_RECV_EVD_HANDLE |
-                         DAT_EP_FIELD_REQUEST_EVD_HANDLE |
-                         DAT_EP_FIELD_CONNECT_EVD_HANDLE |
-                         DAT_EP_FIELD_EP_ATTR_SERVICE_TYPE |
-                         DAT_EP_FIELD_EP_ATTR_MAX_MESSAGE_SIZE |
-                         DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE |
-                         DAT_EP_FIELD_EP_ATTR_QOS |
-                         DAT_EP_FIELD_EP_ATTR_REQUEST_COMPLETION_FLAGS |
-                         DAT_EP_FIELD_EP_ATTR_RECV_COMPLETION_FLAGS |
-                         DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS |
-                         DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS |
-                         DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV |
-                         DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV )) &&
-         ( ep->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
-           ep->param.ep_state != DAT_EP_STATE_RESERVED &&
-           ep->param.ep_state != DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING ) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep));
-       goto bail;
-    }
-
-    /*
-     * Validate handles being modified
-     */
-    if ( ep_param_mask & DAT_EP_FIELD_PZ_HANDLE )
-    {
-       if (ep_param->pz_handle != NULL &&
-           DAPL_BAD_HANDLE (ep_param->pz_handle, DAPL_MAGIC_PZ) )
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_RECV_EVD_HANDLE )
-    {
-       if (ep_param->recv_evd_handle != NULL &&
-           (DAPL_BAD_HANDLE (ep_param->recv_evd_handle, DAPL_MAGIC_EVD) ||
-            ! ((DAPL_EVD *)ep_param->recv_evd_handle)->evd_flags & DAT_EVD_DTO_FLAG))
-
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_REQUEST_EVD_HANDLE )
-    {
-       if (ep_param->request_evd_handle != NULL &&
-           DAPL_BAD_HANDLE (ep_param->request_evd_handle, DAPL_MAGIC_EVD))
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_CONNECT_EVD_HANDLE )
-    {
-       if (ep_param->connect_evd_handle != NULL &&
-           DAPL_BAD_HANDLE (ep_param->connect_evd_handle, DAPL_MAGIC_EVD) &&
-           ! (((DAPL_EVD *)ep_param->connect_evd_handle)->evd_flags & DAT_EVD_CONNECTION_FLAG) )
-
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-    }
-
-    /*
-     * Validate the attributes against the HCA limits
-     */
-    ep_attr = ep->param.ep_attr;
-
-    dapl_os_memzero (&ep_attr_limit, sizeof (DAT_EP_ATTR));
-    dat_status = dapls_ib_query_hca (ia->hca_ptr, NULL, &ep_attr_limit, NULL);
-    if ( dat_status != DAT_SUCCESS )
-    {
-       goto bail;
-    }
-
-    ep_attr_request = ep_param->ep_attr;
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_SERVICE_TYPE )
-    {
-       if ( ep_attr_request.service_type != DAT_SERVICE_TYPE_RC )
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_MESSAGE_SIZE )
-    {
-       if ( ep_attr_request.max_mtu_size > ep_attr_limit.max_mtu_size)
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_mtu_size = ep_attr_request.max_mtu_size;
-       }
-    }
-
-    /* Do nothing if the DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE flag is   */
-    /* set. Each RDMA transport/provider may or may not have a limit  */
-    /* on the size of an RDMA DTO. For InfiniBand, this parameter is  */
-    /* validated in the implementation of the dapls_ib_qp_modify()    */
-    /* function.                                                      */
-    /*                                                                */
-    /*         if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE ) */
-    /*         {                                                         */
-    /*                                                                */
-    /*         }                                                         */
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_QOS )
-    {
-       /* Do nothing, not defined in the spec yet */
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_RECV_COMPLETION_FLAGS )
-    {
-       dat_status = dapl_ep_check_recv_completion_flags (
-                                 ep_attr_request.recv_completion_flags);
-       if ( dat_status != DAT_SUCCESS )
-
-       {
-           goto bail;
-       }
-       else
-       {
-           ep_attr.recv_completion_flags =
-               ep_attr_request.recv_completion_flags;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_REQUEST_COMPLETION_FLAGS )
-    {
-       dat_status = dapl_ep_check_request_completion_flags (
-                                    ep_attr_request.request_completion_flags);
-       if ( dat_status != DAT_SUCCESS )
-       {
-           goto bail;
-       }
-       else
-       {
-           ep_attr.request_completion_flags =
-               ep_attr_request.request_completion_flags;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS )
-    {
-       if ( ep_attr_request.max_recv_dtos > ep_attr_limit.max_recv_dtos ||
-            ( ep_param->recv_evd_handle  == DAT_HANDLE_NULL &&
-             ( ep_attr_request.max_recv_dtos > 0 ) ) )
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_recv_dtos = ep_attr_request.max_recv_dtos;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS )
-    {
-       if ( ep_attr_request.max_request_dtos > ep_attr_limit.max_request_dtos ||
-            ( ep_param->request_evd_handle  == DAT_HANDLE_NULL &&
-             ( ep_attr_request.max_request_dtos > 0 ) ) )
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_request_dtos = ep_attr_request.max_request_dtos;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV )
-    {
-       if ( ep_attr_request.max_recv_iov > ep_attr_limit.max_recv_iov)
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_recv_iov = ep_attr_request.max_recv_iov;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV )
-    {
-       if ( ep_attr_request.max_request_iov > ep_attr_limit.max_request_iov)
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_request_iov = ep_attr_request.max_request_iov;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RDMA_READ_IOV )
-    {
-       if ( ep_attr_request.max_rdma_read_iov > ep_attr_limit.max_rdma_read_iov)
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_rdma_read_iov = ep_attr_request.max_rdma_read_iov;
-       }
-    }
-
-    if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RDMA_WRITE_IOV )
-    {
-       if ( ep_attr_request.max_rdma_write_iov > ep_attr_limit.max_rdma_write_iov)
-       {
-           dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-           goto bail;
-       }
-       else
-       {
-           ep_attr.max_rdma_write_iov = ep_attr_request.max_rdma_write_iov;
-       }
-    }
-
-    *ia_ptr = ia;
-    *ep_ptr = ep;
-    *ep_attr_ptr = ep_attr;
-
-bail:
-    return dat_status;
-}
+       DAPL_IA *ia;
+       DAPL_EP *ep;
+       DAT_EP_ATTR ep_attr;
+       DAT_EP_ATTR ep_attr_limit;
+       DAT_EP_ATTR ep_attr_request;
+       DAT_RETURN dat_status;
+
+       *ia_ptr = NULL;
+       *ep_ptr = NULL;
+       dat_status = DAT_SUCCESS;
+
+       if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
+
+       ep = (DAPL_EP *) ep_handle;
+       ia = ep->header.owner_ia;
+
+       /*
+        * Verify parameters valid in current EP state
+        */
+       if (ep_param_mask & (DAT_EP_FIELD_IA_HANDLE |
+                            DAT_EP_FIELD_EP_STATE |
+                            DAT_EP_FIELD_LOCAL_IA_ADDRESS_PTR |
+                            DAT_EP_FIELD_LOCAL_PORT_QUAL |
+                            DAT_EP_FIELD_REMOTE_IA_ADDRESS_PTR |
+                            DAT_EP_FIELD_REMOTE_PORT_QUAL)) {
+               dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+               goto bail;
+       }
 
+       /*
+        * Can only change the PZ handle if we are UNCONNECTED or
+        * TENTATIVE_CONNECTION_PENDING (psp PROVIDER allocated EP)
+        */
+       if ((ep_param_mask & DAT_EP_FIELD_PZ_HANDLE) &&
+           (ep->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
+            ep->param.ep_state != DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_STATE, dapls_ep_state_subtype(ep));
+               goto bail;
+       }
+
+       if ((ep_param_mask & (DAT_EP_FIELD_RECV_EVD_HANDLE |
+                             DAT_EP_FIELD_REQUEST_EVD_HANDLE |
+                             DAT_EP_FIELD_CONNECT_EVD_HANDLE |
+                             DAT_EP_FIELD_EP_ATTR_SERVICE_TYPE |
+                             DAT_EP_FIELD_EP_ATTR_MAX_MESSAGE_SIZE |
+                             DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE |
+                             DAT_EP_FIELD_EP_ATTR_QOS |
+                             DAT_EP_FIELD_EP_ATTR_REQUEST_COMPLETION_FLAGS |
+                             DAT_EP_FIELD_EP_ATTR_RECV_COMPLETION_FLAGS |
+                             DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS |
+                             DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS |
+                             DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV |
+                             DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV)) &&
+           (ep->param.ep_state != DAT_EP_STATE_UNCONNECTED &&
+            ep->param.ep_state != DAT_EP_STATE_RESERVED &&
+            ep->param.ep_state != DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_STATE, dapls_ep_state_subtype(ep));
+               goto bail;
+       }
+
+       /*
+        * Validate handles being modified
+        */
+       if (ep_param_mask & DAT_EP_FIELD_PZ_HANDLE) {
+               if (ep_param->pz_handle != NULL &&
+                   DAPL_BAD_HANDLE(ep_param->pz_handle, DAPL_MAGIC_PZ)) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_RECV_EVD_HANDLE) {
+               if (ep_param->recv_evd_handle != NULL &&
+                   (DAPL_BAD_HANDLE(ep_param->recv_evd_handle, DAPL_MAGIC_EVD)
+                    || !((DAPL_EVD *) ep_param->recv_evd_handle)->
+                    evd_flags & DAT_EVD_DTO_FLAG))
+               {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_REQUEST_EVD_HANDLE) {
+               if (ep_param->request_evd_handle != NULL &&
+                   DAPL_BAD_HANDLE(ep_param->request_evd_handle,
+                                   DAPL_MAGIC_EVD)) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_CONNECT_EVD_HANDLE) {
+               if (ep_param->connect_evd_handle != NULL &&
+                   DAPL_BAD_HANDLE(ep_param->connect_evd_handle,
+                                   DAPL_MAGIC_EVD)
+                   && !(((DAPL_EVD *) ep_param->connect_evd_handle)->
+                        evd_flags & DAT_EVD_CONNECTION_FLAG))
+               {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               }
+       }
+
+       /*
+        * Validate the attributes against the HCA limits
+        */
+       ep_attr = ep->param.ep_attr;
+
+       dapl_os_memzero(&ep_attr_limit, sizeof(DAT_EP_ATTR));
+       dat_status =
+           dapls_ib_query_hca(ia->hca_ptr, NULL, &ep_attr_limit, NULL);
+       if (dat_status != DAT_SUCCESS) {
+               goto bail;
+       }
+
+       ep_attr_request = ep_param->ep_attr;
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_SERVICE_TYPE) {
+               if (ep_attr_request.service_type != DAT_SERVICE_TYPE_RC) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_MESSAGE_SIZE) {
+               if (ep_attr_request.max_mtu_size > ep_attr_limit.max_mtu_size) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_mtu_size = ep_attr_request.max_mtu_size;
+               }
+       }
+
+       /* Do nothing if the DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE flag is   */
+       /* set. Each RDMA transport/provider may or may not have a limit  */
+       /* on the size of an RDMA DTO. For InfiniBand, this parameter is  */
+       /* validated in the implementation of the dapls_ib_qp_modify()    */
+       /* function.                                                      */
+       /*                                                                */
+       /*          if ( ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RDMA_SIZE ) */
+       /*  {                                                         */
+       /*                                                                */
+       /*  }                                                         */
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_QOS) {
+               /* Do nothing, not defined in the spec yet */
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_RECV_COMPLETION_FLAGS) {
+               dat_status =
+                   dapl_ep_check_recv_completion_flags(ep_attr_request.
+                                                       recv_completion_flags);
+               if (dat_status != DAT_SUCCESS)
+               {
+                       goto bail;
+               } else {
+                       ep_attr.recv_completion_flags =
+                           ep_attr_request.recv_completion_flags;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_REQUEST_COMPLETION_FLAGS) {
+               dat_status =
+                   dapl_ep_check_request_completion_flags(ep_attr_request.
+                                                          request_completion_flags);
+               if (dat_status != DAT_SUCCESS) {
+                       goto bail;
+               } else {
+                       ep_attr.request_completion_flags =
+                           ep_attr_request.request_completion_flags;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_DTOS) {
+               if (ep_attr_request.max_recv_dtos > ep_attr_limit.max_recv_dtos
+                   || (ep_param->recv_evd_handle == DAT_HANDLE_NULL
+                       && (ep_attr_request.max_recv_dtos > 0))) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_recv_dtos = ep_attr_request.max_recv_dtos;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_DTOS) {
+               if (ep_attr_request.max_request_dtos >
+                   ep_attr_limit.max_request_dtos
+                   || (ep_param->request_evd_handle == DAT_HANDLE_NULL
+                       && (ep_attr_request.max_request_dtos > 0))) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_request_dtos =
+                           ep_attr_request.max_request_dtos;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RECV_IOV) {
+               if (ep_attr_request.max_recv_iov > ep_attr_limit.max_recv_iov) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_recv_iov = ep_attr_request.max_recv_iov;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_REQUEST_IOV) {
+               if (ep_attr_request.max_request_iov >
+                   ep_attr_limit.max_request_iov) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_request_iov =
+                           ep_attr_request.max_request_iov;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RDMA_READ_IOV) {
+               if (ep_attr_request.max_rdma_read_iov >
+                   ep_attr_limit.max_rdma_read_iov) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_rdma_read_iov =
+                           ep_attr_request.max_rdma_read_iov;
+               }
+       }
+
+       if (ep_param_mask & DAT_EP_FIELD_EP_ATTR_MAX_RDMA_WRITE_IOV) {
+               if (ep_attr_request.max_rdma_write_iov >
+                   ep_attr_limit.max_rdma_write_iov) {
+                       dat_status =
+                           DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+                       goto bail;
+               } else {
+                       ep_attr.max_rdma_write_iov =
+                           ep_attr_request.max_rdma_write_iov;
+               }
+       }
+
+       *ia_ptr = ia;
+       *ep_ptr = ep;
+       *ep_attr_ptr = ep_attr;
+
+      bail:
+       return dat_status;
+}
 
 /*
  * Local variables:
@@ -707,4 +640,3 @@ bail:
  *  tab-width: 8
  * End:
  */
-
index dc6c39c..437cc5a 100644 (file)
  *     DAT_PRIVILEGES_VIOLATION
  */
 DAT_RETURN DAT_API
-dapl_ep_post_rdma_read (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_COUNT               num_segments,
-       IN      DAT_LMR_TRIPLET         *local_iov,
-       IN      DAT_DTO_COOKIE          user_cookie,
-       IN      const DAT_RMR_TRIPLET   *remote_iov,
-       IN      DAT_COMPLETION_FLAGS    completion_flags)
+dapl_ep_post_rdma_read(IN DAT_EP_HANDLE ep_handle,
+                      IN DAT_COUNT num_segments,
+                      IN DAT_LMR_TRIPLET * local_iov,
+                      IN DAT_DTO_COOKIE user_cookie,
+                      IN const DAT_RMR_TRIPLET * remote_iov,
+                      IN DAT_COMPLETION_FLAGS completion_flags)
 {
 
-    DAT_RETURN         dat_status;
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_post_rdma_read (%p, %d, %p, %p, %p, %x)\n",
-                 ep_handle, 
-                 num_segments, 
-                 local_iov, 
-                 user_cookie.as_64,
-                 remote_iov, 
-                 completion_flags);
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_post_rdma_read (%p, %d, %p, %p, %p, %x)\n",
+                    ep_handle,
+                    num_segments,
+                    local_iov,
+                    user_cookie.as_64, remote_iov, completion_flags);
 
-    dat_status = dapl_ep_post_send_req(ep_handle, 
-                                 num_segments, 
-                                 local_iov, 
-                                 user_cookie, 
-                                 remote_iov, 
-                                 completion_flags, 
-                                 DAPL_DTO_TYPE_RDMA_READ,
-                                 OP_RDMA_READ);
+       dat_status = dapl_ep_post_send_req(ep_handle,
+                                          num_segments,
+                                          local_iov,
+                                          user_cookie,
+                                          remote_iov,
+                                          completion_flags,
+                                          DAPL_DTO_TYPE_RDMA_READ,
+                                          OP_RDMA_READ);
 
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN, 
-                 "dapl_ep_post_rdma_read () returns 0x%x\n", 
-                 dat_status);
+       dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+                    "dapl_ep_post_rdma_read () returns 0x%x\n", dat_status);
 
-    return dat_status;
+       return dat_status;
 }
-
index 2b1210d..ff84db0 100644 (file)
  *     DAT_PRIVILEGES_VIOLATION
  *     DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN DAT_API
-dapl_ep_post_rdma_read_to_rmr (
-       IN      DAT_EP_HANDLE ep_handle,        /* ep_handle            */
-       IN      const DAT_RMR_TRIPLET *local,   /* local_iov            */
-       IN      DAT_DTO_COOKIE cookie,          /* user_cookie          */
-       IN      const DAT_RMR_TRIPLET *remote,  /* remote_iov           */
-       IN      DAT_COMPLETION_FLAGS flags)     /* completion_flags     */
-{
+DAT_RETURN DAT_API dapl_ep_post_rdma_read_to_rmr(IN DAT_EP_HANDLE ep_handle,   /* ep_handle            */
+                                                IN const DAT_RMR_TRIPLET * local,      /* local_iov            */
+                                                IN DAT_DTO_COOKIE cookie,      /* user_cookie          */
+                                                IN const DAT_RMR_TRIPLET * remote,     /* remote_iov           */
+                                                IN DAT_COMPLETION_FLAGS flags)
+{                              /* completion_flags     */
        return DAT_MODEL_NOT_SUPPORTED;
 }
 
index ef79d0c..b8bea97 100644 (file)
  *     DAT_PRIVILEGES_VIOLATION
  */
 DAT_RETURN DAT_API
-dapl_ep_post_rdma_write (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_COUNT               num_segments,
-       IN      DAT_LMR_TRIPLET         *local_iov,
-       IN      DAT_DTO_COOKIE          user_cookie,
-       IN      const DAT_RMR_TRIPLET   *remote_iov,
-       IN      DAT_COMPLETION_FLAGS    completion_flags )
+dapl_ep_post_rdma_write(IN DAT_EP_HANDLE ep_handle,
+                       IN DAT_COUNT num_segments,
+                       IN DAT_LMR_TRIPLET * local_iov,
+                       IN DAT_DTO_COOKIE user_cookie,
+                       IN const DAT_RMR_TRIPLET * remote_iov,
+                       IN DAT_COMPLETION_FLAGS completion_flags)
 {
-    DAT_RETURN         dat_status;
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_post_rdma_write (%p, %d, %p, %p, %p, %x)\n",
-                 ep_handle, 
-                 num_segments, 
-                 local_iov, 
-                 user_cookie.as_64,
-                 remote_iov, 
-                 completion_flags);
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_post_rdma_write (%p, %d, %p, %p, %p, %x)\n",
+                    ep_handle,
+                    num_segments,
+                    local_iov,
+                    user_cookie.as_64, remote_iov, completion_flags);
 
-    dat_status = dapl_ep_post_send_req(ep_handle, 
-                                 num_segments, 
-                                 local_iov, 
-                                 user_cookie, 
-                                 remote_iov, 
-                                 completion_flags, 
-                                 DAPL_DTO_TYPE_RDMA_WRITE,
-                                 OP_RDMA_WRITE);
+       dat_status = dapl_ep_post_send_req(ep_handle,
+                                          num_segments,
+                                          local_iov,
+                                          user_cookie,
+                                          remote_iov,
+                                          completion_flags,
+                                          DAPL_DTO_TYPE_RDMA_WRITE,
+                                          OP_RDMA_WRITE);
 
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-                "dapl_ep_post_rdma_write () returns 0x%x",
-                dat_status);
+       dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+                    "dapl_ep_post_rdma_write () returns 0x%x", dat_status);
 
-
-    return dat_status;
+       return dat_status;
 }
index b11eb96..fe3a605 100644 (file)
  *     DAT_PROVILEGES_VIOLATION
  */
 DAT_RETURN DAT_API
-dapl_ep_post_recv (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_COUNT               num_segments,
-       IN      DAT_LMR_TRIPLET         *local_iov,
-       IN      DAT_DTO_COOKIE          user_cookie,
-       IN      DAT_COMPLETION_FLAGS    completion_flags )
+dapl_ep_post_recv(IN DAT_EP_HANDLE ep_handle,
+                 IN DAT_COUNT num_segments,
+                 IN DAT_LMR_TRIPLET * local_iov,
+                 IN DAT_DTO_COOKIE user_cookie,
+                 IN DAT_COMPLETION_FLAGS completion_flags)
 {
-    DAPL_EP            *ep_ptr;
-    DAPL_COOKIE                *cookie;
-    DAT_RETURN         dat_status;
+       DAPL_EP *ep_ptr;
+       DAPL_COOKIE *cookie;
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_post_recv (%p, %d, %p, %p, %x)\n",
-                 ep_handle,
-                 num_segments,
-                 local_iov,
-                 user_cookie.as_64,
-                 completion_flags);
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_post_recv (%p, %d, %p, %p, %x)\n",
+                    ep_handle,
+                    num_segments,
+                    local_iov, user_cookie.as_64, completion_flags);
 
-    if ( DAPL_BAD_HANDLE (ep_handle, DAPL_MAGIC_EP) )
-    {
-       dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-       goto bail;
-    }
+       if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP)) {
+               dat_status =
+                   DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+               goto bail;
+       }
 
-    ep_ptr = (DAPL_EP *) ep_handle;
+       ep_ptr = (DAPL_EP *) ep_handle;
 
-    /*
-     * Synchronization ok since this buffer is only used for receive
-     * requests, which aren't allowed to race with each other.
-     */
-    dat_status = dapls_dto_cookie_alloc (&ep_ptr->recv_buffer,
-                                        DAPL_DTO_TYPE_RECV,
-                                        user_cookie,
-                                        &cookie);
-    if ( DAT_SUCCESS != dat_status)
-    {
-       goto bail;
-    }
+       /*
+        * Synchronization ok since this buffer is only used for receive
+        * requests, which aren't allowed to race with each other.
+        */
+       dat_status = dapls_dto_cookie_alloc(&ep_ptr->recv_buffer,
+                                           DAPL_DTO_TYPE_RECV,
+                                           user_cookie, &cookie);
+       if (DAT_SUCCESS != dat_status) {
+               goto bail;
+       }
 
-    /*
-     * Invoke provider specific routine to post DTO
-     */
-    dat_status = dapls_ib_post_recv (ep_ptr, cookie, num_segments, local_iov);
+       /*
+        * Invoke provider specific routine to post DTO
+        */
+       dat_status =
+           dapls_ib_post_recv(ep_ptr, cookie, num_segments, local_iov);
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-       dapls_cookie_dealloc (&ep_ptr->recv_buffer, cookie);
-    }
+       if (dat_status != DAT_SUCCESS) {
+               dapls_cookie_dealloc(&ep_ptr->recv_buffer, cookie);
+       }
 
-bail:
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-                 "dapl_ep_post_recv () returns 0x%x\n",
-                 dat_status);
+      bail:
+       dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+                    "dapl_ep_post_recv () returns 0x%x\n", dat_status);
 
-    return dat_status;
+       return dat_status;
 }
index 0229132..fc1aade 100644 (file)
  *     DAT_PRIVILEGES_VIOLATION
  */
 DAT_RETURN DAT_API
-dapl_ep_post_send (
-       IN      DAT_EP_HANDLE           ep_handle,
-       IN      DAT_COUNT               num_segments,
-       IN      DAT_LMR_TRIPLET         *local_iov,
-       IN      DAT_DTO_COOKIE          user_cookie,
-       IN      DAT_COMPLETION_FLAGS    completion_flags )
+dapl_ep_post_send(IN DAT_EP_HANDLE ep_handle,
+                 IN DAT_COUNT num_segments,
+                 IN DAT_LMR_TRIPLET * local_iov,
+                 IN DAT_DTO_COOKIE user_cookie,
+                 IN DAT_COMPLETION_FLAGS completion_flags)
 {
-    DAT_RMR_TRIPLET    remote_iov = {0,0,0};
-    DAT_RETURN         dat_status;
+       DAT_RMR_TRIPLET remote_iov = { 0, 0, 0 };
+       DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-                 "dapl_ep_post_send (%p, %d, %p, %p, %x)\n",
-                 ep_handle, 
-                 num_segments, 
-                 local_iov, 
-                 user_cookie.as_64,
-                 completion_flags);
+       dapl_dbg_log(DAPL_DBG_TYPE_API,
+                    "dapl_ep_post_send (%p, %d, %p, %p, %x)\n",
+                    ep_handle,
+                    num_segments,
+                    local_iov, user_cookie.as_64, completion_flags);
 
-    dat_status = dapl_ep_post_send_req(ep_handle,
-                                 num_segments,
-                                 local_iov,
-                                 user_cookie,
-                                 &remote_iov,
-                                 completion_flags,
-                                 DAPL_DTO_TYPE_SEND,
-                                 OP_SEND);
+       dat_status = dapl_ep_post_send_req(ep_handle,
+                                          num_segments,
+                                          local_iov,
+                                          user_cookie,
+                                          &remote_iov,
+                                          completion_flags,
+                                          DAPL_DTO_TYPE_SEND, OP_SEND);
 
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-                 "dapl_ep_post_send () returns 0x%x\n",
-                 dat_status);
+       dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+                    "dapl_ep_post_send () returns 0x%x\n", dat_status);
 
-
-    return dat_status;
+       return dat_status;
 }
index 68a3a51..0589b28 100644 (file)
  *     DAT_PRIVILEGES_VIOLATION
  *     DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN DAT_API
-dapl_ep_post_send_with_invalidate (
-       IN      DAT_EP_HANDLE ep_handle,      /* ep_handle            */
-       IN      DAT_COUNT num_segments,       /* num_segments         */
-       IN      DAT_LMR_TRIPLET *local_iov,   /* local_iov            */
-       IN      DAT_DTO_COOKIE user_cookie,   /* user_cookie          */
-       IN      DAT_COMPLETION_FLAGS flags,   /* completion_flags     */
-       IN      DAT_BOOLEAN invalidate_flag,  /* invalidate_flag      */
-       IN      DAT_RMR_CONTEXT rmr_context)  /* RMR context          */
-{
+DAT_RETURN DAT_API dapl_ep_post_send_with_invalidate(IN DAT_EP_HANDLE ep_handle,       /* ep_handle            */
+                                                    IN DAT_COUNT num_segments, /* num_segments         */
+