[Pkg-ofed-commits] r260 - in branches/ofed-1.4.1upgrade/dapl/branches/upstream/current: . dapl/common dapl/include dapl/openib_cma dapl/openib_cma/linux dapl/openib_scm dapl/openib_scm/linux dapl/udapl dapl/udapl/linux dat/common dat/include/dat2 dat/udat test/dapltest test/dapltest/cmd test/dapltest/common test/dapltest/include test/dapltest/mdep/linux test/dapltest/test test/dapltest/udapl test/dtest

Guy Coates gmpc-guest at alioth.debian.org
Thu May 28 08:23:18 UTC 2009


Author: gmpc-guest
Date: 2009-05-28 20:23:18 +0000 (Thu, 28 May 2009)
New Revision: 260

Added:
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/linux/
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/linux/openib_osd.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/linux/
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/linux/openib_osd.h
Modified:
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/ChangeLog
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.am
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.in
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure.in
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec.in
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_adapter_util.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cno_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cookie.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_accept.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_callback.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_handoff.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_reject.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_csp.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_debug.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_connect.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create_with_srq.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_disconnect.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_dup_connect.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_get_status.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_modify.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read_to_rmr.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_write.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_recv.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send_invalidate.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_recv_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_reset.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_set_watermark.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_connection_callb.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_cq_async_error_callb.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dequeue.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dto_callb.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_post_se.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_qp_async_error_callb.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_resize.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_un_async_error_callb.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_consumer_context.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_handle_type.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hash.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hca_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_close.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_ha.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_open.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_llist.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_read.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_write.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_mr_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_name_service.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_provider.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create_any.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ring_buffer_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_bind.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_set_consumer_context.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_sp_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_post_recv.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_resize.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_set_lw.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_timer_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl_debug.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cm.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cq.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_dto.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_extensions.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_mem.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_qp.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cm.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cq.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_dto.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_extensions.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_mem.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_qp.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_free.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_modify_agent.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_wait.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_clear_unwaitable.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_disable.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_enable.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_modify_cno.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_query.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_set_unwaitable.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_wait.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_init.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_lmr_create.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_api.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dictionary.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dr.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_init.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_sr.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_strerror.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/include/dat2/dat_ib_extensions.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_api.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_sr_parser.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.am
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.in
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_fft_cmd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_getopt.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_limit_cmd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_main.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_netaddr.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_params.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_performance_cmd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_qos_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_quit_cmd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_server_cmd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_transaction_cmd.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_endian.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_global.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_performance_cmd_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_quit_cmd_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_transaction_cmd_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_execute.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_proto.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_tdep.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_transaction_test.h
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/mdep/linux/dapl_mdep_user.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_bpool.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client_info.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_cnxn.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_execute.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_connmgt.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_endpoint.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_hwconn.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_mem.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_pz.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_queryinfo.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_test.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_limit.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_memlist.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_client.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_server.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_stats.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_quit_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server_info.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_data.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_thread.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_stats.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_test.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_util.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/udapl/udapl_tdep.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.am
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.in
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtest.c
   branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtestx.c
Log:
[svn-upgrade] Integrating new upstream version, dapl (2.0.19)

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/ChangeLog
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/ChangeLog	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/ChangeLog	2009-05-28 20:23:18 UTC (rev 260)
@@ -1,3 +1,550 @@
+commit 0ef94459e0a0175233b43b3fcbaaac2596e1042d
+Author: Arlin Davis <arlin.r.davis at 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 at intel.com>
+
+commit f91f27eaaab28b13a631adf75b933b7be3afbc0f
+Author: Arlin Davis <arlin.r.davis at 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 at intel.com>
+
+commit 8d6846056f4c86b6a06346147df55d37c4ba9933
+Author: Arlin Davis <arlin.r.davis at 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 at intel.com>
+
+commit c61f75b3412935e7d4a7a1acc9c495dcb4ac7e24
+Author: Arlin Davis <arlin.r.davis at 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 at intel.com>
+
+commit c88a191c7a408b0fb3dfb418a77a5b3b5afc778e
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Wed Apr 22 13:16:19 2009 -0700
+
+    dtest/dapltest: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 8699a9f1bd2bb45b04b87f887698707ba7b62d0a
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Apr 21 15:51:24 2009 -0700
+
+    ibal-scm: remove, obsolete
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 67ddd6bfba46f1f7a61b772257132f1257d05c96
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Apr 21 15:44:15 2009 -0700
+
+    scm, cma provider: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit d0898091090ff19be7929fed0d14f1ca696d5e53
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Apr 21 15:39:01 2009 -0700
+
+    udapl: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit a688d1cfb52fde256c5bfd95a27f940dd17e7ced
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Apr 21 15:31:20 2009 -0700
+
+    dapl common: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 2bded73c7f68cfb870e432ab3ebae7427d595cbe
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Apr 21 12:52:29 2009 -0700
+
+    dat: Cleanup code with Lindent
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 31e7b9210fc5334ff3be62558e74e3fdf01d6cbd
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Mon Apr 20 12:28:08 2009 -0700
+
+    Release 2.0.18
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 29bf0a24f54c45d2742026756f31f1a1f26fb6f3
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Thu Apr 16 14:35:18 2009 -0700
+
+    dapltest: reset server listen ports to avoid collisions during long runs
+    
+    If server is running continuously the port number increments
+    from base without reseting between tests. This will
+    eventually cause collisions in port space.
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit c27af8de0501d132b8152ec8546023cdba212de5
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Thu Apr 16 10:21:51 2009 -0700
+
+    To avoid duplicating port numbers between different tests, the next port
+    number to use must increment based on the number of endpoints per thread *
+    the number of threads.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 3084310197c20aaa50abe82260fc835786f591f5
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Thu Apr 16 10:21:45 2009 -0700
+
+    dapltest assumes that events across multiple endpoints occur in a specific
+    order.  Since this is a false assumption, avoid this by directing events to
+    per endpoint EVDs, rather than using shared EVDs.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit ef87a0a462f4fa07ac252e28d3aeb44af73cc202
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Thu Apr 16 10:21:41 2009 -0700
+
+    Synchronization is missing between removing items from an EVD and queuing
+    them.  Since the removal thread is the user's, but the queuing thread is
+    not, the synchronization must be provided by DAPL.  Hold the evd lock
+    around any calls to dapls_rbuf_*.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit f5e86d28f803162ffdf94b41ec7435dec92f728d
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Thu Apr 16 10:21:26 2009 -0700
+
+    Communication to the CR thread is done using an internal socket.  When a
+    new connection request is ready for processing, an object is placed on
+    the CR list, and data is written to the internal socket.  The write causes
+    the CR thread to wake-up and process anything on its cr list.
+    
+    If multiple objects are placed on the CR list around the same time, then
+    the CR thread will read in a single character, but process the entire list.
+    This results in additional data being left on the internal socket.  When
+    the CR does a select(), it will find more data to read, read the data, but
+    not have any real work to do.  The result is that the thread spins in a
+    loop checking for changes when none have occurred until all data on the
+    internal socket has been read.
+    
+    Avoid this overhead by reading all data off the internal socket before
+    processing the CR list.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 2ab52e9b1ab37c6eb44206c135e0568a8c2d01fa
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Thu Apr 16 10:21:13 2009 -0700
+
+    The dapl connect call takes as input an address (sockaddr) and a port number
+    as separate input parameters.  It modifies the sockaddr address to set the
+    port number before trying to connect.  This leads to a situation in
+    dapltest with multiple threads that reference the same buffer for their
+    address, but specify different port numbers, where the different threads
+    end up trying to connect to the same remote port.
+    
+    To solve this, do not modify the caller's address buffer and instead use
+    a local buffer.  This fixes an issue seen running multithreaded tests with
+    dapltest.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 7947026ede478f08b4a7b8cb607f457765bf2afa
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Thu Apr 16 10:21:03 2009 -0700
+
+    Windows socket calls should check return values against SOCKET_ERROR to
+    determine if an error occurred.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit e66e42fc44c50c8202f7c98f76d799a69aa3f1b6
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Fri Apr 10 08:33:41 2009 -0700
+
+    Build: add new file dapl/openib_cma/linux/openib_osd.h to EXTRA_DIST
+    
+    Fix rpmbuild problem with new cma osd include file.
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit acb213adb3268e9bf6999e2bf040d4a71212b701
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Fri Apr 10 08:32:24 2009 -0700
+
+    dapl scm: reduce wait time for thread startup.
+    
+    thread startup wait reduce to 2ms to reduce open times.
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 55459699fa9c0e5fb7e2b17822f0916412c64b35
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Fri Apr 10 08:31:22 2009 -0700
+
+    dapl-scm: getsockopt optlen needs initialized to size of optval
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit d710c5327e05a40796341d16b45a2b098b03f588
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:17:32 2009 -0700
+
+    The connection request thread adds sockets to a select list unless
+    the cr->socket is invalid and the cr request state is set to destroy.  If the
+    cr->socket is invalid, but the cr->state is not destroy, then the cr->socket
+    is added to an FD set for select/poll.  This results in select/poll
+    returning an error when select is called.  As a result, the cr thread never
+    actually blocks during this state.
+    
+    Fix this by only destroying a cr based on its state being set to destroy
+    and skip adding cr->sockets to the FD set when they are invalid.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 0be961c432f897d4f92d9a24dcb7c42ad30ea160
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:08:16 2009 -0700
+
+    Make sure all locks are initialized properly and don't zero their memory
+    once they are.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 9abdc26cd6154aa55588759ba54c9ca69e3fe2b5
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:08:13 2009 -0700
+
+    The lock functions are defined just a few lines beneath the prototypes
+    as inline.  Remove the duplicate prototypes.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 9578c4aeb9878d98374e4b7abc02db182aef82c6
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:08:07 2009 -0700
+
+    Make sure all locks are initialized and don't zero out their memory once
+    they are.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 97edcbb662b489303ef68c0da02831efaddeed91
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:08:03 2009 -0700
+
+    The IBAL library allocates a small number of threads for callbacks to the
+    user.  If the user blocks all of the callback threads, no additional
+    callbacks can be invoked.  The DAPL IBAL provider cancels listen requests
+    from within an IBAL callback, then waits for a second callback to confirm
+    that the listen has been canceled.  If there is a single IBAL callback
+    thread, or multiple listens are canceled simultaneously, then the provider
+    can deadlock waiting for a cancel callback that never occurs.
+    
+    This problem is seen when running dapltest with multiple threads.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 3e56e63bcb68de352edadafdcfcc4cb222c08c7b
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:57 2009 -0700
+
+    We need to check the return value from select for errors before checking
+    the FD sets.  An item may be in an FD set but select could have returned
+    an error.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit a8a977becaeefe0d7f8e01e01631a11988d2d54e
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:53 2009 -0700
+
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit ecc79cc0a1ae2bdbb3dfd19e15b3b562ac9a2957
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:49 2009 -0700
+
+    Enable building with CQ_WAIT_OBJECTS support to directly wait on CQ
+    completion channels in the Windows version of the openib_scm provider.
+    Also minor fixup to use DAPL_DBG_TYPE_UTIL for debug log messages
+    instead of DAPL_DBG_TYPE_CM.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 73728763666a46df5789af93b50db53cdf64afd6
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:44 2009 -0700
+
+    The IBAL-SCM provider will run into an inifinite loop if the check for
+    cr->socket > SCM_MAX_CONN - 1 fails.  The code continues back to the start
+    of the while loop without moving to the next connection request entry
+    in the list.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 9b1b396539926d36ffacfff04fbe7c081e436b45
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:40 2009 -0700
+
+    next_cr is set just before and inside the check
+    if ((cr->socket == DAPL_INVALID_SOCKET && cr->state == SCM_DESTROY)
+    Remove setting it inside the if statement.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 7b49a9850f62276bb7bfccb2d85a1e94e311813c
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:35 2009 -0700
+
+    Some errors on windows are more easily interpretted in hex than decimal.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 08ee072a1396ac2c28983878dbc6b02feb035787
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:32 2009 -0700
+
+    The WinOF HCA driver cannot handle transitioning from RTS -> RESET ->
+    INIT -> ERROR.  Simply delete the QP and re-create it to reinitialize
+    the endpoint until the bug is fixed.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 51ef5d96ce67d6141ec02b2a318f1b6e12be1bcf
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:23 2009 -0700
+
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit a8582be0e1fc89e856f1d0b43a3c1b271295a352
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:07:18 2009 -0700
+
+    Convert the openib_cma provider to common code between linux and windows.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit cc2a71dfe0c35a70f6b1ba66070a3a06059a8bb5
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Apr 10 08:06:53 2009 -0700
+
+    Move from using pipes to sockets for internal communication.  This
+    avoids issues with windows only supporting select() on sockets.
+    
+    Remove windows specific definition of dapl_dbg_log.
+    
+    Update to latest windows libibverbs implementation using completion
+    channel abstraction to improve windows scalability and simplify
+    porting where FD's are accessed directly in Linux.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit b3ad2ed97399a24a869841e17d1314e11c379aae
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Mar 31 05:41:50 2009 -0800
+
+    Release 2.0.17
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 5d732929f8a90a490994e8e35a3666c3647ad4fe
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Mar 31 05:22:11 2009 -0800
+
+    dapl: ia64 build problem on SuSE 11, atomic.h no longer exists.
+    
+    Add autotools check for SuSE 11 and include intrinsics.h
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit d7b8654db3a1f4ead16cb2e6d15f0902a322a188
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Mon Mar 16 13:23:50 2009 -0800
+
+    Release 2.0.16
+    
+    Fix changelog year in spec file.
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 08d9e26a85911f99d47cbb92ec8bccfc7f073be0
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Mon Mar 16 13:15:22 2009 -0800
+
+    Release 2.0.16
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 42c97b2a11d63ac6ba8a15fe8c82061e7da6e136
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Fri Mar 13 12:39:12 2009 -0800
+
+    uDAPL: scm provider, remove query gid/lid from connection setup phase
+    
+    move lid/gid queries from the connection setup phase
+    and put them in the open call to avoid overhead
+    of more fd's during connections. No need
+    to query during connection setup since uDAPL
+    binds to specific hca/ports via dat_ia_open.
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 775394b73980a7bc0af018a33d2a5bb795469c78
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Thu Mar 12 12:44:43 2009 -0800
+
+    Build: missing new linux/osd include file in EXTRA_DIST
+    
+    Add dapl/openib_scm/linux/openib_osd.h to EXTRA_DIST
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 647e288c1c9af5261495a5ed88e6ecbe1daf6d6e
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Thu Mar 12 12:11:21 2009 -0800
+
+    Build: spec files missing Requires(post) statements for sed/coreutils
+    
+    needed for anaconda install
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 1f5b3b7cab0785b64e8dab035dd4cd27111497d3
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Wed Mar 4 10:04:13 2009 -0800
+
+    dapl scm: remove unecessary thread when using direct objects
+    
+    A thread is created for processing events on devices without
+    direct event objecti support. Since all openfabrics devices support
+    direct events there is no need to start a thread. Move this under
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 66e4236e2c57dbaf860b7c20809b65a4fbbafa6f
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Mar 3 11:08:12 2009 -0800
+
+    dtestx: add missing F64u definition for windows
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit d9e771da16ec2b360a222ceccbbca5d088e20ee5
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Tue Mar 3 09:25:26 2009 -0800
+
+    uDAPL common: add 64 bit counters for IA, EP, and EVD's.
+    
+     -DDAPL_COUNTERS to build-in counters for cma and scm providers.
+     New extension calls in dat_ib_extensions.h for counters
+    	dat_print_counters, dat_query_counters
+     Counters for operations, async errors, and data
+     Update dtestx (-p) with print and query counter examples
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit 5e6ad3cdaa1d72523ad6b38d8306e0a2d0f1ada6
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Tue Feb 17 07:24:27 2009 -0800
+
+    Modify the openib_scm provider to support both OFED and WinOF releases.
+    This takes advantage of having a libibverbs compatibility library.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 0425c24c3b66e672bba346a1d0946b11c7b8b11e
+Author: Stan Smith <stan.smith at intel.com>
+Date:   Fri Jan 30 09:52:33 2009 -0800
+
+    Update the dapl.git tree with the latest SVN version of the
+    ibal-scm provider.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 83543b6cca342e25fd6408454f1261ec6835a172
+Author: Stan Smith <stan.smith at intel.com>
+Date:   Fri Jan 30 09:52:25 2009 -0800
+
+    Merge SVN IBAL provider code back into the main git tree.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit be0b6122d0fe4f93afc8cf3ec961702faf82fb44
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Jan 30 09:52:11 2009 -0800
+
+    Changes to dtest to support building on Windows.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 9f87610c4b37e4db4d74205c14028582a2f6a79e
+Author: Stan Smith <stan.smith at intel.com>
+Date:   Fri Jan 30 09:48:26 2009 -0800
+
+    Add return codes to various functions.
+    Add script (batch file) for Windows testing.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 723067550265defdcfe6e00460a4f89f7a81fbf1
+Author: Sean Hefty <sean.hefty at intel.com>
+Date:   Fri Jan 30 09:46:40 2009 -0800
+
+    Merge OFED and WinOF trees for common dapl code.
+    
+    Signed-off-by: Sean Hefty <sean.hefty at intel.com>
+
+commit 5b37e080e1ecc6903b3ab1ac9b0d4c9f8a18b790
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Fri Jan 16 08:16:13 2009 -0800
+
+    dtest/dapltest: use $(top_builddir) for .la files during test builds
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
+commit bd655d4fdd7e63e7fdeed3979926da5582f71e4b
+Author: Arlin Davis <arlin.r.davis at intel.com>
+Date:   Wed Nov 26 07:12:30 2008 -0800
+
+    Release 2.0.15
+    
+    Signed-off-by: Arlin Davis <ardavis at ichips.intel.com>
+
 commit 5d5dec42717c963d1644ee3e716459dc5d58e930
 Author: Arlin Davis <arlin.r.davis at intel.com>
 Date:   Mon Oct 27 08:48:53 2008 -0800

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.am
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.am	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.am	2009-05-28 20:23:18 UTC (rev 260)
@@ -11,6 +11,10 @@
 OSFLAGS += -DREDHAT_EL5
 endif
 
+if OS_SUSE11
+OSFLAGS += -DSUSE_11
+endif
+
 if EXT_TYPE_IB
 XFLAGS = -DDAT_EXTENSIONS
 XPROGRAMS_CMA = dapl/openib_cma/dapl_ib_extensions.c
@@ -43,13 +47,15 @@
 				-DOPENIB -DCQ_WAIT_OBJECT \
 				-I$(srcdir)/dat/include/ -I$(srcdir)/dapl/include/ \
 				-I$(srcdir)/dapl/common -I$(srcdir)/dapl/udapl/linux \
-				-I$(srcdir)/dapl/openib_cma 
+				-I$(srcdir)/dapl/openib_cma \
+				-I$(srcdir)/dapl/openib_cma/linux
 		
 dapl_udapl_libdaploscm_la_CFLAGS = $(AM_CFLAGS) -D_GNU_SOURCE $(OSFLAGS) $(XFLAGS) \
                                 -DOPENIB -DCQ_WAIT_OBJECT \
                                 -I$(srcdir)/dat/include/ -I$(srcdir)/dapl/include/ \
                                 -I$(srcdir)/dapl/common -I$(srcdir)/dapl/udapl/linux \
-                                -I$(srcdir)/dapl/openib_scm
+                                -I$(srcdir)/dapl/openib_scm \
+				-I$(srcdir)/dapl/openib_scm/linux
 
 if HAVE_LD_VERSION_SCRIPT
     dat_version_script = -Wl,--version-script=$(srcdir)/dat/udat/libdat2.map
@@ -361,8 +367,10 @@
 	     dapl/include/dapl_vendor.h \
 	     dapl/openib_cma/dapl_ib_dto.h \
 	     dapl/openib_cma/dapl_ib_util.h \
+	     dapl/openib_cma/linux/openib_osd.h \
 	     dapl/openib_scm/dapl_ib_dto.h \
 	     dapl/openib_scm/dapl_ib_util.h \
+	     dapl/openib_scm/linux/openib_osd.h \
 	     dat/udat/libdat2.map \
 	     dapl/udapl/libdaplofa.map \
 	     dapl/udapl/libdaploscm.map \

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.in
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.in	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/Makefile.in	2009-05-28 20:23:18 UTC (rev 260)
@@ -43,6 +43,7 @@
 # and built-in atomics for RedHat EL5
 @OS_RHEL4_TRUE at am__append_1 = -DREDHAT_EL4
 @OS_RHEL5_TRUE at am__append_2 = -DREDHAT_EL5
+ at OS_SUSE11_TRUE@am__append_3 = -DSUSE_11
 DIST_COMMON = README $(am__configure_deps) $(libdatinclude_HEADERS) \
 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
 	$(srcdir)/config.h.in $(srcdir)/dapl.spec.in \
@@ -534,6 +535,8 @@
 OS_RHEL4_TRUE = @OS_RHEL4_TRUE@
 OS_RHEL5_FALSE = @OS_RHEL5_FALSE@
 OS_RHEL5_TRUE = @OS_RHEL5_TRUE@
+OS_SUSE11_FALSE = @OS_SUSE11_FALSE@
+OS_SUSE11_TRUE = @OS_SUSE11_TRUE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -591,7 +594,8 @@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 OSFLAGS = -DOS_RELEASE=$(shell expr `uname -r | cut -f1 -d.` \* 65536 \
-	+ `uname -r | cut -f2 -d.`) $(am__append_1) $(am__append_2)
+	+ `uname -r | cut -f2 -d.`) $(am__append_1) $(am__append_2) \
+	$(am__append_3)
 @EXT_TYPE_IB_FALSE at XFLAGS = 
 @EXT_TYPE_IB_TRUE at XFLAGS = -DDAT_EXTENSIONS
 @EXT_TYPE_IB_FALSE at XPROGRAMS_CMA = 
@@ -614,13 +618,15 @@
 				-DOPENIB -DCQ_WAIT_OBJECT \
 				-I$(srcdir)/dat/include/ -I$(srcdir)/dapl/include/ \
 				-I$(srcdir)/dapl/common -I$(srcdir)/dapl/udapl/linux \
-				-I$(srcdir)/dapl/openib_cma 
+				-I$(srcdir)/dapl/openib_cma \
+				-I$(srcdir)/dapl/openib_cma/linux
 
 dapl_udapl_libdaploscm_la_CFLAGS = $(AM_CFLAGS) -D_GNU_SOURCE $(OSFLAGS) $(XFLAGS) \
                                 -DOPENIB -DCQ_WAIT_OBJECT \
                                 -I$(srcdir)/dat/include/ -I$(srcdir)/dapl/include/ \
                                 -I$(srcdir)/dapl/common -I$(srcdir)/dapl/udapl/linux \
-                                -I$(srcdir)/dapl/openib_scm
+                                -I$(srcdir)/dapl/openib_scm \
+				-I$(srcdir)/dapl/openib_scm/linux
 
 @HAVE_LD_VERSION_SCRIPT_FALSE at dat_version_script = 
 @HAVE_LD_VERSION_SCRIPT_TRUE at dat_version_script = -Wl,--version-script=$(srcdir)/dat/udat/libdat2.map
@@ -929,8 +935,10 @@
 	     dapl/include/dapl_vendor.h \
 	     dapl/openib_cma/dapl_ib_dto.h \
 	     dapl/openib_cma/dapl_ib_util.h \
+	     dapl/openib_cma/linux/openib_osd.h \
 	     dapl/openib_scm/dapl_ib_dto.h \
 	     dapl/openib_scm/dapl_ib_util.h \
+	     dapl/openib_scm/linux/openib_osd.h \
 	     dat/udat/libdat2.map \
 	     dapl/udapl/libdaplofa.map \
 	     dapl/udapl/libdaploscm.map \
@@ -3174,7 +3182,7 @@
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
 	mkdir $(distdir)
-	$(mkdir_p) $(distdir)/. $(distdir)/config $(distdir)/dapl/common $(distdir)/dapl/include $(distdir)/dapl/openib_cma $(distdir)/dapl/openib_scm $(distdir)/dapl/udapl $(distdir)/dapl/udapl/linux $(distdir)/dat/common $(distdir)/dat/include/dat2 $(distdir)/dat/udat $(distdir)/dat/udat/linux $(distdir)/man $(distdir)/test/dapltest/include $(distdir)/test/dapltest/mdep/linux
+	$(mkdir_p) $(distdir)/. $(distdir)/config $(distdir)/dapl/common $(distdir)/dapl/include $(distdir)/dapl/openib_cma $(distdir)/dapl/openib_cma/linux $(distdir)/dapl/openib_scm $(distdir)/dapl/openib_scm/linux $(distdir)/dapl/udapl $(distdir)/dapl/udapl/linux $(distdir)/dat/common $(distdir)/dat/include/dat2 $(distdir)/dat/udat $(distdir)/dat/udat/linux $(distdir)/man $(distdir)/test/dapltest/include $(distdir)/test/dapltest/mdep/linux
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure	2009-05-28 20:23:18 UTC (rev 260)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for dapl 2.0.15.
+# Generated by GNU Autoconf 2.59 for dapl 2.0.19.
 #
 # Report bugs to <general at lists.openfabrics.org>.
 #
@@ -423,8 +423,8 @@
 # Identity of this package.
 PACKAGE_NAME='dapl'
 PACKAGE_TARNAME='dapl'
-PACKAGE_VERSION='2.0.15'
-PACKAGE_STRING='dapl 2.0.15'
+PACKAGE_VERSION='2.0.19'
+PACKAGE_STRING='dapl 2.0.19'
 PACKAGE_BUGREPORT='general at lists.openfabrics.org'
 
 ac_unique_file="dat/udat/udat.c"
@@ -465,7 +465,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL HAVE_LD_VERSION_SCRIPT_TRUE HAVE_LD_VERSION_SCRIPT_FALSE DEBUG_TRUE DEBUG_FALSE EXT_TYPE_IB_TRUE EXT_TYPE_IB_FALSE OS_RHEL4_TRUE OS_RHEL4_FALSE OS_RHEL5_TRUE OS_RHEL5_FALSE LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE SED EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL HAVE_LD_VERSION_SCRIPT_TRUE HAVE_LD_VERSION_SCRIPT_FALSE DEBUG_TRUE DEBUG_FALSE EXT_TYPE_IB_TRUE EXT_TYPE_IB_FALSE OS_RHEL4_TRUE OS_RHEL4_FALSE OS_RHEL5_TRUE OS_RHEL5_FALSE OS_SUSE11_TRUE OS_SUSE11_FALSE LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -954,7 +954,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures dapl 2.0.15 to adapt to many kinds of systems.
+\`configure' configures dapl 2.0.19 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1020,7 +1020,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of dapl 2.0.15:";;
+     short | recursive ) echo "Configuration of dapl 2.0.19:";;
    esac
   cat <<\_ACEOF
 
@@ -1162,7 +1162,7 @@
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-dapl configure 2.0.15
+dapl configure 2.0.19
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1176,7 +1176,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by dapl $as_me 2.0.15, which was
+It was created by dapl $as_me 2.0.19, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1822,7 +1822,7 @@
 
 # Define the identity of the package.
  PACKAGE=dapl
- VERSION=2.0.15
+ VERSION=2.0.19
 
 
 cat >>confdefs.h <<_ACEOF
@@ -19824,6 +19824,31 @@
 fi
 
 
+echo "$as_me:$LINENO: checking Check for SUSE_11 system" >&5
+echo $ECHO_N "checking Check for SUSE_11 system... $ECHO_C" >&6
+if test "${ac_cv_suse11+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -f /etc/SuSE-release &&
+       test -n "`grep -e "VERSION = 11" /etc/SuSE-release`"; then
+        ac_cv_suse11=yes
+    else
+        ac_cv_suse11=no
+    fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_suse11" >&5
+echo "${ECHO_T}$ac_cv_suse11" >&6
+
+
+if test "$ac_cv_suse11" = "yes"; then
+  OS_SUSE11_TRUE=
+  OS_SUSE11_FALSE='#'
+else
+  OS_SUSE11_TRUE='#'
+  OS_SUSE11_FALSE=
+fi
+
+
                                         ac_config_files="$ac_config_files Makefile test/dtest/Makefile test/dapltest/Makefile dapl.spec"
 
 
@@ -19981,6 +20006,13 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${OS_SUSE11_TRUE}" && test -z "${OS_SUSE11_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"OS_SUSE11\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"OS_SUSE11\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -20252,7 +20284,7 @@
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by dapl $as_me 2.0.15, which was
+This file was extended by dapl $as_me 2.0.19, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20315,7 +20347,7 @@
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-dapl config.status 2.0.15
+dapl config.status 2.0.19
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -20592,6 +20624,8 @@
 s, at OS_RHEL4_FALSE@,$OS_RHEL4_FALSE,;t t
 s, at OS_RHEL5_TRUE@,$OS_RHEL5_TRUE,;t t
 s, at OS_RHEL5_FALSE@,$OS_RHEL5_FALSE,;t t
+s, at OS_SUSE11_TRUE@,$OS_SUSE11_TRUE,;t t
+s, at OS_SUSE11_FALSE@,$OS_SUSE11_FALSE,;t t
 s, at LIBOBJS@,$LIBOBJS,;t t
 s, at LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure.in
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure.in	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/configure.in	2009-05-28 20:23:18 UTC (rev 260)
@@ -1,11 +1,11 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT(dapl, 2.0.15, general at lists.openfabrics.org)
+AC_INIT(dapl, 2.0.19, general at 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.15)
+AM_INIT_AUTOMAKE(dapl, 2.0.19)
 
 AM_PROG_LIBTOOL
 
@@ -86,6 +86,16 @@
     fi)
 AM_CONDITIONAL(OS_RHEL5, test "$ac_cv_rhel5" = "yes")
 
+dnl Check for SuSE release 11
+AC_CACHE_CHECK(Check for SUSE_11 system, ac_cv_suse11,
+    if test -f /etc/SuSE-release &&
+       test -n "`grep -e "VERSION = 11" /etc/SuSE-release`"; then
+        ac_cv_suse11=yes
+    else
+        ac_cv_suse11=no
+    fi)
+AM_CONDITIONAL(OS_SUSE11, test "$ac_cv_suse11" = "yes")
+
 AC_CONFIG_FILES([Makefile test/dtest/Makefile test/dapltest/Makefile dapl.spec])
 
 AC_OUTPUT

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_adapter_util.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_adapter_util.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_adapter_util.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -247,7 +247,7 @@
 void 
 dapls_query_provider_specific_attr(
    	IN DAPL_IA			*ia_ptr,
-	IN DAT_PROVIDER_ATTR		*provider_attr );
+	IN DAT_PROVIDER_ATTR		*attr_ptr );
 
 #ifdef CQ_WAIT_OBJECT
 DAT_RETURN
@@ -266,7 +266,7 @@
 DAT_RETURN
 dapls_ib_wait_object_wait (
 	IN ib_wait_obj_handle_t		cq_wait_obj_handle,
-	IN u_int32_t 			timeout);
+	IN uint32_t 			timeout);
 #endif
 
 #ifdef DAT_EXTENSIONS

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cno_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cno_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cno_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -38,8 +38,6 @@
 #include "dapl_cno_util.h"
 #include "dapl_adapter_util.h"
 
-
-
 /*
  * dapl_cno_alloc
  *
@@ -52,57 +50,52 @@
  *	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 @@
  * 	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 @@
  * 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 @@
  *	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 @@
  *	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;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cookie.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cookie.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cookie.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -81,31 +81,22 @@
 #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_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_put(DAPL_COOKIE_BUFFER * buffer, DAPL_COOKIE * cookie);
 
-
 /*********************************************************************
  *                                                                   *
  * Function Definitions                                              *
  *                                                                   *
  *********************************************************************/
 
-
 /*
  * dapls_cb_create
  *
@@ -126,41 +117,34 @@
  *
  */
 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;
+	DAT_COUNT i;
 
-    /*
-     * allocate one additional entry so that the tail 
-     * can always point at an empty location
-     */
-    size++; 
+	/*
+	 * 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);
+	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;
-        }
+		for (i = 0; i < size; i++) {
+			buffer->pool[i].index = i;
+			buffer->pool[i].ep = ep;
+		}
 
-        return (DAT_SUCCESS);
-    }
-    else
-    {
-	return (DAT_INSUFFICIENT_RESOURCES);
-    }
+		return (DAT_SUCCESS);
+	} else {
+		return (DAT_INSUFFICIENT_RESOURCES);
+	}
 }
 
-
 /*
  * dapls_cb_free
  *
@@ -176,18 +160,15 @@
  *	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 @@
  *	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;
+	DAT_RETURN dat_status;
+	DAT_COUNT new_head;
 
-    dapl_os_assert(NULL != cookie_ptr);
+	dapl_os_assert(NULL != cookie_ptr);
 
-    new_head = (dapl_os_atomic_read (&buffer->head) + 1) % buffer->pool_size;
+	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;
+	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 @@
  *	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 @@
  *	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 @@
 		return 0;
 	else if (head > tail)
 		return (head - tail);
-	else 
+	else
 		return ((buffer->pool_size - tail) + head);
 }
 
@@ -308,34 +278,32 @@
  *
  */
 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;
+	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;
+	if (DAT_SUCCESS != dapls_cb_get(buffer, &cookie)) {
+		*cookie_ptr = NULL;
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    *cookie_ptr =  cookie;
+	dat_status = DAT_SUCCESS;
+	cookie->type = DAPL_COOKIE_TYPE_RMR;
+	cookie->val.rmr.rmr = rmr;
+	cookie->val.rmr.cookie = user_cookie;
 
- bail:
-    return dat_status;
+	*cookie_ptr = cookie;
+
+      bail:
+	return dat_status;
 }
 
-
 /*
  * dapls_dto_cookie_alloc
  *
@@ -355,38 +323,34 @@
  *
  */
 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;
+	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;
+	if (DAT_SUCCESS != dapls_cb_get(buffer, &cookie)) {
+		*cookie_ptr = NULL;
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+	}
 
-    *cookie_ptr = cookie;
-    return DAT_SUCCESS;
+	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

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_accept.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_accept.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_accept.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -63,186 +63,179 @@
  *	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_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);
+	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;
-    }
+	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;
-    }
+	cr_ptr = (DAPL_CR *) cr_handle;
 
-    /*
-     * 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;
+	/*
+	 * 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;
 	}
-    } 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;
+
+	/* 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;
+	if ((0 != private_data_size) && (NULL == private_data)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
 
-    /*
-     * 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_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;
+		}
+	} 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;
+		}
+	}
 
-	 || (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;
-    }
+	ep_ptr = (DAPL_EP *) ep_handle;
 
-    /* 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;
-    }
+	/*
+	 * 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)))
 
-    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;
+	    || (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;
+	}
 
-    dapl_os_unlock ( &ep_ptr->header.lock );
+	/* 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;
+	}
 
-    dat_status = dapls_ib_accept_connection ( cr_handle,
-					      ep_handle,
-					      private_data_size,
-					      private_data );
+	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;
 
-    /*
-     * 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 );
+	dapl_os_unlock(&ep_ptr->header.lock);
 
-	    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;
-	}
+	dat_status = dapls_ib_accept_connection(cr_handle,
+						ep_handle,
+						private_data_size,
+						private_data);
 
 	/*
-	 * After restoring values above, we now check if we need
-	 * to translate the error
+	 * If the provider failed, unwind the damage so we are back at
+	 * the initial state.
 	 */
-	if ( DAT_GET_TYPE(dat_status) == DAT_LENGTH_ERROR )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	}
+	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);
 
-    }
-    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;
-    }
+			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;
+		}
 
- bail:
-    return dat_status;
+		/*
+		 * 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;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_callback.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_callback.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_callback.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -45,22 +45,18 @@
 #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);
+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);
+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 @@
  * 	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_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);
+	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 );
+	/*
+	 * 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);
+	/* 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 );
+	/*
+	 * 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;
-	}
+		/* 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;
+		evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
+		/* if something has happened to our EVD, bail. */
+		if (evd_ptr == NULL) {
+			return;
+		}
 	}
-    }
 
-    prd_ptr = (DAPL_PRIVATE *)private_data_ptr;
+	prd_ptr = (DAPL_PRIVATE *) private_data_ptr;
 
-    dat_status = DAT_INTERNAL_ERROR;	/* init to ERR */
+	dat_status = DAT_INTERNAL_ERROR;	/* init to ERR */
 
-    switch (dat_event_num)
-    {
+	switch (dat_event_num) {
 	case DAT_CONNECTION_REQUEST_EVENT:
-	{
-	    /*
-	     * Requests arriving on a disabled SP are immediatly rejected
-	     */
+		{
+			/*
+			 * 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_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;
-	    }
+				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);
+			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;
+			/*
+			 * 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;
-	}
+			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;
+		{
+			/* 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;
-	    }
+				break;
+			}
 
-	    ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
-	    ep_ptr->cm_handle      = ib_cm_handle;
-	    dapl_os_unlock ( &ep_ptr->header.lock );
+			ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
+			ep_ptr->cm_handle = ib_cm_handle;
+			dapl_os_unlock(&ep_ptr->header.lock);
 
-	    break;
-	}
+			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 );
+		{
+			/*
+			 * 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;
-	}
+			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 );
+		{
+			/*
+			 * 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;
-	}
+			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;
-	}
+			break;
+		}
 	default:
-	{
-	    evd_ptr = NULL;
-	    dapl_os_assert (0);		/* shouldn't happen */
-	    break;
+		{
+			evd_ptr = NULL;
+			dapl_os_assert(0);	/* shouldn't happen */
+			break;
+		}
 	}
-    }
 
-    if (evd_ptr != NULL )
-    {
-	dat_status = dapls_evd_post_connection_event (
-				evd_ptr,
-				dat_event_num,
-				(DAT_HANDLE) ep_ptr,
-				0,
-				NULL);
-    }
+	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);
+	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;
-    }
+		return;
+	}
 }
 
-
 /*
  * dapli_connection_request
  *
@@ -331,148 +306,136 @@
  *
  */
 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;
+	DAT_RETURN dat_status;
 
-    DAPL_CR		*cr_ptr;
-    DAPL_EP		*ep_ptr;
-    DAPL_IA		*ia_ptr;
-    DAT_SP_HANDLE	sp_handle;
+	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;
-    }
+	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;
+	/*
+	 * 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.
 	 */
-	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;
+	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);
 	}
-	ep_ptr->param.ia_handle           = ia_ptr;
-	ep_ptr->param.local_ia_address_ptr= (DAT_IA_ADDRESS_PTR) &ia_ptr->hca_ptr->hca_address;
+	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));
+	}
 
-	/* Link the EP onto the IA */
-	dapl_ia_link_ep (ia_ptr, ep_ptr);
-    }
+	/* EP will be NULL unless RSP service point */
+	ep_ptr = (DAPL_EP *) sp_ptr->ep_handle;
 
-    cr_ptr->param.local_ep_handle = ep_ptr;
+	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;
 
-    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;
+		/* Link the EP onto the IA */
+		dapl_ia_link_ep(ia_ptr, ep_ptr);
 	}
-	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);
+	cr_ptr->param.local_ep_handle = ep_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;
+	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;
+	}
 
-    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);
+	/* link the CR onto the SP so we can pick it up later */
+	dapl_sp_link_cr(sp_ptr, 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);
+	/* Post the event.  */
+	/* assign sp_ptr to union to avoid typecast errors from some compilers */
+	sp_handle.psp_handle = (DAT_PSP_HANDLE) sp_ptr;
 
-	/* 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;
-    }
+	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);
 
-    return DAT_SUCCESS;
+		/* 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;
 }
 
-
 /*
  * dapli_get_sp_ep
  *
@@ -492,101 +455,90 @@
  * 	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;
+	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);
+	/*
+	 * 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;
-    }
+	/* 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;
+	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;
+	}
 
-    /* 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);
 
-    /* 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 (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;
+		}
 
-	/*
-	 * 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);
 	}
 
-	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;
+      skip_unlock:
+	return ep_ptr;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_handoff.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_handoff.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_handoff.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -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);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,46 +59,40 @@
  *	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;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_reject.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_reject.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_reject.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,81 +59,73 @@
  *	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;
-    }
+	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;
+	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;
-    }
-
-    dat_status =  dapls_ib_reject_connection ( cr_ptr->ib_cm_handle,
-					       IB_CM_REJ_REASON_CONSUMER_REJ,
-					       pdata_size, pdata );
-
-    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);
+		}
 
- bail:
-    return dat_status;
+		/* 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;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_cr_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -50,38 +50,34 @@
  *
  */
 
-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 @@
  * 	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));
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_csp.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_csp.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_csp.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -71,30 +71,24 @@
  * 	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;
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_debug.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_debug.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_debug.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -25,95 +25,214 @@
  * and/or other materials provided with the distribution.
  */
 
-#include "dapl_debug.h"
 #include "dapl.h"
 #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;
+	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_, getpid());
-	    dapl_os_vprintf (fmt, args);
-	    va_end (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:%d: ", _ptr_host_,
+				dapl_os_getpid());
+			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);
+		}
 	}
-    }
 }
 
-#if defined(DAPL_COUNTERS)
-int dapl_dbg_counters[DCNT_NUM_COUNTERS] = { 0 };
+#ifdef DAPL_COUNTERS
 
 /*
- * The order of this list must match exactly with the #defines
- * in dapl_debug.h
+ * The order of this list must match the DAT counter definitions 
  */
-char  *dapl_dbg_counter_names[] = {
-	"dapl_ep_create",
-	"dapl_ep_free",
-	"dapl_ep_connect",
-	"dapl_ep_disconnect",
-	"dapl_ep_post_send",
-	"dapl_ep_post_recv",
-	"dapl_ep_post_rdma_write",
-	"dapl_ep_post_rdma_read",
-	"dapl_evd_create",
-	"dapl_evd_free",
-	"dapl_evd_wait",
-	"dapl_evd_blocked",
-	"dapl_evd_completion_notify",
-	"dapl_evd_dto_callback",
-	"dapl_evd_connection_callback",
-	"dapl_evd_dequeue",
-	"dapl_evd_poll",
-	"dapl_evd_found",
-	"dapl_evd_not_found",
-	"dapls_timer_set",
-	"dapls_timer_cancel",
-	"dapl_extensions"
+static char *ia_cntr_names[] = {
+	"DCNT_IA_PZ_CREATE",
+	"DCNT_IA_PZ_FREE",
+	"DCNT_IA_LMR_CREATE",
+	"DCNT_IA_LMR_FREE",
+	"DCNT_IA_RMR_CREATE",
+	"DCNT_IA_RMR_FREE",
+	"DCNT_IA_PSP_CREATE",
+	"DCNT_IA_PSP_CREATE_ANY",
+	"DCNT_IA_PSP_FREE",
+	"DCNT_IA_RSP_CREATE",
+	"DCNT_IA_RSP_FREE",
+	"DCNT_IA_EVD_CREATE",
+	"DCNT_IA_EVD_FREE",
+	"DCNT_IA_EP_CREATE",
+	"DCNT_IA_EP_FREE",
+	"DCNT_IA_SRQ_CREATE",
+	"DCNT_IA_SRQ_FREE",
+	"DCNT_IA_SP_CR",
+	"DCNT_IA_SP_CR_ACCEPTED",
+	"DCNT_IA_SP_CR_REJECTED",
+	"DCNT_IA_MEM_ALLOC",
+	"DCNT_IA_MEM_ALLOC_DATA",
+	"DCNT_IA_MEM_FREE",
+	"DCNT_IA_ASYNC_ERROR",
+	"DCNT_IA_ASYNC_QP_ERROR",
+	"DCNT_IA_ASYNC_CQ_ERROR"
 };
 
-void dapl_dump_cntr( int cntr )
+static char *ep_cntr_names[] = {
+	"DCNT_EP_CONNECT",
+	"DCNT_EP_DISCONNECT",
+	"DCNT_EP_POST_SEND",
+	"DCNT_EP_POST_SEND_DATA",
+	"DCNT_EP_POST_SEND_UD",
+	"DCNT_EP_POST_SEND_UD_DATA",
+	"DCNT_EP_POST_RECV",
+	"DCNT_EP_POST_RECV_DATA",
+	"DCNT_EP_POST_WRITE",
+	"DCNT_EP_POST_WRITE_DATA",
+	"DCNT_EP_POST_WRITE_IMM",
+	"DCNT_EP_POST_WRITE_IMM_DATA",
+	"DCNT_EP_POST_READ",
+	"DCNT_EP_POST_READ_DATA",
+	"DCNT_EP_POST_CMP_SWAP",
+	"DCNT_EP_POST_FETCH_ADD",
+	"DCNT_EP_RECV",
+	"DCNT_EP_RECV_DATA",
+	"DCNT_EP_RECV_UD",
+	"DCNT_EP_RECV_UD_DATA",
+	"DCNT_EP_RECV_IMM",
+	"DCNT_EP_RECV_IMM_DATA",
+	"DCNT_EP_RECV_RDMA_IMM",
+	"DCNT_EP_RECV_RDMA_IMM_DATA",
+};
+
+static char *evd_cntr_names[] = {
+	"DCNT_EVD_WAIT",
+	"DCNT_EVD_WAIT_BLOCKED",
+	"DCNT_EVD_WAIT_NOTIFY",
+	"DCNT_EVD_DEQUEUE",
+	"DCNT_EVD_DEQUEUE_FOUND",
+	"DCNT_EVD_DEQUEUE_NOT_FOUND",
+	"DCNT_EVD_DEQUEUE_POLL",
+	"DCNT_EVD_DEQUEUE_POLL_FOUND",
+	"DCNT_EVD_CONN_CALLBACK",
+	"DCNT_EVD_DTO_CALLBACK",
+};
+
+DAT_RETURN dapl_query_counter(DAT_HANDLE dh,
+			      int counter, void *p_cntrs_out, int reset)
 {
-    int i;
+	int i, max;
+	DAT_UINT64 *p_cntrs;
+	DAT_HANDLE_TYPE type = 0;
 
-    for ( i = 0; i < DCNT_NUM_COUNTERS; i++ )
-    {
-        if (( cntr == i ) || ( cntr == DCNT_ALL_COUNTERS ))
-        {
-            dapl_dbg_log (  DAPL_DBG_TYPE_CNTR,
-                            "DAPL Counter: %s = %lu \n",
-                            dapl_dbg_counter_names[i],
-                            dapl_dbg_counters[i] );
-        }
-    }
+	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;
+	}
+
+	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;
+		}
+	}
+	return DAT_SUCCESS;
 }
 
-#endif /* DAPL_COUNTERS */
+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;
+	}
+	return NULL;
+}
+
+#include <inttypes.h>
+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;
+	}
+
+	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;
+		}
+	}
+	return;
+}
+
+#endif				/* DAPL_COUNTERS */

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_connect.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_connect.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_connect.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,301 +67,293 @@
  *	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_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);
-    DAPL_CNTR (DCNT_EP_CONNECT);
+	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;
+	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;
-    }
+	/*
+	 * 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;
-    }
-
-    /*
-     * 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;
+	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;
 	}
-	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;
+	/* 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);
 
-	dapl_os_lock ( &ep_ptr->header.lock );
 	/*
-	 * 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;
 
-	ep_ptr->qp_handle = alloc_ep.qp_handle;
-	ep_ptr->qpn = alloc_ep.qpn;
-	ep_ptr->qp_state = alloc_ep.qp_state;
+		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_unlock ( &ep_ptr->header.lock );
-    }
+		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;
+		}
 
-    /*
-     * 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 );
+		ep_ptr->qp_handle = alloc_ep.qp_handle;
+		ep_ptr->qpn = alloc_ep.qpn;
+		ep_ptr->qp_state = alloc_ep.qp_state;
 
-    /*
-     * 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;
+		dapl_os_unlock(&ep_ptr->header.lock);
 	}
-    }
 
-    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;
-    }
+	/*
+	 * 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);
 
-    if ( qos != DAT_QOS_BEST_EFFORT ||
-	 connect_flags != DAT_CONNECT_DEFAULT_FLAG )
-    {
 	/*
-	 * At this point we only support one QOS level
+	 * 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
 	 */
-	dapl_os_unlock ( &ep_ptr->header.lock );
-	dat_status = DAT_ERROR (DAT_MODEL_NOT_SUPPORTED, 0);
-	goto bail;
-    }
+	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;
+	}
 
-    /*
-     * 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);
+	/* 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);
 
-    max_req_pdata_size = dapls_ib_private_data_size(
-				NULL, DAPL_PDATA_CONN_REQ,
-				ep_ptr->header.owner_ia->hca_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 (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;
-    }
+	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;
+	}
 
-    /* transition the state before requesting a connection to avoid
-     * race conditions
-     */
-    ep_ptr->param.ep_state = DAT_EP_STATE_ACTIVE_CONNECTION_PENDING;
+	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;
+	}
 
-    /*
-     * 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 );
+	/*
+	 * 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);
 
-#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 */
+	max_req_pdata_size =
+	    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,
+				       ep_ptr->header.owner_ia->hca_ptr);
 
-    /* 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;
+	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;
+	}
 
-    dat_status =  dapls_ib_connect ( ep_handle,
-				     remote_ia_address,
-				     remote_conn_qual,
-				     private_data_size + req_hdr_size,
-				     private_data_ptr );
+	/* transition the state before requesting a connection to avoid
+	 * race conditions
+	 */
+	ep_ptr->param.ep_state = DAT_EP_STATE_ACTIVE_CONNECTION_PENDING;
 
-    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
+	 * At this point we're committed, and done with the endpoint
+	 * except for the connect, so we can drop the lock.
 	 */
-	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
-    {
+	dapl_os_unlock(&ep_ptr->header.lock);
+
+#ifdef IBHOSTS_NAMING
 	/*
-	 * 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.
+	 * 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_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));
+	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 */
 
-	    dapls_timer_set ( ep_ptr->cxn_timer,
-			      dapls_ep_timeout,
-			      ep_ptr,
-			      timeout );
+	/* 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 @@
  *	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;
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -39,7 +39,6 @@
 #include "dapl_ep_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * dapl_ep_create
  *
@@ -65,277 +64,268 @@
  *	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_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);
-    DAPL_CNTR(DCNT_EP_CREATE);
+	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;
+	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;
-    }
+	/*
+	 * 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;
-    }
+				       (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;
+	/* 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;
+		}
 	}
-	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;
+	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;
+		}
 	}
-	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;
+	/* 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;
 	}
-	else
-	{
-	    evd_ptr->completion_type = ep_attr->recv_completion_flags;
-	}
-    }
 
+	/*
+	 * 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);
 
-    /* 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;
-    }
+	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;
 
-    /*
-     * 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);
+	/*
+	 * 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;
+	}
 
-    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
+		 */
+		dat_status = dapls_ib_qp_alloc(ia_ptr, ep_ptr, ep_ptr);
 
-    /*
-     * 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 (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;
+	}
 
 	/*
-	 * Get a QP from the IB provider
+	 * 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.
 	 */
-	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 (connect_evd_handle != DAT_HANDLE_NULL) {
+		dapl_os_atomic_inc(&((DAPL_EVD *) connect_evd_handle)->
+				   evd_ref_count);
 	}
-    }
-    else
-    {
-	ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
-    }
+	/* 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

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create_with_srq.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create_with_srq.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_create_with_srq.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -41,7 +41,6 @@
 #include "dapl_ep_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * dapl_ep_create_with_srq
  *
@@ -71,295 +70,282 @@
  *	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;
+	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);
+	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;
+	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 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;
-    }
+	/*
+	 * 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 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;
-    }
+	/* 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;
-    }
+	/*
+	 * 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;
+	}
 
-    if ( ep_handle == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
-	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 (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;
+	/*
+	 * 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;
 	}
-	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;
+	/*
+	 * 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;
+		}
 	}
-	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;
+	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;
+		}
 	}
-	else
-	{
-	    evd_ptr->completion_type = ep_attr->recv_completion_flags;
-	}
-    }
 
-    dat_status = DAT_NOT_IMPLEMENTED;
+	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;
+	/*
+	 * 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
 
-    /* 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;
-    }
+	/* 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);
+	/*
+	 * 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;
+	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;
-    }
+	/*
+	 * 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 (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
+	 * 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 (pz_handle != DAT_HANDLE_NULL) {
+		/* Take a reference on the PZ handle */
+		dapl_os_atomic_inc(&((DAPL_PZ *) pz_handle)->pz_ref_count);
 
-	if ( dat_status != DAT_SUCCESS)
-	{
-	    dapl_os_atomic_dec (& ((DAPL_PZ *)pz_handle)->pz_ref_count);
-	    dapl_ep_dealloc ( ep_ptr );
-	    goto bail;
+		/*
+		 * 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.
-     */
-    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.
+	 */
+	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;
 
-#endif	/* notdef */
+#endif				/* notdef */
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_disconnect.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_disconnect.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_disconnect.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -63,125 +63,117 @@
  *	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_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);
-    DAPL_CNTR(DCNT_EP_DISCONNECT);
+	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;
+	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;
-    }
-
-    /*
-     * 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)
-    {
 	/*
-	 * 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 (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);
 
-    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
+	 * Do the verification of parameters and the state change
+	 * atomically.
 	 */
-	ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
+	dapl_os_lock(&ep_ptr->header.lock);
 
-	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);
+	/* 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;
+	}
 
-	/* clean up connection state */
-	dapl_sp_remove_ep (ep_ptr);
+	/* 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;
+	}
 
-	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;
-    }
+	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;
+	}
 
-    /*
-     * 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 );
+	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;
 
-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);
+		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);
 
-    return dat_status;
-}
+		/* 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:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_dup_connect.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_dup_connect.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_dup_connect.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -70,61 +70,58 @@
  *	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;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,146 +61,137 @@
  *	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_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);
-    DAPL_CNTR(DCNT_EP_FREE);
+	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;
+	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;
-    }
+	/*
+	 * 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;
-    }
+	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;
+	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.
-     */
+	/* 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);
+	/*
+	 * 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 );
+	/*
+	 * 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;
-    }
+	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 );
+	/* 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;
-    }
+	/*
+	 * 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.
+	/*
+	 * Finish tearing everything down.
 	 */
-	if (dat_status != DAT_SUCCESS)
-	{
-	    ep_ptr->qp_state = save_qp_state;
-	    goto bail;
+	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;
 
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_get_status.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_get_status.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_get_status.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,57 +61,49 @@
  *	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)) ? DAT_FALSE : DAT_TRUE;
-    }
+	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)) ? DAT_FALSE : DAT_TRUE;
-    }
+	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

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_modify.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_modify.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_modify.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -46,15 +46,13 @@
  */
 
 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,321 +75,280 @@
  *	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;
+	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 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;
+	/* 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;
-    }
+	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;
-    }
+	/*
+	 * 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_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_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;
-    }
+	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;
+	/*
+	 * 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_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;
+	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 );
+	/*
+	 * 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;
-    }
+	/*
+	 * 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 );
+	/*
+	 * 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;
+	copy_of_old_ep = *ep2;
 
-    /*
-     * Setup new ep.
-     */
-    new_ep = *ep2;
-    new_ep.param.ep_attr = ep_attr2;
+	/*
+	 * 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;
+	/*
+	 * 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;
-    }
+	/* 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;
-    }
+	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.
+	 * 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.
 	 */
-	dapl_os_assert ( (ep2->param.ep_state
-			  != DAT_EP_STATE_PASSIVE_CONNECTION_PENDING)
-			 && (ep2->param.ep_state
-			     != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING) );
+	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;
-    }
+		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;
+	/*
+	 * 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;
+	*ep2 = new_ep;
 
-    dapl_os_unlock ( &ep2->header.lock );
+	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);
-    }
+	/*
+	 * 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.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.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);
-    }
+	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);
-    }
+	/* 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.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.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);
-    }
+	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 );
+      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);
+		}
 	}
-	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 );
+	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);
+		}
 	}
-	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 );
+	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);
+		}
 	}
-	else
-	{
-	    dapls_cb_free ( &copy_of_old_ep.recv_buffer );
-	}
-    }
 
-    return dat_status;
+	return dat_status;
 }
 
-
 /*
  * dapli_ep_modify_validate_parameters
  *
@@ -404,302 +361,278 @@
  */
 
 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;
+	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;
+	*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;
-    }
+	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;
+	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;
-    }
+	/*
+	 * 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;
-    }
+	/*
+	 * 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;
-    }
+	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;
+	/*
+	 * 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))
+	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;
+		}
+	}
 
-	{
-	    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_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;
+		}
 	}
-    }
 
-    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) )
+	/*
+	 * Validate the attributes against the HCA limits
+	 */
+	ep_attr = ep->param.ep_attr;
 
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	    goto bail;
+	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;
 	}
-    }
 
-    /*
-     * Validate the attributes against the HCA limits
-     */
-    ep_attr = ep->param.ep_attr;
+	ep_attr_request = 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_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;
+	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;
+		}
 	}
-	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 ) */
-    /* 	{                                                         */
-    /*                                                                */
-    /* 	}                                                         */
+	/* 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_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 )
+	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;
+		}
+	}
 
-	{
-	    goto bail;
+	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;
+		}
 	}
-	else
-	{
-	    ep_attr.recv_completion_flags =
-		ep_attr_request.recv_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_REQUEST_COMPLETION_FLAGS )
-    {
-	dat_status = dapl_ep_check_request_completion_flags (
-				     ep_attr_request.request_completion_flags);
-	if ( dat_status != DAT_SUCCESS )
-	{
-	    goto bail;
+	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;
+		}
 	}
-	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;
+	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;
+		}
 	}
-	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;
+	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;
+		}
 	}
-	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;
+	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;
+		}
 	}
-	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;
+	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;
+		}
 	}
-	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;
-       }
-    }
+	*ia_ptr = ia;
+	*ep_ptr = ep;
+	*ep_attr_ptr = ep_attr;
 
-    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;
+      bail:
+	return dat_status;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4
@@ -707,4 +640,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,40 +67,34 @@
  * 	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_CNTR(DCNT_POST_RDMA_READ);
+	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;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read_to_rmr.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read_to_rmr.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_read_to_rmr.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -72,14 +72,12 @@
  *	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;
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_write.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_write.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_rdma_write.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,39 +67,33 @@
  *	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_CNTR(DCNT_POST_RDMA_WRITE);
+	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;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_recv.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_recv.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_recv.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,61 +67,54 @@
  * 	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_CNTR (DCNT_POST_RECV);
+	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;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,38 +67,31 @@
  *	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_CNTR(DCNT_POST_SEND);
+	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;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send_invalidate.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send_invalidate.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_post_send_invalidate.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -71,16 +71,15 @@
  *	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         */
+						     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          */
 	return DAT_MODEL_NOT_SUPPORTED;
 }
 
@@ -91,4 +90,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,63 +59,58 @@
  *	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_ep_query (
-	IN	DAT_EP_HANDLE		ep_handle,
-	IN	DAT_EP_PARAM_MASK	ep_param_mask,
-	OUT	DAT_EP_PARAM		*ep_param )
+dapl_ep_query(IN DAT_EP_HANDLE ep_handle,
+	      IN DAT_EP_PARAM_MASK ep_param_mask, OUT DAT_EP_PARAM * ep_param)
 {
-    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_query (%p, %x, %p)\n", 
-		  ep_handle, 
-		  ep_param_mask, 
-		  ep_param);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_ep_query (%p, %x, %p)\n",
+		     ep_handle, ep_param_mask, ep_param);
 
-    dat_status = DAT_SUCCESS;
-    ep_ptr = (DAPL_EP *) ep_handle;
+	dat_status = DAT_SUCCESS;
+	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;
-    }
+	/*
+	 * 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;
+	}
 
-    if ( ep_param == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
-    
-    /*
-     * Fill in according to user request
-     *
-     * N.B. Just slam all values into the user structure, there
-     *      is nothing to be gained by checking for each bit.
-     */    
-    if ( ep_param_mask & DAT_EP_FIELD_ALL )
-    {
-        /* only attempt to get remote IA address if consumer requested it */
-        if ( ep_param_mask & DAT_EP_FIELD_REMOTE_IA_ADDRESS_PTR )
-        {
-	    if ( ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED )
-	    {
-		/* obtain the remote IP address */
-		dat_status = dapls_ib_cm_remote_addr ((DAT_HANDLE)ep_handle,
-						      &ep_ptr->remote_ia_address );
-	    }
-	    ep_ptr->param.remote_ia_address_ptr = 
-		(DAT_IA_ADDRESS_PTR) &ep_ptr->remote_ia_address;
+	if (ep_param == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
 	}
-	*ep_param = ep_ptr->param;
-    }
 
- bail:
-    return dat_status;
+	/*
+	 * Fill in according to user request
+	 *
+	 * N.B. Just slam all values into the user structure, there
+	 *      is nothing to be gained by checking for each bit.
+	 */
+	if (ep_param_mask & DAT_EP_FIELD_ALL) {
+		/* only attempt to get remote IA address if consumer requested it */
+		if (ep_param_mask & DAT_EP_FIELD_REMOTE_IA_ADDRESS_PTR) {
+			if (ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED) {
+				/* obtain the remote IP address */
+				dat_status =
+				    dapls_ib_cm_remote_addr((DAT_HANDLE)
+							    ep_handle,
+							    &ep_ptr->
+							    remote_ia_address);
+			}
+			ep_ptr->param.remote_ia_address_ptr =
+			    (DAT_IA_ADDRESS_PTR) & ep_ptr->remote_ia_address;
+		}
+		*ep_param = ep_ptr->param;
+	}
+
+      bail:
+	return dat_status;
 }
 
 /*
@@ -125,4 +120,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_recv_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_recv_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_recv_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,34 +59,33 @@
  *	DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_ep_recv_query (
-	IN	DAT_EP_HANDLE	   ep_handle,
-	OUT	DAT_COUNT	   *nbufs_allocate,
-	OUT	DAT_COUNT	   *bufs_alloc_span)
+dapl_ep_recv_query(IN DAT_EP_HANDLE ep_handle,
+		   OUT DAT_COUNT * nbufs_allocate,
+		   OUT DAT_COUNT * bufs_alloc_span)
 {
-    DAPL_EP		*ep_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EP *ep_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_ep_recv_query (%p, %p, %p)\n",
-		  ep_handle, nbufs_allocate, bufs_alloc_span);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_ep_recv_query (%p, %p, %p)\n",
+		     ep_handle, nbufs_allocate, bufs_alloc_span);
 
-    ep_ptr = (DAPL_EP *) ep_handle;
+	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;
-    }
+	/*
+	 * 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;
+	}
 
-    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+	dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_reset.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_reset.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_reset.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,41 +61,39 @@
  *	DAT_INVALID_PARAMETER
  *	DAT_INVALID_STATE
  */
-DAT_RETURN DAT_API
-dapl_ep_reset (
-	IN	DAT_EP_HANDLE	   ep_handle)
+DAT_RETURN DAT_API dapl_ep_reset(IN DAT_EP_HANDLE ep_handle)
 {
-    DAPL_EP		*ep_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EP *ep_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    ep_ptr = (DAPL_EP *) ep_handle;
+	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;
-    }
+	/*
+	 * 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;
+	}
 
-    if ( ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED
-	 && ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECTED )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,dapls_ep_state_subtype (ep_ptr));
-	goto bail;
-    }
+	if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED
+	    && ep_ptr->param.ep_state != DAT_EP_STATE_DISCONNECTED) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE,
+			      dapls_ep_state_subtype(ep_ptr));
+		goto bail;
+	}
 
-    if ( ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED )
-    {
-	dapls_ib_reinit_ep ( ep_ptr );
-	ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
-    }
+	if (ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED) {
+		dapls_ib_reinit_ep(ep_ptr);
+		ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+	}
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_set_watermark.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_set_watermark.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_set_watermark.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -60,34 +60,33 @@
  *	DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_ep_set_watermark (
-	IN	DAT_EP_HANDLE	   ep_handle,
-	IN	DAT_COUNT	   soft_high_watermark,
-	IN	DAT_COUNT	   hard_high_watermark)
+dapl_ep_set_watermark(IN DAT_EP_HANDLE ep_handle,
+		      IN DAT_COUNT soft_high_watermark,
+		      IN DAT_COUNT hard_high_watermark)
 {
-    DAPL_EP		*ep_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EP *ep_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_ep_set_watermark (%p, %d, %d)\n",
-		  ep_handle, soft_high_watermark, hard_high_watermark);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_ep_set_watermark (%p, %d, %d)\n",
+		     ep_handle, soft_high_watermark, hard_high_watermark);
 
-    ep_ptr = (DAPL_EP *) ep_handle;
+	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;
-    }
+	/*
+	 * 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;
+	}
 
-    dat_status = DAT_NOT_IMPLEMENTED;
+	dat_status = DAT_NOT_IMPLEMENTED;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ep_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -39,7 +39,7 @@
 #include "dapl_cookie.h"
 #include "dapl_adapter_util.h"
 #include "dapl_evd_util.h"
-#include "dapl_cr_util.h"               /* for callback routine */
+#include "dapl_cr_util.h"	/* for callback routine */
 
 /*
  * Local definitions
@@ -59,40 +59,36 @@
  */
 #define IB_RDMA_DEFAULT	4
 
-extern void dapli_ep_default_attrs (
-    IN DAPL_EP			*ep_ptr );
+extern void dapli_ep_default_attrs(IN DAPL_EP * ep_ptr);
 
-
-
 char *dapl_get_ep_state_str(DAT_EP_STATE state)
 {
 #ifdef DAPL_DBG
-    static char *state_str[DAT_EP_STATE_CONNECTED_MULTI_PATH+1] = {
-        "DAT_EP_STATE_UNCONNECTED",                  /* quiescent state */
-        "DAT_EP_STATE_UNCONFIGURED_UNCONNECTED",
-        "DAT_EP_STATE_RESERVED",
-        "DAT_EP_STATE_UNCONFIGURED_RESERVED",
-        "DAT_EP_STATE_PASSIVE_CONNECTION_PENDING",
-        "DAT_EP_STATE_UNCONFIGURED_PASSIVE",
-        "DAT_EP_STATE_ACTIVE_CONNECTION_PENDING",
-        "DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING",
-        "DAT_EP_STATE_UNCONFIGURED_TENTATIVE",
-        "DAT_EP_STATE_CONNECTED",
-        "DAT_EP_STATE_DISCONNECT_PENDING",
-        "DAT_EP_STATE_DISCONNECTED",
-        "DAT_EP_STATE_COMPLETION_PENDING",
-        "DAT_EP_STATE_CONNECTED_SINGLE_PATH",
-        "DAT_EP_STATE_CONNECTED_MULTI_PATH"
-     };
-     return state_str[state];
+	static char *state_str[DAT_EP_STATE_CONNECTED_MULTI_PATH + 1] = {
+		"DAT_EP_STATE_UNCONNECTED",	/* quiescent state */
+		"DAT_EP_STATE_UNCONFIGURED_UNCONNECTED",
+		"DAT_EP_STATE_RESERVED",
+		"DAT_EP_STATE_UNCONFIGURED_RESERVED",
+		"DAT_EP_STATE_PASSIVE_CONNECTION_PENDING",
+		"DAT_EP_STATE_UNCONFIGURED_PASSIVE",
+		"DAT_EP_STATE_ACTIVE_CONNECTION_PENDING",
+		"DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING",
+		"DAT_EP_STATE_UNCONFIGURED_TENTATIVE",
+		"DAT_EP_STATE_CONNECTED",
+		"DAT_EP_STATE_DISCONNECT_PENDING",
+		"DAT_EP_STATE_DISCONNECTED",
+		"DAT_EP_STATE_COMPLETION_PENDING",
+		"DAT_EP_STATE_CONNECTED_SINGLE_PATH",
+		"DAT_EP_STATE_CONNECTED_MULTI_PATH"
+	};
+	return state_str[state];
 #else
-    static char buf[12];
-    sprintf(buf,"%d",state);
-    return buf;
+	static char buf[12];
+	sprintf(buf, "%d", state);
+	return buf;
 #endif
 }
 
-
 /*
  * dapl_ep_alloc
  *
@@ -108,86 +104,89 @@
  * 	none
  *
  */
-DAPL_EP *
-dapl_ep_alloc (
-	IN DAPL_IA		*ia_ptr,
-	IN const DAT_EP_ATTR	*ep_attr )
+DAPL_EP *dapl_ep_alloc(IN DAPL_IA * ia_ptr, IN const DAT_EP_ATTR * ep_attr)
 {
-    DAPL_EP		*ep_ptr;
+	DAPL_EP *ep_ptr;
 
-    /* Allocate EP */
-    ep_ptr = (DAPL_EP *)dapl_os_alloc (sizeof (DAPL_EP) + sizeof (DAT_SOCK_ADDR));
-    if ( ep_ptr == NULL )
-    {
-	goto bail;
-    }
+	/* Allocate EP */
+	ep_ptr =
+	    (DAPL_EP *) dapl_os_alloc(sizeof(DAPL_EP) + sizeof(DAT_SOCK_ADDR));
+	if (ep_ptr == NULL) {
+		goto bail;
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (ep_ptr, sizeof (DAPL_EP) + sizeof (DAT_SOCK_ADDR));
+	/* zero the structure */
+	dapl_os_memzero(ep_ptr, sizeof(DAPL_EP) + sizeof(DAT_SOCK_ADDR));
 
-    /*
-     * initialize the header
-     */
-    ep_ptr->header.provider            = ia_ptr->header.provider;
-    ep_ptr->header.magic               = DAPL_MAGIC_EP;
-    ep_ptr->header.handle_type         = DAT_HANDLE_TYPE_EP;
-    ep_ptr->header.owner_ia            = ia_ptr;
-    ep_ptr->header.user_context.as_64  = 0;
-    ep_ptr->header.user_context.as_ptr = NULL;
+#ifdef DAPL_COUNTERS
+	/* Allocate counters */
+	ep_ptr->cntrs =
+	    dapl_os_alloc(sizeof(DAT_UINT64) * DCNT_EP_ALL_COUNTERS);
+	if (ep_ptr->cntrs == NULL) {
+		dapl_os_free(ep_ptr, sizeof(DAPL_EP) + sizeof(DAT_SOCK_ADDR));
+		return (NULL);
+	}
+	dapl_os_memzero(ep_ptr->cntrs,
+			sizeof(DAT_UINT64) * DCNT_EP_ALL_COUNTERS);
+#endif				/* DAPL_COUNTERS */
 
-    dapl_llist_init_entry (&ep_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&ep_ptr->header.lock);
+	/*
+	 * initialize the header
+	 */
+	ep_ptr->header.provider = ia_ptr->header.provider;
+	ep_ptr->header.magic = DAPL_MAGIC_EP;
+	ep_ptr->header.handle_type = DAT_HANDLE_TYPE_EP;
+	ep_ptr->header.owner_ia = ia_ptr;
+	ep_ptr->header.user_context.as_64 = 0;
+	ep_ptr->header.user_context.as_ptr = NULL;
 
-    /*
-     * Initialize the body
-     */
-    /*
-     * Set up default parameters if the user passed in a NULL
-     */
-    if ( ep_attr == NULL )
-    {
-	dapli_ep_default_attrs (ep_ptr);
-    }
-    else
-    {
-	ep_ptr->param.ep_attr = *ep_attr;
-    }
+	dapl_llist_init_entry(&ep_ptr->header.ia_list_entry);
+	dapl_os_lock_init(&ep_ptr->header.lock);
 
-    /*
-     * IBM OS API specific fields
-     */
-    ep_ptr->qp_handle = IB_INVALID_HANDLE;
-    ep_ptr->qpn       = 0;
-    ep_ptr->qp_state  = DAPL_QP_STATE_UNATTACHED;
-    ep_ptr->cm_handle = IB_INVALID_HANDLE;
+	/*
+	 * Initialize the body
+	 */
+	/*
+	 * Set up default parameters if the user passed in a NULL
+	 */
+	if (ep_attr == NULL) {
+		dapli_ep_default_attrs(ep_ptr);
+	} else {
+		ep_ptr->param.ep_attr = *ep_attr;
+	}
 
-    if ( DAT_SUCCESS != dapls_cb_create (
-	     &ep_ptr->req_buffer,
-	     ep_ptr,
-	     ep_ptr->param.ep_attr.max_request_dtos) )
-    {
-	dapl_ep_dealloc (ep_ptr);
-	ep_ptr = NULL;
-	goto bail;
-    }
+	/*
+	 * IBM OS API specific fields
+	 */
+	ep_ptr->qp_handle = IB_INVALID_HANDLE;
+	ep_ptr->qpn = 0;
+	ep_ptr->qp_state = DAPL_QP_STATE_UNATTACHED;
+	ep_ptr->cm_handle = IB_INVALID_HANDLE;
 
-    if ( DAT_SUCCESS != dapls_cb_create (
-	     &ep_ptr->recv_buffer,
-	     ep_ptr,
-	     ep_ptr->param.ep_attr.max_recv_dtos) )
-    {
-	dapl_ep_dealloc (ep_ptr);
-	ep_ptr = NULL;
-	goto bail;
-    }
+	if (DAT_SUCCESS != dapls_cb_create(&ep_ptr->req_buffer,
+					   ep_ptr,
+					   ep_ptr->param.ep_attr.
+					   max_request_dtos)) {
+		dapl_ep_dealloc(ep_ptr);
+		ep_ptr = NULL;
+		goto bail;
+	}
 
-    dapls_io_trc_alloc (ep_ptr);
+	if (DAT_SUCCESS != dapls_cb_create(&ep_ptr->recv_buffer,
+					   ep_ptr,
+					   ep_ptr->param.ep_attr.max_recv_dtos))
+	{
+		dapl_ep_dealloc(ep_ptr);
+		ep_ptr = NULL;
+		goto bail;
+	}
 
-bail:
-    return ep_ptr;
+	dapls_io_trc_alloc(ep_ptr);
+
+      bail:
+	return ep_ptr;
 }
 
-
 /*
  * dapl_ep_dealloc
  *
@@ -203,34 +202,33 @@
  * 	none
  *
  */
-void
-dapl_ep_dealloc (
-	IN DAPL_EP		*ep_ptr )
+void dapl_ep_dealloc(IN DAPL_EP * ep_ptr)
 {
-    dapl_os_assert (ep_ptr->header.magic == DAPL_MAGIC_EP);
+	dapl_os_assert(ep_ptr->header.magic == DAPL_MAGIC_EP);
 
-    ep_ptr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
+	ep_ptr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
 
-    dapls_cb_free ( &ep_ptr->req_buffer );
-    dapls_cb_free ( &ep_ptr->recv_buffer );
+	dapls_cb_free(&ep_ptr->req_buffer);
+	dapls_cb_free(&ep_ptr->recv_buffer);
 
-    if ( NULL != ep_ptr->cxn_timer )
-    {
-	dapl_os_free ( ep_ptr->cxn_timer, sizeof ( DAPL_OS_TIMER ) );
-    }
-
+	if (NULL != ep_ptr->cxn_timer) {
+		dapl_os_free(ep_ptr->cxn_timer, sizeof(DAPL_OS_TIMER));
+	}
 #if defined(_WIN32) || defined(_WIN64)
-    if ( ep_ptr->ibal_cm_handle )
-    {
-        dapl_os_free ( ep_ptr->ibal_cm_handle,
-                       sizeof ( *ep_ptr->ibal_cm_handle ) );
-        ep_ptr->ibal_cm_handle = NULL;
-    }
+	if (ep_ptr->ibal_cm_handle) {
+		dapl_os_free(ep_ptr->ibal_cm_handle,
+			     sizeof(*ep_ptr->ibal_cm_handle));
+		ep_ptr->ibal_cm_handle = NULL;
+	}
 #endif
-    dapl_os_free (ep_ptr, sizeof (DAPL_EP) + sizeof (DAT_SOCK_ADDR) );
-}
 
+#ifdef DAPL_COUNTERS
+	dapl_os_free(ep_ptr->cntrs, sizeof(DAT_UINT64) * DCNT_EP_ALL_COUNTERS);
+#endif				/* DAPL_COUNTERS */
 
+	dapl_os_free(ep_ptr, sizeof(DAPL_EP) + sizeof(DAT_SOCK_ADDR));
+}
+
 /*
  * dapl_ep_default_attrs
  *
@@ -246,319 +244,287 @@
  * 	none
  *
  */
-void
-dapli_ep_default_attrs (
-	IN DAPL_EP		*ep_ptr )
+void dapli_ep_default_attrs(IN DAPL_EP * ep_ptr)
 {
-    DAT_EP_ATTR		ep_attr_limit;
-    DAT_EP_ATTR		*ep_attr;
-    DAT_RETURN		dat_status;
+	DAT_EP_ATTR ep_attr_limit;
+	DAT_EP_ATTR *ep_attr;
+	DAT_RETURN dat_status;
 
-    ep_attr = &ep_ptr->param.ep_attr;
-    /* Set up defaults */
-    dapl_os_memzero (ep_attr, sizeof (DAT_EP_ATTR));
+	ep_attr = &ep_ptr->param.ep_attr;
+	/* Set up defaults */
+	dapl_os_memzero(ep_attr, sizeof(DAT_EP_ATTR));
 
-    /* mtu and rdma sizes fixed in IB as per IBTA 1.1, 9.4.3, 9.4.4, 9.7.7.  */
-    ep_attr->max_mtu_size     = 0x80000000;
-    ep_attr->max_rdma_size    = 0x80000000;
+	/* mtu and rdma sizes fixed in IB as per IBTA 1.1, 9.4.3, 9.4.4, 9.7.7.  */
+	ep_attr->max_mtu_size = 0x80000000;
+	ep_attr->max_rdma_size = 0x80000000;
 
-    ep_attr->qos	      = DAT_QOS_BEST_EFFORT;
-    ep_attr->service_type     = DAT_SERVICE_TYPE_RC;
-    ep_attr->max_recv_dtos    = IB_IO_DEFAULT;
-    ep_attr->max_request_dtos = IB_IO_DEFAULT;
-    ep_attr->max_recv_iov     = IB_IOV_DEFAULT;
-    ep_attr->max_request_iov  = IB_IOV_DEFAULT;
-    ep_attr->max_rdma_read_in = IB_RDMA_DEFAULT;
-    ep_attr->max_rdma_read_out= IB_RDMA_DEFAULT;
+	ep_attr->qos = DAT_QOS_BEST_EFFORT;
+	ep_attr->service_type = DAT_SERVICE_TYPE_RC;
+	ep_attr->max_recv_dtos = IB_IO_DEFAULT;
+	ep_attr->max_request_dtos = IB_IO_DEFAULT;
+	ep_attr->max_recv_iov = IB_IOV_DEFAULT;
+	ep_attr->max_request_iov = IB_IOV_DEFAULT;
+	ep_attr->max_rdma_read_in = IB_RDMA_DEFAULT;
+	ep_attr->max_rdma_read_out = IB_RDMA_DEFAULT;
 
-    /*
-     * Configure the EP as a standard completion type, which will be
-     * used by the EVDs. A threshold of 1 is the default state of an
-     * EVD.
-     */
-    ep_attr->request_completion_flags = DAT_COMPLETION_EVD_THRESHOLD_FLAG;
-    ep_attr->recv_completion_flags    = DAT_COMPLETION_EVD_THRESHOLD_FLAG;
-    /*
-     * Unspecified defaults:
-     *    - ep_privileges: No RDMA capabilities
-     *    - num_transport_specific_params: none
-     *    - transport_specific_params: none
-     *    - num_provider_specific_params: 0
-     *    - provider_specific_params: 0
-     */
+	/*
+	 * Configure the EP as a standard completion type, which will be
+	 * used by the EVDs. A threshold of 1 is the default state of an
+	 * EVD.
+	 */
+	ep_attr->request_completion_flags = DAT_COMPLETION_EVD_THRESHOLD_FLAG;
+	ep_attr->recv_completion_flags = DAT_COMPLETION_EVD_THRESHOLD_FLAG;
+	/*
+	 * Unspecified defaults:
+	 *    - ep_privileges: No RDMA capabilities
+	 *    - num_transport_specific_params: none
+	 *    - transport_specific_params: none
+	 *    - num_provider_specific_params: 0
+	 *    - provider_specific_params: 0
+	 */
 
-     dat_status = dapls_ib_query_hca (ep_ptr->header.owner_ia->hca_ptr, 
-				      NULL, &ep_attr_limit, NULL);
-     /* check against HCA maximums */
-     if (dat_status == DAT_SUCCESS)
-     {
-	 ep_ptr->param.ep_attr.max_mtu_size =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_mtu_size,
-		      ep_attr_limit.max_mtu_size);
-	 ep_ptr->param.ep_attr.max_rdma_size =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_rdma_size,
-		      ep_attr_limit.max_rdma_size);
-	 ep_ptr->param.ep_attr.max_recv_dtos =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_recv_dtos,
-		      ep_attr_limit.max_recv_dtos);
-	 ep_ptr->param.ep_attr.max_request_dtos =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_request_dtos,
-		      ep_attr_limit.max_request_dtos);
-	 ep_ptr->param.ep_attr.max_recv_iov =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_recv_iov,
-		      ep_attr_limit.max_recv_iov);
-	 ep_ptr->param.ep_attr.max_request_iov =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_request_iov,
-		      ep_attr_limit.max_request_iov);
-	 ep_ptr->param.ep_attr.max_rdma_read_in =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_rdma_read_in,
-		      ep_attr_limit.max_rdma_read_in);
-	 ep_ptr->param.ep_attr.max_rdma_read_out =
-	     DAPL_MIN(ep_ptr->param.ep_attr.max_rdma_read_out,
-		      ep_attr_limit.max_rdma_read_out);
-     }
+	dat_status = dapls_ib_query_hca(ep_ptr->header.owner_ia->hca_ptr,
+					NULL, &ep_attr_limit, NULL);
+	/* check against HCA maximums */
+	if (dat_status == DAT_SUCCESS) {
+		ep_ptr->param.ep_attr.max_mtu_size =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_mtu_size,
+			     ep_attr_limit.max_mtu_size);
+		ep_ptr->param.ep_attr.max_rdma_size =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_rdma_size,
+			     ep_attr_limit.max_rdma_size);
+		ep_ptr->param.ep_attr.max_recv_dtos =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_recv_dtos,
+			     ep_attr_limit.max_recv_dtos);
+		ep_ptr->param.ep_attr.max_request_dtos =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_request_dtos,
+			     ep_attr_limit.max_request_dtos);
+		ep_ptr->param.ep_attr.max_recv_iov =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_recv_iov,
+			     ep_attr_limit.max_recv_iov);
+		ep_ptr->param.ep_attr.max_request_iov =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_request_iov,
+			     ep_attr_limit.max_request_iov);
+		ep_ptr->param.ep_attr.max_rdma_read_in =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_rdma_read_in,
+			     ep_attr_limit.max_rdma_read_in);
+		ep_ptr->param.ep_attr.max_rdma_read_out =
+		    DAPL_MIN(ep_ptr->param.ep_attr.max_rdma_read_out,
+			     ep_attr_limit.max_rdma_read_out);
+	}
 }
 
-
-DAT_RETURN
-dapl_ep_check_recv_completion_flags (
-    DAT_COMPLETION_FLAGS        flags )
+DAT_RETURN dapl_ep_check_recv_completion_flags(DAT_COMPLETION_FLAGS flags)
 {
 
-    /*
-     * InfiniBand will not allow signal suppression for RECV completions,
-     * see the 1.0.1 spec section 10.7.3.1, 10.8.6.
-     * N.B. SIGNALLED has a different meaning in dapl than it does
-     *      in IB; IB SIGNALLED is the same as DAPL SUPPRESS. DAPL
-     *      SIGNALLED simply means the user will not get awakened when
-     *      an EVD completes, even though the dapl handler is invoked.
-     */
+	/*
+	 * InfiniBand will not allow signal suppression for RECV completions,
+	 * see the 1.0.1 spec section 10.7.3.1, 10.8.6.
+	 * N.B. SIGNALLED has a different meaning in dapl than it does
+	 *      in IB; IB SIGNALLED is the same as DAPL SUPPRESS. DAPL
+	 *      SIGNALLED simply means the user will not get awakened when
+	 *      an EVD completes, even though the dapl handler is invoked.
+	 */
 
-    if (flags & DAT_COMPLETION_SUPPRESS_FLAG)
-    {
-	return DAT_INVALID_PARAMETER;
-    }
+	if (flags & DAT_COMPLETION_SUPPRESS_FLAG) {
+		return DAT_INVALID_PARAMETER;
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-DAT_RETURN
-dapl_ep_check_request_completion_flags (
-    DAT_COMPLETION_FLAGS        flags )
+DAT_RETURN dapl_ep_check_request_completion_flags(DAT_COMPLETION_FLAGS flags)
 {
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 DAT_RETURN
-dapl_ep_post_send_req (
-    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,
-    IN  DAPL_DTO_TYPE 		dto_type,
-    IN  int			op_type)
+dapl_ep_post_send_req(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,
+		      IN DAPL_DTO_TYPE dto_type, IN int op_type)
 {
-    DAPL_EP 		*ep_ptr;
-    DAPL_COOKIE		*cookie;
-    DAT_RETURN		dat_status;
+	DAPL_EP *ep_ptr;
+	DAPL_COOKIE *cookie;
+	DAT_RETURN dat_status;
 
-    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 send
-     * requests, which aren't allowed to race with each other.
-     */
-    dat_status = dapls_dto_cookie_alloc (
-		 &ep_ptr->req_buffer,
-		 dto_type,
-		 user_cookie,
-		 &cookie );
-    if (dat_status != DAT_SUCCESS) {
-	dapl_log(DAPL_DBG_TYPE_ERR,
-		 " dapl_post_req resource ERR:"
-		 " dtos pending = %d, max_dtos %d, max_cb %d hd %d tl %d\n",
-		 dapls_cb_pending(&ep_ptr->req_buffer),
-		 ep_ptr->param.ep_attr.max_request_dtos,
-		 ep_ptr->req_buffer.pool_size,
-		 ep_ptr->req_buffer.head,
-		 ep_ptr->req_buffer.tail);
+	/*
+	 * Synchronization ok since this buffer is only used for send
+	 * requests, which aren't allowed to race with each other.
+	 */
+	dat_status = dapls_dto_cookie_alloc(&ep_ptr->req_buffer,
+					    dto_type, user_cookie, &cookie);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " dapl_post_req resource ERR:"
+			 " dtos pending = %d, max_dtos %d, max_cb %d hd %d tl %d\n",
+			 dapls_cb_pending(&ep_ptr->req_buffer),
+			 ep_ptr->param.ep_attr.max_request_dtos,
+			 ep_ptr->req_buffer.pool_size,
+			 ep_ptr->req_buffer.head, ep_ptr->req_buffer.tail);
 
-	goto bail;
-    }
+		goto bail;
+	}
 
-    /*
-     * Invoke provider specific routine to post DTO
-     */
-    dat_status = dapls_ib_post_send ( ep_ptr,
-				      op_type,
-				      cookie,
-				      num_segments,
-				      local_iov,
-				      remote_iov,
-				      completion_flags );
+	/*
+	 * Invoke provider specific routine to post DTO
+	 */
+	dat_status = dapls_ib_post_send(ep_ptr,
+					op_type,
+					cookie,
+					num_segments,
+					local_iov,
+					remote_iov, completion_flags);
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-	dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);
-    }
+	if (dat_status != DAT_SUCCESS) {
+		dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 /*
  * dapli_ep_timeout
  *
  * If this routine is invoked before a connection occurs, generate an
  * event
  */
-void
-dapls_ep_timeout (
-	uintptr_t			arg )
+void dapls_ep_timeout(uintptr_t arg)
 {
-    DAPL_EP		*ep_ptr;
-    ib_cm_events_t	ib_cm_event;
+	DAPL_EP *ep_ptr;
+	ib_cm_events_t ib_cm_event;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_CM, "--> dapls_ep_timeout! ep %lx\n", arg);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, "--> dapls_ep_timeout! ep %lx\n", arg);
 
-    ep_ptr = (DAPL_EP *)arg;
+	ep_ptr = (DAPL_EP *) arg;
 
-    /* reset the EP state */
-    ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+	/* reset the EP state */
+	ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
 
-    /* Clean up the EP and put the underlying QP into the ERROR state.
-     * The disconnect_clean interface requires the provided dependent 
-     *cm event number.
-     */
-    ib_cm_event = dapls_ib_get_cm_event (DAT_CONNECTION_EVENT_DISCONNECTED);
-    dapls_ib_disconnect_clean ( ep_ptr,
-				DAT_TRUE,
-				ib_cm_event );
+	/* Clean up the EP and put the underlying QP into the ERROR state.
+	 * The disconnect_clean interface requires the provided dependent 
+	 *cm event number.
+	 */
+	ib_cm_event = dapls_ib_get_cm_event(DAT_CONNECTION_EVENT_DISCONNECTED);
+	dapls_ib_disconnect_clean(ep_ptr, DAT_TRUE, ib_cm_event);
 
-    (void) dapls_evd_post_connection_event (
-		(DAPL_EVD *)ep_ptr->param.connect_evd_handle,
-		DAT_CONNECTION_EVENT_TIMED_OUT,
-		(DAT_HANDLE) ep_ptr,
-		0,
-		0);
+	(void)dapls_evd_post_connection_event((DAPL_EVD *) ep_ptr->param.
+					      connect_evd_handle,
+					      DAT_CONNECTION_EVENT_TIMED_OUT,
+					      (DAT_HANDLE) ep_ptr, 0, 0);
 }
 
-
 /*
  * dapls_ep_state_subtype
  *
  * Return the INVALID_STATE connection subtype associated with an
  * INVALID_STATE on an EP. Strictly for error reporting.
  */
-DAT_RETURN_SUBTYPE
-dapls_ep_state_subtype (
-    IN  DAPL_EP			*ep_ptr )
+DAT_RETURN_SUBTYPE dapls_ep_state_subtype(IN DAPL_EP * ep_ptr)
 {
-    DAT_RETURN_SUBTYPE	dat_status;
+	DAT_RETURN_SUBTYPE dat_status;
 
-    switch ( ep_ptr->param.ep_state )
-    {
+	switch (ep_ptr->param.ep_state) {
 	case DAT_EP_STATE_UNCONNECTED:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_UNCONNECTED;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_UNCONNECTED;
+			break;
+		}
 	case DAT_EP_STATE_RESERVED:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_RESERVED;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_RESERVED;
+			break;
+		}
 	case DAT_EP_STATE_PASSIVE_CONNECTION_PENDING:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_PASSCONNPENDING;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_PASSCONNPENDING;
+			break;
+		}
 	case DAT_EP_STATE_ACTIVE_CONNECTION_PENDING:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_ACTCONNPENDING;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_ACTCONNPENDING;
+			break;
+		}
 	case DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_TENTCONNPENDING;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_TENTCONNPENDING;
+			break;
+		}
 	case DAT_EP_STATE_CONNECTED:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_CONNECTED;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_CONNECTED;
+			break;
+		}
 	case DAT_EP_STATE_DISCONNECT_PENDING:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_DISCPENDING;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_DISCPENDING;
+			break;
+		}
 	case DAT_EP_STATE_DISCONNECTED:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_DISCONNECTED;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_DISCONNECTED;
+			break;
+		}
 	case DAT_EP_STATE_COMPLETION_PENDING:
-	{
-	    dat_status = DAT_INVALID_STATE_EP_COMPLPENDING;
-	    break;
-	}
+		{
+			dat_status = DAT_INVALID_STATE_EP_COMPLPENDING;
+			break;
+		}
 
 	default:
-	{
-	    dat_status = 0;
-	    break;
+		{
+			dat_status = 0;
+			break;
+		}
 	}
-    }
 
-    return dat_status;
+	return dat_status;
 }
 
 #ifdef DAPL_DBG_IO_TRC
 /* allocate trace buffer */
-void
-dapls_io_trc_alloc (
-    DAPL_EP		*ep_ptr)
+void dapls_io_trc_alloc(DAPL_EP * ep_ptr)
 {
-    DAT_RETURN		dat_status;
-    int			i;
-    struct io_buf_track *ibt;
+	DAT_RETURN dat_status;
+	int i;
+	struct io_buf_track *ibt;
 
-    ep_ptr->ibt_dumped = 0;		/* bool to control how often we print */
-    dat_status = dapls_rbuf_alloc (&ep_ptr->ibt_queue, DBG_IO_TRC_QLEN);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
-    ibt = (struct io_buf_track *)dapl_os_alloc (sizeof (struct io_buf_track) * DBG_IO_TRC_QLEN);
+	ep_ptr->ibt_dumped = 0;	/* bool to control how often we print */
+	dat_status = dapls_rbuf_alloc(&ep_ptr->ibt_queue, DBG_IO_TRC_QLEN);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
+	ibt =
+	    (struct io_buf_track *)dapl_os_alloc(sizeof(struct io_buf_track) *
+						 DBG_IO_TRC_QLEN);
 
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapls_rbuf_destroy (&ep_ptr->ibt_queue);
-	goto bail;
-    }
-    ep_ptr->ibt_base = ibt;
-    dapl_os_memzero (ibt, sizeof (struct io_buf_track) * DBG_IO_TRC_QLEN);
+	if (dat_status != DAT_SUCCESS) {
+		dapls_rbuf_destroy(&ep_ptr->ibt_queue);
+		goto bail;
+	}
+	ep_ptr->ibt_base = ibt;
+	dapl_os_memzero(ibt, sizeof(struct io_buf_track) * DBG_IO_TRC_QLEN);
 
-    /* add events to free event queue */
-    for (i = 0; i < DBG_IO_TRC_QLEN; i++)
-    {
-	dapls_rbuf_add (&ep_ptr->ibt_queue, ibt++);
-    }
-bail:
-    return;
+	/* add events to free event queue */
+	for (i = 0; i < DBG_IO_TRC_QLEN; i++) {
+		dapls_rbuf_add(&ep_ptr->ibt_queue, ibt++);
+	}
+      bail:
+	return;
 }
-#endif /* DAPL_DBG_IO_TRC */
+#endif				/* DAPL_DBG_IO_TRC */
 
 /*
  * Generate a disconnect event on abruct close for older verbs providers 
@@ -566,57 +532,48 @@
  */
 
 void
-dapl_ep_legacy_post_disconnect(
-    DAPL_EP		*ep_ptr,
-    DAT_CLOSE_FLAGS	disconnect_flags)
+dapl_ep_legacy_post_disconnect(DAPL_EP * ep_ptr,
+			       DAT_CLOSE_FLAGS disconnect_flags)
 {
-    ib_cm_events_t	ib_cm_event;
-    DAPL_CR		*cr_ptr;
+	ib_cm_events_t ib_cm_event;
+	DAPL_CR *cr_ptr;
 
-    /*
-     * Acquire the lock and make sure we didn't get a callback
-     * that cleaned up.
-     */
-    dapl_os_lock ( &ep_ptr->header.lock );
-    if (disconnect_flags == DAT_CLOSE_ABRUPT_FLAG &&
-	ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING )
-    {
 	/*
-	 * If this is an ABRUPT close, the provider will not generate
-	 * a disconnect message so we do it manually here. Just invoke
-	 * the CM callback as it will clean up the appropriate
-	 * data structures, reset the state, and generate the event
-	 * on the way out. Obtain the provider dependent cm_event to 
-	 * pass into the callback for a disconnect.
+	 * Acquire the lock and make sure we didn't get a callback
+	 * that cleaned up.
 	 */
-	ib_cm_event = dapls_ib_get_cm_event (DAT_CONNECTION_EVENT_DISCONNECTED);
+	dapl_os_lock(&ep_ptr->header.lock);
+	if (disconnect_flags == DAT_CLOSE_ABRUPT_FLAG &&
+	    ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECT_PENDING) {
+		/*
+		 * If this is an ABRUPT close, the provider will not generate
+		 * a disconnect message so we do it manually here. Just invoke
+		 * the CM callback as it will clean up the appropriate
+		 * data structures, reset the state, and generate the event
+		 * on the way out. Obtain the provider dependent cm_event to 
+		 * pass into the callback for a disconnect.
+		 */
+		ib_cm_event =
+		    dapls_ib_get_cm_event(DAT_CONNECTION_EVENT_DISCONNECTED);
 
-	cr_ptr = ep_ptr->cr_ptr;
-	dapl_os_unlock ( &ep_ptr->header.lock );
+		cr_ptr = ep_ptr->cr_ptr;
+		dapl_os_unlock(&ep_ptr->header.lock);
 
-	if (cr_ptr != NULL)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
-		"    dapl_ep_disconnect force callback on EP %p CM handle %x\n",
-		 ep_ptr, cr_ptr->ib_cm_handle);
+		if (cr_ptr != NULL) {
+			dapl_dbg_log(DAPL_DBG_TYPE_API | DAPL_DBG_TYPE_CM,
+				     "    dapl_ep_disconnect force callback on EP %p CM handle %x\n",
+				     ep_ptr, cr_ptr->ib_cm_handle);
 
-	    dapls_cr_callback (cr_ptr->ib_cm_handle,
-			       ib_cm_event,
-			       NULL,
-			       cr_ptr->sp_ptr);
+			dapls_cr_callback(cr_ptr->ib_cm_handle,
+					  ib_cm_event, NULL, cr_ptr->sp_ptr);
+		} else {
+			dapl_evd_connection_callback(ep_ptr->cm_handle,
+						     ib_cm_event,
+						     NULL, (void *)ep_ptr);
+		}
+	} else {
+		dapl_os_unlock(&ep_ptr->header.lock);
 	}
-	else
-	{
-	    dapl_evd_connection_callback (ep_ptr->cm_handle,
-					  ib_cm_event,
-					  NULL,
-					  (void *) ep_ptr);
-	}
-    }
-    else
-    {
-	dapl_os_unlock ( &ep_ptr->header.lock );
-    }
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_connection_callb.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_connection_callb.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_connection_callb.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -42,7 +42,6 @@
 #include "dapl_ep_util.h"
 #include "dapl_timer_util.h"
 
-
 /*
  * dapl_evd_connection_callback
  *
@@ -63,190 +62,179 @@
  */
 
 void
-dapl_evd_connection_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,
-    IN    const void         	*context)
+dapl_evd_connection_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,
+			     IN const void *context)
 {
-    DAPL_EP		*ep_ptr;
-    DAPL_EVD		*evd_ptr;
-    DAPL_PRIVATE	*prd_ptr;
-    DAT_EVENT_NUMBER	dat_event_num;
-    DAT_RETURN		dat_status;
-    int			private_data_size;
+	DAPL_EP *ep_ptr;
+	DAPL_EVD *evd_ptr;
+	DAPL_PRIVATE *prd_ptr;
+	DAT_EVENT_NUMBER dat_event_num;
+	DAT_RETURN dat_status;
+	int private_data_size;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
+		     "--> dapl_evd_connection_callback: ctxt: %p event: %x cm_handle %p\n",
+		     context, ib_cm_event, (void *)ib_cm_handle);
 
-    dapl_dbg_log (
-	DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
-	"--> dapl_evd_connection_callback: ctxt: %p event: %x cm_handle %p\n",
-	context,
-	ib_cm_event,
-	(void *) ib_cm_handle );
+	/*
+	 * Determine the type of handle passed back to us in the context
+	 * and sort out key parameters.
+	 */
+	if (context == NULL
+	    || ((DAPL_HEADER *) context)->magic != DAPL_MAGIC_EP) {
+		return;
+	}
 
-    DAPL_CNTR(DCNT_EVD_CONN_CALLBACK);
+	/*
+	 * Active side of the connection, context is an EP and
+	 * PSP is irrelevant.
+	 */
+	ep_ptr = (DAPL_EP *) context;
+	evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
+	DAPL_CNTR(evd_ptr, DCNT_EVD_CONN_CALLBACK);
 
-    /*
-     * Determine the type of handle passed back to us in the context
-     * and sort out key parameters.
-     */
-    if ( context == NULL || ((DAPL_HEADER *)context)->magic != DAPL_MAGIC_EP)
-    {
-	return;
-    }
+	prd_ptr = (DAPL_PRIVATE *) private_data_ptr;
+	private_data_size = 0;
+	/*
+	 * All operations effect the EP, so lock it once and unlock
+	 * when necessary
+	 */
+	dapl_os_lock(&ep_ptr->header.lock);
 
-    /*
-     * Active side of the connection, context is an EP and
-     * PSP is irrelevant.
-     */
-    ep_ptr  = (DAPL_EP *) context;
-    evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
+	/*
+	 * If a connection timer has been set up on this EP, cancel it now
+	 */
+	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;
+	}
 
-    prd_ptr = (DAPL_PRIVATE *)private_data_ptr;
-    private_data_size = 0;
-    /*
-     * All operations effect the EP, so lock it once and unlock
-     * when necessary
-     */
-    dapl_os_lock (&ep_ptr->header.lock);
+	/* Obtain the event number from the provider layer */
+	dat_event_num = dapls_ib_get_dat_event(ib_cm_event, DAT_FALSE);
 
-    /*
-     * If a connection timer has been set up on this EP, cancel it now
-     */
-    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;
-    }
-
-    /* Obtain the event number from the provider layer */
-    dat_event_num = dapls_ib_get_dat_event (ib_cm_event, DAT_FALSE);
-
-    switch (dat_event_num)
-    {
+	switch (dat_event_num) {
 	case DAT_CONNECTION_EVENT_ESTABLISHED:
-	{
-	    /* If we don't have an EP at this point we are very screwed
-	     * up
-	     */
-	    if ( ep_ptr->param.ep_state != DAT_EP_STATE_ACTIVE_CONNECTION_PENDING)
-	    {
-		/* If someone pulled the plug on the connection, just
-		 * exit
-		 */
-		dapl_os_unlock ( &ep_ptr->header.lock );
-		dat_status = DAT_SUCCESS;
-		break;
-	    }
-	    ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
-	    ep_ptr->cm_handle      = ib_cm_handle;
-	    if (prd_ptr == NULL)
-	    {
-		private_data_size  = 0;
-	    }
-	    else
-	    {
-		private_data_size  = 
-		    dapls_ib_private_data_size(
-					prd_ptr, DAPL_PDATA_CONN_REP,
-		    			ep_ptr->header.owner_ia->hca_ptr);
-	    }
+		{
+			/* If we don't have an EP at this point we are very screwed
+			 * up
+			 */
+			if (ep_ptr->param.ep_state !=
+			    DAT_EP_STATE_ACTIVE_CONNECTION_PENDING) {
+				/* If someone pulled the plug on the connection, just
+				 * exit
+				 */
+				dapl_os_unlock(&ep_ptr->header.lock);
+				dat_status = DAT_SUCCESS;
+				break;
+			}
+			ep_ptr->param.ep_state = DAT_EP_STATE_CONNECTED;
+			ep_ptr->cm_handle = ib_cm_handle;
+			if (prd_ptr == NULL) {
+				private_data_size = 0;
+			} else {
+				private_data_size =
+				    dapls_ib_private_data_size(prd_ptr,
+							       DAPL_PDATA_CONN_REP,
+							       ep_ptr->header.
+							       owner_ia->
+							       hca_ptr);
+			}
 
-	    if (private_data_size > 0)
-	    {
-		/* copy in the private data */
-		dapl_os_memcpy ( ep_ptr->private.private_data,
-				 prd_ptr->private_data,
-				 DAPL_MIN (private_data_size, DAPL_MAX_PRIVATE_DATA_SIZE));
-	    }
-	    dapl_os_unlock (&ep_ptr->header.lock);
+			if (private_data_size > 0) {
+				/* copy in the private data */
+				dapl_os_memcpy(ep_ptr->private.private_data,
+					       prd_ptr->private_data,
+					       DAPL_MIN(private_data_size,
+							DAPL_MAX_PRIVATE_DATA_SIZE));
+			}
+			dapl_os_unlock(&ep_ptr->header.lock);
 
-	    break;
-	}
+			break;
+		}
 	case DAT_CONNECTION_EVENT_PEER_REJECTED:
-	{
-	    /* peer reject may include private data */
-	    if (prd_ptr != NULL) 
-		private_data_size  = 
-		    dapls_ib_private_data_size(
-					prd_ptr, DAPL_PDATA_CONN_REJ,
-		    			ep_ptr->header.owner_ia->hca_ptr);
+		{
+			/* peer reject may include private data */
+			if (prd_ptr != NULL)
+				private_data_size =
+				    dapls_ib_private_data_size(prd_ptr,
+							       DAPL_PDATA_CONN_REJ,
+							       ep_ptr->header.
+							       owner_ia->
+							       hca_ptr);
 
-	    if (private_data_size > 0) 
-		dapl_os_memcpy (ep_ptr->private.private_data,
-				prd_ptr->private_data,
-				DAPL_MIN (private_data_size, 
-                                          DAPL_MAX_PRIVATE_DATA_SIZE));
+			if (private_data_size > 0)
+				dapl_os_memcpy(ep_ptr->private.private_data,
+					       prd_ptr->private_data,
+					       DAPL_MIN(private_data_size,
+							DAPL_MAX_PRIVATE_DATA_SIZE));
 
-            dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
-			 "dapl_evd_connection_callback PEER REJ pd=%p sz=%d\n",
-			 prd_ptr, private_data_size);
-	}
+			dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
+				     "dapl_evd_connection_callback PEER REJ pd=%p sz=%d\n",
+				     prd_ptr, private_data_size);
+		}
 	case DAT_CONNECTION_EVENT_DISCONNECTED:
 	case DAT_CONNECTION_EVENT_UNREACHABLE:
 	case DAT_CONNECTION_EVENT_NON_PEER_REJECTED:
-	{
-	    ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
-	    dapls_ib_disconnect_clean (ep_ptr, DAT_TRUE, ib_cm_event);
-	    dapl_os_unlock (&ep_ptr->header.lock);
+		{
+			ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+			dapls_ib_disconnect_clean(ep_ptr, DAT_TRUE,
+						  ib_cm_event);
+			dapl_os_unlock(&ep_ptr->header.lock);
 
-	    break;
-	}
+			break;
+		}
 	case DAT_CONNECTION_EVENT_BROKEN:
 	case DAT_CONNECTION_EVENT_TIMED_OUT:
-	{
-	    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 );
+		{
+			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;
-	}
+			break;
+		}
 	case DAT_CONNECTION_REQUEST_EVENT:
 	default:
-	{
-	    dapl_os_unlock (&ep_ptr->header.lock);
-	    evd_ptr = NULL;
+		{
+			dapl_os_unlock(&ep_ptr->header.lock);
+			evd_ptr = NULL;
 
-	    dapl_os_assert (0);		/* shouldn't happen */
-	    break;
+			dapl_os_assert(0);	/* shouldn't happen */
+			break;
+		}
 	}
-    }
 
-    /*
-     * Post the event
-     * If the EP has been freed, the evd_ptr will be NULL
-     */
-    if ( evd_ptr != NULL )
-    {
-	dat_status = dapls_evd_post_connection_event (
-			evd_ptr,
-			dat_event_num,
-			(DAT_HANDLE) ep_ptr,
-			private_data_size, /* CONNECTED or REJECT */
-			ep_ptr->private.private_data );
+	/*
+	 * Post the event
+	 * If the EP has been freed, the evd_ptr will be NULL
+	 */
+	if (evd_ptr != NULL) {
+		dat_status = dapls_evd_post_connection_event(evd_ptr, dat_event_num, (DAT_HANDLE) ep_ptr, private_data_size,	/* CONNECTED or REJECT */
+							     ep_ptr->private.
+							     private_data);
 
-	if (dat_status != DAT_SUCCESS && 
-	    dat_event_num == DAT_CONNECTION_EVENT_ESTABLISHED)
-	{
-	    /* We can't tell the user we are connected, something
-	     * is wrong locally. Just kill the connection and
-	     * reset the state to DISCONNECTED as we don't
-	     * expect a callback on an ABRUPT disconnect.
-	     */
-	    dapls_ib_disconnect (ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
-	    dapl_os_lock (&ep_ptr->header.lock);
-	    ep_ptr->param.ep_state  = DAT_EP_STATE_DISCONNECTED;
-	    dapl_os_unlock (&ep_ptr->header.lock);
+		if (dat_status != DAT_SUCCESS &&
+		    dat_event_num == DAT_CONNECTION_EVENT_ESTABLISHED) {
+			/* We can't tell the user we are connected, something
+			 * is wrong locally. Just kill the connection and
+			 * reset the state to DISCONNECTED as we don't
+			 * expect a callback on an ABRUPT disconnect.
+			 */
+			dapls_ib_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
+			dapl_os_lock(&ep_ptr->header.lock);
+			ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+			dapl_os_unlock(&ep_ptr->header.lock);
+		}
 	}
-    }
 
-    dapl_dbg_log (DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
-		  "dapl_evd_connection_callback () returns\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_CM | DAPL_DBG_TYPE_CALLBACK,
+		     "dapl_evd_connection_callback () returns\n");
 
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_cq_async_error_callb.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_cq_async_error_callb.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_cq_async_error_callb.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -53,44 +53,38 @@
  *
  */
 
-void 
-dapl_evd_cq_async_error_callback (
-	IN	ib_hca_handle_t 	ib_hca_handle,
-	IN	ib_cq_handle_t		ib_cq_handle,
-	IN	ib_error_record_t *	cause_ptr,
-	IN	void *			context)
-
+void
+dapl_evd_cq_async_error_callback(IN ib_hca_handle_t ib_hca_handle,
+				 IN ib_cq_handle_t ib_cq_handle,
+				 IN ib_error_record_t * cause_ptr,
+				 IN void *context)
 {
-    DAPL_EVD		*async_evd;
-    DAPL_EVD		*evd;
-    DAT_RETURN		dat_status;
+	DAPL_EVD *async_evd;
+	DAPL_EVD *evd;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION ,
-		  "dapl_evd_cq_async_error_callback (%p, %p, %p, %p)\n",
-		  ib_hca_handle, 
-		  ib_cq_handle, 
-		  cause_ptr, 
-		  context);
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
+		     "dapl_evd_cq_async_error_callback (%p, %p, %p, %p)\n",
+		     ib_hca_handle, ib_cq_handle, cause_ptr, context);
 
-    if ( NULL == context )
-    {
-	dapl_os_panic ("NULL == context\n");
-    }
+	if (NULL == context) {
+		dapl_os_panic("NULL == context\n");
+	}
 
-    evd = (DAPL_EVD *) context;
-    async_evd = evd->header.owner_ia->async_error_evd;
+	evd = (DAPL_EVD *) context;
+	async_evd = evd->header.owner_ia->async_error_evd;
+	DAPL_CNTR(evd->header.owner_ia, DCNT_IA_ASYNC_CQ_ERROR);
 
-    dat_status = dapls_evd_post_async_error_event(
-	async_evd,
-	DAT_ASYNC_ERROR_EVD_OVERFLOW,
-	(DAT_IA_HANDLE) async_evd->header.owner_ia);
+	dat_status = dapls_evd_post_async_error_event(async_evd,
+						      DAT_ASYNC_ERROR_EVD_OVERFLOW,
+						      (DAT_IA_HANDLE)
+						      async_evd->header.
+						      owner_ia);
 
+	if (dat_status != DAT_SUCCESS) {
+		dapl_os_panic("async EVD overflow\n");
+	}
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-	dapl_os_panic ("async EVD overflow\n");
-    }
-
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION ,
-		  "dapl_evd_cq_async_error_callback () returns\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
+		     "dapl_evd_cq_async_error_callback () returns\n");
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dequeue.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dequeue.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dequeue.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -62,85 +62,73 @@
  * 	DAT_QUEUE_EMPTY
  */
 
-DAT_RETURN DAT_API dapl_evd_dequeue (
-    IN    DAT_EVD_HANDLE	evd_handle,
-    OUT   DAT_EVENT		*event)
-
+DAT_RETURN DAT_API dapl_evd_dequeue(IN DAT_EVD_HANDLE evd_handle,
+				    OUT DAT_EVENT * event)
 {
-    DAPL_EVD	*evd_ptr;
-    DAT_EVENT	*local_event;
-    DAT_RETURN	dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_EVENT *local_event;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_evd_dequeue (%p, %p)\n",
-		  evd_handle, 
-		  event);
-    DAPL_CNTR(DCNT_EVD_DEQUEUE);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_evd_dequeue (%p, %p)\n", evd_handle, event);
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if (DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
 
-    if (event == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	if (event == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
+	DAPL_CNTR(evd_ptr, DCNT_EVD_DEQUEUE);
 
-    /*
-     * We need to dequeue under lock, as the IB OS Access API
-     * restricts us from having multiple threads in CQ poll, and the
-     * DAPL 1.1 API allows multiple threads in dat_evd_dequeue()
-     */
-    dapl_os_lock ( &evd_ptr->header.lock );
+	/*
+	 * We need to dequeue under lock, as the IB OS Access API
+	 * restricts us from having multiple threads in CQ poll, and the
+	 * DAPL 1.1 API allows multiple threads in dat_evd_dequeue()
+	 */
+	dapl_os_lock(&evd_ptr->header.lock);
 
-    /*
-     * Make sure there are no other waiters and the evd is active.
-     * Currently this means only the OPEN state is allowed.
-     */
-    if (evd_ptr->evd_state != DAPL_EVD_STATE_OPEN || 
-	evd_ptr->catastrophic_overflow)
-    {
-	dapl_os_unlock ( &evd_ptr->header.lock );
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,0);
-	goto bail;
-    }
+	/*
+	 * Make sure there are no other waiters and the evd is active.
+	 * Currently this means only the OPEN state is allowed.
+	 */
+	if (evd_ptr->evd_state != DAPL_EVD_STATE_OPEN ||
+	    evd_ptr->catastrophic_overflow) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+		dat_status = DAT_ERROR(DAT_INVALID_STATE, 0);
+		goto bail;
+	}
 
-    /*
-     * Try the EVD rbuf first; poll from the CQ only if that's empty.
-     * This keeps events in order if dat_evd_wait() has copied events
-     * from CQ to EVD.  
-     */
-    local_event = (DAT_EVENT *)dapls_rbuf_remove (&evd_ptr->pending_event_queue);
-    if (local_event != NULL)
-    {
-	*event = *local_event;
-	dat_status = dapls_rbuf_add (&evd_ptr->free_event_queue, 
-				     local_event);
-	DAPL_CNTR(DCNT_EVD_DEQUEUE_FOUND);
-    }
-    else if (evd_ptr->ib_cq_handle != IB_INVALID_HANDLE)
-    {
-	dat_status = dapls_evd_cq_poll_to_event(evd_ptr, event);
-	DAPL_CNTR(DCNT_EVD_DEQUEUE_POLL);
-    }
-    else
-    {
-	dat_status = DAT_ERROR (DAT_QUEUE_EMPTY,0);
-	DAPL_CNTR(DCNT_EVD_DEQUEUE_NOT_FOUND);
-    }
+	/*
+	 * Try the EVD rbuf first; poll from the CQ only if that's empty.
+	 * This keeps events in order if dat_evd_wait() has copied events
+	 * from CQ to EVD.  
+	 */
+	local_event =
+	    (DAT_EVENT *) dapls_rbuf_remove(&evd_ptr->pending_event_queue);
+	if (local_event != NULL) {
+		*event = *local_event;
+		dat_status = dapls_rbuf_add(&evd_ptr->free_event_queue,
+					    local_event);
+		DAPL_CNTR(evd_ptr, DCNT_EVD_DEQUEUE_FOUND);
 
-    dapl_os_unlock ( &evd_ptr->header.lock );
- bail:
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-		  "dapl_evd_dequeue () returns 0x%x\n", 
-		  dat_status);
+	} else if (evd_ptr->ib_cq_handle != IB_INVALID_HANDLE) {
+		dat_status = dapls_evd_cq_poll_to_event(evd_ptr, event);
+		DAPL_CNTR(evd_ptr, DCNT_EVD_DEQUEUE_POLL);
+	} else {
+		dat_status = DAT_ERROR(DAT_QUEUE_EMPTY, 0);
+		DAPL_CNTR(evd_ptr, DCNT_EVD_DEQUEUE_NOT_FOUND);
+	}
 
-    return dat_status;
-}
+	dapl_os_unlock(&evd_ptr->header.lock);
+      bail:
+	dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+		     "dapl_evd_dequeue () returns 0x%x\n", dat_status);
 
+	return dat_status;
+}

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dto_callb.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dto_callb.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_dto_callb.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -46,7 +46,6 @@
  *                                                                   *
  *********************************************************************/
 
-
 /*********************************************************************
  *                                                                   *
  * Function Definitions                                              *
@@ -69,94 +68,91 @@
  *
  */
 
-void 
-dapl_evd_dto_callback (
-    IN ib_hca_handle_t 	hca_handle, 
-    IN ib_cq_handle_t 	cq_handle, 
-    IN void* 		user_context)
+void
+dapl_evd_dto_callback(IN ib_hca_handle_t hca_handle,
+		      IN ib_cq_handle_t cq_handle, IN void *user_context)
 {
-    DAPL_EVD 		*evd_ptr;
-    DAT_RETURN          dat_status;
-    DAPL_EVD_STATE	state;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
+	DAPL_EVD_STATE state;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "dapl_evd_dto_callback(%p, %p, %p)\n",
-		  hca_handle, 
-		  cq_handle, 
-		  user_context);
-    DAPL_CNTR(DCNT_EVD_DTO_CALLBACK);
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "dapl_evd_dto_callback(%p, %p, %p)\n",
+		     hca_handle, cq_handle, user_context);
 
-    evd_ptr = (DAPL_EVD *) user_context;
+	evd_ptr = (DAPL_EVD *) user_context;
+	DAPL_CNTR(evd_ptr, DCNT_EVD_DTO_CALLBACK);
 
-    dapl_os_assert (hca_handle == evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle);
-    dapl_os_assert (evd_ptr->ib_cq_handle == cq_handle);
-    dapl_os_assert (evd_ptr->header.magic == DAPL_MAGIC_EVD);
+	dapl_os_assert(hca_handle ==
+		       evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle);
+	dapl_os_assert(evd_ptr->ib_cq_handle == cq_handle);
+	dapl_os_assert(evd_ptr->header.magic == DAPL_MAGIC_EVD);
 
-    /* Read once.  */
-    state = *(volatile DAPL_EVD_STATE *) &evd_ptr->evd_state;
+	/* Read once.  */
+	state = *(volatile DAPL_EVD_STATE *)&evd_ptr->evd_state;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_EVD, 
-		  "-- dapl_evd_dto_callback: CQ %p, state %x\n", 
-		  (void *)evd_ptr->ib_cq_handle, 
-		  state);
+	dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+		     "-- dapl_evd_dto_callback: CQ %p, state %x\n",
+		     (void *)evd_ptr->ib_cq_handle, state);
 
-    /*
-     * This function does not dequeue from the CQ; only the consumer
-     * can do that. Instead, it wakes up waiters if any exist.
-     * It rearms the completion only if completions should always occur
-     * (specifically if a CNO is associated with the EVD and the
-     * EVD is enabled.
-     */
-       
-    if (state == DAPL_EVD_STATE_WAITED)
-    {
 	/*
-	 * If we could, it would be best to avoid this wakeup
-	 * (and the context switch) unless the number of events/CQs
-	 * waiting for the waiter was its threshold.  We don't
-	 * currently have the ability to determine that without
-	 * dequeueing the events, and we can't do that for
-	 * synchronization reasons (racing with the waiter waking
-	 * up and dequeuing, sparked by other callbacks).
+	 * This function does not dequeue from the CQ; only the consumer
+	 * can do that. Instead, it wakes up waiters if any exist.
+	 * It rearms the completion only if completions should always occur
+	 * (specifically if a CNO is associated with the EVD and the
+	 * EVD is enabled.
 	 */
 
-	/*
-	 * We don't need to worry about taking the lock for the
-	 * wakeup because wakeups are sticky.
-	 */
+	if (state == DAPL_EVD_STATE_WAITED) {
+		/*
+		 * If we could, it would be best to avoid this wakeup
+		 * (and the context switch) unless the number of events/CQs
+		 * waiting for the waiter was its threshold.  We don't
+		 * currently have the ability to determine that without
+		 * dequeueing the events, and we can't do that for
+		 * synchronization reasons (racing with the waiter waking
+		 * up and dequeuing, sparked by other callbacks).
+		 */
+
+		/*
+		 * We don't need to worry about taking the lock for the
+		 * wakeup because wakeups are sticky.
+		 */
 #ifdef CQ_WAIT_OBJECT
-        if (evd_ptr->cq_wait_obj_handle)
-	    dapls_ib_wait_object_wakeup (evd_ptr->cq_wait_obj_handle);
-	else
+		if (evd_ptr->cq_wait_obj_handle)
+			dapls_ib_wait_object_wakeup(evd_ptr->
+						    cq_wait_obj_handle);
+		else
 #endif
-	    dapl_os_wait_object_wakeup (&evd_ptr->wait_object);
+			dapl_os_wait_object_wakeup(&evd_ptr->wait_object);
 
-    }
-    else if (state == DAPL_EVD_STATE_OPEN)
-    {
-	DAPL_CNO *cno = evd_ptr->cno_ptr;
-	if (evd_ptr->evd_enabled && (evd_ptr->cno_ptr != NULL))
-	{
-	    /*
-	     * Re-enable callback, *then* trigger.
-	     * This guarantees we won't miss any events.
-	     */
-	    dat_status = dapls_ib_completion_notify (hca_handle, 
-						     evd_ptr,
-						     IB_NOTIFY_ON_NEXT_COMP);
-	    
-            if ( DAT_SUCCESS != dat_status )
-            {
-                (void) dapls_evd_post_async_error_event(
-                    evd_ptr->header.owner_ia->async_error_evd,
-                    DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR,
-                    (DAT_IA_HANDLE) evd_ptr->header.owner_ia);
-            }
+	} else if (state == DAPL_EVD_STATE_OPEN) {
+		DAPL_CNO *cno = evd_ptr->cno_ptr;
+		if (evd_ptr->evd_enabled && (evd_ptr->cno_ptr != NULL)) {
+			/*
+			 * Re-enable callback, *then* trigger.
+			 * This guarantees we won't miss any events.
+			 */
+			dat_status = dapls_ib_completion_notify(hca_handle,
+								evd_ptr,
+								IB_NOTIFY_ON_NEXT_COMP);
 
-	    dapl_internal_cno_trigger(cno, evd_ptr);
+			if (DAT_SUCCESS != dat_status) {
+				(void)dapls_evd_post_async_error_event(evd_ptr->
+								       header.
+								       owner_ia->
+								       async_error_evd,
+								       DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR,
+								       (DAT_IA_HANDLE)
+								       evd_ptr->
+								       header.
+								       owner_ia);
+			}
+
+			dapl_internal_cno_trigger(cno, evd_ptr);
+		}
 	}
-    }
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN, "dapl_evd_dto_callback () returns\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_RTN, "dapl_evd_dto_callback () returns\n");
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -39,7 +39,7 @@
 #include "dapl.h"
 #include "dapl_evd_util.h"
 #include "dapl_ia_util.h"
-#include "dapl_cno_util.h"		/* for __KDAPL__ */
+#include "dapl_cno_util.h"	/* for __KDAPL__ */
 
 /*
  * dapl_evd_free
@@ -59,77 +59,72 @@
  *     DAT_INVALID_HANDLE
  *     DAT_INVALID_STATE
  */
-DAT_RETURN DAT_API dapl_evd_free (
-    IN    DAT_EVD_HANDLE    evd_handle)
-
+DAT_RETURN DAT_API dapl_evd_free(IN DAT_EVD_HANDLE evd_handle)
 {
-    DAPL_EVD    *evd_ptr;
-    DAPL_CNO	*cno_ptr;
-    DAT_RETURN  dat_status;
+	DAPL_EVD *evd_ptr;
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_evd_free (%p)\n", evd_handle);
-    DAPL_CNTR (DCNT_EVD_FREE);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_evd_free (%p)\n", evd_handle);
 
-    dat_status = DAT_SUCCESS;
-    evd_ptr = (DAPL_EVD *)evd_handle;
+	dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
 
-    if (DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, 0);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
 
-    if (dapl_os_atomic_read (&evd_ptr->evd_ref_count) != 0)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_EVD_IN_USE);
-	goto bail;
-    }
+	DAPL_CNTR(evd_ptr->header.owner_ia, DCNT_IA_EVD_FREE);
 
-    /* obtain the cno_ptr before the evd is released, which must occur
-     * before deallocating the CNO
-     */
-    cno_ptr = evd_ptr->cno_ptr;
+	if (dapl_os_atomic_read(&evd_ptr->evd_ref_count) != 0) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_EVD_IN_USE);
+		goto bail;
+	}
 
-    dapl_ia_unlink_evd (evd_ptr->header.owner_ia, evd_ptr);
+	/* obtain the cno_ptr before the evd is released, which must occur
+	 * before deallocating the CNO
+	 */
+	cno_ptr = evd_ptr->cno_ptr;
 
-    dat_status = dapls_evd_dealloc (evd_ptr);
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_ia_link_evd (evd_ptr->header.owner_ia, evd_ptr);
-    }
+	dapl_ia_unlink_evd(evd_ptr->header.owner_ia, evd_ptr);
 
+	dat_status = dapls_evd_dealloc(evd_ptr);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_ia_link_evd(evd_ptr->header.owner_ia, evd_ptr);
+	}
 #if defined(__KDAPL__)
-    if (cno_ptr != NULL)
-    {
-	if (dapl_os_atomic_read (&cno_ptr->cno_ref_count) > 0 || cno_ptr->cno_waiters > 0)
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_STATE,
-				    DAT_INVALID_STATE_EVD_IN_USE);
-	    goto bail;
+	if (cno_ptr != NULL) {
+		if (dapl_os_atomic_read(&cno_ptr->cno_ref_count) > 0
+		    || cno_ptr->cno_waiters > 0) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_STATE,
+				      DAT_INVALID_STATE_EVD_IN_USE);
+			goto bail;
+		}
+		dapl_ia_unlink_cno(cno_ptr->header.owner_ia, cno_ptr);
+		dapl_cno_dealloc(cno_ptr);
 	}
-	dapl_ia_unlink_cno (cno_ptr->header.owner_ia, cno_ptr);
-	dapl_cno_dealloc (cno_ptr);
-    }
 #else
-    if (cno_ptr != NULL)
-    {
-	if (dapl_os_atomic_read(&cno_ptr->cno_ref_count) == 0 && cno_ptr->cno_waiters > 0)
-	{
-	    /*
-	     * Last reference on the CNO, trigger a notice. See
-	     * uDAPL 1.1 spec 6.3.2.3
-	     */
-	    dapl_internal_cno_trigger (cno_ptr, NULL);
+	if (cno_ptr != NULL) {
+		if (dapl_os_atomic_read(&cno_ptr->cno_ref_count) == 0
+		    && cno_ptr->cno_waiters > 0) {
+			/*
+			 * Last reference on the CNO, trigger a notice. See
+			 * uDAPL 1.1 spec 6.3.2.3
+			 */
+			dapl_internal_cno_trigger(cno_ptr, NULL);
+		}
 	}
-    }
-#endif	/* defined(__KDAPL__) */
+#endif				/* defined(__KDAPL__) */
 
-bail:
-    if ( dat_status )
-        dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-			"dapl_evd_free () returns 0x%x\n", dat_status);
+      bail:
+	if (dat_status)
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+			     "dapl_evd_free () returns 0x%x\n", dat_status);
 
-    return dat_status;
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_post_se.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_post_se.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_post_se.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,46 +59,39 @@
  * 	DAT_INVALID_PARAMETER
  */
 
-
-DAT_RETURN DAT_API dapl_evd_post_se (
-	DAT_EVD_HANDLE		evd_handle,	
-	const DAT_EVENT		*event)
-
+DAT_RETURN DAT_API dapl_evd_post_se(DAT_EVD_HANDLE evd_handle,
+				    const DAT_EVENT * event)
 {
-    DAPL_EVD	*evd_ptr;
-    DAT_RETURN	dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if (DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    /* Only post to EVDs that are specific to software events */
-    if ( !(evd_ptr->evd_flags & DAT_EVD_SOFTWARE_FLAG) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG1);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	/* Only post to EVDs that are specific to software events */
+	if (!(evd_ptr->evd_flags & DAT_EVD_SOFTWARE_FLAG)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+		goto bail;
+	}
 
-    if (!event)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
-    if (event->event_number != DAT_SOFTWARE_EVENT)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	if (!event) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
+	if (event->event_number != DAT_SOFTWARE_EVENT) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    dat_status = dapls_evd_post_software_event(
-	evd_ptr,
-	DAT_SOFTWARE_EVENT,
-	event->event_data.software_event_data.pointer);
+	dat_status = dapls_evd_post_software_event(evd_ptr,
+						   DAT_SOFTWARE_EVENT,
+						   event->event_data.
+						   software_event_data.pointer);
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_qp_async_error_callb.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_qp_async_error_callb.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_qp_async_error_callb.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,100 +54,96 @@
  *
  */
 
-void 
-dapl_evd_qp_async_error_callback (
-	IN	ib_hca_handle_t 	ib_hca_handle,
-	IN	ib_qp_handle_t		ib_qp_handle,
-	IN	ib_error_record_t *	cause_ptr,
-	IN	void *			context)
-
+void
+dapl_evd_qp_async_error_callback(IN ib_hca_handle_t ib_hca_handle,
+				 IN ib_qp_handle_t ib_qp_handle,
+				 IN ib_error_record_t * cause_ptr,
+				 IN void *context)
 {
-    /*
-     * This is an affiliated error and hence should be able to 
-     * supply us with exact information on the error type and QP. 
-     *
-     * However the Mellanox and IBM APIs for registering this callback 
-     * are different. 
-     *
-     * The IBM API allows consumers to register the callback with 
-     *
-     * ib_int32_t 
-     * ib_set_qp_async_error_eh_us (
-     * 		ib_hca_handle_t 	hca_handle,
-     * 		ib_qp_async_handler_t 	handler )
-     *
-     * Notice that this function does not take a context. The context is 
-     * specified per QP in the call to ib_qp_create_us().
-     *
-     * In contrast the Mellanox API requires that the context be specified 
-     * when the funciton is registered:
-     *
-     * VAPI_ret_t 
-     * VAPI_set_async_event_handler (
-     * 		IN VAPI_hca_hndl_t 		hca_hndl,
-     * 		IN VAPI_async_event_handler_t 	handler,
-     * 		IN void* 			private_data )
-     *
-     * Therefore we always specify the context as the asyncronous EVD 
-     * to be compatible with both APIs.
-     */
+	/*
+	 * This is an affiliated error and hence should be able to 
+	 * supply us with exact information on the error type and QP. 
+	 *
+	 * However the Mellanox and IBM APIs for registering this callback 
+	 * are different. 
+	 *
+	 * The IBM API allows consumers to register the callback with 
+	 *
+	 * ib_int32_t 
+	 * ib_set_qp_async_error_eh_us (
+	 *          ib_hca_handle_t         hca_handle,
+	 *          ib_qp_async_handler_t   handler )
+	 *
+	 * Notice that this function does not take a context. The context is 
+	 * specified per QP in the call to ib_qp_create_us().
+	 *
+	 * In contrast the Mellanox API requires that the context be specified 
+	 * when the funciton is registered:
+	 *
+	 * VAPI_ret_t 
+	 * VAPI_set_async_event_handler (
+	 *          IN VAPI_hca_hndl_t              hca_hndl,
+	 *          IN VAPI_async_event_handler_t   handler,
+	 *          IN void*                        private_data )
+	 *
+	 * Therefore we always specify the context as the asyncronous EVD 
+	 * to be compatible with both APIs.
+	 */
 
-    DAPL_IA		*ia_ptr;
-    DAPL_EP		*ep_ptr;
-    DAPL_EVD		*async_evd;
-    DAT_EVENT_NUMBER	async_event;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_EP *ep_ptr;
+	DAPL_EVD *async_evd;
+	DAT_EVENT_NUMBER async_event;
+	DAT_RETURN dat_status;
 
 #ifdef _VENDOR_IBAL_
-    dapl_dbg_log (DAPL_DBG_TYPE_ERR,"%s() IB err %s\n",
-			__FUNCTION__, ib_get_async_event_str(cause_ptr->code));
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, "%s() IB err %s\n",
+		     __FUNCTION__, ib_get_async_event_str(cause_ptr->code));
 #else
-    dapl_dbg_log (DAPL_DBG_TYPE_ERR,"%s() IB async QP err - ctx=%p\n",
-			__FUNCTION__, context);
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, "%s() IB async QP err - ctx=%p\n",
+		     __FUNCTION__, context);
 #endif
 
-    ep_ptr    = (DAPL_EP *) context;
-    if ( !ep_ptr ) {
-        dapl_dbg_log (DAPL_DBG_TYPE_ERR,"%s() NULL context?\n",__FUNCTION__);
-        return;
-    }
+	ep_ptr = (DAPL_EP *) context;
+	if (!ep_ptr) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR, "%s() NULL context?\n",
+			     __FUNCTION__);
+		return;
+	}
 
-    ia_ptr    = ep_ptr->header.owner_ia;
-    async_evd = (DAPL_EVD *) ia_ptr->async_error_evd;
+	ia_ptr = ep_ptr->header.owner_ia;
+	async_evd = (DAPL_EVD *) ia_ptr->async_error_evd;
+	DAPL_CNTR(ia_ptr, DCNT_IA_ASYNC_QP_ERROR);
 
-    dapl_dbg_log (
-	DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
-	"--> %s: ep %p qp %p (%x) state %d\n", __FUNCTION__,
-	ep_ptr, 
-	ep_ptr->qp_handle, 
-	ep_ptr->qpn,
-	ep_ptr->param.ep_state);
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
+		     "--> %s: ep %p qp %p (%x) state %d\n", __FUNCTION__,
+		     ep_ptr,
+		     ep_ptr->qp_handle, ep_ptr->qpn, ep_ptr->param.ep_state);
 
-    /*
-     * Transition to ERROR if we are connected; other states need to
-     * complete first (e.g. pending states)
-     */
-    if ( ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED)
-    {
-	ep_ptr->param.ep_state = DAT_EP_STATE_ERROR;
-    }
-
-    dapl_os_assert (async_evd != NULL);
-
-    dat_status = dapls_ib_get_async_event(cause_ptr, &async_event);
-    if ( dat_status == DAT_SUCCESS )
-    {
 	/*
-	 * If dapls_ib_get_async_event is not successful,
-	 * an event has been generated by the provide that
-	 * we are not interested in.
+	 * Transition to ERROR if we are connected; other states need to
+	 * complete first (e.g. pending states)
 	 */
-	(void) dapls_evd_post_async_error_event( async_evd,
-					      async_event,
-					      async_evd->header.owner_ia);
-    }
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
-		  "%s() returns\n",__FUNCTION__);
+	if (ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED) {
+		ep_ptr->param.ep_state = DAT_EP_STATE_ERROR;
+	}
+
+	dapl_os_assert(async_evd != NULL);
+
+	dat_status = dapls_ib_get_async_event(cause_ptr, &async_event);
+	if (dat_status == DAT_SUCCESS) {
+		/*
+		 * If dapls_ib_get_async_event is not successful,
+		 * an event has been generated by the provide that
+		 * we are not interested in.
+		 */
+		(void)dapls_evd_post_async_error_event(async_evd,
+						       async_event,
+						       async_evd->header.
+						       owner_ia);
+	}
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
+		     "%s() returns\n", __FUNCTION__);
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_resize.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_resize.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_resize.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -36,7 +36,7 @@
  *
  * $Id:$
  **********************************************************************/
- 
+
 #include "dapl.h"
 #include "dapl_evd_util.h"
 #include "dapl_ring_buffer_util.h"
@@ -63,76 +63,68 @@
  * 	DAT_INVALID_STATE
  */
 
-DAT_RETURN DAT_API dapl_evd_resize (
-	IN	DAT_EVD_HANDLE	   evd_handle,
-	IN	DAT_COUNT	   evd_qlen )
+DAT_RETURN DAT_API dapl_evd_resize(IN DAT_EVD_HANDLE evd_handle,
+				   IN DAT_COUNT evd_qlen)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_EVD		*evd_ptr;
-    DAT_COUNT   	pend_cnt;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_EVD *evd_ptr;
+	DAT_COUNT pend_cnt;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_evd_resize (%p, %d)\n",
-		  evd_handle, evd_qlen);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_evd_resize (%p, %d)\n",
+		     evd_handle, evd_qlen);
 
-    if (DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE1);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1);
+		goto bail;
+	}
 
-    evd_ptr     = (DAPL_EVD *)evd_handle;
-    ia_ptr      = evd_ptr->header.owner_ia;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	ia_ptr = evd_ptr->header.owner_ia;
 
-    if ( evd_qlen == evd_ptr->qlen )
-    {
-	 dat_status = DAT_SUCCESS;
-	 goto bail;
-    }
+	if (evd_qlen == evd_ptr->qlen) {
+		dat_status = DAT_SUCCESS;
+		goto bail;
+	}
 
-    if ( evd_qlen > ia_ptr->hca_ptr->ia_attr.max_evd_qlen )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	if (evd_qlen > ia_ptr->hca_ptr->ia_attr.max_evd_qlen) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    dapl_os_lock(&evd_ptr->header.lock);
+	dapl_os_lock(&evd_ptr->header.lock);
 
-    /* Don't try to resize if we are actively waiting */
-    if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED)
-    {
-        dapl_os_unlock(&evd_ptr->header.lock);
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,0);
-	goto bail;
-    }
+	/* Don't try to resize if we are actively waiting */
+	if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+		dat_status = DAT_ERROR(DAT_INVALID_STATE, 0);
+		goto bail;
+	}
 
-    pend_cnt = dapls_rbuf_count(&evd_ptr->pending_event_queue);
-    if (pend_cnt > evd_qlen) {
-	dapl_os_unlock(&evd_ptr->header.lock);
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,0);
-	goto bail;
-    }
+	pend_cnt = dapls_rbuf_count(&evd_ptr->pending_event_queue);
+	if (pend_cnt > evd_qlen) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+		dat_status = DAT_ERROR(DAT_INVALID_STATE, 0);
+		goto bail;
+	}
 
-    dat_status = dapls_ib_cq_resize(evd_ptr->header.owner_ia,
-				    evd_ptr,
-				    &evd_qlen);
-    if (dat_status != DAT_SUCCESS)
-    {
-        dapl_os_unlock(&evd_ptr->header.lock);
-	goto bail;
-    }
+	dat_status = dapls_ib_cq_resize(evd_ptr->header.owner_ia,
+					evd_ptr, &evd_qlen);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+		goto bail;
+	}
 
-    dat_status = dapls_evd_event_realloc (evd_ptr, evd_qlen);
-    if (dat_status != DAT_SUCCESS)
-    {
-        dapl_os_unlock(&evd_ptr->header.lock);
-	goto bail;
-    }
+	dat_status = dapls_evd_event_realloc(evd_ptr, evd_qlen);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+		goto bail;
+	}
 
-    dapl_os_unlock(&evd_ptr->header.lock);
+	dapl_os_unlock(&evd_ptr->header.lock);
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_un_async_error_callb.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_un_async_error_callb.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_un_async_error_callb.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,45 +54,39 @@
  *
  */
 
-void 
-dapl_evd_un_async_error_callback (
-	IN	ib_hca_handle_t		ib_hca_handle,
-	IN	ib_error_record_t *	cause_ptr,
-	IN	void *			context)
-
+void
+dapl_evd_un_async_error_callback(IN ib_hca_handle_t ib_hca_handle,
+				 IN ib_error_record_t * cause_ptr,
+				 IN void *context)
 {
-    DAPL_EVD		*async_evd;
-    DAT_EVENT_NUMBER	async_event;
-    DAT_RETURN		dat_status;
+	DAPL_EVD *async_evd;
+	DAT_EVENT_NUMBER async_event;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
-		  "dapl_evd_un_async_error_callback (%p, %p, %p)\n", 
-		  ib_hca_handle, 
-		  cause_ptr, 
-		  context);
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
+		     "dapl_evd_un_async_error_callback (%p, %p, %p)\n",
+		     ib_hca_handle, cause_ptr, context);
 
-    if ( NULL == context )
-    {
-	dapl_os_panic ("NULL == context\n");
-	return;
-    }
+	if (NULL == context) {
+		dapl_os_panic("NULL == context\n");
+		return;
+	}
 
-    async_evd = (DAPL_EVD *) context;
+	async_evd = (DAPL_EVD *) context;
+	DAPL_CNTR(async_evd->header.owner_ia, DCNT_IA_ASYNC_ERROR);
 
-    dat_status = dapls_ib_get_async_event(cause_ptr, &async_event);
+	dat_status = dapls_ib_get_async_event(cause_ptr, &async_event);
 
-    if ( dat_status == DAT_SUCCESS )
-    {
-	/*
-	 * If dapls_ib_get_async_event is not successful,
-	 * an event has been generated by the provider that
-	 * we are not interested in. E.g. LINK_UP.
-	 */
-	dapls_evd_post_async_error_event( async_evd,
-					  async_event,
-					  async_evd->header.owner_ia);
-    }
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
-		  "dapl_evd_un_async_error_callback () returns\n");
+	if (dat_status == DAT_SUCCESS) {
+		/*
+		 * If dapls_ib_get_async_event is not successful,
+		 * an event has been generated by the provider that
+		 * we are not interested in. E.g. LINK_UP.
+		 */
+		dapls_evd_post_async_error_event(async_evd,
+						 async_event,
+						 async_evd->header.owner_ia);
+	}
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK | DAPL_DBG_TYPE_EXCEPTION,
+		     "dapl_evd_un_async_error_callback () returns\n");
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_evd_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -48,63 +48,69 @@
 #include "dapl_sp_util.h"
 #include "dapl_ep_util.h"
 
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+STATIC _INLINE_ void dapli_evd_eh_print_cqe(IN ib_work_completion_t * cqe);
 
-STATIC _INLINE_ void dapli_evd_eh_print_cqe (
-	IN  ib_work_completion_t	*cqe);
+DAT_RETURN dapli_evd_event_alloc(IN DAPL_EVD * evd_ptr, IN DAT_COUNT qlen);
 
-DAT_RETURN dapli_evd_event_alloc (
-	IN  DAPL_EVD		*evd_ptr,
-	IN  DAT_COUNT		qlen);
-
-
-char *dapl_event_str( IN DAT_EVENT_NUMBER  event_num )
+char *dapl_event_str(IN DAT_EVENT_NUMBER event_num)
 {
 #if defined(DAPL_DBG)
-    struct dat_event_str { char *str; DAT_EVENT_NUMBER num;};
-    static struct dat_event_str events[] = {
-    {"DAT_DTO_COMPLETION_EVENT", DAT_DTO_COMPLETION_EVENT},
-    {"DAT_RMR_BIND_COMPLETION_EVENT", DAT_RMR_BIND_COMPLETION_EVENT},
-    {"DAT_CONNECTION_REQUEST_EVENT", DAT_CONNECTION_REQUEST_EVENT},
-    {"DAT_CONNECTION_EVENT_ESTABLISHED", DAT_CONNECTION_EVENT_ESTABLISHED},
-    {"DAT_CONNECTION_EVENT_PEER_REJECTED", DAT_CONNECTION_EVENT_PEER_REJECTED},
-    {"DAT_CONNECTION_EVENT_NON_PEER_REJECTED", DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
-    {"DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR", DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR},
-    {"DAT_CONNECTION_EVENT_DISCONNECTED", DAT_CONNECTION_EVENT_DISCONNECTED},
-    {"DAT_CONNECTION_EVENT_BROKEN", DAT_CONNECTION_EVENT_BROKEN},
-    {"DAT_CONNECTION_EVENT_TIMED_OUT", DAT_CONNECTION_EVENT_TIMED_OUT},
-    {"DAT_CONNECTION_EVENT_UNREACHABLE", DAT_CONNECTION_EVENT_UNREACHABLE},
-    {"DAT_ASYNC_ERROR_EVD_OVERFLOW", DAT_ASYNC_ERROR_EVD_OVERFLOW},
-    {"DAT_ASYNC_ERROR_IA_CATASTROPHIC", DAT_ASYNC_ERROR_IA_CATASTROPHIC},
-    {"DAT_ASYNC_ERROR_EP_BROKEN", DAT_ASYNC_ERROR_EP_BROKEN},
-    {"DAT_ASYNC_ERROR_TIMED_OUT", DAT_ASYNC_ERROR_TIMED_OUT},
-    {"DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR", DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR},
-    {"DAT_HA_DOWN_TO_1", DAT_HA_DOWN_TO_1},
-    {"DAT_HA_UP_TO_MULTI_PATH", DAT_HA_UP_TO_MULTI_PATH},
-    {"DAT_SOFTWARE_EVENT", DAT_SOFTWARE_EVENT},
+	struct dat_event_str {
+		char *str;
+		DAT_EVENT_NUMBER num;
+	};
+	static struct dat_event_str events[] = {
+		{"DAT_DTO_COMPLETION_EVENT", DAT_DTO_COMPLETION_EVENT},
+		{"DAT_RMR_BIND_COMPLETION_EVENT",
+		 DAT_RMR_BIND_COMPLETION_EVENT},
+		{"DAT_CONNECTION_REQUEST_EVENT", DAT_CONNECTION_REQUEST_EVENT},
+		{"DAT_CONNECTION_EVENT_ESTABLISHED",
+		 DAT_CONNECTION_EVENT_ESTABLISHED},
+		{"DAT_CONNECTION_EVENT_PEER_REJECTED",
+		 DAT_CONNECTION_EVENT_PEER_REJECTED},
+		{"DAT_CONNECTION_EVENT_NON_PEER_REJECTED",
+		 DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
+		{"DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR",
+		 DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR},
+		{"DAT_CONNECTION_EVENT_DISCONNECTED",
+		 DAT_CONNECTION_EVENT_DISCONNECTED},
+		{"DAT_CONNECTION_EVENT_BROKEN", DAT_CONNECTION_EVENT_BROKEN},
+		{"DAT_CONNECTION_EVENT_TIMED_OUT",
+		 DAT_CONNECTION_EVENT_TIMED_OUT},
+		{"DAT_CONNECTION_EVENT_UNREACHABLE",
+		 DAT_CONNECTION_EVENT_UNREACHABLE},
+		{"DAT_ASYNC_ERROR_EVD_OVERFLOW", DAT_ASYNC_ERROR_EVD_OVERFLOW},
+		{"DAT_ASYNC_ERROR_IA_CATASTROPHIC",
+		 DAT_ASYNC_ERROR_IA_CATASTROPHIC},
+		{"DAT_ASYNC_ERROR_EP_BROKEN", DAT_ASYNC_ERROR_EP_BROKEN},
+		{"DAT_ASYNC_ERROR_TIMED_OUT", DAT_ASYNC_ERROR_TIMED_OUT},
+		{"DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR",
+		 DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR},
+		{"DAT_HA_DOWN_TO_1", DAT_HA_DOWN_TO_1},
+		{"DAT_HA_UP_TO_MULTI_PATH", DAT_HA_UP_TO_MULTI_PATH},
+		{"DAT_SOFTWARE_EVENT", DAT_SOFTWARE_EVENT},
 #ifdef DAT_EXTENSIONS
-    {"DAT_EXTENSION_EVENT", DAT_EXTENSION_EVENT},
-    {"DAT_IB_EXTENSION_RANGE_BASE", DAT_IB_EXTENSION_RANGE_BASE},
-    {"DAT_IB_UD_CONNECTION_REQUEST_EVENT", DAT_IB_EXTENSION_RANGE_BASE+1},
-    {"DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED", DAT_IB_EXTENSION_RANGE_BASE+2},
-    {"DAT_IW_EXTENSION_RANGE_BASE", DAT_IW_EXTENSION_RANGE_BASE},
-#endif /* DAT_EXTENSIONS */
-    {NULL,0},
-    };
-    int i;
+		{"DAT_EXTENSION_EVENT", DAT_EXTENSION_EVENT},
+		{"DAT_IB_EXTENSION_RANGE_BASE", DAT_IB_EXTENSION_RANGE_BASE},
+		{"DAT_IB_UD_CONNECTION_REQUEST_EVENT",
+		 DAT_IB_EXTENSION_RANGE_BASE + 1},
+		{"DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED",
+		 DAT_IB_EXTENSION_RANGE_BASE + 2},
+		{"DAT_IW_EXTENSION_RANGE_BASE", DAT_IW_EXTENSION_RANGE_BASE},
+#endif				/* DAT_EXTENSIONS */
+		{NULL, 0},
+	};
+	int i;
 
-    for(i=0; events[i].str; i++)
-    {
-        if (events[i].num == event_num)
-            return events[i].str;
-    }
-    return "Unknown DAT event?";
+	for (i = 0; events[i].str; i++) {
+		if (events[i].num == event_num)
+			return events[i].str;
+	}
+	return "Unknown DAT event?";
 #else
-    static char str[16];
-    sprintf(str,"%x",event_num);
-    return str;
+	static char str[16];
+	sprintf(str, "%x", event_num);
+	return str;
 #endif
 }
 
@@ -130,117 +136,100 @@
  */
 
 DAT_RETURN
-dapls_evd_internal_create (
-    DAPL_IA		*ia_ptr,
-    DAPL_CNO		*cno_ptr,
-    DAT_COUNT		min_qlen,
-    DAT_EVD_FLAGS	evd_flags,
-    DAPL_EVD		**evd_ptr_ptr)
+dapls_evd_internal_create(DAPL_IA * ia_ptr,
+			  DAPL_CNO * cno_ptr,
+			  DAT_COUNT min_qlen,
+			  DAT_EVD_FLAGS evd_flags, DAPL_EVD ** evd_ptr_ptr)
 {
-    DAPL_EVD	*evd_ptr;
-    DAT_COUNT	cq_len;
-    DAT_RETURN	dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_COUNT cq_len;
+	DAT_RETURN dat_status;
 
-    dat_status   = DAT_SUCCESS;
-    *evd_ptr_ptr = NULL;
-    cq_len       = min_qlen;
+	dat_status = DAT_SUCCESS;
+	*evd_ptr_ptr = NULL;
+	cq_len = min_qlen;
 
-    evd_ptr = dapls_evd_alloc (ia_ptr,
-			       cno_ptr,
-			       evd_flags,
-			       min_qlen);
-    if (!evd_ptr)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	evd_ptr = dapls_evd_alloc(ia_ptr, cno_ptr, evd_flags, min_qlen);
+	if (!evd_ptr) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /*
-     * If we are dealing with event streams besides a CQ event stream,
-     * be conservative and set producer side locking.  Otherwise, no.
-     */
-    evd_ptr->evd_producer_locking_needed =
-	((evd_flags & ~ (DAT_EVD_DTO_FLAG|DAT_EVD_RMR_BIND_FLAG)) != 0);
-
-    /* Before we setup any callbacks, transition state to OPEN.  */
-    evd_ptr->evd_state = DAPL_EVD_STATE_OPEN;
-
-    if (evd_flags & DAT_EVD_ASYNC_FLAG)
-    {
 	/*
-	 * There is no cq associate with async evd. Set it to invalid
+	 * If we are dealing with event streams besides a CQ event stream,
+	 * be conservative and set producer side locking.  Otherwise, no.
 	 */
-	evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
+	evd_ptr->evd_producer_locking_needed =
+	    ((evd_flags & ~(DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG)) != 0);
 
-    }
-    else if ( 0 != (evd_flags & ~ (DAT_EVD_SOFTWARE_FLAG
-				   | DAT_EVD_CONNECTION_FLAG
-				   | DAT_EVD_CR_FLAG) ) )
-    {
+	/* Before we setup any callbacks, transition state to OPEN.  */
+	evd_ptr->evd_state = DAPL_EVD_STATE_OPEN;
+
+	if (evd_flags & DAT_EVD_ASYNC_FLAG) {
+		/*
+		 * There is no cq associate with async evd. Set it to invalid
+		 */
+		evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
+
+	} else if (0 != (evd_flags & ~(DAT_EVD_SOFTWARE_FLAG
+				       | DAT_EVD_CONNECTION_FLAG
+				       | DAT_EVD_CR_FLAG))) {
 #if defined(_VENDOR_IBAL_)
-	/* 
-	 * The creation of CQ required a PD (PZ) associated with it and
-	 * we do not have a PD here; therefore, the work-around is that we
-	 * will postpone the creation of the cq till the creation of QP which
-	 * this cq will associate with.
-	 */
-	evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
+		/* 
+		 * The creation of CQ required a PD (PZ) associated with it and
+		 * we do not have a PD here; therefore, the work-around is that we
+		 * will postpone the creation of the cq till the creation of QP which
+		 * this cq will associate with.
+		 */
+		evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
 #else
-	dat_status = dapls_ib_cq_alloc (ia_ptr,
-					evd_ptr,
-					&cq_len);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    goto bail;
-	}
+		dat_status = dapls_ib_cq_alloc(ia_ptr, evd_ptr, &cq_len);
+		if (dat_status != DAT_SUCCESS) {
+			goto bail;
+		}
 
-	/* Now reset the cq_len in the attributes, it may have changed */
-	evd_ptr->qlen = cq_len;
+		/* Now reset the cq_len in the attributes, it may have changed */
+		evd_ptr->qlen = cq_len;
 
-	dat_status =
-	    dapls_ib_setup_async_callback (
-				   ia_ptr,
-				   DAPL_ASYNC_CQ_COMPLETION,
-				   evd_ptr,
-				   (ib_async_handler_t)dapl_evd_dto_callback,
-				   evd_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    goto bail;
-	}
+		dat_status =
+		    dapls_ib_setup_async_callback(ia_ptr,
+						  DAPL_ASYNC_CQ_COMPLETION,
+						  evd_ptr,
+						  (ib_async_handler_t)
+						  dapl_evd_dto_callback,
+						  evd_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			goto bail;
+		}
 
-	dat_status = dapls_set_cq_notify (ia_ptr, evd_ptr);
+		dat_status = dapls_set_cq_notify(ia_ptr, evd_ptr);
 
-	if (dat_status != DAT_SUCCESS)
-	{
-	    goto bail;
+		if (dat_status != DAT_SUCCESS) {
+			goto bail;
+		}
+#endif				/* _VENDOR_IBAL_ */
 	}
 
-#endif /* _VENDOR_IBAL_ */
-    }
+	/* We now have an accurate count of events, so allocate them into
+	 * the EVD
+	 */
+	dat_status = dapli_evd_event_alloc(evd_ptr, cq_len);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
 
-    /* We now have an accurate count of events, so allocate them into
-     * the EVD
-     */
-    dat_status = dapli_evd_event_alloc (evd_ptr, cq_len);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
+	dapl_ia_link_evd(ia_ptr, evd_ptr);
+	*evd_ptr_ptr = evd_ptr;
 
-    dapl_ia_link_evd (ia_ptr, evd_ptr);
-    *evd_ptr_ptr = evd_ptr;
-
-bail:
-    if (dat_status != DAT_SUCCESS)
-    {
-	if (evd_ptr)
-	{
-	    dapls_evd_dealloc (evd_ptr);
+      bail:
+	if (dat_status != DAT_SUCCESS) {
+		if (evd_ptr) {
+			dapls_evd_dealloc(evd_ptr);
+		}
 	}
-    }
 
-    return dat_status;
+	return dat_status;
 }
 
 /*
@@ -258,79 +247,85 @@
  * 	none
  *
  */
-DAPL_EVD *
-dapls_evd_alloc (
-    IN DAPL_IA		*ia_ptr,
-    IN DAPL_CNO		*cno_ptr,
-    IN DAT_EVD_FLAGS	evd_flags,
-    IN DAT_COUNT	qlen)
+DAPL_EVD *dapls_evd_alloc(IN DAPL_IA * ia_ptr,
+			  IN DAPL_CNO * cno_ptr,
+			  IN DAT_EVD_FLAGS evd_flags, IN DAT_COUNT qlen)
 {
-    DAPL_EVD	*evd_ptr;
+	DAPL_EVD *evd_ptr;
 
-    /* Allocate EVD */
-    evd_ptr = (DAPL_EVD *)dapl_os_alloc (sizeof (DAPL_EVD));
-    if (!evd_ptr)
-    {
-	goto bail;
-    }
+	/* Allocate EVD */
+	evd_ptr = (DAPL_EVD *) dapl_os_alloc(sizeof(DAPL_EVD));
+	if (!evd_ptr) {
+		goto bail;
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (evd_ptr, sizeof (DAPL_EVD));
+	/* zero the structure */
+	dapl_os_memzero(evd_ptr, sizeof(DAPL_EVD));
 
-    /*
-     * initialize the header
-     */
-    evd_ptr->header.provider            = ia_ptr->header.provider;
-    evd_ptr->header.magic               = DAPL_MAGIC_EVD;
-    evd_ptr->header.handle_type         = DAT_HANDLE_TYPE_EVD;
-    evd_ptr->header.owner_ia            = ia_ptr;
-    evd_ptr->header.user_context.as_64  = 0;
-    evd_ptr->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&evd_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&evd_ptr->header.lock);
+#ifdef DAPL_COUNTERS
+	/* Allocate counters */
+	evd_ptr->cntrs =
+	    dapl_os_alloc(sizeof(DAT_UINT64) * DCNT_EVD_ALL_COUNTERS);
+	if (evd_ptr->cntrs == NULL) {
+		dapl_os_free(evd_ptr, sizeof(DAPL_EVD));
+		return (NULL);
+	}
+	dapl_os_memzero(evd_ptr->cntrs,
+			sizeof(DAT_UINT64) * DCNT_EVD_ALL_COUNTERS);
+#endif				/* DAPL_COUNTERS */
 
-    /*
-     * Initialize the body
-     */
-    evd_ptr->evd_state     = DAPL_EVD_STATE_INITIAL;
-    evd_ptr->evd_flags     = evd_flags;
-    evd_ptr->evd_enabled   = DAT_TRUE;
-    evd_ptr->evd_waitable  = DAT_TRUE;
-    evd_ptr->evd_producer_locking_needed = 1;/* Conservative value.  */
-    evd_ptr->ib_cq_handle  = IB_INVALID_HANDLE;
-    dapl_os_atomic_set (&evd_ptr->evd_ref_count, 0);
-    evd_ptr->catastrophic_overflow = DAT_FALSE;
-    evd_ptr->qlen          = qlen;
-    evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD; /* FIXME: should be DAPL_EVD_STATE_INIT */
-    dapl_os_wait_object_init (&evd_ptr->wait_object);
+	/*
+	 * initialize the header
+	 */
+	evd_ptr->header.provider = ia_ptr->header.provider;
+	evd_ptr->header.magic = DAPL_MAGIC_EVD;
+	evd_ptr->header.handle_type = DAT_HANDLE_TYPE_EVD;
+	evd_ptr->header.owner_ia = ia_ptr;
+	evd_ptr->header.user_context.as_64 = 0;
+	evd_ptr->header.user_context.as_ptr = NULL;
+	dapl_llist_init_entry(&evd_ptr->header.ia_list_entry);
+	dapl_os_lock_init(&evd_ptr->header.lock);
 
+	/*
+	 * Initialize the body
+	 */
+	evd_ptr->evd_state = DAPL_EVD_STATE_INITIAL;
+	evd_ptr->evd_flags = evd_flags;
+	evd_ptr->evd_enabled = DAT_TRUE;
+	evd_ptr->evd_waitable = DAT_TRUE;
+	evd_ptr->evd_producer_locking_needed = 1;	/* Conservative value.  */
+	evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
+	dapl_os_atomic_set(&evd_ptr->evd_ref_count, 0);
+	evd_ptr->catastrophic_overflow = DAT_FALSE;
+	evd_ptr->qlen = qlen;
+	evd_ptr->completion_type = DAPL_EVD_STATE_THRESHOLD;	/* FIXME: should be DAPL_EVD_STATE_INIT */
+	dapl_os_wait_object_init(&evd_ptr->wait_object);
+
 #ifdef CQ_WAIT_OBJECT
-    /* Create CQ wait object; no CNO and data stream type */
-    if (( cno_ptr == NULL ) && 
-	    ((evd_flags & ~ (DAT_EVD_DTO_FLAG|DAT_EVD_RMR_BIND_FLAG)) == 0 ))
-    {
-        dapls_ib_wait_object_create (evd_ptr, &evd_ptr->cq_wait_obj_handle);
-	if (evd_ptr->cq_wait_obj_handle == NULL) {
-		dapl_os_free(evd_ptr, sizeof (DAPL_EVD));
-		evd_ptr = NULL;
-		goto bail;
+	/* Create CQ wait object; no CNO and data stream type */
+	if ((cno_ptr == NULL) &&
+	    ((evd_flags & ~(DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG)) == 0)) {
+		dapls_ib_wait_object_create(evd_ptr,
+					    &evd_ptr->cq_wait_obj_handle);
+		if (evd_ptr->cq_wait_obj_handle == NULL) {
+			dapl_os_free(evd_ptr, sizeof(DAPL_EVD));
+			evd_ptr = NULL;
+			goto bail;
+		}
 	}
-    }
 #endif
 
-    evd_ptr->cno_active_count = 0;
-    if ( cno_ptr != NULL )
-    {
-	/* Take a reference count on the CNO */
-	dapl_os_atomic_inc (&cno_ptr->cno_ref_count);
-    }
-    evd_ptr->cno_ptr = cno_ptr;
+	evd_ptr->cno_active_count = 0;
+	if (cno_ptr != NULL) {
+		/* Take a reference count on the CNO */
+		dapl_os_atomic_inc(&cno_ptr->cno_ref_count);
+	}
+	evd_ptr->cno_ptr = cno_ptr;
 
-bail:
-    return evd_ptr;
+      bail:
+	return evd_ptr;
 }
 
-
 /*
  * dapls_evd_event_alloc
  *
@@ -348,56 +343,50 @@
  *	ERROR
  *
  */
-DAT_RETURN
-dapli_evd_event_alloc (
-    IN DAPL_EVD		*evd_ptr,
-    IN DAT_COUNT	qlen)
+DAT_RETURN dapli_evd_event_alloc(IN DAPL_EVD * evd_ptr, IN DAT_COUNT qlen)
 {
-    DAT_EVENT	*event_ptr;
-    DAT_COUNT	i;
-    DAT_RETURN	dat_status;
+	DAT_EVENT *event_ptr;
+	DAT_COUNT i;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    /* Allocate EVENTs */
-    event_ptr = (DAT_EVENT *) dapl_os_alloc (evd_ptr->qlen * sizeof (DAT_EVENT));
-    if (event_ptr == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
-    evd_ptr->events = event_ptr;
+	/* Allocate EVENTs */
+	event_ptr =
+	    (DAT_EVENT *) dapl_os_alloc(evd_ptr->qlen * sizeof(DAT_EVENT));
+	if (event_ptr == NULL) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
+	evd_ptr->events = event_ptr;
 
-    /* allocate free event queue */
-    dat_status = dapls_rbuf_alloc (&evd_ptr->free_event_queue, qlen);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
+	/* allocate free event queue */
+	dat_status = dapls_rbuf_alloc(&evd_ptr->free_event_queue, qlen);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
 
-    /* allocate pending event queue */
-    dat_status = dapls_rbuf_alloc (&evd_ptr->pending_event_queue, qlen);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
+	/* allocate pending event queue */
+	dat_status = dapls_rbuf_alloc(&evd_ptr->pending_event_queue, qlen);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
 
-    /* add events to free event queue */
-    for (i = 0; i < evd_ptr->qlen; i++)
-    {
-	dapls_rbuf_add (&evd_ptr->free_event_queue, (void *)event_ptr);
-	event_ptr++;
-    }
+	/* add events to free event queue */
+	for (i = 0; i < evd_ptr->qlen; i++) {
+		dapls_rbuf_add(&evd_ptr->free_event_queue, (void *)event_ptr);
+		event_ptr++;
+	}
 
-    evd_ptr->cq_notified = DAT_FALSE;
-    evd_ptr->cq_notified_when = 0;
-    evd_ptr->threshold = 0;
+	evd_ptr->cq_notified = DAT_FALSE;
+	evd_ptr->cq_notified_when = 0;
+	evd_ptr->threshold = 0;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 /*
  * dapls_evd_event_realloc
  *
@@ -415,58 +404,52 @@
  *	ERROR
  *
  */
-DAT_RETURN
-dapls_evd_event_realloc (
-    IN DAPL_EVD		*evd_ptr,
-    IN DAT_COUNT	qlen)
+DAT_RETURN dapls_evd_event_realloc(IN DAPL_EVD * evd_ptr, IN DAT_COUNT qlen)
 {
-    DAT_EVENT	*events;
-    DAT_COUNT	old_qlen;
-    DAT_COUNT   i;
-    intptr_t	diff;
-    DAT_RETURN	dat_status;
+	DAT_EVENT *events;
+	DAT_COUNT old_qlen;
+	DAT_COUNT i;
+	intptr_t diff;
+	DAT_RETURN dat_status;
 
-    /* Allocate EVENTs */
-    events = (DAT_EVENT *) dapl_os_realloc (evd_ptr->events,
-						qlen * sizeof (DAT_EVENT));
-    if ( NULL == events )
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* Allocate EVENTs */
+	events = (DAT_EVENT *) dapl_os_realloc(evd_ptr->events,
+					       qlen * sizeof(DAT_EVENT));
+	if (NULL == events) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    diff = events - evd_ptr->events;
-    evd_ptr->events = events;
+	diff = events - evd_ptr->events;
+	evd_ptr->events = events;
 
-    old_qlen = evd_ptr->qlen;
-    evd_ptr->qlen = qlen;
+	old_qlen = evd_ptr->qlen;
+	evd_ptr->qlen = qlen;
 
-    /* reallocate free event queue */
-    dat_status = dapls_rbuf_realloc (&evd_ptr->free_event_queue, qlen);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
-    dapls_rbuf_adjust (&evd_ptr->free_event_queue, diff);
+	/* reallocate free event queue */
+	dat_status = dapls_rbuf_realloc(&evd_ptr->free_event_queue, qlen);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
+	dapls_rbuf_adjust(&evd_ptr->free_event_queue, diff);
 
-    /* reallocate pending event queue */
-    dat_status = dapls_rbuf_realloc (&evd_ptr->pending_event_queue, qlen);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
-    dapls_rbuf_adjust (&evd_ptr->pending_event_queue, diff);
+	/* reallocate pending event queue */
+	dat_status = dapls_rbuf_realloc(&evd_ptr->pending_event_queue, qlen);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
+	dapls_rbuf_adjust(&evd_ptr->pending_event_queue, diff);
 
-    /*
-     * add new events to free event queue. 
-     */
-    for (i = old_qlen; i < qlen; i++)
-    {
-	dapls_rbuf_add (&evd_ptr->free_event_queue, (void *) &events[i]);
-    }
+	/*
+	 * add new events to free event queue. 
+	 */
+	for (i = old_qlen; i < qlen; i++) {
+		dapls_rbuf_add(&evd_ptr->free_event_queue, (void *)&events[i]);
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*
@@ -486,82 +469,80 @@
  * 	status
  *
  */
-DAT_RETURN
-dapls_evd_dealloc (
-    IN DAPL_EVD		*evd_ptr )
+DAT_RETURN dapls_evd_dealloc(IN DAPL_EVD * evd_ptr)
 {
-    DAT_RETURN	dat_status;
-    DAPL_IA	*ia_ptr;
+	DAT_RETURN dat_status;
+	DAPL_IA *ia_ptr;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_os_assert (evd_ptr->header.magic == DAPL_MAGIC_EVD);
-    dapl_os_assert (dapl_os_atomic_read (&evd_ptr->evd_ref_count) == 0);
+	dapl_os_assert(evd_ptr->header.magic == DAPL_MAGIC_EVD);
+	dapl_os_assert(dapl_os_atomic_read(&evd_ptr->evd_ref_count) == 0);
 
-    /*
-     * Destroy the CQ first, to keep any more callbacks from coming
-     * up from it.
-     */
-    if (evd_ptr->ib_cq_handle != IB_INVALID_HANDLE)
-    {
-	ia_ptr = evd_ptr->header.owner_ia;
+	/*
+	 * Destroy the CQ first, to keep any more callbacks from coming
+	 * up from it.
+	 */
+	if (evd_ptr->ib_cq_handle != IB_INVALID_HANDLE) {
+		ia_ptr = evd_ptr->header.owner_ia;
 
-	dat_status = dapls_ib_cq_free (ia_ptr, evd_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    goto bail;
+		dat_status = dapls_ib_cq_free(ia_ptr, evd_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			goto bail;
+		}
 	}
-    }
 
-    /*
-     * We should now be safe to invalidate the EVD; reset the
-     * magic to prevent reuse.
-     */
-    evd_ptr->header.magic = DAPL_MAGIC_INVALID;
+	/*
+	 * We should now be safe to invalidate the EVD; reset the
+	 * magic to prevent reuse.
+	 */
+	evd_ptr->header.magic = DAPL_MAGIC_INVALID;
 
-    /* Release reference on the CNO if it exists */
-    if ( evd_ptr->cno_ptr != NULL )
-    {
-	dapl_os_atomic_dec ( &evd_ptr->cno_ptr->cno_ref_count );
-	evd_ptr->cno_ptr = NULL;
-    }
+	/* Release reference on the CNO if it exists */
+	if (evd_ptr->cno_ptr != NULL) {
+		dapl_os_atomic_dec(&evd_ptr->cno_ptr->cno_ref_count);
+		evd_ptr->cno_ptr = NULL;
+	}
 
-    /* If the ring buffer allocation failed, then the dapls_rbuf_destroy   */
-    /* function will detect that the ring buffer's internal data (ex. base */
-    /* pointer) are invalid and will handle the situation appropriately    */
-    dapls_rbuf_destroy (&evd_ptr->free_event_queue);
-    dapls_rbuf_destroy (&evd_ptr->pending_event_queue);
+	/* If the ring buffer allocation failed, then the dapls_rbuf_destroy   */
+	/* function will detect that the ring buffer's internal data (ex. base */
+	/* pointer) are invalid and will handle the situation appropriately    */
+	dapls_rbuf_destroy(&evd_ptr->free_event_queue);
+	dapls_rbuf_destroy(&evd_ptr->pending_event_queue);
 
-    if (evd_ptr->events)
-    {
-	dapl_os_free (evd_ptr->events, evd_ptr->qlen * sizeof (DAT_EVENT));
-    }
+	if (evd_ptr->events) {
+		dapl_os_free(evd_ptr->events,
+			     evd_ptr->qlen * sizeof(DAT_EVENT));
+	}
 
-    dapl_os_wait_object_destroy (&evd_ptr->wait_object);
+	dapl_os_wait_object_destroy(&evd_ptr->wait_object);
 
 #ifdef CQ_WAIT_OBJECT
-    if (evd_ptr->cq_wait_obj_handle)
-    {
-	dapls_ib_wait_object_destroy (evd_ptr->cq_wait_obj_handle);
-    }
+	if (evd_ptr->cq_wait_obj_handle) {
+		dapls_ib_wait_object_destroy(evd_ptr->cq_wait_obj_handle);
+	}
 #endif
 
-    dapl_os_free (evd_ptr, sizeof (DAPL_EVD));
+#ifdef DAPL_COUNTERS
+	dapl_os_free(evd_ptr->cntrs,
+		     sizeof(DAT_UINT64) * DCNT_EVD_ALL_COUNTERS);
+#endif				/* DAPL_COUNTERS */
 
-bail:
-    return dat_status;
+	dapl_os_free(evd_ptr, sizeof(DAPL_EVD));
+
+      bail:
+	return dat_status;
 }
 
-STATIC _INLINE_ char * DAPL_GET_DTO_OP_STR(int op)
+STATIC _INLINE_ char *DAPL_GET_DTO_OP_STR(int op)
 {
-    static char *dto_ops[] =
-    {
-        "OP_SEND",
-        "OP_RECEIVE",
-        "OP_RDMA_WRITE",
-        "OP_RDMA_READ"
-    };
-    return ((op < 0 || op > 3) ? "Invalid DTO OP?" : dto_ops[op]);
+	static char *dto_ops[] = {
+		"OP_SEND",
+		"OP_RECEIVE",
+		"OP_RDMA_WRITE",
+		"OP_RDMA_READ"
+	};
+	return ((op < 0 || op > 3) ? "Invalid DTO OP?" : dto_ops[op]);
 }
 
 #if !defined(DAPL_GET_CQE_OP_STR)
@@ -584,39 +565,33 @@
  *
  */
 
-void
-dapli_evd_eh_print_cqe (
-    IN 	ib_work_completion_t	*cqe_ptr)
+void dapli_evd_eh_print_cqe(IN ib_work_completion_t * cqe_ptr)
 {
 #ifdef DAPL_DBG
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<\n");
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t dapl_evd_dto_callback : CQE \n");
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t\t work_req_id %lli\n",
-		  DAPL_GET_CQE_WRID (cqe_ptr));
-    if (DAPL_GET_CQE_STATUS (cqe_ptr) == 0)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t\t op_type: %s\n",
-		  DAPL_GET_CQE_OP_STR(cqe_ptr));
-	dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t\t bytes_num %d\n",
-		  DAPL_GET_CQE_BYTESNUM (cqe_ptr));
-    }
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t\t status %d vendor_err 0x%x\n",
-		  DAPL_GET_CQE_STATUS(cqe_ptr),
-		  DAPL_GET_CQE_VENDOR_ERR(cqe_ptr));
-    dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		  "\t >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "\t >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "\t dapl_evd_dto_callback : CQE \n");
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "\t\t work_req_id %lli\n", DAPL_GET_CQE_WRID(cqe_ptr));
+	if (DAPL_GET_CQE_STATUS(cqe_ptr) == 0) {
+		dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+			     "\t\t op_type: %s\n",
+			     DAPL_GET_CQE_OP_STR(cqe_ptr));
+		dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+			     "\t\t bytes_num %d\n",
+			     DAPL_GET_CQE_BYTESNUM(cqe_ptr));
+	}
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "\t\t status %d vendor_err 0x%x\n",
+		     DAPL_GET_CQE_STATUS(cqe_ptr),
+		     DAPL_GET_CQE_VENDOR_ERR(cqe_ptr));
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "\t >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<\n");
 #endif
-    return;
+	return;
 }
 
-
-
 /*
  * Event posting code follows.
  */
@@ -649,26 +624,22 @@
  *
  */
 
-static DAT_EVENT *
-dapli_evd_get_event (
-    DAPL_EVD *evd_ptr)
+static DAT_EVENT *dapli_evd_get_event(DAPL_EVD * evd_ptr)
 {
-    DAT_EVENT	*event;
+	DAT_EVENT *event;
 
-    if (evd_ptr->evd_producer_locking_needed)
-    {
-	dapl_os_lock (&evd_ptr->header.lock);
-    }
+	if (evd_ptr->evd_producer_locking_needed) {
+		dapl_os_lock(&evd_ptr->header.lock);
+	}
 
-    event = (DAT_EVENT *)dapls_rbuf_remove (&evd_ptr->free_event_queue);
+	event = (DAT_EVENT *) dapls_rbuf_remove(&evd_ptr->free_event_queue);
 
-    /* Release the lock if it was taken and the call failed.  */
-    if (!event && evd_ptr->evd_producer_locking_needed)
-    {
-	dapl_os_unlock (&evd_ptr->header.lock);
-    }
+	/* Release the lock if it was taken and the call failed.  */
+	if (!event && evd_ptr->evd_producer_locking_needed) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+	}
 
-    return event;
+	return event;
 }
 
 /* dapli_evd_post_event
@@ -689,70 +660,60 @@
  */
 
 static void
-dapli_evd_post_event (
-    IN	DAPL_EVD	*evd_ptr,
-    IN	const DAT_EVENT	*event_ptr)
+dapli_evd_post_event(IN DAPL_EVD * evd_ptr, IN const DAT_EVENT * event_ptr)
 {
-    DAT_RETURN	dat_status;
-    DAPL_CNO 	*cno_to_trigger = NULL;
+	DAT_RETURN dat_status;
+	DAPL_CNO *cno_to_trigger = NULL;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_EVD, "%s: Called with event %s\n",
-		  __FUNCTION__, dapl_event_str(event_ptr->event_number));
+	dapl_dbg_log(DAPL_DBG_TYPE_EVD, "%s: Called with event %s\n",
+		     __FUNCTION__, dapl_event_str(event_ptr->event_number));
 
-    dat_status = dapls_rbuf_add (&evd_ptr->pending_event_queue,
-				     (void *)event_ptr);
-    dapl_os_assert (dat_status == DAT_SUCCESS);
+	dat_status = dapls_rbuf_add(&evd_ptr->pending_event_queue,
+				    (void *)event_ptr);
+	dapl_os_assert(dat_status == DAT_SUCCESS);
 
-    dapl_os_assert (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED
-		   || evd_ptr->evd_state == DAPL_EVD_STATE_OPEN);
+	dapl_os_assert(evd_ptr->evd_state == DAPL_EVD_STATE_WAITED
+		       || evd_ptr->evd_state == DAPL_EVD_STATE_OPEN);
 
-    if (evd_ptr->evd_state == DAPL_EVD_STATE_OPEN)
-    {
-	/* No waiter.  Arrange to trigger a CNO if it exists.  */
+	if (evd_ptr->evd_state == DAPL_EVD_STATE_OPEN) {
+		/* No waiter.  Arrange to trigger a CNO if it exists.  */
 
-	if (evd_ptr->evd_enabled)
-	{
-	    cno_to_trigger = evd_ptr->cno_ptr;
-	}
-	if (evd_ptr->evd_producer_locking_needed)
-	{
-	    dapl_os_unlock (&evd_ptr->header.lock);
-	}
-    }
-    else
-    {
-	/*
-	 * We're in DAPL_EVD_STATE_WAITED.  Take the lock if
-	 * we don't have it, recheck, and signal.
-	 */
-	if (!evd_ptr->evd_producer_locking_needed)
-	{
-	    dapl_os_lock (&evd_ptr->header.lock);
-	}
+		if (evd_ptr->evd_enabled) {
+			cno_to_trigger = evd_ptr->cno_ptr;
+		}
+		if (evd_ptr->evd_producer_locking_needed) {
+			dapl_os_unlock(&evd_ptr->header.lock);
+		}
+	} else {
+		/*
+		 * We're in DAPL_EVD_STATE_WAITED.  Take the lock if
+		 * we don't have it, recheck, and signal.
+		 */
+		if (!evd_ptr->evd_producer_locking_needed) {
+			dapl_os_lock(&evd_ptr->header.lock);
+		}
 
-	if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED
-	    && (dapls_rbuf_count (&evd_ptr->pending_event_queue)
-		>= evd_ptr->threshold))
-	{
-	    dapl_os_unlock (&evd_ptr->header.lock);
+		if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED
+		    && (dapls_rbuf_count(&evd_ptr->pending_event_queue)
+			>= evd_ptr->threshold)) {
+			dapl_os_unlock(&evd_ptr->header.lock);
 
 #ifdef CQ_WAIT_OBJECT
-            if (evd_ptr->cq_wait_obj_handle)
-	        dapls_ib_wait_object_wakeup (evd_ptr->cq_wait_obj_handle);
-	    else
+			if (evd_ptr->cq_wait_obj_handle)
+				dapls_ib_wait_object_wakeup(evd_ptr->
+							    cq_wait_obj_handle);
+			else
 #endif
-	        dapl_os_wait_object_wakeup (&evd_ptr->wait_object);
+				dapl_os_wait_object_wakeup(&evd_ptr->
+							   wait_object);
+		} else {
+			dapl_os_unlock(&evd_ptr->header.lock);
+		}
 	}
-	else
-	{
-	    dapl_os_unlock (&evd_ptr->header.lock);
-	}
-    }
 
-    if (cno_to_trigger != NULL)
-    {
-	dapl_internal_cno_trigger (cno_to_trigger, evd_ptr);
-    }
+	if (cno_to_trigger != NULL) {
+		dapl_internal_cno_trigger(cno_to_trigger, evd_ptr);
+	}
 }
 
 /* dapli_evd_post_event_nosignal
@@ -775,26 +736,24 @@
  */
 
 static void
-dapli_evd_post_event_nosignal (
-    IN	DAPL_EVD	*evd_ptr,
-    IN	const DAT_EVENT	*event_ptr)
+dapli_evd_post_event_nosignal(IN DAPL_EVD * evd_ptr,
+			      IN const DAT_EVENT * event_ptr)
 {
-    DAT_RETURN	dat_status;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_EVD, "%s: Called with event %s\n",
-		  __FUNCTION__, dapl_event_str(event_ptr->event_number));
+	dapl_dbg_log(DAPL_DBG_TYPE_EVD, "%s: Called with event %s\n",
+		     __FUNCTION__, dapl_event_str(event_ptr->event_number));
 
-    dat_status = dapls_rbuf_add (&evd_ptr->pending_event_queue,
-				     (void *)event_ptr);
-    dapl_os_assert (dat_status == DAT_SUCCESS);
+	dat_status = dapls_rbuf_add(&evd_ptr->pending_event_queue,
+				    (void *)event_ptr);
+	dapl_os_assert(dat_status == DAT_SUCCESS);
 
-    dapl_os_assert (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED
-		   || evd_ptr->evd_state == DAPL_EVD_STATE_OPEN);
+	dapl_os_assert(evd_ptr->evd_state == DAPL_EVD_STATE_WAITED
+		       || evd_ptr->evd_state == DAPL_EVD_STATE_OPEN);
 
-    if (evd_ptr->evd_producer_locking_needed)
-    {
-	dapl_os_unlock (&evd_ptr->header.lock);
-    }
+	if (evd_ptr->evd_producer_locking_needed) {
+		dapl_os_unlock(&evd_ptr->header.lock);
+	}
 }
 
 /* dapli_evd_format_overflow_event
@@ -810,17 +769,17 @@
  *
  */
 static void
-dapli_evd_format_overflow_event (
-	IN  DAPL_EVD  *evd_ptr,
-	OUT DAT_EVENT *event_ptr)
+dapli_evd_format_overflow_event(IN DAPL_EVD * evd_ptr,
+				OUT DAT_EVENT * event_ptr)
 {
-    DAPL_IA *ia_ptr;
+	DAPL_IA *ia_ptr;
 
-    ia_ptr = evd_ptr->header.owner_ia;
+	ia_ptr = evd_ptr->header.owner_ia;
 
-    event_ptr->evd_handle   = (DAT_EVD_HANDLE)evd_ptr;
-    event_ptr->event_number = DAT_ASYNC_ERROR_EVD_OVERFLOW;
-    event_ptr->event_data.asynch_error_event_data.dat_handle = (DAT_HANDLE)ia_ptr;
+	event_ptr->evd_handle = (DAT_EVD_HANDLE) evd_ptr;
+	event_ptr->event_number = DAT_ASYNC_ERROR_EVD_OVERFLOW;
+	event_ptr->event_data.asynch_error_event_data.dat_handle =
+	    (DAT_HANDLE) ia_ptr;
 }
 
 /* dapli_evd_post_overflow_event
@@ -836,185 +795,169 @@
  *
  */
 static void
-dapli_evd_post_overflow_event (
-    IN  DAPL_EVD  *async_evd_ptr,
-    IN  DAPL_EVD  *overflow_evd_ptr)
+dapli_evd_post_overflow_event(IN DAPL_EVD * async_evd_ptr,
+			      IN DAPL_EVD * overflow_evd_ptr)
 {
-    DAT_EVENT *overflow_event;
+	DAT_EVENT *overflow_event;
 
-    /* The overflow_evd_ptr mght be the same as evd.
-     * In that case we've got a catastrophic overflow.
-     */
-    dapl_log(DAPL_DBG_TYPE_WARN,
-             " WARNING: overflow event on EVD %p/n", overflow_evd_ptr);
+	/* The overflow_evd_ptr mght be the same as evd.
+	 * In that case we've got a catastrophic overflow.
+	 */
+	dapl_log(DAPL_DBG_TYPE_WARN,
+		 " WARNING: overflow event on EVD %p/n", overflow_evd_ptr);
 
-    if (async_evd_ptr == overflow_evd_ptr)
-    {
-	async_evd_ptr->catastrophic_overflow = DAT_TRUE;
-	async_evd_ptr->evd_state = DAPL_EVD_STATE_DEAD;
-	return;
-    }
+	if (async_evd_ptr == overflow_evd_ptr) {
+		async_evd_ptr->catastrophic_overflow = DAT_TRUE;
+		async_evd_ptr->evd_state = DAPL_EVD_STATE_DEAD;
+		return;
+	}
 
-    overflow_event = dapli_evd_get_event (overflow_evd_ptr);
-    if (!overflow_event)
-    {
-	/* this is not good */
-	overflow_evd_ptr->catastrophic_overflow = DAT_TRUE;
-	overflow_evd_ptr->evd_state = DAPL_EVD_STATE_DEAD;
-	return;
-    }
-    dapli_evd_format_overflow_event (overflow_evd_ptr, overflow_event);
-    dapli_evd_post_event (overflow_evd_ptr, overflow_event);
+	overflow_event = dapli_evd_get_event(overflow_evd_ptr);
+	if (!overflow_event) {
+		/* this is not good */
+		overflow_evd_ptr->catastrophic_overflow = DAT_TRUE;
+		overflow_evd_ptr->evd_state = DAPL_EVD_STATE_DEAD;
+		return;
+	}
+	dapli_evd_format_overflow_event(overflow_evd_ptr, overflow_event);
+	dapli_evd_post_event(overflow_evd_ptr, overflow_event);
 
-    return;
+	return;
 }
 
-static DAT_EVENT *
-dapli_evd_get_and_init_event (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number)
+static DAT_EVENT *dapli_evd_get_and_init_event(IN DAPL_EVD * evd_ptr,
+					       IN DAT_EVENT_NUMBER event_number)
 {
-    DAT_EVENT 		*event_ptr;
+	DAT_EVENT *event_ptr;
 
-    event_ptr = dapli_evd_get_event (evd_ptr);
-    if (NULL == event_ptr)
-    {
-	dapli_evd_post_overflow_event (
-	    evd_ptr->header.owner_ia->async_error_evd,
-	    evd_ptr);
-    }
-    else
-    {
-	event_ptr->evd_handle = (DAT_EVD_HANDLE) evd_ptr;
-	event_ptr->event_number = event_number;
-    }
+	event_ptr = dapli_evd_get_event(evd_ptr);
+	if (NULL == event_ptr) {
+		dapli_evd_post_overflow_event(evd_ptr->header.owner_ia->
+					      async_error_evd, evd_ptr);
+	} else {
+		event_ptr->evd_handle = (DAT_EVD_HANDLE) evd_ptr;
+		event_ptr->event_number = event_number;
+	}
 
-    return event_ptr;
+	return event_ptr;
 }
 
 DAT_RETURN
-dapls_evd_post_cr_arrival_event (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number,
-    IN DAT_SP_HANDLE			sp_handle,
-    DAT_IA_ADDRESS_PTR			ia_address_ptr,
-    DAT_CONN_QUAL			conn_qual,
-    DAT_CR_HANDLE			cr_handle)
+dapls_evd_post_cr_arrival_event(IN DAPL_EVD * evd_ptr,
+				IN DAT_EVENT_NUMBER event_number,
+				IN DAT_SP_HANDLE sp_handle,
+				DAT_IA_ADDRESS_PTR ia_address_ptr,
+				DAT_CONN_QUAL conn_qual,
+				DAT_CR_HANDLE cr_handle)
 {
-    DAT_EVENT 		*event_ptr;
-    event_ptr = dapli_evd_get_and_init_event (evd_ptr, event_number);
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
+	DAT_EVENT *event_ptr;
+	event_ptr = dapli_evd_get_and_init_event(evd_ptr, event_number);
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
 
-    if (event_ptr == NULL)
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    }
+	if (event_ptr == NULL) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+	}
 
-    event_ptr->event_data.cr_arrival_event_data.sp_handle = sp_handle;
-    event_ptr->event_data.cr_arrival_event_data.local_ia_address_ptr
-	= ia_address_ptr;
-    event_ptr->event_data.cr_arrival_event_data.conn_qual = conn_qual;
-    event_ptr->event_data.cr_arrival_event_data.cr_handle = cr_handle;
+	event_ptr->event_data.cr_arrival_event_data.sp_handle = sp_handle;
+	event_ptr->event_data.cr_arrival_event_data.local_ia_address_ptr
+	    = ia_address_ptr;
+	event_ptr->event_data.cr_arrival_event_data.conn_qual = conn_qual;
+	event_ptr->event_data.cr_arrival_event_data.cr_handle = cr_handle;
 
-    dapli_evd_post_event (evd_ptr, event_ptr);
+	dapli_evd_post_event(evd_ptr, event_ptr);
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 DAT_RETURN
-dapls_evd_post_connection_event (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number,
-    IN DAT_EP_HANDLE               	ep_handle,
-    IN DAT_COUNT                   	private_data_size,
-    IN DAT_PVOID                   	private_data)
+dapls_evd_post_connection_event(IN DAPL_EVD * evd_ptr,
+				IN DAT_EVENT_NUMBER event_number,
+				IN DAT_EP_HANDLE ep_handle,
+				IN DAT_COUNT private_data_size,
+				IN DAT_PVOID private_data)
 {
-    DAT_EVENT 		*event_ptr;
-    event_ptr = dapli_evd_get_and_init_event (evd_ptr, event_number);
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
+	DAT_EVENT *event_ptr;
+	event_ptr = dapli_evd_get_and_init_event(evd_ptr, event_number);
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
 
-    if (event_ptr == NULL)
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    }
+	if (event_ptr == NULL) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+	}
 
-    event_ptr->event_data.connect_event_data.ep_handle = ep_handle;
-    event_ptr->event_data.connect_event_data.private_data_size
-	= private_data_size;
-    event_ptr->event_data.connect_event_data.private_data = private_data;
+	event_ptr->event_data.connect_event_data.ep_handle = ep_handle;
+	event_ptr->event_data.connect_event_data.private_data_size
+	    = private_data_size;
+	event_ptr->event_data.connect_event_data.private_data = private_data;
 
-    dapli_evd_post_event (evd_ptr, event_ptr);
+	dapli_evd_post_event(evd_ptr, event_ptr);
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 DAT_RETURN
-dapls_evd_post_async_error_event (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number,
-    IN DAT_IA_HANDLE			ia_handle)
+dapls_evd_post_async_error_event(IN DAPL_EVD * evd_ptr,
+				 IN DAT_EVENT_NUMBER event_number,
+				 IN DAT_IA_HANDLE ia_handle)
 {
-    DAT_EVENT 		*event_ptr;
-    event_ptr = dapli_evd_get_and_init_event (evd_ptr, event_number);
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
-    dapl_log(DAPL_DBG_TYPE_WARN,
-             " WARNING: async event - %s evd=%p/n", 
-             dapl_event_str(event_number),evd_ptr);
+	DAT_EVENT *event_ptr;
+	event_ptr = dapli_evd_get_and_init_event(evd_ptr, event_number);
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
+	dapl_log(DAPL_DBG_TYPE_WARN,
+		 " WARNING: async event - %s evd=%p/n",
+		 dapl_event_str(event_number), evd_ptr);
 
-    if (event_ptr == NULL)
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    }
+	if (event_ptr == NULL) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+	}
 
-    event_ptr->event_data.asynch_error_event_data.dat_handle = (DAT_HANDLE)ia_handle;
+	event_ptr->event_data.asynch_error_event_data.dat_handle =
+	    (DAT_HANDLE) ia_handle;
 
-    dapli_evd_post_event (evd_ptr, event_ptr);
+	dapli_evd_post_event(evd_ptr, event_ptr);
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 DAT_RETURN
-dapls_evd_post_software_event (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number,
-    IN DAT_PVOID			pointer)
+dapls_evd_post_software_event(IN DAPL_EVD * evd_ptr,
+			      IN DAT_EVENT_NUMBER event_number,
+			      IN DAT_PVOID pointer)
 {
-    DAT_EVENT 		*event_ptr;
-    event_ptr = dapli_evd_get_and_init_event (evd_ptr, event_number);
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
+	DAT_EVENT *event_ptr;
+	event_ptr = dapli_evd_get_and_init_event(evd_ptr, event_number);
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
 
-    if (event_ptr == NULL)
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    }
+	if (event_ptr == NULL) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+	}
 
-    event_ptr->event_data.software_event_data.pointer = pointer;
+	event_ptr->event_data.software_event_data.pointer = pointer;
 
-    dapli_evd_post_event (evd_ptr, event_ptr);
+	dapli_evd_post_event(evd_ptr, event_ptr);
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapls_evd_post_generic_event
  *
@@ -1033,196 +976,195 @@
  *
  */
 DAT_RETURN
-dapls_evd_post_generic_event (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number,
-    IN DAT_EVENT_DATA			*data)
+dapls_evd_post_generic_event(IN DAPL_EVD * evd_ptr,
+			     IN DAT_EVENT_NUMBER event_number,
+			     IN DAT_EVENT_DATA * data)
 {
-    DAT_EVENT 		*event_ptr;
+	DAT_EVENT *event_ptr;
 
-    event_ptr = dapli_evd_get_and_init_event (evd_ptr, event_number);
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
+	event_ptr = dapli_evd_get_and_init_event(evd_ptr, event_number);
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
 
-    if (event_ptr == NULL)
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    }
+	if (event_ptr == NULL) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+	}
 
-    event_ptr->event_data = *data;
+	event_ptr->event_data = *data;
 
-    dapli_evd_post_event (evd_ptr, event_ptr);
+	dapli_evd_post_event(evd_ptr, event_ptr);
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
 #ifdef DAT_EXTENSIONS
 DAT_RETURN
-dapls_evd_post_cr_event_ext (
-    IN DAPL_SP			*sp_ptr,
-    IN DAT_EVENT_NUMBER		event_number,
-    IN dp_ib_cm_handle_t	ib_cm_handle,
-    IN DAT_COUNT		p_size,
-    IN DAT_PVOID		p_data,
-    IN DAT_PVOID		ext_data)
+dapls_evd_post_cr_event_ext(IN DAPL_SP * sp_ptr,
+			    IN DAT_EVENT_NUMBER event_number,
+			    IN dp_ib_cm_handle_t ib_cm_handle,
+			    IN DAT_COUNT p_size,
+			    IN DAT_PVOID p_data, IN DAT_PVOID ext_data)
 {
-    DAPL_CR		*cr_ptr;
-    DAPL_EP		*ep_ptr;
-    DAT_EVENT 		*event_ptr;
-    DAT_SP_HANDLE	sp_handle;
-    
-    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,
-		     "---> post_cr_event_ext: conn event on down SP\n");
-	(void)dapls_ib_reject_connection(ib_cm_handle,
-					 DAT_CONNECTION_EVENT_UNREACHABLE,
-					 0, NULL);
-	return DAT_CONN_QUAL_UNAVAILABLE;
-    }
-    
-    /*
-     * RSP connections only allow a single connection. Close
-     * it down NOW so we reject any further connections.
-     */
-    if (sp_ptr->header.handle_type == DAT_HANDLE_TYPE_RSP) 
-	sp_ptr->listening = DAT_FALSE;
-    
-    dapl_os_unlock (&sp_ptr->header.lock);
+	DAPL_CR *cr_ptr;
+	DAPL_EP *ep_ptr;
+	DAT_EVENT *event_ptr;
+	DAT_SP_HANDLE sp_handle;
 
-    /* allocate new connect request */
-    cr_ptr = dapls_cr_alloc(sp_ptr->header.owner_ia);
-    if (cr_ptr == NULL)
-    	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;
-    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
-     */
-    cr_ptr->param.private_data = cr_ptr->private_data;
-    cr_ptr->param.private_data_size = p_size;
-    if (p_size)
-	dapl_os_memcpy(cr_ptr->private_data, p_data, p_size);
-    
-    /* EP will be NULL unless RSP service point */
-    ep_ptr = (DAPL_EP *)sp_ptr->ep_handle;
+	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,
+			     "---> post_cr_event_ext: conn event on down SP\n");
+		(void)dapls_ib_reject_connection(ib_cm_handle,
+						 DAT_CONNECTION_EVENT_UNREACHABLE,
+						 0, NULL);
+		return DAT_CONN_QUAL_UNAVAILABLE;
+	}
 
-    if (sp_ptr->psp_flags == DAT_PSP_PROVIDER_FLAG)
-    {
-	DAPL_IA *ia_ptr;
 	/*
-	 * 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.
+	 * RSP connections only allow a single connection. Close
+	 * it down NOW so we reject any further connections.
 	 */
-	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;
+	if (sp_ptr->header.handle_type == DAT_HANDLE_TYPE_RSP)
+		sp_ptr->listening = DAT_FALSE;
 
-	/* Link the EP onto the IA */
-	dapl_ia_link_ep(ia_ptr, ep_ptr);
-    }
+	dapl_os_unlock(&sp_ptr->header.lock);
 
-    cr_ptr->param.local_ep_handle = ep_ptr;
+	/* allocate new connect request */
+	cr_ptr = dapls_cr_alloc(sp_ptr->header.owner_ia);
+	if (cr_ptr == NULL)
+		return DAT_INSUFFICIENT_RESOURCES;
 
-    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;
+	/* 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;
+	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
+	 */
+	cr_ptr->param.private_data = cr_ptr->private_data;
+	cr_ptr->param.private_data_size = p_size;
+	if (p_size)
+		dapl_os_memcpy(cr_ptr->private_data, p_data, p_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) {
+		DAPL_IA *ia_ptr;
+		/*
+		 * 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);
 	}
-	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);
- 
-    /* assign sp_ptr to union to avoid typecast errors from some compilers */
-    sp_handle.psp_handle = (DAT_PSP_HANDLE)sp_ptr;
+	cr_ptr->param.local_ep_handle = ep_ptr;
 
-   /* Post the event.  */
-        
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
-    event_ptr = dapli_evd_get_and_init_event(sp_ptr->evd_handle, 
-					     event_number);
-    if (event_ptr == NULL)
-	return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    
-    event_ptr->event_data.cr_arrival_event_data.sp_handle = sp_handle;
-    event_ptr->event_data.cr_arrival_event_data.local_ia_address_ptr = 
-	(DAT_IA_ADDRESS_PTR)&sp_ptr->header.owner_ia->hca_ptr->hca_address;
-    event_ptr->event_data.cr_arrival_event_data.conn_qual = sp_ptr->conn_qual;
-    event_ptr->event_data.cr_arrival_event_data.cr_handle = (DAT_HANDLE)cr_ptr;
-    
-    dapl_os_memcpy(&event_ptr->event_extension_data[0], ext_data, 64);
+	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;
+	}
 
-    dapli_evd_post_event(sp_ptr->evd_handle, event_ptr);
+	/* link the CR onto the SP so we can pick it up later */
+	dapl_sp_link_cr(sp_ptr, cr_ptr);
 
-    return DAT_SUCCESS;
-}
+	/* assign sp_ptr to union to avoid typecast errors from some compilers */
+	sp_handle.psp_handle = (DAT_PSP_HANDLE) sp_ptr;
 
+	/* Post the event.  */
 
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
+	event_ptr = dapli_evd_get_and_init_event(sp_ptr->evd_handle,
+						 event_number);
+	if (event_ptr == NULL)
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
+
+	event_ptr->event_data.cr_arrival_event_data.sp_handle = sp_handle;
+	event_ptr->event_data.cr_arrival_event_data.local_ia_address_ptr =
+	    (DAT_IA_ADDRESS_PTR) & sp_ptr->header.owner_ia->hca_ptr->
+	    hca_address;
+	event_ptr->event_data.cr_arrival_event_data.conn_qual =
+	    sp_ptr->conn_qual;
+	event_ptr->event_data.cr_arrival_event_data.cr_handle =
+	    (DAT_HANDLE) cr_ptr;
+
+	dapl_os_memcpy(&event_ptr->event_extension_data[0], ext_data, 64);
+
+	dapli_evd_post_event(sp_ptr->evd_handle, event_ptr);
+
+	return DAT_SUCCESS;
+}
+
 DAT_RETURN
-dapls_evd_post_connection_event_ext (
-    IN DAPL_EVD				*evd_ptr,
-    IN DAT_EVENT_NUMBER			event_number,
-    IN DAT_EP_HANDLE               	ep_handle,
-    IN DAT_COUNT                   	private_data_size,
-    IN DAT_PVOID                   	private_data,
-    IN DAT_PVOID			ext_data)
+dapls_evd_post_connection_event_ext(IN DAPL_EVD * evd_ptr,
+				    IN DAT_EVENT_NUMBER event_number,
+				    IN DAT_EP_HANDLE ep_handle,
+				    IN DAT_COUNT private_data_size,
+				    IN DAT_PVOID private_data,
+				    IN DAT_PVOID ext_data)
 {
-    DAT_EVENT 		*event_ptr;
-    event_ptr = dapli_evd_get_and_init_event (evd_ptr, event_number);
-    /*
-     * Note event lock may be held on successful return
-     * to be released by dapli_evd_post_event(), if provider side locking
-     * is needed.
-     */
-    if (event_ptr == NULL)
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-    
-    event_ptr->event_data.connect_event_data.ep_handle = ep_handle;
-    event_ptr->event_data.connect_event_data.private_data_size
-	= private_data_size;
-    event_ptr->event_data.connect_event_data.private_data = private_data;
-    
-    dapl_os_memcpy(&event_ptr->event_extension_data[0], ext_data, 64);
+	DAT_EVENT *event_ptr;
+	event_ptr = dapli_evd_get_and_init_event(evd_ptr, event_number);
+	/*
+	 * Note event lock may be held on successful return
+	 * to be released by dapli_evd_post_event(), if provider side locking
+	 * is needed.
+	 */
+	if (event_ptr == NULL)
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
 
-    dapli_evd_post_event (evd_ptr, event_ptr);
+	event_ptr->event_data.connect_event_data.ep_handle = ep_handle;
+	event_ptr->event_data.connect_event_data.private_data_size
+	    = private_data_size;
+	event_ptr->event_data.connect_event_data.private_data = private_data;
 
-    return DAT_SUCCESS;
+	dapl_os_memcpy(&event_ptr->event_extension_data[0], ext_data, 64);
+
+	dapli_evd_post_event(evd_ptr, event_ptr);
+
+	return DAT_SUCCESS;
 }
 #endif
 
-
-
 /*
  * dapli_evd_cqe_to_event
  *
@@ -1240,173 +1182,172 @@
  *
  */
 static void
-dapli_evd_cqe_to_event (
-    IN  DAPL_EVD		*evd_ptr,
-    IN  void			*cqe_ptr,
-    OUT DAT_EVENT		*event_ptr)
+dapli_evd_cqe_to_event(IN DAPL_EVD * evd_ptr,
+		       IN void *cqe_ptr, OUT DAT_EVENT * event_ptr)
 {
-    DAPL_EP			*ep_ptr;
-    DAPL_COOKIE			*cookie;
-    DAT_DTO_COMPLETION_STATUS	dto_status;
-    DAPL_COOKIE_BUFFER		*buffer;
-    
-    /*
-     * All that can be relied on if the status is bad is the status
-     * and WRID.
-     */
-    dto_status = dapls_ib_get_dto_status (cqe_ptr);
+	DAPL_EP *ep_ptr;
+	DAPL_COOKIE *cookie;
+	DAT_DTO_COMPLETION_STATUS dto_status;
+	DAPL_COOKIE_BUFFER *buffer;
 
-    cookie = (DAPL_COOKIE *) (uintptr_t) DAPL_GET_CQE_WRID (cqe_ptr);
-    dapl_os_assert ( (NULL != cookie) );
+	/*
+	 * All that can be relied on if the status is bad is the status
+	 * and WRID.
+	 */
+	dto_status = dapls_ib_get_dto_status(cqe_ptr);
 
-    ep_ptr = cookie->ep;
-    dapl_os_assert ( (NULL != ep_ptr) );
-    if (ep_ptr->header.magic != DAPL_MAGIC_EP)
-    {
-	/* ep may have been freed, just return */
-	return;
-    }
+	cookie = (DAPL_COOKIE *) (uintptr_t) DAPL_GET_CQE_WRID(cqe_ptr);
+	dapl_os_assert((NULL != cookie));
 
-    dapls_io_trc_update_completion (ep_ptr, cookie, dto_status);
+	ep_ptr = cookie->ep;
+	dapl_os_assert((NULL != ep_ptr));
+	if (ep_ptr->header.magic != DAPL_MAGIC_EP) {
+		/* ep may have been freed, just return */
+		return;
+	}
 
-    event_ptr->evd_handle = (DAT_EVD_HANDLE) evd_ptr;
+	dapls_io_trc_update_completion(ep_ptr, cookie, dto_status);
 
-    switch (cookie->type)
-    {
+	event_ptr->evd_handle = (DAT_EVD_HANDLE) evd_ptr;
+
+	switch (cookie->type) {
 	case DAPL_COOKIE_TYPE_DTO:
-	{
+		{
 #ifdef DAT_EXTENSIONS
-	    /* Extended via request post or message receive */
-	    if ((cookie->val.dto.type == DAPL_DTO_TYPE_EXTENSION) ||
-		(cookie->val.dto.type == DAPL_DTO_TYPE_RECV && 
-		DAPL_GET_CQE_OPTYPE(cqe_ptr) !=  OP_RECEIVE))
-	    {
-		dapls_cqe_to_event_extension (ep_ptr, cookie, cqe_ptr, event_ptr);
-                if (cookie->val.dto.type == DAPL_DTO_TYPE_RECV)
-                        dapls_cookie_dealloc (&ep_ptr->recv_buffer, cookie);
-                else
-                        dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);
-		break;
-	    }
+			/* Extended via request post or message receive */
+			if ((cookie->val.dto.type == DAPL_DTO_TYPE_EXTENSION) ||
+			    (cookie->val.dto.type == DAPL_DTO_TYPE_RECV &&
+			     DAPL_GET_CQE_OPTYPE(cqe_ptr) != OP_RECEIVE)) {
+				dapls_cqe_to_event_extension(ep_ptr, cookie,
+							     cqe_ptr,
+							     event_ptr);
+				if (cookie->val.dto.type == DAPL_DTO_TYPE_RECV)
+					dapls_cookie_dealloc(&ep_ptr->
+							     recv_buffer,
+							     cookie);
+				else
+					dapls_cookie_dealloc(&ep_ptr->
+							     req_buffer,
+							     cookie);
+				break;
+			}
 #endif
 
-	    if (DAPL_DTO_TYPE_RECV == cookie->val.dto.type)
-	    	buffer = &ep_ptr->recv_buffer;
-	    else
-	    	buffer = &ep_ptr->req_buffer;
-	    
-	    event_ptr->event_number = DAT_DTO_COMPLETION_EVENT;
-	    event_ptr->event_data.dto_completion_event_data.ep_handle =
-		cookie->ep;
-	    event_ptr->event_data.dto_completion_event_data.user_cookie =
-		cookie->val.dto.cookie;
-	    event_ptr->event_data.dto_completion_event_data.status = dto_status;
+			if (DAPL_DTO_TYPE_RECV == cookie->val.dto.type)
+				buffer = &ep_ptr->recv_buffer;
+			else
+				buffer = &ep_ptr->req_buffer;
 
-	    if ( cookie->val.dto.type == DAPL_DTO_TYPE_SEND ||
-		 cookie->val.dto.type == DAPL_DTO_TYPE_RDMA_WRITE )
-	    {
-		/* Get size from DTO; CQE value may be off.  */
-		event_ptr->event_data.dto_completion_event_data.transfered_length =
-		    cookie->val.dto.size;
-	    }
-	    else
-	    {
-		event_ptr->event_data.dto_completion_event_data.transfered_length =
-		     DAPL_GET_CQE_BYTESNUM (cqe_ptr);
-	    }
+			event_ptr->event_number = DAT_DTO_COMPLETION_EVENT;
+			event_ptr->event_data.dto_completion_event_data.
+			    ep_handle = cookie->ep;
+			event_ptr->event_data.dto_completion_event_data.
+			    user_cookie = cookie->val.dto.cookie;
+			event_ptr->event_data.dto_completion_event_data.status =
+			    dto_status;
 
-	    dapls_cookie_dealloc (buffer, cookie);
-	    break;
-	}
+			if (cookie->val.dto.type == DAPL_DTO_TYPE_SEND ||
+			    cookie->val.dto.type == DAPL_DTO_TYPE_RDMA_WRITE) {
+				/* Get size from DTO; CQE value may be off.  */
+				event_ptr->event_data.dto_completion_event_data.
+				    transfered_length = cookie->val.dto.size;
+			} else {
+				event_ptr->event_data.dto_completion_event_data.
+				    transfered_length =
+				    DAPL_GET_CQE_BYTESNUM(cqe_ptr);
+			}
 
+			dapls_cookie_dealloc(buffer, cookie);
+			break;
+		}
+
 	case DAPL_COOKIE_TYPE_RMR:
-	{
-	    event_ptr->event_number = DAT_RMR_BIND_COMPLETION_EVENT;
+		{
+			event_ptr->event_number = DAT_RMR_BIND_COMPLETION_EVENT;
 
-	    event_ptr->event_data.rmr_completion_event_data.rmr_handle =
-		cookie->val.rmr.rmr;
-	    event_ptr->event_data.rmr_completion_event_data.user_cookie =
-		cookie->val.rmr.cookie;
-	    if (dto_status == DAT_DTO_SUCCESS)
-	    {
-		event_ptr->event_data.rmr_completion_event_data.status =
-		    DAT_RMR_BIND_SUCCESS;
-		dapl_os_assert ((DAPL_GET_CQE_OPTYPE (cqe_ptr)) == OP_BIND_MW);
-	    }
-	    else
-	    {
-		dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,
-			      " MW bind completion ERROR: %d: op %#x ep: %p\n", 
-			      dto_status, 
-			      DAPL_GET_CQE_OPTYPE (cqe_ptr), ep_ptr);
-		event_ptr->event_data.rmr_completion_event_data.status =
-		    DAT_RMR_OPERATION_FAILED;
-		dapl_os_atomic_dec(&cookie->val.rmr.rmr->lmr->lmr_ref_count);
-	    }
+			event_ptr->event_data.rmr_completion_event_data.
+			    rmr_handle = cookie->val.rmr.rmr;
+			event_ptr->event_data.rmr_completion_event_data.
+			    user_cookie = cookie->val.rmr.cookie;
+			if (dto_status == DAT_DTO_SUCCESS) {
+				event_ptr->event_data.rmr_completion_event_data.
+				    status = DAT_RMR_BIND_SUCCESS;
+				dapl_os_assert((DAPL_GET_CQE_OPTYPE(cqe_ptr)) ==
+					       OP_BIND_MW);
+			} else {
+				dapl_dbg_log(DAPL_DBG_TYPE_DTO_COMP_ERR,
+					     " MW bind completion ERROR: %d: op %#x ep: %p\n",
+					     dto_status,
+					     DAPL_GET_CQE_OPTYPE(cqe_ptr),
+					     ep_ptr);
+				event_ptr->event_data.rmr_completion_event_data.
+				    status = DAT_RMR_OPERATION_FAILED;
+				dapl_os_atomic_dec(&cookie->val.rmr.rmr->lmr->
+						   lmr_ref_count);
+			}
 
-	    dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);
-	    break;
-	}
+			dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);
+			break;
+		}
 	default:
-	{
-	    dapl_os_assert (!"Invalid Operation type");
-	    break;
-	}
-    } /* end switch */
+		{
+			dapl_os_assert(!"Invalid Operation type");
+			break;
+		}
+	}			/* end switch */
 
-    /*
-     * Most error DTO ops result in disconnecting the EP. See
-     * IBTA Vol 1.1, Chapter 10,Table 68, for expected effect on
-     * state.
-     */
-    if ((dto_status != DAT_DTO_SUCCESS) &&
-        (dto_status != DAT_DTO_ERR_FLUSHED))
-    {
-	DAPL_EVD		*evd_ptr;
-
 	/*
-	 * If we are connected, generate disconnect and generate an
-	 * event. We may be racing with other disconnect ops, so we
-	 * need to check. We may also be racing CM connection events,
-	 * requiring us to check for connection pending states too.
+	 * Most error DTO ops result in disconnecting the EP. See
+	 * IBTA Vol 1.1, Chapter 10,Table 68, for expected effect on
+	 * state.
 	 */
-	dapl_os_lock ( &ep_ptr->header.lock );
-	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_PASSIVE_CONNECTION_PENDING||
-	    ep_ptr->param.ep_state == DAT_EP_STATE_COMPLETION_PENDING )
+	if ((dto_status != DAT_DTO_SUCCESS) &&
+	    (dto_status != DAT_DTO_ERR_FLUSHED)) {
+		DAPL_EVD *evd_ptr;
 
-	{
-	    ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
-	    dapl_os_unlock ( &ep_ptr->header.lock );
-	    dapls_io_trc_dump (ep_ptr, cqe_ptr, dto_status);
+		/*
+		 * If we are connected, generate disconnect and generate an
+		 * event. We may be racing with other disconnect ops, so we
+		 * need to check. We may also be racing CM connection events,
+		 * requiring us to check for connection pending states too.
+		 */
+		dapl_os_lock(&ep_ptr->header.lock);
+		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_PASSIVE_CONNECTION_PENDING
+		    || ep_ptr->param.ep_state ==
+		    DAT_EP_STATE_COMPLETION_PENDING)
+		{
+			ep_ptr->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+			dapl_os_unlock(&ep_ptr->header.lock);
+			dapls_io_trc_dump(ep_ptr, cqe_ptr, dto_status);
 
-	    /* Let the other side know we have disconnected */
-	    (void) dapls_ib_disconnect (ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
+			/* Let the other side know we have disconnected */
+			(void)dapls_ib_disconnect(ep_ptr,
+						  DAT_CLOSE_ABRUPT_FLAG);
 
-	    /* ... and clean up the local side */
-	    evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
-	    if (evd_ptr != NULL)
-	    {
-		dapls_evd_post_connection_event (evd_ptr,
-						DAT_CONNECTION_EVENT_BROKEN,
-						(DAT_HANDLE) ep_ptr,
-						0,
-						0);
-	    }
-	}
-	else
-	{
-	    dapl_os_unlock ( &ep_ptr->header.lock );
-	}
+			/* ... and clean up the local side */
+			evd_ptr = (DAPL_EVD *) ep_ptr->param.connect_evd_handle;
+			if (evd_ptr != NULL) {
+				dapls_evd_post_connection_event(evd_ptr,
+								DAT_CONNECTION_EVENT_BROKEN,
+								(DAT_HANDLE)
+								ep_ptr, 0, 0);
+			}
+		} else {
+			dapl_os_unlock(&ep_ptr->header.lock);
+		}
 
-	dapl_log(DAPL_DBG_TYPE_ERR,
-		 "DTO completion ERR: status %d, op %s, vendor_err 0x%x - %s\n",
-		 DAPL_GET_CQE_STATUS(cqe_ptr),
-		 DAPL_GET_DTO_OP_STR(cookie->val.dto.type),
-		 DAPL_GET_CQE_VENDOR_ERR(cqe_ptr),
-		 inet_ntoa(((struct sockaddr_in *)&ep_ptr->remote_ia_address)->sin_addr));
-    }
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 "DTO completion ERR: status %d, op %s, vendor_err 0x%x - %s\n",
+			 DAPL_GET_CQE_STATUS(cqe_ptr),
+			 DAPL_GET_DTO_OP_STR(cookie->val.dto.type),
+			 DAPL_GET_CQE_VENDOR_ERR(cqe_ptr),
+			 inet_ntoa(((struct sockaddr_in *)&ep_ptr->
+				    remote_ia_address)->sin_addr));
+	}
 }
 
 /*
@@ -1426,59 +1367,53 @@
  * 	none
  *
  */
-void
-dapls_evd_copy_cq (
-    DAPL_EVD 	*evd_ptr)
+void dapls_evd_copy_cq(DAPL_EVD * evd_ptr)
 {
-    ib_work_completion_t	cur_cqe;
-    DAT_RETURN			dat_status;
-    DAT_EVENT			*event;
+	ib_work_completion_t cur_cqe;
+	DAT_RETURN dat_status;
+	DAT_EVENT *event;
 
-    if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE)
-    {
-	/* Nothing to do if no CQ.  */
-	return;
-    }
+	if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE) {
+		/* Nothing to do if no CQ.  */
+		return;
+	}
 
-    while (1)
-    {
-	dat_status = dapls_ib_completion_poll (evd_ptr->header.owner_ia->hca_ptr,
-					       evd_ptr,
-					       &cur_cqe);
+	while (1) {
+		dat_status =
+		    dapls_ib_completion_poll(evd_ptr->header.owner_ia->hca_ptr,
+					     evd_ptr, &cur_cqe);
 
-	if (dat_status != DAT_SUCCESS)
-	{
-	    break;
-	}
+		if (dat_status != DAT_SUCCESS) {
+			break;
+		}
 
-	/* For debugging.  */
-	dapli_evd_eh_print_cqe (&cur_cqe);
+		/* For debugging.  */
+		dapli_evd_eh_print_cqe(&cur_cqe);
 
-	/*
-	 * Can use DAT_DTO_COMPLETION_EVENT because dapli_evd_cqe_to_event
-	 * will overwrite.
-	 */
+		/*
+		 * Can use DAT_DTO_COMPLETION_EVENT because dapli_evd_cqe_to_event
+		 * will overwrite.
+		 */
 
-	event = dapli_evd_get_and_init_event (
-		evd_ptr, DAT_DTO_COMPLETION_EVENT );
-	if (event == NULL)
-	{
-	    /* We've already attempted the overflow post; return.  */
-	    return;
-	}
+		event =
+		    dapli_evd_get_and_init_event(evd_ptr,
+						 DAT_DTO_COMPLETION_EVENT);
+		if (event == NULL) {
+			/* We've already attempted the overflow post; return.  */
+			return;
+		}
 
-	dapli_evd_cqe_to_event ( evd_ptr, &cur_cqe, event );
+		dapli_evd_cqe_to_event(evd_ptr, &cur_cqe, event);
 
-	dapli_evd_post_event_nosignal ( evd_ptr, event );
-    }
+		dapli_evd_post_event_nosignal(evd_ptr, event);
+	}
 
-    if ( DAT_GET_TYPE (dat_status) != DAT_QUEUE_EMPTY )
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-	    "dapls_evd_copy_cq: dapls_ib_completion_poll returned 0x%x\n",
-	    dat_status);
-	dapl_os_assert (!"Bad return from dapls_ib_completion_poll");
-    }
+	if (DAT_GET_TYPE(dat_status) != DAT_QUEUE_EMPTY) {
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     "dapls_evd_copy_cq: dapls_ib_completion_poll returned 0x%x\n",
+			     dat_status);
+		dapl_os_assert(!"Bad return from dapls_ib_completion_poll");
+	}
 }
 
 /*
@@ -1498,26 +1433,23 @@
  *
  */
 DAT_RETURN
-dapls_evd_cq_poll_to_event (
-    IN DAPL_EVD 	*evd_ptr,
-    OUT DAT_EVENT	*event)
+dapls_evd_cq_poll_to_event(IN DAPL_EVD * evd_ptr, OUT DAT_EVENT * event)
 {
-    DAT_RETURN			dat_status;
-    ib_work_completion_t	cur_cqe;
+	DAT_RETURN dat_status;
+	ib_work_completion_t cur_cqe;
 
-    dat_status = dapls_ib_completion_poll (evd_ptr->header.owner_ia->hca_ptr,
-					   evd_ptr,
-					   &cur_cqe);
-    if (dat_status == DAT_SUCCESS)
-    {
-	/* For debugging.  */
-	dapli_evd_eh_print_cqe (&cur_cqe);
+	dat_status = dapls_ib_completion_poll(evd_ptr->header.owner_ia->hca_ptr,
+					      evd_ptr, &cur_cqe);
+	if (dat_status == DAT_SUCCESS) {
+		/* For debugging.  */
+		dapli_evd_eh_print_cqe(&cur_cqe);
 
-	dapli_evd_cqe_to_event (evd_ptr, &cur_cqe, event);
-    }
+		dapli_evd_cqe_to_event(evd_ptr, &cur_cqe, event);
+	}
 
-    return dat_status;
+	return dat_status;
 }
+
 #ifdef DAPL_DBG_IO_TRC
 /*
  * Update I/O completions in the I/O trace buffer. I/O is posted to
@@ -1525,78 +1457,74 @@
  * completed with the completion status
  */
 void
-dapls_io_trc_update_completion (
-    DAPL_EP			*ep_ptr,
-    DAPL_COOKIE			*cookie,
-    DAT_DTO_COMPLETION_STATUS	dto_status)
+dapls_io_trc_update_completion(DAPL_EP * ep_ptr,
+			       DAPL_COOKIE * cookie,
+			       DAT_DTO_COMPLETION_STATUS dto_status)
 {
-    int i;
-    static unsigned int		c_cnt = 1;
+	int i;
+	static unsigned int c_cnt = 1;
 
-    for (i = 0; i < DBG_IO_TRC_QLEN; i++)
-    {
-	if (ep_ptr->ibt_base[i].cookie == cookie)
-	{
-	    ep_ptr->ibt_base[i].status = dto_status;
-	    ep_ptr->ibt_base[i].done   = c_cnt++;
+	for (i = 0; i < DBG_IO_TRC_QLEN; i++) {
+		if (ep_ptr->ibt_base[i].cookie == cookie) {
+			ep_ptr->ibt_base[i].status = dto_status;
+			ep_ptr->ibt_base[i].done = c_cnt++;
+		}
 	}
-    }
 }
 
-
 /*
  * Dump the I/O trace buffers
  */
 void
-dapls_io_trc_dump (
-    DAPL_EP			*ep_ptr,
-    void			*cqe_ptr,
-    DAT_DTO_COMPLETION_STATUS	dto_status)
+dapls_io_trc_dump(DAPL_EP * ep_ptr,
+		  void *cqe_ptr, DAT_DTO_COMPLETION_STATUS dto_status)
 {
-    struct io_buf_track *ibt;
-    int 		 i;
-    int			 cnt;
+	struct io_buf_track *ibt;
+	int i;
+	int cnt;
 
-    dapl_os_printf ("DISCONNECTING: dto_status     = %x\n", dto_status);
-    dapl_os_printf ("               OpType        = %x\n",
-		   DAPL_GET_CQE_OPTYPE (cqe_ptr));
-    dapl_os_printf ("               Bytes         = %x\n",
-		   DAPL_GET_CQE_BYTESNUM (cqe_ptr));
-    dapl_os_printf ("               WRID (cookie) = %llx\n",
-		   DAPL_GET_CQE_WRID (cqe_ptr));
+	dapl_os_printf("DISCONNECTING: dto_status     = %x\n", dto_status);
+	dapl_os_printf("               OpType        = %x\n",
+		       DAPL_GET_CQE_OPTYPE(cqe_ptr));
+	dapl_os_printf("               Bytes         = %x\n",
+		       DAPL_GET_CQE_BYTESNUM(cqe_ptr));
+	dapl_os_printf("               WRID (cookie) = %llx\n",
+		       DAPL_GET_CQE_WRID(cqe_ptr));
 
-    if (ep_ptr->ibt_dumped == 0)
-    {
+	if (ep_ptr->ibt_dumped == 0) {
 
-	dapl_os_printf ("EP %p (qpn %d) I/O trace buffer\n",
-		       ep_ptr, ep_ptr->qpn);
+		dapl_os_printf("EP %p (qpn %d) I/O trace buffer\n",
+			       ep_ptr, ep_ptr->qpn);
 
-	ep_ptr->ibt_dumped = 1;
-	ibt = (struct io_buf_track *)dapls_rbuf_remove (&ep_ptr->ibt_queue);
-	cnt = DBG_IO_TRC_QLEN;
-	while (ibt != NULL && cnt > 0)
-	{
-	    dapl_os_printf ("%2d. %3s (%2d, %d) OP: %x cookie %p wqe %p rmv_target_addr %llx rmv_rmr_context %x\n",
-		cnt, ibt->done == 0 ? "WRK" : "DON", ibt->status, ibt->done,
-		ibt->op_type, ibt->cookie, ibt->wqe,
-		ibt->remote_iov.target_address,
-		ibt->remote_iov.rmr_context);
-	    for (i = 0; i < 3; i++)
-	    {
-		if (ibt->iov[i].segment_length != 0)
-		{
-		    dapl_os_printf ("     (%4llx, %8x, %8llx)\n",
-				   ibt->iov[i].segment_length,
-				   ibt->iov[i].lmr_context,
-				   ibt->iov[i].virtual_address);
+		ep_ptr->ibt_dumped = 1;
+		ibt =
+		    (struct io_buf_track *)dapls_rbuf_remove(&ep_ptr->
+							     ibt_queue);
+		cnt = DBG_IO_TRC_QLEN;
+		while (ibt != NULL && cnt > 0) {
+			dapl_os_printf
+			    ("%2d. %3s (%2d, %d) OP: %x cookie %p wqe %p rmv_target_addr %llx rmv_rmr_context %x\n",
+			     cnt, ibt->done == 0 ? "WRK" : "DON", ibt->status,
+			     ibt->done, ibt->op_type, ibt->cookie, ibt->wqe,
+			     ibt->remote_iov.target_address,
+			     ibt->remote_iov.rmr_context);
+			for (i = 0; i < 3; i++) {
+				if (ibt->iov[i].segment_length != 0) {
+					dapl_os_printf
+					    ("     (%4llx, %8x, %8llx)\n",
+					     ibt->iov[i].segment_length,
+					     ibt->iov[i].lmr_context,
+					     ibt->iov[i].virtual_address);
+				}
+			}
+			ibt =
+			    (struct io_buf_track *)dapls_rbuf_remove(&ep_ptr->
+								     ibt_queue);
+			cnt--;
 		}
-	    }
-	    ibt = (struct io_buf_track *)dapls_rbuf_remove (&ep_ptr->ibt_queue);
-	    cnt--;
 	}
-    }
 }
-#endif /* DAPL_DBG_IO_TRC */
+#endif				/* DAPL_DBG_IO_TRC */
 
 /*
  * Local variables:

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_consumer_context.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_consumer_context.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_consumer_context.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -56,41 +56,37 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_get_consumer_context (
-	IN	DAT_HANDLE  dat_handle,
-	OUT	DAT_CONTEXT *context )
+dapl_get_consumer_context(IN DAT_HANDLE dat_handle, OUT DAT_CONTEXT * context)
 {
-    DAT_RETURN	dat_status;
-    DAPL_HEADER	*header;
+	DAT_RETURN dat_status;
+	DAPL_HEADER *header;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    header = (DAPL_HEADER *)dat_handle;
-    if ( ((header) == NULL) ||
-	 DAPL_BAD_PTR(header) ||
-	 (header->magic != DAPL_MAGIC_IA &&
-	  header->magic != DAPL_MAGIC_EVD &&
-	  header->magic != DAPL_MAGIC_EP &&
-	  header->magic != DAPL_MAGIC_LMR &&
-	  header->magic != DAPL_MAGIC_RMR &&
-	  header->magic != DAPL_MAGIC_PZ &&
-	  header->magic != DAPL_MAGIC_PSP &&
-	  header->magic != DAPL_MAGIC_RSP &&
-	  header->magic != DAPL_MAGIC_CR))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    if ( context == NULL || DAPL_BAD_PTR(header) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	header = (DAPL_HEADER *) dat_handle;
+	if (((header) == NULL) ||
+	    DAPL_BAD_PTR(header) ||
+	    (header->magic != DAPL_MAGIC_IA &&
+	     header->magic != DAPL_MAGIC_EVD &&
+	     header->magic != DAPL_MAGIC_EP &&
+	     header->magic != DAPL_MAGIC_LMR &&
+	     header->magic != DAPL_MAGIC_RMR &&
+	     header->magic != DAPL_MAGIC_PZ &&
+	     header->magic != DAPL_MAGIC_PSP &&
+	     header->magic != DAPL_MAGIC_RSP &&
+	     header->magic != DAPL_MAGIC_CR)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	if (context == NULL || DAPL_BAD_PTR(header)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    *context = header->user_context;
+	*context = header->user_context;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_handle_type.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_handle_type.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_get_handle_type.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,33 +57,31 @@
  */
 
 DAT_RETURN DAT_API
-dapl_get_handle_type (
-	IN	DAT_HANDLE	   dat_handle,
-	OUT	DAT_HANDLE_TYPE	   *handle_type )
+dapl_get_handle_type(IN DAT_HANDLE dat_handle,
+		     OUT DAT_HANDLE_TYPE * handle_type)
 {
-    DAT_RETURN	dat_status;
-    DAPL_HEADER	*header;
+	DAT_RETURN dat_status;
+	DAPL_HEADER *header;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    header = (DAPL_HEADER *)dat_handle;
-    if ( ((header) == NULL) ||
-	 DAPL_BAD_PTR(header) ||
-	 (header->magic != DAPL_MAGIC_IA &&
-	  header->magic != DAPL_MAGIC_EVD &&
-	  header->magic != DAPL_MAGIC_EP &&
-	  header->magic != DAPL_MAGIC_LMR &&
-	  header->magic != DAPL_MAGIC_RMR &&
-	  header->magic != DAPL_MAGIC_PZ &&
-	  header->magic != DAPL_MAGIC_PSP &&
-	  header->magic != DAPL_MAGIC_RSP &&
-	  header->magic != DAPL_MAGIC_CR))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    *handle_type = header->handle_type;
+	header = (DAPL_HEADER *) dat_handle;
+	if (((header) == NULL) ||
+	    DAPL_BAD_PTR(header) ||
+	    (header->magic != DAPL_MAGIC_IA &&
+	     header->magic != DAPL_MAGIC_EVD &&
+	     header->magic != DAPL_MAGIC_EP &&
+	     header->magic != DAPL_MAGIC_LMR &&
+	     header->magic != DAPL_MAGIC_RMR &&
+	     header->magic != DAPL_MAGIC_PZ &&
+	     header->magic != DAPL_MAGIC_PSP &&
+	     header->magic != DAPL_MAGIC_RSP &&
+	     header->magic != DAPL_MAGIC_CR)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	*handle_type = header->handle_type;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hash.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hash.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hash.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -48,39 +48,36 @@
 /*
  * A hash table element
  */
-typedef struct DAPL_HASH_ELEM
-{
-    struct DAPL_HASH_ELEM * next_element;
-    DAPL_HASH_KEY           key;
-    void *                  datum;
+typedef struct DAPL_HASH_ELEM {
+	struct DAPL_HASH_ELEM *next_element;
+	DAPL_HASH_KEY key;
+	void *datum;
 } DAPL_HASH_ELEM;
 
 /*
  * The hash table
  */
-struct dapl_hash_table
-{
-    unsigned long       num_entries;
-    unsigned long       tbl_size;
-    DAPL_HASH_ELEM      *table;
-    DAPL_OS_LOCK        lock;
-    /*
-     * statistics - we tally on insert operations, counting
-     * the number of entries in the whole hash table, as
-     * well as the length of chains we walk to insert.  This
-     * ignores empty buckets, giving us data on overall table
-     * occupancy, as well as max/average chain length for
-     * the buckets used.  If our hash function results in
-     * hot buckets, this will show it.
-     */
-    uint64_t  hash_tbl_inserts;   /* total inserts ops    */
-    uint64_t  hash_tbl_max;       /* max in entire table  */
-    uint64_t  hash_tbl_total;     /* total in table       */
-    uint64_t  hash_chn_max;       /* longest chain        */
-    uint64_t  hash_chn_total;     /* total non-0 lenghts  */
+struct dapl_hash_table {
+	unsigned long num_entries;
+	unsigned long tbl_size;
+	DAPL_HASH_ELEM *table;
+	DAPL_OS_LOCK lock;
+	/*
+	 * statistics - we tally on insert operations, counting
+	 * the number of entries in the whole hash table, as
+	 * well as the length of chains we walk to insert.  This
+	 * ignores empty buckets, giving us data on overall table
+	 * occupancy, as well as max/average chain length for
+	 * the buckets used.  If our hash function results in
+	 * hot buckets, this will show it.
+	 */
+	uint64_t hash_tbl_inserts;	/* total inserts ops    */
+	uint64_t hash_tbl_max;	/* max in entire table  */
+	uint64_t hash_tbl_total;	/* total in table       */
+	uint64_t hash_chn_max;	/* longest chain        */
+	uint64_t hash_chn_total;	/* total non-0 lenghts  */
 };
 
-
 /*********************************************************************
  *                                                                   *
  * Defines                                                           *
@@ -113,7 +110,6 @@
         }\
     } while (0)
 
-
 /*********************************************************************
  *                                                                   *
  * Internal Functions                                                *
@@ -128,34 +124,28 @@
  *	    head	head for list
  */
 static void
-dapli_hash_rehash (
-		 DAPL_HASH_ELEM * element,
-		 DAPL_HASH_KEY key,
-		 void **datum,
-		 DAPL_HASH_ELEM ** head)
+dapli_hash_rehash(DAPL_HASH_ELEM * element,
+		  DAPL_HASH_KEY key, void **datum, DAPL_HASH_ELEM ** head)
 {
-    /*
-     * assume we looked at the contents of element already,
-     * and start with the next element.
-     */
-    dapl_os_assert (element->next_element);
-    dapl_os_assert (!NO_DATUM (element->datum));
+	/*
+	 * assume we looked at the contents of element already,
+	 * and start with the next element.
+	 */
+	dapl_os_assert(element->next_element);
+	dapl_os_assert(!NO_DATUM(element->datum));
 
-    *head = element;
-    while (1)
-    {
-	element = element->next_element;
-	if (!element)
-	{
-	    break;
+	*head = element;
+	while (1) {
+		element = element->next_element;
+		if (!element) {
+			break;
+		}
+		if (element->key == key) {
+			*datum = element->datum;
+			return;
+		}
 	}
-	if (element->key == key)
-	{
-	    *datum = element->datum;
-	    return;
-	}
-    }
-    *head = 0;
+	*head = 0;
 }
 
 /*
@@ -170,122 +160,102 @@
  *          DAT_TRUE on success     
  */
 static DAT_BOOLEAN
-dapli_hash_add (
-              DAPL_HASH_TABLEP p_table,
-              DAPL_HASH_KEY key,
-              void          *datum,
-              DAT_BOOLEAN   allow_dup,
-              DAT_BOOLEAN * report_dup)
+dapli_hash_add(DAPL_HASH_TABLEP p_table,
+	       DAPL_HASH_KEY key,
+	       void *datum, DAT_BOOLEAN allow_dup, DAT_BOOLEAN * report_dup)
 {
-    void           *olddatum;
-    DAPL_HASH_KEY   hashValue, save_key = key;
-    DAPL_HASH_ELEM *found;
-    DAT_BOOLEAN     status = DAT_FALSE;
-    unsigned int    chain_len = 0;
+	void *olddatum;
+	DAPL_HASH_KEY hashValue, save_key = key;
+	DAPL_HASH_ELEM *found;
+	DAT_BOOLEAN status = DAT_FALSE;
+	unsigned int chain_len = 0;
 
-    if (report_dup)
-    {
-	(*report_dup) = DAT_FALSE;
-    }
+	if (report_dup) {
+		(*report_dup) = DAT_FALSE;
+	}
 
-    if (NO_DATUM (datum))
-    {
-	/*
-	 * Reserved value used for datum
-	 */
-	dapl_dbg_log (
-            DAPL_DBG_TYPE_ERR,
-            "dapli_hash_add () called with magic NO_DATA value (%p) "
-            "used as datum!\n", datum);
-	return DAT_FALSE;
-    }
+	if (NO_DATUM(datum)) {
+		/*
+		 * Reserved value used for datum
+		 */
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dapli_hash_add () called with magic NO_DATA value (%p) "
+			     "used as datum!\n", datum);
+		return DAT_FALSE;
+	}
 
-    DAPL_HASHLOOKUP (p_table, key, olddatum, found);
-    if (found)
-    {
-	/*
-	 * key exists already
-	 */
-	if (report_dup)
-	{
-	    *report_dup = DAT_TRUE;
+	DAPL_HASHLOOKUP(p_table, key, olddatum, found);
+	if (found) {
+		/*
+		 * key exists already
+		 */
+		if (report_dup) {
+			*report_dup = DAT_TRUE;
+		}
+
+		if (!allow_dup) {
+			dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+				     "dapli_hash_add () called with duplicate key ("
+				     F64x ")\n", key);
+			return DAT_FALSE;
+		}
 	}
 
-	if (!allow_dup)
-	{
-	    dapl_dbg_log (
-                DAPL_DBG_TYPE_ERR,
-                "dapli_hash_add () called with duplicate key (" F64x ")\n",
-                key);
-	    return DAT_FALSE;
+	hashValue = DAPL_DOHASH(key, p_table->tbl_size);
+	key = save_key;
+	if (NO_DATUM(p_table->table[hashValue].datum)) {
+		/*
+		 * Empty head - just fill it in
+		 */
+		p_table->table[hashValue].key = key;
+		p_table->table[hashValue].datum = datum;
+		p_table->table[hashValue].next_element = 0;
+		p_table->num_entries++;
+		status = DAT_TRUE;
+	} else {
+		DAPL_HASH_ELEM *newelement = (DAPL_HASH_ELEM *)
+		    dapl_os_alloc(sizeof(DAPL_HASH_ELEM));
+		/*
+		 * Add an element to the end of the chain
+		 */
+		if (newelement) {
+			DAPL_HASH_ELEM *lastelement;
+			newelement->key = key;
+			newelement->datum = datum;
+			newelement->next_element = 0;
+			for (lastelement = &p_table->table[hashValue];
+			     lastelement->next_element;
+			     lastelement = lastelement->next_element) {
+				/* Walk to the end of the chain */
+				chain_len++;
+			}
+			lastelement->next_element = newelement;
+			p_table->num_entries++;
+			status = DAT_TRUE;
+		} else {
+			/* allocation failed - should not happen */
+			status = DAT_FALSE;
+		}
 	}
-    }
 
-    hashValue = DAPL_DOHASH (key, p_table->tbl_size);
-    key = save_key;
-    if (NO_DATUM (p_table->table[hashValue].datum))
-    {
 	/*
-	 * Empty head - just fill it in
+	 * Tally up our counters. chain_len is one less than current chain
+	 * length.
 	 */
-	p_table->table[hashValue].key = key;
-	p_table->table[hashValue].datum = datum;
-	p_table->table[hashValue].next_element = 0;
-	p_table->num_entries++;
-	status = DAT_TRUE;
-    }
-    else
-    {
-	DAPL_HASH_ELEM *newelement = (DAPL_HASH_ELEM *)
-                                        dapl_os_alloc (sizeof (DAPL_HASH_ELEM));
-	/*
-	 * Add an element to the end of the chain
-	 */
-	if (newelement)
-	{
-	    DAPL_HASH_ELEM *lastelement;
-	    newelement->key = key;
-	    newelement->datum = datum;
-	    newelement->next_element = 0;
-	    for (lastelement = &p_table->table[hashValue];
-                 lastelement->next_element;
-                 lastelement = lastelement->next_element)
-	    {
-		/* Walk to the end of the chain */
-		chain_len++;
-	    }
-	    lastelement->next_element = newelement;
-	    p_table->num_entries++;
-	    status = DAT_TRUE;
+	chain_len++;
+	p_table->hash_tbl_inserts++;
+	p_table->hash_tbl_total += p_table->num_entries;
+	p_table->hash_chn_total += chain_len;
+	if (p_table->num_entries > p_table->hash_tbl_max) {
+		p_table->hash_tbl_max = p_table->num_entries;
 	}
-	else
-	{
-	    /* allocation failed - should not happen */
-	    status = DAT_FALSE;
+	if (chain_len > p_table->hash_chn_max) {
+		p_table->hash_chn_max = chain_len;
 	}
-    }
 
-    /*
-     * Tally up our counters. chain_len is one less than current chain
-     * length.
-     */
-    chain_len++;
-    p_table->hash_tbl_inserts++;
-    p_table->hash_tbl_total += p_table->num_entries;
-    p_table->hash_chn_total += chain_len;
-    if (p_table->num_entries > p_table->hash_tbl_max)
-    {
-	p_table->hash_tbl_max = p_table->num_entries;
-    }
-    if (chain_len > p_table->hash_chn_max)
-    {
-	p_table->hash_chn_max = chain_len;
-    }
-
-    return status;
+	return status;
 }
 
-
 /*
  * Remove element from hash bucket
  * 
@@ -295,180 +265,159 @@
  *          DAT_TRUE on success
  */
 static DAT_BOOLEAN
-dapl_hash_delete_element (DAPL_HASH_ELEM * element,
-                         DAPL_HASH_KEY key,
-                         DAPL_HASH_DATA *p_datum)
+dapl_hash_delete_element(DAPL_HASH_ELEM * element,
+			 DAPL_HASH_KEY key, DAPL_HASH_DATA * p_datum)
 {
-    DAPL_HASH_ELEM *curelement;
-    DAPL_HASH_ELEM *lastelement;
+	DAPL_HASH_ELEM *curelement;
+	DAPL_HASH_ELEM *lastelement;
 
-    lastelement = NULL;
-    for (curelement = element;
-         curelement;
-         lastelement = curelement, curelement = curelement->next_element)
-    {
-	if (curelement->key == key)
-	{
-	    if (p_datum)
-	    {
-		*p_datum = curelement->datum;
-	    }
-	    if (lastelement)
-	    {
-		/*
-		 * curelement was malloc'd; free it
-		 */
-		lastelement->next_element = curelement->next_element;
-		dapl_os_free ((void *) curelement, sizeof (DAPL_HASH_ELEM));
-	    }
-	    else
-	    {
-		/*
-		 * curelement is static list head
-		 */
-		DAPL_HASH_ELEM *n = curelement->next_element;
-		if (n)
-		{
-		    /*
-		     * If there is a next element, copy its contents into the
-		     * head and free the original next element.
-		     */
-		    curelement->key = n->key;
-		    curelement->datum = n->datum;
-		    curelement->next_element = n->next_element;
-		    dapl_os_free ((void *) n, sizeof (DAPL_HASH_ELEM));
+	lastelement = NULL;
+	for (curelement = element;
+	     curelement;
+	     lastelement = curelement, curelement = curelement->next_element) {
+		if (curelement->key == key) {
+			if (p_datum) {
+				*p_datum = curelement->datum;
+			}
+			if (lastelement) {
+				/*
+				 * curelement was malloc'd; free it
+				 */
+				lastelement->next_element =
+				    curelement->next_element;
+				dapl_os_free((void *)curelement,
+					     sizeof(DAPL_HASH_ELEM));
+			} else {
+				/*
+				 * curelement is static list head
+				 */
+				DAPL_HASH_ELEM *n = curelement->next_element;
+				if (n) {
+					/*
+					 * If there is a next element, copy its contents into the
+					 * head and free the original next element.
+					 */
+					curelement->key = n->key;
+					curelement->datum = n->datum;
+					curelement->next_element =
+					    n->next_element;
+					dapl_os_free((void *)n,
+						     sizeof(DAPL_HASH_ELEM));
+				} else {
+					curelement->datum = NO_DATUM_VALUE;
+				}
+			}
+			break;
 		}
-		else
-		{
-		    curelement->datum = NO_DATUM_VALUE;
-		}
-	    }
-	    break;
 	}
-    }
 
-    return ( curelement != NULL ? DAT_TRUE : DAT_FALSE );
+	return (curelement != NULL ? DAT_TRUE : DAT_FALSE);
 }
 
-
 /*********************************************************************
  *                                                                   *
  * External Functions                                                *
  *                                                                   *
  *********************************************************************/
 
-
 /*
  * Create a new hash table with at least 'table_size' hash buckets.
  */
 DAT_RETURN
-dapls_hash_create (
-    IN DAT_COUNT        table_size,
-    OUT DAPL_HASH_TABLE **pp_table)
+dapls_hash_create(IN DAT_COUNT table_size, OUT DAPL_HASH_TABLE ** pp_table)
 {
-    DAPL_HASH_TABLE *p_table;
-    DAT_COUNT       table_length = table_size * sizeof (DAPL_HASH_ELEM);
-    DAT_RETURN	    dat_status;
-    DAT_COUNT	    i;
+	DAPL_HASH_TABLE *p_table;
+	DAT_COUNT table_length = table_size * sizeof(DAPL_HASH_ELEM);
+	DAT_RETURN dat_status;
+	DAT_COUNT i;
 
-    dapl_os_assert (pp_table);
-    dat_status = DAT_SUCCESS;
+	dapl_os_assert(pp_table);
+	dat_status = DAT_SUCCESS;
 
-    /* Allocate hash table */
-    p_table = dapl_os_alloc (sizeof (DAPL_HASH_TABLE));
-    if (NULL == p_table)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* Allocate hash table */
+	p_table = dapl_os_alloc(sizeof(DAPL_HASH_TABLE));
+	if (NULL == p_table) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /* Init hash table, allocate and init and buckets */
-    dapl_os_memzero (p_table, sizeof (DAPL_HASH_TABLE));
-    p_table->tbl_size = table_size;
-    p_table->table = (DAPL_HASH_ELEM *) dapl_os_alloc (table_length);
-    if (NULL == p_table->table)
-    {
-	dapl_os_free (p_table, sizeof (DAPL_HASH_TABLE));
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* Init hash table, allocate and init and buckets */
+	dapl_os_memzero(p_table, sizeof(DAPL_HASH_TABLE));
+	p_table->tbl_size = table_size;
+	p_table->table = (DAPL_HASH_ELEM *) dapl_os_alloc(table_length);
+	if (NULL == p_table->table) {
+		dapl_os_free(p_table, sizeof(DAPL_HASH_TABLE));
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dapl_os_lock_init (&p_table->lock);
-    for (i = 0;  i < table_size;  i++)
-    {
-	p_table->table[i].datum = NO_DATUM_VALUE;
-	p_table->table[i].key   = 0;
-	p_table->table[i].next_element = 0;
-    }
+	dapl_os_lock_init(&p_table->lock);
+	for (i = 0; i < table_size; i++) {
+		p_table->table[i].datum = NO_DATUM_VALUE;
+		p_table->table[i].key = 0;
+		p_table->table[i].next_element = 0;
+	}
 
-    *pp_table = p_table;
+	*pp_table = p_table;
 
- bail:
-    return DAT_SUCCESS;
+      bail:
+	return DAT_SUCCESS;
 }
 
-
 /*
  * Destroy a hash table
  */
-DAT_RETURN
-dapls_hash_free (
-    IN DAPL_HASH_TABLE *p_table)
+DAT_RETURN dapls_hash_free(IN DAPL_HASH_TABLE * p_table)
 {
-    dapl_os_assert (p_table && p_table->table);
+	dapl_os_assert(p_table && p_table->table);
 
-    dapl_os_lock_destroy (&p_table->lock);
-    dapl_os_free (p_table->table, sizeof (DAPL_HASH_ELEM) * p_table->tbl_size);
-    dapl_os_free (p_table, sizeof (DAPL_HASH_TABLE));
+	dapl_os_lock_destroy(&p_table->lock);
+	dapl_os_free(p_table->table,
+		     sizeof(DAPL_HASH_ELEM) * p_table->tbl_size);
+	dapl_os_free(p_table, sizeof(DAPL_HASH_TABLE));
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * Returns the number of elements stored in the table
  */
 
-DAT_RETURN
-dapls_hash_size (
-    IN DAPL_HASH_TABLE  *p_table,
-    OUT DAT_COUNT       *p_size)
+DAT_RETURN dapls_hash_size(IN DAPL_HASH_TABLE * p_table, OUT DAT_COUNT * p_size)
 {
-    dapl_os_assert (p_table && p_size);
+	dapl_os_assert(p_table && p_size);
 
-    *p_size = p_table->num_entries;
+	*p_size = p_table->num_entries;
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * Inserts the specified data into the table with the given key.
  * Duplicates are not expected, and return in error, having done nothing.
  */
 
 DAT_RETURN
-dapls_hash_insert (
-    IN DAPL_HASH_TABLE  *p_table, 
-    IN DAPL_HASH_KEY    key,
-    IN DAPL_HASH_DATA   data)
+dapls_hash_insert(IN DAPL_HASH_TABLE * p_table,
+		  IN DAPL_HASH_KEY key, IN DAPL_HASH_DATA data)
 {
-    DAT_RETURN	    dat_status;
+	DAT_RETURN dat_status;
 
-    dapl_os_assert (p_table);
-    dat_status = DAT_SUCCESS;
+	dapl_os_assert(p_table);
+	dat_status = DAT_SUCCESS;
 
-    dapl_os_lock (&p_table->lock);
-    if (!dapli_hash_add (p_table, key, data, DAT_FALSE, NULL))
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-    }
-    dapl_os_unlock (&p_table->lock);
+	dapl_os_lock(&p_table->lock);
+	if (!dapli_hash_add(p_table, key, data, DAT_FALSE, NULL)) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+	}
+	dapl_os_unlock(&p_table->lock);
 
-    return dat_status;
+	return dat_status;
 }
 
-
 /*
  * Searches for the given key.  If found, 
  * DAT_SUCCESS is returned and the associated 
@@ -476,63 +425,54 @@
  * pointer if that pointer is not NULL.
  */
 DAT_RETURN
-dapls_hash_search (
-    IN DAPL_HASH_TABLE *p_table,
-    IN DAPL_HASH_KEY    key,
-    OUT DAPL_HASH_DATA *p_data)
+dapls_hash_search(IN DAPL_HASH_TABLE * p_table,
+		  IN DAPL_HASH_KEY key, OUT DAPL_HASH_DATA * p_data)
 {
-    DAT_RETURN	    dat_status;
-    void           *olddatum;
-    DAPL_HASH_ELEM *found;
+	DAT_RETURN dat_status;
+	void *olddatum;
+	DAPL_HASH_ELEM *found;
 
-    dapl_os_assert (p_table);
-    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,0);
+	dapl_os_assert(p_table);
+	dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, 0);
 
-    dapl_os_lock (&p_table->lock);
-    DAPL_HASHLOOKUP (p_table, key, olddatum, found);
-    dapl_os_unlock (&p_table->lock);
+	dapl_os_lock(&p_table->lock);
+	DAPL_HASHLOOKUP(p_table, key, olddatum, found);
+	dapl_os_unlock(&p_table->lock);
 
-    if (found)
-    {
-	if (p_data)
-	{
-	    *p_data = olddatum;
+	if (found) {
+		if (p_data) {
+			*p_data = olddatum;
+		}
+		dat_status = DAT_SUCCESS;
 	}
-	dat_status = DAT_SUCCESS;
-    }
 
-    return dat_status;
+	return dat_status;
 }
 
-
 DAT_RETURN
-dapls_hash_remove (
-    IN DAPL_HASH_TABLE *p_table,
-    IN DAPL_HASH_KEY key,
-    OUT DAPL_HASH_DATA *p_data)
+dapls_hash_remove(IN DAPL_HASH_TABLE * p_table,
+		  IN DAPL_HASH_KEY key, OUT DAPL_HASH_DATA * p_data)
 {
-    DAT_RETURN      dat_status;
-    DAPL_HASH_KEY   hashValue, save_key = key;
+	DAT_RETURN dat_status;
+	DAPL_HASH_KEY hashValue, save_key = key;
 
-    dapl_os_assert (p_table);
-    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,0);
+	dapl_os_assert(p_table);
+	dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, 0);
 
-    if (p_table->num_entries == 0)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-                      "dapls_hash_remove () called on empty hash table!\n");
-	return dat_status;
-    }
+	if (p_table->num_entries == 0) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dapls_hash_remove () called on empty hash table!\n");
+		return dat_status;
+	}
 
-    hashValue = DAPL_DOHASH (key, p_table->tbl_size);
-    key = save_key;
-    dapl_os_lock (&p_table->lock);
-    if (dapl_hash_delete_element (&p_table->table[hashValue], key, p_data))
-    {
-	p_table->num_entries--;
-	dat_status = DAT_SUCCESS;
-    }
-    dapl_os_unlock (&p_table->lock);
+	hashValue = DAPL_DOHASH(key, p_table->tbl_size);
+	key = save_key;
+	dapl_os_lock(&p_table->lock);
+	if (dapl_hash_delete_element(&p_table->table[hashValue], key, p_data)) {
+		p_table->num_entries--;
+		dat_status = DAT_SUCCESS;
+	}
+	dapl_os_unlock(&p_table->lock);
 
-    return dat_status;
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hca_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hca_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_hca_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -40,7 +40,6 @@
 #include "dapl_hca_util.h"
 #include "dapl_hash.h"
 
-
 /*
  * dapl_hca_alloc
  *
@@ -57,53 +56,46 @@
  * 	none
  *
  */
-DAPL_HCA *
-dapl_hca_alloc ( 
-    char 		*name,
-    char 		*port )
+DAPL_HCA *dapl_hca_alloc(char *name, char *port)
 {
-    DAPL_HCA	*hca_ptr;
+	DAPL_HCA *hca_ptr;
 
-    hca_ptr = dapl_os_alloc (sizeof (DAPL_HCA));
-    if ( NULL == hca_ptr )
-    {
-	goto bail;
-    }
+	hca_ptr = dapl_os_alloc(sizeof(DAPL_HCA));
+	if (NULL == hca_ptr) {
+		goto bail;
+	}
 
-    dapl_os_memzero (hca_ptr, sizeof (DAPL_HCA));
+	dapl_os_memzero(hca_ptr, sizeof(DAPL_HCA));
 
-    if ( DAT_SUCCESS != dapls_hash_create (
-	DAPL_HASH_TABLE_DEFAULT_CAPACITY, &hca_ptr->lmr_hash_table) )
-    {
-	goto bail;
-    }
+	if (DAT_SUCCESS !=
+	    dapls_hash_create(DAPL_HASH_TABLE_DEFAULT_CAPACITY,
+			      &hca_ptr->lmr_hash_table)) {
+		goto bail;
+	}
 
-    dapl_os_lock_init(&hca_ptr->lock);
-    dapl_llist_init_head(&hca_ptr->ia_list_head);
-            
-    hca_ptr->name = dapl_os_strdup(name);
-    if ( NULL == hca_ptr->name )
-    {
-	goto bail;
-    }
+	dapl_os_lock_init(&hca_ptr->lock);
+	dapl_llist_init_head(&hca_ptr->ia_list_head);
 
-    hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
-    hca_ptr->port_num = dapl_os_strtol(port, NULL, 0);
+	hca_ptr->name = dapl_os_strdup(name);
+	if (NULL == hca_ptr->name) {
+		goto bail;
+	}
 
-    return (hca_ptr);
+	hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
+	hca_ptr->port_num = dapl_os_strtol(port, NULL, 0);
 
-bail:
-    if ( NULL != hca_ptr )
-    {
-	if ( NULL != hca_ptr->lmr_hash_table )
-	{
-	    dapls_hash_free (hca_ptr->lmr_hash_table);
-	}
+	return (hca_ptr);
 
-	dapl_os_free (hca_ptr, sizeof (DAPL_HCA));
-    }
+      bail:
+	if (NULL != hca_ptr) {
+		if (NULL != hca_ptr->lmr_hash_table) {
+			dapls_hash_free(hca_ptr->lmr_hash_table);
+		}
 
-    return NULL;
+		dapl_os_free(hca_ptr, sizeof(DAPL_HCA));
+	}
+
+	return NULL;
 }
 
 /*
@@ -121,12 +113,11 @@
  * 	none
  *
  */
-void
-dapl_hca_free ( DAPL_HCA *hca_ptr )
+void dapl_hca_free(DAPL_HCA * hca_ptr)
 {
-    (void) dapls_hash_free ( hca_ptr->lmr_hash_table );
-    dapl_os_free(hca_ptr->name, dapl_os_strlen(hca_ptr->name)+1);
-    dapl_os_free (hca_ptr, sizeof (DAPL_HCA));
+	(void)dapls_hash_free(hca_ptr->lmr_hash_table);
+	dapl_os_free(hca_ptr->name, dapl_os_strlen(hca_ptr->name) + 1);
+	dapl_os_free(hca_ptr, sizeof(DAPL_HCA));
 }
 
 /*
@@ -145,16 +136,12 @@
  * 	none
  *
  */
-void
-dapl_hca_link_ia (
-	IN	DAPL_HCA	   *hca_ptr,
-	IN	DAPL_IA		   *ia_ptr)
+void dapl_hca_link_ia(IN DAPL_HCA * hca_ptr, IN DAPL_IA * ia_ptr)
 {
-    dapl_os_lock (&hca_ptr->lock);
-    dapl_llist_add_head (&hca_ptr->ia_list_head, 
-		     &ia_ptr->hca_ia_list_entry, 
-		     ia_ptr);
-    dapl_os_unlock (&hca_ptr->lock);
+	dapl_os_lock(&hca_ptr->lock);
+	dapl_llist_add_head(&hca_ptr->ia_list_head,
+			    &ia_ptr->hca_ia_list_entry, ia_ptr);
+	dapl_os_unlock(&hca_ptr->lock);
 }
 
 /*
@@ -173,21 +160,17 @@
  * 	none
  *
  */
-void
-dapl_hca_unlink_ia (
-	IN	DAPL_HCA	   *hca_ptr,
-	IN	DAPL_IA		   *ia_ptr)
+void dapl_hca_unlink_ia(IN DAPL_HCA * hca_ptr, IN DAPL_IA * ia_ptr)
 {
-    dapl_os_lock (&hca_ptr->lock);
-    /*
-     * If an error occurred when we were opening the IA it
-     * will not be linked on the list; don't unlink an unlinked
-     * list!
-     */
-    if ( ! dapl_llist_is_empty (&hca_ptr->ia_list_head) )
-    {
-	dapl_llist_remove_entry (&hca_ptr->ia_list_head, 
-				 &ia_ptr->hca_ia_list_entry);
-    }
-    dapl_os_unlock (&hca_ptr->lock);
+	dapl_os_lock(&hca_ptr->lock);
+	/*
+	 * If an error occurred when we were opening the IA it
+	 * will not be linked on the list; don't unlink an unlinked
+	 * list!
+	 */
+	if (!dapl_llist_is_empty(&hca_ptr->ia_list_head)) {
+		dapl_llist_remove_entry(&hca_ptr->ia_list_head,
+					&ia_ptr->hca_ia_list_entry);
+	}
+	dapl_os_unlock(&hca_ptr->lock);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_close.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_close.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_close.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,40 +58,30 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_ia_close (
-	IN	DAT_IA_HANDLE	ia_handle,
-	IN	DAT_CLOSE_FLAGS ia_flags)
+dapl_ia_close(IN DAT_IA_HANDLE ia_handle, IN DAT_CLOSE_FLAGS ia_flags)
 {
-    DAPL_IA			*ia_ptr;
-    DAT_RETURN			dat_status;
+	DAPL_IA *ia_ptr;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_ia_close (%p, %d)\n",
-		  ia_handle, 
-		  ia_flags);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_ia_close (%p, %d)\n", ia_handle, ia_flags);
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    
-    if (DAPL_BAD_HANDLE (ia_ptr, DAPL_MAGIC_IA))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
-    
-    if ( DAT_CLOSE_ABRUPT_FLAG == ia_flags )
-    {
-        dat_status = dapl_ia_abrupt_close (ia_ptr);
-    }
-    else if ( DAT_CLOSE_GRACEFUL_FLAG == ia_flags )
-    {
-        dat_status = dapl_ia_graceful_close (ia_ptr);
-    }
-    else 
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-    }
+	ia_ptr = (DAPL_IA *) ia_handle;
 
- bail:
-    return dat_status;
-}
+	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
 
+	if (DAT_CLOSE_ABRUPT_FLAG == ia_flags) {
+		dat_status = dapl_ia_abrupt_close(ia_ptr);
+	} else if (DAT_CLOSE_GRACEFUL_FLAG == ia_flags) {
+		dat_status = dapl_ia_graceful_close(ia_ptr);
+	} else {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+	}
+
+      bail:
+	return dat_status;
+}

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_ha.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_ha.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_ha.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,12 +61,10 @@
  *	DAT_MODEL_NOT_SUPPORTED
  */
 
-DAT_RETURN DAT_API
-dapl_ia_ha (
-	IN	 DAT_IA_HANDLE ia_handle, /* ia_handle */
-	IN const DAT_NAME_PTR  provider,  /* provider  */
-	OUT	 DAT_BOOLEAN  *answer)    /* answer    */
-{
+DAT_RETURN DAT_API dapl_ia_ha(IN DAT_IA_HANDLE ia_handle,	/* ia_handle */
+			      IN const DAT_NAME_PTR provider,	/* provider  */
+			      OUT DAT_BOOLEAN * answer)
+{				/* answer    */
 	return DAT_MODEL_NOT_SUPPORTED;
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_open.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_open.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_open.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -43,21 +43,15 @@
 #include "dapl_ia_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * LOCAL PROTOTYPES
  */
 #ifdef IBHOSTS_NAMING
-void dapli_assign_hca_ip_address (
-	DAPL_HCA		*hca_ptr,
-	char 			*device_name);
-#endif /* IBHOSTS_NAMING */
+void dapli_assign_hca_ip_address(DAPL_HCA * hca_ptr, char *device_name);
+#endif				/* IBHOSTS_NAMING */
 
-void dapli_hca_cleanup (
-	DAPL_HCA		*hca_ptr,
-	DAT_BOOLEAN		dec_ref );
+void dapli_hca_cleanup(DAPL_HCA * hca_ptr, DAT_BOOLEAN dec_ref);
 
-
 /*
  * dapl_ia_open
  *
@@ -87,254 +81,225 @@
  * 	DAT_PROVIDER_NOT_FOUND	(returned by dat registry if necessary)
  */
 DAT_RETURN DAT_API
-dapl_ia_open (
-	IN	const DAT_NAME_PTR name,
-	IN	DAT_COUNT	   async_evd_qlen,
-	INOUT	DAT_EVD_HANDLE     *async_evd_handle_ptr,
-	OUT	DAT_IA_HANDLE 	   *ia_handle_ptr)
+dapl_ia_open(IN const DAT_NAME_PTR name,
+	     IN DAT_COUNT async_evd_qlen,
+	     INOUT DAT_EVD_HANDLE * async_evd_handle_ptr,
+	     OUT DAT_IA_HANDLE * ia_handle_ptr)
 {
-    DAT_RETURN		dat_status;
-    DAT_PROVIDER	*provider;
-    DAPL_HCA		*hca_ptr;
-    DAPL_IA		*ia_ptr;
-    DAPL_EVD		*evd_ptr;
+	DAT_RETURN dat_status;
+	DAT_PROVIDER *provider;
+	DAPL_HCA *hca_ptr;
+	DAPL_IA *ia_ptr;
+	DAPL_EVD *evd_ptr;
 
-    dat_status = DAT_SUCCESS;
-    hca_ptr = NULL;
-    ia_ptr = NULL;
+	dat_status = DAT_SUCCESS;
+	hca_ptr = NULL;
+	ia_ptr = NULL;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_ia_open (%s, %d, %p, %p)\n",
-		  name,
-		  async_evd_qlen,
-		  async_evd_handle_ptr,
-		  ia_handle_ptr);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_ia_open (%s, %d, %p, %p)\n",
+		     name, async_evd_qlen, async_evd_handle_ptr, ia_handle_ptr);
 
-    dat_status = dapl_provider_list_search (name, &provider);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
-	goto bail;
-    }
+	dat_status = dapl_provider_list_search(name, &provider);
+	if (DAT_SUCCESS != dat_status) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+		goto bail;
+	}
 
-    /* ia_handle_ptr and async_evd_handle_ptr cannot be NULL */
-    if (ia_handle_ptr == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-	goto bail;
-    }
-    if (async_evd_handle_ptr == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	goto bail;
-    }
+	/* ia_handle_ptr and async_evd_handle_ptr cannot be NULL */
+	if (ia_handle_ptr == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
+	if (async_evd_handle_ptr == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    /* initialize the caller's OUT param */
-    *ia_handle_ptr = DAT_HANDLE_NULL;
+	/* initialize the caller's OUT param */
+	*ia_handle_ptr = DAT_HANDLE_NULL;
 
-    /* get the hca_ptr */
-    hca_ptr = (DAPL_HCA *) provider->extension;
+	/* get the hca_ptr */
+	hca_ptr = (DAPL_HCA *) provider->extension;
 
-    /*
-     * Open the HCA if it has not been done before.
-     */
-    dapl_os_lock (&hca_ptr->lock);
-    if (hca_ptr->ib_hca_handle == IB_INVALID_HANDLE )
-    {
-	/* register with the HW */
-	dat_status = dapls_ib_open_hca (hca_ptr->name,
-					hca_ptr);
-
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-			  "dapls_ib_open_hca failed %x\n", dat_status);
-	    dapl_os_unlock (&hca_ptr->lock);
-	    goto bail;
-	}
-
 	/*
-	 * Obtain the IP address associated with this name and HCA.
+	 * Open the HCA if it has not been done before.
 	 */
+	dapl_os_lock(&hca_ptr->lock);
+	if (hca_ptr->ib_hca_handle == IB_INVALID_HANDLE) {
+		/* register with the HW */
+		dat_status = dapls_ib_open_hca(hca_ptr->name, hca_ptr);
+
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+				     "dapls_ib_open_hca failed %x\n",
+				     dat_status);
+			dapl_os_unlock(&hca_ptr->lock);
+			goto bail;
+		}
+
+		/*
+		 * Obtain the IP address associated with this name and HCA.
+		 */
 #ifdef IBHOSTS_NAMING
-	dapli_assign_hca_ip_address (hca_ptr, name);
-#endif /* IBHOSTS_NAMING */
+		dapli_assign_hca_ip_address(hca_ptr, name);
+#endif				/* IBHOSTS_NAMING */
 
-	/*
-	 * Obtain IA attributes from the HCA to limit certain
-	 * operations.
-	 * If using DAPL_ATS naming, ib_query_hca will also set the ip
-	 * address.
-	 */
-	dat_status = dapls_ib_query_hca (hca_ptr,
-					 &hca_ptr->ia_attr,
-					 NULL,
-					 &hca_ptr->hca_address);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapli_hca_cleanup (hca_ptr, DAT_FALSE);
-	    dapl_os_unlock (&hca_ptr->lock);
-	    goto bail;
+		/*
+		 * Obtain IA attributes from the HCA to limit certain
+		 * operations.
+		 * If using DAPL_ATS naming, ib_query_hca will also set the ip
+		 * address.
+		 */
+		dat_status = dapls_ib_query_hca(hca_ptr,
+						&hca_ptr->ia_attr,
+						NULL, &hca_ptr->hca_address);
+		if (dat_status != DAT_SUCCESS) {
+			dapli_hca_cleanup(hca_ptr, DAT_FALSE);
+			dapl_os_unlock(&hca_ptr->lock);
+			goto bail;
+		}
 	}
-    }
 
-    /* Take a reference on the hca_handle */
-    dapl_os_atomic_inc (& hca_ptr->handle_ref_count );
-    dapl_os_unlock (&hca_ptr->lock);
+	/* Take a reference on the hca_handle */
+	dapl_os_atomic_inc(&hca_ptr->handle_ref_count);
+	dapl_os_unlock(&hca_ptr->lock);
 
-    /* Allocate and initialize ia structure */
-    ia_ptr = dapl_ia_alloc (provider, hca_ptr);
-    if (!ia_ptr)
-    {
-	dapl_os_lock (&hca_ptr->lock);
-	dapli_hca_cleanup (hca_ptr, DAT_TRUE);
-	dapl_os_unlock (&hca_ptr->lock);
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* Allocate and initialize ia structure */
+	ia_ptr = dapl_ia_alloc(provider, hca_ptr);
+	if (!ia_ptr) {
+		dapl_os_lock(&hca_ptr->lock);
+		dapli_hca_cleanup(hca_ptr, DAT_TRUE);
+		dapl_os_unlock(&hca_ptr->lock);
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /* we need an async EVD for this IA
-     * use the one passed in (if non-NULL) or create one
-     */
+	/* we need an async EVD for this IA
+	 * use the one passed in (if non-NULL) or create one
+	 */
 
-    evd_ptr = (DAPL_EVD *) *async_evd_handle_ptr;
-    if (evd_ptr)
-    {
-	if (DAPL_BAD_HANDLE (evd_ptr, DAPL_MAGIC_EVD) ||
-	    ! (evd_ptr->evd_flags & DAT_EVD_ASYNC_FLAG))
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_ASYNC);
-	    goto bail;
-	}
+	evd_ptr = (DAPL_EVD *) * async_evd_handle_ptr;
+	if (evd_ptr) {
+		if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD) ||
+		    !(evd_ptr->evd_flags & DAT_EVD_ASYNC_FLAG)) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_HANDLE,
+				      DAT_INVALID_HANDLE_EVD_ASYNC);
+			goto bail;
+		}
 
-	/* InfiniBand allows only 1 asychronous event handler per HCA */
-	/* (see InfiniBand Spec, release 1.1, vol I, section 11.5.2,  */
-	/*  page 559).                                                */
-	/*                                                            */
-	/* We only need to make sure that this EVD's CQ belongs to    */
-	/* the same HCA as is being opened.                           */
+		/* InfiniBand allows only 1 asychronous event handler per HCA */
+		/* (see InfiniBand Spec, release 1.1, vol I, section 11.5.2,  */
+		/*  page 559).                                                */
+		/*                                                            */
+		/* We only need to make sure that this EVD's CQ belongs to    */
+		/* the same HCA as is being opened.                           */
 
-	if ( evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle !=
-	     hca_ptr->ib_hca_handle )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_ASYNC);
-	    goto bail;
-	}
+		if (evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle !=
+		    hca_ptr->ib_hca_handle) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_HANDLE,
+				      DAT_INVALID_HANDLE_EVD_ASYNC);
+			goto bail;
+		}
 
-	ia_ptr->cleanup_async_error_evd = DAT_FALSE;
-	ia_ptr->async_error_evd = evd_ptr;
-    }
-    else
-    {
-	/* Verify we have >0 length, and let the provider check the size */
-	if ( async_evd_qlen <= 0 )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	    goto bail;
-	}
-	dat_status = dapls_evd_internal_create (ia_ptr,
-					       NULL,	/* CNO ptr */
-					       async_evd_qlen,
-					       DAT_EVD_ASYNC_FLAG,
-					       &evd_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    goto bail;
-	}
+		ia_ptr->cleanup_async_error_evd = DAT_FALSE;
+		ia_ptr->async_error_evd = evd_ptr;
+	} else {
+		/* Verify we have >0 length, and let the provider check the size */
+		if (async_evd_qlen <= 0) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+			goto bail;
+		}
+		dat_status = dapls_evd_internal_create(ia_ptr, NULL,	/* CNO ptr */
+						       async_evd_qlen,
+						       DAT_EVD_ASYNC_FLAG,
+						       &evd_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			goto bail;
+		}
 
-	dapl_os_atomic_inc (& evd_ptr->evd_ref_count);
+		dapl_os_atomic_inc(&evd_ptr->evd_ref_count);
 
-	dapl_os_lock ( &hca_ptr->lock );
-	if ( hca_ptr->async_evd != (DAPL_EVD *) 0 )
-	{
+		dapl_os_lock(&hca_ptr->lock);
+		if (hca_ptr->async_evd != (DAPL_EVD *) 0) {
 #if 0
-	    /*
-	     * The async EVD for this HCA has already been assigned.
-	     * It's an error to try and assign another one.
-	     *
-	     * However, we need to somehow allow multiple IAs
-	     * off of the same HCA.  The right way to do this
-	     * is by dispatching events off the HCA to the appropriate
-	     * IA, but we aren't there yet.  So for now we create
-	     * the EVD but don't connect it to anything.
-	     */
-	    dapl_os_atomic_dec ( &evd_ptr->evd_ref_count );
-	    dapl_evd_free ( evd_ptr );
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-	    goto bail;
+			/*
+			 * The async EVD for this HCA has already been assigned.
+			 * It's an error to try and assign another one.
+			 *
+			 * However, we need to somehow allow multiple IAs
+			 * off of the same HCA.  The right way to do this
+			 * is by dispatching events off the HCA to the appropriate
+			 * IA, but we aren't there yet.  So for now we create
+			 * the EVD but don't connect it to anything.
+			 */
+			dapl_os_atomic_dec(&evd_ptr->evd_ref_count);
+			dapl_evd_free(evd_ptr);
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+			goto bail;
 #endif
-	    dapl_os_unlock ( &hca_ptr->lock );
-	}
-	else
-	{
-	    hca_ptr->async_evd = evd_ptr;
-	    dapl_os_unlock ( &hca_ptr->lock );
+			dapl_os_unlock(&hca_ptr->lock);
+		} else {
+			hca_ptr->async_evd = evd_ptr;
+			dapl_os_unlock(&hca_ptr->lock);
 
-	    /* Register the handlers associated with the async EVD.  */
-	    dat_status = dapls_ia_setup_callbacks ( ia_ptr, evd_ptr );
-	    if ( dat_status != DAT_SUCCESS )
-	    {
-		/* Assign the EVD so it gets cleaned up */
+			/* Register the handlers associated with the async EVD.  */
+			dat_status = dapls_ia_setup_callbacks(ia_ptr, evd_ptr);
+			if (dat_status != DAT_SUCCESS) {
+				/* Assign the EVD so it gets cleaned up */
+				ia_ptr->cleanup_async_error_evd = DAT_TRUE;
+				ia_ptr->async_error_evd = evd_ptr;
+				goto bail;
+			}
+		}
+
 		ia_ptr->cleanup_async_error_evd = DAT_TRUE;
 		ia_ptr->async_error_evd = evd_ptr;
-		goto bail;
-	    }
 	}
 
-	ia_ptr->cleanup_async_error_evd = DAT_TRUE;
-	ia_ptr->async_error_evd = evd_ptr;
-    }
+	dat_status = DAT_SUCCESS;
+	*ia_handle_ptr = ia_ptr;
+	*async_evd_handle_ptr = evd_ptr;
 
-    dat_status = DAT_SUCCESS;
-    *ia_handle_ptr = ia_ptr;
-    *async_evd_handle_ptr = evd_ptr;
-
-bail:
-    if (dat_status != DAT_SUCCESS)
-    {
-	if (ia_ptr)
-	{
-	    /* This will release the async EVD if needed.  */
-	    dapl_ia_close (ia_ptr, DAT_CLOSE_ABRUPT_FLAG);
+      bail:
+	if (dat_status != DAT_SUCCESS) {
+		if (ia_ptr) {
+			/* This will release the async EVD if needed.  */
+			dapl_ia_close(ia_ptr, DAT_CLOSE_ABRUPT_FLAG);
+		}
 	}
-    }
 
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-		  "dapl_ia_open () returns 0x%x\n",
-		  dat_status);
+	dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+		     "dapl_ia_open () returns 0x%x\n", dat_status);
 
-    return dat_status;
+	return dat_status;
 }
 
-
 /*
  * dapli_hca_cleanup
  *
  * Clean up partially allocated HCA stuff. Strictly to make cleanup
  * simple.
  */
-void
-dapli_hca_cleanup (
-	DAPL_HCA		*hca_ptr,
-	DAT_BOOLEAN		dec_ref )
+void dapli_hca_cleanup(DAPL_HCA * hca_ptr, DAT_BOOLEAN dec_ref)
 {
-    dapls_ib_close_hca (hca_ptr);
-    hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
-    if ( dec_ref == DAT_TRUE )
-    {
-	dapl_os_atomic_dec (& hca_ptr->handle_ref_count );
-    }
+	dapls_ib_close_hca(hca_ptr);
+	hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
+	if (dec_ref == DAT_TRUE) {
+		dapl_os_atomic_dec(&hca_ptr->handle_ref_count);
+	}
 }
 
-
 #ifdef IBHOSTS_NAMING
 
-char *dapli_get_adapter_num (
-	char 			*device_name);
+char *dapli_get_adapter_num(char *device_name);
 
-void dapli_setup_dummy_addr (
-	IN  DAPL_HCA		*hca_ptr,
-	IN  char		*hca_name);
+void dapli_setup_dummy_addr(IN DAPL_HCA * hca_ptr, IN char *hca_name);
 /*
  * dapli_assign_hca_ip_address
  *
@@ -370,65 +335,56 @@
  * Returns:
  * 	char * to string number
  */
-void
-dapli_assign_hca_ip_address (
-	DAPL_HCA		*hca_ptr,
-	char 			*device_name)
+void dapli_assign_hca_ip_address(DAPL_HCA * hca_ptr, char *device_name)
 {
-    char		*adapter_num;
+	char *adapter_num;
 #define NAMELEN	128
-    struct addrinfo	*addr;
-    char 		hostname[NAMELEN];
-    char		*str;
-    int			rc;
+	struct addrinfo *addr;
+	char hostname[NAMELEN];
+	char *str;
+	int rc;
 
-    /*
-     * Obtain the IP address of the adapter. This is a simple
-     * scheme that creates a name that must appear available to
-     * DNS, e.g. it must be in the local site DNS or in the local
-     * /etc/hosts file, etc.
-     *
-     *	<hostname>-ib<index>
-     *
-     * This scheme obviously doesn't work with adapters from
-     * multiple vendors, but will suffice in common installations.
-     */
+	/*
+	 * Obtain the IP address of the adapter. This is a simple
+	 * scheme that creates a name that must appear available to
+	 * DNS, e.g. it must be in the local site DNS or in the local
+	 * /etc/hosts file, etc.
+	 *
+	 *  <hostname>-ib<index>
+	 *
+	 * This scheme obviously doesn't work with adapters from
+	 * multiple vendors, but will suffice in common installations.
+	 */
 
-    rc = gethostname (hostname, NAMELEN);
+	rc = gethostname(hostname, NAMELEN);
 
-    /* guarantee NUL termination if hostname gets truncated */
-    hostname[NAMELEN-1] = '\0';
+	/* guarantee NUL termination if hostname gets truncated */
+	hostname[NAMELEN - 1] = '\0';
 
-    /*
-     * Strip off domain info if it exists (e.g. mynode.mydomain.com)
-     */
-    for (str = hostname; *str && *str != '.'; )
-    {
-	str++;
-    }
-    if ( *str == '.' )
-    {
-	*str = '\0';
-    }
-    strcat (hostname, "-ib");
-    adapter_num = dapli_get_adapter_num (device_name);
-    strcat (hostname, adapter_num);
+	/*
+	 * Strip off domain info if it exists (e.g. mynode.mydomain.com)
+	 */
+	for (str = hostname; *str && *str != '.';) {
+		str++;
+	}
+	if (*str == '.') {
+		*str = '\0';
+	}
+	strcat(hostname, "-ib");
+	adapter_num = dapli_get_adapter_num(device_name);
+	strcat(hostname, adapter_num);
 
-    rc = dapls_osd_getaddrinfo (hostname, &addr);
+	rc = dapls_osd_getaddrinfo(hostname, &addr);
 
-    if ( rc != 0 )
-    {
-	/* Not registered in DNS, provide a dummy value */
-	dapli_setup_dummy_addr (hca_ptr, hostname);
-    }
-    else
-    {
-	hca_ptr->hca_address = * ((DAT_SOCK_ADDR6 *)addr->ai_addr);
-	dapls_osd_freeaddrinfo (addr);
-    }
+	if (rc != 0) {
+		/* Not registered in DNS, provide a dummy value */
+		dapli_setup_dummy_addr(hca_ptr, hostname);
+	} else {
+		hca_ptr->hca_address = *((DAT_SOCK_ADDR6 *) addr->ai_addr);
+		dapls_osd_freeaddrinfo(addr);
+	}
 }
 
-
 /*
  * dapli_stup_dummy_addr
  *
@@ -449,23 +405,19 @@
  * Returns:
  * 	none
  */
-void
-dapli_setup_dummy_addr (
-	IN  DAPL_HCA		*hca_ptr,
-	IN  char		*rhost_name )
+void dapli_setup_dummy_addr(IN DAPL_HCA * hca_ptr, IN char *rhost_name)
 {
-    struct sockaddr_in	     *si;
+	struct sockaddr_in *si;
 
-    /* Not registered in DNS, provide a dummy value */
-    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-		 "WARNING: <%s> not registered in DNS, using dummy IP value\n",
-		    rhost_name);
-    si = (struct sockaddr_in *)&hca_ptr->hca_address;
-    hca_ptr->hca_address.sin6_family = AF_INET;
-    si->sin_addr.s_addr = 0x01020304;
+	/* Not registered in DNS, provide a dummy value */
+	dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+		     "WARNING: <%s> not registered in DNS, using dummy IP value\n",
+		     rhost_name);
+	si = (struct sockaddr_in *)&hca_ptr->hca_address;
+	hca_ptr->hca_address.sin6_family = AF_INET;
+	si->sin_addr.s_addr = 0x01020304;
 }
 
-
 /*
  * dapls_get_adapter_num
  *
@@ -480,32 +432,27 @@
  * Returns:
  * 	char * to string number
  */
-char *
-dapli_get_adapter_num (
-	char 		*device_name)
+char *dapli_get_adapter_num(char *device_name)
 {
-    static char		*zero = "0";
-    char		*p;
+	static char *zero = "0";
+	char *p;
 
-    /*
-     * Optimisticaly simple algorithm: the device number appears at
-     * the end of the device name string. Device that do not end
-     * in a number are by default "0".
-     */
+	/*
+	 * Optimisticaly simple algorithm: the device number appears at
+	 * the end of the device name string. Device that do not end
+	 * in a number are by default "0".
+	 */
 
-    for (p = device_name; *p; p++)
-    {
-	if ( isdigit (*p) )
-	{
-	    return p;
+	for (p = device_name; *p; p++) {
+		if (isdigit(*p)) {
+			return p;
+		}
 	}
-    }
 
-    return zero;
+	return zero;
 }
-#endif /* IBHOSTS_NAMING */
+#endif				/* IBHOSTS_NAMING */
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -62,173 +62,166 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_ia_query (
-	IN	DAT_IA_HANDLE	   		ia_handle,
-	OUT	DAT_EVD_HANDLE     		*async_evd_handle,
-	IN	DAT_IA_ATTR_MASK	   	ia_attr_mask,
-	OUT	DAT_IA_ATTR	   		*ia_attr,
-	IN	DAT_PROVIDER_ATTR_MASK		provider_attr_mask,
-	OUT	DAT_PROVIDER_ATTR		*provider_attr )
+dapl_ia_query(IN DAT_IA_HANDLE ia_handle,
+	      OUT DAT_EVD_HANDLE * async_evd_handle,
+	      IN DAT_IA_ATTR_MASK ia_attr_mask,
+	      OUT DAT_IA_ATTR * ia_attr,
+	      IN DAT_PROVIDER_ATTR_MASK provider_attr_mask,
+	      OUT DAT_PROVIDER_ATTR * provider_attr)
 {
-    DAPL_IA		*ia_ptr;
-    DAT_RETURN		dat_status;
-    struct evd_merge_type {
-	DAT_BOOLEAN		array[6][6];
-    } *evd_merge;
-    DAT_BOOLEAN		val;
-    int			i;
-    int			j;
+	DAPL_IA *ia_ptr;
+	DAT_RETURN dat_status;
+	struct evd_merge_type {
+		DAT_BOOLEAN array[6][6];
+	} *evd_merge;
+	DAT_BOOLEAN val;
+	int i;
+	int j;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_ia_query (%p, %p, 0x%llx, %p, 0x%x, %p)\n", 
-		  ia_handle, 
-		  async_evd_handle, 
-		  ia_attr_mask, 
-		  ia_attr, 
-		  provider_attr_mask,
-		  provider_attr);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_ia_query (%p, %p, 0x%llx, %p, 0x%x, %p)\n",
+		     ia_handle,
+		     async_evd_handle,
+		     ia_attr_mask, ia_attr, provider_attr_mask, provider_attr);
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    dat_status = DAT_SUCCESS;
+	ia_ptr = (DAPL_IA *) ia_handle;
+	dat_status = DAT_SUCCESS;
 
-    if (DAPL_BAD_HANDLE (ia_ptr, DAPL_MAGIC_IA))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
-
-    if ( NULL != async_evd_handle )
-    {
-	*async_evd_handle = ia_ptr->async_error_evd;
-    }
-
-    if ( ia_attr_mask & DAT_IA_FIELD_ALL )
-    {
-	if ( NULL == ia_attr )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-	    goto bail;
+	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
 	}
 
-	/*
-	 * Obtain parameters from the HCA.  Protect against multiple
-	 * IAs beating on the HCA at the same time.
-	 */
-	dat_status = dapls_ib_query_hca (ia_ptr->hca_ptr, ia_attr, NULL, NULL);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    goto bail;
+	if (NULL != async_evd_handle) {
+		*async_evd_handle = ia_ptr->async_error_evd;
 	}
-    }
 
-    if ( ia_attr_mask & ~DAT_IA_FIELD_ALL )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (ia_attr_mask & DAT_IA_FIELD_ALL) {
+		if (NULL == ia_attr) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+			goto bail;
+		}
 
-    if ( provider_attr_mask & DAT_PROVIDER_FIELD_ALL )
-    {
-	if ( NULL == provider_attr )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
-	    goto bail;
+		/*
+		 * Obtain parameters from the HCA.  Protect against multiple
+		 * IAs beating on the HCA at the same time.
+		 */
+		dat_status =
+		    dapls_ib_query_hca(ia_ptr->hca_ptr, ia_attr, NULL, NULL);
+		if (dat_status != DAT_SUCCESS) {
+			goto bail;
+		}
 	}
 
-	strncpy ( provider_attr->provider_name,
-		  ia_ptr->header.provider->device_name,
-		  DAT_NAME_MAX_LENGTH );
-	provider_attr->provider_version_major	  = VN_PROVIDER_MAJOR;
-	provider_attr->provider_version_minor	  = VN_PROVIDER_MINOR;
-	provider_attr->dapl_version_major	  = DAT_VERSION_MAJOR;
-	provider_attr->dapl_version_minor	  = DAT_VERSION_MINOR;
-	provider_attr->lmr_mem_types_supported	  = 
-	    DAT_MEM_TYPE_VIRTUAL | DAT_MEM_TYPE_LMR;
+	if (ia_attr_mask & ~DAT_IA_FIELD_ALL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
+
+	if (provider_attr_mask & DAT_PROVIDER_FIELD_ALL) {
+		if (NULL == provider_attr) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG6);
+			goto bail;
+		}
+
+		strncpy(provider_attr->provider_name,
+			ia_ptr->header.provider->device_name,
+			DAT_NAME_MAX_LENGTH);
+		provider_attr->provider_version_major = VN_PROVIDER_MAJOR;
+		provider_attr->provider_version_minor = VN_PROVIDER_MINOR;
+		provider_attr->dapl_version_major = DAT_VERSION_MAJOR;
+		provider_attr->dapl_version_minor = DAT_VERSION_MINOR;
+		provider_attr->lmr_mem_types_supported =
+		    DAT_MEM_TYPE_VIRTUAL | DAT_MEM_TYPE_LMR;
 #if VN_MEM_SHARED_VIRTUAL_SUPPORT > 0 && !defined(__KDAPL__)
-	provider_attr->lmr_mem_types_supported	 |= DAT_MEM_TYPE_SHARED_VIRTUAL;
+		provider_attr->lmr_mem_types_supported |=
+		    DAT_MEM_TYPE_SHARED_VIRTUAL;
 #endif
-	provider_attr->iov_ownership_on_return	  = DAT_IOV_CONSUMER;
-	provider_attr->dat_qos_supported 	  = DAT_QOS_BEST_EFFORT;
-	provider_attr->completion_flags_supported = DAT_COMPLETION_DEFAULT_FLAG;
-	provider_attr->is_thread_safe 		  = DAT_FALSE;
-	/*
-	 * N.B. The second part of the following equation will evaluate
-	 * 	to 0 unless IBHOSTS_NAMING is enabled.
-	 */
-	provider_attr->max_private_data_size 	  = 
-	    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,
-			ia_ptr->hca_ptr) -
-			(sizeof(DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE); 
-	provider_attr->supports_multipath 	  = DAT_FALSE;
-	provider_attr->ep_creator 		  = DAT_PSP_CREATES_EP_NEVER;
-	provider_attr->optimal_buffer_alignment   = DAT_OPTIMAL_ALIGNMENT;
-	/* The value of pz_support may vary by transport */
-	provider_attr->num_provider_specific_attr = 0;
-	provider_attr->provider_specific_attr 	  = NULL;
+		provider_attr->iov_ownership_on_return = DAT_IOV_CONSUMER;
+		provider_attr->dat_qos_supported = DAT_QOS_BEST_EFFORT;
+		provider_attr->completion_flags_supported =
+		    DAT_COMPLETION_DEFAULT_FLAG;
+		provider_attr->is_thread_safe = DAT_FALSE;
+		/*
+		 * N.B. The second part of the following equation will evaluate
+		 *      to 0 unless IBHOSTS_NAMING is enabled.
+		 */
+		provider_attr->max_private_data_size =
+		    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REQ,
+					       ia_ptr->hca_ptr) -
+		    (sizeof(DAPL_PRIVATE) - DAPL_MAX_PRIVATE_DATA_SIZE);
+		provider_attr->supports_multipath = DAT_FALSE;
+		provider_attr->ep_creator = DAT_PSP_CREATES_EP_NEVER;
+		provider_attr->optimal_buffer_alignment = DAT_OPTIMAL_ALIGNMENT;
+		/* The value of pz_support may vary by transport */
+		provider_attr->num_provider_specific_attr = 0;
+		provider_attr->provider_specific_attr = NULL;
 #if !defined(__KDAPL__)
-	provider_attr->pz_support                 = DAT_PZ_UNIQUE;
-#endif /* !KDAPL */
+		provider_attr->pz_support = DAT_PZ_UNIQUE;
+#endif				/* !KDAPL */
 
-	/*
-	 *  Query for provider specific attributes
-	 */
-	dapls_query_provider_specific_attr(ia_ptr, provider_attr);
+		/*
+		 *  Query for provider specific attributes
+		 */
+		dapls_query_provider_specific_attr(ia_ptr, provider_attr);
 
-	/*
-	 * Set up evd_stream_merging_supported options. Note there is
-	 * one bit per allowable combination, using the ordinal
-	 * position of the DAT_EVD_FLAGS as positions in the
-	 * array. e.g.
-	 * [0][0] is DAT_EVD_SOFTWARE_FLAG | DAT_EVD_SOFTWARE_FLAG,
-	 * [0][1] is DAT_EVD_SOFTWARE_FLAG | DAT_EVD_CR_FLAG, and
-	 * [2][4] is DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG
-	 *
-	 * Most combinations are true, so initialize the array that way.
-	 * Then finish by resetting the bad combinations.
-	 *
-	 * DAT_EVD_ASYNC_FLAG is not supported. InfiniBand only allows
-	 * a single asynchronous event handle per HCA, and the first
-	 * dat_ia_open forces the creation of the only one that can be
-	 * used. We disallow the user from creating an ASYNC EVD here.
-	 */
+		/*
+		 * Set up evd_stream_merging_supported options. Note there is
+		 * one bit per allowable combination, using the ordinal
+		 * position of the DAT_EVD_FLAGS as positions in the
+		 * array. e.g.
+		 * [0][0] is DAT_EVD_SOFTWARE_FLAG | DAT_EVD_SOFTWARE_FLAG,
+		 * [0][1] is DAT_EVD_SOFTWARE_FLAG | DAT_EVD_CR_FLAG, and
+		 * [2][4] is DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG
+		 *
+		 * Most combinations are true, so initialize the array that way.
+		 * Then finish by resetting the bad combinations.
+		 *
+		 * DAT_EVD_ASYNC_FLAG is not supported. InfiniBand only allows
+		 * a single asynchronous event handle per HCA, and the first
+		 * dat_ia_open forces the creation of the only one that can be
+		 * used. We disallow the user from creating an ASYNC EVD here.
+		 */
 
-	evd_merge = (struct evd_merge_type *)&provider_attr->evd_stream_merging_supported[0][0];
-	val = DAT_TRUE;
-	for ( i = 0; i < 6; i++)
-	{
-	    if (i > 4)
-	    {
-		/* ASYNC EVD is 5, so entire row will be 0 */
-		val = DAT_FALSE;
-	    }
-	    for ( j = 0; j < 5; j++)
-	    {
-		evd_merge->array[i][j] = val;
-	    }
-	    /* Set the ASYNC_EVD column to FALSE */
-	    evd_merge->array[i][5] = DAT_FALSE;
-	}
+		evd_merge =
+		    (struct evd_merge_type *)&provider_attr->
+		    evd_stream_merging_supported[0][0];
+		val = DAT_TRUE;
+		for (i = 0; i < 6; i++) {
+			if (i > 4) {
+				/* ASYNC EVD is 5, so entire row will be 0 */
+				val = DAT_FALSE;
+			}
+			for (j = 0; j < 5; j++) {
+				evd_merge->array[i][j] = val;
+			}
+			/* Set the ASYNC_EVD column to FALSE */
+			evd_merge->array[i][5] = DAT_FALSE;
+		}
 
 #ifndef DAPL_MERGE_CM_DTO
-	/*
-	 * If an implementation supports CM and DTO completions on
-	 * the same EVD then DAPL_MERGE_CM_DTO should be set to
-	 * skip the following code
-	 */
-	/* DAT_EVD_DTO_FLAG | DAT_EVD_CONNECTION_FLAG */
-	evd_merge->array[2][3] = DAT_FALSE;
-	/* DAT_EVD_CONNECTION_FLAG | DAT_EVD_DTO_FLAG */
-	evd_merge->array[3][2] = DAT_FALSE;
-#endif /* DAPL_MERGE_CM_DTO */
-    }
+		/*
+		 * If an implementation supports CM and DTO completions on
+		 * the same EVD then DAPL_MERGE_CM_DTO should be set to
+		 * skip the following code
+		 */
+		/* DAT_EVD_DTO_FLAG | DAT_EVD_CONNECTION_FLAG */
+		evd_merge->array[2][3] = DAT_FALSE;
+		/* DAT_EVD_CONNECTION_FLAG | DAT_EVD_DTO_FLAG */
+		evd_merge->array[3][2] = DAT_FALSE;
+#endif				/* DAPL_MERGE_CM_DTO */
+	}
 
-bail:
-    if (dat_status != DAT_SUCCESS) {
-	dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-			"dapl_ia_query () returns 0x%x\n", dat_status);
-    }
+      bail:
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+			     "dapl_ia_query () returns 0x%x\n", dat_status);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ia_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -44,10 +44,8 @@
 #include "dapl_adapter_util.h"
 
 /* Internal prototype */
-void dapli_ia_release_hca (
-	DAPL_HCA		*hca_ptr );
+void dapli_ia_release_hca(DAPL_HCA * hca_ptr);
 
-
 /*
  * dapl_ia_alloc
  *
@@ -63,55 +61,64 @@
  * 	none
  *
  */
-DAPL_IA *
-dapl_ia_alloc ( DAT_PROVIDER * provider, DAPL_HCA * hca_ptr )
+DAPL_IA *dapl_ia_alloc(DAT_PROVIDER * provider, DAPL_HCA * hca_ptr)
 {
-    DAPL_IA * ia_ptr;
+	DAPL_IA *ia_ptr;
 
-    /* Allocate IA */
-    ia_ptr = (DAPL_IA *) dapl_os_alloc (sizeof (DAPL_IA));
-    if (ia_ptr == NULL)
-    {
-	return (NULL);
-    }
+	/* Allocate IA */
+	ia_ptr = (DAPL_IA *) dapl_os_alloc(sizeof(DAPL_IA));
+	if (ia_ptr == NULL) {
+		return (NULL);
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (ia_ptr, sizeof (DAPL_IA));
+	/* zero the structure */
+	dapl_os_memzero(ia_ptr, sizeof(DAPL_IA));
 
-    /*
-     * initialize the header
-     */
-    ia_ptr->header.provider            = provider;
-    ia_ptr->header.magic               = DAPL_MAGIC_IA;
-    ia_ptr->header.handle_type         = DAT_HANDLE_TYPE_IA;
-    ia_ptr->header.owner_ia            = ia_ptr;
-    ia_ptr->header.user_context.as_64  = 0;
-    ia_ptr->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&ia_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&ia_ptr->header.lock);
+#ifdef DAPL_COUNTERS
+	/* Allocate counters */
+	ia_ptr->cntrs =
+	    dapl_os_alloc(sizeof(DAT_UINT64) * DCNT_IA_ALL_COUNTERS);
+	if (ia_ptr->cntrs == NULL) {
+		dapl_os_free(ia_ptr, sizeof(DAPL_IA));
+		return (NULL);
+	}
+	dapl_os_memzero(ia_ptr->cntrs,
+			sizeof(DAT_UINT64) * DCNT_IA_ALL_COUNTERS);
+#endif				/* DAPL_COUNTERS */
 
-    /*
-     * initialize the body
-     */
-    ia_ptr->hca_ptr = hca_ptr;
-    ia_ptr->async_error_evd = NULL;
-    ia_ptr->cleanup_async_error_evd = DAT_FALSE;
-    dapl_llist_init_entry (&ia_ptr->hca_ia_list_entry);
-    dapl_llist_init_head (&ia_ptr->ep_list_head);
-    dapl_llist_init_head (&ia_ptr->lmr_list_head);
-    dapl_llist_init_head (&ia_ptr->rmr_list_head);
-    dapl_llist_init_head (&ia_ptr->pz_list_head);
-    dapl_llist_init_head (&ia_ptr->evd_list_head);
-    dapl_llist_init_head (&ia_ptr->cno_list_head);
-    dapl_llist_init_head (&ia_ptr->rsp_list_head);
-    dapl_llist_init_head (&ia_ptr->psp_list_head);
+	/*
+	 * initialize the header
+	 */
+	ia_ptr->header.provider = provider;
+	ia_ptr->header.magic = DAPL_MAGIC_IA;
+	ia_ptr->header.handle_type = DAT_HANDLE_TYPE_IA;
+	ia_ptr->header.owner_ia = ia_ptr;
+	ia_ptr->header.user_context.as_64 = 0;
+	ia_ptr->header.user_context.as_ptr = NULL;
+	dapl_llist_init_entry(&ia_ptr->header.ia_list_entry);
+	dapl_os_lock_init(&ia_ptr->header.lock);
 
-    dapl_hca_link_ia (hca_ptr, ia_ptr);
+	/*
+	 * initialize the body
+	 */
+	ia_ptr->hca_ptr = hca_ptr;
+	ia_ptr->async_error_evd = NULL;
+	ia_ptr->cleanup_async_error_evd = DAT_FALSE;
+	dapl_llist_init_entry(&ia_ptr->hca_ia_list_entry);
+	dapl_llist_init_head(&ia_ptr->ep_list_head);
+	dapl_llist_init_head(&ia_ptr->lmr_list_head);
+	dapl_llist_init_head(&ia_ptr->rmr_list_head);
+	dapl_llist_init_head(&ia_ptr->pz_list_head);
+	dapl_llist_init_head(&ia_ptr->evd_list_head);
+	dapl_llist_init_head(&ia_ptr->cno_list_head);
+	dapl_llist_init_head(&ia_ptr->rsp_list_head);
+	dapl_llist_init_head(&ia_ptr->psp_list_head);
 
-    return (ia_ptr);
+	dapl_hca_link_ia(hca_ptr, ia_ptr);
+
+	return (ia_ptr);
 }
 
-
 /*
  * dapl_ia_abrupt_close
  *
@@ -128,298 +135,269 @@
  *
  */
 
-DAT_RETURN
-dapl_ia_abrupt_close (
-	IN DAPL_IA 	*ia_ptr )
+DAT_RETURN dapl_ia_abrupt_close(IN DAPL_IA * ia_ptr)
 {
-    DAT_RETURN		dat_status;
-    DAPL_EP		*ep_ptr, *next_ep_ptr;
-    DAPL_LMR		*lmr_ptr, *next_lmr_ptr;
-    DAPL_RMR		*rmr_ptr, *next_rmr_ptr;
-    DAPL_PZ		*pz_ptr, *next_pz_ptr;
-    DAPL_EVD		*evd_ptr, *next_evd_ptr;
-    DAPL_CNO		*cno_ptr, *next_cno_ptr;
-    DAPL_SP		*sp_ptr, *next_sp_ptr; /* for PSP and RSP queues */
-    DAPL_CR		*cr_ptr, *next_cr_ptr;
-    DAPL_HCA		*hca_ptr;
+	DAT_RETURN dat_status;
+	DAPL_EP *ep_ptr, *next_ep_ptr;
+	DAPL_LMR *lmr_ptr, *next_lmr_ptr;
+	DAPL_RMR *rmr_ptr, *next_rmr_ptr;
+	DAPL_PZ *pz_ptr, *next_pz_ptr;
+	DAPL_EVD *evd_ptr, *next_evd_ptr;
+	DAPL_CNO *cno_ptr, *next_cno_ptr;
+	DAPL_SP *sp_ptr, *next_sp_ptr;	/* for PSP and RSP queues */
+	DAPL_CR *cr_ptr, *next_cr_ptr;
+	DAPL_HCA *hca_ptr;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    /*
-     * clear all the data structures associated with the IA.
-     * this must be done in order (rmr,rsp) before (ep lmr psp) before
-     * (pz evd)
-     *
-     * Note that in all the following we can leave the loop either
-     * when we run out of entries, or when we get back to the head
-     * if we end up skipping an entry.
-     */
+	/*
+	 * clear all the data structures associated with the IA.
+	 * this must be done in order (rmr,rsp) before (ep lmr psp) before
+	 * (pz evd)
+	 *
+	 * Note that in all the following we can leave the loop either
+	 * when we run out of entries, or when we get back to the head
+	 * if we end up skipping an entry.
+	 */
 
-    rmr_ptr = (dapl_llist_is_empty (&ia_ptr->rmr_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->rmr_list_head));
-    while (rmr_ptr != NULL)
-    {
-	next_rmr_ptr = dapl_llist_next_entry (&ia_ptr->rmr_list_head,
-					      &rmr_ptr->header.ia_list_entry);
-	dat_status = dapl_rmr_free (rmr_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): rmr_free(%p) returns %x\n",
-			  rmr_ptr,
-			  dat_status );
+	rmr_ptr = (dapl_llist_is_empty(&ia_ptr->rmr_list_head)
+		   ? NULL : dapl_llist_peek_head(&ia_ptr->rmr_list_head));
+	while (rmr_ptr != NULL) {
+		next_rmr_ptr = dapl_llist_next_entry(&ia_ptr->rmr_list_head,
+						     &rmr_ptr->header.
+						     ia_list_entry);
+		dat_status = dapl_rmr_free(rmr_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): rmr_free(%p) returns %x\n",
+				     rmr_ptr, dat_status);
+		}
+		rmr_ptr = next_rmr_ptr;
 	}
-	rmr_ptr = next_rmr_ptr;
-    }
 
-    sp_ptr = (dapl_llist_is_empty (&ia_ptr->rsp_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->rsp_list_head));
-    while (sp_ptr != NULL)
-    {
-	next_sp_ptr = dapl_llist_next_entry (&ia_ptr->rsp_list_head,
-					     &sp_ptr->header.ia_list_entry);
-	dat_status = dapl_rsp_free (sp_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): rsp_free(%p) returns %x\n",
-			  sp_ptr,
-			  dat_status );
+	sp_ptr = (dapl_llist_is_empty(&ia_ptr->rsp_list_head)
+		  ? NULL : dapl_llist_peek_head(&ia_ptr->rsp_list_head));
+	while (sp_ptr != NULL) {
+		next_sp_ptr = dapl_llist_next_entry(&ia_ptr->rsp_list_head,
+						    &sp_ptr->header.
+						    ia_list_entry);
+		dat_status = dapl_rsp_free(sp_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): rsp_free(%p) returns %x\n",
+				     sp_ptr, dat_status);
+		}
+		sp_ptr = next_sp_ptr;
 	}
-	sp_ptr = next_sp_ptr;
-    }
 
-    ep_ptr = (dapl_llist_is_empty (&ia_ptr->ep_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->ep_list_head));
-    while (ep_ptr != NULL)
-    {
-	next_ep_ptr = dapl_llist_next_entry (&ia_ptr->ep_list_head,
-					     &ep_ptr->header.ia_list_entry);
-	/*
-	 * Issue a disconnect if the EP needs it
-	 */
-	if ( ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED ||
-	     ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED ||
-	     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 )
-	{
-	    dat_status = dapl_ep_disconnect (ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
-	    if (dat_status != DAT_SUCCESS)
-	    {
-		dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): ep_disconnect(%p) returns %x\n",
-			  ep_ptr,
-			  dat_status );
-	    }
-	}
-	/* force the EP into error state to force flush all posted DTOs. */
-	{
-	    DAT_EP_ATTR		ep_attr;
-	    DAT_NAMED_ATTR	ep_state;
+	ep_ptr = (dapl_llist_is_empty(&ia_ptr->ep_list_head)
+		  ? NULL : dapl_llist_peek_head(&ia_ptr->ep_list_head));
+	while (ep_ptr != NULL) {
+		next_ep_ptr = dapl_llist_next_entry(&ia_ptr->ep_list_head,
+						    &ep_ptr->header.
+						    ia_list_entry);
+		/*
+		 * Issue a disconnect if the EP needs it
+		 */
+		if (ep_ptr->param.ep_state == DAT_EP_STATE_CONNECTED ||
+		    ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED ||
+		    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) {
+			dat_status =
+			    dapl_ep_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
+			if (dat_status != DAT_SUCCESS) {
+				dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+					     "ia_close(ABRUPT): ep_disconnect(%p) returns %x\n",
+					     ep_ptr, dat_status);
+			}
+		}
+		/* force the EP into error state to force flush all posted DTOs. */
+		{
+			DAT_EP_ATTR ep_attr;
+			DAT_NAMED_ATTR ep_state;
 
-	    dapl_os_memzero (&ep_attr, sizeof (DAT_EP_ATTR));
-	    ep_state.name  = (char *)IB_QP_STATE;
-	    ep_state.value = (char *)DAPL_QP_STATE_ERROR;
-	    ep_attr.ep_provider_specific_count = 1;
-	    ep_attr.ep_provider_specific       = &ep_state;
+			dapl_os_memzero(&ep_attr, sizeof(DAT_EP_ATTR));
+			ep_state.name = (char *)IB_QP_STATE;
+			ep_state.value = (char *)DAPL_QP_STATE_ERROR;
+			ep_attr.ep_provider_specific_count = 1;
+			ep_attr.ep_provider_specific = &ep_state;
 
-	    (void) dapls_ib_qp_modify (ia_ptr,
-				       ep_ptr,
-				       &ep_attr );
-	}
+			(void)dapls_ib_qp_modify(ia_ptr, ep_ptr, &ep_attr);
+		}
 
-	dat_status = dapl_ep_free (ep_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): ep_free(%p) returns %x\n",
-			  ep_ptr,
-			  dat_status );
+		dat_status = dapl_ep_free(ep_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): ep_free(%p) returns %x\n",
+				     ep_ptr, dat_status);
+		}
+		ep_ptr = next_ep_ptr;
 	}
-	ep_ptr = next_ep_ptr;
-    }
 
-    lmr_ptr = (dapl_llist_is_empty (&ia_ptr->lmr_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->lmr_list_head));
-    while (lmr_ptr != NULL)
-    {
-	next_lmr_ptr = dapl_llist_next_entry (&ia_ptr->lmr_list_head,
-					      &lmr_ptr->header.ia_list_entry);
-	dat_status = dapl_lmr_free (lmr_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): lmr_free(%p) returns %x\n",
-			  lmr_ptr,
-			  dat_status );
+	lmr_ptr = (dapl_llist_is_empty(&ia_ptr->lmr_list_head)
+		   ? NULL : dapl_llist_peek_head(&ia_ptr->lmr_list_head));
+	while (lmr_ptr != NULL) {
+		next_lmr_ptr = dapl_llist_next_entry(&ia_ptr->lmr_list_head,
+						     &lmr_ptr->header.
+						     ia_list_entry);
+		dat_status = dapl_lmr_free(lmr_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): lmr_free(%p) returns %x\n",
+				     lmr_ptr, dat_status);
+		}
+		lmr_ptr = next_lmr_ptr;
 	}
-	lmr_ptr = next_lmr_ptr;
-    }
 
-    sp_ptr = (dapl_llist_is_empty (&ia_ptr->psp_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->psp_list_head));
-    while (sp_ptr != NULL)
-    {
-	/*
-	 * Shut down the PSP so we get no further callbacks. There
-	 * should be no competing threads after this.
-	 */
-	dat_status = dapls_ib_remove_conn_listener (ia_ptr,
-						    sp_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): psp cannot remove listener, returns %x\n",
-			  dat_status);
-	}
+	sp_ptr = (dapl_llist_is_empty(&ia_ptr->psp_list_head)
+		  ? NULL : dapl_llist_peek_head(&ia_ptr->psp_list_head));
+	while (sp_ptr != NULL) {
+		/*
+		 * Shut down the PSP so we get no further callbacks. There
+		 * should be no competing threads after this.
+		 */
+		dat_status = dapls_ib_remove_conn_listener(ia_ptr, sp_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): psp cannot remove listener, returns %x\n",
+				     dat_status);
+		}
 
-	next_sp_ptr = dapl_llist_next_entry (&ia_ptr->psp_list_head,
-					     &sp_ptr->header.ia_list_entry);
+		next_sp_ptr = dapl_llist_next_entry(&ia_ptr->psp_list_head,
+						    &sp_ptr->header.
+						    ia_list_entry);
 
-	/* Remove CR's from this PSP and clean them up */
-	cr_ptr = dapl_llist_is_empty (&sp_ptr->cr_list_head) ? NULL :
-		dapl_llist_peek_head (&sp_ptr->cr_list_head);
-	while (cr_ptr != NULL)
-	{
-	    next_cr_ptr = dapl_llist_next_entry (&sp_ptr->cr_list_head,
-						 &cr_ptr->header.ia_list_entry);
-	    /* Remove the CR from the queue & cleanup*/
-	    dapl_os_lock (&sp_ptr->header.lock);
-	    dapl_sp_remove_cr (sp_ptr, cr_ptr);
-	    dapl_os_unlock (&sp_ptr->header.lock);
+		/* Remove CR's from this PSP and clean them up */
+		cr_ptr = dapl_llist_is_empty(&sp_ptr->cr_list_head) ? NULL :
+		    dapl_llist_peek_head(&sp_ptr->cr_list_head);
+		while (cr_ptr != NULL) {
+			next_cr_ptr =
+			    dapl_llist_next_entry(&sp_ptr->cr_list_head,
+						  &cr_ptr->header.
+						  ia_list_entry);
+			/* Remove the CR from the queue & cleanup */
+			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);
-	    cr_ptr = next_cr_ptr;
-	}
+			dapls_cr_free(cr_ptr);
+			cr_ptr = next_cr_ptr;
+		}
 
-	dat_status = dapl_psp_free (sp_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): psp_free(%p) returns %x\n",
-			  sp_ptr,
-			  dat_status );
+		dat_status = dapl_psp_free(sp_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): psp_free(%p) returns %x\n",
+				     sp_ptr, dat_status);
+		}
+
+		sp_ptr = next_sp_ptr;
 	}
 
-	sp_ptr = next_sp_ptr;
-    }
-
-    pz_ptr = (dapl_llist_is_empty (&ia_ptr->pz_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->pz_list_head));
-    while (pz_ptr != NULL)
-    {
-	next_pz_ptr = dapl_llist_next_entry (&ia_ptr->pz_list_head,
-					     &pz_ptr->header.ia_list_entry);
-	dat_status = dapl_pz_free (pz_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): pz_free(%p) returns %x\n",
-			  pz_ptr,
-			  dat_status );
+	pz_ptr = (dapl_llist_is_empty(&ia_ptr->pz_list_head)
+		  ? NULL : dapl_llist_peek_head(&ia_ptr->pz_list_head));
+	while (pz_ptr != NULL) {
+		next_pz_ptr = dapl_llist_next_entry(&ia_ptr->pz_list_head,
+						    &pz_ptr->header.
+						    ia_list_entry);
+		dat_status = dapl_pz_free(pz_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): pz_free(%p) returns %x\n",
+				     pz_ptr, dat_status);
+		}
+		pz_ptr = next_pz_ptr;
 	}
-	pz_ptr = next_pz_ptr;
-    }
 
-    /*
-     * EVDs are tricky; we want to release all except for the async
-     * EVD.  That EVD needs to stick around until after we close the
-     * HCA, to accept any async events that occur.  So we cycle through
-     * the list with dapl_llist_next_entry instead of dapl_llist_is_empty.
-     */
-    evd_ptr = (dapl_llist_is_empty (&ia_ptr->evd_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->evd_list_head));
-    while (evd_ptr != NULL)
-    {
-	next_evd_ptr = dapl_llist_next_entry (&ia_ptr->evd_list_head,
-					      &evd_ptr->header.ia_list_entry);
-	if (evd_ptr == ia_ptr->async_error_evd)
-	{
+	/*
+	 * EVDs are tricky; we want to release all except for the async
+	 * EVD.  That EVD needs to stick around until after we close the
+	 * HCA, to accept any async events that occur.  So we cycle through
+	 * the list with dapl_llist_next_entry instead of dapl_llist_is_empty.
+	 */
+	evd_ptr = (dapl_llist_is_empty(&ia_ptr->evd_list_head)
+		   ? NULL : dapl_llist_peek_head(&ia_ptr->evd_list_head));
+	while (evd_ptr != NULL) {
+		next_evd_ptr = dapl_llist_next_entry(&ia_ptr->evd_list_head,
+						     &evd_ptr->header.
+						     ia_list_entry);
+		if (evd_ptr == ia_ptr->async_error_evd) {
 #if !defined(__KDAPL__)
-	    /* Don't delete the EVD, but break any CNO connections.  */
-	    dapl_evd_disable (evd_ptr);
-	    dapl_evd_modify_cno (evd_ptr, DAT_HANDLE_NULL);
-#endif /* __KDAPL__ */
+			/* Don't delete the EVD, but break any CNO connections.  */
+			dapl_evd_disable(evd_ptr);
+			dapl_evd_modify_cno(evd_ptr, DAT_HANDLE_NULL);
+#endif				/* __KDAPL__ */
+		} else {
+			/* it isn't the async EVD; delete it.  */
+			dat_status = dapl_evd_free(evd_ptr);
+			if (dat_status != DAT_SUCCESS) {
+				dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+					     "ia_close(ABRUPT): evd_free(%p) returns %x\n",
+					     evd_ptr, dat_status);
+			}
+		}
+		evd_ptr = next_evd_ptr;
 	}
-	else
-	{
-	    /* it isn't the async EVD; delete it.  */
-	    dat_status = dapl_evd_free (evd_ptr);
-	    if (dat_status != DAT_SUCCESS)
-	    {
-		dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			      "ia_close(ABRUPT): evd_free(%p) returns %x\n",
-			      evd_ptr,
-				dat_status );
-	    }
-	}
-	evd_ptr = next_evd_ptr;
-    }
 
-    cno_ptr = (dapl_llist_is_empty (&ia_ptr->cno_list_head)
-	      ? NULL : dapl_llist_peek_head (&ia_ptr->cno_list_head));
-    while (cno_ptr != NULL)
-    {
-	next_cno_ptr = dapl_llist_next_entry (&ia_ptr->cno_list_head,
-					      &cno_ptr->header.ia_list_entry);
+	cno_ptr = (dapl_llist_is_empty(&ia_ptr->cno_list_head)
+		   ? NULL : dapl_llist_peek_head(&ia_ptr->cno_list_head));
+	while (cno_ptr != NULL) {
+		next_cno_ptr = dapl_llist_next_entry(&ia_ptr->cno_list_head,
+						     &cno_ptr->header.
+						     ia_list_entry);
 #if !defined(__KDAPL__)
-	if (cno_ptr->cno_waiters > 0)
-	{
-	    /* Notify the waiter the IA is going away: see uDAPL 1.1 spec,
-	     * 6.3.2.3
-	     */
-	    dapl_internal_cno_trigger (cno_ptr, NULL);
+		if (cno_ptr->cno_waiters > 0) {
+			/* Notify the waiter the IA is going away: see uDAPL 1.1 spec,
+			 * 6.3.2.3
+			 */
+			dapl_internal_cno_trigger(cno_ptr, NULL);
+		}
+		/* clean up the CNO */
+		dat_status = dapl_cno_free(cno_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): cno_free(%p) returns %x\n",
+				     cno_ptr, dat_status);
+		}
+#endif				/* __KDAPL__ */
+		cno_ptr = next_cno_ptr;
 	}
-	/* clean up the CNO */
-	dat_status = dapl_cno_free (cno_ptr);
-	if (dat_status != DAT_SUCCESS)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): cno_free(%p) returns %x\n",
-			  cno_ptr,
-			  dat_status );
-	}
-#endif /* __KDAPL__ */
-	cno_ptr = next_cno_ptr;
-    }
 
-    hca_ptr = ia_ptr->hca_ptr;
+	hca_ptr = ia_ptr->hca_ptr;
 
-    /*
-     * Free the async EVD, shutting down callbacks from the HCA.
-     */
-    if ( ia_ptr->async_error_evd &&
-	 (DAT_TRUE == ia_ptr->cleanup_async_error_evd) )
-    {
-	dat_status = dapls_ia_teardown_callbacks ( ia_ptr );
+	/*
+	 * Free the async EVD, shutting down callbacks from the HCA.
+	 */
+	if (ia_ptr->async_error_evd &&
+	    (DAT_TRUE == ia_ptr->cleanup_async_error_evd)) {
+		dat_status = dapls_ia_teardown_callbacks(ia_ptr);
 
-	dapl_os_atomic_dec (& ia_ptr->async_error_evd->evd_ref_count);
-	dat_status = dapl_evd_free (ia_ptr->async_error_evd);
+		dapl_os_atomic_dec(&ia_ptr->async_error_evd->evd_ref_count);
+		dat_status = dapl_evd_free(ia_ptr->async_error_evd);
 
-	if (DAT_SUCCESS != dat_status)
-	{
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-			  "ia_close(ABRUPT): evd_free(%p) returns %x\n",
-			  ia_ptr->async_error_evd,
-			  dat_status );
+		if (DAT_SUCCESS != dat_status) {
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "ia_close(ABRUPT): evd_free(%p) returns %x\n",
+				     ia_ptr->async_error_evd, dat_status);
+		}
+
+		ia_ptr->async_error_evd = NULL;
 	}
 
-	ia_ptr->async_error_evd = NULL;
-    }
+	/*
+	 * Release our reference on the hca_handle. If we are the last
+	 * one, close it
+	 */
+	dapli_ia_release_hca(hca_ptr);
 
-    /*
-     * Release our reference on the hca_handle. If we are the last
-     * one, close it
-     */
-    dapli_ia_release_hca (hca_ptr);
+	dapls_ia_free(ia_ptr);
 
-    dapls_ia_free (ia_ptr);
-
-    return DAT_SUCCESS;		/* Abrupt close can't fail.  */
+	return DAT_SUCCESS;	/* Abrupt close can't fail.  */
 }
 
-
 /*
  * dapl_ia_graceful_close
  *
@@ -436,107 +414,105 @@
  *
  */
 
-DAT_RETURN
-dapl_ia_graceful_close (
-	IN DAPL_IA 	*ia_ptr )
+DAT_RETURN dapl_ia_graceful_close(IN DAPL_IA * ia_ptr)
 {
-    DAT_RETURN		dat_status;
-    DAT_RETURN		cur_dat_status;
-    DAPL_EVD		*evd_ptr;
-    DAPL_LLIST_ENTRY 	*entry;
-    DAPL_HCA		*hca_ptr;
+	DAT_RETURN dat_status;
+	DAT_RETURN cur_dat_status;
+	DAPL_EVD *evd_ptr;
+	DAPL_LLIST_ENTRY *entry;
+	DAPL_HCA *hca_ptr;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( !dapl_llist_is_empty (&ia_ptr->rmr_list_head) ||
-	 !dapl_llist_is_empty (&ia_ptr->rsp_list_head) ||
-	 !dapl_llist_is_empty (&ia_ptr->ep_list_head)  ||
-	 !dapl_llist_is_empty (&ia_ptr->lmr_list_head) ||
-	 !dapl_llist_is_empty (&ia_ptr->psp_list_head) ||
-	 !dapl_llist_is_empty (&ia_ptr->pz_list_head) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_IA_IN_USE);
-	goto bail;
-    }
-
-    /* if the async evd does not need to be cleaned up */
-    /* (ie. it was not created by dapl_ia_open)        */
-    /*  then the evd list should be empty              */
-    if ( DAT_FALSE == ia_ptr->cleanup_async_error_evd )
-    {
-	if ( !dapl_llist_is_empty (&ia_ptr->evd_list_head) )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_IA_IN_USE);
-	    goto bail;
+	if (!dapl_llist_is_empty(&ia_ptr->rmr_list_head) ||
+	    !dapl_llist_is_empty(&ia_ptr->rsp_list_head) ||
+	    !dapl_llist_is_empty(&ia_ptr->ep_list_head) ||
+	    !dapl_llist_is_empty(&ia_ptr->lmr_list_head) ||
+	    !dapl_llist_is_empty(&ia_ptr->psp_list_head) ||
+	    !dapl_llist_is_empty(&ia_ptr->pz_list_head)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_IA_IN_USE);
+		goto bail;
 	}
-    }
-    /* else the async evd should be the only evd in    */
-    /* the list.                                        */
-    else
-    {
-	evd_ptr = (dapl_llist_is_empty (&ia_ptr->evd_list_head)
-		   ? NULL : dapl_llist_peek_head (&ia_ptr->evd_list_head));
 
-	if ( evd_ptr != NULL &&
-	     ! (evd_ptr->evd_flags & DAT_EVD_ASYNC_FLAG) )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_IA_IN_USE);
-	    goto bail;
+	/* if the async evd does not need to be cleaned up */
+	/* (ie. it was not created by dapl_ia_open)        */
+	/*  then the evd list should be empty              */
+	if (DAT_FALSE == ia_ptr->cleanup_async_error_evd) {
+		if (!dapl_llist_is_empty(&ia_ptr->evd_list_head)) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_STATE,
+				      DAT_INVALID_STATE_IA_IN_USE);
+			goto bail;
+		}
 	}
+	/* else the async evd should be the only evd in    */
+	/* the list.                                        */
+	else {
+		evd_ptr = (dapl_llist_is_empty(&ia_ptr->evd_list_head)
+			   ? NULL : dapl_llist_peek_head(&ia_ptr->
+							 evd_list_head));
 
-	entry = ia_ptr->evd_list_head;
+		if (evd_ptr != NULL &&
+		    !(evd_ptr->evd_flags & DAT_EVD_ASYNC_FLAG)) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_STATE,
+				      DAT_INVALID_STATE_IA_IN_USE);
+			goto bail;
+		}
 
-	/* if the async evd is not the only element in the list */
-	if ( entry->blink != entry->flink )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_IA_IN_USE);
-	    goto bail;
+		entry = ia_ptr->evd_list_head;
+
+		/* if the async evd is not the only element in the list */
+		if (entry->blink != entry->flink) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_STATE,
+				      DAT_INVALID_STATE_IA_IN_USE);
+			goto bail;
+		}
+
+		/*
+		 * If the async evd has a non-unary ref count (i.e. it's in
+		 * use by someone besides us.
+		 */
+		if (dapl_os_atomic_read(&evd_ptr->evd_ref_count) != 1) {
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_STATE,
+				      DAT_INVALID_STATE_IA_IN_USE);
+			goto bail;
+		}
 	}
 
 	/*
-	 * If the async evd has a non-unary ref count (i.e. it's in
-	 * use by someone besides us.
+	 * We've validated the call; now we can start the teardown.
+	 * Because we're in the IA close routine, we're safe from races with DAPL
+	 * consumers on this IA (operate/destroy races are disallowed in
+	 * DAPL).
 	 */
-	if ( dapl_os_atomic_read (&evd_ptr->evd_ref_count) != 1 )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_IA_IN_USE);
-	    goto bail;
-	}
-    }
+	hca_ptr = ia_ptr->hca_ptr;
 
-    /*
-     * We've validated the call; now we can start the teardown.
-     * Because we're in the IA close routine, we're safe from races with DAPL
-     * consumers on this IA (operate/destroy races are disallowed in
-     * DAPL).
-     */
-    hca_ptr = ia_ptr->hca_ptr;
+	/* Tear down the async EVD if needed, first shutting down callbacks.  */
+	if (ia_ptr->async_error_evd &&
+	    (DAT_TRUE == ia_ptr->cleanup_async_error_evd)) {
+		cur_dat_status = dapls_ia_teardown_callbacks(ia_ptr);
+		if (DAT_SUCCESS != cur_dat_status) {
+			dat_status = cur_dat_status;
+		}
+		dapl_os_atomic_dec(&ia_ptr->async_error_evd->evd_ref_count);
+		cur_dat_status = dapl_evd_free(ia_ptr->async_error_evd);
+		if (DAT_SUCCESS != cur_dat_status) {
+			dat_status = cur_dat_status;
+		}
 
-    /* Tear down the async EVD if needed, first shutting down callbacks.  */
-    if ( ia_ptr->async_error_evd &&
-	 (DAT_TRUE == ia_ptr->cleanup_async_error_evd) )
-    {
-	cur_dat_status = dapls_ia_teardown_callbacks ( ia_ptr );
-	if ( DAT_SUCCESS != cur_dat_status )
-	{
-	    dat_status = cur_dat_status;
+		ia_ptr->async_error_evd = NULL;
 	}
-	dapl_os_atomic_dec (& ia_ptr->async_error_evd->evd_ref_count);
-	cur_dat_status = dapl_evd_free (ia_ptr->async_error_evd);
-	if ( DAT_SUCCESS != cur_dat_status )
-	{
-	    dat_status = cur_dat_status;
-	}
 
-	ia_ptr->async_error_evd = NULL;
-    }
+	dapli_ia_release_hca(hca_ptr);
 
-    dapli_ia_release_hca (hca_ptr);
+	dapls_ia_free(ia_ptr);
 
-    dapls_ia_free (ia_ptr);
-
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*
@@ -544,22 +520,18 @@
  * handle. Manipulate under lock to prevent races with threads trying to
  * open the HCA.
  */
-void
-dapli_ia_release_hca (
-    DAPL_HCA		*hca_ptr )
+void dapli_ia_release_hca(DAPL_HCA * hca_ptr)
 {
-    dapl_os_lock (&hca_ptr->lock);
-    dapl_os_atomic_dec (& hca_ptr->handle_ref_count );
-    if ( dapl_os_atomic_read (&hca_ptr->handle_ref_count) == 0 )
-    {
-	dapls_ib_close_hca (hca_ptr);
-	hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
-        hca_ptr->async_evd = NULL; 
-    }
-    dapl_os_unlock (&hca_ptr->lock);
+	dapl_os_lock(&hca_ptr->lock);
+	dapl_os_atomic_dec(&hca_ptr->handle_ref_count);
+	if (dapl_os_atomic_read(&hca_ptr->handle_ref_count) == 0) {
+		dapls_ib_close_hca(hca_ptr);
+		hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
+		hca_ptr->async_evd = NULL;
+	}
+	dapl_os_unlock(&hca_ptr->lock);
 }
 
-
 /*
  * dapls_ia_free
  *
@@ -575,28 +547,31 @@
  * 	none
  *
  */
-void
-dapls_ia_free ( DAPL_IA *ia_ptr )
+void dapls_ia_free(DAPL_IA * ia_ptr)
 {
-    dapl_os_assert (ia_ptr->header.magic == DAPL_MAGIC_IA);
+	dapl_os_assert(ia_ptr->header.magic == DAPL_MAGIC_IA);
 
-    dapl_os_assert (ia_ptr->async_error_evd == NULL);
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->lmr_list_head));
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->rmr_list_head));
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->ep_list_head));
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->evd_list_head));
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->cno_list_head));
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->psp_list_head));
-    dapl_os_assert (dapl_llist_is_empty (&ia_ptr->rsp_list_head));
+	dapl_os_assert(ia_ptr->async_error_evd == NULL);
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->lmr_list_head));
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->rmr_list_head));
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->ep_list_head));
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->evd_list_head));
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->cno_list_head));
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->psp_list_head));
+	dapl_os_assert(dapl_llist_is_empty(&ia_ptr->rsp_list_head));
 
-    /*
-     * deinitialize the header
-     */
-    dapl_hca_unlink_ia (ia_ptr->hca_ptr, ia_ptr);
-    ia_ptr->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */
-    dapl_os_lock_destroy (&ia_ptr->header.lock);
+	/*
+	 * deinitialize the header
+	 */
+	dapl_hca_unlink_ia(ia_ptr->hca_ptr, ia_ptr);
+	ia_ptr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
+	dapl_os_lock_destroy(&ia_ptr->header.lock);
 
-    dapl_os_free (ia_ptr, sizeof (DAPL_IA));
+#ifdef DAPL_COUNTERS
+	dapl_os_free(ia_ptr->cntrs, sizeof(DAT_UINT64) * DCNT_IA_ALL_COUNTERS);
+#endif				/* DAPL_COUNTERS */
+
+	dapl_os_free(ia_ptr, sizeof(DAPL_IA));
 }
 
 /*
@@ -615,16 +590,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_ep (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_EP	   *ep_ptr)
+void dapl_ia_link_ep(IN DAPL_IA * ia_ptr, IN DAPL_EP * ep_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->ep_list_head,
-			 &ep_ptr->header.ia_list_entry,
-			 ep_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->ep_list_head,
+			    &ep_ptr->header.ia_list_entry, ep_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -643,15 +614,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_ep (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_EP	   *ep_ptr)
+void dapl_ia_unlink_ep(IN DAPL_IA * ia_ptr, IN DAPL_EP * ep_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->ep_list_head,
-			     &ep_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->ep_list_head,
+				&ep_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -670,16 +638,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_srq (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_SRQ   *srq_ptr)
+void dapl_ia_link_srq(IN DAPL_IA * ia_ptr, IN DAPL_SRQ * srq_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->srq_list_head,
-			 &srq_ptr->header.ia_list_entry,
-			 srq_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->srq_list_head,
+			    &srq_ptr->header.ia_list_entry, srq_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -698,15 +662,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_srq (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_SRQ   *srq_ptr)
+void dapl_ia_unlink_srq(IN DAPL_IA * ia_ptr, IN DAPL_SRQ * srq_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->srq_list_head,
-			     &srq_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->srq_list_head,
+				&srq_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -725,16 +686,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_lmr (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_LMR   *lmr_ptr)
+void dapl_ia_link_lmr(IN DAPL_IA * ia_ptr, IN DAPL_LMR * lmr_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->lmr_list_head,
-			 &lmr_ptr->header.ia_list_entry,
-			 lmr_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->lmr_list_head,
+			    &lmr_ptr->header.ia_list_entry, lmr_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -753,15 +710,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_lmr (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_LMR   *lmr_ptr)
+void dapl_ia_unlink_lmr(IN DAPL_IA * ia_ptr, IN DAPL_LMR * lmr_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->lmr_list_head,
-			     &lmr_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->lmr_list_head,
+				&lmr_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -780,16 +734,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_rmr (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_RMR   *rmr_ptr)
+void dapl_ia_link_rmr(IN DAPL_IA * ia_ptr, IN DAPL_RMR * rmr_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->rmr_list_head,
-			 &rmr_ptr->header.ia_list_entry,
-			 rmr_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->rmr_list_head,
+			    &rmr_ptr->header.ia_list_entry, rmr_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -808,15 +758,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_rmr (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_RMR   *rmr_ptr)
+void dapl_ia_unlink_rmr(IN DAPL_IA * ia_ptr, IN DAPL_RMR * rmr_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->rmr_list_head,
-			     &rmr_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->rmr_list_head,
+				&rmr_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -835,16 +782,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_pz (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_PZ	   *pz_ptr)
+void dapl_ia_link_pz(IN DAPL_IA * ia_ptr, IN DAPL_PZ * pz_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->pz_list_head,
-			 &pz_ptr->header.ia_list_entry,
-			 pz_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->pz_list_head,
+			    &pz_ptr->header.ia_list_entry, pz_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -863,15 +806,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_pz (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_PZ	   *pz_ptr)
+void dapl_ia_unlink_pz(IN DAPL_IA * ia_ptr, IN DAPL_PZ * pz_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->pz_list_head,
-			     &pz_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->pz_list_head,
+				&pz_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -890,16 +830,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_evd (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_EVD   *evd_ptr)
+void dapl_ia_link_evd(IN DAPL_IA * ia_ptr, IN DAPL_EVD * evd_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->evd_list_head,
-			 &evd_ptr->header.ia_list_entry,
-			 evd_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->evd_list_head,
+			    &evd_ptr->header.ia_list_entry, evd_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -918,15 +854,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_evd (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_EVD   *evd_ptr)
+void dapl_ia_unlink_evd(IN DAPL_IA * ia_ptr, IN DAPL_EVD * evd_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->evd_list_head,
-			     &evd_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->evd_list_head,
+				&evd_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -945,16 +878,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_cno (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_CNO   *cno_ptr)
+void dapl_ia_link_cno(IN DAPL_IA * ia_ptr, IN DAPL_CNO * cno_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->cno_list_head,
-			 &cno_ptr->header.ia_list_entry,
-			 cno_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->cno_list_head,
+			    &cno_ptr->header.ia_list_entry, cno_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -973,15 +902,12 @@
  * 	none
  *
  */
-void
-dapl_ia_unlink_cno (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_CNO   *cno_ptr)
+void dapl_ia_unlink_cno(IN DAPL_IA * ia_ptr, IN DAPL_CNO * cno_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (&ia_ptr->cno_list_head,
-			     &cno_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(&ia_ptr->cno_list_head,
+				&cno_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -1000,16 +926,12 @@
  * 	none
  *
  */
-void
-dapl_ia_link_psp (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_SP    *sp_ptr)
+void dapl_ia_link_psp(IN DAPL_IA * ia_ptr, IN DAPL_SP * sp_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->psp_list_head,
-			 &sp_ptr->header.ia_list_entry,
-			 sp_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->psp_list_head,
+			    &sp_ptr->header.ia_list_entry, sp_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -1028,27 +950,21 @@
  * 	none
  *
  */
-void
-dapls_ia_unlink_sp (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_SP    *sp_ptr)
+void dapls_ia_unlink_sp(IN DAPL_IA * ia_ptr, IN DAPL_SP * sp_ptr)
 {
-    DAPL_LLIST_HEAD	*list_head;
+	DAPL_LLIST_HEAD *list_head;
 
-    if ( sp_ptr->header.handle_type == DAT_HANDLE_TYPE_PSP )
-    {
-	list_head = &ia_ptr->psp_list_head;
-    }
-    else
-    {
-	dapl_os_assert (sp_ptr->header.handle_type == DAT_HANDLE_TYPE_RSP);
-	list_head = &ia_ptr->rsp_list_head;
-    }
+	if (sp_ptr->header.handle_type == DAT_HANDLE_TYPE_PSP) {
+		list_head = &ia_ptr->psp_list_head;
+	} else {
+		dapl_os_assert(sp_ptr->header.handle_type ==
+			       DAT_HANDLE_TYPE_RSP);
+		list_head = &ia_ptr->rsp_list_head;
+	}
 
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_remove_entry (list_head,
-			     &sp_ptr->header.ia_list_entry);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_remove_entry(list_head, &sp_ptr->header.ia_list_entry);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
 /*
@@ -1067,45 +983,36 @@
  * 	none
  *
  */
-DAPL_SP *
-dapls_ia_sp_search (
-	IN	DAPL_IA		   *ia_ptr,
-	IN	DAT_CONN_QUAL	   conn_qual,
-	IN	DAT_BOOLEAN	   is_psp )
+DAPL_SP *dapls_ia_sp_search(IN DAPL_IA * ia_ptr,
+			    IN DAT_CONN_QUAL conn_qual, IN DAT_BOOLEAN is_psp)
 {
-    DAPL_SP 	   	*sp_ptr;
-    DAPL_LLIST_HEAD	*list_head;
+	DAPL_SP *sp_ptr;
+	DAPL_LLIST_HEAD *list_head;
 
-    if ( is_psp )
-    {
-	list_head = &ia_ptr->psp_list_head;
-    }
-    else
-    {
-	list_head = &ia_ptr->rsp_list_head;
-    }
+	if (is_psp) {
+		list_head = &ia_ptr->psp_list_head;
+	} else {
+		list_head = &ia_ptr->rsp_list_head;
+	}
 
-    dapl_os_lock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
 
-    sp_ptr = (dapl_llist_is_empty (list_head) ? NULL :
-		dapl_llist_peek_head (list_head));
+	sp_ptr = (dapl_llist_is_empty(list_head) ? NULL :
+		  dapl_llist_peek_head(list_head));
 
-    while (sp_ptr != NULL)
-    {
-	if ( sp_ptr->conn_qual == conn_qual )
-	{
-	    break;
+	while (sp_ptr != NULL) {
+		if (sp_ptr->conn_qual == conn_qual) {
+			break;
+		}
+		sp_ptr = dapl_llist_next_entry(list_head,
+					       &sp_ptr->header.ia_list_entry);
 	}
-	sp_ptr = dapl_llist_next_entry (list_head,
-					&sp_ptr->header.ia_list_entry);
-    }
 
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_unlock(&ia_ptr->header.lock);
 
-    return sp_ptr;
+	return sp_ptr;
 }
 
-
 /*
  * dapl_ia_link_rsp
  *
@@ -1122,127 +1029,112 @@
  * 	none
  *
  */
-void
-dapl_ia_link_rsp (
-	IN	DAPL_IA	   *ia_ptr,
-	IN	DAPL_SP    *sp_ptr)
+void dapl_ia_link_rsp(IN DAPL_IA * ia_ptr, IN DAPL_SP * sp_ptr)
 {
-    dapl_os_lock (&ia_ptr->header.lock);
-    dapl_llist_add_head (&ia_ptr->rsp_list_head,
-			 &sp_ptr->header.ia_list_entry,
-			 sp_ptr);
-    dapl_os_unlock (&ia_ptr->header.lock);
+	dapl_os_lock(&ia_ptr->header.lock);
+	dapl_llist_add_head(&ia_ptr->rsp_list_head,
+			    &sp_ptr->header.ia_list_entry, sp_ptr);
+	dapl_os_unlock(&ia_ptr->header.lock);
 }
 
-
 DAT_RETURN
-dapls_ia_setup_callbacks (
-    IN	DAPL_IA		*ia_ptr,
-    IN	DAPL_EVD	*async_evd_ptr )
+dapls_ia_setup_callbacks(IN DAPL_IA * ia_ptr, IN DAPL_EVD * async_evd_ptr)
 {
-    DAT_RETURN dat_status = DAT_SUCCESS;
+	DAT_RETURN dat_status = DAT_SUCCESS;
 
-    /* unaffiliated handler */
-    dat_status =
-	dapls_ib_setup_async_callback (
-	    ia_ptr,
-	    DAPL_ASYNC_UNAFILIATED,
-	    NULL,
-	    (ib_async_handler_t)dapl_evd_un_async_error_callback,
-	    async_evd_ptr);
+	/* unaffiliated handler */
+	dat_status =
+	    dapls_ib_setup_async_callback(ia_ptr,
+					  DAPL_ASYNC_UNAFILIATED,
+					  NULL,
+					  (ib_async_handler_t)
+					  dapl_evd_un_async_error_callback,
+					  async_evd_ptr);
 
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ib_set_un_async_error_eh failed %d\n", dat_status);
-	goto bail;
-    }
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ib_set_un_async_error_eh failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-    /* affiliated cq handler */
-    dat_status = dapls_ib_setup_async_callback (
-	ia_ptr,
-	DAPL_ASYNC_CQ_ERROR,
-	NULL,
-	(ib_async_handler_t)dapl_evd_cq_async_error_callback,
-	async_evd_ptr);
+	/* affiliated cq handler */
+	dat_status = dapls_ib_setup_async_callback(ia_ptr,
+						   DAPL_ASYNC_CQ_ERROR,
+						   NULL,
+						   (ib_async_handler_t)
+						   dapl_evd_cq_async_error_callback,
+						   async_evd_ptr);
 
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ib_set_cq_async_error_eh failed %d\n", dat_status);
-	goto bail;
-    }
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ib_set_cq_async_error_eh failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-    /* affiliated qp handler */
-    dat_status = dapls_ib_setup_async_callback (
-	ia_ptr,
-	DAPL_ASYNC_QP_ERROR,
-	NULL,
-	(ib_async_handler_t)dapl_evd_qp_async_error_callback,
-	ia_ptr);
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ib_set_qp_async_error_eh failed %d\n", dat_status);
-	goto bail;
-    }
+	/* affiliated qp handler */
+	dat_status = dapls_ib_setup_async_callback(ia_ptr,
+						   DAPL_ASYNC_QP_ERROR,
+						   NULL,
+						   (ib_async_handler_t)
+						   dapl_evd_qp_async_error_callback,
+						   ia_ptr);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ib_set_qp_async_error_eh failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-DAT_RETURN
-dapls_ia_teardown_callbacks (
-    IN	DAPL_IA		*ia_ptr)
+DAT_RETURN dapls_ia_teardown_callbacks(IN DAPL_IA * ia_ptr)
 {
-    DAT_RETURN dat_status = DAT_SUCCESS;
+	DAT_RETURN dat_status = DAT_SUCCESS;
 
-    /* unaffiliated handler */
-    dat_status =
-	dapls_ib_setup_async_callback (
-	    ia_ptr,
-	    DAPL_ASYNC_UNAFILIATED,
-	    NULL,
-	    (ib_async_handler_t) 0,
-	    NULL);
+	/* unaffiliated handler */
+	dat_status =
+	    dapls_ib_setup_async_callback(ia_ptr,
+					  DAPL_ASYNC_UNAFILIATED,
+					  NULL, (ib_async_handler_t) 0, NULL);
 
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ib_set_un_async_error_eh failed %d\n", dat_status);
-	goto bail;
-    }
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ib_set_un_async_error_eh failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-    /* affiliated cq handler */
-    dat_status = dapls_ib_setup_async_callback (
-	ia_ptr,
-	DAPL_ASYNC_CQ_ERROR,
-	NULL,
-	(ib_async_handler_t) 0,
-	NULL);
+	/* affiliated cq handler */
+	dat_status = dapls_ib_setup_async_callback(ia_ptr,
+						   DAPL_ASYNC_CQ_ERROR,
+						   NULL,
+						   (ib_async_handler_t) 0,
+						   NULL);
 
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ib_set_cq_async_error_eh failed %d\n", dat_status);
-	goto bail;
-    }
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ib_set_cq_async_error_eh failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-    /* affiliated qp handler */
-    dat_status = dapls_ib_setup_async_callback (
-	ia_ptr,
-	DAPL_ASYNC_QP_ERROR,
-	NULL,
-	(ib_async_handler_t) 0,
-	NULL);
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ib_set_qp_async_error_eh failed %d\n", dat_status);
-	goto bail;
-    }
+	/* affiliated qp handler */
+	dat_status = dapls_ib_setup_async_callback(ia_ptr,
+						   DAPL_ASYNC_QP_ERROR,
+						   NULL,
+						   (ib_async_handler_t) 0,
+						   NULL);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ib_set_qp_async_error_eh failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_llist.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_llist.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_llist.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,10 +57,9 @@
  *
  * Purpose: initialize a linked list head
  */
-void
-dapl_llist_init_head (DAPL_LLIST_HEAD * head)
+void dapl_llist_init_head(DAPL_LLIST_HEAD * head)
 {
-    *head = NULL;
+	*head = NULL;
 }
 
 /*
@@ -68,13 +67,12 @@
  *
  * Purpose: initialize a linked list entry
  */
-void
-dapl_llist_init_entry (DAPL_LLIST_ENTRY * entry)
+void dapl_llist_init_entry(DAPL_LLIST_ENTRY * entry)
 {
-    entry->blink = NULL;
-    entry->flink = NULL;
-    entry->data = 0;
-    entry->list_head = NULL;
+	entry->blink = NULL;
+	entry->flink = NULL;
+	entry->data = 0;
+	entry->list_head = NULL;
 }
 
 /*
@@ -82,10 +80,9 @@
  *
  * Purpose: returns TRUE if the linked list is empty
  */
-DAT_BOOLEAN
-dapl_llist_is_empty (DAPL_LLIST_HEAD * head)
+DAT_BOOLEAN dapl_llist_is_empty(DAPL_LLIST_HEAD * head)
 {
-    return (*head == NULL);
+	return (*head == NULL);
 }
 
 /*
@@ -94,30 +91,26 @@
  * Purpose: Add an entry to the head of a linked list
  */
 void
-dapl_llist_add_head (DAPL_LLIST_HEAD * head,
-		     DAPL_LLIST_ENTRY * entry,
-		     void * data)
+dapl_llist_add_head(DAPL_LLIST_HEAD * head,
+		    DAPL_LLIST_ENTRY * entry, void *data)
 {
-    DAPL_LLIST_ENTRY *first;
+	DAPL_LLIST_ENTRY *first;
 
-    /* deal with empty list */
-    if (dapl_llist_is_empty (head))
-    {
-	entry->flink = entry;
-	entry->blink = entry;
-    }
-    else
-    {
-	first = *head;
-	entry->flink = first;
-	entry->blink = first->blink;
-	first->blink->flink = entry;
-	first->blink = entry;
-    }
+	/* deal with empty list */
+	if (dapl_llist_is_empty(head)) {
+		entry->flink = entry;
+		entry->blink = entry;
+	} else {
+		first = *head;
+		entry->flink = first;
+		entry->blink = first->blink;
+		first->blink->flink = entry;
+		first->blink = entry;
+	}
 
-    *head            = entry;
-    entry->data      = data;
-    entry->list_head = head;
+	*head = entry;
+	entry->data = data;
+	entry->list_head = head;
 }
 
 /*
@@ -126,32 +119,27 @@
  * Purpose: Add an entry to the tail of a linked list
  */
 void
-dapl_llist_add_tail (DAPL_LLIST_HEAD * head,
-		     DAPL_LLIST_ENTRY * entry,
-		     void * data)
+dapl_llist_add_tail(DAPL_LLIST_HEAD * head,
+		    DAPL_LLIST_ENTRY * entry, void *data)
 {
-    DAPL_LLIST_ENTRY *last;
+	DAPL_LLIST_ENTRY *last;
 
-    /* deal with empty list */
-    if (dapl_llist_is_empty (head))
-    {
-	*head = entry;
-	entry->flink = entry;
-	entry->blink = entry;
-    }
-    else
-    {
-	last = (*head)->blink;
-	entry->flink = last->flink;
-	entry->blink = last;
-	last->flink->blink = entry;
-	last->flink = entry;
-    }
-    entry->data      = data;
-    entry->list_head = head;
+	/* deal with empty list */
+	if (dapl_llist_is_empty(head)) {
+		*head = entry;
+		entry->flink = entry;
+		entry->blink = entry;
+	} else {
+		last = (*head)->blink;
+		entry->flink = last->flink;
+		entry->blink = last;
+		last->flink->blink = entry;
+		last->flink = entry;
+	}
+	entry->data = data;
+	entry->list_head = head;
 }
 
-
 /*
  * dapl_llist_add_entry()
  *
@@ -159,33 +147,31 @@
  * not verify the list or the validity of the entries passed in.
  */
 void
-dapl_llist_add_entry (DAPL_LLIST_HEAD * head,
+dapl_llist_add_entry(DAPL_LLIST_HEAD * head,
 		     DAPL_LLIST_ENTRY * entry,
-		     DAPL_LLIST_ENTRY * new_entry,
-		     void * data)
+		     DAPL_LLIST_ENTRY * new_entry, void *data)
 {
-    DAPL_LLIST_ENTRY *first;
-    DAPL_LLIST_ENTRY *prev;
+	DAPL_LLIST_ENTRY *first;
+	DAPL_LLIST_ENTRY *prev;
 
-    /* get the head pointer */
-    first = *head;
+	/* get the head pointer */
+	first = *head;
 
-    /* link the entry into the queue */
-    prev = entry->blink;
-    entry->blink = new_entry;
-    prev->flink  = new_entry;
+	/* link the entry into the queue */
+	prev = entry->blink;
+	entry->blink = new_entry;
+	prev->flink = new_entry;
 
-    new_entry->flink = entry;
-    new_entry->blink = prev;
+	new_entry->flink = entry;
+	new_entry->blink = prev;
 
-    new_entry->data      = data;
-    new_entry->list_head = head;
+	new_entry->data = data;
+	new_entry->list_head = head;
 
-    /* If the old entry was the head of the list, adjust */
-    if (first == entry)
-    {
-	(*head) = new_entry;
-    }
+	/* If the old entry was the head of the list, adjust */
+	if (first == entry) {
+		(*head) = new_entry;
+	}
 
 }
 
@@ -194,27 +180,25 @@
  *
  * Purpose: Remove the first entry of a linked list
  */
-void *
-dapl_llist_remove_head (DAPL_LLIST_HEAD *head)
+void *dapl_llist_remove_head(DAPL_LLIST_HEAD * head)
 {
-    DAPL_LLIST_ENTRY *first;
+	DAPL_LLIST_ENTRY *first;
 
-    dapl_os_assert (!dapl_llist_is_empty (head));
-    first = *head;
-    *head = first->flink;
+	dapl_os_assert(!dapl_llist_is_empty(head));
+	first = *head;
+	*head = first->flink;
 
-    first->flink->blink = first->blink;
-    first->blink->flink = first->flink;
+	first->flink->blink = first->blink;
+	first->blink->flink = first->flink;
 
-    if (first->flink == first)
-    {
-	*head = NULL;
-    }
-    /* clean up the links for good measure */
-    first->flink = NULL;
-    first->blink = NULL;
-    first->list_head = NULL;
-    return (first->data);
+	if (first->flink == first) {
+		*head = NULL;
+	}
+	/* clean up the links for good measure */
+	first->flink = NULL;
+	first->blink = NULL;
+	first->list_head = NULL;
+	return (first->data);
 }
 
 /*
@@ -222,27 +206,25 @@
  *
  * Purpose: Remove the last entry of a linked list
  */
-void *
-dapl_llist_remove_tail (DAPL_LLIST_HEAD *head)
+void *dapl_llist_remove_tail(DAPL_LLIST_HEAD * head)
 {
-    DAPL_LLIST_ENTRY *last;
+	DAPL_LLIST_ENTRY *last;
 
-    dapl_os_assert (!dapl_llist_is_empty (head));
-    last = (*head)->blink;
+	dapl_os_assert(!dapl_llist_is_empty(head));
+	last = (*head)->blink;
 
-    last->blink->flink = last->flink;
-    last->flink->blink = last->blink;
+	last->blink->flink = last->flink;
+	last->flink->blink = last->blink;
 
-    if (last->flink == last)
-    {
-	*head = NULL;
-    }
-    /* clean up the links for good measure */
-    last->flink = NULL;
-    last->blink = NULL;
-    last->list_head = NULL;
+	if (last->flink == last) {
+		*head = NULL;
+	}
+	/* clean up the links for good measure */
+	last->flink = NULL;
+	last->blink = NULL;
+	last->list_head = NULL;
 
-    return (last->data);
+	return (last->data);
 }
 
 /*
@@ -250,73 +232,64 @@
  *
  * Purpose: Remove the specified entry from a linked list
  */
-void *
-dapl_llist_remove_entry (DAPL_LLIST_HEAD *head, DAPL_LLIST_ENTRY *entry)
+void *dapl_llist_remove_entry(DAPL_LLIST_HEAD * head, DAPL_LLIST_ENTRY * entry)
 {
-    DAPL_LLIST_ENTRY *first;
+	DAPL_LLIST_ENTRY *first;
 
-    dapl_os_assert (!dapl_llist_is_empty (head));
-    first = *head;
+	dapl_os_assert(!dapl_llist_is_empty(head));
+	first = *head;
 
-    /* if it's the first entry, pull it off */
-    if (first == entry)
-    {
-	(*head) = first->flink;
-	/* if it was the only entry, kill the list */
-	if (first->flink == first)
-	{
-	    (*head) = NULL;
+	/* if it's the first entry, pull it off */
+	if (first == entry) {
+		(*head) = first->flink;
+		/* if it was the only entry, kill the list */
+		if (first->flink == first) {
+			(*head) = NULL;
+		}
 	}
-    }
 #ifdef VERIFY_LINKED_LIST
-    else
-    {
-	DAPL_LLIST_ENTRY *try_entry;
+	else {
+		DAPL_LLIST_ENTRY *try_entry;
 
-	try_entry = first->flink;
-	for (;;)
-	{
-	    if (try_entry == first)
-	    {
-		/* not finding the element on the list is a BAD thing */
-		dapl_os_assert (0);
-		break;
-	    }
-	    if (try_entry == entry)
-	    {
-		break;
-	    }
-	    try_entry = try_entry->flink;
+		try_entry = first->flink;
+		for (;;) {
+			if (try_entry == first) {
+				/* not finding the element on the list is a BAD thing */
+				dapl_os_assert(0);
+				break;
+			}
+			if (try_entry == entry) {
+				break;
+			}
+			try_entry = try_entry->flink;
+		}
 	}
-    }
-#endif /* VERIFY_LINKED_LIST */
+#endif				/* VERIFY_LINKED_LIST */
 
-    dapl_os_assert ( entry->list_head == head );
-    entry->list_head = NULL;
+	dapl_os_assert(entry->list_head == head);
+	entry->list_head = NULL;
 
-    entry->flink->blink = entry->blink;
-    entry->blink->flink = entry->flink;
-    entry->flink = NULL;
-    entry->blink = NULL;
+	entry->flink->blink = entry->blink;
+	entry->blink->flink = entry->flink;
+	entry->flink = NULL;
+	entry->blink = NULL;
 
-    return (entry->data);
+	return (entry->data);
 }
 
 /*
  * dapl_llist_peek_head
  */
 
-void *
-dapl_llist_peek_head (DAPL_LLIST_HEAD *head)
+void *dapl_llist_peek_head(DAPL_LLIST_HEAD * head)
 {
-    DAPL_LLIST_ENTRY *first;
+	DAPL_LLIST_ENTRY *first;
 
-    dapl_os_assert (!dapl_llist_is_empty (head));
-    first = *head;
-    return (first->data);
+	dapl_os_assert(!dapl_llist_is_empty(head));
+	first = *head;
+	return (first->data);
 }
 
-
 /*
  * dapl_llist_next_entry
  *
@@ -324,26 +297,21 @@
  * head
  */
 
-void *
-dapl_llist_next_entry (IN    DAPL_LLIST_HEAD 	*head,
-		       IN    DAPL_LLIST_ENTRY 	*cur_ent)
+void *dapl_llist_next_entry(IN DAPL_LLIST_HEAD * head,
+			    IN DAPL_LLIST_ENTRY * cur_ent)
 {
-    DAPL_LLIST_ENTRY *next;
+	DAPL_LLIST_ENTRY *next;
 
-    dapl_os_assert (!dapl_llist_is_empty (head));
-    if ( cur_ent == NULL )
-    {
-	next = *head;
-    }
-    else
-    {
-	next = cur_ent->flink;
-	if ( next == *head )
-	{
-	    return NULL;
+	dapl_os_assert(!dapl_llist_is_empty(head));
+	if (cur_ent == NULL) {
+		next = *head;
+	} else {
+		next = cur_ent->flink;
+		if (next == *head) {
+			return NULL;
+		}
 	}
-    }
-    return (next->data);
+	return (next->data);
 }
 
 #ifdef DAPL_DBG
@@ -352,33 +320,24 @@
  *
  * Purpose: Prints the linked list for debugging
  */
-void
-dapl_llist_debug_print_list (DAPL_LLIST_HEAD *head)
+void dapl_llist_debug_print_list(DAPL_LLIST_HEAD * head)
 {
-    DAPL_LLIST_ENTRY * entry;
-    DAPL_LLIST_ENTRY * first;
-    first = *head;
-    if (!first)
-    {
-	dapl_os_printf ("EMPTY_LIST\n");
-	return;
-    }
-    dapl_os_printf ("HEAD %p\n", *head);
-    dapl_os_printf ("Entry %p %p %p %p\n",
-		first,
-		first->flink,
-		first->blink,
-		first->data);
-    entry = first->flink;
-    while (entry != first)
-    {
-	dapl_os_printf ("Entry %p %p %p %p\n",
-		    entry,
-		    entry->flink,
-		    entry->blink,
-		    entry->data);
-	entry = entry->flink;
-    }
+	DAPL_LLIST_ENTRY *entry;
+	DAPL_LLIST_ENTRY *first;
+	first = *head;
+	if (!first) {
+		dapl_os_printf("EMPTY_LIST\n");
+		return;
+	}
+	dapl_os_printf("HEAD %p\n", *head);
+	dapl_os_printf("Entry %p %p %p %p\n",
+		       first, first->flink, first->blink, first->data);
+	entry = first->flink;
+	while (entry != first) {
+		dapl_os_printf("Entry %p %p %p %p\n",
+			       entry, entry->flink, entry->blink, entry->data);
+		entry = entry->flink;
+	}
 }
 
-#endif /* DAPL_DBG */
+#endif				/* DAPL_DBG */

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,84 +57,79 @@
  * 	DAT_INVALID_STATE 
  */
 
-DAT_RETURN DAT_API
-dapl_lmr_free (
-    IN	DAT_LMR_HANDLE  lmr_handle )
+DAT_RETURN DAT_API dapl_lmr_free(IN DAT_LMR_HANDLE lmr_handle)
 {
-    DAPL_LMR 		*lmr;
-    DAT_RETURN		dat_status;
+	DAPL_LMR *lmr;
+	DAPL_PZ *pz;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_lmr_free (%p)\n", lmr_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_lmr_free (%p)\n", lmr_handle);
 
-    if ( DAPL_BAD_HANDLE (lmr_handle, DAPL_MAGIC_LMR) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_LMR);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(lmr_handle, DAPL_MAGIC_LMR)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
+		goto bail;
+	}
 
-    lmr = (DAPL_LMR *) lmr_handle;
+	lmr = (DAPL_LMR *) lmr_handle;
+	pz = (DAPL_PZ *) lmr->param.pz_handle;
 
-    switch (lmr->param.mem_type)
-    {
+	DAPL_CNTR(pz->header.owner_ia, DCNT_IA_LMR_FREE);
+
+	switch (lmr->param.mem_type) {
 #if defined(__KDAPL__)
 	case DAT_MEM_TYPE_PHYSICAL:
 #else
 	case DAT_MEM_TYPE_SHARED_VIRTUAL:
-#endif	/* defined(__KDAPL__) */
-	/* fall through */
+#endif				/* defined(__KDAPL__) */
+		/* fall through */
 	case DAT_MEM_TYPE_VIRTUAL:
 	case DAT_MEM_TYPE_LMR:
-	{
-	    DAPL_PZ 	*pz;
+		{
+			if (0 != dapl_os_atomic_read(&lmr->lmr_ref_count)) {
+				return DAT_INVALID_STATE;
+			}
 
-	    if ( 0 != dapl_os_atomic_read (&lmr->lmr_ref_count) )
-	    {
-		return DAT_INVALID_STATE;
-	    }
+			dat_status =
+			    dapls_hash_remove(lmr->header.owner_ia->hca_ptr->
+					      lmr_hash_table,
+					      lmr->param.lmr_context, NULL);
+			if (dat_status != DAT_SUCCESS) {
+				goto bail;
+			}
 
-	    dat_status = dapls_hash_remove (lmr->header.owner_ia->hca_ptr->lmr_hash_table, 
-					    lmr->param.lmr_context, NULL);
-	    if (dat_status != DAT_SUCCESS)
-	    {
-		goto bail;
-	    }
+			dat_status = dapls_ib_mr_deregister(lmr);
 
-	    dat_status = dapls_ib_mr_deregister (lmr);
+			if (dat_status == DAT_SUCCESS) {
+				dapl_os_atomic_dec(&pz->pz_ref_count);
+				dapl_lmr_dealloc(lmr);
+			} else {
+				/*
+				 * Deregister failed; put it back in the
+				 * hash table.
+				 */
+				dapls_hash_insert(lmr->header.owner_ia->
+						  hca_ptr->lmr_hash_table,
+						  lmr->param.lmr_context, lmr);
+			}
 
-	    if (dat_status == DAT_SUCCESS)
-	    {
-
-		pz = (DAPL_PZ *) lmr->param.pz_handle;
-		dapl_os_atomic_dec (&pz->pz_ref_count);
-
-		dapl_lmr_dealloc (lmr);
-	    }
-	    else
-	    {
-		/*
-		 * Deregister failed; put it back in the
-		 * hash table.
-		 */
-		dapls_hash_insert (lmr->header.owner_ia->hca_ptr->lmr_hash_table, 
-				   lmr->param.lmr_context, lmr);
-	    }
-
-	    break;
-	}
+			break;
+		}
 #if defined(__KDAPL__)
 	case DAT_MEM_TYPE_PLATFORM:
 	case DAT_MEM_TYPE_IA:
 	case DAT_MEM_TYPE_BYPASS:
-	{
-	    return DAT_ERROR (DAT_NOT_IMPLEMENTED,0);
-	}
-#endif	/* defined(__KDAPL__) */
+		{
+			return DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
+		}
+#endif				/* defined(__KDAPL__) */
 	default:
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG1);
-	    break;
+		{
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+			break;
+		}
 	}
-    }
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -55,36 +55,32 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_lmr_query (
-    IN	DAT_LMR_HANDLE		lmr_handle,
-    IN	DAT_LMR_PARAM_MASK	lmr_param_mask,
-    IN	DAT_LMR_PARAM		*lmr_param )
+dapl_lmr_query(IN DAT_LMR_HANDLE lmr_handle,
+	       IN DAT_LMR_PARAM_MASK lmr_param_mask,
+	       IN DAT_LMR_PARAM * lmr_param)
 {
-    DAPL_LMR		*lmr;
-    DAT_RETURN		dat_status;
+	DAPL_LMR *lmr;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_lmr_query (%p, 0x%x, %p)\n", 
-		  lmr_handle, 
-		  lmr_param_mask, 
-		  lmr_param);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_lmr_query (%p, 0x%x, %p)\n",
+		     lmr_handle, lmr_param_mask, lmr_param);
 
-    if ( DAPL_BAD_HANDLE (lmr_handle, DAPL_MAGIC_LMR) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_LMR);
-	goto bail;
-    }
-    if (NULL == lmr_param)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(lmr_handle, DAPL_MAGIC_LMR)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
+		goto bail;
+	}
+	if (NULL == lmr_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    dat_status = DAT_SUCCESS;
-    lmr = (DAPL_LMR *) lmr_handle;
+	dat_status = DAT_SUCCESS;
+	lmr = (DAPL_LMR *) lmr_handle;
 
-    dapl_os_memcpy (lmr_param, &lmr->param, sizeof (DAT_LMR_PARAM));
+	dapl_os_memcpy(lmr_param, &lmr->param, sizeof(DAT_LMR_PARAM));
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_read.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_read.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_read.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,29 +57,27 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_lmr_sync_rdma_read (
-    IN  DAT_IA_HANDLE		ia_handle,
-    IN  const DAT_LMR_TRIPLET	*local_segments,
-    IN  DAT_VLEN		num_segments )
+dapl_lmr_sync_rdma_read(IN DAT_IA_HANDLE ia_handle,
+			IN const DAT_LMR_TRIPLET * local_segments,
+			IN DAT_VLEN num_segments)
 {
-    DAPL_IA			*ia_ptr;
-    DAT_RETURN			dat_status;
+	DAPL_IA *ia_ptr;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dat_lmr_sync_rdma_read (%p, %p, %ld)\n",
-		  ia_handle, local_segments, num_segments);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dat_lmr_sync_rdma_read (%p, %p, %ld)\n",
+		     ia_handle, local_segments, num_segments);
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    
-    if (DAPL_BAD_HANDLE (ia_ptr, DAPL_MAGIC_IA))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
+	ia_ptr = (DAPL_IA *) ia_handle;
 
-    dat_status = dapl_os_sync_rdma_read (local_segments, num_segments);
+	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
 
- bail:
-    return dat_status;
-}
+	dat_status = dapl_os_sync_rdma_read(local_segments, num_segments);
 
+      bail:
+	return dat_status;
+}

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_write.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_write.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_sync_rdma_write.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,29 +57,27 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_lmr_sync_rdma_write (
-    IN  DAT_IA_HANDLE		ia_handle,
-    IN  const DAT_LMR_TRIPLET	*local_segments,
-    IN  DAT_VLEN		num_segments)
+dapl_lmr_sync_rdma_write(IN DAT_IA_HANDLE ia_handle,
+			 IN const DAT_LMR_TRIPLET * local_segments,
+			 IN DAT_VLEN num_segments)
 {
-    DAPL_IA			*ia_ptr;
-    DAT_RETURN			dat_status;
+	DAPL_IA *ia_ptr;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dat_lmr_sync_rdma_write (%p, %p, %ld)\n",
-		  ia_handle, local_segments, num_segments);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dat_lmr_sync_rdma_write (%p, %p, %ld)\n",
+		     ia_handle, local_segments, num_segments);
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    
-    if (DAPL_BAD_HANDLE (ia_ptr, DAPL_MAGIC_IA))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
+	ia_ptr = (DAPL_IA *) ia_handle;
 
-    dat_status = dapl_os_sync_rdma_write (local_segments, num_segments);
+	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
 
- bail:
-    return dat_status;
-}
+	dat_status = dapl_os_sync_rdma_write(local_segments, num_segments);
 
+      bail:
+	return dat_status;
+}

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_lmr_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -38,61 +38,56 @@
 #include "dapl_lmr_util.h"
 #include "dapl_ia_util.h"
 
-DAPL_LMR *
-dapl_lmr_alloc (
-    IN DAPL_IA 			*ia, 
-    IN DAT_MEM_TYPE	 	mem_type, 
-    IN DAT_REGION_DESCRIPTION	region_desc,
-    IN DAT_VLEN			length,
-    IN DAT_PZ_HANDLE		pz_handle,
-    IN DAT_MEM_PRIV_FLAGS	mem_priv)
+DAPL_LMR *dapl_lmr_alloc(IN DAPL_IA * ia,
+			 IN DAT_MEM_TYPE mem_type,
+			 IN DAT_REGION_DESCRIPTION region_desc,
+			 IN DAT_VLEN length,
+			 IN DAT_PZ_HANDLE pz_handle,
+			 IN DAT_MEM_PRIV_FLAGS mem_priv)
 {
-    DAPL_LMR *lmr;
+	DAPL_LMR *lmr;
 
-    /* Allocate LMR */
-    lmr = (DAPL_LMR *) dapl_os_alloc (sizeof (DAPL_LMR));
-    if (NULL == lmr)
-    {
-	return (NULL);
-    }
+	/* Allocate LMR */
+	lmr = (DAPL_LMR *) dapl_os_alloc(sizeof(DAPL_LMR));
+	if (NULL == lmr) {
+		return (NULL);
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (lmr, sizeof (DAPL_LMR));
+	/* zero the structure */
+	dapl_os_memzero(lmr, sizeof(DAPL_LMR));
 
-    /*
-     * initialize the header
-     */
-    lmr->header.provider            = ia->header.provider;
-    lmr->header.magic               = DAPL_MAGIC_LMR;
-    lmr->header.handle_type         = DAT_HANDLE_TYPE_LMR;
-    lmr->header.owner_ia            = ia;
-    lmr->header.user_context.as_64  = 0;
-    lmr->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&lmr->header.ia_list_entry);
-    dapl_ia_link_lmr (ia, lmr);
-    dapl_os_lock_init (&lmr->header.lock);
+	/*
+	 * initialize the header
+	 */
+	lmr->header.provider = ia->header.provider;
+	lmr->header.magic = DAPL_MAGIC_LMR;
+	lmr->header.handle_type = DAT_HANDLE_TYPE_LMR;
+	lmr->header.owner_ia = ia;
+	lmr->header.user_context.as_64 = 0;
+	lmr->header.user_context.as_ptr = NULL;
+	dapl_llist_init_entry(&lmr->header.ia_list_entry);
+	dapl_ia_link_lmr(ia, lmr);
+	dapl_os_lock_init(&lmr->header.lock);
 
-    /* 
-     * initialize the body 
-     */
-    lmr->param.ia_handle = (DAT_IA_HANDLE) ia;
-    lmr->param.mem_type = mem_type;
-    lmr->param.region_desc = region_desc;
-    lmr->param.length = length;
-    lmr->param.pz_handle = pz_handle;
-    lmr->param.mem_priv = mem_priv;
-    dapl_os_atomic_set (&lmr->lmr_ref_count, 0);
+	/* 
+	 * initialize the body 
+	 */
+	lmr->param.ia_handle = (DAT_IA_HANDLE) ia;
+	lmr->param.mem_type = mem_type;
+	lmr->param.region_desc = region_desc;
+	lmr->param.length = length;
+	lmr->param.pz_handle = pz_handle;
+	lmr->param.mem_priv = mem_priv;
+	dapl_os_atomic_set(&lmr->lmr_ref_count, 0);
 
-    return (lmr);
+	return (lmr);
 }
 
-void 
-dapl_lmr_dealloc (
-    IN DAPL_LMR *lmr)
+void dapl_lmr_dealloc(IN DAPL_LMR * lmr)
 {
-    lmr->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */
-    dapl_ia_unlink_lmr (lmr->header.owner_ia, lmr);
-    dapl_os_lock_destroy (&lmr->header.lock);
-    
-    dapl_os_free ((void *) lmr, sizeof (DAPL_LMR));
+	lmr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
+	dapl_ia_unlink_lmr(lmr->header.owner_ia, lmr);
+	dapl_os_lock_destroy(&lmr->header.lock);
+
+	dapl_os_free((void *)lmr, sizeof(DAPL_LMR));
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_mr_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_mr_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_mr_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,52 +57,50 @@
  */
 
 DAT_VADDR
-dapl_mr_get_address (
-	IN  DAT_REGION_DESCRIPTION   desc, 
-	IN  DAT_MEM_TYPE             type)
+dapl_mr_get_address(IN DAT_REGION_DESCRIPTION desc, IN DAT_MEM_TYPE type)
 {
-    switch (type)
-    {
+	switch (type) {
 	case DAT_MEM_TYPE_VIRTUAL:
-	{
-	    return (DAT_VADDR) (uintptr_t) desc.for_va;
-	}
+		{
+			return (DAT_VADDR) (uintptr_t) desc.for_va;
+		}
 	case DAT_MEM_TYPE_LMR:
-	{
-	    DAPL_LMR 	*lmr;
+		{
+			DAPL_LMR *lmr;
 
-	    lmr = (DAPL_LMR *) desc.for_lmr_handle;
+			lmr = (DAPL_LMR *) desc.for_lmr_handle;
 
-	    /* Since this function is recoursive we cannot inline it */
-	    return dapl_mr_get_address (lmr->param.region_desc, 
-                                   lmr->param.mem_type);
-	}
+			/* Since this function is recoursive we cannot inline it */
+			return dapl_mr_get_address(lmr->param.region_desc,
+						   lmr->param.mem_type);
+		}
 #if defined(__KDAPL__)
 	case DAT_MEM_TYPE_PHYSICAL:
-	{
-	    return desc.for_pa;
-	}
+		{
+			return desc.for_pa;
+		}
 #else
 	case DAT_MEM_TYPE_SHARED_VIRTUAL:
-	{
-	    /* multi-cast necessary to convert a pvoid to a DAT_VADDR on
-	     * all architectures
-	     */
-	    return (DAT_VADDR) (uintptr_t) desc.for_shared_memory.virtual_address;
-	}
-#endif	/* defined(__KDAPL__) */
+		{
+			/* multi-cast necessary to convert a pvoid to a DAT_VADDR on
+			 * all architectures
+			 */
+			return (DAT_VADDR) (uintptr_t) desc.for_shared_memory.
+			    virtual_address;
+		}
+#endif				/* defined(__KDAPL__) */
 	default:
-	{
-	    /*
-	     * The following kDAPL memory types have not been implemented:
-	     *    DAT_MEM_TYPE_PLATFORM
-	     *    DAT_MEM_TYPE_IA
-	     * 	  DAT_MEM_TYPE_BYPASS
-	     */
-	    dapl_os_assert (0);
-	    return 0;
+		{
+			/*
+			 * The following kDAPL memory types have not been implemented:
+			 *    DAT_MEM_TYPE_PLATFORM
+			 *    DAT_MEM_TYPE_IA
+			 *    DAT_MEM_TYPE_BYPASS
+			 */
+			dapl_os_assert(0);
+			return 0;
+		}
 	}
-    }
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_name_service.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_name_service.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_name_service.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -50,13 +50,11 @@
  * Prototypes
  */
 #ifdef IBHOSTS_NAMING
-DAT_RETURN dapli_ns_create_gid_map (void);
+DAT_RETURN dapli_ns_create_gid_map(void);
 
-DAT_RETURN dapli_ns_add_address (
-	IN DAPL_GID_MAP		*gme);
-#endif /* IBHOSTS_NAMING */
+DAT_RETURN dapli_ns_add_address(IN DAPL_GID_MAP * gme);
+#endif				/* IBHOSTS_NAMING */
 
-
 /*
  * dapls_ns_init
  *
@@ -72,32 +70,29 @@
  * 	DAT_SUCCESS
  *	DAT_INVALID_PARAMETER
  */
-DAT_RETURN
-dapls_ns_init (void)
+DAT_RETURN dapls_ns_init(void)
 {
-    DAT_RETURN		dat_status;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 #ifdef IBHOSTS_NAMING
-    dat_status =  dapli_ns_create_gid_map ();
-#endif /* IBHOSTS_NAMING */
+	dat_status = dapli_ns_create_gid_map();
+#endif				/* IBHOSTS_NAMING */
 
-    return dat_status;
+	return dat_status;
 }
 
-
 #ifdef IBHOSTS_NAMING
 
 #define	MAX_GID_ENTRIES		32
-DAPL_GID_MAP	g_gid_map_table[MAX_GID_ENTRIES];
+DAPL_GID_MAP g_gid_map_table[MAX_GID_ENTRIES];
 
 #ifdef _WIN32
 #define MAP_FILE        "c:/WINNT/system32/drivers/etc/ibhosts"
 #else
 #define MAP_FILE	"/etc/dapl/ibhosts"
-#endif  /* !defined WIN32 */
+#endif				/* !defined WIN32 */
 
-
 /*
  * dapli_ns_create_gid_map()
  *
@@ -119,74 +114,66 @@
  * Returns:
  * 	char * to string number
  */
-DAT_RETURN
-dapli_ns_create_gid_map (void)
+DAT_RETURN dapli_ns_create_gid_map(void)
 {
-    FILE		*f;
-    ib_gid_t		gid;
-    char		hostname[128];
-    int			rc;
-    struct addrinfo	*addr;
-    struct sockaddr_in	*si;
-    DAPL_GID_MAP	gmt;
+	FILE *f;
+	ib_gid_t gid;
+	char hostname[128];
+	int rc;
+	struct addrinfo *addr;
+	struct sockaddr_in *si;
+	DAPL_GID_MAP gmt;
 
-    f = fopen (MAP_FILE, "r");
-    if ( f == NULL )
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		      "ERROR: Must have file <%s> for IP/GID mappings\n",
-		       MAP_FILE);
-	return DAT_ERROR (DAT_INTERNAL_ERROR, 0);
-    }
+	f = fopen(MAP_FILE, "r");
+	if (f == NULL) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "ERROR: Must have file <%s> for IP/GID mappings\n",
+			     MAP_FILE);
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
 
-    rc = fscanf ( f, "%s " F64x " " F64x , hostname, &gid.gid_prefix, &gid.guid);
-    while ( rc != EOF )
-    {
-	rc = dapls_osd_getaddrinfo (hostname, &addr);
+	rc = fscanf(f, "%s " F64x " " F64x, hostname, &gid.gid_prefix,
+		    &gid.guid);
+	while (rc != EOF) {
+		rc = dapls_osd_getaddrinfo(hostname, &addr);
 
-	if ( rc != 0 )
-	{
-	    /*
-	     * hostname not registered in DNS, provide a dummy value
-	     */
-	    dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-		  "WARNING: <%s> not registered in DNS, using dummy IP value\n",
-			   hostname);
-	    /*dapl_os_memcpy(hca_ptr->hca_address.sa_data, "0x01020304", 4);*/
-	    gmt.ip_address = 0x01020304;
+		if (rc != 0) {
+			/*
+			 * hostname not registered in DNS, provide a dummy value
+			 */
+			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+				     "WARNING: <%s> not registered in DNS, using dummy IP value\n",
+				     hostname);
+			/*dapl_os_memcpy(hca_ptr->hca_address.sa_data, "0x01020304", 4); */
+			gmt.ip_address = 0x01020304;
+		} else {
+			/*
+			 * Load into the ip/gid mapping table
+			 */
+			si = (struct sockaddr_in *)addr->ai_addr;
+			if (AF_INET == addr->ai_addr->sa_family) {
+				gmt.ip_address = si->sin_addr.s_addr;
+			} else {
+				dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+					     "WARNING: <%s> Address family not supported, using dummy IP value\n",
+					     hostname);
+				gmt.ip_address = 0x01020304;
+			}
+			dapls_osd_freeaddrinfo(addr);
+		}
+		gmt.gid.gid_prefix = gid.gid_prefix;
+		gmt.gid.guid = gid.guid;
+
+		dapli_ns_add_address(&gmt);
+		rc = fscanf(f, "%s " F64x " " F64x, hostname, &gid.gid_prefix,
+			    &gid.guid);
 	}
-	else
-	{
-	    /*
-	     * Load into the ip/gid mapping table
-	     */
-	    si = (struct sockaddr_in *)addr->ai_addr;
-	    if ( AF_INET == addr->ai_addr->sa_family )
-	    {
-		gmt.ip_address = si->sin_addr.s_addr;
-	    }
-	    else
-	    {
-		dapl_dbg_log (DAPL_DBG_TYPE_WARN,
-		     "WARNING: <%s> Address family not supported, using dummy IP value\n",
-		     hostname);
-		gmt.ip_address = 0x01020304;
-	    }
-	    dapls_osd_freeaddrinfo (addr);
-	}
-	gmt.gid.gid_prefix = gid.gid_prefix;
-	gmt.gid.guid       = gid.guid;
 
-	dapli_ns_add_address (&gmt);
-	rc = fscanf ( f, "%s " F64x " " F64x , hostname, &gid.gid_prefix, &gid.guid);
-    }
+	fclose(f);
 
-    fclose (f);
-
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapli_ns_add_address
  *
@@ -204,31 +191,26 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *	DAT_INVALID_PARAMETER
  */
-DAT_RETURN
-dapli_ns_add_address (
-	IN DAPL_GID_MAP		*gme)
+DAT_RETURN dapli_ns_add_address(IN DAPL_GID_MAP * gme)
 {
-    DAPL_GID_MAP	     *gmt;
-    int			     count;
+	DAPL_GID_MAP *gmt;
+	int count;
 
-    gmt = g_gid_map_table;
+	gmt = g_gid_map_table;
 
-    for ( count = 0, gmt = g_gid_map_table; gmt->ip_address; gmt++ )
-    {
-	count++;
-    }
+	for (count = 0, gmt = g_gid_map_table; gmt->ip_address; gmt++) {
+		count++;
+	}
 
-    if ( count > MAX_GID_ENTRIES )
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, 0);
-    }
+	if (count > MAX_GID_ENTRIES) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 0);
+	}
 
-    *gmt = *gme;
+	*gmt = *gme;
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapls_ns_lookup_address
  *
@@ -248,35 +230,31 @@
  *	DAT_INVALID_PARAMETER
  */
 DAT_RETURN
-dapls_ns_lookup_address (
-	IN  DAPL_IA			*ia_ptr,
-	IN  DAT_IA_ADDRESS_PTR		remote_ia_address,
-	OUT ib_gid_t			*gid)
+dapls_ns_lookup_address(IN DAPL_IA * ia_ptr,
+			IN DAT_IA_ADDRESS_PTR remote_ia_address,
+			OUT ib_gid_t * gid)
 {
-    DAPL_GID_MAP	     *gmt;
-    struct sockaddr_in	     *si;
+	DAPL_GID_MAP *gmt;
+	struct sockaddr_in *si;
 
-    ia_ptr = ia_ptr;		/* unused here */
+	ia_ptr = ia_ptr;	/* unused here */
 
-    si = (struct sockaddr_in *)remote_ia_address;
+	si = (struct sockaddr_in *)remote_ia_address;
 
-    for ( gmt = g_gid_map_table; gmt->ip_address; gmt++ )
-    {
-	if (gmt->ip_address == si->sin_addr.s_addr)
-	{
-	    gid->guid = gmt->gid.guid;
-	    gid->gid_prefix = gmt->gid.gid_prefix;
+	for (gmt = g_gid_map_table; gmt->ip_address; gmt++) {
+		if (gmt->ip_address == si->sin_addr.s_addr) {
+			gid->guid = gmt->gid.guid;
+			gid->gid_prefix = gmt->gid.gid_prefix;
 
-	    return DAT_SUCCESS;
+			return DAT_SUCCESS;
+		}
 	}
-    }
 
-    return DAT_ERROR (DAT_INVALID_PARAMETER, 0);
+	return DAT_ERROR(DAT_INVALID_PARAMETER, 0);
 }
 
-#endif /* IBHOSTS_NAMING */
+#endif				/* IBHOSTS_NAMING */
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_provider.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_provider.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_provider.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -37,7 +37,7 @@
 
 #include "dapl_provider.h"
 
-extern DAT_RETURN dapl_not_implemented (void);
+extern DAT_RETURN dapl_not_implemented(void);
 
 /*********************************************************************
  *                                                                   *
@@ -45,203 +45,197 @@
  *                                                                   *
  *********************************************************************/
 
-DAPL_PROVIDER_LIST 		g_dapl_provider_list;
+DAPL_PROVIDER_LIST g_dapl_provider_list;
 
-
 /*
  * the function table for this provider
  */
 
-
 #if defined(__KDAPL__)
-DAT_PROVIDER g_dapl_provider_template =
-{
-    NULL,
-    0,
-    &dapl_ia_open,
-    &dapl_ia_query,
-    &dapl_ia_close,
-    &dapl_ia_memtype_hint,		/* unimplemented */
+DAT_PROVIDER g_dapl_provider_template = {
+	NULL,
+	0,
+	&dapl_ia_open,
+	&dapl_ia_query,
+	&dapl_ia_close,
+	&dapl_ia_memtype_hint,	/* unimplemented */
 
-    &dapl_set_consumer_context,		/* untested */
-    &dapl_get_consumer_context,		/* untested */
-    &dapl_get_handle_type,		/* untested */
+	&dapl_set_consumer_context,	/* untested */
+	&dapl_get_consumer_context,	/* untested */
+	&dapl_get_handle_type,	/* untested */
 
-    &dapl_cr_query,
-    &dapl_cr_accept,
-    &dapl_cr_reject,
-    &dapl_cr_handoff,
+	&dapl_cr_query,
+	&dapl_cr_accept,
+	&dapl_cr_reject,
+	&dapl_cr_handoff,
 
-    &dapl_evd_kcreate,
-    &dapl_evd_kquery,			/* untested */
-    &dapl_evd_modify_upcall,
-    &dapl_evd_resize,			/* unimplemented */
-    &dapl_evd_post_se,			/* untested */
-    &dapl_evd_dequeue,
-    &dapl_evd_free,
+	&dapl_evd_kcreate,
+	&dapl_evd_kquery,	/* untested */
+	&dapl_evd_modify_upcall,
+	&dapl_evd_resize,	/* unimplemented */
+	&dapl_evd_post_se,	/* untested */
+	&dapl_evd_dequeue,
+	&dapl_evd_free,
 
-    &dapl_ep_create,
-    &dapl_ep_query,
-    &dapl_ep_modify,			/* untested */
-    &dapl_ep_connect,
-    &dapl_ep_dup_connect,		/* untested */
-    &dapl_ep_disconnect,
-    &dapl_ep_post_send,
-    &dapl_ep_post_recv,
-    &dapl_ep_post_rdma_read,
-    &dapl_ep_post_rdma_write,
-    &dapl_ep_get_status,
-    &dapl_ep_free,
+	&dapl_ep_create,
+	&dapl_ep_query,
+	&dapl_ep_modify,	/* untested */
+	&dapl_ep_connect,
+	&dapl_ep_dup_connect,	/* untested */
+	&dapl_ep_disconnect,
+	&dapl_ep_post_send,
+	&dapl_ep_post_recv,
+	&dapl_ep_post_rdma_read,
+	&dapl_ep_post_rdma_write,
+	&dapl_ep_get_status,
+	&dapl_ep_free,
 
-    &dapl_lmr_kcreate,
-    &dapl_lmr_query,
-    &dapl_lmr_free,
+	&dapl_lmr_kcreate,
+	&dapl_lmr_query,
+	&dapl_lmr_free,
 
-    &dapl_rmr_create,
-    &dapl_rmr_query,			/* untested */
-    &dapl_rmr_bind,
-    &dapl_rmr_free,
+	&dapl_rmr_create,
+	&dapl_rmr_query,	/* untested */
+	&dapl_rmr_bind,
+	&dapl_rmr_free,
 
-    &dapl_psp_create,
-    &dapl_psp_query,			/* untested */
-    &dapl_psp_free,
+	&dapl_psp_create,
+	&dapl_psp_query,	/* untested */
+	&dapl_psp_free,
 
-    &dapl_rsp_create,
-    &dapl_rsp_query,			/* untested */
-    &dapl_rsp_free,
+	&dapl_rsp_create,
+	&dapl_rsp_query,	/* untested */
+	&dapl_rsp_free,
 
-    &dapl_pz_create,
-    &dapl_pz_query,			/* untested */
-    &dapl_pz_free,
+	&dapl_pz_create,
+	&dapl_pz_query,		/* untested */
+	&dapl_pz_free,
 
-    /* dat-1.1 */
-    &dapl_psp_create_any,
-    &dapl_ep_reset,
+	/* dat-1.1 */
+	&dapl_psp_create_any,
+	&dapl_ep_reset,
 
-    /* dat-1.2 */
-    &dapl_lmr_sync_rdma_read,
-    &dapl_lmr_sync_rdma_write,
+	/* dat-1.2 */
+	&dapl_lmr_sync_rdma_read,
+	&dapl_lmr_sync_rdma_write,
 
-    &dapl_ep_create_with_srq,
-    &dapl_ep_recv_query,
-    &dapl_ep_set_watermark, 
-    &dapl_srq_create,
-    &dapl_srq_free,
-    &dapl_srq_post_recv,
-    &dapl_srq_query,
-    &dapl_srq_resize,
-    &dapl_srq_set_lw
+	&dapl_ep_create_with_srq,
+	&dapl_ep_recv_query,
+	&dapl_ep_set_watermark,
+	&dapl_srq_create,
+	&dapl_srq_free,
+	&dapl_srq_post_recv,
+	&dapl_srq_query,
+	&dapl_srq_resize,
+	&dapl_srq_set_lw
 };
 #else
 /*
  * uDAPL version of the provider jump table
  */
-DAT_PROVIDER g_dapl_provider_template =
-{
-    NULL,
-    0,
-    &dapl_ia_open,
-    &dapl_ia_query,
-    &dapl_ia_close,
+DAT_PROVIDER g_dapl_provider_template = {
+	NULL,
+	0,
+	&dapl_ia_open,
+	&dapl_ia_query,
+	&dapl_ia_close,
 
-    &dapl_set_consumer_context,
-    &dapl_get_consumer_context,
-    &dapl_get_handle_type,
+	&dapl_set_consumer_context,
+	&dapl_get_consumer_context,
+	&dapl_get_handle_type,
 
-    &dapl_cno_create,
-    &dapl_cno_modify_agent,
-    &dapl_cno_query,
-    &dapl_cno_free,
-    &dapl_cno_wait,
+	&dapl_cno_create,
+	&dapl_cno_modify_agent,
+	&dapl_cno_query,
+	&dapl_cno_free,
+	&dapl_cno_wait,
 
-    &dapl_cr_query,
-    &dapl_cr_accept,
-    &dapl_cr_reject,
-    &dapl_cr_handoff,
+	&dapl_cr_query,
+	&dapl_cr_accept,
+	&dapl_cr_reject,
+	&dapl_cr_handoff,
 
-    &dapl_evd_create,
-    &dapl_evd_query,
-    &dapl_evd_modify_cno,
-    &dapl_evd_enable,
-    &dapl_evd_disable,
-    &dapl_evd_wait,
-    &dapl_evd_resize,
-    &dapl_evd_post_se,
-    &dapl_evd_dequeue,
-    &dapl_evd_free,
+	&dapl_evd_create,
+	&dapl_evd_query,
+	&dapl_evd_modify_cno,
+	&dapl_evd_enable,
+	&dapl_evd_disable,
+	&dapl_evd_wait,
+	&dapl_evd_resize,
+	&dapl_evd_post_se,
+	&dapl_evd_dequeue,
+	&dapl_evd_free,
 
-    &dapl_ep_create,
-    &dapl_ep_query,
-    &dapl_ep_modify,
-    &dapl_ep_connect,
-    &dapl_ep_dup_connect,
-    &dapl_ep_disconnect,
-    &dapl_ep_post_send,
-    &dapl_ep_post_recv,
-    &dapl_ep_post_rdma_read,
-    &dapl_ep_post_rdma_write,
-    &dapl_ep_get_status,
-    &dapl_ep_free,
+	&dapl_ep_create,
+	&dapl_ep_query,
+	&dapl_ep_modify,
+	&dapl_ep_connect,
+	&dapl_ep_dup_connect,
+	&dapl_ep_disconnect,
+	&dapl_ep_post_send,
+	&dapl_ep_post_recv,
+	&dapl_ep_post_rdma_read,
+	&dapl_ep_post_rdma_write,
+	&dapl_ep_get_status,
+	&dapl_ep_free,
 
-    &dapl_lmr_create,
-    &dapl_lmr_query,
-    &dapl_lmr_free,
+	&dapl_lmr_create,
+	&dapl_lmr_query,
+	&dapl_lmr_free,
 
-    &dapl_rmr_create,
-    &dapl_rmr_query,
-    &dapl_rmr_bind,
-    &dapl_rmr_free,
+	&dapl_rmr_create,
+	&dapl_rmr_query,
+	&dapl_rmr_bind,
+	&dapl_rmr_free,
 
-    &dapl_psp_create,
-    &dapl_psp_query,
-    &dapl_psp_free,
+	&dapl_psp_create,
+	&dapl_psp_query,
+	&dapl_psp_free,
 
-    &dapl_rsp_create,
-    &dapl_rsp_query,
-    &dapl_rsp_free,
+	&dapl_rsp_create,
+	&dapl_rsp_query,
+	&dapl_rsp_free,
 
-    &dapl_pz_create,
-    &dapl_pz_query,
-    &dapl_pz_free,
+	&dapl_pz_create,
+	&dapl_pz_query,
+	&dapl_pz_free,
 
-    &dapl_psp_create_any,
-    &dapl_ep_reset,
-    &dapl_evd_set_unwaitable,
-    &dapl_evd_clear_unwaitable,
+	&dapl_psp_create_any,
+	&dapl_ep_reset,
+	&dapl_evd_set_unwaitable,
+	&dapl_evd_clear_unwaitable,
 
-    /* dat-1.2 */
-    &dapl_lmr_sync_rdma_read,
-    &dapl_lmr_sync_rdma_write,
+	/* dat-1.2 */
+	&dapl_lmr_sync_rdma_read,
+	&dapl_lmr_sync_rdma_write,
 
-    &dapl_ep_create_with_srq,
-    &dapl_ep_recv_query,
-    &dapl_ep_set_watermark, 
-    &dapl_srq_create,
-    &dapl_srq_free,
-    &dapl_srq_post_recv,
-    &dapl_srq_query,
-    &dapl_srq_resize,
-    &dapl_srq_set_lw,
+	&dapl_ep_create_with_srq,
+	&dapl_ep_recv_query,
+	&dapl_ep_set_watermark,
+	&dapl_srq_create,
+	&dapl_srq_free,
+	&dapl_srq_post_recv,
+	&dapl_srq_query,
+	&dapl_srq_resize,
+	&dapl_srq_set_lw,
 
-    /* dat-2.0 */
-    &dapl_csp_create,
-    &dapl_csp_query,
-    &dapl_csp_free,
-    &dapl_ep_common_connect,
-    &dapl_rmr_create_for_ep,
-    &dapl_ep_post_send_with_invalidate,
-    &dapl_ep_post_rdma_read_to_rmr,
-    &dapl_cno_fd_create,
-    &dapl_cno_trigger,
-    &dapl_ia_ha
-
+	/* dat-2.0 */
+	&dapl_csp_create,
+	&dapl_csp_query,
+	&dapl_csp_free,
+	&dapl_ep_common_connect,
+	&dapl_rmr_create_for_ep,
+	&dapl_ep_post_send_with_invalidate,
+	&dapl_ep_post_rdma_read_to_rmr,
+	&dapl_cno_fd_create,
+	&dapl_cno_trigger,
+	&dapl_ia_ha
 #ifdef DAT_EXTENSIONS
-    ,&dapl_extensions
+	    , &dapl_extensions
 #endif
 };
-#endif /* __KDAPL__ */
+#endif				/* __KDAPL__ */
 
-
 /*********************************************************************
  *                                                                   *
  * Function Prototypes                                               *
@@ -249,242 +243,207 @@
  *********************************************************************/
 
 static DAT_BOOLEAN
-dapl_provider_list_key_cmp (
-    const char *name_a,
-    const char *name_b );
+dapl_provider_list_key_cmp(const char *name_a, const char *name_b);
 
-
 /*********************************************************************
  *                                                                   *
  * Function Definitions                                              *
  *                                                                   *
  *********************************************************************/
 
-DAT_RETURN
-dapl_provider_list_create ( void )
+DAT_RETURN dapl_provider_list_create(void)
 {
-    DAT_RETURN status;
+	DAT_RETURN status;
 
-    status = DAT_SUCCESS;
+	status = DAT_SUCCESS;
 
-    /* create the head node */
-    g_dapl_provider_list.head = dapl_os_alloc (sizeof (DAPL_PROVIDER_LIST_NODE));
-    if ( NULL == g_dapl_provider_list.head )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* create the head node */
+	g_dapl_provider_list.head =
+	    dapl_os_alloc(sizeof(DAPL_PROVIDER_LIST_NODE));
+	if (NULL == g_dapl_provider_list.head) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dapl_os_memzero (g_dapl_provider_list.head, sizeof (DAPL_PROVIDER_LIST_NODE));
+	dapl_os_memzero(g_dapl_provider_list.head,
+			sizeof(DAPL_PROVIDER_LIST_NODE));
 
-    /* create the tail node */
-    g_dapl_provider_list.tail = dapl_os_alloc (sizeof (DAPL_PROVIDER_LIST_NODE));
-    if ( NULL == g_dapl_provider_list.tail )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* create the tail node */
+	g_dapl_provider_list.tail =
+	    dapl_os_alloc(sizeof(DAPL_PROVIDER_LIST_NODE));
+	if (NULL == g_dapl_provider_list.tail) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dapl_os_memzero (g_dapl_provider_list.tail, sizeof (DAPL_PROVIDER_LIST_NODE));
+	dapl_os_memzero(g_dapl_provider_list.tail,
+			sizeof(DAPL_PROVIDER_LIST_NODE));
 
-    g_dapl_provider_list.head->next = g_dapl_provider_list.tail;
-    g_dapl_provider_list.tail->prev = g_dapl_provider_list.head;
-    g_dapl_provider_list.size = 0;
+	g_dapl_provider_list.head->next = g_dapl_provider_list.tail;
+	g_dapl_provider_list.tail->prev = g_dapl_provider_list.head;
+	g_dapl_provider_list.size = 0;
 
-bail:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != g_dapl_provider_list.head )
-	{
-	    dapl_os_free (g_dapl_provider_list.head, sizeof (DAPL_PROVIDER_LIST_NODE));
-	}
+      bail:
+	if (DAT_SUCCESS != status) {
+		if (NULL != g_dapl_provider_list.head) {
+			dapl_os_free(g_dapl_provider_list.head,
+				     sizeof(DAPL_PROVIDER_LIST_NODE));
+		}
 
-	if ( NULL != g_dapl_provider_list.tail )
-	{
-	    dapl_os_free (g_dapl_provider_list.tail, sizeof (DAPL_PROVIDER_LIST_NODE));
+		if (NULL != g_dapl_provider_list.tail) {
+			dapl_os_free(g_dapl_provider_list.tail,
+				     sizeof(DAPL_PROVIDER_LIST_NODE));
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
-DAT_RETURN
-dapl_provider_list_destroy ( void )
+DAT_RETURN dapl_provider_list_destroy(void)
 {
-    DAPL_PROVIDER_LIST_NODE *cur_node;
+	DAPL_PROVIDER_LIST_NODE *cur_node;
 
-    while ( NULL != g_dapl_provider_list.head )
-    {
-	cur_node = g_dapl_provider_list.head;
-	g_dapl_provider_list.head = cur_node->next;
+	while (NULL != g_dapl_provider_list.head) {
+		cur_node = g_dapl_provider_list.head;
+		g_dapl_provider_list.head = cur_node->next;
 
-	dapl_os_free (cur_node, sizeof (DAPL_PROVIDER_LIST_NODE));
-    }
+		dapl_os_free(cur_node, sizeof(DAPL_PROVIDER_LIST_NODE));
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
-DAT_COUNT
-dapl_provider_list_size ( void )
+DAT_COUNT dapl_provider_list_size(void)
 {
-    return g_dapl_provider_list.size;
+	return g_dapl_provider_list.size;
 }
 
-
 DAT_RETURN
-dapl_provider_list_insert (
-    IN  const char *name,
-    IN  DAT_PROVIDER **p_data )
+dapl_provider_list_insert(IN const char *name, IN DAT_PROVIDER ** p_data)
 {
-    DAPL_PROVIDER_LIST_NODE *cur_node, *prev_node, *next_node;
-    DAT_RETURN status;
-    unsigned int len;
+	DAPL_PROVIDER_LIST_NODE *cur_node, *prev_node, *next_node;
+	DAT_RETURN status;
+	unsigned int len;
 
-    status = DAT_SUCCESS;
+	status = DAT_SUCCESS;
 
-    cur_node = dapl_os_alloc (sizeof (DAPL_PROVIDER_LIST_NODE));
+	cur_node = dapl_os_alloc(sizeof(DAPL_PROVIDER_LIST_NODE));
 
-    if ( NULL == cur_node )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == cur_node) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    len = dapl_os_strlen (name);
+	len = dapl_os_strlen(name);
 
-    if ( DAT_NAME_MAX_LENGTH <= len )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (DAT_NAME_MAX_LENGTH <= len) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /* insert node at end of list to preserve registration order*/
-    prev_node = g_dapl_provider_list.tail->prev;
-    next_node = g_dapl_provider_list.tail;
+	/* insert node at end of list to preserve registration order */
+	prev_node = g_dapl_provider_list.tail->prev;
+	next_node = g_dapl_provider_list.tail;
 
-    dapl_os_memcpy (cur_node->name, name, len);
-    cur_node->name[len] = '\0';
-    cur_node->data = g_dapl_provider_template;
-    cur_node->data.device_name = cur_node->name;
+	dapl_os_memcpy(cur_node->name, name, len);
+	cur_node->name[len] = '\0';
+	cur_node->data = g_dapl_provider_template;
+	cur_node->data.device_name = cur_node->name;
 
-    cur_node->next = next_node;
-    cur_node->prev = prev_node;
+	cur_node->next = next_node;
+	cur_node->prev = prev_node;
 
-    prev_node->next = cur_node;
-    next_node->prev = cur_node;
+	prev_node->next = cur_node;
+	next_node->prev = cur_node;
 
-    g_dapl_provider_list.size++;
+	g_dapl_provider_list.size++;
 
-    if ( NULL != p_data )
-    {
-	*p_data = &cur_node->data;
-    }
+	if (NULL != p_data) {
+		*p_data = &cur_node->data;
+	}
 
-bail:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != cur_node )
-	{
-	    dapl_os_free (cur_node, sizeof (DAPL_PROVIDER_LIST_NODE));
+      bail:
+	if (DAT_SUCCESS != status) {
+		if (NULL != cur_node) {
+			dapl_os_free(cur_node, sizeof(DAPL_PROVIDER_LIST_NODE));
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
 DAT_RETURN
-dapl_provider_list_search (
-    IN  const char *name,
-    OUT DAT_PROVIDER **p_data )
+dapl_provider_list_search(IN const char *name, OUT DAT_PROVIDER ** p_data)
 {
-    DAPL_PROVIDER_LIST_NODE *cur_node;
-    DAT_RETURN status;
+	DAPL_PROVIDER_LIST_NODE *cur_node;
+	DAT_RETURN status;
 
-    status = DAT_ERROR (DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
+	status = DAT_ERROR(DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
 
-    for (cur_node = g_dapl_provider_list.head->next;
-	 g_dapl_provider_list.tail != cur_node;
-	 cur_node = cur_node->next)
-    {
-	if ( dapl_provider_list_key_cmp (cur_node->name, name) )
-	{
-	    if ( NULL != p_data )
-	    {
-		*p_data = &cur_node->data;
-	    }
+	for (cur_node = g_dapl_provider_list.head->next;
+	     g_dapl_provider_list.tail != cur_node; cur_node = cur_node->next) {
+		if (dapl_provider_list_key_cmp(cur_node->name, name)) {
+			if (NULL != p_data) {
+				*p_data = &cur_node->data;
+			}
 
-	    status = DAT_SUCCESS;
-	    goto bail;
+			status = DAT_SUCCESS;
+			goto bail;
+		}
 	}
-    }
 
-bail:
-    return status;
+      bail:
+	return status;
 }
 
-
-DAT_RETURN
-dapl_provider_list_remove (
-    IN  const char *name )
+DAT_RETURN dapl_provider_list_remove(IN const char *name)
 {
-    DAPL_PROVIDER_LIST_NODE *cur_node, *prev_node, *next_node;
-    DAT_RETURN status;
+	DAPL_PROVIDER_LIST_NODE *cur_node, *prev_node, *next_node;
+	DAT_RETURN status;
 
-    status = DAT_ERROR (DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
+	status = DAT_ERROR(DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
 
-    for (cur_node = g_dapl_provider_list.head->next;
-	 g_dapl_provider_list.tail != cur_node;
-	 cur_node = cur_node->next)
-    {
-	if ( dapl_provider_list_key_cmp (cur_node->name, name) )
-	{
-	    prev_node = cur_node->prev;
-	    next_node = cur_node->next;
+	for (cur_node = g_dapl_provider_list.head->next;
+	     g_dapl_provider_list.tail != cur_node; cur_node = cur_node->next) {
+		if (dapl_provider_list_key_cmp(cur_node->name, name)) {
+			prev_node = cur_node->prev;
+			next_node = cur_node->next;
 
-	    prev_node->next = next_node;
-	    next_node->prev = prev_node;
+			prev_node->next = next_node;
+			next_node->prev = prev_node;
 
-	    dapl_os_free (cur_node, sizeof (DAPL_PROVIDER_LIST_NODE));
+			dapl_os_free(cur_node, sizeof(DAPL_PROVIDER_LIST_NODE));
 
-	    g_dapl_provider_list.size--;
+			g_dapl_provider_list.size--;
 
-	    status = DAT_SUCCESS;
-	    goto bail;
+			status = DAT_SUCCESS;
+			goto bail;
+		}
 	}
-    }
 
-bail:
-    return status;
+      bail:
+	return status;
 }
 
-
-DAT_BOOLEAN
-dapl_provider_list_key_cmp (
-    const char *name_a,
-    const char *name_b )
+DAT_BOOLEAN dapl_provider_list_key_cmp(const char *name_a, const char *name_b)
 {
-    unsigned int len;
+	unsigned int len;
 
-    len = dapl_os_strlen (name_a);
+	len = dapl_os_strlen(name_a);
 
-    if ( dapl_os_strlen (name_b) != len )
-    {
-	return DAT_FALSE;
-    }
-    else if ( dapl_os_memcmp (name_a, name_b, len) )
-    {
-	return DAT_FALSE;
-    }
-    else
-    {
-	return DAT_TRUE;
-    }
+	if (dapl_os_strlen(name_b) != len) {
+		return DAT_FALSE;
+	} else if (dapl_os_memcmp(name_a, name_b, len)) {
+		return DAT_FALSE;
+	} else {
+		return DAT_TRUE;
+	}
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -68,139 +68,131 @@
  * 	DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_psp_create (
-	IN	DAT_IA_HANDLE	   ia_handle,
-	IN	DAT_CONN_QUAL	   conn_qual,
-	IN	DAT_EVD_HANDLE	   evd_handle,
-	IN	DAT_PSP_FLAGS	   psp_flags,
-	OUT	DAT_PSP_HANDLE	   *psp_handle )
+dapl_psp_create(IN DAT_IA_HANDLE ia_handle,
+		IN DAT_CONN_QUAL conn_qual,
+		IN DAT_EVD_HANDLE evd_handle,
+		IN DAT_PSP_FLAGS psp_flags, OUT DAT_PSP_HANDLE * psp_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SP		*sp_ptr;
-    DAPL_EVD		*evd_ptr;
-    DAT_BOOLEAN		sp_found;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_SP *sp_ptr;
+	DAPL_EVD *evd_ptr;
+	DAT_BOOLEAN sp_found;
+	DAT_RETURN dat_status;
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    dat_status = DAT_SUCCESS;
+	ia_ptr = (DAPL_IA *) ia_handle;
+	dat_status = DAT_SUCCESS;
 
-    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_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EVD_CR);
-	goto bail;
-    }
+	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_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CR);
+		goto bail;
+	}
 
-    if ( psp_handle == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG5);
-	goto bail;
-    }
+	if (psp_handle == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
+		goto bail;
+	}
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    if ( ! (evd_ptr->evd_flags & DAT_EVD_CR_FLAG) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EVD_CR);
-	goto bail;
-    }
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	if (!(evd_ptr->evd_flags & DAT_EVD_CR_FLAG)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CR);
+		goto bail;
+	}
 
-    if (psp_flags != DAT_PSP_CONSUMER_FLAG &&
-	psp_flags != DAT_PSP_PROVIDER_FLAG)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG4);
-	goto bail;
-    }
-	
+	if (psp_flags != DAT_PSP_CONSUMER_FLAG &&
+	    psp_flags != DAT_PSP_PROVIDER_FLAG) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
 
-    /*
-     * See if we have a quiescent listener to use for this PSP, else
-     * create one and set it listening
-     */
-    sp_ptr = dapls_ia_sp_search (ia_ptr, conn_qual, DAT_TRUE);
-    sp_found = DAT_TRUE;
-    if (sp_ptr == NULL)
-    {
-	/* Allocate PSP */
-	sp_found = DAT_FALSE;
-	sp_ptr   = dapls_sp_alloc ( ia_ptr, DAT_TRUE );
-	if ( sp_ptr == NULL )
-	{
-	    dat_status = 
-		DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	    goto bail;
+	DAPL_CNTR(ia_ptr, DCNT_IA_PSP_CREATE);
+
+	/*
+	 * See if we have a quiescent listener to use for this PSP, else
+	 * create one and set it listening
+	 */
+	sp_ptr = dapls_ia_sp_search(ia_ptr, conn_qual, DAT_TRUE);
+	sp_found = DAT_TRUE;
+	if (sp_ptr == NULL) {
+		/* Allocate PSP */
+		sp_found = DAT_FALSE;
+		sp_ptr = dapls_sp_alloc(ia_ptr, DAT_TRUE);
+		if (sp_ptr == NULL) {
+			dat_status =
+			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				      DAT_RESOURCE_MEMORY);
+			goto bail;
+		}
+	} else if (sp_ptr->listening == DAT_TRUE) {
+		dat_status = DAT_ERROR(DAT_CONN_QUAL_IN_USE, 0);
+		goto bail;
 	}
-    }
-    else if (sp_ptr->listening == DAT_TRUE)
-    {
-	dat_status = DAT_ERROR (DAT_CONN_QUAL_IN_USE, 0);
-	goto bail;
-    }
 
-    /*
-     * Fill out the args for a PSP
-     */
-    sp_ptr->conn_qual  = conn_qual;
-    sp_ptr->evd_handle = evd_handle;
-    sp_ptr->psp_flags  = psp_flags;
-    sp_ptr->ep_handle  = NULL;
+	/*
+	 * Fill out the args for a PSP
+	 */
+	sp_ptr->conn_qual = conn_qual;
+	sp_ptr->evd_handle = evd_handle;
+	sp_ptr->psp_flags = psp_flags;
+	sp_ptr->ep_handle = NULL;
 
-    /*
-     * Take a reference on the EVD handle
-     */
-    dapl_os_atomic_inc (& ((DAPL_EVD *)evd_handle)->evd_ref_count);
+	/*
+	 * Take a reference on the EVD handle
+	 */
+	dapl_os_atomic_inc(&((DAPL_EVD *) evd_handle)->evd_ref_count);
 
-    /* 
-     * Set up a listener for a connection. Connections can arrive
-     * even before this call returns!
-     */
-    sp_ptr->state     = DAPL_SP_STATE_PSP_LISTENING;
-    sp_ptr->listening = DAT_TRUE;
+	/* 
+	 * Set up a listener for a connection. Connections can arrive
+	 * even before this call returns!
+	 */
+	sp_ptr->state = DAPL_SP_STATE_PSP_LISTENING;
+	sp_ptr->listening = DAT_TRUE;
 
-    /*
-     * If this is a new sp we need to add it to the IA queue, and set up
-     * a conn_listener.
-     */
-    if (sp_found == DAT_FALSE)
-    {
-	/* Link it onto the IA before enabling it to receive conn
-	 * requests
+	/*
+	 * If this is a new sp we need to add it to the IA queue, and set up
+	 * a conn_listener.
 	 */
-	dapl_ia_link_psp (ia_ptr, sp_ptr);
+	if (sp_found == DAT_FALSE) {
+		/* Link it onto the IA before enabling it to receive conn
+		 * requests
+		 */
+		dapl_ia_link_psp(ia_ptr, sp_ptr);
 
-	dat_status = dapls_ib_setup_conn_listener ( ia_ptr,
-						    conn_qual, 
-						    sp_ptr );
+		dat_status = dapls_ib_setup_conn_listener(ia_ptr,
+							  conn_qual, sp_ptr);
 
-	if ( dat_status != DAT_SUCCESS )
-	{
-	    /*
-	     * Have a problem setting up the connection, something
-	     * wrong!  Decrements the EVD refcount & release it.
-	     */
-	    dapl_os_atomic_dec (& ((DAPL_EVD *)evd_handle)->evd_ref_count);
-	    sp_ptr->evd_handle = NULL;
-	    dapls_ia_unlink_sp ( ia_ptr, sp_ptr );
-	    dapls_sp_free_sp ( sp_ptr );
+		if (dat_status != DAT_SUCCESS) {
+			/*
+			 * Have a problem setting up the connection, something
+			 * wrong!  Decrements the EVD refcount & release it.
+			 */
+			dapl_os_atomic_dec(&((DAPL_EVD *) evd_handle)->
+					   evd_ref_count);
+			sp_ptr->evd_handle = NULL;
+			dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+			dapls_sp_free_sp(sp_ptr);
 
-	    dapl_dbg_log (DAPL_DBG_TYPE_CM, 
-		      "--> dapl_psp_create setup_conn_listener failed: %x\n", 
-		      dat_status);
+			dapl_dbg_log(DAPL_DBG_TYPE_CM,
+				     "--> dapl_psp_create setup_conn_listener failed: %x\n",
+				     dat_status);
 
-	    goto bail;
+			goto bail;
+		}
 	}
-    }
 
-    /*
-     * Return handle to the user
-     */
-    *psp_handle = (DAT_PSP_HANDLE)sp_ptr;
+	/*
+	 * Return handle to the user
+	 */
+	*psp_handle = (DAT_PSP_HANDLE) sp_ptr;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create_any.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create_any.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_create_any.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -71,143 +71,138 @@
  * 	DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_psp_create_any (
-	IN	DAT_IA_HANDLE	   ia_handle,
-	OUT	DAT_CONN_QUAL	   *conn_qual,
-	IN	DAT_EVD_HANDLE	   evd_handle,
-	IN	DAT_PSP_FLAGS	   psp_flags,
-	OUT	DAT_PSP_HANDLE	   *psp_handle )
+dapl_psp_create_any(IN DAT_IA_HANDLE ia_handle,
+		    OUT DAT_CONN_QUAL * conn_qual,
+		    IN DAT_EVD_HANDLE evd_handle,
+		    IN DAT_PSP_FLAGS psp_flags, OUT DAT_PSP_HANDLE * psp_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SP		*sp_ptr;
-    DAPL_EVD		*evd_ptr;
-    DAT_RETURN		dat_status;
-    static DAT_CONN_QUAL hint_conn_qual = 1024;	/* seed value */
-    DAT_CONN_QUAL	lcl_conn_qual;
-    DAT_CONN_QUAL	limit_conn_qual;
+	DAPL_IA *ia_ptr;
+	DAPL_SP *sp_ptr;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
+	static DAT_CONN_QUAL hint_conn_qual = 1024;	/* seed value */
+	DAT_CONN_QUAL lcl_conn_qual;
+	DAT_CONN_QUAL limit_conn_qual;
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    dat_status = DAT_SUCCESS;
+	ia_ptr = (DAPL_IA *) ia_handle;
+	dat_status = DAT_SUCCESS;
 
-    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_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EVD_CR);
-	goto bail;
-    }
+	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_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CR);
+		goto bail;
+	}
 
-    if ( psp_handle == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG5);
-	goto bail;
-    }
-    if (conn_qual == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	if (psp_handle == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
+		goto bail;
+	}
+	if (conn_qual == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    if ( ! (evd_ptr->evd_flags & DAT_EVD_CR_FLAG) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EVD_CR);
-	goto bail;
-    }
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	if (!(evd_ptr->evd_flags & DAT_EVD_CR_FLAG)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CR);
+		goto bail;
+	}
 
-    if (psp_flags != DAT_PSP_CONSUMER_FLAG &&
-	psp_flags != DAT_PSP_PROVIDER_FLAG)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG4);
-	goto bail;
-    }
-	
-    /* Allocate PSP */
-    sp_ptr = dapls_sp_alloc ( ia_ptr, DAT_TRUE );
-    if ( sp_ptr == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (psp_flags != DAT_PSP_CONSUMER_FLAG &&
+	    psp_flags != DAT_PSP_PROVIDER_FLAG) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
 
-    /*
-     * Fill out the args for a PSP
-     */
-    sp_ptr->evd_handle = evd_handle;
-    sp_ptr->psp_flags  = psp_flags;
-    sp_ptr->ep_handle  = NULL;
+	/* Allocate PSP */
+	sp_ptr = dapls_sp_alloc(ia_ptr, DAT_TRUE);
+	if (sp_ptr == NULL) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /*
-     * Take a reference on the EVD handle
-     */
-    dapl_os_atomic_inc (& ((DAPL_EVD *)evd_handle)->evd_ref_count);
+	DAPL_CNTR(ia_ptr, DCNT_IA_PSP_CREATE_ANY);
 
-    /* Link it onto the IA */
-    dapl_ia_link_psp (ia_ptr, sp_ptr);
+	/*
+	 * Fill out the args for a PSP
+	 */
+	sp_ptr->evd_handle = evd_handle;
+	sp_ptr->psp_flags = psp_flags;
+	sp_ptr->ep_handle = NULL;
 
-    /* 
-     * Set up a listener for a connection. Connections can arrive
-     * even before this call returns!
-     */
-    sp_ptr->state     = DAPL_SP_STATE_PSP_LISTENING;
-    sp_ptr->listening = DAT_TRUE;
+	/*
+	 * Take a reference on the EVD handle
+	 */
+	dapl_os_atomic_inc(&((DAPL_EVD *) evd_handle)->evd_ref_count);
 
-    limit_conn_qual = 0;
-    lcl_conn_qual   = hint_conn_qual;
-    dat_status      = ~DAT_SUCCESS;
+	/* Link it onto the IA */
+	dapl_ia_link_psp(ia_ptr, sp_ptr);
 
-    while (dat_status != DAT_SUCCESS)
-    { 
-	dat_status = dapls_ib_setup_conn_listener ( ia_ptr,
-						    lcl_conn_qual, 
-						    sp_ptr );
+	/* 
+	 * Set up a listener for a connection. Connections can arrive
+	 * even before this call returns!
+	 */
+	sp_ptr->state = DAPL_SP_STATE_PSP_LISTENING;
+	sp_ptr->listening = DAT_TRUE;
 
-	lcl_conn_qual++;
+	limit_conn_qual = 0;
+	lcl_conn_qual = hint_conn_qual;
+	dat_status = ~DAT_SUCCESS;
 
-	if ( dat_status == DAT_CONN_QUAL_IN_USE )
-	{
-	    /*
-	     * If we have a big number of tries and we still haven't
-	     * found a service_ID we can use, bail out with an error,
-	     * something is wrong!
-	     */
-	    if ( limit_conn_qual++ > 100000)
-	    {
-		dat_status = DAT_CONN_QUAL_UNAVAILABLE;
-		break;
-	    }
+	while (dat_status != DAT_SUCCESS) {
+		dat_status = dapls_ib_setup_conn_listener(ia_ptr,
+							  lcl_conn_qual,
+							  sp_ptr);
+
+		lcl_conn_qual++;
+
+		if (dat_status == DAT_CONN_QUAL_IN_USE) {
+			/*
+			 * If we have a big number of tries and we still haven't
+			 * found a service_ID we can use, bail out with an error,
+			 * something is wrong!
+			 */
+			if (limit_conn_qual++ > 100000) {
+				dat_status = DAT_CONN_QUAL_UNAVAILABLE;
+				break;
+			}
+		}
 	}
-    }
-    hint_conn_qual = lcl_conn_qual;
+	hint_conn_qual = lcl_conn_qual;
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-	/*
-	 * Have a problem setting up the connection, something wrong!
-	 */
-	dapl_os_atomic_dec (& ((DAPL_EVD *)evd_handle)->evd_ref_count);
-	sp_ptr->evd_handle = NULL;
-	dapls_ia_unlink_sp ( ia_ptr, sp_ptr );
-	dapls_sp_free_sp ( sp_ptr );
+	if (dat_status != DAT_SUCCESS) {
+		/*
+		 * Have a problem setting up the connection, something wrong!
+		 */
+		dapl_os_atomic_dec(&((DAPL_EVD *) evd_handle)->evd_ref_count);
+		sp_ptr->evd_handle = NULL;
+		dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+		dapls_sp_free_sp(sp_ptr);
 
-	dapl_os_printf ("--> dapl_psp_create cannot set up conn listener: %x\n", dat_status);
+		dapl_os_printf
+		    ("--> dapl_psp_create cannot set up conn listener: %x\n",
+		     dat_status);
 
-	goto bail;
-    }
+		goto bail;
+	}
 
-    sp_ptr->conn_qual  = lcl_conn_qual - 1;
+	sp_ptr->conn_qual = lcl_conn_qual - 1;
 
-    /*
-     * Return handle to the user
-     */
-    *conn_qual  = sp_ptr->conn_qual;
-    *psp_handle = (DAT_PSP_HANDLE)sp_ptr;
+	/*
+	 * Return handle to the user
+	 */
+	*conn_qual = sp_ptr->conn_qual;
+	*psp_handle = (DAT_PSP_HANDLE) sp_ptr;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,92 +58,88 @@
  * 	DAT_SUCCESS
  * 	DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API
-dapl_psp_free (
-	IN	DAT_PSP_HANDLE	   psp_handle )
+DAT_RETURN DAT_API dapl_psp_free(IN DAT_PSP_HANDLE psp_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SP		*sp_ptr;
-    DAT_RETURN		dat_status;
-    DAPL_SP_STATE	save_state;
+	DAPL_IA *ia_ptr;
+	DAPL_SP *sp_ptr;
+	DAT_RETURN dat_status;
+	DAPL_SP_STATE save_state;
 
-    sp_ptr = (DAPL_SP *) psp_handle;
-    dat_status = DAT_SUCCESS;
-    /*
-     * Verify handle
-     */
-    dapl_dbg_log (DAPL_DBG_TYPE_CM, ">>> dapl_psp_free %p\n", psp_handle);
+	sp_ptr = (DAPL_SP *) psp_handle;
+	dat_status = DAT_SUCCESS;
+	/*
+	 * Verify handle
+	 */
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, ">>> dapl_psp_free %p\n", psp_handle);
 
-    if ( DAPL_BAD_HANDLE (sp_ptr, DAPL_MAGIC_PSP ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_PSP);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(sp_ptr, DAPL_MAGIC_PSP)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP);
+		goto bail;
+	}
 
-    ia_ptr = sp_ptr->header.owner_ia;
+	ia_ptr = sp_ptr->header.owner_ia;
 
-    /* 
-     * Remove the connection listener if it has been established
-     * and there are no current connections in progress.
-     * If we defer removing the sp it becomes something of a zombie
-     * container until the last connection is disconnected, after
-     * which it will be cleaned up.
-     */
-    dapl_os_lock (&sp_ptr->header.lock);
+	DAPL_CNTR(ia_ptr->header.owner_ia, DCNT_IA_PSP_FREE);
 
-    sp_ptr->listening = DAT_FALSE;
+	/* 
+	 * Remove the connection listener if it has been established
+	 * and there are no current connections in progress.
+	 * If we defer removing the sp it becomes something of a zombie
+	 * container until the last connection is disconnected, after
+	 * which it will be cleaned up.
+	 */
+	dapl_os_lock(&sp_ptr->header.lock);
 
-    /* Release reference on EVD. If an error was encountered in a previous
-     * free the evd_handle will be NULL
-     */
-    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->listening = DAT_FALSE;
 
-    /*
-     * Release the base resource if there are no outstanding
-     * connections; else the last disconnect on this PSP will free it
-     * up. The PSP is used to contain CR records for each connection,
-     * which contain information necessary to disconnect.
-     */
-    dapl_dbg_log (DAPL_DBG_TYPE_CM,
-                  ">>> dapl_psp_free: state %d cr_list_count %d\n",
-                  sp_ptr->state, sp_ptr->cr_list_count );
+	/* Release reference on EVD. If an error was encountered in a previous
+	 * free the evd_handle will be NULL
+	 */
+	if (sp_ptr->evd_handle) {
+		dapl_os_atomic_dec(&((DAPL_EVD *) sp_ptr->evd_handle)->
+				   evd_ref_count);
+		sp_ptr->evd_handle = NULL;
+	}
 
-    if ( (sp_ptr->state == DAPL_SP_STATE_PSP_LISTENING ||
-	  sp_ptr->state == DAPL_SP_STATE_PSP_PENDING) &&
-	 sp_ptr->cr_list_count == 0 )
-    {
-	save_state = sp_ptr->state;
-	sp_ptr->state = DAPL_SP_STATE_FREE;
-	dapl_os_unlock (&sp_ptr->header.lock);
+	/*
+	 * Release the base resource if there are no outstanding
+	 * connections; else the last disconnect on this PSP will free it
+	 * up. The PSP is used to contain CR records for each connection,
+	 * which contain information necessary to disconnect.
+	 */
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     ">>> dapl_psp_free: state %d cr_list_count %d\n",
+		     sp_ptr->state, sp_ptr->cr_list_count);
 
-	dat_status = dapls_ib_remove_conn_listener ( ia_ptr,
-						     sp_ptr );
-	if (dat_status != DAT_SUCCESS)
-	{
-	    /* revert to entry state on error */
-	    sp_ptr->state = save_state;
-	    goto bail;
+	if ((sp_ptr->state == DAPL_SP_STATE_PSP_LISTENING ||
+	     sp_ptr->state == DAPL_SP_STATE_PSP_PENDING) &&
+	    sp_ptr->cr_list_count == 0) {
+		save_state = sp_ptr->state;
+		sp_ptr->state = DAPL_SP_STATE_FREE;
+		dapl_os_unlock(&sp_ptr->header.lock);
+
+		dat_status = dapls_ib_remove_conn_listener(ia_ptr, sp_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			/* revert to entry state on error */
+			sp_ptr->state = save_state;
+			goto bail;
+		}
+		dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+		dapls_sp_free_sp(sp_ptr);
+	} else {
+		/* The PSP is now in the pending state, where it will sit until
+		 * the last connection terminates or the app uses the same
+		 * ServiceID again, which will reactivate it.
+		 */
+		sp_ptr->state = DAPL_SP_STATE_PSP_PENDING;
+		dapl_os_unlock(&sp_ptr->header.lock);
+		dapl_dbg_log(DAPL_DBG_TYPE_CM,
+			     ">>> dapl_psp_free: PSP PENDING\n");
 	}
-	dapls_ia_unlink_sp ( ia_ptr, sp_ptr );
-	dapls_sp_free_sp ( sp_ptr );
-    }
-    else
-    {
-	/* The PSP is now in the pending state, where it will sit until
-	 * the last connection terminates or the app uses the same
-	 * ServiceID again, which will reactivate it.
-	 */
-	sp_ptr->state = DAPL_SP_STATE_PSP_PENDING;
-	dapl_os_unlock (&sp_ptr->header.lock);
-	dapl_dbg_log (DAPL_DBG_TYPE_CM, ">>> dapl_psp_free: PSP PENDING\n");
-    }
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_psp_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,41 +57,39 @@
  *	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_psp_query (
-	IN	DAT_PSP_HANDLE	   	psp_handle,
-	IN	DAT_PSP_PARAM_MASK  	psp_args_mask,
-	OUT	DAT_PSP_PARAM	   	*psp_param )
+dapl_psp_query(IN DAT_PSP_HANDLE psp_handle,
+	       IN DAT_PSP_PARAM_MASK psp_args_mask,
+	       OUT DAT_PSP_PARAM * psp_param)
 {
-    DAPL_SP		*sp_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_SP *sp_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (psp_handle, DAPL_MAGIC_PSP) ||
-	 ((DAPL_SP *)psp_handle)->listening != DAT_TRUE )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_PSP);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(psp_handle, DAPL_MAGIC_PSP) ||
+	    ((DAPL_SP *) psp_handle)->listening != DAT_TRUE) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP);
+		goto bail;
+	}
 
-    if (NULL == psp_param)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (NULL == psp_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    sp_ptr = (DAPL_SP *) psp_handle;
+	sp_ptr = (DAPL_SP *) psp_handle;
 
-    /*
-     * Fill in the PSP params
-     */
-    psp_param->ia_handle   = sp_ptr->header.owner_ia;
-    psp_param->conn_qual   = sp_ptr->conn_qual;
-    psp_param->evd_handle  = sp_ptr->evd_handle;
-    psp_param->psp_flags   = sp_ptr->psp_flags;
+	/*
+	 * Fill in the PSP params
+	 */
+	psp_param->ia_handle = sp_ptr->header.owner_ia;
+	psp_param->conn_qual = sp_ptr->conn_qual;
+	psp_param->evd_handle = sp_ptr->evd_handle;
+	psp_param->psp_flags = sp_ptr->psp_flags;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -56,50 +56,45 @@
  *      DAT_INVLAID_HANDLE
  */
 DAT_RETURN DAT_API
-dapl_pz_create (
-    IN	DAT_IA_HANDLE   ia_handle,
-    OUT	DAT_PZ_HANDLE   *pz_handle)
+dapl_pz_create(IN DAT_IA_HANDLE ia_handle, OUT DAT_PZ_HANDLE * pz_handle)
 {
-    DAPL_IA 		*ia;
-    DAPL_PZ 		*pz;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia;
+	DAPL_PZ *pz;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_pz_create (%p, %p)\n",
-		  ia_handle, 
-		  pz_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_pz_create (%p, %p)\n", ia_handle, pz_handle);
 
-    dat_status = DAT_SUCCESS;
-    if ( DAPL_BAD_HANDLE (ia_handle, DAPL_MAGIC_IA) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
+	dat_status = DAT_SUCCESS;
+	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
 
-    if (NULL == pz_handle)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	if (NULL == pz_handle) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    ia = (DAPL_IA *) ia_handle;
+	ia = (DAPL_IA *) ia_handle;
 
-    pz = dapl_pz_alloc (ia);
-    if ( NULL == pz )
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	pz = dapl_pz_alloc(ia);
+	if (NULL == pz) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
+	DAPL_CNTR(ia, DCNT_IA_PZ_CREATE);
 
-    dat_status = dapls_ib_pd_alloc (ia, pz);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	dapl_pz_dealloc (pz);
-	pz = NULL;
-    }
+	dat_status = dapls_ib_pd_alloc(ia, pz);
+	if (DAT_SUCCESS != dat_status) {
+		dapl_pz_dealloc(pz);
+		pz = NULL;
+	}
 
-    *pz_handle = pz;
+	*pz_handle = pz;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,36 +54,35 @@
  * 	DAT_INVALID_STATE
  * 	DAT_INVALID_HANDLE
  */
-DAT_RETURN DAT_API
-dapl_pz_free (
-    IN	DAT_PZ_HANDLE   pz_handle)
+DAT_RETURN DAT_API dapl_pz_free(IN DAT_PZ_HANDLE pz_handle)
 {
-    DAPL_PZ		*pz;
-    DAT_RETURN		dat_status;
+	DAPL_PZ *pz;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_pz_free (%p)\n", pz_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_pz_free (%p)\n", pz_handle);
 
-    dat_status = DAT_SUCCESS;
-    if ( DAPL_BAD_HANDLE (pz_handle, DAPL_MAGIC_PZ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_PZ);
-	goto bail;
-    }
+	dat_status = DAT_SUCCESS;
+	if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+		goto bail;
+	}
 
-    pz = (DAPL_PZ *) pz_handle;
+	pz = (DAPL_PZ *) pz_handle;
 
-    if ( 0 != dapl_os_atomic_read (&pz->pz_ref_count) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_PZ_IN_USE);
-	goto bail;
-    }
+	DAPL_CNTR(pz->header.owner_ia, DCNT_IA_PZ_FREE);
 
-    dat_status = dapls_ib_pd_free (pz);
-    if ( DAT_SUCCESS == dat_status )
-    {
-	dapl_pz_dealloc (pz);
-    }
+	if (0 != dapl_os_atomic_read(&pz->pz_ref_count)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_PZ_IN_USE);
+		goto bail;
+	}
 
- bail:
-    return dat_status;
+	dat_status = dapls_ib_pd_free(pz);
+	if (DAT_SUCCESS == dat_status) {
+		dapl_pz_dealloc(pz);
+	}
+
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,38 +54,33 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_pz_query (
-    IN	DAT_PZ_HANDLE		pz_handle,
-    IN	DAT_PZ_PARAM_MASK	pz_param_mask,
-    OUT	DAT_PZ_PARAM		*pz_param)
+dapl_pz_query(IN DAT_PZ_HANDLE pz_handle,
+	      IN DAT_PZ_PARAM_MASK pz_param_mask, OUT DAT_PZ_PARAM * pz_param)
 {
-    DAPL_PZ		*pz;
-    DAT_RETURN		dat_status;
+	DAPL_PZ *pz;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_pz_query (%p, %x, %p)\n", 
-		  pz_handle, 
-		  pz_param_mask, 
-		  pz_param);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_pz_query (%p, %x, %p)\n",
+		     pz_handle, pz_param_mask, pz_param);
 
-    if ( DAPL_BAD_HANDLE (pz_handle, DAPL_MAGIC_PZ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_PZ);
-	goto bail;
-    }
-    if (NULL == pz_param)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+		goto bail;
+	}
+	if (NULL == pz_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    dat_status = DAT_SUCCESS;
-    pz = (DAPL_PZ *) pz_handle;
+	dat_status = DAT_SUCCESS;
+	pz = (DAPL_PZ *) pz_handle;
 
-    /* Since the DAT_PZ_ARGS values are easily accessible, */
-    /* don't bother checking the DAT_PZ_ARGS_MASK value    */
-    pz_param->ia_handle = (DAT_IA_HANDLE) pz->header.owner_ia;
+	/* Since the DAT_PZ_ARGS values are easily accessible, */
+	/* don't bother checking the DAT_PZ_ARGS_MASK value    */
+	pz_param->ia_handle = (DAT_IA_HANDLE) pz->header.owner_ia;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_pz_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -52,41 +52,38 @@
  * 	none
  *
  */
-DAPL_PZ *
-dapl_pz_alloc (
-    IN DAPL_IA 		*ia)
+DAPL_PZ *dapl_pz_alloc(IN DAPL_IA * ia)
 {
-    DAPL_PZ *pz;
+	DAPL_PZ *pz;
 
-    /* Allocate PZ */
-    pz = (DAPL_PZ *) dapl_os_alloc (sizeof (DAPL_PZ));
-    if (NULL == pz)
-    {
-	return (NULL);
-    }
+	/* Allocate PZ */
+	pz = (DAPL_PZ *) dapl_os_alloc(sizeof(DAPL_PZ));
+	if (NULL == pz) {
+		return (NULL);
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (pz, sizeof (DAPL_PZ));
+	/* zero the structure */
+	dapl_os_memzero(pz, sizeof(DAPL_PZ));
 
-    /*
-     * initialize the header
-     */
-    pz->header.provider 	   = ia->header.provider;
-    pz->header.magic 		   = DAPL_MAGIC_PZ;
-    pz->header.handle_type 	   = DAT_HANDLE_TYPE_PZ;
-    pz->header.owner_ia 	   = ia;
-    pz->header.user_context.as_64  = 0;
-    pz->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&pz->header.ia_list_entry);
-    dapl_ia_link_pz (ia, pz);
-    dapl_os_lock_init (&pz->header.lock);
+	/*
+	 * initialize the header
+	 */
+	pz->header.provider = ia->header.provider;
+	pz->header.magic = DAPL_MAGIC_PZ;
+	pz->header.handle_type = DAT_HANDLE_TYPE_PZ;
+	pz->header.owner_ia = ia;
+	pz->header.user_context.as_64 = 0;
+	pz->header.user_context.as_ptr = NULL;
+	dapl_llist_init_entry(&pz->header.ia_list_entry);
+	dapl_ia_link_pz(ia, pz);
+	dapl_os_lock_init(&pz->header.lock);
 
-    /* 
-     * initialize the body 
-     */
-    dapl_os_atomic_set (&pz->pz_ref_count, 0);
+	/* 
+	 * initialize the body 
+	 */
+	dapl_os_atomic_set(&pz->pz_ref_count, 0);
 
-    return (pz);
+	return (pz);
 }
 
 /*
@@ -104,13 +101,11 @@
  * 	none
  *
  */
-void
-dapl_pz_dealloc (
-    IN DAPL_PZ *pz)
+void dapl_pz_dealloc(IN DAPL_PZ * pz)
 {
-    pz->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */
-    dapl_ia_unlink_pz (pz->header.owner_ia, pz);
-    dapl_os_lock_destroy (&pz->header.lock);
+	pz->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
+	dapl_ia_unlink_pz(pz->header.owner_ia, pz);
+	dapl_os_lock_destroy(&pz->header.lock);
 
-    dapl_os_free (pz, sizeof (DAPL_PZ));
+	dapl_os_free(pz, sizeof(DAPL_PZ));
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ring_buffer_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ring_buffer_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_ring_buffer_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -37,7 +37,6 @@
 
 #include "dapl_ring_buffer_util.h"
 
-
 /*
  * dapls_rbuf_alloc
  *
@@ -57,42 +56,34 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN
-dapls_rbuf_alloc (
-        INOUT  DAPL_RING_BUFFER		*rbuf,
-	IN     DAT_COUNT		 size )
+DAT_RETURN dapls_rbuf_alloc(INOUT DAPL_RING_BUFFER * rbuf, IN DAT_COUNT size)
 {
-    unsigned int			rsize;	/* real size */
+	unsigned int rsize;	/* real size */
 
-    /* The circular buffer must be allocated one too large.
-     * This eliminates any need for a distinct counter, as
-     * having the two pointers equal always means "empty" -- never "full"
-     */
-    size++;
+	/* The circular buffer must be allocated one too large.
+	 * This eliminates any need for a distinct counter, as
+	 * having the two pointers equal always means "empty" -- never "full"
+	 */
+	size++;
 
-    /* Put size on a power of 2 boundary */
-    rsize = 1;
-    while ( (DAT_COUNT)rsize < size)
-    {
-	rsize <<= 1;
-    }
+	/* Put size on a power of 2 boundary */
+	rsize = 1;
+	while ((DAT_COUNT) rsize < size) {
+		rsize <<= 1;
+	}
 
-    rbuf->base = (void *) dapl_os_alloc (rsize * sizeof (void *));
-    if ( rbuf->base != NULL )
-    {
-	rbuf->lim = rsize - 1;
-	dapl_os_atomic_set (&rbuf->head, 0);
-	dapl_os_atomic_set (&rbuf->tail, 0);
-    }
-    else
-    {
-	return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
-    }
+	rbuf->base = (void *)dapl_os_alloc(rsize * sizeof(void *));
+	if (rbuf->base != NULL) {
+		rbuf->lim = rsize - 1;
+		dapl_os_atomic_set(&rbuf->head, 0);
+		dapl_os_atomic_set(&rbuf->tail, 0);
+	} else {
+		return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapls_rbuf_realloc
  *
@@ -113,52 +104,45 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN
-dapls_rbuf_realloc (
-        INOUT  DAPL_RING_BUFFER		*rbuf,
-	IN     DAT_COUNT		 size )
+DAT_RETURN dapls_rbuf_realloc(INOUT DAPL_RING_BUFFER * rbuf, IN DAT_COUNT size)
 {
-    DAPL_RING_BUFFER	new_rbuf;
-    void 		*entry;
-    DAT_RETURN		dat_status;
+	DAPL_RING_BUFFER new_rbuf;
+	void *entry;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    /* decreasing the size or retaining the old size is not allowed */
-    if (size <= rbuf->lim + 1)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	goto bail;
-    }
+	/* decreasing the size or retaining the old size is not allowed */
+	if (size <= rbuf->lim + 1) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    /*
-     * !This is NOT ATOMIC!
-     * Simple algorithm: Allocate a new ring buffer, take everything
-     * out of the old one and put it in the new one, and release the 
-     * old base buffer.
-     */
-    dat_status = dapls_rbuf_alloc (&new_rbuf, size);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
+	/*
+	 * !This is NOT ATOMIC!
+	 * Simple algorithm: Allocate a new ring buffer, take everything
+	 * out of the old one and put it in the new one, and release the 
+	 * old base buffer.
+	 */
+	dat_status = dapls_rbuf_alloc(&new_rbuf, size);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
 
-    while ( (entry = dapls_rbuf_remove(rbuf)) != NULL)
-    {
-	/* We know entries will fit so ignore the return code */
-	(void)dapls_rbuf_add (&new_rbuf, entry);
-    }
+	while ((entry = dapls_rbuf_remove(rbuf)) != NULL) {
+		/* We know entries will fit so ignore the return code */
+		(void)dapls_rbuf_add(&new_rbuf, entry);
+	}
 
-    /* release the old base buffer */
-    dapl_os_free (rbuf->base, (rbuf->lim + 1) * sizeof (void *));
+	/* release the old base buffer */
+	dapl_os_free(rbuf->base, (rbuf->lim + 1) * sizeof(void *));
 
-    *rbuf = new_rbuf;
- 
- bail:
-    return dat_status;
+	*rbuf = new_rbuf;
+
+      bail:
+	return dat_status;
 }
 
-
 /*
  * dapls_rbuf_destroy
  *
@@ -174,21 +158,17 @@
  *	none
  *
  */
-void
-dapls_rbuf_destroy (
-	IN  DAPL_RING_BUFFER		*rbuf)
+void dapls_rbuf_destroy(IN DAPL_RING_BUFFER * rbuf)
 {
-    if ( (NULL == rbuf) || 
-         (NULL == rbuf->base) )
-    {
-        return;
-    }
+	if ((NULL == rbuf) || (NULL == rbuf->base)) {
+		return;
+	}
 
-    dapl_os_free (rbuf->base, (rbuf->lim + 1) * sizeof (void *));
-    rbuf->base = NULL;
-    rbuf->lim = 0;
+	dapl_os_free(rbuf->base, (rbuf->lim + 1) * sizeof(void *));
+	rbuf->base = NULL;
+	rbuf->lim = 0;
 
-    return;
+	return;
 }
 
 /*
@@ -208,31 +188,26 @@
  *	DAT_INSUFFICIENT_RESOURCES         (queue full)
  *
  */
-DAT_RETURN
-dapls_rbuf_add (
-	IN  DAPL_RING_BUFFER		*rbuf,
-	IN  void			*entry)
+DAT_RETURN dapls_rbuf_add(IN DAPL_RING_BUFFER * rbuf, IN void *entry)
 {
-    int			pos;
-    int			val;
+	int pos;
+	int val;
 
-    while ( ((dapl_os_atomic_read (&rbuf->head) + 1) & rbuf->lim) != (dapl_os_atomic_read (&rbuf->tail) & rbuf->lim) )
-    {
-	pos = dapl_os_atomic_read (&rbuf->head);
-	val = dapl_os_atomic_assign (&rbuf->head, pos, pos + 1);
-	if ( val == pos )
-	{
-	    pos =  (pos + 1) & rbuf->lim; /* verify in range */
-	    rbuf->base[pos] = entry;
-	    return DAT_SUCCESS;
+	while (((dapl_os_atomic_read(&rbuf->head) + 1) & rbuf->lim) !=
+	       (dapl_os_atomic_read(&rbuf->tail) & rbuf->lim)) {
+		pos = dapl_os_atomic_read(&rbuf->head);
+		val = dapl_os_atomic_assign(&rbuf->head, pos, pos + 1);
+		if (val == pos) {
+			pos = (pos + 1) & rbuf->lim;	/* verify in range */
+			rbuf->base[pos] = entry;
+			return DAT_SUCCESS;
+		}
 	}
-    }
 
-    return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
+	return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
 
 }
 
-
 /*
  * dapls_rbuf_remove
  *
@@ -249,30 +224,26 @@
  *	DAT_QUEUE_EMPTY
    
  */
-void *
-dapls_rbuf_remove (
-	IN  DAPL_RING_BUFFER	*rbuf )
+void *dapls_rbuf_remove(IN DAPL_RING_BUFFER * rbuf)
 {
-    int			pos;
-    int			val;
+	int pos;
+	int val;
 
-    while ( dapl_os_atomic_read (&rbuf->head) != dapl_os_atomic_read (&rbuf->tail) )
-    {
-	pos = dapl_os_atomic_read (&rbuf->tail);
-	val = dapl_os_atomic_assign (&rbuf->tail, pos, pos + 1);
-	if ( val == pos )
-	{
-	    pos =  (pos + 1) & rbuf->lim; /* verify in range */
+	while (dapl_os_atomic_read(&rbuf->head) !=
+	       dapl_os_atomic_read(&rbuf->tail)) {
+		pos = dapl_os_atomic_read(&rbuf->tail);
+		val = dapl_os_atomic_assign(&rbuf->tail, pos, pos + 1);
+		if (val == pos) {
+			pos = (pos + 1) & rbuf->lim;	/* verify in range */
 
-	    return (rbuf->base[pos]);
+			return (rbuf->base[pos]);
+		}
 	}
-    }
 
-    return NULL;
+	return NULL;
 
 }
 
-
 /*
  * dapli_rbuf_count
  *
@@ -289,30 +260,24 @@
  *	count of entries
  *
  */
-DAT_COUNT
-dapls_rbuf_count (
-	IN DAPL_RING_BUFFER		*rbuf )
+DAT_COUNT dapls_rbuf_count(IN DAPL_RING_BUFFER * rbuf)
 {
-    DAT_COUNT count;
-    int head;
-    int tail;
+	DAT_COUNT count;
+	int head;
+	int tail;
 
-    head = dapl_os_atomic_read (&rbuf->head) & rbuf->lim;
-    tail = dapl_os_atomic_read (&rbuf->tail) & rbuf->lim;
-    if ( head > tail )
-    {
-	count = head - tail;
-    }
-    else
-    {
-	/* add 1 to lim as it is a mask, number of entries - 1 */
-	count = (rbuf->lim + 1 - tail + head) & rbuf->lim;
-    }
+	head = dapl_os_atomic_read(&rbuf->head) & rbuf->lim;
+	tail = dapl_os_atomic_read(&rbuf->tail) & rbuf->lim;
+	if (head > tail) {
+		count = head - tail;
+	} else {
+		/* add 1 to lim as it is a mask, number of entries - 1 */
+		count = (rbuf->lim + 1 - tail + head) & rbuf->lim;
+	}
 
-    return count;
+	return count;
 }
 
-
 /*
  * dapls_rbuf_adjust
  *
@@ -332,19 +297,15 @@
  * Returns:
  *	none
  */
-void
-dapls_rbuf_adjust (
-	IN  DAPL_RING_BUFFER	*rbuf,
-	IN  intptr_t		offset)
+void dapls_rbuf_adjust(IN DAPL_RING_BUFFER * rbuf, IN intptr_t offset)
 {
-    int			pos;
+	int pos;
 
-    pos = dapl_os_atomic_read (&rbuf->head);
-    while ( pos != dapl_os_atomic_read (&rbuf->tail) )
-    {
-	rbuf->base[pos] = (void*)((char*)rbuf->base[pos] + offset);
-	pos =  (pos + 1) & rbuf->lim; /* verify in range */
-    }
+	pos = dapl_os_atomic_read(&rbuf->head);
+	while (pos != dapl_os_atomic_read(&rbuf->tail)) {
+		rbuf->base[pos] = (void *)((char *)rbuf->base[pos] + offset);
+		pos = (pos + 1) & rbuf->lim;	/* verify in range */
+	}
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_bind.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_bind.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_bind.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -47,23 +47,20 @@
  *********************************************************************/
 
 STATIC _INLINE_ DAT_RETURN
-dapli_rmr_bind_fuse (
-    IN  DAPL_RMR		*rmr,
-    IN  const DAT_LMR_TRIPLET 	*lmr_triplet,
-    IN  DAT_MEM_PRIV_FLAGS 	mem_priv,
-    IN  DAPL_EP 		*ep_ptr,
-    IN  DAT_RMR_COOKIE 		user_cookie,
-    IN  DAT_COMPLETION_FLAGS	completion_flags,
-    OUT DAT_RMR_CONTEXT 	*rmr_context );
+dapli_rmr_bind_fuse(IN DAPL_RMR * rmr,
+		    IN const DAT_LMR_TRIPLET * lmr_triplet,
+		    IN DAT_MEM_PRIV_FLAGS mem_priv,
+		    IN DAPL_EP * ep_ptr,
+		    IN DAT_RMR_COOKIE user_cookie,
+		    IN DAT_COMPLETION_FLAGS completion_flags,
+		    OUT DAT_RMR_CONTEXT * rmr_context);
 
 STATIC _INLINE_ DAT_RETURN
-dapli_rmr_bind_unfuse (
-    IN  DAPL_RMR		*rmr,
-    IN  DAPL_EP 		*ep_ptr,
-    IN  DAT_RMR_COOKIE 		user_cookie,
-    IN  DAT_COMPLETION_FLAGS 	completion_flags);
+dapli_rmr_bind_unfuse(IN DAPL_RMR * rmr,
+		      IN DAPL_EP * ep_ptr,
+		      IN DAT_RMR_COOKIE user_cookie,
+		      IN DAT_COMPLETION_FLAGS completion_flags);
 
-
 /*********************************************************************
  *                                                                   *
  * Function Definitions                                              *
@@ -71,213 +68,205 @@
  *********************************************************************/
 
 DAT_RETURN
-dapli_rmr_bind_fuse (
-    IN  DAPL_RMR		*rmr,
-    IN  const DAT_LMR_TRIPLET* 	lmr_triplet,
-    IN  DAT_MEM_PRIV_FLAGS 	mem_priv,
-    IN  DAPL_EP 		*ep_ptr,
-    IN  DAT_RMR_COOKIE 		user_cookie,
-    IN  DAT_COMPLETION_FLAGS	completion_flags,
-    OUT DAT_RMR_CONTEXT 	*rmr_context )
+dapli_rmr_bind_fuse(IN DAPL_RMR * rmr,
+		    IN const DAT_LMR_TRIPLET * lmr_triplet,
+		    IN DAT_MEM_PRIV_FLAGS mem_priv,
+		    IN DAPL_EP * ep_ptr,
+		    IN DAT_RMR_COOKIE user_cookie,
+		    IN DAT_COMPLETION_FLAGS completion_flags,
+		    OUT DAT_RMR_CONTEXT * rmr_context)
 {
-    DAPL_LMR 			*lmr;
-    DAPL_COOKIE			*cookie;
-    DAT_RETURN 			dat_status;
-    DAT_BOOLEAN			is_signaled;
-    DAPL_HASH_DATA		hash_lmr;
+	DAPL_LMR *lmr;
+	DAPL_COOKIE *cookie;
+	DAT_RETURN dat_status;
+	DAT_BOOLEAN is_signaled;
+	DAPL_HASH_DATA hash_lmr;
 
-    dat_status = dapls_hash_search (rmr->header.owner_ia->hca_ptr->lmr_hash_table,
-				    lmr_triplet->lmr_context,
-				    &hash_lmr);
-    if ( DAT_SUCCESS != dat_status)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	goto bail;
-    }
-    lmr = (DAPL_LMR*)hash_lmr;
+	dat_status =
+	    dapls_hash_search(rmr->header.owner_ia->hca_ptr->lmr_hash_table,
+			      lmr_triplet->lmr_context, &hash_lmr);
+	if (DAT_SUCCESS != dat_status) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
+	lmr = (DAPL_LMR *) hash_lmr;
 
-    /* if the ep in unconnected return an error. IB requires that the */
-    /* QP be connected to change a memory window binding since:       */
-    /*                                                                */
-    /* - memory window bind operations are WQEs placed on a QP's      */
-    /*   send queue                                                   */
-    /*                                                                */
-    /* - QP's only process WQEs on the send queue when the QP is in   */
-    /*   the RTS state                                                */
-    if (DAT_EP_STATE_CONNECTED != ep_ptr->param.ep_state)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep_ptr));
-	goto bail;
-    }
+	/* if the ep in unconnected return an error. IB requires that the */
+	/* QP be connected to change a memory window binding since:       */
+	/*                                                                */
+	/* - memory window bind operations are WQEs placed on a QP's      */
+	/*   send queue                                                   */
+	/*                                                                */
+	/* - QP's only process WQEs on the send queue when the QP is in   */
+	/*   the RTS state                                                */
+	if (DAT_EP_STATE_CONNECTED != ep_ptr->param.ep_state) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE,
+			      dapls_ep_state_subtype(ep_ptr));
+		goto bail;
+	}
 
-    if ( DAT_FALSE == dapl_mr_bounds_check (
-	     dapl_mr_get_address (lmr->param.region_desc, lmr->param.mem_type),
-	     lmr->param.length,
-	     lmr_triplet->virtual_address,
-	     lmr_triplet->segment_length) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	goto bail;
-    }
+	if (DAT_FALSE ==
+	    dapl_mr_bounds_check(dapl_mr_get_address
+				 (lmr->param.region_desc, lmr->param.mem_type),
+				 lmr->param.length,
+				 lmr_triplet->virtual_address,
+				 lmr_triplet->segment_length)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    /* If the LMR, RMR, and EP are not in the same PZ, there is an error */
-    if ( (ep_ptr->param.pz_handle != lmr->param.pz_handle) ||
-	 (ep_ptr->param.pz_handle != rmr->param.pz_handle) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-	goto bail;
-    }
+	/* If the LMR, RMR, and EP are not in the same PZ, there is an error */
+	if ((ep_ptr->param.pz_handle != lmr->param.pz_handle) ||
+	    (ep_ptr->param.pz_handle != rmr->param.pz_handle)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
 
-    if ( !dapl_rmr_validate_completion_flag (DAT_COMPLETION_SUPPRESS_FLAG,
-					    ep_ptr->param.ep_attr.request_completion_flags,
-					    completion_flags) ||
-	 !dapl_rmr_validate_completion_flag (DAT_COMPLETION_UNSIGNALLED_FLAG,
-					    ep_ptr->param.ep_attr.request_completion_flags,
-					    completion_flags) ||
-	 !dapl_rmr_validate_completion_flag (DAT_COMPLETION_BARRIER_FENCE_FLAG,
-					    ep_ptr->param.ep_attr.request_completion_flags,
-					    completion_flags) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-	goto bail;
-    }
+	if (!dapl_rmr_validate_completion_flag(DAT_COMPLETION_SUPPRESS_FLAG,
+					       ep_ptr->param.ep_attr.
+					       request_completion_flags,
+					       completion_flags)
+	    ||
+	    !dapl_rmr_validate_completion_flag(DAT_COMPLETION_UNSIGNALLED_FLAG,
+					       ep_ptr->param.ep_attr.
+					       request_completion_flags,
+					       completion_flags)
+	    ||
+	    !dapl_rmr_validate_completion_flag
+	    (DAT_COMPLETION_BARRIER_FENCE_FLAG,
+	     ep_ptr->param.ep_attr.request_completion_flags,
+	     completion_flags)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
 
-    dat_status = dapls_rmr_cookie_alloc (&ep_ptr->req_buffer,
-					 rmr,
-					 user_cookie,
-					 &cookie);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	goto bail;
-    }
+	dat_status = dapls_rmr_cookie_alloc(&ep_ptr->req_buffer,
+					    rmr, user_cookie, &cookie);
+	if (DAT_SUCCESS != dat_status) {
+		goto bail;
+	}
 
-    is_signaled = (completion_flags & DAT_COMPLETION_SUPPRESS_FLAG) ? DAT_FALSE : DAT_TRUE;
+	is_signaled =
+	    (completion_flags & DAT_COMPLETION_SUPPRESS_FLAG) ? DAT_FALSE :
+	    DAT_TRUE;
 
-    dat_status = dapls_ib_mw_bind (rmr,
-				   lmr,
-				   ep_ptr,
-				   cookie,
-				   lmr_triplet->virtual_address,
-				   lmr_triplet->segment_length,
-				   mem_priv,
-				   is_signaled);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);
-	goto bail;
-    }
+	dat_status = dapls_ib_mw_bind(rmr,
+				      lmr,
+				      ep_ptr,
+				      cookie,
+				      lmr_triplet->virtual_address,
+				      lmr_triplet->segment_length,
+				      mem_priv, is_signaled);
+	if (DAT_SUCCESS != dat_status) {
+		dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);
+		goto bail;
+	}
 
-    dapl_os_atomic_inc (&lmr->lmr_ref_count);
+	dapl_os_atomic_inc(&lmr->lmr_ref_count);
 
-    /* if the RMR was previously bound */
-    if ( NULL != rmr->lmr )
-    {
-	dapl_os_atomic_dec (&rmr->lmr->lmr_ref_count);
-    }
+	/* if the RMR was previously bound */
+	if (NULL != rmr->lmr) {
+		dapl_os_atomic_dec(&rmr->lmr->lmr_ref_count);
+	}
 
-    rmr->param.mem_priv = mem_priv;
-    rmr->param.lmr_triplet = *lmr_triplet;
-    rmr->ep = ep_ptr;
-    rmr->lmr = lmr;
+	rmr->param.mem_priv = mem_priv;
+	rmr->param.lmr_triplet = *lmr_triplet;
+	rmr->ep = ep_ptr;
+	rmr->lmr = lmr;
 
-    if ( NULL != rmr_context )
-    {
-	*rmr_context = rmr->param.rmr_context;
-    }
+	if (NULL != rmr_context) {
+		*rmr_context = rmr->param.rmr_context;
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 DAT_RETURN
-dapli_rmr_bind_unfuse (
-    IN  DAPL_RMR		*rmr,
-    IN  DAPL_EP 		*ep_ptr,
-    IN  DAT_RMR_COOKIE 		user_cookie,
-    IN  DAT_COMPLETION_FLAGS 	completion_flags)
+dapli_rmr_bind_unfuse(IN DAPL_RMR * rmr,
+		      IN DAPL_EP * ep_ptr,
+		      IN DAT_RMR_COOKIE user_cookie,
+		      IN DAT_COMPLETION_FLAGS completion_flags)
 {
-    DAPL_COOKIE			*cookie;
-    DAT_RETURN 			dat_status;
-    DAT_BOOLEAN			is_signaled;
+	DAPL_COOKIE *cookie;
+	DAT_RETURN dat_status;
+	DAT_BOOLEAN is_signaled;
 
-    dat_status = DAT_SUCCESS;
-    /*
-     * if the ep in unconnected return an error. IB requires that the
-     * QP be connected to change a memory window binding since:
-     *
-     * - memory window bind operations are WQEs placed on a QP's
-     *   send queue
-     *
-     * - QP's only process WQEs on the send queue when the QP is in
-     *   the RTS state
-     */
-    if (DAT_EP_STATE_CONNECTED != ep_ptr->param.ep_state)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE, dapls_ep_state_subtype (ep_ptr));
-	goto bail1;
-    }
+	dat_status = DAT_SUCCESS;
+	/*
+	 * if the ep in unconnected return an error. IB requires that the
+	 * QP be connected to change a memory window binding since:
+	 *
+	 * - memory window bind operations are WQEs placed on a QP's
+	 *   send queue
+	 *
+	 * - QP's only process WQEs on the send queue when the QP is in
+	 *   the RTS state
+	 */
+	if (DAT_EP_STATE_CONNECTED != ep_ptr->param.ep_state) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE,
+			      dapls_ep_state_subtype(ep_ptr));
+		goto bail1;
+	}
 
-    /* If the RMR and EP are not in the same PZ, there is an error */
-    if ( ep_ptr->param.pz_handle != rmr->param.pz_handle )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	goto bail1;
-    }
+	/* If the RMR and EP are not in the same PZ, there is an error */
+	if (ep_ptr->param.pz_handle != rmr->param.pz_handle) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail1;
+	}
 
-    if ( !dapl_rmr_validate_completion_flag (DAT_COMPLETION_SUPPRESS_FLAG,
-					    ep_ptr->param.ep_attr.request_completion_flags,
-					    completion_flags) ||
-	 !dapl_rmr_validate_completion_flag (DAT_COMPLETION_UNSIGNALLED_FLAG,
-					    ep_ptr->param.ep_attr.request_completion_flags,
-					    completion_flags) ||
-	 !dapl_rmr_validate_completion_flag (DAT_COMPLETION_BARRIER_FENCE_FLAG,
-					    ep_ptr->param.ep_attr.request_completion_flags,
-					    completion_flags) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	goto bail1;
-    }
+	if (!dapl_rmr_validate_completion_flag(DAT_COMPLETION_SUPPRESS_FLAG,
+					       ep_ptr->param.ep_attr.
+					       request_completion_flags,
+					       completion_flags)
+	    ||
+	    !dapl_rmr_validate_completion_flag(DAT_COMPLETION_UNSIGNALLED_FLAG,
+					       ep_ptr->param.ep_attr.
+					       request_completion_flags,
+					       completion_flags)
+	    ||
+	    !dapl_rmr_validate_completion_flag
+	    (DAT_COMPLETION_BARRIER_FENCE_FLAG,
+	     ep_ptr->param.ep_attr.request_completion_flags,
+	     completion_flags)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail1;
+	}
 
-    dat_status = dapls_rmr_cookie_alloc (&ep_ptr->req_buffer,
-					 rmr,
-					 user_cookie,
-					 &cookie);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	goto bail1;
-    }
+	dat_status = dapls_rmr_cookie_alloc(&ep_ptr->req_buffer,
+					    rmr, user_cookie, &cookie);
+	if (DAT_SUCCESS != dat_status) {
+		goto bail1;
+	}
 
-    is_signaled = (completion_flags & DAT_COMPLETION_UNSIGNALLED_FLAG) ? DAT_FALSE : DAT_TRUE;
+	is_signaled =
+	    (completion_flags & DAT_COMPLETION_UNSIGNALLED_FLAG) ? DAT_FALSE :
+	    DAT_TRUE;
 
-    dat_status = dapls_ib_mw_unbind (rmr,
-				     ep_ptr,
-				     cookie,
-				     is_signaled);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	dapls_cookie_dealloc (&ep_ptr->req_buffer, cookie);
-	goto bail1;
-    }
+	dat_status = dapls_ib_mw_unbind(rmr, ep_ptr, cookie, is_signaled);
+	if (DAT_SUCCESS != dat_status) {
+		dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);
+		goto bail1;
+	}
 
-    /* if the RMR was previously bound */
-    if ( NULL != rmr->lmr )
-    {
-	dapl_os_atomic_dec (&rmr->lmr->lmr_ref_count);
-    }
+	/* if the RMR was previously bound */
+	if (NULL != rmr->lmr) {
+		dapl_os_atomic_dec(&rmr->lmr->lmr_ref_count);
+	}
 
-    rmr->param.mem_priv = DAT_MEM_PRIV_NONE_FLAG;
-    rmr->param.lmr_triplet.lmr_context = 0;
-    rmr->param.lmr_triplet.virtual_address = 0;
-    rmr->param.lmr_triplet.segment_length = 0;
-    rmr->ep = ep_ptr;
-    rmr->lmr = NULL;
+	rmr->param.mem_priv = DAT_MEM_PRIV_NONE_FLAG;
+	rmr->param.lmr_triplet.lmr_context = 0;
+	rmr->param.lmr_triplet.virtual_address = 0;
+	rmr->param.lmr_triplet.segment_length = 0;
+	rmr->ep = ep_ptr;
+	rmr->lmr = NULL;
 
-bail1:
-    return dat_status;
+      bail1:
+	return dat_status;
 }
 
-
 /*
  * dapl_rmr_bind
  *
@@ -290,48 +279,41 @@
  * Output:
  */
 DAT_RETURN DAT_API
-dapl_rmr_bind (
-	IN	DAT_RMR_HANDLE		rmr_handle,
-	IN	DAT_LMR_HANDLE		lmr_handle,
-	IN	const DAT_LMR_TRIPLET	*lmr_triplet,
-	IN	DAT_MEM_PRIV_FLAGS	mem_priv,
-	IN	DAT_VA_TYPE		va_type,
-	IN	DAT_EP_HANDLE		ep_handle,
-	IN	DAT_RMR_COOKIE		user_cookie,
-	IN	DAT_COMPLETION_FLAGS 	completion_flags,
-	OUT	DAT_RMR_CONTEXT		*rmr_context )
+dapl_rmr_bind(IN DAT_RMR_HANDLE rmr_handle,
+	      IN DAT_LMR_HANDLE lmr_handle,
+	      IN const DAT_LMR_TRIPLET * lmr_triplet,
+	      IN DAT_MEM_PRIV_FLAGS mem_priv,
+	      IN DAT_VA_TYPE va_type,
+	      IN DAT_EP_HANDLE ep_handle,
+	      IN DAT_RMR_COOKIE user_cookie,
+	      IN DAT_COMPLETION_FLAGS completion_flags,
+	      OUT DAT_RMR_CONTEXT * rmr_context)
 {
-    DAPL_RMR				*rmr;
-    DAPL_EP 				*ep_ptr;
+	DAPL_RMR *rmr;
+	DAPL_EP *ep_ptr;
 
-    if ( DAPL_BAD_HANDLE (rmr_handle, DAPL_MAGIC_RMR) )
-    {
-	return DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
-    }
-    if ( DAPL_BAD_HANDLE (ep_handle, DAPL_MAGIC_EP) )
-    {
-	return DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
+	if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+	}
+	if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP)) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
 
-    rmr = (DAPL_RMR *) rmr_handle;
-    ep_ptr = (DAPL_EP *) ep_handle;
+	rmr = (DAPL_RMR *) rmr_handle;
+	ep_ptr = (DAPL_EP *) ep_handle;
 
-    /* if the rmr should be bound */
-    if (0 != lmr_triplet->segment_length)
-    {
-	return dapli_rmr_bind_fuse (rmr,
-				    lmr_triplet,
-				    mem_priv,
-				    ep_ptr,
-				    user_cookie,
-				    completion_flags,
-				    rmr_context);
-    }
-    else /* the rmr should be unbound */
-    {
-	return dapli_rmr_bind_unfuse (rmr,
-				      ep_ptr,
-				      user_cookie,
-				      completion_flags);
-    }
+	/* if the rmr should be bound */
+	if (0 != lmr_triplet->segment_length) {
+		return dapli_rmr_bind_fuse(rmr,
+					   lmr_triplet,
+					   mem_priv,
+					   ep_ptr,
+					   user_cookie,
+					   completion_flags, rmr_context);
+	} else {		/* the rmr should be unbound */
+
+		return dapli_rmr_bind_unfuse(rmr,
+					     ep_ptr,
+					     user_cookie, completion_flags);
+	}
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,47 +54,46 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_rmr_create (
-	IN	DAT_PZ_HANDLE	   pz_handle,
-	OUT	DAT_RMR_HANDLE	   *rmr_handle)
+dapl_rmr_create(IN DAT_PZ_HANDLE pz_handle, OUT DAT_RMR_HANDLE * rmr_handle)
 {
-    DAPL_PZ		*pz;
-    DAPL_RMR 		*rmr;
-    DAT_RETURN		dat_status;
+	DAPL_PZ *pz;
+	DAPL_RMR *rmr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (pz_handle, DAPL_MAGIC_PZ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_PZ);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+		goto bail;
+	}
 
-    pz = (DAPL_PZ *) pz_handle;
+	pz = (DAPL_PZ *) pz_handle;
+	rmr = dapl_rmr_alloc(pz);
 
-    rmr = dapl_rmr_alloc (pz);
+	if (rmr == NULL) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
+	DAPL_CNTR(pz->header.owner_ia, DCNT_IA_RMR_CREATE);
 
-    if ( rmr == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	dat_status = dapls_ib_mw_alloc(rmr);
 
-    dat_status = dapls_ib_mw_alloc (rmr);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_rmr_dealloc(rmr);
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+			      DAT_RESOURCE_MEMORY_REGION);
+		goto bail;
+	}
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-	dapl_rmr_dealloc (rmr);
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY_REGION);
-	goto bail;
-    }
+	dapl_os_atomic_inc(&pz->pz_ref_count);
 
-    dapl_os_atomic_inc (&pz->pz_ref_count);
+	*rmr_handle = rmr;
 
-    *rmr_handle = rmr;
-
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*
@@ -126,11 +125,9 @@
  *	DAT_INVALID_HANDLE
  *	DAT_MODEL_NOT_SUPPORTED
  */
-DAT_RETURN DAT_API
-dapl_rmr_create_for_ep (
-	IN      DAT_PZ_HANDLE pz_handle,	/* pz_handle            */
-	OUT     DAT_RMR_HANDLE *rmr_handle)	/* rmr_handle           */
-{
+DAT_RETURN DAT_API dapl_rmr_create_for_ep(IN DAT_PZ_HANDLE pz_handle,	/* pz_handle            */
+					  OUT DAT_RMR_HANDLE * rmr_handle)
+{				/* rmr_handle           */
 	return DAT_MODEL_NOT_SUPPORTED;
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -53,44 +53,43 @@
  * 	DAT_SUCCESS
  * 	DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API
-dapl_rmr_free (
-    IN	DAT_RMR_HANDLE  rmr_handle )
+DAT_RETURN DAT_API dapl_rmr_free(IN DAT_RMR_HANDLE rmr_handle)
 {
-    DAPL_RMR	 	*rmr;
-    DAT_RETURN		dat_status;
+	DAPL_RMR *rmr;
+	DAPL_PZ *pz;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (rmr_handle, DAPL_MAGIC_RMR) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_RMR);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+		goto bail;
+	}
 
-    rmr = (DAPL_RMR *) rmr_handle;
+	rmr = (DAPL_RMR *) rmr_handle;
+	pz = (DAPL_PZ *) rmr->param.pz_handle;
+	DAPL_CNTR(pz->header.owner_ia, DCNT_IA_RMR_FREE);
 
-    /*
-     * If the user did not perform an unbind op, release
-     * counts here.
-     */
-    if ( rmr->param.lmr_triplet.virtual_address != 0 )
-    {
-        dapl_os_atomic_dec (&rmr->lmr->lmr_ref_count); 
-        rmr->param.lmr_triplet.virtual_address = 0;
-    }
+	/*
+	 * If the user did not perform an unbind op, release
+	 * counts here.
+	 */
+	if (rmr->param.lmr_triplet.virtual_address != 0) {
+		dapl_os_atomic_dec(&rmr->lmr->lmr_ref_count);
+		rmr->param.lmr_triplet.virtual_address = 0;
+	}
 
-    dat_status = dapls_ib_mw_free (rmr);
+	dat_status = dapls_ib_mw_free(rmr);
 
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
+	}
 
-    dapl_os_atomic_dec (&rmr->pz->pz_ref_count);
+	dapl_os_atomic_dec(&rmr->pz->pz_ref_count);
 
-    dapl_rmr_dealloc (rmr);
+	dapl_rmr_dealloc(rmr);
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,39 +58,36 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_rmr_query (
-	IN	DAT_RMR_HANDLE		rmr_handle,
-	IN	DAT_RMR_PARAM_MASK   	rmr_param_mask,
-	IN	DAT_RMR_PARAM  		*rmr_param )
+dapl_rmr_query(IN DAT_RMR_HANDLE rmr_handle,
+	       IN DAT_RMR_PARAM_MASK rmr_param_mask,
+	       IN DAT_RMR_PARAM * rmr_param)
 {
-    DAPL_RMR		*rmr;
-    DAT_RETURN		dat_status;
+	DAPL_RMR *rmr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (rmr_handle, DAPL_MAGIC_RMR) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_RMR);
-	goto bail;
-    }
-    if (NULL == rmr_param)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+		goto bail;
+	}
+	if (NULL == rmr_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    rmr = (DAPL_RMR *) rmr_handle;
+	rmr = (DAPL_RMR *) rmr_handle;
 
-    /* If the RMR is unbound, there is no LMR triplet associated with   */
-    /* this RMR.  If the consumer requests this field, return an error. */
-    if ( (rmr_param_mask & DAT_RMR_FIELD_LMR_TRIPLET) && (NULL == rmr->lmr) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
+	/* If the RMR is unbound, there is no LMR triplet associated with   */
+	/* this RMR.  If the consumer requests this field, return an error. */
+	if ((rmr_param_mask & DAT_RMR_FIELD_LMR_TRIPLET) && (NULL == rmr->lmr)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
 
-    dapl_os_memcpy (rmr_param, &rmr->param, sizeof (DAT_RMR_PARAM));
+	dapl_os_memcpy(rmr_param, &rmr->param, sizeof(DAT_RMR_PARAM));
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rmr_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,60 +31,54 @@
 #include "dapl_rmr_util.h"
 #include "dapl_ia_util.h"
 
-DAPL_RMR *
-dapl_rmr_alloc(
-	IN DAPL_PZ 		*pz)
+DAPL_RMR *dapl_rmr_alloc(IN DAPL_PZ * pz)
 {
-    DAPL_RMR *rmr;
+	DAPL_RMR *rmr;
 
-    /* Allocate LMR */
-    rmr = (DAPL_RMR *) dapl_os_alloc(sizeof(DAPL_RMR));
-    if (NULL == rmr)
-    {
-        return (NULL);
-    }
+	/* Allocate LMR */
+	rmr = (DAPL_RMR *) dapl_os_alloc(sizeof(DAPL_RMR));
+	if (NULL == rmr) {
+		return (NULL);
+	}
 
-    /* zero the structure */
-    dapl_os_memzero(rmr, sizeof(DAPL_RMR));
+	/* zero the structure */
+	dapl_os_memzero(rmr, sizeof(DAPL_RMR));
 
-    /*
-     * initialize the header
-     */
-    rmr->header.provider            = pz->header.provider;
-    rmr->header.magic               = DAPL_MAGIC_RMR;
-    rmr->header.handle_type         = DAT_HANDLE_TYPE_RMR;
-    rmr->header.owner_ia            = pz->header.owner_ia;
-    rmr->header.user_context.as_64  = 0;
-    rmr->header.user_context.as_ptr = 0;
-    dapl_llist_init_entry (&rmr->header.ia_list_entry);
-    dapl_ia_link_rmr(rmr->header.owner_ia, rmr);
-    dapl_os_lock_init(&rmr->header.lock);
+	/*
+	 * initialize the header
+	 */
+	rmr->header.provider = pz->header.provider;
+	rmr->header.magic = DAPL_MAGIC_RMR;
+	rmr->header.handle_type = DAT_HANDLE_TYPE_RMR;
+	rmr->header.owner_ia = pz->header.owner_ia;
+	rmr->header.user_context.as_64 = 0;
+	rmr->header.user_context.as_ptr = 0;
+	dapl_llist_init_entry(&rmr->header.ia_list_entry);
+	dapl_ia_link_rmr(rmr->header.owner_ia, rmr);
+	dapl_os_lock_init(&rmr->header.lock);
 
-    /* 
-     * initialize the body 
-     */
-    rmr->param.ia_handle = (DAT_IA_HANDLE) pz->header.owner_ia;
-    rmr->param.pz_handle = (DAT_PZ_HANDLE) pz;
-    rmr->param.lmr_triplet.lmr_context     = 0;
-    rmr->param.lmr_triplet.virtual_address = 0;
-    rmr->param.lmr_triplet.segment_length  = 0;
+	/* 
+	 * initialize the body 
+	 */
+	rmr->param.ia_handle = (DAT_IA_HANDLE) pz->header.owner_ia;
+	rmr->param.pz_handle = (DAT_PZ_HANDLE) pz;
+	rmr->param.lmr_triplet.lmr_context = 0;
+	rmr->param.lmr_triplet.virtual_address = 0;
+	rmr->param.lmr_triplet.segment_length = 0;
 
-    rmr->param.mem_priv = 0;
-    rmr->pz = pz;
-    rmr->lmr = NULL;
-    
-    return (rmr);
+	rmr->param.mem_priv = 0;
+	rmr->pz = pz;
+	rmr->lmr = NULL;
+
+	return (rmr);
 }
 
-
-void
-dapl_rmr_dealloc(
-    IN DAPL_RMR *rmr)
+void dapl_rmr_dealloc(IN DAPL_RMR * rmr)
 {
-    rmr->header.magic = DAPL_MAGIC_INVALID; /* reset magic to prevent reuse */
+	rmr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
 
-    dapl_ia_unlink_rmr(rmr->header.owner_ia, rmr);
-    dapl_os_lock_destroy(&rmr->header.lock);
-    
-    dapl_os_free((void *) rmr, sizeof(DAPL_RMR));
+	dapl_ia_unlink_rmr(rmr->header.owner_ia, rmr);
+	dapl_os_lock_destroy(&rmr->header.lock);
+
+	dapl_os_free((void *)rmr, sizeof(DAPL_RMR));
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -69,141 +69,138 @@
  *	DAT_CONN_QUAL_IN_USE
  */
 DAT_RETURN DAT_API
-dapl_rsp_create (
-	IN	DAT_IA_HANDLE	   ia_handle,
-	IN	DAT_CONN_QUAL	   conn_qual,
-	IN	DAT_EP_HANDLE	   ep_handle,
-	IN	DAT_EVD_HANDLE	   evd_handle,
-	OUT	DAT_RSP_HANDLE	   *rsp_handle )
+dapl_rsp_create(IN DAT_IA_HANDLE ia_handle,
+		IN DAT_CONN_QUAL conn_qual,
+		IN DAT_EP_HANDLE ep_handle,
+		IN DAT_EVD_HANDLE evd_handle, OUT DAT_RSP_HANDLE * rsp_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SP		*sp_ptr;
-    DAPL_EVD		*evd_ptr;
-    DAPL_EP		*ep_ptr;
-    DAT_BOOLEAN		sp_found;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_SP *sp_ptr;
+	DAPL_EVD *evd_ptr;
+	DAPL_EP *ep_ptr;
+	DAT_BOOLEAN sp_found;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
-    ia_ptr = (DAPL_IA *)ia_handle;
+	dat_status = DAT_SUCCESS;
+	ia_ptr = (DAPL_IA *) ia_handle;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_CM, 
-                  ">>> dapl_rsp_free conn_qual: %x EP: %p\n", 
-		  conn_qual, ep_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     ">>> dapl_rsp_free conn_qual: %x EP: %p\n",
+		     conn_qual, ep_handle);
 
-    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_HANDLE (ep_handle, DAPL_MAGIC_EP) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EP);
-	goto bail;
-    }
-    if ( DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EVD_CR);
-	goto bail;
-    }
+	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_HANDLE(ep_handle, DAPL_MAGIC_EP)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+		goto bail;
+	}
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CR);
+		goto bail;
+	}
 
-    if ( rsp_handle == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG5);
-	goto bail;
-    }
+	if (rsp_handle == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
+		goto bail;
+	}
 
-    ep_ptr = (DAPL_EP *) ep_handle;
-    if ( ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,dapls_ep_state_subtype (ep_ptr));
-	goto bail;
-    }
+	ep_ptr = (DAPL_EP *) ep_handle;
+	if (ep_ptr->param.ep_state != DAT_EP_STATE_UNCONNECTED) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE,
+			      dapls_ep_state_subtype(ep_ptr));
+		goto bail;
+	}
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    if ( ! (evd_ptr->evd_flags & DAT_EVD_CR_FLAG) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_EVD_CR);
-	goto bail;
-    }
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	if (!(evd_ptr->evd_flags & DAT_EVD_CR_FLAG)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_CR);
+		goto bail;
+	}
 
-    sp_ptr = dapls_ia_sp_search (ia_ptr, conn_qual, DAT_FALSE);
-    sp_found = DAT_TRUE;
-    if (sp_ptr == NULL)
-    {
-	sp_found = DAT_FALSE;
+	DAPL_CNTR(ia_ptr, DCNT_IA_RSP_CREATE);
 
-	/* Allocate RSP */
-	sp_ptr = dapls_sp_alloc ( ia_ptr, DAT_FALSE );
-	if ( sp_ptr == NULL )
-	{
-	    dat_status = 
-		DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	    goto bail;
+	sp_ptr = dapls_ia_sp_search(ia_ptr, conn_qual, DAT_FALSE);
+	sp_found = DAT_TRUE;
+	if (sp_ptr == NULL) {
+		sp_found = DAT_FALSE;
+
+		/* Allocate RSP */
+		sp_ptr = dapls_sp_alloc(ia_ptr, DAT_FALSE);
+		if (sp_ptr == NULL) {
+			dat_status =
+			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				      DAT_RESOURCE_MEMORY);
+			goto bail;
+		}
 	}
-    }
 
-    /*
-     * Fill out the RSP args
-     */
-    sp_ptr->conn_qual  = conn_qual;
-    sp_ptr->evd_handle = evd_handle;
-    sp_ptr->psp_flags  = 0;
-    sp_ptr->ep_handle  = ep_handle;
+	/*
+	 * Fill out the RSP args
+	 */
+	sp_ptr->conn_qual = conn_qual;
+	sp_ptr->evd_handle = evd_handle;
+	sp_ptr->psp_flags = 0;
+	sp_ptr->ep_handle = ep_handle;
 
-    /*
-     * Take a reference on the EVD handle
-     */
-    dapl_os_atomic_inc (& ((DAPL_EVD *)evd_handle)->evd_ref_count);
+	/*
+	 * Take a reference on the EVD handle
+	 */
+	dapl_os_atomic_inc(&((DAPL_EVD *) evd_handle)->evd_ref_count);
 
-    /*
-     * Update the EP state indicating the provider now owns it
-     */
-    ep_ptr->param.ep_state = DAT_EP_STATE_RESERVED;
+	/*
+	 * Update the EP state indicating the provider now owns it
+	 */
+	ep_ptr->param.ep_state = DAT_EP_STATE_RESERVED;
 
-    /* 
-     * Set up a listener for a connection. Connections can arrive
-     * even before this call returns!
-     */
-    sp_ptr->state     = DAPL_SP_STATE_RSP_LISTENING;
-    sp_ptr->listening = DAT_TRUE;
+	/* 
+	 * Set up a listener for a connection. Connections can arrive
+	 * even before this call returns!
+	 */
+	sp_ptr->state = DAPL_SP_STATE_RSP_LISTENING;
+	sp_ptr->listening = DAT_TRUE;
 
-    if (sp_found == DAT_FALSE)
-    {
-	/* Link it onto the IA */
-	dapl_ia_link_rsp (ia_ptr, sp_ptr);
+	if (sp_found == DAT_FALSE) {
+		/* Link it onto the IA */
+		dapl_ia_link_rsp(ia_ptr, sp_ptr);
 
-	dat_status = dapls_ib_setup_conn_listener ( ia_ptr,
-						    conn_qual, 
-						    sp_ptr );
+		dat_status = dapls_ib_setup_conn_listener(ia_ptr,
+							  conn_qual, sp_ptr);
 
-	if ( dat_status != DAT_SUCCESS )
-	{
-	    /*
-	     * Have a problem setting up the connection, something
-	     * wrong!  Decrements the EVD refcount & release it. Set 
-	     * the state to FREE, so we know the call failed.
-	     */
-	    dapl_os_atomic_dec (& ((DAPL_EVD *)evd_handle)->evd_ref_count);
-	    sp_ptr->evd_handle = NULL;
-	    sp_ptr->state      = DAPL_SP_STATE_FREE;
-	    dapls_ia_unlink_sp (ia_ptr, sp_ptr);
-	    dapls_sp_free_sp (sp_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			/*
+			 * Have a problem setting up the connection, something
+			 * wrong!  Decrements the EVD refcount & release it. Set 
+			 * the state to FREE, so we know the call failed.
+			 */
+			dapl_os_atomic_dec(&((DAPL_EVD *) evd_handle)->
+					   evd_ref_count);
+			sp_ptr->evd_handle = NULL;
+			sp_ptr->state = DAPL_SP_STATE_FREE;
+			dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+			dapls_sp_free_sp(sp_ptr);
 
-	    dapl_dbg_log (DAPL_DBG_TYPE_CM, 
-		      "--> dapl_rsp_create setup_conn_listener failed: %x\n", 
-		      dat_status);
+			dapl_dbg_log(DAPL_DBG_TYPE_CM,
+				     "--> dapl_rsp_create setup_conn_listener failed: %x\n",
+				     dat_status);
 
-	    goto bail;
+			goto bail;
+		}
 	}
-    }
 
-    /*
-     * Return handle to the user
-     */
-    *rsp_handle = (DAT_RSP_HANDLE)sp_ptr;
+	/*
+	 * Return handle to the user
+	 */
+	*rsp_handle = (DAT_RSP_HANDLE) sp_ptr;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*
@@ -214,5 +211,3 @@
  *  tab-width: 8
  * End:
  */
-
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,98 +58,90 @@
  *	DAT_SUCCESS
  *	DAT_INVALID_HANDLE
  */
-DAT_RETURN DAT_API
-dapl_rsp_free (
-	IN	DAT_RSP_HANDLE	   rsp_handle )
+DAT_RETURN DAT_API dapl_rsp_free(IN DAT_RSP_HANDLE rsp_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SP		*sp_ptr;
-    DAPL_EP		*ep_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_SP *sp_ptr;
+	DAPL_EP *ep_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    sp_ptr = (DAPL_SP *) rsp_handle;
-    /*
-     * Verify handle
-     */
-    dapl_dbg_log (DAPL_DBG_TYPE_CM, 
-                  ">>> dapl_rsp_free %p\n", 
-		  rsp_handle);
-    if ( DAPL_BAD_HANDLE (sp_ptr, DAPL_MAGIC_RSP ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_RSP);
-	goto bail;
-    }
+	sp_ptr = (DAPL_SP *) rsp_handle;
+	/*
+	 * Verify handle
+	 */
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, ">>> dapl_rsp_free %p\n", rsp_handle);
+	if (DAPL_BAD_HANDLE(sp_ptr, DAPL_MAGIC_RSP)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP);
+		goto bail;
+	}
 
-    /* ia_ptr = (DAPL_IA *)sp_ptr->header.owner_ia; */
-    ia_ptr = sp_ptr->header.owner_ia;
+	/* ia_ptr = (DAPL_IA *)sp_ptr->header.owner_ia; */
+	ia_ptr = sp_ptr->header.owner_ia;
 
-    /*
-     * Remove the connection listener if there are no connections.  If
-     * we defer removing the sp it becomes something of a zombie
-     * container until disconnection, after which it will be cleaned up.
-     */
-    dapl_os_lock (&sp_ptr->header.lock);
+	DAPL_CNTR(ia_ptr, DCNT_IA_RSP_FREE);
 
-    /*
-     * Make sure we don't leave a dangling EP. If the state is still
-     * RESERVED then the RSP still owns it.
-     */
-    ep_ptr = (DAPL_EP *)sp_ptr->ep_handle;
-    if ( ep_ptr != NULL && ep_ptr->param.ep_state == DAT_EP_STATE_RESERVED )
-    {
-	ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
-    }
-    sp_ptr->ep_handle = NULL;
+	/*
+	 * Remove the connection listener if there are no connections.  If
+	 * we defer removing the sp it becomes something of a zombie
+	 * container until disconnection, after which it will be cleaned up.
+	 */
+	dapl_os_lock(&sp_ptr->header.lock);
 
-    /* Release reference on EVD. If an error was encountered in a previous
-     * free the evd_handle will be NULL
-     */
-    if (sp_ptr->evd_handle)
-    {
-	dapl_os_atomic_dec (& ((DAPL_EVD *)sp_ptr->evd_handle)->evd_ref_count);
-	sp_ptr->evd_handle = NULL;
-    }
+	/*
+	 * Make sure we don't leave a dangling EP. If the state is still
+	 * RESERVED then the RSP still owns it.
+	 */
+	ep_ptr = (DAPL_EP *) sp_ptr->ep_handle;
+	if (ep_ptr != NULL && ep_ptr->param.ep_state == DAT_EP_STATE_RESERVED) {
+		ep_ptr->param.ep_state = DAT_EP_STATE_UNCONNECTED;
+	}
+	sp_ptr->ep_handle = NULL;
 
-    /*
-     * Release the base resource if there are no outstanding connections;
-     * else the last disconnect on this RSP will free it up. The RSP
-     * is used to contain CR records for each connection, which 
-     * contain information necessary to disconnect.
-     * sp_ptr->listening will be DAT_TRUE if there has never been a
-     * connection event, and DAT_FALSE if a connection attempt resulted
-     * in a reject.
-     */
-    if ( sp_ptr->cr_list_count == 0 )
-    {
-	/* This RSP has never been used. Clean it up */
-	sp_ptr->listening  = DAT_FALSE;
-	sp_ptr->state      = DAPL_SP_STATE_FREE;
-	dapl_os_unlock (&sp_ptr->header.lock);
-
-	dat_status = dapls_ib_remove_conn_listener ( ia_ptr,
-						     sp_ptr );
-	if (dat_status != DAT_SUCCESS)
-	{
-	    sp_ptr->state     = DAPL_SP_STATE_RSP_LISTENING;
-	    goto bail;
+	/* Release reference on EVD. If an error was encountered in a previous
+	 * free the evd_handle will be NULL
+	 */
+	if (sp_ptr->evd_handle) {
+		dapl_os_atomic_dec(&((DAPL_EVD *) sp_ptr->evd_handle)->
+				   evd_ref_count);
+		sp_ptr->evd_handle = NULL;
 	}
-	dapls_ia_unlink_sp ( ia_ptr, sp_ptr );
-	dapls_sp_free_sp ( sp_ptr );
-    }
-    else
-    {
-	/* The RSP is now in the pending state, where it will sit until
-	 * the connection terminates or the app uses the same
-	 * ServiceID again, which will reactivate it.
+
+	/*
+	 * Release the base resource if there are no outstanding connections;
+	 * else the last disconnect on this RSP will free it up. The RSP
+	 * is used to contain CR records for each connection, which 
+	 * contain information necessary to disconnect.
+	 * sp_ptr->listening will be DAT_TRUE if there has never been a
+	 * connection event, and DAT_FALSE if a connection attempt resulted
+	 * in a reject.
 	 */
-	sp_ptr->state = DAPL_SP_STATE_RSP_PENDING;
-	dapl_os_unlock (&sp_ptr->header.lock);
-    }
+	if (sp_ptr->cr_list_count == 0) {
+		/* This RSP has never been used. Clean it up */
+		sp_ptr->listening = DAT_FALSE;
+		sp_ptr->state = DAPL_SP_STATE_FREE;
+		dapl_os_unlock(&sp_ptr->header.lock);
 
- bail:
-    return dat_status;
+		dat_status = dapls_ib_remove_conn_listener(ia_ptr, sp_ptr);
+		if (dat_status != DAT_SUCCESS) {
+			sp_ptr->state = DAPL_SP_STATE_RSP_LISTENING;
+			goto bail;
+		}
+		dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+		dapls_sp_free_sp(sp_ptr);
+	} else {
+		/* The RSP is now in the pending state, where it will sit until
+		 * the connection terminates or the app uses the same
+		 * ServiceID again, which will reactivate it.
+		 */
+		sp_ptr->state = DAPL_SP_STATE_RSP_PENDING;
+		dapl_os_unlock(&sp_ptr->header.lock);
+	}
+
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_rsp_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,40 +57,37 @@
  *	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_rsp_query (
-	IN	DAT_RSP_HANDLE	   rsp_handle,
-	IN	DAT_RSP_PARAM_MASK  rsp_mask,
-	OUT	DAT_RSP_PARAM	   *rsp_param )
+dapl_rsp_query(IN DAT_RSP_HANDLE rsp_handle,
+	       IN DAT_RSP_PARAM_MASK rsp_mask, OUT DAT_RSP_PARAM * rsp_param)
 {
-    DAPL_SP		*sp_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_SP *sp_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (rsp_handle, DAPL_MAGIC_RSP) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_RSP);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(rsp_handle, DAPL_MAGIC_RSP)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP);
+		goto bail;
+	}
 
-    if (NULL == rsp_param)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (NULL == rsp_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    sp_ptr = (DAPL_SP *) rsp_handle;
+	sp_ptr = (DAPL_SP *) rsp_handle;
 
-    /*
-     * Fill in the RSP params
-     */
-    rsp_param->ia_handle   = sp_ptr->header.owner_ia;
-    rsp_param->conn_qual   = sp_ptr->conn_qual;
-    rsp_param->evd_handle  = sp_ptr->evd_handle;
-    rsp_param->ep_handle   = sp_ptr->ep_handle;
+	/*
+	 * Fill in the RSP params
+	 */
+	rsp_param->ia_handle = sp_ptr->header.owner_ia;
+	rsp_param->conn_qual = sp_ptr->conn_qual;
+	rsp_param->evd_handle = sp_ptr->evd_handle;
+	rsp_param->ep_handle = sp_ptr->ep_handle;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_set_consumer_context.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_set_consumer_context.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_set_consumer_context.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,34 +57,30 @@
  * 	DAT_INVALID_HANDLE
  */
 DAT_RETURN DAT_API
-dapl_set_consumer_context (
-	IN	DAT_HANDLE  dat_handle,
-	IN	DAT_CONTEXT context )
+dapl_set_consumer_context(IN DAT_HANDLE dat_handle, IN DAT_CONTEXT context)
 {
-    DAT_RETURN	dat_status;
-    DAPL_HEADER	*header;
+	DAT_RETURN dat_status;
+	DAPL_HEADER *header;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    header = (DAPL_HEADER *)dat_handle;
-    if ( ((header) == NULL) ||
-	 DAPL_BAD_PTR(header) ||
-	 (header->magic != DAPL_MAGIC_IA &&
-	  header->magic != DAPL_MAGIC_EVD &&
-	  header->magic != DAPL_MAGIC_EP &&
-	  header->magic != DAPL_MAGIC_LMR &&
-	  header->magic != DAPL_MAGIC_RMR &&
-	  header->magic != DAPL_MAGIC_PZ &&
-	  header->magic != DAPL_MAGIC_PSP &&
-	  header->magic != DAPL_MAGIC_RSP &&
-	  header->magic != DAPL_MAGIC_CR))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    header->user_context = context;
+	header = (DAPL_HEADER *) dat_handle;
+	if (((header) == NULL) ||
+	    DAPL_BAD_PTR(header) ||
+	    (header->magic != DAPL_MAGIC_IA &&
+	     header->magic != DAPL_MAGIC_EVD &&
+	     header->magic != DAPL_MAGIC_EP &&
+	     header->magic != DAPL_MAGIC_LMR &&
+	     header->magic != DAPL_MAGIC_RMR &&
+	     header->magic != DAPL_MAGIC_PZ &&
+	     header->magic != DAPL_MAGIC_PSP &&
+	     header->magic != DAPL_MAGIC_RSP &&
+	     header->magic != DAPL_MAGIC_CR)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	header->user_context = context;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_sp_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_sp_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_sp_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -39,12 +39,10 @@
 #include "dapl_sp_util.h"
 #include "dapl_cr_util.h"
 
-
 /*
  * Local definitions
  */
 
-
 /*
  * dapl_sp_alloc
  *
@@ -61,55 +59,47 @@
  *	pointer to sp info struct
  *
  */
-DAPL_SP *
-dapls_sp_alloc (
-	IN DAPL_IA		*ia_ptr,
-	IN DAT_BOOLEAN		is_psp )
+DAPL_SP *dapls_sp_alloc(IN DAPL_IA * ia_ptr, IN DAT_BOOLEAN is_psp)
 {
-    DAPL_SP		*sp_ptr;
+	DAPL_SP *sp_ptr;
 
-    /* Allocate EP */
-    sp_ptr = (DAPL_SP *)dapl_os_alloc (sizeof (DAPL_SP));
-    if ( sp_ptr == NULL )
-    {
-	return (NULL);
-    }
+	/* Allocate EP */
+	sp_ptr = (DAPL_SP *) dapl_os_alloc(sizeof(DAPL_SP));
+	if (sp_ptr == NULL) {
+		return (NULL);
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (sp_ptr, sizeof (DAPL_SP));
+	/* zero the structure */
+	dapl_os_memzero(sp_ptr, sizeof(DAPL_SP));
 
-    /*
-     * initialize the header
-     */
-    sp_ptr->header.provider            = ia_ptr->header.provider;
-    if ( is_psp )
-    {
-	sp_ptr->header.magic               = DAPL_MAGIC_PSP;
-	sp_ptr->header.handle_type         = DAT_HANDLE_TYPE_PSP;
-    }
-    else
-    {
-	sp_ptr->header.magic               = DAPL_MAGIC_RSP;
-	sp_ptr->header.handle_type         = DAT_HANDLE_TYPE_RSP;
-    }
-    sp_ptr->header.owner_ia            = ia_ptr;
-    sp_ptr->header.user_context.as_64  = 0;
-    sp_ptr->header.user_context.as_ptr = NULL;
-    dapl_llist_init_entry (&sp_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&sp_ptr->header.lock);
+	/*
+	 * initialize the header
+	 */
+	sp_ptr->header.provider = ia_ptr->header.provider;
+	if (is_psp) {
+		sp_ptr->header.magic = DAPL_MAGIC_PSP;
+		sp_ptr->header.handle_type = DAT_HANDLE_TYPE_PSP;
+	} else {
+		sp_ptr->header.magic = DAPL_MAGIC_RSP;
+		sp_ptr->header.handle_type = DAT_HANDLE_TYPE_RSP;
+	}
+	sp_ptr->header.owner_ia = ia_ptr;
+	sp_ptr->header.user_context.as_64 = 0;
+	sp_ptr->header.user_context.as_ptr = NULL;
+	dapl_llist_init_entry(&sp_ptr->header.ia_list_entry);
+	dapl_os_lock_init(&sp_ptr->header.lock);
 
-#if defined(_WIN32) || defined(_WIN64)
-    dapl_os_wait_object_init( &sp_ptr->wait_object );
+#if defined(_VENDOR_IBAL_)
+	dapl_os_wait_object_init(&sp_ptr->wait_object);
 #endif
-    /*
-     * Initialize the Body (set to NULL above)
-     */
-    dapl_llist_init_head (&sp_ptr->cr_list_head);
+	/*
+	 * Initialize the Body (set to NULL above)
+	 */
+	dapl_llist_init_head(&sp_ptr->cr_list_head);
 
-    return ( sp_ptr );
+	return (sp_ptr);
 }
 
-
 /*
  * dapl_sp_free
  *
@@ -125,24 +115,21 @@
  * 	none
  *
  */
-void
-dapls_sp_free_sp (
-	IN DAPL_SP		*sp_ptr )
+void dapls_sp_free_sp(IN DAPL_SP * sp_ptr)
 {
-    dapl_os_assert (sp_ptr->header.magic == DAPL_MAGIC_PSP ||
-		    sp_ptr->header.magic == DAPL_MAGIC_RSP);
-    dapl_os_assert (dapl_llist_is_empty (&sp_ptr->cr_list_head));
+	dapl_os_assert(sp_ptr->header.magic == DAPL_MAGIC_PSP ||
+		       sp_ptr->header.magic == DAPL_MAGIC_RSP);
+	dapl_os_assert(dapl_llist_is_empty(&sp_ptr->cr_list_head));
 
-#if defined(_WIN32) || defined(_WIN64)
-    dapl_os_wait_object_destroy( &sp_ptr->wait_object );
+#if defined(_VENDOR_IBAL_)
+	dapl_os_wait_object_destroy(&sp_ptr->wait_object);
 #endif
-    dapl_os_lock (&sp_ptr->header.lock);
-    sp_ptr->header.magic = DAPL_MAGIC_INVALID;/* reset magic to prevent reuse */
-    dapl_os_unlock (&sp_ptr->header.lock);
-    dapl_os_free (sp_ptr, sizeof (DAPL_SP));
+	dapl_os_lock(&sp_ptr->header.lock);
+	sp_ptr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
+	dapl_os_unlock(&sp_ptr->header.lock);
+	dapl_os_free(sp_ptr, sizeof(DAPL_SP));
 }
 
-
 /*
  * dapl_cr_link_cr
  *
@@ -159,20 +146,15 @@
  * 	none
  *
  */
-void
-dapl_sp_link_cr (
-	IN DAPL_SP		*sp_ptr,
-	IN DAPL_CR		*cr_ptr )
+void dapl_sp_link_cr(IN DAPL_SP * sp_ptr, IN DAPL_CR * cr_ptr)
 {
-    dapl_os_lock (&sp_ptr->header.lock);
-    dapl_llist_add_tail (&sp_ptr->cr_list_head,
-			 &cr_ptr->header.ia_list_entry,
-			 cr_ptr);
-    sp_ptr->cr_list_count++;
-    dapl_os_unlock (&sp_ptr->header.lock);
+	dapl_os_lock(&sp_ptr->header.lock);
+	dapl_llist_add_tail(&sp_ptr->cr_list_head,
+			    &cr_ptr->header.ia_list_entry, cr_ptr);
+	sp_ptr->cr_list_count++;
+	dapl_os_unlock(&sp_ptr->header.lock);
 }
 
-
 /*
  * dapl_sp_search_cr
  *
@@ -192,38 +174,31 @@
  * 	cr_ptr_fnd	Pointer to matching DAPL_CR
  *
  */
-DAPL_CR *
-dapl_sp_search_cr (
-	IN DAPL_SP		*sp_ptr,
-	IN  dp_ib_cm_handle_t   ib_cm_handle )
+DAPL_CR *dapl_sp_search_cr(IN DAPL_SP * sp_ptr,
+			   IN dp_ib_cm_handle_t ib_cm_handle)
 {
-    DAPL_CR		*cr_ptr;
-    DAPL_CR		*cr_ptr_fnd;
+	DAPL_CR *cr_ptr;
+	DAPL_CR *cr_ptr_fnd;
 
-    if (dapl_llist_is_empty (&sp_ptr->cr_list_head))
-    {
-	return NULL;
-    }
-    cr_ptr_fnd = NULL;
-    cr_ptr = (DAPL_CR *) dapl_llist_peek_head (&sp_ptr->cr_list_head);
-    dapl_os_assert( cr_ptr );
+	if (dapl_llist_is_empty(&sp_ptr->cr_list_head)) {
+		return NULL;
+	}
+	cr_ptr_fnd = NULL;
+	cr_ptr = (DAPL_CR *) dapl_llist_peek_head(&sp_ptr->cr_list_head);
+	dapl_os_assert(cr_ptr);
 
-    do
-    {
-	if ( cr_ptr->ib_cm_handle == ib_cm_handle )
-	{
-	    cr_ptr_fnd = cr_ptr;
+	do {
+		if (cr_ptr->ib_cm_handle == ib_cm_handle) {
+			cr_ptr_fnd = cr_ptr;
 
-	    break;
-	}
-	cr_ptr = cr_ptr->header.ia_list_entry.flink->data;
-    } while ((void *)cr_ptr != (void *)sp_ptr->cr_list_head->data);
+			break;
+		}
+		cr_ptr = cr_ptr->header.ia_list_entry.flink->data;
+	} while ((void *)cr_ptr != (void *)sp_ptr->cr_list_head->data);
 
-    return cr_ptr_fnd;
+	return cr_ptr_fnd;
 }
 
-
-
 /*
  * dapl_sp_remove_cr
  *
@@ -242,26 +217,20 @@
  * 	void
  *
  */
-void
-dapl_sp_remove_cr (
-	IN  DAPL_SP		*sp_ptr,
-	IN  DAPL_CR		*cr_ptr )
+void dapl_sp_remove_cr(IN DAPL_SP * sp_ptr, IN DAPL_CR * cr_ptr)
 {
-    if ( dapl_llist_is_empty (&sp_ptr->cr_list_head) )
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-		  "**dapl_sp_remove_cr: removing from empty queue! sp %p\n",
-		      sp_ptr );
-	return;
-    }
+	if (dapl_llist_is_empty(&sp_ptr->cr_list_head)) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "**dapl_sp_remove_cr: removing from empty queue! sp %p\n",
+			     sp_ptr);
+		return;
+	}
 
-    dapl_llist_remove_entry (&sp_ptr->cr_list_head,
-			     &cr_ptr->header.ia_list_entry);
-    sp_ptr->cr_list_count--;
+	dapl_llist_remove_entry(&sp_ptr->cr_list_head,
+				&cr_ptr->header.ia_list_entry);
+	sp_ptr->cr_list_count--;
 }
 
-
-
 /*
  * dapl_sp_remove_ep
  *
@@ -278,31 +247,28 @@
  * 	void
  *
  */
-void
-dapl_sp_remove_ep (
-	IN  DAPL_EP		*ep_ptr )
+void dapl_sp_remove_ep(IN DAPL_EP * ep_ptr)
 {
-    DAPL_SP		*sp_ptr;
-    DAPL_CR		*cr_ptr;
+	DAPL_SP *sp_ptr;
+	DAPL_CR *cr_ptr;
 
-    cr_ptr = ep_ptr->cr_ptr;
+	cr_ptr = ep_ptr->cr_ptr;
 
-    if (cr_ptr != NULL)
-    {
-	sp_ptr = cr_ptr->sp_ptr;
+	if (cr_ptr != NULL) {
+		sp_ptr = cr_ptr->sp_ptr;
 
-	dapl_os_lock (&sp_ptr->header.lock);
+		dapl_os_lock(&sp_ptr->header.lock);
 
-	/* Remove the CR from the queue */
-	dapl_sp_remove_cr (sp_ptr, cr_ptr);
+		/* Remove the CR from the queue */
+		dapl_sp_remove_cr(sp_ptr, cr_ptr);
 
-	dapl_os_unlock (&sp_ptr->header.lock);
+		dapl_os_unlock(&sp_ptr->header.lock);
 
-	/* free memory outside of the lock */
-	dapls_cr_free (cr_ptr);
+		/* free memory outside of the lock */
+		dapls_cr_free(cr_ptr);
 
-	return;
-    }
+		return;
+	}
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -41,7 +41,6 @@
 #include "dapl_srq_util.h"
 #include "dapl_adapter_util.h"
 
-
 /*
  * dapl_srq_create
  *
@@ -67,89 +66,82 @@
  *	DAT_MODEL_NOT_SUPPORTED
  */
 DAT_RETURN DAT_API
-dapl_srq_create (
-	IN	DAT_IA_HANDLE	   	ia_handle,
-	IN	DAT_PZ_HANDLE	   	pz_handle,
-	IN	DAT_SRQ_ATTR		*srq_attr,
-	OUT	DAT_SRQ_HANDLE	   	*srq_handle )
+dapl_srq_create(IN DAT_IA_HANDLE ia_handle,
+		IN DAT_PZ_HANDLE pz_handle,
+		IN DAT_SRQ_ATTR * srq_attr, OUT DAT_SRQ_HANDLE * srq_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SRQ		*srq_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_SRQ *srq_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_srq_create (%p, %p, %p, %p)\n",
-		  ia_handle, 
-		  pz_handle, 
-		  srq_attr, 
-		  srq_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_srq_create (%p, %p, %p, %p)\n",
+		     ia_handle, pz_handle, srq_attr, srq_handle);
 
-    ia_ptr = (DAPL_IA *)ia_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 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;
-    }
+	DAPL_CNTR(ia_ptr, DCNT_IA_SRQ_CREATE);
 
-    if ( srq_handle == NULL )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-	goto bail;
-    }
-    if (DAPL_BAD_PTR(srq_attr))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	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;
+	}
 
-    /* Allocate SRQ */
-    srq_ptr = dapl_srq_alloc (ia_ptr, srq_attr);
-    if (srq_ptr == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (srq_handle == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
+	if (DAPL_BAD_PTR(srq_attr)) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    srq_ptr->param.ia_handle = (DAT_IA_HANDLE) ia_ptr;
-    srq_ptr->param.srq_state = DAT_SRQ_STATE_OPERATIONAL;
-    srq_ptr->param.pz_handle = pz_handle;
+	/* Allocate SRQ */
+	srq_ptr = dapl_srq_alloc(ia_ptr, srq_attr);
+	if (srq_ptr == NULL) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /*
-     * XXX Allocate provider resource here!!!
-     */
-    /* XXX */    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-    /* XXX */    dapl_srq_dealloc (srq_ptr);
-    /* XXX */    goto bail;
+	srq_ptr->param.ia_handle = (DAT_IA_HANDLE) ia_ptr;
+	srq_ptr->param.srq_state = DAT_SRQ_STATE_OPERATIONAL;
+	srq_ptr->param.pz_handle = pz_handle;
 
-    /* Link it onto the IA */
-    dapl_ia_link_srq (ia_ptr, srq_ptr);
+	/*
+	 * XXX Allocate provider resource here!!!
+	 */
+	/* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+	/* XXX */ dapl_srq_dealloc(srq_ptr);
+	/* XXX */ goto bail;
 
-    *srq_handle = srq_ptr;
+	/* Link it onto the IA */
+	dapl_ia_link_srq(ia_ptr, srq_ptr);
 
-bail:
-    return dat_status;
+	*srq_handle = srq_ptr;
+
+      bail:
+	return dat_status;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,69 +59,69 @@
  *	DAT_INVALID_PARAMETER
  *	DAT_INVALID_STATE
  */
-DAT_RETURN DAT_API
-dapl_srq_free (
-	IN	DAT_SRQ_HANDLE	   srq_handle)
+DAT_RETURN DAT_API dapl_srq_free(IN DAT_SRQ_HANDLE srq_handle)
 {
-    DAPL_SRQ		*srq_ptr;
-    DAPL_IA		*ia_ptr;
-    DAT_SRQ_PARAM	*param;
-    DAT_RETURN		dat_status;
+	DAPL_SRQ *srq_ptr;
+	DAPL_IA *ia_ptr;
+	DAT_SRQ_PARAM *param;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_srq_free (%p)\n", srq_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_free (%p)\n", srq_handle);
 
-    srq_ptr = (DAPL_SRQ *) srq_handle;
-    param = &srq_ptr->param;
+	srq_ptr = (DAPL_SRQ *) srq_handle;
+	param = &srq_ptr->param;
 
-    /*
-     * Verify parameter & state
-     */
-    if ( DAPL_BAD_HANDLE (srq_ptr, DAPL_MAGIC_SRQ ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-	goto bail;
-    }
-
-    if (dapl_os_atomic_read (&srq_ptr->srq_ref_count) != 0)
-    {
 	/*
-	 * The DAPL 1.2 spec says to return DAT_SRQ_IN_USE, which does
-	 * not exist. Have filed the following as an errata.
+	 * Verify parameter & state
 	 */
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_SRQ_IN_USE);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(srq_ptr, DAPL_MAGIC_SRQ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+		goto bail;
+	}
 
-    ia_ptr = srq_ptr->header.owner_ia;
+	if (dapl_os_atomic_read(&srq_ptr->srq_ref_count) != 0) {
+		/*
+		 * The DAPL 1.2 spec says to return DAT_SRQ_IN_USE, which does
+		 * not exist. Have filed the following as an errata.
+		 */
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_SRQ_IN_USE);
+		goto bail;
+	}
 
-    /*
-     * Do verification of parameters and the state change atomically.
-     */
-    dapl_os_lock ( &srq_ptr->header.lock );
+	ia_ptr = srq_ptr->header.owner_ia;
 
-    /* Remove the SRQ from the IA */
-    dapl_ia_unlink_srq ( ia_ptr, srq_ptr );
+	DAPL_CNTR(ia_ptr, DCNT_IA_SRQ_FREE);
 
-    dapl_os_unlock (&srq_ptr->header.lock);
+	/*
+	 * Do verification of parameters and the state change atomically.
+	 */
+	dapl_os_lock(&srq_ptr->header.lock);
 
-    /*
-     * Finish tearing everything down.
-     */
+	/* Remove the SRQ from the IA */
+	dapl_ia_unlink_srq(ia_ptr, srq_ptr);
 
-    /*
-     * Take care of the transport resource
-     */
+	dapl_os_unlock(&srq_ptr->header.lock);
 
-    /* XXX Put provider code here!!! */
+	/*
+	 * Finish tearing everything down.
+	 */
 
-    /* Free the resource */
-    dapl_srq_dealloc (srq_ptr);
+	/*
+	 * Take care of the transport resource
+	 */
 
-bail:
-    return dat_status;
+	/* XXX Put provider code here!!! */
 
+	/* Free the resource */
+	dapl_srq_dealloc(srq_ptr);
+
+      bail:
+	return dat_status;
+
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_post_recv.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_post_recv.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_post_recv.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -68,63 +68,56 @@
  * 	DAT_PROVILEGES_VIOLATION
  */
 DAT_RETURN DAT_API
-dapl_srq_post_recv (
-	IN	DAT_SRQ_HANDLE	   	srq_handle,
-	IN	DAT_COUNT	   	num_segments,
-	IN	DAT_LMR_TRIPLET	   	*local_iov,
-	IN	DAT_DTO_COOKIE	   	user_cookie)
+dapl_srq_post_recv(IN DAT_SRQ_HANDLE srq_handle,
+		   IN DAT_COUNT num_segments,
+		   IN DAT_LMR_TRIPLET * local_iov,
+		   IN DAT_DTO_COOKIE user_cookie)
 {
-    DAPL_SRQ 		*srq_ptr;
-    DAPL_COOKIE		*cookie;
-    DAT_RETURN		dat_status;
+	DAPL_SRQ *srq_ptr;
+	DAPL_COOKIE *cookie;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_srq_post_recv (%p, %d, %p, %p)\n",
-		  srq_handle,
-		  num_segments,
-		  local_iov,
-		  user_cookie.as_64);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_srq_post_recv (%p, %d, %p, %p)\n",
+		     srq_handle, num_segments, local_iov, user_cookie.as_64);
 
-    if ( DAPL_BAD_HANDLE (srq_handle, DAPL_MAGIC_SRQ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+		goto bail;
+	}
 
-    srq_ptr = (DAPL_SRQ *) srq_handle;
+	srq_ptr = (DAPL_SRQ *) srq_handle;
 
-    /*
-     * Synchronization ok since this buffer is only used for receive
-     * requests, which aren't allowed to race with each other. The
-     * app must syncronize access to the SRQ.
-     */
-    dat_status = dapls_dto_cookie_alloc (&srq_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. The
+	 * app must syncronize access to the SRQ.
+	 */
+	dat_status = dapls_dto_cookie_alloc(&srq_ptr->recv_buffer,
+					    DAPL_DTO_TYPE_RECV,
+					    user_cookie, &cookie);
+	if (DAT_SUCCESS != dat_status) {
+		goto bail;
+	}
 
-    /*
-     * Take reference before posting to avoid race conditions with
-     * completions
-     */
-    dapl_os_atomic_inc (&srq_ptr->recv_count);
+	/*
+	 * Take reference before posting to avoid race conditions with
+	 * completions
+	 */
+	dapl_os_atomic_inc(&srq_ptr->recv_count);
 
-    /*
-     * Invoke provider specific routine to post DTO
-     */
-    /* XXX Put code here XXX */
-    /* XXX */    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+	/*
+	 * Invoke provider specific routine to post DTO
+	 */
+	/* XXX Put code here XXX */
+	/* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 
-    if ( dat_status != DAT_SUCCESS )
-    {
-	dapl_os_atomic_dec (&srq_ptr->recv_count);
-	dapls_cookie_dealloc (&srq_ptr->recv_buffer, cookie);
-    }
+	if (dat_status != DAT_SUCCESS) {
+		dapl_os_atomic_dec(&srq_ptr->recv_count);
+		dapls_cookie_dealloc(&srq_ptr->recv_buffer, cookie);
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,43 +59,39 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_srq_query (
-	IN	DAT_SRQ_HANDLE		srq_handle,
-	IN	DAT_SRQ_PARAM_MASK	srq_param_mask,
-	OUT	DAT_SRQ_PARAM		*srq_param)
+dapl_srq_query(IN DAT_SRQ_HANDLE srq_handle,
+	       IN DAT_SRQ_PARAM_MASK srq_param_mask,
+	       OUT DAT_SRQ_PARAM * srq_param)
 {
-    DAPL_SRQ		*srq_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_SRQ *srq_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_srq_query (%p, %x, %p)\n", 
-		  srq_handle, 
-		  srq_param_mask, 
-		  srq_param);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_srq_query (%p, %x, %p)\n",
+		     srq_handle, srq_param_mask, srq_param);
 
-    if ( DAPL_BAD_HANDLE (srq_handle, DAPL_MAGIC_SRQ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-	goto bail;
-    }
-    if (srq_param == NULL)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+		goto bail;
+	}
+	if (srq_param == NULL) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    srq_ptr = (DAPL_SRQ *) srq_handle;
+	srq_ptr = (DAPL_SRQ *) srq_handle;
 
-    /*
-     * XXX Need to calculate available_dto_count and outstanding_dto_count
-     */
-    srq_ptr->param.available_dto_count   = DAT_VALUE_UNKNOWN;
-    srq_ptr->param.outstanding_dto_count = DAT_VALUE_UNKNOWN;
+	/*
+	 * XXX Need to calculate available_dto_count and outstanding_dto_count
+	 */
+	srq_ptr->param.available_dto_count = DAT_VALUE_UNKNOWN;
+	srq_ptr->param.outstanding_dto_count = DAT_VALUE_UNKNOWN;
 
-    *srq_param = srq_ptr->param;
+	*srq_param = srq_ptr->param;
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_resize.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_resize.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_resize.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -36,7 +36,7 @@
  *
  * $Id:$
  **********************************************************************/
- 
+
 #include "dapl.h"
 #include "dapl_srq_util.h"
 #include "dapl_adapter_util.h"
@@ -64,43 +64,40 @@
  */
 
 DAT_RETURN DAT_API
-dapl_srq_resize (
-	IN	DAT_SRQ_HANDLE	   srq_handle,
-	IN	DAT_COUNT	   srq_max_recv_dto )
+dapl_srq_resize(IN DAT_SRQ_HANDLE srq_handle, IN DAT_COUNT srq_max_recv_dto)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_SRQ		*srq_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia_ptr;
+	DAPL_SRQ *srq_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_srq_resize (%p, %d)\n",
-		  srq_handle, srq_max_recv_dto);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_resize (%p, %d)\n",
+		     srq_handle, srq_max_recv_dto);
 
-    if (DAPL_BAD_HANDLE (srq_handle, DAPL_MAGIC_SRQ))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+		goto bail;
+	}
 
-    srq_ptr = (DAPL_SRQ *)srq_handle;
-    ia_ptr  = srq_ptr->header.owner_ia;
+	srq_ptr = (DAPL_SRQ *) srq_handle;
+	ia_ptr = srq_ptr->header.owner_ia;
 
-    /*
-     * Check for nonsense requests per the spec
-     */
-    if (srq_max_recv_dto <= srq_ptr->param.low_watermark)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_NO_SUBTYPE);
-	goto bail;
-    }
+	/*
+	 * Check for nonsense requests per the spec
+	 */
+	if (srq_max_recv_dto <= srq_ptr->param.low_watermark) {
+		dat_status = DAT_ERROR(DAT_INVALID_STATE, DAT_NO_SUBTYPE);
+		goto bail;
+	}
 
-    /* XXX Put implementation here XXX */
+	/* XXX Put implementation here XXX */
 
-    /* XXX */    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+	/* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_set_lw.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_set_lw.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_set_lw.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -36,7 +36,7 @@
  *
  * $Id:$
  **********************************************************************/
- 
+
 #include "dapl.h"
 #include "dapl_srq_util.h"
 #include "dapl_adapter_util.h"
@@ -64,32 +64,30 @@
  */
 
 DAT_RETURN DAT_API
-dapl_srq_set_lw (
-	IN	DAT_SRQ_HANDLE	   srq_handle,
-	IN	DAT_COUNT	   low_watermark )
+dapl_srq_set_lw(IN DAT_SRQ_HANDLE srq_handle, IN DAT_COUNT low_watermark)
 {
-    DAPL_SRQ		*srq_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_SRQ *srq_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API, "dapl_srq_set_lw (%p, %d)\n",
-		  srq_handle, low_watermark);
+	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_srq_set_lw (%p, %d)\n",
+		     srq_handle, low_watermark);
 
-    if (DAPL_BAD_HANDLE (srq_handle, DAPL_MAGIC_SRQ))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(srq_handle, DAPL_MAGIC_SRQ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+		goto bail;
+	}
 
-    srq_ptr = (DAPL_SRQ *)srq_handle;
+	srq_ptr = (DAPL_SRQ *) srq_handle;
 
-    /* XXX Put implementation here XXX */
+	/* XXX Put implementation here XXX */
 
-    /* XXX */    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+	/* XXX */ dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_srq_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,62 +54,54 @@
  * 	pointer to srq
  *
  */
-DAPL_SRQ *
-dapl_srq_alloc (
-	IN DAPL_IA		*ia_ptr,
-	IN const DAT_SRQ_ATTR	*srq_attr )
+DAPL_SRQ *dapl_srq_alloc(IN DAPL_IA * ia_ptr, IN const DAT_SRQ_ATTR * srq_attr)
 {
-    DAPL_SRQ		*srq_ptr;
+	DAPL_SRQ *srq_ptr;
 
-    /* Allocate SRQ */
-    srq_ptr = (DAPL_SRQ *)dapl_os_alloc (sizeof (DAPL_SRQ));
+	/* Allocate SRQ */
+	srq_ptr = (DAPL_SRQ *) dapl_os_alloc(sizeof(DAPL_SRQ));
 
-    if ( srq_ptr == NULL )
-    {
-	goto bail;
-    }
+	if (srq_ptr == NULL) {
+		goto bail;
+	}
 
-    /* zero the structure */
-    dapl_os_memzero (srq_ptr, sizeof (DAPL_SRQ));
+	/* zero the structure */
+	dapl_os_memzero(srq_ptr, sizeof(DAPL_SRQ));
 
-    /*
-     * initialize the header
-     */
-    srq_ptr->header.provider            = ia_ptr->header.provider;
-    srq_ptr->header.magic               = DAPL_MAGIC_SRQ;
-    srq_ptr->header.handle_type         = DAT_HANDLE_TYPE_SRQ;
-    srq_ptr->header.owner_ia            = ia_ptr;
-    srq_ptr->header.user_context.as_64  = 0;
-    srq_ptr->header.user_context.as_ptr = NULL;
-    dapl_os_atomic_set (&srq_ptr->srq_ref_count, 0);
+	/*
+	 * initialize the header
+	 */
+	srq_ptr->header.provider = ia_ptr->header.provider;
+	srq_ptr->header.magic = DAPL_MAGIC_SRQ;
+	srq_ptr->header.handle_type = DAT_HANDLE_TYPE_SRQ;
+	srq_ptr->header.owner_ia = ia_ptr;
+	srq_ptr->header.user_context.as_64 = 0;
+	srq_ptr->header.user_context.as_ptr = NULL;
+	dapl_os_atomic_set(&srq_ptr->srq_ref_count, 0);
 
-    dapl_llist_init_entry (&srq_ptr->header.ia_list_entry);
-    dapl_os_lock_init (&srq_ptr->header.lock);
+	dapl_llist_init_entry(&srq_ptr->header.ia_list_entry);
+	dapl_os_lock_init(&srq_ptr->header.lock);
 
-    /*
-     * Initialize the body. 
-     * XXX Assume srq_attrs is required
-     */
-    srq_ptr->param.max_recv_dtos = srq_attr->max_recv_dtos;
-    srq_ptr->param.max_recv_iov  = srq_attr->max_recv_iov;
-    srq_ptr->param.low_watermark = srq_attr->low_watermark;
+	/*
+	 * Initialize the body. 
+	 * XXX Assume srq_attrs is required
+	 */
+	srq_ptr->param.max_recv_dtos = srq_attr->max_recv_dtos;
+	srq_ptr->param.max_recv_iov = srq_attr->max_recv_iov;
+	srq_ptr->param.low_watermark = srq_attr->low_watermark;
 
-    /* Get a cookie buffer to track outstanding recvs */
-    if ( DAT_SUCCESS != dapls_cb_create (
-	     &srq_ptr->recv_buffer,
-	     (DAPL_EP *) srq_ptr,	/* just saves the value */
-	     srq_ptr->param.max_recv_dtos) )
-    {
-	dapl_srq_dealloc (srq_ptr);
-	srq_ptr = NULL;
-	goto bail;
-    }
+	/* Get a cookie buffer to track outstanding recvs */
+	if (DAT_SUCCESS != dapls_cb_create(&srq_ptr->recv_buffer, (DAPL_EP *) srq_ptr,	/* just saves the value */
+					   srq_ptr->param.max_recv_dtos)) {
+		dapl_srq_dealloc(srq_ptr);
+		srq_ptr = NULL;
+		goto bail;
+	}
 
-bail:
-    return srq_ptr;
+      bail:
+	return srq_ptr;
 }
 
-
 /*
  * dapl_srq_dealloc
  *
@@ -125,21 +117,18 @@
  * 	none
  *
  */
-void
-dapl_srq_dealloc (
-	IN DAPL_SRQ		*srq_ptr )
+void dapl_srq_dealloc(IN DAPL_SRQ * srq_ptr)
 {
-    dapl_os_assert (srq_ptr->header.magic == DAPL_MAGIC_SRQ);
+	dapl_os_assert(srq_ptr->header.magic == DAPL_MAGIC_SRQ);
 
-    srq_ptr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
-    dapl_ia_unlink_srq (srq_ptr->header.owner_ia, srq_ptr);
-    dapls_cb_free (&srq_ptr->recv_buffer);
-    dapl_os_lock_destroy (&srq_ptr->header.lock);
+	srq_ptr->header.magic = DAPL_MAGIC_INVALID;	/* reset magic to prevent reuse */
+	dapl_ia_unlink_srq(srq_ptr->header.owner_ia, srq_ptr);
+	dapls_cb_free(&srq_ptr->recv_buffer);
+	dapl_os_lock_destroy(&srq_ptr->header.lock);
 
-    dapl_os_free (srq_ptr, sizeof (DAPL_SRQ));
+	dapl_os_free(srq_ptr, sizeof(DAPL_SRQ));
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_timer_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_timer_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/common/dapl_timer_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -52,34 +52,29 @@
 #include "dapl.h"
 #include "dapl_timer_util.h"
 
-
-struct timer_head
-{
-    DAPL_LLIST_HEAD		timer_list_head;
-    DAPL_OS_LOCK		lock;
-    DAPL_OS_WAIT_OBJECT		wait_object;
-    DAPL_OS_THREAD		timeout_thread_handle;
+struct timer_head {
+	DAPL_LLIST_HEAD timer_list_head;
+	DAPL_OS_LOCK lock;
+	DAPL_OS_WAIT_OBJECT wait_object;
+	DAPL_OS_THREAD timeout_thread_handle;
 } g_daplTimerHead;
 
 typedef struct timer_head DAPL_TIMER_HEAD;
 
+void dapls_timer_thread(void *arg);
 
-void dapls_timer_thread (void	*arg );
-
-void
-dapls_timer_init ()
+void dapls_timer_init()
 {
-    /*
-     * Set up the timer thread elements. The timer thread isn't
-     * started until it is actually needed
-     */
-    g_daplTimerHead.timer_list_head = NULL;
-    dapl_os_lock_init ( &g_daplTimerHead.lock );
-    dapl_os_wait_object_init ( &g_daplTimerHead.wait_object );
-    g_daplTimerHead.timeout_thread_handle = 0;
+	/*
+	 * Set up the timer thread elements. The timer thread isn't
+	 * started until it is actually needed
+	 */
+	g_daplTimerHead.timer_list_head = NULL;
+	dapl_os_lock_init(&g_daplTimerHead.lock);
+	dapl_os_wait_object_init(&g_daplTimerHead.wait_object);
+	g_daplTimerHead.timeout_thread_handle = 0;
 }
 
-
 /*
  * dapls_timer_set
  *
@@ -97,110 +92,104 @@
  *
  */
 DAT_RETURN
-dapls_timer_set (
-	IN  DAPL_OS_TIMER		*timer,
-	IN  void			(*func)	(uintptr_t),
-	IN  void			*data,
-	IN  DAPL_OS_TIMEVAL		expires )
+dapls_timer_set(IN DAPL_OS_TIMER * timer,
+		IN void (*func) (uintptr_t),
+		IN void *data, IN DAPL_OS_TIMEVAL expires)
 {
-    DAPL_OS_TIMER		*list_ptr;
-    DAPL_OS_TIMEVAL		cur_time;
-    DAT_BOOLEAN			wakeup_tmo_thread;
+	DAPL_OS_TIMER *list_ptr;
+	DAPL_OS_TIMEVAL cur_time;
+	DAT_BOOLEAN wakeup_tmo_thread;
 
-    DAPL_CNTR(DCNT_TIMER_SET);
-    /*
-     * Start the timer thread the first time we need a timer
-     */
-    if ( g_daplTimerHead.timeout_thread_handle == 0 )
-    {
-	dapl_os_thread_create ( dapls_timer_thread,
-				&g_daplTimerHead,
-				&g_daplTimerHead.timeout_thread_handle );
-    }
+	/*
+	 * Start the timer thread the first time we need a timer
+	 */
+	if (g_daplTimerHead.timeout_thread_handle == 0) {
+		dapl_os_thread_create(dapls_timer_thread,
+				      &g_daplTimerHead,
+				      &g_daplTimerHead.timeout_thread_handle);
+	}
 
-    dapl_llist_init_entry ( &timer->list_entry);
-    wakeup_tmo_thread = DAT_FALSE;
-    dapl_os_get_time ( &cur_time );
-    timer->expires  = cur_time + expires; /* calculate future time */
-    timer->function = func;
-    timer->data     = data;
+	dapl_llist_init_entry(&timer->list_entry);
+	wakeup_tmo_thread = DAT_FALSE;
+	dapl_os_get_time(&cur_time);
+	timer->expires = cur_time + expires;	/* calculate future time */
+	timer->function = func;
+	timer->data = data;
 
-    /*
-     * Put the element on the queue: sorted by wakeup time, eariliest
-     * first.
-     */
-    dapl_os_lock ( &g_daplTimerHead.lock );
-    /*
-     * Deal with 3 cases due to our list structure:
-     * 1) list is empty: become the list head
-     * 2) New timer is sooner than list head: become the list head
-     * 3) otherwise, sort the timer into the list, no need to wake
-     *    the timer thread up
-     */
-    if ( dapl_llist_is_empty ( &g_daplTimerHead.timer_list_head) )
-    {
-	/* Case 1: add entry to head of list */
-	dapl_llist_add_head ( &g_daplTimerHead.timer_list_head,
-			      (DAPL_LLIST_ENTRY *)&timer->list_entry,
-			      timer );
-	wakeup_tmo_thread = DAT_TRUE;
-    }
-    else
-    {
-	list_ptr = (DAPL_OS_TIMER *)
-		dapl_llist_peek_head (&g_daplTimerHead.timer_list_head);
+	/*
+	 * Put the element on the queue: sorted by wakeup time, eariliest
+	 * first.
+	 */
+	dapl_os_lock(&g_daplTimerHead.lock);
+	/*
+	 * Deal with 3 cases due to our list structure:
+	 * 1) list is empty: become the list head
+	 * 2) New timer is sooner than list head: become the list head
+	 * 3) otherwise, sort the timer into the list, no need to wake
+	 *    the timer thread up
+	 */
+	if (dapl_llist_is_empty(&g_daplTimerHead.timer_list_head)) {
+		/* Case 1: add entry to head of list */
+		dapl_llist_add_head(&g_daplTimerHead.timer_list_head,
+				    (DAPL_LLIST_ENTRY *) & timer->list_entry,
+				    timer);
+		wakeup_tmo_thread = DAT_TRUE;
+	} else {
+		list_ptr = (DAPL_OS_TIMER *)
+		    dapl_llist_peek_head(&g_daplTimerHead.timer_list_head);
 
-	if ( timer->expires < list_ptr->expires )
-	{
-	    /* Case 2: add entry to head of list */
-	    dapl_llist_add_head ( &g_daplTimerHead.timer_list_head,
-				  (DAPL_LLIST_ENTRY *)&timer->list_entry,
-				  timer );
-	    wakeup_tmo_thread = DAT_TRUE;
-	}
-	else
-	{
-	    /* Case 3: figure out where entry goes in sorted list */
-	    list_ptr = dapl_llist_next_entry (
-			    &g_daplTimerHead.timer_list_head,
-			    (DAPL_LLIST_ENTRY *)&list_ptr->list_entry);
+		if (timer->expires < list_ptr->expires) {
+			/* Case 2: add entry to head of list */
+			dapl_llist_add_head(&g_daplTimerHead.timer_list_head,
+					    (DAPL_LLIST_ENTRY *) & timer->
+					    list_entry, timer);
+			wakeup_tmo_thread = DAT_TRUE;
+		} else {
+			/* Case 3: figure out where entry goes in sorted list */
+			list_ptr =
+			    dapl_llist_next_entry(&g_daplTimerHead.
+						  timer_list_head,
+						  (DAPL_LLIST_ENTRY *) &
+						  list_ptr->list_entry);
 
-	    while (list_ptr != NULL)
-	    {
-		if ( timer->expires < list_ptr->expires )
-		{
-		    dapl_llist_add_entry ( &g_daplTimerHead.timer_list_head,
-					   (DAPL_LLIST_ENTRY *)&list_ptr->list_entry,
-					   (DAPL_LLIST_ENTRY *)&timer->list_entry,
-					   timer );
-		    break;
+			while (list_ptr != NULL) {
+				if (timer->expires < list_ptr->expires) {
+					dapl_llist_add_entry(&g_daplTimerHead.
+							     timer_list_head,
+							     (DAPL_LLIST_ENTRY
+							      *) & list_ptr->
+							     list_entry,
+							     (DAPL_LLIST_ENTRY
+							      *) & timer->
+							     list_entry, timer);
+					break;
 
+				}
+				list_ptr =
+				    dapl_llist_next_entry(&g_daplTimerHead.
+							  timer_list_head,
+							  (DAPL_LLIST_ENTRY *) &
+							  list_ptr->list_entry);
+			}
+			if (list_ptr == NULL) {
+				/* entry goes to the end of the list */
+				dapl_llist_add_tail(&g_daplTimerHead.
+						    timer_list_head,
+						    (DAPL_LLIST_ENTRY *) &
+						    timer->list_entry, timer);
+			}
 		}
-		list_ptr = dapl_llist_next_entry (
-				&g_daplTimerHead.timer_list_head,
-				(DAPL_LLIST_ENTRY *)&list_ptr->list_entry);
-	    }
-	    if (list_ptr == NULL)
-	    {
-		/* entry goes to the end of the list */
-		dapl_llist_add_tail ( &g_daplTimerHead.timer_list_head,
-				      (DAPL_LLIST_ENTRY *)&timer->list_entry,
-				      timer );
-	    }
+
 	}
+	dapl_os_unlock(&g_daplTimerHead.lock);
 
-    }
-    dapl_os_unlock ( &g_daplTimerHead.lock );
+	if (wakeup_tmo_thread == DAT_TRUE) {
+		dapl_os_wait_object_wakeup(&g_daplTimerHead.wait_object);
+	}
 
-    if (wakeup_tmo_thread == DAT_TRUE)
-    {
-	dapl_os_wait_object_wakeup (&g_daplTimerHead.wait_object);
-    }
-
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapls_os_timer_cancel
  *
@@ -212,31 +201,27 @@
  * Returns:
  *	no return value
  */
-void
-dapls_timer_cancel (
-	IN  DAPL_OS_TIMER		*timer)
+void dapls_timer_cancel(IN DAPL_OS_TIMER * timer)
 {
-    DAPL_CNTR(DCNT_TIMER_CANCEL);
-    dapl_os_lock ( &g_daplTimerHead.lock );
-    /*
-     * make sure the entry has not been removed by another thread
-     */
-    if ( ! dapl_llist_is_empty ( &g_daplTimerHead.timer_list_head ) &&
-	 timer->list_entry.list_head == &g_daplTimerHead.timer_list_head )
-    {
-	dapl_llist_remove_entry ( &g_daplTimerHead.timer_list_head,
-				  (DAPL_LLIST_ENTRY *)&timer->list_entry );
-    }
-    /*
-     * If this was the first entry on the queue we could awaken the
-     * thread and have it reset the list; but it will just wake up
-     * and find that the timer entry has been removed, then go back
-     * to sleep, so don't bother.
-     */
-    dapl_os_unlock ( &g_daplTimerHead.lock );
+	dapl_os_lock(&g_daplTimerHead.lock);
+	/*
+	 * make sure the entry has not been removed by another thread
+	 */
+	if (!dapl_llist_is_empty(&g_daplTimerHead.timer_list_head) &&
+	    timer->list_entry.list_head == &g_daplTimerHead.timer_list_head) {
+		dapl_llist_remove_entry(&g_daplTimerHead.timer_list_head,
+					(DAPL_LLIST_ENTRY *) & timer->
+					list_entry);
+	}
+	/*
+	 * If this was the first entry on the queue we could awaken the
+	 * thread and have it reset the list; but it will just wake up
+	 * and find that the timer entry has been removed, then go back
+	 * to sleep, so don't bother.
+	 */
+	dapl_os_unlock(&g_daplTimerHead.lock);
 }
 
-
 /*
  * dapls_timer_thread
  *
@@ -252,82 +237,79 @@
  * Returns:
  *	no return value
  */
-void
-dapls_timer_thread (
-	void			*arg )
+void dapls_timer_thread(void *arg)
 {
-    DAPL_OS_TIMER		*list_ptr;
-    DAPL_OS_TIMEVAL		cur_time;
-    DAT_RETURN			dat_status;
-    DAPL_TIMER_HEAD		*timer_head;
+	DAPL_OS_TIMER *list_ptr;
+	DAPL_OS_TIMEVAL cur_time;
+	DAT_RETURN dat_status;
+	DAPL_TIMER_HEAD *timer_head;
 
-    timer_head = arg;
+	timer_head = arg;
 
-    for (;;)
-    {
-	if ( dapl_llist_is_empty ( &timer_head->timer_list_head ) )
-	{
-	    dat_status = dapl_os_wait_object_wait (&timer_head->wait_object,
-						   DAT_TIMEOUT_INFINITE );
-	}
+	for (;;) {
+		if (dapl_llist_is_empty(&timer_head->timer_list_head)) {
+			dat_status =
+			    dapl_os_wait_object_wait(&timer_head->wait_object,
+						     DAT_TIMEOUT_INFINITE);
+		}
 
-	/*
-	 * Lock policy:
-	 * While this thread is accessing the timer list, it holds the
-	 * lock.  Otherwise, it doesn't.
-	 */
-	dapl_os_lock ( &timer_head->lock );
-	while ( ! dapl_llist_is_empty ( &timer_head->timer_list_head) )
-	{
-	    list_ptr = (DAPL_OS_TIMER *)
-		dapl_llist_peek_head ( &g_daplTimerHead.timer_list_head );
-	    dapl_os_get_time ( &cur_time );
-
-	    if ( list_ptr->expires <= cur_time )
-	    {
 		/*
-		 * Remove the entry from the list. Sort out how much
-		 * time we need to sleep for the next one
+		 * Lock policy:
+		 * While this thread is accessing the timer list, it holds the
+		 * lock.  Otherwise, it doesn't.
 		 */
-		list_ptr = dapl_llist_remove_head ( &timer_head->timer_list_head );
-		dapl_os_unlock ( &timer_head->lock );
+		dapl_os_lock(&timer_head->lock);
+		while (!dapl_llist_is_empty(&timer_head->timer_list_head)) {
+			list_ptr = (DAPL_OS_TIMER *)
+			    dapl_llist_peek_head(&g_daplTimerHead.
+						 timer_list_head);
+			dapl_os_get_time(&cur_time);
 
+			if (list_ptr->expires <= cur_time) {
+				/*
+				 * Remove the entry from the list. Sort out how much
+				 * time we need to sleep for the next one
+				 */
+				list_ptr =
+				    dapl_llist_remove_head(&timer_head->
+							   timer_list_head);
+				dapl_os_unlock(&timer_head->lock);
+
+				/*
+				 * Invoke the user callback
+				 */
+				list_ptr->function((uintptr_t) list_ptr->data);
+				/* timer structure was allocated by caller, we don't
+				 * free it here.
+				 */
+
+				/* reacquire the lock */
+				dapl_os_lock(&timer_head->lock);
+			} else {
+				dapl_os_unlock(&timer_head->lock);
+				dat_status =
+				    dapl_os_wait_object_wait(&timer_head->
+							     wait_object,
+							     (DAT_TIMEOUT)
+							     (list_ptr->
+							      expires -
+							      cur_time));
+				dapl_os_lock(&timer_head->lock);
+			}
+		}
 		/*
-		 * Invoke the user callback
+		 * release the lock before going back to the top to sleep
 		 */
-		list_ptr->function ( (uintptr_t)list_ptr->data );
-		/* timer structure was allocated by caller, we don't
-		 * free it here.
-		 */
+		dapl_os_unlock(&timer_head->lock);
 
-		/* reacquire the lock */
-		dapl_os_lock ( &timer_head->lock );
-	    }
-	    else
-	    {
-		dapl_os_unlock ( &timer_head->lock );
-		dat_status =
-		    dapl_os_wait_object_wait ( &timer_head->wait_object,
-					       (DAT_TIMEOUT) (list_ptr->expires - cur_time) );
-		dapl_os_lock ( &timer_head->lock );
-	    }
-	}
-	/*
-	 * release the lock before going back to the top to sleep
-	 */
-	dapl_os_unlock ( &timer_head->lock );
-
-	if ( dat_status == DAT_INTERNAL_ERROR )
-	{
-	    /*
-	     * XXX What do we do here?
-	     */
-	}
-    } /* for (;;) */
+		if (dat_status == DAT_INTERNAL_ERROR) {
+			/*
+			 * XXX What do we do here?
+			 */
+		}
+	}			/* for (;;) */
 }
 
-
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -313,6 +313,9 @@
     DAPL_LLIST_HEAD	psp_list_head;		/* PSP queue */
     DAPL_LLIST_HEAD	rsp_list_head;		/* RSP queue */
     DAPL_LLIST_HEAD	srq_list_head;		/* SRQ queue */
+#ifdef DAPL_COUNTERS
+    void		*cntrs;
+#endif
 };
 
 /* DAPL_CNO maps to DAT_CNO_HANDLE */
@@ -388,6 +391,10 @@
 
     DAT_COUNT		threshold;
     DAPL_EVD_COMPLETION	completion_type;
+
+#ifdef DAPL_COUNTERS
+    void		*cntrs;
+#endif
 };
 
 /* DAPL_PRIVATE used to pass private data in a connection */
@@ -472,6 +479,9 @@
     DAT_BOOLEAN         sent_discreq;
     dp_ib_cm_handle_t   ibal_cm_handle;
 #endif
+#ifdef DAPL_COUNTERS
+    void		*cntrs;
+#endif
 };
 
 /* DAPL_SRQ maps to DAT_SRQ_HANDLE */
@@ -543,7 +553,7 @@
     ib_cm_srvc_handle_t	cm_srvc_handle; /* Used by Mellanox CM */
     DAPL_LLIST_HEAD	cr_list_head;	/* CR pending queue */
     DAT_COUNT		cr_list_count;	/* count of CRs on queue */
-#if _VENDOR_IBAL_
+#if defined(_VENDOR_IBAL_)
     DAPL_OS_WAIT_OBJECT wait_object;    /* cancel & destroy. */
 #endif
 };

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl_debug.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl_debug.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/include/dapl_debug.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -83,66 +83,30 @@
 #define dapl_log g_dapl_dbg_type==0 ? (void) 1 : dapl_internal_dbg_log
 
 #if defined(DAPL_DBG)
-
 #define dapl_dbg_log g_dapl_dbg_type==0 ? (void) 1 : dapl_internal_dbg_log
-
-#else  /* !DAPL_DBG */
-
-#if defined(_WIN32) || defined(_WIN64)
-/* sigh - no support for (...) in macros. Compiler should optimize this away */
-static __inline void dapl_dbg_log ( DAPL_DBG_TYPE type,  const char *fmt,  ...)
-{
-}
 #else
 #define dapl_dbg_log(...)
 #endif
 
-#endif /* !DAPL_DBG */
+#include <dat2/dat_ib_extensions.h>
 
-/*
- * Counters
- */
-#define DCNT_EP_CREATE			0
-#define DCNT_EP_FREE			1
-#define DCNT_EP_CONNECT			2
-#define DCNT_EP_DISCONNECT		3
-#define DCNT_POST_SEND			4
-#define DCNT_POST_RECV			5
-#define DCNT_POST_RDMA_WRITE		6
-#define DCNT_POST_RDMA_READ		7
-#define DCNT_EVD_CREATE			8
-#define DCNT_EVD_FREE			9
-#define DCNT_EVD_WAIT			10
-#define DCNT_EVD_WAIT_BLOCKED		11
-#define DCNT_EVD_WAIT_CMP_NTFY		12
-#define DCNT_EVD_DTO_CALLBACK		13
-#define DCNT_EVD_CONN_CALLBACK		14
-#define DCNT_EVD_DEQUEUE		15
-#define DCNT_EVD_DEQUEUE_POLL		16
-#define DCNT_EVD_DEQUEUE_FOUND		17
-#define DCNT_EVD_DEQUEUE_NOT_FOUND	18
-#define DCNT_TIMER_SET			19
-#define DCNT_TIMER_CANCEL		20
-#define DCNT_EXTENSION			21
-#define DCNT_NUM_COUNTERS		22
-#define DCNT_ALL_COUNTERS               DCNT_NUM_COUNTERS
+#ifdef DAPL_COUNTERS
 
-#if defined(DAPL_COUNTERS)
+#define DAPL_CNTR(h_ptr, cntr) ((DAT_UINT64*)h_ptr->cntrs)[cntr]++
+#define DAPL_CNTR_DATA(h_ptr, cntr, data) ((DAT_UINT64*)h_ptr->cntrs)[cntr]+= data
 
-extern void dapl_dump_cntr( int cntr );
-extern int dapl_dbg_counters[];
+DAT_RETURN dapl_query_counter(DAT_HANDLE dh, 
+			      int counter, 
+			      void *p_cntrs_out,
+			      int reset);
+char *dapl_query_counter_name(DAT_HANDLE dh, int counter);
+void dapl_print_counter(DAT_HANDLE dh, int counter, int reset);
 
-#define DAPL_CNTR(cntr)         dapl_os_atomic_inc (&dapl_dbg_counters[cntr]);
-#define DAPL_DUMP_CNTR(cntr)    dapl_dump_cntr( cntr );
-#define DAPL_COUNTERS_INIT()
-
 #else
 
-#define DAPL_CNTR(cntr)
-#define DAPL_DUMP_CNTR(cntr) 
-#define DAPL_COUNTERS_INIT()
+#define DAPL_CNTR(handle, cntr)
+#define DAPL_CNTR_DATA(handle, cntr, data)
 
 #endif /* DAPL_COUNTERS */
 
-
 #endif /* _DAPL_DEBUG_H_ */

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cm.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cm.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cm.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -46,30 +46,20 @@
 #include "dapl_name_service.h"
 #include "dapl_ib_util.h"
 #include "dapl_vendor.h"
-#include <sys/poll.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#include "dapl_osd.h"
 
 extern struct rdma_event_channel *g_cm_events;
 
 /* local prototypes */
-static struct dapl_cm_id * dapli_req_recv(struct dapl_cm_id *conn, 
-					  struct rdma_cm_event *event);
-static void dapli_cm_active_cb(struct dapl_cm_id *conn, 
-			      struct rdma_cm_event *event);
-static void dapli_cm_passive_cb(struct dapl_cm_id *conn, 
+static struct dapl_cm_id *dapli_req_recv(struct dapl_cm_id *conn,
+					 struct rdma_cm_event *event);
+static void dapli_cm_active_cb(struct dapl_cm_id *conn,
 			       struct rdma_cm_event *event);
+static void dapli_cm_passive_cb(struct dapl_cm_id *conn,
+				struct rdma_cm_event *event);
 static void dapli_addr_resolve(struct dapl_cm_id *conn);
 static void dapli_route_resolve(struct dapl_cm_id *conn);
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return bswap_64(x); }
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return x; }
-#endif
-
 /* cma requires 16 bit SID, in network order */
 #define IB_PORT_MOD 32001
 #define IB_PORT_BASE (65535 - IB_PORT_MOD)
@@ -82,7 +72,7 @@
 
 /* private data header to validate consumer rejects versus abnormal events */
 struct dapl_pdata_hdr {
-	DAT_UINT32	version;
+	DAT_UINT32 version;
 };
 
 static void dapli_addr_resolve(struct dapl_cm_id *conn)
@@ -91,21 +81,20 @@
 #ifdef DAPL_DBG
 	struct rdma_addr *ipaddr = &conn->cm_id->route.addr;
 #endif
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" addr_resolve: cm_id %p SRC %x DST %x\n", 
-		conn->cm_id, 
-		ntohl(((struct sockaddr_in *)
-			&ipaddr->src_addr)->sin_addr.s_addr),
-		ntohl(((struct sockaddr_in *)
-			&ipaddr->dst_addr)->sin_addr.s_addr));
-	
-	ret =  rdma_resolve_route(conn->cm_id, conn->route_timeout);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " addr_resolve: cm_id %p SRC %x DST %x\n",
+		     conn->cm_id, ntohl(((struct sockaddr_in *)
+					 &ipaddr->src_addr)->sin_addr.s_addr),
+		     ntohl(((struct sockaddr_in *)
+			    &ipaddr->dst_addr)->sin_addr.s_addr));
+
+	ret = rdma_resolve_route(conn->cm_id, conn->route_timeout);
 	if (ret) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " dapl_cma_connect: rdma_resolve_route ERR %d %s\n",
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " dapl_cma_connect: rdma_resolve_route ERR 0x%x %s\n",
 			 ret, strerror(errno));
-		dapl_evd_connection_callback(conn, 
-					     IB_CME_LOCAL_FAILURE, 
+		dapl_evd_connection_callback(conn,
+					     IB_CME_LOCAL_FAILURE,
 					     NULL, conn->ep);
 	}
 }
@@ -115,54 +104,52 @@
 	int ret;
 #ifdef DAPL_DBG
 	struct rdma_addr *ipaddr = &conn->cm_id->route.addr;
-	struct ib_addr   *ibaddr = &conn->cm_id->route.addr.addr.ibaddr;
+	struct ib_addr *ibaddr = &conn->cm_id->route.addr.addr.ibaddr;
 #endif
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" route_resolve: cm_id %p SRC %x DST %x PORT %d\n", 
-		conn->cm_id, 
-		ntohl(((struct sockaddr_in *)
-			&ipaddr->src_addr)->sin_addr.s_addr),
-		ntohl(((struct sockaddr_in *)
-			&ipaddr->dst_addr)->sin_addr.s_addr),
-		ntohs(((struct sockaddr_in *)
-			&ipaddr->dst_addr)->sin_port) );
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " route_resolve: cm_id %p SRC %x DST %x PORT %d\n",
+		     conn->cm_id, ntohl(((struct sockaddr_in *)
+					 &ipaddr->src_addr)->sin_addr.s_addr),
+		     ntohl(((struct sockaddr_in *)
+			    &ipaddr->dst_addr)->sin_addr.s_addr),
+		     ntohs(((struct sockaddr_in *)
+			    &ipaddr->dst_addr)->sin_port));
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" route_resolve: SRC GID subnet %016llx id %016llx\n",
-		(unsigned long long)
-			cpu_to_be64(ibaddr->sgid.global.subnet_prefix),
-		(unsigned long long)
-			cpu_to_be64(ibaddr->sgid.global.interface_id));
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " route_resolve: SRC GID subnet %016llx id %016llx\n",
+		     (unsigned long long)
+		     ntohll(ibaddr->sgid.global.subnet_prefix),
+		     (unsigned long long)
+		     ntohll(ibaddr->sgid.global.interface_id));
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" route_resolve: DST GID subnet %016llx id %016llx\n",
-		(unsigned long long)
-			cpu_to_be64(ibaddr->dgid.global.subnet_prefix),
-		(unsigned long long)
-			cpu_to_be64(ibaddr->dgid.global.interface_id));
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" route_resolve: cm_id %p pdata %p plen %d rr %d ind %d\n",
-		conn->cm_id,
-		conn->params.private_data, 
-		conn->params.private_data_len,
-		conn->params.responder_resources, 
-		conn->params.initiator_depth );
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " route_resolve: DST GID subnet %016llx id %016llx\n",
+		     (unsigned long long)
+		     ntohll(ibaddr->dgid.global.subnet_prefix),
+		     (unsigned long long)
+		     ntohll(ibaddr->dgid.global.interface_id));
 
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " route_resolve: cm_id %p pdata %p plen %d rr %d ind %d\n",
+		     conn->cm_id,
+		     conn->params.private_data,
+		     conn->params.private_data_len,
+		     conn->params.responder_resources,
+		     conn->params.initiator_depth);
+
 	ret = rdma_connect(conn->cm_id, &conn->params);
 	if (ret) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " dapl_cma_connect: rdma_connect ERR %d %s\n",
 			 ret, strerror(errno));
 		goto bail;
 	}
 	return;
 
-bail:
-	dapl_evd_connection_callback(conn, 
-				     IB_CME_LOCAL_FAILURE, 
-				     NULL, conn->ep);
+      bail:
+	dapl_evd_connection_callback(conn,
+				     IB_CME_LOCAL_FAILURE, NULL, conn->ep);
 }
 
 /* 
@@ -175,13 +162,12 @@
 {
 	struct rdma_cm_id *cm_id;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		     " destroy_conn: conn %p id %d\n",
-		     conn,conn->cm_id);
-	
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " destroy_conn: conn %p id %d\n", conn, conn->cm_id);
+
 	dapl_os_lock(&conn->lock);
 	conn->destroy = 1;
-	
+
 	if (conn->ep) {
 		conn->ep->cm_handle = IB_INVALID_HANDLE;
 		conn->ep->qp_handle = IB_INVALID_HANDLE;
@@ -205,72 +191,73 @@
 	dapl_os_free(conn, sizeof(*conn));
 }
 
-static struct dapl_cm_id * dapli_req_recv(struct dapl_cm_id *conn,
-					  struct rdma_cm_event *event)
+static struct dapl_cm_id *dapli_req_recv(struct dapl_cm_id *conn,
+					 struct rdma_cm_event *event)
 {
 	struct dapl_cm_id *new_conn;
 #ifdef DAPL_DBG
 	struct rdma_addr *ipaddr = &event->id->route.addr;
 #endif
-	
+
 	if (conn->sp == NULL) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     " dapli_rep_recv: on invalid listen "
-			     "handle\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     " dapli_rep_recv: on invalid listen " "handle\n");
 		return NULL;
 	}
 
 	/* allocate new cm_id and merge listen parameters */
-	new_conn = dapl_os_alloc(sizeof(*new_conn)); 
+	new_conn = dapl_os_alloc(sizeof(*new_conn));
 	if (new_conn) {
 		(void)dapl_os_memzero(new_conn, sizeof(*new_conn));
-		new_conn->cm_id = event->id; /* provided by uCMA */
-		event->id->context = new_conn; /* update CM_ID context */
+		dapl_os_lock_init(&new_conn->lock);
+		new_conn->cm_id = event->id;	/* provided by uCMA */
+		event->id->context = new_conn;	/* update CM_ID context */
 		new_conn->sp = conn->sp;
 		new_conn->hca = conn->hca;
-		
+
 		/* Get requesters connect data, setup for accept */
-		new_conn->params.responder_resources = 
-			DAPL_MIN(event->param.conn.responder_resources,
-				 conn->hca->ib_trans.max_rdma_rd_in);
-		new_conn->params.initiator_depth = 
-			DAPL_MIN(event->param.conn.initiator_depth,
-				 conn->hca->ib_trans.max_rdma_rd_out);
+		new_conn->params.responder_resources =
+		    DAPL_MIN(event->param.conn.responder_resources,
+			     conn->hca->ib_trans.max_rdma_rd_in);
+		new_conn->params.initiator_depth =
+		    DAPL_MIN(event->param.conn.initiator_depth,
+			     conn->hca->ib_trans.max_rdma_rd_out);
 
 		new_conn->params.flow_control = event->param.conn.flow_control;
-		new_conn->params.rnr_retry_count = event->param.conn.rnr_retry_count;
+		new_conn->params.rnr_retry_count =
+		    event->param.conn.rnr_retry_count;
 		new_conn->params.retry_count = event->param.conn.retry_count;
 
 		/* save private data */
 		if (event->param.conn.private_data_len) {
-			dapl_os_memcpy(new_conn->p_data, 
+			dapl_os_memcpy(new_conn->p_data,
 				       event->param.conn.private_data,
 				       event->param.conn.private_data_len);
 			new_conn->params.private_data = new_conn->p_data;
-			new_conn->params.private_data_len = 
-						event->param.conn.private_data_len;
+			new_conn->params.private_data_len =
+			    event->param.conn.private_data_len;
 		}
 
 		dapl_dbg_log(DAPL_DBG_TYPE_CM, " passive_cb: "
 			     "REQ: SP %p PORT %d LID %d "
 			     "NEW CONN %p ID %p pD %p,%d\n",
-			     new_conn->sp,
-			     ntohs(((struct sockaddr_in *)
-					&ipaddr->src_addr)->sin_port),
+			     new_conn->sp, ntohs(((struct sockaddr_in *)
+						  &ipaddr->src_addr)->sin_port),
 			     event->listen_id, new_conn, event->id,
-			     event->param.conn.private_data, event->param.conn.private_data_len);
-		
+			     event->param.conn.private_data,
+			     event->param.conn.private_data_len);
+
 		dapl_dbg_log(DAPL_DBG_TYPE_CM, " passive_cb: "
 			     "REQ: IP SRC %x PORT %d DST %x PORT %d "
-			     "rr %d init %d\n", 
-			     ntohl(((struct sockaddr_in *)
-				&ipaddr->src_addr)->sin_addr.s_addr),
+			     "rr %d init %d\n", ntohl(((struct sockaddr_in *)
+						       &ipaddr->src_addr)->
+						      sin_addr.s_addr),
 			     ntohs(((struct sockaddr_in *)
-				&ipaddr->src_addr)->sin_port),
+				    &ipaddr->src_addr)->sin_port),
 			     ntohl(((struct sockaddr_in *)
-				&ipaddr->dst_addr)->sin_addr.s_addr),
+				    &ipaddr->dst_addr)->sin_addr.s_addr),
 			     ntohs(((struct sockaddr_in *)
-				&ipaddr->dst_addr)->sin_port),
+				    &ipaddr->dst_addr)->sin_port),
 			     new_conn->params.responder_resources,
 			     new_conn->params.initiator_depth);
 	}
@@ -278,11 +265,11 @@
 }
 
 static void dapli_cm_active_cb(struct dapl_cm_id *conn,
-			      struct rdma_cm_event *event)
+			       struct rdma_cm_event *event)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " active_cb: conn %p id %d event %d\n",
-		     conn, conn->cm_id, event->event );
+		     conn, conn->cm_id, event->event);
 
 	dapl_os_lock(&conn->lock);
 	if (conn->destroy) {
@@ -291,112 +278,119 @@
 	}
 	dapl_os_unlock(&conn->lock);
 
-        /* There is a chance that we can get events after
-         * the consumer calls disconnect in a pending state
-         * since the IB CM and uDAPL states are not shared.
-         * In some cases, IB CM could generate either a DCONN
-         * or CONN_ERR after the consumer returned from
-         * dapl_ep_disconnect with a DISCONNECTED event
-         * already queued. Check state here and bail to
-         * avoid any events after a disconnect.
-         */
-        if (DAPL_BAD_HANDLE(conn->ep, DAPL_MAGIC_EP))
-                return;
+	/* There is a chance that we can get events after
+	 * the consumer calls disconnect in a pending state
+	 * since the IB CM and uDAPL states are not shared.
+	 * In some cases, IB CM could generate either a DCONN
+	 * or CONN_ERR after the consumer returned from
+	 * dapl_ep_disconnect with a DISCONNECTED event
+	 * already queued. Check state here and bail to
+	 * avoid any events after a disconnect.
+	 */
+	if (DAPL_BAD_HANDLE(conn->ep, DAPL_MAGIC_EP))
+		return;
 
-        dapl_os_lock(&conn->ep->header.lock);
-        if (conn->ep->param.ep_state == DAT_EP_STATE_DISCONNECTED) {
-                dapl_os_unlock(&conn->ep->header.lock);
-                return;
-        }
-        if (event->event == RDMA_CM_EVENT_DISCONNECTED)
-                conn->ep->param.ep_state = DAT_EP_STATE_DISCONNECTED;
+	dapl_os_lock(&conn->ep->header.lock);
+	if (conn->ep->param.ep_state == DAT_EP_STATE_DISCONNECTED) {
+		dapl_os_unlock(&conn->ep->header.lock);
+		return;
+	}
+	if (event->event == RDMA_CM_EVENT_DISCONNECTED)
+		conn->ep->param.ep_state = DAT_EP_STATE_DISCONNECTED;
 
-        dapl_os_unlock(&conn->ep->header.lock);
+	dapl_os_unlock(&conn->ep->header.lock);
 
 	switch (event->event) {
 	case RDMA_CM_EVENT_UNREACHABLE:
 	case RDMA_CM_EVENT_CONNECT_ERROR:
-	{
-		dapl_log(DAPL_DBG_TYPE_WARN,
-                        "dapl_cma_active: CONN_ERR event=0x%x"
-                        " status=%d %s DST %s, %d\n", 
-                        event->event, event->status,
-                        (event->status == -ETIMEDOUT)?"TIMEOUT":"", 
-			inet_ntoa(((struct sockaddr_in *)
-			    &conn->cm_id->route.addr.dst_addr)->sin_addr),
-			ntohs(((struct sockaddr_in *)
-			    &conn->cm_id->route.addr.dst_addr)->sin_port));
+		{
+			dapl_log(DAPL_DBG_TYPE_WARN,
+				 "dapl_cma_active: CONN_ERR event=0x%x"
+				 " status=%d %s DST %s, %d\n",
+				 event->event, event->status,
+				 (event->status == -ETIMEDOUT) ? "TIMEOUT" : "",
+				 inet_ntoa(((struct sockaddr_in *)
+					    &conn->cm_id->route.addr.dst_addr)->
+					   sin_addr),
+				 ntohs(((struct sockaddr_in *)
+					&conn->cm_id->route.addr.dst_addr)->
+				       sin_port));
 
-		/* per DAT SPEC provider always returns UNREACHABLE */
-		dapl_evd_connection_callback(conn, 
-					     IB_CME_DESTINATION_UNREACHABLE, 
-					     NULL, conn->ep);
-		break;
-	}
+			/* per DAT SPEC provider always returns UNREACHABLE */
+			dapl_evd_connection_callback(conn,
+						     IB_CME_DESTINATION_UNREACHABLE,
+						     NULL, conn->ep);
+			break;
+		}
 	case RDMA_CM_EVENT_REJECTED:
-	{
-		ib_cm_events_t cm_event;
-		unsigned char  *pdata = NULL;
+		{
+			ib_cm_events_t cm_event;
+			unsigned char *pdata = NULL;
 
-		dapl_dbg_log(
-			DAPL_DBG_TYPE_CM,
-			" dapli_cm_active_handler: REJECTED reason=%d\n",	
-			event->status);
+			dapl_dbg_log(DAPL_DBG_TYPE_CM,
+				     " dapli_cm_active_handler: REJECTED reason=%d\n",
+				     event->status);
 
-		/* valid REJ from consumer will always contain private data */
-		if (event->status == 28 &&
-		    event->param.conn.private_data_len) {
-			cm_event = IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
-			pdata = (unsigned char*)event->param.conn.private_data
-				+ sizeof(struct dapl_pdata_hdr);
-		} else {
-			cm_event = IB_CME_DESTINATION_REJECT;
-			dapl_log(DAPL_DBG_TYPE_WARN, 
-				"dapl_cma_active: non-consumer REJ,"
-				" reason=%d, DST %s, %d\n", 
-				event->status,
-				inet_ntoa(((struct sockaddr_in *)
-				&conn->cm_id->route.addr.dst_addr)->sin_addr),
-				ntohs(((struct sockaddr_in *)
-				&conn->cm_id->route.addr.dst_addr)->sin_port));
-		}		
-		dapl_evd_connection_callback(conn, cm_event, pdata, conn->ep);
-		break;
-	}
+			/* valid REJ from consumer will always contain private data */
+			if (event->status == 28 &&
+			    event->param.conn.private_data_len) {
+				cm_event =
+				    IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
+				pdata =
+				    (unsigned char *)event->param.conn.
+				    private_data +
+				    sizeof(struct dapl_pdata_hdr);
+			} else {
+				cm_event = IB_CME_DESTINATION_REJECT;
+				dapl_log(DAPL_DBG_TYPE_WARN,
+					 "dapl_cma_active: non-consumer REJ,"
+					 " reason=%d, DST %s, %d\n",
+					 event->status,
+					 inet_ntoa(((struct sockaddr_in *)
+						    &conn->cm_id->route.addr.
+						    dst_addr)->sin_addr),
+					 ntohs(((struct sockaddr_in *)
+						&conn->cm_id->route.addr.
+						dst_addr)->sin_port));
+			}
+			dapl_evd_connection_callback(conn, cm_event, pdata,
+						     conn->ep);
+			break;
+		}
 	case RDMA_CM_EVENT_ESTABLISHED:
-		dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-     		     " active_cb: cm_id %d PORT %d CONNECTED to %s!\n",
-     		     conn->cm_id,
-		     ntohs(((struct sockaddr_in *)
-			&conn->cm_id->route.addr.dst_addr)->sin_port),
-		     inet_ntoa(((struct sockaddr_in *)
-			    &conn->cm_id->route.addr.dst_addr)->sin_addr));
+		dapl_dbg_log(DAPL_DBG_TYPE_CM,
+			     " active_cb: cm_id %d PORT %d CONNECTED to %s!\n",
+			     conn->cm_id, ntohs(((struct sockaddr_in *)
+						 &conn->cm_id->route.addr.
+						 dst_addr)->sin_port),
+			     inet_ntoa(((struct sockaddr_in *)
+					&conn->cm_id->route.addr.dst_addr)->
+				       sin_addr));
 
 		/* setup local and remote ports for ep query */
-		conn->ep->param.remote_port_qual = 
-			PORT_TO_SID(rdma_get_dst_port(conn->cm_id));
-		conn->ep->param.local_port_qual = 
-			PORT_TO_SID(rdma_get_src_port(conn->cm_id));
+		conn->ep->param.remote_port_qual =
+		    PORT_TO_SID(rdma_get_dst_port(conn->cm_id));
+		conn->ep->param.local_port_qual =
+		    PORT_TO_SID(rdma_get_src_port(conn->cm_id));
 
 		dapl_evd_connection_callback(conn, IB_CME_CONNECTED,
-					     event->param.conn.private_data, 
+					     event->param.conn.private_data,
 					     conn->ep);
 		break;
 
 	case RDMA_CM_EVENT_DISCONNECTED:
-		rdma_disconnect(conn->cm_id); /* required for DREP */
+		rdma_disconnect(conn->cm_id);	/* required for DREP */
 		/* validate EP handle */
-		if (!DAPL_BAD_HANDLE(conn->ep, DAPL_MAGIC_EP)) 
-			dapl_evd_connection_callback(conn, 
+		if (!DAPL_BAD_HANDLE(conn->ep, DAPL_MAGIC_EP))
+			dapl_evd_connection_callback(conn,
 						     IB_CME_DISCONNECTED,
-						     NULL, 
-						     conn->ep);
+						     NULL, conn->ep);
 		break;
 	default:
-		dapl_dbg_log(
-			DAPL_DBG_TYPE_ERR,
-			" dapli_cm_active_cb_handler: Unexpected CM "
-			"event %d on ID 0x%p\n", event->event, conn->cm_id);
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     " dapli_cm_active_cb_handler: Unexpected CM "
+			     "event %d on ID 0x%p\n", event->event,
+			     conn->cm_id);
 		break;
 	}
 
@@ -404,11 +398,11 @@
 }
 
 static void dapli_cm_passive_cb(struct dapl_cm_id *conn,
-			       struct rdma_cm_event *event)
+				struct rdma_cm_event *event)
 {
 	struct dapl_cm_id *new_conn;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " passive_cb: conn %p id %d event %d\n",
 		     conn, event->id, event->event);
 
@@ -422,67 +416,69 @@
 	switch (event->event) {
 	case RDMA_CM_EVENT_CONNECT_REQUEST:
 		/* create new conn object with new conn_id from event */
-		new_conn = dapli_req_recv(conn,event);
+		new_conn = dapli_req_recv(conn, event);
 
-		if (new_conn)	
-			dapls_cr_callback(new_conn, 
-					  IB_CME_CONNECTION_REQUEST_PENDING, 
-				 	  event->param.conn.private_data, new_conn->sp);
+		if (new_conn)
+			dapls_cr_callback(new_conn,
+					  IB_CME_CONNECTION_REQUEST_PENDING,
+					  event->param.conn.private_data,
+					  new_conn->sp);
 		break;
 	case RDMA_CM_EVENT_UNREACHABLE:
 	case RDMA_CM_EVENT_CONNECT_ERROR:
 		dapl_log(DAPL_DBG_TYPE_WARN,
-                        "dapl_cm_passive: CONN_ERR event=0x%x status=%d %s,"
-			" DST %s,%d\n", 
-                        event->event, event->status,
-                        (event->status == -ETIMEDOUT)?"TIMEOUT":"", 
-			inet_ntoa(((struct sockaddr_in *)
-			    &conn->cm_id->route.addr.dst_addr)->sin_addr),
-			ntohs(((struct sockaddr_in *)
-			    &conn->cm_id->route.addr.dst_addr)->sin_port));
+			 "dapl_cm_passive: CONN_ERR event=0x%x status=%d %s,"
+			 " DST %s,%d\n",
+			 event->event, event->status,
+			 (event->status == -ETIMEDOUT) ? "TIMEOUT" : "",
+			 inet_ntoa(((struct sockaddr_in *)
+				    &conn->cm_id->route.addr.dst_addr)->
+				   sin_addr), ntohs(((struct sockaddr_in *)
+						     &conn->cm_id->route.addr.
+						     dst_addr)->sin_port));
 
 		dapls_cr_callback(conn, IB_CME_DESTINATION_UNREACHABLE,
 				  NULL, conn->sp);
 		break;
 
 	case RDMA_CM_EVENT_REJECTED:
-	{
-		/* will alwasys be abnormal NON-consumer from active side */
-		dapl_log(DAPL_DBG_TYPE_WARN, 
-			"dapl_cm_passive: non-consumer REJ, reason=%d,"
-			" DST %s, %d\n", 
-			event->status,
-			inet_ntoa(((struct sockaddr_in *)
-			&conn->cm_id->route.addr.dst_addr)->sin_addr),
-			ntohs(((struct sockaddr_in *)
-			&conn->cm_id->route.addr.dst_addr)->sin_port));
-		
-		dapls_cr_callback(conn, IB_CME_DESTINATION_REJECT, 
-				  NULL, conn->sp);
-		break;
-	}
+		{
+			/* will alwasys be abnormal NON-consumer from active side */
+			dapl_log(DAPL_DBG_TYPE_WARN,
+				 "dapl_cm_passive: non-consumer REJ, reason=%d,"
+				 " DST %s, %d\n",
+				 event->status,
+				 inet_ntoa(((struct sockaddr_in *)
+					    &conn->cm_id->route.addr.dst_addr)->
+					   sin_addr),
+				 ntohs(((struct sockaddr_in *)
+					&conn->cm_id->route.addr.dst_addr)->
+				       sin_port));
+
+			dapls_cr_callback(conn, IB_CME_DESTINATION_REJECT,
+					  NULL, conn->sp);
+			break;
+		}
 	case RDMA_CM_EVENT_ESTABLISHED:
-		dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-     		     " passive_cb: cm_id %p PORT %d CONNECTED from 0x%x!\n",
-     		     conn->cm_id,
-		     ntohs(((struct sockaddr_in *)
-			&conn->cm_id->route.addr.src_addr)->sin_port),
-		     ntohl(((struct sockaddr_in *)
-			&conn->cm_id->route.addr.dst_addr)->sin_addr.s_addr));
+		dapl_dbg_log(DAPL_DBG_TYPE_CM,
+			     " passive_cb: cm_id %p PORT %d CONNECTED from 0x%x!\n",
+			     conn->cm_id, ntohs(((struct sockaddr_in *)
+						 &conn->cm_id->route.addr.
+						 src_addr)->sin_port),
+			     ntohl(((struct sockaddr_in *)
+				    &conn->cm_id->route.addr.dst_addr)->
+				   sin_addr.s_addr));
 
-		dapls_cr_callback(conn, IB_CME_CONNECTED, 
-				  NULL, conn->sp);
-		
+		dapls_cr_callback(conn, IB_CME_CONNECTED, NULL, conn->sp);
+
 		break;
 	case RDMA_CM_EVENT_DISCONNECTED:
-		rdma_disconnect(conn->cm_id); /* required for DREP */
+		rdma_disconnect(conn->cm_id);	/* required for DREP */
 		/* validate SP handle context */
-		if (!DAPL_BAD_HANDLE(conn->sp, DAPL_MAGIC_PSP) || 
+		if (!DAPL_BAD_HANDLE(conn->sp, DAPL_MAGIC_PSP) ||
 		    !DAPL_BAD_HANDLE(conn->sp, DAPL_MAGIC_RSP))
-			dapls_cr_callback(conn, 
-					  IB_CME_DISCONNECTED, 
-					  NULL, 
-					  conn->sp);
+			dapls_cr_callback(conn,
+					  IB_CME_DISCONNECTED, NULL, conn->sp);
 		break;
 	default:
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR, " passive_cb: "
@@ -494,7 +490,6 @@
 	return;
 }
 
-
 /************************ DAPL provider entry points **********************/
 
 /*
@@ -521,29 +516,28 @@
 DAT_RETURN dapls_ib_connect(IN DAT_EP_HANDLE ep_handle,
 			    IN DAT_IA_ADDRESS_PTR r_addr,
 			    IN DAT_CONN_QUAL r_qual,
-			    IN DAT_COUNT p_size,
-			    IN void *p_data)
+			    IN DAT_COUNT p_size, IN void *p_data)
 {
 	struct dapl_ep *ep_ptr = ep_handle;
 	struct dapl_cm_id *conn;
-			
+	int ret;
+
 	/* Sanity check */
-	if (NULL == ep_ptr) 
+	if (NULL == ep_ptr)
 		return DAT_SUCCESS;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		     " connect: rSID 0x%llx rPort %d, pdata %p, ln %d\n", 
-		     r_qual,ntohs(SID_TO_PORT(r_qual)),p_data,p_size);
-			
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " connect: rSID 0x%llx rPort %d, pdata %p, ln %d\n",
+		     r_qual, ntohs(SID_TO_PORT(r_qual)), p_data, p_size);
+
 	/* rdma conn and cm_id pre-bound; reference via qp_handle */
 	conn = ep_ptr->cm_handle = ep_ptr->qp_handle;
 
 	/* Setup QP/CM parameters and private data in cm_id */
 	(void)dapl_os_memzero(&conn->params, sizeof(conn->params));
 	conn->params.responder_resources =
-		ep_ptr->param.ep_attr.max_rdma_read_in;
-	conn->params.initiator_depth =
-		ep_ptr->param.ep_attr.max_rdma_read_out;
+	    ep_ptr->param.ep_attr.max_rdma_read_in;
+	conn->params.initiator_depth = ep_ptr->param.ep_attr.max_rdma_read_out;
 	conn->params.flow_control = 1;
 	conn->params.rnr_retry_count = IB_RNR_RETRY_COUNT;
 	conn->params.retry_count = IB_RC_RETRY_COUNT;
@@ -557,22 +551,23 @@
 	dapl_os_memcpy(&conn->r_addr, r_addr, sizeof(*r_addr));
 
 	/* Resolve remote address, src already bound during QP create */
-	((struct sockaddr_in*)&conn->r_addr)->sin_port = SID_TO_PORT(r_qual);
-	((struct sockaddr_in*)&conn->r_addr)->sin_family = AF_INET;
+	((struct sockaddr_in *)&conn->r_addr)->sin_port = SID_TO_PORT(r_qual);
+	((struct sockaddr_in *)&conn->r_addr)->sin_family = AF_INET;
 
-	if (rdma_resolve_addr(conn->cm_id, NULL, 
-			      (struct sockaddr *)&conn->r_addr, 
-			      conn->arp_timeout)) {
+	ret = rdma_resolve_addr(conn->cm_id, NULL,
+				(struct sockaddr *)&conn->r_addr,
+				conn->arp_timeout);
+	if (ret) {
 		dapl_log(DAPL_DBG_TYPE_ERR,
-			 " dapl_cma_connect: rdma_resolve_addr ERR %s\n", 
-			 strerror(errno));
-		return dapl_convert_errno(errno,"ib_connect");
+			 " dapl_cma_connect: rdma_resolve_addr ERR 0x%x %s\n",
+			 ret, strerror(errno));
+		return dapl_convert_errno(errno, "ib_connect");
 	}
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" connect: resolve_addr: cm_id %p -> %s port %d\n", 
-		conn->cm_id, 
-		inet_ntoa(((struct sockaddr_in *)&conn->r_addr)->sin_addr),
-		((struct sockaddr_in*)&conn->r_addr)->sin_port );
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " connect: resolve_addr: cm_id %p -> %s port %d\n",
+		     conn->cm_id,
+		     inet_ntoa(((struct sockaddr_in *)&conn->r_addr)->sin_addr),
+		     ((struct sockaddr_in *)&conn->r_addr)->sin_port);
 
 	return DAT_SUCCESS;
 }
@@ -594,24 +589,23 @@
  *
  */
 DAT_RETURN
-dapls_ib_disconnect(IN DAPL_EP *ep_ptr,
-		    IN DAT_CLOSE_FLAGS close_flags)
+dapls_ib_disconnect(IN DAPL_EP * ep_ptr, IN DAT_CLOSE_FLAGS close_flags)
 {
 	dp_ib_cm_handle_t conn = ep_ptr->cm_handle;
 	int ret;
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " disconnect(ep %p, conn %p, id %d flags %x)\n",
-		     ep_ptr,conn, (conn?conn->cm_id:0),close_flags);
+		     ep_ptr, conn, (conn ? conn->cm_id : 0), close_flags);
 
-        if ((conn == IB_INVALID_HANDLE) || (conn->cm_id == NULL))
+	if ((conn == IB_INVALID_HANDLE) || (conn->cm_id == NULL))
 		return DAT_SUCCESS;
 
 	/* no graceful half-pipe disconnect option */
 	ret = rdma_disconnect(conn->cm_id);
 	if (ret)
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-			     " disconnect: ID %p ret %d\n", 
+			     " disconnect: ID %p ret 0x%x\n",
 			     ep_ptr->cm_handle, ret);
 
 	/* 
@@ -640,7 +634,7 @@
  *
  */
 void
-dapls_ib_disconnect_clean(IN DAPL_EP *ep_ptr,
+dapls_ib_disconnect_clean(IN DAPL_EP * ep_ptr,
 			  IN DAT_BOOLEAN active,
 			  IN const ib_cm_events_t ib_cm_event)
 {
@@ -669,74 +663,73 @@
  *
  */
 DAT_RETURN
-dapls_ib_setup_conn_listener(IN DAPL_IA *ia_ptr,
-			     IN DAT_UINT64 ServiceID,
-			     IN DAPL_SP *sp_ptr )
+dapls_ib_setup_conn_listener(IN DAPL_IA * ia_ptr,
+			     IN DAT_UINT64 ServiceID, IN DAPL_SP * sp_ptr)
 {
 	DAT_RETURN dat_status = DAT_SUCCESS;
 	ib_cm_srvc_handle_t conn;
-	DAT_SOCK_ADDR6	addr;	/* local binding address */
+	DAT_SOCK_ADDR6 addr;	/* local binding address */
 
 	/* Allocate CM and initialize lock */
-	if ((conn = dapl_os_alloc(sizeof(*conn))) == NULL) 
+	if ((conn = dapl_os_alloc(sizeof(*conn))) == NULL)
 		return DAT_INSUFFICIENT_RESOURCES;
-	
+
 	dapl_os_memzero(conn, sizeof(*conn));
 	dapl_os_lock_init(&conn->lock);
-		 
+
 	/* create CM_ID, bind to local device, create QP */
-	if (rdma_create_id(g_cm_events, &conn->cm_id, (void*)conn, RDMA_PS_TCP)) {
+	if (rdma_create_id
+	    (g_cm_events, &conn->cm_id, (void *)conn, RDMA_PS_TCP)) {
 		dapl_os_free(conn, sizeof(*conn));
-		return(dapl_convert_errno(errno,"setup_listener"));
+		return (dapl_convert_errno(errno, "setup_listener"));
 	}
-	
+
 	/* open identifies the local device; per DAT specification */
 	/* Get family and address then set port to consumer's ServiceID */
 	dapl_os_memcpy(&addr, &ia_ptr->hca_ptr->hca_address, sizeof(addr));
 	((struct sockaddr_in *)&addr)->sin_port = SID_TO_PORT(ServiceID);
 
-	if (rdma_bind_addr(conn->cm_id,(struct sockaddr *)&addr)) {
+	if (rdma_bind_addr(conn->cm_id, (struct sockaddr *)&addr)) {
 		if ((errno == EBUSY) || (errno == EADDRINUSE))
 			dat_status = DAT_CONN_QUAL_IN_USE;
 		else
-			dat_status = 
-				dapl_convert_errno(errno,"setup_listener");
+			dat_status =
+			    dapl_convert_errno(errno, "setup_listener");
 		goto bail;
 	}
 
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
-		" listen(ia_ptr %p SID 0x%llx Port %d sp %p conn %p id %d)\n",
-		ia_ptr, ServiceID, ntohs(SID_TO_PORT(ServiceID)), 
-		sp_ptr, conn, conn->cm_id);
+		     " listen(ia_ptr %p SID 0x%llx Port %d sp %p conn %p id %d)\n",
+		     ia_ptr, ServiceID, ntohs(SID_TO_PORT(ServiceID)),
+		     sp_ptr, conn, conn->cm_id);
 
 	sp_ptr->cm_srvc_handle = conn;
 	conn->sp = sp_ptr;
 	conn->hca = ia_ptr->hca_ptr;
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " listen(conn=%p cm_id=%d)\n",
-		     sp_ptr->cm_srvc_handle,conn->cm_id);
-	
-	if (rdma_listen(conn->cm_id,0)) { /* max cma backlog */
+		     sp_ptr->cm_srvc_handle, conn->cm_id);
 
+	if (rdma_listen(conn->cm_id, 0)) {	/* max cma backlog */
+
 		if ((errno == EBUSY) || (errno == EADDRINUSE))
 			dat_status = DAT_CONN_QUAL_IN_USE;
 		else
-			dat_status = 
-				dapl_convert_errno(errno,"setup_listener");
-        	goto bail;
+			dat_status =
+			    dapl_convert_errno(errno, "setup_listener");
+		goto bail;
 	}
 
-	/* success */ 
+	/* success */
 	return DAT_SUCCESS;
 
-bail:
+      bail:
 	rdma_destroy_id(conn->cm_id);
 	dapl_os_free(conn, sizeof(*conn));
 	return dat_status;
 }
 
-
 /*
  * dapl_ib_remove_conn_listener
  *
@@ -755,18 +748,18 @@
  *
  */
 DAT_RETURN
-dapls_ib_remove_conn_listener(IN DAPL_IA *ia_ptr, IN DAPL_SP *sp_ptr)
+dapls_ib_remove_conn_listener(IN DAPL_IA * ia_ptr, IN DAPL_SP * sp_ptr)
 {
 	ib_cm_srvc_handle_t conn = sp_ptr->cm_srvc_handle;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " remove_listen(ia_ptr %p sp_ptr %p cm_ptr %p)\n",
-		     ia_ptr, sp_ptr, conn );
-	
-	if (conn != IB_INVALID_HANDLE) { 
+		     ia_ptr, sp_ptr, conn);
+
+	if (conn != IB_INVALID_HANDLE) {
 		sp_ptr->cm_srvc_handle = NULL;
-        	dapli_destroy_conn(conn);
-	}	
+		dapli_destroy_conn(conn);
+	}
 	return DAT_SUCCESS;
 }
 
@@ -793,19 +786,18 @@
 DAT_RETURN
 dapls_ib_accept_connection(IN DAT_CR_HANDLE cr_handle,
 			   IN DAT_EP_HANDLE ep_handle,
-			   IN DAT_COUNT p_size,
-			   IN const DAT_PVOID p_data)
+			   IN DAT_COUNT p_size, IN const DAT_PVOID p_data)
 {
-	DAPL_CR *cr_ptr = (DAPL_CR *)cr_handle;
-	DAPL_EP *ep_ptr = (DAPL_EP *)ep_handle;
+	DAPL_CR *cr_ptr = (DAPL_CR *) cr_handle;
+	DAPL_EP *ep_ptr = (DAPL_EP *) ep_handle;
 	DAPL_IA *ia_ptr = ep_ptr->header.owner_ia;
 	struct dapl_cm_id *cr_conn = cr_ptr->ib_cm_handle;
 	int ret;
 	DAT_RETURN dat_status;
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " accept(cr %p conn %p, id %p, p_data %p, p_sz=%d)\n",
-		     cr_ptr, cr_conn, cr_conn->cm_id, p_data, p_size );
+		     cr_ptr, cr_conn, cr_conn->cm_id, p_data, p_size);
 
 	/* Obtain size of private data structure & contents */
 	if (p_size > IB_MAX_REP_PDATA_SIZE) {
@@ -841,23 +833,23 @@
 		ep_ptr->qp_handle->cm_id->qp = NULL;
 		dapli_destroy_conn(ep_ptr->qp_handle);
 	} else {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			" dapl_cma_accept: ERR dev(%p!=%p) or"
-			" port mismatch(%d!=%d)\n", 
-			ep_ptr->qp_handle->cm_id->verbs,cr_conn->cm_id->verbs,
-			ntohs(ep_ptr->qp_handle->cm_id->port_num),
-			ntohs(cr_conn->cm_id->port_num));
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " dapl_cma_accept: ERR dev(%p!=%p) or"
+			 " port mismatch(%d!=%d)\n",
+			 ep_ptr->qp_handle->cm_id->verbs, cr_conn->cm_id->verbs,
+			 ntohs(ep_ptr->qp_handle->cm_id->port_num),
+			 ntohs(cr_conn->cm_id->port_num));
 		dat_status = DAT_INTERNAL_ERROR;
 		goto bail;
 	}
 
-   	cr_ptr->param.local_ep_handle = ep_handle;
+	cr_ptr->param.local_ep_handle = ep_handle;
 	cr_conn->params.private_data = p_data;
 	cr_conn->params.private_data_len = p_size;
 
 	ret = rdma_accept(cr_conn->cm_id, &cr_conn->params);
 	if (ret) {
-		dapl_log(DAPL_DBG_TYPE_ERR," dapl_cma_accept: ERR %d %s\n", 
+		dapl_log(DAPL_DBG_TYPE_ERR, " dapl_cma_accept: ERR %d %s\n",
 			 ret, strerror(errno));
 		dat_status = dapl_convert_errno(ret, "accept");
 		goto bail;
@@ -870,17 +862,18 @@
 
 	/* setup local and remote ports for ep query */
 	/* Note: port qual in network order */
-	ep_ptr->param.remote_port_qual = PORT_TO_SID(rdma_get_dst_port(cr_conn->cm_id));
-	ep_ptr->param.local_port_qual = PORT_TO_SID(rdma_get_src_port(cr_conn->cm_id));
+	ep_ptr->param.remote_port_qual =
+	    PORT_TO_SID(rdma_get_dst_port(cr_conn->cm_id));
+	ep_ptr->param.local_port_qual =
+	    PORT_TO_SID(rdma_get_src_port(cr_conn->cm_id));
 
 	return DAT_SUCCESS;
-bail:
+      bail:
 	rdma_reject(cr_conn->cm_id, NULL, 0);
 	dapli_destroy_conn(cr_conn);
-	return dat_status; 
+	return dat_status;
 }
 
-
 /*
  * dapls_ib_reject_connection
  *
@@ -898,22 +891,21 @@
  *
  */
 DAT_RETURN
-dapls_ib_reject_connection(
-	IN dp_ib_cm_handle_t cm_handle, 
-	IN int reason,
-	IN DAT_COUNT private_data_size,
-	IN const DAT_PVOID private_data)
+dapls_ib_reject_connection(IN dp_ib_cm_handle_t cm_handle,
+			   IN int reason,
+			   IN DAT_COUNT private_data_size,
+			   IN const DAT_PVOID private_data)
 {
-    	int ret;
+	int ret;
 	int offset = sizeof(struct dapl_pdata_hdr);
-	struct dapl_pdata_hdr pdata_hdr = {
-        	.version = htonl(
-                        (DAT_VERSION_MAJOR << 24) |
-                        (DAT_VERSION_MINOR << 16) |
-                        (VN_PROVIDER_MAJOR << 8 ) |
-                        (VN_PROVIDER_MINOR))
-	};
+	struct dapl_pdata_hdr pdata_hdr;
 
+	memset(&pdata_hdr, 0, sizeof pdata_hdr);
+	pdata_hdr.version = htonl((DAT_VERSION_MAJOR << 24) |
+				  (DAT_VERSION_MINOR << 16) |
+				  (VN_PROVIDER_MAJOR << 8) |
+				  (VN_PROVIDER_MINOR));
+
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " reject: handle %p reason %x, ver=%x, data %p, sz=%d\n",
 		     cm_handle, reason, ntohl(pdata_hdr.version),
@@ -921,31 +913,28 @@
 
 	if (cm_handle == IB_INVALID_HANDLE) {
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-			     " reject: invalid handle: reason %d\n",
-			     reason);
-		return DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CR);
+			     " reject: invalid handle: reason %d\n", reason);
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
 	}
-    
-        if (private_data_size > 
-		dapls_ib_private_data_size(
-			NULL, DAPL_PDATA_CONN_REJ, cm_handle->hca))
+
+	if (private_data_size >
+	    dapls_ib_private_data_size(NULL, DAPL_PDATA_CONN_REJ,
+				       cm_handle->hca))
 		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	
+
 	/* setup pdata_hdr and users data, in CR pdata buffer */
 	dapl_os_memcpy(cm_handle->p_data, &pdata_hdr, offset);
 	if (private_data_size)
-        	dapl_os_memcpy(cm_handle->p_data+offset,
-			       private_data, 
-			       private_data_size);
-	
+		dapl_os_memcpy(cm_handle->p_data + offset,
+			       private_data, private_data_size);
+
 	/*
 	 * Always some private data with reject so active peer can
-         * determine real application reject from an abnormal 
+	 * determine real application reject from an abnormal 
 	 * application termination
 	 */
-	ret = rdma_reject(cm_handle->cm_id, 
-			  cm_handle->p_data, 
-			  offset+private_data_size);
+	ret = rdma_reject(cm_handle->cm_id,
+			  cm_handle->p_data, offset + private_data_size);
 
 	dapli_destroy_conn(cm_handle);
 	return dapl_convert_errno(ret, "reject");
@@ -968,39 +957,39 @@
  *
  */
 DAT_RETURN
-dapls_ib_cm_remote_addr(IN DAT_HANDLE dat_handle, OUT DAT_SOCK_ADDR6 *raddr)
+dapls_ib_cm_remote_addr(IN DAT_HANDLE dat_handle, OUT DAT_SOCK_ADDR6 * raddr)
 {
 	DAPL_HEADER *header;
 	dp_ib_cm_handle_t ib_cm_handle;
 	struct rdma_addr *ipaddr;
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " remote_addr(cm_handle=%p, r_addr=%p)\n",
 		     dat_handle, raddr);
 
-	header = (DAPL_HEADER *)dat_handle;
+	header = (DAPL_HEADER *) dat_handle;
 
-	if (header->magic == DAPL_MAGIC_EP) 
-		ib_cm_handle = ((DAPL_EP *)dat_handle)->cm_handle;
-	else if (header->magic == DAPL_MAGIC_CR) 
-		ib_cm_handle = ((DAPL_CR *)dat_handle)->ib_cm_handle;
-	else 
+	if (header->magic == DAPL_MAGIC_EP)
+		ib_cm_handle = ((DAPL_EP *) dat_handle)->cm_handle;
+	else if (header->magic == DAPL_MAGIC_CR)
+		ib_cm_handle = ((DAPL_CR *) dat_handle)->ib_cm_handle;
+	else
 		return DAT_INVALID_HANDLE;
 
 	/* get remote IP address from cm_id route */
 	ipaddr = &ib_cm_handle->cm_id->route.addr;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		" remote_addr: conn %p id %p SRC %x DST %x PORT %d\n", 
-		ib_cm_handle, ib_cm_handle->cm_id, 
-		ntohl(((struct sockaddr_in *)
-			&ipaddr->src_addr)->sin_addr.s_addr),
-		ntohl(((struct sockaddr_in *)
-			&ipaddr->dst_addr)->sin_addr.s_addr),
-		ntohs(((struct sockaddr_in *)
-			&ipaddr->dst_addr)->sin_port));
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " remote_addr: conn %p id %p SRC %x DST %x PORT %d\n",
+		     ib_cm_handle, ib_cm_handle->cm_id,
+		     ntohl(((struct sockaddr_in *)
+			    &ipaddr->src_addr)->sin_addr.s_addr),
+		     ntohl(((struct sockaddr_in *)
+			    &ipaddr->dst_addr)->sin_addr.s_addr),
+		     ntohs(((struct sockaddr_in *)
+			    &ipaddr->dst_addr)->sin_port));
 
-	dapl_os_memcpy(raddr,&ipaddr->dst_addr,sizeof(DAT_SOCK_ADDR));
+	dapl_os_memcpy(raddr, &ipaddr->dst_addr, sizeof(DAT_SOCK_ADDR));
 	return DAT_SUCCESS;
 }
 
@@ -1026,17 +1015,16 @@
  * 	length of private data
  *
  */
-int dapls_ib_private_data_size(	IN DAPL_PRIVATE	*prd_ptr,
-				IN DAPL_PDATA_OP conn_op,
-				IN DAPL_HCA     *hca_ptr)
+int dapls_ib_private_data_size(IN DAPL_PRIVATE * prd_ptr,
+			       IN DAPL_PDATA_OP conn_op, IN DAPL_HCA * hca_ptr)
 {
-	int  size;
+	int size;
 
-        if (hca_ptr->ib_hca_handle->device->transport_type 
-					== IBV_TRANSPORT_IWARP)
-		return(IWARP_MAX_PDATA_SIZE-sizeof(struct dapl_pdata_hdr));
+	if (hca_ptr->ib_hca_handle->device->transport_type
+	    == IBV_TRANSPORT_IWARP)
+		return (IWARP_MAX_PDATA_SIZE - sizeof(struct dapl_pdata_hdr));
 
-	switch(conn_op)	{
+	switch (conn_op) {
 
 	case DAPL_PDATA_CONN_REQ:
 		size = IB_MAX_REQ_PDATA_SIZE;
@@ -1045,7 +1033,7 @@
 		size = IB_MAX_REP_PDATA_SIZE;
 		break;
 	case DAPL_PDATA_CONN_REJ:
-		size = IB_MAX_REJ_PDATA_SIZE-sizeof(struct dapl_pdata_hdr);
+		size = IB_MAX_REJ_PDATA_SIZE - sizeof(struct dapl_pdata_hdr);
 		break;
 	case DAPL_PDATA_CONN_DREQ:
 		size = IB_MAX_DREQ_PDATA_SIZE;
@@ -1056,7 +1044,7 @@
 	default:
 		size = 0;
 
-	} /* end case */
+	}			/* end case */
 
 	return size;
 }
@@ -1066,39 +1054,42 @@
  */
 #define DAPL_IB_EVENT_CNT	13
 
-static struct ib_cm_event_map
-{
+static struct ib_cm_event_map {
 	const ib_cm_events_t ib_cm_event;
 	DAT_EVENT_NUMBER dat_event_num;
-	} ib_cm_event_map[DAPL_IB_EVENT_CNT] = {
-	/* 00 */  { IB_CME_CONNECTED,	
-				DAT_CONNECTION_EVENT_ESTABLISHED}, 
-	/* 01 */  { IB_CME_DISCONNECTED,	
-				DAT_CONNECTION_EVENT_DISCONNECTED},
-	/* 02 */  { IB_CME_DISCONNECTED_ON_LINK_DOWN, 
-				DAT_CONNECTION_EVENT_DISCONNECTED},
-	/* 03 */  { IB_CME_CONNECTION_REQUEST_PENDING,	
-				DAT_CONNECTION_REQUEST_EVENT},
-	/* 04 */  { IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
-				DAT_CONNECTION_REQUEST_EVENT},
-	/* 05 */  { IB_CME_CONNECTION_REQUEST_ACKED,
-				DAT_CONNECTION_REQUEST_EVENT},
-	/* 06 */  { IB_CME_DESTINATION_REJECT,
-				DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
-	/* 07 */  { IB_CME_DESTINATION_REJECT_PRIVATE_DATA,		
-				DAT_CONNECTION_EVENT_PEER_REJECTED},
-	/* 08 */  { IB_CME_DESTINATION_UNREACHABLE,	
-				DAT_CONNECTION_EVENT_UNREACHABLE},
-	/* 09 */  { IB_CME_TOO_MANY_CONNECTION_REQUESTS,
-				DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
-	/* 10 */  { IB_CME_LOCAL_FAILURE,
-				DAT_CONNECTION_EVENT_BROKEN},
-	/* 11 */  { IB_CME_BROKEN,
-				DAT_CONNECTION_EVENT_BROKEN},
-	/* 12 */  { IB_CME_TIMEOUT,	
-				DAT_CONNECTION_EVENT_TIMED_OUT},
-};
- 
+} ib_cm_event_map[DAPL_IB_EVENT_CNT] = {
+	/* 00 */  {
+	IB_CME_CONNECTED, DAT_CONNECTION_EVENT_ESTABLISHED},
+	    /* 01 */  {
+	IB_CME_DISCONNECTED, DAT_CONNECTION_EVENT_DISCONNECTED},
+	    /* 02 */  {
+	IB_CME_DISCONNECTED_ON_LINK_DOWN,
+		    DAT_CONNECTION_EVENT_DISCONNECTED},
+	    /* 03 */  {
+	IB_CME_CONNECTION_REQUEST_PENDING, DAT_CONNECTION_REQUEST_EVENT},
+	    /* 04 */  {
+	IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
+		    DAT_CONNECTION_REQUEST_EVENT},
+	    /* 05 */  {
+	IB_CME_CONNECTION_REQUEST_ACKED, DAT_CONNECTION_REQUEST_EVENT},
+	    /* 06 */  {
+	IB_CME_DESTINATION_REJECT,
+		    DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
+	    /* 07 */  {
+	IB_CME_DESTINATION_REJECT_PRIVATE_DATA,
+		    DAT_CONNECTION_EVENT_PEER_REJECTED},
+	    /* 08 */  {
+	IB_CME_DESTINATION_UNREACHABLE, DAT_CONNECTION_EVENT_UNREACHABLE},
+	    /* 09 */  {
+	IB_CME_TOO_MANY_CONNECTION_REQUESTS,
+		    DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
+	    /* 10 */  {
+	IB_CME_LOCAL_FAILURE, DAT_CONNECTION_EVENT_BROKEN},
+	    /* 11 */  {
+	IB_CME_BROKEN, DAT_CONNECTION_EVENT_BROKEN},
+	    /* 12 */  {
+IB_CME_TIMEOUT, DAT_CONNECTION_EVENT_TIMED_OUT},};
+
 /*
  * dapls_ib_get_cm_event
  *
@@ -1119,24 +1110,23 @@
 {
 	DAT_EVENT_NUMBER dat_event_num;
 	int i;
-	
+
 	active = active;
 
 	dat_event_num = 0;
-	for(i = 0; i < DAPL_IB_EVENT_CNT; i++) {
+	for (i = 0; i < DAPL_IB_EVENT_CNT; i++) {
 		if (ib_cm_event == ib_cm_event_map[i].ib_cm_event) {
 			dat_event_num = ib_cm_event_map[i].dat_event_num;
 			break;
 		}
 	}
 	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
-		"dapls_ib_get_dat_event: event(%s) ib=0x%x dat=0x%x\n",
-		active ? "active" : "passive", ib_cm_event, dat_event_num);
+		     "dapls_ib_get_dat_event: event(%s) ib=0x%x dat=0x%x\n",
+		     active ? "active" : "passive", ib_cm_event, dat_event_num);
 
 	return dat_event_num;
 }
 
-
 /*
  * dapls_ib_get_dat_event
  *
@@ -1152,14 +1142,13 @@
  * Returns:
  * 	DAT_EVENT_NUMBER of translated provider value
  */
-ib_cm_events_t
-dapls_ib_get_cm_event(IN DAT_EVENT_NUMBER dat_event_num)
+ib_cm_events_t dapls_ib_get_cm_event(IN DAT_EVENT_NUMBER dat_event_num)
 {
 	ib_cm_events_t ib_cm_event;
 	int i;
 
 	ib_cm_event = 0;
-	for(i = 0; i < DAPL_IB_EVENT_CNT; i++) {
+	for (i = 0; i < DAPL_IB_EVENT_CNT; i++) {
 		if (dat_event_num == ib_cm_event_map[i].dat_event_num) {
 			ib_cm_event = ib_cm_event_map[i].ib_cm_event;
 			break;
@@ -1168,7 +1157,6 @@
 	return ib_cm_event;
 }
 
-
 void dapli_cma_event_cb(void)
 {
 	struct rdma_cm_event *event;
@@ -1176,10 +1164,10 @@
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cm_event()\n");
 
 	/* process one CM event, fairness */
-	if(!rdma_get_cm_event(g_cm_events, &event)) {
+	if (!rdma_get_cm_event(g_cm_events, &event)) {
 		struct dapl_cm_id *conn;
-				
-		/* set proper conn from cm_id context*/
+
+		/* set proper conn from cm_id context */
 		if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST)
 			conn = (struct dapl_cm_id *)event->listen_id->context;
 		else
@@ -1201,76 +1189,78 @@
 		case RDMA_CM_EVENT_ADDR_ERROR:
 			dapl_log(DAPL_DBG_TYPE_WARN,
 				 "dapl_cma_active: CM ADDR ERROR: ->"
-				 " DST %s retry (%d)..\n", 
+				 " DST %s retry (%d)..\n",
 				 inet_ntoa(((struct sockaddr_in *)
-					&conn->r_addr)->sin_addr),
+					    &conn->r_addr)->sin_addr),
 				 conn->arp_retries);
-			
+
 			/* retry address resolution */
-			if ((--conn->arp_retries) && 
-				(event->status == -ETIMEDOUT)) {
+			if ((--conn->arp_retries) &&
+			    (event->status == -ETIMEDOUT)) {
 				int ret;
-				ret = rdma_resolve_addr(
-					conn->cm_id, NULL, 
-					(struct sockaddr *)&conn->r_addr, 
-					conn->arp_timeout);
-				if (!ret) 
+				ret = rdma_resolve_addr(conn->cm_id, NULL,
+							(struct sockaddr *)
+							&conn->r_addr,
+							conn->arp_timeout);
+				if (!ret)
 					break;
-				else { 
-					dapl_dbg_log(
-						DAPL_DBG_TYPE_WARN,
-						" ERROR: rdma_resolve_addr = "
-						"%d %s\n", 
-						ret,strerror(errno));
+				else {
+					dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+						     " ERROR: rdma_resolve_addr = "
+						     "%d %s\n",
+						     ret, strerror(errno));
 				}
-			} 
+			}
 			/* retries exhausted or resolve_addr failed */
 			dapl_log(DAPL_DBG_TYPE_ERR,
-				"dapl_cma_active: ARP_ERR, retries(%d)"
-				" exhausted -> DST %s,%d\n", 
-                        	IB_ARP_RETRY_COUNT, 
-				inet_ntoa(((struct sockaddr_in *)
-				&conn->cm_id->route.addr.dst_addr)->sin_addr),
-				ntohs(((struct sockaddr_in *)
-				&conn->cm_id->route.addr.dst_addr)->sin_port));
+				 "dapl_cma_active: ARP_ERR, retries(%d)"
+				 " exhausted -> DST %s,%d\n",
+				 IB_ARP_RETRY_COUNT,
+				 inet_ntoa(((struct sockaddr_in *)
+					    &conn->cm_id->route.addr.dst_addr)->
+					   sin_addr),
+				 ntohs(((struct sockaddr_in *)
+					&conn->cm_id->route.addr.dst_addr)->
+				       sin_port));
 
-			dapl_evd_connection_callback(
-				conn, IB_CME_DESTINATION_UNREACHABLE, 
-				NULL, conn->ep);
+			dapl_evd_connection_callback(conn,
+						     IB_CME_DESTINATION_UNREACHABLE,
+						     NULL, conn->ep);
 			break;
 
 		case RDMA_CM_EVENT_ROUTE_ERROR:
-			dapl_log(DAPL_DBG_TYPE_WARN, 
+			dapl_log(DAPL_DBG_TYPE_WARN,
 				 "dapl_cma_active: CM ROUTE ERROR: ->"
-				 " DST %s retry (%d)..\n", 
+				 " DST %s retry (%d)..\n",
 				 inet_ntoa(((struct sockaddr_in *)
-					&conn->r_addr)->sin_addr),
-				 conn->route_retries );
+					    &conn->r_addr)->sin_addr),
+				 conn->route_retries);
 
 			/* retry route resolution */
-			if ((--conn->route_retries) && 
-				(event->status == -ETIMEDOUT))
+			if ((--conn->route_retries) &&
+			    (event->status == -ETIMEDOUT))
 				dapli_addr_resolve(conn);
 			else {
-			    dapl_log(DAPL_DBG_TYPE_ERR,
-                        	"dapl_cma_active: PATH_RECORD_ERR,"
-				" retries(%d) exhausted, DST %s,%d\n",
-                        	IB_ROUTE_RETRY_COUNT, 
-				inet_ntoa(((struct sockaddr_in *)
-				&conn->cm_id->route.addr.dst_addr)->sin_addr),
-				ntohs(((struct sockaddr_in *)
-				&conn->cm_id->route.addr.dst_addr)->sin_port));
+				dapl_log(DAPL_DBG_TYPE_ERR,
+					 "dapl_cma_active: PATH_RECORD_ERR,"
+					 " retries(%d) exhausted, DST %s,%d\n",
+					 IB_ROUTE_RETRY_COUNT,
+					 inet_ntoa(((struct sockaddr_in *)
+						    &conn->cm_id->route.addr.
+						    dst_addr)->sin_addr),
+					 ntohs(((struct sockaddr_in *)
+						&conn->cm_id->route.addr.
+						dst_addr)->sin_port));
 
-				dapl_evd_connection_callback( 
-					conn, 
-					IB_CME_DESTINATION_UNREACHABLE, 
-					NULL, conn->ep);
+				dapl_evd_connection_callback(conn,
+							     IB_CME_DESTINATION_UNREACHABLE,
+							     NULL, conn->ep);
 			}
 			break;
-		
+
 		case RDMA_CM_EVENT_DEVICE_REMOVAL:
-			dapl_evd_connection_callback(conn, 
-						     IB_CME_LOCAL_FAILURE, 
+			dapl_evd_connection_callback(conn,
+						     IB_CME_LOCAL_FAILURE,
 						     NULL, conn->ep);
 			break;
 		case RDMA_CM_EVENT_CONNECT_REQUEST:
@@ -1280,22 +1270,22 @@
 		case RDMA_CM_EVENT_ESTABLISHED:
 		case RDMA_CM_EVENT_DISCONNECTED:
 			/* passive or active */
-			if (conn->sp) 
-				dapli_cm_passive_cb(conn,event);
-			else 
-				dapli_cm_active_cb(conn,event);
+			if (conn->sp)
+				dapli_cm_passive_cb(conn, event);
+			else
+				dapli_cm_active_cb(conn, event);
 			break;
 		case RDMA_CM_EVENT_CONNECT_RESPONSE:
 		default:
 			dapl_dbg_log(DAPL_DBG_TYPE_WARN,
-			     " cm_event: UNEXPECTED EVENT=%p ID=%p CTX=%p\n",
-			     event->event, event->id, 
-			     event->id->context);
+				     " cm_event: UNEXPECTED EVENT=%p ID=%p CTX=%p\n",
+				     event->event, event->id,
+				     event->id->context);
 			break;
 		}
 		/* ack event, unblocks destroy_cm_id in consumer threads */
 		rdma_ack_cm_event(event);
-	} 
+	}
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cq.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cq.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_cq.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -35,43 +35,35 @@
  *
  **********************************************************************/
 
+#include "openib_osd.h"
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_lmr_util.h"
 #include "dapl_evd_util.h"
 #include "dapl_ring_buffer_util.h"
-#include <sys/poll.h>
 
 /* One CQ event channel per HCA */
 void dapli_cq_event_cb(struct _ib_hca_transport *hca)
 {
 	/* check all comp events on this device */
-	struct dapl_evd	*evd_ptr = NULL;
-	struct ibv_cq	*ibv_cq = NULL;
-	struct pollfd	cq_fd = {
-		.fd      = hca->ib_cq->fd,
-		.events  = POLLIN,
-		.revents = 0 
-	};
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL," dapli_cq_event_cb(%p)\n", hca);
+	struct dapl_evd *evd_ptr = NULL;
+	struct ibv_cq *ibv_cq = NULL;
 
-	if ((poll(&cq_fd, 1, 0) == 1) &&
-		(!ibv_get_cq_event(hca->ib_cq,  
-				   &ibv_cq, (void*)&evd_ptr))) {
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapli_cq_event_cb(%p)\n", hca);
 
+	if (!ibv_get_cq_event(hca->ib_cq, &ibv_cq, (void *)&evd_ptr)) {
+
 		if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD)) {
 			ibv_ack_cq_events(ibv_cq, 1);
 			return;
 		}
 
 		/* process DTO event via callback */
-		dapl_evd_dto_callback ( hca->cm_id->verbs,
-					evd_ptr->ib_cq_handle,
-					(void*)evd_ptr );
+		dapl_evd_dto_callback(hca->cm_id->verbs,
+				      evd_ptr->ib_cq_handle, (void *)evd_ptr);
 
 		ibv_ack_cq_events(ibv_cq, 1);
-	} 
+	}
 }
 
 /*
@@ -79,34 +71,54 @@
  *
  * Not returned by verbs:     DAT_DTO_ERR_PARTIAL_PACKET
  */
-static struct ib_status_map
-{
-    int				ib_status;
-    DAT_DTO_COMPLETION_STATUS	dat_status;
+static struct ib_status_map {
+	int ib_status;
+	DAT_DTO_COMPLETION_STATUS dat_status;
 } ib_status_map[] = {
-/* 00 */  { IBV_WC_SUCCESS,		DAT_DTO_SUCCESS},
-/* 01 */  { IBV_WC_LOC_LEN_ERR,		DAT_DTO_ERR_LOCAL_LENGTH},
-/* 02 */  { IBV_WC_LOC_QP_OP_ERR,	DAT_DTO_ERR_LOCAL_EP},
-/* 03 */  { IBV_WC_LOC_EEC_OP_ERR,	DAT_DTO_ERR_TRANSPORT},
-/* 04 */  { IBV_WC_LOC_PROT_ERR,	DAT_DTO_ERR_LOCAL_PROTECTION},
-/* 05 */  { IBV_WC_WR_FLUSH_ERR,	DAT_DTO_ERR_FLUSHED},
-/* 06 */  { IBV_WC_MW_BIND_ERR,		DAT_RMR_OPERATION_FAILED},
-/* 07 */  { IBV_WC_BAD_RESP_ERR,	DAT_DTO_ERR_BAD_RESPONSE},
-/* 08 */  { IBV_WC_LOC_ACCESS_ERR,	DAT_DTO_ERR_LOCAL_PROTECTION},
-/* 09 */  { IBV_WC_REM_INV_REQ_ERR,	DAT_DTO_ERR_REMOTE_RESPONDER},
-/* 10 */  { IBV_WC_REM_ACCESS_ERR,	DAT_DTO_ERR_REMOTE_ACCESS},
-/* 11 */  { IBV_WC_REM_OP_ERR,		DAT_DTO_ERR_REMOTE_RESPONDER},
-/* 12 */  { IBV_WC_RETRY_EXC_ERR,	DAT_DTO_ERR_TRANSPORT},
-/* 13 */  { IBV_WC_RNR_RETRY_EXC_ERR,	DAT_DTO_ERR_RECEIVER_NOT_READY},
-/* 14 */  { IBV_WC_LOC_RDD_VIOL_ERR,	DAT_DTO_ERR_LOCAL_PROTECTION},
-/* 15 */  { IBV_WC_REM_INV_RD_REQ_ERR,	DAT_DTO_ERR_REMOTE_RESPONDER},
-/* 16 */  { IBV_WC_REM_ABORT_ERR,	DAT_DTO_ERR_REMOTE_RESPONDER},
-/* 17 */  { IBV_WC_INV_EECN_ERR,	DAT_DTO_ERR_TRANSPORT},
-/* 18 */  { IBV_WC_INV_EEC_STATE_ERR,	DAT_DTO_ERR_TRANSPORT},
-/* 19 */  { IBV_WC_FATAL_ERR,		DAT_DTO_ERR_TRANSPORT},
-/* 20 */  { IBV_WC_RESP_TIMEOUT_ERR,	DAT_DTO_ERR_RECEIVER_NOT_READY},
-/* 21 */  { IBV_WC_GENERAL_ERR,		DAT_DTO_ERR_TRANSPORT},
-};
+/* 00 */  {
+	IBV_WC_SUCCESS, DAT_DTO_SUCCESS},
+/* 01 */  {
+	IBV_WC_LOC_LEN_ERR, DAT_DTO_ERR_LOCAL_LENGTH},
+/* 02 */  {
+	IBV_WC_LOC_QP_OP_ERR, DAT_DTO_ERR_LOCAL_EP},
+/* 03 */  {
+	IBV_WC_LOC_EEC_OP_ERR, DAT_DTO_ERR_TRANSPORT},
+/* 04 */  {
+	IBV_WC_LOC_PROT_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
+/* 05 */  {
+	IBV_WC_WR_FLUSH_ERR, DAT_DTO_ERR_FLUSHED},
+/* 06 */  {
+	IBV_WC_MW_BIND_ERR, DAT_RMR_OPERATION_FAILED},
+/* 07 */  {
+	IBV_WC_BAD_RESP_ERR, DAT_DTO_ERR_BAD_RESPONSE},
+/* 08 */  {
+	IBV_WC_LOC_ACCESS_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
+/* 09 */  {
+	IBV_WC_REM_INV_REQ_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+/* 10 */  {
+	IBV_WC_REM_ACCESS_ERR, DAT_DTO_ERR_REMOTE_ACCESS},
+/* 11 */  {
+	IBV_WC_REM_OP_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+/* 12 */  {
+	IBV_WC_RETRY_EXC_ERR, DAT_DTO_ERR_TRANSPORT},
+/* 13 */  {
+	IBV_WC_RNR_RETRY_EXC_ERR, DAT_DTO_ERR_RECEIVER_NOT_READY},
+/* 14 */  {
+	IBV_WC_LOC_RDD_VIOL_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
+/* 15 */  {
+	IBV_WC_REM_INV_RD_REQ_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+/* 16 */  {
+	IBV_WC_REM_ABORT_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+/* 17 */  {
+	IBV_WC_INV_EECN_ERR, DAT_DTO_ERR_TRANSPORT},
+/* 18 */  {
+	IBV_WC_INV_EEC_STATE_ERR, DAT_DTO_ERR_TRANSPORT},
+/* 19 */  {
+	IBV_WC_FATAL_ERR, DAT_DTO_ERR_TRANSPORT},
+/* 20 */  {
+	IBV_WC_RESP_TIMEOUT_ERR, DAT_DTO_ERR_RECEIVER_NOT_READY},
+/* 21 */  {
+IBV_WC_GENERAL_ERR, DAT_DTO_ERR_TRANSPORT},};
 
 /*
  * dapls_ib_get_dto_status
@@ -124,69 +136,68 @@
  */
 
 DAT_DTO_COMPLETION_STATUS
-dapls_ib_get_dto_status (IN ib_work_completion_t *cqe_ptr)
+dapls_ib_get_dto_status(IN ib_work_completion_t * cqe_ptr)
 {
 	uint32_t ib_status;
 	int i;
 
-	ib_status = DAPL_GET_CQE_STATUS (cqe_ptr);
+	ib_status = DAPL_GET_CQE_STATUS(cqe_ptr);
 
 	/*
-	* Due to the implementation of verbs completion code, we need to
-	* search the table for the correct value rather than assuming
-	* linear distribution.
-	*/
-	for (i=0; i <= IBV_WC_GENERAL_ERR; i++) {
+	 * Due to the implementation of verbs completion code, we need to
+	 * search the table for the correct value rather than assuming
+	 * linear distribution.
+	 */
+	for (i = 0; i <= IBV_WC_GENERAL_ERR; i++) {
 		if (ib_status == ib_status_map[i].ib_status) {
 			if (ib_status != IBV_WC_SUCCESS) {
 				dapl_dbg_log(DAPL_DBG_TYPE_DTO_COMP_ERR,
-	    				" DTO completion ERROR: %d: op %#x\n",
-					ib_status, 
-					DAPL_GET_CQE_OPTYPE (cqe_ptr));
+					     " DTO completion ERROR: %d: op %#x\n",
+					     ib_status,
+					     DAPL_GET_CQE_OPTYPE(cqe_ptr));
 			}
 			return ib_status_map[i].dat_status;
 		}
 	}
 
 	dapl_dbg_log(DAPL_DBG_TYPE_DTO_COMP_ERR,
-	    	     " DTO completion ERROR: %d: op %#x\n", 
-		     ib_status,
-		     DAPL_GET_CQE_OPTYPE (cqe_ptr));
+		     " DTO completion ERROR: %d: op %#x\n",
+		     ib_status, DAPL_GET_CQE_OPTYPE(cqe_ptr));
 
 	return DAT_DTO_FAILURE;
 }
-    
-DAT_RETURN dapls_ib_get_async_event(IN ib_error_record_t *err_record,
-				    OUT DAT_EVENT_NUMBER *async_event)
+
+DAT_RETURN dapls_ib_get_async_event(IN ib_error_record_t * err_record,
+				    OUT DAT_EVENT_NUMBER * async_event)
 {
 	DAT_RETURN dat_status = DAT_SUCCESS;
 	int err_code = err_record->event_type;
 
 	switch (err_code) {
-	/* OVERFLOW error */
+		/* OVERFLOW error */
 	case IBV_EVENT_CQ_ERR:
 		*async_event = DAT_ASYNC_ERROR_EVD_OVERFLOW;
 		break;
-	/* INTERNAL errors */
+		/* INTERNAL errors */
 	case IBV_EVENT_DEVICE_FATAL:
 		*async_event = DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR;
 		break;
-	/* CATASTROPHIC errors */
+		/* CATASTROPHIC errors */
 	case IBV_EVENT_PORT_ERR:
 		*async_event = DAT_ASYNC_ERROR_IA_CATASTROPHIC;
 		break;
-	/* BROKEN QP error */
+		/* BROKEN QP error */
 	case IBV_EVENT_SQ_DRAINED:
 	case IBV_EVENT_QP_FATAL:
 	case IBV_EVENT_QP_REQ_ERR:
 	case IBV_EVENT_QP_ACCESS_ERR:
 		*async_event = DAT_ASYNC_ERROR_EP_BROKEN;
 		break;
-	/* connection completion */
+		/* connection completion */
 	case IBV_EVENT_COMM_EST:
 		*async_event = DAT_CONNECTION_EVENT_ESTABLISHED;
 		break;
-	/* TODO: process HW state changes */
+		/* TODO: process HW state changes */
 	case IBV_EVENT_PATH_MIG:
 	case IBV_EVENT_PATH_MIG_ERR:
 	case IBV_EVENT_PORT_ACTIVE:
@@ -194,7 +205,7 @@
 	case IBV_EVENT_PKEY_CHANGE:
 	case IBV_EVENT_SM_CHANGE:
 	default:
-		dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, 0);
+		dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
 	}
 	return dat_status;
 }
@@ -218,15 +229,14 @@
  *
  */
 DAT_RETURN
-dapls_ib_cq_alloc(IN DAPL_IA *ia_ptr,
-		  IN DAPL_EVD *evd_ptr,
-		  IN DAT_COUNT *cqlen )
+dapls_ib_cq_alloc(IN DAPL_IA * ia_ptr,
+		  IN DAPL_EVD * evd_ptr, IN DAT_COUNT * cqlen)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		"dapls_ib_cq_alloc: evd %p cqlen=%d \n", evd_ptr, *cqlen);
-
 	struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     "dapls_ib_cq_alloc: evd %p cqlen=%d \n", evd_ptr, *cqlen);
+
 #ifdef CQ_WAIT_OBJECT
 	if (evd_ptr->cq_wait_obj_handle)
 		channel = evd_ptr->cq_wait_obj_handle->events;
@@ -234,27 +244,24 @@
 
 	/* Call IB verbs to create CQ */
 	evd_ptr->ib_cq_handle = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle,
-					      *cqlen,
-					      evd_ptr,
-					      channel, 0);
-	
-	if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE) 
-		return(dapl_convert_errno(errno,"create_cq"));
+					      *cqlen, evd_ptr, channel, 0);
 
+	if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE)
+		return (dapl_convert_errno(errno, "create_cq"));
+
 	/* arm cq for events */
 	dapls_set_cq_notify(ia_ptr, evd_ptr);
-	
-        /* update with returned cq entry size */
+
+	/* update with returned cq entry size */
 	*cqlen = evd_ptr->ib_cq_handle->cqe;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     "dapls_ib_cq_alloc: new_cq %p cqlen=%d \n", 
-		     evd_ptr->ib_cq_handle, *cqlen );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     "dapls_ib_cq_alloc: new_cq %p cqlen=%d \n",
+		     evd_ptr->ib_cq_handle, *cqlen);
 
 	return DAT_SUCCESS;
 }
 
-
 /*
  * dapl_ib_cq_resize
  *
@@ -274,9 +281,8 @@
  *
  */
 DAT_RETURN
-dapls_ib_cq_resize(IN DAPL_IA *ia_ptr,
-		   IN DAPL_EVD *evd_ptr,
-		   IN DAT_COUNT *cqlen )
+dapls_ib_cq_resize(IN DAPL_IA * ia_ptr,
+		   IN DAPL_EVD * evd_ptr, IN DAT_COUNT * cqlen)
 {
 	ib_cq_handle_t new_cq;
 	struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
@@ -295,21 +301,21 @@
 	new_cq = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle, *cqlen,
 			       evd_ptr, channel, 0);
 
-	if (new_cq == IB_INVALID_HANDLE) 
-		return	DAT_INSUFFICIENT_RESOURCES;
-	
+	if (new_cq == IB_INVALID_HANDLE)
+		return DAT_INSUFFICIENT_RESOURCES;
+
 	/* destroy the original and replace if successful */
 	if (ibv_destroy_cq(evd_ptr->ib_cq_handle)) {
 		ibv_destroy_cq(new_cq);
-		return(dapl_convert_errno(errno,"resize_cq"));
+		return (dapl_convert_errno(errno, "resize_cq"));
 	}
-		
+
 	/* update EVD with new cq handle and size */
 	evd_ptr->ib_cq_handle = new_cq;
 	*cqlen = new_cq->cqe;
 
 	/* arm cq for events */
-	dapls_set_cq_notify (ia_ptr, evd_ptr);
+	dapls_set_cq_notify(ia_ptr, evd_ptr);
 
 	return DAT_SUCCESS;
 }
@@ -331,13 +337,13 @@
  *	DAT_INVALID_PARAMETER
  *
  */
-DAT_RETURN dapls_ib_cq_free(IN DAPL_IA *ia_ptr, IN DAPL_EVD *evd_ptr)
+DAT_RETURN dapls_ib_cq_free(IN DAPL_IA * ia_ptr, IN DAPL_EVD * evd_ptr)
 {
 	if (evd_ptr->ib_cq_handle != IB_INVALID_HANDLE) {
-		/* copy all entries on CQ to EVD before destroying */	
-		dapls_evd_copy_cq(evd_ptr); 
-		if (ibv_destroy_cq(evd_ptr->ib_cq_handle)) 
-			return(dapl_convert_errno(errno,"destroy_cq"));
+		/* copy all entries on CQ to EVD before destroying */
+		dapls_evd_copy_cq(evd_ptr);
+		if (ibv_destroy_cq(evd_ptr->ib_cq_handle))
+			return (dapl_convert_errno(errno, "destroy_cq"));
 		evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
 	}
 	return DAT_SUCCESS;
@@ -359,10 +365,10 @@
  * 	DAT_SUCCESS
  *	dapl_convert_errno 
  */
-DAT_RETURN dapls_set_cq_notify(IN DAPL_IA *ia_ptr, IN DAPL_EVD *evd_ptr)
+DAT_RETURN dapls_set_cq_notify(IN DAPL_IA * ia_ptr, IN DAPL_EVD * evd_ptr)
 {
 	if (ibv_req_notify_cq(evd_ptr->ib_cq_handle, 0))
-		return(dapl_convert_errno(errno,"notify_cq"));
+		return (dapl_convert_errno(errno, "notify_cq"));
 	else
 		return DAT_SUCCESS;
 }
@@ -385,11 +391,11 @@
  *	dapl_convert_errno
  */
 DAT_RETURN dapls_ib_completion_notify(IN ib_hca_handle_t hca_handle,
-				      IN DAPL_EVD *evd_ptr,
+				      IN DAPL_EVD * evd_ptr,
 				      IN ib_notification_type_t type)
 {
-	if (ibv_req_notify_cq( evd_ptr->ib_cq_handle, type ))
-		return(dapl_convert_errno(errno,"notify_cq_type"));
+	if (ibv_req_notify_cq(evd_ptr->ib_cq_handle, type))
+		return (dapl_convert_errno(errno, "notify_cq_type"));
 	else
 		return DAT_SUCCESS;
 }
@@ -412,13 +418,13 @@
  *	DAT_QUEUE_EMPTY
  *	
  */
-DAT_RETURN dapls_ib_completion_poll(IN DAPL_HCA *hca_ptr,
-				    IN DAPL_EVD *evd_ptr,
-				    IN ib_work_completion_t *wc_ptr)
+DAT_RETURN dapls_ib_completion_poll(IN DAPL_HCA * hca_ptr,
+				    IN DAPL_EVD * evd_ptr,
+				    IN ib_work_completion_t * wc_ptr)
 {
 	if (ibv_poll_cq(evd_ptr->ib_cq_handle, 1, wc_ptr) == 1)
 		return DAT_SUCCESS;
-	
+
 	return DAT_QUEUE_EMPTY;
 }
 
@@ -426,70 +432,65 @@
 
 /* NEW common wait objects for providers with direct CQ wait objects */
 DAT_RETURN
-dapls_ib_wait_object_create(IN DAPL_EVD *evd_ptr,
-			    IN ib_wait_obj_handle_t *p_cq_wait_obj_handle)
+dapls_ib_wait_object_create(IN DAPL_EVD * evd_ptr,
+			    IN ib_wait_obj_handle_t * p_cq_wait_obj_handle)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " cq_object_create: (%p,%p)\n", 
-		     evd_ptr, p_cq_wait_obj_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_create: (%p,%p)\n",
+		     evd_ptr, p_cq_wait_obj_handle);
 
-	*p_cq_wait_obj_handle = 
-		dapl_os_alloc(sizeof(struct _ib_wait_obj_handle));
+	*p_cq_wait_obj_handle =
+	    dapl_os_alloc(sizeof(struct _ib_wait_obj_handle));
 
-	if (*p_cq_wait_obj_handle == NULL) 
-		return(dapl_convert_errno(ENOMEM," wait_object_create"));
-	
-	dapl_os_memzero(*p_cq_wait_obj_handle, 
+	if (*p_cq_wait_obj_handle == NULL)
+		return (dapl_convert_errno(ENOMEM, " wait_object_create"));
+
+	dapl_os_memzero(*p_cq_wait_obj_handle,
 			sizeof(struct _ib_wait_obj_handle));
 
 	/* create pipe for waking up work thread */
-	if (pipe((*p_cq_wait_obj_handle)->pipe)) 
+	if (pipe((*p_cq_wait_obj_handle)->pipe))
 		goto bail;
-		
+
 	/* set cq_wait object to evd_ptr */
-	(*p_cq_wait_obj_handle)->events = 
-		ibv_create_comp_channel(
-			evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle);	
-		
-	if ((*p_cq_wait_obj_handle)->events == NULL) 		
+	(*p_cq_wait_obj_handle)->events =
+	    ibv_create_comp_channel(evd_ptr->header.owner_ia->hca_ptr->
+				    ib_hca_handle);
+
+	if ((*p_cq_wait_obj_handle)->events == NULL)
 		goto bail;
 
 	return DAT_SUCCESS;
-bail:
-	dapl_os_free(*p_cq_wait_obj_handle, 
-		     sizeof(struct _ib_wait_obj_handle));
+      bail:
+	dapl_os_free(*p_cq_wait_obj_handle, sizeof(struct _ib_wait_obj_handle));
 	*p_cq_wait_obj_handle = NULL;
-	return(dapl_convert_errno(errno," wait_object_create"));
+	return (dapl_convert_errno(errno, " wait_object_create"));
 }
 
-
 DAT_RETURN
 dapls_ib_wait_object_destroy(IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " cq_object_destroy: wait_obj=%p\n", 
-		     p_cq_wait_obj_handle );
-	
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_destroy: wait_obj=%p\n", p_cq_wait_obj_handle);
+
 	ibv_destroy_comp_channel(p_cq_wait_obj_handle->events);
 
-	dapl_os_free(p_cq_wait_obj_handle, 
-		     sizeof(struct _ib_wait_obj_handle));
+	dapl_os_free(p_cq_wait_obj_handle, sizeof(struct _ib_wait_obj_handle));
 
 	return DAT_SUCCESS;
 }
 
 DAT_RETURN
-dapls_ib_wait_object_wakeup (IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
+dapls_ib_wait_object_wakeup(IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
 {
-	dapl_dbg_log (  DAPL_DBG_TYPE_UTIL, 
-			" cq_object_wakeup: wait_obj=%p\n", 
-			p_cq_wait_obj_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wakeup: wait_obj=%p\n", p_cq_wait_obj_handle);
 
-        /* write to pipe for wake up */
-        if (write(p_cq_wait_obj_handle->pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-		" wait object wakeup write error = %s\n",
-		strerror(errno));
+	/* write to pipe for wake up */
+	if (write(p_cq_wait_obj_handle->pipe[1], "w", sizeof "w") == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " wait object wakeup write error = %s\n",
+			 strerror(errno));
 	return DAT_SUCCESS;
 }
 
@@ -497,15 +498,15 @@
 dapls_ib_wait_object_wait(IN ib_wait_obj_handle_t p_cq_wait_obj_handle,
 			  IN u_int32_t timeout)
 {
-	struct dapl_evd	*evd_ptr;
-	struct ibv_cq	*ibv_cq = NULL;
-	int		status = 0; 
-	int		timeout_ms = -1;
-	struct pollfd   ufds[2];
+	struct dapl_evd *evd_ptr;
+	struct ibv_cq *ibv_cq = NULL;
+	int status = 0;
+	int timeout_ms = -1;
+	struct pollfd ufds[2];
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " cq_object_wait: CQ channel %p time %d\n", 
-		     p_cq_wait_obj_handle, timeout );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wait: CQ channel %p time %d\n",
+		     p_cq_wait_obj_handle, timeout);
 
 	/* setup cq event channel and pipe fd for consumer wakeup */
 	ufds[0].fd = p_cq_wait_obj_handle->events->fd;
@@ -514,38 +515,38 @@
 	ufds[1].fd = p_cq_wait_obj_handle->pipe[0];
 	ufds[1].events = POLLIN;
 	ufds[1].revents = 0;
-	
+
 	/* uDAPL timeout values in usecs */
 	if (timeout != DAT_TIMEOUT_INFINITE)
-		timeout_ms = timeout/1000;
+		timeout_ms = timeout / 1000;
 
 	/* restart syscall */
-	while ((status = poll(ufds, 2, timeout_ms)) == -1 )
+	while ((status = poll(ufds, 2, timeout_ms)) == -1)
 		if (errno == EINTR)
 			continue;
 
 	/* returned event */
 	if (status > 0) {
 		if (ufds[0].revents == POLLIN) {
-			if (!ibv_get_cq_event(p_cq_wait_obj_handle->events, 
-					      &ibv_cq, (void*)&evd_ptr)) {
+			if (!ibv_get_cq_event(p_cq_wait_obj_handle->events,
+					      &ibv_cq, (void *)&evd_ptr)) {
 				ibv_ack_cq_events(ibv_cq, 1);
 			}
 		}
 		status = 0;
 
-	/* timeout */
-	} else if (status == 0) 
+		/* timeout */
+	} else if (status == 0)
 		status = ETIMEDOUT;
-	else 
+	else
 		status = errno;
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 		     " cq_object_wait: RET evd %p ibv_cq %p %s\n",
 		     evd_ptr, ibv_cq, strerror(errno));
-	
-	return(dapl_convert_errno(status,"cq_wait_object_wait"));
 
+	return (dapl_convert_errno(status, "cq_wait_object_wait"));
+
 }
 #endif
 
@@ -556,4 +557,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_dto.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_dto.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_dto.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -54,8 +54,6 @@
 #include <dat2/dat_ib_extensions.h>
 #endif
 
-#define	DEFAULT_DS_ENTRIES	8
-
 STATIC _INLINE_ int dapls_cqe_opcode(ib_work_completion_t *cqe_p);
 
 /*
@@ -70,10 +68,9 @@
 	IN  DAT_COUNT		segments,
 	IN  DAT_LMR_TRIPLET	*local_iov )
 {
-	ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-	ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
 	struct ibv_recv_wr wr;
 	struct ibv_recv_wr *bad_wr;
+	ib_data_segment_t *ds = (ib_data_segment_t *)local_iov;
 	DAT_COUNT i, total_len;
 	int ret;
 	
@@ -81,51 +78,32 @@
 		     " post_rcv: ep %p cookie %p segs %d l_iov %p\n",
 		     ep_ptr, cookie, segments, local_iov);
 
-	if (segments <= DEFAULT_DS_ENTRIES) 
-		ds_array_p = ds_array;
-	else
-		ds_array_start_p = ds_array_p = 
-			dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
-	if (NULL == ds_array_p)
-		return (DAT_INSUFFICIENT_RESOURCES);
-	
 	/* setup work request */
 	total_len = 0;
 	wr.next = 0;
-	wr.num_sge = 0;
+	wr.num_sge = segments;
 	wr.wr_id = (uint64_t)(uintptr_t)cookie;
-	wr.sg_list = ds_array_p;
+	wr.sg_list = ds;
 
-	for (i = 0; i < segments; i++) {
-		if (!local_iov[i].segment_length)
-			continue;
-
-		ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
-		ds_array_p->length = local_iov[i].segment_length;
-		ds_array_p->lkey = local_iov[i].lmr_context;
-		
-		dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-			     " post_rcv: l_key 0x%x va %p len %d\n",
-			     ds_array_p->lkey, ds_array_p->addr, 
-			     ds_array_p->length );
-
-		total_len += ds_array_p->length;
-		wr.num_sge++;
-		ds_array_p++;
+	if (cookie != NULL) { 
+		for (i = 0; i < segments; i++) {
+			dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+				     " post_rcv: l_key 0x%x va %p len %d\n",
+				     ds->lkey, ds->addr, ds->length);
+			total_len += ds->length;
+			ds++;
+		}
+		cookie->val.dto.size = total_len;
 	}
 
-	if (cookie != NULL) 
-		cookie->val.dto.size = total_len;
-
 	ret = ibv_post_recv(ep_ptr->qp_handle->cm_id->qp, &wr, &bad_wr);
 	
-	if (ds_array_start_p != NULL)
-	    dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
 	if (ret)
 		return( dapl_convert_errno(errno,"ibv_recv") );
 
+	DAPL_CNTR(ep_ptr, DCNT_EP_POST_RECV);
+	DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_RECV_DATA, total_len);
+
 	return DAT_SUCCESS;
 }
 
@@ -144,64 +122,40 @@
 	IN  const DAT_RMR_TRIPLET	*remote_iov,
 	IN  DAT_COMPLETION_FLAGS	completion_flags)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p op %d ck %p sgs",
-		     "%d l_iov %p r_iov %p f %d\n",
-		     ep_ptr, op_type, cookie, segments, local_iov, 
-		     remote_iov, completion_flags);
-
-	ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-	ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
 	struct ibv_send_wr wr;
 	struct ibv_send_wr *bad_wr;
+	ib_data_segment_t *ds = (ib_data_segment_t *)local_iov;
 	ib_hca_transport_t *ibt_ptr = 
 		&ep_ptr->header.owner_ia->hca_ptr->ib_trans;
 	DAT_COUNT i, total_len;
 	int ret;
 	
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
-		     ep_ptr, cookie, segments, local_iov);
+		     " post_snd: ep %p op %d ck %p sgs",
+		     "%d l_iov %p r_iov %p f %d\n",
+		     ep_ptr, op_type, cookie, segments, local_iov, 
+		     remote_iov, completion_flags);
 
-	if(segments <= DEFAULT_DS_ENTRIES) 
-		ds_array_p = ds_array;
-	else
-		ds_array_start_p = ds_array_p = 
-			dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
-	if (NULL == ds_array_p)
-		return (DAT_INSUFFICIENT_RESOURCES);
-	
 	/* setup the work request */
 	wr.next = 0;
 	wr.opcode = op_type;
-	wr.num_sge = 0;
+	wr.num_sge = segments;
 	wr.send_flags = 0;
 	wr.wr_id = (uint64_t)(uintptr_t)cookie;
-	wr.sg_list = ds_array_p;
+	wr.sg_list = ds;
 	total_len = 0;
 
-	for (i = 0; i < segments; i++ ) {
-		if ( !local_iov[i].segment_length )
-			continue;
-
-		ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
-		ds_array_p->length = local_iov[i].segment_length;
-		ds_array_p->lkey = local_iov[i].lmr_context;
-		
-		dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-			     " post_snd: lkey 0x%x va %p len %d\n",
-			     ds_array_p->lkey, ds_array_p->addr, 
-			     ds_array_p->length );
-
-		total_len += ds_array_p->length;
-		wr.num_sge++;
-		ds_array_p++;
+	if (cookie != NULL) {
+		for (i = 0; i < segments; i++ ) {
+			dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+				     " post_snd: lkey 0x%x va %p len %d\n",
+				     ds->lkey, ds->addr, ds->length );
+			total_len += ds->length;
+			ds++;
+		}
+		cookie->val.dto.size = total_len;
 	}
 
-	if (cookie != NULL) 
-		cookie->val.dto.size = total_len;
-
 	if (wr.num_sge && 
 	    (op_type == OP_RDMA_WRITE || op_type == OP_RDMA_READ)) {
 		wr.wr.rdma.remote_addr = remote_iov->virtual_address;
@@ -211,7 +165,6 @@
 			     wr.wr.rdma.rkey, wr.wr.rdma.remote_addr);
 	}
 
-
 	/* inline data for send or write ops */
 	if ((total_len <= ibt_ptr->max_inline_send) && 
 	   ((op_type == OP_SEND) || (op_type == OP_RDMA_WRITE))) 
@@ -231,12 +184,28 @@
 
 	ret = ibv_post_send(ep_ptr->qp_handle->cm_id->qp, &wr, &bad_wr);
 
-	if (ds_array_start_p != NULL)
-	    dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
 	if (ret)
 		return( dapl_convert_errno(errno,"ibv_send") );
 
+#ifdef DAPL_COUNTERS
+	switch (op_type) {
+	case OP_SEND:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_SEND);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_SEND_DATA,total_len);
+		break;
+	case OP_RDMA_WRITE:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_WRITE);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_WRITE_DATA,total_len);
+		break;	
+	case OP_RDMA_READ:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_READ);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_READ_DATA,total_len);
+		break;
+	default:
+		break;
+	}
+#endif /* DAPL_COUNTERS */
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP," post_snd: returned\n");
 	return DAT_SUCCESS;
 }
@@ -297,62 +266,38 @@
 	IN  DAT_UINT64			swap,
 	IN  DAT_COMPLETION_FLAGS	completion_flags)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p op %d ck %p sgs",
-		     "%d l_iov %p r_iov %p f %d\n",
-		     ep_ptr, op_type, cookie, segments, local_iov, 
-		     remote_iov, completion_flags);
-
-	ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-	ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
 	struct ibv_send_wr wr;
 	struct ibv_send_wr *bad_wr;
+	ib_data_segment_t *ds = (ib_data_segment_t *)local_iov;
 	DAT_COUNT i, total_len;
 	int ret;
 	
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
-		     ep_ptr, cookie, segments, local_iov);
+		     " post_ext_snd: ep %p op %d ck %p sgs",
+		     "%d l_iov %p r_iov %p f %d\n",
+		     ep_ptr, op_type, cookie, segments, local_iov, 
+		     remote_iov, completion_flags);
 
-	if(segments <= DEFAULT_DS_ENTRIES) 
-		ds_array_p = ds_array;
-	else
-		ds_array_start_p = ds_array_p = 
-			dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
-	if (NULL == ds_array_p)
-		return (DAT_INSUFFICIENT_RESOURCES);
-	
 	/* setup the work request */
 	wr.next = 0;
 	wr.opcode = op_type;
-	wr.num_sge = 0;
+	wr.num_sge = segments;
 	wr.send_flags = 0;
 	wr.wr_id = (uint64_t)(uintptr_t)cookie;
-	wr.sg_list = ds_array_p;
+	wr.sg_list = ds;
 	total_len = 0;
 
-	for (i = 0; i < segments; i++ ) {
-		if ( !local_iov[i].segment_length )
-			continue;
-
-		ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
-		ds_array_p->length = local_iov[i].segment_length;
-		ds_array_p->lkey = local_iov[i].lmr_context;
-		
-		dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-			     " post_snd: lkey 0x%x va %p len %d\n",
-			     ds_array_p->lkey, ds_array_p->addr, 
-			     ds_array_p->length );
-
-		total_len += ds_array_p->length;
-		wr.num_sge++;
-		ds_array_p++;
+	if (cookie != NULL) {
+		for (i = 0; i < segments; i++ ) {
+			dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+				     " post_ext_snd: lkey 0x%x va %p ln %d\n",
+				     ds->lkey, ds->addr, ds->length);
+			total_len += ds->length;
+			ds++;
+		}
+		cookie->val.dto.size = total_len;
 	}
 
-	if (cookie != NULL) 
-		cookie->val.dto.size = total_len;
-
 	switch (op_type) {
 	case OP_RDMA_WRITE_IMM:
 		/* OP_RDMA_WRITE)IMMED has direct IB wr_type mapping */
@@ -411,12 +356,27 @@
 
 	ret = ibv_post_send(ep_ptr->qp_handle->cm_id->qp, &wr, &bad_wr);
 
-	if (segments > DEFAULT_DS_ENTRIES)
-	    dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
 	if (ret)
 		return( dapl_convert_errno(errno,"ibv_send") );
-	
+
+#ifdef DAPL_COUNTERS
+	switch (op_type) {
+	case OP_RDMA_WRITE_IMM:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_WRITE_IMM);
+		DAPL_CNTR_DATA(ep_ptr, 
+			       DCNT_EP_POST_WRITE_IMM_DATA, total_len);
+		break;
+	case OP_COMP_AND_SWAP:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_CMP_SWAP);
+		break;	
+	case OP_FETCH_AND_ADD:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_FETCH_ADD);
+		break;
+	default:
+		break;
+	}
+#endif /* DAPL_COUNTERS */
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP," post_snd: returned\n");
 	return DAT_SUCCESS;
 }
@@ -434,6 +394,10 @@
 /* map Work Completions to DAPL WR operations */
 STATIC _INLINE_ int dapls_cqe_opcode(ib_work_completion_t *cqe_p)
 {
+#ifdef DAPL_COUNTERS
+	DAPL_COOKIE *cookie = (DAPL_COOKIE *)(uintptr_t)cqe_p->wr_id;
+#endif /* DAPL_COUNTERS */
+
 	switch (cqe_p->opcode) {
 	case IBV_WC_SEND:
 		return (OP_SEND);
@@ -451,11 +415,21 @@
 	case IBV_WC_BIND_MW:
 		return (OP_BIND_MW);
 	case IBV_WC_RECV:
-		if (cqe_p->wc_flags & IBV_WC_WITH_IMM)
+		if (cqe_p->wc_flags & IBV_WC_WITH_IMM) {
+			DAPL_CNTR(cookie->ep, DCNT_EP_RECV_IMM);
+			DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_IMM_DATA, 
+				       cqe_p->byte_len);
 			return (OP_RECEIVE_IMM);
-		else
+		} else {
+			DAPL_CNTR(cookie->ep, DCNT_EP_RECV);
+			DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_DATA, 
+				       cqe_p->byte_len);
 			return (OP_RECEIVE);
+		}
 	case IBV_WC_RECV_RDMA_WITH_IMM:
+		DAPL_CNTR(cookie->ep, DCNT_EP_RECV_RDMA_IMM);
+		DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_RDMA_IMM_DATA, 
+			       cqe_p->byte_len);
 		return (OP_RECEIVE_IMM);
 	default:
 		return (OP_INVALID);

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_extensions.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_extensions.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_extensions.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -43,20 +43,17 @@
 #include "dapl_cookie.h"
 #include <stdarg.h>
 
-
 DAT_RETURN
-dapli_post_ext( IN       DAT_EP_HANDLE		ep_handle,
-		IN       DAT_UINT64		cmp_add,	
-		IN       DAT_UINT64		swap,
-		IN	 DAT_UINT32		immed_data,
-		IN	 DAT_COUNT		segments,
-		IN       DAT_LMR_TRIPLET	*local_iov,
-		IN       DAT_DTO_COOKIE		user_cookie,
-		IN const DAT_RMR_TRIPLET	*remote_iov,
-		IN	 int			op_type, 
-		IN       DAT_COMPLETION_FLAGS	flags );
+dapli_post_ext(IN DAT_EP_HANDLE ep_handle,
+	       IN DAT_UINT64 cmp_add,
+	       IN DAT_UINT64 swap,
+	       IN DAT_UINT32 immed_data,
+	       IN DAT_COUNT segments,
+	       IN DAT_LMR_TRIPLET * local_iov,
+	       IN DAT_DTO_COOKIE user_cookie,
+	       IN const DAT_RMR_TRIPLET * remote_iov,
+	       IN int op_type, IN DAT_COMPLETION_FLAGS flags);
 
-
 /*
  * dapl_extensions
  *
@@ -76,114 +73,141 @@
  *
  */
 DAT_RETURN
-dapl_extensions(IN DAT_HANDLE		dat_handle, 
-		IN DAT_EXTENDED_OP	ext_op, 
-		IN va_list		args)
+dapl_extensions(IN DAT_HANDLE dat_handle,
+		IN DAT_EXTENDED_OP ext_op, IN va_list args)
 {
-	DAT_EP_HANDLE		ep;
-	DAT_LMR_TRIPLET		*lmr_p;
-	DAT_DTO_COOKIE		cookie;
-	const DAT_RMR_TRIPLET	*rmr_p;
-	DAT_UINT64		dat_uint64a, dat_uint64b;
-	DAT_UINT32		dat_uint32;
-	DAT_COUNT		segments = 1;
-	DAT_COMPLETION_FLAGS	comp_flags;
-	DAT_RETURN		status = DAT_NOT_IMPLEMENTED;
+	DAT_EP_HANDLE ep;
+	DAT_LMR_TRIPLET *lmr_p;
+	DAT_DTO_COOKIE cookie;
+	const DAT_RMR_TRIPLET *rmr_p;
+	DAT_UINT64 dat_uint64a, dat_uint64b;
+	DAT_UINT32 dat_uint32;
+	DAT_COUNT segments = 1;
+	DAT_COMPLETION_FLAGS comp_flags;
+	DAT_RETURN status = DAT_NOT_IMPLEMENTED;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_API,
 		     "dapl_extensions(hdl %p operation %d, ...)\n",
 		     dat_handle, ext_op);
 
-	DAPL_CNTR(DCNT_EXTENSION);
+	switch ((int)ext_op) {
 
-	switch ((int)ext_op)
-	{
-	
 	case DAT_IB_RDMA_WRITE_IMMED_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " WRITE_IMMED_DATA extension call\n");
-		
-		ep          = dat_handle;		 /* ep_handle */
-		segments    = va_arg( args, DAT_COUNT);  /* num segments */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*);  
-		cookie      = va_arg( args, DAT_DTO_COOKIE);
-		rmr_p       = va_arg( args, const DAT_RMR_TRIPLET*); 
-		dat_uint32  = va_arg( args, DAT_UINT32); /* immed data */
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);   
-		
+
+		ep = dat_handle;	/* ep_handle */
+		segments = va_arg(args, DAT_COUNT);	/* num segments */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		rmr_p = va_arg(args, const DAT_RMR_TRIPLET *);
+		dat_uint32 = va_arg(args, DAT_UINT32);	/* immed data */
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
+
 		status = dapli_post_ext(ep, 0, 0, dat_uint32, segments, lmr_p,
-    					cookie, rmr_p, OP_RDMA_WRITE_IMM,
-    	    				comp_flags );
-    		break;
+					cookie, rmr_p, OP_RDMA_WRITE_IMM,
+					comp_flags);
+		break;
 
 	case DAT_IB_CMP_AND_SWAP_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " CMP_AND_SWAP extension call\n");
 
-		ep          = dat_handle;		/* ep_handle */
-		dat_uint64a = va_arg( args, DAT_UINT64); /* cmp_value */
-		dat_uint64b = va_arg( args, DAT_UINT64); /* swap_value */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*); 
-		cookie      = va_arg( args, DAT_DTO_COOKIE);  
-		rmr_p       = va_arg( args, const DAT_RMR_TRIPLET*);
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);
+		ep = dat_handle;	/* ep_handle */
+		dat_uint64a = va_arg(args, DAT_UINT64);	/* cmp_value */
+		dat_uint64b = va_arg(args, DAT_UINT64);	/* swap_value */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		rmr_p = va_arg(args, const DAT_RMR_TRIPLET *);
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
 
 		status = dapli_post_ext(ep, dat_uint64a, dat_uint64b,
-					0, segments, lmr_p, cookie, rmr_p, 
-					OP_COMP_AND_SWAP, comp_flags );
-   		break;
+					0, segments, lmr_p, cookie, rmr_p,
+					OP_COMP_AND_SWAP, comp_flags);
+		break;
 
 	case DAT_IB_FETCH_AND_ADD_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " FETCH_AND_ADD extension call\n");
-		
-		ep          = dat_handle;		/* ep_handle */
-		dat_uint64a = va_arg( args, DAT_UINT64); /* add value */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*);  
-		cookie      = va_arg( args, DAT_DTO_COOKIE);
-		rmr_p       = va_arg( args, const DAT_RMR_TRIPLET*); 
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);   
-		
-		status = dapli_post_ext(ep, dat_uint64a, 0, 0, segments, 
-					lmr_p, cookie, rmr_p, 
-					OP_FETCH_AND_ADD, comp_flags );
 
-    		break;
+		ep = dat_handle;	/* ep_handle */
+		dat_uint64a = va_arg(args, DAT_UINT64);	/* add value */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		rmr_p = va_arg(args, const DAT_RMR_TRIPLET *);
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
 
+		status = dapli_post_ext(ep, dat_uint64a, 0, 0, segments,
+					lmr_p, cookie, rmr_p,
+					OP_FETCH_AND_ADD, comp_flags);
+
+		break;
+
+#ifdef DAPL_COUNTERS
+	case DAT_QUERY_COUNTERS_OP:
+		{
+			int cntr, reset;
+			DAT_UINT64 *p_cntr_out;
+
+			dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+				     " Query counter extension call\n");
+
+			cntr = va_arg(args, int);
+			p_cntr_out = va_arg(args, DAT_UINT64 *);
+			reset = va_arg(args, int);
+
+			status = dapl_query_counter(dat_handle, cntr,
+						    p_cntr_out, reset);
+			break;
+		}
+	case DAT_PRINT_COUNTERS_OP:
+		{
+			int cntr, reset;
+
+			dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+				     " Print counter extension call\n");
+
+			cntr = va_arg(args, int);
+			reset = va_arg(args, int);
+
+			dapl_print_counter(dat_handle, cntr, reset);
+			status = DAT_SUCCESS;
+			break;
+		}
+#endif				/* DAPL_COUNTERS */
+
 	default:
-    		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
 			     "unsupported extension(%d)\n", (int)ext_op);
 	}
-	
-	return(status);
+
+	return (status);
 }
 
-
 DAT_RETURN
-dapli_post_ext( IN       DAT_EP_HANDLE		ep_handle,
-		IN       DAT_UINT64		cmp_add,	
-		IN       DAT_UINT64		swap,
-		IN	 DAT_UINT32		immed_data,
-		IN	 DAT_COUNT		segments,
-		IN       DAT_LMR_TRIPLET	*local_iov,
-		IN       DAT_DTO_COOKIE		user_cookie,
-		IN const DAT_RMR_TRIPLET	*remote_iov,
-		IN	 int			op_type, 
-		IN       DAT_COMPLETION_FLAGS	flags )
+dapli_post_ext(IN DAT_EP_HANDLE ep_handle,
+	       IN DAT_UINT64 cmp_add,
+	       IN DAT_UINT64 swap,
+	       IN DAT_UINT32 immed_data,
+	       IN DAT_COUNT segments,
+	       IN DAT_LMR_TRIPLET * local_iov,
+	       IN DAT_DTO_COOKIE user_cookie,
+	       IN const DAT_RMR_TRIPLET * remote_iov,
+	       IN int op_type, IN DAT_COMPLETION_FLAGS flags)
 {
-	DAPL_EP 	*ep_ptr;
-	ib_qp_handle_t	qp_ptr;
-	DAPL_COOKIE	*cookie = NULL;
-	DAT_RETURN	dat_status = DAT_SUCCESS;
+	DAPL_EP *ep_ptr;
+	ib_qp_handle_t qp_ptr;
+	DAPL_COOKIE *cookie = NULL;
+	DAT_RETURN dat_status = DAT_SUCCESS;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_API,
 		     " post_ext_op: ep %p cmp_val %d "
 		     "swap_val %d cookie 0x%x, r_iov %p, flags 0x%x\n",
-		     ep_handle, (unsigned)cmp_add, (unsigned)swap, 
+		     ep_handle, (unsigned)cmp_add, (unsigned)swap,
 		     (unsigned)user_cookie.as_64, remote_iov, flags);
 
 	if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP))
-		return(DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
+		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
 
 	ep_ptr = (DAPL_EP *) ep_handle;
 	qp_ptr = ep_ptr->qp_handle;
@@ -194,11 +218,10 @@
 	 */
 	dat_status = dapls_dto_cookie_alloc(&ep_ptr->req_buffer,
 					    DAPL_DTO_TYPE_EXTENSION,
-					    user_cookie,
-					    &cookie);
+					    user_cookie, &cookie);
 	if (dat_status != DAT_SUCCESS)
 		goto bail;
-		
+
 	/*
 	 * Take reference before posting to avoid race conditions with
 	 * completions
@@ -208,13 +231,8 @@
 	/*
 	 * Invoke provider specific routine to post DTO
 	 */
-	dat_status = dapls_ib_post_ext_send(ep_ptr,	
-					    op_type,
-					    cookie,	
-					    segments,	/* data segments */
-					    local_iov, 
-					    remote_iov,
-					    immed_data,	/* immed data */
+	dat_status = dapls_ib_post_ext_send(ep_ptr, op_type, cookie, segments,	/* data segments */
+					    local_iov, remote_iov, immed_data,	/* immed data */
 					    cmp_add,	/* compare or add */
 					    swap,	/* swap */
 					    flags);
@@ -224,32 +242,30 @@
 		dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);
 	}
 
-bail:
+      bail:
 	return dat_status;
 
 }
 
-
 /* 
  * New provider routine to process extended DTO events 
  */
 void
-dapls_cqe_to_event_extension(IN DAPL_EP			*ep_ptr,
-			     IN DAPL_COOKIE		*cookie,
-			     IN ib_work_completion_t	*cqe_ptr,
-			     IN DAT_EVENT		*event_ptr)
+dapls_cqe_to_event_extension(IN DAPL_EP * ep_ptr,
+			     IN DAPL_COOKIE * cookie,
+			     IN ib_work_completion_t * cqe_ptr,
+			     IN DAT_EVENT * event_ptr)
 {
 	uint32_t ibtype;
-	DAT_DTO_COMPLETION_EVENT_DATA *dto = 
-			&event_ptr->event_data.dto_completion_event_data;
-	DAT_IB_EXTENSION_EVENT_DATA *ext_data = 
-			(DAT_IB_EXTENSION_EVENT_DATA *)
-			&event_ptr->event_extension_data[0];
+	DAT_DTO_COMPLETION_EVENT_DATA *dto =
+	    &event_ptr->event_data.dto_completion_event_data;
+	DAT_IB_EXTENSION_EVENT_DATA *ext_data = (DAT_IB_EXTENSION_EVENT_DATA *)
+	    & event_ptr->event_extension_data[0];
 	DAT_DTO_COMPLETION_STATUS dto_status;
 
 	/* Get status from cqe */
-        dto_status = dapls_ib_get_dto_status(cqe_ptr);
-	
+	dto_status = dapls_ib_get_dto_status(cqe_ptr);
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EVD,
 		     " cqe_to_event_ext: dto_ptr %p ext_ptr %p status %d\n",
 		     dto, ext_data, dto_status);
@@ -257,48 +273,48 @@
 	event_ptr->event_number = DAT_IB_DTO_EVENT;
 	dto->ep_handle = cookie->ep;
 	dto->user_cookie = cookie->val.dto.cookie;
-	dto->operation = DAPL_GET_CQE_DTOS_OPTYPE(cqe_ptr); /* new for 2.0 */
+	dto->operation = DAPL_GET_CQE_DTOS_OPTYPE(cqe_ptr);	/* new for 2.0 */
 	dto->status = ext_data->status = dto_status;
 
 	if (dto_status != DAT_DTO_SUCCESS)
 		return;
-	
+
 	/* 
 	 * Get operation type from CQ work completion entry and
 	 * if extented operation then set extended event data
-         */
+	 */
 	ibtype = DAPL_GET_CQE_OPTYPE(cqe_ptr);
-        
-	switch (ibtype)	{
 
+	switch (ibtype) {
+
 	case OP_RDMA_WRITE_IMM:
-		dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: OP_RDMA_WRITE_IMMED\n");
-		
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: OP_RDMA_WRITE_IMMED\n");
+
 		/* type and outbound rdma write transfer size */
 		dto->transfered_length = cookie->val.dto.size;
 		ext_data->type = DAT_IB_RDMA_WRITE_IMMED;
 		break;
 	case OP_RECEIVE_IMM:
-		dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: OP_RECEIVE_RDMA_IMMED\n");
-		
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: OP_RECEIVE_RDMA_IMMED\n");
+
 		/* immed recvd, type and inbound rdma write transfer size */
 		dto->transfered_length = DAPL_GET_CQE_BYTESNUM(cqe_ptr);
 		ext_data->type = DAT_IB_RDMA_WRITE_IMMED_DATA;
 		ext_data->val.immed.data = DAPL_GET_CQE_IMMED_DATA(cqe_ptr);
 		break;
 	case OP_COMP_AND_SWAP:
-                dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: COMP_AND_SWAP_RESP\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: COMP_AND_SWAP_RESP\n");
 
-                /* original data is returned in LMR provided with post */
+		/* original data is returned in LMR provided with post */
 		ext_data->type = DAT_IB_CMP_AND_SWAP;
 		dto->transfered_length = DAPL_GET_CQE_BYTESNUM(cqe_ptr);
 		break;
 	case OP_FETCH_AND_ADD:
-                dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: FETCH_AND_ADD_RESP\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: FETCH_AND_ADD_RESP\n");
 
 		/* original data is returned in LMR provided with post */
 		ext_data->type = DAT_IB_FETCH_AND_ADD;

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_mem.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_mem.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_mem.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -35,13 +35,6 @@
  *
  **********************************************************************/
 
-#include <sys/ioctl.h>  /* for IOCTL's */
-#include <sys/types.h>  /* for socket(2) and related bits and pieces */
-#include <sys/socket.h> /* for socket(2) */
-#include <net/if.h>     /* for struct ifreq */
-#include <net/if_arp.h> /* for ARPHRD_ETHER */
-#include <unistd.h>		/* for _SC_CLK_TCK */
-
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_lmr_util.h"
@@ -61,10 +54,9 @@
  *	ibv_access_flags
  *
  */
-STATIC _INLINE_ int
-dapls_convert_privileges(IN DAT_MEM_PRIV_FLAGS privileges)
+STATIC _INLINE_ int dapls_convert_privileges(IN DAT_MEM_PRIV_FLAGS privileges)
 {
-	int	access = 0;
+	int access = 0;
 
 	/*
 	 * if (DAT_MEM_PRIV_LOCAL_READ_FLAG & privileges) do nothing
@@ -80,7 +72,7 @@
 	if (DAT_MEM_PRIV_REMOTE_READ_FLAG & privileges)
 		access |= IBV_ACCESS_REMOTE_READ;
 #ifdef DAT_EXTENSIONS
-	if (DAT_IB_MEM_PRIV_REMOTE_ATOMIC & privileges) 
+	if (DAT_IB_MEM_PRIV_REMOTE_ATOMIC & privileges)
 		access |= IBV_ACCESS_REMOTE_ATOMIC;
 #endif
 
@@ -104,17 +96,15 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN
-dapls_ib_pd_alloc(IN DAPL_IA *ia_ptr, IN DAPL_PZ *pz)
+DAT_RETURN dapls_ib_pd_alloc(IN DAPL_IA * ia_ptr, IN DAPL_PZ * pz)
 {
 	/* get a protection domain */
 	pz->pd_handle = ibv_alloc_pd(ia_ptr->hca_ptr->ib_hca_handle);
-	if (!pz->pd_handle) 
-		return(dapl_convert_errno(ENOMEM,"alloc_pd"));
+	if (!pz->pd_handle)
+		return (dapl_convert_errno(ENOMEM, "alloc_pd"));
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " pd_alloc: pd_handle=%p\n", 
-		     pz->pd_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " pd_alloc: pd_handle=%p\n", pz->pd_handle);
 
 	return DAT_SUCCESS;
 }
@@ -136,13 +126,12 @@
  *      DAT_INVALID_STATE
  *
  */
-DAT_RETURN
-dapls_ib_pd_free(IN DAPL_PZ *pz )
+DAT_RETURN dapls_ib_pd_free(IN DAPL_PZ * pz)
 {
 	if (pz->pd_handle != IB_INVALID_HANDLE) {
 		if (ibv_dealloc_pd(pz->pd_handle))
-			return(dapl_convert_errno(errno,"dealloc_pd"));
-		pz->pd_handle = IB_INVALID_HANDLE;	
+			return (dapl_convert_errno(errno, "dealloc_pd"));
+		pz->pd_handle = IB_INVALID_HANDLE;
 	}
 	return DAT_SUCCESS;
 }
@@ -167,57 +156,53 @@
  *
  */
 DAT_RETURN
-dapls_ib_mr_register(IN  DAPL_IA *ia_ptr,
-		     IN  DAPL_LMR *lmr,
-		     IN  DAT_PVOID virt_addr,
-		     IN  DAT_VLEN length,
-		     IN  DAT_MEM_PRIV_FLAGS privileges,
-		     IN  DAT_VA_TYPE va_type)
+dapls_ib_mr_register(IN DAPL_IA * ia_ptr,
+		     IN DAPL_LMR * lmr,
+		     IN DAT_PVOID virt_addr,
+		     IN DAT_VLEN length,
+		     IN DAT_MEM_PRIV_FLAGS privileges, IN DAT_VA_TYPE va_type)
 {
-	ib_pd_handle_t	ib_pd_handle;
+	ib_pd_handle_t ib_pd_handle;
 
-	ib_pd_handle = ((DAPL_PZ *)lmr->param.pz_handle)->pd_handle;
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " mr_register: ia=%p, lmr=%p va=%p ln=%d pv=0x%x\n", 
-		     ia_ptr, lmr, virt_addr, length, privileges );
+	ib_pd_handle = ((DAPL_PZ *) lmr->param.pz_handle)->pd_handle;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " mr_register: ia=%p, lmr=%p va=%p ln=%d pv=0x%x\n",
+		     ia_ptr, lmr, virt_addr, length, privileges);
+
 	/* TODO: shared memory */
 	if (lmr->param.mem_type == DAT_MEM_TYPE_SHARED_VIRTUAL) {
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-			     " mr_register_shared: NOT IMPLEMENTED\n");    
-		return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+			     " mr_register_shared: NOT IMPLEMENTED\n");
+		return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 	}
 
 	/* IB verbs does not support */
 	if (va_type == DAT_VA_TYPE_ZB) {
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-			" va_type == DAT_VA_TYPE_ZB: NOT SUPPORTED\n");    
-		return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+			     " va_type == DAT_VA_TYPE_ZB: NOT SUPPORTED\n");
+		return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 	}
 
-	/* local read is default on IB */ 
-	lmr->mr_handle = 
-		ibv_reg_mr(((DAPL_PZ *)lmr->param.pz_handle)->pd_handle, 
-			    virt_addr, 
-			    length, 
-			    dapls_convert_privileges(privileges));
+	/* local read is default on IB */
+	lmr->mr_handle =
+	    ibv_reg_mr(((DAPL_PZ *) lmr->param.pz_handle)->pd_handle,
+		       virt_addr, length, dapls_convert_privileges(privileges));
 
-	if (!lmr->mr_handle) 
-		return(dapl_convert_errno(ENOMEM,"reg_mr"));
-	
-	lmr->param.lmr_context = lmr->mr_handle->lkey; 
+	if (!lmr->mr_handle)
+		return (dapl_convert_errno(ENOMEM, "reg_mr"));
+
+	lmr->param.lmr_context = lmr->mr_handle->lkey;
 	lmr->param.rmr_context = lmr->mr_handle->rkey;
 	lmr->param.registered_size = length;
-	lmr->param.registered_address = (DAT_VADDR)(uintptr_t)virt_addr;
+	lmr->param.registered_address = (DAT_VADDR) (uintptr_t) virt_addr;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " mr_register: mr=%p addr=%p h %x pd %p ctx %p "
-		     "lkey=0x%x rkey=0x%x priv=%x\n", 
-		     lmr->mr_handle, lmr->mr_handle->addr, 
-		     lmr->mr_handle->handle,	
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " mr_register: mr=%p addr=%p pd %p ctx %p "
+		     "lkey=0x%x rkey=0x%x priv=%x\n",
+		     lmr->mr_handle, lmr->mr_handle->addr,
 		     lmr->mr_handle->pd, lmr->mr_handle->context,
-		     lmr->mr_handle->lkey, lmr->mr_handle->rkey, 
+		     lmr->mr_handle->lkey, lmr->mr_handle->rkey,
 		     length, dapls_convert_privileges(privileges));
 
 	return DAT_SUCCESS;
@@ -239,18 +224,16 @@
  *	DAT_INVALID_STATE
  *
  */
-DAT_RETURN
-dapls_ib_mr_deregister(IN DAPL_LMR *lmr)
+DAT_RETURN dapls_ib_mr_deregister(IN DAPL_LMR * lmr)
 {
 	if (lmr->mr_handle != IB_INVALID_HANDLE) {
 		if (ibv_dereg_mr(lmr->mr_handle))
-			return(dapl_convert_errno(errno,"dereg_pd"));
+			return (dapl_convert_errno(errno, "dereg_pd"));
 		lmr->mr_handle = IB_INVALID_HANDLE;
 	}
 	return DAT_SUCCESS;
 }
 
-
 /*
  * dapl_ib_mr_register_shared
  *
@@ -271,15 +254,15 @@
  *
  */
 DAT_RETURN
-dapls_ib_mr_register_shared(IN DAPL_IA *ia_ptr,
-			    IN DAPL_LMR *lmr,
+dapls_ib_mr_register_shared(IN DAPL_IA * ia_ptr,
+			    IN DAPL_LMR * lmr,
 			    IN DAT_MEM_PRIV_FLAGS privileges,
 			    IN DAT_VA_TYPE va_type)
 {
-    dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-	         " mr_register_shared: NOT IMPLEMENTED\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+		     " mr_register_shared: NOT IMPLEMENTED\n");
 
-    return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -298,14 +281,12 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN
-dapls_ib_mw_alloc (IN DAPL_RMR *rmr)
+DAT_RETURN dapls_ib_mw_alloc(IN DAPL_RMR * rmr)
 {
 
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_alloc: NOT IMPLEMENTED\n");
-   	
-	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_alloc: NOT IMPLEMENTED\n");
+
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -324,13 +305,11 @@
  *	DAT_INVALID_STATE
  *
  */
-DAT_RETURN
-dapls_ib_mw_free(IN DAPL_RMR *rmr)
-{	
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_free: NOT IMPLEMENTED\n");
+DAT_RETURN dapls_ib_mw_free(IN DAPL_RMR * rmr)
+{
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_free: NOT IMPLEMENTED\n");
 
-	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -351,19 +330,17 @@
  *
  */
 DAT_RETURN
-dapls_ib_mw_bind(IN DAPL_RMR *rmr,
-		 IN DAPL_LMR *lmr,
-		 IN DAPL_EP  *ep,
-		 IN DAPL_COOKIE *cookie,
+dapls_ib_mw_bind(IN DAPL_RMR * rmr,
+		 IN DAPL_LMR * lmr,
+		 IN DAPL_EP * ep,
+		 IN DAPL_COOKIE * cookie,
 		 IN DAT_VADDR virtual_address,
 		 IN DAT_VLEN length,
-		 IN DAT_MEM_PRIV_FLAGS mem_priv,
-		 IN DAT_BOOLEAN is_signaled)
+		 IN DAT_MEM_PRIV_FLAGS mem_priv, IN DAT_BOOLEAN is_signaled)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_bind: NOT IMPLEMENTED\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_bind: NOT IMPLEMENTED\n");
 
-	return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -385,15 +362,13 @@
  *
  */
 DAT_RETURN
-dapls_ib_mw_unbind(IN DAPL_RMR *rmr,
-		   IN DAPL_EP  *ep,
-		   IN DAPL_COOKIE *cookie,
-		   IN DAT_BOOLEAN is_signaled )
+dapls_ib_mw_unbind(IN DAPL_RMR * rmr,
+		   IN DAPL_EP * ep,
+		   IN DAPL_COOKIE * cookie, IN DAT_BOOLEAN is_signaled)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_unbind: NOT IMPLEMENTED\n");
-	
-	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_unbind: NOT IMPLEMENTED\n");
+
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -403,4 +378,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_qp.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_qp.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_qp.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,39 +61,38 @@
  *	DAT_INTERNAL_ERROR
  *
  */
-DAT_RETURN dapls_ib_qp_alloc(IN DAPL_IA *ia_ptr,
-			     IN DAPL_EP *ep_ptr,
-			     IN DAPL_EP *ep_ctx_ptr)
+DAT_RETURN dapls_ib_qp_alloc(IN DAPL_IA * ia_ptr,
+			     IN DAPL_EP * ep_ptr, IN DAPL_EP * ep_ctx_ptr)
 {
-   	DAT_EP_ATTR *attr;
+	DAT_EP_ATTR *attr;
 	DAPL_EVD *rcv_evd, *req_evd;
 	ib_cq_handle_t rcv_cq, req_cq;
 	ib_pd_handle_t ib_pd_handle;
 	struct ibv_qp_init_attr qp_create;
 	dp_ib_cm_handle_t conn;
 	struct rdma_cm_id *cm_id;
-			
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " qp_alloc: ia_ptr %p ep_ptr %p ep_ctx_ptr %p\n",
 		     ia_ptr, ep_ptr, ep_ctx_ptr);
 
 	attr = &ep_ptr->param.ep_attr;
-	ib_pd_handle = ((DAPL_PZ *)ep_ptr->param.pz_handle)->pd_handle;
-	rcv_evd	= (DAPL_EVD *) ep_ptr->param.recv_evd_handle;
-	req_evd	= (DAPL_EVD *) ep_ptr->param.request_evd_handle;
+	ib_pd_handle = ((DAPL_PZ *) ep_ptr->param.pz_handle)->pd_handle;
+	rcv_evd = (DAPL_EVD *) ep_ptr->param.recv_evd_handle;
+	req_evd = (DAPL_EVD *) ep_ptr->param.request_evd_handle;
 
 	/* 
 	 * DAT allows usage model of EP's with no EVD's but IB does not. 
 	 * Create a CQ with zero entries under the covers to support and 
 	 * catch any invalid posting. 
 	 */
-	if (rcv_evd != DAT_HANDLE_NULL) 
+	if (rcv_evd != DAT_HANDLE_NULL)
 		rcv_cq = rcv_evd->ib_cq_handle;
-	else if (!ia_ptr->hca_ptr->ib_trans.ib_cq_empty) 
+	else if (!ia_ptr->hca_ptr->ib_trans.ib_cq_empty)
 		rcv_cq = ia_ptr->hca_ptr->ib_trans.ib_cq_empty;
 	else {
-		struct ibv_comp_channel *channel = 
-					ia_ptr->hca_ptr->ib_trans.ib_cq;
+		struct ibv_comp_channel *channel =
+		    ia_ptr->hca_ptr->ib_trans.ib_cq;
 #ifdef CQ_WAIT_OBJECT
 		if (rcv_evd->cq_wait_obj_handle)
 			channel = rcv_evd->cq_wait_obj_handle->events;
@@ -102,14 +101,14 @@
 		rcv_cq = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle,
 				       0, NULL, channel, 0);
 
-		if (rcv_cq == IB_INVALID_HANDLE) 
-			return(dapl_convert_errno(ENOMEM, "create_cq"));
+		if (rcv_cq == IB_INVALID_HANDLE)
+			return (dapl_convert_errno(ENOMEM, "create_cq"));
 
 		ia_ptr->hca_ptr->ib_trans.ib_cq_empty = rcv_cq;
 	}
-	if (req_evd != DAT_HANDLE_NULL) 
+	if (req_evd != DAT_HANDLE_NULL)
 		req_cq = req_evd->ib_cq_handle;
-	else 
+	else
 		req_cq = ia_ptr->hca_ptr->ib_trans.ib_cq_empty;
 
 	/* 
@@ -124,31 +123,31 @@
 	 * and after CR arrives). Discovery should happen at connection time 
 	 * based on addressing and not on static configuration during open.
 	 */
-	
+
 	/* Allocate CM and initialize lock */
-	if ((conn = dapl_os_alloc(sizeof(*conn))) == NULL) 
-		return(dapl_convert_errno(ENOMEM, "create_cq"));
-	
+	if ((conn = dapl_os_alloc(sizeof(*conn))) == NULL)
+		return (dapl_convert_errno(ENOMEM, "create_cq"));
+
 	dapl_os_memzero(conn, sizeof(*conn));
 	dapl_os_lock_init(&conn->lock);
 
 	/* create CM_ID, bind to local device, create QP */
-	if (rdma_create_id(g_cm_events, &cm_id, (void*)conn, RDMA_PS_TCP)) {
+	if (rdma_create_id(g_cm_events, &cm_id, (void *)conn, RDMA_PS_TCP)) {
 		dapl_os_free(conn, sizeof(*conn));
-		return(dapl_convert_errno(errno, "create_qp"));
+		return (dapl_convert_errno(errno, "create_qp"));
 	}
 
 	/* open identifies the local device; per DAT specification */
 	if (rdma_bind_addr(cm_id,
 			   (struct sockaddr *)&ia_ptr->hca_ptr->hca_address))
 		goto bail;
-	
+
 	/* Setup attributes and create qp */
-	dapl_os_memzero((void*)&qp_create, sizeof(qp_create));
+	dapl_os_memzero((void *)&qp_create, sizeof(qp_create));
 	qp_create.cap.max_send_wr = attr->max_request_dtos;
 	qp_create.cap.max_send_sge = attr->max_request_iov;
-	qp_create.cap.max_inline_data = 
-		ia_ptr->hca_ptr->ib_trans.max_inline_send; 
+	qp_create.cap.max_inline_data =
+	    ia_ptr->hca_ptr->ib_trans.max_inline_send;
 	qp_create.send_cq = req_cq;
 
 	/* ibv assumes rcv_cq is never NULL, set to req_cq */
@@ -162,25 +161,25 @@
 		qp_create.cap.max_recv_sge = attr->max_recv_iov;
 	}
 	qp_create.qp_type = IBV_QPT_RC;
-	qp_create.qp_context = (void*)ep_ptr;
+	qp_create.qp_context = (void *)ep_ptr;
 
 	/* Let uCMA transition QP states */
 	if (rdma_create_qp(cm_id, ib_pd_handle, &qp_create))
-		goto bail; 
-		
+		goto bail;
+
 	conn->cm_id = cm_id;
 	conn->ep = ep_ptr;
 	conn->hca = ia_ptr->hca_ptr;
 
 	/* setup timers for address and route resolution */
-	conn->arp_timeout = dapl_os_get_env_val("DAPL_CM_ARP_TIMEOUT_MS", 
+	conn->arp_timeout = dapl_os_get_env_val("DAPL_CM_ARP_TIMEOUT_MS",
 						IB_ARP_TIMEOUT);
-	conn->arp_retries = dapl_os_get_env_val("DAPL_CM_ARP_RETRY_COUNT", 
+	conn->arp_retries = dapl_os_get_env_val("DAPL_CM_ARP_RETRY_COUNT",
 						IB_ARP_RETRY_COUNT);
-	conn->route_timeout = dapl_os_get_env_val("DAPL_CM_ROUTE_TIMEOUT_MS", 
-						    IB_ROUTE_TIMEOUT);
-	conn->route_retries = dapl_os_get_env_val("DAPL_CM_ROUTE_RETRY_COUNT", 
-						    IB_ROUTE_RETRY_COUNT);
+	conn->route_timeout = dapl_os_get_env_val("DAPL_CM_ROUTE_TIMEOUT_MS",
+						  IB_ROUTE_TIMEOUT);
+	conn->route_retries = dapl_os_get_env_val("DAPL_CM_ROUTE_RETRY_COUNT",
+						  IB_ROUTE_RETRY_COUNT);
 
 	/* setup up ep->param to reference the bound local address and port */
 	ep_ptr->param.local_ia_address_ptr = &cm_id->route.addr.src_addr;
@@ -188,19 +187,19 @@
 
 	ep_ptr->qp_handle = conn;
 	ep_ptr->qp_state = IB_QP_STATE_INIT;
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " qp_alloc: qpn %p sq %d,%d rq %d,%d port=%d\n",
 		     ep_ptr->qp_handle->cm_id->qp->qp_num,
-		     qp_create.cap.max_send_wr,qp_create.cap.max_send_sge,
-		     qp_create.cap.max_recv_wr,qp_create.cap.max_recv_sge,
+		     qp_create.cap.max_send_wr, qp_create.cap.max_send_sge,
+		     qp_create.cap.max_recv_wr, qp_create.cap.max_recv_sge,
 		     ep_ptr->param.local_port_qual);
-	
+
 	return DAT_SUCCESS;
-bail:
+      bail:
 	rdma_destroy_id(cm_id);
 	dapl_os_free(conn, sizeof(*conn));
-	return(dapl_convert_errno(errno, "create_qp"));
+	return (dapl_convert_errno(errno, "create_qp"));
 }
 
 /*
@@ -220,14 +219,14 @@
  *  dapl_convert_errno
  *
  */
-DAT_RETURN dapls_ib_qp_free(IN DAPL_IA *ia_ptr, IN DAPL_EP *ep_ptr)
+DAT_RETURN dapls_ib_qp_free(IN DAPL_IA * ia_ptr, IN DAPL_EP * ep_ptr)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_EP, " qp_free:  ep_ptr %p qp %p\n",	
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " qp_free:  ep_ptr %p qp %p\n",
 		     ep_ptr, ep_ptr->qp_handle);
 
 	if (ep_ptr->qp_handle != IB_INVALID_HANDLE) {
 		/* qp_handle is conn object with reference to cm_id and qp */
-		dapli_destroy_conn(ep_ptr->qp_handle); 
+		dapli_destroy_conn(ep_ptr->qp_handle);
 		ep_ptr->qp_handle = IB_INVALID_HANDLE;
 		ep_ptr->qp_state = IB_QP_STATE_ERROR;
 	}
@@ -256,40 +255,39 @@
  *	DAT_INVALID_PARAMETER
  *
  */
-DAT_RETURN dapls_ib_qp_modify(IN DAPL_IA *ia_ptr,
-			      IN DAPL_EP *ep_ptr,
-			      IN DAT_EP_ATTR *attr)
+DAT_RETURN dapls_ib_qp_modify(IN DAPL_IA * ia_ptr,
+			      IN DAPL_EP * ep_ptr, IN DAT_EP_ATTR * attr)
 {
 	struct ibv_qp_attr qp_attr;
-	
+
 	if (ep_ptr->qp_handle == IB_INVALID_HANDLE)
 		return DAT_INVALID_PARAMETER;
 
 	/*
 	 * Check if we have the right qp_state to modify attributes
 	 */
-	if ((ep_ptr->qp_handle->cm_id->qp->state != IBV_QPS_RTR) && 
-	    (ep_ptr->qp_handle->cm_id->qp->state != IBV_QPS_RTS)) 
+	if ((ep_ptr->qp_handle->cm_id->qp->state != IBV_QPS_RTR) &&
+	    (ep_ptr->qp_handle->cm_id->qp->state != IBV_QPS_RTS))
 		return DAT_INVALID_STATE;
 
 	/* Adjust to current EP attributes */
-	dapl_os_memzero((void*)&qp_attr, sizeof(qp_attr));
+	dapl_os_memzero((void *)&qp_attr, sizeof(qp_attr));
 	qp_attr.cap.max_send_wr = attr->max_request_dtos;
 	qp_attr.cap.max_recv_wr = attr->max_recv_dtos;
 	qp_attr.cap.max_send_sge = attr->max_request_iov;
 	qp_attr.cap.max_recv_sge = attr->max_recv_iov;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     "modify_qp: qp %p sq %d,%d, rq %d,%d\n", 
-		     ep_ptr->qp_handle->cm_id->qp, 
-		     qp_attr.cap.max_send_wr, qp_attr.cap.max_send_sge, 
+		     "modify_qp: qp %p sq %d,%d, rq %d,%d\n",
+		     ep_ptr->qp_handle->cm_id->qp,
+		     qp_attr.cap.max_send_wr, qp_attr.cap.max_send_sge,
 		     qp_attr.cap.max_recv_wr, qp_attr.cap.max_recv_sge);
 
 	if (ibv_modify_qp(ep_ptr->qp_handle->cm_id->qp, &qp_attr, IBV_QP_CAP)) {
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
 			     "modify_qp: modify ep %p qp %p failed\n",
 			     ep_ptr, ep_ptr->qp_handle->cm_id->qp);
-		return(dapl_convert_errno(errno,"modify_qp_state"));
+		return (dapl_convert_errno(errno, "modify_qp_state"));
 	}
 
 	return DAT_SUCCESS;
@@ -310,11 +308,11 @@
  * 	void
  *
  */
-void dapls_ib_reinit_ep(IN DAPL_EP *ep_ptr)
+void dapls_ib_reinit_ep(IN DAPL_EP * ep_ptr)
 {
 	/* uCMA does not allow reuse of CM_ID, destroy and create new one */
 	if (ep_ptr->qp_handle != IB_INVALID_HANDLE) {
-		
+
 		/* destroy */
 		dapli_destroy_conn(ep_ptr->qp_handle);
 
@@ -324,7 +322,6 @@
 	}
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -39,104 +39,186 @@
 static const char rcsid[] = "$Id:  $";
 #endif
 
+#include "openib_osd.h"
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_ib_util.h"
+#include "dapl_osd.h"
 
 #include <stdlib.h>
-#include <netinet/tcp.h>
-#include <sys/poll.h>
-#include <fcntl.h>
 
-#include <sys/ioctl.h>  /* for IOCTL's */
-#include <sys/types.h>  /* for socket(2) and related bits and pieces */
-#include <sys/socket.h> /* for socket(2) */
-#include <net/if.h>     /* for struct ifreq */
-#include <net/if_arp.h> /* for ARPHRD_INFINIBAND */
-#include <arpa/inet.h>  /* for inet_ntoa */
-
-
 int g_dapl_loopback_connection = 0;
-int g_ib_pipe[2];
 struct rdma_event_channel *g_cm_events = NULL;
 ib_thread_state_t g_ib_thread_state = 0;
 DAPL_OS_THREAD g_ib_thread;
 DAPL_OS_LOCK g_hca_lock;
-struct dapl_llist_entry	*g_hca_list;	
+struct dapl_llist_entry *g_hca_list;
 
+#if defined(_WIN64) || defined(_WIN32)
+#include "..\..\..\..\..\etc\user\comp_channel.cpp"
+#include "..\..\..\..\..\etc\user\dlist.c"
+
+#define getipaddr_netdev(x,y,z) -1
+struct ibvw_windata windata;
+
+static int dapls_os_init(void)
+{
+	return ibvw_get_windata(&windata, IBVW_WINDATA_VERSION);
+}
+
+static void dapls_os_release(void)
+{
+	if (windata.comp_mgr)
+		ibvw_release_windata(&windata, IBVW_WINDATA_VERSION);
+	windata.comp_mgr = NULL;
+}
+
+static int dapls_config_comp_channel(struct ibv_comp_channel *channel)
+{
+	channel->comp_channel.Milliseconds = 0;
+	return 0;
+}
+
+static int dapls_config_cm_channel(struct rdma_event_channel *channel)
+{
+	channel->channel.Milliseconds = 0;
+	return 0;
+}
+
+static int dapls_config_verbs(struct ibv_context *verbs)
+{
+	verbs->channel.Milliseconds = 0;
+	return 0;
+}
+
+static int dapls_thread_signal(void)
+{
+	CompManagerCancel(windata.comp_mgr);
+	return 0;
+}
+#else				// _WIN64 || WIN32
+int g_ib_pipe[2];
+
+static int dapls_os_init(void)
+{
+	/* create pipe for waking up work thread */
+	return pipe(g_ib_pipe);
+}
+
+static void dapls_os_release(void)
+{
+	/* close pipe? */
+}
+
 /* Get IP address using network device name */
 static int getipaddr_netdev(char *name, char *addr, int addr_len)
 {
-    struct ifreq ifr;
-    int skfd, ret, len;
+	struct ifreq ifr;
+	int skfd, ret, len;
 
-    /* Fill in the structure */
-    snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name);
-    ifr.ifr_hwaddr.sa_family = ARPHRD_INFINIBAND;
+	/* Fill in the structure */
+	snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name);
+	ifr.ifr_hwaddr.sa_family = ARPHRD_INFINIBAND;
 
-    /* Create a socket fd */
-    skfd = socket(PF_INET, SOCK_STREAM, 0);
-    ret = ioctl(skfd, SIOCGIFADDR, &ifr);
-    if (ret)
-	goto bail;
+	/* Create a socket fd */
+	skfd = socket(PF_INET, SOCK_STREAM, 0);
+	ret = ioctl(skfd, SIOCGIFADDR, &ifr);
+	if (ret)
+		goto bail;
 
-    switch (ifr.ifr_addr.sa_family) 
-    {
+	switch (ifr.ifr_addr.sa_family) {
 #ifdef	AF_INET6
 	case AF_INET6:
-	    len = sizeof(struct sockaddr_in6);
-	    break;
+		len = sizeof(struct sockaddr_in6);
+		break;
 #endif
-	case AF_INET:	
-	default:	
-	    len = sizeof(struct sockaddr);
-	    break;
-    }
-      
-    if (len <= addr_len)
-	memcpy(addr, &ifr.ifr_addr, len);
-    else
-	ret = EINVAL;
+	case AF_INET:
+	default:
+		len = sizeof(struct sockaddr);
+		break;
+	}
 
-bail:
-    close(skfd);
-    return ret;
+	if (len <= addr_len)
+		memcpy(addr, &ifr.ifr_addr, len);
+	else
+		ret = EINVAL;
+
+      bail:
+	close(skfd);
+	return ret;
 }
 
+static int dapls_config_fd(int fd)
+{
+	int opts;
+
+	opts = fcntl(fd, F_GETFL);
+	if (opts < 0 || fcntl(fd, F_SETFL, opts | O_NONBLOCK) < 0) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " dapls_config_fd: fcntl on fd %d ERR %d %s\n",
+			 fd, opts, strerror(errno));
+		return errno;
+	}
+
+	return 0;
+}
+
+static int dapls_config_comp_channel(struct ibv_comp_channel *channel)
+{
+	return dapls_config_fd(channel->fd);
+}
+
+static int dapls_config_cm_channel(struct rdma_event_channel *channel)
+{
+	return dapls_config_fd(channel->fd);
+}
+
+static int dapls_config_verbs(struct ibv_context *verbs)
+{
+	return dapls_config_fd(verbs->async_fd);
+}
+
+static int dapls_thread_signal(void)
+{
+	return write(g_ib_pipe[1], "w", sizeof "w");
+}
+#endif
+
 /* Get IP address using network name, address, or device name */
 static int getipaddr(char *name, char *addr, int len)
 {
-        struct addrinfo *res;
+	struct addrinfo *res;
 
-        /* assume netdev for first attempt, then network and address type */
-        if (getipaddr_netdev(name,addr,len)) {
-                if (getaddrinfo(name, NULL, NULL, &res)) {
-                        dapl_log(DAPL_DBG_TYPE_ERR,
-                                " open_hca: getaddr_netdev ERROR:"
-                                " %s. Is %s configured?\n",
-                                strerror(errno), name);
-                        return 1;
-                } else {
-                        if (len >= res->ai_addrlen)
-                                memcpy(addr, res->ai_addr, res->ai_addrlen);
-                        else {
-                                freeaddrinfo(res);
-                                return 1;
-                        }
-                        freeaddrinfo(res);
-                }
-        }
+	/* assume netdev for first attempt, then network and address type */
+	if (getipaddr_netdev(name, addr, len)) {
+		if (getaddrinfo(name, NULL, NULL, &res)) {
+			dapl_log(DAPL_DBG_TYPE_ERR,
+				 " open_hca: getaddr_netdev ERROR:"
+				 " %s. Is %s configured?\n",
+				 strerror(errno), name);
+			return 1;
+		} else {
+			if (len >= res->ai_addrlen)
+				memcpy(addr, res->ai_addr, res->ai_addrlen);
+			else {
+				freeaddrinfo(res);
+				return 1;
+			}
+			freeaddrinfo(res);
+		}
+	}
 
-        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                " getipaddr: family %d port %d addr %d.%d.%d.%d\n",
-                ((struct sockaddr_in *)addr)->sin_family,
-                ((struct sockaddr_in *)addr)->sin_port,
-                ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 0 & 0xff,
-                ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 8 & 0xff,
-                ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 16 & 0xff,
-                ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 24 & 0xff);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " getipaddr: family %d port %d addr %d.%d.%d.%d\n",
+		     ((struct sockaddr_in *)addr)->sin_family,
+		     ((struct sockaddr_in *)addr)->sin_port,
+		     ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 0 & 0xff,
+		     ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 8 & 0xff,
+		     ((struct sockaddr_in *)addr)->sin_addr.s_addr >> 16 & 0xff,
+		     ((struct sockaddr_in *)addr)->sin_addr.
+		     s_addr >> 24 & 0xff);
 
-        return 0;
+	return 0;
 }
 
 /*
@@ -155,17 +237,16 @@
  *
  */
 int32_t dapls_ib_init(void)
-{	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapl_ib_init: \n" );
+{
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " dapl_ib_init: \n");
 
 	/* initialize hca_list lock */
 	dapl_os_lock_init(&g_hca_lock);
-	
+
 	/* initialize hca list for CQ events */
 	dapl_llist_init_head(&g_hca_list);
 
-	/* create pipe for waking up work thread */
-	if (pipe(g_ib_pipe))
+	if (dapls_os_init())
 		return 1;
 
 	return 0;
@@ -177,6 +258,7 @@
 	dapli_ib_thread_destroy();
 	if (g_cm_events != NULL)
 		rdma_destroy_event_channel(g_cm_events);
+	dapls_os_release();
 	return 0;
 }
 
@@ -197,15 +279,14 @@
  *      dapl_convert_errno
  *
  */
-DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
+DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA * hca_ptr)
 {
-	long opts;
 	struct rdma_cm_id *cm_id = NULL;
 	union ibv_gid *gid;
 	int ret;
 	DAT_RETURN dat_status;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 		     " open_hca: %s - %p\n", hca_name, hca_ptr);
 
 	/* Setup the global cm event channel */
@@ -213,141 +294,124 @@
 	if (g_cm_events == NULL) {
 		g_cm_events = rdma_create_event_channel();
 		if (g_cm_events == NULL) {
-			dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-				" open_hca: ERR - RDMA channel %s\n",
-				strerror(errno));
+			dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+				     " open_hca: ERR - RDMA channel %s\n",
+				     strerror(errno));
 			return DAT_INTERNAL_ERROR;
 		}
 	}
 	dapl_os_unlock(&g_hca_lock);
 
-	dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-			" open_hca: RDMA channel created(%p,%d)\n",
-			g_cm_events, g_cm_events->fd);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " open_hca: RDMA channel created (%p)\n", g_cm_events);
 
 	dat_status = dapli_ib_thread_init();
 	if (dat_status != DAT_SUCCESS)
 		return dat_status;
 
 	/* HCA name will be hostname or IP address */
-	if (getipaddr((char*)hca_name,
-		      (char*)&hca_ptr->hca_address, 
-		      sizeof(DAT_SOCK_ADDR6)))
+	if (getipaddr((char *)hca_name,
+		      (char *)&hca_ptr->hca_address, sizeof(DAT_SOCK_ADDR6)))
 		return DAT_INVALID_ADDRESS;
 
 	/* cm_id will bind local device/GID based on IP address */
-	if (rdma_create_id(g_cm_events, &cm_id, (void*)hca_ptr, RDMA_PS_TCP)) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " open_hca: rdma_create_id ERR %s\n", 
-			 strerror(errno));
+	if (rdma_create_id(g_cm_events, &cm_id, (void *)hca_ptr, RDMA_PS_TCP)) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " open_hca: rdma_create_id ERR %s\n", strerror(errno));
 		return DAT_INTERNAL_ERROR;
 	}
-	ret = rdma_bind_addr(cm_id,
-			     (struct sockaddr *)&hca_ptr->hca_address);
+	ret = rdma_bind_addr(cm_id, (struct sockaddr *)&hca_ptr->hca_address);
 	if ((ret) || (cm_id->verbs == NULL)) {
-                rdma_destroy_id(cm_id); 
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		rdma_destroy_id(cm_id);
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " open_hca: rdma_bind ERR %s."
-			 " Is %s configured?\n", 
-			 strerror(errno),hca_name);
+			 " Is %s configured?\n", strerror(errno), hca_name);
 		return DAT_INVALID_ADDRESS;
 	}
 
 	/* keep reference to IB device and cm_id */
 	hca_ptr->ib_trans.cm_id = cm_id;
 	hca_ptr->ib_hca_handle = cm_id->verbs;
+	dapls_config_verbs(cm_id->verbs);
 	hca_ptr->port_num = cm_id->port_num;
 	gid = &cm_id->route.addr.addr.ibaddr.sgid;
 
-	dapl_dbg_log(
-		DAPL_DBG_TYPE_UTIL,
-		" open_hca: ctx=%p port=%d GID subnet %016llx id %016llx\n",
-		cm_id->verbs,cm_id->port_num,
-		(unsigned long long)bswap_64(gid->global.subnet_prefix),
-		(unsigned long long)bswap_64(gid->global.interface_id));
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " open_hca: ctx=%p port=%d GID subnet %016llx id %016llx\n",
+		     cm_id->verbs, cm_id->port_num,
+		     (unsigned long long)ntohll(gid->global.subnet_prefix),
+		     (unsigned long long)ntohll(gid->global.interface_id));
 
 	/* set inline max with env or default, get local lid and gid 0 */
-        if (hca_ptr->ib_hca_handle->device->transport_type
-                                        == IBV_TRANSPORT_IWARP)
-		hca_ptr->ib_trans.max_inline_send = 
-			dapl_os_get_env_val("DAPL_MAX_INLINE", 
-					    INLINE_SEND_IWARP_DEFAULT);
-        else
-		hca_ptr->ib_trans.max_inline_send = 
-			dapl_os_get_env_val("DAPL_MAX_INLINE", 
-					    INLINE_SEND_IB_DEFAULT);
+	if (hca_ptr->ib_hca_handle->device->transport_type
+	    == IBV_TRANSPORT_IWARP)
+		hca_ptr->ib_trans.max_inline_send =
+		    dapl_os_get_env_val("DAPL_MAX_INLINE",
+					INLINE_SEND_IWARP_DEFAULT);
+	else
+		hca_ptr->ib_trans.max_inline_send =
+		    dapl_os_get_env_val("DAPL_MAX_INLINE",
+					INLINE_SEND_IB_DEFAULT);
 
-	/* set CM timer defaults */	
+	/* set CM timer defaults */
 	hca_ptr->ib_trans.max_cm_timeout =
-		dapl_os_get_env_val("DAPL_MAX_CM_RESPONSE_TIME", 
-				    IB_CM_RESPONSE_TIMEOUT);
-	hca_ptr->ib_trans.max_cm_retries = 
-		dapl_os_get_env_val("DAPL_MAX_CM_RETRIES", 
-				    IB_CM_RETRIES);
+	    dapl_os_get_env_val("DAPL_MAX_CM_RESPONSE_TIME",
+				IB_CM_RESPONSE_TIMEOUT);
+	hca_ptr->ib_trans.max_cm_retries =
+	    dapl_os_get_env_val("DAPL_MAX_CM_RETRIES", IB_CM_RETRIES);
 
 	/* EVD events without direct CQ channels, non-blocking */
-	hca_ptr->ib_trans.ib_cq = 
-		ibv_create_comp_channel(hca_ptr->ib_hca_handle);
+	hca_ptr->ib_trans.ib_cq =
+	    ibv_create_comp_channel(hca_ptr->ib_hca_handle);
 	if (hca_ptr->ib_trans.ib_cq == NULL) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " open_hca: ibv_create_comp_channel ERR %s\n",
 			 strerror(errno));
 		goto bail;
 	}
-	dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-			" open_hca: CQ channel created(fd=%d)\n",
-			hca_ptr->ib_trans.ib_cq->fd);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " open_hca: CQ channel created\n");
 
-	opts = fcntl(hca_ptr->ib_trans.ib_cq->fd, F_GETFL); /* uCQ */
-	if (opts < 0 || fcntl(hca_ptr->ib_trans.ib_cq->fd, 
-			      F_SETFL, opts | O_NONBLOCK) < 0) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " open_hca: fcntl on ib_cq->fd %d ERR %d %s\n", 
-			 hca_ptr->ib_trans.ib_cq->fd, opts,
-			 strerror(errno));
+	if (dapls_config_comp_channel(hca_ptr->ib_trans.ib_cq)) {
 		goto bail;
 	}
-	
+
 	/* 
 	 * Put new hca_transport on list for async and CQ event processing 
 	 * Wakeup work thread to add to polling list
 	 */
-	dapl_llist_init_entry((DAPL_LLIST_ENTRY*)&hca_ptr->ib_trans.entry);
-	dapl_os_lock( &g_hca_lock );
-	dapl_llist_add_tail(&g_hca_list, 
-			    (DAPL_LLIST_ENTRY*)&hca_ptr->ib_trans.entry, 
+	dapl_llist_init_entry((DAPL_LLIST_ENTRY *) & hca_ptr->ib_trans.entry);
+	dapl_os_lock(&g_hca_lock);
+	dapl_llist_add_tail(&g_hca_list,
+			    (DAPL_LLIST_ENTRY *) & hca_ptr->ib_trans.entry,
 			    &hca_ptr->ib_trans.entry);
-	if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			 " open_hca: thread wakeup error = %s\n", 
+	if (dapls_thread_signal() == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " open_hca: thread wakeup error = %s\n",
 			 strerror(errno));
 	dapl_os_unlock(&g_hca_lock);
-	
-  	dapl_dbg_log(
-		DAPL_DBG_TYPE_UTIL, 
-		" open_hca: %s, %s %d.%d.%d.%d INLINE_MAX=%d\n", hca_name, 
-		((struct sockaddr_in *)
-			&hca_ptr->hca_address)->sin_family == AF_INET ?  
-			"AF_INET":"AF_INET6",
-		((struct sockaddr_in *)
-			&hca_ptr->hca_address)->sin_addr.s_addr >> 0 & 0xff,
-		((struct sockaddr_in *)
-			&hca_ptr->hca_address)->sin_addr.s_addr >> 8 & 0xff,
-		((struct sockaddr_in *)
-			&hca_ptr->hca_address)->sin_addr.s_addr >> 16 & 0xff,
-		((struct sockaddr_in *)
-			&hca_ptr->hca_address)->sin_addr.s_addr >> 24 & 0xff,
-		hca_ptr->ib_trans.max_inline_send );
 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " open_hca: %s, %s %d.%d.%d.%d INLINE_MAX=%d\n", hca_name,
+		     ((struct sockaddr_in *)
+		      &hca_ptr->hca_address)->sin_family == AF_INET ?
+		     "AF_INET" : "AF_INET6", ((struct sockaddr_in *)
+					      &hca_ptr->hca_address)->sin_addr.
+		     s_addr >> 0 & 0xff, ((struct sockaddr_in *)
+					  &hca_ptr->hca_address)->sin_addr.
+		     s_addr >> 8 & 0xff, ((struct sockaddr_in *)
+					  &hca_ptr->hca_address)->sin_addr.
+		     s_addr >> 16 & 0xff, ((struct sockaddr_in *)
+					   &hca_ptr->hca_address)->sin_addr.
+		     s_addr >> 24 & 0xff, hca_ptr->ib_trans.max_inline_send);
+
 	hca_ptr->ib_trans.d_hca = hca_ptr;
 	return DAT_SUCCESS;
-bail:
-	rdma_destroy_id(hca_ptr->ib_trans.cm_id); 
+      bail:
+	rdma_destroy_id(hca_ptr->ib_trans.cm_id);
 	hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
 	return DAT_INTERNAL_ERROR;
 }
 
-
 /*
  * dapls_ib_close_hca
  *
@@ -364,14 +428,14 @@
  *	dapl_convert_errno 
  *
  */
-DAT_RETURN dapls_ib_close_hca(IN DAPL_HCA *hca_ptr)
+DAT_RETURN dapls_ib_close_hca(IN DAPL_HCA * hca_ptr)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL," close_hca: %p->%p\n",
-		     hca_ptr,hca_ptr->ib_hca_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " close_hca: %p->%p\n",
+		     hca_ptr, hca_ptr->ib_hca_handle);
 
 	if (hca_ptr->ib_hca_handle != IB_INVALID_HANDLE) {
-		if (rdma_destroy_id(hca_ptr->ib_trans.cm_id)) 
-			return(dapl_convert_errno(errno,"ib_close_device"));
+		if (rdma_destroy_id(hca_ptr->ib_trans.cm_id))
+			return (dapl_convert_errno(errno, "ib_close_device"));
 		hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
 	}
 
@@ -387,28 +451,25 @@
 	 * Wakeup work thread to remove from polling list
 	 */
 	hca_ptr->ib_trans.destroy = 1;
-	if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			 " destroy: thread wakeup error = %s\n", 
+	if (dapls_thread_signal() == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " destroy: thread wakeup error = %s\n",
 			 strerror(errno));
 
 	/* wait for thread to remove HCA references */
 	while (hca_ptr->ib_trans.destroy != 2) {
-		struct timespec	sleep, remain;
-		sleep.tv_sec = 0;
-		sleep.tv_nsec = 10000000; /* 10 ms */
-		if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
-			dapl_log(DAPL_DBG_TYPE_UTIL, 
-				 " destroy: thread wakeup error = %s\n", 
-				 strerror(errno));		
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
+		if (dapls_thread_signal() == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " destroy: thread wakeup error = %s\n",
+				 strerror(errno));
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 			     " ib_thread_destroy: wait on hca %p destroy\n");
-		nanosleep (&sleep, &remain);
+		dapl_os_sleep_usec(10000);
 	}
-bail:
+      bail:
 	return (DAT_SUCCESS);
 }
-  
+
 /*
  * dapls_ib_query_hca
  *
@@ -428,31 +489,31 @@
  *	DAT_INVALID_HANDLE
  */
 
-DAT_RETURN dapls_ib_query_hca(IN DAPL_HCA *hca_ptr,
-			      OUT DAT_IA_ATTR *ia_attr,
-			      OUT DAT_EP_ATTR *ep_attr,
-			      OUT DAT_SOCK_ADDR6 *ip_addr)
+DAT_RETURN dapls_ib_query_hca(IN DAPL_HCA * hca_ptr,
+			      OUT DAT_IA_ATTR * ia_attr,
+			      OUT DAT_EP_ATTR * ep_attr,
+			      OUT DAT_SOCK_ADDR6 * ip_addr)
 {
 	struct ibv_device_attr dev_attr;
 	struct ibv_port_attr port_attr;
 
 	if (hca_ptr->ib_hca_handle == NULL) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR," query_hca: BAD handle\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR, " query_hca: BAD handle\n");
 		return (DAT_INVALID_HANDLE);
 	}
 
 	/* local IP address of device, set during ia_open */
 	if (ip_addr != NULL)
 		memcpy(ip_addr, &hca_ptr->hca_address, sizeof(DAT_SOCK_ADDR6));
-	
-	if (ia_attr == NULL && ep_attr == NULL) 
+
+	if (ia_attr == NULL && ep_attr == NULL)
 		return DAT_SUCCESS;
 
-	/* query verbs for this device and port attributes */	
+	/* query verbs for this device and port attributes */
 	if (ibv_query_device(hca_ptr->ib_hca_handle, &dev_attr) ||
-			     ibv_query_port(hca_ptr->ib_hca_handle, 
-					    hca_ptr->port_num, &port_attr))
-		return(dapl_convert_errno(errno,"ib_query_hca"));
+	    ibv_query_port(hca_ptr->ib_hca_handle,
+			   hca_ptr->port_num, &port_attr))
+		return (dapl_convert_errno(errno, "ib_query_hca"));
 
 	/*
 	 * There is no query for inline data so there is no way to 
@@ -461,103 +522,108 @@
 	 * we are provided with a query mechanism from verbs.
 	 */
 	if (hca_ptr->ib_trans.max_inline_send)
-			dev_attr.max_sge--;
+		dev_attr.max_sge--;
 
 	if (ia_attr != NULL) {
-		(void) dapl_os_memzero(ia_attr, sizeof(*ia_attr));
+		(void)dapl_os_memzero(ia_attr, sizeof(*ia_attr));
 		ia_attr->adapter_name[DAT_NAME_MAX_LENGTH - 1] = '\0';
 		ia_attr->vendor_name[DAT_NAME_MAX_LENGTH - 1] = '\0';
-		ia_attr->ia_address_ptr = 
-			(DAT_IA_ADDRESS_PTR)&hca_ptr->hca_address;
+		ia_attr->ia_address_ptr =
+		    (DAT_IA_ADDRESS_PTR) & hca_ptr->hca_address;
 
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			"dapl_query_hca: %s %s %s\n", hca_ptr->name,
-			((struct sockaddr_in *)
-			ia_attr->ia_address_ptr)->sin_family == AF_INET ? 
-			"AF_INET":"AF_INET6",
-			inet_ntoa(((struct sockaddr_in *)
-				ia_attr->ia_address_ptr)->sin_addr));
-		
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 "dapl_query_hca: %s %s %s\n", hca_ptr->name,
+			 ((struct sockaddr_in *)
+			  ia_attr->ia_address_ptr)->sin_family == AF_INET ?
+			 "AF_INET" : "AF_INET6",
+			 inet_ntoa(((struct sockaddr_in *)
+				    ia_attr->ia_address_ptr)->sin_addr));
+
 		ia_attr->hardware_version_major = dev_attr.hw_ver;
-		ia_attr->max_eps                  = dev_attr.max_qp;
-		ia_attr->max_dto_per_ep           = dev_attr.max_qp_wr;
-		ia_attr->max_rdma_read_in         = dev_attr.max_res_rd_atom;
-		ia_attr->max_rdma_read_out        = dev_attr.max_qp_init_rd_atom;
-		ia_attr->max_rdma_read_per_ep_in  = dev_attr.max_qp_rd_atom;
-		ia_attr->max_rdma_read_per_ep_out = dev_attr.max_qp_init_rd_atom;
-		ia_attr->max_rdma_read_per_ep_in_guaranteed  = DAT_TRUE;
+		ia_attr->max_eps = dev_attr.max_qp;
+		ia_attr->max_dto_per_ep = dev_attr.max_qp_wr;
+		ia_attr->max_rdma_read_in = dev_attr.max_res_rd_atom;
+		ia_attr->max_rdma_read_out = dev_attr.max_qp_init_rd_atom;
+		ia_attr->max_rdma_read_per_ep_in = dev_attr.max_qp_rd_atom;
+		ia_attr->max_rdma_read_per_ep_out =
+		    dev_attr.max_qp_init_rd_atom;
+		ia_attr->max_rdma_read_per_ep_in_guaranteed = DAT_TRUE;
 		ia_attr->max_rdma_read_per_ep_out_guaranteed = DAT_TRUE;
-		ia_attr->max_evds                 = dev_attr.max_cq;
-		ia_attr->max_evd_qlen             = dev_attr.max_cqe;
+		ia_attr->max_evds = dev_attr.max_cq;
+		ia_attr->max_evd_qlen = dev_attr.max_cqe;
 		ia_attr->max_iov_segments_per_dto = dev_attr.max_sge;
-		ia_attr->max_lmrs                 = dev_attr.max_mr;
-		ia_attr->max_lmr_block_size       = dev_attr.max_mr_size;
-		ia_attr->max_rmrs                 = dev_attr.max_mw;
-		ia_attr->max_lmr_virtual_address  = dev_attr.max_mr_size;
-		ia_attr->max_rmr_target_address   = dev_attr.max_mr_size;
-		ia_attr->max_pzs                  = dev_attr.max_pd;
-		ia_attr->max_mtu_size             = port_attr.max_msg_sz;
-		ia_attr->max_rdma_size            = port_attr.max_msg_sz;
-		ia_attr->num_transport_attr       = 0;
-		ia_attr->transport_attr           = NULL;
-		ia_attr->num_vendor_attr          = 0;
-		ia_attr->vendor_attr              = NULL;
+		ia_attr->max_lmrs = dev_attr.max_mr;
+		/* 32bit attribute from 64bit, 4G-1 limit, DAT v2 needs fix */
+		ia_attr->max_lmr_block_size = 
+		    (dev_attr.max_mr_size >> 32) ? ~0 : dev_attr.max_mr_size;
+		ia_attr->max_rmrs = dev_attr.max_mw;
+		ia_attr->max_lmr_virtual_address = dev_attr.max_mr_size;
+		ia_attr->max_rmr_target_address = dev_attr.max_mr_size;
+		ia_attr->max_pzs = dev_attr.max_pd;
+		ia_attr->max_mtu_size = port_attr.max_msg_sz;
+		ia_attr->max_rdma_size = port_attr.max_msg_sz;
+		ia_attr->num_transport_attr = 0;
+		ia_attr->transport_attr = NULL;
+		ia_attr->num_vendor_attr = 0;
+		ia_attr->vendor_attr = NULL;
 		/* iWARP spec. - 1 sge for RDMA reads */
 		if (hca_ptr->ib_hca_handle->device->transport_type
-							== IBV_TRANSPORT_IWARP)
+		    == IBV_TRANSPORT_IWARP)
 			ia_attr->max_iov_segments_per_rdma_read = 1;
 		else
 			ia_attr->max_iov_segments_per_rdma_read =
-							dev_attr.max_sge;
+			    dev_attr.max_sge;
 
 		ia_attr->max_iov_segments_per_rdma_write = dev_attr.max_sge;
 		/* save rd_atom for peer validation during connect requests */
-		hca_ptr->ib_trans.max_rdma_rd_in  = dev_attr.max_qp_rd_atom;
-		hca_ptr->ib_trans.max_rdma_rd_out = dev_attr.max_qp_init_rd_atom;
+		hca_ptr->ib_trans.max_rdma_rd_in = dev_attr.max_qp_rd_atom;
+		hca_ptr->ib_trans.max_rdma_rd_out =
+		    dev_attr.max_qp_init_rd_atom;
 #ifdef DAT_EXTENSIONS
 		ia_attr->extension_supported = DAT_EXTENSION_IB;
 		ia_attr->extension_version = DAT_IB_EXTENSION_VERSION;
 #endif
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			"dapl_query_hca: (ver=%x) ep's %d ep_q %d"
-			" evd's %d evd_q %d\n", 
-			ia_attr->hardware_version_major,
-			ia_attr->max_eps, ia_attr->max_dto_per_ep,
-			ia_attr->max_evds, ia_attr->max_evd_qlen );
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			"dapl_query_hca: msg %llu rdma %llu iov's %d"
-			" lmr %d rmr %d rd_in,out %d,%d inline=%d\n", 
-			ia_attr->max_mtu_size, ia_attr->max_rdma_size,
-			ia_attr->max_iov_segments_per_dto, ia_attr->max_lmrs, 
-			ia_attr->max_rmrs, ia_attr->max_rdma_read_per_ep_in,
-			ia_attr->max_rdma_read_per_ep_out,
-                        hca_ptr->ib_trans.max_inline_send);
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 "dapl_query_hca: (ver=%x) ep's %d ep_q %d"
+			 " evd's %d evd_q %d mr %u\n",
+			 ia_attr->hardware_version_major,
+			 ia_attr->max_eps, ia_attr->max_dto_per_ep,
+			 ia_attr->max_evds, ia_attr->max_evd_qlen, 
+			 ia_attr->max_lmr_block_size);
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 "dapl_query_hca: msg %llu rdma %llu iov's %d"
+			 " lmr %d rmr %d rd_in,out %d,%d inline=%d\n",
+			 ia_attr->max_mtu_size, ia_attr->max_rdma_size,
+			 ia_attr->max_iov_segments_per_dto, ia_attr->max_lmrs,
+			 ia_attr->max_rmrs, ia_attr->max_rdma_read_per_ep_in,
+			 ia_attr->max_rdma_read_per_ep_out,
+			 hca_ptr->ib_trans.max_inline_send);
 	}
-	
+
 	if (ep_attr != NULL) {
-		(void) dapl_os_memzero(ep_attr, sizeof(*ep_attr));
-		ep_attr->max_mtu_size     = port_attr.max_msg_sz;
-		ep_attr->max_rdma_size    = port_attr.max_msg_sz;
-		ep_attr->max_recv_dtos    = dev_attr.max_qp_wr;
+		(void)dapl_os_memzero(ep_attr, sizeof(*ep_attr));
+		ep_attr->max_mtu_size = port_attr.max_msg_sz;
+		ep_attr->max_rdma_size = port_attr.max_msg_sz;
+		ep_attr->max_recv_dtos = dev_attr.max_qp_wr;
 		ep_attr->max_request_dtos = dev_attr.max_qp_wr;
-		ep_attr->max_recv_iov     = dev_attr.max_sge;
-		ep_attr->max_request_iov  = dev_attr.max_sge;
+		ep_attr->max_recv_iov = dev_attr.max_sge;
+		ep_attr->max_request_iov = dev_attr.max_sge;
 		ep_attr->max_rdma_read_in = dev_attr.max_qp_rd_atom;
-		ep_attr->max_rdma_read_out= dev_attr.max_qp_init_rd_atom;
+		ep_attr->max_rdma_read_out = dev_attr.max_qp_init_rd_atom;
 		/* iWARP spec. - 1 sge for RDMA reads */
 		if (hca_ptr->ib_hca_handle->device->transport_type
-							== IBV_TRANSPORT_IWARP)
+		    == IBV_TRANSPORT_IWARP)
 			ep_attr->max_rdma_read_iov = 1;
 		else
 			ep_attr->max_rdma_read_iov = dev_attr.max_sge;
 
-		ep_attr->max_rdma_write_iov= dev_attr.max_sge;
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			"dapl_query_hca: MAX msg %llu dto %d iov %d"
-			" rdma i%d,o%d\n", 
-			ep_attr->max_mtu_size,
-			ep_attr->max_recv_dtos, ep_attr->max_recv_iov,
-			ep_attr->max_rdma_read_in, ep_attr->max_rdma_read_out);
+		ep_attr->max_rdma_write_iov = dev_attr.max_sge;
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 "dapl_query_hca: MAX msg %llu dto %d iov %d"
+			 " rdma i%d,o%d\n",
+			 ep_attr->max_mtu_size,
+			 ep_attr->max_recv_dtos, ep_attr->max_recv_iov,
+			 ep_attr->max_rdma_read_in, ep_attr->max_rdma_read_out);
 	}
 	return DAT_SUCCESS;
 }
@@ -583,12 +649,11 @@
  *	DAT_INVALID_PARAMETER
  *
  */
-DAT_RETURN dapls_ib_setup_async_callback(IN  DAPL_IA *ia_ptr,
-					 IN  DAPL_ASYNC_HANDLER_TYPE type,
-					 IN  DAPL_EVD *evd_ptr,
-					 IN  ib_async_handler_t callback,
-					 IN  void *context)
-
+DAT_RETURN dapls_ib_setup_async_callback(IN DAPL_IA * ia_ptr,
+					 IN DAPL_ASYNC_HANDLER_TYPE type,
+					 IN DAPL_EVD * evd_ptr,
+					 IN ib_async_handler_t callback,
+					 IN void *context)
 {
 	ib_hca_transport_t *hca_ptr;
 
@@ -597,24 +662,19 @@
 		     ia_ptr, type, evd_ptr, callback, context);
 
 	hca_ptr = &ia_ptr->hca_ptr->ib_trans;
-	switch(type)
-	{
+	switch (type) {
 	case DAPL_ASYNC_UNAFILIATED:
-		hca_ptr->async_unafiliated = 
-			(ib_async_handler_t)callback;
+		hca_ptr->async_unafiliated = (ib_async_handler_t) callback;
 		hca_ptr->async_un_ctx = context;
 		break;
 	case DAPL_ASYNC_CQ_ERROR:
-		hca_ptr->async_cq_error = 
-			(ib_async_cq_handler_t)callback;
+		hca_ptr->async_cq_error = (ib_async_cq_handler_t) callback;
 		break;
 	case DAPL_ASYNC_CQ_COMPLETION:
-		hca_ptr->async_cq = 
-			(ib_async_dto_handler_t)callback;
+		hca_ptr->async_cq = (ib_async_dto_handler_t) callback;
 		break;
 	case DAPL_ASYNC_QP_ERROR:
-		hca_ptr->async_qp_error = 
-			(ib_async_qp_handler_t)callback;
+		hca_ptr->async_qp_error = (ib_async_qp_handler_t) callback;
 		break;
 	default:
 		break;
@@ -624,24 +684,21 @@
 
 DAT_RETURN dapli_ib_thread_init(void)
 {
-	long opts;
 	DAT_RETURN dat_status;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-		     " ib_thread_init(%d)\n", getpid());
+		     " ib_thread_init(%d)\n", dapl_os_getpid());
 
 	dapl_os_lock(&g_hca_lock);
 	if (g_ib_thread_state != IB_THREAD_INIT) {
 		dapl_os_unlock(&g_hca_lock);
 		return DAT_SUCCESS;
 	}
-		
+
 	/* uCMA events non-blocking */
-	opts = fcntl(g_cm_events->fd, F_GETFL); /* uCMA */
-	if (opts < 0 || fcntl(g_cm_events->fd, 
-			      F_SETFL, opts | O_NONBLOCK) < 0) {
+	if (dapls_config_cm_channel(g_cm_events)) {
 		dapl_os_unlock(&g_hca_lock);
-		return(dapl_convert_errno(errno, "create_thread ERR: cm_fd"));
+		return (dapl_convert_errno(errno, "create_thread ERR: cm_fd"));
 	}
 
 	g_ib_thread_state = IB_THREAD_CREATE;
@@ -650,28 +707,25 @@
 	/* create thread to process inbound connect request */
 	dat_status = dapl_os_thread_create(dapli_thread, NULL, &g_ib_thread);
 	if (dat_status != DAT_SUCCESS)
-		return(dapl_convert_errno(errno,
-					  "create_thread ERR:"
-					  " check resource limits"));
-	
+		return (dapl_convert_errno(errno,
+					   "create_thread ERR:"
+					   " check resource limits"));
+
 	/* wait for thread to start */
 	dapl_os_lock(&g_hca_lock);
 	while (g_ib_thread_state != IB_THREAD_RUN) {
-                struct timespec sleep, remain;
-                sleep.tv_sec = 0;
-                sleep.tv_nsec = 2000000; /* 2 ms */
-                dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                             " ib_thread_init: waiting for ib_thread\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+			     " ib_thread_init: waiting for ib_thread\n");
 		dapl_os_unlock(&g_hca_lock);
-                nanosleep (&sleep, &remain);
+		dapl_os_sleep_usec(2000);
 		dapl_os_lock(&g_hca_lock);
-        }
+	}
 	dapl_os_unlock(&g_hca_lock);
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-		     " ib_thread_init(%d) exit\n",getpid());
+		     " ib_thread_init(%d) exit\n", dapl_os_getpid());
 
- 	return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
 void dapli_ib_thread_destroy(void)
@@ -679,181 +733,229 @@
 	int retries = 10;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-		     " ib_thread_destroy(%d)\n", getpid());
+		     " ib_thread_destroy(%d)\n", dapl_os_getpid());
 	/* 
 	 * wait for async thread to terminate. 
 	 * pthread_join would be the correct method
 	 * but some applications have some issues
 	 */
-	 
+
 	/* destroy ib_thread, wait for termination, if not already */
 	dapl_os_lock(&g_hca_lock);
-	if (g_ib_thread_state != IB_THREAD_RUN) 
+	if (g_ib_thread_state != IB_THREAD_RUN)
 		goto bail;
-			
+
 	g_ib_thread_state = IB_THREAD_CANCEL;
-	if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			 " destroy: thread wakeup error = %s\n", 
+	if (dapls_thread_signal() == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " destroy: thread wakeup error = %s\n",
 			 strerror(errno));
 	while ((g_ib_thread_state != IB_THREAD_EXIT) && (retries--)) {
-		struct timespec	sleep, remain;
-		sleep.tv_sec = 0;
-		sleep.tv_nsec = 2000000; /* 2 ms */
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			" ib_thread_destroy: waiting for ib_thread\n");
-		if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
-			dapl_log(DAPL_DBG_TYPE_UTIL, 
-				 " destroy: thread wakeup error = %s\n", 
-				strerror(errno));
-		dapl_os_unlock( &g_hca_lock );
-		nanosleep(&sleep, &remain);
-		dapl_os_lock( &g_hca_lock );
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+			     " ib_thread_destroy: waiting for ib_thread\n");
+		if (dapls_thread_signal() == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " destroy: thread wakeup error = %s\n",
+				 strerror(errno));
+		dapl_os_unlock(&g_hca_lock);
+		dapl_os_sleep_usec(2000);
+		dapl_os_lock(&g_hca_lock);
 	}
 
-bail:
-	dapl_os_unlock( &g_hca_lock );
-	
+      bail:
+	dapl_os_unlock(&g_hca_lock);
+
 	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-		     " ib_thread_destroy(%d) exit\n",getpid());
+		     " ib_thread_destroy(%d) exit\n", dapl_os_getpid());
 }
 
 void dapli_async_event_cb(struct _ib_hca_transport *hca)
 {
-	struct ibv_async_event	event;
-	struct pollfd	async_fd = {
-		.fd      = hca->cm_id->verbs->async_fd,
-		.events  = POLLIN,
-		.revents = 0
-	};
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " async_event(%p)\n",hca);
+	struct ibv_async_event event;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " async_event(%p)\n", hca);
+
 	if (hca->destroy)
 		return;
 
-	if ((poll(&async_fd, 1, 0)==1) &&
-		(!ibv_get_async_event(hca->cm_id->verbs, &event))) {
+	if (!ibv_get_async_event(hca->cm_id->verbs, &event)) {
 
 		switch (event.event_type) {
-		case	IBV_EVENT_CQ_ERR:
-		{
-			struct dapl_ep *evd_ptr = 
-				event.element.cq->cq_context;
+		case IBV_EVENT_CQ_ERR:
+			{
+				struct dapl_ep *evd_ptr =
+				    event.element.cq->cq_context;
 
-			dapl_log(
-				DAPL_DBG_TYPE_ERR,
-				"dapl async_event CQ (%p) ERR %d\n",
-				evd_ptr, event.event_type);				
-			
-			/* report up if async callback still setup */
-			if (hca->async_cq_error)
-				hca->async_cq_error(hca->cm_id->verbs,
-						    event.element.cq,	
-						    &event,
-						    (void*)evd_ptr);
-			break;
-		}
-		case	IBV_EVENT_COMM_EST:
-		{
-			/* Received msgs on connected QP before RTU */
-			dapl_log(
-				DAPL_DBG_TYPE_UTIL,
-				" async_event COMM_EST(%p) rdata beat RTU\n",
-				event.element.qp);	
+				dapl_log(DAPL_DBG_TYPE_ERR,
+					 "dapl async_event CQ (%p) ERR %d\n",
+					 evd_ptr, event.event_type);
 
-			break;
-		}
-		case	IBV_EVENT_QP_FATAL:
-		case	IBV_EVENT_QP_REQ_ERR:
-		case	IBV_EVENT_QP_ACCESS_ERR:
-		case	IBV_EVENT_QP_LAST_WQE_REACHED:
-		case	IBV_EVENT_SRQ_ERR:
-		case	IBV_EVENT_SRQ_LIMIT_REACHED:
-		case	IBV_EVENT_SQ_DRAINED:
-		{
-			struct dapl_ep *ep_ptr = 
-				event.element.qp->qp_context;
+				/* report up if async callback still setup */
+				if (hca->async_cq_error)
+					hca->async_cq_error(hca->cm_id->verbs,
+							    event.element.cq,
+							    &event,
+							    (void *)evd_ptr);
+				break;
+			}
+		case IBV_EVENT_COMM_EST:
+			{
+				/* Received msgs on connected QP before RTU */
+				dapl_log(DAPL_DBG_TYPE_UTIL,
+					 " async_event COMM_EST(%p) rdata beat RTU\n",
+					 event.element.qp);
 
-			dapl_log(
-				DAPL_DBG_TYPE_ERR,
-				"dapl async_event QP (%p) ERR %d\n",
-				ep_ptr, event.event_type);	
-			
-			/* report up if async callback still setup */
-			if (hca->async_qp_error)
-				hca->async_qp_error(hca->cm_id->verbs,
-						    ep_ptr->qp_handle,
-						    &event,
-						    (void*)ep_ptr);
-			break;
-		}
-		case	IBV_EVENT_PATH_MIG:
-		case	IBV_EVENT_PATH_MIG_ERR:
-		case	IBV_EVENT_DEVICE_FATAL:
-		case	IBV_EVENT_PORT_ACTIVE:
-		case	IBV_EVENT_PORT_ERR:
-		case	IBV_EVENT_LID_CHANGE:
-		case	IBV_EVENT_PKEY_CHANGE:
-		case	IBV_EVENT_SM_CHANGE:
-		{
-			dapl_log(DAPL_DBG_TYPE_WARN,
-				     "dapl async_event: DEV ERR %d\n",
-				     event.event_type);	
+				break;
+			}
+		case IBV_EVENT_QP_FATAL:
+		case IBV_EVENT_QP_REQ_ERR:
+		case IBV_EVENT_QP_ACCESS_ERR:
+		case IBV_EVENT_QP_LAST_WQE_REACHED:
+		case IBV_EVENT_SRQ_ERR:
+		case IBV_EVENT_SRQ_LIMIT_REACHED:
+		case IBV_EVENT_SQ_DRAINED:
+			{
+				struct dapl_ep *ep_ptr =
+				    event.element.qp->qp_context;
 
-			/* report up if async callback still setup */
-			if (hca->async_unafiliated)
-				hca->async_unafiliated( 
-						hca->cm_id->verbs,
-						&event,
-						hca->async_un_ctx);
-			break;
-		}
-		case	IBV_EVENT_CLIENT_REREGISTER:
+				dapl_log(DAPL_DBG_TYPE_ERR,
+					 "dapl async_event QP (%p) ERR %d\n",
+					 ep_ptr, event.event_type);
+
+				/* report up if async callback still setup */
+				if (hca->async_qp_error)
+					hca->async_qp_error(hca->cm_id->verbs,
+							    ep_ptr->qp_handle,
+							    &event,
+							    (void *)ep_ptr);
+				break;
+			}
+		case IBV_EVENT_PATH_MIG:
+		case IBV_EVENT_PATH_MIG_ERR:
+		case IBV_EVENT_DEVICE_FATAL:
+		case IBV_EVENT_PORT_ACTIVE:
+		case IBV_EVENT_PORT_ERR:
+		case IBV_EVENT_LID_CHANGE:
+		case IBV_EVENT_PKEY_CHANGE:
+		case IBV_EVENT_SM_CHANGE:
+			{
+				dapl_log(DAPL_DBG_TYPE_WARN,
+					 "dapl async_event: DEV ERR %d\n",
+					 event.event_type);
+
+				/* report up if async callback still setup */
+				if (hca->async_unafiliated)
+					hca->async_unafiliated(hca->cm_id->
+							       verbs, &event,
+							       hca->
+							       async_un_ctx);
+				break;
+			}
+		case IBV_EVENT_CLIENT_REREGISTER:
 			/* no need to report this event this time */
-			dapl_log (DAPL_DBG_TYPE_UTIL,
-				     " async_event: IBV_EVENT_CLIENT_REREGISTER\n");
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " async_event: IBV_EVENT_CLIENT_REREGISTER\n");
 			break;
 
 		default:
-			dapl_log (DAPL_DBG_TYPE_WARN,
-				     "dapl async_event: %d UNKNOWN\n", 
-				     event.event_type);
+			dapl_log(DAPL_DBG_TYPE_WARN,
+				 "dapl async_event: %d UNKNOWN\n",
+				 event.event_type);
 			break;
-		
+
 		}
 		ibv_ack_async_event(&event);
 	}
 }
 
+#if defined(_WIN64) || defined(_WIN32)
 /* work thread for uAT, uCM, CQ, and async events */
-void dapli_thread(void *arg) 
+void dapli_thread(void *arg)
 {
-	struct pollfd		 ufds[__FD_SETSIZE];
-	struct _ib_hca_transport *uhca[__FD_SETSIZE]={NULL};
 	struct _ib_hca_transport *hca;
-	int			 ret,idx,fds;
-	char			 rbuf[2];
-	
-	dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
-		      " ib_thread(%d,0x%x): ENTER: pipe %d ucma %d\n",
-		      getpid(), g_ib_thread, g_ib_pipe[0], g_cm_events->fd);
+	struct _ib_hca_transport *uhca[8];
+	COMP_CHANNEL *channel;
+	int ret, idx, cnt;
 
- 	/* Poll across pipe, CM, AT never changes */
-	dapl_os_lock( &g_hca_lock );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " ib_thread(%d,0x%x): ENTER: \n",
+		     dapl_os_getpid(), g_ib_thread);
+
+	dapl_os_lock(&g_hca_lock);
+	for (g_ib_thread_state = IB_THREAD_RUN;
+	     g_ib_thread_state == IB_THREAD_RUN; dapl_os_lock(&g_hca_lock)) {
+
+		idx = 0;
+		hca = dapl_llist_is_empty(&g_hca_list) ? NULL :
+		    dapl_llist_peek_head(&g_hca_list);
+
+		while (hca) {
+			uhca[idx++] = hca;
+			hca = dapl_llist_next_entry(&g_hca_list,
+						    (DAPL_LLIST_ENTRY *) & hca->
+						    entry);
+		}
+		cnt = idx;
+
+		dapl_os_unlock(&g_hca_lock);
+		ret = CompManagerPoll(windata.comp_mgr, INFINITE, &channel);
+
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+			     " ib_thread(%d) poll_event 0x%x\n",
+			     dapl_os_getpid(), ret);
+
+		dapli_cma_event_cb();
+
+		/* check and process CQ and ASYNC events, per device */
+		for (idx = 0; idx < cnt; idx++) {
+			if (uhca[idx]->destroy == 1) {
+				dapl_os_lock(&g_hca_lock);
+				dapl_llist_remove_entry(&g_hca_list,
+							(DAPL_LLIST_ENTRY *) &
+							uhca[idx]->entry);
+				dapl_os_unlock(&g_hca_lock);
+				uhca[idx]->destroy = 2;
+			} else {
+				dapli_cq_event_cb(uhca[idx]);
+				dapli_async_event_cb(uhca[idx]);
+			}
+		}
+	}
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " ib_thread(%d) EXIT\n",
+		     dapl_os_getpid());
+	g_ib_thread_state = IB_THREAD_EXIT;
+	dapl_os_unlock(&g_hca_lock);
+}
+#else				// _WIN64 || WIN32
+/* work thread for uAT, uCM, CQ, and async events */
+void dapli_thread(void *arg)
+{
+	struct pollfd ufds[__FD_SETSIZE];
+	struct _ib_hca_transport *uhca[__FD_SETSIZE] = { NULL };
+	struct _ib_hca_transport *hca;
+	int ret, idx, fds;
+	char rbuf[2];
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " ib_thread(%d,0x%x): ENTER: pipe %d ucma %d\n",
+		     dapl_os_getpid(), g_ib_thread, g_ib_pipe[0],
+		     g_cm_events->fd);
+
+	/* Poll across pipe, CM, AT never changes */
+	dapl_os_lock(&g_hca_lock);
 	g_ib_thread_state = IB_THREAD_RUN;
-		
+
 	ufds[0].fd = g_ib_pipe[0];	/* pipe */
 	ufds[0].events = POLLIN;
 	ufds[1].fd = g_cm_events->fd;	/* uCMA */
 	ufds[1].events = POLLIN;
-	
+
 	while (g_ib_thread_state == IB_THREAD_RUN) {
-		
+
 		/* build ufds after pipe and uCMA events */
 		ufds[0].revents = 0;
 		ufds[1].revents = 0;
-		idx=1;
+		idx = 1;
 
 		/*  Walk HCA list and setup async and CQ events */
 		if (!dapl_llist_is_empty(&g_hca_list))
@@ -861,55 +963,56 @@
 		else
 			hca = NULL;
 
-		while(hca) {
-		
+		while (hca) {
+
 			/* uASYNC events */
-			ufds[++idx].fd = hca->cm_id->verbs->async_fd;	
+			ufds[++idx].fd = hca->cm_id->verbs->async_fd;
 			ufds[idx].events = POLLIN;
 			ufds[idx].revents = 0;
 			uhca[idx] = hca;
 
 			/* uCQ, non-direct events */
-			ufds[++idx].fd = hca->ib_cq->fd; 
+			ufds[++idx].fd = hca->ib_cq->fd;
 			ufds[idx].events = POLLIN;
 			ufds[idx].revents = 0;
 			uhca[idx] = hca;
 
 			dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-				" ib_thread(%d) poll_fd: hca[%d]=%p, async=%d"
-				" pipe=%d cm=%d cq=d\n",
-				getpid(), hca, ufds[idx-1].fd, 
-				ufds[0].fd, ufds[1].fd, ufds[idx].fd);
+				     " ib_thread(%d) poll_fd: hca[%d]=%p, async=%d"
+				     " pipe=%d cm=%d cq=d\n",
+				     dapl_os_getpid(), hca, ufds[idx - 1].fd,
+				     ufds[0].fd, ufds[1].fd, ufds[idx].fd);
 
-			hca = dapl_llist_next_entry(
-				&g_hca_list,
-				(DAPL_LLIST_ENTRY*)&hca->entry);
+			hca = dapl_llist_next_entry(&g_hca_list,
+						    (DAPL_LLIST_ENTRY *) & hca->
+						    entry);
 		}
-		
+
 		/* unlock, and setup poll */
-		fds = idx+1;
+		fds = idx + 1;
 		dapl_os_unlock(&g_hca_lock);
-                ret = poll(ufds, fds, -1); 
+		ret = poll(ufds, fds, -1);
 		if (ret <= 0) {
 			dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 				     " ib_thread(%d): ERR %s poll\n",
-				     getpid(),strerror(errno));
-                	dapl_os_lock(&g_hca_lock);
+				     dapl_os_getpid(), strerror(errno));
+			dapl_os_lock(&g_hca_lock);
 			continue;
 		}
 
 		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-			" ib_thread(%d) poll_event: "
-			" async=0x%x pipe=0x%x cm=0x%x cq=0x%x\n",
-			getpid(), ufds[idx-1].revents, ufds[0].revents, 
-			ufds[1].revents, ufds[idx].revents);
+			     " ib_thread(%d) poll_event: "
+			     " async=0x%x pipe=0x%x cm=0x%x cq=0x%x\n",
+			     dapl_os_getpid(), ufds[idx - 1].revents,
+			     ufds[0].revents, ufds[1].revents,
+			     ufds[idx].revents);
 
 		/* uCMA events */
 		if (ufds[1].revents == POLLIN)
 			dapli_cma_event_cb();
 
 		/* check and process CQ and ASYNC events, per device */
-		for(idx=2;idx<fds;idx++) {
+		for (idx = 2; idx < fds; idx++) {
 			if (ufds[idx].revents == POLLIN) {
 				dapli_cq_event_cb(uhca[idx]);
 				dapli_async_event_cb(uhca[idx]);
@@ -924,13 +1027,14 @@
 					 strerror(errno));
 
 			/* cleanup any device on list marked for destroy */
-			for(idx=3;idx<fds;idx++) {
-				if(uhca[idx] && uhca[idx]->destroy == 1) {
+			for (idx = 3; idx < fds; idx++) {
+				if (uhca[idx] && uhca[idx]->destroy == 1) {
 					dapl_os_lock(&g_hca_lock);
-					dapl_llist_remove_entry(
-						&g_hca_list, 
-						(DAPL_LLIST_ENTRY*)
-							&uhca[idx]->entry);
+					dapl_llist_remove_entry(&g_hca_list,
+								(DAPL_LLIST_ENTRY
+								 *)
+								& uhca[idx]->
+								entry);
 					dapl_os_unlock(&g_hca_lock);
 					uhca[idx]->destroy = 2;
 				}
@@ -939,10 +1043,12 @@
 		dapl_os_lock(&g_hca_lock);
 	}
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL," ib_thread(%d) EXIT\n",getpid());
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " ib_thread(%d) EXIT\n",
+		     dapl_os_getpid());
 	g_ib_thread_state = IB_THREAD_EXIT;
-	dapl_os_unlock(&g_hca_lock);	
+	dapl_os_unlock(&g_hca_lock);
 }
+#endif
 
 /*
  * dapls_set_provider_specific_attr
@@ -956,30 +1062,33 @@
  * Returns:
  * 	void
  */
-DAT_NAMED_ATTR	ib_attrs[] = {
+DAT_NAMED_ATTR ib_attrs[] = {
 #ifdef DAT_EXTENSIONS
-    {
-    	"DAT_EXTENSION_INTERFACE", "TRUE"
-    },
-    {
-    	DAT_IB_ATTR_FETCH_AND_ADD, "TRUE"
-    },
-    {
-    	DAT_IB_ATTR_CMP_AND_SWAP, "TRUE"
-    },
-    {
-    	DAT_IB_ATTR_IMMED_DATA, "TRUE"
-    },
+	{
+	 "DAT_EXTENSION_INTERFACE", "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_FETCH_AND_ADD, "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_CMP_AND_SWAP, "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_IMMED_DATA, "TRUE"}
+	,
+#ifdef DAPL_COUNTERS
+	{
+	 DAT_ATTR_COUNTERS, "TRUE"}
+	,
+#endif				/* DAPL_COUNTERS */
 #endif
 };
 
 #define SPEC_ATTR_SIZE( x )	(sizeof( x ) / sizeof( DAT_NAMED_ATTR))
 
-void dapls_query_provider_specific_attr(
-	IN DAPL_IA		*ia_ptr,
-	IN DAT_PROVIDER_ATTR	*attr_ptr )
+void dapls_query_provider_specific_attr(IN DAPL_IA * ia_ptr,
+					IN DAT_PROVIDER_ATTR * attr_ptr)
 {
-    attr_ptr->num_provider_specific_attr = SPEC_ATTR_SIZE(ib_attrs);
-    attr_ptr->provider_specific_attr     = ib_attrs;
+	attr_ptr->num_provider_specific_attr = SPEC_ATTR_SIZE(ib_attrs);
+	attr_ptr->provider_specific_attr = ib_attrs;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/dapl_ib_util.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -38,8 +38,8 @@
 #ifndef _DAPL_IB_UTIL_H_
 #define _DAPL_IB_UTIL_H_
 
+#include "openib_osd.h"
 #include <infiniband/verbs.h>
-#include <byteswap.h>
 #include <rdma/rdma_cma.h>
 
 /* Typedefs to map common DAPL provider types to IB verbs */
@@ -177,7 +177,7 @@
 typedef struct dapl_cm_id	*ib_cm_srvc_handle_t;
 
 /* Operation and state mappings */
-typedef enum	ibv_send_flags	ib_send_op_type_t;
+typedef int	ib_send_op_type_t;
 typedef	struct	ibv_sge		ib_data_segment_t;
 typedef enum	ibv_qp_state	ib_qp_state_t;
 typedef	enum	ibv_event_type	ib_async_event_type;
@@ -294,33 +294,24 @@
 {
     if (!err)	return DAT_SUCCESS;
     	
-    if ((err != EAGAIN) && (err != ETIME) && 
-	(err != ETIMEDOUT) && (err != EINTR))
-	dapl_log (DAPL_DBG_TYPE_ERR," %s %s\n", str, strerror(err));
+#if DAPL_DBG
+    if ((err != EAGAIN) && (err != ETIMEDOUT))
+	dapl_dbg_log (DAPL_DBG_TYPE_ERR," %s %s\n", str, strerror(err));
+#endif 
 
     switch( err )
     {
 	case EOVERFLOW	: return DAT_LENGTH_ERROR;
 	case EACCES	: return DAT_PRIVILEGES_VIOLATION;
-	case ENXIO	: 
-	case ERANGE	: 
 	case EPERM	: return DAT_PROTECTION_VIOLATION;		  
-	case EINVAL	:
-        case EBADF	: 
-	case ENOENT	:
-	case ENOTSOCK	: return DAT_INVALID_HANDLE;
+	case EINVAL	: return DAT_INVALID_HANDLE;
     	case EISCONN	: return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_CONNECTED;
     	case ECONNREFUSED : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_NOTREADY;
-	case ETIME	:	    
 	case ETIMEDOUT	: return DAT_TIMEOUT_EXPIRED;
     	case ENETUNREACH: return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_UNREACHABLE;
-	case EBUSY	: return DAT_PROVIDER_IN_USE;
-	case EADDRINUSE	: return DAT_CONN_QUAL_IN_USE;
+    	case EADDRINUSE	: return DAT_CONN_QUAL_IN_USE;
     	case EALREADY	: return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_ACTCONNPENDING;
-        case ENOSPC	: 
-	case ENOMEM	:
-        case E2BIG	:
-        case EDQUOT	: return DAT_INSUFFICIENT_RESOURCES;
+	case ENOMEM	: return DAT_INSUFFICIENT_RESOURCES;
         case EAGAIN	: return DAT_QUEUE_EMPTY;
 	case EINTR	: return DAT_INTERRUPTED_CALL;
     	case EAFNOSUPPORT : return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_MALFORMED;

Added: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/linux/openib_osd.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/linux/openib_osd.h	                        (rev 0)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_cma/linux/openib_osd.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -0,0 +1,15 @@
+#ifndef OPENIB_OSD_H
+#define OPENIB_OSD_H
+
+#include <byteswap.h>
+#include <sys/poll.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define htonll(x) (x)
+#define ntohll(x) (x)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define htonll(x)  bswap_64(x)
+#define ntohll(x)  bswap_64(x)
+#endif
+
+#endif // OPENIB_OSD_H

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cm.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cm.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cm.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -52,42 +52,205 @@
 #include "dapl_cr_util.h"
 #include "dapl_name_service.h"
 #include "dapl_ib_util.h"
+#include "dapl_osd.h"
 
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <netinet/tcp.h>
-#include <byteswap.h>
-#include <poll.h>
+extern DAPL_SOCKET g_scm[2];
 
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#if defined(_WIN32) || defined(_WIN64)
+enum DAPL_FD_EVENTS {
+	DAPL_FD_READ = 0x1,
+	DAPL_FD_WRITE = 0x2,
+	DAPL_FD_ERROR = 0x4
+};
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) {return bswap_64(x);}
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) {return x;}
+static int dapl_config_socket(DAPL_SOCKET s)
+{
+	unsigned long nonblocking = 1;
+	return ioctlsocket(s, FIONBIO, &nonblocking);
+}
+
+static int dapl_connect_socket(DAPL_SOCKET s, struct sockaddr *addr,
+			       int addrlen)
+{
+	int err;
+
+	err = connect(s, addr, addrlen);
+	if (err == SOCKET_ERROR)
+		err = WSAGetLastError();
+	return (err == WSAEWOULDBLOCK) ? EAGAIN : err;
+}
+
+struct dapl_fd_set {
+	struct fd_set set[3];
+};
+
+static struct dapl_fd_set *dapl_alloc_fd_set(void)
+{
+	return dapl_os_alloc(sizeof(struct dapl_fd_set));
+}
+
+static void dapl_fd_zero(struct dapl_fd_set *set)
+{
+	FD_ZERO(&set->set[0]);
+	FD_ZERO(&set->set[1]);
+	FD_ZERO(&set->set[2]);
+}
+
+static int dapl_fd_set(DAPL_SOCKET s, struct dapl_fd_set *set,
+		       enum DAPL_FD_EVENTS event)
+{
+	FD_SET(s, &set->set[(event == DAPL_FD_READ) ? 0 : 1]);
+	FD_SET(s, &set->set[2]);
+	return 0;
+}
+
+static enum DAPL_FD_EVENTS dapl_poll(DAPL_SOCKET s, enum DAPL_FD_EVENTS event)
+{
+	struct fd_set rw_fds;
+	struct fd_set err_fds;
+	struct timeval tv;
+	int ret;
+
+	FD_ZERO(&rw_fds);
+	FD_ZERO(&err_fds);
+	FD_SET(s, &rw_fds);
+	FD_SET(s, &err_fds);
+
+	tv.tv_sec = 0;
+	tv.tv_usec = 0;
+
+	if (event == DAPL_FD_READ)
+		ret = select(1, &rw_fds, NULL, &err_fds, &tv);
+	else
+		ret = select(1, NULL, &rw_fds, &err_fds, &tv);
+
+	if (ret == 0)
+		return 0;
+	else if (ret == SOCKET_ERROR)
+		return WSAGetLastError();
+	else if (FD_ISSET(s, &rw_fds))
+		return event;
+	else
+		return DAPL_FD_ERROR;
+}
+
+static int dapl_select(struct dapl_fd_set *set)
+{
+	int ret;
+
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " dapl_select: sleep\n");
+	ret = select(0, &set->set[0], &set->set[1], &set->set[2], NULL);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " dapl_select: wakeup\n");
+
+	if (ret == SOCKET_ERROR)
+		dapl_dbg_log(DAPL_DBG_TYPE_CM,
+			     " dapl_select: error 0x%x\n", WSAGetLastError());
+
+	return ret;
+}
+#else				// _WIN32 || _WIN64
+enum DAPL_FD_EVENTS {
+	DAPL_FD_READ = POLLIN,
+	DAPL_FD_WRITE = POLLOUT,
+	DAPL_FD_ERROR = POLLERR
+};
+
+static int dapl_config_socket(DAPL_SOCKET s)
+{
+	int ret;
+
+	ret = fcntl(s, F_GETFL);
+	if (ret >= 0)
+		ret = fcntl(s, F_SETFL, ret | O_NONBLOCK);
+	return ret;
+}
+
+static int dapl_connect_socket(DAPL_SOCKET s, struct sockaddr *addr,
+			       int addrlen)
+{
+	int ret;
+
+	ret = connect(s, addr, addrlen);
+
+	return (errno == EINPROGRESS) ? EAGAIN : ret;
+}
+
+struct dapl_fd_set {
+	int index;
+	struct pollfd set[DAPL_FD_SETSIZE];
+};
+
+static struct dapl_fd_set *dapl_alloc_fd_set(void)
+{
+	return dapl_os_alloc(sizeof(struct dapl_fd_set));
+}
+
+static void dapl_fd_zero(struct dapl_fd_set *set)
+{
+	set->index = 0;
+}
+
+static int dapl_fd_set(DAPL_SOCKET s, struct dapl_fd_set *set,
+		       enum DAPL_FD_EVENTS event)
+{
+	if (set->index == DAPL_FD_SETSIZE - 1) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 "SCM ERR: cm_thread exceeded FD_SETSIZE %d\n",
+			 set->index + 1);
+		return -1;
+	}
+
+	set->set[set->index].fd = s;
+	set->set[set->index].revents = 0;
+	set->set[set->index++].events = event;
+	return 0;
+}
+
+static enum DAPL_FD_EVENTS dapl_poll(DAPL_SOCKET s, enum DAPL_FD_EVENTS event)
+{
+	struct pollfd fds;
+	int ret;
+
+	fds.fd = s;
+	fds.events = event;
+	fds.revents = 0;
+	ret = poll(&fds, 1, 0);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " dapl_poll: ret=%d, events=0x%x\n",
+		     ret, fds.revents);
+	if (ret <= 0)
+		return ret;
+
+	return fds.revents;
+}
+
+static int dapl_select(struct dapl_fd_set *set)
+{
+	int ret;
+
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " dapl_select: sleep, fds=%d\n",
+		     set->index);
+	ret = poll(set->set, set->index, -1);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " dapl_select: wakeup, ret=0x%x\n", ret);
+	return ret;
+}
 #endif
 
-extern int g_scm_pipe[2];
-
 static struct ib_cm_handle *dapli_cm_create(void)
-{ 
+{
 	struct ib_cm_handle *cm_ptr;
 
 	/* Allocate CM, init lock, and initialize */
-	if ((cm_ptr = dapl_os_alloc(sizeof(*cm_ptr))) == NULL) 
+	if ((cm_ptr = dapl_os_alloc(sizeof(*cm_ptr))) == NULL)
 		return NULL;
 
-        if (dapl_os_lock_init(&cm_ptr->lock)) 
+	(void)dapl_os_memzero(cm_ptr, sizeof(*cm_ptr));
+	if (dapl_os_lock_init(&cm_ptr->lock))
 		goto bail;
 
-	(void)dapl_os_memzero(cm_ptr, sizeof(*cm_ptr));
 	cm_ptr->dst.ver = htons(DSCM_VER);
-	cm_ptr->socket = -1;
+	cm_ptr->socket = DAPL_INVALID_SOCKET;
 	return cm_ptr;
-bail:
+      bail:
 	dapl_os_free(cm_ptr, sizeof(*cm_ptr));
 	return NULL;
 }
@@ -95,13 +258,13 @@
 /* mark for destroy, remove all references, schedule cleanup */
 static void dapli_cm_destroy(struct ib_cm_handle *cm_ptr)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
-		     " cm_destroy: cm %p ep %p\n", cm_ptr,cm_ptr->ep);
-	
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " cm_destroy: cm %p ep %p\n", cm_ptr, cm_ptr->ep);
+
 	/* cleanup, never made it to work queue */
 	if (cm_ptr->state == SCM_INIT) {
-		if (cm_ptr->socket >= 0)  
-			close(cm_ptr->socket);
+		if (cm_ptr->socket != DAPL_INVALID_SOCKET)
+			closesocket(cm_ptr->socket);
 		dapl_os_free(cm_ptr, sizeof(*cm_ptr));
 		return;
 	}
@@ -112,16 +275,16 @@
 		cm_ptr->ep->cm_handle = IB_INVALID_HANDLE;
 
 	/* close socket if still active */
-	if (cm_ptr->socket >= 0) {
-		close(cm_ptr->socket);
-		cm_ptr->socket = -1;
+	if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+		closesocket(cm_ptr->socket);
+		cm_ptr->socket = DAPL_INVALID_SOCKET;
 	}
 	dapl_os_unlock(&cm_ptr->lock);
 
 	/* wakeup work thread */
-	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_CM, 
-			 " cm_destroy: thread wakeup error = %s\n", 
+	if (send(g_scm[1], "w", sizeof "w", 0) == -1)
+		dapl_log(DAPL_DBG_TYPE_CM,
+			 " cm_destroy: thread wakeup error = %s\n",
 			 strerror(errno));
 }
 
@@ -129,41 +292,30 @@
 static void dapli_cm_queue(struct ib_cm_handle *cm_ptr)
 {
 	/* add to work queue for cr thread processing */
-	dapl_llist_init_entry((DAPL_LLIST_ENTRY*)&cm_ptr->entry);
+	dapl_llist_init_entry((DAPL_LLIST_ENTRY *) & cm_ptr->entry);
 	dapl_os_lock(&cm_ptr->hca->ib_trans.lock);
-	dapl_llist_add_tail(&cm_ptr->hca->ib_trans.list, 
-			    (DAPL_LLIST_ENTRY*)&cm_ptr->entry, cm_ptr);
+	dapl_llist_add_tail(&cm_ptr->hca->ib_trans.list,
+			    (DAPL_LLIST_ENTRY *) & cm_ptr->entry, cm_ptr);
 	dapl_os_unlock(&cm_ptr->hca->ib_trans.lock);
 
-        /* wakeup CM work thread */
-	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_CM, 
-			 " cm_queue: thread wakeup error = %s\n", 
+	/* wakeup CM work thread */
+	if (send(g_scm[1], "w", sizeof "w", 0) == -1)
+		dapl_log(DAPL_DBG_TYPE_CM,
+			 " cm_queue: thread wakeup error = %s\n",
 			 strerror(errno));
 }
 
-static uint16_t dapli_get_lid(IN struct ibv_context *ctx, IN uint8_t port)
-{
-	struct ibv_port_attr port_attr;
-
-	if(ibv_query_port(ctx, port,&port_attr))
-		return(0xffff);
-	else
-		return(port_attr.lid);
-}
-
 /*
  * ACTIVE/PASSIVE: called from CR thread or consumer via ep_disconnect
  */
-static DAT_RETURN 
-dapli_socket_disconnect(dp_ib_cm_handle_t	cm_ptr)
+static DAT_RETURN dapli_socket_disconnect(dp_ib_cm_handle_t cm_ptr)
 {
-	DAPL_EP	*ep_ptr = cm_ptr->ep;
+	DAPL_EP *ep_ptr = cm_ptr->ep;
 	DAT_UINT32 disc_data = htonl(0xdead);
 
 	if (ep_ptr == NULL)
 		return DAT_SUCCESS;
-	
+
 	dapl_os_lock(&cm_ptr->lock);
 	if ((cm_ptr->state == SCM_INIT) ||
 	    (cm_ptr->state == SCM_DISCONNECTED) ||
@@ -172,14 +324,14 @@
 		return DAT_SUCCESS;
 	} else {
 		/* send disc date, close socket, schedule destroy */
-		if (cm_ptr->socket >= 0) { 
-			if (write(cm_ptr->socket, 
-				  &disc_data, sizeof(disc_data)) == -1)
-				dapl_log(DAPL_DBG_TYPE_WARN, 
-					 " cm_disc: write error = %s\n", 
+		if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+			if (send(cm_ptr->socket, (char *)&disc_data,
+				 sizeof(disc_data), 0) == -1)
+				dapl_log(DAPL_DBG_TYPE_WARN,
+					 " cm_disc: write error = %s\n",
 					 strerror(errno));
-			close(cm_ptr->socket);
-			cm_ptr->socket = -1;
+			closesocket(cm_ptr->socket);
+			cm_ptr->socket = DAPL_INVALID_SOCKET;
 		}
 		cm_ptr->state = SCM_DISCONNECTED;
 	}
@@ -189,15 +341,14 @@
 	if (ep_ptr->param.ep_attr.service_type == DAT_SERVICE_TYPE_RC) {
 		if (ep_ptr->cr_ptr) {
 			dapls_cr_callback(cm_ptr,
-					IB_CME_DISCONNECTED,
-					NULL,
-					((DAPL_CR *)ep_ptr->cr_ptr)->sp_ptr);
+					  IB_CME_DISCONNECTED,
+					  NULL,
+					  ((DAPL_CR *) ep_ptr->cr_ptr)->sp_ptr);
 		} else {
 			dapl_evd_connection_callback(ep_ptr->cm_handle,
-						IB_CME_DISCONNECTED,
-						NULL,
-						ep_ptr);
-		}	
+						     IB_CME_DISCONNECTED,
+						     NULL, ep_ptr);
+		}
 	}
 
 	/* scheduled destroy via disconnect clean in callback */
@@ -207,116 +358,117 @@
 /*
  * ACTIVE: socket connected, send QP information to peer 
  */
-void
-dapli_socket_connected(dp_ib_cm_handle_t cm_ptr, int err)
+static void dapli_socket_connected(dp_ib_cm_handle_t cm_ptr, int err)
 {
-	int		len, opt = 1;
-	struct iovec    iovec[2];
-	struct dapl_ep	*ep_ptr = cm_ptr->ep;
+	int len, opt = 1;
+	struct iovec iov[2];
+	struct dapl_ep *ep_ptr = cm_ptr->ep;
 
 	if (err) {
 		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " CONN_PENDING: socket ERR %s -> %s\n",
-			 strerror(err),
-			 inet_ntoa(((struct sockaddr_in *)
-			 ep_ptr->param.remote_ia_address_ptr)->sin_addr));
+			 strerror(err), inet_ntoa(((struct sockaddr_in *)
+						   ep_ptr->param.
+						   remote_ia_address_ptr)->
+						  sin_addr));
 		goto bail;
 	}
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " socket connected, write QP and private data\n"); 
+		     " socket connected, write QP and private data\n");
 
 	/* no delay for small packets */
-	setsockopt(cm_ptr->socket,IPPROTO_TCP,TCP_NODELAY,&opt,sizeof(opt));
+	setsockopt(cm_ptr->socket, IPPROTO_TCP, TCP_NODELAY,
+		   (char *)&opt, sizeof(opt));
 
 	/* send qp info and pdata to remote peer */
-	iovec[0].iov_base = &cm_ptr->dst;
-	iovec[0].iov_len  = sizeof(ib_qp_cm_t);
+	iov[0].iov_base = (void *)&cm_ptr->dst;
+	iov[0].iov_len = sizeof(ib_qp_cm_t);
 	if (cm_ptr->dst.p_size) {
-		iovec[1].iov_base = cm_ptr->p_data;
-		iovec[1].iov_len  = ntohl(cm_ptr->dst.p_size);
+		iov[1].iov_base = cm_ptr->p_data;
+		iov[1].iov_len = ntohl(cm_ptr->dst.p_size);
+		len = writev(cm_ptr->socket, iov, 2);
+	} else {
+		len = writev(cm_ptr->socket, iov, 1);
 	}
 
-	len = writev(cm_ptr->socket, iovec, (cm_ptr->dst.p_size ? 2:1));
-    	if (len != (ntohl(cm_ptr->dst.p_size) + sizeof(ib_qp_cm_t))) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+	if (len != (ntohl(cm_ptr->dst.p_size) + sizeof(ib_qp_cm_t))) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " CONN_PENDING write: ERR %s, wcnt=%d -> %s\n",
-			 strerror(errno), len,
-			 inet_ntoa(((struct sockaddr_in *)
-		           ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
+			 strerror(errno), len, inet_ntoa(((struct sockaddr_in *)
+							  ep_ptr->param.
+							  remote_ia_address_ptr)->
+							 sin_addr));
 		goto bail;
 	}
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " connected: sending SRC port=0x%x lid=0x%x,"
 		     " qpn=0x%x, psize=%d\n",
-		     ntohs(cm_ptr->dst.port), ntohs(cm_ptr->dst.lid), 
-		     ntohl(cm_ptr->dst.qpn), ntohl(cm_ptr->dst.p_size)); 
-        dapl_dbg_log(DAPL_DBG_TYPE_CM,
-                     " connected: sending SRC GID subnet %016llx id %016llx\n",
-                     (unsigned long long) 
-			cpu_to_be64(cm_ptr->dst.gid.global.subnet_prefix),
-                     (unsigned long long) 
-			cpu_to_be64(cm_ptr->dst.gid.global.interface_id));
+		     ntohs(cm_ptr->dst.port), ntohs(cm_ptr->dst.lid),
+		     ntohl(cm_ptr->dst.qpn), ntohl(cm_ptr->dst.p_size));
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " connected: sending SRC GID subnet %016llx id %016llx\n",
+		     (unsigned long long)
+		     htonll(cm_ptr->dst.gid.global.subnet_prefix),
+		     (unsigned long long)
+		     htonll(cm_ptr->dst.gid.global.interface_id));
 
 	/* queue up to work thread to avoid blocking consumer */
 	cm_ptr->state = SCM_RTU_PENDING;
 	return;
-bail:
+      bail:
 	/* close socket, free cm structure and post error event */
 	dapli_cm_destroy(cm_ptr);
 	dapl_evd_connection_callback(NULL, IB_CME_LOCAL_FAILURE, NULL, ep_ptr);
 }
 
-
 /*
  * ACTIVE: Create socket, connect, defer exchange QP information to CR thread
  * to avoid blocking. 
  */
-DAT_RETURN 
-dapli_socket_connect(DAPL_EP		*ep_ptr,
-	   	     DAT_IA_ADDRESS_PTR	r_addr,
-		     DAT_CONN_QUAL	r_qual,
-		     DAT_COUNT		p_size,
-		     DAT_PVOID		p_data)
+DAT_RETURN
+dapli_socket_connect(DAPL_EP * ep_ptr,
+		     DAT_IA_ADDRESS_PTR r_addr,
+		     DAT_CONN_QUAL r_qual, DAT_COUNT p_size, DAT_PVOID p_data)
 {
 	dp_ib_cm_handle_t cm_ptr;
-	int		ret;
-	DAPL_IA		*ia_ptr = ep_ptr->header.owner_ia;
+	int ret;
+	DAPL_IA *ia_ptr = ep_ptr->header.owner_ia;
+	struct sockaddr_in addr;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: r_qual %d p_size=%d\n", 
-		     r_qual,p_size);
-			
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: r_qual %d p_size=%d\n",
+		     r_qual, p_size);
+
 	cm_ptr = dapli_cm_create();
 	if (cm_ptr == NULL)
 		return DAT_INSUFFICIENT_RESOURCES;
 
 	/* create, connect, sockopt, and exchange QP information */
-	if ((cm_ptr->socket = socket(AF_INET,SOCK_STREAM,0)) < 0 ) {
-		dapl_os_free( cm_ptr, sizeof( *cm_ptr ) );
+	if ((cm_ptr->socket =
+	     socket(AF_INET, SOCK_STREAM, 0)) == DAPL_INVALID_SOCKET) {
+		dapl_os_free(cm_ptr, sizeof(*cm_ptr));
 		return DAT_INSUFFICIENT_RESOURCES;
 	}
 
-	/* non-blocking */
-	ret = fcntl(cm_ptr->socket, F_GETFL); 
-        if (ret < 0 || fcntl(cm_ptr->socket,
-                              F_SETFL, ret | O_NONBLOCK) < 0) {
-                dapl_log(DAPL_DBG_TYPE_ERR,
-                         " socket connect: fcntl on socket %d ERR %d %s\n",
-                         cm_ptr->socket, ret,
-                         strerror(errno));
-                goto bail;
-        }
+	ret = dapl_config_socket(cm_ptr->socket);
+	if (ret < 0) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " socket connect: config socket %d ERR %d %s\n",
+			 cm_ptr->socket, ret, strerror(errno));
+		goto bail;
+	}
 
-	((struct sockaddr_in*)r_addr)->sin_port = htons(r_qual);
-	ret = connect(cm_ptr->socket, r_addr, sizeof(*r_addr));
-	if (ret && errno != EINPROGRESS) {
+	dapl_os_memcpy(&addr, r_addr, sizeof(addr));
+	addr.sin_port = htons(r_qual);
+	ret = dapl_connect_socket(cm_ptr->socket, (struct sockaddr *)&addr,
+				  sizeof(addr));
+	if (ret && ret != EAGAIN) {
 		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " socket connect ERROR: %s -> %s r_qual %d\n",
-			 strerror(errno), 
-		     	 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr),
-			 (unsigned int)r_qual);
+			 strerror(errno),
+			 inet_ntoa(addr.sin_addr), (unsigned int)r_qual);
 		dapli_cm_destroy(cm_ptr);
 		return DAT_INVALID_ADDRESS;
-	} 
+	}
 
 	/* Send QP info, IA address, and private data */
 	cm_ptr->dst.qpn = htonl(ep_ptr->qp_handle->qp_num);
@@ -324,28 +476,9 @@
 	cm_ptr->dst.qp_type = htons(ep_ptr->qp_handle->qp_type);
 #endif
 	cm_ptr->dst.port = htons(ia_ptr->hca_ptr->port_num);
-	cm_ptr->dst.lid = 
-		htons(dapli_get_lid(ia_ptr->hca_ptr->ib_hca_handle, 
-				    (uint8_t)ia_ptr->hca_ptr->port_num));
-	if (cm_ptr->dst.lid == 0xffff) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " CONNECT: query LID ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr));
-		goto bail;
-	}
+	cm_ptr->dst.lid = ia_ptr->hca_ptr->ib_trans.lid;
+	cm_ptr->dst.gid = ia_ptr->hca_ptr->ib_trans.gid;
 
-        /* in network order */
-        if (ibv_query_gid(ia_ptr->hca_ptr->ib_hca_handle,
-				    (uint8_t)ia_ptr->hca_ptr->port_num,
-				    0, &cm_ptr->dst.gid)) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " CONNECT: query GID ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr));
-		goto bail;
-	}
-
 	/* save references */
 	cm_ptr->hca = ia_ptr->hca_ptr;
 	cm_ptr->ep = ep_ptr;
@@ -356,24 +489,23 @@
 	}
 
 	/* connected or pending, either way results via async event */
-	if (ret == 0) 
-		dapli_socket_connected(cm_ptr,0);
-	else 
+	if (ret == 0)
+		dapli_socket_connected(cm_ptr, 0);
+	else
 		cm_ptr->state = SCM_CONN_PENDING;
-	
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-	             " connect: socket %d to %s r_qual %d pending\n",
+		     " connect: socket %d to %s r_qual %d pending\n",
 		     cm_ptr->socket,
-		     inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr),
-		     (unsigned int)r_qual);
-			
+		     inet_ntoa(addr.sin_addr), (unsigned int)r_qual);
+
 	dapli_cm_queue(cm_ptr);
 	return DAT_SUCCESS;
-bail:
+      bail:
 	dapl_log(DAPL_DBG_TYPE_ERR,
 		 " socket connect ERROR: %s query lid(0x%x)/gid"
 		 " -> %s r_qual %d\n",
-		 strerror(errno), ntohs(cm_ptr->dst.lid), 
+		 strerror(errno), ntohs(cm_ptr->dst.lid),
 		 inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr),
 		 (unsigned int)r_qual);
 
@@ -381,41 +513,38 @@
 	dapli_cm_destroy(cm_ptr);
 	return DAT_INTERNAL_ERROR;
 }
-	
 
 /*
  * ACTIVE: exchange QP information, called from CR thread
  */
-void 
-dapli_socket_connect_rtu(dp_ib_cm_handle_t	cm_ptr)
+static void dapli_socket_connect_rtu(dp_ib_cm_handle_t cm_ptr)
 {
-	DAPL_EP		*ep_ptr = cm_ptr->ep;
-	int		len;
-	struct iovec    iovec[2];
-	short		rtu_data = htons(0x0E0F);
-	ib_cm_events_t	event = IB_CME_DESTINATION_REJECT;
+	DAPL_EP *ep_ptr = cm_ptr->ep;
+	int len;
+	short rtu_data = htons(0x0E0F);
+	ib_cm_events_t event = IB_CME_DESTINATION_REJECT;
 
 	/* read DST information into cm_ptr, overwrite SRC info */
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," connect_rtu: recv peer QP data\n"); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect_rtu: recv peer QP data\n");
 
-	iovec[0].iov_base = &cm_ptr->dst;
-	iovec[0].iov_len  = sizeof(ib_qp_cm_t);
-	len = readv(cm_ptr->socket, iovec, 1);
+	len = recv(cm_ptr->socket, (char *)&cm_ptr->dst, sizeof(ib_qp_cm_t), 0);
 	if (len != sizeof(ib_qp_cm_t) || ntohs(cm_ptr->dst.ver) != DSCM_VER) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-		     " CONN_RTU read: ERR %s, rcnt=%d, ver=%d -> %s\n",
-		     strerror(errno), len, cm_ptr->dst.ver,
-		     inet_ntoa(((struct sockaddr_in *)
-		         ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " CONN_RTU read: ERR %s, rcnt=%d, ver=%d -> %s\n",
+			 strerror(errno), len, cm_ptr->dst.ver,
+			 inet_ntoa(((struct sockaddr_in *)
+				    ep_ptr->param.remote_ia_address_ptr)->
+				   sin_addr));
 		goto bail;
 	}
 	/* check for consumer reject */
 	if (cm_ptr->dst.rej) {
-		dapl_log(DAPL_DBG_TYPE_CM, 
+		dapl_log(DAPL_DBG_TYPE_CM,
 			 " CONN_RTU read: PEER REJ reason=0x%x -> %s\n",
 			 ntohs(cm_ptr->dst.rej),
 			 inet_ntoa(((struct sockaddr_in *)
-			   ep_ptr->param.remote_ia_address_ptr)->sin_addr));
+				    ep_ptr->param.remote_ia_address_ptr)->
+				   sin_addr));
 		event = IB_CME_DESTINATION_REJECT_PRIVATE_DATA;
 		goto bail;
 	}
@@ -430,80 +559,83 @@
 	cm_ptr->dst.p_size = ntohl(cm_ptr->dst.p_size);
 
 	/* save remote address information */
-	dapl_os_memcpy( &ep_ptr->remote_ia_address, 
-			&cm_ptr->dst.ia_address, 
-			sizeof(ep_ptr->remote_ia_address));
+	dapl_os_memcpy(&ep_ptr->remote_ia_address,
+		       &cm_ptr->dst.ia_address,
+		       sizeof(ep_ptr->remote_ia_address));
 
-	dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " CONN_RTU: DST %s port=0x%x lid=0x%x,"
 		     " qpn=0x%x, qp_type=%d, psize=%d\n",
 		     inet_ntoa(((struct sockaddr_in *)
 				&cm_ptr->dst.ia_address)->sin_addr),
-		     cm_ptr->dst.port, cm_ptr->dst.lid, 
-		     cm_ptr->dst.qpn, cm_ptr->dst.qp_type, 
-		     cm_ptr->dst.p_size); 
+		     cm_ptr->dst.port, cm_ptr->dst.lid,
+		     cm_ptr->dst.qpn, cm_ptr->dst.qp_type, cm_ptr->dst.p_size);
 
 	/* validate private data size before reading */
 	if (cm_ptr->dst.p_size > IB_MAX_REP_PDATA_SIZE) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " CONN_RTU read: psize (%d) wrong -> %s\n",
-			 cm_ptr->dst.p_size,
-			 inet_ntoa(((struct sockaddr_in *)
-			   ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
+			 cm_ptr->dst.p_size, inet_ntoa(((struct sockaddr_in *)
+							ep_ptr->param.
+							remote_ia_address_ptr)->
+						       sin_addr));
 		goto bail;
 	}
 
 	/* read private data into cm_handle if any present */
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," socket connected, read private data\n"); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     " socket connected, read private data\n");
 	if (cm_ptr->dst.p_size) {
-		iovec[0].iov_base = cm_ptr->p_data;
-		iovec[0].iov_len  = cm_ptr->dst.p_size;
-		len = readv(cm_ptr->socket, iovec, 1);
+		len =
+		    recv(cm_ptr->socket, cm_ptr->p_data, cm_ptr->dst.p_size, 0);
 		if (len != cm_ptr->dst.p_size) {
-			dapl_log(DAPL_DBG_TYPE_ERR, 
-			    " CONN_RTU read pdata: ERR %s, rcnt=%d -> %s\n",
-			    strerror(errno), len,
-			    inet_ntoa(((struct sockaddr_in *)
-			      ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
+			dapl_log(DAPL_DBG_TYPE_ERR,
+				 " CONN_RTU read pdata: ERR %s, rcnt=%d -> %s\n",
+				 strerror(errno), len,
+				 inet_ntoa(((struct sockaddr_in *)
+					    ep_ptr->param.
+					    remote_ia_address_ptr)->sin_addr));
 			goto bail;
 		}
 	}
 
 	/* modify QP to RTR and then to RTS with remote info */
 	dapl_os_lock(&ep_ptr->header.lock);
-	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
+	if (dapls_modify_qp_state(ep_ptr->qp_handle,
 				  IBV_QPS_RTR, cm_ptr) != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " CONN_RTU: QPS_RTR ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)
-			   ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
+			 strerror(errno), inet_ntoa(((struct sockaddr_in *)
+						     ep_ptr->param.
+						     remote_ia_address_ptr)->
+						    sin_addr));
 		dapl_os_unlock(&ep_ptr->header.lock);
 		goto bail;
 	}
-	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
+	if (dapls_modify_qp_state(ep_ptr->qp_handle,
 				  IBV_QPS_RTS, cm_ptr) != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " CONN_RTU: QPS_RTS ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)
-			   ep_ptr->param.remote_ia_address_ptr)->sin_addr)); 
+			 strerror(errno), inet_ntoa(((struct sockaddr_in *)
+						     ep_ptr->param.
+						     remote_ia_address_ptr)->
+						    sin_addr));
 		dapl_os_unlock(&ep_ptr->header.lock);
 		goto bail;
 	}
 	dapl_os_unlock(&ep_ptr->header.lock);
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," connect_rtu: send RTU\n"); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect_rtu: send RTU\n");
 
 	/* complete handshake after final QP state change */
-	if (write(cm_ptr->socket, &rtu_data, sizeof(rtu_data)) == -1) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+	if (send(cm_ptr->socket, (char *)&rtu_data, sizeof(rtu_data), 0) == -1) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " CONN_RTU: write error = %s\n", strerror(errno));
 		goto bail;
 	}
 	/* init cm_handle and post the event with private data */
 	ep_ptr->cm_handle = cm_ptr;
 	cm_ptr->state = SCM_CONNECTED;
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," ACTIVE: connected!\n"); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " ACTIVE: connected!\n");
 
 #ifdef DAT_EXTENSIONS
 	if (cm_ptr->dst.qp_type == IBV_QPT_UD) {
@@ -514,43 +646,42 @@
 		xevent.type = DAT_IB_UD_REMOTE_AH;
 		xevent.remote_ah.ah = cm_ptr->ah;
 		xevent.remote_ah.qpn = cm_ptr->dst.qpn;
-		dapl_os_memcpy( &xevent.remote_ah.ia_addr,
-				&cm_ptr->dst.ia_address, 
-				sizeof(cm_ptr->dst.ia_address));
-	
-		dapls_evd_post_connection_event_ext(
-			(DAPL_EVD*)ep_ptr->param.connect_evd_handle,
-			DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED,
-			(DAT_EP_HANDLE)ep_ptr,
-			(DAT_COUNT)cm_ptr->dst.p_size,
-			(DAT_PVOID*)cm_ptr->p_data,
-			(DAT_PVOID*)&xevent);
-    	} else 
+		dapl_os_memcpy(&xevent.remote_ah.ia_addr,
+			       &cm_ptr->dst.ia_address,
+			       sizeof(cm_ptr->dst.ia_address));
+
+		dapls_evd_post_connection_event_ext((DAPL_EVD *) ep_ptr->param.
+						    connect_evd_handle,
+						    DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED,
+						    (DAT_EP_HANDLE) ep_ptr,
+						    (DAT_COUNT) cm_ptr->dst.
+						    p_size,
+						    (DAT_PVOID *) cm_ptr->
+						    p_data,
+						    (DAT_PVOID *) & xevent);
+	} else
 #endif
-	dapl_evd_connection_callback(cm_ptr, 
-				     IB_CME_CONNECTED, 
-				     cm_ptr->p_data, 
-				     ep_ptr);	
+		dapl_evd_connection_callback(cm_ptr,
+					     IB_CME_CONNECTED,
+					     cm_ptr->p_data, ep_ptr);
 	return;
-bail:
+      bail:
 	/* close socket, free cm structure and post error event */
 	dapli_cm_destroy(cm_ptr);
-	dapls_ib_reinit_ep(ep_ptr); /* reset QP state */
+	dapls_ib_reinit_ep(ep_ptr);	/* reset QP state */
 	dapl_evd_connection_callback(NULL, event, NULL, ep_ptr);
 }
 
 /*
  * PASSIVE: Create socket, listen, accept, exchange QP information 
  */
-DAT_RETURN 
-dapli_socket_listen(DAPL_IA		*ia_ptr,
-		    DAT_CONN_QUAL	serviceID,
-		    DAPL_SP		*sp_ptr )
+DAT_RETURN
+dapli_socket_listen(DAPL_IA * ia_ptr, DAT_CONN_QUAL serviceID, DAPL_SP * sp_ptr)
 {
-	struct sockaddr_in	addr;
-	ib_cm_srvc_handle_t	cm_ptr = NULL;
-	int			opt = 1;
-	DAT_RETURN		dat_status = DAT_SUCCESS;
+	struct sockaddr_in addr;
+	ib_cm_srvc_handle_t cm_ptr = NULL;
+	int opt = 1;
+	DAT_RETURN dat_status = DAT_SUCCESS;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " listen(ia_ptr %p ServiceID %d sp_ptr %p)\n",
@@ -562,33 +693,34 @@
 
 	cm_ptr->sp = sp_ptr;
 	cm_ptr->hca = ia_ptr->hca_ptr;
-	
+
 	/* bind, listen, set sockopt, accept, exchange data */
-	if ((cm_ptr->socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " ERR: listen socket create: %s\n", 
+	if ((cm_ptr->socket =
+	     socket(AF_INET, SOCK_STREAM, 0)) == DAPL_INVALID_SOCKET) {
+		dapl_log(DAPL_DBG_TYPE_ERR, " ERR: listen socket create: %s\n",
 			 strerror(errno));
 		dat_status = DAT_INSUFFICIENT_RESOURCES;
 		goto bail;
 	}
 
-	setsockopt(cm_ptr->socket,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));
-	addr.sin_port        = htons(serviceID);
-	addr.sin_family      = AF_INET;
+	setsockopt(cm_ptr->socket, SOL_SOCKET, SO_REUSEADDR,
+		   (char *)&opt, sizeof(opt));
+	addr.sin_port = htons(serviceID);
+	addr.sin_family = AF_INET;
 	addr.sin_addr.s_addr = INADDR_ANY;
 
-	if ((bind(cm_ptr->socket,(struct sockaddr*)&addr, sizeof(addr)) < 0) ||
-	    (listen(cm_ptr->socket, 128) < 0)) {
+	if ((bind(cm_ptr->socket, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+	    || (listen(cm_ptr->socket, 128) < 0)) {
 		dapl_dbg_log(DAPL_DBG_TYPE_CM,
 			     " listen: ERROR %s on conn_qual 0x%x\n",
-			     strerror(errno),serviceID); 
+			     strerror(errno), serviceID);
 		if (errno == EADDRINUSE)
 			dat_status = DAT_CONN_QUAL_IN_USE;
 		else
 			dat_status = DAT_CONN_QUAL_UNAVAILABLE;
 		goto bail;
 	}
-	
+
 	/* set cm_handle for this service point, save listen socket */
 	sp_ptr->cm_srvc_handle = cm_ptr;
 
@@ -598,12 +730,12 @@
 
 	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " listen: qual 0x%x cr %p s_fd %d\n",
-		     ntohs(serviceID), cm_ptr, cm_ptr->socket ); 
+		     ntohs(serviceID), cm_ptr, cm_ptr->socket);
 
 	return dat_status;
-bail:
-	dapl_dbg_log( DAPL_DBG_TYPE_CM,
-			" listen: ERROR on conn_qual 0x%x\n",serviceID); 
+      bail:
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " listen: ERROR on conn_qual 0x%x\n", serviceID);
 	dapli_cm_destroy(cm_ptr);
 	return dat_status;
 }
@@ -611,65 +743,59 @@
 /*
  * PASSIVE: accept socket 
  */
-void 
-dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
+static void dapli_socket_accept(ib_cm_srvc_handle_t cm_ptr)
 {
-	dp_ib_cm_handle_t	acm_ptr;
-	int		len;
-		
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," socket_accept\n"); 
+	dp_ib_cm_handle_t acm_ptr;
+	int len;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " socket_accept\n");
+
 	/* Allocate accept CM and initialize */
-	if ((acm_ptr = dapl_os_alloc(sizeof(*acm_ptr))) == NULL) 
-		goto bail;
+	if ((acm_ptr = dapli_cm_create()) == NULL)
+		return;
 
-	(void) dapl_os_memzero(acm_ptr, sizeof(*acm_ptr));
-	
-	acm_ptr->socket = -1;
 	acm_ptr->sp = cm_ptr->sp;
 	acm_ptr->hca = cm_ptr->hca;
 
 	len = sizeof(acm_ptr->dst.ia_address);
-	acm_ptr->socket = accept(cm_ptr->socket, 
-				(struct sockaddr*)&acm_ptr->dst.ia_address, 
-				(socklen_t*)&len);
-	if (acm_ptr->socket < 0) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			" accept: ERR %s on FD %d l_cr %p\n",
-			strerror(errno),cm_ptr->socket,cm_ptr); 
+	acm_ptr->socket = accept(cm_ptr->socket,
+				 (struct sockaddr *)&acm_ptr->dst.ia_address,
+				 (socklen_t *) & len);
+	if (acm_ptr->socket == DAPL_INVALID_SOCKET) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " accept: ERR %s on FD %d l_cr %p\n",
+			 strerror(errno), cm_ptr->socket, cm_ptr);
 		goto bail;
-   	}
+	}
 
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " socket accepted, queue new cm %p\n",acm_ptr); 
+		     " socket accepted, queue new cm %p\n", acm_ptr);
 
 	acm_ptr->state = SCM_ACCEPTING;
 	dapli_cm_queue(acm_ptr);
 	return;
-bail:
+      bail:
 	/* close socket, free cm structure, active will see socket close as reject */
-	if (acm_ptr)
-		dapli_cm_destroy(acm_ptr);
+	dapli_cm_destroy(acm_ptr);
 }
 
 /*
  * PASSIVE: receive peer QP information, private data, post cr_event 
  */
-void 
-dapli_socket_accept_data(ib_cm_srvc_handle_t acm_ptr)
+static void dapli_socket_accept_data(ib_cm_srvc_handle_t acm_ptr)
 {
 	int len;
 	void *p_data = NULL;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," socket accepted, read QP data\n"); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " socket accepted, read QP data\n");
 
 	/* read in DST QP info, IA address. check for private data */
-	len = read(acm_ptr->socket, &acm_ptr->dst, sizeof(ib_qp_cm_t));
-	if (len != sizeof(ib_qp_cm_t) || 
-	    ntohs(acm_ptr->dst.ver) != DSCM_VER) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			     " accept read: ERR %s, rcnt=%d, ver=%d\n",
-			     strerror(errno), len, acm_ptr->dst.ver); 
+	len =
+	    recv(acm_ptr->socket, (char *)&acm_ptr->dst, sizeof(ib_qp_cm_t), 0);
+	if (len != sizeof(ib_qp_cm_t) || ntohs(acm_ptr->dst.ver) != DSCM_VER) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " accept read: ERR %s, rcnt=%d, ver=%d\n",
+			 strerror(errno), len, ntohs(acm_ptr->dst.ver));
 		goto bail;
 	}
 
@@ -682,36 +808,37 @@
 #endif
 	acm_ptr->dst.p_size = ntohl(acm_ptr->dst.p_size);
 
-	dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " accept: DST %s port=0x%x lid=0x%x, qpn=0x%x, psize=%d\n",
-		     inet_ntoa(((struct sockaddr_in *)&acm_ptr->dst.ia_address)->sin_addr),
-		     acm_ptr->dst.port, acm_ptr->dst.lid, 
-		     acm_ptr->dst.qpn, acm_ptr->dst.p_size); 
+		     inet_ntoa(((struct sockaddr_in *)&acm_ptr->dst.
+				ia_address)->sin_addr), acm_ptr->dst.port,
+		     acm_ptr->dst.lid, acm_ptr->dst.qpn, acm_ptr->dst.p_size);
 
 	/* validate private data size before reading */
 	if (acm_ptr->dst.p_size > IB_MAX_REQ_PDATA_SIZE) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
 			     " accept read: psize (%d) wrong\n",
-			     acm_ptr->dst.p_size); 
+			     acm_ptr->dst.p_size);
 		goto bail;
 	}
 
-	dapl_dbg_log(DAPL_DBG_TYPE_EP," socket accepted, read private data\n"); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " socket accepted, read private data\n");
 
 	/* read private data into cm_handle if any present */
 	if (acm_ptr->dst.p_size) {
-		len = read( acm_ptr->socket, 
-			    acm_ptr->p_data, acm_ptr->dst.p_size);
+		len =
+		    recv(acm_ptr->socket, acm_ptr->p_data, acm_ptr->dst.p_size,
+			 0);
 		if (len != acm_ptr->dst.p_size) {
-			dapl_log(DAPL_DBG_TYPE_ERR, 
-				     " accept read pdata: ERR %s, rcnt=%d\n",
-				     strerror(errno), len); 
+			dapl_log(DAPL_DBG_TYPE_ERR,
+				 " accept read pdata: ERR %s, rcnt=%d\n",
+				 strerror(errno), len);
 			goto bail;
 		}
-		dapl_dbg_log(DAPL_DBG_TYPE_EP," accept: psize=%d read\n",len);
+		dapl_dbg_log(DAPL_DBG_TYPE_EP, " accept: psize=%d read\n", len);
 		p_data = acm_ptr->p_data;
 	}
-	
+
 	acm_ptr->state = SCM_ACCEPTING_DATA;
 
 #ifdef DAT_EXTENSIONS
@@ -721,23 +848,21 @@
 		/* post EVENT, modify_qp created ah */
 		xevent.status = 0;
 		xevent.type = DAT_IB_UD_CONNECT_REQUEST;
-		
-		dapls_evd_post_cr_event_ext(
-			acm_ptr->sp,
-			DAT_IB_UD_CONNECTION_REQUEST_EVENT,
-			acm_ptr,
-			(DAT_COUNT)acm_ptr->dst.p_size,
-			(DAT_PVOID*)acm_ptr->p_data,
-			(DAT_PVOID*)&xevent);
-    	} else 
+
+		dapls_evd_post_cr_event_ext(acm_ptr->sp,
+					    DAT_IB_UD_CONNECTION_REQUEST_EVENT,
+					    acm_ptr,
+					    (DAT_COUNT) acm_ptr->dst.p_size,
+					    (DAT_PVOID *) acm_ptr->p_data,
+					    (DAT_PVOID *) & xevent);
+	} else
 #endif
-	/* trigger CR event and return SUCCESS */
-	dapls_cr_callback(acm_ptr,
-			  IB_CME_CONNECTION_REQUEST_PENDING,
-		          p_data,
-			  acm_ptr->sp );
+		/* trigger CR event and return SUCCESS */
+		dapls_cr_callback(acm_ptr,
+				  IB_CME_CONNECTION_REQUEST_PENDING,
+				  p_data, acm_ptr->sp);
 	return;
-bail:
+      bail:
 	/* close socket, free cm structure, active will see socket close as reject */
 	dapli_cm_destroy(acm_ptr);
 	return;
@@ -748,70 +873,67 @@
  * queue on work thread to receive RTU information to avoid blocking
  * user thread. 
  */
-DAT_RETURN 
-dapli_socket_accept_usr(DAPL_EP		*ep_ptr,
-			DAPL_CR		*cr_ptr,
-			DAT_COUNT	p_size,
-			DAT_PVOID	p_data)
+DAT_RETURN
+dapli_socket_accept_usr(DAPL_EP * ep_ptr,
+			DAPL_CR * cr_ptr, DAT_COUNT p_size, DAT_PVOID p_data)
 {
-	DAPL_IA		*ia_ptr = ep_ptr->header.owner_ia;
-	dp_ib_cm_handle_t  cm_ptr = cr_ptr->ib_cm_handle;
-	ib_qp_cm_t	local;
-	struct iovec    iovec[2];
-	int		len;
+	DAPL_IA *ia_ptr = ep_ptr->header.owner_ia;
+	dp_ib_cm_handle_t cm_ptr = cr_ptr->ib_cm_handle;
+	ib_qp_cm_t local;
+	struct iovec iov[2];
+	int len;
 
-	if (p_size > IB_MAX_REP_PDATA_SIZE) 
+	if (p_size > IB_MAX_REP_PDATA_SIZE)
 		return DAT_LENGTH_ERROR;
 
 	/* must have a accepted socket */
-	if (cm_ptr->socket < 0)
+	if (cm_ptr->socket == DAPL_INVALID_SOCKET)
 		return DAT_INTERNAL_ERROR;
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     " ACCEPT_USR: remote port=0x%x lid=0x%x"
 		     " qpn=0x%x qp_type %d, psize=%d\n",
 		     cm_ptr->dst.port, cm_ptr->dst.lid,
-		     cm_ptr->dst.qpn, cm_ptr->dst.qp_type,
-		     cm_ptr->dst.p_size); 
+		     cm_ptr->dst.qpn, cm_ptr->dst.qp_type, cm_ptr->dst.p_size);
 
 #ifdef DAT_EXTENSIONS
-	if (cm_ptr->dst.qp_type == IBV_QPT_UD && 
+	if (cm_ptr->dst.qp_type == IBV_QPT_UD &&
 	    ep_ptr->qp_handle->qp_type != IBV_QPT_UD) {
-		    dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-				 " ACCEPT_USR: ERR remote QP is UD,"
-				 ", but local QP is not\n"); 
-		    return (DAT_INVALID_HANDLE | DAT_INVALID_HANDLE_EP);
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     " ACCEPT_USR: ERR remote QP is UD,"
+			     ", but local QP is not\n");
+		return (DAT_INVALID_HANDLE | DAT_INVALID_HANDLE_EP);
 	}
 #endif
 
 	/* modify QP to RTR and then to RTS with remote info already read */
 	dapl_os_lock(&ep_ptr->header.lock);
-	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
+	if (dapls_modify_qp_state(ep_ptr->qp_handle,
 				  IBV_QPS_RTR, cm_ptr) != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " ACCEPT_USR: QPS_RTR ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)
-				&cm_ptr->dst.ia_address)->sin_addr)); 
+			 strerror(errno), inet_ntoa(((struct sockaddr_in *)
+						     &cm_ptr->dst.ia_address)->
+						    sin_addr));
 		dapl_os_unlock(&ep_ptr->header.lock);
 		goto bail;
 	}
-	if (dapls_modify_qp_state(ep_ptr->qp_handle, 
+	if (dapls_modify_qp_state(ep_ptr->qp_handle,
 				  IBV_QPS_RTS, cm_ptr) != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " ACCEPT_USR: QPS_RTS ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)
-				&cm_ptr->dst.ia_address)->sin_addr)); 
+			 strerror(errno), inet_ntoa(((struct sockaddr_in *)
+						     &cm_ptr->dst.ia_address)->
+						    sin_addr));
 		dapl_os_unlock(&ep_ptr->header.lock);
 		goto bail;
 	}
 	dapl_os_unlock(&ep_ptr->header.lock);
 
 	/* save remote address information */
-	dapl_os_memcpy( &ep_ptr->remote_ia_address, 
-			&cm_ptr->dst.ia_address, 
-			sizeof(ep_ptr->remote_ia_address));
+	dapl_os_memcpy(&ep_ptr->remote_ia_address,
+		       &cm_ptr->dst.ia_address,
+		       sizeof(ep_ptr->remote_ia_address));
 
 	/* send our QP info, IA address, pdata. Don't overwrite dst data */
 	local.ver = htons(DSCM_VER);
@@ -819,88 +941,71 @@
 	local.qpn = htonl(ep_ptr->qp_handle->qp_num);
 	local.qp_type = htons(ep_ptr->qp_handle->qp_type);
 	local.port = htons(ia_ptr->hca_ptr->port_num);
-	local.lid = htons(dapli_get_lid(ia_ptr->hca_ptr->ib_hca_handle, 
-				        (uint8_t)ia_ptr->hca_ptr->port_num));
-	if (local.lid == 0xffff) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " ACCEPT_USR: query LID ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)
-				&cm_ptr->dst.ia_address)->sin_addr)); 
-		goto bail;
-	}
-
-        /* in network order */
-	if (ibv_query_gid(ia_ptr->hca_ptr->ib_hca_handle,
-			  (uint8_t)ia_ptr->hca_ptr->port_num,
-			  0, &local.gid)) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " ACCEPT_USR: query GID ERR %s -> %s\n",
-			 strerror(errno), 
-			 inet_ntoa(((struct sockaddr_in *)
-				&cm_ptr->dst.ia_address)->sin_addr)); 
-		goto bail;
-	}
-
+	local.lid = ia_ptr->hca_ptr->ib_trans.lid;
+	local.gid = ia_ptr->hca_ptr->ib_trans.gid;
 	local.ia_address = ia_ptr->hca_ptr->hca_address;
 	local.p_size = htonl(p_size);
-	iovec[0].iov_base = &local;
-	iovec[0].iov_len  = sizeof(ib_qp_cm_t);
+	iov[0].iov_base = (void *)&local;
+	iov[0].iov_len = sizeof(ib_qp_cm_t);
 	if (p_size) {
-		iovec[1].iov_base = p_data;
-		iovec[1].iov_len  = p_size;
+		iov[1].iov_base = p_data;
+		iov[1].iov_len = p_size;
+		len = writev(cm_ptr->socket, iov, 2);
+	} else {
+		len = writev(cm_ptr->socket, iov, 1);
 	}
-	len = writev(cm_ptr->socket, iovec, (p_size ? 2:1));
-    	if (len != (p_size + sizeof(ib_qp_cm_t))) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+
+	if (len != (p_size + sizeof(ib_qp_cm_t))) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " ACCEPT_USR: ERR %s, wcnt=%d -> %s\n",
-			 strerror(errno), len,
-			 inet_ntoa(((struct sockaddr_in *)
-			     &cm_ptr->dst.ia_address)->sin_addr)); 
+			 strerror(errno), len, inet_ntoa(((struct sockaddr_in *)
+							  &cm_ptr->dst.
+							  ia_address)->
+							 sin_addr));
 		goto bail;
 	}
-	dapl_dbg_log(DAPL_DBG_TYPE_CM, 
+
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
 		     " ACCEPT_USR: local port=0x%x lid=0x%x"
 		     " qpn=0x%x psize=%d\n",
-		     ntohs(local.port), ntohs(local.lid), 
-		     ntohl(local.qpn), ntohl(local.p_size)); 
-        dapl_dbg_log(DAPL_DBG_TYPE_CM,
-                     " ACCEPT_USR SRC GID subnet %016llx id %016llx\n",
-                     (unsigned long long) 
-			cpu_to_be64(local.gid.global.subnet_prefix),
-                     (unsigned long long) 
-			cpu_to_be64(local.gid.global.interface_id));
+		     ntohs(local.port), ntohs(local.lid),
+		     ntohl(local.qpn), ntohl(local.p_size));
+	dapl_dbg_log(DAPL_DBG_TYPE_CM,
+		     " ACCEPT_USR SRC GID subnet %016llx id %016llx\n",
+		     (unsigned long long)
+		     htonll(local.gid.global.subnet_prefix),
+		     (unsigned long long)
+		     htonll(local.gid.global.interface_id));
 
 	/* save state and reference to EP, queue for RTU data */
 	cm_ptr->ep = ep_ptr;
 	cm_ptr->hca = ia_ptr->hca_ptr;
 	cm_ptr->state = SCM_ACCEPTED;
 
-	dapl_dbg_log( DAPL_DBG_TYPE_EP," PASSIVE: accepted!\n" ); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " PASSIVE: accepted!\n");
 	return DAT_SUCCESS;
-bail:
+      bail:
 	dapli_cm_destroy(cm_ptr);
-	dapls_ib_reinit_ep(ep_ptr); /* reset QP state */
+	dapls_ib_reinit_ep(ep_ptr);	/* reset QP state */
 	return DAT_INTERNAL_ERROR;
 }
 
 /*
  * PASSIVE: read RTU from active peer, post CONN event
  */
-void 
-dapli_socket_accept_rtu(dp_ib_cm_handle_t	cm_ptr)
+void dapli_socket_accept_rtu(dp_ib_cm_handle_t cm_ptr)
 {
-	int		len;
-	short		rtu_data = 0;
+	int len;
+	short rtu_data = 0;
 
 	/* complete handshake after final QP state change */
-	len = read(cm_ptr->socket, &rtu_data, sizeof(rtu_data));
+	len = recv(cm_ptr->socket, (char *)&rtu_data, sizeof(rtu_data), 0);
 	if (len != sizeof(rtu_data) || ntohs(rtu_data) != 0x0e0f) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " ACCEPT_RTU: ERR %s, rcnt=%d rdata=%x\n",
 			 strerror(errno), len, ntohs(rtu_data),
 			 inet_ntoa(((struct sockaddr_in *)
-				&cm_ptr->dst.ia_address)->sin_addr)); 
+				    &cm_ptr->dst.ia_address)->sin_addr));
 		goto bail;
 	}
 
@@ -908,7 +1013,7 @@
 	cm_ptr->state = SCM_CONNECTED;
 
 	/* final data exchange if remote QP state is good to go */
-	dapl_dbg_log( DAPL_DBG_TYPE_EP," PASSIVE: connected!\n" ); 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " PASSIVE: connected!\n");
 
 #ifdef DAT_EXTENSIONS
 	if (cm_ptr->dst.qp_type == IBV_QPT_UD) {
@@ -919,28 +1024,29 @@
 		xevent.type = DAT_IB_UD_PASSIVE_REMOTE_AH;
 		xevent.remote_ah.ah = cm_ptr->ah;
 		xevent.remote_ah.qpn = cm_ptr->dst.qpn;
-		dapl_os_memcpy( &xevent.remote_ah.ia_addr,
-				&cm_ptr->dst.ia_address, 
-				sizeof(cm_ptr->dst.ia_address));
-	
-		dapls_evd_post_connection_event_ext(
-			(DAPL_EVD*)cm_ptr->ep->param.connect_evd_handle,
-			DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED,
-			(DAT_EP_HANDLE)cm_ptr->ep,
-			(DAT_COUNT)cm_ptr->dst.p_size,
-			(DAT_PVOID*)cm_ptr->p_data,
-			(DAT_PVOID*)&xevent);
-    	} else 
+		dapl_os_memcpy(&xevent.remote_ah.ia_addr,
+			       &cm_ptr->dst.ia_address,
+			       sizeof(cm_ptr->dst.ia_address));
+
+		dapls_evd_post_connection_event_ext((DAPL_EVD *) cm_ptr->ep->
+						    param.connect_evd_handle,
+						    DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED,
+						    (DAT_EP_HANDLE) cm_ptr->ep,
+						    (DAT_COUNT) cm_ptr->dst.
+						    p_size,
+						    (DAT_PVOID *) cm_ptr->
+						    p_data,
+						    (DAT_PVOID *) & xevent);
+	} else
 #endif
-	dapls_cr_callback(cm_ptr, IB_CME_CONNECTED, NULL, cm_ptr->sp);
+		dapls_cr_callback(cm_ptr, IB_CME_CONNECTED, NULL, cm_ptr->sp);
 	return;
-bail:
-	dapls_ib_reinit_ep(cm_ptr->ep); /* reset QP state */
+      bail:
+	dapls_ib_reinit_ep(cm_ptr->ep);	/* reset QP state */
 	dapli_cm_destroy(cm_ptr);
 	dapls_cr_callback(cm_ptr, IB_CME_DESTINATION_REJECT, NULL, cm_ptr->sp);
 }
 
-
 /*
  * dapls_ib_connect
  *
@@ -963,23 +1069,21 @@
  *
  */
 DAT_RETURN
-dapls_ib_connect (
-	IN  DAT_EP_HANDLE		ep_handle,
-	IN  DAT_IA_ADDRESS_PTR		remote_ia_address,
-	IN  DAT_CONN_QUAL		remote_conn_qual,
-	IN  DAT_COUNT			private_data_size,
-	IN  void			*private_data )
+dapls_ib_connect(IN DAT_EP_HANDLE ep_handle,
+		 IN DAT_IA_ADDRESS_PTR remote_ia_address,
+		 IN DAT_CONN_QUAL remote_conn_qual,
+		 IN DAT_COUNT private_data_size, IN void *private_data)
 {
-	DAPL_EP		*ep_ptr;
-	ib_qp_handle_t	qp_ptr;
-	
-	dapl_dbg_log ( DAPL_DBG_TYPE_EP,
-			" connect(ep_handle %p ....)\n", ep_handle);
+	DAPL_EP *ep_ptr;
+	ib_qp_handle_t qp_ptr;
 
-	ep_ptr = (DAPL_EP*)ep_handle;
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     " connect(ep_handle %p ....)\n", ep_handle);
+
+	ep_ptr = (DAPL_EP *) ep_handle;
 	qp_ptr = ep_ptr->qp_handle;
 
-	return (dapli_socket_connect(ep_ptr, remote_ia_address, 
+	return (dapli_socket_connect(ep_ptr, remote_ia_address,
 				     remote_conn_qual,
 				     private_data_size, private_data));
 }
@@ -1000,13 +1104,10 @@
  * 	DAT_SUCCESS
  */
 DAT_RETURN
-dapls_ib_disconnect(
-	IN	DAPL_EP			*ep_ptr,
-	IN	DAT_CLOSE_FLAGS		close_flags)
+dapls_ib_disconnect(IN DAPL_EP * ep_ptr, IN DAT_CLOSE_FLAGS close_flags)
 {
-	dapl_dbg_log (DAPL_DBG_TYPE_EP,
-			"dapls_ib_disconnect(ep_handle %p ....)\n",
-			ep_ptr);
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     "dapls_ib_disconnect(ep_handle %p ....)\n", ep_ptr);
 
 	/* reinit to modify QP state */
 	dapls_ib_reinit_ep(ep_ptr);
@@ -1015,7 +1116,7 @@
 	    ep_ptr->param.ep_state == DAT_EP_STATE_DISCONNECTED)
 		return DAT_SUCCESS;
 	else
-		return(dapli_socket_disconnect(ep_ptr->cm_handle));
+		return (dapli_socket_disconnect(ep_ptr->cm_handle));
 }
 
 /*
@@ -1037,10 +1138,9 @@
  *
  */
 void
-dapls_ib_disconnect_clean (
-	IN  DAPL_EP			*ep_ptr,
-	IN  DAT_BOOLEAN			active,
-	IN  const ib_cm_events_t	ib_cm_event )
+dapls_ib_disconnect_clean(IN DAPL_EP * ep_ptr,
+			  IN DAT_BOOLEAN active,
+			  IN const ib_cm_events_t ib_cm_event)
 {
 	if (ep_ptr->cm_handle)
 		dapli_cm_destroy(ep_ptr->cm_handle);
@@ -1069,15 +1169,12 @@
  *
  */
 DAT_RETURN
-dapls_ib_setup_conn_listener (
-	IN  DAPL_IA		*ia_ptr,
-	IN  DAT_UINT64		ServiceID,
-	IN  DAPL_SP		*sp_ptr )
+dapls_ib_setup_conn_listener(IN DAPL_IA * ia_ptr,
+			     IN DAT_UINT64 ServiceID, IN DAPL_SP * sp_ptr)
 {
-	return (dapli_socket_listen( ia_ptr, ServiceID, sp_ptr ));
+	return (dapli_socket_listen(ia_ptr, ServiceID, sp_ptr));
 }
 
-
 /*
  * dapl_ib_remove_conn_listener
  *
@@ -1096,29 +1193,27 @@
  *
  */
 DAT_RETURN
-dapls_ib_remove_conn_listener (
-	IN  DAPL_IA		*ia_ptr,
-	IN  DAPL_SP		*sp_ptr )
+dapls_ib_remove_conn_listener(IN DAPL_IA * ia_ptr, IN DAPL_SP * sp_ptr)
 {
-	ib_cm_srvc_handle_t	cm_ptr = sp_ptr->cm_srvc_handle;
+	ib_cm_srvc_handle_t cm_ptr = sp_ptr->cm_srvc_handle;
 
-	dapl_dbg_log (DAPL_DBG_TYPE_EP,
-			"dapls_ib_remove_conn_listener(ia_ptr %p sp_ptr %p cm_ptr %p)\n",
-			ia_ptr, sp_ptr, cm_ptr );
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     "dapls_ib_remove_conn_listener(ia_ptr %p sp_ptr %p cm_ptr %p)\n",
+		     ia_ptr, sp_ptr, cm_ptr);
 
 	/* close accepted socket, free cm_srvc_handle and return */
 	if (cm_ptr != NULL) {
-		if (cm_ptr->socket >= 0) {
-			close(cm_ptr->socket );
-			cm_ptr->socket = -1;
+		if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+			closesocket(cm_ptr->socket);
+			cm_ptr->socket = DAPL_INVALID_SOCKET;
 		}
-	    	/* cr_thread will free */
+		/* cr_thread will free */
 		cm_ptr->state = SCM_DESTROY;
 		sp_ptr->cm_srvc_handle = NULL;
-		if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
-			dapl_log(DAPL_DBG_TYPE_CM, 
-				 " cm_destroy: thread wakeup error = %s\n", 
-				strerror(errno));
+		if (send(g_scm[1], "w", sizeof "w", 0) == -1)
+			dapl_log(DAPL_DBG_TYPE_CM,
+				 " cm_destroy: thread wakeup error = %s\n",
+				 strerror(errno));
 	}
 	return DAT_SUCCESS;
 }
@@ -1144,34 +1239,31 @@
  *
  */
 DAT_RETURN
-dapls_ib_accept_connection (
-	IN  DAT_CR_HANDLE	cr_handle,
-	IN  DAT_EP_HANDLE	ep_handle,
-	IN  DAT_COUNT		p_size,
-	IN  const DAT_PVOID	p_data )
+dapls_ib_accept_connection(IN DAT_CR_HANDLE cr_handle,
+			   IN DAT_EP_HANDLE ep_handle,
+			   IN DAT_COUNT p_size, IN const DAT_PVOID p_data)
 {
-	DAPL_CR			*cr_ptr;
-	DAPL_EP			*ep_ptr;
-	
+	DAPL_CR *cr_ptr;
+	DAPL_EP *ep_ptr;
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
 		     "dapls_ib_accept_connection(cr %p ep %p prd %p,%d)\n",
-		     cr_handle, ep_handle, p_data, p_size  );
+		     cr_handle, ep_handle, p_data, p_size);
 
-	cr_ptr = (DAPL_CR *)cr_handle;
-	ep_ptr = (DAPL_EP *)ep_handle;
-	
+	cr_ptr = (DAPL_CR *) cr_handle;
+	ep_ptr = (DAPL_EP *) ep_handle;
+
 	/* allocate and attach a QP if necessary */
 	if (ep_ptr->qp_state == DAPL_QP_STATE_UNATTACHED) {
 		DAT_RETURN status;
-		status = dapls_ib_qp_alloc(ep_ptr->header.owner_ia, 
+		status = dapls_ib_qp_alloc(ep_ptr->header.owner_ia,
 					   ep_ptr, ep_ptr);
 		if (status != DAT_SUCCESS)
-    			return status;
+			return status;
 	}
-	return(dapli_socket_accept_usr(ep_ptr, cr_ptr, p_size, p_data));
+	return (dapli_socket_accept_usr(ep_ptr, cr_ptr, p_size, p_data));
 }
 
-
 /*
  * dapls_ib_reject_connection
  *
@@ -1189,40 +1281,40 @@
  *
  */
 DAT_RETURN
-dapls_ib_reject_connection(
-	IN dp_ib_cm_handle_t cm_ptr,
-	IN int reason,
-	IN DAT_COUNT psize,
-	IN const DAT_PVOID pdata)
+dapls_ib_reject_connection(IN dp_ib_cm_handle_t cm_ptr,
+			   IN int reason,
+			   IN DAT_COUNT psize, IN const DAT_PVOID pdata)
 {
-	struct iovec iovec[2];
+	struct iovec iov[2];
 
-	dapl_dbg_log (DAPL_DBG_TYPE_EP,
-		      " reject(cm %p reason %x, pdata %p, psize %d)\n",
-		      cm_ptr, reason, pdata, psize);
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     " reject(cm %p reason %x, pdata %p, psize %d)\n",
+		     cm_ptr, reason, pdata, psize);
 
 	/* write reject data to indicate reject */
-	if (cm_ptr->socket >= 0) {
-		cm_ptr->dst.rej = (uint16_t)reason;
+	if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+		cm_ptr->dst.rej = (uint16_t) reason;
 		cm_ptr->dst.rej = htons(cm_ptr->dst.rej);
-		iovec[0].iov_base = &cm_ptr->dst;
-		iovec[0].iov_len  = sizeof(ib_qp_cm_t);
+
+		iov[0].iov_base = (void *)&cm_ptr->dst;
+		iov[0].iov_len = sizeof(ib_qp_cm_t);
 		if (psize) {
-			iovec[1].iov_base = pdata;
-			iovec[2].iov_len = psize;
-			writev(cm_ptr->socket, &iovec[0], 2);
-		} else
-			writev(cm_ptr->socket, &iovec[0], 1);
+			iov[1].iov_base = pdata;
+			iov[1].iov_len = psize;
+			writev(cm_ptr->socket, iov, 2);
+		} else {
+			writev(cm_ptr->socket, iov, 1);
+		}
 
-		close(cm_ptr->socket);
-		cm_ptr->socket = -1;
+		closesocket(cm_ptr->socket);
+		cm_ptr->socket = DAPL_INVALID_SOCKET;
 	}
 
 	/* cr_thread will destroy CR */
 	cm_ptr->state = SCM_REJECTED;
-	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_CM, 
-			 " cm_destroy: thread wakeup error = %s\n", 
+	if (send(g_scm[1], "w", sizeof "w", 0) == -1)
+		dapl_log(DAPL_DBG_TYPE_CM,
+			 " cm_destroy: thread wakeup error = %s\n",
 			 strerror(errno));
 	return DAT_SUCCESS;
 }
@@ -1244,29 +1336,27 @@
  *
  */
 DAT_RETURN
-dapls_ib_cm_remote_addr (
-	IN      DAT_HANDLE	dat_handle,
-	OUT	DAT_SOCK_ADDR6	*remote_ia_address )
+dapls_ib_cm_remote_addr(IN DAT_HANDLE dat_handle,
+			OUT DAT_SOCK_ADDR6 * remote_ia_address)
 {
-	DAPL_HEADER	*header;
-	dp_ib_cm_handle_t	ib_cm_handle;
+	DAPL_HEADER *header;
+	dp_ib_cm_handle_t ib_cm_handle;
 
-	dapl_dbg_log (DAPL_DBG_TYPE_EP,
-		      "dapls_ib_cm_remote_addr(dat_handle %p, ....)\n",
-		      dat_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     "dapls_ib_cm_remote_addr(dat_handle %p, ....)\n",
+		     dat_handle);
 
-	header = (DAPL_HEADER *)dat_handle;
+	header = (DAPL_HEADER *) dat_handle;
 
-	if (header->magic == DAPL_MAGIC_EP) 
+	if (header->magic == DAPL_MAGIC_EP)
 		ib_cm_handle = ((DAPL_EP *) dat_handle)->cm_handle;
-	else if (header->magic == DAPL_MAGIC_CR) 
+	else if (header->magic == DAPL_MAGIC_CR)
 		ib_cm_handle = ((DAPL_CR *) dat_handle)->ib_cm_handle;
-	else 
+	else
 		return DAT_INVALID_HANDLE;
 
-	dapl_os_memcpy(	remote_ia_address, 
-			&ib_cm_handle->dst.ia_address, 
-			sizeof(DAT_SOCK_ADDR6) );
+	dapl_os_memcpy(remote_ia_address,
+		       &ib_cm_handle->dst.ia_address, sizeof(DAT_SOCK_ADDR6));
 
 	return DAT_SUCCESS;
 }
@@ -1292,45 +1382,43 @@
  * 	length of private data
  *
  */
-int dapls_ib_private_data_size( IN DAPL_PRIVATE *prd_ptr,
-				IN DAPL_PDATA_OP conn_op,
-				IN DAPL_HCA     *hca_ptr)
+int dapls_ib_private_data_size(IN DAPL_PRIVATE * prd_ptr,
+			       IN DAPL_PDATA_OP conn_op, IN DAPL_HCA * hca_ptr)
 {
-	int  size;
+	int size;
 
-	switch (conn_op)
-	{
-		case DAPL_PDATA_CONN_REQ:
+	switch (conn_op) {
+	case DAPL_PDATA_CONN_REQ:
 		{
 			size = IB_MAX_REQ_PDATA_SIZE;
 			break;
 		}
-		case DAPL_PDATA_CONN_REP:
+	case DAPL_PDATA_CONN_REP:
 		{
 			size = IB_MAX_REP_PDATA_SIZE;
 			break;
 		}
-		case DAPL_PDATA_CONN_REJ:
+	case DAPL_PDATA_CONN_REJ:
 		{
 			size = IB_MAX_REJ_PDATA_SIZE;
 			break;
 		}
-		case DAPL_PDATA_CONN_DREQ:
+	case DAPL_PDATA_CONN_DREQ:
 		{
 			size = IB_MAX_DREQ_PDATA_SIZE;
 			break;
 		}
-		case DAPL_PDATA_CONN_DREP:
+	case DAPL_PDATA_CONN_DREP:
 		{
 			size = IB_MAX_DREP_PDATA_SIZE;
 			break;
 		}
-		default:
+	default:
 		{
 			size = 0;
 		}
 
-	} /* end case */
+	}			/* end case */
 
 	return size;
 }
@@ -1340,35 +1428,39 @@
  */
 #define DAPL_IB_EVENT_CNT	11
 
-static struct ib_cm_event_map
-{
-	const ib_cm_events_t	ib_cm_event;
-	DAT_EVENT_NUMBER	dat_event_num;
-	} ib_cm_event_map[DAPL_IB_EVENT_CNT] = {
-	/* 00 */  { IB_CME_CONNECTED,	
-					DAT_CONNECTION_EVENT_ESTABLISHED}, 
-	/* 01 */  { IB_CME_DISCONNECTED,	
-					DAT_CONNECTION_EVENT_DISCONNECTED},
-	/* 02 */  { IB_CME_DISCONNECTED_ON_LINK_DOWN, 
-					DAT_CONNECTION_EVENT_DISCONNECTED},
-	/* 03 */  { IB_CME_CONNECTION_REQUEST_PENDING,	
-					DAT_CONNECTION_REQUEST_EVENT},
-	/* 04 */  { IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
-					DAT_CONNECTION_REQUEST_EVENT},
-	/* 05 */  { IB_CME_DESTINATION_REJECT,
-					DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
-	/* 06 */  { IB_CME_DESTINATION_REJECT_PRIVATE_DATA,		
-					DAT_CONNECTION_EVENT_PEER_REJECTED},
-	/* 07 */  { IB_CME_DESTINATION_UNREACHABLE,	
-					DAT_CONNECTION_EVENT_UNREACHABLE},
-	/* 08 */  { IB_CME_TOO_MANY_CONNECTION_REQUESTS,
-					DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
-	/* 09 */  { IB_CME_LOCAL_FAILURE,
-					DAT_CONNECTION_EVENT_BROKEN},
-	/* 10 */  { IB_CM_LOCAL_FAILURE,
-					DAT_CONNECTION_EVENT_BROKEN}
+static struct ib_cm_event_map {
+	const ib_cm_events_t ib_cm_event;
+	DAT_EVENT_NUMBER dat_event_num;
+} ib_cm_event_map[DAPL_IB_EVENT_CNT] = {
+	/* 00 */  {
+	IB_CME_CONNECTED, DAT_CONNECTION_EVENT_ESTABLISHED},
+	    /* 01 */  {
+	IB_CME_DISCONNECTED, DAT_CONNECTION_EVENT_DISCONNECTED},
+	    /* 02 */  {
+	IB_CME_DISCONNECTED_ON_LINK_DOWN,
+		    DAT_CONNECTION_EVENT_DISCONNECTED},
+	    /* 03 */  {
+	IB_CME_CONNECTION_REQUEST_PENDING, DAT_CONNECTION_REQUEST_EVENT},
+	    /* 04 */  {
+	IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA,
+		    DAT_CONNECTION_REQUEST_EVENT},
+	    /* 05 */  {
+	IB_CME_DESTINATION_REJECT,
+		    DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
+	    /* 06 */  {
+	IB_CME_DESTINATION_REJECT_PRIVATE_DATA,
+		    DAT_CONNECTION_EVENT_PEER_REJECTED},
+	    /* 07 */  {
+	IB_CME_DESTINATION_UNREACHABLE, DAT_CONNECTION_EVENT_UNREACHABLE},
+	    /* 08 */  {
+	IB_CME_TOO_MANY_CONNECTION_REQUESTS,
+		    DAT_CONNECTION_EVENT_NON_PEER_REJECTED},
+	    /* 09 */  {
+	IB_CME_LOCAL_FAILURE, DAT_CONNECTION_EVENT_BROKEN},
+	    /* 10 */  {
+	IB_CM_LOCAL_FAILURE, DAT_CONNECTION_EVENT_BROKEN}
 };
- 
+
 /*
  * dapls_ib_get_cm_event
  *
@@ -1384,13 +1476,12 @@
  * 	ib_cm_event of translated DAPL value
  */
 DAT_EVENT_NUMBER
-dapls_ib_get_dat_event (
-	IN    const ib_cm_events_t	ib_cm_event,
-	IN    DAT_BOOLEAN		active)
+dapls_ib_get_dat_event(IN const ib_cm_events_t ib_cm_event,
+		       IN DAT_BOOLEAN active)
 {
-	DAT_EVENT_NUMBER	dat_event_num;
-	int			i;
-	
+	DAT_EVENT_NUMBER dat_event_num;
+	int i;
+
 	active = active;
 
 	if (ib_cm_event > IB_CM_LOCAL_FAILURE)
@@ -1403,14 +1494,13 @@
 			break;
 		}
 	}
-	dapl_dbg_log (DAPL_DBG_TYPE_CALLBACK,
-		"dapls_ib_get_dat_event: event translate(%s) ib=0x%x dat=0x%x\n",
-		active ? "active" : "passive",  ib_cm_event, dat_event_num);
+	dapl_dbg_log(DAPL_DBG_TYPE_CALLBACK,
+		     "dapls_ib_get_dat_event: event translate(%s) ib=0x%x dat=0x%x\n",
+		     active ? "active" : "passive", ib_cm_event, dat_event_num);
 
 	return dat_event_num;
 }
 
-
 /*
  * dapls_ib_get_dat_event
  *
@@ -1426,156 +1516,166 @@
  * Returns:
  * 	DAT_EVENT_NUMBER of translated provider value
  */
-ib_cm_events_t
-dapls_ib_get_cm_event (
-	IN    DAT_EVENT_NUMBER		dat_event_num)
+ib_cm_events_t dapls_ib_get_cm_event(IN DAT_EVENT_NUMBER dat_event_num)
 {
-    ib_cm_events_t	ib_cm_event;
-    int			i;
+	ib_cm_events_t ib_cm_event;
+	int i;
 
-    ib_cm_event = 0;
-    for (i = 0; i < DAPL_IB_EVENT_CNT; i++) {
-	if ( dat_event_num == ib_cm_event_map[i].dat_event_num ) {
-		ib_cm_event = ib_cm_event_map[i].ib_cm_event;
-		break;
+	ib_cm_event = 0;
+	for (i = 0; i < DAPL_IB_EVENT_CNT; i++) {
+		if (dat_event_num == ib_cm_event_map[i].dat_event_num) {
+			ib_cm_event = ib_cm_event_map[i].ib_cm_event;
+			break;
+		}
 	}
-    }
-    return ib_cm_event;
+	return ib_cm_event;
 }
 
 /* outbound/inbound CR processing thread to avoid blocking applications */
-#define SCM_MAX_CONN 8192
-void cr_thread(void *arg) 
+void cr_thread(void *arg)
 {
-    struct dapl_hca	*hca_ptr = arg;
-    dp_ib_cm_handle_t	cr, next_cr;
-    int 		opt,ret,idx;
-    socklen_t		opt_len;
-    char		rbuf[2];
-    struct pollfd	ufds[SCM_MAX_CONN];
-     
-    dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cr_thread: ENTER hca %p\n",hca_ptr);
+	struct dapl_hca *hca_ptr = arg;
+	dp_ib_cm_handle_t cr, next_cr;
+	int opt, ret;
+	socklen_t opt_len;
+	char rbuf[2];
+	struct dapl_fd_set *set;
+	enum DAPL_FD_EVENTS event;
 
-    dapl_os_lock( &hca_ptr->ib_trans.lock );
-    hca_ptr->ib_trans.cr_state = IB_THREAD_RUN;
-    while (hca_ptr->ib_trans.cr_state == IB_THREAD_RUN) {
-	idx=0;
-	ufds[idx].fd = g_scm_pipe[0]; /* wakeup and process work */
-        ufds[idx].events = POLLIN;
-	ufds[idx].revents = 0;
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cr_thread: ENTER hca %p\n", hca_ptr);
+	set = dapl_alloc_fd_set();
+	if (!set)
+		goto out;
 
-	if (!dapl_llist_is_empty(&hca_ptr->ib_trans.list))
-            next_cr = dapl_llist_peek_head (&hca_ptr->ib_trans.list);
-	else
-	    next_cr = NULL;
+	dapl_os_lock(&hca_ptr->ib_trans.lock);
+	hca_ptr->ib_trans.cr_state = IB_THREAD_RUN;
 
-	while (next_cr) {
-	    cr = next_cr;
-	    if ((cr->socket == -1 && cr->state == SCM_DESTROY) ||
-		hca_ptr->ib_trans.cr_state != IB_THREAD_RUN) {
+	while (hca_ptr->ib_trans.cr_state == IB_THREAD_RUN) {
+		dapl_fd_zero(set);
+		dapl_fd_set(g_scm[0], set, DAPL_FD_READ);
 
-		dapl_dbg_log(DAPL_DBG_TYPE_CM," cr_thread: Free %p\n", cr);
-		next_cr = dapl_llist_next_entry(&hca_ptr->ib_trans.list,
-						(DAPL_LLIST_ENTRY*)&cr->entry );
-		dapl_llist_remove_entry(&hca_ptr->ib_trans.list, 
-					(DAPL_LLIST_ENTRY*)&cr->entry);
-		dapl_os_free(cr, sizeof(*cr));
-		continue;
-	    }
+		if (!dapl_llist_is_empty(&hca_ptr->ib_trans.list))
+			next_cr = dapl_llist_peek_head(&hca_ptr->ib_trans.list);
+		else
+			next_cr = NULL;
 
-	    if (idx==SCM_MAX_CONN-1) {
-		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
-			     "SCM ERR: cm_thread exceeded FD_SETSIZE %d\n",idx+1);
-		continue;
-	    }
-		
-	    /* Add to ufds for poll, check for immediate work */
-	    ufds[++idx].fd = cr->socket; /* add listen or cr */
-	    ufds[idx].revents = 0;
-	    if (cr->state == SCM_CONN_PENDING)
-	    	ufds[idx].events = POLLOUT;
-	    else
-		ufds[idx].events = POLLIN;
+		while (next_cr) {
+			cr = next_cr;
+			next_cr = dapl_llist_next_entry(&hca_ptr->ib_trans.list,
+							(DAPL_LLIST_ENTRY *) &
+							cr->entry);
+			if (cr->state == SCM_DESTROY
+			    || hca_ptr->ib_trans.cr_state != IB_THREAD_RUN) {
+				dapl_llist_remove_entry(&hca_ptr->ib_trans.list,
+							(DAPL_LLIST_ENTRY *) &
+							cr->entry);
+				dapl_os_free(cr, sizeof(*cr));
+				continue;
+			}
+			if (cr->socket == DAPL_INVALID_SOCKET)
+				continue;
 
-	    /* check socket for event, accept in or connect out */
-	    dapl_dbg_log(DAPL_DBG_TYPE_CM," poll cr=%p, fd=%d,%d\n", 
-				cr, cr->socket, ufds[idx].fd);
-	    dapl_os_unlock(&hca_ptr->ib_trans.lock);
-	    ret = poll(&ufds[idx],1,0);
-	    dapl_dbg_log(DAPL_DBG_TYPE_CM,
-			 " poll wakeup ret=%d cr->st=%d"
-			 " ev=0x%x fd=%d\n",
-			 ret,cr->state,ufds[idx].revents,ufds[idx].fd);
+			event = (cr->state == SCM_CONN_PENDING) ?
+			    DAPL_FD_WRITE : DAPL_FD_READ;
+			if (dapl_fd_set(cr->socket, set, event)) {
+				dapl_log(DAPL_DBG_TYPE_ERR,
+					 " cr_thread: DESTROY CR st=%d fd %d"
+					 " -> %s\n", cr->state, cr->socket,
+					 inet_ntoa(((struct sockaddr_in *)
+						    &cr->dst.ia_address)->
+						   sin_addr));
+				dapli_cm_destroy(cr);
+				continue;
+			}
 
-	    /* data on listen, qp exchange, and on disconnect request */
-	    if ((ret == 1) && ufds[idx].revents == POLLIN) {
-		if (cr->socket > 0) {
-			if (cr->state == SCM_LISTEN)
-				dapli_socket_accept(cr);
-			else if (cr->state == SCM_ACCEPTING)
-				dapli_socket_accept_data(cr);
-			else if (cr->state == SCM_ACCEPTED)
-				dapli_socket_accept_rtu(cr);
-			else if (cr->state == SCM_RTU_PENDING)
-				dapli_socket_connect_rtu(cr);
-			else if (cr->state == SCM_CONNECTED)
-				dapli_socket_disconnect(cr);
+			dapl_dbg_log(DAPL_DBG_TYPE_CM,
+				     " poll cr=%p, socket=%d\n", cr,
+				     cr->socket);
+			dapl_os_unlock(&hca_ptr->ib_trans.lock);
+
+			ret = dapl_poll(cr->socket, event);
+
+			dapl_dbg_log(DAPL_DBG_TYPE_CM,
+				     " poll ret=0x%x cr->state=%d socket=%d\n",
+				     ret, cr->state, cr->socket);
+
+			/* data on listen, qp exchange, and on disconnect request */
+			if (ret == DAPL_FD_READ) {
+				if (cr->socket != DAPL_INVALID_SOCKET) {
+					switch (cr->state) {
+					case SCM_LISTEN:
+						dapli_socket_accept(cr);
+						break;
+					case SCM_ACCEPTING:
+						dapli_socket_accept_data(cr);
+						break;
+					case SCM_ACCEPTED:
+						dapli_socket_accept_rtu(cr);
+						break;
+					case SCM_RTU_PENDING:
+						dapli_socket_connect_rtu(cr);
+						break;
+					case SCM_CONNECTED:
+						dapli_socket_disconnect(cr);
+						break;
+					default:
+						break;
+					}
+				}
+				/* connect socket is writable, check status */
+			} else if (ret == DAPL_FD_WRITE || ret == DAPL_FD_ERROR) {
+				if (cr->state == SCM_CONN_PENDING) {
+					opt = 0;
+					opt_len = sizeof(opt);
+					ret = getsockopt(cr->socket, SOL_SOCKET,
+							 SO_ERROR, (char *)&opt,
+							 &opt_len);
+					if (!ret)
+						dapli_socket_connected(cr, opt);
+					else
+						dapli_socket_connected(cr,
+								       errno);
+				} else {
+					dapl_log(DAPL_DBG_TYPE_CM,
+						 " CM poll ERR, wrong state(%d) -> %s SKIP\n",
+						 cr->state,
+						 inet_ntoa(((struct sockaddr_in
+							     *)&cr->dst.
+							    ia_address)->
+							   sin_addr));
+				}
+			} else if (ret != 0) {
+				dapl_log(DAPL_DBG_TYPE_CM,
+					 " CM poll warning %s, ret=%d st=%d -> %s\n",
+					 strerror(errno), ret, cr->state,
+					 inet_ntoa(((struct sockaddr_in *)
+						    &cr->dst.ia_address)->
+						   sin_addr));
+
+				/* POLLUP, NVAL, or poll error, issue event if connected */
+				if (cr->state == SCM_CONNECTED)
+					dapli_socket_disconnect(cr);
+			}
+
+			dapl_os_lock(&hca_ptr->ib_trans.lock);
 		}
-	    /* connect socket is writable, check status */
-	    } else if ((ret == 1) && 
-			(ufds[idx].revents & POLLOUT ||
-			 ufds[idx].revents & POLLERR)) {
-		if (cr->state == SCM_CONN_PENDING) {
-			opt = 0;
-			ret = getsockopt(cr->socket, SOL_SOCKET, 
-					 SO_ERROR, &opt, &opt_len);
-			if (!ret)
-				dapli_socket_connected(cr,opt);
-			else
-				dapli_socket_connected(cr,errno);
-		} else {
-			dapl_log(DAPL_DBG_TYPE_CM,
-				 " CM poll ERR, wrong state(%d) -> %s SKIP\n",
-				 cr->state,
-				 inet_ntoa(((struct sockaddr_in*)
-					&cr->dst.ia_address)->sin_addr));
+
+		dapl_os_unlock(&hca_ptr->ib_trans.lock);
+		dapl_select(set);
+
+		/* if pipe used to wakeup, consume */
+		while (dapl_poll(g_scm[0], DAPL_FD_READ) == DAPL_FD_READ) {
+			if (recv(g_scm[0], rbuf, 2, 0) == -1)
+				dapl_log(DAPL_DBG_TYPE_CM,
+					 " cr_thread: read pipe error = %s\n",
+					 strerror(errno));
 		}
-	    } else if (ret != 0) {
-		dapl_log(DAPL_DBG_TYPE_CM,
-			 " CM poll warning %s, ret=%d revnt=%x st=%d -> %s\n",
-			 strerror(errno), ret, ufds[idx].revents, cr->state,
-			 inet_ntoa(((struct sockaddr_in*)
-				&cr->dst.ia_address)->sin_addr));
+		dapl_os_lock(&hca_ptr->ib_trans.lock);
+	}
 
-		/* POLLUP, NVAL, or poll error, issue event if connected */
-		if (cr->state == SCM_CONNECTED)
-			dapli_socket_disconnect(cr);
-	    } 
-	    dapl_os_lock(&hca_ptr->ib_trans.lock);
-	    next_cr =  dapl_llist_next_entry(&hca_ptr->ib_trans.list,
-					     (DAPL_LLIST_ENTRY*)&cr->entry);
-	} 
 	dapl_os_unlock(&hca_ptr->ib_trans.lock);
-	dapl_dbg_log(DAPL_DBG_TYPE_CM," cr_thread: sleep, %d\n", idx+1);
-	poll(ufds,idx+1,-1); /* infinite, all sockets and pipe */
-	/* if pipe used to wakeup, consume */
-	if (ufds[0].revents == POLLIN)
-		if (read(g_scm_pipe[0], rbuf, 2) == -1)
-			dapl_log(DAPL_DBG_TYPE_CM,
-				 " cr_thread: read pipe error = %s\n",
-				 strerror(errno));
-	dapl_dbg_log(DAPL_DBG_TYPE_CM," cr_thread: wakeup\n");
-	dapl_os_lock(&hca_ptr->ib_trans.lock);
-    } 
-    dapl_os_unlock(&hca_ptr->ib_trans.lock);	
-    hca_ptr->ib_trans.cr_state = IB_THREAD_EXIT;
-    dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cr_thread(hca %p) exit\n",hca_ptr);
+	free(set);
+      out:
+	hca_ptr->ib_trans.cr_state = IB_THREAD_EXIT;
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cr_thread(hca %p) exit\n", hca_ptr);
 }
-
-/*
- * Local variables:
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 8
- * End:
- */

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cq.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cq.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_cq.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -46,97 +46,122 @@
  *
  **************************************************************************/
 
+#include "openib_osd.h"
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_lmr_util.h"
 #include "dapl_evd_util.h"
 #include "dapl_ring_buffer_util.h"
-#include <sys/poll.h>
-#include <signal.h>
 
-int dapli_cq_thread_init(struct dapl_hca *hca_ptr)
+#if defined(_WIN64) || defined(_WIN32)
+#include "..\..\..\..\..\etc\user\comp_channel.cpp"
+#include "..\..\..\..\..\etc\user\dlist.c"
+
+void dapli_cq_thread_destroy(struct dapl_hca *hca_ptr)
 {
-        DAT_RETURN dat_status;
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread_destroy(%p)\n", hca_ptr);
 
-        dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cq_thread_init(%p)\n", hca_ptr);
+	if (hca_ptr->ib_trans.cq_state != IB_THREAD_RUN)
+		return;
 
-        /* create thread to process inbound connect request */
-	hca_ptr->ib_trans.cq_state = IB_THREAD_INIT;
-        dat_status = dapl_os_thread_create(cq_thread, (void*)hca_ptr, &hca_ptr->ib_trans.cq_thread);
-        if (dat_status != DAT_SUCCESS)
-        {
-                dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-                             " cq_thread_init: failed to create thread\n");
-                return 1;
-        }
-	
-	/* wait for thread to start */
-	while (hca_ptr->ib_trans.cq_state != IB_THREAD_RUN) {
-                struct timespec sleep, remain;
-                sleep.tv_sec = 0;
-                sleep.tv_nsec = 20000000; /* 20 ms */
-                dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                             " cq_thread_init: waiting for cq_thread\n");
-                nanosleep (&sleep, &remain);
-        }
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cq_thread_init(%d) exit\n",getpid());
-        return 0;
+	/* destroy cr_thread and lock */
+	hca_ptr->ib_trans.cq_state = IB_THREAD_CANCEL;
+	CompChannelCancel(&hca_ptr->ib_trans.ib_cq->comp_channel);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " cq_thread_destroy(%p) cancel\n",
+		     hca_ptr);
+	while (hca_ptr->ib_trans.cq_state != IB_THREAD_EXIT) {
+		dapl_os_sleep_usec(20000);
+	}
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread_destroy(%d) exit\n",
+		     dapl_os_getpid());
 }
 
+static void cq_thread(void *arg)
+{
+	struct dapl_hca *hca_ptr = arg;
+	struct dapl_evd *evd_ptr;
+	struct ibv_cq *ibv_cq = NULL;
+
+	hca_ptr->ib_trans.cq_state = IB_THREAD_RUN;
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread: ENTER hca %p\n", hca_ptr);
+
+	/* wait on DTO event, or signal to abort */
+	while (hca_ptr->ib_trans.cq_state == IB_THREAD_RUN) {
+		if (!ibv_get_cq_event
+		    (hca_ptr->ib_trans.ib_cq, &ibv_cq, (void *)&evd_ptr)) {
+
+			if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD)) {
+				ibv_ack_cq_events(ibv_cq, 1);
+				return;
+			}
+
+			/* process DTO event via callback */
+			dapl_evd_dto_callback(hca_ptr->ib_hca_handle,
+					      evd_ptr->ib_cq_handle,
+					      (void *)evd_ptr);
+
+			ibv_ack_cq_events(ibv_cq, 1);
+		}
+	}
+	hca_ptr->ib_trans.cq_state = IB_THREAD_EXIT;
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread: EXIT: hca %p \n",
+		     hca_ptr);
+}
+
+#else				// _WIN32 || _WIN64
+
 void dapli_cq_thread_destroy(struct dapl_hca *hca_ptr)
 {
-        dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cq_thread_destroy(%p)\n", hca_ptr);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread_destroy(%p)\n", hca_ptr);
 
 	if (hca_ptr->ib_trans.cq_state != IB_THREAD_RUN)
 		return;
 
-        /* destroy cr_thread and lock */
-        hca_ptr->ib_trans.cq_state = IB_THREAD_CANCEL;
-        pthread_kill(hca_ptr->ib_trans.cq_thread, SIGUSR1);
-        dapl_dbg_log(DAPL_DBG_TYPE_CM," cq_thread_destroy(%p) cancel\n",hca_ptr);
-        while (hca_ptr->ib_trans.cq_state != IB_THREAD_EXIT) {
-                struct timespec sleep, remain;
-                sleep.tv_sec = 0;
-                sleep.tv_nsec = 2000000; /* 2 ms */
-                dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                             " cq_thread_destroy: waiting for cq_thread\n");
-                nanosleep (&sleep, &remain);
-        }
-        dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cq_thread_destroy(%d) exit\n",getpid());
+	/* destroy cr_thread and lock */
+	hca_ptr->ib_trans.cq_state = IB_THREAD_CANCEL;
+	pthread_kill(hca_ptr->ib_trans.cq_thread, SIGUSR1);
+	dapl_dbg_log(DAPL_DBG_TYPE_CM, " cq_thread_destroy(%p) cancel\n",
+		     hca_ptr);
+	while (hca_ptr->ib_trans.cq_state != IB_THREAD_EXIT) {
+		dapl_os_sleep_usec(20000);
+	}
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread_destroy(%d) exit\n",
+		     dapl_os_getpid());
 }
 
 /* catch the signal */
 static void ib_cq_handler(int signum)
 {
-        return;
+	return;
 }
 
-void cq_thread( void *arg )
+static void cq_thread(void *arg)
 {
-        struct dapl_hca *hca_ptr = arg;
-        struct dapl_evd *evd_ptr;
-        struct ibv_cq   *ibv_cq = NULL;
-	sigset_t	sigset;
+	struct dapl_hca *hca_ptr = arg;
+	struct dapl_evd *evd_ptr;
+	struct ibv_cq *ibv_cq = NULL;
+	sigset_t sigset;
 
 	sigemptyset(&sigset);
-        sigaddset(&sigset,SIGUSR1);
-        pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
-        signal(SIGUSR1, ib_cq_handler);
+	sigaddset(&sigset, SIGUSR1);
+	pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
+	signal(SIGUSR1, ib_cq_handler);
 
 	hca_ptr->ib_trans.cq_state = IB_THREAD_RUN;
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cq_thread: ENTER hca %p\n",hca_ptr);
-	
-        /* wait on DTO event, or signal to abort */
-        while (hca_ptr->ib_trans.cq_state == IB_THREAD_RUN) {
-                struct pollfd cq_fd = {
-                        .fd      = hca_ptr->ib_trans.ib_cq->fd,
-                        .events  = POLLIN,
-                        .revents = 0
-                };
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread: ENTER hca %p\n", hca_ptr);
+
+	/* wait on DTO event, or signal to abort */
+	while (hca_ptr->ib_trans.cq_state == IB_THREAD_RUN) {
+		struct pollfd cq_fd = {
+			.fd = hca_ptr->ib_trans.ib_cq->fd,
+			.events = POLLIN,
+			.revents = 0
+		};
 		if ((poll(&cq_fd, 1, -1) == 1) &&
-			(!ibv_get_cq_event(hca_ptr->ib_trans.ib_cq,  
-				   &ibv_cq, (void*)&evd_ptr))) {
+		    (!ibv_get_cq_event
+		     (hca_ptr->ib_trans.ib_cq, &ibv_cq, (void *)&evd_ptr))) {
 
 			if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD)) {
 				ibv_ack_cq_events(ibv_cq, 1);
@@ -144,51 +169,99 @@
 			}
 
 			/* process DTO event via callback */
-			dapl_evd_dto_callback ( hca_ptr->ib_hca_handle,
-						evd_ptr->ib_cq_handle,
-						(void*)evd_ptr );
+			dapl_evd_dto_callback(hca_ptr->ib_hca_handle,
+					      evd_ptr->ib_cq_handle,
+					      (void *)evd_ptr);
 
 			ibv_ack_cq_events(ibv_cq, 1);
-		} 
-        }
-        hca_ptr->ib_trans.cq_state = IB_THREAD_EXIT;
-        dapl_dbg_log(DAPL_DBG_TYPE_UTIL," cq_thread: EXIT: hca %p \n", hca_ptr);
+		}
+	}
+	hca_ptr->ib_trans.cq_state = IB_THREAD_EXIT;
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread: EXIT: hca %p \n",
+		     hca_ptr);
 }
 
+#endif				// _WIN32 || _WIN64
 
+int dapli_cq_thread_init(struct dapl_hca *hca_ptr)
+{
+	DAT_RETURN dat_status;
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread_init(%p)\n", hca_ptr);
+
+	/* create thread to process inbound connect request */
+	hca_ptr->ib_trans.cq_state = IB_THREAD_INIT;
+	dat_status =
+	    dapl_os_thread_create(cq_thread, (void *)hca_ptr,
+				  &hca_ptr->ib_trans.cq_thread);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     " cq_thread_init: failed to create thread\n");
+		return 1;
+	}
+
+	/* wait for thread to start */
+	while (hca_ptr->ib_trans.cq_state != IB_THREAD_RUN) {
+		dapl_os_sleep_usec(20000);
+	}
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " cq_thread_init(%d) exit\n",
+		     dapl_os_getpid());
+	return 0;
+}
+
 /*
  * Map all verbs DTO completion codes to the DAT equivelent.
  *
  * Not returned by verbs:     DAT_DTO_ERR_PARTIAL_PACKET
  */
-static struct ib_status_map
-{
-    int				ib_status;
-    DAT_DTO_COMPLETION_STATUS	dat_status;
+static struct ib_status_map {
+	int ib_status;
+	DAT_DTO_COMPLETION_STATUS dat_status;
 } ib_status_map[] = {
-	/* 00 */  { IBV_WC_SUCCESS,		DAT_DTO_SUCCESS},
-	/* 01 */  { IBV_WC_LOC_LEN_ERR,		DAT_DTO_ERR_LOCAL_LENGTH},
-	/* 02 */  { IBV_WC_LOC_QP_OP_ERR,	DAT_DTO_ERR_LOCAL_EP},
-	/* 03 */  { IBV_WC_LOC_EEC_OP_ERR,	DAT_DTO_ERR_TRANSPORT},
-	/* 04 */  { IBV_WC_LOC_PROT_ERR,	DAT_DTO_ERR_LOCAL_PROTECTION},
-	/* 05 */  { IBV_WC_WR_FLUSH_ERR,	DAT_DTO_ERR_FLUSHED},
-	/* 06 */  { IBV_WC_MW_BIND_ERR,		DAT_RMR_OPERATION_FAILED},
-	/* 07 */  { IBV_WC_BAD_RESP_ERR,	DAT_DTO_ERR_BAD_RESPONSE},
-	/* 08 */  { IBV_WC_LOC_ACCESS_ERR,	DAT_DTO_ERR_LOCAL_PROTECTION},
-	/* 09 */  { IBV_WC_REM_INV_REQ_ERR,	DAT_DTO_ERR_REMOTE_RESPONDER},
-	/* 10 */  { IBV_WC_REM_ACCESS_ERR,	DAT_DTO_ERR_REMOTE_ACCESS},
-	/* 11 */  { IBV_WC_REM_OP_ERR,		DAT_DTO_ERR_REMOTE_RESPONDER},
-	/* 12 */  { IBV_WC_RETRY_EXC_ERR,	DAT_DTO_ERR_TRANSPORT},
-	/* 13 */  { IBV_WC_RNR_RETRY_EXC_ERR,	DAT_DTO_ERR_RECEIVER_NOT_READY},
-	/* 14 */  { IBV_WC_LOC_RDD_VIOL_ERR,	DAT_DTO_ERR_LOCAL_PROTECTION},
-	/* 15 */  { IBV_WC_REM_INV_RD_REQ_ERR,	DAT_DTO_ERR_REMOTE_RESPONDER},
-	/* 16 */  { IBV_WC_REM_ABORT_ERR,	DAT_DTO_ERR_REMOTE_RESPONDER},
-	/* 17 */  { IBV_WC_INV_EECN_ERR,	DAT_DTO_ERR_TRANSPORT},
-	/* 18 */  { IBV_WC_INV_EEC_STATE_ERR,	DAT_DTO_ERR_TRANSPORT},
-	/* 19 */  { IBV_WC_FATAL_ERR,		DAT_DTO_ERR_TRANSPORT},
-	/* 20 */  { IBV_WC_RESP_TIMEOUT_ERR,	DAT_DTO_ERR_RECEIVER_NOT_READY},
-	/* 21 */  { IBV_WC_GENERAL_ERR,		DAT_DTO_ERR_TRANSPORT},
-};
+	/* 00 */  {
+	IBV_WC_SUCCESS, DAT_DTO_SUCCESS},
+	    /* 01 */  {
+	IBV_WC_LOC_LEN_ERR, DAT_DTO_ERR_LOCAL_LENGTH},
+	    /* 02 */  {
+	IBV_WC_LOC_QP_OP_ERR, DAT_DTO_ERR_LOCAL_EP},
+	    /* 03 */  {
+	IBV_WC_LOC_EEC_OP_ERR, DAT_DTO_ERR_TRANSPORT},
+	    /* 04 */  {
+	IBV_WC_LOC_PROT_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
+	    /* 05 */  {
+	IBV_WC_WR_FLUSH_ERR, DAT_DTO_ERR_FLUSHED},
+	    /* 06 */  {
+	IBV_WC_MW_BIND_ERR, DAT_RMR_OPERATION_FAILED},
+	    /* 07 */  {
+	IBV_WC_BAD_RESP_ERR, DAT_DTO_ERR_BAD_RESPONSE},
+	    /* 08 */  {
+	IBV_WC_LOC_ACCESS_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
+	    /* 09 */  {
+	IBV_WC_REM_INV_REQ_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+	    /* 10 */  {
+	IBV_WC_REM_ACCESS_ERR, DAT_DTO_ERR_REMOTE_ACCESS},
+	    /* 11 */  {
+	IBV_WC_REM_OP_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+	    /* 12 */  {
+	IBV_WC_RETRY_EXC_ERR, DAT_DTO_ERR_TRANSPORT},
+	    /* 13 */  {
+	IBV_WC_RNR_RETRY_EXC_ERR, DAT_DTO_ERR_RECEIVER_NOT_READY},
+	    /* 14 */  {
+	IBV_WC_LOC_RDD_VIOL_ERR, DAT_DTO_ERR_LOCAL_PROTECTION},
+	    /* 15 */  {
+	IBV_WC_REM_INV_RD_REQ_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+	    /* 16 */  {
+	IBV_WC_REM_ABORT_ERR, DAT_DTO_ERR_REMOTE_RESPONDER},
+	    /* 17 */  {
+	IBV_WC_INV_EECN_ERR, DAT_DTO_ERR_TRANSPORT},
+	    /* 18 */  {
+	IBV_WC_INV_EEC_STATE_ERR, DAT_DTO_ERR_TRANSPORT},
+	    /* 19 */  {
+	IBV_WC_FATAL_ERR, DAT_DTO_ERR_TRANSPORT},
+	    /* 20 */  {
+	IBV_WC_RESP_TIMEOUT_ERR, DAT_DTO_ERR_RECEIVER_NOT_READY},
+	    /* 21 */  {
+IBV_WC_GENERAL_ERR, DAT_DTO_ERR_TRANSPORT},};
 
 /*
  * dapls_ib_get_dto_status
@@ -206,72 +279,70 @@
  */
 
 DAT_DTO_COMPLETION_STATUS
-dapls_ib_get_dto_status (
-	IN ib_work_completion_t		*cqe_ptr)
+dapls_ib_get_dto_status(IN ib_work_completion_t * cqe_ptr)
 {
-	uint32_t	ib_status;
-	int		i;
+	uint32_t ib_status;
+	int i;
 
-	ib_status = DAPL_GET_CQE_STATUS (cqe_ptr);
+	ib_status = DAPL_GET_CQE_STATUS(cqe_ptr);
 
 	/*
-	* Due to the implementation of verbs completion code, we need to
-	* search the table for the correct value rather than assuming
-	* linear distribution.
-	*/
+	 * Due to the implementation of verbs completion code, we need to
+	 * search the table for the correct value rather than assuming
+	 * linear distribution.
+	 */
 	for (i = 0; i <= IBV_WC_GENERAL_ERR; i++) {
 		if (ib_status == ib_status_map[i].ib_status) {
-			if ( ib_status != IBV_WC_SUCCESS ) {
-				dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,
-	    			" DTO completion ERROR: %d: op %#x\n", 
-				ib_status, DAPL_GET_CQE_OPTYPE (cqe_ptr));
+			if (ib_status != IBV_WC_SUCCESS) {
+				dapl_dbg_log(DAPL_DBG_TYPE_DTO_COMP_ERR,
+					     " DTO completion ERROR: %d: op %#x\n",
+					     ib_status,
+					     DAPL_GET_CQE_OPTYPE(cqe_ptr));
 			}
 			return ib_status_map[i].dat_status;
 		}
 	}
 
-	dapl_dbg_log (DAPL_DBG_TYPE_DTO_COMP_ERR,
-	    		" DTO completion ERROR: %d: op %#x\n", 
-			ib_status,
-			DAPL_GET_CQE_OPTYPE (cqe_ptr));
+	dapl_dbg_log(DAPL_DBG_TYPE_DTO_COMP_ERR,
+		     " DTO completion ERROR: %d: op %#x\n",
+		     ib_status, DAPL_GET_CQE_OPTYPE(cqe_ptr));
 
 	return DAT_DTO_FAILURE;
 }
-    
-DAT_RETURN dapls_ib_get_async_event (
-	IN  ib_error_record_t		*err_record,
-	OUT DAT_EVENT_NUMBER		*async_event)
+
+DAT_RETURN dapls_ib_get_async_event(IN ib_error_record_t * err_record,
+				    OUT DAT_EVENT_NUMBER * async_event)
 {
-    DAT_RETURN	dat_status = DAT_SUCCESS;
-    int	err_code = err_record->event_type;
-    
-    switch (err_code) {
-	/* OVERFLOW error */
+	DAT_RETURN dat_status = DAT_SUCCESS;
+	int err_code = err_record->event_type;
+
+	switch (err_code) {
+		/* OVERFLOW error */
 	case IBV_EVENT_CQ_ERR:
-	    *async_event = DAT_ASYNC_ERROR_EVD_OVERFLOW;
-	    break;
-	/* INTERNAL errors */
+		*async_event = DAT_ASYNC_ERROR_EVD_OVERFLOW;
+		break;
+		/* INTERNAL errors */
 	case IBV_EVENT_DEVICE_FATAL:
-	    *async_event = DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR;
-	    break;
-	/* CATASTROPHIC errors */
+		*async_event = DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR;
+		break;
+		/* CATASTROPHIC errors */
 	case IBV_EVENT_PORT_ERR:
-	    *async_event = DAT_ASYNC_ERROR_IA_CATASTROPHIC;
-	    break;
-	/* BROKEN QP error */
+		*async_event = DAT_ASYNC_ERROR_IA_CATASTROPHIC;
+		break;
+		/* BROKEN QP error */
 	case IBV_EVENT_SQ_DRAINED:
 	case IBV_EVENT_QP_FATAL:
 	case IBV_EVENT_QP_REQ_ERR:
 	case IBV_EVENT_QP_ACCESS_ERR:
-	    *async_event = DAT_ASYNC_ERROR_EP_BROKEN;
-	    break;
+		*async_event = DAT_ASYNC_ERROR_EP_BROKEN;
+		break;
 
-	/* connection completion */
+		/* connection completion */
 	case IBV_EVENT_COMM_EST:
-	    *async_event = DAT_CONNECTION_EVENT_ESTABLISHED;
-	    break;
+		*async_event = DAT_CONNECTION_EVENT_ESTABLISHED;
+		break;
 
-	/* TODO: process HW state changes */
+		/* TODO: process HW state changes */
 	case IBV_EVENT_PATH_MIG:
 	case IBV_EVENT_PATH_MIG_ERR:
 	case IBV_EVENT_PORT_ACTIVE:
@@ -279,9 +350,9 @@
 	case IBV_EVENT_PKEY_CHANGE:
 	case IBV_EVENT_SM_CHANGE:
 	default:
-	    dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, 0);
-    }
-    return dat_status;
+		dat_status = DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
+	}
+	return dat_status;
 }
 
 /*
@@ -303,16 +374,14 @@
  *
  */
 DAT_RETURN
-dapls_ib_cq_alloc (
-	IN  DAPL_IA		*ia_ptr,
-	IN  DAPL_EVD		*evd_ptr,
-	IN  DAT_COUNT		*cqlen )
+dapls_ib_cq_alloc(IN DAPL_IA * ia_ptr,
+		  IN DAPL_EVD * evd_ptr, IN DAT_COUNT * cqlen)
 {
-	dapl_dbg_log ( DAPL_DBG_TYPE_UTIL, 
-		"dapls_ib_cq_alloc: evd %p cqlen=%d \n", evd_ptr, *cqlen );
-
 	struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     "dapls_ib_cq_alloc: evd %p cqlen=%d \n", evd_ptr, *cqlen);
+
 #ifdef CQ_WAIT_OBJECT
 	if (evd_ptr->cq_wait_obj_handle)
 		channel = evd_ptr->cq_wait_obj_handle;
@@ -320,27 +389,24 @@
 
 	/* Call IB verbs to create CQ */
 	evd_ptr->ib_cq_handle = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle,
-					      *cqlen,
-					      evd_ptr,
-					      channel, 0);
-	
-	if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE) 
-		return	DAT_INSUFFICIENT_RESOURCES;
+					      *cqlen, evd_ptr, channel, 0);
 
+	if (evd_ptr->ib_cq_handle == IB_INVALID_HANDLE)
+		return DAT_INSUFFICIENT_RESOURCES;
+
 	/* arm cq for events */
 	dapls_set_cq_notify(ia_ptr, evd_ptr);
-	
-        /* update with returned cq entry size */
+
+	/* update with returned cq entry size */
 	*cqlen = evd_ptr->ib_cq_handle->cqe;
 
-	dapl_dbg_log ( DAPL_DBG_TYPE_UTIL, 
-		"dapls_ib_cq_alloc: new_cq %p cqlen=%d \n", 
-		evd_ptr->ib_cq_handle, *cqlen );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     "dapls_ib_cq_alloc: new_cq %p cqlen=%d \n",
+		     evd_ptr->ib_cq_handle, *cqlen);
 
 	return DAT_SUCCESS;
 }
 
-
 /*
  * dapl_ib_cq_resize
  *
@@ -360,12 +426,10 @@
  *
  */
 DAT_RETURN
-dapls_ib_cq_resize (
-	IN  DAPL_IA	*ia_ptr,
-	IN  DAPL_EVD	*evd_ptr,
-	IN  DAT_COUNT	*cqlen )
+dapls_ib_cq_resize(IN DAPL_IA * ia_ptr,
+		   IN DAPL_EVD * evd_ptr, IN DAT_COUNT * cqlen)
 {
-	ib_cq_handle_t	new_cq;
+	ib_cq_handle_t new_cq;
 	struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
 
 	/* IB verbs doe not support resize. Try to re-create CQ
@@ -382,21 +446,21 @@
 	new_cq = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle, *cqlen,
 			       evd_ptr, channel, 0);
 
-	if (new_cq == IB_INVALID_HANDLE) 
-		return	DAT_INSUFFICIENT_RESOURCES;
-	
+	if (new_cq == IB_INVALID_HANDLE)
+		return DAT_INSUFFICIENT_RESOURCES;
+
 	/* destroy the original and replace if successful */
 	if (ibv_destroy_cq(evd_ptr->ib_cq_handle)) {
 		ibv_destroy_cq(new_cq);
-		return(dapl_convert_errno(errno,"resize_cq"));
+		return (dapl_convert_errno(errno, "resize_cq"));
 	}
-		
+
 	/* update EVD with new cq handle and size */
 	evd_ptr->ib_cq_handle = new_cq;
 	*cqlen = new_cq->cqe;
 
 	/* arm cq for events */
-	dapls_set_cq_notify (ia_ptr, evd_ptr);
+	dapls_set_cq_notify(ia_ptr, evd_ptr);
 
 	return DAT_SUCCESS;
 }
@@ -418,19 +482,17 @@
  *	DAT_INVALID_PARAMETER
  *
  */
-DAT_RETURN dapls_ib_cq_free (
-	IN  DAPL_IA		*ia_ptr,
-	IN  DAPL_EVD		*evd_ptr)
+DAT_RETURN dapls_ib_cq_free(IN DAPL_IA * ia_ptr, IN DAPL_EVD * evd_ptr)
 {
 	DAT_EVENT event;
-	ib_work_completion_t wc;	
+	ib_work_completion_t wc;
 
 	if (evd_ptr->ib_cq_handle != IB_INVALID_HANDLE) {
-		/* pull off CQ and EVD entries and toss */	
-        	while (ibv_poll_cq(evd_ptr->ib_cq_handle, 1, &wc) == 1);
-		while (dapl_evd_dequeue(evd_ptr, &event) == DAT_SUCCESS);
-		if (ibv_destroy_cq(evd_ptr->ib_cq_handle)) 
-			return(dapl_convert_errno(errno,"ibv_destroy_cq"));
+		/* pull off CQ and EVD entries and toss */
+		while (ibv_poll_cq(evd_ptr->ib_cq_handle, 1, &wc) == 1) ;
+		while (dapl_evd_dequeue(evd_ptr, &event) == DAT_SUCCESS) ;
+		if (ibv_destroy_cq(evd_ptr->ib_cq_handle))
+			return (dapl_convert_errno(errno, "ibv_destroy_cq"));
 		evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
 	}
 	return DAT_SUCCESS;
@@ -452,12 +514,10 @@
  * 	DAT_SUCCESS
  *	dapl_convert_errno 
  */
-DAT_RETURN dapls_set_cq_notify (
-	IN  DAPL_IA	    *ia_ptr,
-	IN  DAPL_EVD	    *evd_ptr)
+DAT_RETURN dapls_set_cq_notify(IN DAPL_IA * ia_ptr, IN DAPL_EVD * evd_ptr)
 {
-	if (ibv_req_notify_cq( evd_ptr->ib_cq_handle, 0 ))
-		return(dapl_convert_errno(errno,"notify_cq"));
+	if (ibv_req_notify_cq(evd_ptr->ib_cq_handle, 0))
+		return (dapl_convert_errno(errno, "notify_cq"));
 	else
 		return DAT_SUCCESS;
 }
@@ -479,13 +539,12 @@
  * 	DAT_SUCCESS
  *	dapl_convert_errno
  */
-DAT_RETURN dapls_ib_completion_notify (
-	IN  ib_hca_handle_t		hca_handle,
-	IN  DAPL_EVD			*evd_ptr,
-	IN  ib_notification_type_t	type)
+DAT_RETURN dapls_ib_completion_notify(IN ib_hca_handle_t hca_handle,
+				      IN DAPL_EVD * evd_ptr,
+				      IN ib_notification_type_t type)
 {
-	if (ibv_req_notify_cq( evd_ptr->ib_cq_handle, type ))
-		return(dapl_convert_errno(errno,"notify_cq_type"));
+	if (ibv_req_notify_cq(evd_ptr->ib_cq_handle, type))
+		return (dapl_convert_errno(errno, "notify_cq_type"));
 	else
 		return DAT_SUCCESS;
 }
@@ -508,109 +567,134 @@
  *	DAT_QUEUE_EMPTY
  *	
  */
-DAT_RETURN dapls_ib_completion_poll (
-	IN  DAPL_HCA			*hca_ptr,
-	IN  DAPL_EVD			*evd_ptr,
-	IN  ib_work_completion_t	*wc_ptr)
+DAT_RETURN dapls_ib_completion_poll(IN DAPL_HCA * hca_ptr,
+				    IN DAPL_EVD * evd_ptr,
+				    IN ib_work_completion_t * wc_ptr)
 {
-	int	ret;
+	int ret;
 
-    	ret = ibv_poll_cq(evd_ptr->ib_cq_handle, 1, wc_ptr);
-	if (ret == 1) 
-		return	DAT_SUCCESS;
-	
-	return	DAT_QUEUE_EMPTY;
+	ret = ibv_poll_cq(evd_ptr->ib_cq_handle, 1, wc_ptr);
+	if (ret == 1)
+		return DAT_SUCCESS;
+
+	return DAT_QUEUE_EMPTY;
 }
 
 #ifdef CQ_WAIT_OBJECT
 
 /* NEW common wait objects for providers with direct CQ wait objects */
 DAT_RETURN
-dapls_ib_wait_object_create ( 
-		IN DAPL_EVD		*evd_ptr,
-		IN ib_wait_obj_handle_t	*p_cq_wait_obj_handle )
+dapls_ib_wait_object_create(IN DAPL_EVD * evd_ptr,
+			    IN ib_wait_obj_handle_t * p_cq_wait_obj_handle)
 {
-	dapl_dbg_log (	DAPL_DBG_TYPE_CM, 
-			" cq_object_create: (%p,%p)\n", 
-			evd_ptr, p_cq_wait_obj_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_create: (%p,%p)\n",
+		     evd_ptr, p_cq_wait_obj_handle);
 
 	/* set cq_wait object to evd_ptr */
-	*p_cq_wait_obj_handle = 
-		ibv_create_comp_channel(evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle);	
-		
+	*p_cq_wait_obj_handle =
+	    ibv_create_comp_channel(evd_ptr->header.owner_ia->hca_ptr->
+				    ib_hca_handle);
+
 	return DAT_SUCCESS;
 }
 
 DAT_RETURN
-dapls_ib_wait_object_destroy (
-	IN ib_wait_obj_handle_t	    p_cq_wait_obj_handle)
+dapls_ib_wait_object_destroy(IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
 {
-	dapl_dbg_log (  DAPL_DBG_TYPE_UTIL, 
-			" cq_object_destroy: wait_obj=%p\n", 
-			p_cq_wait_obj_handle );
-	
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_destroy: wait_obj=%p\n", p_cq_wait_obj_handle);
+
 	ibv_destroy_comp_channel(p_cq_wait_obj_handle);
-	
+
 	return DAT_SUCCESS;
 }
 
 DAT_RETURN
-dapls_ib_wait_object_wakeup (
-	IN ib_wait_obj_handle_t		p_cq_wait_obj_handle)
+dapls_ib_wait_object_wakeup(IN ib_wait_obj_handle_t p_cq_wait_obj_handle)
 {
-	dapl_dbg_log (  DAPL_DBG_TYPE_UTIL, 
-			" cq_object_wakeup: wait_obj=%p\n", 
-			p_cq_wait_obj_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wakeup: wait_obj=%p\n", p_cq_wait_obj_handle);
 
-        /* no wake up mechanism */
+	/* no wake up mechanism */
 	return DAT_SUCCESS;
 }
 
+#if defined(_WIN32) || defined(_WIN64)
 DAT_RETURN
-dapls_ib_wait_object_wait (
-	IN ib_wait_obj_handle_t	    p_cq_wait_obj_handle,
-	IN u_int32_t 		    timeout)
+dapls_ib_wait_object_wait(IN ib_wait_obj_handle_t p_cq_wait_obj_handle,
+			  IN uint32_t timeout)
 {
-	struct dapl_evd	*evd_ptr;
-	struct ibv_cq	*ibv_cq = NULL;
-	int		status = 0; 
-	int		timeout_ms = -1;
+	struct dapl_evd *evd_ptr;
+	struct ibv_cq *ibv_cq = NULL;
+	int status = 0;
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wait: CQ channel %p time %d\n",
+		     p_cq_wait_obj_handle, timeout);
+
+	/* uDAPL timeout values in usecs */
+	p_cq_wait_obj_handle->comp_channel.Milliseconds = timeout / 1000;
+
+	/* returned event */
+	status = ibv_get_cq_event(p_cq_wait_obj_handle, &ibv_cq,
+				  (void *)&evd_ptr);
+	if (status == 0) {
+		ibv_ack_cq_events(ibv_cq, 1);
+	}
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wait: RET evd %p ibv_cq %p %s\n",
+		     evd_ptr, ibv_cq, strerror(errno));
+
+	return (dapl_convert_errno(status, "cq_wait_object_wait"));
+}
+#else				//_WIN32 || _WIN64
+DAT_RETURN
+dapls_ib_wait_object_wait(IN ib_wait_obj_handle_t p_cq_wait_obj_handle,
+			  IN uint32_t timeout)
+{
+	struct dapl_evd *evd_ptr;
+	struct ibv_cq *ibv_cq = NULL;
+	int status = 0;
+	int timeout_ms = -1;
 	struct pollfd cq_fd = {
-			.fd      = p_cq_wait_obj_handle->fd,
-			.events  = POLLIN,
-			.revents = 0
-		};
+		.fd = p_cq_wait_obj_handle->fd,
+		.events = POLLIN,
+		.revents = 0
+	};
 
-	dapl_dbg_log ( DAPL_DBG_TYPE_CM, 
-			" cq_object_wait: CQ channel %p time %d\n", 
-			p_cq_wait_obj_handle, timeout );
-	
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wait: CQ channel %p time %d\n",
+		     p_cq_wait_obj_handle, timeout);
+
 	/* uDAPL timeout values in usecs */
 	if (timeout != DAT_TIMEOUT_INFINITE)
-		timeout_ms = timeout/1000;
+		timeout_ms = timeout / 1000;
 
 	status = poll(&cq_fd, 1, timeout_ms);
 
 	/* returned event */
 	if (status > 0) {
-		if (!ibv_get_cq_event(p_cq_wait_obj_handle, 
-				      &ibv_cq, (void*)&evd_ptr)) {
+		if (!ibv_get_cq_event(p_cq_wait_obj_handle,
+				      &ibv_cq, (void *)&evd_ptr)) {
 			ibv_ack_cq_events(ibv_cq, 1);
 		}
 		status = 0;
 
-	/* timeout */
-	} else if (status == 0) 
+		/* timeout */
+	} else if (status == 0)
 		status = ETIMEDOUT;
-	
-	dapl_dbg_log (DAPL_DBG_TYPE_CM, 
-		      " cq_object_wait: RET evd %p ibv_cq %p %s\n",
-		      evd_ptr, ibv_cq,strerror(errno));
-	
-	return(dapl_convert_errno(status,"cq_wait_object_wait"));
-	
+
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " cq_object_wait: RET evd %p ibv_cq %p %s\n",
+		     evd_ptr, ibv_cq, strerror(errno));
+
+	return (dapl_convert_errno(status, "cq_wait_object_wait"));
+
 }
-#endif
+#endif				//_WIN32 || _WIN64
+#endif				// CQ_WAIT_OBJECT
 
 /*
  * Local variables:
@@ -619,4 +703,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_dto.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_dto.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_dto.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -73,10 +73,9 @@
 	IN  DAT_COUNT		segments,
 	IN  DAT_LMR_TRIPLET	*local_iov )
 {
-	ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-	ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
 	struct ibv_recv_wr wr;
 	struct ibv_recv_wr *bad_wr;
+	ib_data_segment_t *ds = (ib_data_segment_t *)local_iov;
 	DAT_COUNT i, total_len;
 	int ret;
 	
@@ -84,51 +83,32 @@
 		     " post_rcv: ep %p cookie %p segs %d l_iov %p\n",
 		     ep_ptr, cookie, segments, local_iov);
 
-	if (segments <= DEFAULT_DS_ENTRIES) 
-		ds_array_p = ds_array;
-	else
-		ds_array_start_p = ds_array_p = 
-			dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
-	if (NULL == ds_array_p)
-		return (DAT_INSUFFICIENT_RESOURCES);
-	
 	/* setup work request */
 	total_len = 0;
 	wr.next = 0;
-	wr.num_sge = 0;
+	wr.num_sge = segments;
 	wr.wr_id = (uint64_t)(uintptr_t)cookie;
-	wr.sg_list = ds_array_p;
+	wr.sg_list = ds;
 
-	for (i = 0; i < segments; i++) {
-		if (!local_iov[i].segment_length)
-			continue;
-
-		ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
-		ds_array_p->length = local_iov[i].segment_length;
-		ds_array_p->lkey = local_iov[i].lmr_context;
-		
-		dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-			     " post_rcv: l_key 0x%x va %p len %d\n",
-			     ds_array_p->lkey, ds_array_p->addr, 
-			     ds_array_p->length );
-
-		total_len += ds_array_p->length;
-		wr.num_sge++;
-		ds_array_p++;
+	if (cookie != NULL) {
+		for (i = 0; i < segments; i++) {
+			dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+				     " post_rcv: l_key 0x%x va %p len %d\n",
+				     ds->lkey, ds->addr, ds->length );
+			total_len += ds->length;
+			ds++;
+		}
+		cookie->val.dto.size = total_len;
 	}
 
-	if (cookie != NULL) 
-		cookie->val.dto.size = total_len;
-
 	ret = ibv_post_recv(ep_ptr->qp_handle, &wr, &bad_wr);
 	
-	if (ds_array_start_p != NULL)
-	    dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
 	if (ret)
-		return( dapl_convert_errno(errno,"ibv_recv") );
+		return(dapl_convert_errno(errno,"ibv_recv"));
 
+	DAPL_CNTR(ep_ptr, DCNT_EP_POST_RECV);
+	DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_RECV_DATA, total_len);
+
 	return DAT_SUCCESS;
 }
 
@@ -147,34 +127,20 @@
 	IN  const DAT_RMR_TRIPLET	*remote_iov,
 	IN  DAT_COMPLETION_FLAGS	completion_flags)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p op %d ck %p sgs",
-		     "%d l_iov %p r_iov %p f %d\n",
-		     ep_ptr, op_type, cookie, segments, local_iov, 
-		     remote_iov, completion_flags);
-
-	ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-	ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
 	struct ibv_send_wr wr;
 	struct ibv_send_wr *bad_wr;
+	ib_data_segment_t *ds = (ib_data_segment_t *)local_iov;
 	ib_hca_transport_t *ibt_ptr = 
 		&ep_ptr->header.owner_ia->hca_ptr->ib_trans;
 	DAT_COUNT i, total_len;
 	int ret;
 	
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
-		     ep_ptr, cookie, segments, local_iov);
+		     " post_snd: ep %p op %d ck %p sgs",
+		     "%d l_iov %p r_iov %p f %d\n",
+		     ep_ptr, op_type, cookie, segments, local_iov, 
+		     remote_iov, completion_flags);
 
-	if(segments <= DEFAULT_DS_ENTRIES) 
-		ds_array_p = ds_array;
-	else
-		ds_array_start_p = ds_array_p = 
-			dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
-	if (NULL == ds_array_p)
-		return (DAT_INSUFFICIENT_RESOURCES);
-
 #ifdef DAT_EXTENSIONS	
 	if (ep_ptr->qp_handle->qp_type != IBV_QPT_RC)
 		return(DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
@@ -182,33 +148,23 @@
 	/* setup the work request */
 	wr.next = 0;
 	wr.opcode = op_type;
-	wr.num_sge = 0;
+	wr.num_sge = segments;
 	wr.send_flags = 0;
 	wr.wr_id = (uint64_t)(uintptr_t)cookie;
-	wr.sg_list = ds_array_p;
+	wr.sg_list = ds;
 	total_len = 0;
 
-	for (i = 0; i < segments; i++ ) {
-		if ( !local_iov[i].segment_length )
-			continue;
-
-		ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
-		ds_array_p->length = local_iov[i].segment_length;
-		ds_array_p->lkey = local_iov[i].lmr_context;
-		
-		dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-			     " post_snd: lkey 0x%x va %p len %d\n",
-			     ds_array_p->lkey, ds_array_p->addr, 
-			     ds_array_p->length );
-
-		total_len += ds_array_p->length;
-		wr.num_sge++;
-		ds_array_p++;
+	if (cookie != NULL) {
+		for (i = 0; i < segments; i++ ) {
+			dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+				     " post_snd: lkey 0x%x va %p len %d\n",
+				     ds->lkey, ds->addr, ds->length );
+			total_len += ds->length;
+			ds++;
+		}
+		cookie->val.dto.size = total_len;
 	}
 
-	if (cookie != NULL) 
-		cookie->val.dto.size = total_len;
-
 	if (wr.num_sge && 
 	    (op_type == OP_RDMA_WRITE || op_type == OP_RDMA_READ)) {
 		wr.wr.rdma.remote_addr = remote_iov->virtual_address;
@@ -238,12 +194,28 @@
 
 	ret = ibv_post_send(ep_ptr->qp_handle, &wr, &bad_wr);
 
-	if (ds_array_start_p != NULL)
-	    dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
 	if (ret)
-		return( dapl_convert_errno(errno,"ibv_send") );
+		return(dapl_convert_errno(errno,"ibv_send"));
 
+#ifdef DAPL_COUNTERS
+	switch (op_type) {
+	case OP_SEND:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_SEND);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_SEND_DATA,total_len);
+		break;
+	case OP_RDMA_WRITE:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_WRITE);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_WRITE_DATA,total_len);
+		break;	
+	case OP_RDMA_READ:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_READ);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_READ_DATA,total_len);
+		break;
+	default:
+		break;
+	}
+#endif /* DAPL_COUNTERS */
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP," post_snd: returned\n");
 	return DAT_SUCCESS;
 }
@@ -317,62 +289,38 @@
 	IN  DAT_COMPLETION_FLAGS	completion_flags,
 	IN  DAT_IB_ADDR_HANDLE		*remote_ah)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_ext_snd: ep %p op %d ck %p sgs",
-		     "%d l_iov %p r_iov %p f %d\n",
-		     ep_ptr, op_type, cookie, segments, local_iov, 
-		     remote_iov, completion_flags, remote_ah);
-
-	ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-	ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
 	struct ibv_send_wr wr;
 	struct ibv_send_wr *bad_wr;
+	ib_data_segment_t *ds = (ib_data_segment_t *)local_iov;
 	DAT_COUNT i, total_len;
 	int ret;
 	
 	dapl_dbg_log(DAPL_DBG_TYPE_EP,
-		     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
-		     ep_ptr, cookie, segments, local_iov);
+		     " post_ext_snd: ep %p op %d ck %p sgs",
+		     "%d l_iov %p r_iov %p f %d\n",
+		     ep_ptr, op_type, cookie, segments, local_iov, 
+		     remote_iov, completion_flags, remote_ah);
 
-	if(segments <= DEFAULT_DS_ENTRIES) 
-		ds_array_p = ds_array;
-	else
-		ds_array_start_p = ds_array_p = 
-			dapl_os_alloc(segments * sizeof(ib_data_segment_t));
-
-	if (NULL == ds_array_p)
-		return (DAT_INSUFFICIENT_RESOURCES);
-	
 	/* setup the work request */
 	wr.next = 0;
 	wr.opcode = op_type;
-	wr.num_sge = 0;
+	wr.num_sge = segments;
 	wr.send_flags = 0;
 	wr.wr_id = (uint64_t)(uintptr_t)cookie;
-	wr.sg_list = ds_array_p;
+	wr.sg_list = ds;
 	total_len = 0;
 
-	for (i = 0; i < segments; i++ ) {
-		if ( !local_iov[i].segment_length )
-			continue;
-
-		ds_array_p->addr = (uint64_t) local_iov[i].virtual_address;
-		ds_array_p->length = local_iov[i].segment_length;
-		ds_array_p->lkey = local_iov[i].lmr_context;
-		
-		dapl_dbg_log(DAPL_DBG_TYPE_EP, 
-			     " post_snd: lkey 0x%x va %p len %d\n",
-			     ds_array_p->lkey, ds_array_p->addr, 
-			     ds_array_p->length );
-
-		total_len += ds_array_p->length;
-		wr.num_sge++;
-		ds_array_p++;
+	if (cookie != NULL) {
+		for (i = 0; i < segments; i++ ) {
+			dapl_dbg_log(DAPL_DBG_TYPE_EP, 
+				     " post_snd: lkey 0x%x va %p len %d\n",
+				     ds->lkey, ds->addr, ds->length );
+			total_len += ds->length;
+			ds++;
+		}
+		cookie->val.dto.size = total_len;
 	}
 
-	if (cookie != NULL) 
-		cookie->val.dto.size = total_len;
-
 	switch (op_type) {
 	case OP_RDMA_WRITE_IMM:
 		/* OP_RDMA_WRITE)IMMED has direct IB wr_type mapping */
@@ -446,14 +394,33 @@
 
 	ret = ibv_post_send(ep_ptr->qp_handle, &wr, &bad_wr);
 
-	if (segments > DEFAULT_DS_ENTRIES)
-	    dapl_os_free(ds_array_start_p, segments * sizeof(ib_data_segment_t));
-
 	if (ret)
 		return( dapl_convert_errno(errno,"ibv_send") );
 	
+#ifdef DAPL_COUNTERS
+	switch (op_type) {
+	case OP_RDMA_WRITE_IMM:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_WRITE_IMM);
+		DAPL_CNTR_DATA(ep_ptr, 
+			       DCNT_EP_POST_WRITE_IMM_DATA, total_len);
+		break;
+	case OP_COMP_AND_SWAP:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_CMP_SWAP);
+		break;	
+	case OP_FETCH_AND_ADD:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_FETCH_ADD);
+		break;
+	case OP_SEND_UD:
+		DAPL_CNTR(ep_ptr, DCNT_EP_POST_SEND_UD);
+		DAPL_CNTR_DATA(ep_ptr, DCNT_EP_POST_SEND_UD_DATA, total_len);
+		break;
+	default:
+		break;
+	}
+#endif /* DAPL_COUNTERS */
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EP," post_snd: returned\n");
-	return DAT_SUCCESS;
+        return DAT_SUCCESS;
 }
 #endif
 
@@ -470,6 +437,10 @@
 /* map Work Completions to DAPL WR operations */
 STATIC _INLINE_ int dapls_cqe_opcode(ib_work_completion_t *cqe_p)
 {
+#ifdef DAPL_COUNTERS
+	DAPL_COOKIE *cookie = (DAPL_COOKIE *)(uintptr_t)cqe_p->wr_id;
+#endif /* DAPL_COUNTERS */
+
 	switch (cqe_p->opcode) {
 	case IBV_WC_SEND:
 		if (CQE_WR_TYPE_UD(cqe_p->wr_id))
@@ -490,13 +461,27 @@
 	case IBV_WC_BIND_MW:
 		return (OP_BIND_MW);
 	case IBV_WC_RECV:
-		if (CQE_WR_TYPE_UD(cqe_p->wr_id)) 
+		if (CQE_WR_TYPE_UD(cqe_p->wr_id)) {
+			DAPL_CNTR(cookie->ep, DCNT_EP_RECV_UD);
+			DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_UD_DATA, 
+				       cqe_p->byte_len);
 			return (OP_RECV_UD);
-		else if (cqe_p->wc_flags & IBV_WC_WITH_IMM)
-			return (OP_RECEIVE_MSG_IMM);
-		else
+		}
+		else if (cqe_p->wc_flags & IBV_WC_WITH_IMM) {
+			DAPL_CNTR(cookie->ep, DCNT_EP_RECV_IMM);
+			DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_IMM_DATA, 
+				       cqe_p->byte_len);
+			return (OP_RECEIVE_IMM);
+		} else {
+			DAPL_CNTR(cookie->ep, DCNT_EP_RECV);
+			DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_DATA, 
+				       cqe_p->byte_len);
 			return (OP_RECEIVE);
+		}
 	case IBV_WC_RECV_RDMA_WITH_IMM:
+		DAPL_CNTR(cookie->ep, DCNT_EP_RECV_RDMA_IMM);
+		DAPL_CNTR_DATA(cookie->ep, DCNT_EP_RECV_RDMA_IMM_DATA, 
+			       cqe_p->byte_len);
 		return (OP_RECEIVE_IMM);
 	default:
 		return (OP_INVALID);

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_extensions.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_extensions.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_extensions.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -43,21 +43,18 @@
 #include "dapl_cookie.h"
 #include <stdarg.h>
 
-
 DAT_RETURN
-dapli_post_ext( IN       DAT_EP_HANDLE		ep_handle,
-		IN       DAT_UINT64		cmp_add,	
-		IN       DAT_UINT64		swap,
-		IN	 DAT_UINT32		immed_data,
-		IN	 DAT_COUNT		segments,
-		IN       DAT_LMR_TRIPLET	*local_iov,
-		IN       DAT_DTO_COOKIE		user_cookie,
-		IN const DAT_RMR_TRIPLET	*remote_iov,
-		IN	 int			op_type, 
-		IN       DAT_COMPLETION_FLAGS	flags,
-		IN	 DAT_IB_ADDR_HANDLE	*ah);
+dapli_post_ext(IN DAT_EP_HANDLE ep_handle,
+	       IN DAT_UINT64 cmp_add,
+	       IN DAT_UINT64 swap,
+	       IN DAT_UINT32 immed_data,
+	       IN DAT_COUNT segments,
+	       IN DAT_LMR_TRIPLET * local_iov,
+	       IN DAT_DTO_COOKIE user_cookie,
+	       IN const DAT_RMR_TRIPLET * remote_iov,
+	       IN int op_type,
+	       IN DAT_COMPLETION_FLAGS flags, IN DAT_IB_ADDR_HANDLE * ah);
 
-
 /*
  * dapl_extensions
  *
@@ -77,131 +74,158 @@
  *
  */
 DAT_RETURN
-dapl_extensions(IN DAT_HANDLE		dat_handle, 
-		IN DAT_EXTENDED_OP	ext_op, 
-		IN va_list		args)
+dapl_extensions(IN DAT_HANDLE dat_handle,
+		IN DAT_EXTENDED_OP ext_op, IN va_list args)
 {
-	DAT_EP_HANDLE		ep;
-	DAT_IB_ADDR_HANDLE	*ah = NULL;
-	DAT_LMR_TRIPLET		*lmr_p;
-	DAT_DTO_COOKIE		cookie;
-	const DAT_RMR_TRIPLET	*rmr_p;
-	DAT_UINT64		dat_uint64a, dat_uint64b;
-	DAT_UINT32		dat_uint32;
-	DAT_COUNT		segments = 1;
-	DAT_COMPLETION_FLAGS	comp_flags;
-	DAT_RETURN		status = DAT_NOT_IMPLEMENTED;
+	DAT_EP_HANDLE ep;
+	DAT_IB_ADDR_HANDLE *ah = NULL;
+	DAT_LMR_TRIPLET *lmr_p;
+	DAT_DTO_COOKIE cookie;
+	const DAT_RMR_TRIPLET *rmr_p;
+	DAT_UINT64 dat_uint64a, dat_uint64b;
+	DAT_UINT32 dat_uint32;
+	DAT_COUNT segments = 1;
+	DAT_COMPLETION_FLAGS comp_flags;
+	DAT_RETURN status = DAT_NOT_IMPLEMENTED;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_API,
 		     "dapl_extensions(hdl %p operation %d, ...)\n",
 		     dat_handle, ext_op);
 
-	DAPL_CNTR(DCNT_EXTENSION);
+	switch ((int)ext_op) {
 
-	switch ((int)ext_op)
-	{
-	
 	case DAT_IB_RDMA_WRITE_IMMED_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " WRITE_IMMED_DATA extension call\n");
-		
-		ep          = dat_handle;		 /* ep_handle */
-		segments    = va_arg( args, DAT_COUNT);  /* num segments */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*);  
-		cookie      = va_arg( args, DAT_DTO_COOKIE);
-		rmr_p       = va_arg( args, const DAT_RMR_TRIPLET*); 
-		dat_uint32  = va_arg( args, DAT_UINT32); /* immed data */
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);   
-		
+
+		ep = dat_handle;	/* ep_handle */
+		segments = va_arg(args, DAT_COUNT);	/* num segments */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		rmr_p = va_arg(args, const DAT_RMR_TRIPLET *);
+		dat_uint32 = va_arg(args, DAT_UINT32);	/* immed data */
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
+
 		status = dapli_post_ext(ep, 0, 0, dat_uint32, segments, lmr_p,
-    					cookie, rmr_p, OP_RDMA_WRITE_IMM,
-    	    				comp_flags, ah);
-    		break;
+					cookie, rmr_p, OP_RDMA_WRITE_IMM,
+					comp_flags, ah);
+		break;
 
 	case DAT_IB_CMP_AND_SWAP_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " CMP_AND_SWAP extension call\n");
 
-		ep          = dat_handle;		/* ep_handle */
-		dat_uint64a = va_arg( args, DAT_UINT64); /* cmp_value */
-		dat_uint64b = va_arg( args, DAT_UINT64); /* swap_value */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*); 
-		cookie      = va_arg( args, DAT_DTO_COOKIE);  
-		rmr_p       = va_arg( args, const DAT_RMR_TRIPLET*);
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);
+		ep = dat_handle;	/* ep_handle */
+		dat_uint64a = va_arg(args, DAT_UINT64);	/* cmp_value */
+		dat_uint64b = va_arg(args, DAT_UINT64);	/* swap_value */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		rmr_p = va_arg(args, const DAT_RMR_TRIPLET *);
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
 
 		status = dapli_post_ext(ep, dat_uint64a, dat_uint64b,
-					0, segments, lmr_p, cookie, rmr_p, 
+					0, segments, lmr_p, cookie, rmr_p,
 					OP_COMP_AND_SWAP, comp_flags, ah);
-   		break;
+		break;
 
 	case DAT_IB_FETCH_AND_ADD_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " FETCH_AND_ADD extension call\n");
-		
-		ep          = dat_handle;		/* ep_handle */
-		dat_uint64a = va_arg( args, DAT_UINT64); /* add value */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*);  
-		cookie      = va_arg( args, DAT_DTO_COOKIE);
-		rmr_p       = va_arg( args, const DAT_RMR_TRIPLET*); 
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);   
-		
-		status = dapli_post_ext(ep, dat_uint64a, 0, 0, segments, 
-					lmr_p, cookie, rmr_p, 
+
+		ep = dat_handle;	/* ep_handle */
+		dat_uint64a = va_arg(args, DAT_UINT64);	/* add value */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		rmr_p = va_arg(args, const DAT_RMR_TRIPLET *);
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
+
+		status = dapli_post_ext(ep, dat_uint64a, 0, 0, segments,
+					lmr_p, cookie, rmr_p,
 					OP_FETCH_AND_ADD, comp_flags, ah);
-    		break;
+		break;
 
 	case DAT_IB_UD_SEND_OP:
-    		dapl_dbg_log(DAPL_DBG_TYPE_RTN, 
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
 			     " UD post_send extension call\n");
-		
-		ep          = dat_handle;		/* ep_handle */
-		segments    = va_arg( args, DAT_COUNT);  /* segments */
-		lmr_p       = va_arg( args, DAT_LMR_TRIPLET*);  
-		ah          = va_arg( args, DAT_IB_ADDR_HANDLE*);  
-		cookie      = va_arg( args, DAT_DTO_COOKIE);
-		comp_flags  = va_arg( args, DAT_COMPLETION_FLAGS);  
-				
-		status = dapli_post_ext(ep, 0, 0, 0, segments, 
-					lmr_p, cookie, NULL, 
+
+		ep = dat_handle;	/* ep_handle */
+		segments = va_arg(args, DAT_COUNT);	/* segments */
+		lmr_p = va_arg(args, DAT_LMR_TRIPLET *);
+		ah = va_arg(args, DAT_IB_ADDR_HANDLE *);
+		cookie = va_arg(args, DAT_DTO_COOKIE);
+		comp_flags = va_arg(args, DAT_COMPLETION_FLAGS);
+
+		status = dapli_post_ext(ep, 0, 0, 0, segments,
+					lmr_p, cookie, NULL,
 					OP_SEND_UD, comp_flags, ah);
-    		break;
+		break;
 
+#ifdef DAPL_COUNTERS
+	case DAT_QUERY_COUNTERS_OP:
+		{
+			int cntr, reset;
+			DAT_UINT64 *p_cntr_out;
+
+			dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+				     " Query counter extension call\n");
+
+			cntr = va_arg(args, int);
+			p_cntr_out = va_arg(args, DAT_UINT64 *);
+			reset = va_arg(args, int);
+
+			status = dapl_query_counter(dat_handle, cntr,
+						    p_cntr_out, reset);
+			break;
+		}
+	case DAT_PRINT_COUNTERS_OP:
+		{
+			int cntr, reset;
+
+			dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+				     " Print counter extension call\n");
+
+			cntr = va_arg(args, int);
+			reset = va_arg(args, int);
+
+			dapl_print_counter(dat_handle, cntr, reset);
+			status = DAT_SUCCESS;
+			break;
+		}
+#endif				/* DAPL_COUNTERS */
+
 	default:
-    		dapl_dbg_log(DAPL_DBG_TYPE_ERR, 
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
 			     "unsupported extension(%d)\n", (int)ext_op);
 	}
-	
-	return(status);
+
+	return (status);
 }
 
-
 DAT_RETURN
-dapli_post_ext( IN       DAT_EP_HANDLE		ep_handle,
-		IN       DAT_UINT64		cmp_add,	
-		IN       DAT_UINT64		swap,
-		IN	 DAT_UINT32		immed_data,
-		IN	 DAT_COUNT		segments,
-		IN       DAT_LMR_TRIPLET	*local_iov,
-		IN       DAT_DTO_COOKIE		user_cookie,
-		IN const DAT_RMR_TRIPLET	*remote_iov,
-		IN	 int			op_type, 
-		IN       DAT_COMPLETION_FLAGS	flags,
-		IN	 DAT_IB_ADDR_HANDLE	*ah)
+dapli_post_ext(IN DAT_EP_HANDLE ep_handle,
+	       IN DAT_UINT64 cmp_add,
+	       IN DAT_UINT64 swap,
+	       IN DAT_UINT32 immed_data,
+	       IN DAT_COUNT segments,
+	       IN DAT_LMR_TRIPLET * local_iov,
+	       IN DAT_DTO_COOKIE user_cookie,
+	       IN const DAT_RMR_TRIPLET * remote_iov,
+	       IN int op_type,
+	       IN DAT_COMPLETION_FLAGS flags, IN DAT_IB_ADDR_HANDLE * ah)
 {
-	DAPL_EP 	*ep_ptr;
-	ib_qp_handle_t	qp_ptr;
-	DAPL_COOKIE	*cookie = NULL;
-	DAT_RETURN	dat_status = DAT_SUCCESS;
+	DAPL_EP *ep_ptr;
+	ib_qp_handle_t qp_ptr;
+	DAPL_COOKIE *cookie = NULL;
+	DAT_RETURN dat_status = DAT_SUCCESS;
 
 	dapl_dbg_log(DAPL_DBG_TYPE_API,
 		     " post_ext_op: ep %p cmp_val %d "
 		     "swap_val %d cookie 0x%x, r_iov %p, flags 0x%x, ah %p\n",
-		     ep_handle, (unsigned)cmp_add, (unsigned)swap, 
+		     ep_handle, (unsigned)cmp_add, (unsigned)swap,
 		     (unsigned)user_cookie.as_64, remote_iov, flags, ah);
 
 	if (DAPL_BAD_HANDLE(ep_handle, DAPL_MAGIC_EP))
-		return(DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
+		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
 
 	ep_ptr = (DAPL_EP *) ep_handle;
 	qp_ptr = ep_ptr->qp_handle;
@@ -212,11 +236,10 @@
 	 */
 	dat_status = dapls_dto_cookie_alloc(&ep_ptr->req_buffer,
 					    DAPL_DTO_TYPE_EXTENSION,
-					    user_cookie,
-					    &cookie);
+					    user_cookie, &cookie);
 	if (dat_status != DAT_SUCCESS)
 		goto bail;
-		
+
 	/*
 	 * Take reference before posting to avoid race conditions with
 	 * completions
@@ -226,49 +249,41 @@
 	/*
 	 * Invoke provider specific routine to post DTO
 	 */
-	dat_status = dapls_ib_post_ext_send(ep_ptr,	
-					    op_type,
-					    cookie,	
-					    segments,	/* data segments */
-					    local_iov, 
-					    remote_iov,
-					    immed_data,	/* immed data */
+	dat_status = dapls_ib_post_ext_send(ep_ptr, op_type, cookie, segments,	/* data segments */
+					    local_iov, remote_iov, immed_data,	/* immed data */
 					    cmp_add,	/* compare or add */
 					    swap,	/* swap */
-					    flags,
-					    ah);
+					    flags, ah);
 
 	if (dat_status != DAT_SUCCESS) {
 		dapl_os_atomic_dec(&ep_ptr->req_count);
 		dapls_cookie_dealloc(&ep_ptr->req_buffer, cookie);
 	}
 
-bail:
+      bail:
 	return dat_status;
 
 }
 
-
 /* 
  * New provider routine to process extended DTO events 
  */
 void
-dapls_cqe_to_event_extension(IN DAPL_EP			*ep_ptr,
-			     IN DAPL_COOKIE		*cookie,
-			     IN ib_work_completion_t	*cqe_ptr,
-			     IN DAT_EVENT		*event_ptr)
+dapls_cqe_to_event_extension(IN DAPL_EP * ep_ptr,
+			     IN DAPL_COOKIE * cookie,
+			     IN ib_work_completion_t * cqe_ptr,
+			     IN DAT_EVENT * event_ptr)
 {
 	uint32_t ibtype;
-	DAT_DTO_COMPLETION_EVENT_DATA *dto = 
-			&event_ptr->event_data.dto_completion_event_data;
-	DAT_IB_EXTENSION_EVENT_DATA *ext_data = 
-			(DAT_IB_EXTENSION_EVENT_DATA *)
-			&event_ptr->event_extension_data[0];
+	DAT_DTO_COMPLETION_EVENT_DATA *dto =
+	    &event_ptr->event_data.dto_completion_event_data;
+	DAT_IB_EXTENSION_EVENT_DATA *ext_data = (DAT_IB_EXTENSION_EVENT_DATA *)
+	    & event_ptr->event_extension_data[0];
 	DAT_DTO_COMPLETION_STATUS dto_status;
 
 	/* Get status from cqe */
-        dto_status = dapls_ib_get_dto_status(cqe_ptr);
-	
+	dto_status = dapls_ib_get_dto_status(cqe_ptr);
+
 	dapl_dbg_log(DAPL_DBG_TYPE_EVD,
 		     " cqe_to_event_ext: dto_ptr %p ext_ptr %p status %d\n",
 		     dto, ext_data, dto_status);
@@ -276,73 +291,71 @@
 	event_ptr->event_number = DAT_IB_DTO_EVENT;
 	dto->ep_handle = cookie->ep;
 	dto->user_cookie = cookie->val.dto.cookie;
-	dto->operation = DAPL_GET_CQE_DTOS_OPTYPE(cqe_ptr); /* new for 2.0 */
+	dto->operation = DAPL_GET_CQE_DTOS_OPTYPE(cqe_ptr);	/* new for 2.0 */
 	dto->status = ext_data->status = dto_status;
 
 	if (dto_status != DAT_DTO_SUCCESS)
 		return;
-	
+
 	/* 
 	 * Get operation type from CQ work completion entry and
 	 * if extented operation then set extended event data
-         */
+	 */
 	ibtype = DAPL_GET_CQE_OPTYPE(cqe_ptr);
-        
-	switch (ibtype)	{
 
+	switch (ibtype) {
+
 	case OP_RDMA_WRITE_IMM:
-		dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: OP_RDMA_WRITE_IMMED\n");
-		
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: OP_RDMA_WRITE_IMMED\n");
+
 		/* type and outbound rdma write transfer size */
 		dto->transfered_length = cookie->val.dto.size;
 		ext_data->type = DAT_IB_RDMA_WRITE_IMMED;
 		break;
 	case OP_RECEIVE_IMM:
-		dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: OP_RECEIVE_RDMA_IMMED\n");
-		
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: OP_RECEIVE_RDMA_IMMED\n");
+
 		/* immed recvd, type and inbound rdma write transfer size */
 		dto->transfered_length = DAPL_GET_CQE_BYTESNUM(cqe_ptr);
 		ext_data->type = DAT_IB_RDMA_WRITE_IMMED_DATA;
 		ext_data->val.immed.data = DAPL_GET_CQE_IMMED_DATA(cqe_ptr);
 		break;
 	case OP_RECEIVE_MSG_IMM:
-		dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: OP_RECEIVE_MSG_IMMED\n");
-		
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: OP_RECEIVE_MSG_IMMED\n");
+
 		/* immed recvd, type and inbound recv message transfer size */
 		dto->transfered_length = DAPL_GET_CQE_BYTESNUM(cqe_ptr);
 		ext_data->type = DAT_IB_RECV_IMMED_DATA;
 		ext_data->val.immed.data = DAPL_GET_CQE_IMMED_DATA(cqe_ptr);
 		break;
 	case OP_COMP_AND_SWAP:
-                dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: COMP_AND_SWAP_RESP\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: COMP_AND_SWAP_RESP\n");
 
-                /* original data is returned in LMR provided with post */
+		/* original data is returned in LMR provided with post */
 		ext_data->type = DAT_IB_CMP_AND_SWAP;
 		dto->transfered_length = DAPL_GET_CQE_BYTESNUM(cqe_ptr);
 		break;
 	case OP_FETCH_AND_ADD:
-                dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: FETCH_AND_ADD_RESP\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+			     " cqe_to_event_ext: FETCH_AND_ADD_RESP\n");
 
 		/* original data is returned in LMR provided with post */
 		ext_data->type = DAT_IB_FETCH_AND_ADD;
 		dto->transfered_length = DAPL_GET_CQE_BYTESNUM(cqe_ptr);
 		break;
 	case OP_SEND_UD:
-                dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: UD_SEND\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD, " cqe_to_event_ext: UD_SEND\n");
 
 		/* type and outbound send transfer size */
 		ext_data->type = DAT_IB_UD_SEND;
 		dto->transfered_length = cookie->val.dto.size;
 		break;
 	case OP_RECV_UD:
-                dapl_dbg_log (DAPL_DBG_TYPE_EVD,
-                                " cqe_to_event_ext: UD_RECV\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_EVD, " cqe_to_event_ext: UD_RECV\n");
 
 		/* type and inbound recv message transfer size */
 		ext_data->type = DAT_IB_UD_RECV;

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_mem.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_mem.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_mem.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2005-2007 Intel Corporation.  All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
+	/*
+	 * Copyright (c) 2005-2007 Intel Corporation.  All rights reserved.
+	 *
+	 * This Software is licensed under one of the following licenses:
+	 *
+	 * 1) under the terms of the "Common Public License 1.0" a copy of which is
+	 *    available from the Open Source Initiative, see
+	 *    http://www.opensource.org/licenses/cpl.php.
+	 *
+	 * 2) under the terms of the "The BSD License" a copy of which is
+	 *    available from the Open Source Initiative, see
+	 *    http://www.opensource.org/licenses/bsd-license.php.
+	 *
+	 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
+	 *    copy of which is available from the Open Source Initiative, see
+	 *    http://www.opensource.org/licenses/gpl-license.php.
+	 *
+	 * Licensee has the right to choose one of the above licenses.
+	 *
+	 * Redistributions of source code must retain the above copyright
+	 * notice and one of the license notices.
+	 *
+	 * Redistributions in binary form must reproduce both the above copyright
+	 * notice, one of the license notices in the documentation
+	 * and/or other materials provided with the distribution.
+	 */
 
 /**********************************************************************
  * 
@@ -35,13 +35,6 @@
  *
  **********************************************************************/
 
-#include <sys/ioctl.h>  /* for IOCTL's */
-#include <sys/types.h>  /* for socket(2) and related bits and pieces */
-#include <sys/socket.h> /* for socket(2) */
-#include <net/if.h>     /* for struct ifreq */
-#include <net/if_arp.h> /* for ARPHRD_ETHER */
-#include <unistd.h>		/* for _SC_CLK_TCK */
-
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_lmr_util.h"
@@ -61,10 +54,9 @@
  *	ibv_access_flags
  *
  */
-STATIC _INLINE_ int
-dapls_convert_privileges(IN DAT_MEM_PRIV_FLAGS privileges)
+STATIC _INLINE_ int dapls_convert_privileges(IN DAT_MEM_PRIV_FLAGS privileges)
 {
-	int	access = 0;
+	int access = 0;
 
 	/*
 	 * if (DAT_MEM_PRIV_LOCAL_READ_FLAG & privileges) do nothing
@@ -80,11 +72,10 @@
 	if (DAT_MEM_PRIV_REMOTE_READ_FLAG & privileges)
 		access |= IBV_ACCESS_REMOTE_READ;
 #ifdef DAT_EXTENSIONS
-        if (DAT_IB_MEM_PRIV_REMOTE_ATOMIC & privileges)
-                access |= IBV_ACCESS_REMOTE_ATOMIC;
+	if (DAT_IB_MEM_PRIV_REMOTE_ATOMIC & privileges)
+		access |= IBV_ACCESS_REMOTE_ATOMIC;
 #endif
 
-
 	return access;
 }
 
@@ -105,17 +96,15 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN
-dapls_ib_pd_alloc(IN DAPL_IA *ia_ptr, IN DAPL_PZ *pz)
+DAT_RETURN dapls_ib_pd_alloc(IN DAPL_IA * ia_ptr, IN DAPL_PZ * pz)
 {
 	/* get a protection domain */
 	pz->pd_handle = ibv_alloc_pd(ia_ptr->hca_ptr->ib_hca_handle);
-	if (!pz->pd_handle) 
-		return(dapl_convert_errno(ENOMEM,"alloc_pd"));
+	if (!pz->pd_handle)
+		return (dapl_convert_errno(ENOMEM, "alloc_pd"));
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " pd_alloc: pd_handle=%p\n", 
-		     pz->pd_handle );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " pd_alloc: pd_handle=%p\n", pz->pd_handle);
 
 	return DAT_SUCCESS;
 }
@@ -137,13 +126,12 @@
  *      DAT_INVALID_STATE
  *
  */
-DAT_RETURN
-dapls_ib_pd_free(IN DAPL_PZ *pz )
+DAT_RETURN dapls_ib_pd_free(IN DAPL_PZ * pz)
 {
 	if (pz->pd_handle != IB_INVALID_HANDLE) {
 		if (ibv_dealloc_pd(pz->pd_handle))
-			return(dapl_convert_errno(errno,"ibv_dealloc_pd"));
-		pz->pd_handle = IB_INVALID_HANDLE;	
+			return (dapl_convert_errno(errno, "ibv_dealloc_pd"));
+		pz->pd_handle = IB_INVALID_HANDLE;
 	}
 	return DAT_SUCCESS;
 }
@@ -168,59 +156,55 @@
  *
  */
 DAT_RETURN
-dapls_ib_mr_register(IN  DAPL_IA *ia_ptr,
-		     IN  DAPL_LMR *lmr,
-		     IN  DAT_PVOID virt_addr,
-		     IN  DAT_VLEN length,
-		     IN  DAT_MEM_PRIV_FLAGS privileges,
-		     IN  DAT_VA_TYPE va_type)
+dapls_ib_mr_register(IN DAPL_IA * ia_ptr,
+		     IN DAPL_LMR * lmr,
+		     IN DAT_PVOID virt_addr,
+		     IN DAT_VLEN length,
+		     IN DAT_MEM_PRIV_FLAGS privileges, IN DAT_VA_TYPE va_type)
 {
-	ib_pd_handle_t	ib_pd_handle;
+	ib_pd_handle_t ib_pd_handle;
 	struct ibv_device *ibv_dev = ia_ptr->hca_ptr->ib_hca_handle->device;
 
-	ib_pd_handle = ((DAPL_PZ *)lmr->param.pz_handle)->pd_handle;
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " mr_register: ia=%p, lmr=%p va=%p ln=%d pv=0x%x\n", 
-		     ia_ptr, lmr, virt_addr, length, privileges );
+	ib_pd_handle = ((DAPL_PZ *) lmr->param.pz_handle)->pd_handle;
 
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " mr_register: ia=%p, lmr=%p va=%p ln=%d pv=0x%x\n",
+		     ia_ptr, lmr, virt_addr, length, privileges);
+
 	/* TODO: shared memory */
 	if (lmr->param.mem_type == DAT_MEM_TYPE_SHARED_VIRTUAL) {
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-			     " mr_register_shared: NOT IMPLEMENTED\n");    
-		return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+			     " mr_register_shared: NOT IMPLEMENTED\n");
+		return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 	}
 
-        /* iWARP only support */
+	/* iWARP only support */
 	if ((va_type == DAT_VA_TYPE_ZB) &&
 	    (ibv_dev->transport_type != IBV_TRANSPORT_IWARP)) {
-                dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-                        " va_type == DAT_VA_TYPE_ZB: NOT SUPPORTED\n");
-                return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
-        }
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     " va_type == DAT_VA_TYPE_ZB: NOT SUPPORTED\n");
+		return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+	}
 
-	/* local read is default on IB */ 
-	lmr->mr_handle = 
-		ibv_reg_mr(((DAPL_PZ *)lmr->param.pz_handle)->pd_handle, 
-			    virt_addr, 
-			    length, 
-			    dapls_convert_privileges(privileges));
+	/* local read is default on IB */
+	lmr->mr_handle =
+	    ibv_reg_mr(((DAPL_PZ *) lmr->param.pz_handle)->pd_handle,
+		       virt_addr, length, dapls_convert_privileges(privileges));
 
-	if (!lmr->mr_handle) 
-		return(dapl_convert_errno(ENOMEM,"reg_mr"));
-	
-	lmr->param.lmr_context = lmr->mr_handle->lkey; 
+	if (!lmr->mr_handle)
+		return (dapl_convert_errno(ENOMEM, "reg_mr"));
+
+	lmr->param.lmr_context = lmr->mr_handle->lkey;
 	lmr->param.rmr_context = lmr->mr_handle->rkey;
 	lmr->param.registered_size = length;
-	lmr->param.registered_address = (DAT_VADDR)(uintptr_t)virt_addr;
+	lmr->param.registered_address = (DAT_VADDR) (uintptr_t) virt_addr;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " mr_register: mr=%p addr=%p h %x pd %p ctx %p "
-		     "lkey=0x%x rkey=0x%x priv=%x\n", 
-		     lmr->mr_handle, lmr->mr_handle->addr, 
-		     lmr->mr_handle->handle,	
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " mr_register: mr=%p addr=%p pd %p ctx %p "
+		     "lkey=0x%x rkey=0x%x priv=%x\n",
+		     lmr->mr_handle, lmr->mr_handle->addr,
 		     lmr->mr_handle->pd, lmr->mr_handle->context,
-		     lmr->mr_handle->lkey, lmr->mr_handle->rkey, 
+		     lmr->mr_handle->lkey, lmr->mr_handle->rkey,
 		     length, dapls_convert_privileges(privileges));
 
 	return DAT_SUCCESS;
@@ -242,18 +226,16 @@
  *	DAT_INVALID_STATE
  *
  */
-DAT_RETURN
-dapls_ib_mr_deregister(IN DAPL_LMR *lmr)
+DAT_RETURN dapls_ib_mr_deregister(IN DAPL_LMR * lmr)
 {
 	if (lmr->mr_handle != IB_INVALID_HANDLE) {
 		if (ibv_dereg_mr(lmr->mr_handle))
-			return(dapl_convert_errno(errno,"dereg_pd"));
+			return (dapl_convert_errno(errno, "dereg_pd"));
 		lmr->mr_handle = IB_INVALID_HANDLE;
 	}
 	return DAT_SUCCESS;
 }
 
-
 /*
  * dapl_ib_mr_register_shared
  *
@@ -274,15 +256,15 @@
  *
  */
 DAT_RETURN
-dapls_ib_mr_register_shared(IN DAPL_IA *ia_ptr,
-			    IN DAPL_LMR *lmr,
+dapls_ib_mr_register_shared(IN DAPL_IA * ia_ptr,
+			    IN DAPL_LMR * lmr,
 			    IN DAT_MEM_PRIV_FLAGS privileges,
 			    IN DAT_VA_TYPE va_type)
 {
-    dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-	         " mr_register_shared: NOT IMPLEMENTED\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+		     " mr_register_shared: NOT IMPLEMENTED\n");
 
-    return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -301,14 +283,12 @@
  *	DAT_INSUFFICIENT_RESOURCES
  *
  */
-DAT_RETURN
-dapls_ib_mw_alloc (IN DAPL_RMR *rmr)
+DAT_RETURN dapls_ib_mw_alloc(IN DAPL_RMR * rmr)
 {
 
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_alloc: NOT IMPLEMENTED\n");
-   	
-	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_alloc: NOT IMPLEMENTED\n");
+
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -327,13 +307,11 @@
  *	DAT_INVALID_STATE
  *
  */
-DAT_RETURN
-dapls_ib_mw_free(IN DAPL_RMR *rmr)
-{	
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_free: NOT IMPLEMENTED\n");
+DAT_RETURN dapls_ib_mw_free(IN DAPL_RMR * rmr)
+{
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_free: NOT IMPLEMENTED\n");
 
-	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -354,19 +332,17 @@
  *
  */
 DAT_RETURN
-dapls_ib_mw_bind(IN DAPL_RMR *rmr,
-		 IN DAPL_LMR *lmr,
-		 IN DAPL_EP  *ep,
-		 IN DAPL_COOKIE *cookie,
+dapls_ib_mw_bind(IN DAPL_RMR * rmr,
+		 IN DAPL_LMR * lmr,
+		 IN DAPL_EP * ep,
+		 IN DAPL_COOKIE * cookie,
 		 IN DAT_VADDR virtual_address,
 		 IN DAT_VLEN length,
-		 IN DAT_MEM_PRIV_FLAGS mem_priv,
-		 IN DAT_BOOLEAN is_signaled)
+		 IN DAT_MEM_PRIV_FLAGS mem_priv, IN DAT_BOOLEAN is_signaled)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_bind: NOT IMPLEMENTED\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_bind: NOT IMPLEMENTED\n");
 
-	return DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -388,15 +364,13 @@
  *
  */
 DAT_RETURN
-dapls_ib_mw_unbind(IN DAPL_RMR *rmr,
-		   IN DAPL_EP  *ep,
-		   IN DAPL_COOKIE *cookie,
-		   IN DAT_BOOLEAN is_signaled )
+dapls_ib_mw_unbind(IN DAPL_RMR * rmr,
+		   IN DAPL_EP * ep,
+		   IN DAPL_COOKIE * cookie, IN DAT_BOOLEAN is_signaled)
 {
-	dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-		     " mw_unbind: NOT IMPLEMENTED\n");
-	
-	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);  
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, " mw_unbind: NOT IMPLEMENTED\n");
+
+	return DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 }
 
 /*
@@ -406,4 +380,3 @@
  *  tab-width: 8
  * End:
  */
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_qp.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_qp.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_qp.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,38 +57,36 @@
  *
  */
 DAT_RETURN
-dapls_ib_qp_alloc (
-    IN  DAPL_IA		*ia_ptr,
-    IN  DAPL_EP		*ep_ptr,
-    IN  DAPL_EP		*ep_ctx_ptr )
+dapls_ib_qp_alloc(IN DAPL_IA * ia_ptr,
+		  IN DAPL_EP * ep_ptr, IN DAPL_EP * ep_ctx_ptr)
 {
-   	DAT_EP_ATTR		*attr;
-	DAPL_EVD		*rcv_evd, *req_evd;
-	ib_cq_handle_t		rcv_cq, req_cq;
-	ib_pd_handle_t		ib_pd_handle;
+	DAT_EP_ATTR *attr;
+	DAPL_EVD *rcv_evd, *req_evd;
+	ib_cq_handle_t rcv_cq, req_cq;
+	ib_pd_handle_t ib_pd_handle;
 	struct ibv_qp_init_attr qp_create;
-			
-	dapl_dbg_log (DAPL_DBG_TYPE_EP,
-		      " qp_alloc: ia_ptr %p ep_ptr %p ep_ctx_ptr %p\n",
-		      ia_ptr, ep_ptr, ep_ctx_ptr);
 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     " qp_alloc: ia_ptr %p ep_ptr %p ep_ctx_ptr %p\n",
+		     ia_ptr, ep_ptr, ep_ctx_ptr);
+
 	attr = &ep_ptr->param.ep_attr;
-	ib_pd_handle = ((DAPL_PZ *)ep_ptr->param.pz_handle)->pd_handle;
-	rcv_evd	= (DAPL_EVD *) ep_ptr->param.recv_evd_handle;
-	req_evd	= (DAPL_EVD *) ep_ptr->param.request_evd_handle;
+	ib_pd_handle = ((DAPL_PZ *) ep_ptr->param.pz_handle)->pd_handle;
+	rcv_evd = (DAPL_EVD *) ep_ptr->param.recv_evd_handle;
+	req_evd = (DAPL_EVD *) ep_ptr->param.request_evd_handle;
 
 	/* 
 	 * DAT allows usage model of EP's with no EVD's but IB does not. 
 	 * Create a CQ with zero entries under the covers to support and 
 	 * catch any invalid posting. 
 	 */
-	if ( rcv_evd != DAT_HANDLE_NULL ) 
+	if (rcv_evd != DAT_HANDLE_NULL)
 		rcv_cq = rcv_evd->ib_cq_handle;
-	else if (!ia_ptr->hca_ptr->ib_trans.ib_cq_empty) 
+	else if (!ia_ptr->hca_ptr->ib_trans.ib_cq_empty)
 		rcv_cq = ia_ptr->hca_ptr->ib_trans.ib_cq_empty;
 	else {
-		struct ibv_comp_channel *channel = 
-					ia_ptr->hca_ptr->ib_trans.ib_cq;
+		struct ibv_comp_channel *channel =
+		    ia_ptr->hca_ptr->ib_trans.ib_cq;
 #ifdef CQ_WAIT_OBJECT
 		if (rcv_evd->cq_wait_obj_handle)
 			channel = rcv_evd->cq_wait_obj_handle;
@@ -97,34 +95,35 @@
 		rcv_cq = ibv_create_cq(ia_ptr->hca_ptr->ib_hca_handle,
 				       0, NULL, channel, 0);
 
-		if (rcv_cq == IB_INVALID_HANDLE) 
-			return(dapl_convert_errno(ENOMEM, "create_cq"));
+		if (rcv_cq == IB_INVALID_HANDLE)
+			return (dapl_convert_errno(ENOMEM, "create_cq"));
 
 		ia_ptr->hca_ptr->ib_trans.ib_cq_empty = rcv_cq;
 	}
-	if (req_evd != DAT_HANDLE_NULL) 
+	if (req_evd != DAT_HANDLE_NULL)
 		req_cq = req_evd->ib_cq_handle;
-	else 
+	else
 		req_cq = ia_ptr->hca_ptr->ib_trans.ib_cq_empty;
 
 	/* Setup attributes and create qp */
-	dapl_os_memzero((void*)&qp_create, sizeof(qp_create));
+	dapl_os_memzero((void *)&qp_create, sizeof(qp_create));
 	qp_create.send_cq = req_cq;
 	qp_create.cap.max_send_wr = attr->max_request_dtos;
 	qp_create.cap.max_send_sge = attr->max_request_iov;
-	qp_create.cap.max_inline_data = ia_ptr->hca_ptr->ib_trans.max_inline_send; 
+	qp_create.cap.max_inline_data =
+	    ia_ptr->hca_ptr->ib_trans.max_inline_send;
 	qp_create.qp_type = IBV_QPT_RC;
 
 #ifdef DAT_EXTENSIONS
 	if (attr->service_type == DAT_IB_SERVICE_TYPE_UD) {
 		qp_create.qp_type = IBV_QPT_UD;
-		if (attr->max_message_size > 
+		if (attr->max_message_size >
 		    (128 << ia_ptr->hca_ptr->ib_trans.mtu)) {
 			return (DAT_INVALID_PARAMETER | DAT_INVALID_ARG6);
 		}
 	}
 #endif
-	qp_create.qp_context = (void*)ep_ptr;
+	qp_create.qp_context = (void *)ep_ptr;
 
 	/* ibv assumes rcv_cq is never NULL, set to req_cq */
 	if (rcv_cq == NULL) {
@@ -137,21 +136,20 @@
 		qp_create.cap.max_recv_sge = attr->max_recv_iov;
 	}
 
-	ep_ptr->qp_handle = ibv_create_qp( ib_pd_handle, &qp_create);
-	if (!ep_ptr->qp_handle) 
-		return(dapl_convert_errno(ENOMEM, "create_qp"));
-	
-	dapl_dbg_log (	DAPL_DBG_TYPE_EP,
-			" qp_alloc: qpn %p sq %d,%d rq %d,%d\n", 
-			ep_ptr->qp_handle->qp_num,
-			qp_create.cap.max_send_wr,qp_create.cap.max_send_sge,
-			qp_create.cap.max_recv_wr,qp_create.cap.max_recv_sge );
+	ep_ptr->qp_handle = ibv_create_qp(ib_pd_handle, &qp_create);
+	if (!ep_ptr->qp_handle)
+		return (dapl_convert_errno(ENOMEM, "create_qp"));
 
-	/* Setup QP attributes for INIT state on the way out */ 
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     " qp_alloc: qpn %p sq %d,%d rq %d,%d\n",
+		     ep_ptr->qp_handle->qp_num,
+		     qp_create.cap.max_send_wr, qp_create.cap.max_send_sge,
+		     qp_create.cap.max_recv_wr, qp_create.cap.max_recv_sge);
+
+	/* Setup QP attributes for INIT state on the way out */
 	if (dapls_modify_qp_state(ep_ptr->qp_handle,
-				  IBV_QPS_INIT,
-				  NULL )  != DAT_SUCCESS ) {
-		ibv_destroy_qp(ep_ptr->qp_handle);		
+				  IBV_QPS_INIT, NULL) != DAT_SUCCESS) {
+		ibv_destroy_qp(ep_ptr->qp_handle);
 		ep_ptr->qp_handle = IB_INVALID_HANDLE;
 		return DAT_INTERNAL_ERROR;
 	}
@@ -176,21 +174,18 @@
  *  dapl_convert_errno
  *
  */
-DAT_RETURN
-dapls_ib_qp_free (
-    IN  DAPL_IA		*ia_ptr,
-    IN  DAPL_EP		*ep_ptr )
+DAT_RETURN dapls_ib_qp_free(IN DAPL_IA * ia_ptr, IN DAPL_EP * ep_ptr)
 {
-	dapl_dbg_log (DAPL_DBG_TYPE_EP, " qp_free:  ep_ptr %p qp %p\n",	
-		      ep_ptr, ep_ptr->qp_handle);
+	dapl_dbg_log(DAPL_DBG_TYPE_EP, " qp_free:  ep_ptr %p qp %p\n",
+		     ep_ptr, ep_ptr->qp_handle);
 
 	if (ep_ptr->qp_handle != IB_INVALID_HANDLE) {
 		/* force error state to flush queue, then destroy */
 		dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_ERR, NULL);
-		
-		if (ibv_destroy_qp(ep_ptr->qp_handle)) 
-			return(dapl_convert_errno(errno,"destroy_qp"));
 
+		if (ibv_destroy_qp(ep_ptr->qp_handle))
+			return (dapl_convert_errno(errno, "destroy_qp"));
+
 		ep_ptr->qp_handle = IB_INVALID_HANDLE;
 	}
 
@@ -220,13 +215,11 @@
  *
  */
 DAT_RETURN
-dapls_ib_qp_modify (
-    IN  DAPL_IA		*ia_ptr,
-    IN  DAPL_EP		*ep_ptr,
-    IN  DAT_EP_ATTR	*attr )
+dapls_ib_qp_modify(IN DAPL_IA * ia_ptr,
+		   IN DAPL_EP * ep_ptr, IN DAT_EP_ATTR * attr)
 {
-	struct ibv_qp_attr	qp_attr;
-	
+	struct ibv_qp_attr qp_attr;
+
 	if (ep_ptr->qp_handle == IB_INVALID_HANDLE)
 		return DAT_INVALID_PARAMETER;
 
@@ -235,39 +228,39 @@
 	 * of current state but the only way to be sure is with
 	 * a user mode ibv_query_qp call which is NOT available 
 	 */
-	
+
 	/* move to error state if necessary */
 	if ((ep_ptr->qp_state == IB_QP_STATE_ERROR) &&
 	    (ep_ptr->qp_handle->state != IBV_QPS_ERR)) {
-		return (dapls_modify_qp_state(ep_ptr->qp_handle, 
+		return (dapls_modify_qp_state(ep_ptr->qp_handle,
 					      IBV_QPS_ERR, NULL));
 	}
 
 	/*
 	 * Check if we have the right qp_state to modify attributes
 	 */
-	if ((ep_ptr->qp_handle->state  != IBV_QPS_RTR ) && 
-	    (ep_ptr->qp_handle->state  != IBV_QPS_RTS )) 
+	if ((ep_ptr->qp_handle->state != IBV_QPS_RTR) &&
+	    (ep_ptr->qp_handle->state != IBV_QPS_RTS))
 		return DAT_INVALID_STATE;
 
 	/* Adjust to current EP attributes */
-	dapl_os_memzero((void*)&qp_attr, sizeof(qp_attr));
+	dapl_os_memzero((void *)&qp_attr, sizeof(qp_attr));
 	qp_attr.cap.max_send_wr = attr->max_request_dtos;
 	qp_attr.cap.max_recv_wr = attr->max_recv_dtos;
 	qp_attr.cap.max_send_sge = attr->max_request_iov;
 	qp_attr.cap.max_recv_sge = attr->max_recv_iov;
 
-	dapl_dbg_log (DAPL_DBG_TYPE_EP,
-		      "modify_qp: qp %p sq %d,%d, rq %d,%d\n", 
-		      ep_ptr->qp_handle, 
-		      qp_attr.cap.max_send_wr, qp_attr.cap.max_send_sge, 
-		      qp_attr.cap.max_recv_wr, qp_attr.cap.max_recv_sge );
+	dapl_dbg_log(DAPL_DBG_TYPE_EP,
+		     "modify_qp: qp %p sq %d,%d, rq %d,%d\n",
+		     ep_ptr->qp_handle,
+		     qp_attr.cap.max_send_wr, qp_attr.cap.max_send_sge,
+		     qp_attr.cap.max_recv_wr, qp_attr.cap.max_recv_sge);
 
 	if (ibv_modify_qp(ep_ptr->qp_handle, &qp_attr, IBV_QP_CAP)) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-			      "modify_qp: modify ep %p qp %p failed\n",
-			      ep_ptr, ep_ptr->qp_handle);
-		return(dapl_convert_errno(errno,"modify_qp_state"));
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "modify_qp: modify ep %p qp %p failed\n",
+			     ep_ptr, ep_ptr->qp_handle);
+		return (dapl_convert_errno(errno, "modify_qp_state"));
 	}
 
 	return DAT_SUCCESS;
@@ -288,10 +281,19 @@
  * 	void
  *
  */
-void
-dapls_ib_reinit_ep (
-	IN  DAPL_EP	*ep_ptr)
+#if defined(_WIN32) || defined(_WIN64)
+void dapls_ib_reinit_ep(IN DAPL_EP * ep_ptr)
 {
+	/* work around bug in low level driver - 3/24/09 */
+	/* RTS -> RESET -> INIT -> ERROR QP transition crashes system */
+	if (ep_ptr->qp_handle != IB_INVALID_HANDLE) {
+		dapls_ib_qp_free(ep_ptr->header.owner_ia, ep_ptr);
+		dapls_ib_qp_alloc(ep_ptr->header.owner_ia, ep_ptr, ep_ptr);
+	}
+}
+#else				// _WIN32 || _WIN64
+void dapls_ib_reinit_ep(IN DAPL_EP * ep_ptr)
+{
 	if (ep_ptr->qp_handle != IB_INVALID_HANDLE &&
 	    ep_ptr->qp_handle->qp_type != IBV_QPT_UD) {
 		/* move to RESET state and then to INIT */
@@ -299,61 +301,59 @@
 		dapls_modify_qp_state(ep_ptr->qp_handle, IBV_QPS_INIT, 0);
 	}
 }
+#endif				// _WIN32 || _WIN64
 
 /* 
  * Generic QP modify for init, reset, error, RTS, RTR
  * For UD, create_ah on RTR, qkey on INIT
  */
 DAT_RETURN
-dapls_modify_qp_state ( IN ib_qp_handle_t	qp_handle,
-			IN ib_qp_state_t	qp_state,
-			IN struct ib_cm_handle	*cm_ptr )
+dapls_modify_qp_state(IN ib_qp_handle_t qp_handle,
+		      IN ib_qp_state_t qp_state, IN struct ib_cm_handle *cm_ptr)
 {
-	struct ibv_qp_attr 	qp_attr;
-	enum ibv_qp_attr_mask	mask = IBV_QP_STATE;
-	DAPL_EP			*ep_ptr = (DAPL_EP*)qp_handle->qp_context;
-	DAPL_IA			*ia_ptr = ep_ptr->header.owner_ia;
-	ib_qp_cm_t		*qp_cm = &cm_ptr->dst;
-	int			ret;
-			
-	dapl_os_memzero((void*)&qp_attr, sizeof(qp_attr));
+	struct ibv_qp_attr qp_attr;
+	enum ibv_qp_attr_mask mask = IBV_QP_STATE;
+	DAPL_EP *ep_ptr = (DAPL_EP *) qp_handle->qp_context;
+	DAPL_IA *ia_ptr = ep_ptr->header.owner_ia;
+	ib_qp_cm_t *qp_cm = &cm_ptr->dst;
+	int ret;
+
+	dapl_os_memzero((void *)&qp_attr, sizeof(qp_attr));
 	qp_attr.qp_state = qp_state;
 	switch (qp_state) {
 		/* additional attributes with RTR and RTS */
-		case IBV_QPS_RTR:
+	case IBV_QPS_RTR:
 		{
 			dapl_dbg_log(DAPL_DBG_TYPE_EP,
 				     " QPS_RTR: type %d state %d qpn %x lid %x"
 				     " port %x ep %p qp_state %d\n",
-			             qp_handle->qp_type, qp_handle->qp_type,
-				     qp_cm->qpn, qp_cm->lid, qp_cm->port, 
+				     qp_handle->qp_type, qp_handle->qp_type,
+				     qp_cm->qpn, qp_cm->lid, qp_cm->port,
 				     ep_ptr, ep_ptr->qp_state);
-			
-			mask |= IBV_QP_AV                 |
-				IBV_QP_PATH_MTU           |
-				IBV_QP_DEST_QPN           |
-				IBV_QP_RQ_PSN             |
-				IBV_QP_MAX_DEST_RD_ATOMIC |
-				IBV_QP_MIN_RNR_TIMER;
 
+			mask |= IBV_QP_AV |
+			    IBV_QP_PATH_MTU |
+			    IBV_QP_DEST_QPN |
+			    IBV_QP_RQ_PSN |
+			    IBV_QP_MAX_DEST_RD_ATOMIC | IBV_QP_MIN_RNR_TIMER;
+
 			qp_attr.dest_qp_num = qp_cm->qpn;
 			qp_attr.rq_psn = 1;
-			qp_attr.path_mtu = 
-				ia_ptr->hca_ptr->ib_trans.mtu;
-			qp_attr.max_dest_rd_atomic = 
-				ep_ptr->param.ep_attr.max_rdma_read_out;
+			qp_attr.path_mtu = ia_ptr->hca_ptr->ib_trans.mtu;
+			qp_attr.max_dest_rd_atomic =
+			    ep_ptr->param.ep_attr.max_rdma_read_out;
 			qp_attr.min_rnr_timer =
-				ia_ptr->hca_ptr->ib_trans.rnr_timer;
-						
+			    ia_ptr->hca_ptr->ib_trans.rnr_timer;
+
 			/* address handle. RC and UD */
 			qp_attr.ah_attr.dlid = qp_cm->lid;
 			if (ia_ptr->hca_ptr->ib_trans.global) {
 				qp_attr.ah_attr.is_global = 1;
 				qp_attr.ah_attr.grh.dgid = qp_cm->gid;
-				qp_attr.ah_attr.grh.hop_limit = 
-					ia_ptr->hca_ptr->ib_trans.hop_limit;
-				qp_attr.ah_attr.grh.traffic_class = 
-					ia_ptr->hca_ptr->ib_trans.tclass;
+				qp_attr.ah_attr.grh.hop_limit =
+				    ia_ptr->hca_ptr->ib_trans.hop_limit;
+				qp_attr.ah_attr.grh.traffic_class =
+				    ia_ptr->hca_ptr->ib_trans.tclass;
 			}
 			qp_attr.ah_attr.sl = 0;
 			qp_attr.ah_attr.src_path_bits = 0;
@@ -361,52 +361,52 @@
 #ifdef DAT_EXTENSIONS
 			/* UD: create AH for remote side */
 			if (qp_handle->qp_type == IBV_QPT_UD) {
-				ib_pd_handle_t	pz;
+				ib_pd_handle_t pz;
 				pz = ((DAPL_PZ *)
-					ep_ptr->param.pz_handle)->pd_handle;
+				      ep_ptr->param.pz_handle)->pd_handle;
 				mask = IBV_QP_STATE;
 				cm_ptr->ah = ibv_create_ah(pz,
 							   &qp_attr.ah_attr);
 				if (!cm_ptr->ah)
-					return(dapl_convert_errno(errno,
-								  "ibv_ah"));
-				
+					return (dapl_convert_errno(errno,
+								   "ibv_ah"));
+
 				/* already RTR, multi remote AH's on QP */
 				if (ep_ptr->qp_state == IBV_QPS_RTR ||
 				    ep_ptr->qp_state == IBV_QPS_RTS)
 					return DAT_SUCCESS;
 			}
-#endif			
+#endif
 			break;
-		}		
-		case IBV_QPS_RTS: 
+		}
+	case IBV_QPS_RTS:
 		{
 			/* RC only */
 			if (qp_handle->qp_type == IBV_QPT_RC) {
-				mask |= IBV_QP_SQ_PSN             |
-					IBV_QP_TIMEOUT            |
-					IBV_QP_RETRY_CNT          |
-					IBV_QP_RNR_RETRY          |
-					IBV_QP_MAX_QP_RD_ATOMIC;
-				qp_attr.timeout	= 
+				mask |= IBV_QP_SQ_PSN |
+				    IBV_QP_TIMEOUT |
+				    IBV_QP_RETRY_CNT |
+				    IBV_QP_RNR_RETRY | IBV_QP_MAX_QP_RD_ATOMIC;
+				qp_attr.timeout =
 				    ia_ptr->hca_ptr->ib_trans.ack_timer;
-				qp_attr.retry_cnt = 
+				qp_attr.retry_cnt =
 				    ia_ptr->hca_ptr->ib_trans.ack_retry;
-				qp_attr.rnr_retry = 
+				qp_attr.rnr_retry =
 				    ia_ptr->hca_ptr->ib_trans.rnr_retry;
-				qp_attr.max_rd_atomic = 
+				qp_attr.max_rd_atomic =
 				    ep_ptr->param.ep_attr.max_rdma_read_out;
 			}
 			/* RC and UD */
-			qp_attr.qp_state	= IBV_QPS_RTS;
-			qp_attr.sq_psn		= 1;
+			qp_attr.qp_state = IBV_QPS_RTS;
+			qp_attr.sq_psn = 1;
 
 			dapl_dbg_log(DAPL_DBG_TYPE_EP,
-				" QPS_RTS: psn %x rd_atomic %d ack %d "
-				" retry %d rnr_retry %d ep %p qp_state %d\n",
-				qp_attr.sq_psn, qp_attr.max_rd_atomic, 
-				qp_attr.timeout, qp_attr.retry_cnt, 
-				qp_attr.rnr_retry, ep_ptr, ep_ptr->qp_state);
+				     " QPS_RTS: psn %x rd_atomic %d ack %d "
+				     " retry %d rnr_retry %d ep %p qp_state %d\n",
+				     qp_attr.sq_psn, qp_attr.max_rd_atomic,
+				     qp_attr.timeout, qp_attr.retry_cnt,
+				     qp_attr.rnr_retry, ep_ptr,
+				     ep_ptr->qp_state);
 #ifdef DAT_EXTENSIONS
 			if (qp_handle->qp_type == IBV_QPT_UD) {
 				/* already RTS, multi remote AH's on QP */
@@ -418,17 +418,17 @@
 #endif
 			break;
 		}
-		case IBV_QPS_INIT: 
+	case IBV_QPS_INIT:
 		{
 			mask |= IBV_QP_PKEY_INDEX | IBV_QP_PORT;
 			if (qp_handle->qp_type == IBV_QPT_RC) {
 				mask |= IBV_QP_ACCESS_FLAGS;
-				qp_attr.qp_access_flags = 
-					IBV_ACCESS_LOCAL_WRITE |
-					IBV_ACCESS_REMOTE_WRITE |
-					IBV_ACCESS_REMOTE_READ |
-					IBV_ACCESS_REMOTE_ATOMIC |
-					IBV_ACCESS_MW_BIND;
+				qp_attr.qp_access_flags =
+				    IBV_ACCESS_LOCAL_WRITE |
+				    IBV_ACCESS_REMOTE_WRITE |
+				    IBV_ACCESS_REMOTE_READ |
+				    IBV_ACCESS_REMOTE_ATOMIC |
+				    IBV_ACCESS_MW_BIND;
 			}
 #ifdef DAT_EXTENSIONS
 			if (qp_handle->qp_type == IBV_QPT_UD) {
@@ -439,18 +439,18 @@
 				qp_attr.qkey = SCM_UD_QKEY;
 			}
 #endif
-			qp_attr.pkey_index  = 0;
+			qp_attr.pkey_index = 0;
 			qp_attr.port_num = ia_ptr->hca_ptr->port_num;
-									
-			dapl_dbg_log (DAPL_DBG_TYPE_EP,
-				" QPS_INIT: pi %x port %x acc %x qkey 0x%x\n",
-				qp_attr.pkey_index, qp_attr.port_num,
-				qp_attr.qp_access_flags, qp_attr.qkey);
+
+			dapl_dbg_log(DAPL_DBG_TYPE_EP,
+				     " QPS_INIT: pi %x port %x acc %x qkey 0x%x\n",
+				     qp_attr.pkey_index, qp_attr.port_num,
+				     qp_attr.qp_access_flags, qp_attr.qkey);
 			break;
 		}
-		default:
-			break;
-		
+	default:
+		break;
+
 	}
 
 	ret = ibv_modify_qp(qp_handle, &qp_attr, mask);
@@ -458,7 +458,7 @@
 		ep_ptr->qp_state = qp_state;
 		return DAT_SUCCESS;
 	} else {
-		return(dapl_convert_errno(errno,"modify_qp_state"));
+		return (dapl_convert_errno(errno, "modify_qp_state"));
 	}
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -49,91 +49,93 @@
 static const char rcsid[] = "$Id:  $";
 #endif
 
+#include "openib_osd.h"
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_ib_util.h"
+#include "dapl_osd.h"
 
 #include <stdlib.h>
-#include <netinet/tcp.h>
-#include <sys/utsname.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <unistd.h>	
-#include <fcntl.h>
 
 int g_dapl_loopback_connection = 0;
-int g_scm_pipe[2];
+DAPL_SOCKET g_scm[2];
 
 enum ibv_mtu dapl_ib_mtu(int mtu)
 {
 	switch (mtu) {
-	case 256:  return IBV_MTU_256;
-	case 512:  return IBV_MTU_512;
-	case 1024: return IBV_MTU_1024;
-	case 2048: return IBV_MTU_2048;
-	case 4096: return IBV_MTU_4096;
-	default:   return IBV_MTU_1024;
+	case 256:
+		return IBV_MTU_256;
+	case 512:
+		return IBV_MTU_512;
+	case 1024:
+		return IBV_MTU_1024;
+	case 2048:
+		return IBV_MTU_2048;
+	case 4096:
+		return IBV_MTU_4096;
+	default:
+		return IBV_MTU_1024;
 	}
 }
 
 char *dapl_ib_mtu_str(enum ibv_mtu mtu)
 {
 	switch (mtu) {
-	case IBV_MTU_256:  return "256";
-	case IBV_MTU_512:  return "512";
-	case IBV_MTU_1024: return "1024";
-	case IBV_MTU_2048: return "2048";
-	case IBV_MTU_4096: return "4096";
-	default:           return "1024";
+	case IBV_MTU_256:
+		return "256";
+	case IBV_MTU_512:
+		return "512";
+	case IBV_MTU_1024:
+		return "1024";
+	case IBV_MTU_2048:
+		return "2048";
+	case IBV_MTU_4096:
+		return "4096";
+	default:
+		return "1024";
 	}
 }
 
-/* just get IP address for hostname */
-DAT_RETURN getipaddr( char *addr, int addr_len)
+static DAT_RETURN getlocalipaddr(DAT_SOCK_ADDR * addr, int addr_len)
 {
-	struct sockaddr_in	*ipv4_addr = (struct sockaddr_in*)addr;
-	struct hostent		*h_ptr;
-	struct utsname		ourname;
+	struct sockaddr_in *sin;
+	struct addrinfo *res, hint, *ai;
+	int ret;
+	char hostname[256];
 
-	if (uname(&ourname) < 0)  {
-		 dapl_log(DAPL_DBG_TYPE_ERR, 
-			  " open_hca: uname err=%s\n", strerror(errno));
+	if (addr_len < sizeof(*sin)) {
 		return DAT_INTERNAL_ERROR;
 	}
 
-	h_ptr = gethostbyname(ourname.nodename);
-	if (h_ptr == NULL) {
-		 dapl_log(DAPL_DBG_TYPE_ERR, 
-			  " open_hca: gethostbyname err=%s\n", 
-			  strerror(errno));
-		return DAT_INTERNAL_ERROR;
-	}
+	ret = gethostname(hostname, 256);
+	if (ret)
+		return dapl_convert_errno(ret, "gethostname");
 
-	if (h_ptr->h_addrtype == AF_INET) {
-		int i;
-		struct in_addr  **alist =
-			(struct in_addr **)h_ptr->h_addr_list;
+	memset(&hint, 0, sizeof hint);
+	hint.ai_flags = AI_PASSIVE;
+	hint.ai_family = AF_INET;
+	hint.ai_socktype = SOCK_STREAM;
+	hint.ai_protocol = IPPROTO_TCP;
 
-		*(uint32_t*)&ipv4_addr->sin_addr = 0;
-		ipv4_addr->sin_family = AF_INET;
-		
-		/* Walk the list of addresses for host */
-		for (i=0; alist[i] != NULL; i++) {
-		       /* first non-loopback address */			
-		       if (*(uint32_t*)alist[i] != htonl(0x7f000001)) {
-                               dapl_os_memcpy(&ipv4_addr->sin_addr,
-                                              h_ptr->h_addr_list[i],
-                                              4);
-                               break;
-                       }
-               }
-               /* if no acceptable address found */
-               if (*(uint32_t*)&ipv4_addr->sin_addr == 0)
-			return DAT_INVALID_ADDRESS;
-	} else 
+	ret = getaddrinfo(hostname, NULL, &hint, &res);
+	if (ret) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " getaddrinfo ERR: %d %s\n", ret, gai_strerror(ret));
 		return DAT_INVALID_ADDRESS;
+	}
 
-	return DAT_SUCCESS;
+	ret = DAT_INVALID_ADDRESS;
+	for (ai = res; ai; ai = ai->ai_next) {
+		sin = (struct sockaddr_in *)ai->ai_addr;
+		if (*((uint32_t *) & sin->sin_addr) != htonl(0x7f000001)) {
+			*((struct sockaddr_in *)addr) = *sin;
+			ret = DAT_SUCCESS;
+			break;
+		}
+	}
+
+	freeaddrinfo(res);
+	return ret;
 }
 
 /*
@@ -151,20 +153,83 @@
  * 	0 success, -1 error
  *
  */
-int32_t dapls_ib_init (void)
-{	
-	/* create pipe for waking up thread */
-	if (pipe(g_scm_pipe))
+int32_t dapls_ib_init(void)
+{
+	DAPL_SOCKET listen_socket;
+	struct sockaddr_in addr;
+	socklen_t addrlen = sizeof(addr);
+	int ret;
+
+	listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (listen_socket == DAPL_INVALID_SOCKET)
 		return 1;
 
+	memset(&addr, 0, sizeof addr);
+	addr.sin_family = AF_INET;
+	addr.sin_addr.s_addr = htonl(0x7f000001);
+	ret = bind(listen_socket, (struct sockaddr *)&addr, sizeof addr);
+	if (ret)
+		goto err1;
+
+	ret = getsockname(listen_socket, (struct sockaddr *)&addr, &addrlen);
+	if (ret)
+		goto err1;
+
+	ret = listen(listen_socket, 0);
+	if (ret)
+		goto err1;
+
+	g_scm[1] = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (g_scm[1] == DAPL_INVALID_SOCKET)
+		goto err1;
+
+	ret = connect(g_scm[1], (struct sockaddr *)&addr, sizeof(addr));
+	if (ret)
+		goto err2;
+
+	g_scm[0] = accept(listen_socket, NULL, NULL);
+	if (g_scm[0] == DAPL_INVALID_SOCKET)
+		goto err2;
+
+	closesocket(listen_socket);
 	return 0;
+
+      err2:
+	closesocket(g_scm[1]);
+      err1:
+	closesocket(listen_socket);
+	return 1;
 }
 
-int32_t dapls_ib_release (void)
+int32_t dapls_ib_release(void)
 {
+	closesocket(g_scm[0]);
+	closesocket(g_scm[1]);
 	return 0;
 }
 
+#if defined(_WIN64) || defined(_WIN32)
+int dapls_config_comp_channel(struct ibv_comp_channel *channel)
+{
+	return 0;
+}
+#else				// _WIN64 || WIN32
+int dapls_config_comp_channel(struct ibv_comp_channel *channel)
+{
+	int opts;
+
+	opts = fcntl(channel->fd, F_GETFL);	/* uCQ */
+	if (opts < 0 || fcntl(channel->fd, F_SETFL, opts | O_NONBLOCK) < 0) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " dapls_create_comp_channel: fcntl on ib_cq->fd %d ERR %d %s\n",
+			 channel->fd, opts, strerror(errno));
+		return errno;
+	}
+
+	return 0;
+}
+#endif
+
 /*
  * dapls_ib_open_hca
  *
@@ -182,24 +247,28 @@
  *      dapl_convert_errno
  *
  */
-DAT_RETURN dapls_ib_open_hca (
-        IN   IB_HCA_NAME	hca_name,
-        IN   DAPL_HCA		*hca_ptr)
+DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA * hca_ptr)
 {
 	struct ibv_device **dev_list;
-	int		opts;
-	int		i;
-	DAT_RETURN	dat_status = DAT_SUCCESS;
+	struct ibv_port_attr port_attr;
+	int i;
+	DAT_RETURN dat_status;
 
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		      " open_hca: %s - %p\n", hca_name, hca_ptr );
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " open_hca: %s - %p\n", hca_name, hca_ptr);
 
+	/* get the IP address of the device */
+	dat_status = getlocalipaddr((DAT_SOCK_ADDR *) & hca_ptr->hca_address,
+				    sizeof(DAT_SOCK_ADDR6));
+	if (dat_status != DAT_SUCCESS)
+		return dat_status;
+
 	/* Get list of all IB devices, find match, open */
 	dev_list = ibv_get_device_list(NULL);
 	if (!dev_list) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-			      " open_hca: ibv_get_device_list() failed\n",
-			      hca_name);
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     " open_hca: ibv_get_device_list() failed\n",
+			     hca_name);
 		return DAT_INTERNAL_ERROR;
 	}
 
@@ -211,84 +280,101 @@
 	}
 
 	dapl_log(DAPL_DBG_TYPE_ERR,
-		 " open_hca: device %s not found\n",
-		 hca_name);
+		 " open_hca: device %s not found\n", hca_name);
 	goto err;
 
-found:
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL," open_hca: Found dev %s %016llx\n", 
+      found:
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " open_hca: Found dev %s %016llx\n",
 		     ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
 		     (unsigned long long)
-		     bswap_64(ibv_get_device_guid(hca_ptr->ib_trans.ib_dev)));
+		     ntohll(ibv_get_device_guid(hca_ptr->ib_trans.ib_dev)));
 
 	hca_ptr->ib_hca_handle = ibv_open_device(hca_ptr->ib_trans.ib_dev);
 	if (!hca_ptr->ib_hca_handle) {
-		 dapl_log(DAPL_DBG_TYPE_ERR, 
-			  " open_hca: dev open failed for %s, err=%s\n", 
-			  ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
-			  strerror(errno));
-		 goto err;
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " open_hca: dev open failed for %s, err=%s\n",
+			 ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
+			 strerror(errno));
+		goto err;
 	}
 
+	/* get lid for this hca-port, network order */
+	if (ibv_query_port(hca_ptr->ib_hca_handle,
+			   (uint8_t) hca_ptr->port_num, &port_attr)) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " open_hca: get lid ERR for %s, err=%s\n",
+			 ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
+			 strerror(errno));
+		goto err;
+	} else {
+		hca_ptr->ib_trans.lid = htons(port_attr.lid);
+	}
+
+	/* get gid for this hca-port, network order */
+	if (ibv_query_gid(hca_ptr->ib_hca_handle,
+			  (uint8_t) hca_ptr->port_num,
+			  0, &hca_ptr->ib_trans.gid)) {
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " open_hca: query GID ERR for %s, err=%s\n",
+			 ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
+			 strerror(errno));
+		goto err;
+	}
+
 	/* set RC tunables via enviroment or default */
-	hca_ptr->ib_trans.max_inline_send = 
-		dapl_os_get_env_val("DAPL_MAX_INLINE", INLINE_SEND_DEFAULT);
-	hca_ptr->ib_trans.ack_retry = 
-		dapl_os_get_env_val("DAPL_ACK_RETRY", SCM_ACK_RETRY);
+	hca_ptr->ib_trans.max_inline_send =
+	    dapl_os_get_env_val("DAPL_MAX_INLINE", INLINE_SEND_DEFAULT);
+	hca_ptr->ib_trans.ack_retry =
+	    dapl_os_get_env_val("DAPL_ACK_RETRY", SCM_ACK_RETRY);
 	hca_ptr->ib_trans.ack_timer =
-		dapl_os_get_env_val("DAPL_ACK_TIMER", SCM_ACK_TIMER);
-	hca_ptr->ib_trans.rnr_retry = 
-		dapl_os_get_env_val("DAPL_RNR_RETRY", SCM_RNR_RETRY);
-	hca_ptr->ib_trans.rnr_timer = 
-		dapl_os_get_env_val("DAPL_RNR_TIMER", SCM_RNR_TIMER);
+	    dapl_os_get_env_val("DAPL_ACK_TIMER", SCM_ACK_TIMER);
+	hca_ptr->ib_trans.rnr_retry =
+	    dapl_os_get_env_val("DAPL_RNR_RETRY", SCM_RNR_RETRY);
+	hca_ptr->ib_trans.rnr_timer =
+	    dapl_os_get_env_val("DAPL_RNR_TIMER", SCM_RNR_TIMER);
 	hca_ptr->ib_trans.global =
-		dapl_os_get_env_val("DAPL_GLOBAL_ROUTING", SCM_GLOBAL);
+	    dapl_os_get_env_val("DAPL_GLOBAL_ROUTING", SCM_GLOBAL);
 	hca_ptr->ib_trans.hop_limit =
-		dapl_os_get_env_val("DAPL_HOP_LIMIT", SCM_HOP_LIMIT);
+	    dapl_os_get_env_val("DAPL_HOP_LIMIT", SCM_HOP_LIMIT);
 	hca_ptr->ib_trans.tclass =
-		dapl_os_get_env_val("DAPL_TCLASS", SCM_TCLASS);
+	    dapl_os_get_env_val("DAPL_TCLASS", SCM_TCLASS);
 	hca_ptr->ib_trans.mtu =
-		dapl_ib_mtu(dapl_os_get_env_val("DAPL_IB_MTU", SCM_IB_MTU));
+	    dapl_ib_mtu(dapl_os_get_env_val("DAPL_IB_MTU", SCM_IB_MTU));
 
+#ifndef CQ_WAIT_OBJECT
 	/* initialize cq_lock */
 	dat_status = dapl_os_lock_init(&hca_ptr->ib_trans.cq_lock);
 	if (dat_status != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " open_hca: failed to init cq_lock\n");
 		goto bail;
 	}
-
 	/* EVD events without direct CQ channels, non-blocking */
-	hca_ptr->ib_trans.ib_cq = 
-		ibv_create_comp_channel(hca_ptr->ib_hca_handle);
+	hca_ptr->ib_trans.ib_cq =
+	    ibv_create_comp_channel(hca_ptr->ib_hca_handle);
 	if (hca_ptr->ib_trans.ib_cq == NULL) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " open_hca: ibv_create_comp_channel ERR %s\n",
 			 strerror(errno));
 		goto bail;
 	}
 
-	opts = fcntl(hca_ptr->ib_trans.ib_cq->fd, F_GETFL); /* uCQ */
-	if (opts < 0 || fcntl(hca_ptr->ib_trans.ib_cq->fd, 
-			      F_SETFL, opts | O_NONBLOCK) < 0) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
-			 " open_hca: fcntl on ib_cq->fd %d ERR %d %s\n", 
-			 hca_ptr->ib_trans.ib_cq->fd, opts,
-			 strerror(errno));
+	if (dapls_config_comp_channel(hca_ptr->ib_trans.ib_cq)) {
 		goto bail;
 	}
 
 	if (dapli_cq_thread_init(hca_ptr)) {
-                dapl_log(DAPL_DBG_TYPE_ERR,
-                         " open_hca: cq_thread_init failed for %s\n",
-                         ibv_get_device_name(hca_ptr->ib_trans.ib_dev));
-                goto bail;
-        }
+		dapl_log(DAPL_DBG_TYPE_ERR,
+			 " open_hca: cq_thread_init failed for %s\n",
+			 ibv_get_device_name(hca_ptr->ib_trans.ib_dev));
+		goto bail;
+	}
+#endif				/* CQ_WAIT_OBJECT */
 
 	/* initialize cr_list lock */
 	dat_status = dapl_os_lock_init(&hca_ptr->ib_trans.lock);
 	if (dat_status != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " open_hca: failed to init cr_list lock\n");
 		goto bail;
 	}
@@ -298,48 +384,44 @@
 
 	/* create thread to process inbound connect request */
 	hca_ptr->ib_trans.cr_state = IB_THREAD_INIT;
-	dat_status = dapl_os_thread_create(cr_thread, 
-					   (void*)hca_ptr, 
-					   &hca_ptr->ib_trans.thread );
+	dat_status = dapl_os_thread_create(cr_thread,
+					   (void *)hca_ptr,
+					   &hca_ptr->ib_trans.thread);
 	if (dat_status != DAT_SUCCESS) {
-		dapl_log(DAPL_DBG_TYPE_ERR, 
+		dapl_log(DAPL_DBG_TYPE_ERR,
 			 " open_hca: failed to create thread\n");
 		goto bail;
 	}
-	
+
 	/* wait for thread */
 	while (hca_ptr->ib_trans.cr_state != IB_THREAD_RUN) {
-		struct timespec	sleep, remain;
-		sleep.tv_sec = 0;
-		sleep.tv_nsec = 2000000; /* 2 ms */
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			     " open_hca: waiting for cr_thread\n");
-		nanosleep (&sleep, &remain);
+		dapl_os_sleep_usec(2000);
 	}
 
-	/* get the IP address of the device */
-	dat_status = getipaddr((char*)&hca_ptr->hca_address, 
-				sizeof(DAT_SOCK_ADDR6));
-	
-	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-		     " open_hca: devname %s, port %d, hostname_IP %s\n",  
-		     ibv_get_device_name(hca_ptr->ib_trans.ib_dev), 
-		     hca_ptr->port_num,
-		     inet_ntoa(((struct sockaddr_in *)
-				&hca_ptr->hca_address)->sin_addr));
-		
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " open_hca: devname %s, port %d, hostname_IP %s\n",
+		     ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
+		     hca_ptr->port_num, inet_ntoa(((struct sockaddr_in *)
+						   &hca_ptr->hca_address)->
+						  sin_addr));
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " open_hca: LID 0x%x GID Subnet 0x" F64x " ID 0x" F64x
+		     "\n", ntohs(hca_ptr->ib_trans.lid), (unsigned long long)
+		     htonll(hca_ptr->ib_trans.gid.global.subnet_prefix),
+		     (unsigned long long)htonll(hca_ptr->ib_trans.gid.global.
+						interface_id));
+
 	ibv_free_device_list(dev_list);
 	return dat_status;
 
-bail:
-	ibv_close_device(hca_ptr->ib_hca_handle); 
+      bail:
+	ibv_close_device(hca_ptr->ib_hca_handle);
 	hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
-err:
+      err:
 	ibv_free_device_list(dev_list);
 	return DAT_INTERNAL_ERROR;
 }
 
-
 /*
  * dapls_ib_close_hca
  *
@@ -356,42 +438,41 @@
  *	dapl_convert_errno 
  *
  */
-DAT_RETURN dapls_ib_close_hca (	IN   DAPL_HCA	*hca_ptr )
+DAT_RETURN dapls_ib_close_hca(IN DAPL_HCA * hca_ptr)
 {
-	dapl_dbg_log (DAPL_DBG_TYPE_UTIL," close_hca: %p\n",hca_ptr);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " close_hca: %p\n", hca_ptr);
 
+#ifndef CQ_WAIT_OBJECT
 	dapli_cq_thread_destroy(hca_ptr);
+	dapl_os_lock_destroy(&hca_ptr->ib_trans.cq_lock);
+#endif				/* CQ_WAIT_OBJECT */
 
 	if (hca_ptr->ib_hca_handle != IB_INVALID_HANDLE) {
-		if (ibv_close_device(hca_ptr->ib_hca_handle)) 
-			return(dapl_convert_errno(errno,"ib_close_device"));
+		if (ibv_close_device(hca_ptr->ib_hca_handle))
+			return (dapl_convert_errno(errno, "ib_close_device"));
 		hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
 	}
-	dapl_os_lock_destroy(&hca_ptr->ib_trans.cq_lock);
 
 	/* destroy cr_thread and lock */
 	hca_ptr->ib_trans.cr_state = IB_THREAD_CANCEL;
-	if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
-		dapl_log(DAPL_DBG_TYPE_UTIL, 
-			 " thread_destroy: thread wakeup err = %s\n", 
+	if (send(g_scm[1], "w", sizeof "w", 0) == -1)
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			 " thread_destroy: thread wakeup err = %s\n",
 			 strerror(errno));
 	while (hca_ptr->ib_trans.cr_state != IB_THREAD_EXIT) {
-		struct timespec	sleep, remain;
-		sleep.tv_sec = 0;
-		sleep.tv_nsec = 2000000; /* 2 ms */
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
 			     " close_hca: waiting for cr_thread\n");
-		if (write(g_scm_pipe[1], "w", sizeof "w") == -1)
-			dapl_log(DAPL_DBG_TYPE_UTIL, 
-				 " thread_destroy: thread wakeup err = %s\n", 
+		if (send(g_scm[1], "w", sizeof "w", 0) == -1)
+			dapl_log(DAPL_DBG_TYPE_UTIL,
+				 " thread_destroy: thread wakeup err = %s\n",
 				 strerror(errno));
-		nanosleep (&sleep, &remain);
+		dapl_os_sleep_usec(2000);
 	}
 	dapl_os_lock_destroy(&hca_ptr->ib_trans.lock);
 
 	return (DAT_SUCCESS);
 }
-  
+
 /*
  * dapls_ib_query_hca
  *
@@ -411,122 +492,128 @@
  *	DAT_INVALID_HANDLE
  */
 
-DAT_RETURN dapls_ib_query_hca (
-	IN  DAPL_HCA                       *hca_ptr,
-	OUT DAT_IA_ATTR                    *ia_attr,
-	OUT DAT_EP_ATTR                    *ep_attr,
-	OUT DAT_SOCK_ADDR6                 *ip_addr)
+DAT_RETURN dapls_ib_query_hca(IN DAPL_HCA * hca_ptr,
+			      OUT DAT_IA_ATTR * ia_attr,
+			      OUT DAT_EP_ATTR * ep_attr,
+			      OUT DAT_SOCK_ADDR6 * ip_addr)
 {
-	struct ibv_device_attr	dev_attr;
-	struct ibv_port_attr	port_attr;
+	struct ibv_device_attr dev_attr;
+	struct ibv_port_attr port_attr;
 
 	if (hca_ptr->ib_hca_handle == NULL) {
-		dapl_dbg_log (DAPL_DBG_TYPE_ERR," query_hca: BAD handle\n");
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR, " query_hca: BAD handle\n");
 		return (DAT_INVALID_HANDLE);
 	}
 
 	/* local IP address of device, set during ia_open */
 	if (ip_addr != NULL)
 		memcpy(ip_addr, &hca_ptr->hca_address, sizeof(DAT_SOCK_ADDR6));
-	
-	if (ia_attr == NULL && ep_attr == NULL) 
+
+	if (ia_attr == NULL && ep_attr == NULL)
 		return DAT_SUCCESS;
 
-	/* query verbs for this device and port attributes */	
+	/* query verbs for this device and port attributes */
 	if (ibv_query_device(hca_ptr->ib_hca_handle, &dev_attr) ||
-			     ibv_query_port(hca_ptr->ib_hca_handle, 
-					    hca_ptr->port_num, &port_attr))
-		return(dapl_convert_errno(errno,"ib_query_hca"));
+	    ibv_query_port(hca_ptr->ib_hca_handle,
+			   hca_ptr->port_num, &port_attr))
+		return (dapl_convert_errno(errno, "ib_query_hca"));
 
 	if (ia_attr != NULL) {
-		(void) dapl_os_memzero(ia_attr, sizeof(*ia_attr));
+		(void)dapl_os_memzero(ia_attr, sizeof(*ia_attr));
 		ia_attr->adapter_name[DAT_NAME_MAX_LENGTH - 1] = '\0';
 		ia_attr->vendor_name[DAT_NAME_MAX_LENGTH - 1] = '\0';
-		ia_attr->ia_address_ptr = (DAT_IA_ADDRESS_PTR)&hca_ptr->hca_address;
+		ia_attr->ia_address_ptr =
+		    (DAT_IA_ADDRESS_PTR) & hca_ptr->hca_address;
 
-		dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-			     " query_hca: %s %s \n", 
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+			     " query_hca: %s %s \n",
 			     ibv_get_device_name(hca_ptr->ib_trans.ib_dev),
 			     inet_ntoa(((struct sockaddr_in *)
 					&hca_ptr->hca_address)->sin_addr));
-		
-		ia_attr->hardware_version_major   = dev_attr.hw_ver;
+
+		ia_attr->hardware_version_major = dev_attr.hw_ver;
 		/* ia_attr->hardware_version_minor   = dev_attr.fw_ver; */
-		ia_attr->max_eps                  = dev_attr.max_qp;
-		ia_attr->max_dto_per_ep           = dev_attr.max_qp_wr;
-		ia_attr->max_rdma_read_in         = dev_attr.max_qp_rd_atom;
-		ia_attr->max_rdma_read_out        = dev_attr.max_qp_init_rd_atom;
-		ia_attr->max_rdma_read_per_ep_in  = dev_attr.max_qp_rd_atom;
-		ia_attr->max_rdma_read_per_ep_out = dev_attr.max_qp_init_rd_atom;
-		ia_attr->max_rdma_read_per_ep_in_guaranteed  = DAT_TRUE;
+		ia_attr->max_eps = dev_attr.max_qp;
+		ia_attr->max_dto_per_ep = dev_attr.max_qp_wr;
+		ia_attr->max_rdma_read_in = dev_attr.max_qp_rd_atom;
+		ia_attr->max_rdma_read_out = dev_attr.max_qp_init_rd_atom;
+		ia_attr->max_rdma_read_per_ep_in = dev_attr.max_qp_rd_atom;
+		ia_attr->max_rdma_read_per_ep_out =
+		    dev_attr.max_qp_init_rd_atom;
+		ia_attr->max_rdma_read_per_ep_in_guaranteed = DAT_TRUE;
 		ia_attr->max_rdma_read_per_ep_out_guaranteed = DAT_TRUE;
-		ia_attr->max_evds                 = dev_attr.max_cq;
-		ia_attr->max_evd_qlen             = dev_attr.max_cqe;
+		ia_attr->max_evds = dev_attr.max_cq;
+		ia_attr->max_evd_qlen = dev_attr.max_cqe;
 		ia_attr->max_iov_segments_per_dto = dev_attr.max_sge;
-		ia_attr->max_lmrs                 = dev_attr.max_mr;
-		ia_attr->max_lmr_block_size       = dev_attr.max_mr_size;
-		ia_attr->max_rmrs                 = dev_attr.max_mw;
-		ia_attr->max_lmr_virtual_address  = dev_attr.max_mr_size;
-		ia_attr->max_rmr_target_address   = dev_attr.max_mr_size;
-		ia_attr->max_pzs                  = dev_attr.max_pd;
-		ia_attr->max_message_size         = port_attr.max_msg_sz;
-		ia_attr->max_rdma_size            = port_attr.max_msg_sz;
+		ia_attr->max_lmrs = dev_attr.max_mr;
+		/* 32bit attribute from 64bit, 4G-1 limit, DAT v2 needs fix */
+		ia_attr->max_lmr_block_size = 
+		    (dev_attr.max_mr_size >> 32) ? ~0 : dev_attr.max_mr_size;
+		ia_attr->max_rmrs = dev_attr.max_mw;
+		ia_attr->max_lmr_virtual_address = dev_attr.max_mr_size;
+		ia_attr->max_rmr_target_address = dev_attr.max_mr_size;
+		ia_attr->max_pzs = dev_attr.max_pd;
+		ia_attr->max_message_size = port_attr.max_msg_sz;
+		ia_attr->max_rdma_size = port_attr.max_msg_sz;
 		ia_attr->max_iov_segments_per_rdma_read = dev_attr.max_sge;
 		ia_attr->max_iov_segments_per_rdma_write = dev_attr.max_sge;
-		ia_attr->num_transport_attr       = 0;
-		ia_attr->transport_attr           = NULL;
-		ia_attr->num_vendor_attr          = 0;
-		ia_attr->vendor_attr              = NULL;
+		ia_attr->num_transport_attr = 0;
+		ia_attr->transport_attr = NULL;
+		ia_attr->num_vendor_attr = 0;
+		ia_attr->vendor_attr = NULL;
 #ifdef DAT_EXTENSIONS
-                ia_attr->extension_supported = DAT_EXTENSION_IB;
-                ia_attr->extension_version = DAT_IB_EXTENSION_VERSION;
+		ia_attr->extension_supported = DAT_EXTENSION_IB;
+		ia_attr->extension_version = DAT_IB_EXTENSION_VERSION;
 #endif
 		hca_ptr->ib_trans.mtu = DAPL_MIN(port_attr.active_mtu,
 						 hca_ptr->ib_trans.mtu);
-		hca_ptr->ib_trans.ack_timer = 
-			DAPL_MAX(dev_attr.local_ca_ack_delay,
-				 hca_ptr->ib_trans.ack_timer);
+		hca_ptr->ib_trans.ack_timer =
+		    DAPL_MAX(dev_attr.local_ca_ack_delay,
+			     hca_ptr->ib_trans.ack_timer);
 
 		/* set MTU in transport specific named attribute */
 		hca_ptr->ib_trans.named_attr.name = "DAT_IB_TRANSPORT_MTU";
-		hca_ptr->ib_trans.named_attr.value = 
-			dapl_ib_mtu_str(hca_ptr->ib_trans.mtu);
+		hca_ptr->ib_trans.named_attr.value =
+		    dapl_ib_mtu_str(hca_ptr->ib_trans.mtu);
 
-		dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-			" query_hca: (%x.%x) ep %d ep_q %d evd %d"
-			" evd_q %d mtu %d\n", 
-			ia_attr->hardware_version_major,
-			ia_attr->hardware_version_minor,
-			ia_attr->max_eps, ia_attr->max_dto_per_ep,
-			ia_attr->max_evds, ia_attr->max_evd_qlen,
-			128 << hca_ptr->ib_trans.mtu);
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			     " query_hca: (%x.%x) ep %d ep_q %d evd %d"
+			     " evd_q %d mtu %d\n",
+			     ia_attr->hardware_version_major,
+			     ia_attr->hardware_version_minor,
+			     ia_attr->max_eps, ia_attr->max_dto_per_ep,
+			     ia_attr->max_evds, ia_attr->max_evd_qlen,
+			     128 << hca_ptr->ib_trans.mtu);
 
-		dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-			" query_hca: msg %llu rdma %llu iov %d lmr %d rmr %d"
-			" ack_time %d\n", 
-			ia_attr->max_message_size, ia_attr->max_rdma_size,
-			ia_attr->max_iov_segments_per_dto, ia_attr->max_lmrs, 
-			ia_attr->max_rmrs,hca_ptr->ib_trans.ack_timer );
+		dapl_log(DAPL_DBG_TYPE_UTIL,
+			     " query_hca: msg %llu rdma %llu iov %d lmr %d rmr %d"
+			     " ack_time %d mr %u\n",
+			     ia_attr->max_message_size, ia_attr->max_rdma_size,
+			     ia_attr->max_iov_segments_per_dto,
+			     ia_attr->max_lmrs, ia_attr->max_rmrs,
+			     hca_ptr->ib_trans.ack_timer,
+			     ia_attr->max_lmr_block_size);
 	}
-	
+
 	if (ep_attr != NULL) {
-		(void) dapl_os_memzero(ep_attr, sizeof(*ep_attr));
+		(void)dapl_os_memzero(ep_attr, sizeof(*ep_attr));
 		ep_attr->max_message_size = port_attr.max_msg_sz;
-		ep_attr->max_rdma_size    = port_attr.max_msg_sz;
-		ep_attr->max_recv_dtos    = dev_attr.max_qp_wr;
+		ep_attr->max_rdma_size = port_attr.max_msg_sz;
+		ep_attr->max_recv_dtos = dev_attr.max_qp_wr;
 		ep_attr->max_request_dtos = dev_attr.max_qp_wr;
-		ep_attr->max_recv_iov     = dev_attr.max_sge;
-		ep_attr->max_request_iov  = dev_attr.max_sge;
+		ep_attr->max_recv_iov = dev_attr.max_sge;
+		ep_attr->max_request_iov = dev_attr.max_sge;
 		ep_attr->max_rdma_read_in = dev_attr.max_qp_rd_atom;
-		ep_attr->max_rdma_read_out= dev_attr.max_qp_init_rd_atom;
-		ep_attr->max_rdma_read_iov= dev_attr.max_sge;
-		ep_attr->max_rdma_write_iov= dev_attr.max_sge;
-		dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-			" query_hca: MAX msg %llu mtu %d dto %d iov %d"
-			" rdma i%d,o%d\n", 
-			ep_attr->max_message_size,
-			ep_attr->max_recv_dtos, ep_attr->max_recv_iov,
-			ep_attr->max_rdma_read_in, ep_attr->max_rdma_read_out);
+		ep_attr->max_rdma_read_out = dev_attr.max_qp_init_rd_atom;
+		ep_attr->max_rdma_read_iov = dev_attr.max_sge;
+		ep_attr->max_rdma_write_iov = dev_attr.max_sge;
+		dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+			     " query_hca: MAX msg %llu mtu %d dto %d iov %d"
+			     " rdma i%d,o%d\n",
+			     ep_attr->max_message_size,
+			     ep_attr->max_recv_dtos, ep_attr->max_recv_iov,
+			     ep_attr->max_rdma_read_in,
+			     ep_attr->max_rdma_read_out);
 	}
 	return DAT_SUCCESS;
 }
@@ -552,44 +639,37 @@
  *	DAT_INVALID_PARAMETER
  *
  */
-DAT_RETURN dapls_ib_setup_async_callback (
-	IN  DAPL_IA			*ia_ptr,
-	IN  DAPL_ASYNC_HANDLER_TYPE	handler_type,
-	IN  DAPL_EVD			*evd_ptr,
-	IN  ib_async_handler_t		callback,
-	IN  void			*context )
-
+DAT_RETURN dapls_ib_setup_async_callback(IN DAPL_IA * ia_ptr,
+					 IN DAPL_ASYNC_HANDLER_TYPE
+					 handler_type, IN DAPL_EVD * evd_ptr,
+					 IN ib_async_handler_t callback,
+					 IN void *context)
 {
-    ib_hca_transport_t	*hca_ptr;
+	ib_hca_transport_t *hca_ptr;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
-		  " setup_async_cb: ia %p type %d handle %p cb %p ctx %p\n",
-		  ia_ptr, handler_type, evd_ptr, callback, context);
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+		     " setup_async_cb: ia %p type %d handle %p cb %p ctx %p\n",
+		     ia_ptr, handler_type, evd_ptr, callback, context);
 
-    hca_ptr = &ia_ptr->hca_ptr->ib_trans;
-    switch(handler_type)
-    {
+	hca_ptr = &ia_ptr->hca_ptr->ib_trans;
+	switch (handler_type) {
 	case DAPL_ASYNC_UNAFILIATED:
-		hca_ptr->async_unafiliated = 
-			(ib_async_handler_t)callback;
+		hca_ptr->async_unafiliated = (ib_async_handler_t) callback;
 		hca_ptr->async_un_ctx = context;
 		break;
 	case DAPL_ASYNC_CQ_ERROR:
-		hca_ptr->async_cq_error = 
-			(ib_async_cq_handler_t)callback;
+		hca_ptr->async_cq_error = (ib_async_cq_handler_t) callback;
 		break;
 	case DAPL_ASYNC_CQ_COMPLETION:
-		hca_ptr->async_cq = 
-			(ib_async_dto_handler_t)callback;
+		hca_ptr->async_cq = (ib_async_dto_handler_t) callback;
 		break;
 	case DAPL_ASYNC_QP_ERROR:
-		hca_ptr->async_qp_error = 
-			(ib_async_qp_handler_t)callback;
+		hca_ptr->async_qp_error = (ib_async_qp_handler_t) callback;
 		break;
 	default:
 		break;
-    }
-    return DAT_SUCCESS;
+	}
+	return DAT_SUCCESS;
 }
 
 /*
@@ -604,41 +684,42 @@
  * Returns:
  *      void
  */
-DAT_NAMED_ATTR  ib_attrs[] = {
-    {
-	"DAT_IB_TRANSPORT_MTU", "1024"
-    },
+DAT_NAMED_ATTR ib_attrs[] = {
+	{
+	 "DAT_IB_TRANSPORT_MTU", "1024"}
+	,
 #ifdef DAT_EXTENSIONS
-    {
-        "DAT_EXTENSION_INTERFACE", "TRUE"
-    },
-    {
-        DAT_IB_ATTR_FETCH_AND_ADD, "TRUE"
-    },
-    {
-        DAT_IB_ATTR_CMP_AND_SWAP, "TRUE"
-    },
-    {
-        DAT_IB_ATTR_IMMED_DATA, "TRUE"
-    },
-    {
-        DAT_IB_ATTR_UD, "TRUE"
-    },
+	{
+	 "DAT_EXTENSION_INTERFACE", "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_FETCH_AND_ADD, "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_CMP_AND_SWAP, "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_IMMED_DATA, "TRUE"}
+	,
+	{
+	 DAT_IB_ATTR_UD, "TRUE"}
+	,
+#ifdef DAPL_COUNTERS
+	{
+	 DAT_ATTR_COUNTERS, "TRUE"}
+	,
+#endif				/* DAPL_COUNTERS */
 #endif
 };
 
 #define SPEC_ATTR_SIZE( x )     (sizeof( x ) / sizeof( DAT_NAMED_ATTR))
 
-void dapls_query_provider_specific_attr(
-	IN DAPL_IA		*ia_ptr,
-        IN DAT_PROVIDER_ATTR    *attr_ptr )
+void dapls_query_provider_specific_attr(IN DAPL_IA * ia_ptr,
+					IN DAT_PROVIDER_ATTR * attr_ptr)
 {
-    attr_ptr->num_provider_specific_attr = SPEC_ATTR_SIZE(ib_attrs);
-    attr_ptr->provider_specific_attr = ib_attrs;
+	attr_ptr->num_provider_specific_attr = SPEC_ATTR_SIZE(ib_attrs);
+	attr_ptr->provider_specific_attr = ib_attrs;
 
-    /* set MTU to actual settings */
-    ib_attrs[0].value = ia_ptr->hca_ptr->ib_trans.named_attr.value;
+	/* set MTU to actual settings */
+	ib_attrs[0].value = ia_ptr->hca_ptr->ib_trans.named_attr.value;
 }
-
-
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/dapl_ib_util.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -49,8 +49,8 @@
 #ifndef _DAPL_IB_UTIL_H_
 #define _DAPL_IB_UTIL_H_
 
+#include "openib_osd.h"
 #include <infiniband/verbs.h>
-#include <byteswap.h>
 
 #ifdef DAT_EXTENSIONS
 #include <dat2/dat_ib_extensions.h>
@@ -73,10 +73,8 @@
 typedef	struct ibv_context	*ib_hca_handle_t;
 typedef ib_hca_handle_t		dapl_ibal_ca_t;
 
-/* CM mappings, user CM not complete use SOCKETS */
-
 /* destination info to exchange, define wire protocol version */
-#define DSCM_VER 3
+#define DSCM_VER 4
 typedef struct _ib_qp_cm
 { 
 	uint16_t		ver;
@@ -85,8 +83,8 @@
 	uint16_t		port;
 	uint32_t		qpn;
 	uint32_t		p_size;
+	union ibv_gid		gid;
 	DAT_SOCK_ADDR6		ia_address;
-        union ibv_gid		gid;
 	uint16_t		qp_type; 
 } ib_qp_cm_t;
 
@@ -110,20 +108,18 @@
 	struct dapl_llist_entry	entry;
 	DAPL_OS_LOCK		lock;
 	SCM_STATE		state;
-	int			socket;
+	DAPL_SOCKET		socket;
 	struct dapl_hca		*hca;
 	struct dapl_sp		*sp;	
-	struct dapl_ep 		*ep;	
+	struct dapl_ep 		*ep;
 	ib_qp_cm_t		dst;
-	unsigned char		p_data[256];
+	unsigned char		p_data[256];	/* must follow ib_qp_cm_t */
 	struct ibv_ah		*ah;
 };
 
 typedef struct ib_cm_handle	*dp_ib_cm_handle_t;
 typedef dp_ib_cm_handle_t	ib_cm_srvc_handle_t;
 
-DAT_RETURN getipaddr(char *addr, int addr_len);
-
 /* CM events */
 typedef enum 
 {
@@ -141,11 +137,8 @@
 
 } ib_cm_events_t;
 
-/* prototype for cm thread */
-void cr_thread (void *arg);
-
 /* Operation and state mappings */
-typedef enum	ibv_send_flags	ib_send_op_type_t;
+typedef int ib_send_op_type_t;
 typedef	struct	ibv_sge		ib_data_segment_t;
 typedef enum	ibv_qp_state	ib_qp_state_t;
 typedef	enum	ibv_event_type	ib_async_event_type;
@@ -184,7 +177,7 @@
 #define SCM_ACK_RETRY 7  /* 3 bits, 7 * 268ms = 1.8 seconds */
 #define SCM_RNR_TIMER 12 /* 5 bits, 12 =.64ms, 28 =163ms, 31 =491ms */
 #define SCM_RNR_RETRY 7  /* 3 bits, 7 == infinite */
-#define SCM_IB_MTU    1024
+#define SCM_IB_MTU    2048
 
 /* Global routing defaults */
 #define SCM_GLOBAL	0	/* global routing is disabled */
@@ -284,12 +277,13 @@
 /* ib_hca_transport_t, specific to this implementation */
 typedef struct _ib_hca_transport
 { 
+	union ibv_gid		gid;
 	struct	ibv_device	*ib_dev;
 	ib_cq_handle_t		ib_cq_empty;
 	DAPL_OS_LOCK		cq_lock;	
 	int			max_inline_send;
 	ib_thread_state_t       cq_state;
-	DAPL_OS_THREAD          cq_thread;
+	DAPL_OS_THREAD		cq_thread;
 	struct ibv_comp_channel *ib_cq;
 	int			cr_state;
 	DAPL_OS_THREAD		thread;
@@ -300,6 +294,7 @@
 	ib_async_cq_handler_t	async_cq_error;
 	ib_async_dto_handler_t	async_cq;
 	ib_async_qp_handler_t	async_qp_error;
+	uint16_t		lid;
 	uint8_t			ack_timer;
 	uint8_t			ack_retry;
 	uint8_t			rnr_timer;
@@ -317,7 +312,6 @@
 /* prototypes */
 int32_t	dapls_ib_init (void);
 int32_t	dapls_ib_release (void);
-void cq_thread (void *arg);
 void cr_thread(void *arg);
 int dapli_cq_thread_init(struct dapl_hca *hca_ptr);
 void dapli_cq_thread_destroy(struct dapl_hca *hca_ptr);
@@ -349,7 +343,7 @@
     if (!err)	return DAT_SUCCESS;
     	
 #if DAPL_DBG
-    if ((err != EAGAIN) && (err != ETIME) && (err != ETIMEDOUT))
+    if ((err != EAGAIN) && (err != ETIMEDOUT))
 	dapl_dbg_log (DAPL_DBG_TYPE_ERR," %s %s\n", str, strerror(err));
 #endif 
 
@@ -357,24 +351,15 @@
     {
 	case EOVERFLOW	: return DAT_LENGTH_ERROR;
 	case EACCES	: return DAT_PRIVILEGES_VIOLATION;
-	case ENXIO	: 
-	case ERANGE	: 
 	case EPERM	: return DAT_PROTECTION_VIOLATION;		  
-	case EINVAL	:
-        case EBADF	: 
-	case ENOENT	:
-	case ENOTSOCK	: return DAT_INVALID_HANDLE;
+	case EINVAL	: return DAT_INVALID_HANDLE;
     	case EISCONN	: return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_CONNECTED;
     	case ECONNREFUSED : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_NOTREADY;
-	case ETIME	:	    
 	case ETIMEDOUT	: return DAT_TIMEOUT_EXPIRED;
     	case ENETUNREACH: return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_UNREACHABLE;
     	case EADDRINUSE	: return DAT_CONN_QUAL_IN_USE;
     	case EALREADY	: return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_ACTCONNPENDING;
-        case ENOSPC	: 
-	case ENOMEM	:
-        case E2BIG	:
-        case EDQUOT	: return DAT_INSUFFICIENT_RESOURCES;
+	case ENOMEM	: return DAT_INSUFFICIENT_RESOURCES;
         case EAGAIN	: return DAT_QUEUE_EMPTY;
 	case EINTR	: return DAT_INTERRUPTED_CALL;
     	case EAFNOSUPPORT : return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_MALFORMED;

Added: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/linux/openib_osd.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/linux/openib_osd.h	                        (rev 0)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/openib_scm/linux/openib_osd.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -0,0 +1,21 @@
+#ifndef OPENIB_OSD_H
+#define OPENIB_OSD_H
+
+#include <endian.h>
+#include <netinet/in.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define htonll(x) (x)
+#define ntohll(x) (x)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define htonll(x)  bswap_64(x)
+#define ntohll(x)  bswap_64(x)
+#endif
+
+#define DAPL_SOCKET int
+#define DAPL_INVALID_SOCKET -1
+#define DAPL_FD_SETSIZE 8192
+
+#define closesocket close
+
+#endif // OPENIB_OSD_H

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,45 +61,41 @@
  *	DAT_INVALID_HANDLE
  *	DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API dapl_cno_create(
-	IN	DAT_IA_HANDLE			ia_handle,	/* ia_handle */
-	IN	DAT_OS_WAIT_PROXY_AGENT		wait_agent,	/* agent */
-	OUT	DAT_CNO_HANDLE			*cno_handle)	/* cno_handle */
+DAT_RETURN DAT_API dapl_cno_create(IN DAT_IA_HANDLE ia_handle,	/* ia_handle */
+				   IN DAT_OS_WAIT_PROXY_AGENT wait_agent,	/* agent */
+				   OUT DAT_CNO_HANDLE * cno_handle)
+{				/* cno_handle */
+	DAPL_IA *ia_ptr;
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
 
-{
-    DAPL_IA	*ia_ptr;
-    DAPL_CNO	*cno_ptr;
-    DAT_RETURN	dat_status;
+	ia_ptr = (DAPL_IA *) ia_handle;
+	cno_ptr = NULL;
+	dat_status = DAT_SUCCESS;
 
-    ia_ptr = (DAPL_IA *)ia_handle;
-    cno_ptr = NULL;
-    dat_status = DAT_SUCCESS;
+	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
 
-    if (DAPL_BAD_HANDLE (ia_handle, DAPL_MAGIC_IA))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
+	cno_ptr = dapl_cno_alloc(ia_ptr, wait_agent);
 
-    cno_ptr = dapl_cno_alloc(ia_ptr, wait_agent);
+	if (!cno_ptr) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    if (!cno_ptr)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
 
-    cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
+	dapl_ia_link_cno(ia_ptr, cno_ptr);
 
-    dapl_ia_link_cno(ia_ptr, cno_ptr);
+	*cno_handle = cno_ptr;
 
-    *cno_handle = cno_ptr;
-
- bail:
-    if (dat_status != DAT_SUCCESS && cno_ptr != NULL)
-    {
-	dapl_cno_dealloc(cno_ptr);
-    }
-    return dat_status;
+      bail:
+	if (dat_status != DAT_SUCCESS && cno_ptr != NULL) {
+		dapl_cno_dealloc(cno_ptr);
+	}
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_free.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_free.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_free.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,33 +58,30 @@
  *	DAT_INVALID_HANDLE
  *	DAT_INVALID_STATE
  */
-DAT_RETURN DAT_API dapl_cno_free(
-	IN	DAT_CNO_HANDLE			cno_handle)	/* cno_handle */
+DAT_RETURN DAT_API dapl_cno_free(IN DAT_CNO_HANDLE cno_handle)
+{				/* cno_handle */
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
 
-{
-    DAPL_CNO    *cno_ptr;
-    DAT_RETURN  dat_status;
+	dat_status = DAT_SUCCESS;
+	cno_ptr = (DAPL_CNO *) cno_handle;
 
-    dat_status = DAT_SUCCESS;
-    cno_ptr = (DAPL_CNO *)cno_handle;
+	if (DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+		goto bail;
+	}
 
-    if (DAPL_BAD_HANDLE (cno_handle, DAPL_MAGIC_CNO))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CNO);
-	goto bail;
-    }
+	if (dapl_os_atomic_read(&cno_ptr->cno_ref_count) != 0
+	    || cno_ptr->cno_waiters != 0) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_CNO_IN_USE);
+		goto bail;
+	}
 
-    if (dapl_os_atomic_read(&cno_ptr->cno_ref_count) != 0
-	|| cno_ptr->cno_waiters != 0)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_CNO_IN_USE);
-	goto bail;
-    }
+	dapl_ia_unlink_cno(cno_ptr->header.owner_ia, cno_ptr);
+	dapl_cno_dealloc(cno_ptr);
 
-    dapl_ia_unlink_cno (cno_ptr->header.owner_ia, cno_ptr);
-    dapl_cno_dealloc (cno_ptr);
-
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_modify_agent.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_modify_agent.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_modify_agent.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,27 +57,24 @@
  *	DAT_INVALID_HANDLE
  *	DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API dapl_cno_modify_agent(
-	IN	DAT_CNO_HANDLE		cno_handle,	/* cno_handle */
-	IN	DAT_OS_WAIT_PROXY_AGENT	prx_agent )	/* agent */
+DAT_RETURN DAT_API dapl_cno_modify_agent(IN DAT_CNO_HANDLE cno_handle,	/* cno_handle */
+					 IN DAT_OS_WAIT_PROXY_AGENT prx_agent)
+{				/* agent */
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
 
-{
-    DAPL_CNO	 *cno_ptr;
-    DAT_RETURN   dat_status;
+	dat_status = DAT_SUCCESS;
+	if (DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+		goto bail;
+	}
 
-    dat_status = DAT_SUCCESS;
-    if ( DAPL_BAD_HANDLE (cno_handle, DAPL_MAGIC_CNO) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CNO);
-	goto bail;
-    }
+	cno_ptr = (DAPL_CNO *) cno_handle;
+	dapl_os_lock(&cno_ptr->header.lock);
+	cno_ptr->cno_wait_agent = prx_agent;
+	dapl_os_unlock(&cno_ptr->header.lock);
 
-    cno_ptr = (DAPL_CNO *) cno_handle;
-    dapl_os_lock(&cno_ptr->header.lock);
-    cno_ptr->cno_wait_agent = prx_agent;
-    dapl_os_unlock(&cno_ptr->header.lock);
-
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -61,36 +61,32 @@
  *	DAT_INVALID_HANDLE
  *	DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API dapl_cno_query(
-	IN	DAT_CNO_HANDLE		cno_handle,	/* cno_handle */
-	IN	DAT_CNO_PARAM_MASK	cno_param_mask,	/* cno_param_mask */
-	OUT	DAT_CNO_PARAM 		*cno_param )	/* cno_param */
+DAT_RETURN DAT_API dapl_cno_query(IN DAT_CNO_HANDLE cno_handle,	/* cno_handle */
+				  IN DAT_CNO_PARAM_MASK cno_param_mask,	/* cno_param_mask */
+				  OUT DAT_CNO_PARAM * cno_param)
 
+{				/* cno_param */
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
 
-{
-    DAPL_CNO	 *cno_ptr;
-    DAT_RETURN   dat_status;
+	dat_status = DAT_SUCCESS;
 
-    dat_status = DAT_SUCCESS;
+	if (DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+		goto bail;
+	}
 
-    if ( DAPL_BAD_HANDLE (cno_handle, DAPL_MAGIC_CNO) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CNO);
-	goto bail;
-    }
+	if (NULL == cno_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
 
-    if ( NULL == cno_param )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
+	cno_ptr = (DAPL_CNO *) cno_handle;
+	cno_param->ia_handle = cno_ptr->header.owner_ia;
+	cno_param->proxy_type = DAT_PROXY_TYPE_AGENT;
+	cno_param->proxy.agent = cno_ptr->cno_wait_agent;
 
-    cno_ptr = (DAPL_CNO *) cno_handle;
-    cno_param->ia_handle = cno_ptr->header.owner_ia;
-    cno_param->proxy_type = DAT_PROXY_TYPE_AGENT;
-    cno_param->proxy.agent = cno_ptr->cno_wait_agent;
-
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_wait.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_wait.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_cno_wait.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,75 +59,65 @@
  *	DAT_QUEUE_EMPTY
  *	DAT_INVALID_PARAMETER
  */
-DAT_RETURN DAT_API dapl_cno_wait(
-	IN	DAT_CNO_HANDLE		cno_handle,	/* cno_handle */
-	IN	DAT_TIMEOUT		timeout,	/* agent */
-	OUT	DAT_EVD_HANDLE		*evd_handle)	/* ia_handle */
+DAT_RETURN DAT_API dapl_cno_wait(IN DAT_CNO_HANDLE cno_handle,	/* cno_handle */
+				 IN DAT_TIMEOUT timeout,	/* agent */
+				 OUT DAT_EVD_HANDLE * evd_handle)
+{				/* ia_handle */
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
 
-{
-    DAPL_CNO 		*cno_ptr;
-    DAT_RETURN 		dat_status;
+	if (DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) {
+		dat_status = DAT_INVALID_HANDLE | DAT_INVALID_HANDLE_CNO;
+		goto bail;
+	}
 
-    if ( DAPL_BAD_HANDLE (cno_handle, DAPL_MAGIC_CNO) )
-    {
-	dat_status = DAT_INVALID_HANDLE | DAT_INVALID_HANDLE_CNO;
-	goto bail;
-    }
+	dat_status = DAT_SUCCESS;
 
-    dat_status = DAT_SUCCESS;
+	cno_ptr = (DAPL_CNO *) cno_handle;
 
-    cno_ptr = (DAPL_CNO *) cno_handle;
+	if (cno_ptr->cno_state == DAPL_CNO_STATE_DEAD) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_CNO_DEAD);
+		goto bail;
+	}
 
-    if ( cno_ptr->cno_state == DAPL_CNO_STATE_DEAD )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_CNO_DEAD);
-	goto bail;
-    }
+	dapl_os_lock(&cno_ptr->header.lock);
+	while (cno_ptr->cno_state == DAPL_CNO_STATE_UNTRIGGERED
+	       && DAT_GET_TYPE(dat_status) != DAT_TIMEOUT_EXPIRED) {
+		cno_ptr->cno_waiters++;
+		dapl_os_unlock(&cno_ptr->header.lock);
+		dat_status = dapl_os_wait_object_wait(&cno_ptr->cno_wait_object,
+						      timeout);
+		dapl_os_lock(&cno_ptr->header.lock);
+		cno_ptr->cno_waiters--;
+	}
 
-    dapl_os_lock ( &cno_ptr->header.lock );
-    while (cno_ptr->cno_state == DAPL_CNO_STATE_UNTRIGGERED
-	   && DAT_GET_TYPE(dat_status) != DAT_TIMEOUT_EXPIRED)
-    {
-	cno_ptr->cno_waiters++;
-	dapl_os_unlock ( &cno_ptr->header.lock );
-	dat_status = dapl_os_wait_object_wait (&cno_ptr->cno_wait_object,
-					       timeout);
-	dapl_os_lock ( &cno_ptr->header.lock );
-	cno_ptr->cno_waiters--;
-    }
+	if (cno_ptr->cno_state == DAPL_CNO_STATE_DEAD) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_CNO_DEAD);
+	} else if (dat_status == DAT_SUCCESS) {
+		/*
+		 * After the first triggering, this will be a valid handle.
+		 * If we're racing with wakeups of other CNO waiters,
+		 * that's ok.
+		 */
+		dapl_os_assert(cno_ptr->cno_state == DAPL_CNO_STATE_TRIGGERED);
+		cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
+		*evd_handle = cno_ptr->cno_evd_triggered;
+	} else if (DAT_GET_TYPE(dat_status) == DAT_TIMEOUT_EXPIRED) {
+		cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
+		*evd_handle = NULL;
+		dat_status = DAT_QUEUE_EMPTY;
+	} else {
+		/*
+		 * The only other reason we could have made it out of
+		 * the loop is an interrupted system call.
+		 */
+		dapl_os_assert(DAT_GET_TYPE(dat_status) ==
+			       DAT_INTERRUPTED_CALL);
+	}
+	dapl_os_unlock(&cno_ptr->header.lock);
 
-    if ( cno_ptr->cno_state == DAPL_CNO_STATE_DEAD )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_CNO_DEAD);
-    }
-    else if ( dat_status == DAT_SUCCESS )
-    {
-	/*
-	 * After the first triggering, this will be a valid handle.
-	 * If we're racing with wakeups of other CNO waiters,
-	 * that's ok.
-	 */
-	dapl_os_assert ( cno_ptr->cno_state == DAPL_CNO_STATE_TRIGGERED ); 
-	cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
-	*evd_handle        = cno_ptr->cno_evd_triggered;
-    }
-    else if ( DAT_GET_TYPE(dat_status) == DAT_TIMEOUT_EXPIRED )
-    {
-	cno_ptr->cno_state = DAPL_CNO_STATE_UNTRIGGERED;
-	*evd_handle        = NULL;
-	dat_status         = DAT_QUEUE_EMPTY;
-    }
-    else
-    {
-	/*
-	 * The only other reason we could have made it out of
-	 * the loop is an interrupted system call.
-	 */
-	dapl_os_assert(DAT_GET_TYPE(dat_status) == DAT_INTERRUPTED_CALL);
-    }
-    dapl_os_unlock ( &cno_ptr->header.lock );
-
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_clear_unwaitable.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_clear_unwaitable.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_clear_unwaitable.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -55,28 +55,25 @@
  *	DAT_SUCCESS
  *	DAT_INVALID_HANDLE
  */
-DAT_RETURN DAT_API
-dapl_evd_clear_unwaitable (
-	IN    DAT_EVD_HANDLE	evd_handle )
+DAT_RETURN DAT_API dapl_evd_clear_unwaitable(IN DAT_EVD_HANDLE evd_handle)
 {
-    DAPL_EVD		*evd_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
 
-    evd_ptr    = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD) )
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD))
+	{
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	dapl_os_lock(&evd_ptr->header.lock);
+	evd_ptr->evd_waitable = DAT_TRUE;
+	dapl_os_unlock(&evd_ptr->header.lock);
 
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    dapl_os_lock ( &evd_ptr->header.lock );
-    evd_ptr->evd_waitable = DAT_TRUE;
-    dapl_os_unlock ( &evd_ptr->header.lock );
+	dat_status = DAT_SUCCESS;
 
-    dat_status = DAT_SUCCESS;
-
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -72,123 +72,113 @@
  * even if it is not required. However, it will not be armed.
  */
 
-DAT_RETURN DAT_API dapl_evd_create (
-    IN    DAT_IA_HANDLE		ia_handle,
-    IN    DAT_COUNT		evd_min_qlen,
-    IN    DAT_CNO_HANDLE	cno_handle,
-    IN    DAT_EVD_FLAGS		evd_flags,
-    OUT   DAT_EVD_HANDLE	*evd_handle )
+DAT_RETURN DAT_API dapl_evd_create(IN DAT_IA_HANDLE ia_handle,
+				   IN DAT_COUNT evd_min_qlen,
+				   IN DAT_CNO_HANDLE cno_handle,
+				   IN DAT_EVD_FLAGS evd_flags,
+				   OUT DAT_EVD_HANDLE * evd_handle)
 {
-    DAPL_IA		*ia_ptr;
-    DAPL_EVD		*evd_ptr;
-    DAPL_CNO		*cno_ptr;
-    DAT_RETURN		dat_status;
-    DAT_PROVIDER_ATTR	provider_attr;
-    int			i;
-    int			j;
-    int			flag_mask[6];
+	DAPL_IA *ia_ptr;
+	DAPL_EVD *evd_ptr;
+	DAPL_CNO *cno_ptr;
+	DAT_RETURN dat_status;
+	DAT_PROVIDER_ATTR provider_attr;
+	int i;
+	int j;
+	int flag_mask[6];
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_evd_create (%p, %d, %p, 0x%x, %p)\n", 
-		  ia_handle, 
-		  evd_min_qlen, 
-		  cno_handle, 
-		  evd_flags, 
-		  evd_handle);
-    DAPL_CNTR(DCNT_EVD_CREATE);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_evd_create (%p, %d, %p, 0x%x, %p)\n",
+		     ia_handle,
+		     evd_min_qlen, cno_handle, evd_flags, evd_handle);
 
-    ia_ptr      = (DAPL_IA *)ia_handle;
-    cno_ptr     = (DAPL_CNO *)cno_handle;
-    evd_ptr     = NULL;
-    *evd_handle = NULL;
-    dat_status  = DAT_SUCCESS;
+	ia_ptr = (DAPL_IA *) ia_handle;
+	cno_ptr = (DAPL_CNO *) cno_handle;
+	evd_ptr = NULL;
+	*evd_handle = NULL;
+	dat_status = DAT_SUCCESS;
 
-    if (DAPL_BAD_HANDLE (ia_handle, DAPL_MAGIC_IA))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
+	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
 
-    if ( evd_min_qlen <= 0 )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
-    if ( evd_min_qlen > ia_ptr->hca_ptr->ia_attr.max_evd_qlen )
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_TEVD);
-	goto bail;
-    }
+	DAPL_CNTR(ia_ptr, DCNT_IA_EVD_CREATE);
 
-    if (cno_handle != DAT_HANDLE_NULL
-	&& DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) 
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,DAT_INVALID_HANDLE_CNO);
-	goto bail;
-    }
+	if (evd_min_qlen <= 0) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
+	if (evd_min_qlen > ia_ptr->hca_ptr->ia_attr.max_evd_qlen) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_TEVD);
+		goto bail;
+	}
 
-    /*
-     * Check the merging attributes to ensure the combination of
-     * flags requested is supported.
-     */
-    dapl_ia_query (ia_handle, NULL,
-		   0, NULL,
-		   DAT_PROVIDER_FIELD_ALL, &provider_attr);
-    
-    /* Set up an array of flags to compare against; the EVD bits are
-     * a sparse array that need to be mapped to the merging flags
-     */
-    flag_mask[0] = DAT_EVD_SOFTWARE_FLAG;
-    flag_mask[1] = DAT_EVD_CR_FLAG;
-    flag_mask[2] = DAT_EVD_DTO_FLAG;
-    flag_mask[3] = DAT_EVD_CONNECTION_FLAG;
-    flag_mask[4] = DAT_EVD_RMR_BIND_FLAG;
-    flag_mask[5] = DAT_EVD_ASYNC_FLAG;
+	if (cno_handle != DAT_HANDLE_NULL
+	    && DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+		goto bail;
+	}
 
-    for (i = 0; i < 6; i++)
-    {
-	if (flag_mask[i] & evd_flags)
-	{
-	    for (j = 0; j < 6; j++)
-	    {
-		if (flag_mask[j] & evd_flags)
-		{
-		    if (provider_attr.evd_stream_merging_supported[i][j] == DAT_FALSE)
-		    {
-			dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG4);
-			goto bail;
-		    }
+	/*
+	 * Check the merging attributes to ensure the combination of
+	 * flags requested is supported.
+	 */
+	dapl_ia_query(ia_handle, NULL,
+		      0, NULL, DAT_PROVIDER_FIELD_ALL, &provider_attr);
+
+	/* Set up an array of flags to compare against; the EVD bits are
+	 * a sparse array that need to be mapped to the merging flags
+	 */
+	flag_mask[0] = DAT_EVD_SOFTWARE_FLAG;
+	flag_mask[1] = DAT_EVD_CR_FLAG;
+	flag_mask[2] = DAT_EVD_DTO_FLAG;
+	flag_mask[3] = DAT_EVD_CONNECTION_FLAG;
+	flag_mask[4] = DAT_EVD_RMR_BIND_FLAG;
+	flag_mask[5] = DAT_EVD_ASYNC_FLAG;
+
+	for (i = 0; i < 6; i++) {
+		if (flag_mask[i] & evd_flags) {
+			for (j = 0; j < 6; j++) {
+				if (flag_mask[j] & evd_flags) {
+					if (provider_attr.
+					    evd_stream_merging_supported[i][j]
+					    == DAT_FALSE) {
+						dat_status =
+						    DAT_ERROR
+						    (DAT_INVALID_PARAMETER,
+						     DAT_INVALID_ARG4);
+						goto bail;
+					}
+				}
+			}	/* end for j */
 		}
-	    } /* end for j */
+	}			/* end for i */
+
+	dat_status = dapls_evd_internal_create(ia_ptr,
+					       cno_ptr,
+					       evd_min_qlen,
+					       evd_flags, &evd_ptr);
+	if (dat_status != DAT_SUCCESS) {
+		goto bail;
 	}
-    } /* end for i */
 
-    dat_status = dapls_evd_internal_create (ia_ptr, 
-                                          cno_ptr, 
-                                          evd_min_qlen, 
-                                          evd_flags,
-                                          &evd_ptr);
-    if (dat_status != DAT_SUCCESS)
-    {
-	goto bail;
-    }
+	evd_ptr->evd_state = DAPL_EVD_STATE_OPEN;
 
-    evd_ptr->evd_state = DAPL_EVD_STATE_OPEN;
+	*evd_handle = (DAT_EVD_HANDLE) evd_ptr;
 
-    *evd_handle = (DAT_EVD_HANDLE) evd_ptr;
-
-bail:
-    if (dat_status != DAT_SUCCESS)
-    {
-	if (evd_ptr)
-	{
-	    dapl_evd_free (evd_ptr);
+      bail:
+	if (dat_status != DAT_SUCCESS) {
+		if (evd_ptr) {
+			dapl_evd_free(evd_ptr);
+		}
 	}
-    }
 
-    dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-		  "dapl_evd_create () returns 0x%x\n", 
-		  dat_status);
+	dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+		     "dapl_evd_create () returns 0x%x\n", dat_status);
 
-    return dat_status;
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_disable.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_disable.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_disable.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,24 +57,22 @@
  * 	DAT_INVALID_HANDLE
  */
 
-DAT_RETURN DAT_API dapl_evd_disable (
-	IN	DAT_EVD_HANDLE	   evd_handle)
+DAT_RETURN DAT_API dapl_evd_disable(IN DAT_EVD_HANDLE evd_handle)
 {
-    DAPL_EVD		*evd_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD) )
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD))
+	{
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
 
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
+	evd_ptr->evd_enabled = DAT_FALSE;
 
-    evd_ptr->evd_enabled = DAT_FALSE;
-
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_enable.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_enable.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_enable.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,37 +58,34 @@
  * 	DAT_INVALID_HANDLE
  */
 
-DAT_RETURN DAT_API dapl_evd_enable (
-	IN	DAT_EVD_HANDLE	   evd_handle)
+DAT_RETURN DAT_API dapl_evd_enable(IN DAT_EVD_HANDLE evd_handle)
 {
-    DAPL_EVD		*evd_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD) )
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD))
+	{
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
 
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
+	evd_ptr->evd_enabled = DAT_TRUE;
 
-    evd_ptr->evd_enabled = DAT_TRUE;
+	/* We need to enable the callback handler if there is a CNO.  */
+	if (evd_ptr->cno_ptr != NULL &&
+	    evd_ptr->ib_cq_handle != IB_INVALID_HANDLE) {
+		dat_status =
+		    dapls_ib_completion_notify(evd_ptr->header.owner_ia->
+					       hca_ptr->ib_hca_handle, evd_ptr,
+					       IB_NOTIFY_ON_NEXT_COMP);
 
-    /* We need to enable the callback handler if there is a CNO.  */
-    if (evd_ptr->cno_ptr != NULL && 
-	evd_ptr->ib_cq_handle != IB_INVALID_HANDLE )
-    {
-	dat_status = dapls_ib_completion_notify (
-	    evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle,
-	    evd_ptr,
-	    IB_NOTIFY_ON_NEXT_COMP);
+		/* FIXME report error */
+		dapl_os_assert(dat_status == DAT_SUCCESS);
+	}
 
-	/* FIXME report error */
-	dapl_os_assert(dat_status == DAT_SUCCESS);
-    }
-
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_modify_cno.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_modify_cno.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_modify_cno.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,59 +59,52 @@
  * 	DAT_INVALID_HANDLE
  */
 
-DAT_RETURN DAT_API dapl_evd_modify_cno (
-	IN	DAT_EVD_HANDLE		evd_handle,
-	IN	DAT_CNO_HANDLE		cno_handle)
+DAT_RETURN DAT_API dapl_evd_modify_cno(IN DAT_EVD_HANDLE evd_handle,
+				       IN DAT_CNO_HANDLE cno_handle)
 
-
 {
-    DAPL_EVD	*evd_ptr;
-    DAPL_CNO	*cno_ptr;
-    DAPL_CNO	*old_cno_ptr;
-    DAT_RETURN	dat_status;
+	DAPL_EVD *evd_ptr;
+	DAPL_CNO *cno_ptr;
+	DAPL_CNO *old_cno_ptr;
+	DAT_RETURN dat_status;
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    cno_ptr = (DAPL_CNO *)cno_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	cno_ptr = (DAPL_CNO *) cno_handle;
+	dat_status = DAT_SUCCESS;
 
-    if (DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, 0);
-	goto bail;
-    }
-    if (cno_handle != NULL &&
-	DAPL_BAD_HANDLE (cno_handle, DAPL_MAGIC_CNO))
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
-	goto bail;
-    }
-    dapl_os_lock (&evd_ptr->header.lock);
-    old_cno_ptr = evd_ptr->cno_ptr;
-    evd_ptr->cno_ptr = cno_ptr;
-    dapl_os_unlock (&evd_ptr->header.lock);
-    if (cno_ptr)
-    {
-	dapl_os_atomic_inc ( & (cno_ptr->cno_ref_count) );
-    }
-    if (old_cno_ptr)
-    {
-	dapl_os_atomic_dec ( & (old_cno_ptr->cno_ref_count) );
-    }
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	if (cno_handle != NULL && DAPL_BAD_HANDLE(cno_handle, DAPL_MAGIC_CNO)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+		goto bail;
+	}
+	dapl_os_lock(&evd_ptr->header.lock);
+	old_cno_ptr = evd_ptr->cno_ptr;
+	evd_ptr->cno_ptr = cno_ptr;
+	dapl_os_unlock(&evd_ptr->header.lock);
+	if (cno_ptr) {
+		dapl_os_atomic_inc(&(cno_ptr->cno_ref_count));
+	}
+	if (old_cno_ptr) {
+		dapl_os_atomic_dec(&(old_cno_ptr->cno_ref_count));
+	}
 
-    /* We need to enable the callback handler if the EVD is enabled.  */
-    if (evd_ptr->evd_enabled &&
-	cno_handle != DAT_HANDLE_NULL &&
-	evd_ptr->ib_cq_handle != IB_INVALID_HANDLE)
-    {
-	dat_status = dapls_ib_completion_notify (
-	    evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle,
-	    evd_ptr,
-	    IB_NOTIFY_ON_NEXT_COMP);
+	/* We need to enable the callback handler if the EVD is enabled.  */
+	if (evd_ptr->evd_enabled &&
+	    cno_handle != DAT_HANDLE_NULL &&
+	    evd_ptr->ib_cq_handle != IB_INVALID_HANDLE) {
+		dat_status =
+		    dapls_ib_completion_notify(evd_ptr->header.owner_ia->
+					       hca_ptr->ib_hca_handle, evd_ptr,
+					       IB_NOTIFY_ON_NEXT_COMP);
 
-	/* FIXME report error */
-	dapl_os_assert (dat_status == DAT_SUCCESS);
-    }
+		/* FIXME report error */
+		dapl_os_assert(dat_status == DAT_SUCCESS);
+	}
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_query.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_query.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_query.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,58 +57,56 @@
  * 	DAT_INVALID_PARAMETER
  */
 DAT_RETURN DAT_API
-dapl_evd_query (
-	IN	DAT_EVD_HANDLE		evd_handle,
-	IN	DAT_EVD_PARAM_MASK	evd_param_mask,
-	OUT	DAT_EVD_PARAM		*evd_param )
+dapl_evd_query(IN DAT_EVD_HANDLE evd_handle,
+	       IN DAT_EVD_PARAM_MASK evd_param_mask,
+	       OUT DAT_EVD_PARAM * evd_param)
 {
-    DAPL_EVD	    *evd_ptr;
-    DAT_RETURN	    dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    if ( NULL == evd_param )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
-
-    /* Note: the spec. allows for events to be directed to a NULL EVD */
-    /* with handle of type DAT_HANDLE_NULL. See 6.3.1                 */
-    if ( DAT_HANDLE_NULL == evd_handle )
-    {
-	dapl_os_memzero (evd_param, sizeof (DAT_EVD_PARAM));
-    }
-    else
-    {
-	if ( DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD) )
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	    goto bail;
+	if (NULL == evd_param) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
 	}
 
-	evd_ptr = (DAPL_EVD *) evd_handle;
+	/* Note: the spec. allows for events to be directed to a NULL EVD */
+	/* with handle of type DAT_HANDLE_NULL. See 6.3.1                 */
+	if (DAT_HANDLE_NULL == evd_handle) {
+		dapl_os_memzero(evd_param, sizeof(DAT_EVD_PARAM));
+	} else {
+		if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
+			dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+			goto bail;
+		}
 
-	/*
-	 * We may be racing against the thread safe modify
-	 * calls here (dat_evd_{enable,disable,{set,clear}_unwaitable}).
-	 * They are thread safe, so our reads need to be atomic with
-	 * regard to those calls.  The below is ok (a single bit
-	 * read counts as atomic; if it's in transition you'll get one
-	 * of the correct values) but we'll need to be careful
-	 * about reading the state variable atomically when we add
-	 * in waitable/unwaitable.
-	 */
-	evd_param->evd_state =
-	    (evd_ptr->evd_enabled ? DAT_EVD_STATE_ENABLED : DAT_EVD_STATE_DISABLED);
-	evd_param->evd_state |=
-	    (evd_ptr->evd_waitable ? DAT_EVD_STATE_WAITABLE : DAT_EVD_STATE_UNWAITABLE);
-	evd_param->ia_handle = evd_ptr->header.owner_ia;
-	evd_param->evd_qlen = evd_ptr->qlen;
-	evd_param->cno_handle = (DAT_CNO_HANDLE) evd_ptr->cno_ptr;
-	evd_param->evd_flags  = evd_ptr->evd_flags;
-    }
+		evd_ptr = (DAPL_EVD *) evd_handle;
 
-bail:
-    return dat_status;
+		/*
+		 * We may be racing against the thread safe modify
+		 * calls here (dat_evd_{enable,disable,{set,clear}_unwaitable}).
+		 * They are thread safe, so our reads need to be atomic with
+		 * regard to those calls.  The below is ok (a single bit
+		 * read counts as atomic; if it's in transition you'll get one
+		 * of the correct values) but we'll need to be careful
+		 * about reading the state variable atomically when we add
+		 * in waitable/unwaitable.
+		 */
+		evd_param->evd_state =
+		    (evd_ptr->
+		     evd_enabled ? DAT_EVD_STATE_ENABLED :
+		     DAT_EVD_STATE_DISABLED);
+		evd_param->evd_state |=
+		    (evd_ptr->
+		     evd_waitable ? DAT_EVD_STATE_WAITABLE :
+		     DAT_EVD_STATE_UNWAITABLE);
+		evd_param->ia_handle = evd_ptr->header.owner_ia;
+		evd_param->evd_qlen = evd_ptr->qlen;
+		evd_param->cno_handle = (DAT_CNO_HANDLE) evd_ptr->cno_ptr;
+		evd_param->evd_flags = evd_ptr->evd_flags;
+	}
+
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_set_unwaitable.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_set_unwaitable.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_set_unwaitable.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -56,43 +56,40 @@
  *	DAT_SUCCESS
  *	DAT_INVALID_HANDLE
  */
-DAT_RETURN DAT_API
-dapl_evd_set_unwaitable (
-	IN    DAT_EVD_HANDLE	evd_handle )
+DAT_RETURN DAT_API dapl_evd_set_unwaitable(IN DAT_EVD_HANDLE evd_handle)
 {
-    DAPL_EVD		*evd_ptr;
-    DAT_RETURN		dat_status;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
 
-    evd_ptr    = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if ( DAPL_BAD_HANDLE (evd_handle, DAPL_MAGIC_EVD) )
+	if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD))
+	{
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	dapl_os_lock(&evd_ptr->header.lock);
+	evd_ptr->evd_waitable = DAT_FALSE;
+	dapl_os_unlock(&evd_ptr->header.lock);
 
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    dapl_os_lock ( &evd_ptr->header.lock );
-    evd_ptr->evd_waitable = DAT_FALSE;
-    dapl_os_unlock ( &evd_ptr->header.lock );
-
-    /*
-     * If this evd is waiting, wake it up. There is an obvious race
-     * condition here where we may wakeup the waiter before it goes to
-     * sleep; but the wait_object allows this and will do the right
-     * thing.
-     */
-    if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED)
-    {
+	/*
+	 * If this evd is waiting, wake it up. There is an obvious race
+	 * condition here where we may wakeup the waiter before it goes to
+	 * sleep; but the wait_object allows this and will do the right
+	 * thing.
+	 */
+	if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED) {
 #ifdef CQ_WAIT_OBJECT
-        if (evd_ptr->cq_wait_obj_handle)
-	    dapls_ib_wait_object_wakeup (evd_ptr->cq_wait_obj_handle);
-	else
+		if (evd_ptr->cq_wait_obj_handle)
+			dapls_ib_wait_object_wakeup(evd_ptr->
+						    cq_wait_obj_handle);
+		else
 #endif
-	    dapl_os_wait_object_wakeup (&evd_ptr->wait_object);
-    }
-bail:
-    return dat_status;
+			dapl_os_wait_object_wakeup(&evd_ptr->wait_object);
+	}
+      bail:
+	return dat_status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_wait.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_wait.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_evd_wait.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -63,222 +63,215 @@
  * 	DAT_INVALID_STATE
  */
 
-DAT_RETURN DAT_API dapl_evd_wait (
-    IN  DAT_EVD_HANDLE	evd_handle,
-    IN  DAT_TIMEOUT	time_out,
-    IN  DAT_COUNT       threshold,
-    OUT DAT_EVENT	*event,
-    OUT DAT_COUNT       *nmore)
-
+DAT_RETURN DAT_API dapl_evd_wait(IN DAT_EVD_HANDLE evd_handle,
+				 IN DAT_TIMEOUT time_out,
+				 IN DAT_COUNT threshold,
+				 OUT DAT_EVENT * event, OUT DAT_COUNT * nmore)
 {
-    DAPL_EVD		*evd_ptr;
-    DAT_RETURN		dat_status;
-    DAT_EVENT		*local_event;
-    DAT_BOOLEAN		notify_requested = DAT_FALSE;
-    DAT_BOOLEAN		waitable;
-    DAPL_EVD_STATE	evd_state;
+	DAPL_EVD *evd_ptr;
+	DAT_RETURN dat_status;
+	DAT_EVENT *local_event;
+	DAT_BOOLEAN notify_requested = DAT_FALSE;
+	DAT_BOOLEAN waitable;
+	DAPL_EVD_STATE evd_state;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-		  "dapl_evd_wait (%p, %d, %d, %p, %p)\n", 
-		  evd_handle, 
-		  time_out, 
-		  threshold, 
-		  event, 
-		  nmore);
-    DAPL_CNTR(DCNT_EVD_WAIT);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_evd_wait (%p, %d, %d, %p, %p)\n",
+		     evd_handle, time_out, threshold, event, nmore);
 
-    evd_ptr = (DAPL_EVD *)evd_handle;
-    dat_status = DAT_SUCCESS;
+	evd_ptr = (DAPL_EVD *) evd_handle;
+	dat_status = DAT_SUCCESS;
 
-    if (DAPL_BAD_HANDLE (evd_ptr, DAPL_MAGIC_EVD))
-    {
+	if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD)) {
+		/*
+		 * We return directly rather than bailing because
+		 * bailing attempts to update the evd, and we don't have
+		 * one.
+		 */
+		dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 0);
+		goto bail;
+	}
+	if (!event) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+		goto bail;
+	}
+	if (!nmore) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
+		goto bail;
+	}
+	if (threshold <= 0 ||
+	    (threshold > 1
+	     && evd_ptr->completion_type != DAPL_EVD_STATE_THRESHOLD)
+	    || threshold > evd_ptr->qlen) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+		goto bail;
+	}
+	if (evd_ptr->catastrophic_overflow) {
+		dat_status = DAT_ERROR(DAT_INVALID_STATE, 0);
+		goto bail;
+	}
+	DAPL_CNTR(evd_ptr, DCNT_EVD_WAIT);
+
+	dapl_dbg_log(DAPL_DBG_TYPE_EVD,
+		     "dapl_evd_wait: EVD %p, CQ %p\n",
+		     evd_ptr, (void *)evd_ptr->ib_cq_handle);
+
 	/*
-	 * We return directly rather than bailing because
-	 * bailing attempts to update the evd, and we don't have
-	 * one.
+	 * Make sure there are no other waiters and the evd is active.
+	 * Currently this means only the OPEN state is allowed.
+	 * Do this atomically.  We need to take a lock to synchronize
+	 * with dapl_evd_dequeue(), but the atomic transition allows
+	 * non-locking synchronization with dapl_evd_query() and
+	 * dapl_evd_{query,enable,disable,{set,clear}_unwaitable}.
 	 */
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE,0);
-	goto bail;
-    }
-    if (!event)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG4);
-	goto bail;
-    }
-    if (!nmore)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG5);
-	goto bail;
-    }
-    if (threshold <= 0 ||
-	(threshold > 1 && evd_ptr->completion_type != DAPL_EVD_STATE_THRESHOLD) ||
-	threshold > evd_ptr->qlen)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG3);
-	goto bail;
-    }
-    if ( evd_ptr->catastrophic_overflow )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,0);
-	goto bail;
-    }
 
-    dapl_dbg_log (DAPL_DBG_TYPE_EVD, 
-	          "dapl_evd_wait: EVD %p, CQ %p\n", 
-                  evd_ptr,
-		  (void *)evd_ptr->ib_cq_handle);
+	dapl_os_lock(&evd_ptr->header.lock);
+	waitable = evd_ptr->evd_waitable;
 
-    /*
-     * Make sure there are no other waiters and the evd is active.
-     * Currently this means only the OPEN state is allowed.
-     * Do this atomically.  We need to take a lock to synchronize
-     * with dapl_evd_dequeue(), but the atomic transition allows
-     * non-locking synchronization with dapl_evd_query() and
-     * dapl_evd_{query,enable,disable,{set,clear}_unwaitable}.
-     */
+	dapl_os_assert(sizeof(DAT_COUNT) == sizeof(DAPL_EVD_STATE));
+	evd_state = evd_ptr->evd_state;
+	if (evd_ptr->evd_state == DAPL_EVD_STATE_OPEN)
+		evd_ptr->evd_state = DAPL_EVD_STATE_WAITED;
 
-    dapl_os_lock ( &evd_ptr->header.lock );
-    waitable = evd_ptr->evd_waitable;
+	if (evd_state != DAPL_EVD_STATE_OPEN) {
+		/* Bogus state, bail out */
+		dat_status = DAT_ERROR(DAT_INVALID_STATE, 0);
+		goto bail;
+	}
 
-    dapl_os_assert ( sizeof(DAT_COUNT) == sizeof(DAPL_EVD_STATE) );
-    evd_state = evd_ptr->evd_state;
-    if (evd_ptr->evd_state == DAPL_EVD_STATE_OPEN)
-	evd_ptr->evd_state = DAPL_EVD_STATE_WAITED;
+	if (!waitable) {
+		/* This EVD is not waitable, reset the state and bail */
+		if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED)
+			evd_ptr->evd_state = evd_state;
 
-    if ( evd_state != DAPL_EVD_STATE_OPEN )
-    {
-	/* Bogus state, bail out */
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,0);
-	dapl_os_unlock ( &evd_ptr->header.lock );
-	goto bail;
-    }
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE,
+			      DAT_INVALID_STATE_EVD_UNWAITABLE);
+		goto bail;
+	}
 
-    if (!waitable)
-    {
-	/* This EVD is not waitable, reset the state and bail */
-	if (evd_ptr->evd_state == DAPL_EVD_STATE_WAITED)
-		evd_ptr->evd_state = evd_state;
-
-	dat_status = DAT_ERROR (DAT_INVALID_STATE, DAT_INVALID_STATE_EVD_UNWAITABLE);
-	dapl_os_unlock ( &evd_ptr->header.lock );
-	goto bail;
-    }
-    dapl_os_unlock ( &evd_ptr->header.lock );
-
-
-    /*
-     * We now own the EVD, even though we don't have the lock anymore,
-     * because we're in the WAITED state.
-     */
-
-    evd_ptr->threshold = threshold;
-
-    for (;;)
-    {
 	/*
-	 * Ideally we'd just check the number of entries on the CQ, but
-	 * we don't have a way to do that.  Because we have to set *nmore
-	 * at some point in this routine, we'll need to do this copy
-	 * sometime even if threshold == 1.
-	 *
-	 * For connection evd or async evd, the function checks and
-	 * return right away if the ib_cq_handle associate with these evd
-	 * equal to IB_INVALID_HANDLE
+	 * We now own the EVD, even though we don't have the lock anymore,
+	 * because we're in the WAITED state.
 	 */
-	dapls_evd_copy_cq(evd_ptr);
 
-	if (dapls_rbuf_count(&evd_ptr->pending_event_queue) >= threshold)
-	{
-	    break;
-	}
+	evd_ptr->threshold = threshold;
 
-	/*
-	 * Do not enable the completion notification if this evd is not 
-	 * a DTO_EVD or RMR_BIND_EVD
-	 */
-	if ( (!notify_requested) &&
-             ((evd_ptr->evd_flags & DAT_EVD_DTO_FLAG) ||
-              (evd_ptr->evd_flags & DAT_EVD_RMR_BIND_FLAG)) )
-	{
-	    dat_status = dapls_ib_completion_notify (
-		evd_ptr->header.owner_ia->hca_ptr->ib_hca_handle,
-		evd_ptr,
-		(evd_ptr->completion_type == DAPL_EVD_STATE_SOLICITED_WAIT) ?
-		     IB_NOTIFY_ON_SOLIC_COMP : IB_NOTIFY_ON_NEXT_COMP );  
+	for (;;) {
+		/*
+		 * Ideally we'd just check the number of entries on the CQ, but
+		 * we don't have a way to do that.  Because we have to set *nmore
+		 * at some point in this routine, we'll need to do this copy
+		 * sometime even if threshold == 1.
+		 *
+		 * For connection evd or async evd, the function checks and
+		 * return right away if the ib_cq_handle associate with these evd
+		 * equal to IB_INVALID_HANDLE
+		 */
+		dapl_os_unlock(&evd_ptr->header.lock);
+		dapls_evd_copy_cq(evd_ptr);
+		dapl_os_lock(&evd_ptr->header.lock);
 
-	    DAPL_CNTR(DCNT_EVD_WAIT_CMP_NTFY);
-	    /* FIXME report error */
-	    dapl_os_assert(dat_status == DAT_SUCCESS);
+		if (dapls_rbuf_count(&evd_ptr->pending_event_queue) >=
+		    threshold) {
+			break;
+		}
 
-	    notify_requested = DAT_TRUE;
+		/*
+		 * Do not enable the completion notification if this evd is not 
+		 * a DTO_EVD or RMR_BIND_EVD
+		 */
+		if ((!notify_requested) &&
+		    ((evd_ptr->evd_flags & DAT_EVD_DTO_FLAG) ||
+		     (evd_ptr->evd_flags & DAT_EVD_RMR_BIND_FLAG))) {
+			dat_status =
+			    dapls_ib_completion_notify(evd_ptr->header.
+						       owner_ia->hca_ptr->
+						       ib_hca_handle, evd_ptr,
+						       (evd_ptr->
+							completion_type ==
+							DAPL_EVD_STATE_SOLICITED_WAIT)
+						       ? IB_NOTIFY_ON_SOLIC_COMP
+						       :
+						       IB_NOTIFY_ON_NEXT_COMP);
 
-	    /* Try again.  */
-	    continue;
-	}
+			DAPL_CNTR(evd_ptr, DCNT_EVD_WAIT_NOTIFY);
+			/* FIXME report error */
+			dapl_os_assert(dat_status == DAT_SUCCESS);
 
+			notify_requested = DAT_TRUE;
 
-	/*
-	 * Unused by poster; it has no way to tell how many
-	 * items are on the queue without copying them over to the
-	 * EVD queue, and we're the only ones allowed to dequeue
-	 * from the CQ for synchronization/locking reasons.
-	 */
-	evd_ptr->threshold = threshold;	
+			/* Try again.  */
+			continue;
+		}
 
-	DAPL_CNTR(DCNT_EVD_WAIT_BLOCKED);
+		/*
+		 * Unused by poster; it has no way to tell how many
+		 * items are on the queue without copying them over to the
+		 * EVD queue, and we're the only ones allowed to dequeue
+		 * from the CQ for synchronization/locking reasons.
+		 */
+		evd_ptr->threshold = threshold;
 
+		DAPL_CNTR(evd_ptr, DCNT_EVD_WAIT_BLOCKED);
+		dapl_os_unlock(&evd_ptr->header.lock);
+
 #ifdef CQ_WAIT_OBJECT
-	if (evd_ptr->cq_wait_obj_handle)
-		dat_status = dapls_ib_wait_object_wait (
-				evd_ptr->cq_wait_obj_handle, time_out );
-	else
+		if (evd_ptr->cq_wait_obj_handle)
+			dat_status =
+			    dapls_ib_wait_object_wait(evd_ptr->
+						      cq_wait_obj_handle,
+						      time_out);
+		else
 #endif
-		dat_status = dapl_os_wait_object_wait (
-				&evd_ptr->wait_object, time_out );
-	/*
-	 * FIXME: if the thread loops around and waits again
-	 * the time_out value needs to be updated.
-	 */
+			dat_status =
+			    dapl_os_wait_object_wait(&evd_ptr->wait_object,
+						     time_out);
 
-	notify_requested = DAT_FALSE; /* We've used it up.  */
+		dapl_os_lock(&evd_ptr->header.lock);
 
-	/* See if we were awakened by evd_set_unwaitable */
-	if ( !evd_ptr->evd_waitable )
-	{
-		dat_status = DAT_ERROR (DAT_INVALID_STATE,0);
-	}
+		/*
+		 * FIXME: if the thread loops around and waits again
+		 * the time_out value needs to be updated.
+		 */
 
-	if (dat_status != DAT_SUCCESS)
-	{
-	    /*
-	     * If the status is DAT_TIMEOUT, we'll break out of the
-	     * loop, *not* dequeue an event (because dat_status
-	     * != DAT_SUCCESS), set *nmore (as we should for timeout)
-	     * and return DAT_TIMEOUT.
-	     */
-	    break;
+		notify_requested = DAT_FALSE;	/* We've used it up.  */
+
+		/* See if we were awakened by evd_set_unwaitable */
+		if (!evd_ptr->evd_waitable) {
+			dat_status = DAT_ERROR(DAT_INVALID_STATE, 0);
+		}
+
+		if (dat_status != DAT_SUCCESS) {
+			/*
+			 * If the status is DAT_TIMEOUT, we'll break out of the
+			 * loop, *not* dequeue an event (because dat_status
+			 * != DAT_SUCCESS), set *nmore (as we should for timeout)
+			 * and return DAT_TIMEOUT.
+			 */
+			break;
+		}
 	}
-    }
-	    
-    evd_ptr->evd_state = DAPL_EVD_STATE_OPEN;
 
-    if (dat_status == DAT_SUCCESS)
-    {
-	local_event = dapls_rbuf_remove(&evd_ptr->pending_event_queue);
-	*event = *local_event;
-	dapls_rbuf_add(&evd_ptr->free_event_queue, local_event);
-    }
+	evd_ptr->evd_state = DAPL_EVD_STATE_OPEN;
 
-    /*
-     * Valid if dat_status == DAT_SUCCESS || dat_status == DAT_TIMEOUT
-     * Undefined otherwise, so ok to set it.
-     */
-    *nmore = dapls_rbuf_count(&evd_ptr->pending_event_queue);
+	if (dat_status == DAT_SUCCESS) {
+		local_event = dapls_rbuf_remove(&evd_ptr->pending_event_queue);
+		*event = *local_event;
+		dapls_rbuf_add(&evd_ptr->free_event_queue, local_event);
+	}
 
- bail:
-    if ( dat_status ) {
-        dapl_dbg_log (DAPL_DBG_TYPE_RTN,
-			"dapl_evd_wait () returns 0x%x\n", dat_status);
-    }
-    return dat_status;
+	/*
+	 * Valid if dat_status == DAT_SUCCESS || dat_status == DAT_TIMEOUT
+	 * Undefined otherwise, so ok to set it.
+	 */
+	*nmore = dapls_rbuf_count(&evd_ptr->pending_event_queue);
+
+      bail:
+	dapl_os_unlock(&evd_ptr->header.lock);
+	if (dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_RTN,
+			     "dapl_evd_wait () returns 0x%x\n", dat_status);
+	}
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_init.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_init.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_init.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -37,7 +37,7 @@
  **********************************************************************/
 
 #include "dapl.h"
-#include <dat2/dat_registry.h> /* Provider API function prototypes */
+#include <dat2/dat_registry.h>	/* Provider API function prototypes */
 #include "dapl_hca_util.h"
 #include "dapl_init.h"
 #include "dapl_provider.h"
@@ -48,7 +48,6 @@
 #include "dapl_timer_util.h"
 #include "dapl_vendor.h"
 
-
 /*
  * dapl_init
  *
@@ -66,65 +65,61 @@
  *
  * Return Values:
  */
-void dapl_init ( void )
+void dapl_init(void)
 {
-    DAT_RETURN		dat_status;
+	DAT_RETURN dat_status;
 
-    /* set up debug type */
-    g_dapl_dbg_type = dapl_os_get_env_val ( "DAPL_DBG_TYPE", 
-					    DAPL_DBG_TYPE_ERR );
-    /* set up debug destination */
-    g_dapl_dbg_dest = dapl_os_get_env_val ( "DAPL_DBG_DEST", 
-					    DAPL_DBG_DEST_STDOUT );
+	/* set up debug type */
+	g_dapl_dbg_type = dapl_os_get_env_val("DAPL_DBG_TYPE",
+					      DAPL_DBG_TYPE_ERR);
+	/* set up debug destination */
+	g_dapl_dbg_dest = dapl_os_get_env_val("DAPL_DBG_DEST",
+					      DAPL_DBG_DEST_STDOUT);
 
-    /* open log file on first logging call if necessary */
-    if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)
-	openlog("libdapl", LOG_ODELAY|LOG_PID|LOG_CONS, LOG_USER);
-	
-    dapl_log (DAPL_DBG_TYPE_UTIL, "dapl_init: dbg_type=0x%x,dbg_dest=0x%x\n",
-	      g_dapl_dbg_type, g_dapl_dbg_dest);
+	/* open log file on first logging call if necessary */
+	if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)
+		openlog("libdapl", LOG_ODELAY | LOG_PID | LOG_CONS, LOG_USER);
 
-    /* See if the user is on a loopback setup */
-    g_dapl_loopback_connection = dapl_os_get_env_bool ( "DAPL_LOOPBACK" );
+	dapl_log(DAPL_DBG_TYPE_UTIL, "dapl_init: dbg_type=0x%x,dbg_dest=0x%x\n",
+		 g_dapl_dbg_type, g_dapl_dbg_dest);
 
-    dapl_dbg_log (DAPL_DBG_TYPE_UTIL, "DAPL: %s Setting Loopback\n", 
-                  g_dapl_loopback_connection ? "" : "NOT");
+	/* See if the user is on a loopback setup */
+	g_dapl_loopback_connection = dapl_os_get_env_bool("DAPL_LOOPBACK");
 
-    /* initialize verbs library */
-    dapls_ib_init ();
-    
-    /* initialize the timer */
-    dapls_timer_init();
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, "DAPL: %s Setting Loopback\n",
+		     g_dapl_loopback_connection ? "" : "NOT");
 
-    /* Set up name services */
-    dat_status = dapls_ns_init ();
-    if (DAT_SUCCESS != dat_status)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-                      "dapls_ns_init failed %d\n", dat_status);
-	goto bail;
-    }
+	/* initialize verbs library */
+	dapls_ib_init();
 
-    /* initialize the provider list */
-    dat_status = dapl_provider_list_create ();
+	/* initialize the timer */
+	dapls_timer_init();
 
-    if (DAT_SUCCESS != dat_status)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-                      "dapl_provider_list_create failed %d\n", dat_status);
-	goto bail;
-    }
+	/* Set up name services */
+	dat_status = dapls_ns_init();
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dapls_ns_init failed %d\n", dat_status);
+		goto bail;
+	}
 
-    DAPL_COUNTERS_INIT();
+	/* initialize the provider list */
+	dat_status = dapl_provider_list_create();
 
-    return;
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dapl_provider_list_create failed %d\n",
+			     dat_status);
+		goto bail;
+	}
 
-bail:
-    dapl_dbg_log (DAPL_DBG_TYPE_ERR, "ERROR: dapl_init failed\n");
-    return;
+	return;
+
+      bail:
+	dapl_dbg_log(DAPL_DBG_TYPE_ERR, "ERROR: dapl_init failed\n");
+	return;
 }
 
-
 /*
  * dapl_fini
  *
@@ -142,30 +137,29 @@
  *
  * Return Values:
  */
-void dapl_fini ( void )
+void dapl_fini(void)
 {
-    DAT_RETURN		dat_status;
+	DAT_RETURN dat_status;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_UTIL, "DAPL: ENTER (dapl_fini)\n");
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, "DAPL: ENTER (dapl_fini)\n");
 
-    dat_status = dapl_provider_list_destroy ();
-    if (DAT_SUCCESS != dat_status)
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-                      "dapl_provider_list_destroy failed %d\n", dat_status);
-    }
-    
-    dapls_ib_release ();
+	dat_status = dapl_provider_list_destroy();
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dapl_provider_list_destroy failed %d\n",
+			     dat_status);
+	}
 
-    dapl_dbg_log (DAPL_DBG_TYPE_UTIL, "DAPL: Exit (dapl_fini)\n");
+	dapls_ib_release();
 
-    if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)
-	closelog();
+	dapl_dbg_log(DAPL_DBG_TYPE_UTIL, "DAPL: Exit (dapl_fini)\n");
 
-    return;
+	if (g_dapl_dbg_dest & DAPL_DBG_DEST_SYSLOG)
+		closelog();
+
+	return;
 }
 
-
 /*
  *
  * This function is called by the registry to initialize a provider
@@ -176,143 +170,133 @@
  *
  */
 void DAT_API
-DAT_PROVIDER_INIT_FUNC_NAME (
-    IN const DAT_PROVIDER_INFO 	*provider_info,
-    IN const char 		*instance_data )
+DAT_PROVIDER_INIT_FUNC_NAME(IN const DAT_PROVIDER_INFO * provider_info,
+			    IN const char *instance_data)
 {
-    DAT_PROVIDER	*provider;
-    DAPL_HCA		*hca_ptr;
-    DAT_RETURN		dat_status;
-    char *        	data;
-    char *		name;
-    char *		port;
-    unsigned int 	len;
-    unsigned int 	i;
+	DAT_PROVIDER *provider;
+	DAPL_HCA *hca_ptr;
+	DAT_RETURN dat_status;
+	char *data;
+	char *name;
+	char *port;
+	unsigned int len;
+	unsigned int i;
 
-    data = NULL;
-    provider = NULL;
-    hca_ptr = NULL;
+	data = NULL;
+	provider = NULL;
+	hca_ptr = NULL;
 
 #if defined(_WIN32) || defined(_WIN64)
-    /* initialize DAPL library here as when called from DLL context in DLLmain()
-     * the IB (ibal) call hangs.
-     */
-    dapl_init();
+	/* initialize DAPL library here as when called from DLL context in DLLmain()
+	 * the IB (ibal) call hangs.
+	 */
+	dapl_init();
 #endif
 
-    dat_status = dapl_provider_list_insert(provider_info->ia_name, &provider);
-    if ( DAT_SUCCESS != dat_status ) 
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR, 
-                      "dat_provider_list_insert failed: %x\n", dat_status);
-	goto bail;
-    }
+	dat_status =
+	    dapl_provider_list_insert(provider_info->ia_name, &provider);
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dat_provider_list_insert failed: %x\n",
+			     dat_status);
+		goto bail;
+	}
 
-    data = dapl_os_strdup(instance_data);
-    if ( NULL == data )
-    {
-        goto bail;
-    }
-    
-    len = dapl_os_strlen(data);
-    
-    for ( i = 0; i < len; i++ )
-    {
-        if ( ' ' == data[i] ) 
-        { 
-            data[i] = '\0';
-            break; 
-        }
-    }
+	data = dapl_os_strdup(instance_data);
+	if (NULL == data) {
+		goto bail;
+	}
 
-    /* if the instance data did not have a valid format */
-    if ( i == len ) 
-    {
-        goto bail;
-    }
+	len = dapl_os_strlen(data);
 
-    name = data;
-    port = data + (i + 1);
+	for (i = 0; i < len; i++) {
+		if (' ' == data[i]) {
+			data[i] = '\0';
+			break;
+		}
+	}
 
-    hca_ptr = dapl_hca_alloc (name, port);
-    if ( NULL == hca_ptr )
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR, "%s() dapl_hca_alloc failed?\n");
-	goto bail;
-    }
-    
-    provider->extension = hca_ptr;
-    dat_status = dat_registry_add_provider (provider, provider_info);
-    if ( DAT_SUCCESS != dat_status ) 
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-                      "dat_registry_add_provider failed: %x\n", dat_status);
-    }
+	/* if the instance data did not have a valid format */
+	if (i == len) {
+		goto bail;
+	}
 
- bail:
-    if ( NULL != data )
-    {
-        dapl_os_free(data, len + 1);
-    }
-    
-    if ( DAT_SUCCESS != dat_status ) 
-    {
-        if ( NULL != provider )
-        {
-            (void) dapl_provider_list_remove(provider_info->ia_name);
-        }
-        
-        if ( NULL != hca_ptr )
-        {
-            dapl_hca_free (hca_ptr);
-        }
-    }
-}
+	name = data;
+	port = data + (i + 1);
 
+	hca_ptr = dapl_hca_alloc(name, port);
+	if (NULL == hca_ptr) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "%s() dapl_hca_alloc failed?\n");
+		goto bail;
+	}
 
+	provider->extension = hca_ptr;
+	dat_status = dat_registry_add_provider(provider, provider_info);
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dat_registry_add_provider failed: %x\n",
+			     dat_status);
+	}
+
+      bail:
+	if (NULL != data) {
+		dapl_os_free(data, len + 1);
+	}
+
+	if (DAT_SUCCESS != dat_status) {
+		if (NULL != provider) {
+			(void)dapl_provider_list_remove(provider_info->ia_name);
+		}
+
+		if (NULL != hca_ptr) {
+			dapl_hca_free(hca_ptr);
+		}
+	}
+}
+
 /*
  *
  * This function is called by the registry to de-initialize a provider
  *
  */
 void DAT_API
-DAT_PROVIDER_FINI_FUNC_NAME (
-    IN const DAT_PROVIDER_INFO 	*provider_info )
+DAT_PROVIDER_FINI_FUNC_NAME(IN const DAT_PROVIDER_INFO * provider_info)
 {
-    DAT_PROVIDER	*provider;
-    DAT_RETURN		dat_status;
-    
-    dat_status = dapl_provider_list_search(provider_info->ia_name, &provider);
-    if ( DAT_SUCCESS != dat_status ) 
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-                      "dat_registry_add_provider failed: %x\n", dat_status);
-	return;
-    }
-    
-    dat_status = dat_registry_remove_provider (provider, provider_info);
-    if ( DAT_SUCCESS != dat_status ) 
-    {
-	dapl_dbg_log (DAPL_DBG_TYPE_ERR,
-                      "dat_registry_add_provider failed: %x\n", dat_status);
-    }
+	DAT_PROVIDER *provider;
+	DAT_RETURN dat_status;
 
-    /*
-     * free HCA memory
-     */
-    dapl_hca_free (provider->extension);
+	dat_status =
+	    dapl_provider_list_search(provider_info->ia_name, &provider);
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dat_registry_add_provider failed: %x\n",
+			     dat_status);
+		return;
+	}
 
-    (void) dapl_provider_list_remove(provider_info->ia_name);
+	dat_status = dat_registry_remove_provider(provider, provider_info);
+	if (DAT_SUCCESS != dat_status) {
+		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
+			     "dat_registry_add_provider failed: %x\n",
+			     dat_status);
+	}
 
+	/*
+	 * free HCA memory
+	 */
+	dapl_hca_free(provider->extension);
+
+	(void)dapl_provider_list_remove(provider_info->ia_name);
+
 #if defined(_WIN32) || defined(_WIN64)
-    /* cleanup DAPL library - relocated here from OSD DLL context as the IBAL
-     * calls hung in the DLL context?
-     */
-    dapl_fini();
+	/* cleanup DAPL library - relocated here from OSD DLL context as the IBAL
+	 * calls hung in the DLL context?
+	 */
+	dapl_fini();
 #endif
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_lmr_create.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_lmr_create.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/dapl_lmr_create.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -45,46 +45,42 @@
  *********************************************************************/
 
 STATIC _INLINE_ DAT_RETURN
-dapli_lmr_create_virtual (	
-    IN	DAPL_IA			*ia,
-    IN	DAT_PVOID		virt_addr,
-    IN	DAT_VLEN		length,
-    IN	DAPL_PZ			*pz,
-    IN	DAT_MEM_PRIV_FLAGS	privileges,
-    IN	DAT_VA_TYPE		va_type,
-    OUT	DAT_LMR_HANDLE		*lmr_handle,
-    OUT	DAT_LMR_CONTEXT		*lmr_context,
-    OUT DAT_RMR_CONTEXT		*rmr_context,
-    OUT	DAT_VLEN		*registered_length,
-    OUT	DAT_VADDR		*registered_address );
+dapli_lmr_create_virtual(IN DAPL_IA * ia,
+			 IN DAT_PVOID virt_addr,
+			 IN DAT_VLEN length,
+			 IN DAPL_PZ * pz,
+			 IN DAT_MEM_PRIV_FLAGS privileges,
+			 IN DAT_VA_TYPE va_type,
+			 OUT DAT_LMR_HANDLE * lmr_handle,
+			 OUT DAT_LMR_CONTEXT * lmr_context,
+			 OUT DAT_RMR_CONTEXT * rmr_context,
+			 OUT DAT_VLEN * registered_length,
+			 OUT DAT_VADDR * registered_address);
 
 STATIC _INLINE_ DAT_RETURN
-dapli_lmr_create_lmr (    
-    IN  DAPL_IA                 *ia,
-    IN  DAPL_LMR	        *original_lmr,
-    IN  DAPL_PZ                 *pz,
-    IN  DAT_MEM_PRIV_FLAGS      privileges,
-    IN	DAT_VA_TYPE		va_type,
-    OUT DAT_LMR_HANDLE          *lmr_handle,
-    OUT DAT_LMR_CONTEXT         *lmr_context,
-    OUT DAT_RMR_CONTEXT		*rmr_context,
-    OUT DAT_VLEN                *registered_length,
-    OUT DAT_VADDR               *registered_address );
+dapli_lmr_create_lmr(IN DAPL_IA * ia,
+		     IN DAPL_LMR * original_lmr,
+		     IN DAPL_PZ * pz,
+		     IN DAT_MEM_PRIV_FLAGS privileges,
+		     IN DAT_VA_TYPE va_type,
+		     OUT DAT_LMR_HANDLE * lmr_handle,
+		     OUT DAT_LMR_CONTEXT * lmr_context,
+		     OUT DAT_RMR_CONTEXT * rmr_context,
+		     OUT DAT_VLEN * registered_length,
+		     OUT DAT_VADDR * registered_address);
 
-
 STATIC _INLINE_ DAT_RETURN
-dapli_lmr_create_shared (
-    IN  DAPL_IA                 *ia,
-    IN  DAT_REGION_DESCRIPTION  reg_desc,
-    IN  DAT_VLEN                length,
-    IN  DAPL_PZ                 *pz,
-    IN  DAT_MEM_PRIV_FLAGS      privileges,
-    IN	DAT_VA_TYPE		va_type,
-    OUT DAT_LMR_HANDLE          *lmr_handle,
-    OUT DAT_LMR_CONTEXT         *lmr_context,
-    OUT DAT_RMR_CONTEXT         *rmr_context,
-    OUT DAT_VLEN                *registered_length,
-    OUT DAT_VADDR               *registered_address );
+dapli_lmr_create_shared(IN DAPL_IA * ia,
+			IN DAT_REGION_DESCRIPTION reg_desc,
+			IN DAT_VLEN length,
+			IN DAPL_PZ * pz,
+			IN DAT_MEM_PRIV_FLAGS privileges,
+			IN DAT_VA_TYPE va_type,
+			OUT DAT_LMR_HANDLE * lmr_handle,
+			OUT DAT_LMR_CONTEXT * lmr_context,
+			OUT DAT_RMR_CONTEXT * rmr_context,
+			OUT DAT_VLEN * registered_length,
+			OUT DAT_VADDR * registered_address);
 
 /*********************************************************************
  *                                                                   *
@@ -93,336 +89,292 @@
  *********************************************************************/
 
 DAT_RETURN
-dapli_lmr_create_virtual (	
-    IN	DAPL_IA			*ia,
-    IN	DAT_PVOID		virt_addr,
-    IN	DAT_VLEN		length,
-    IN	DAPL_PZ			*pz,
-    IN	DAT_MEM_PRIV_FLAGS	privileges,
-    IN	DAT_VA_TYPE		va_type,
-    OUT	DAT_LMR_HANDLE		*lmr_handle,
-    OUT	DAT_LMR_CONTEXT		*lmr_context,
-    OUT DAT_RMR_CONTEXT		*rmr_context,
-    OUT	DAT_VLEN		*registered_length,
-    OUT	DAT_VADDR		*registered_address )
+dapli_lmr_create_virtual(IN DAPL_IA * ia,
+			 IN DAT_PVOID virt_addr,
+			 IN DAT_VLEN length,
+			 IN DAPL_PZ * pz,
+			 IN DAT_MEM_PRIV_FLAGS privileges,
+			 IN DAT_VA_TYPE va_type,
+			 OUT DAT_LMR_HANDLE * lmr_handle,
+			 OUT DAT_LMR_CONTEXT * lmr_context,
+			 OUT DAT_RMR_CONTEXT * rmr_context,
+			 OUT DAT_VLEN * registered_length,
+			 OUT DAT_VADDR * registered_address)
 {
-    DAPL_LMR 			*lmr;
-    DAT_REGION_DESCRIPTION 	reg_desc;
-    DAT_RETURN			dat_status;
+	DAPL_LMR *lmr;
+	DAT_REGION_DESCRIPTION reg_desc;
+	DAT_RETURN dat_status;
 
-    reg_desc.for_va = virt_addr;
-    dat_status = DAT_SUCCESS;
+	reg_desc.for_va = virt_addr;
+	dat_status = DAT_SUCCESS;
 
-    lmr = dapl_lmr_alloc (ia, 
-                         DAT_MEM_TYPE_VIRTUAL,
-                         reg_desc,
-                         length,
-                         (DAT_PZ_HANDLE) pz, 
-                         privileges);
+	lmr = dapl_lmr_alloc(ia,
+			     DAT_MEM_TYPE_VIRTUAL,
+			     reg_desc, length, (DAT_PZ_HANDLE) pz, privileges);
 
-    if ( NULL == lmr )
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == lmr) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_status = dapls_ib_mr_register (ia,
-				       lmr,
-				       virt_addr,
-				       length,
-				       privileges,
-				       va_type);
+	dat_status = dapls_ib_mr_register(ia,
+					  lmr,
+					  virt_addr,
+					  length, privileges, va_type);
 
-    if (DAT_SUCCESS != dat_status)
-    {
-	dapl_lmr_dealloc (lmr);
-	goto bail;
-    }
+	if (DAT_SUCCESS != dat_status) {
+		dapl_lmr_dealloc(lmr);
+		goto bail;
+	}
 
-    /* if the LMR context is already in the hash table */
-    dat_status =  dapls_hash_search (ia->hca_ptr->lmr_hash_table, 
-				     lmr->param.lmr_context,
-				     NULL);
-    if (dat_status == DAT_SUCCESS)
-    {
-	(void)dapls_ib_mr_deregister (lmr);
-	dapl_lmr_dealloc (lmr);
+	/* if the LMR context is already in the hash table */
+	dat_status = dapls_hash_search(ia->hca_ptr->lmr_hash_table,
+				       lmr->param.lmr_context, NULL);
+	if (dat_status == DAT_SUCCESS) {
+		(void)dapls_ib_mr_deregister(lmr);
+		dapl_lmr_dealloc(lmr);
 
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_LMR_IN_USE);
-	goto bail;
-    }
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
+		goto bail;
+	}
 
-    dat_status = dapls_hash_insert (ia->hca_ptr->lmr_hash_table, 
-				    lmr->param.lmr_context,
-				    lmr);
-    if (dat_status != DAT_SUCCESS)
-    {
-	(void)dapls_ib_mr_deregister (lmr);
-	dapl_lmr_dealloc (lmr);
+	dat_status = dapls_hash_insert(ia->hca_ptr->lmr_hash_table,
+				       lmr->param.lmr_context, lmr);
+	if (dat_status != DAT_SUCCESS) {
+		(void)dapls_ib_mr_deregister(lmr);
+		dapl_lmr_dealloc(lmr);
 
-	/* The value returned by dapls_hash_insert(.) is not    */
-	/* returned to the consumer because the spec. requires */
-	/* that dat_lmr_create(.) return only certain values.  */
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+		/* The value returned by dapls_hash_insert(.) is not    */
+		/* returned to the consumer because the spec. requires */
+		/* that dat_lmr_create(.) return only certain values.  */
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dapl_os_atomic_inc (&pz->pz_ref_count);
-    *lmr_handle = (DAT_LMR_HANDLE) lmr;
+	dapl_os_atomic_inc(&pz->pz_ref_count);
+	*lmr_handle = (DAT_LMR_HANDLE) lmr;
 
-    if (NULL != lmr_context)
-    {
-	*lmr_context = lmr->param.lmr_context;
-    }
-    if (NULL != rmr_context)
-    {
-	*rmr_context = lmr->param.rmr_context;
-    }
-    if (NULL != registered_length)
-    {
-	*registered_length =  lmr->param.registered_size;
-    }
-    if (NULL != registered_address)
-    {
-	*registered_address = lmr->param.registered_address;
-    }
+	if (NULL != lmr_context) {
+		*lmr_context = lmr->param.lmr_context;
+	}
+	if (NULL != rmr_context) {
+		*rmr_context = lmr->param.rmr_context;
+	}
+	if (NULL != registered_length) {
+		*registered_length = lmr->param.registered_size;
+	}
+	if (NULL != registered_address) {
+		*registered_address = lmr->param.registered_address;
+	}
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 DAT_RETURN
-dapli_lmr_create_lmr (    
-    IN  DAPL_IA                 *ia,
-    IN  DAPL_LMR	        *original_lmr,
-    IN  DAPL_PZ                 *pz,
-    IN  DAT_MEM_PRIV_FLAGS      privileges,
-    IN	DAT_VA_TYPE		va_type,
-    OUT DAT_LMR_HANDLE          *lmr_handle,
-    OUT DAT_LMR_CONTEXT         *lmr_context,
-    OUT DAT_RMR_CONTEXT		*rmr_context,
-    OUT DAT_VLEN                *registered_length,
-    OUT DAT_VADDR               *registered_address )
+dapli_lmr_create_lmr(IN DAPL_IA * ia,
+		     IN DAPL_LMR * original_lmr,
+		     IN DAPL_PZ * pz,
+		     IN DAT_MEM_PRIV_FLAGS privileges,
+		     IN DAT_VA_TYPE va_type,
+		     OUT DAT_LMR_HANDLE * lmr_handle,
+		     OUT DAT_LMR_CONTEXT * lmr_context,
+		     OUT DAT_RMR_CONTEXT * rmr_context,
+		     OUT DAT_VLEN * registered_length,
+		     OUT DAT_VADDR * registered_address)
 {
-    DAPL_LMR 			*lmr;
-    DAT_REGION_DESCRIPTION 	reg_desc;
-    DAT_RETURN			dat_status;
-    DAPL_HASH_DATA		hash_lmr;
+	DAPL_LMR *lmr;
+	DAT_REGION_DESCRIPTION reg_desc;
+	DAT_RETURN dat_status;
+	DAPL_HASH_DATA hash_lmr;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-    		  "dapl_lmr_create_lmr (%p, %p, %p, %x, %x, %p, %p, %p, %p)\n",
-		  ia,
-		  original_lmr, 
-		  pz, privileges, va_type,
-		  lmr_handle, 
-		  lmr_context, 
-		  registered_length, 
-		  registered_address);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_lmr_create_lmr (%p, %p, %p, %x, %x, %p, %p, %p, %p)\n",
+		     ia,
+		     original_lmr,
+		     pz, privileges, va_type,
+		     lmr_handle,
+		     lmr_context, registered_length, registered_address);
 
-    dat_status = dapls_hash_search (ia->hca_ptr->lmr_hash_table, 
-				    original_lmr->param.lmr_context, 
-				    &hash_lmr);
-     if ( dat_status != DAT_SUCCESS )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER,DAT_INVALID_ARG2);
-	goto bail;
-    }
-    lmr = (DAPL_LMR*)hash_lmr;
-    reg_desc.for_lmr_handle = (DAT_LMR_HANDLE) original_lmr;
+	dat_status = dapls_hash_search(ia->hca_ptr->lmr_hash_table,
+				       original_lmr->param.lmr_context,
+				       &hash_lmr);
+	if (dat_status != DAT_SUCCESS) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+		goto bail;
+	}
+	lmr = (DAPL_LMR *) hash_lmr;
+	reg_desc.for_lmr_handle = (DAT_LMR_HANDLE) original_lmr;
 
-    lmr = dapl_lmr_alloc (ia, 
-			  DAT_MEM_TYPE_LMR,
-			  reg_desc,
-			  original_lmr->param.length,
-			  (DAT_PZ_HANDLE) pz,
-			  privileges);
+	lmr = dapl_lmr_alloc(ia,
+			     DAT_MEM_TYPE_LMR,
+			     reg_desc,
+			     original_lmr->param.length,
+			     (DAT_PZ_HANDLE) pz, privileges);
 
-    if (NULL == lmr)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == lmr) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_status = dapls_ib_mr_register_shared (ia,
-					      lmr,
-					      privileges,
-					      va_type);
+	dat_status = dapls_ib_mr_register_shared(ia, lmr, privileges, va_type);
 
-    if (DAT_SUCCESS != dat_status)
-    {
-	dapl_lmr_dealloc (lmr);
-	goto bail;
-    }
+	if (DAT_SUCCESS != dat_status) {
+		dapl_lmr_dealloc(lmr);
+		goto bail;
+	}
 
-    /* if the LMR context is already in the hash table */
-    dat_status = dapls_hash_search (ia->hca_ptr->lmr_hash_table, 
-				    lmr->param.lmr_context,
-				    NULL);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dapls_ib_mr_deregister (lmr);
-	dapl_lmr_dealloc (lmr);
+	/* if the LMR context is already in the hash table */
+	dat_status = dapls_hash_search(ia->hca_ptr->lmr_hash_table,
+				       lmr->param.lmr_context, NULL);
+	if (dat_status == DAT_SUCCESS) {
+		dapls_ib_mr_deregister(lmr);
+		dapl_lmr_dealloc(lmr);
 
-	dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_LMR_IN_USE);
-	goto bail;
-    }
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
+		goto bail;
+	}
 
-    dat_status = dapls_hash_insert (ia->hca_ptr->lmr_hash_table, 
-				    lmr->param.lmr_context,
-				    lmr);
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapls_ib_mr_deregister (lmr);
-	dapl_lmr_dealloc (lmr);
+	dat_status = dapls_hash_insert(ia->hca_ptr->lmr_hash_table,
+				       lmr->param.lmr_context, lmr);
+	if (dat_status != DAT_SUCCESS) {
+		dapls_ib_mr_deregister(lmr);
+		dapl_lmr_dealloc(lmr);
 
-	/* The value returned by dapls_hash_insert(.) is not    */
-	/* returned to the consumer because the spec. requires */
-	/* that dat_lmr_create(.) return only certain values.  */
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+		/* The value returned by dapls_hash_insert(.) is not    */
+		/* returned to the consumer because the spec. requires */
+		/* that dat_lmr_create(.) return only certain values.  */
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dapl_os_atomic_inc (&pz->pz_ref_count);
-    *lmr_handle = (DAT_LMR_HANDLE) lmr;
+	dapl_os_atomic_inc(&pz->pz_ref_count);
+	*lmr_handle = (DAT_LMR_HANDLE) lmr;
 
-    if (NULL != lmr_context)
-    {
-	*lmr_context = lmr->param.lmr_context;
-    }
-    if (NULL != rmr_context)
-    {
-	*rmr_context = lmr->param.rmr_context;
-    }
-    if (NULL != registered_length)
-    {
-	*registered_length = lmr->param.registered_size;
-    }
-    if (NULL != registered_address)
-    {
-	*registered_address = lmr->param.registered_address;
-    }
+	if (NULL != lmr_context) {
+		*lmr_context = lmr->param.lmr_context;
+	}
+	if (NULL != rmr_context) {
+		*rmr_context = lmr->param.rmr_context;
+	}
+	if (NULL != registered_length) {
+		*registered_length = lmr->param.registered_size;
+	}
+	if (NULL != registered_address) {
+		*registered_address = lmr->param.registered_address;
+	}
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
-
 DAT_RETURN
-dapli_lmr_create_shared (
-    IN  DAPL_IA                 *ia,
-    IN  DAT_REGION_DESCRIPTION  reg_desc,
-    IN  DAT_VLEN                length,
-    IN  DAPL_PZ                 *pz,
-    IN  DAT_MEM_PRIV_FLAGS      privileges,
-    IN	DAT_VA_TYPE		va_type,
-    OUT DAT_LMR_HANDLE          *lmr_handle,
-    OUT DAT_LMR_CONTEXT         *lmr_context,
-    OUT DAT_RMR_CONTEXT         *rmr_context,
-    OUT DAT_VLEN                *registered_length,
-    OUT DAT_VADDR               *registered_address )
+dapli_lmr_create_shared(IN DAPL_IA * ia,
+			IN DAT_REGION_DESCRIPTION reg_desc,
+			IN DAT_VLEN length,
+			IN DAPL_PZ * pz,
+			IN DAT_MEM_PRIV_FLAGS privileges,
+			IN DAT_VA_TYPE va_type,
+			OUT DAT_LMR_HANDLE * lmr_handle,
+			OUT DAT_LMR_CONTEXT * lmr_context,
+			OUT DAT_RMR_CONTEXT * rmr_context,
+			OUT DAT_VLEN * registered_length,
+			OUT DAT_VADDR * registered_address)
 {
-    DAPL_LMR			*lmr;
-    DAT_RETURN			dat_status;
+	DAPL_LMR *lmr;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    dapl_dbg_log (DAPL_DBG_TYPE_API,
-    		  "dapl_lmr_create_shared_virtual (ia=%p len=%x pz=%p priv=%x)\n",
-		  ia,
-		  length,
-		  pz, privileges);
+	dapl_dbg_log(DAPL_DBG_TYPE_API,
+		     "dapl_lmr_create_shared_virtual (ia=%p len=%x pz=%p priv=%x)\n",
+		     ia, length, pz, privileges);
 
-    lmr = dapl_lmr_alloc (ia, 
-			  DAT_MEM_TYPE_LMR,
-			  reg_desc,
-			  length, /* length is meaningless */
-			  (DAT_PZ_HANDLE) pz,
-			  privileges);
+	lmr = dapl_lmr_alloc(ia, DAT_MEM_TYPE_LMR, reg_desc, length,	/* length is meaningless */
+			     (DAT_PZ_HANDLE) pz, privileges);
 
-    if (NULL == lmr)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == lmr) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    /*
-     * Added for the shared memory support - - -
-     * Save the region description.  We need to copy the shared
-     * memory id because the region_desc only contains a pointer
-     * to it.
-     */
-    dapl_os_memcpy(&lmr->shmid,
- 		   reg_desc.for_shared_memory.shared_memory_id,
- 		   sizeof(lmr->shmid));
-    lmr->param.region_desc = reg_desc;
-    lmr->param.length      = length;
-    lmr->param.mem_type    = DAT_MEM_TYPE_SHARED_VIRTUAL;
-    lmr->param.region_desc.for_shared_memory.shared_memory_id = &lmr->shmid;
+	/*
+	 * Added for the shared memory support - - -
+	 * Save the region description.  We need to copy the shared
+	 * memory id because the region_desc only contains a pointer
+	 * to it.
+	 */
+	dapl_os_memcpy(&lmr->shmid,
+		       reg_desc.for_shared_memory.shared_memory_id,
+		       sizeof(lmr->shmid));
+	lmr->param.region_desc = reg_desc;
+	lmr->param.length = length;
+	lmr->param.mem_type = DAT_MEM_TYPE_SHARED_VIRTUAL;
+	lmr->param.region_desc.for_shared_memory.shared_memory_id = &lmr->shmid;
 
-    dat_status = dapls_ib_mr_register_shared(ia, lmr, privileges, va_type);
-    if (dat_status != DAT_SUCCESS)
-    {
-	dapl_lmr_dealloc (lmr);
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY_REGION);
-	goto bail;
-    }
+	dat_status = dapls_ib_mr_register_shared(ia, lmr, privileges, va_type);
+	if (dat_status != DAT_SUCCESS) {
+		dapl_lmr_dealloc(lmr);
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+			      DAT_RESOURCE_MEMORY_REGION);
+		goto bail;
+	}
 
-    /* if the LMR context is already in the hash table */
-    dat_status = dapls_hash_search(ia->hca_ptr->lmr_hash_table, 
-				   lmr->param.lmr_context,
-				   NULL);
-    if (DAT_SUCCESS == dat_status)
-    {
-	(void)dapls_ib_mr_deregister (lmr);
-	dapl_lmr_dealloc (lmr);
+	/* if the LMR context is already in the hash table */
+	dat_status = dapls_hash_search(ia->hca_ptr->lmr_hash_table,
+				       lmr->param.lmr_context, NULL);
+	if (DAT_SUCCESS == dat_status) {
+		(void)dapls_ib_mr_deregister(lmr);
+		dapl_lmr_dealloc(lmr);
 
-        dat_status = DAT_ERROR (DAT_INVALID_STATE,DAT_INVALID_STATE_LMR_IN_USE);
-	goto bail;
-    }
-    
-    dat_status = dapls_hash_insert(ia->hca_ptr->lmr_hash_table, 
-				   lmr->param.lmr_context,
-				   lmr);
-    if (dat_status != DAT_SUCCESS)
-    {
-	(void)dapls_ib_mr_deregister (lmr);
-	dapl_lmr_dealloc (lmr);
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
+		goto bail;
+	}
 
-	/* The value returned by dapls_hash_insert(.) is not    */
-	/* returned to the consumer because the spec. requires */
-	/* that dat_lmr_create(.) return only certain values.  */
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	dat_status = dapls_hash_insert(ia->hca_ptr->lmr_hash_table,
+				       lmr->param.lmr_context, lmr);
+	if (dat_status != DAT_SUCCESS) {
+		(void)dapls_ib_mr_deregister(lmr);
+		dapl_lmr_dealloc(lmr);
 
-    dapl_os_atomic_inc (&pz->pz_ref_count);
-    *lmr_handle = (DAT_LMR_HANDLE) lmr;
+		/* The value returned by dapls_hash_insert(.) is not    */
+		/* returned to the consumer because the spec. requires */
+		/* that dat_lmr_create(.) return only certain values.  */
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    if (NULL != lmr_context)
-    {
-	*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
-    }
-    if (NULL != rmr_context)
-    {
-	*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
-    }
-    if (NULL != registered_length)
-    {
-	*registered_length = lmr->param.length;
-    }
-    if (NULL != registered_address)
-    {
-	*registered_address = (DAT_VADDR) (uintptr_t) 
-		lmr->param.region_desc.for_shared_memory.virtual_address;
-    }
- bail:
+	dapl_os_atomic_inc(&pz->pz_ref_count);
+	*lmr_handle = (DAT_LMR_HANDLE) lmr;
 
-    return dat_status;
+	if (NULL != lmr_context) {
+		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
+	}
+	if (NULL != rmr_context) {
+		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
+	}
+	if (NULL != registered_length) {
+		*registered_length = lmr->param.length;
+	}
+	if (NULL != registered_address) {
+		*registered_address = (DAT_VADDR) (uintptr_t)
+		    lmr->param.region_desc.for_shared_memory.virtual_address;
+	}
+      bail:
+
+	return dat_status;
 }
 
-
 /*
  * dapl_lmr_create
  *
@@ -452,89 +404,103 @@
  *
  */
 DAT_RETURN DAT_API
-dapl_lmr_create (
-	IN	DAT_IA_HANDLE		ia_handle,
-	IN	DAT_MEM_TYPE		mem_type,
-	IN	DAT_REGION_DESCRIPTION	region_description,
-	IN	DAT_VLEN		length,
-	IN	DAT_PZ_HANDLE		pz_handle,
-	IN	DAT_MEM_PRIV_FLAGS	privileges,
-	IN	DAT_VA_TYPE		va_type,
-	OUT	DAT_LMR_HANDLE		*lmr_handle,
-	OUT	DAT_LMR_CONTEXT		*lmr_context,
-        OUT     DAT_RMR_CONTEXT		*rmr_context,
-	OUT	DAT_VLEN		*registered_length,
-	OUT	DAT_VADDR		*registered_address )
+dapl_lmr_create(IN DAT_IA_HANDLE ia_handle,
+		IN DAT_MEM_TYPE mem_type,
+		IN DAT_REGION_DESCRIPTION region_description,
+		IN DAT_VLEN length,
+		IN DAT_PZ_HANDLE pz_handle,
+		IN DAT_MEM_PRIV_FLAGS privileges,
+		IN DAT_VA_TYPE va_type,
+		OUT DAT_LMR_HANDLE * lmr_handle,
+		OUT DAT_LMR_CONTEXT * lmr_context,
+		OUT DAT_RMR_CONTEXT * rmr_context,
+		OUT DAT_VLEN * registered_length,
+		OUT DAT_VADDR * registered_address)
 {
-    DAPL_IA 		*ia;
-    DAPL_PZ 		*pz;
-    DAT_RETURN		dat_status;
+	DAPL_IA *ia;
+	DAPL_PZ *pz;
+	DAT_RETURN dat_status;
 
-    if ( DAPL_BAD_HANDLE (ia_handle, DAPL_MAGIC_IA) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
-    if ( DAPL_BAD_HANDLE (pz_handle, DAPL_MAGIC_PZ) )
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-	goto bail;
-    }
-    if (NULL == lmr_handle)
-    {
-	dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
-        goto bail;
-    }
+	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
+	if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+		goto bail;
+	}
+	if (NULL == lmr_handle) {
+		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG7);
+		goto bail;
+	}
 
-    ia = (DAPL_IA *) ia_handle;
-    pz = (DAPL_PZ *) pz_handle;
+	ia = (DAPL_IA *) ia_handle;
+	pz = (DAPL_PZ *) pz_handle;
 
-    switch (mem_type)
-    {
+	DAPL_CNTR(ia, DCNT_IA_LMR_CREATE);
+
+	switch (mem_type) {
 	case DAT_MEM_TYPE_VIRTUAL:
-	{
-	    dat_status = dapli_lmr_create_virtual ( 
-		ia, region_description.for_va, length, pz, privileges, va_type, 
-		lmr_handle, lmr_context, rmr_context, registered_length, 
-		registered_address);
-	    break;
-	}
+		{
+			dat_status =
+			    dapli_lmr_create_virtual(ia,
+						     region_description.for_va,
+						     length, pz, privileges,
+						     va_type, lmr_handle,
+						     lmr_context, rmr_context,
+						     registered_length,
+						     registered_address);
+			break;
+		}
 	case DAT_MEM_TYPE_LMR:
-	{
-	    DAPL_LMR *lmr;
+		{
+			DAPL_LMR *lmr;
 
-	    if ( DAPL_BAD_HANDLE (region_description.for_lmr_handle, DAPL_MAGIC_LMR) )
-	    {
-		dat_status = DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
-		goto bail;
-	    }
+			if (DAPL_BAD_HANDLE
+			    (region_description.for_lmr_handle,
+			     DAPL_MAGIC_LMR)) {
+				dat_status =
+				    DAT_ERROR(DAT_INVALID_HANDLE,
+					      DAT_INVALID_HANDLE_LMR);
+				goto bail;
+			}
 
-	    lmr = (DAPL_LMR *) region_description.for_lmr_handle;
+			lmr = (DAPL_LMR *) region_description.for_lmr_handle;
 
-	    dat_status = dapli_lmr_create_lmr (
-		ia, lmr, pz, privileges, va_type, lmr_handle, 
-		lmr_context, rmr_context, registered_length, registered_address);
-	    break;
-	}
+			dat_status =
+			    dapli_lmr_create_lmr(ia, lmr, pz, privileges,
+						 va_type, lmr_handle,
+						 lmr_context, rmr_context,
+						 registered_length,
+						 registered_address);
+			break;
+		}
 	case DAT_MEM_TYPE_SHARED_VIRTUAL:
-	{
+		{
 #if (VN_MEM_SHARED_VIRTUAL_SUPPORT > 0)
-	    dat_status =  dapli_lmr_create_shared (
-                ia, region_description, length, pz, privileges, va_type,
-                lmr_handle, lmr_context, rmr_context, registered_length,
-                registered_address);
+			dat_status =
+			    dapli_lmr_create_shared(ia, region_description,
+						    length, pz, privileges,
+						    va_type, lmr_handle,
+						    lmr_context, rmr_context,
+						    registered_length,
+						    registered_address);
 #else
-            dat_status = DAT_ERROR (DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
+			dat_status =
+			    DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
 #endif
-	    break;
-	}
+			break;
+		}
 	default:
-	{
-	    dat_status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-	    break;
+		{
+			dat_status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+			break;
+		}
 	}
-    }
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -57,11 +57,11 @@
 #include "dapl_debug.h"
 
 #include <sys/time.h>
-#include <stdlib.h>			/* needed for getenv() */
-#include <pthread.h>			/* needed for pthread_atfork() */
-#include <signal.h>			/* needed for thread setup */
+#include <stdlib.h>		/* needed for getenv() */
+#include <pthread.h>		/* needed for pthread_atfork() */
+#include <signal.h>		/* needed for thread setup */
 
-static void dapls_osd_fork_cleanup (void);
+static void dapls_osd_fork_cleanup(void);
 
 /*
  * dapl_osd_init
@@ -76,22 +76,19 @@
  * Returns:
  *	DAT_SUCCESS
  */
-void
-dapl_os_init ( )
+void dapl_os_init()
 {
-    int status;
+	int status;
 
-    /*
-     * Set up fork control
-     */
-    status = pthread_atfork ( NULL, NULL, dapls_osd_fork_cleanup );
-    if ( status != 0 )
-    {
-	dapl_os_printf ("WARNING: pthread_atfork %d\n", status);
-    }
+	/*
+	 * Set up fork control
+	 */
+	status = pthread_atfork(NULL, NULL, dapls_osd_fork_cleanup);
+	if (status != 0) {
+		dapl_os_printf("WARNING: pthread_atfork %d\n", status);
+	}
 }
 
-
 /*
  * dapl_os_get_time
  *
@@ -104,21 +101,17 @@
  *	DAT_SUCCESS
  */
 
-DAT_RETURN
-dapl_os_get_time (
-    OUT DAPL_OS_TIMEVAL * loc)
+DAT_RETURN dapl_os_get_time(OUT DAPL_OS_TIMEVAL * loc)
 {
-    struct timeval	tv;
-    struct timezone	tz;
+	struct timeval tv;
+	struct timezone tz;
 
+	gettimeofday(&tv, &tz);
+	*loc = ((DAT_UINT64) (tv.tv_sec) * 1000000L) + (DAT_UINT64) tv.tv_usec;
 
-    gettimeofday (&tv, &tz);
-    *loc = ((DAT_UINT64) (tv.tv_sec) * 1000000L) + (DAT_UINT64) tv.tv_usec;
-
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapl_os_get__env_bool
  *
@@ -131,22 +124,18 @@
  * Returns:
  *	TRUE or FALSE
  */
-int
-dapl_os_get_env_bool (
-	char		*env_str )
+int dapl_os_get_env_bool(char *env_str)
 {
-    char		*env_var;
+	char *env_var;
 
-    env_var = getenv (env_str);
-    if (env_var != NULL)
-    {
-	return 1;
-    }
+	env_var = getenv(env_str);
+	if (env_var != NULL) {
+		return 1;
+	}
 
-    return 0;
+	return 0;
 }
 
-
 /*
  * dapl_os_get_env_val
  *
@@ -159,23 +148,18 @@
  * Returns:
  *	TRUE or FALSE
  */
-int
-dapl_os_get_env_val (
-	char		*env_str,
-	int		def_val )
+int dapl_os_get_env_val(char *env_str, int def_val)
 {
-    char		*env_var;
+	char *env_var;
 
-    env_var = getenv (env_str);
-    if ( env_var != NULL )
-    {
-	def_val = strtol (env_var, NULL, 0);
-    }
+	env_var = getenv(env_str);
+	if (env_var != NULL) {
+		def_val = strtol(env_var, NULL, 0);
+	}
 
-    return  def_val;
+	return def_val;
 }
 
-
 /*
  * Wait object routines
  */
@@ -192,23 +176,19 @@
  *	DAT_SUCCESS
  *	DAT_INTERNAL_ERROR
  */
-DAT_RETURN 
-dapl_os_wait_object_init (
-    IN DAPL_OS_WAIT_OBJECT *wait_obj)
+DAT_RETURN dapl_os_wait_object_init(IN DAPL_OS_WAIT_OBJECT * wait_obj)
 {
-    wait_obj->signaled = DAT_FALSE;
-    if ( 0 != pthread_cond_init ( &wait_obj->cv, NULL ) )
-    {
-	return DAT_ERROR (DAT_INTERNAL_ERROR,0);
-    }
+	wait_obj->signaled = DAT_FALSE;
+	if (0 != pthread_cond_init(&wait_obj->cv, NULL)) {
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
 
-    /* Always returns 0.  */
-    pthread_mutex_init ( &wait_obj->lock, NULL );
+	/* Always returns 0.  */
+	pthread_mutex_init(&wait_obj->lock, NULL);
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /* Wait on the supplied wait object, up to the specified time_out.
  * A timeout of DAT_TIMEOUT_INFINITE will wait indefinitely.
  * Timeout should be specified in micro seconds.
@@ -222,85 +202,72 @@
  *	DAT_TIMEOUT -- the specified time limit was reached.
  */
 
-DAT_RETURN 
-dapl_os_wait_object_wait (
-    IN	DAPL_OS_WAIT_OBJECT *wait_obj, 
-    IN  DAT_TIMEOUT timeout_val)
+DAT_RETURN
+dapl_os_wait_object_wait(IN DAPL_OS_WAIT_OBJECT * wait_obj,
+			 IN DAT_TIMEOUT timeout_val)
 {
-    DAT_RETURN 		dat_status;
-    int 		pthread_status;
-    struct timespec 	future;
+	DAT_RETURN dat_status;
+	int pthread_status;
+	struct timespec future;
 
-    dat_status = DAT_SUCCESS;
-    pthread_status = 0;
+	dat_status = DAT_SUCCESS;
+	pthread_status = 0;
 
-    if ( timeout_val != DAT_TIMEOUT_INFINITE )
-    {
-	struct timeval now;
-	struct timezone tz;
-	unsigned int microsecs;
+	if (timeout_val != DAT_TIMEOUT_INFINITE) {
+		struct timeval now;
+		struct timezone tz;
+		unsigned int microsecs;
 
-	gettimeofday (&now, &tz);
+		gettimeofday(&now, &tz);
 #define USEC_PER_SEC 1000000
-	microsecs = now.tv_usec + timeout_val;
-	now.tv_sec = now.tv_sec + microsecs/USEC_PER_SEC;
-	now.tv_usec = microsecs % USEC_PER_SEC;
+		microsecs = now.tv_usec + timeout_val;
+		now.tv_sec = now.tv_sec + microsecs / USEC_PER_SEC;
+		now.tv_usec = microsecs % USEC_PER_SEC;
 
-	/* Convert timeval to timespec */
-	future.tv_sec = now.tv_sec;
-	future.tv_nsec = now.tv_usec * 1000;
+		/* Convert timeval to timespec */
+		future.tv_sec = now.tv_sec;
+		future.tv_nsec = now.tv_usec * 1000;
 
-	pthread_mutex_lock (&wait_obj->lock);
-	while ( wait_obj->signaled == DAT_FALSE && pthread_status == 0)
-	{
-	    pthread_status = pthread_cond_timedwait (
-		    &wait_obj->cv , &wait_obj->lock , &future );
+		pthread_mutex_lock(&wait_obj->lock);
+		while (wait_obj->signaled == DAT_FALSE && pthread_status == 0) {
+			pthread_status =
+			    pthread_cond_timedwait(&wait_obj->cv,
+						   &wait_obj->lock, &future);
 
-	    /*
-	     * No need to reset &future if we go around the loop;
-	     * It's an absolute time.
-	     */
+			/*
+			 * No need to reset &future if we go around the loop;
+			 * It's an absolute time.
+			 */
+		}
+		/* Reset the signaled status if we were woken up.  */
+		if (pthread_status == 0) {
+			wait_obj->signaled = DAT_FALSE;
+		}
+		pthread_mutex_unlock(&wait_obj->lock);
+	} else {
+		pthread_mutex_lock(&wait_obj->lock);
+		while (wait_obj->signaled == DAT_FALSE && pthread_status == 0) {
+			pthread_status =
+			    pthread_cond_wait(&wait_obj->cv, &wait_obj->lock);
+		}
+		/* Reset the signaled status if we were woken up.  */
+		if (pthread_status == 0) {
+			wait_obj->signaled = DAT_FALSE;
+		}
+		pthread_mutex_unlock(&wait_obj->lock);
 	}
-	/* Reset the signaled status if we were woken up.  */
-	if (pthread_status == 0)
-	{
-	    wait_obj->signaled = DAT_FALSE;
+
+	if (ETIMEDOUT == pthread_status) {
+		dat_status = DAT_ERROR(DAT_TIMEOUT_EXPIRED, 0);
+	} else if (EINTR == pthread_status) {
+		dat_status = DAT_ERROR(DAT_INTERRUPTED_CALL, 0);
+	} else if (0 != pthread_status) {
+		dat_status = DAT_ERROR(DAT_INTERNAL_ERROR, 0);
 	}
-	pthread_mutex_unlock (&wait_obj->lock);
-    }
-    else
-    {
-	pthread_mutex_lock (&wait_obj->lock);
-	while ( wait_obj->signaled == DAT_FALSE && pthread_status == 0)
-	{
-	    pthread_status = pthread_cond_wait (
-		    &wait_obj->cv , &wait_obj->lock );
-	}
-	/* Reset the signaled status if we were woken up.  */
-	if (pthread_status == 0)
-	{
-	    wait_obj->signaled = DAT_FALSE;
-	}
-	pthread_mutex_unlock (&wait_obj->lock);
-    }
 
-    if (ETIMEDOUT == pthread_status)
-    {
-	dat_status = DAT_ERROR (DAT_TIMEOUT_EXPIRED, 0);
-    }
-    else if ( EINTR == pthread_status)
-    {
-	dat_status = DAT_ERROR (DAT_INTERRUPTED_CALL, 0);
-    }
-    else if ( 0 != pthread_status)
-    {
-	dat_status = DAT_ERROR (DAT_INTERNAL_ERROR, 0);
-    }
-
-    return dat_status;
+	return dat_status;
 }
 
-
 /*
  * dapl_os_wait_object_wakeup
  *
@@ -313,22 +280,18 @@
  *	DAT_SUCCESS
  *	DAT_INTERNAL_ERROR
  */
-DAT_RETURN 
-dapl_os_wait_object_wakeup (
-    IN	DAPL_OS_WAIT_OBJECT *wait_obj)
+DAT_RETURN dapl_os_wait_object_wakeup(IN DAPL_OS_WAIT_OBJECT * wait_obj)
 {
-    pthread_mutex_lock ( &wait_obj->lock );
-    wait_obj->signaled = DAT_TRUE;
-    pthread_mutex_unlock ( &wait_obj->lock );
-    if ( 0 != pthread_cond_signal ( &wait_obj->cv ) )
-    {
-	return DAT_ERROR (DAT_INTERNAL_ERROR,0);
-    }
+	pthread_mutex_lock(&wait_obj->lock);
+	wait_obj->signaled = DAT_TRUE;
+	pthread_mutex_unlock(&wait_obj->lock);
+	if (0 != pthread_cond_signal(&wait_obj->cv)) {
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapl_os_wait_object_destroy
  *
@@ -341,23 +304,18 @@
  *	DAT_SUCCESS
  *	DAT_INTERNAL_ERROR
  */
-DAT_RETURN 
-dapl_os_wait_object_destroy (
-    IN	DAPL_OS_WAIT_OBJECT *wait_obj)
+DAT_RETURN dapl_os_wait_object_destroy(IN DAPL_OS_WAIT_OBJECT * wait_obj)
 {
-    if ( 0 != pthread_cond_destroy ( &wait_obj->cv ) )
-    {
-	return DAT_ERROR (DAT_INTERNAL_ERROR,0);
-    }
-    if ( 0 != pthread_mutex_destroy ( &wait_obj->lock ) )
-    {
-	return DAT_ERROR (DAT_INTERNAL_ERROR,0);
-    }
+	if (0 != pthread_cond_destroy(&wait_obj->cv)) {
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
+	if (0 != pthread_mutex_destroy(&wait_obj->lock)) {
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /*
  * dapls_osd_fork_cleanup
  *
@@ -370,166 +328,180 @@
  * Returns:
  *	TRUE or FALSE
  */
-void dapls_osd_fork_cleanup (void)
+void dapls_osd_fork_cleanup(void)
 {
-    DAPL_PROVIDER_LIST_NODE 	*cur_node;
-    DAPL_HCA			*hca_ptr;
-    DAPL_IA			*ia_ptr;
-    DAPL_LMR 			*lmr_ptr;
-    DAPL_RMR	 		*rmr_ptr;
-    DAPL_PZ	 		*pz_ptr;
-    DAPL_CR	 		*cr_ptr;
-    DAPL_EP			*ep_ptr;
-    DAPL_EVD			*evd_ptr;
-    DAT_EP_PARAM		*param;
-    DAPL_SP			*sp_ptr;
-    
-    while ( NULL != g_dapl_provider_list.head )
-    {
-	cur_node = g_dapl_provider_list.head;
-	g_dapl_provider_list.head = cur_node->next;
+	DAPL_PROVIDER_LIST_NODE *cur_node;
+	DAPL_HCA *hca_ptr;
+	DAPL_IA *ia_ptr;
+	DAPL_LMR *lmr_ptr;
+	DAPL_RMR *rmr_ptr;
+	DAPL_PZ *pz_ptr;
+	DAPL_CR *cr_ptr;
+	DAPL_EP *ep_ptr;
+	DAPL_EVD *evd_ptr;
+	DAT_EP_PARAM *param;
+	DAPL_SP *sp_ptr;
 
-        hca_ptr = (DAPL_HCA *) cur_node->data.extension;
+	while (NULL != g_dapl_provider_list.head) {
+		cur_node = g_dapl_provider_list.head;
+		g_dapl_provider_list.head = cur_node->next;
 
-	/*
-	 * Walk the list of IA ptrs & clean up. This is purposely
-	 * a destructive list walk, we really don't want to preserve
-	 * any of it.
-	 */
-	while (!dapl_llist_is_empty (  &hca_ptr->ia_list_head ) )
-	{
-	    ia_ptr = (DAPL_IA *)
-		dapl_llist_peek_head ( &hca_ptr->ia_list_head );
+		hca_ptr = (DAPL_HCA *) cur_node->data.extension;
 
-	    /*
-	     * The rest of the cleanup code is similar to dapl_ia_close,
-	     * the big difference is that we don't release IB resources,
-	     * only memory; the underlying IB subsystem doesn't deal
-	     * with fork at all, so leave IB handles alone.
-	     */
-	    while (!dapl_llist_is_empty ( &ia_ptr->rmr_list_head ) )
-	    {
-		rmr_ptr = (DAPL_RMR *)
-		    dapl_llist_peek_head (&ia_ptr->rmr_list_head);
-		if ( rmr_ptr->param.lmr_triplet.virtual_address != 0 )
-		{
-                    dapl_os_atomic_dec (&rmr_ptr->lmr->lmr_ref_count); 
-                    rmr_ptr->param.lmr_triplet.virtual_address = 0;
-		}
-		dapl_os_atomic_dec ( &rmr_ptr->pz->pz_ref_count );
-		dapl_ia_unlink_rmr ( rmr_ptr->header.owner_ia, rmr_ptr );
-		dapl_rmr_dealloc ( rmr_ptr );
-	    }
+		/*
+		 * Walk the list of IA ptrs & clean up. This is purposely
+		 * a destructive list walk, we really don't want to preserve
+		 * any of it.
+		 */
+		while (!dapl_llist_is_empty(&hca_ptr->ia_list_head)) {
+			ia_ptr = (DAPL_IA *)
+			    dapl_llist_peek_head(&hca_ptr->ia_list_head);
 
-	    while (!dapl_llist_is_empty ( &ia_ptr->rsp_list_head ))
-	    {
-		sp_ptr = (DAPL_SP *)
-		    dapl_llist_peek_head ( &ia_ptr->rsp_list_head );
-		dapl_os_atomic_dec (& ((DAPL_EVD *)sp_ptr->evd_handle)->evd_ref_count);
-		dapls_ia_unlink_sp ( ia_ptr, sp_ptr );
-		dapls_sp_free_sp ( sp_ptr );
-	    }
+			/*
+			 * The rest of the cleanup code is similar to dapl_ia_close,
+			 * the big difference is that we don't release IB resources,
+			 * only memory; the underlying IB subsystem doesn't deal
+			 * with fork at all, so leave IB handles alone.
+			 */
+			while (!dapl_llist_is_empty(&ia_ptr->rmr_list_head)) {
+				rmr_ptr = (DAPL_RMR *)
+				    dapl_llist_peek_head(&ia_ptr->
+							 rmr_list_head);
+				if (rmr_ptr->param.lmr_triplet.
+				    virtual_address != 0) {
+					dapl_os_atomic_dec(&rmr_ptr->lmr->
+							   lmr_ref_count);
+					rmr_ptr->param.lmr_triplet.
+					    virtual_address = 0;
+				}
+				dapl_os_atomic_dec(&rmr_ptr->pz->pz_ref_count);
+				dapl_ia_unlink_rmr(rmr_ptr->header.owner_ia,
+						   rmr_ptr);
+				dapl_rmr_dealloc(rmr_ptr);
+			}
 
-	    while (!dapl_llist_is_empty ( &ia_ptr->ep_list_head ) )
-	    {
-		ep_ptr = (DAPL_EP *)
-		    dapl_llist_peek_head ( &ia_ptr->ep_list_head );
-		param = &ep_ptr->param;
-		if ( param->pz_handle != NULL )
-		{
-		    dapl_os_atomic_dec ( & ((DAPL_PZ *)param->pz_handle)->pz_ref_count );
-		}
-		if ( param->recv_evd_handle != NULL )
-		{
-		    dapl_os_atomic_dec (& ((DAPL_EVD *)param->recv_evd_handle)->evd_ref_count);
-		}
-		if ( param->request_evd_handle )
-		{
-		    dapl_os_atomic_dec (& ((DAPL_EVD *)param->request_evd_handle)->evd_ref_count);
-		}
-		if ( param->connect_evd_handle != NULL )
-		{
-		    dapl_os_atomic_dec (& ((DAPL_EVD *)param->connect_evd_handle)->evd_ref_count);
-		}
+			while (!dapl_llist_is_empty(&ia_ptr->rsp_list_head)) {
+				sp_ptr = (DAPL_SP *)
+				    dapl_llist_peek_head(&ia_ptr->
+							 rsp_list_head);
+				dapl_os_atomic_dec(&
+						   ((DAPL_EVD *) sp_ptr->
+						    evd_handle)->evd_ref_count);
+				dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+				dapls_sp_free_sp(sp_ptr);
+			}
 
-		/* ...and free the resource */
-		dapl_ia_unlink_ep ( ia_ptr, ep_ptr );
-		dapl_ep_dealloc ( ep_ptr );
-	    }
+			while (!dapl_llist_is_empty(&ia_ptr->ep_list_head)) {
+				ep_ptr = (DAPL_EP *)
+				    dapl_llist_peek_head(&ia_ptr->ep_list_head);
+				param = &ep_ptr->param;
+				if (param->pz_handle != NULL) {
+					dapl_os_atomic_dec(&
+							   ((DAPL_PZ *) param->
+							    pz_handle)->
+							   pz_ref_count);
+				}
+				if (param->recv_evd_handle != NULL) {
+					dapl_os_atomic_dec(&
+							   ((DAPL_EVD *) param->
+							    recv_evd_handle)->
+							   evd_ref_count);
+				}
+				if (param->request_evd_handle) {
+					dapl_os_atomic_dec(&
+							   ((DAPL_EVD *) param->
+							    request_evd_handle)->
+							   evd_ref_count);
+				}
+				if (param->connect_evd_handle != NULL) {
+					dapl_os_atomic_dec(&
+							   ((DAPL_EVD *) param->
+							    connect_evd_handle)->
+							   evd_ref_count);
+				}
 
-	    while ( !dapl_llist_is_empty (&ia_ptr->lmr_list_head) )
-	    {
-		lmr_ptr = (DAPL_LMR *)
-		    dapl_llist_peek_head ( &ia_ptr->lmr_list_head );
+				/* ...and free the resource */
+				dapl_ia_unlink_ep(ia_ptr, ep_ptr);
+				dapl_ep_dealloc(ep_ptr);
+			}
 
-                (void) dapls_hash_remove ( lmr_ptr->header.owner_ia->hca_ptr->lmr_hash_table, 
-                                           lmr_ptr->param.lmr_context, 
-                                           NULL );
-                
-		pz_ptr = (DAPL_PZ *) lmr_ptr->param.pz_handle;
-		dapl_os_atomic_dec ( &pz_ptr->pz_ref_count );
-		dapl_ia_unlink_lmr ( lmr_ptr->header.owner_ia, lmr_ptr );
-		dapl_lmr_dealloc ( lmr_ptr );
-	    }
+			while (!dapl_llist_is_empty(&ia_ptr->lmr_list_head)) {
+				lmr_ptr = (DAPL_LMR *)
+				    dapl_llist_peek_head(&ia_ptr->
+							 lmr_list_head);
 
-	    while ( !dapl_llist_is_empty ( &ia_ptr->psp_list_head ) )
-	    {
-		sp_ptr = (DAPL_SP *)
-		    dapl_llist_peek_head ( &ia_ptr->psp_list_head );
-		while ( !dapl_llist_is_empty (&sp_ptr->cr_list_head) )
-		{
-		    cr_ptr = (DAPL_CR *)
-			dapl_llist_peek_head ( &sp_ptr->cr_list_head );
-		    dapl_sp_remove_cr (sp_ptr, cr_ptr);
-		    dapls_cr_free (cr_ptr);
-		}
+				(void)dapls_hash_remove(lmr_ptr->header.
+							owner_ia->hca_ptr->
+							lmr_hash_table,
+							lmr_ptr->param.
+							lmr_context, NULL);
 
-		dapls_ia_unlink_sp ( ia_ptr, sp_ptr );
-		dapl_os_atomic_dec (& ((DAPL_EVD *)sp_ptr->evd_handle)->evd_ref_count);
-		dapls_sp_free_sp ( sp_ptr );
-	    }
+				pz_ptr = (DAPL_PZ *) lmr_ptr->param.pz_handle;
+				dapl_os_atomic_dec(&pz_ptr->pz_ref_count);
+				dapl_ia_unlink_lmr(lmr_ptr->header.owner_ia,
+						   lmr_ptr);
+				dapl_lmr_dealloc(lmr_ptr);
+			}
 
-	    while (!dapl_llist_is_empty ( &ia_ptr->pz_list_head ) )
-	    {
-		pz_ptr = (DAPL_PZ *)
-		    dapl_llist_peek_head ( &ia_ptr->pz_list_head );
-		dapl_ia_unlink_pz (pz_ptr->header.owner_ia, pz_ptr);
-		dapl_pz_dealloc ( pz_ptr );
-	    }
+			while (!dapl_llist_is_empty(&ia_ptr->psp_list_head)) {
+				sp_ptr = (DAPL_SP *)
+				    dapl_llist_peek_head(&ia_ptr->
+							 psp_list_head);
+				while (!dapl_llist_is_empty
+				       (&sp_ptr->cr_list_head)) {
+					cr_ptr = (DAPL_CR *)
+					    dapl_llist_peek_head(&sp_ptr->
+								 cr_list_head);
+					dapl_sp_remove_cr(sp_ptr, cr_ptr);
+					dapls_cr_free(cr_ptr);
+				}
 
-	    while (!dapl_llist_is_empty (&ia_ptr->evd_list_head))
-	    {
-		evd_ptr = (DAPL_EVD *)
-		    dapl_llist_peek_head ( &ia_ptr->evd_list_head );
-		dapl_ia_unlink_evd ( evd_ptr->header.owner_ia, evd_ptr );
-		/* reset the cq_handle to avoid having it removed */
-		evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
-		dapls_evd_dealloc ( evd_ptr );
-	    }
+				dapls_ia_unlink_sp(ia_ptr, sp_ptr);
+				dapl_os_atomic_dec(&
+						   ((DAPL_EVD *) sp_ptr->
+						    evd_handle)->evd_ref_count);
+				dapls_sp_free_sp(sp_ptr);
+			}
 
-	    dapl_hca_unlink_ia ( ia_ptr->hca_ptr, ia_ptr );
-	    /* asycn error evd was taken care of above, reset the pointer */
-	    ia_ptr->async_error_evd = NULL;
-	    dapls_ia_free ( ia_ptr );
-	}	/* end while ( ia_ptr != NULL ) */
+			while (!dapl_llist_is_empty(&ia_ptr->pz_list_head)) {
+				pz_ptr = (DAPL_PZ *)
+				    dapl_llist_peek_head(&ia_ptr->pz_list_head);
+				dapl_ia_unlink_pz(pz_ptr->header.owner_ia,
+						  pz_ptr);
+				dapl_pz_dealloc(pz_ptr);
+			}
 
+			while (!dapl_llist_is_empty(&ia_ptr->evd_list_head)) {
+				evd_ptr = (DAPL_EVD *)
+				    dapl_llist_peek_head(&ia_ptr->
+							 evd_list_head);
+				dapl_ia_unlink_evd(evd_ptr->header.owner_ia,
+						   evd_ptr);
+				/* reset the cq_handle to avoid having it removed */
+				evd_ptr->ib_cq_handle = IB_INVALID_HANDLE;
+				dapls_evd_dealloc(evd_ptr);
+			}
 
-	dapl_os_free (cur_node, sizeof (DAPL_PROVIDER_LIST_NODE));
-    } /* end while (NULL != g_dapl_provider_list.head) */
+			dapl_hca_unlink_ia(ia_ptr->hca_ptr, ia_ptr);
+			/* asycn error evd was taken care of above, reset the pointer */
+			ia_ptr->async_error_evd = NULL;
+			dapls_ia_free(ia_ptr);
+		}		/* end while ( ia_ptr != NULL ) */
+
+		dapl_os_free(cur_node, sizeof(DAPL_PROVIDER_LIST_NODE));
+	}			/* end while (NULL != g_dapl_provider_list.head) */
 }
 
-
 /*
  * Structure to contain all elements of a thread in order to enable a
  * local routine to intercept and do some necessary initialization.
  */
-struct thread_draft
-{
-    void		(*func) (void *);		/* start routine */
-    void 		*data;		/* argument to start routine */
+struct thread_draft {
+	void (*func) (void *);	/* start routine */
+	void *data;		/* argument to start routine */
 };
 
-void dapli_thread_init (	struct thread_draft	*thread_draft);
+void dapli_thread_init(struct thread_draft *thread_draft);
 
 /*
  * dapls_os_thread_create
@@ -546,56 +518,51 @@
  * Returns:
  *	DAT_SUCCESS
  */
-DAT_RETURN 
-dapl_os_thread_create (
-	IN  void			(*func) (void *),
-	IN  void 			*data,
-	OUT DAPL_OS_THREAD		*thread_id )
+DAT_RETURN
+dapl_os_thread_create(IN void (*func) (void *),
+		      IN void *data, OUT DAPL_OS_THREAD * thread_id)
 {
-    pthread_attr_t 		thread_attr;
-    struct thread_draft		*thread_draft;
-    int 			status;
+	pthread_attr_t thread_attr;
+	struct thread_draft *thread_draft;
+	int status;
 
-    /*
-     * Get default set of thread attributes
-     */
-    status = pthread_attr_init ( &thread_attr );
-    if ( status != 0 )
-    {
-	return DAT_ERROR (DAT_INTERNAL_ERROR,0);
-    }
+	/*
+	 * Get default set of thread attributes
+	 */
+	status = pthread_attr_init(&thread_attr);
+	if (status != 0) {
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
 
-    /* Create dapl threads as detached from this process */
-    status = pthread_attr_setdetachstate ( &thread_attr, 
-					   PTHREAD_CREATE_DETACHED );
-    if ( status != 0 )
-    {
-	return DAT_ERROR (DAT_INTERNAL_ERROR,0);
-    }
+	/* Create dapl threads as detached from this process */
+	status = pthread_attr_setdetachstate(&thread_attr,
+					     PTHREAD_CREATE_DETACHED);
+	if (status != 0) {
+		return DAT_ERROR(DAT_INTERNAL_ERROR, 0);
+	}
 
-    thread_draft = dapl_os_alloc (sizeof ( struct thread_draft));
+	thread_draft = dapl_os_alloc(sizeof(struct thread_draft));
 
-    thread_draft->func = func;
-    thread_draft->data = data;
+	thread_draft->func = func;
+	thread_draft->data = data;
 
-    /* Create the thread. Observe that we first invoke a local
-     * routine to set up OS parameters, before invoking the user
-     * specified routine.
-     */
-    status = pthread_create ( thread_id,
-			      &thread_attr, 
-			      (void * (*) (void *))dapli_thread_init,
-			      (void *)thread_draft );
+	/* Create the thread. Observe that we first invoke a local
+	 * routine to set up OS parameters, before invoking the user
+	 * specified routine.
+	 */
+	status = pthread_create(thread_id,
+				&thread_attr,
+				(void *(*)(void *))dapli_thread_init,
+				(void *)thread_draft);
 
-    /* clean up resources */
-    (void) pthread_attr_destroy ( &thread_attr );
+	/* clean up resources */
+	(void)pthread_attr_destroy(&thread_attr);
 
-    if ( status != 0 )
-    {
-	return DAT_ERROR (DAT_INSUFFICIENT_RESOURCES,0);
-    }
+	if (status != 0) {
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 0);
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
 /*
@@ -607,25 +574,22 @@
  * this should be a user thread, not a dapl thread
  */
 
-void
-dapli_thread_init (
-	struct thread_draft		*thread_draft)
+void dapli_thread_init(struct thread_draft *thread_draft)
 {
-    sigset_t		sigset;
-    void		(*func) (void *);
-    void 		*data;
+	sigset_t sigset;
+	void (*func) (void *);
+	void *data;
 
-    sigfillset (&sigset);
-    pthread_sigmask ( SIG_BLOCK, &sigset, NULL);
+	sigfillset(&sigset);
+	pthread_sigmask(SIG_BLOCK, &sigset, NULL);
 
-    func = thread_draft->func;
-    data = thread_draft->data;
-    dapl_os_free (thread_draft, sizeof ( struct thread_draft ));
+	func = thread_draft->func;
+	data = thread_draft->data;
+	dapl_os_free(thread_draft, sizeof(struct thread_draft));
 
-    (*func) (data);
+	(*func) (data);
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl/udapl/linux/dapl_osd.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,21 +67,40 @@
 #include <sys/time.h>
 #include <syslog.h>
 #include <netdb.h>			/* for getaddrinfo */
+#include <byteswap.h>
 
+#include <sys/ioctl.h>  /* for IOCTL's */
+
 #include "dapl_debug.h"
 
 /*
  * Include files for setting up a network name
  */
+#include <sys/socket.h> /* for socket(2) */
+#include <net/if.h>     /* for struct ifreq */
+#include <net/if_arp.h> /* for ARPHRD_ETHER */
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #include <ctype.h>
 
-#if !defined(REDHAT_EL5) && (defined(__ia64__))
+#include <sys/poll.h>
+#include <signal.h>
+#include <netinet/tcp.h>
+#include <sys/utsname.h>
+#include <fcntl.h>
+
+#if !defined(SUSE_11) && !defined(REDHAT_EL5) && defined(__ia64__)
 #include <asm/atomic.h>
 #endif
 
+#if defined(SUSE_11) && defined(__ia64__)
+#include <asm/types.h>
+#include <asm/intrinsics.h>
+#endif
+
 /* Useful debug definitions */
 #ifndef STATIC
 #define STATIC static
@@ -288,7 +307,16 @@
 	IN  void			*data,
 	OUT DAPL_OS_THREAD		*thread_id );
 
+STATIC _INLINE_ void
+dapl_os_sleep_usec(int usec)
+{
+	struct timespec sleep, remain;
 
+	sleep.tv_sec = 0;
+	sleep.tv_nsec = usec * 1000;
+	nanosleep(&sleep, &remain);
+}
+
 /*
  * Lock Functions
  */
@@ -516,10 +544,11 @@
  * ability to define 64 bit formats, which unfortunatly are non standard
  * in the C compiler world. E.g. %llx for gcc, %I64x for Windows
  */
-#define F64d   "%lld"
-#define F64u   "%llu"
-#define F64x   "%llx"
-#define F64X   "%llX"
+#include <inttypes.h>
+#define F64d   "%"PRId64
+#define F64u   "%"PRIu64
+#define F64x   "%"PRIx64
+#define F64X   "%"PRIX64
 
 
 /*
@@ -543,6 +572,7 @@
 #define dapl_os_vprintf(fmt,args)	vprintf(fmt,args)
 #define dapl_os_syslog(fmt,args)	vsyslog(LOG_USER|LOG_WARNING,fmt,args)
 
+#define dapl_os_getpid getpid
 
 
 #endif /*  _DAPL_OSD_H_ */

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec	2009-05-28 20:23:18 UTC (rev 260)
@@ -32,7 +32,7 @@
 #
 # $Id: $
 Name: dapl
-Version: 2.0.15
+Version: 2.0.19
 Release: 1%{?dist}
 Summary: A Library for userspace access to RDMA devices using OS Agnostic DAT APIs.
 
@@ -43,6 +43,8 @@
 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
+Requires(post): sed
+Requires(post): coreutils
 
 %description
 Along with the OpenFabrics kernel drivers, libdat and libdapl provides a userspace
@@ -134,6 +136,18 @@
 %{_mandir}/man5/*.5*
 
 %changelog
+* Thu Apr 30 2009 Arlin Davis <ardavis at 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 at ichips.intel.com> - 2.0.18
+- DAT/DAPL Version 2.0.18 Release 1, OFED 1.4.1 GA 
+
+* Tue Mar 31 2009 Arlin Davis <ardavis at ichips.intel.com> - 2.0.17
+- DAT/DAPL Version 2.0.17 Release 1, OFED 1.4.1 GA
+
+* Mon Mar 16 2009 Arlin Davis <ardavis at ichips.intel.com> - 2.0.16
+- DAT/DAPL Version 2.0.16 Release 1, OFED 1.4.1 
+
 * Fri Nov 07 2008 Arlin Davis <ardavis at ichips.intel.com> - 2.0.15
 - DAT/DAPL Version 2.0.15 Release 1, OFED 1.4 GA
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec.in
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec.in	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dapl.spec.in	2009-05-28 20:23:18 UTC (rev 260)
@@ -43,6 +43,8 @@
 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
+Requires(post): sed
+Requires(post): coreutils
 
 %description
 Along with the OpenFabrics kernel drivers, libdat and libdapl provides a userspace
@@ -134,6 +136,18 @@
 %{_mandir}/man5/*.5*
 
 %changelog
+* Thu Apr 30 2009 Arlin Davis <ardavis at 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 at ichips.intel.com> - 2.0.18
+- DAT/DAPL Version 2.0.18 Release 1, OFED 1.4.1 GA 
+
+* Tue Mar 31 2009 Arlin Davis <ardavis at ichips.intel.com> - 2.0.17
+- DAT/DAPL Version 2.0.17 Release 1, OFED 1.4.1 GA
+
+* Mon Mar 16 2009 Arlin Davis <ardavis at ichips.intel.com> - 2.0.16
+- DAT/DAPL Version 2.0.16 Release 1, OFED 1.4.1 
+
 * Fri Nov 07 2008 Arlin Davis <ardavis at ichips.intel.com> - 2.0.15
 - DAT/DAPL Version 2.0.15 Release 1, OFED 1.4 GA
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_api.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_api.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_api.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -55,11 +55,10 @@
 /*
  * structure to deal with IA handles
  */
-typedef struct 
-{
-    DAT_OS_LOCK     handle_lock;
-    unsigned long   handle_max;
-    void            **handle_array;
+typedef struct {
+	DAT_OS_LOCK handle_lock;
+	unsigned long handle_max;
+	void **handle_array;
 } DAT_HANDLE_VEC;
 
 /*
@@ -69,108 +68,103 @@
 
 static DAT_HANDLE_VEC g_hv;
 
-
 /***********************************************************************
  * Function: dats_handle_init
  *
  * Initialize a handle_vector. Happens when the module initializes
  ***********************************************************************/
-DAT_RETURN
-dats_handle_vector_init ( void )
+DAT_RETURN dats_handle_vector_init(void)
 {
-    DAT_RETURN		dat_status;
-    unsigned long	i;
+	DAT_RETURN dat_status;
+	unsigned long i;
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    g_hv.handle_max   = DAT_HANDLE_ENTRY_STEP;
+	g_hv.handle_max = DAT_HANDLE_ENTRY_STEP;
 
-    dat_status = dat_os_lock_init (&g_hv.handle_lock);
-    if ( DAT_SUCCESS != dat_status )
-    {
-	return dat_status;
-    }
+	dat_status = dat_os_lock_init(&g_hv.handle_lock);
+	if (DAT_SUCCESS != dat_status) {
+		return dat_status;
+	}
 
-    g_hv.handle_array = dat_os_alloc (sizeof(void *) * DAT_HANDLE_ENTRY_STEP);
-    if (g_hv.handle_array == NULL)
-    {
-	dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	g_hv.handle_array =
+	    dat_os_alloc(sizeof(void *) * DAT_HANDLE_ENTRY_STEP);
+	if (g_hv.handle_array == NULL) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    for (i = 0; i < g_hv.handle_max; i++)
-    {
-	g_hv.handle_array[i] = NULL;
-    }
+	for (i = 0; i < g_hv.handle_max; i++) {
+		g_hv.handle_array[i] = NULL;
+	}
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 /***********************************************************************
  * Function: dats_set_ia_handle
  *
  * Install an ia_handle into a handle vector and return a small
  * integer.
  ***********************************************************************/
-DAT_IA_HANDLE
-dats_set_ia_handle (
-	IN  DAT_IA_HANDLE		ia_handle )
-{   
-    unsigned long	i;
-    void		**h;
+DAT_IA_HANDLE dats_set_ia_handle(IN DAT_IA_HANDLE ia_handle)
+{
+	unsigned long i;
+	void **h;
 
-    dat_os_lock (&g_hv.handle_lock);
+	dat_os_lock(&g_hv.handle_lock);
 
-    /*
-     * Don't give out handle zero since that is DAT_HANDLE_NULL!
-     */
-    for (i = 1; i < g_hv.handle_max; i++)
-    {
-	if (g_hv.handle_array[i] == NULL)
-	{
-	    g_hv.handle_array[i] = ia_handle;
+	/*
+	 * Don't give out handle zero since that is DAT_HANDLE_NULL!
+	 */
+	for (i = 1; i < g_hv.handle_max; i++) {
+		if (g_hv.handle_array[i] == NULL) {
+			g_hv.handle_array[i] = ia_handle;
 
-	    dat_os_unlock (&g_hv.handle_lock);
-            
-	    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-			      "dat_set_handle %p to %d\n", ia_handle, i);
-	    return DAT_UL_TO_IA_HANDLE(i);
+			dat_os_unlock(&g_hv.handle_lock);
+
+			dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+					 "dat_set_handle %p to %d\n", ia_handle,
+					 i);
+			return DAT_UL_TO_IA_HANDLE(i);
+		}
 	}
-    }
 
-    /* Didn't find an entry, grow the list & try again */
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-		      "Growing the handle array from %d to %d\n",
-		      g_hv.handle_max, g_hv.handle_max + DAT_HANDLE_ENTRY_STEP);
-		      
-    /* reallocate the handle array */
-    h = dat_os_alloc (sizeof(void *) * (g_hv.handle_max + DAT_HANDLE_ENTRY_STEP));
-    if (h == NULL)
-    {
-	dat_os_unlock (&g_hv.handle_lock);
-	return DAT_UL_TO_IA_HANDLE(-1);
-    }
-    /* copy old data to new area & free old memory*/
-    memcpy((void *)h, (void *)g_hv.handle_array, sizeof(void *) * g_hv.handle_max);
-    dat_os_free (g_hv.handle_array, sizeof(void *) * g_hv.handle_max);
-    g_hv.handle_array = h;
+	/* Didn't find an entry, grow the list & try again */
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+			 "Growing the handle array from %d to %d\n",
+			 g_hv.handle_max,
+			 g_hv.handle_max + DAT_HANDLE_ENTRY_STEP);
 
-    /* Initialize the new entries */
-    for (i = g_hv.handle_max; i < g_hv.handle_max + DAT_HANDLE_ENTRY_STEP; i++)
-    {
-	g_hv.handle_array[i] = NULL;
-    }
-    i = g_hv.handle_max;
-    g_hv.handle_array[i] = ia_handle;
-    g_hv.handle_max      += DAT_HANDLE_ENTRY_STEP;
-    dat_os_unlock (&g_hv.handle_lock);
+	/* reallocate the handle array */
+	h = dat_os_alloc(sizeof(void *) *
+			 (g_hv.handle_max + DAT_HANDLE_ENTRY_STEP));
+	if (h == NULL) {
+		dat_os_unlock(&g_hv.handle_lock);
+		return DAT_UL_TO_IA_HANDLE(-1);
+	}
+	/* copy old data to new area & free old memory */
+	memcpy((void *)h, (void *)g_hv.handle_array,
+	       sizeof(void *) * g_hv.handle_max);
+	dat_os_free(g_hv.handle_array, sizeof(void *) * g_hv.handle_max);
+	g_hv.handle_array = h;
 
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-		      "dat_set_handle x %p to %d\n", ia_handle, i);
+	/* Initialize the new entries */
+	for (i = g_hv.handle_max; i < g_hv.handle_max + DAT_HANDLE_ENTRY_STEP;
+	     i++) {
+		g_hv.handle_array[i] = NULL;
+	}
+	i = g_hv.handle_max;
+	g_hv.handle_array[i] = ia_handle;
+	g_hv.handle_max += DAT_HANDLE_ENTRY_STEP;
+	dat_os_unlock(&g_hv.handle_lock);
 
-    return DAT_UL_TO_IA_HANDLE(i);
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+			 "dat_set_handle x %p to %d\n", ia_handle, i);
+
+	return DAT_UL_TO_IA_HANDLE(i);
 }
 
 /***********************************************************************
@@ -179,35 +173,32 @@
  * Get a handle from a handle vector and return it in an OUT parameter
  ***********************************************************************/
 DAT_RETURN
-dats_get_ia_handle(
-	IN  DAT_IA_HANDLE 		handle,
-	OUT DAT_IA_HANDLE		*ia_handle_p )
+dats_get_ia_handle(IN DAT_IA_HANDLE handle, OUT DAT_IA_HANDLE * ia_handle_p)
 {
-    DAT_RETURN		dat_status;
+	DAT_RETURN dat_status;
 
-    if (DAT_IA_HANDLE_TO_UL(handle) >= g_hv.handle_max)
-    {
-	dat_status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
-    *ia_handle_p = g_hv.handle_array[DAT_IA_HANDLE_TO_UL(handle)];
+	if (DAT_IA_HANDLE_TO_UL(handle) >= g_hv.handle_max) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
+	*ia_handle_p = g_hv.handle_array[DAT_IA_HANDLE_TO_UL(handle)];
 
-    if (*ia_handle_p == NULL)
-    {
-	dat_status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
-    dat_status = DAT_SUCCESS;
+	if (*ia_handle_p == NULL) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
+	dat_status = DAT_SUCCESS;
 
- bail:
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-		      "dat_get_ia_handle from %d to %p\n", 
-		      handle, *ia_handle_p);
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+			 "dat_get_ia_handle from %d to %p\n",
+			 handle, *ia_handle_p);
 
-    return dat_status;
+	return dat_status;
 }
 
-
 /***********************************************************************
  * Function: dats_is_ia_handle
  *
@@ -222,1077 +213,861 @@
  * be preferable.
  *
  ***********************************************************************/
-DAT_RETURN
-dats_is_ia_handle (
-	IN  DAT_HANDLE			dat_handle)
+DAT_RETURN dats_is_ia_handle(IN DAT_HANDLE dat_handle)
 {
-    unsigned long handle = DAT_IA_HANDLE_TO_UL((DAT_IA_HANDLE)dat_handle);
+	unsigned long handle = DAT_IA_HANDLE_TO_UL((DAT_IA_HANDLE) dat_handle);
 
-    if (g_hv.handle_max <= handle )
-    {
-	return DAT_FALSE;
-    }
-    else if ( NULL == g_hv.handle_array[handle] )
-    {
-        return DAT_FALSE;
-    }
-    else
-    {
-        return DAT_TRUE;
-    }
+	if (g_hv.handle_max <= handle) {
+		return DAT_FALSE;
+	} else if (NULL == g_hv.handle_array[handle]) {
+		return DAT_FALSE;
+	} else {
+		return DAT_TRUE;
+	}
 }
 
-
 /***********************************************************************
  * Function: dats_free_ia_handle
  *
  * Free a handle in a handle vector
  ***********************************************************************/
-DAT_RETURN
-dats_free_ia_handle (
-	IN  DAT_IA_HANDLE		handle)
+DAT_RETURN dats_free_ia_handle(IN DAT_IA_HANDLE handle)
 {
-    DAT_RETURN		dat_status;
+	DAT_RETURN dat_status;
 
-    if (DAT_IA_HANDLE_TO_UL(handle) >= g_hv.handle_max)
-    {
-	dat_status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-	goto bail;
-    }
-    g_hv.handle_array[DAT_IA_HANDLE_TO_UL(handle)] = NULL;
-    dat_status = DAT_SUCCESS;
+	if (DAT_IA_HANDLE_TO_UL(handle) >= g_hv.handle_max) {
+		dat_status =
+		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+		goto bail;
+	}
+	g_hv.handle_array[DAT_IA_HANDLE_TO_UL(handle)] = NULL;
+	dat_status = DAT_SUCCESS;
 
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-		      "dats_free_ia_handle %d\n", handle);
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+			 "dats_free_ia_handle %d\n", handle);
 
- bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
 /**********************************************************************
  * API definitions for common API entry points
  **********************************************************************/
-DAT_RETURN DAT_API dat_ia_query (
-	IN      DAT_IA_HANDLE		ia_handle,
-	OUT     DAT_EVD_HANDLE		*async_evd_handle,
-	IN      DAT_IA_ATTR_MASK	ia_attr_mask,
-	OUT     DAT_IA_ATTR		*ia_attr,
-	IN      DAT_PROVIDER_ATTR_MASK	provider_attr_mask,
-	OUT     DAT_PROVIDER_ATTR 	*provider_attr)
+DAT_RETURN DAT_API dat_ia_query(IN DAT_IA_HANDLE ia_handle,
+				OUT DAT_EVD_HANDLE * async_evd_handle,
+				IN DAT_IA_ATTR_MASK ia_attr_mask,
+				OUT DAT_IA_ATTR * ia_attr,
+				IN DAT_PROVIDER_ATTR_MASK provider_attr_mask,
+				OUT DAT_PROVIDER_ATTR * provider_attr)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_IA_QUERY (dapl_ia_handle,
-				   async_evd_handle,
-				   ia_attr_mask,
-				   ia_attr,
-				   provider_attr_mask,
-				   provider_attr);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_IA_QUERY(dapl_ia_handle,
+					  async_evd_handle,
+					  ia_attr_mask,
+					  ia_attr,
+					  provider_attr_mask, provider_attr);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_set_consumer_context (
-	IN      DAT_HANDLE		dat_handle,
-	IN      DAT_CONTEXT		context)
+DAT_RETURN DAT_API dat_set_consumer_context(IN DAT_HANDLE dat_handle,
+					    IN DAT_CONTEXT context)
 {
-    if ( dats_is_ia_handle (dat_handle) )
-    {
-        DAT_IA_HANDLE   dapl_ia_handle;
-        DAT_RETURN      dat_status;
+	if (dats_is_ia_handle(dat_handle)) {
+		DAT_IA_HANDLE dapl_ia_handle;
+		DAT_RETURN dat_status;
 
-        dat_status = dats_get_ia_handle((DAT_IA_HANDLE)dat_handle,
-					&dapl_ia_handle);
-        
-        /* failure to map the handle is unlikely but possible */
-        /* in a mult-threaded environment                     */
-        if ( DAT_SUCCESS == dat_status )
-        {
-            return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1);
-        }
-        
-        dat_handle = dapl_ia_handle;
-    }
+		dat_status = dats_get_ia_handle((DAT_IA_HANDLE) dat_handle,
+						&dapl_ia_handle);
 
-    return DAT_SET_CONSUMER_CONTEXT (dat_handle,
-				     context);
-}
+		/* failure to map the handle is unlikely but possible */
+		/* in a mult-threaded environment                     */
+		if (DAT_SUCCESS == dat_status) {
+			return DAT_ERROR(DAT_INVALID_HANDLE,
+					 DAT_INVALID_HANDLE1);
+		}
 
+		dat_handle = dapl_ia_handle;
+	}
 
-DAT_RETURN DAT_API dat_get_consumer_context (
-	IN      DAT_HANDLE		dat_handle,
-	OUT     DAT_CONTEXT		*context)
+	return DAT_SET_CONSUMER_CONTEXT(dat_handle, context);
+}
+
+DAT_RETURN DAT_API dat_get_consumer_context(IN DAT_HANDLE dat_handle,
+					    OUT DAT_CONTEXT * context)
 {
-    if ( dats_is_ia_handle (dat_handle) )
-    {
-        DAT_IA_HANDLE   dapl_ia_handle;
-        DAT_RETURN      dat_status;
+	if (dats_is_ia_handle(dat_handle)) {
+		DAT_IA_HANDLE dapl_ia_handle;
+		DAT_RETURN dat_status;
 
-        dat_status = dats_get_ia_handle((DAT_IA_HANDLE)dat_handle,
-                                        &dapl_ia_handle);
+		dat_status = dats_get_ia_handle((DAT_IA_HANDLE) dat_handle,
+						&dapl_ia_handle);
 
-        /* failure to map the handle is unlikely but possible */
-        /* in a mult-threaded environment                     */
-        if ( DAT_SUCCESS == dat_status )
-        {
-            return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1);
-        }
+		/* failure to map the handle is unlikely but possible */
+		/* in a mult-threaded environment                     */
+		if (DAT_SUCCESS == dat_status) {
+			return DAT_ERROR(DAT_INVALID_HANDLE,
+					 DAT_INVALID_HANDLE1);
+		}
 
-        dat_handle = dapl_ia_handle;
-    }
-    
-    return DAT_GET_CONSUMER_CONTEXT (dat_handle,
-                                     context);
+		dat_handle = dapl_ia_handle;
+	}
+
+	return DAT_GET_CONSUMER_CONTEXT(dat_handle, context);
 }
 
-
-DAT_RETURN DAT_API dat_get_handle_type (
-	IN      DAT_HANDLE		dat_handle,
-	OUT     DAT_HANDLE_TYPE		*type)
+DAT_RETURN DAT_API dat_get_handle_type(IN DAT_HANDLE dat_handle,
+				       OUT DAT_HANDLE_TYPE * type)
 {
-    if ( dats_is_ia_handle (dat_handle) )
-    {
-        DAT_IA_HANDLE   dapl_ia_handle;
-        DAT_RETURN      dat_status;
+	if (dats_is_ia_handle(dat_handle)) {
+		DAT_IA_HANDLE dapl_ia_handle;
+		DAT_RETURN dat_status;
 
-        dat_status = dats_get_ia_handle((DAT_IA_HANDLE)dat_handle,
-                                        &dapl_ia_handle);
+		dat_status = dats_get_ia_handle((DAT_IA_HANDLE) dat_handle,
+						&dapl_ia_handle);
 
-        /* failure to map the handle is unlikely but possible */
-        /* in a mult-threaded environment                     */
-        if ( DAT_SUCCESS == dat_status )
-        {
-            return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1);
-        }
+		/* failure to map the handle is unlikely but possible */
+		/* in a mult-threaded environment                     */
+		if (DAT_SUCCESS == dat_status) {
+			return DAT_ERROR(DAT_INVALID_HANDLE,
+					 DAT_INVALID_HANDLE1);
+		}
 
-        dat_handle = dapl_ia_handle;
-    }
+		dat_handle = dapl_ia_handle;
+	}
 
-    return DAT_GET_HANDLE_TYPE (dat_handle, type);
+	return DAT_GET_HANDLE_TYPE(dat_handle, type);
 }
 
-
-DAT_RETURN DAT_API dat_cr_query (
-	IN      DAT_CR_HANDLE		cr_handle,
-	IN      DAT_CR_PARAM_MASK	cr_param_mask,
-	OUT     DAT_CR_PARAM		*cr_param)
+DAT_RETURN DAT_API dat_cr_query(IN DAT_CR_HANDLE cr_handle,
+				IN DAT_CR_PARAM_MASK cr_param_mask,
+				OUT DAT_CR_PARAM * cr_param)
 {
-    if (cr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
-    }
-    return DAT_CR_QUERY (cr_handle,
-			 cr_param_mask,
-			 cr_param);
+	if (cr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+	}
+	return DAT_CR_QUERY(cr_handle, cr_param_mask, cr_param);
 }
 
-
-DAT_RETURN DAT_API dat_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)
+DAT_RETURN DAT_API dat_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)
 {
-    if (cr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
-    }
-    return DAT_CR_ACCEPT (cr_handle,
-			  ep_handle,
-			  private_data_size,
-			  private_data);
+	if (cr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+	}
+	return DAT_CR_ACCEPT(cr_handle,
+			     ep_handle, private_data_size, private_data);
 }
 
-
-DAT_RETURN DAT_API dat_cr_reject (
-	IN      DAT_CR_HANDLE 		cr_handle,
-	IN	DAT_COUNT		private_data_size,
-	IN const DAT_PVOID		private_data)
+DAT_RETURN DAT_API dat_cr_reject(IN DAT_CR_HANDLE cr_handle,
+				 IN DAT_COUNT private_data_size,
+				 IN const DAT_PVOID private_data)
 {
-    if (cr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
-    }
-    return DAT_CR_REJECT (cr_handle, private_data_size, private_data);
+	if (cr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+	}
+	return DAT_CR_REJECT(cr_handle, private_data_size, private_data);
 }
 
-
-DAT_RETURN DAT_API dat_evd_resize (
-	IN      DAT_EVD_HANDLE		evd_handle,
-	IN      DAT_COUNT		evd_min_qlen)
+DAT_RETURN DAT_API dat_evd_resize(IN DAT_EVD_HANDLE evd_handle,
+				  IN DAT_COUNT evd_min_qlen)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_RESIZE (evd_handle,
-			   evd_min_qlen);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_RESIZE(evd_handle, evd_min_qlen);
 }
 
-
-DAT_RETURN DAT_API dat_evd_post_se (
-	IN      DAT_EVD_HANDLE	       evd_handle,
-	IN      const DAT_EVENT		*event)
+DAT_RETURN DAT_API dat_evd_post_se(IN DAT_EVD_HANDLE evd_handle,
+				   IN const DAT_EVENT * event)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_POST_SE (evd_handle,
-			    event);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_POST_SE(evd_handle, event);
 }
 
-
-DAT_RETURN DAT_API dat_evd_dequeue (
-	IN      DAT_EVD_HANDLE		evd_handle,
-	OUT     DAT_EVENT		*event)
+DAT_RETURN DAT_API dat_evd_dequeue(IN DAT_EVD_HANDLE evd_handle,
+				   OUT DAT_EVENT * event)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_DEQUEUE (evd_handle,
-			    event);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_DEQUEUE(evd_handle, event);
 }
 
-
-DAT_RETURN DAT_API dat_evd_free (
-	IN      DAT_EVD_HANDLE 		evd_handle)
+DAT_RETURN DAT_API dat_evd_free(IN DAT_EVD_HANDLE evd_handle)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_FREE (evd_handle);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_FREE(evd_handle);
 }
 
-DAT_RETURN DAT_API dat_evd_query (
-	IN      DAT_EVD_HANDLE		evd_handle,
-	IN      DAT_EVD_PARAM_MASK	evd_param_mask,
-	OUT     DAT_EVD_PARAM		*evd_param)
+DAT_RETURN DAT_API dat_evd_query(IN DAT_EVD_HANDLE evd_handle,
+				 IN DAT_EVD_PARAM_MASK evd_param_mask,
+				 OUT DAT_EVD_PARAM * evd_param)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_QUERY (evd_handle,
-			  evd_param_mask,
-			  evd_param);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_QUERY(evd_handle, evd_param_mask, evd_param);
 }
 
-
-DAT_RETURN DAT_API dat_ep_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	IN      DAT_PZ_HANDLE		pz_handle,
-	IN      DAT_EVD_HANDLE		recv_completion_evd_handle,
-	IN      DAT_EVD_HANDLE		request_completion_evd_handle,
-	IN      DAT_EVD_HANDLE		connect_evd_handle,
-	IN      const DAT_EP_ATTR 	*ep_attributes,
-	OUT     DAT_EP_HANDLE		*ep_handle)
+DAT_RETURN DAT_API dat_ep_create(IN DAT_IA_HANDLE ia_handle,
+				 IN DAT_PZ_HANDLE pz_handle,
+				 IN DAT_EVD_HANDLE recv_completion_evd_handle,
+				 IN DAT_EVD_HANDLE
+				 request_completion_evd_handle,
+				 IN DAT_EVD_HANDLE connect_evd_handle,
+				 IN const DAT_EP_ATTR * ep_attributes,
+				 OUT DAT_EP_HANDLE * ep_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status =  DAT_EP_CREATE (dapl_ia_handle,
-				     pz_handle,
-				     recv_completion_evd_handle,
-				     request_completion_evd_handle,
-				     connect_evd_handle,
-				     ep_attributes,
-				     ep_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_EP_CREATE(dapl_ia_handle,
+					   pz_handle,
+					   recv_completion_evd_handle,
+					   request_completion_evd_handle,
+					   connect_evd_handle,
+					   ep_attributes, ep_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_ep_query (
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      DAT_EP_PARAM_MASK	ep_param_mask,
-	OUT     DAT_EP_PARAM		*ep_param)
+DAT_RETURN DAT_API dat_ep_query(IN DAT_EP_HANDLE ep_handle,
+				IN DAT_EP_PARAM_MASK ep_param_mask,
+				OUT DAT_EP_PARAM * ep_param)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_QUERY (ep_handle,
-			 ep_param_mask,
-			 ep_param);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_QUERY(ep_handle, ep_param_mask, ep_param);
 }
 
-
-DAT_RETURN DAT_API dat_ep_modify (
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      DAT_EP_PARAM_MASK	ep_param_mask,
-	IN      const DAT_EP_PARAM 	*ep_param)
+DAT_RETURN DAT_API dat_ep_modify(IN DAT_EP_HANDLE ep_handle,
+				 IN DAT_EP_PARAM_MASK ep_param_mask,
+				 IN const DAT_EP_PARAM * ep_param)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_MODIFY (ep_handle,
-			  ep_param_mask,
-			  ep_param);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_MODIFY(ep_handle, ep_param_mask, ep_param);
 }
 
-DAT_RETURN DAT_API dat_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			quality_of_service,
-	IN      DAT_CONNECT_FLAGS	connect_flags)
+DAT_RETURN DAT_API dat_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 quality_of_service,
+				  IN DAT_CONNECT_FLAGS connect_flags)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_CONNECT (ep_handle,
-			   remote_ia_address,
-			   remote_conn_qual,
-			   timeout,
-			   private_data_size,
-			   private_data,
-			   quality_of_service,
-			   connect_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_CONNECT(ep_handle,
+			      remote_ia_address,
+			      remote_conn_qual,
+			      timeout,
+			      private_data_size,
+			      private_data, quality_of_service, connect_flags);
 }
 
-DAT_RETURN DAT_API dat_ep_common_connect (
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      DAT_IA_ADDRESS_PTR	remote_ia_address,
-	IN      DAT_TIMEOUT		timeout,
-	IN      DAT_COUNT		private_data_size,
-	IN      const DAT_PVOID		private_data)
+DAT_RETURN DAT_API dat_ep_common_connect(IN DAT_EP_HANDLE ep_handle,
+					 IN DAT_IA_ADDRESS_PTR
+					 remote_ia_address,
+					 IN DAT_TIMEOUT timeout,
+					 IN DAT_COUNT private_data_size,
+					 IN const DAT_PVOID private_data)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_COMMON_CONNECT (ep_handle,
-			   remote_ia_address,
-			   timeout,
-			   private_data_size,
-			   private_data);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_COMMON_CONNECT(ep_handle,
+				     remote_ia_address,
+				     timeout, private_data_size, private_data);
 }
 
-DAT_RETURN DAT_API dat_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			quality_of_service)
+DAT_RETURN DAT_API dat_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 quality_of_service)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_DUP_CONNECT (ep_handle,
-			       ep_dup_handle,
-			       timeout,
-			       private_data_size,
-			       private_data,
-			       quality_of_service);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_DUP_CONNECT(ep_handle,
+				  ep_dup_handle,
+				  timeout,
+				  private_data_size,
+				  private_data, quality_of_service);
 }
 
-
-DAT_RETURN DAT_API dat_ep_disconnect (
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      DAT_CLOSE_FLAGS		close_flags)
+DAT_RETURN DAT_API dat_ep_disconnect(IN DAT_EP_HANDLE ep_handle,
+				     IN DAT_CLOSE_FLAGS close_flags)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_DISCONNECT (ep_handle,
-			      close_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_DISCONNECT(ep_handle, close_flags);
 }
 
-DAT_RETURN DAT_API dat_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_RETURN DAT_API dat_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)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_POST_SEND (ep_handle,
-			     num_segments,
-			     local_iov,
-			     user_cookie,
-			     completion_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_POST_SEND(ep_handle,
+				num_segments,
+				local_iov, user_cookie, completion_flags);
 }
 
-DAT_RETURN DAT_API dat_ep_post_send_with_invalidate (
-	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,
-	IN	DAT_BOOLEAN		invalidate_flag,
-	IN	DAT_RMR_CONTEXT		rmr_context)
+DAT_RETURN DAT_API dat_ep_post_send_with_invalidate(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,
+						    IN DAT_BOOLEAN
+						    invalidate_flag,
+						    IN DAT_RMR_CONTEXT
+						    rmr_context)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_POST_SEND_WITH_INVALIDATE (ep_handle,
-			     num_segments,
-			     local_iov,
-			     user_cookie,
-			     completion_flags,
-			     invalidate_flag,
-			     rmr_context);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_POST_SEND_WITH_INVALIDATE(ep_handle,
+						num_segments,
+						local_iov,
+						user_cookie,
+						completion_flags,
+						invalidate_flag, rmr_context);
 }
 
-DAT_RETURN DAT_API dat_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)
+DAT_RETURN DAT_API dat_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)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_POST_RECV (ep_handle,
-			     num_segments,
-			     local_iov,
-			     user_cookie,
-			     completion_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_POST_RECV(ep_handle,
+				num_segments,
+				local_iov, user_cookie, completion_flags);
 }
 
-
-DAT_RETURN DAT_API dat_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_API dat_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)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_POST_RDMA_READ (ep_handle,
-				  num_segments,
-				  local_iov,
-				  user_cookie,
-				  remote_iov,
-				  completion_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_POST_RDMA_READ(ep_handle,
+				     num_segments,
+				     local_iov,
+				     user_cookie, remote_iov, completion_flags);
 }
 
-
-DAT_RETURN DAT_API dat_ep_post_rdma_read_to_rmr (
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      const DAT_RMR_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_API dat_ep_post_rdma_read_to_rmr(IN DAT_EP_HANDLE ep_handle,
+						IN const DAT_RMR_TRIPLET *
+						local_iov,
+						IN DAT_DTO_COOKIE user_cookie,
+						IN const DAT_RMR_TRIPLET *
+						remote_iov,
+						IN DAT_COMPLETION_FLAGS
+						completion_flags)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_POST_RDMA_READ_TO_RMR (ep_handle,
-				  local_iov,
-				  user_cookie,
-				  remote_iov,
-				  completion_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_POST_RDMA_READ_TO_RMR(ep_handle,
+					    local_iov,
+					    user_cookie,
+					    remote_iov, completion_flags);
 }
 
-
-DAT_RETURN DAT_API dat_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_API dat_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)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_POST_RDMA_WRITE (ep_handle,
-				   num_segments,
-				   local_iov,
-				   user_cookie,
-				   remote_iov,
-				   completion_flags);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_POST_RDMA_WRITE(ep_handle,
+				      num_segments,
+				      local_iov,
+				      user_cookie,
+				      remote_iov, completion_flags);
 }
 
-
-DAT_RETURN DAT_API dat_ep_get_status (
-	IN      DAT_EP_HANDLE		ep_handle,
-	OUT     DAT_EP_STATE		*ep_state,
-	OUT     DAT_BOOLEAN 		*recv_idle,
-	OUT     DAT_BOOLEAN 		*request_idle)
+DAT_RETURN DAT_API dat_ep_get_status(IN DAT_EP_HANDLE ep_handle,
+				     OUT DAT_EP_STATE * ep_state,
+				     OUT DAT_BOOLEAN * recv_idle,
+				     OUT DAT_BOOLEAN * request_idle)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_GET_STATUS (ep_handle,
-			      ep_state,
-			      recv_idle,
-			      request_idle);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_GET_STATUS(ep_handle, ep_state, recv_idle, request_idle);
 }
 
-
-DAT_RETURN DAT_API dat_ep_free (
-	IN      DAT_EP_HANDLE		ep_handle)
+DAT_RETURN DAT_API dat_ep_free(IN DAT_EP_HANDLE ep_handle)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_FREE (ep_handle);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_FREE(ep_handle);
 }
 
-
-DAT_RETURN DAT_API dat_ep_reset (
-	IN      DAT_EP_HANDLE		ep_handle)
+DAT_RETURN DAT_API dat_ep_reset(IN DAT_EP_HANDLE ep_handle)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_RESET (ep_handle);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_RESET(ep_handle);
 }
 
-
-DAT_RETURN DAT_API dat_lmr_free (
-	IN      DAT_LMR_HANDLE		lmr_handle)
+DAT_RETURN DAT_API dat_lmr_free(IN DAT_LMR_HANDLE lmr_handle)
 {
-    if (lmr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
-    }
-    return DAT_LMR_FREE (lmr_handle);
+	if (lmr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
+	}
+	return DAT_LMR_FREE(lmr_handle);
 }
 
-
-DAT_RETURN DAT_API dat_rmr_create (
-	IN      DAT_PZ_HANDLE		pz_handle,
-	OUT     DAT_RMR_HANDLE		*rmr_handle)
+DAT_RETURN DAT_API dat_rmr_create(IN DAT_PZ_HANDLE pz_handle,
+				  OUT DAT_RMR_HANDLE * rmr_handle)
 {
-    if (pz_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-    }
-    return DAT_RMR_CREATE (pz_handle,
-			   rmr_handle);
+	if (pz_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+	}
+	return DAT_RMR_CREATE(pz_handle, rmr_handle);
 }
 
-
-DAT_RETURN DAT_API dat_rmr_create_for_ep (
-	IN      DAT_PZ_HANDLE		pz_handle,
-	OUT     DAT_RMR_HANDLE		*rmr_handle)
+DAT_RETURN DAT_API dat_rmr_create_for_ep(IN DAT_PZ_HANDLE pz_handle,
+					 OUT DAT_RMR_HANDLE * rmr_handle)
 {
-    if (pz_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-    }
-    return DAT_RMR_CREATE_FOR_EP (pz_handle,
-			   rmr_handle);
+	if (pz_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+	}
+	return DAT_RMR_CREATE_FOR_EP(pz_handle, rmr_handle);
 }
-DAT_RETURN DAT_API dat_rmr_query (
-	IN      DAT_RMR_HANDLE		rmr_handle,
-	IN      DAT_RMR_PARAM_MASK	rmr_param_mask,
-	OUT     DAT_RMR_PARAM		*rmr_param)
+DAT_RETURN DAT_API dat_rmr_query(IN DAT_RMR_HANDLE rmr_handle,
+				 IN DAT_RMR_PARAM_MASK rmr_param_mask,
+				 OUT DAT_RMR_PARAM * rmr_param)
 {
-    if (rmr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
-    }
-    return DAT_RMR_QUERY (rmr_handle,
-			  rmr_param_mask,
-			  rmr_param);
+	if (rmr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+	}
+	return DAT_RMR_QUERY(rmr_handle, rmr_param_mask, rmr_param);
 }
 
-
-DAT_RETURN DAT_API dat_rmr_bind (
-	IN      DAT_RMR_HANDLE		rmr_handle,
-	IN	DAT_LMR_HANDLE		lmr_handle,
-	IN      const DAT_LMR_TRIPLET	*lmr_triplet,
-	IN      DAT_MEM_PRIV_FLAGS	mem_priv,
-	IN	DAT_VA_TYPE		va_type,
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      DAT_RMR_COOKIE		user_cookie,
-	IN      DAT_COMPLETION_FLAGS	completion_flags,
-	OUT     DAT_RMR_CONTEXT		*context)
+DAT_RETURN DAT_API dat_rmr_bind(IN DAT_RMR_HANDLE rmr_handle,
+				IN DAT_LMR_HANDLE lmr_handle,
+				IN const DAT_LMR_TRIPLET * lmr_triplet,
+				IN DAT_MEM_PRIV_FLAGS mem_priv,
+				IN DAT_VA_TYPE va_type,
+				IN DAT_EP_HANDLE ep_handle,
+				IN DAT_RMR_COOKIE user_cookie,
+				IN DAT_COMPLETION_FLAGS completion_flags,
+				OUT DAT_RMR_CONTEXT * context)
 {
-    if (rmr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
-    }
-    return DAT_RMR_BIND (rmr_handle,
-			 lmr_handle,
-			 lmr_triplet,
-			 mem_priv,
-			 va_type,
-			 ep_handle,
-			 user_cookie,
-			 completion_flags,
-			 context);
+	if (rmr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+	}
+	return DAT_RMR_BIND(rmr_handle,
+			    lmr_handle,
+			    lmr_triplet,
+			    mem_priv,
+			    va_type,
+			    ep_handle, user_cookie, completion_flags, context);
 }
 
-
-DAT_RETURN DAT_API dat_rmr_free (
-	IN      DAT_RMR_HANDLE		rmr_handle)
+DAT_RETURN DAT_API dat_rmr_free(IN DAT_RMR_HANDLE rmr_handle)
 {
-    if (rmr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
-    }
-    return DAT_RMR_FREE (rmr_handle);
+	if (rmr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+	}
+	return DAT_RMR_FREE(rmr_handle);
 }
 
-DAT_RETURN DAT_API dat_lmr_sync_rdma_read(
-	IN      DAT_IA_HANDLE           ia_handle,
-	IN      const DAT_LMR_TRIPLET   *local_segments,
-	IN      DAT_VLEN                num_segments)
+DAT_RETURN DAT_API dat_lmr_sync_rdma_read(IN DAT_IA_HANDLE ia_handle,
+					  IN const DAT_LMR_TRIPLET *
+					  local_segments,
+					  IN DAT_VLEN num_segments)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_LMR_SYNC_RDMA_READ (dapl_ia_handle,
-					     local_segments,
-					     num_segments);
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_LMR_SYNC_RDMA_READ(dapl_ia_handle,
+						    local_segments,
+						    num_segments);
 
-    }
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_lmr_sync_rdma_write(
-	IN      DAT_IA_HANDLE           ia_handle,
-	IN      const DAT_LMR_TRIPLET   *local_segments,
-	IN      DAT_VLEN                num_segments)
+DAT_RETURN DAT_API dat_lmr_sync_rdma_write(IN DAT_IA_HANDLE ia_handle,
+					   IN const DAT_LMR_TRIPLET *
+					   local_segments,
+					   IN DAT_VLEN num_segments)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_LMR_SYNC_RDMA_WRITE (dapl_ia_handle,
-					      local_segments,
-					      num_segments);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_LMR_SYNC_RDMA_WRITE(dapl_ia_handle,
+						     local_segments,
+						     num_segments);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_psp_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	IN      DAT_CONN_QUAL		conn_qual,
-	IN      DAT_EVD_HANDLE		evd_handle,
-	IN      DAT_PSP_FLAGS		psp_flags,
-	OUT     DAT_PSP_HANDLE		*psp_handle)
+DAT_RETURN DAT_API dat_psp_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_CONN_QUAL conn_qual,
+				  IN DAT_EVD_HANDLE evd_handle,
+				  IN DAT_PSP_FLAGS psp_flags,
+				  OUT DAT_PSP_HANDLE * psp_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_PSP_CREATE (dapl_ia_handle,
-				     conn_qual,
-				     evd_handle,
-				     psp_flags,
-				     psp_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_PSP_CREATE(dapl_ia_handle,
+					    conn_qual,
+					    evd_handle, psp_flags, psp_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_psp_create_any (
-	IN      DAT_IA_HANDLE		ia_handle,
-	OUT     DAT_CONN_QUAL		*conn_qual,
-	IN      DAT_EVD_HANDLE		evd_handle,
-	IN      DAT_PSP_FLAGS		psp_flags,
-	OUT     DAT_PSP_HANDLE		*psp_handle)
+DAT_RETURN DAT_API dat_psp_create_any(IN DAT_IA_HANDLE ia_handle,
+				      OUT DAT_CONN_QUAL * conn_qual,
+				      IN DAT_EVD_HANDLE evd_handle,
+				      IN DAT_PSP_FLAGS psp_flags,
+				      OUT DAT_PSP_HANDLE * psp_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_PSP_CREATE_ANY (dapl_ia_handle,
-					 conn_qual,
-					 evd_handle,
-					 psp_flags,
-					 psp_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_PSP_CREATE_ANY(dapl_ia_handle,
+						conn_qual,
+						evd_handle,
+						psp_flags, psp_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_psp_query (
-	IN      DAT_PSP_HANDLE		psp_handle,
-	IN      DAT_PSP_PARAM_MASK	psp_param_mask,
-	OUT     DAT_PSP_PARAM 		*psp_param)
+DAT_RETURN DAT_API dat_psp_query(IN DAT_PSP_HANDLE psp_handle,
+				 IN DAT_PSP_PARAM_MASK psp_param_mask,
+				 OUT DAT_PSP_PARAM * psp_param)
 {
-    if (psp_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP);
-    }
-    return DAT_PSP_QUERY (psp_handle,
-			  psp_param_mask,
-			  psp_param);
+	if (psp_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP);
+	}
+	return DAT_PSP_QUERY(psp_handle, psp_param_mask, psp_param);
 }
 
-
-DAT_RETURN DAT_API dat_psp_free (
-	IN      DAT_PSP_HANDLE	psp_handle)
+DAT_RETURN DAT_API dat_psp_free(IN DAT_PSP_HANDLE psp_handle)
 {
-    if (psp_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP);
-    }
-    return DAT_PSP_FREE (psp_handle);
+	if (psp_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP);
+	}
+	return DAT_PSP_FREE(psp_handle);
 }
 
-DAT_RETURN DAT_API dat_csp_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	IN      DAT_COMM		*comm,
-	IN	DAT_IA_ADDRESS_PTR	address,
-	IN      DAT_EVD_HANDLE		evd_handle,
-	OUT     DAT_CSP_HANDLE		*csp_handle)
+DAT_RETURN DAT_API dat_csp_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_COMM * comm,
+				  IN DAT_IA_ADDRESS_PTR address,
+				  IN DAT_EVD_HANDLE evd_handle,
+				  OUT DAT_CSP_HANDLE * csp_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_CSP_CREATE (dapl_ia_handle,
-				     comm,
-				     address,
-				     evd_handle,
-				     csp_handle);
-    }
-    return dat_status;
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_CSP_CREATE(dapl_ia_handle,
+					    comm,
+					    address, evd_handle, csp_handle);
+	}
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_csp_query (
-	IN      DAT_CSP_HANDLE		csp_handle,
-	IN      DAT_CSP_PARAM_MASK	csp_param_mask,
-	OUT     DAT_CSP_PARAM 		*csp_param)
+DAT_RETURN DAT_API dat_csp_query(IN DAT_CSP_HANDLE csp_handle,
+				 IN DAT_CSP_PARAM_MASK csp_param_mask,
+				 OUT DAT_CSP_PARAM * csp_param)
 {
-    if (csp_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CSP);
-    }
-    return DAT_CSP_QUERY (csp_handle,
-			  csp_param_mask,
-			  csp_param);
+	if (csp_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CSP);
+	}
+	return DAT_CSP_QUERY(csp_handle, csp_param_mask, csp_param);
 }
 
-DAT_RETURN DAT_API dat_csp_free (
-	IN      DAT_CSP_HANDLE	csp_handle)
+DAT_RETURN DAT_API dat_csp_free(IN DAT_CSP_HANDLE csp_handle)
 {
-    if (csp_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CSP);
-    }
-    return DAT_CSP_FREE (csp_handle);
+	if (csp_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CSP);
+	}
+	return DAT_CSP_FREE(csp_handle);
 }
 
-
-DAT_RETURN DAT_API dat_rsp_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	IN      DAT_CONN_QUAL		conn_qual,
-	IN      DAT_EP_HANDLE		ep_handle,
-	IN      DAT_EVD_HANDLE		evd_handle,
-	OUT     DAT_RSP_HANDLE		*rsp_handle)
+DAT_RETURN DAT_API dat_rsp_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_CONN_QUAL conn_qual,
+				  IN DAT_EP_HANDLE ep_handle,
+				  IN DAT_EVD_HANDLE evd_handle,
+				  OUT DAT_RSP_HANDLE * rsp_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_RSP_CREATE (dapl_ia_handle,
-				     conn_qual,
-				     ep_handle,
-				     evd_handle,
-				     rsp_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_RSP_CREATE(dapl_ia_handle,
+					    conn_qual,
+					    ep_handle, evd_handle, rsp_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_rsp_query (
-	IN      DAT_RSP_HANDLE		rsp_handle,
-	IN      DAT_RSP_PARAM_MASK	rsp_param_mask,
-	OUT     DAT_RSP_PARAM		*rsp_param)
+DAT_RETURN DAT_API dat_rsp_query(IN DAT_RSP_HANDLE rsp_handle,
+				 IN DAT_RSP_PARAM_MASK rsp_param_mask,
+				 OUT DAT_RSP_PARAM * rsp_param)
 {
-    if (rsp_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP);
-    }
-    return DAT_RSP_QUERY (rsp_handle,
-			  rsp_param_mask,
-			  rsp_param);
+	if (rsp_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP);
+	}
+	return DAT_RSP_QUERY(rsp_handle, rsp_param_mask, rsp_param);
 }
 
-
-DAT_RETURN DAT_API dat_rsp_free (
-	IN      DAT_RSP_HANDLE		rsp_handle)
+DAT_RETURN DAT_API dat_rsp_free(IN DAT_RSP_HANDLE rsp_handle)
 {
-    if (rsp_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP);
-    }
-    return DAT_RSP_FREE (rsp_handle);
+	if (rsp_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP);
+	}
+	return DAT_RSP_FREE(rsp_handle);
 }
 
-
-DAT_RETURN DAT_API dat_pz_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	OUT     DAT_PZ_HANDLE		*pz_handle)
+DAT_RETURN DAT_API dat_pz_create(IN DAT_IA_HANDLE ia_handle,
+				 OUT DAT_PZ_HANDLE * pz_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_PZ_CREATE (dapl_ia_handle,
-				    pz_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_PZ_CREATE(dapl_ia_handle, pz_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_pz_query (
-	IN      DAT_PZ_HANDLE		pz_handle,
-	IN      DAT_PZ_PARAM_MASK	pz_param_mask,
-	OUT     DAT_PZ_PARAM		*pz_param)
+DAT_RETURN DAT_API dat_pz_query(IN DAT_PZ_HANDLE pz_handle,
+				IN DAT_PZ_PARAM_MASK pz_param_mask,
+				OUT DAT_PZ_PARAM * pz_param)
 {
-    if (pz_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-    }
-    return DAT_PZ_QUERY (pz_handle,
-			 pz_param_mask,
-			 pz_param);
+	if (pz_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+	}
+	return DAT_PZ_QUERY(pz_handle, pz_param_mask, pz_param);
 }
 
-
-DAT_RETURN DAT_API dat_pz_free (
-	IN      DAT_PZ_HANDLE		pz_handle)
+DAT_RETURN DAT_API dat_pz_free(IN DAT_PZ_HANDLE pz_handle)
 {
-    if (pz_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
-    }
-    return DAT_PZ_FREE (pz_handle);
+	if (pz_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+	}
+	return DAT_PZ_FREE(pz_handle);
 }
 
-DAT_RETURN DAT_API dat_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_attributes,
-        OUT     DAT_EP_HANDLE          *ep_handle)
+DAT_RETURN DAT_API dat_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_attributes,
+					  OUT DAT_EP_HANDLE * ep_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_EP_CREATE_WITH_SRQ (dapl_ia_handle,
-					     pz_handle,
-					     recv_evd_handle,
-					     request_evd_handle,
-					     connect_evd_handle,
-					     srq_handle,
-					     ep_attributes,
-					     ep_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_EP_CREATE_WITH_SRQ(dapl_ia_handle,
+						    pz_handle,
+						    recv_evd_handle,
+						    request_evd_handle,
+						    connect_evd_handle,
+						    srq_handle,
+						    ep_attributes, ep_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_ep_recv_query(
-        IN      DAT_EP_HANDLE         ep_handle,
-        OUT     DAT_COUNT *           nbufs_allocated,
-        OUT     DAT_COUNT *           bufs_alloc_span)
+DAT_RETURN DAT_API dat_ep_recv_query(IN DAT_EP_HANDLE ep_handle,
+				     OUT DAT_COUNT * nbufs_allocated,
+				     OUT DAT_COUNT * bufs_alloc_span)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_RECV_QUERY (ep_handle,
-			      nbufs_allocated,
-			      bufs_alloc_span);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_RECV_QUERY(ep_handle, nbufs_allocated, bufs_alloc_span);
 }
 
-DAT_RETURN DAT_API dat_ep_set_watermark(
-        IN      DAT_EP_HANDLE         ep_handle,
-        IN      DAT_COUNT             soft_high_watermark,
-        IN      DAT_COUNT             hard_high_watermark)
+DAT_RETURN DAT_API dat_ep_set_watermark(IN DAT_EP_HANDLE ep_handle,
+					IN DAT_COUNT soft_high_watermark,
+					IN DAT_COUNT hard_high_watermark)
 {
-    if (ep_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
-    }
-    return DAT_EP_SET_WATERMARK (ep_handle,
-				 soft_high_watermark,
-				 hard_high_watermark);
+	if (ep_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
+	}
+	return DAT_EP_SET_WATERMARK(ep_handle,
+				    soft_high_watermark, hard_high_watermark);
 }
 
 /* SRQ functions */
 
-DAT_RETURN DAT_API dat_srq_create(
-        IN      DAT_IA_HANDLE           ia_handle,
-        IN      DAT_PZ_HANDLE           pz_handle,
-        IN      DAT_SRQ_ATTR            *srq_attr,
-        OUT     DAT_SRQ_HANDLE          *srq_handle)
+DAT_RETURN DAT_API dat_srq_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_PZ_HANDLE pz_handle,
+				  IN DAT_SRQ_ATTR * srq_attr,
+				  OUT DAT_SRQ_HANDLE * srq_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_SRQ_CREATE(dapl_ia_handle,
-				    pz_handle,
-				    srq_attr,
-				    srq_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_SRQ_CREATE(dapl_ia_handle,
+					    pz_handle, srq_attr, srq_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_srq_free(
-	IN      DAT_SRQ_HANDLE        srq_handle)
+DAT_RETURN DAT_API dat_srq_free(IN DAT_SRQ_HANDLE srq_handle)
 {
-    return DAT_SRQ_FREE (srq_handle);
+	return DAT_SRQ_FREE(srq_handle);
 }
 
-DAT_RETURN DAT_API dat_srq_post_recv(
-	IN      DAT_SRQ_HANDLE         srq_handle,
-	IN      DAT_COUNT              num_segments,
-	IN      DAT_LMR_TRIPLET *      local_iov,
-	IN      DAT_DTO_COOKIE         user_cookie)
+DAT_RETURN DAT_API dat_srq_post_recv(IN DAT_SRQ_HANDLE srq_handle,
+				     IN DAT_COUNT num_segments,
+				     IN DAT_LMR_TRIPLET * local_iov,
+				     IN DAT_DTO_COOKIE user_cookie)
 {
-    if (srq_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-    }
-    return DAT_SRQ_POST_RECV (srq_handle,
-			      num_segments,
-			      local_iov,
-			      user_cookie);
+	if (srq_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+	}
+	return DAT_SRQ_POST_RECV(srq_handle,
+				 num_segments, local_iov, user_cookie);
 }
 
-DAT_RETURN DAT_API dat_srq_query(
-	IN      DAT_SRQ_HANDLE         srq_handle,
-	IN      DAT_SRQ_PARAM_MASK     srq_param_mask,
-	OUT     DAT_SRQ_PARAM *        srq_param)
+DAT_RETURN DAT_API dat_srq_query(IN DAT_SRQ_HANDLE srq_handle,
+				 IN DAT_SRQ_PARAM_MASK srq_param_mask,
+				 OUT DAT_SRQ_PARAM * srq_param)
 {
-    if (srq_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-    }
-    return DAT_SRQ_QUERY (srq_handle,
-			  srq_param_mask,
-			  srq_param);
+	if (srq_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+	}
+	return DAT_SRQ_QUERY(srq_handle, srq_param_mask, srq_param);
 }
 
-DAT_RETURN DAT_API dat_srq_resize(
-	IN      DAT_SRQ_HANDLE         srq_handle,
-	IN      DAT_COUNT              srq_max_recv_dto)
+DAT_RETURN DAT_API dat_srq_resize(IN DAT_SRQ_HANDLE srq_handle,
+				  IN DAT_COUNT srq_max_recv_dto)
 {
-    if (srq_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-    }
-    return DAT_SRQ_RESIZE (srq_handle,
-			   srq_max_recv_dto);
+	if (srq_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+	}
+	return DAT_SRQ_RESIZE(srq_handle, srq_max_recv_dto);
 }
 
-DAT_RETURN DAT_API dat_srq_set_lw(
-	IN      DAT_SRQ_HANDLE         srq_handle,
-	IN      DAT_COUNT              low_watermark)
+DAT_RETURN DAT_API dat_srq_set_lw(IN DAT_SRQ_HANDLE srq_handle,
+				  IN DAT_COUNT low_watermark)
 {
-    if (srq_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
-    }
-    return DAT_SRQ_SET_LW (srq_handle,
-			   low_watermark);
+	if (srq_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ);
+	}
+	return DAT_SRQ_SET_LW(srq_handle, low_watermark);
 }
 
 #ifdef DAT_EXTENSIONS
 
 extern int g_dat_extensions;
 
-DAT_RETURN DAT_API dat_extension_op(
-        IN      DAT_HANDLE              handle,
-        IN      DAT_EXTENDED_OP         ext_op,
-        IN      ... )
-
+DAT_RETURN DAT_API dat_extension_op(IN DAT_HANDLE handle,
+				    IN DAT_EXTENDED_OP ext_op, IN ...)
 {
-     DAT_RETURN status;
-     DAT_IA_HANDLE dapl_handle;
-     va_list args;
+	DAT_RETURN status;
+	DAT_IA_HANDLE dapl_handle;
+	va_list args;
 
-     /* If not IA handle then just passthrough */
-     if (dats_get_ia_handle(handle, &dapl_handle) != DAT_SUCCESS)
-     {
-	     dapl_handle = handle;
-     }
+	/* If not IA handle then just passthrough */
+	if (dats_get_ia_handle(handle, &dapl_handle) != DAT_SUCCESS) {
+		dapl_handle = handle;
+	}
 
-     /* verify provider extension support */
-     if (!g_dat_extensions)
-     {
-        return DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
-     }
-   
-     /* extension will validate the handle based on op */
-     va_start(args, ext_op);
-     status = DAT_HANDLE_EXTENDEDOP(dapl_handle, ext_op, args);
-     va_end(args);
+	/* verify provider extension support */
+	if (!g_dat_extensions) {
+		return DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
+	}
 
-     return status;
+	/* extension will validate the handle based on op */
+	va_start(args, ext_op);
+	status = DAT_HANDLE_EXTENDEDOP(dapl_handle, ext_op, args);
+	va_end(args);
+
+	return status;
 }
 #endif
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dictionary.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dictionary.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dictionary.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -37,30 +37,25 @@
  * $Id: dat_dictionary.c,v 1.17 2005/05/20 22:24:01 jlentini Exp $
  **********************************************************************/
 
-
 #include "dat_dictionary.h"
 
-
 /*********************************************************************
  *                                                                   *
  * Structures                                                        *
  *                                                                   *
  *********************************************************************/
 
-typedef struct DAT_DICTIONARY_NODE
-{
-    DAT_PROVIDER_INFO 		key;
-    DAT_DICTIONARY_DATA         data;
-    struct DAT_DICTIONARY_NODE 	*prev;
-    struct DAT_DICTIONARY_NODE 	*next;
+typedef struct DAT_DICTIONARY_NODE {
+	DAT_PROVIDER_INFO key;
+	DAT_DICTIONARY_DATA data;
+	struct DAT_DICTIONARY_NODE *prev;
+	struct DAT_DICTIONARY_NODE *next;
 } DAT_DICTIONARY_NODE;
 
-
-struct DAT_DICTIONARY
-{
-    DAT_DICTIONARY_NODE 	*head;
-    DAT_DICTIONARY_NODE 	*tail;
-    DAT_COUNT           	size;
+struct DAT_DICTIONARY {
+	DAT_DICTIONARY_NODE *head;
+	DAT_DICTIONARY_NODE *tail;
+	DAT_COUNT size;
 };
 
 /*********************************************************************
@@ -70,403 +65,356 @@
  *********************************************************************/
 
 static DAT_RETURN
-dat_dictionary_key_dup (
-    const DAT_PROVIDER_INFO 	*old_key,
-    DAT_PROVIDER_INFO 		*new_key );
+dat_dictionary_key_dup(const DAT_PROVIDER_INFO * old_key,
+		       DAT_PROVIDER_INFO * new_key);
 
 static DAT_BOOLEAN
-dat_dictionary_key_is_equal (
-    const DAT_PROVIDER_INFO 	*key_a,
-    const DAT_PROVIDER_INFO 	*key_b );
+dat_dictionary_key_is_equal(const DAT_PROVIDER_INFO * key_a,
+			    const DAT_PROVIDER_INFO * key_b);
 
-
 /*********************************************************************
  *                                                                   *
  * External Functions                                                *
  *                                                                   *
  *********************************************************************/
 
-
 /***********************************************************************
  * Function: dat_dictionary_create
  ***********************************************************************/
 
-DAT_RETURN
-dat_dictionary_create (
-    OUT DAT_DICTIONARY **pp_dictionary)
+DAT_RETURN dat_dictionary_create(OUT DAT_DICTIONARY ** pp_dictionary)
 {
-    DAT_DICTIONARY *p_dictionary;
-    DAT_RETURN status;
+	DAT_DICTIONARY *p_dictionary;
+	DAT_RETURN status;
 
-    dat_os_assert ( NULL != pp_dictionary);
+	dat_os_assert(NULL != pp_dictionary);
 
-    status = DAT_SUCCESS;
+	status = DAT_SUCCESS;
 
-    /* create the dictionary */
-    p_dictionary = dat_os_alloc (sizeof (DAT_DICTIONARY));
-    if (NULL == p_dictionary)
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* create the dictionary */
+	p_dictionary = dat_os_alloc(sizeof(DAT_DICTIONARY));
+	if (NULL == p_dictionary) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_os_memset (p_dictionary, '\0', sizeof (DAT_DICTIONARY));
+	dat_os_memset(p_dictionary, '\0', sizeof(DAT_DICTIONARY));
 
-    /* create the head node */
-    p_dictionary->head = dat_os_alloc (sizeof (DAT_DICTIONARY_NODE));
-    if (NULL == p_dictionary->head)
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* create the head node */
+	p_dictionary->head = dat_os_alloc(sizeof(DAT_DICTIONARY_NODE));
+	if (NULL == p_dictionary->head) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_os_memset (p_dictionary->head, '\0', sizeof (DAT_DICTIONARY_NODE));
+	dat_os_memset(p_dictionary->head, '\0', sizeof(DAT_DICTIONARY_NODE));
 
-    /* create the tail node */
-    p_dictionary->tail = dat_os_alloc (sizeof (DAT_DICTIONARY_NODE));
-    if (NULL == p_dictionary->tail)
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	/* create the tail node */
+	p_dictionary->tail = dat_os_alloc(sizeof(DAT_DICTIONARY_NODE));
+	if (NULL == p_dictionary->tail) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_os_memset (p_dictionary->tail, '\0', sizeof (DAT_DICTIONARY_NODE));
+	dat_os_memset(p_dictionary->tail, '\0', sizeof(DAT_DICTIONARY_NODE));
 
-    p_dictionary->head->next = p_dictionary->tail;
-    p_dictionary->tail->prev = p_dictionary->head;
+	p_dictionary->head->next = p_dictionary->tail;
+	p_dictionary->tail->prev = p_dictionary->head;
 
-    *pp_dictionary = p_dictionary;
+	*pp_dictionary = p_dictionary;
 
-bail:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != p_dictionary )
-	{
-	    if ( NULL != p_dictionary->head )
-	    {
-		dat_os_free (p_dictionary->head, sizeof (DAT_DICTIONARY_NODE));
-	    }
+      bail:
+	if (DAT_SUCCESS != status) {
+		if (NULL != p_dictionary) {
+			if (NULL != p_dictionary->head) {
+				dat_os_free(p_dictionary->head,
+					    sizeof(DAT_DICTIONARY_NODE));
+			}
 
-	    if ( NULL != p_dictionary->tail )
-	    {
-		dat_os_free (p_dictionary->tail, sizeof (DAT_DICTIONARY_NODE));
-	    }
+			if (NULL != p_dictionary->tail) {
+				dat_os_free(p_dictionary->tail,
+					    sizeof(DAT_DICTIONARY_NODE));
+			}
 
-            dat_os_free (p_dictionary, sizeof (DAT_DICTIONARY));
+			dat_os_free(p_dictionary, sizeof(DAT_DICTIONARY));
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_destroy
  ***********************************************************************/
 
-DAT_RETURN
-dat_dictionary_destroy (
-    IN  DAT_DICTIONARY *p_dictionary)
+DAT_RETURN dat_dictionary_destroy(IN DAT_DICTIONARY * p_dictionary)
 {
-    DAT_DICTIONARY_NODE *cur_node;
+	DAT_DICTIONARY_NODE *cur_node;
 
-    dat_os_assert (NULL != p_dictionary);
+	dat_os_assert(NULL != p_dictionary);
 
-    while (NULL != p_dictionary->head)
-    {
-	cur_node = p_dictionary->head;
-	p_dictionary->head = cur_node->next;
+	while (NULL != p_dictionary->head) {
+		cur_node = p_dictionary->head;
+		p_dictionary->head = cur_node->next;
 
-	dat_os_free (cur_node, sizeof (DAT_DICTIONARY_NODE));
-    }
+		dat_os_free(cur_node, sizeof(DAT_DICTIONARY_NODE));
+	}
 
-    dat_os_free (p_dictionary, sizeof (DAT_DICTIONARY));
+	dat_os_free(p_dictionary, sizeof(DAT_DICTIONARY));
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_size
  ***********************************************************************/
 
 DAT_RETURN
-dat_dictionary_size (
-    IN  DAT_DICTIONARY *p_dictionary,
-    OUT DAT_COUNT *p_size)
+dat_dictionary_size(IN DAT_DICTIONARY * p_dictionary, OUT DAT_COUNT * p_size)
 {
-    dat_os_assert (NULL != p_dictionary);
-    dat_os_assert (NULL != p_size);
+	dat_os_assert(NULL != p_dictionary);
+	dat_os_assert(NULL != p_size);
 
-    *p_size = p_dictionary->size;
+	*p_size = p_dictionary->size;
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_entry_create
  ***********************************************************************/
 
-DAT_RETURN
-dat_dictionary_entry_create (
-    OUT DAT_DICTIONARY_ENTRY *p_entry)
+DAT_RETURN dat_dictionary_entry_create(OUT DAT_DICTIONARY_ENTRY * p_entry)
 {
-    DAT_DICTIONARY_NODE 	*node;
-    DAT_RETURN			dat_status;
+	DAT_DICTIONARY_NODE *node;
+	DAT_RETURN dat_status;
 
-    dat_os_assert (NULL != p_entry);
+	dat_os_assert(NULL != p_entry);
 
-    dat_status = DAT_SUCCESS;
+	dat_status = DAT_SUCCESS;
 
-    node = dat_os_alloc (sizeof (DAT_DICTIONARY_NODE));
-    if (NULL == node)
-    {
-	dat_status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	node = dat_os_alloc(sizeof(DAT_DICTIONARY_NODE));
+	if (NULL == node) {
+		dat_status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    *p_entry = node;
+	*p_entry = node;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_entry_destroy
  ***********************************************************************/
 
-DAT_RETURN
-dat_dictionary_entry_destroy (
-    OUT DAT_DICTIONARY_ENTRY entry)
+DAT_RETURN dat_dictionary_entry_destroy(OUT DAT_DICTIONARY_ENTRY entry)
 {
-    dat_os_free (entry, sizeof (DAT_DICTIONARY_NODE));
-    return DAT_SUCCESS;
+	dat_os_free(entry, sizeof(DAT_DICTIONARY_NODE));
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_insert
  ***********************************************************************/
 
 DAT_RETURN
-dat_dictionary_insert (
-    IN  DAT_DICTIONARY *p_dictionary,
-    IN  DAT_DICTIONARY_ENTRY entry,
-    IN  const DAT_PROVIDER_INFO *key,
-    IN  DAT_DICTIONARY_DATA data)
+dat_dictionary_insert(IN DAT_DICTIONARY * p_dictionary,
+		      IN DAT_DICTIONARY_ENTRY entry,
+		      IN const DAT_PROVIDER_INFO * key,
+		      IN DAT_DICTIONARY_DATA data)
 {
-    DAT_RETURN		dat_status;
-    DAT_DICTIONARY_NODE *cur_node, *prev_node, *next_node;
+	DAT_RETURN dat_status;
+	DAT_DICTIONARY_NODE *cur_node, *prev_node, *next_node;
 
-    dat_os_assert (NULL != p_dictionary);
-    dat_os_assert (NULL != entry);
+	dat_os_assert(NULL != p_dictionary);
+	dat_os_assert(NULL != entry);
 
-    cur_node = entry;
+	cur_node = entry;
 
-    if ( DAT_SUCCESS == dat_dictionary_search (p_dictionary, key, NULL) )
-    {
-	dat_status = DAT_ERROR (DAT_PROVIDER_ALREADY_REGISTERED, 0);
-	goto bail;
-    }
+	if (DAT_SUCCESS == dat_dictionary_search(p_dictionary, key, NULL)) {
+		dat_status = DAT_ERROR(DAT_PROVIDER_ALREADY_REGISTERED, 0);
+		goto bail;
+	}
 
-    dat_status = dat_dictionary_key_dup ( key, &cur_node->key );
-    if ( DAT_SUCCESS != dat_status )
-    {
-	goto bail;
-    }
+	dat_status = dat_dictionary_key_dup(key, &cur_node->key);
+	if (DAT_SUCCESS != dat_status) {
+		goto bail;
+	}
 
-    /* insert node at end of list to preserve registration order*/
-    prev_node = p_dictionary->tail->prev;
-    next_node = p_dictionary->tail;
+	/* insert node at end of list to preserve registration order */
+	prev_node = p_dictionary->tail->prev;
+	next_node = p_dictionary->tail;
 
-    cur_node->data = data;
-    cur_node->next = next_node;
-    cur_node->prev = prev_node;
+	cur_node->data = data;
+	cur_node->next = next_node;
+	cur_node->prev = prev_node;
 
-    prev_node->next = cur_node;
-    next_node->prev = cur_node;
+	prev_node->next = cur_node;
+	next_node->prev = cur_node;
 
-    p_dictionary->size++;
+	p_dictionary->size++;
 
-bail:
-    return dat_status;
+      bail:
+	return dat_status;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_search
  ***********************************************************************/
 
 DAT_RETURN
-dat_dictionary_search (
-    IN  DAT_DICTIONARY *p_dictionary,
-    IN  const DAT_PROVIDER_INFO *key,
-    OUT DAT_DICTIONARY_DATA *p_data)
+dat_dictionary_search(IN DAT_DICTIONARY * p_dictionary,
+		      IN const DAT_PROVIDER_INFO * key,
+		      OUT DAT_DICTIONARY_DATA * p_data)
 {
-    DAT_DICTIONARY_NODE *cur_node;
-    DAT_RETURN status;
+	DAT_DICTIONARY_NODE *cur_node;
+	DAT_RETURN status;
 
-    dat_os_assert (NULL != p_dictionary);
+	dat_os_assert(NULL != p_dictionary);
 
-    status = DAT_ERROR (DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
+	status = DAT_ERROR(DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
 
-    for (cur_node = p_dictionary->head->next;
-	 p_dictionary->tail != cur_node;
-	 cur_node = cur_node->next)
-    {
-	if ( DAT_TRUE == dat_dictionary_key_is_equal (&cur_node->key, key) )
-	{
-	    if ( NULL != p_data )
-	    {
-		*p_data = cur_node->data;
-	    }
+	for (cur_node = p_dictionary->head->next;
+	     p_dictionary->tail != cur_node; cur_node = cur_node->next) {
+		if (DAT_TRUE ==
+		    dat_dictionary_key_is_equal(&cur_node->key, key)) {
+			if (NULL != p_data) {
+				*p_data = cur_node->data;
+			}
 
-	    status = DAT_SUCCESS;
-	    goto bail;
+			status = DAT_SUCCESS;
+			goto bail;
+		}
 	}
-    }
 
-bail:
-    return status;
+      bail:
+	return status;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_enumerate
  ***********************************************************************/
 
 DAT_RETURN
-dat_dictionary_enumerate (
-    IN  DAT_DICTIONARY *p_dictionary,
-    IN  DAT_DICTIONARY_DATA array[],
-    IN  DAT_COUNT array_size)
+dat_dictionary_enumerate(IN DAT_DICTIONARY * p_dictionary,
+			 IN DAT_DICTIONARY_DATA array[],
+			 IN DAT_COUNT array_size)
 {
-    DAT_DICTIONARY_NODE *cur_node;
-    DAT_COUNT i;
-    DAT_RETURN status;
+	DAT_DICTIONARY_NODE *cur_node;
+	DAT_COUNT i;
+	DAT_RETURN status;
 
-    dat_os_assert (NULL != p_dictionary);
-    dat_os_assert (NULL != array);
+	dat_os_assert(NULL != p_dictionary);
+	dat_os_assert(NULL != array);
 
-    status = DAT_SUCCESS;
+	status = DAT_SUCCESS;
 
-    if ( array_size < p_dictionary->size )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, 0);
-	goto bail;
-    }
+	if (array_size < p_dictionary->size) {
+		status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 0);
+		goto bail;
+	}
 
-    for (cur_node = p_dictionary->head->next, i = 0;
-	 p_dictionary->tail != cur_node;
-	 cur_node = cur_node->next, i++)
-    {
-	array[i] = cur_node->data;
-    }
+	for (cur_node = p_dictionary->head->next, i = 0;
+	     p_dictionary->tail != cur_node; cur_node = cur_node->next, i++) {
+		array[i] = cur_node->data;
+	}
 
-bail:
-    return status;
+      bail:
+	return status;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_remove
  ***********************************************************************/
 
 DAT_RETURN
-dat_dictionary_remove (
-    IN  DAT_DICTIONARY *p_dictionary,
-    IN  DAT_DICTIONARY_ENTRY *p_entry,
-    IN  const DAT_PROVIDER_INFO *key,
-    OUT DAT_DICTIONARY_DATA *p_data)
+dat_dictionary_remove(IN DAT_DICTIONARY * p_dictionary,
+		      IN DAT_DICTIONARY_ENTRY * p_entry,
+		      IN const DAT_PROVIDER_INFO * key,
+		      OUT DAT_DICTIONARY_DATA * p_data)
 {
-    DAT_DICTIONARY_NODE *cur_node, *prev_node, *next_node;
-    DAT_RETURN status;
+	DAT_DICTIONARY_NODE *cur_node, *prev_node, *next_node;
+	DAT_RETURN status;
 
-    dat_os_assert (NULL != p_dictionary);
-    dat_os_assert (NULL != p_entry);
+	dat_os_assert(NULL != p_dictionary);
+	dat_os_assert(NULL != p_entry);
 
-    status = DAT_ERROR (DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
+	status = DAT_ERROR(DAT_PROVIDER_NOT_FOUND, DAT_NAME_NOT_REGISTERED);
 
-    for (cur_node = p_dictionary->head->next;
-	 p_dictionary->tail != cur_node;
-	 cur_node = cur_node->next)
-    {
-	if ( DAT_TRUE == dat_dictionary_key_is_equal (&cur_node->key, key) )
-	{
-	    if ( NULL != p_data )
-	    {
-		*p_data = cur_node->data;
-	    }
+	for (cur_node = p_dictionary->head->next;
+	     p_dictionary->tail != cur_node; cur_node = cur_node->next) {
+		if (DAT_TRUE ==
+		    dat_dictionary_key_is_equal(&cur_node->key, key)) {
+			if (NULL != p_data) {
+				*p_data = cur_node->data;
+			}
 
-	    prev_node = cur_node->prev;
-	    next_node = cur_node->next;
+			prev_node = cur_node->prev;
+			next_node = cur_node->next;
 
-	    prev_node->next = next_node;
-	    next_node->prev = prev_node;
+			prev_node->next = next_node;
+			next_node->prev = prev_node;
 
-	    *p_entry = cur_node;
+			*p_entry = cur_node;
 
-	    p_dictionary->size--;
+			p_dictionary->size--;
 
-	    status = DAT_SUCCESS;
-	    goto bail;
+			status = DAT_SUCCESS;
+			goto bail;
+		}
 	}
-    }
 
-bail:
-    return status;
+      bail:
+	return status;
 }
 
-
 /*********************************************************************
  *                                                                   *
  * Internal Function Definitions                                     *
  *                                                                   *
  *********************************************************************/
 
-
 /***********************************************************************
  * Function: dat_dictionary_key_create
  ***********************************************************************/
 
 DAT_RETURN
-dat_dictionary_key_dup (
-    const DAT_PROVIDER_INFO 	*old_key,
-    DAT_PROVIDER_INFO 		*new_key )
+dat_dictionary_key_dup(const DAT_PROVIDER_INFO * old_key,
+		       DAT_PROVIDER_INFO * new_key)
 {
-    dat_os_assert (NULL != old_key);
-    dat_os_assert (NULL != new_key);
+	dat_os_assert(NULL != old_key);
+	dat_os_assert(NULL != new_key);
 
-    dat_os_strncpy (new_key->ia_name, old_key->ia_name, DAT_NAME_MAX_LENGTH);
-    new_key->dapl_version_major = old_key->dapl_version_major;
-    new_key->dapl_version_minor = old_key->dapl_version_minor;
-    new_key->is_thread_safe = old_key->is_thread_safe;
+	dat_os_strncpy(new_key->ia_name, old_key->ia_name, DAT_NAME_MAX_LENGTH);
+	new_key->dapl_version_major = old_key->dapl_version_major;
+	new_key->dapl_version_minor = old_key->dapl_version_minor;
+	new_key->is_thread_safe = old_key->is_thread_safe;
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_dictionary_key_is_equal
  ***********************************************************************/
 
 DAT_BOOLEAN
-dat_dictionary_key_is_equal (
-    const DAT_PROVIDER_INFO	*key_a,
-    const DAT_PROVIDER_INFO	*key_b )
+dat_dictionary_key_is_equal(const DAT_PROVIDER_INFO * key_a,
+			    const DAT_PROVIDER_INFO * key_b)
 {
-    if ( ( dat_os_strlen (key_a->ia_name) == dat_os_strlen (key_b->ia_name) ) &&
-	 ( !dat_os_strncmp (key_a->ia_name, key_b->ia_name, dat_os_strlen (key_a->ia_name)) ) &&
-	 ( key_a->dapl_version_major == key_b->dapl_version_major ) &&
-	 ( key_a->dapl_version_minor == key_b->dapl_version_minor ) &&
-	 ( key_a->is_thread_safe == key_b->is_thread_safe ) )
-    {
-	return DAT_TRUE;
-    }
-    else
-    {
-	return DAT_FALSE;
-    }
+	if ((dat_os_strlen(key_a->ia_name) == dat_os_strlen(key_b->ia_name)) &&
+	    (!dat_os_strncmp
+	     (key_a->ia_name, key_b->ia_name, dat_os_strlen(key_a->ia_name)))
+	    && (key_a->dapl_version_major == key_b->dapl_version_major)
+	    && (key_a->dapl_version_minor == key_b->dapl_version_minor)
+	    && (key_a->is_thread_safe == key_b->is_thread_safe)) {
+		return DAT_TRUE;
+	} else {
+		return DAT_FALSE;
+	}
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dr.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dr.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_dr.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -41,334 +41,281 @@
 #include "dat_dr.h"
 #include "dat_dictionary.h"
 
-
 /*********************************************************************
  *                                                                   *
  * Global Variables                                                  *
  *                                                                   *
  *********************************************************************/
 
-static DAT_OS_LOCK 		g_dr_lock;
-static DAT_DICTIONARY 		*g_dr_dictionary = NULL;
+static DAT_OS_LOCK g_dr_lock;
+static DAT_DICTIONARY *g_dr_dictionary = NULL;
 
-
 /*********************************************************************
  *                                                                   *
  * External Functions                                                *
  *                                                                   *
  *********************************************************************/
 
-
 //***********************************************************************
 // Function: dat_dr_init
 //***********************************************************************
 
-DAT_RETURN
-dat_dr_init ( void )
+DAT_RETURN dat_dr_init(void)
 {
-    DAT_RETURN 			status;
+	DAT_RETURN status;
 
-    status = dat_os_lock_init (&g_dr_lock);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_os_lock_init(&g_dr_lock);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    status = dat_dictionary_create (&g_dr_dictionary);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_dictionary_create(&g_dr_dictionary);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 //***********************************************************************
 // Function: dat_dr_fini
 //***********************************************************************
 
-DAT_RETURN
-dat_dr_fini ( void )
+DAT_RETURN dat_dr_fini(void)
 {
-    DAT_RETURN 			status;
+	DAT_RETURN status;
 
-    status = dat_os_lock_destroy (&g_dr_lock);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_os_lock_destroy(&g_dr_lock);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    status = dat_dictionary_destroy (g_dr_dictionary);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_dictionary_destroy(g_dr_dictionary);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 //***********************************************************************
 // Function: dat_dr_insert
 //***********************************************************************
 
 DAT_RETURN
-dat_dr_insert (
-    IN  const DAT_PROVIDER_INFO *info,
-    IN  DAT_DR_ENTRY 		*entry )
+dat_dr_insert(IN const DAT_PROVIDER_INFO * info, IN DAT_DR_ENTRY * entry)
 {
-    DAT_RETURN 			status;
-    DAT_DICTIONARY_ENTRY 	dict_entry = NULL;
-    DAT_DR_ENTRY		*data;
+	DAT_RETURN status;
+	DAT_DICTIONARY_ENTRY dict_entry = NULL;
+	DAT_DR_ENTRY *data;
 
-    data = dat_os_alloc (sizeof (DAT_DR_ENTRY));
-    if ( NULL == data )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	data = dat_os_alloc(sizeof(DAT_DR_ENTRY));
+	if (NULL == data) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    *data = *entry;
+	*data = *entry;
 
-    status = dat_dictionary_entry_create (&dict_entry);
-    if ( DAT_SUCCESS != status )
-    {
-	goto bail;
-    }
+	status = dat_dictionary_entry_create(&dict_entry);
+	if (DAT_SUCCESS != status) {
+		goto bail;
+	}
 
-    dat_os_lock (&g_dr_lock);
+	dat_os_lock(&g_dr_lock);
 
-    status = dat_dictionary_insert (g_dr_dictionary,
-				    dict_entry,
-				    info,
-				    (DAT_DICTIONARY_DATA *) data);
+	status = dat_dictionary_insert(g_dr_dictionary,
+				       dict_entry,
+				       info, (DAT_DICTIONARY_DATA *) data);
 
-    dat_os_unlock (&g_dr_lock);
+	dat_os_unlock(&g_dr_lock);
 
-bail:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != data )
-	{
-	    dat_os_free (data, sizeof (DAT_DR_ENTRY));
-	}
+      bail:
+	if (DAT_SUCCESS != status) {
+		if (NULL != data) {
+			dat_os_free(data, sizeof(DAT_DR_ENTRY));
+		}
 
-
-	if ( NULL != dict_entry )
-	{
-	    (void) dat_dictionary_entry_destroy (dict_entry);
+		if (NULL != dict_entry) {
+			(void)dat_dictionary_entry_destroy(dict_entry);
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
 //***********************************************************************
 // Function: dat_dr_remove
 //***********************************************************************
 
-DAT_RETURN
-dat_dr_remove (
-    IN  const DAT_PROVIDER_INFO *info )
+DAT_RETURN dat_dr_remove(IN const DAT_PROVIDER_INFO * info)
 {
-    DAT_DICTIONARY_ENTRY 	dict_entry;
-    DAT_RETURN 			status;
-    DAT_DICTIONARY_DATA		data;
+	DAT_DICTIONARY_ENTRY dict_entry;
+	DAT_RETURN status;
+	DAT_DICTIONARY_DATA data;
 
-    dict_entry = NULL;
-    dat_os_lock (&g_dr_lock);
+	dict_entry = NULL;
+	dat_os_lock(&g_dr_lock);
 
-    status = dat_dictionary_search ( g_dr_dictionary,
-				     info,
-				     &data);
+	status = dat_dictionary_search(g_dr_dictionary, info, &data);
 
-    if ( DAT_SUCCESS != status )
-    {
-	/* return status from dat_dictionary_search() */
-	goto bail;
-    }
+	if (DAT_SUCCESS != status) {
+		/* return status from dat_dictionary_search() */
+		goto bail;
+	}
 
-    if ( 0 != ((DAT_DR_ENTRY*)data)->ref_count )
-    {
-	status = DAT_ERROR (DAT_PROVIDER_IN_USE, 0);
-	goto bail;
-    }
+	if (0 != ((DAT_DR_ENTRY *) data)->ref_count) {
+		status = DAT_ERROR(DAT_PROVIDER_IN_USE, 0);
+		goto bail;
+	}
 
-    status = dat_dictionary_remove ( g_dr_dictionary,
-				     &dict_entry,
-				     info,
-				     &data);
-    if ( DAT_SUCCESS != status )
-    {
-	/* return status from dat_dictionary_remove() */
-	goto bail;
-    }
+	status = dat_dictionary_remove(g_dr_dictionary,
+				       &dict_entry, info, &data);
+	if (DAT_SUCCESS != status) {
+		/* return status from dat_dictionary_remove() */
+		goto bail;
+	}
 
-    dat_os_free (data, sizeof (DAT_DR_ENTRY));
+	dat_os_free(data, sizeof(DAT_DR_ENTRY));
 
-bail:
-    dat_os_unlock (&g_dr_lock);
+      bail:
+	dat_os_unlock(&g_dr_lock);
 
-    if ( NULL != dict_entry )
-    {
-	(void) dat_dictionary_entry_destroy (dict_entry);
-    }
+	if (NULL != dict_entry) {
+		(void)dat_dictionary_entry_destroy(dict_entry);
+	}
 
-    return status;
+	return status;
 }
 
-
 //***********************************************************************
 // Function: dat_dr_provider_open
 //***********************************************************************
 
 DAT_RETURN
-dat_dr_provider_open (
-    IN  const DAT_PROVIDER_INFO *info,
-    OUT DAT_IA_OPEN_FUNC	*p_ia_open_func )
+dat_dr_provider_open(IN const DAT_PROVIDER_INFO * info,
+		     OUT DAT_IA_OPEN_FUNC * p_ia_open_func)
 {
-    DAT_RETURN 			status;
-    DAT_DICTIONARY_DATA		data;
+	DAT_RETURN status;
+	DAT_DICTIONARY_DATA data;
 
-    dat_os_lock (&g_dr_lock);
-    status = dat_dictionary_search ( g_dr_dictionary,
-				     info,
-				     &data);
-    dat_os_unlock (&g_dr_lock);
+	dat_os_lock(&g_dr_lock);
+	status = dat_dictionary_search(g_dr_dictionary, info, &data);
+	dat_os_unlock(&g_dr_lock);
 
-    if ( DAT_SUCCESS == status )
-    {
-	((DAT_DR_ENTRY*)data)->ref_count++;
-	*p_ia_open_func = ((DAT_DR_ENTRY*)data)->ia_open_func;
-    }
+	if (DAT_SUCCESS == status) {
+		((DAT_DR_ENTRY *) data)->ref_count++;
+		*p_ia_open_func = ((DAT_DR_ENTRY *) data)->ia_open_func;
+	}
 
-    return status;
+	return status;
 }
 
-
 //***********************************************************************
 // Function: dat_dr_provider_close
 //***********************************************************************
 
-DAT_RETURN
-dat_dr_provider_close (
-    IN  const DAT_PROVIDER_INFO *info )
+DAT_RETURN dat_dr_provider_close(IN const DAT_PROVIDER_INFO * info)
 {
-    DAT_RETURN 			status;
-    DAT_DICTIONARY_DATA		data;
+	DAT_RETURN status;
+	DAT_DICTIONARY_DATA data;
 
-    dat_os_lock (&g_dr_lock);
-    status = dat_dictionary_search ( g_dr_dictionary,
-				     info,
-				     &data);
-    dat_os_unlock (&g_dr_lock);
+	dat_os_lock(&g_dr_lock);
+	status = dat_dictionary_search(g_dr_dictionary, info, &data);
+	dat_os_unlock(&g_dr_lock);
 
-    if ( DAT_SUCCESS == status )
-    {
-	((DAT_DR_ENTRY*)data)->ref_count--;
-    }
+	if (DAT_SUCCESS == status) {
+		((DAT_DR_ENTRY *) data)->ref_count--;
+	}
 
-    return status;
+	return status;
 }
 
-
 //***********************************************************************
 // Function: dat_dr_size
 //***********************************************************************
 
-DAT_RETURN
-dat_dr_size (
-    OUT DAT_COUNT               *size )
+DAT_RETURN dat_dr_size(OUT DAT_COUNT * size)
 {
-    return dat_dictionary_size (g_dr_dictionary, size);
+	return dat_dictionary_size(g_dr_dictionary, size);
 }
 
-
 //***********************************************************************
 // Function: dat_dr_list
 //***********************************************************************
 
 DAT_RETURN
-dat_dr_list (
-    IN  DAT_COUNT               max_to_return,
-    OUT DAT_COUNT               *entries_returned,
-    OUT DAT_PROVIDER_INFO       * (dat_provider_list[]) )
+dat_dr_list(IN DAT_COUNT max_to_return,
+	    OUT DAT_COUNT * entries_returned,
+	    OUT DAT_PROVIDER_INFO * (dat_provider_list[]))
 {
-    DAT_DR_ENTRY 	**array;
-    DAT_COUNT 		array_size;
-    DAT_COUNT 		i;
-    DAT_RETURN 		status;
+	DAT_DR_ENTRY **array;
+	DAT_COUNT array_size;
+	DAT_COUNT i;
+	DAT_RETURN status;
 
-    array = NULL;
-    status = DAT_SUCCESS;
+	array = NULL;
+	status = DAT_SUCCESS;
 
-    /* The dictionary size may increase between the call to      */
-    /* dat_dictionary_size() and dat_dictionary_enumerate().     */
-    /* Therefore we loop until a successful enumeration is made. */
-    *entries_returned = 0;
-    for (;;)
-    {
-	status = dat_dictionary_size (g_dr_dictionary, &array_size);
-	if ( status != DAT_SUCCESS )
-	{
-	    goto bail;
-	}
+	/* The dictionary size may increase between the call to      */
+	/* dat_dictionary_size() and dat_dictionary_enumerate().     */
+	/* Therefore we loop until a successful enumeration is made. */
+	*entries_returned = 0;
+	for (;;) {
+		status = dat_dictionary_size(g_dr_dictionary, &array_size);
+		if (status != DAT_SUCCESS) {
+			goto bail;
+		}
 
-	if (array_size == 0)
-	{
-	    status = DAT_SUCCESS;
-	    goto bail;
-	}
+		if (array_size == 0) {
+			status = DAT_SUCCESS;
+			goto bail;
+		}
 
-	array = dat_os_alloc (array_size * sizeof (DAT_DR_ENTRY *));
-	if ( array == NULL )
-	{
-	    status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	    goto bail;
-	}
+		array = dat_os_alloc(array_size * sizeof(DAT_DR_ENTRY *));
+		if (array == NULL) {
+			status =
+			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				      DAT_RESOURCE_MEMORY);
+			goto bail;
+		}
 
-	dat_os_lock (&g_dr_lock);
+		dat_os_lock(&g_dr_lock);
 
-	status = dat_dictionary_enumerate (g_dr_dictionary,
-					   (DAT_DICTIONARY_DATA *) array,
-					   array_size);
+		status = dat_dictionary_enumerate(g_dr_dictionary,
+						  (DAT_DICTIONARY_DATA *) array,
+						  array_size);
 
-	dat_os_unlock (&g_dr_lock);
+		dat_os_unlock(&g_dr_lock);
 
-	if ( DAT_SUCCESS == status )
-	{
-	    break;
+		if (DAT_SUCCESS == status) {
+			break;
+		} else {
+			dat_os_free(array, array_size * sizeof(DAT_DR_ENTRY *));
+			array = NULL;
+			continue;
+		}
 	}
-	else
-	{
-	    dat_os_free (array, array_size * sizeof (DAT_DR_ENTRY *));
-	    array = NULL;
-	    continue;
-	}
-    }
 
-    for ( i = 0; (i < max_to_return) && (i < array_size); i++)
-    {
-	if ( NULL == dat_provider_list[i] )
-	{
-	    status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	    goto bail;
+	for (i = 0; (i < max_to_return) && (i < array_size); i++) {
+		if (NULL == dat_provider_list[i]) {
+			status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+			goto bail;
+		}
+
+		*dat_provider_list[i] = array[i]->info;
 	}
 
-	*dat_provider_list[i] = array[i]->info;
-    }
+	*entries_returned = i;
 
-    *entries_returned = i;
+      bail:
+	if (NULL != array) {
+		dat_os_free(array, array_size * sizeof(DAT_DR_ENTRY *));
+	}
 
-bail:
-    if ( NULL != array )
-    {
-	dat_os_free (array, array_size * sizeof (DAT_DR_ENTRY *));
-    }
-
-    return status;
+	return status;
 }
 
 /*

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_init.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_init.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_init.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -47,7 +47,6 @@
 #include "dat_sr.h"
 #endif
 
-
 /*********************************************************************
  *                                                                   *
  * Global Variables                                                  *
@@ -83,75 +82,67 @@
  * the state of the DAT registry.
  */
 
-static DAT_MODULE_STATE 	g_module_state = DAT_MODULE_STATE_UNINITIALIZED;
+static DAT_MODULE_STATE g_module_state = DAT_MODULE_STATE_UNINITIALIZED;
 
-
 //***********************************************************************
 // Function: dat_module_get_state
 //***********************************************************************
 
-DAT_MODULE_STATE
-dat_module_get_state ( void )
+DAT_MODULE_STATE dat_module_get_state(void)
 {
-    return g_module_state;
+	return g_module_state;
 }
 
-
 //***********************************************************************
 // Function: dat_init
 //***********************************************************************
 
-void
-dat_init ( void )
+void dat_init(void)
 {
-    if ( DAT_MODULE_STATE_UNINITIALIZED == g_module_state )
-    {
-	/*
-	 * update the module state flag immediately in case there
-	 * is a recursive call to dat_init().
-	 */
-	g_module_state = DAT_MODULE_STATE_INITIALIZING;
+	if (DAT_MODULE_STATE_UNINITIALIZED == g_module_state) {
+		/*
+		 * update the module state flag immediately in case there
+		 * is a recursive call to dat_init().
+		 */
+		g_module_state = DAT_MODULE_STATE_INITIALIZING;
 
-	dat_os_dbg_init ();
+		dat_os_dbg_init();
 
-	dats_handle_vector_init ();
+		dats_handle_vector_init();
 
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_GENERIC,
-			  "DAT Registry: Started (dat_init)\n");
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
+				 "DAT Registry: Started (dat_init)\n");
 
 #ifndef DAT_NO_STATIC_REGISTRY
-	dat_sr_init ();
+		dat_sr_init();
 #endif
-	dat_dr_init ();
+		dat_dr_init();
 
-	g_module_state = DAT_MODULE_STATE_INITIALIZED;
-    }
+		g_module_state = DAT_MODULE_STATE_INITIALIZED;
+	}
 }
 
-
 //***********************************************************************
 // Function: dat_fini
 //***********************************************************************
 
-void
-dat_fini ( void )
+void dat_fini(void)
 {
-    if ( DAT_MODULE_STATE_INITIALIZED == g_module_state )
-    {
-	g_module_state = DAT_MODULE_STATE_DEINITIALIZING;
+	if (DAT_MODULE_STATE_INITIALIZED == g_module_state) {
+		g_module_state = DAT_MODULE_STATE_DEINITIALIZING;
 
-	dat_dr_fini ();
+		dat_dr_fini();
 #ifndef DAT_NO_STATIC_REGISTRY
-	dat_sr_fini ();
+		dat_sr_fini();
 #endif
 
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_GENERIC, "DAT Registry: Stopped (dat_fini)\n");
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
+				 "DAT Registry: Stopped (dat_fini)\n");
 
-	g_module_state = DAT_MODULE_STATE_DEINITIALIZED;
-    }
+		g_module_state = DAT_MODULE_STATE_DEINITIALIZED;
+	}
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_sr.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_sr.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_sr.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -37,463 +37,411 @@
  * $Id: dat_sr.c,v 1.17 2005/03/24 05:58:27 jlentini Exp $
  **********************************************************************/
 
-
 #include "dat_sr.h"
 
 #include "dat_dictionary.h"
 #include "udat_sr_parser.h"
 
-
 /*********************************************************************
  *                                                                   *
  * Global Variables                                                  *
  *                                                                   *
  *********************************************************************/
 
-static DAT_OS_LOCK 		g_sr_lock;
-static DAT_DICTIONARY 		*g_sr_dictionary = NULL;
+static DAT_OS_LOCK g_sr_lock;
+static DAT_DICTIONARY *g_sr_dictionary = NULL;
 
-
 /*********************************************************************
  *                                                                   *
  * External Functions                                                *
  *                                                                   *
  *********************************************************************/
 
-
 //***********************************************************************
 // Function: dat_sr_init
 //***********************************************************************
 
-DAT_RETURN
-dat_sr_init ( void )
+DAT_RETURN dat_sr_init(void)
 {
-    DAT_RETURN 			status;
+	DAT_RETURN status;
 
-    status = dat_os_lock_init (&g_sr_lock);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_os_lock_init(&g_sr_lock);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    status = dat_dictionary_create (&g_sr_dictionary);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_dictionary_create(&g_sr_dictionary);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    /*
-     * Since DAT allows providers to be loaded by either the static
-     * registry or explicitly through OS dependent methods, do not
-     * return an error if no providers are loaded via the static registry.
-     */
+	/*
+	 * Since DAT allows providers to be loaded by either the static
+	 * registry or explicitly through OS dependent methods, do not
+	 * return an error if no providers are loaded via the static registry.
+	 */
 
-    (void) dat_sr_load ();
+	(void)dat_sr_load();
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 //***********************************************************************
 // Function: dat_sr_fini
 //***********************************************************************
 
-extern DAT_RETURN
-dat_sr_fini ( void )
+extern DAT_RETURN dat_sr_fini(void)
 {
-    DAT_RETURN 			status;
+	DAT_RETURN status;
 
-    status = dat_os_lock_destroy (&g_sr_lock);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_os_lock_destroy(&g_sr_lock);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    status = dat_dictionary_destroy (g_sr_dictionary);
-    if ( DAT_SUCCESS != status )
-    {
-	return status;
-    }
+	status = dat_dictionary_destroy(g_sr_dictionary);
+	if (DAT_SUCCESS != status) {
+		return status;
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 //***********************************************************************
 // Function: dat_sr_insert
 //***********************************************************************
 
 extern DAT_RETURN
-dat_sr_insert (
-    IN  const DAT_PROVIDER_INFO *info,
-    IN  DAT_SR_ENTRY 		*entry )
+dat_sr_insert(IN const DAT_PROVIDER_INFO * info, IN DAT_SR_ENTRY * entry)
 {
-    DAT_RETURN 			status;
-    DAT_SR_ENTRY 		*data;
-    DAT_OS_SIZE 		lib_path_size;
-    DAT_OS_SIZE 		lib_path_len;
-    DAT_OS_SIZE 		ia_params_size;
-    DAT_OS_SIZE 		ia_params_len;
-    DAT_DICTIONARY_ENTRY 	dict_entry;
-    DAT_DICTIONARY_DATA		prev_data;
+	DAT_RETURN status;
+	DAT_SR_ENTRY *data;
+	DAT_OS_SIZE lib_path_size;
+	DAT_OS_SIZE lib_path_len;
+	DAT_OS_SIZE ia_params_size;
+	DAT_OS_SIZE ia_params_len;
+	DAT_DICTIONARY_ENTRY dict_entry;
+	DAT_DICTIONARY_DATA prev_data;
 
-    if ( NULL == (data = dat_os_alloc (sizeof (DAT_SR_ENTRY))) )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == (data = dat_os_alloc(sizeof(DAT_SR_ENTRY)))) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_os_memset (data, '\0', sizeof (DAT_SR_ENTRY));
+	dat_os_memset(data, '\0', sizeof(DAT_SR_ENTRY));
 
-    lib_path_len = strlen (entry->lib_path);
-    lib_path_size = (lib_path_len + 1) * sizeof (char);
+	lib_path_len = strlen(entry->lib_path);
+	lib_path_size = (lib_path_len + 1) * sizeof(char);
 
-    if ( NULL == (data->lib_path = dat_os_alloc (lib_path_size)) )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == (data->lib_path = dat_os_alloc(lib_path_size))) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_os_strncpy (data->lib_path, entry->lib_path, lib_path_len);
-    data->lib_path[lib_path_len] = '\0';
+	dat_os_strncpy(data->lib_path, entry->lib_path, lib_path_len);
+	data->lib_path[lib_path_len] = '\0';
 
-    ia_params_len = strlen (entry->ia_params);
-    ia_params_size = (ia_params_len + 1) * sizeof (char);
+	ia_params_len = strlen(entry->ia_params);
+	ia_params_size = (ia_params_len + 1) * sizeof(char);
 
-    if ( NULL == (data->ia_params = dat_os_alloc (ia_params_size)) )
-    {
-	status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	goto bail;
-    }
+	if (NULL == (data->ia_params = dat_os_alloc(ia_params_size))) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto bail;
+	}
 
-    dat_os_strncpy (data->ia_params, entry->ia_params, ia_params_len);
-    data->ia_params[ia_params_len] = '\0';
+	dat_os_strncpy(data->ia_params, entry->ia_params, ia_params_len);
+	data->ia_params[ia_params_len] = '\0';
 
-    data->info = entry->info;
-    data->lib_handle = entry->lib_handle;
-    data->ref_count = entry->ref_count;
-    data->next = NULL;
+	data->info = entry->info;
+	data->lib_handle = entry->lib_handle;
+	data->ref_count = entry->ref_count;
+	data->next = NULL;
 
-    dict_entry = NULL;
-    status = dat_dictionary_entry_create (&dict_entry);
-    if ( DAT_SUCCESS != status )
-    {
-	goto bail;
-    }
+	dict_entry = NULL;
+	status = dat_dictionary_entry_create(&dict_entry);
+	if (DAT_SUCCESS != status) {
+		goto bail;
+	}
 
-    dat_os_lock (&g_sr_lock);
+	dat_os_lock(&g_sr_lock);
 
-    status = dat_dictionary_search (g_sr_dictionary,
-				    info,
-				    &prev_data);
-    if ( DAT_SUCCESS == status )
-    {
-	/* We already have a dictionary entry, so we don't need a new one.
-	 * This means there are multiple duplicate names in dat.conf,
-	 * but presumably they have different paths. Simply link the
-	 * new entry at the end of the chain of like-named entries.
-	 */
-	(void) dat_dictionary_entry_destroy (dict_entry);
-	dict_entry = NULL;
+	status = dat_dictionary_search(g_sr_dictionary, info, &prev_data);
+	if (DAT_SUCCESS == status) {
+		/* We already have a dictionary entry, so we don't need a new one.
+		 * This means there are multiple duplicate names in dat.conf,
+		 * but presumably they have different paths. Simply link the
+		 * new entry at the end of the chain of like-named entries.
+		 */
+		(void)dat_dictionary_entry_destroy(dict_entry);
+		dict_entry = NULL;
 
-	/* Find the next available slot in this chain */
-	while (NULL != ((DAT_SR_ENTRY*)prev_data)->next)
-	{
-	    prev_data = ((DAT_SR_ENTRY*)prev_data)->next;
+		/* Find the next available slot in this chain */
+		while (NULL != ((DAT_SR_ENTRY *) prev_data)->next) {
+			prev_data = ((DAT_SR_ENTRY *) prev_data)->next;
+		}
+		dat_os_assert(NULL != prev_data);
+		((DAT_SR_ENTRY *) prev_data)->next = data;
+	} else {
+		status = dat_dictionary_insert(g_sr_dictionary,
+					       dict_entry,
+					       info,
+					       (DAT_DICTIONARY_DATA *) data);
 	}
-	dat_os_assert (NULL != prev_data);
-	((DAT_SR_ENTRY*)prev_data)->next = data;
-    }
-    else
-    {
-	status = dat_dictionary_insert (g_sr_dictionary,
-				    dict_entry,
-				    info,
-				    (DAT_DICTIONARY_DATA *) data);
-    }
 
-    dat_os_unlock (&g_sr_lock);
+	dat_os_unlock(&g_sr_lock);
 
-bail:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != data )
-	{
-	    if ( NULL != data->lib_path )
-	    {
-		dat_os_free (data->lib_path, lib_path_size);
-	    }
+      bail:
+	if (DAT_SUCCESS != status) {
+		if (NULL != data) {
+			if (NULL != data->lib_path) {
+				dat_os_free(data->lib_path, lib_path_size);
+			}
 
-	    if ( NULL != data->ia_params )
-	    {
-		dat_os_free (data->ia_params, ia_params_size);
-	    }
+			if (NULL != data->ia_params) {
+				dat_os_free(data->ia_params, ia_params_size);
+			}
 
-	    dat_os_free (data, sizeof (DAT_SR_ENTRY));
-	}
+			dat_os_free(data, sizeof(DAT_SR_ENTRY));
+		}
 
-	if ( NULL != dict_entry )
-	{
-	    (void) dat_dictionary_entry_destroy (dict_entry);
+		if (NULL != dict_entry) {
+			(void)dat_dictionary_entry_destroy(dict_entry);
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
 //***********************************************************************
 // Function: dat_sr_size
 //***********************************************************************
 
-extern DAT_RETURN
-dat_sr_size (
-    OUT DAT_COUNT               *size )
+extern DAT_RETURN dat_sr_size(OUT DAT_COUNT * size)
 {
-    return dat_dictionary_size (g_sr_dictionary, size);
+	return dat_dictionary_size(g_sr_dictionary, size);
 }
 
-
 //***********************************************************************
 // Function: dat_sr_list
 //***********************************************************************
 
 extern DAT_RETURN
-dat_sr_list (
-    IN  DAT_COUNT               max_to_return,
-    OUT DAT_COUNT               *entries_returned,
-    OUT DAT_PROVIDER_INFO       * (dat_provider_list[]) )
+dat_sr_list(IN DAT_COUNT max_to_return,
+	    OUT DAT_COUNT * entries_returned,
+	    OUT DAT_PROVIDER_INFO * (dat_provider_list[]))
 {
-    DAT_SR_ENTRY	**array;
-    DAT_COUNT 		array_size;
-    DAT_COUNT 		i;
-    DAT_RETURN 		status;
+	DAT_SR_ENTRY **array;
+	DAT_COUNT array_size;
+	DAT_COUNT i;
+	DAT_RETURN status;
 
-    array = NULL;
-    status = DAT_SUCCESS;
+	array = NULL;
+	status = DAT_SUCCESS;
 
-    /* The dictionary size may increase between the call to      */
-    /* dat_dictionary_size() and dat_dictionary_enumerate().     */
-    /* Therefore we loop until a successful enumeration is made. */
-    *entries_returned = 0;
-    for (;;)
-    {
-	status = dat_dictionary_size (g_sr_dictionary, &array_size);
-	if ( DAT_SUCCESS != status )
-	{
-	    goto bail;
-	}
+	/* The dictionary size may increase between the call to      */
+	/* dat_dictionary_size() and dat_dictionary_enumerate().     */
+	/* Therefore we loop until a successful enumeration is made. */
+	*entries_returned = 0;
+	for (;;) {
+		status = dat_dictionary_size(g_sr_dictionary, &array_size);
+		if (DAT_SUCCESS != status) {
+			goto bail;
+		}
 
-	if (array_size == 0)
-	{
-	    status = DAT_SUCCESS;
-	    goto bail;
-	}
+		if (array_size == 0) {
+			status = DAT_SUCCESS;
+			goto bail;
+		}
 
-	array = dat_os_alloc (array_size * sizeof (DAT_SR_ENTRY *));
-	if ( array == NULL )
-	{
-	    status = DAT_ERROR (DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-	    goto bail;
-	}
+		array = dat_os_alloc(array_size * sizeof(DAT_SR_ENTRY *));
+		if (array == NULL) {
+			status =
+			    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				      DAT_RESOURCE_MEMORY);
+			goto bail;
+		}
 
-	dat_os_lock (&g_sr_lock);
+		dat_os_lock(&g_sr_lock);
 
-	status = dat_dictionary_enumerate (g_sr_dictionary,
-					   (DAT_DICTIONARY_DATA *) array,
-					   array_size);
+		status = dat_dictionary_enumerate(g_sr_dictionary,
+						  (DAT_DICTIONARY_DATA *) array,
+						  array_size);
 
-	dat_os_unlock (&g_sr_lock);
+		dat_os_unlock(&g_sr_lock);
 
-	if ( DAT_SUCCESS == status )
-	{
-	    break;
+		if (DAT_SUCCESS == status) {
+			break;
+		} else {
+			dat_os_free(array, array_size * sizeof(DAT_SR_ENTRY *));
+			array = NULL;
+			continue;
+		}
 	}
-	else
-	{
-	    dat_os_free (array, array_size * sizeof (DAT_SR_ENTRY *));
-	    array = NULL;
-	    continue;
-	}
-    }
 
-    for ( i = 0; (i < max_to_return) && (i < array_size); i++)
-    {
-	if ( NULL == dat_provider_list[i] )
-	{
-	    status = DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-	    goto bail;
+	for (i = 0; (i < max_to_return) && (i < array_size); i++) {
+		if (NULL == dat_provider_list[i]) {
+			status =
+			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+			goto bail;
+		}
+
+		*dat_provider_list[i] = array[i]->info;
 	}
 
-	*dat_provider_list[i] = array[i]->info;
-    }
+	*entries_returned = i;
 
-    *entries_returned = i;
+      bail:
+	if (NULL != array) {
+		dat_os_free(array, array_size * sizeof(DAT_SR_ENTRY *));
+	}
 
-bail:
-    if ( NULL != array )
-    {
-	dat_os_free (array, array_size * sizeof (DAT_SR_ENTRY *));
-    }
-
-    return status;
+	return status;
 }
 
-
-
 //***********************************************************************
 // Function: dat_sr_provider_open
 //***********************************************************************
 
-extern DAT_RETURN
-dat_sr_provider_open (
-    IN  const DAT_PROVIDER_INFO *info )
+extern DAT_RETURN dat_sr_provider_open(IN const DAT_PROVIDER_INFO * info)
 {
-    DAT_RETURN 			status;
-    DAT_SR_ENTRY 		*data;
-    DAT_DICTIONARY_DATA		dict_data;
+	DAT_RETURN status;
+	DAT_SR_ENTRY *data;
+	DAT_DICTIONARY_DATA dict_data;
 
-    dat_os_lock (&g_sr_lock);
+	dat_os_lock(&g_sr_lock);
 
-    status = dat_dictionary_search (g_sr_dictionary,
-				    info,
-				    &dict_data);
+	status = dat_dictionary_search(g_sr_dictionary, info, &dict_data);
 
-    if ( DAT_SUCCESS == status )
-    {
-	data = (DAT_SR_ENTRY*)dict_data;
-	while (data != NULL)
-	{
-	    if ( 0 == data->ref_count )
-	    {
-		/*
-		 * Try to open the path. If it fails, try the next
-		 * path in the chain. Only the first successful library
-		 * open matters, the others will be unused.
-		 */
-		dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-			"DAT Registry: IA %s, trying to load library %s\n",
-			data->info.ia_name, data->lib_path);
+	if (DAT_SUCCESS == status) {
+		data = (DAT_SR_ENTRY *) dict_data;
+		while (data != NULL) {
+			if (0 == data->ref_count) {
+				/*
+				 * Try to open the path. If it fails, try the next
+				 * path in the chain. Only the first successful library
+				 * open matters, the others will be unused.
+				 */
+				dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+						 "DAT Registry: IA %s, trying to load library %s\n",
+						 data->info.ia_name,
+						 data->lib_path);
 
-		status = dat_os_library_load (data->lib_path,
-					      &data->lib_handle);
+				status = dat_os_library_load(data->lib_path,
+							     &data->lib_handle);
 
-		if ( status == DAT_SUCCESS )
-		{
+				if (status == DAT_SUCCESS) {
 #ifdef DAT_DBG
-		    dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-			"DAT2 Registry: IA %s, loaded library %s\n",
-				  data->info.ia_name, data->lib_path);
+					dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+							 "DAT2 Registry: IA %s, loaded library %s\n",
+							 data->info.ia_name,
+							 data->lib_path);
 #endif
-		    data->ref_count++;
-		    data->init_func = dat_os_library_sym (data->lib_handle,
-						  DAT_PROVIDER_INIT_FUNC_STR);
-		    data->fini_func = dat_os_library_sym (data->lib_handle,
-						  DAT_PROVIDER_FINI_FUNC_STR);
-                    /* Warning: DAT and DAPL libraries not ext compatible */
+					data->ref_count++;
+					data->init_func =
+					    dat_os_library_sym(data->lib_handle,
+							       DAT_PROVIDER_INIT_FUNC_STR);
+					data->fini_func =
+					    dat_os_library_sym(data->lib_handle,
+							       DAT_PROVIDER_FINI_FUNC_STR);
+					/* Warning: DAT and DAPL libraries not ext compatible */
 #ifdef DAT_EXTENSIONS
-{
-		    void *fncptr;
+					{
+						void *fncptr;
 
-		    fncptr = dat_os_library_sym(data->lib_handle,
-                                                "dapl_extensions");
+						fncptr =
+						    dat_os_library_sym(data->
+								       lib_handle,
+								       "dapl_extensions");
 
-                    if ((dat_os_library_error() != NULL) || (fncptr == NULL)) 
-		    {
-                            dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
-				  "DAT Registry: WARNING: library %s, "
-				  "extended DAT expected extended uDAPL: %s\n",
-                                  data->lib_path, strerror(errno));
-                    }
-}
+						if ((dat_os_library_error() !=
+						     NULL)
+						    || (fncptr == NULL)) {
+							dat_os_dbg_print
+							    (DAT_OS_DBG_TYPE_SR,
+							     "DAT Registry: WARNING: library %s, "
+							     "extended DAT expected extended uDAPL: %s\n",
+							     data->lib_path,
+							     strerror(errno));
+						}
+					}
 #endif
-		    if ( NULL != data->init_func )
-		    {
-			(*data->init_func) (&data->info, data->ia_params);
-		    }
-		    else
-		    {
-			dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-			   "DAT Registry: Cannot find library init func (%s)\n",
-			   DAT_PROVIDER_INIT_FUNC_STR);
-		    }
+					if (NULL != data->init_func) {
+						(*data->init_func) (&data->info,
+								    data->
+								    ia_params);
+					} else {
+						dat_os_dbg_print
+						    (DAT_OS_DBG_TYPE_SR,
+						     "DAT Registry: Cannot find library init func (%s)\n",
+						     DAT_PROVIDER_INIT_FUNC_STR);
+					}
 
-		    /* exit after we find the first valid entry */
-		    break;
+					/* exit after we find the first valid entry */
+					break;
+				} else {
+					dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+							 "DAT Registry: static registry unable to "
+							 "load library %s\n",
+							 data->lib_path);
+				}
+			} else {
+				data->ref_count++;
+				break;
+			}
+			data = data->next;
 		}
-		else
-		{
-		    dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-				      "DAT Registry: static registry unable to "
-				      "load library %s\n", data->lib_path);
-		}
-	    }
-	    else
-	    {
-		data->ref_count++;
-		break;
-	    }
-	    data = data->next;
 	}
-    }
 
-    dat_os_unlock (&g_sr_lock);
+	dat_os_unlock(&g_sr_lock);
 
-    return status;
+	return status;
 }
 
-
 //***********************************************************************
 // Function: dat_sr_provider_close
 //***********************************************************************
 
-extern DAT_RETURN
-dat_sr_provider_close (
-    IN  const DAT_PROVIDER_INFO *info )
+extern DAT_RETURN dat_sr_provider_close(IN const DAT_PROVIDER_INFO * info)
 {
-    DAT_RETURN 			status;
-    DAT_SR_ENTRY 		*data;
-    DAT_DICTIONARY_DATA		dict_data;
+	DAT_RETURN status;
+	DAT_SR_ENTRY *data;
+	DAT_DICTIONARY_DATA dict_data;
 
-    dat_os_lock (&g_sr_lock);
+	dat_os_lock(&g_sr_lock);
 
-    status = dat_dictionary_search (g_sr_dictionary,
-				    info,
-				    &dict_data);
+	status = dat_dictionary_search(g_sr_dictionary, info, &dict_data);
 
-    if ( DAT_SUCCESS == status )
-    {
-	data = (DAT_SR_ENTRY*)dict_data;
-	while (data != NULL)
-	{
-	    if ( 1 == data->ref_count )
-	    {
-		dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-				  "DAT Registry: IA %s, unloading library %s\n",
-				  data->info.ia_name, data->lib_path);
+	if (DAT_SUCCESS == status) {
+		data = (DAT_SR_ENTRY *) dict_data;
+		while (data != NULL) {
+			if (1 == data->ref_count) {
+				dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+						 "DAT Registry: IA %s, unloading library %s\n",
+						 data->info.ia_name,
+						 data->lib_path);
 
-		if ( NULL != data->fini_func )
-		{
-		    (*data->fini_func) (&data->info);
-		}
+				if (NULL != data->fini_func) {
+					(*data->fini_func) (&data->info);
+				}
 
-		status = dat_os_library_unload (data->lib_handle);
-		if ( status == DAT_SUCCESS )
-		{
-		    data->ref_count--;
+				status =
+				    dat_os_library_unload(data->lib_handle);
+				if (status == DAT_SUCCESS) {
+					data->ref_count--;
+				}
+				break;
+			} else if (data->ref_count > 0) {
+				data->ref_count--;
+				break;
+			}
+			data = data->next;
 		}
-		break;
-	    }
-	    else if ( data->ref_count > 0)
-	    {
-		data->ref_count--;
-		break;
-	    }
-	    data = data->next;
 	}
-    }
 
-    dat_os_unlock (&g_sr_lock);
+	dat_os_unlock(&g_sr_lock);
 
-    return status;
+	return status;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_strerror.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_strerror.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/common/dat_strerror.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -41,7 +41,7 @@
 #include <dat2/kdat.h>
 #else /*__UDAPL__*/
 #include <dat2/udat.h>
-#endif	/* __UDAPL__ */
+#endif				/* __UDAPL__ */
 
 /*********************************************************************
  *                                                                   *
@@ -50,16 +50,11 @@
  *********************************************************************/
 
 static DAT_RETURN
-dat_strerror_major (
-    IN  DAT_RETURN 		value,
-    OUT const char 		**message );
+dat_strerror_major(IN DAT_RETURN value, OUT const char **message);
 
 static DAT_RETURN
-dat_strerror_minor (
-    IN  DAT_RETURN 		value,
-    OUT const char 		**message );
+dat_strerror_minor(IN DAT_RETURN value, OUT const char **message);
 
-
 /*********************************************************************
  *                                                                   *
  * Internal Function Definitions                                     *
@@ -67,533 +62,525 @@
  *********************************************************************/
 
 static DAT_RETURN
-dat_strerror_major (
-    IN  DAT_RETURN 		value,
-    OUT const char 		**message )
+dat_strerror_major(IN DAT_RETURN value, OUT const char **message)
 {
-    switch ( DAT_GET_TYPE (value) )
-    {
+	switch (DAT_GET_TYPE(value)) {
 	case DAT_SUCCESS:
-	{
-	    *message = "DAT_SUCCESS";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_SUCCESS";
+			return DAT_SUCCESS;
+		}
 	case DAT_ABORT:
-	{
-	    *message = "DAT_ABORT";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_ABORT";
+			return DAT_SUCCESS;
+		}
 	case DAT_CONN_QUAL_IN_USE:
-	{
-	    *message = "DAT_CONN_QUAL_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_CONN_QUAL_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INSUFFICIENT_RESOURCES:
-	{
-	    *message = "DAT_INSUFFICIENT_RESOURCES";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INSUFFICIENT_RESOURCES";
+			return DAT_SUCCESS;
+		}
 	case DAT_INTERNAL_ERROR:
-	{
-	    *message = "DAT_INTERNAL_ERROR";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INTERNAL_ERROR";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE:
-	{
-	    *message = "DAT_INVALID_HANDLE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_PARAMETER:
-	{
-	    *message = "DAT_INVALID_PARAMETER";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_PARAMETER";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE:
-	{
-	    *message = "DAT_INVALID_STATE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE";
+			return DAT_SUCCESS;
+		}
 	case DAT_LENGTH_ERROR:
-	{
-	    *message = "DAT_LENGTH_ERROR";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_LENGTH_ERROR";
+			return DAT_SUCCESS;
+		}
 	case DAT_MODEL_NOT_SUPPORTED:
-	{
-	    *message = "DAT_MODEL_NOT_SUPPORTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_MODEL_NOT_SUPPORTED";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROVIDER_NOT_FOUND:
-	{
-	    *message = "DAT_PROVIDER_NOT_FOUND";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROVIDER_NOT_FOUND";
+			return DAT_SUCCESS;
+		}
 	case DAT_PRIVILEGES_VIOLATION:
-	{
-	    *message = "DAT_PRIVILEGES_VIOLATION";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PRIVILEGES_VIOLATION";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROTECTION_VIOLATION:
-	{
-	    *message = "DAT_PROTECTION_VIOLATION";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROTECTION_VIOLATION";
+			return DAT_SUCCESS;
+		}
 	case DAT_QUEUE_EMPTY:
-	{
-	    *message = "DAT_QUEUE_EMPTY";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_QUEUE_EMPTY";
+			return DAT_SUCCESS;
+		}
 	case DAT_QUEUE_FULL:
-	{
-	    *message = "DAT_QUEUE_FULL";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_QUEUE_FULL";
+			return DAT_SUCCESS;
+		}
 	case DAT_TIMEOUT_EXPIRED:
-	{
-	    *message = "DAT_TIMEOUT_EXPIRED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_TIMEOUT_EXPIRED";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROVIDER_ALREADY_REGISTERED:
-	{
-	    *message = "DAT_PROVIDER_ALREADY_REGISTERED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROVIDER_ALREADY_REGISTERED";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROVIDER_IN_USE:
-	{
-	    *message = "DAT_PROVIDER_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROVIDER_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ADDRESS:
-	{
-	    *message = "DAT_INVALID_ADDRESS";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ADDRESS";
+			return DAT_SUCCESS;
+		}
 	case DAT_INTERRUPTED_CALL:
-	{
-	    *message = "DAT_INTERRUPTED_CALL";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INTERRUPTED_CALL";
+			return DAT_SUCCESS;
+		}
 	case DAT_NOT_IMPLEMENTED:
-	{
-	    *message = "DAT_NOT_IMPLEMENTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_NOT_IMPLEMENTED";
+			return DAT_SUCCESS;
+		}
 	default:
-	{
-	    *message = "unknown error";
-	    return DAT_INVALID_PARAMETER;
+		{
+			*message = "unknown error";
+			return DAT_INVALID_PARAMETER;
+		}
 	}
-    }
 }
 
-
 static DAT_RETURN
-dat_strerror_minor (
-    IN  DAT_RETURN 		value,
-    OUT const char 		**message )
+dat_strerror_minor(IN DAT_RETURN value, OUT const char **message)
 {
-    switch ( DAT_GET_SUBTYPE (value) )
-    {
+	switch (DAT_GET_SUBTYPE(value)) {
 
-	case DAT_NO_SUBTYPE:				    /* NO subtype */
-	{
-	    *message = "";
-	    return DAT_SUCCESS;
-	}
+	case DAT_NO_SUBTYPE:	/* NO subtype */
+		{
+			*message = "";
+			return DAT_SUCCESS;
+		}
 	case DAT_SUB_INTERRUPTED:
-	{
-	    *message = "DAT_SUB_INTERRUPTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_SUB_INTERRUPTED";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_MEMORY:
-	{
-	    *message = "DAT_RESOURCE_MEMORY";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_MEMORY";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_DEVICE:
-	{
-	    *message = "DAT_RESOURCE_DEVICE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_DEVICE";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_TEP:
-	{
-	    *message = "DAT_RESOURCE_TEP";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_TEP";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_TEVD:
-	{
-	    *message = "DAT_RESOURCE_TEVD";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_TEVD";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_PROTECTION_DOMAIN:
-	{
-	    *message = "DAT_RESOURCE_PROTECTION_DOMAIN";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_PROTECTION_DOMAIN";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_MEMORY_REGION:
-	{
-	    *message = "DAT_RESOURCE_MEMORY_REGION";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_MEMORY_REGION";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_ERROR_HANDLER:
-	{
-	    *message = "DAT_RESOURCE_ERROR_HANDLER";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_ERROR_HANDLER";
+			return DAT_SUCCESS;
+		}
 	case DAT_RESOURCE_CREDITS:
-	{
-	    *message = "DAT_RESOURCE_CREDITS";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_RESOURCE_CREDITS";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_IA:
-	{
-	    *message = "DAT_INVALID_HANDLE_IA";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_IA";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_EP:
-	{
-	    *message = "DAT_INVALID_HANDLE_EP";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_EP";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_LMR:
-	{
-	    *message = "DAT_INVALID_HANDLE_LMR";
-	    return DAT_SUCCESS;
-	}
-	case  DAT_INVALID_HANDLE_RMR:
-	{
-	    *message = "DAT_INVALID_HANDLE_RMR";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_LMR";
+			return DAT_SUCCESS;
+		}
+	case DAT_INVALID_HANDLE_RMR:
+		{
+			*message = "DAT_INVALID_HANDLE_RMR";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_PZ:
-	{
-	    *message = "DAT_INVALID_HANDLE_PZ";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_PZ";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_PSP:
-	{
-	    *message = "DAT_INVALID_HANDLE_PSP";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_PSP";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_RSP:
-	{
-	    *message = "DAT_INVALID_HANDLE_RSP";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_RSP";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_CR:
-	{
-	    *message = "DAT_INVALID_HANDLE_CR";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_CR";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_CNO:
-	{
-	    *message = "DAT_INVALID_HANDLE_CNO";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_CNO";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_EVD_CR:
-	{
-	    *message = "DAT_INVALID_HANDLE_EVD_CR";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_EVD_CR";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_EVD_REQUEST:
-	{
-	    *message = "DAT_INVALID_HANDLE_EVD_REQUEST";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_EVD_REQUEST";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_EVD_RECV:
-	{
-	    *message = "DAT_INVALID_HANDLE_EVD_RECV";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_EVD_RECV";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_EVD_CONN:
-	{
-	    *message = "DAT_INVALID_HANDLE_EVD_CONN";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_EVD_CONN";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_HANDLE_EVD_ASYNC:
-	{
-	    *message = "DAT_INVALID_HANDLE_EVD_ASYNC";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_HANDLE_EVD_ASYNC";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG1:
-	{
-	    *message = "DAT_INVALID_ARG1";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG1";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG2:
-	{
-	    *message = "DAT_INVALID_ARG2";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG2";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG3:
-	{
-	    *message = "DAT_INVALID_ARG3";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG3";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG4:
-	{
-	    *message = "DAT_INVALID_ARG4";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG4";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG5:
-	{
-	    *message = "DAT_INVALID_ARG5";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG5";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG6:
-	{
-	    *message = "DAT_INVALID_ARG6";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG6";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG7:
-	{
-	    *message = "DAT_INVALID_ARG7";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG7";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG8:
-	{
-	    *message = "DAT_INVALID_ARG8";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG8";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG9:
-	{
-	    *message = "DAT_INVALID_ARG9";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG9";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ARG10:
-	{
-	    *message = "DAT_INVALID_ARG10";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ARG10";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_UNCONNECTED:
-	{
-	    *message = "DAT_INVALID_STATE_EP_UNCONNECTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_UNCONNECTED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_ACTCONNPENDING:
-	{
-	    *message = "DAT_INVALID_STATE_EP_ACTCONNPENDING";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_ACTCONNPENDING";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_PASSCONNPENDING:
-	{
-	    *message = "DAT_INVALID_STATE_EP_PASSCONNPENDING";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_PASSCONNPENDING";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_TENTCONNPENDING:
-	{
-	    *message = "DAT_INVALID_STATE_EP_TENTCONNPENDING";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_TENTCONNPENDING";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_CONNECTED:
-	{
-	    *message = "DAT_INVALID_STATE_EP_CONNECTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_CONNECTED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_DISCONNECTED:
-	{
-	    *message = "DAT_INVALID_STATE_EP_DISCONNECTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_DISCONNECTED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_RESERVED:
-	{
-	    *message = "DAT_INVALID_STATE_EP_RESERVED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_RESERVED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_COMPLPENDING:
-	{
-	    *message = "DAT_INVALID_STATE_EP_COMPLPENDING";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_COMPLPENDING";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_DISCPENDING:
-	{
-	    *message = "DAT_INVALID_STATE_EP_DISCPENDING";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_DISCPENDING";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_PROVIDERCONTROL:
-	{
-	    *message = "DAT_INVALID_STATE_EP_PROVIDERCONTROL";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_PROVIDERCONTROL";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EP_NOTREADY:
-	{
-	    *message = "DAT_INVALID_STATE_EP_NOTREADY";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EP_NOTREADY";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_CNO_IN_USE:
-	{
-	    *message = "DAT_INVALID_STATE_CNO_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_CNO_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_CNO_DEAD:
-	{
-	    *message = "DAT_INVALID_STATE_CNO_DEAD";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_CNO_DEAD";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_OPEN:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_OPEN";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_OPEN";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_ENABLED:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_ENABLED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_ENABLED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_DISABLED:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_DISABLED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_DISABLED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_WAITABLE:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_WAITABLE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_WAITABLE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_UNWAITABLE:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_UNWAITABLE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_UNWAITABLE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_IN_USE:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_CONFIG_NOTIFY:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_CONFIG_NOTIFY";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_CONFIG_NOTIFY";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_CONFIG_SOLICITED:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_CONFIG_SOLICITED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_CONFIG_SOLICITED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_CONFIG_THRESHOLD";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_WAITER:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_WAITER";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_WAITER";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_EVD_ASYNC:
-	{
-	    *message = "DAT_INVALID_STATE_EVD_ASYNC";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_EVD_ASYNC";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_IA_IN_USE:
-	{
-	    *message = "DAT_INVALID_STATE_IA_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_IA_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_LMR_IN_USE:
-	{
-	    *message = "DAT_INVALID_STATE_LMR_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_LMR_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_LMR_FREE:
-	{
-	    *message = "DAT_INVALID_STATE_LMR_FREE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_LMR_FREE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_PZ_IN_USE:
-	{
-	    *message = "DAT_INVALID_STATE_PZ_IN_USE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_PZ_IN_USE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_STATE_PZ_FREE:
-	{
-	    *message = "DAT_INVALID_STATE_PZ_FREE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_STATE_PZ_FREE";
+			return DAT_SUCCESS;
+		}
 	case DAT_PRIVILEGES_READ:
-	{
-	    *message = "DAT_PRIVILEGES_READ";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PRIVILEGES_READ";
+			return DAT_SUCCESS;
+		}
 	case DAT_PRIVILEGES_WRITE:
-	{
-	    *message = "DAT_PRIVILEGES_WRITE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PRIVILEGES_WRITE";
+			return DAT_SUCCESS;
+		}
 	case DAT_PRIVILEGES_RDMA_READ:
-	{
-	    *message = "DAT_PRIVILEGES_RDMA_READ";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PRIVILEGES_RDMA_READ";
+			return DAT_SUCCESS;
+		}
 	case DAT_PRIVILEGES_RDMA_WRITE:
-	{
-	    *message = "DAT_PRIVILEGES_RDMA_WRITE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PRIVILEGES_RDMA_WRITE";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROTECTION_READ:
-	{
-	    *message = "DAT_PROTECTION_READ";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROTECTION_READ";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROTECTION_WRITE:
-	{
-	    *message = "DAT_PROTECTION_WRITE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROTECTION_WRITE";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROTECTION_RDMA_READ:
-	{
-	    *message = "DAT_PROTECTION_RDMA_READ";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROTECTION_RDMA_READ";
+			return DAT_SUCCESS;
+		}
 	case DAT_PROTECTION_RDMA_WRITE:
-	{
-	    *message = "DAT_PROTECTION_RDMA_WRITE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_PROTECTION_RDMA_WRITE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ADDRESS_UNSUPPORTED:
-	{
-	    *message = "DAT_INVALID_ADDRESS_UNSUPPORTED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ADDRESS_UNSUPPORTED";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ADDRESS_UNREACHABLE:
-	{
-	    *message = "DAT_INVALID_ADDRESS_UNREACHABLE";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ADDRESS_UNREACHABLE";
+			return DAT_SUCCESS;
+		}
 	case DAT_INVALID_ADDRESS_MALFORMED:
-	{
-	    *message = "DAT_INVALID_ADDRESS_MALFORMED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_INVALID_ADDRESS_MALFORMED";
+			return DAT_SUCCESS;
+		}
 	case DAT_NAME_NOT_REGISTERED:
-	{
-	    *message = "DAT_NAME_NOT_REGISTERED";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_NAME_NOT_REGISTERED";
+			return DAT_SUCCESS;
+		}
 	case DAT_MAJOR_NOT_FOUND:
-	{
-	    *message = "DAT_MAJOR_NOT_FOUND";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_MAJOR_NOT_FOUND";
+			return DAT_SUCCESS;
+		}
 	case DAT_MINOR_NOT_FOUND:
-	{
-	    *message = "DAT_MINOR_NOT_FOUND";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_MINOR_NOT_FOUND";
+			return DAT_SUCCESS;
+		}
 	case DAT_THREAD_SAFETY_NOT_FOUND:
-	{
-	    *message = "DAT_THREAD_SAFETY_NOT_FOUND";
-	    return DAT_SUCCESS;
-	}
+		{
+			*message = "DAT_THREAD_SAFETY_NOT_FOUND";
+			return DAT_SUCCESS;
+		}
 	default:
-	{
-	    *message = "unknown minor error";
-	    return DAT_INVALID_PARAMETER;
+		{
+			*message = "unknown minor error";
+			return DAT_INVALID_PARAMETER;
+		}
 	}
-    }
 }
 
-
 /*********************************************************************
  *                                                                   *
  * External Function Definitions                                     *
@@ -601,30 +588,24 @@
  *********************************************************************/
 
 DAT_RETURN DAT_API
-dat_strerror (
-    IN  DAT_RETURN 		value,
-    OUT const char 		**major_message,
-    OUT const char 		**minor_message )
+dat_strerror(IN DAT_RETURN value,
+	     OUT const char **major_message, OUT const char **minor_message)
 {
-    /*
-     * The DAT specification contains a note to implementers
-     * suggesting that the consumer's DAT_RETURN value be used
-     * as an index into a table of text strings. However,
-     * the DAT_RETURN values are not consecutive. Therefore this
-     * implementation does not follow the suggested implementation.
-     */
+	/*
+	 * The DAT specification contains a note to implementers
+	 * suggesting that the consumer's DAT_RETURN value be used
+	 * as an index into a table of text strings. However,
+	 * the DAT_RETURN values are not consecutive. Therefore this
+	 * implementation does not follow the suggested implementation.
+	 */
 
-    if ( DAT_SUCCESS != dat_strerror_major (value, major_message) )
-    {
-	return DAT_INVALID_PARAMETER;
-    }
-    else if (minor_message != NULL)
-    {
-	if ( DAT_SUCCESS != dat_strerror_minor (value, minor_message) )
-	{
-	    return DAT_INVALID_PARAMETER;
+	if (DAT_SUCCESS != dat_strerror_major(value, major_message)) {
+		return DAT_INVALID_PARAMETER;
+	} else if (minor_message != NULL) {
+		if (DAT_SUCCESS != dat_strerror_minor(value, minor_message)) {
+			return DAT_INVALID_PARAMETER;
+		}
 	}
-    }
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/include/dat2/dat_ib_extensions.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/include/dat2/dat_ib_extensions.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/include/dat2/dat_ib_extensions.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -58,7 +58,21 @@
  *	DAT_NAMED_ATTR	name == extended operations and version, 
  *			version_value = version number of extension API
  */
-#define DAT_IB_EXTENSION_VERSION	202	/* 2.0.2 */
+
+/* 2.0.1 - Initial IB extension support, atomic and immed data
+ *         dat_ib_post_fetch_and_add()
+ *         dat_ib_post_cmp_and_swap()
+ *         dat_ib_post_rdma_write_immed()
+ *		
+ * 2.0.2 - Add UD support, post send and remote_ah via connect events 
+ *         dat_ib_post_send_ud()
+ *
+ * 2.0.3 - Add query/print counter support for IA, EP, and EVD's 
+ *         dat_query_counters(), dat_print_counters()
+ *
+ */
+#define DAT_IB_EXTENSION_VERSION	203	/* 2.0.3 */
+#define DAT_ATTR_COUNTERS		"DAT_COUNTERS"
 #define DAT_IB_ATTR_FETCH_AND_ADD	"DAT_IB_FETCH_AND_ADD"
 #define DAT_IB_ATTR_CMP_AND_SWAP	"DAT_IB_CMP_AND_SWAP"
 #define DAT_IB_ATTR_IMMED_DATA		"DAT_IB_IMMED_DATA"
@@ -87,7 +101,9 @@
 	DAT_IB_FETCH_AND_ADD_OP,
 	DAT_IB_CMP_AND_SWAP_OP,
 	DAT_IB_RDMA_WRITE_IMMED_OP,
-	DAT_IB_UD_SEND_OP
+	DAT_IB_UD_SEND_OP,
+	DAT_QUERY_COUNTERS_OP,
+	DAT_PRINT_COUNTERS_OP
 	
 } DAT_IB_OP;
 
@@ -247,7 +263,93 @@
 
 } DAT_IB_SERVICE_TYPE;
 
+/*
+ * Definitions for 64-bit IA Counters
+ */
+typedef enum dat_ia_counters
+{
+	DCNT_IA_PZ_CREATE,
+	DCNT_IA_PZ_FREE,
+	DCNT_IA_LMR_CREATE,
+	DCNT_IA_LMR_FREE,
+	DCNT_IA_RMR_CREATE,
+	DCNT_IA_RMR_FREE,
+	DCNT_IA_PSP_CREATE,
+	DCNT_IA_PSP_CREATE_ANY,
+	DCNT_IA_PSP_FREE,
+	DCNT_IA_RSP_CREATE,
+	DCNT_IA_RSP_FREE,
+	DCNT_IA_EVD_CREATE,
+	DCNT_IA_EVD_FREE,
+	DCNT_IA_EP_CREATE,
+	DCNT_IA_EP_FREE,
+	DCNT_IA_SRQ_CREATE,
+	DCNT_IA_SRQ_FREE,
+	DCNT_IA_SP_CR,
+	DCNT_IA_SP_CR_ACCEPTED,
+	DCNT_IA_SP_CR_REJECTED,
+	DCNT_IA_MEM_ALLOC,
+	DCNT_IA_MEM_ALLOC_DATA,
+	DCNT_IA_MEM_FREE,
+	DCNT_IA_ASYNC_ERROR,
+	DCNT_IA_ASYNC_QP_ERROR,
+	DCNT_IA_ASYNC_CQ_ERROR,
+	DCNT_IA_ALL_COUNTERS,  /* MUST be last */
 
+} DAT_IA_COUNTERS;
+
+/*
+ * Definitions for 64-bit EP Counters
+ */
+typedef enum dat_ep_counters
+{
+	DCNT_EP_CONNECT,
+	DCNT_EP_DISCONNECT,
+	DCNT_EP_POST_SEND,
+	DCNT_EP_POST_SEND_DATA,
+	DCNT_EP_POST_SEND_UD,
+	DCNT_EP_POST_SEND_UD_DATA,
+	DCNT_EP_POST_RECV,
+	DCNT_EP_POST_RECV_DATA,
+	DCNT_EP_POST_WRITE,
+	DCNT_EP_POST_WRITE_DATA,
+	DCNT_EP_POST_WRITE_IMM,
+	DCNT_EP_POST_WRITE_IMM_DATA,
+	DCNT_EP_POST_READ,
+	DCNT_EP_POST_READ_DATA,
+	DCNT_EP_POST_CMP_SWAP,
+	DCNT_EP_POST_FETCH_ADD,
+	DCNT_EP_RECV,
+	DCNT_EP_RECV_DATA,
+	DCNT_EP_RECV_UD,
+	DCNT_EP_RECV_UD_DATA,
+	DCNT_EP_RECV_IMM,
+	DCNT_EP_RECV_IMM_DATA,
+	DCNT_EP_RECV_RDMA_IMM,
+	DCNT_EP_RECV_RDMA_IMM_DATA,
+	DCNT_EP_ALL_COUNTERS,  /* MUST be last */
+
+} DAT_EP_COUNTERS;
+
+/*
+ * Definitions for 64-bit EVD Counters
+ */
+typedef enum dat_evd_counters
+{
+	DCNT_EVD_WAIT,
+	DCNT_EVD_WAIT_BLOCKED,
+	DCNT_EVD_WAIT_NOTIFY,
+	DCNT_EVD_DEQUEUE,
+	DCNT_EVD_DEQUEUE_FOUND,
+	DCNT_EVD_DEQUEUE_NOT_FOUND,
+	DCNT_EVD_DEQUEUE_POLL,
+	DCNT_EVD_DEQUEUE_POLL_FOUND,
+	DCNT_EVD_CONN_CALLBACK,
+	DCNT_EVD_DTO_CALLBACK,
+	DCNT_EVD_ALL_COUNTERS,  /* MUST be last */
+
+} DAT_EVD_COUNTERS;
+
 /* Extended RETURN and EVENT STATUS string helper functions */
 
 /* DAT_EXT_RETURN error to string */
@@ -370,5 +472,32 @@
 				(cookie), \
 				(flgs))
 
+
+/* 
+ * Query counter(s):  
+ * Provide IA, EP, or EVD and call will return appropriate counters
+ * 	DAT_HANDLE dat_handle, enum cntr, *DAT_UINT64 p_cntrs_out, int reset
+ *
+ * use _ALL_COUNTERS to query all
+ */
+#define dat_query_counters(dat_handle, cntr, p_cntrs_out, reset) \
+	     dat_extension_op(  dat_handle, \
+				DAT_QUERY_COUNTERS_OP, \
+				(cntr), \
+				(p_cntrs_out), \
+				(reset))
+/* 
+ * Print counter(s):  
+ * Provide IA, EP, or EVD and call will print appropriate counters
+ * 	DAT_HANDLE dat_handle, int cntr, int reset
+ * 
+ * use _ALL_COUNTERS to print all
+ */
+#define dat_print_counters(dat_handle, cntr, reset) \
+	     dat_extension_op(  dat_handle, \
+				DAT_PRINT_COUNTERS_OP, \
+				(cntr), \
+				(reset))
+
 #endif /* _DAT_IB_EXTENSIONS_H_ */
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -38,7 +38,7 @@
  **********************************************************************/
 
 #include <dat2/udat.h>
-#include <dat2/dat_registry.h> /* Provider API function prototypes */
+#include <dat2/dat_registry.h>	/* Provider API function prototypes */
 
 #include "dat_dr.h"
 #include "dat_init.h"
@@ -47,7 +47,6 @@
 #include "dat_sr.h"
 #endif
 
-
 #define UDAT_IS_BAD_POINTER(p) ( NULL == (p) )
 
 /*********************************************************************
@@ -56,10 +55,8 @@
  *                                                                   *
  *********************************************************************/
 
-DAT_BOOLEAN
-udat_check_state ( void );
+DAT_BOOLEAN udat_check_state(void);
 
-
 /*********************************************************************
  *                                                                   *
  * External Function Definitions                                     *
@@ -77,74 +74,64 @@
  *
  */
 
-
 /***********************************************************************
  * Function: dat_registry_add_provider
  ***********************************************************************/
 
 DAT_RETURN DAT_API
-dat_registry_add_provider (
-	IN  const DAT_PROVIDER	 	*provider,
-	IN  const DAT_PROVIDER_INFO	*provider_info )
+dat_registry_add_provider(IN const DAT_PROVIDER * provider,
+			  IN const DAT_PROVIDER_INFO * provider_info)
 {
-    DAT_DR_ENTRY 	entry;
+	DAT_DR_ENTRY entry;
 
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-	      "DAT Registry: %s (%s,%x:%x,%x)\n", __FUNCTION__,
-		      provider_info->ia_name,
-		      provider_info->dapl_version_major,
-		      provider_info->dapl_version_minor,
-		      provider_info->is_thread_safe);
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+			 "DAT Registry: %s (%s,%x:%x,%x)\n", __FUNCTION__,
+			 provider_info->ia_name,
+			 provider_info->dapl_version_major,
+			 provider_info->dapl_version_minor,
+			 provider_info->is_thread_safe);
 
-    if ( UDAT_IS_BAD_POINTER (provider) )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
-    }
+	if (UDAT_IS_BAD_POINTER(provider)) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+	}
 
-    if ( UDAT_IS_BAD_POINTER (provider_info) )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-    }
+	if (UDAT_IS_BAD_POINTER(provider_info)) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+	}
 
-    if ( DAT_FALSE == udat_check_state () )
-    {
-	return DAT_ERROR (DAT_INVALID_STATE, 0);
-    }
+	if (DAT_FALSE == udat_check_state()) {
+		return DAT_ERROR(DAT_INVALID_STATE, 0);
+	}
 
-    entry.ref_count = 0;
-    entry.ia_open_func = provider->ia_open_func;
-    entry.info = *provider_info;
+	entry.ref_count = 0;
+	entry.ia_open_func = provider->ia_open_func;
+	entry.info = *provider_info;
 
-    return dat_dr_insert (provider_info, &entry);
+	return dat_dr_insert(provider_info, &entry);
 }
 
-
 //***********************************************************************
 // Function: dat_registry_remove_provider
 //***********************************************************************
 
 DAT_RETURN DAT_API
-dat_registry_remove_provider (
-	IN  const DAT_PROVIDER 		*provider,
-	IN  const DAT_PROVIDER_INFO	*provider_info )
+dat_registry_remove_provider(IN const DAT_PROVIDER * provider,
+			     IN const DAT_PROVIDER_INFO * provider_info)
 {
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_PROVIDER_API,
-		      "DAT Registry: dat_registry_remove_provider () called\n");
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
+			 "DAT Registry: dat_registry_remove_provider () called\n");
 
-    if ( UDAT_IS_BAD_POINTER (provider) )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
-    }
+	if (UDAT_IS_BAD_POINTER(provider)) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+	}
 
-    if ( DAT_FALSE == udat_check_state () )
-    {
-	return DAT_ERROR (DAT_INVALID_STATE, 0);
-    }
+	if (DAT_FALSE == udat_check_state()) {
+		return DAT_ERROR(DAT_INVALID_STATE, 0);
+	}
 
-    return dat_dr_remove (provider_info);
+	return dat_dr_remove(provider_info);
 }
 
-
 /*
  *
  * Consumer API
@@ -156,277 +143,235 @@
  ***********************************************************************/
 
 DAT_RETURN DAT_API
-dat_ia_openv (
-    IN	   const DAT_NAME_PTR	name,
-    IN	   DAT_COUNT		async_event_qlen,
-    INOUT  DAT_EVD_HANDLE	*async_event_handle,
-    OUT    DAT_IA_HANDLE	*ia_handle,
-    IN     DAT_UINT32		dapl_major,
-    IN     DAT_UINT32           dapl_minor,
-    IN     DAT_BOOLEAN          thread_safety )
+dat_ia_openv(IN const DAT_NAME_PTR name,
+	     IN DAT_COUNT async_event_qlen,
+	     INOUT DAT_EVD_HANDLE * async_event_handle,
+	     OUT DAT_IA_HANDLE * ia_handle,
+	     IN DAT_UINT32 dapl_major,
+	     IN DAT_UINT32 dapl_minor, IN DAT_BOOLEAN thread_safety)
 {
-    DAT_IA_OPEN_FUNC		ia_open_func;
-    DAT_PROVIDER_INFO 		info;
-    DAT_OS_SIZE 		len;
-    DAT_RETURN			dat_status;
+	DAT_IA_OPEN_FUNC ia_open_func;
+	DAT_PROVIDER_INFO info;
+	DAT_OS_SIZE len;
+	DAT_RETURN dat_status;
 
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-       	      "DAT Registry: dat_ia_openv (%s,%x:%x,%x) called\n",
-		      name,
-		      dapl_major,
-		      dapl_minor,
-		      thread_safety);
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+			 "DAT Registry: dat_ia_openv (%s,%x:%x,%x) called\n",
+			 name, dapl_major, dapl_minor, thread_safety);
 
-    if ( UDAT_IS_BAD_POINTER (name) )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
-    }
+	if (UDAT_IS_BAD_POINTER(name)) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+	}
 
-    len = dat_os_strlen (name);
+	len = dat_os_strlen(name);
 
-    if ( DAT_NAME_MAX_LENGTH <= len )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
-    }
+	if (DAT_NAME_MAX_LENGTH <= len) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+	}
 
-    if ( UDAT_IS_BAD_POINTER (ia_handle) )
-    {
-	return DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-    }
+	if (UDAT_IS_BAD_POINTER(ia_handle)) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+	}
 
-    if ( DAT_FALSE == udat_check_state () )
-    {
-	return DAT_ERROR (DAT_INVALID_STATE, 0);
-    }
+	if (DAT_FALSE == udat_check_state()) {
+		return DAT_ERROR(DAT_INVALID_STATE, 0);
+	}
 
-    dat_os_strncpy (info.ia_name, name, len+1);
+	dat_os_strncpy(info.ia_name, name, len + 1);
 
-    info.dapl_version_major = dapl_major;
-    info.dapl_version_minor = dapl_minor;
-    info.is_thread_safe = thread_safety;
+	info.dapl_version_major = dapl_major;
+	info.dapl_version_minor = dapl_minor;
+	info.is_thread_safe = thread_safety;
 
-    /*
-     * Since DAT allows providers to be loaded by either the static
-     * registry or explicitly through OS dependent methods, do not
-     * return an error if no providers are loaded via the static registry.
-     * Don't even bother calling the static registry if DAT is compiled
-     * with no static registry support.
-     */
+	/*
+	 * Since DAT allows providers to be loaded by either the static
+	 * registry or explicitly through OS dependent methods, do not
+	 * return an error if no providers are loaded via the static registry.
+	 * Don't even bother calling the static registry if DAT is compiled
+	 * with no static registry support.
+	 */
 
 #ifndef DAT_NO_STATIC_REGISTRY
-    (void) dat_sr_provider_open ( &info );
+	(void)dat_sr_provider_open(&info);
 #endif
 
-    dat_status = dat_dr_provider_open ( &info, &ia_open_func);
-    if ( dat_status != DAT_SUCCESS )
-    {
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-			  "DAT Registry: dat_ia_open () provider information "
-			  "for IA name %s not found in dynamic registry\n",
-			  name);
+	dat_status = dat_dr_provider_open(&info, &ia_open_func);
+	if (dat_status != DAT_SUCCESS) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+				 "DAT Registry: dat_ia_open () provider information "
+				 "for IA name %s not found in dynamic registry\n",
+				 name);
 
-	return dat_status;
-    }
+		return dat_status;
+	}
 
-    dat_status = (*ia_open_func) (name,
-				  async_event_qlen,
-				  async_event_handle,
-				  ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	*ia_handle = (DAT_IA_HANDLE) dats_set_ia_handle (*ia_handle);
-    }
+	dat_status = (*ia_open_func) (name,
+				      async_event_qlen,
+				      async_event_handle, ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		*ia_handle = (DAT_IA_HANDLE) dats_set_ia_handle(*ia_handle);
+	}
 
-    /*
-     *  See if provider supports extensions
-     */
-    if (dat_status == DAT_SUCCESS)
-    {
-        DAT_IA_ATTR       ia_attr;
+	/*
+	 *  See if provider supports extensions
+	 */
+	if (dat_status == DAT_SUCCESS) {
+		DAT_IA_ATTR ia_attr;
 
-        if ( dat_ia_query( *ia_handle,
-                           NULL,
-                           DAT_IA_ALL,
-                           &ia_attr,
-                           0,
-                           NULL ) == DAT_SUCCESS )
-        {
-		if (ia_attr.extension_supported)
-		{
-                        dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
-                                 "DAT Registry: dat_ia_open () "
-                                 "Extensions (Type=%d, ver=%d) supported!\n",
-				 ia_attr.extension_supported,
-				 ia_attr.extension_version);
-			g_dat_extensions = 1;
+		if (dat_ia_query(*ia_handle,
+				 NULL,
+				 DAT_IA_ALL,
+				 &ia_attr, 0, NULL) == DAT_SUCCESS) {
+			if (ia_attr.extension_supported) {
+				dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+						 "DAT Registry: dat_ia_open () "
+						 "Extensions (Type=%d, ver=%d) supported!\n",
+						 ia_attr.extension_supported,
+						 ia_attr.extension_version);
+				g_dat_extensions = 1;
+			}
 		}
-        }
-    }
-    return dat_status;
+	}
+	return dat_status;
 }
 
-
 /************************************************************************
  * Function: dat_ia_close
  ***********************************************************************/
 
 DAT_RETURN DAT_API
-dat_ia_close (
-    IN DAT_IA_HANDLE	ia_handle,
-    IN DAT_CLOSE_FLAGS	ia_flags)
+dat_ia_close(IN DAT_IA_HANDLE ia_handle, IN DAT_CLOSE_FLAGS ia_flags)
 {
-    DAT_PROVIDER	*provider;
-    DAT_PROVIDER_ATTR   provider_attr;
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN 		dat_status;
-    const char 		*ia_name;
+	DAT_PROVIDER *provider;
+	DAT_PROVIDER_ATTR provider_attr;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
+	const char *ia_name;
 
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-		      "DAT Registry: dat_ia_close () called\n");
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+			 "DAT Registry: dat_ia_close () called\n");
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status != DAT_SUCCESS)
-    {
-	return DAT_ERROR (DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status != DAT_SUCCESS) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
+	}
 
-    if ( DAT_FALSE == udat_check_state () )
-    {
-	return DAT_ERROR (DAT_INVALID_STATE, 0);
-    }
+	if (DAT_FALSE == udat_check_state()) {
+		return DAT_ERROR(DAT_INVALID_STATE, 0);
+	}
 
-    provider = DAT_HANDLE_TO_PROVIDER (dapl_ia_handle);
-    ia_name = provider->device_name;
+	provider = DAT_HANDLE_TO_PROVIDER(dapl_ia_handle);
+	ia_name = provider->device_name;
 
-    if ( DAT_SUCCESS != (dat_status = dat_ia_query (ia_handle,
-						    NULL,
-						    0,
-						    NULL,
-						    DAT_PROVIDER_FIELD_ALL,
-						    &provider_attr)) )
-    {
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-			  "DAT Registry: query function for %s provider failed\n",
-			  ia_name);
-    }
-    else if ( DAT_SUCCESS != (dat_status =
-			      (*provider->ia_close_func) (dapl_ia_handle, ia_flags)) )
-    {
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-			  "DAT Registry: close function for %s provider failed\n",
-			  ia_name);
-    }
-    else
-    {
-	DAT_PROVIDER_INFO info;
-	DAT_OS_SIZE len;
+	if (DAT_SUCCESS != (dat_status = dat_ia_query(ia_handle,
+						      NULL,
+						      0,
+						      NULL,
+						      DAT_PROVIDER_FIELD_ALL,
+						      &provider_attr))) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+				 "DAT Registry: query function for %s provider failed\n",
+				 ia_name);
+	} else if (DAT_SUCCESS != (dat_status =
+				   (*provider->ia_close_func) (dapl_ia_handle,
+							       ia_flags))) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+				 "DAT Registry: close function for %s provider failed\n",
+				 ia_name);
+	} else {
+		DAT_PROVIDER_INFO info;
+		DAT_OS_SIZE len;
 
-	len = dat_os_strlen (ia_name);
+		len = dat_os_strlen(ia_name);
 
-	dat_os_assert ( len < DAT_NAME_MAX_LENGTH );
+		dat_os_assert(len < DAT_NAME_MAX_LENGTH);
 
-	dat_os_strncpy (info.ia_name, ia_name, len+1);
+		dat_os_strncpy(info.ia_name, ia_name, len + 1);
 
-	info.dapl_version_major = provider_attr.dapl_version_major;
-	info.dapl_version_minor = provider_attr.dapl_version_minor;
-	info.is_thread_safe = provider_attr.is_thread_safe;
+		info.dapl_version_major = provider_attr.dapl_version_major;
+		info.dapl_version_minor = provider_attr.dapl_version_minor;
+		info.is_thread_safe = provider_attr.is_thread_safe;
 
-	dat_status = dat_dr_provider_close ( &info );
-	if ( DAT_SUCCESS != dat_status )
-	{
-	    dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-			      "DAT Registry: dynamic registry unable to close "
-			      "provider for IA name %s\n",
-			      ia_name);
-	}
+		dat_status = dat_dr_provider_close(&info);
+		if (DAT_SUCCESS != dat_status) {
+			dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+					 "DAT Registry: dynamic registry unable to close "
+					 "provider for IA name %s\n", ia_name);
+		}
 
-	/* Remove the handle from the handle table */
-	(void) dats_free_ia_handle(ia_handle);
+		/* Remove the handle from the handle table */
+		(void)dats_free_ia_handle(ia_handle);
 
 #ifndef DAT_NO_STATIC_REGISTRY
-	dat_status = dat_sr_provider_close ( &info );
-	if ( DAT_SUCCESS != dat_status )
-	{
-	    dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-			      "DAT Registry: static registry unable to close "
-			      "provider for IA name %s\n",
-			      ia_name);
-	}
+		dat_status = dat_sr_provider_close(&info);
+		if (DAT_SUCCESS != dat_status) {
+			dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+					 "DAT Registry: static registry unable to close "
+					 "provider for IA name %s\n", ia_name);
+		}
 #endif
-    }
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
 //***********************************************************************
 // Function: dat_registry_list_providers
 //***********************************************************************
 
 DAT_RETURN DAT_API
-dat_registry_list_providers (
-    IN  DAT_COUNT   		max_to_return,
-    OUT DAT_COUNT   		*entries_returned,
-    OUT	DAT_PROVIDER_INFO 	* (dat_provider_list[]))
+dat_registry_list_providers(IN DAT_COUNT max_to_return,
+			    OUT DAT_COUNT * entries_returned,
+			    OUT DAT_PROVIDER_INFO * (dat_provider_list[]))
 {
-    DAT_RETURN	dat_status;
+	DAT_RETURN dat_status;
 
-    dat_status = DAT_SUCCESS;
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_CONSUMER_API,
-		      "DAT Registry: dat_registry_list_providers () called\n");
+	dat_status = DAT_SUCCESS;
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
+			 "DAT Registry: dat_registry_list_providers () called\n");
 
-    if ( DAT_FALSE == udat_check_state () )
-    {
-	return DAT_ERROR (DAT_INVALID_STATE, 0);
-    }
+	if (DAT_FALSE == udat_check_state()) {
+		return DAT_ERROR(DAT_INVALID_STATE, 0);
+	}
 
-    if ( ( UDAT_IS_BAD_POINTER (entries_returned) ) )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-    }
+	if ((UDAT_IS_BAD_POINTER(entries_returned))) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+	}
 
-    if (0 != max_to_return && ( UDAT_IS_BAD_POINTER (dat_provider_list) ) )
-    {
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
-    }
+	if (0 != max_to_return && (UDAT_IS_BAD_POINTER(dat_provider_list))) {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+	}
 
-    if ( 0 == max_to_return )
-    {
-	/* the user is allowed to call with max_to_return set to zero.
-	 * in which case we simply return (in *entries_returned) the
-	 * number of providers currently installed.  We must also
-	 * (per spec) return an error
-	 */
+	if (0 == max_to_return) {
+		/* the user is allowed to call with max_to_return set to zero.
+		 * in which case we simply return (in *entries_returned) the
+		 * number of providers currently installed.  We must also
+		 * (per spec) return an error
+		 */
 #ifndef DAT_NO_STATIC_REGISTRY
-	(void) dat_sr_size ( entries_returned );
+		(void)dat_sr_size(entries_returned);
 #else
-	(void) dat_dr_size ( entries_returned );
+		(void)dat_dr_size(entries_returned);
 #endif
-	return DAT_ERROR (DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
-    }
-    else
-    {
+		return DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
+	} else {
 #ifndef DAT_NO_STATIC_REGISTRY
-	dat_status = dat_sr_list (max_to_return,
-				  entries_returned,
-				  dat_provider_list);
+		dat_status = dat_sr_list(max_to_return,
+					 entries_returned, dat_provider_list);
 #else
-	dat_status = dat_dr_list (max_to_return,
-				  entries_returned,
-				  dat_provider_list);
+		dat_status = dat_dr_list(max_to_return,
+					 entries_returned, dat_provider_list);
 #endif
-    }
-    return dat_status;
+	}
+	return dat_status;
 }
 
-
 /*********************************************************************
  *                                                                   *
  * Internal Function Definitions                                     *
  *                                                                   *
  *********************************************************************/
 
-
 //***********************************************************************
 // Function: udat_check_state
 //***********************************************************************
@@ -436,32 +381,25 @@
  * of handling DAT API calls and false otherwise.
  */
 
-DAT_BOOLEAN
-udat_check_state ( void )
+DAT_BOOLEAN udat_check_state(void)
 {
-    DAT_MODULE_STATE 		state;
-    DAT_BOOLEAN 		status;
+	DAT_MODULE_STATE state;
+	DAT_BOOLEAN status;
 
-    state = dat_module_get_state ();
+	state = dat_module_get_state();
 
-    if ( DAT_MODULE_STATE_UNINITIALIZED == state )
-    {
-	dat_init ();
-	status = DAT_TRUE;
-    }
-    else if ( DAT_MODULE_STATE_DEINITIALIZED == state )
-    {
-	status = DAT_FALSE;
-    }
-    else
-    {
-	status = DAT_TRUE;
-    }
+	if (DAT_MODULE_STATE_UNINITIALIZED == state) {
+		dat_init();
+		status = DAT_TRUE;
+	} else if (DAT_MODULE_STATE_DEINITIALIZED == state) {
+		status = DAT_FALSE;
+	} else {
+		status = DAT_TRUE;
+	}
 
-    return status;
+	return status;
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_api.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_api.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_api.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -53,261 +53,204 @@
 
 #define UDAT_IS_BAD_HANDLE(h) ( NULL == (p) )
 
-DAT_RETURN DAT_API dat_lmr_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	IN      DAT_MEM_TYPE		mem_type,
-	IN      DAT_REGION_DESCRIPTION	region_description,
-	IN      DAT_VLEN		length,
-	IN      DAT_PZ_HANDLE		pz_handle,
-	IN      DAT_MEM_PRIV_FLAGS	privileges,
-	IN	DAT_VA_TYPE		va_type,
-	OUT     DAT_LMR_HANDLE	 	*lmr_handle,
-	OUT     DAT_LMR_CONTEXT		*lmr_context,
-	OUT     DAT_RMR_CONTEXT		*rmr_context,
-	OUT     DAT_VLEN 		*registered_length,
-	OUT     DAT_VADDR 		*registered_address)
+DAT_RETURN DAT_API dat_lmr_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_MEM_TYPE mem_type,
+				  IN DAT_REGION_DESCRIPTION region_description,
+				  IN DAT_VLEN length,
+				  IN DAT_PZ_HANDLE pz_handle,
+				  IN DAT_MEM_PRIV_FLAGS privileges,
+				  IN DAT_VA_TYPE va_type,
+				  OUT DAT_LMR_HANDLE * lmr_handle,
+				  OUT DAT_LMR_CONTEXT * lmr_context,
+				  OUT DAT_RMR_CONTEXT * rmr_context,
+				  OUT DAT_VLEN * registered_length,
+				  OUT DAT_VADDR * registered_address)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_LMR_CREATE (dapl_ia_handle,
-				     mem_type,
-				     region_description,
-				     length,
-				     pz_handle,
-				     privileges,
-				     va_type,
-				     lmr_handle,
-				     lmr_context,
-				     rmr_context,
-				     registered_length,
-				     registered_address);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_LMR_CREATE(dapl_ia_handle,
+					    mem_type,
+					    region_description,
+					    length,
+					    pz_handle,
+					    privileges,
+					    va_type,
+					    lmr_handle,
+					    lmr_context,
+					    rmr_context,
+					    registered_length,
+					    registered_address);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_evd_create (
-	IN      DAT_IA_HANDLE		ia_handle,
-	IN      DAT_COUNT		evd_min_qlen,
-	IN      DAT_CNO_HANDLE		cno_handle,
-	IN      DAT_EVD_FLAGS		evd_flags,
-	OUT     DAT_EVD_HANDLE		*evd_handle)
+DAT_RETURN DAT_API dat_evd_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_COUNT evd_min_qlen,
+				  IN DAT_CNO_HANDLE cno_handle,
+				  IN DAT_EVD_FLAGS evd_flags,
+				  OUT DAT_EVD_HANDLE * evd_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_EVD_CREATE (dapl_ia_handle,
-				     evd_min_qlen,
-				     cno_handle,
-				     evd_flags,
-				     evd_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_EVD_CREATE(dapl_ia_handle,
+					    evd_min_qlen,
+					    cno_handle, evd_flags, evd_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-
-DAT_RETURN DAT_API dat_evd_modify_cno (
-	IN      DAT_EVD_HANDLE		evd_handle,
-	IN      DAT_CNO_HANDLE		cno_handle)
+DAT_RETURN DAT_API dat_evd_modify_cno(IN DAT_EVD_HANDLE evd_handle,
+				      IN DAT_CNO_HANDLE cno_handle)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_MODIFY_CNO (evd_handle,
-			       cno_handle);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_MODIFY_CNO(evd_handle, cno_handle);
 }
 
-
-DAT_RETURN DAT_API dat_cno_create (
-	IN 	DAT_IA_HANDLE		ia_handle,
-	IN 	DAT_OS_WAIT_PROXY_AGENT agent,
-	OUT 	DAT_CNO_HANDLE		*cno_handle)
+DAT_RETURN DAT_API dat_cno_create(IN DAT_IA_HANDLE ia_handle,
+				  IN DAT_OS_WAIT_PROXY_AGENT agent,
+				  OUT DAT_CNO_HANDLE * cno_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_CNO_CREATE (dapl_ia_handle,
-				     agent,
-				     cno_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_CNO_CREATE(dapl_ia_handle, agent, cno_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_cno_fd_create (
-	IN 	DAT_IA_HANDLE		ia_handle,
-	OUT	DAT_FD			*fd,
-	OUT 	DAT_CNO_HANDLE		*cno_handle)
+DAT_RETURN DAT_API dat_cno_fd_create(IN DAT_IA_HANDLE ia_handle,
+				     OUT DAT_FD * fd,
+				     OUT DAT_CNO_HANDLE * cno_handle)
 {
-    DAT_IA_HANDLE	dapl_ia_handle;
-    DAT_RETURN		dat_status;
+	DAT_IA_HANDLE dapl_ia_handle;
+	DAT_RETURN dat_status;
 
-    dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
-    if (dat_status == DAT_SUCCESS)
-    {
-	dat_status = DAT_CNO_FD_CREATE (dapl_ia_handle,
-				     (DAT_FD *)fd,
-				     cno_handle);
-    }
+	dat_status = dats_get_ia_handle(ia_handle, &dapl_ia_handle);
+	if (dat_status == DAT_SUCCESS) {
+		dat_status = DAT_CNO_FD_CREATE(dapl_ia_handle,
+					       (DAT_FD *) fd, cno_handle);
+	}
 
-    return dat_status;
+	return dat_status;
 }
 
-DAT_RETURN DAT_API dat_cno_modify_agent (
-	IN 	DAT_CNO_HANDLE		 cno_handle,
-	IN 	DAT_OS_WAIT_PROXY_AGENT	 agent)
+DAT_RETURN DAT_API dat_cno_modify_agent(IN DAT_CNO_HANDLE cno_handle,
+					IN DAT_OS_WAIT_PROXY_AGENT agent)
 {
-    if (cno_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
-    }
-    return DAT_CNO_MODIFY_AGENT (cno_handle,
-				 agent);
+	if (cno_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+	}
+	return DAT_CNO_MODIFY_AGENT(cno_handle, agent);
 }
 
-
-DAT_RETURN DAT_API dat_cno_query (
-	IN      DAT_CNO_HANDLE		cno_handle,
-	IN      DAT_CNO_PARAM_MASK	cno_param_mask,
-	OUT     DAT_CNO_PARAM		*cno_param)
+DAT_RETURN DAT_API dat_cno_query(IN DAT_CNO_HANDLE cno_handle,
+				 IN DAT_CNO_PARAM_MASK cno_param_mask,
+				 OUT DAT_CNO_PARAM * cno_param)
 {
-    return DAT_CNO_QUERY (cno_handle,
-			  cno_param_mask,
-			  cno_param);
+	return DAT_CNO_QUERY(cno_handle, cno_param_mask, cno_param);
 }
 
-
-DAT_RETURN DAT_API dat_cno_free (
-	IN DAT_CNO_HANDLE		cno_handle)
+DAT_RETURN DAT_API dat_cno_free(IN DAT_CNO_HANDLE cno_handle)
 {
-    if (cno_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
-    }
-    return DAT_CNO_FREE (cno_handle);
+	if (cno_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+	}
+	return DAT_CNO_FREE(cno_handle);
 }
 
-
-DAT_RETURN DAT_API dat_cno_wait (
-	IN  	DAT_CNO_HANDLE		cno_handle,
-	IN  	DAT_TIMEOUT		timeout,
-	OUT 	DAT_EVD_HANDLE		*evd_handle)
+DAT_RETURN DAT_API dat_cno_wait(IN DAT_CNO_HANDLE cno_handle,
+				IN DAT_TIMEOUT timeout,
+				OUT DAT_EVD_HANDLE * evd_handle)
 {
-    if (cno_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
-    }
-    return DAT_CNO_WAIT (cno_handle,
-			 timeout,
-			 evd_handle);
+	if (cno_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO);
+	}
+	return DAT_CNO_WAIT(cno_handle, timeout, evd_handle);
 }
 
-
-DAT_RETURN DAT_API dat_evd_enable (
-	IN      DAT_EVD_HANDLE		evd_handle)
+DAT_RETURN DAT_API dat_evd_enable(IN DAT_EVD_HANDLE evd_handle)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_ENABLE (evd_handle);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_ENABLE(evd_handle);
 }
 
-
-DAT_RETURN DAT_API dat_evd_wait (
-	IN  	DAT_EVD_HANDLE		evd_handle,
-	IN  	DAT_TIMEOUT		Timeout,
-	IN  	DAT_COUNT		Threshold,
-	OUT 	DAT_EVENT		*event,
-	OUT 	DAT_COUNT		*n_more_events)
+DAT_RETURN DAT_API dat_evd_wait(IN DAT_EVD_HANDLE evd_handle,
+				IN DAT_TIMEOUT Timeout,
+				IN DAT_COUNT Threshold,
+				OUT DAT_EVENT * event,
+				OUT DAT_COUNT * n_more_events)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_WAIT (evd_handle,
-			 Timeout,
-			 Threshold,
-			 event,
-			 n_more_events);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_WAIT(evd_handle,
+			    Timeout, Threshold, event, n_more_events);
 }
 
-
-DAT_RETURN DAT_API dat_evd_disable (
-	IN      DAT_EVD_HANDLE		evd_handle)
+DAT_RETURN DAT_API dat_evd_disable(IN DAT_EVD_HANDLE evd_handle)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_DISABLE (evd_handle);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_DISABLE(evd_handle);
 }
 
-
-DAT_RETURN DAT_API dat_evd_set_unwaitable (
-	IN 	DAT_EVD_HANDLE		 evd_handle)
+DAT_RETURN DAT_API dat_evd_set_unwaitable(IN DAT_EVD_HANDLE evd_handle)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_SET_UNWAITABLE (evd_handle);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_SET_UNWAITABLE(evd_handle);
 }
 
-
-DAT_RETURN DAT_API dat_evd_clear_unwaitable (
-	IN 	DAT_EVD_HANDLE		 evd_handle)
+DAT_RETURN DAT_API dat_evd_clear_unwaitable(IN DAT_EVD_HANDLE evd_handle)
 {
-    if (evd_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EVD_REQUEST);
-    }
-    return DAT_EVD_CLEAR_UNWAITABLE (evd_handle);
+	if (evd_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE,
+				 DAT_INVALID_HANDLE_EVD_REQUEST);
+	}
+	return DAT_EVD_CLEAR_UNWAITABLE(evd_handle);
 }
 
-
-
-DAT_RETURN DAT_API dat_cr_handoff (
-    IN          DAT_CR_HANDLE		cr_handle,
-    IN          DAT_CONN_QUAL		handoff)
+DAT_RETURN DAT_API dat_cr_handoff(IN DAT_CR_HANDLE cr_handle,
+				  IN DAT_CONN_QUAL handoff)
 {
-    if (cr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
-    }
-    return DAT_CR_HANDOFF (cr_handle,
-			   handoff);
+	if (cr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR);
+	}
+	return DAT_CR_HANDOFF(cr_handle, handoff);
 }
 
-
-DAT_RETURN DAT_API dat_lmr_query (
-	IN      DAT_LMR_HANDLE		lmr_handle,
-	IN      DAT_LMR_PARAM_MASK	lmr_param_mask,
-	OUT     DAT_LMR_PARAM		*lmr_param)
+DAT_RETURN DAT_API dat_lmr_query(IN DAT_LMR_HANDLE lmr_handle,
+				 IN DAT_LMR_PARAM_MASK lmr_param_mask,
+				 OUT DAT_LMR_PARAM * lmr_param)
 {
-    if (lmr_handle == NULL)
-    {
-	return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
-    }
-    return DAT_LMR_QUERY (lmr_handle,
-			  lmr_param_mask,
-			  lmr_param);
+	if (lmr_handle == NULL) {
+		return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
+	}
+	return DAT_LMR_QUERY(lmr_handle, lmr_param_mask, lmr_param);
 }
 
-
 /*
  * Local variables:
  *  c-indent-level: 4

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_sr_parser.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_sr_parser.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/dat/udat/udat_sr_parser.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -41,7 +41,6 @@
 #include "udat_sr_parser.h"
 #include "dat_sr.h"
 
-
 /*********************************************************************
  *                                                                   *
  * Constants                                                         *
@@ -65,210 +64,146 @@
 #define DAT_SR_CHAR_QUOTE 		'"'
 #define DAT_SR_CHAR_BACKSLASH 		'\\'
 
-
 /*********************************************************************
  *                                                                   *
  * Enumerations                                                      *
  *                                                                   *
  *********************************************************************/
 
-typedef enum
-{
-    DAT_SR_TOKEN_STRING, /* text field (both quoted or unquoted) */
-    DAT_SR_TOKEN_EOR,	 /* end of record (newline)              */
-    DAT_SR_TOKEN_EOF	 /* end of file                          */
+typedef enum {
+	DAT_SR_TOKEN_STRING,	/* text field (both quoted or unquoted) */
+	DAT_SR_TOKEN_EOR,	/* end of record (newline)              */
+	DAT_SR_TOKEN_EOF	/* end of file                          */
 } DAT_SR_TOKEN_TYPE;
 
-typedef enum
-{
-    DAT_SR_API_UDAT,
-    DAT_SR_API_KDAT
+typedef enum {
+	DAT_SR_API_UDAT,
+	DAT_SR_API_KDAT
 } DAT_SR_API_TYPE;
 
-
 /*********************************************************************
  *                                                                   *
  * Structures                                                        *
  *                                                                   *
  *********************************************************************/
 
-typedef struct
-{
-    DAT_SR_TOKEN_TYPE 		type;
-    char * 			value; /* valid if type is DAT_SR_TOKEN_STRING */
-    DAT_OS_SIZE 		value_len;
+typedef struct {
+	DAT_SR_TOKEN_TYPE type;
+	char *value;		/* valid if type is DAT_SR_TOKEN_STRING */
+	DAT_OS_SIZE value_len;
 } DAT_SR_TOKEN;
 
-typedef struct DAT_SR_STACK_NODE
-{
-    DAT_SR_TOKEN 		token;
-    struct DAT_SR_STACK_NODE    *next;
+typedef struct DAT_SR_STACK_NODE {
+	DAT_SR_TOKEN token;
+	struct DAT_SR_STACK_NODE *next;
 } DAT_SR_STACK_NODE;
 
-typedef struct
-{
-    DAT_UINT32 			major;
-    DAT_UINT32 			minor;
+typedef struct {
+	DAT_UINT32 major;
+	DAT_UINT32 minor;
 } DAT_SR_VERSION;
 
-typedef struct
-{
-    char * 			id;
-    DAT_SR_VERSION 		version;
+typedef struct {
+	char *id;
+	DAT_SR_VERSION version;
 } DAT_SR_PROVIDER_VERSION;
 
-typedef struct
-{
-    DAT_SR_API_TYPE 		type;
-    DAT_SR_VERSION 		version;
+typedef struct {
+	DAT_SR_API_TYPE type;
+	DAT_SR_VERSION version;
 } DAT_SR_API_VERSION;
 
-typedef struct
-{
-    char * 			ia_name;
-    DAT_SR_API_VERSION 		api_version;
-    DAT_BOOLEAN 		is_thread_safe;
-    DAT_BOOLEAN 		is_default;
-    char * 			lib_path;
-    DAT_SR_PROVIDER_VERSION 	provider_version;
-    char * 			ia_params;
-    char * 			platform_params;
+typedef struct {
+	char *ia_name;
+	DAT_SR_API_VERSION api_version;
+	DAT_BOOLEAN is_thread_safe;
+	DAT_BOOLEAN is_default;
+	char *lib_path;
+	DAT_SR_PROVIDER_VERSION provider_version;
+	char *ia_params;
+	char *platform_params;
 } DAT_SR_CONF_ENTRY;
 
-
 /*********************************************************************
  *                                                                   *
  * Internal Function Declarations                                    *
  *                                                                   *
  *********************************************************************/
 
-static DAT_RETURN
-dat_sr_load_entry (
-    DAT_SR_CONF_ENTRY *entry);
+static DAT_RETURN dat_sr_load_entry(DAT_SR_CONF_ENTRY * entry);
 
-static DAT_BOOLEAN
-dat_sr_is_valid_entry (
-    DAT_SR_CONF_ENTRY *entry);
+static DAT_BOOLEAN dat_sr_is_valid_entry(DAT_SR_CONF_ENTRY * entry);
 
-static char *
-dat_sr_type_to_str (
-    DAT_SR_TOKEN_TYPE type);
+static char *dat_sr_type_to_str(DAT_SR_TOKEN_TYPE type);
 
-static DAT_RETURN
-dat_sr_parse_eof (
-    DAT_OS_FILE *file);
+static DAT_RETURN dat_sr_parse_eof(DAT_OS_FILE * file);
 
-static DAT_RETURN
-dat_sr_parse_entry (
-    DAT_OS_FILE *file);
+static DAT_RETURN dat_sr_parse_entry(DAT_OS_FILE * file);
 
 static DAT_RETURN
-dat_sr_parse_ia_name (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_ia_name(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_api (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_api(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_thread_safety (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_thread_safety(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_default (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_default(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_lib_path (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_lib_path(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_provider_version (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_provider_version(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_ia_params (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_ia_params(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_platform_params (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_platform_params(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_parse_eoe (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry);
+dat_sr_parse_eoe(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry);
 
 static DAT_RETURN
-dat_sr_convert_api (
-    char *str,
-    DAT_SR_API_VERSION *api_version);
+dat_sr_convert_api(char *str, DAT_SR_API_VERSION * api_version);
 
 static DAT_RETURN
-dat_sr_convert_thread_safety (
-    char *str,
-    DAT_BOOLEAN *is_thread_safe);
+dat_sr_convert_thread_safety(char *str, DAT_BOOLEAN * is_thread_safe);
 
-static DAT_RETURN
-dat_sr_convert_default (
-    char *str,
-    DAT_BOOLEAN *is_default);
+static DAT_RETURN dat_sr_convert_default(char *str, DAT_BOOLEAN * is_default);
 
 static DAT_RETURN
-dat_sr_convert_provider_version (
-    char *str,
-    DAT_SR_PROVIDER_VERSION *provider_version);
+dat_sr_convert_provider_version(char *str,
+				DAT_SR_PROVIDER_VERSION * provider_version);
 
-static DAT_RETURN
-dat_sr_get_token (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token);
+static DAT_RETURN dat_sr_get_token(DAT_OS_FILE * file, DAT_SR_TOKEN * token);
 
-static DAT_RETURN
-dat_sr_put_token (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token);
+static DAT_RETURN dat_sr_put_token(DAT_OS_FILE * file, DAT_SR_TOKEN * token);
 
-static DAT_RETURN
-dat_sr_read_token (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token);
+static DAT_RETURN dat_sr_read_token(DAT_OS_FILE * file, DAT_SR_TOKEN * token);
 
 static DAT_RETURN
-dat_sr_read_str (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token,
-    DAT_OS_SIZE token_len);
+dat_sr_read_str(DAT_OS_FILE * file,
+		DAT_SR_TOKEN * token, DAT_OS_SIZE token_len);
 
 static DAT_RETURN
-dat_sr_read_quoted_str (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token,
-    DAT_OS_SIZE token_len,
-    DAT_COUNT num_escape_seq);
+dat_sr_read_quoted_str(DAT_OS_FILE * file,
+		       DAT_SR_TOKEN * token,
+		       DAT_OS_SIZE token_len, DAT_COUNT num_escape_seq);
 
-static void
-dat_sr_read_comment (
-    DAT_OS_FILE *file);
+static void dat_sr_read_comment(DAT_OS_FILE * file);
 
-
 /*********************************************************************
  *                                                                   *
  * Global Variables                                                  *
  *                                                                   *
  *********************************************************************/
 
-static DAT_SR_STACK_NODE 	*g_token_stack = NULL;
+static DAT_SR_STACK_NODE *g_token_stack = NULL;
 
-
 /*********************************************************************
  *                                                                   *
  * External Function Definitions                                     *
@@ -279,95 +214,82 @@
  * Function: dat_sr_load
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_load (void)
+DAT_RETURN dat_sr_load(void)
 {
-    char 			*sr_path;
-    DAT_OS_FILE 		*sr_file;
+	char *sr_path;
+	DAT_OS_FILE *sr_file;
 
-    sr_path = dat_os_getenv(DAT_SR_CONF_ENV);
+	sr_path = dat_os_getenv(DAT_SR_CONF_ENV);
 
-    /* environment override */
-    if ((sr_path != NULL) && ((sr_file = dat_os_fopen(sr_path)) == NULL)) 
-    {
-        dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
-                         "DAT Registry: DAT_OVERRIDE, "
-                         "bad filename - %s, aborting\n",
-                         sr_path);
-        goto bail;
-    } 
-    
-    if (sr_path == NULL) { 
+	/* environment override */
+	if ((sr_path != NULL) && ((sr_file = dat_os_fopen(sr_path)) == NULL)) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+				 "DAT Registry: DAT_OVERRIDE, "
+				 "bad filename - %s, aborting\n", sr_path);
+		goto bail;
+	}
 
+	if (sr_path == NULL) {
+
 #ifdef DAT_CONF
-        sr_path = DAT_CONF;
+		sr_path = DAT_CONF;
 #else
-        sr_path = DAT_SR_CONF_DEFAULT;
+		sr_path = DAT_SR_CONF_DEFAULT;
 #endif
-        sr_file = dat_os_fopen (sr_path);
-        if (sr_file == NULL) 
-        {
+		sr_file = dat_os_fopen(sr_path);
+		if (sr_file == NULL) {
 #ifdef DAT_CONF
-            dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
-                             "DAT Registry: sysconfdir, "
-                             "bad filename - %s, retry default at %s\n",
-                             sr_path, DAT_SR_CONF_DEFAULT);
-	    /* try default after sysconfdir fails */
-            sr_path = DAT_SR_CONF_DEFAULT;
-            sr_file = dat_os_fopen(sr_path);
-            if (sr_file == NULL) { 
+			dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+					 "DAT Registry: sysconfdir, "
+					 "bad filename - %s, retry default at %s\n",
+					 sr_path, DAT_SR_CONF_DEFAULT);
+			/* try default after sysconfdir fails */
+			sr_path = DAT_SR_CONF_DEFAULT;
+			sr_file = dat_os_fopen(sr_path);
+			if (sr_file == NULL) {
 #endif
-                dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
-                                 "DAT Registry: default, "
-                                 "bad filename - %s, aborting\n",
-                                 sr_path);
-                goto bail;
+				dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+						 "DAT Registry: default, "
+						 "bad filename - %s, aborting\n",
+						 sr_path);
+				goto bail;
 #ifdef DAT_CONF
-            }
+			}
 #endif
-        }
-    }
+		}
+	}
 
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
-		     "DAT Registry: using config file %s\n", sr_path);
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_GENERIC,
+			 "DAT Registry: using config file %s\n", sr_path);
 
-    for (;;)
-    {
-	if ( DAT_SUCCESS == dat_sr_parse_eof (sr_file) )
-	{
-	    break;
+	for (;;) {
+		if (DAT_SUCCESS == dat_sr_parse_eof(sr_file)) {
+			break;
+		} else if (DAT_SUCCESS == dat_sr_parse_entry(sr_file)) {
+			continue;
+		} else {
+			dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+					 "DAT Registry: ERROR parsing - %s\n",
+					 sr_path);
+			goto cleanup;
+		}
 	}
-	else if ( DAT_SUCCESS == dat_sr_parse_entry (sr_file) )
-	{
-	    continue;
+
+	if (0 != dat_os_fclose(sr_file)) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+				 "DAT Registry: ERROR closing - %s\n", sr_path);
+		goto bail;
 	}
-	else
-	{
-	    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-                             "DAT Registry: ERROR parsing - %s\n", 
-                             sr_path);
-            goto cleanup;
-	}
-    }
 
-    if (0 != dat_os_fclose (sr_file)) 
-    {
-        dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-                         "DAT Registry: ERROR closing - %s\n", 
-                          sr_path);
-	goto bail;
-    }
+	return DAT_SUCCESS;
 
-    return DAT_SUCCESS;
+      cleanup:
+	dat_os_fclose(sr_file);
+      bail:
+	return DAT_INTERNAL_ERROR;
 
-cleanup:
-    dat_os_fclose(sr_file);	
-bail:
-    return DAT_INTERNAL_ERROR;
-
 }
 
-
 /*********************************************************************
  *                                                                   *
  * Internal Function Definitions                                     *
@@ -378,386 +300,339 @@
  * Function: dat_sr_is_valid_entry
  ***********************************************************************/
 
-DAT_BOOLEAN
-dat_sr_is_valid_entry (
-    DAT_SR_CONF_ENTRY *entry)
+DAT_BOOLEAN dat_sr_is_valid_entry(DAT_SR_CONF_ENTRY * entry)
 {
-    if ( ( DAT_SR_API_UDAT == entry->api_version.type ) &&
-	 (entry->is_default) )
-    {
-	return DAT_TRUE;
-    }
-    else
-    {
-	return DAT_FALSE;
-    }
+	if ((DAT_SR_API_UDAT == entry->api_version.type) && (entry->is_default)) {
+		return DAT_TRUE;
+	} else {
+		return DAT_FALSE;
+	}
 }
 
-
 /***********************************************************************
  * Function: dat_sr_load_entry
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_load_entry (
-    DAT_SR_CONF_ENTRY *conf_entry)
+DAT_RETURN dat_sr_load_entry(DAT_SR_CONF_ENTRY * conf_entry)
 {
-    DAT_SR_ENTRY entry;
+	DAT_SR_ENTRY entry;
 
-    if ( DAT_NAME_MAX_LENGTH < (strlen (conf_entry->ia_name) + 1) )
-    {
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-			 "DAT Registry: ia name %s is longer than "
-			 "DAT_NAME_MAX_LENGTH (%i)\n",
-			 conf_entry->ia_name, DAT_NAME_MAX_LENGTH);
+	if (DAT_NAME_MAX_LENGTH < (strlen(conf_entry->ia_name) + 1)) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+				 "DAT Registry: ia name %s is longer than "
+				 "DAT_NAME_MAX_LENGTH (%i)\n",
+				 conf_entry->ia_name, DAT_NAME_MAX_LENGTH);
 
-	return DAT_INSUFFICIENT_RESOURCES;
-    }
+		return DAT_INSUFFICIENT_RESOURCES;
+	}
 
-    dat_os_strncpy (entry.info.ia_name, conf_entry->ia_name, DAT_NAME_MAX_LENGTH);
-    entry.info.dapl_version_major = conf_entry->api_version.version.major;
-    entry.info.dapl_version_minor = conf_entry->api_version.version.minor;
-    entry.info.is_thread_safe = conf_entry->is_thread_safe;
-    entry.lib_path = conf_entry->lib_path;
-    entry.ia_params = conf_entry->ia_params;
-    entry.lib_handle = NULL;
-    entry.ref_count = 0;
+	dat_os_strncpy(entry.info.ia_name, conf_entry->ia_name,
+		       DAT_NAME_MAX_LENGTH);
+	entry.info.dapl_version_major = conf_entry->api_version.version.major;
+	entry.info.dapl_version_minor = conf_entry->api_version.version.minor;
+	entry.info.is_thread_safe = conf_entry->is_thread_safe;
+	entry.lib_path = conf_entry->lib_path;
+	entry.ia_params = conf_entry->ia_params;
+	entry.lib_handle = NULL;
+	entry.ref_count = 0;
 
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-		     "DAT Registry: loading provider for %s\n",
-		     conf_entry->ia_name);
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+			 "DAT Registry: loading provider for %s\n",
+			 conf_entry->ia_name);
 
-    return dat_sr_insert (&entry.info, &entry);
+	return dat_sr_insert(&entry.info, &entry);
 }
 
-
 /***********************************************************************
  * Function: dat_sr_type_to_str
  ***********************************************************************/
 
-char *
-dat_sr_type_to_str (
-    DAT_SR_TOKEN_TYPE type)
+char *dat_sr_type_to_str(DAT_SR_TOKEN_TYPE type)
 {
-    static char *str_array[] = { "string", "eor", "eof" };
+	static char *str_array[] = { "string", "eor", "eof" };
 
-    if ( (type < 0) || (2 < type) )
-    {
-	return "error: invalid token type";
-    }
+	if ((type < 0) || (2 < type)) {
+		return "error: invalid token type";
+	}
 
-    return str_array[type];
+	return str_array[type];
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_eof
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_eof (
-    DAT_OS_FILE 		*file)
+DAT_RETURN dat_sr_parse_eof(DAT_OS_FILE * file)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )
-    {
-	return DAT_INTERNAL_ERROR;
-    }
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token)) {
+		return DAT_INTERNAL_ERROR;
+	}
 
-    if ( DAT_SR_TOKEN_EOF == token.type )
-    {
-	return DAT_SUCCESS;
-    }
-    else
-    {
-	dat_sr_put_token (file, &token);
-	return DAT_INTERNAL_ERROR;
-    }
+	if (DAT_SR_TOKEN_EOF == token.type) {
+		return DAT_SUCCESS;
+	} else {
+		dat_sr_put_token(file, &token);
+		return DAT_INTERNAL_ERROR;
+	}
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_ia_name
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_entry (
-    DAT_OS_FILE 		*file)
+DAT_RETURN dat_sr_parse_entry(DAT_OS_FILE * file)
 {
-    DAT_SR_CONF_ENTRY 		entry;
-    DAT_RETURN 			status;
+	DAT_SR_CONF_ENTRY entry;
+	DAT_RETURN status;
 
-    dat_os_memset (&entry, 0, sizeof (DAT_SR_CONF_ENTRY));
+	dat_os_memset(&entry, 0, sizeof(DAT_SR_CONF_ENTRY));
 
-    if ( (DAT_SUCCESS == dat_sr_parse_ia_name (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_api (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_thread_safety (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_default (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_lib_path (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_provider_version (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_ia_params (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_platform_params (file, &entry)) &&
-	 (DAT_SUCCESS == dat_sr_parse_eoe (file, &entry)) )
-    {
-	dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-			 "\n"
-			 "DAT Registry: entry \n"
-			 " ia_name %s\n"
-			 " api_version\n"
-			 "     type 0x%X\n"
-			 "     major.minor %d.%d\n"
-			 " is_thread_safe %d\n"
-			 " is_default %d\n"
-			 " lib_path %s\n"
-			 " provider_version\n"
-			 "     id %s\n"
-			 "     major.minor %d.%d\n"
-			 " ia_params %s\n"
-			 "\n",
-			 entry.ia_name,
-			 entry.api_version.type,
-			 entry.api_version.version.major,
-			 entry.api_version.version.minor,
-			 entry.is_thread_safe,
-			 entry.is_default,
-			 entry.lib_path,
-			 entry.provider_version.id,
-			 entry.provider_version.version.major,
-			 entry.provider_version.version.minor,
-			 entry.ia_params);
+	if ((DAT_SUCCESS == dat_sr_parse_ia_name(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_api(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_thread_safety(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_default(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_lib_path(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_provider_version(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_ia_params(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_platform_params(file, &entry)) &&
+	    (DAT_SUCCESS == dat_sr_parse_eoe(file, &entry))) {
+		dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+				 "\n"
+				 "DAT Registry: entry \n"
+				 " ia_name %s\n"
+				 " api_version\n"
+				 "     type 0x%X\n"
+				 "     major.minor %d.%d\n"
+				 " is_thread_safe %d\n"
+				 " is_default %d\n"
+				 " lib_path %s\n"
+				 " provider_version\n"
+				 "     id %s\n"
+				 "     major.minor %d.%d\n"
+				 " ia_params %s\n"
+				 "\n",
+				 entry.ia_name,
+				 entry.api_version.type,
+				 entry.api_version.version.major,
+				 entry.api_version.version.minor,
+				 entry.is_thread_safe,
+				 entry.is_default,
+				 entry.lib_path,
+				 entry.provider_version.id,
+				 entry.provider_version.version.major,
+				 entry.provider_version.version.minor,
+				 entry.ia_params);
 
-	if ( DAT_TRUE == dat_sr_is_valid_entry (&entry) )
-	{
-	    /*
-	     * The static registry configuration file may have multiple
-	     * entries with the same IA name. The first entry will be
-	     * installed in the static registry causing subsequent attempts
-	     * to register the same IA name to fail. Therefore the return code
-	     * from dat_sr_load_entry() is ignored.
-	     */
-	    (void) dat_sr_load_entry (&entry);
-	}
+		if (DAT_TRUE == dat_sr_is_valid_entry(&entry)) {
+			/*
+			 * The static registry configuration file may have multiple
+			 * entries with the same IA name. The first entry will be
+			 * installed in the static registry causing subsequent attempts
+			 * to register the same IA name to fail. Therefore the return code
+			 * from dat_sr_load_entry() is ignored.
+			 */
+			(void)dat_sr_load_entry(&entry);
+		}
 
-	status = DAT_SUCCESS;
-    }
-    else /* resync */
-    {
-	DAT_SR_TOKEN 		token;
+		status = DAT_SUCCESS;
+	} else {		/* resync */
 
-	/*
-	 * The static registry format is specified in the DAT specification.
-	 * While the registry file's contents may change between revisions of
-	 * the specification, there is no way to determine the specification
-	 * version to which the configuration file conforms. If an entry is
-	 * found that does not match the expected format, the entry is discarded
-	 * and the parsing of the file continues. There is no way to determine if
-	 * the entry was an error or an entry confirming to an alternate version
-	 * of specification.
-	 */
+		DAT_SR_TOKEN token;
 
-	for (;;)
-	{
-	    if ( DAT_SUCCESS != dat_sr_get_token (file, &token) )
-	    {
-		status = DAT_INTERNAL_ERROR;
-		break;
-	    }
+		/*
+		 * The static registry format is specified in the DAT specification.
+		 * While the registry file's contents may change between revisions of
+		 * the specification, there is no way to determine the specification
+		 * version to which the configuration file conforms. If an entry is
+		 * found that does not match the expected format, the entry is discarded
+		 * and the parsing of the file continues. There is no way to determine if
+		 * the entry was an error or an entry confirming to an alternate version
+		 * of specification.
+		 */
 
-	    if ( DAT_SR_TOKEN_STRING != token.type )
-	    {
-		status = DAT_SUCCESS;
-		break;
-	    }
-	    else
-	    {
-		dat_os_free (token.value,
-			    (sizeof (char) * dat_os_strlen (token.value)) + 1);
-		continue;
-	    }
+		for (;;) {
+			if (DAT_SUCCESS != dat_sr_get_token(file, &token)) {
+				status = DAT_INTERNAL_ERROR;
+				break;
+			}
+
+			if (DAT_SR_TOKEN_STRING != token.type) {
+				status = DAT_SUCCESS;
+				break;
+			} else {
+				dat_os_free(token.value,
+					    (sizeof(char) *
+					     dat_os_strlen(token.value)) + 1);
+				continue;
+			}
+		}
 	}
-    }
 
-    /* free resources */
-    if ( NULL != entry.ia_name )
-    {
-	dat_os_free (entry.ia_name,
-		    sizeof (char) * (dat_os_strlen (entry.ia_name) + 1));
-    }
-    if ( NULL != entry.lib_path )
-    {
-	dat_os_free (entry.lib_path,
-		    sizeof (char) * (dat_os_strlen (entry.lib_path) + 1));
-    }
+	/* free resources */
+	if (NULL != entry.ia_name) {
+		dat_os_free(entry.ia_name,
+			    sizeof(char) * (dat_os_strlen(entry.ia_name) + 1));
+	}
+	if (NULL != entry.lib_path) {
+		dat_os_free(entry.lib_path,
+			    sizeof(char) * (dat_os_strlen(entry.lib_path) + 1));
+	}
 
-    if ( NULL != entry.provider_version.id )
-    {
-	dat_os_free (entry.provider_version.id,
-		    sizeof (char) * (dat_os_strlen (entry.provider_version.id) + 1));
-    }
+	if (NULL != entry.provider_version.id) {
+		dat_os_free(entry.provider_version.id,
+			    sizeof(char) *
+			    (dat_os_strlen(entry.provider_version.id) + 1));
+	}
 
-    if ( NULL != entry.ia_params )
-    {
-	dat_os_free (entry.ia_params,
-		    sizeof (char) * (dat_os_strlen (entry.ia_params) + 1));
-    }
+	if (NULL != entry.ia_params) {
+		dat_os_free(entry.ia_params,
+			    sizeof(char) * (dat_os_strlen(entry.ia_params) +
+					    1));
+	}
 
-    return status;
+	return status;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_ia_name
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_ia_name (
-    DAT_OS_FILE 	*file,
-    DAT_SR_CONF_ENTRY 	*entry)
+DAT_RETURN dat_sr_parse_ia_name(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type) {
-	dat_sr_put_token (file, &token);
-	goto bail;
-    }
-    entry->ia_name = token.value;
-    return DAT_SUCCESS;
+	if (DAT_SR_TOKEN_STRING != token.type) {
+		dat_sr_put_token(file, &token);
+		goto bail;
+	}
+	entry->ia_name = token.value;
+	return DAT_SUCCESS;
 
-bail:
-    return DAT_INTERNAL_ERROR;
+      bail:
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_ia_name
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_api (
-    DAT_OS_FILE 	*file,
-    DAT_SR_CONF_ENTRY 	*entry)
+DAT_RETURN dat_sr_parse_api(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type)
-	goto cleanup;
+	if (DAT_SR_TOKEN_STRING != token.type)
+		goto cleanup;
 
-    if (DAT_SUCCESS != dat_sr_convert_api(token.value, &entry->api_version))
-	goto cleanup;
-    
-    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);
-    return DAT_SUCCESS;
+	if (DAT_SUCCESS != dat_sr_convert_api(token.value, &entry->api_version))
+		goto cleanup;
 
-cleanup:
-    dat_sr_put_token (file, &token);
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " api_ver, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+	dat_os_free(token.value,
+		    (sizeof(char) * dat_os_strlen(token.value)) + 1);
+	return DAT_SUCCESS;
+
+      cleanup:
+	dat_sr_put_token(file, &token);
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " api_ver, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_thread_safety
  ***********************************************************************/
 
 static DAT_RETURN
-dat_sr_parse_thread_safety (
-    DAT_OS_FILE 	*file,
-    DAT_SR_CONF_ENTRY 	*entry)
+dat_sr_parse_thread_safety(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type)
-	goto cleanup;
+	if (DAT_SR_TOKEN_STRING != token.type)
+		goto cleanup;
 
-    if (DAT_SUCCESS != dat_sr_convert_thread_safety(
-			token.value, &entry->is_thread_safe))
-	goto cleanup;
-    
-    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);
-    return DAT_SUCCESS;
+	if (DAT_SUCCESS !=
+	    dat_sr_convert_thread_safety(token.value, &entry->is_thread_safe))
+		goto cleanup;
 
-cleanup:
-    dat_sr_put_token (file, &token);
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " thread_safety, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+	dat_os_free(token.value,
+		    (sizeof(char) * dat_os_strlen(token.value)) + 1);
+	return DAT_SUCCESS;
+
+      cleanup:
+	dat_sr_put_token(file, &token);
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " thread_safety, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_default
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_default (
-    DAT_OS_FILE 	*file,
-    DAT_SR_CONF_ENTRY 	*entry)
+DAT_RETURN dat_sr_parse_default(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type)
-	goto cleanup;
+	if (DAT_SR_TOKEN_STRING != token.type)
+		goto cleanup;
 
-    if (DAT_SUCCESS != dat_sr_convert_default(token.value, &entry->is_default))
-	goto cleanup;
-    
-    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);
-    return DAT_SUCCESS;
+	if (DAT_SUCCESS !=
+	    dat_sr_convert_default(token.value, &entry->is_default))
+		goto cleanup;
 
-cleanup:
-    dat_sr_put_token (file, &token);
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " default section, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+	dat_os_free(token.value,
+		    (sizeof(char) * dat_os_strlen(token.value)) + 1);
+	return DAT_SUCCESS;
+
+      cleanup:
+	dat_sr_put_token(file, &token);
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " default section, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_lib_path
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_lib_path (
-    DAT_OS_FILE 	*file,
-    DAT_SR_CONF_ENTRY 	*entry)
+DAT_RETURN dat_sr_parse_lib_path(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token(file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type) {
- 	dat_sr_put_token (file, &token);
-	goto bail;
-    }
-    entry->lib_path = token.value;
-    return DAT_SUCCESS;
+	if (DAT_SR_TOKEN_STRING != token.type) {
+		dat_sr_put_token(file, &token);
+		goto bail;
+	}
+	entry->lib_path = token.value;
+	return DAT_SUCCESS;
 
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " lib_path, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " lib_path, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
 /***********************************************************************
@@ -765,703 +640,577 @@
  ***********************************************************************/
 
 DAT_RETURN
-dat_sr_parse_provider_version (
-    DAT_OS_FILE 	*file,
-    DAT_SR_CONF_ENTRY 	*entry)
+dat_sr_parse_provider_version(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type)
-	goto cleanup;
+	if (DAT_SR_TOKEN_STRING != token.type)
+		goto cleanup;
 
-    if (DAT_SUCCESS != dat_sr_convert_provider_version(
-			token.value, &entry->provider_version))
-	goto cleanup;
-    
-    dat_os_free(token.value, (sizeof(char) * dat_os_strlen(token.value))+1);
-    return DAT_SUCCESS;
+	if (DAT_SUCCESS !=
+	    dat_sr_convert_provider_version(token.value,
+					    &entry->provider_version))
+		goto cleanup;
 
-cleanup:
-    dat_sr_put_token (file, &token);
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " provider_ver, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+	dat_os_free(token.value,
+		    (sizeof(char) * dat_os_strlen(token.value)) + 1);
+	return DAT_SUCCESS;
+
+      cleanup:
+	dat_sr_put_token(file, &token);
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " provider_ver, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
 /***********************************************************************
  * Function: dat_sr_parse_ia_params
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_ia_params (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry)
+DAT_RETURN dat_sr_parse_ia_params(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type) {
-	dat_sr_put_token (file, &token);
-	goto bail;
-    }
+	if (DAT_SR_TOKEN_STRING != token.type) {
+		dat_sr_put_token(file, &token);
+		goto bail;
+	}
 
-    entry->ia_params = token.value;
-    return DAT_SUCCESS;
+	entry->ia_params = token.value;
+	return DAT_SUCCESS;
 
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " ia_params, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " ia_params, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_platform_params
  ***********************************************************************/
 
 DAT_RETURN
-dat_sr_parse_platform_params (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry)
+dat_sr_parse_platform_params(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if (DAT_SR_TOKEN_STRING != token.type) {
-	dat_sr_put_token (file, &token);
-	goto bail;
-    }
+	if (DAT_SR_TOKEN_STRING != token.type) {
+		dat_sr_put_token(file, &token);
+		goto bail;
+	}
 
-    entry->platform_params = token.value;
-    return DAT_SUCCESS;
+	entry->platform_params = token.value;
+	return DAT_SUCCESS;
 
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " platform_params, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " platform_params, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_parse_eoe
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_parse_eoe (
-    DAT_OS_FILE *file,
-    DAT_SR_CONF_ENTRY *entry)
+DAT_RETURN dat_sr_parse_eoe(DAT_OS_FILE * file, DAT_SR_CONF_ENTRY * entry)
 {
-    DAT_SR_TOKEN 	token;
+	DAT_SR_TOKEN token;
 
-    if (DAT_SUCCESS != dat_sr_get_token (file, &token))
-	goto bail;
+	if (DAT_SUCCESS != dat_sr_get_token(file, &token))
+		goto bail;
 
-    if ((DAT_SR_TOKEN_EOF != token.type) &&
-	(DAT_SR_TOKEN_EOR != token.type)) {
-	dat_sr_put_token (file, &token);
-	goto bail;
-    }
-    
-    return DAT_SUCCESS;
+	if ((DAT_SR_TOKEN_EOF != token.type) &&
+	    (DAT_SR_TOKEN_EOR != token.type)) {
+		dat_sr_put_token(file, &token);
+		goto bail;
+	}
 
-bail:
-    dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR, 
-		     " ERR: corrupt dat.conf entry field:"
-		     " EOR, EOF, file offset=%ld\n", ftell(file));
-    return DAT_INTERNAL_ERROR;
+	return DAT_SUCCESS;
+
+      bail:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_ERROR,
+			 " ERR: corrupt dat.conf entry field:"
+			 " EOR, EOF, file offset=%ld\n", ftell(file));
+	return DAT_INTERNAL_ERROR;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_convert_api
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_convert_api (
-    char *str,
-    DAT_SR_API_VERSION *api_version)
+DAT_RETURN dat_sr_convert_api(char *str, DAT_SR_API_VERSION * api_version)
 {
-    int i;
-    int minor_i;
+	int i;
+	int minor_i;
 
-    if (dat_os_strlen(str) <= 0)
-	return DAT_INTERNAL_ERROR;
+	if (dat_os_strlen(str) <= 0)
+		return DAT_INTERNAL_ERROR;
 
-    if ( 'u' == str[0] )
-    {
-	api_version->type = DAT_SR_API_UDAT;
-    }
-    else if ( 'k' == str[0] )
-    {
-	api_version->type = DAT_SR_API_KDAT;
-    }
-    else
-    {
-	return DAT_INTERNAL_ERROR;
-    }
+	if ('u' == str[0]) {
+		api_version->type = DAT_SR_API_UDAT;
+	} else if ('k' == str[0]) {
+		api_version->type = DAT_SR_API_KDAT;
+	} else {
+		return DAT_INTERNAL_ERROR;
+	}
 
-    for ( i = 1 /* move past initial [u|k] */; '\0' != str[i]; i++ )
-    {
-	if ( '.' == str[i] )
-	{
-	    break;
+	for (i = 1 /* move past initial [u|k] */ ; '\0' != str[i]; i++) {
+		if ('.' == str[i]) {
+			break;
+		} else if (DAT_TRUE != dat_os_isdigit(str[i])) {
+			return DAT_INTERNAL_ERROR;
+		}
 	}
-	else if ( DAT_TRUE != dat_os_isdigit (str[i]) )
-	{
-	    return DAT_INTERNAL_ERROR;
-	}
-    }
 
-    api_version->version.major = (DAT_UINT32) dat_os_strtol (str + 1, NULL, 10);
+	api_version->version.major =
+	    (DAT_UINT32) dat_os_strtol(str + 1, NULL, 10);
 
-    /* move past '.' */
-    minor_i = ++i;
+	/* move past '.' */
+	minor_i = ++i;
 
-    for ( ; '\0' != str[i]; i++ )
-    {
-	if ( DAT_TRUE != dat_os_isdigit (str[i]) )
-	{
-	    return DAT_INTERNAL_ERROR;
+	for (; '\0' != str[i]; i++) {
+		if (DAT_TRUE != dat_os_isdigit(str[i])) {
+			return DAT_INTERNAL_ERROR;
+		}
 	}
-    }
 
-    api_version->version.minor = (DAT_UINT32) dat_os_strtol (str + minor_i, NULL, 10);
+	api_version->version.minor =
+	    (DAT_UINT32) dat_os_strtol(str + minor_i, NULL, 10);
 
-    if ( '\0' != str[i] )
-    {
-	return DAT_INTERNAL_ERROR;
-    }
+	if ('\0' != str[i]) {
+		return DAT_INTERNAL_ERROR;
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_convert_thread_safety
  ***********************************************************************/
 
 static DAT_RETURN
-dat_sr_convert_thread_safety (
-    char *str,
-    DAT_BOOLEAN *is_thread_safe)
+dat_sr_convert_thread_safety(char *str, DAT_BOOLEAN * is_thread_safe)
 {
-    if ( !dat_os_strncmp (str,
-			 DAT_SR_TOKEN_THREADSAFE,
-			 dat_os_strlen (DAT_SR_TOKEN_THREADSAFE)) )
-    {
-	*is_thread_safe = DAT_TRUE;
-	return DAT_SUCCESS;
-    }
-    else if ( !dat_os_strncmp (str,
-			      DAT_SR_TOKEN_NONTHREADSAFE,
-			      dat_os_strlen (DAT_SR_TOKEN_NONTHREADSAFE)) )
-    {
-	*is_thread_safe = DAT_FALSE;
-	return DAT_SUCCESS;
-    }
-    else
-    {
-	return DAT_INTERNAL_ERROR;
-    }
+	if (!dat_os_strncmp(str,
+			    DAT_SR_TOKEN_THREADSAFE,
+			    dat_os_strlen(DAT_SR_TOKEN_THREADSAFE))) {
+		*is_thread_safe = DAT_TRUE;
+		return DAT_SUCCESS;
+	} else if (!dat_os_strncmp(str,
+				   DAT_SR_TOKEN_NONTHREADSAFE,
+				   dat_os_strlen(DAT_SR_TOKEN_NONTHREADSAFE))) {
+		*is_thread_safe = DAT_FALSE;
+		return DAT_SUCCESS;
+	} else {
+		return DAT_INTERNAL_ERROR;
+	}
 }
 
-
 /***********************************************************************
  * Function: dat_sr_convert_default
  ***********************************************************************/
 
-static DAT_RETURN
-dat_sr_convert_default (
-    char *str,
-    DAT_BOOLEAN *is_default)
+static DAT_RETURN dat_sr_convert_default(char *str, DAT_BOOLEAN * is_default)
 {
-    if ( !dat_os_strncmp (str,
-			 DAT_SR_TOKEN_DEFAULT,
-			 dat_os_strlen (DAT_SR_TOKEN_DEFAULT)) )
-    {
-	*is_default = DAT_TRUE;
-	return DAT_SUCCESS;
-    }
-    else if ( !dat_os_strncmp (str,
-			      DAT_SR_TOKEN_NONDEFAULT,
-			      dat_os_strlen (DAT_SR_TOKEN_NONDEFAULT)) )
-    {
-	*is_default = DAT_FALSE;
-	return DAT_SUCCESS;
-    }
-    else
-    {
-	return DAT_INTERNAL_ERROR;
-    }
+	if (!dat_os_strncmp(str,
+			    DAT_SR_TOKEN_DEFAULT,
+			    dat_os_strlen(DAT_SR_TOKEN_DEFAULT))) {
+		*is_default = DAT_TRUE;
+		return DAT_SUCCESS;
+	} else if (!dat_os_strncmp(str,
+				   DAT_SR_TOKEN_NONDEFAULT,
+				   dat_os_strlen(DAT_SR_TOKEN_NONDEFAULT))) {
+		*is_default = DAT_FALSE;
+		return DAT_SUCCESS;
+	} else {
+		return DAT_INTERNAL_ERROR;
+	}
 }
 
-
 /***********************************************************************
  * Function: dat_sr_convert_provider_version
  ***********************************************************************/
 
 DAT_RETURN
-dat_sr_convert_provider_version (
-    char *str,
-    DAT_SR_PROVIDER_VERSION *provider_version)
+dat_sr_convert_provider_version(char *str,
+				DAT_SR_PROVIDER_VERSION * provider_version)
 {
-    DAT_RETURN 		status;
-    int 		i;
-    int 		decimal_i;
+	DAT_RETURN status;
+	int i;
+	int decimal_i;
 
-    if ((dat_os_strlen(str) <= 0) || (NULL != provider_version->id))
-	return DAT_INTERNAL_ERROR;
+	if ((dat_os_strlen(str) <= 0) || (NULL != provider_version->id))
+		return DAT_INTERNAL_ERROR;
 
-    status = DAT_SUCCESS;
+	status = DAT_SUCCESS;
 
-    for ( i = 0; '\0' != str[i]; i++ )
-    {
-	if ( '.' == str[i] )
-	{
-	    break;
+	for (i = 0; '\0' != str[i]; i++) {
+		if ('.' == str[i]) {
+			break;
+		}
 	}
-    }
 
-    /* if no id value was found */
-    if ( 0 == i )
-    {
-	status = DAT_INTERNAL_ERROR;
-	goto exit;
-    }
+	/* if no id value was found */
+	if (0 == i) {
+		status = DAT_INTERNAL_ERROR;
+		goto exit;
+	}
 
-    if ( NULL == (provider_version->id = dat_os_alloc (sizeof (char) * (i + 1))) )
-    {
-	    status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,DAT_RESOURCE_MEMORY);
-	goto exit;
-    }
+	if (NULL ==
+	    (provider_version->id = dat_os_alloc(sizeof(char) * (i + 1)))) {
+		status =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto exit;
+	}
 
-    dat_os_strncpy (provider_version->id, str, i);
-    provider_version->id[i] = '\0';
+	dat_os_strncpy(provider_version->id, str, i);
+	provider_version->id[i] = '\0';
 
-    /* move past '.' */
-    decimal_i = ++i;
+	/* move past '.' */
+	decimal_i = ++i;
 
-    for ( ; '\0' != str[i]; i++ )
-    {
-	if ( '.' == str[i] )
-	{
-	    break;
+	for (; '\0' != str[i]; i++) {
+		if ('.' == str[i]) {
+			break;
+		} else if (DAT_TRUE != dat_os_isdigit(str[i])) {
+			status = DAT_INTERNAL_ERROR;
+			goto exit;
+		}
 	}
-	else if ( DAT_TRUE != dat_os_isdigit (str[i]) )
-	{
-	    status = DAT_INTERNAL_ERROR;
-	    goto exit;
+
+	/* if no version value was found */
+	if (decimal_i == i) {
+		status = DAT_INTERNAL_ERROR;
+		goto exit;
 	}
-    }
 
-    /* if no version value was found */
-    if ( decimal_i == i )
-    {
-	status = DAT_INTERNAL_ERROR;
-	goto exit;
-    }
+	provider_version->version.major = (DAT_UINT32)
+	    dat_os_strtol(str + decimal_i, NULL, 10);
 
-    provider_version->version.major = (DAT_UINT32)
-	dat_os_strtol (str + decimal_i, NULL, 10);
+	/* move past '.' */
+	decimal_i = ++i;
 
-    /* move past '.' */
-    decimal_i = ++i;
+	for (; '\0' != str[i]; i++) {
+		if (DAT_TRUE != dat_os_isdigit(str[i])) {
+			status = DAT_INTERNAL_ERROR;
+			goto exit;
+		}
+	}
 
-    for ( ; '\0' != str[i]; i++ )
-    {
-	if ( DAT_TRUE != dat_os_isdigit (str[i]) )
-	{
-	    status = DAT_INTERNAL_ERROR;
-	    goto exit;
+	/* if no version value was found */
+	if (decimal_i == i) {
+		status = DAT_INTERNAL_ERROR;
+		goto exit;
 	}
-    }
 
-    /* if no version value was found */
-    if ( decimal_i == i )
-    {
-	status = DAT_INTERNAL_ERROR;
-	goto exit;
-    }
+	provider_version->version.minor = (DAT_UINT32)
+	    dat_os_strtol(str + decimal_i, NULL, 10);
 
-    provider_version->version.minor = (DAT_UINT32)
-	dat_os_strtol (str + decimal_i, NULL, 10);
+	if ('\0' != str[i]) {
+		status = DAT_INTERNAL_ERROR;
+		goto exit;
+	}
 
-    if ( '\0' != str[i] )
-    {
-	status = DAT_INTERNAL_ERROR;
-	goto exit;
-    }
-
-exit:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != provider_version->id )
-	{
-	    dat_os_free (provider_version->id,
-			sizeof (char) * (dat_os_strlen (provider_version->id) + 1));
-	    provider_version->id = NULL;
+      exit:
+	if (DAT_SUCCESS != status) {
+		if (NULL != provider_version->id) {
+			dat_os_free(provider_version->id,
+				    sizeof(char) *
+				    (dat_os_strlen(provider_version->id) + 1));
+			provider_version->id = NULL;
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_get_token
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_get_token (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token)
+DAT_RETURN dat_sr_get_token(DAT_OS_FILE * file, DAT_SR_TOKEN * token)
 {
-    if ( NULL == g_token_stack )
-    {
-	return dat_sr_read_token (file, token);
-    }
-    else
-    {
-	DAT_SR_STACK_NODE *top;
+	if (NULL == g_token_stack) {
+		return dat_sr_read_token(file, token);
+	} else {
+		DAT_SR_STACK_NODE *top;
 
-	top = g_token_stack;
+		top = g_token_stack;
 
-	*token = top->token;
-	g_token_stack = top->next;
+		*token = top->token;
+		g_token_stack = top->next;
 
-	dat_os_free (top, sizeof (DAT_SR_STACK_NODE));
+		dat_os_free(top, sizeof(DAT_SR_STACK_NODE));
 
-	return DAT_SUCCESS;
-    }
+		return DAT_SUCCESS;
+	}
 }
 
-
 /***********************************************************************
  * Function: dat_sr_put_token
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_put_token (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token)
+DAT_RETURN dat_sr_put_token(DAT_OS_FILE * file, DAT_SR_TOKEN * token)
 {
-    DAT_SR_STACK_NODE *top;
+	DAT_SR_STACK_NODE *top;
 
-    if ( NULL == (top = dat_os_alloc (sizeof (DAT_SR_STACK_NODE))) )
-    {
-	return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
-    }
+	if (NULL == (top = dat_os_alloc(sizeof(DAT_SR_STACK_NODE)))) {
+		return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
+	}
 
-    top->token = *token;
-    top->next = g_token_stack;
-    g_token_stack = top;
+	top->token = *token;
+	top->next = g_token_stack;
+	g_token_stack = top;
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_read_token
  ***********************************************************************/
 
-DAT_RETURN
-dat_sr_read_token (
-    DAT_OS_FILE 		*file,
-    DAT_SR_TOKEN 		*token)
+DAT_RETURN dat_sr_read_token(DAT_OS_FILE * file, DAT_SR_TOKEN * token)
 {
-    DAT_OS_FILE_POS 		pos;
-    DAT_OS_SIZE 		token_len;
-    DAT_COUNT 			num_escape_seq;
-    DAT_BOOLEAN 		is_quoted_str;
-    DAT_BOOLEAN 		is_prev_char_backslash;
+	DAT_OS_FILE_POS pos;
+	DAT_OS_SIZE token_len;
+	DAT_COUNT num_escape_seq;
+	DAT_BOOLEAN is_quoted_str;
+	DAT_BOOLEAN is_prev_char_backslash;
 
-    /*
-     * The DAT standard does not specify a maximum size for quoted strings.
-     * Therefore the tokenizer must be able to read in a token of arbitrary
-     * size. Instead of allocating a fixed length buffer, the tokenizer first
-     * scans the input a single character at a time looking for the begining
-     * and end of the token. Once the these positions are found, the entire
-     * token is read into memory. By using this algorithm,the implementation
-     * does not place an arbitrary maximum on the token size.
-     */
+	/*
+	 * The DAT standard does not specify a maximum size for quoted strings.
+	 * Therefore the tokenizer must be able to read in a token of arbitrary
+	 * size. Instead of allocating a fixed length buffer, the tokenizer first
+	 * scans the input a single character at a time looking for the begining
+	 * and end of the token. Once the these positions are found, the entire
+	 * token is read into memory. By using this algorithm,the implementation
+	 * does not place an arbitrary maximum on the token size.
+	 */
 
-    token_len = 0;
-    num_escape_seq = 0;
-    is_quoted_str = DAT_FALSE;
-    is_prev_char_backslash = DAT_FALSE;
+	token_len = 0;
+	num_escape_seq = 0;
+	is_quoted_str = DAT_FALSE;
+	is_prev_char_backslash = DAT_FALSE;
 
-    for (;;)
-    {
-	DAT_OS_FILE_POS cur_pos;
-	int c;
+	for (;;) {
+		DAT_OS_FILE_POS cur_pos;
+		int c;
 
-	/* if looking for start of the token */
-	if ( 0 == token_len )
-	{
-	    if ( DAT_SUCCESS != dat_os_fgetpos (file, &cur_pos) )
-	    {
-		return DAT_INTERNAL_ERROR;
-	    }
-	}
+		/* if looking for start of the token */
+		if (0 == token_len) {
+			if (DAT_SUCCESS != dat_os_fgetpos(file, &cur_pos)) {
+				return DAT_INTERNAL_ERROR;
+			}
+		}
 
-	c = dat_os_fgetc (file);
+		c = dat_os_fgetc(file);
 
-	/* if looking for start of the token */
-	if ( 0 == token_len )
-	{
-	    if ( EOF == c )
-	    {
-		token->type = DAT_SR_TOKEN_EOF;
-		token->value = NULL;
-		token->value_len = 0;
-		goto success;
-	    }
-	    else if ( DAT_SR_CHAR_NEWLINE == c )
-	    {
-		token->type = DAT_SR_TOKEN_EOR;
-		token->value = NULL;
-		token->value_len = 0;
-		goto success;
-	    }
-	    else if ( dat_os_isblank (c) )
-	    {
-		continue;
-	    }
-	    else if ( DAT_SR_CHAR_COMMENT == c )
-	    {
-		dat_sr_read_comment (file);
-		continue;
-	    }
-	    else
-	    {
-		if ( DAT_SR_CHAR_QUOTE == c )
-		{
-		    is_quoted_str = DAT_TRUE;
+		/* if looking for start of the token */
+		if (0 == token_len) {
+			if (EOF == c) {
+				token->type = DAT_SR_TOKEN_EOF;
+				token->value = NULL;
+				token->value_len = 0;
+				goto success;
+			} else if (DAT_SR_CHAR_NEWLINE == c) {
+				token->type = DAT_SR_TOKEN_EOR;
+				token->value = NULL;
+				token->value_len = 0;
+				goto success;
+			} else if (dat_os_isblank(c)) {
+				continue;
+			} else if (DAT_SR_CHAR_COMMENT == c) {
+				dat_sr_read_comment(file);
+				continue;
+			} else {
+				if (DAT_SR_CHAR_QUOTE == c) {
+					is_quoted_str = DAT_TRUE;
+				}
+
+				pos = cur_pos;
+				token_len++;
+			}
+		} else {	/* looking for the end of the token */
+
+			if (EOF == c) {
+				break;
+			} else if (DAT_SR_CHAR_NEWLINE == c) {
+				/* put back the newline */
+				dat_os_fputc(file, c);
+				break;
+			} else if (!is_quoted_str && dat_os_isblank(c)) {
+				break;
+			} else {
+				token_len++;
+
+				if ((DAT_SR_CHAR_QUOTE == c)
+				    && !is_prev_char_backslash) {
+					break;
+				} else if ((DAT_SR_CHAR_BACKSLASH == c)
+					   && !is_prev_char_backslash) {
+					is_prev_char_backslash = DAT_TRUE;
+					num_escape_seq++;
+				} else {
+					is_prev_char_backslash = DAT_FALSE;
+				}
+			}
 		}
+	}
 
-		pos = cur_pos;
-		token_len++;
-	    }
+	/* the token was a string */
+	if (DAT_SUCCESS != dat_os_fsetpos(file, &pos)) {
+		return DAT_INTERNAL_ERROR;
 	}
-	else /* looking for the end of the token */
-	{
-	    if ( EOF == c )
-	    {
-		break;
-	    }
-	    else if ( DAT_SR_CHAR_NEWLINE == c )
-	    {
-		/* put back the newline */
-		dat_os_fputc (file, c);
-		break;
-	    }
-	    else if ( !is_quoted_str && dat_os_isblank (c) )
-	    {
-		break;
-	    }
-	    else
-	    {
-		token_len++;
 
-		if ( (DAT_SR_CHAR_QUOTE == c) && !is_prev_char_backslash )
-		{
-		    break;
+	if (is_quoted_str) {
+		if (DAT_SUCCESS != dat_sr_read_quoted_str(file,
+							  token,
+							  token_len,
+							  num_escape_seq)) {
+			return DAT_INTERNAL_ERROR;
 		}
-		else if ( (DAT_SR_CHAR_BACKSLASH == c) && !is_prev_char_backslash )
-		{
-		    is_prev_char_backslash = DAT_TRUE;
-		    num_escape_seq++;
+	} else {
+		if (DAT_SUCCESS != dat_sr_read_str(file, token, token_len)) {
+			return DAT_INTERNAL_ERROR;
 		}
-		else
-		{
-		    is_prev_char_backslash = DAT_FALSE;
-		}
-	    }
 	}
-    }
 
-    /* the token was a string */
-    if ( DAT_SUCCESS != dat_os_fsetpos (file, &pos) )
-    {
-	return DAT_INTERNAL_ERROR;
-    }
+      success:
+	dat_os_dbg_print(DAT_OS_DBG_TYPE_SR,
+			 "\n"
+			 "DAT Registry: token\n"
+			 " type  %s\n"
+			 " value <%s>\n"
+			 "\n",
+			 dat_sr_type_to_str(token->type),
+			 ((DAT_SR_TOKEN_STRING ==
+			   token->type) ? token->value : ""));
 
-    if ( is_quoted_str )
-    {
-	if ( DAT_SUCCESS != dat_sr_read_quoted_str (file,
-						   token,
-						   token_len,
-						   num_escape_seq) )
-	{
-	    return DAT_INTERNAL_ERROR;
-	}
-    }
-    else
-    {
-	if ( DAT_SUCCESS != dat_sr_read_str (file,
-					    token,
-					    token_len) )
-	{
-	    return DAT_INTERNAL_ERROR;
-	}
-    }
-
-success:
-    dat_os_dbg_print (DAT_OS_DBG_TYPE_SR,
-		     "\n"
-		     "DAT Registry: token\n"
-		     " type  %s\n"
-		     " value <%s>\n"
-		     "\n",
-		     dat_sr_type_to_str (token->type),
-		     ((DAT_SR_TOKEN_STRING == token->type) ? token->value : "") );
-
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_read_str
  ***********************************************************************/
 
 DAT_RETURN
-dat_sr_read_str (
-    DAT_OS_FILE *file,
-    DAT_SR_TOKEN *token,
-    DAT_OS_SIZE token_len)
+dat_sr_read_str(DAT_OS_FILE * file, DAT_SR_TOKEN * token, DAT_OS_SIZE token_len)
 {
-    token->type = DAT_SR_TOKEN_STRING;
-    token->value_len = sizeof (char) * (token_len + 1); /* +1 for null termination */
-    if ( NULL == (token->value = dat_os_alloc (token->value_len)) )
-    {
-	return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
-    }
+	token->type = DAT_SR_TOKEN_STRING;
+	token->value_len = sizeof(char) * (token_len + 1);	/* +1 for null termination */
+	if (NULL == (token->value = dat_os_alloc(token->value_len))) {
+		return DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
+	}
 
-    if ( token_len != dat_os_fread (file, token->value, token_len) )
-    {
-	dat_os_free (token->value, token->value_len);
-	token->value = NULL;
+	if (token_len != dat_os_fread(file, token->value, token_len)) {
+		dat_os_free(token->value, token->value_len);
+		token->value = NULL;
 
-	return DAT_INTERNAL_ERROR;
-    }
+		return DAT_INTERNAL_ERROR;
+	}
 
-    token->value[token->value_len - 1] = '\0';
+	token->value[token->value_len - 1] = '\0';
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_read_quoted_str
  ***********************************************************************/
 
 DAT_RETURN
-dat_sr_read_quoted_str (
-    DAT_OS_FILE 	*file,
-    DAT_SR_TOKEN 	*token,
-    DAT_OS_SIZE 	token_len,
-    DAT_COUNT 		num_escape_seq)
+dat_sr_read_quoted_str(DAT_OS_FILE * file,
+		       DAT_SR_TOKEN * token,
+		       DAT_OS_SIZE token_len, DAT_COUNT num_escape_seq)
 {
-    DAT_OS_SIZE 	str_len;
-    DAT_OS_SIZE 	i;
-    DAT_OS_SIZE 	j;
-    int 		c;
-    DAT_RETURN 		status;
-    DAT_BOOLEAN 	is_prev_char_backslash;
+	DAT_OS_SIZE str_len;
+	DAT_OS_SIZE i;
+	DAT_OS_SIZE j;
+	int c;
+	DAT_RETURN status;
+	DAT_BOOLEAN is_prev_char_backslash;
 
-    str_len = token_len - 2; /* minus 2 " characters */
-    is_prev_char_backslash = DAT_FALSE;
-    status = DAT_SUCCESS;
+	str_len = token_len - 2;	/* minus 2 " characters */
+	is_prev_char_backslash = DAT_FALSE;
+	status = DAT_SUCCESS;
 
-    token->type = DAT_SR_TOKEN_STRING;
-    /* +1 for null termination */
-    token->value_len = sizeof (char) * (str_len - num_escape_seq + 1);
+	token->type = DAT_SR_TOKEN_STRING;
+	/* +1 for null termination */
+	token->value_len = sizeof(char) * (str_len - num_escape_seq + 1);
 
-    if ( NULL == (token->value = dat_os_alloc (token->value_len)) )
-    {
-	status = DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
-	goto exit;
-    }
+	if (NULL == (token->value = dat_os_alloc(token->value_len))) {
+		status = DAT_INSUFFICIENT_RESOURCES | DAT_RESOURCE_MEMORY;
+		goto exit;
+	}
 
-    /* throw away " */
-    if ( DAT_SR_CHAR_QUOTE != dat_os_fgetc (file) )
-    {
-	status = DAT_INTERNAL_ERROR;
-	goto exit;
-    }
+	/* throw away " */
+	if (DAT_SR_CHAR_QUOTE != dat_os_fgetc(file)) {
+		status = DAT_INTERNAL_ERROR;
+		goto exit;
+	}
 
-    for ( i = 0, j = 0; i < str_len; i++ )
-    {
-	c = dat_os_fgetc (file);
+	for (i = 0, j = 0; i < str_len; i++) {
+		c = dat_os_fgetc(file);
 
-	if ( EOF == c )
-	{
-	    status = DAT_INTERNAL_ERROR;
-	    goto exit;
+		if (EOF == c) {
+			status = DAT_INTERNAL_ERROR;
+			goto exit;
+		} else if ((DAT_SR_CHAR_BACKSLASH == c)
+			   && !is_prev_char_backslash) {
+			is_prev_char_backslash = DAT_TRUE;
+		} else {
+			token->value[j] = (char)c;
+			j++;
+
+			is_prev_char_backslash = DAT_FALSE;
+		}
 	}
-	else if ( (DAT_SR_CHAR_BACKSLASH == c) && !is_prev_char_backslash )
-	{
-	    is_prev_char_backslash = DAT_TRUE;
-	}
-	else
-	{
-	    token->value[j] = (char)c;
-	    j++;
 
-	    is_prev_char_backslash = DAT_FALSE;
+	/* throw away " */
+	if (DAT_SR_CHAR_QUOTE != dat_os_fgetc(file)) {
+		status = DAT_INTERNAL_ERROR;
+		goto exit;
 	}
-    }
 
-    /* throw away " */
-    if ( DAT_SR_CHAR_QUOTE != dat_os_fgetc (file) )
-    {
-	status = DAT_INTERNAL_ERROR;
-	goto exit;
-    }
+	token->value[token->value_len - 1] = '\0';
 
-    token->value[token->value_len - 1] = '\0';
-
-exit:
-    if ( DAT_SUCCESS != status )
-    {
-	if ( NULL != token->value )
-	{
-	    dat_os_free (token->value, token->value_len);
-	    token->value = NULL;
+      exit:
+	if (DAT_SUCCESS != status) {
+		if (NULL != token->value) {
+			dat_os_free(token->value, token->value_len);
+			token->value = NULL;
+		}
 	}
-    }
 
-    return status;
+	return status;
 }
 
-
 /***********************************************************************
  * Function: dat_sr_read_comment
  ***********************************************************************/
 
-void
-dat_sr_read_comment (
-    DAT_OS_FILE *file)
+void dat_sr_read_comment(DAT_OS_FILE * file)
 {
-    int c;
+	int c;
 
-    /* read up to an EOR or EOF to move past the comment */
-    do
-    {
-	c = dat_os_fgetc (file);
-    } while ( (DAT_SR_CHAR_NEWLINE != c) && (EOF != c) );
+	/* read up to an EOR or EOF to move past the comment */
+	do {
+		c = dat_os_fgetc(file);
+	} while ((DAT_SR_CHAR_NEWLINE != c) && (EOF != c));
 
-    /* put back the newline */
-    dat_os_ungetc (file, c);
+	/* put back the newline */
+	dat_os_ungetc(file, c);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.am
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.am	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.am	2009-05-28 20:23:18 UTC (rev 260)
@@ -63,5 +63,5 @@
 	udapl/udapl_tdep.c			\
 	mdep/linux/dapl_mdep_user.c
 	
-dapltest_LDADD = $(srcdir)/../../dat/udat/libdat2.la
+dapltest_LDADD = $(top_builddir)/dat/udat/libdat2.la
 dapltest_LDFLAGS = -lpthread  

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.in
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.in	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/Makefile.in	2009-05-28 20:23:18 UTC (rev 260)
@@ -91,7 +91,7 @@
 	dapltest-udapl_tdep.$(OBJEXT) \
 	dapltest-dapl_mdep_user.$(OBJEXT)
 dapltest_OBJECTS = $(am_dapltest_OBJECTS)
-dapltest_DEPENDENCIES = $(srcdir)/../../dat/udat/libdat2.la
+dapltest_DEPENDENCIES = $(top_builddir)/dat/udat/libdat2.la
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
 am__depfiles_maybe = depfiles
@@ -159,6 +159,8 @@
 OS_RHEL4_TRUE = @OS_RHEL4_TRUE@
 OS_RHEL5_FALSE = @OS_RHEL5_FALSE@
 OS_RHEL5_TRUE = @OS_RHEL5_TRUE@
+OS_SUSE11_FALSE = @OS_SUSE11_FALSE@
+OS_SUSE11_TRUE = @OS_SUSE11_TRUE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -272,7 +274,7 @@
 	udapl/udapl_tdep.c			\
 	mdep/linux/dapl_mdep_user.c
 
-dapltest_LDADD = $(srcdir)/../../dat/udat/libdat2.la
+dapltest_LDADD = $(top_builddir)/dat/udat/libdat2.la
 dapltest_LDFLAGS = -lpthread  
 all: all-am
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_fft_cmd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_fft_cmd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_fft_cmd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,324 +31,295 @@
 #include "dapl_proto.h"
 
 //---------------------------------------------------------------------------
-void DT_FFT_Cmd_Init (FFT_Cmd_t *cmd)
+void DT_FFT_Cmd_Init(FFT_Cmd_t * cmd)
 {
-    int i;
-    memset ((void *)cmd, 0, sizeof (FFT_Cmd_t));
-    cmd->fft_type = NONE;
-    cmd->device_name[0] = '\0';
-    cmd->server_name[0] = '\0';
-    for (i=0; i<MAXCASES; i++)
-    {
-	cmd->cases_flag[i] = false;
-    }
-    cmd->size = 0;
-    cmd->num_iter = 1000;
-    cmd->num_threads = 10;
-    cmd->num_vis = 500;
-    cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
+	int i;
+	memset((void *)cmd, 0, sizeof(FFT_Cmd_t));
+	cmd->fft_type = NONE;
+	cmd->device_name[0] = '\0';
+	cmd->server_name[0] = '\0';
+	for (i = 0; i < MAXCASES; i++) {
+		cmd->cases_flag[i] = false;
+	}
+	cmd->size = 0;
+	cmd->num_iter = 1000;
+	cmd->num_threads = 10;
+	cmd->num_vis = 500;
+	cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
 }
 
 //------------------------------------------------------------------------------
-bool DT_FFT_Cmd_Parse (FFT_Cmd_t *cmd,
-		    int               my_argc,
-		    char              ** my_argv,
-		    mygetopt_t        *opts)
+bool DT_FFT_Cmd_Parse(FFT_Cmd_t * cmd,
+		      int my_argc, char **my_argv, mygetopt_t * opts)
 {
-    int           c;
-    int           i, caseNum;
-    unsigned int  len;
+	int c;
+	int i, caseNum;
+	unsigned int len;
 
-    for (;;)
-    {
-	c = DT_mygetopt_r (my_argc, my_argv, "D:f:s:i:t:v:R:", opts);
-	if (c == EOF)
-	{
-	    break;
-	}
-	switch (c)
-	{
-	    case 'D':  //device name
-	    {
-		strcpy (cmd->device_name, opts->optarg);
-		break;
-	    }
-	    case 's':  //server name
-	    {
-		strcpy (cmd->server_name, opts->optarg);
-		break;
-	    }
-	    case 'i':	// num iterations
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -i<iterations> option\n");
-		    DT_FFT_Cmd_Usage ();
-		    return (false);
+	for (;;) {
+		c = DT_mygetopt_r(my_argc, my_argv, "D:f:s:i:t:v:R:", opts);
+		if (c == EOF) {
+			break;
 		}
-		cmd->num_iter = atoi (opts->optarg);
-		break;
-	    }
-	    case 't':	// num threads
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -t<num_threads> option\n");
-		    DT_FFT_Cmd_Usage ();
-		    return (false);
-		}
-		cmd->num_threads = atoi (opts->optarg);
-		break;
-	    }
-	    case 'v':	// num vis
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -v<num_vis> option\n");
-		    DT_FFT_Cmd_Usage ();
-		    return (false);
-		}
-		cmd->num_vis = atoi (opts->optarg);
-		break;
-	    }
-	    case 'f':  //function feature
-	    {
-		if (strcmp (opts->optarg, "hwconn")==0)
-		{
-		    cmd->fft_type = HWCONN;
-		    cmd->size = 4;  //4 cases for hwconn
-		    break;
-		}
-#if 0 // not yet implemented
-		else if (strcmp (opts->optarg, "cqmgt")==0)
-		{
-		    cmd->fft_type = CQMGT;
-		    cmd->size = 10;  //10 cases for cqmgt
-		    break;
-		}
+		switch (c) {
+		case 'D':	//device name
+			{
+				strcpy(cmd->device_name, opts->optarg);
+				break;
+			}
+		case 's':	//server name
+			{
+				strcpy(cmd->server_name, opts->optarg);
+				break;
+			}
+		case 'i':	// num iterations
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -i<iterations> option\n");
+					DT_FFT_Cmd_Usage();
+					return (false);
+				}
+				cmd->num_iter = atoi(opts->optarg);
+				break;
+			}
+		case 't':	// num threads
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -t<num_threads> option\n");
+					DT_FFT_Cmd_Usage();
+					return (false);
+				}
+				cmd->num_threads = atoi(opts->optarg);
+				break;
+			}
+		case 'v':	// num vis
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -v<num_vis> option\n");
+					DT_FFT_Cmd_Usage();
+					return (false);
+				}
+				cmd->num_vis = atoi(opts->optarg);
+				break;
+			}
+		case 'f':	//function feature
+			{
+				if (strcmp(opts->optarg, "hwconn") == 0) {
+					cmd->fft_type = HWCONN;
+					cmd->size = 4;	//4 cases for hwconn
+					break;
+				}
+#if 0				// not yet implemented
+				else if (strcmp(opts->optarg, "cqmgt") == 0) {
+					cmd->fft_type = CQMGT;
+					cmd->size = 10;	//10 cases for cqmgt
+					break;
+				}
 #endif
-		else if (strcmp (opts->optarg, "endpoint")==0)
-		{
-		    cmd->fft_type = ENDPOINT;
-		    cmd->size = 3;  //13 cases for endpoint
-		    break;
-		}
-		else if (strcmp (opts->optarg, "pz")==0)
-		{
-		    cmd->fft_type = PTAGMGT;
-		    cmd->size = 3;  //10 cases for Ptagmgt
-		    break;
-		}
-		else if (strcmp (opts->optarg, "mem")==0)
-		{
-		    cmd->fft_type = MEMMGT;
-		    cmd->size = 5;  //12 cases for Memmgt
-		    break;
-		}
-		else if (strcmp (opts->optarg, "connmgt")==0)
-		{
-		    cmd->fft_type = CONNMGT;
-		    cmd->size = 2;  //16 cases for connmgt
-		    break;
-		}
-#if 0 // not yet implemented
-		else if (strcmp (opts->optarg, "connmgt_client")==0)
-		{
-		    cmd->fft_type = CONNMGT_CLIENT;
-		    cmd->size = 16;  //16 cases for connmgt_client
-		    break;
-		}
+				else if (strcmp(opts->optarg, "endpoint") == 0) {
+					cmd->fft_type = ENDPOINT;
+					cmd->size = 3;	//13 cases for endpoint
+					break;
+				} else if (strcmp(opts->optarg, "pz") == 0) {
+					cmd->fft_type = PTAGMGT;
+					cmd->size = 3;	//10 cases for Ptagmgt
+					break;
+				} else if (strcmp(opts->optarg, "mem") == 0) {
+					cmd->fft_type = MEMMGT;
+					cmd->size = 5;	//12 cases for Memmgt
+					break;
+				} else if (strcmp(opts->optarg, "connmgt") == 0) {
+					cmd->fft_type = CONNMGT;
+					cmd->size = 2;	//16 cases for connmgt
+					break;
+				}
+#if 0				// not yet implemented
+				else if (strcmp(opts->optarg, "connmgt_client")
+					 == 0) {
+					cmd->fft_type = CONNMGT_CLIENT;
+					cmd->size = 16;	//16 cases for connmgt_client
+					break;
+				}
 #endif
-		else if (strcmp (opts->optarg, "queryinfo")==0)
-		{
-		    cmd->fft_type = QUERYINFO;
+				else if (strcmp(opts->optarg, "queryinfo") == 0) {
+					cmd->fft_type = QUERYINFO;
 #ifndef __KDAPLTEST__
-		    cmd->size = 18;  //18 cases for UDAPL queryinfo
+					cmd->size = 18;	//18 cases for UDAPL queryinfo
 #else
-		    cmd->size = 16;  //16 cases for KDAPL queryinfo
+					cmd->size = 16;	//16 cases for KDAPL queryinfo
 #endif
-		    break;
-		}
-#if 0 // not yet implemented
-		else if (strcmp (opts->optarg, "ns")==0)
-		{
-		    cmd->fft_type = NS;
-		    cmd->size = 10;  //10 cases for ns
-		    break;
-		}
-		else if (strcmp (opts->optarg, "errhand")==0)
-		{
-		    cmd->fft_type = ERRHAND;
-		    cmd->size = 2;  //2 cases for errhand
-		    break;
-		}
-		else if (strcmp (opts->optarg, "unsupp")==0)
-		{
-		    cmd->fft_type = UNSUPP;
-		    cmd->size = 2;  //2 cases for unsupp
-		    break;
-		}
-		else if (strcmp (opts->optarg, "stress")==0)
-		{
-		    cmd->fft_type = STRESS;
-		    cmd->size = 6;  //6 cases for stress
-		    break;
-		}
-		else if (strcmp (opts->optarg, "stress_client")==0)
-		{
-		    cmd->fft_type = STRESS_CLIENT;
-		    cmd->size = 6;  //6 cases for stress_client
-		    break;
-		}
+					break;
+				}
+#if 0				// not yet implemented
+				else if (strcmp(opts->optarg, "ns") == 0) {
+					cmd->fft_type = NS;
+					cmd->size = 10;	//10 cases for ns
+					break;
+				} else if (strcmp(opts->optarg, "errhand") == 0) {
+					cmd->fft_type = ERRHAND;
+					cmd->size = 2;	//2 cases for errhand
+					break;
+				} else if (strcmp(opts->optarg, "unsupp") == 0) {
+					cmd->fft_type = UNSUPP;
+					cmd->size = 2;	//2 cases for unsupp
+					break;
+				} else if (strcmp(opts->optarg, "stress") == 0) {
+					cmd->fft_type = STRESS;
+					cmd->size = 6;	//6 cases for stress
+					break;
+				} else if (strcmp(opts->optarg, "stress_client")
+					   == 0) {
+					cmd->fft_type = STRESS_CLIENT;
+					cmd->size = 6;	//6 cases for stress_client
+					break;
+				}
 #endif
-		else
-		{
-		    DT_Mdep_printf ("don't know this function feature: %s\n",
-			opts->optarg);
-		    DT_FFT_Cmd_Usage ();
-		    return (false);
+				else {
+					DT_Mdep_printf
+					    ("don't know this function feature: %s\n",
+					     opts->optarg);
+					DT_FFT_Cmd_Usage();
+					return (false);
+				}
+			}
+		case 'R':	// Service Reliability Level
+			{
+				cmd->ReliabilityLevel =
+				    DT_ParseQoS(opts->optarg);
+				if (0 == cmd->ReliabilityLevel) {
+					DT_Mdep_printf
+					    ("Invalid FFT Test Parameter: %c\n",
+					     c);
+					DT_FFT_Cmd_Usage();
+					return (false);
+				}
+				break;
+			}
+
+		case '?':
+		default:
+			{
+				DT_Mdep_printf
+				    ("Invalid FFT Test Parameter: %c\n", c);
+				DT_FFT_Cmd_Usage();
+				return (false);
+			}
 		}
-	    }
-	    case 'R':  // Service Reliability Level
-	    {
-		cmd->ReliabilityLevel = DT_ParseQoS (opts->optarg);
-		if (0 == cmd->ReliabilityLevel)
-		{
-		    DT_Mdep_printf ("Invalid FFT Test Parameter: %c\n", c);
-		    DT_FFT_Cmd_Usage ();
-		    return (false);
+	}
+	if (cmd->device_name[0] == '\0') {
+		if (!DT_Mdep_GetDefaultDeviceName(cmd->device_name)) {
+			DT_Mdep_printf("can't get default device name\n");
+			DT_FFT_Cmd_Usage();
+			return (false);
 		}
-		break;
-	    }
+	}
 
-	    case '?':
-	    default:
-	    {
-		DT_Mdep_printf ("Invalid FFT Test Parameter: %c\n", c);
-		DT_FFT_Cmd_Usage ();
+	if (cmd->fft_type == NONE) {
+		DT_Mdep_printf
+		    ("must define the function feature with -f to test\n");
+		DT_FFT_Cmd_Usage();
 		return (false);
-	    }
 	}
-    }
-    if (cmd->device_name[0] == '\0')
-    {
-	if (!DT_Mdep_GetDefaultDeviceName (cmd->device_name))
-	{
-	    DT_Mdep_printf ("can't get default device name\n");
-	    DT_FFT_Cmd_Usage ();
-	    return (false);
+	if (cmd->server_name[0] == '\0' &&
+	    (cmd->fft_type == CONNMGT_CLIENT || cmd->fft_type == DATAXFER_CLIENT
+	     || cmd->fft_type == UNSUPP || cmd->fft_type == STRESS_CLIENT)) {
+		DT_Mdep_printf("must define the server name with -s option\n");
+		DT_FFT_Cmd_Usage();
+		return (false);
 	}
-    }
 
-    if (cmd->fft_type ==NONE)
-    {
-	DT_Mdep_printf ("must define the function feature with -f to test\n");
-	DT_FFT_Cmd_Usage ();
-	return (false);
-    }
-    if (cmd->server_name[0] =='\0' &&
-	(cmd->fft_type==CONNMGT_CLIENT || cmd->fft_type == DATAXFER_CLIENT ||
-	 cmd->fft_type == UNSUPP || cmd->fft_type == STRESS_CLIENT))
-    {
-	DT_Mdep_printf ("must define the server name with -s option\n");
-	DT_FFT_Cmd_Usage ();
-	return (false);
-    }
-
-    if (cmd->server_name[0] =='\0' && cmd->fft_type==NS )
-    {
-	DT_Mdep_printf ("\
+	if (cmd->server_name[0] == '\0' && cmd->fft_type == NS) {
+		DT_Mdep_printf("\
 	    Must specify host name or host IP address with -s option to be tested\n");
-	DT_FFT_Cmd_Usage ();
-	return (false);
-    }
-
-    //now parse the test cases
-    if (opts->optind == my_argc) //default: test all cases
-    {
-	for (i=0; i<cmd->size; i++)
-	{
-	    cmd->cases_flag[i] = true;
+		DT_FFT_Cmd_Usage();
+		return (false);
 	}
-	return true;
-    }
-
-    //test specified cases
-    i = opts->optind;
-    while (i<my_argc)
-    {
-	if (strlen (my_argv[i])<5 || strncmp (my_argv[i], "case", 4) !=0)
+	//now parse the test cases
+	if (opts->optind == my_argc)	//default: test all cases
 	{
-	    DT_Mdep_printf ("test cases format is not correct: %s\n", my_argv[i]);
-	    DT_FFT_Cmd_Usage ();
-	    return (false);
+		for (i = 0; i < cmd->size; i++) {
+			cmd->cases_flag[i] = true;
+		}
+		return true;
 	}
-	len = strspn (my_argv[i] + 4, "0123456789");
-	if (len==0 || len != strlen (my_argv[i] + 4) )
-	{
-	    DT_Mdep_printf ("must specify case number: %s\n", my_argv[i]);
-	    DT_FFT_Cmd_Usage ();
-	    return (false);
+	//test specified cases
+	i = opts->optind;
+	while (i < my_argc) {
+		if (strlen(my_argv[i]) < 5
+		    || strncmp(my_argv[i], "case", 4) != 0) {
+			DT_Mdep_printf("test cases format is not correct: %s\n",
+				       my_argv[i]);
+			DT_FFT_Cmd_Usage();
+			return (false);
+		}
+		len = strspn(my_argv[i] + 4, "0123456789");
+		if (len == 0 || len != strlen(my_argv[i] + 4)) {
+			DT_Mdep_printf("must specify case number: %s\n",
+				       my_argv[i]);
+			DT_FFT_Cmd_Usage();
+			return (false);
+		}
+		caseNum = atoi(my_argv[i] + 4);
+		if (caseNum < 0 || caseNum >= cmd->size) {
+			DT_Mdep_printf
+			    ("test case number must be within range : 0 -- %d\n",
+			     cmd->size - 1);
+			DT_FFT_Cmd_Usage();
+			return (false);
+		}
+		cmd->cases_flag[caseNum] = true;
+		i++;
 	}
-	caseNum = atoi (my_argv[i] + 4);
-	if (caseNum<0 || caseNum>=cmd->size)
-	{
-	    DT_Mdep_printf ("test case number must be within range : 0 -- %d\n",
-		cmd->size-1);
-	    DT_FFT_Cmd_Usage ();
-	    return (false);
-	}
-	cmd->cases_flag[caseNum] = true;
-	i++;
-    }
-    return (true);
+	return (true);
 }
 
 //--------------------------------------------------------------
-void DT_FFT_Cmd_Usage (void)
+void DT_FFT_Cmd_Usage(void)
 {
-    char usage[] =
-    {
-	"dapltest -T F [-D <dev_name>] -f <funcfeature> [-i <iter_num>] \n"
-	"[-t <num_threads>] [-v <num_vis>] [-s <server_name>] [case0] [case1] [...]\n"
-	"USAGE:        [-D <device Name>]\n"
-	"USAGE:         -f <func_feature>\n"
-	"USAGE:             hwconn\n"
-	"USAGE:             endpoint\n"
-	"USAGE:             pz\n"
-	"USAGE:             mem\n"
-	"USAGE:             connmgt\n"
-	"USAGE:             queryinfo\n"
-#if 0 // not yet implemented
-	"USAGE:             connmgt_client       (not yet implemented)\n"
-	"USAGE:             cqmgt                (not yet implemented)\n"
-	"USAGE:             ns                   (not yet implemented)\n"
-	"USAGE:             errhand              (not yet implemented)\n"
-	"USAGE:             unsupp               (not yet implemented)\n"
-	"USAGE:             stress               (not yet implemented)\n"
-	"USAGE:             stress_client        (not yet implemented)\n"
+	char usage[] = {
+		"dapltest -T F [-D <dev_name>] -f <funcfeature> [-i <iter_num>] \n"
+		    "[-t <num_threads>] [-v <num_vis>] [-s <server_name>] [case0] [case1] [...]\n"
+		    "USAGE:        [-D <device Name>]\n"
+		    "USAGE:         -f <func_feature>\n"
+		    "USAGE:             hwconn\n"
+		    "USAGE:             endpoint\n"
+		    "USAGE:             pz\n"
+		    "USAGE:             mem\n"
+		    "USAGE:             connmgt\n"
+		    "USAGE:             queryinfo\n"
+#if 0				// not yet implemented
+		    "USAGE:             connmgt_client       (not yet implemented)\n"
+		    "USAGE:             cqmgt                (not yet implemented)\n"
+		    "USAGE:             ns                   (not yet implemented)\n"
+		    "USAGE:             errhand              (not yet implemented)\n"
+		    "USAGE:             unsupp               (not yet implemented)\n"
+		    "USAGE:             stress               (not yet implemented)\n"
+		    "USAGE:             stress_client        (not yet implemented)\n"
 #endif
-	"USAGE:         -i <iter_num>: itreration time for stress test\n"
-	"USAGE:         -t <num_threads>: number of threads for stress test\n"
-	"USAGE:         -v <num_vis>: number of vis for stress test\n"
-	"USAGE:         -s <server_name>\n"
-	"USAGE:             server host name or ip address\n"
-	"USAGE:        [-R <service reliability>]\n"
-	"USAGE:            (BE == QOS_BEST_EFFORT - Default )\n"
-	"USAGE:            (HT == QOS_HIGH_THROUGHPUT))\n"
-	"USAGE:            (LL == QOS_LOW_LATENCY)\n"
-	"USAGE:            (EC == QOS_ECONOMY)\n"
-	"USAGE:            (PM == QOS_PREMIUM)\n"
-	"NOTE: iter_num is just for stress_client test, default 100000\n"
-	"NOTE: Server_name must be specified for connmgt_client, \n"
-	"      NS and unsupp function feature.\n"
-	"NOTE: if test cases are not specified, test all cases in that function\n"
-	"      feature. else just test the specified cases\n"
-    };
+		"USAGE:         -i <iter_num>: itreration time for stress test\n"
+		    "USAGE:         -t <num_threads>: number of threads for stress test\n"
+		    "USAGE:         -v <num_vis>: number of vis for stress test\n"
+		    "USAGE:         -s <server_name>\n"
+		    "USAGE:             server host name or ip address\n"
+		    "USAGE:        [-R <service reliability>]\n"
+		    "USAGE:            (BE == QOS_BEST_EFFORT - Default )\n"
+		    "USAGE:            (HT == QOS_HIGH_THROUGHPUT))\n"
+		    "USAGE:            (LL == QOS_LOW_LATENCY)\n"
+		    "USAGE:            (EC == QOS_ECONOMY)\n"
+		    "USAGE:            (PM == QOS_PREMIUM)\n"
+		    "NOTE: iter_num is just for stress_client test, default 100000\n"
+		    "NOTE: Server_name must be specified for connmgt_client, \n"
+		    "      NS and unsupp function feature.\n"
+		    "NOTE: if test cases are not specified, test all cases in that function\n"
+		    "      feature. else just test the specified cases\n"
+	};
 
-    DT_Mdep_printf ("USAGE: -------FFT TEST------------\n");
-    DT_Mdep_printf ("%s\n", usage);
+	DT_Mdep_printf("USAGE: -------FFT TEST------------\n");
+	DT_Mdep_printf("%s\n", usage);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_getopt.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_getopt.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_getopt.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -40,15 +40,14 @@
  *  Initialize the getopt fields in preparation for parsing
  *  a command line.
  */
-void
-DT_mygetopt_init (mygetopt_t * opts)
+void DT_mygetopt_init(mygetopt_t * opts)
 {
-    opts->magic = GETOPT_MAGIC;
-    opts->place = EMSG;
-    opts->opterr = 1;
-    opts->optind = 1;
-    opts->optopt = 0;
-    opts->optarg = 0;
+	opts->magic = GETOPT_MAGIC;
+	opts->place = EMSG;
+	opts->opterr = 1;
+	opts->optind = 1;
+	opts->optopt = 0;
+	opts->optarg = 0;
 }
 
 /**
@@ -60,122 +59,95 @@
  *    (int) ':' when a required option argument is missing.
  */
 int
-DT_mygetopt_r (int argc, char *const * argv,
-	   const char *ostr, mygetopt_t * opts)
+DT_mygetopt_r(int argc, char *const *argv, const char *ostr, mygetopt_t * opts)
 {
-    char           *p;
-    char           *oli;	/* option letter list index */
-    if (GETOPT_MAGIC != opts->magic)
-    {
-	DT_Mdep_printf ("%s: getopt warning: "
-		    "option argument is not properly initialized.\n",
-		    argc > 0 ? argv[0] : "unknown command");
-	DT_mygetopt_init (opts);
-    }
-    if (!* (opts->place))      /* update scanning pointer */
-    {
-	if ((opts->optind) >= argc ||
-	    * ((opts->place) = argv[ (opts->optind)]) != '-')
-	{
-	    (opts->place) = EMSG;
-	    return (EOF);
+	char *p;
+	char *oli;		/* option letter list index */
+	if (GETOPT_MAGIC != opts->magic) {
+		DT_Mdep_printf("%s: getopt warning: "
+			       "option argument is not properly initialized.\n",
+			       argc > 0 ? argv[0] : "unknown command");
+		DT_mygetopt_init(opts);
 	}
-	if ((opts->place)[0] != '-')
-	{
-	    /* Invalid 1st argument */
-	    return (BADCH);
-	}
-	if ((opts->place)[1] && *++ (opts->place) == '-')
-	{
-	    /* found "--" which is an invalid option */
-	    ++ (opts->optind);
-	    (opts->place) = EMSG;
-	    return (BADCH);
-	}
-    }				/* option letter okay? */
-    opts->optopt = (int) * (opts->place)++;
-    oli = strchr (ostr, (opts->optopt));
-    if (opts->optopt == (int) ':' || ! oli)
-    {
-	/*
-	 * if the user didn't specify '-' as an option, assume it means EOF.
-	 */
-	if ((opts->optopt) == (int) '-')
-	{
-	    /* return (EOF); */
-	    return (BADCH);
-	}
-	if (!* (opts->place))
-	{
-	    ++ (opts->optind);
-	}
-	if ((opts->opterr) && *ostr != ':')
-	{
-	    p = strchr (*argv, '/');
-	    if (!p)
-	    {
-		p = *argv;
-	    }
-	    else
-	    {
-		++p;
-	    }
-
-	    if (opts->optopt != '?')	/* Anything but '?' needs error */
-	    {
-		DT_Mdep_printf ("%s: Illegal option -- %c\n",
-			    p, (opts->optopt));
-	    }
-	}
-	return (BADCH);
-    }
-    if (*++oli != ':')	      /* don't need argument */
-    {
-	(opts->optarg) = NULL;
-	if (!* (opts->place))
-	{
-	    ++ (opts->optind);
-	}
-    }
-    else		    /* need an argument */
-    {
-	if (* (opts->place))	 /* no white space */
-	{
-	    (opts->optarg) = (opts->place);
-	}
-	else
-	{
-	    if (argc <= ++ (opts->optind))     /* no arg */
-	    {
-		(opts->place) = EMSG;
-		if (*ostr == ':')
-		{
-		    return (BADARG);
+	if (!*(opts->place)) {	/* update scanning pointer */
+		if ((opts->optind) >= argc ||
+		    *((opts->place) = argv[(opts->optind)]) != '-') {
+			(opts->place) = EMSG;
+			return (EOF);
 		}
-		p = strchr (*argv, '/');
-		if (!p)
-		{
-		    p = *argv;
+		if ((opts->place)[0] != '-') {
+			/* Invalid 1st argument */
+			return (BADCH);
 		}
-		else
-		{
-		    ++p;
+		if ((opts->place)[1] && *++(opts->place) == '-') {
+			/* found "--" which is an invalid option */
+			++(opts->optind);
+			(opts->place) = EMSG;
+			return (BADCH);
 		}
-		if ((opts->opterr))
-		{
-		    DT_Mdep_printf (
-				"%s: option requires an argument -- %c\n",
-				p, (opts->optopt));
+	}			/* option letter okay? */
+	opts->optopt = (int)*(opts->place)++;
+	oli = strchr(ostr, (opts->optopt));
+	if (opts->optopt == (int)':' || !oli) {
+		/*
+		 * if the user didn't specify '-' as an option, assume it means EOF.
+		 */
+		if ((opts->optopt) == (int)'-') {
+			/* return (EOF); */
+			return (BADCH);
 		}
+		if (!*(opts->place)) {
+			++(opts->optind);
+		}
+		if ((opts->opterr) && *ostr != ':') {
+			p = strchr(*argv, '/');
+			if (!p) {
+				p = *argv;
+			} else {
+				++p;
+			}
+
+			if (opts->optopt != '?') {	/* Anything but '?' needs error */
+				DT_Mdep_printf("%s: Illegal option -- %c\n",
+					       p, (opts->optopt));
+			}
+		}
 		return (BADCH);
-	    }
-	    else	      /* white space */
-	    {
-		(opts->optarg) = argv[ (opts->optind)];
-	    }
 	}
-	(opts->place) = EMSG;
-	++ (opts->optind);
-    }
-    return (opts->optopt);	/* dump back option letter */
+	if (*++oli != ':') {	/* don't need argument */
+		(opts->optarg) = NULL;
+		if (!*(opts->place)) {
+			++(opts->optind);
+		}
+	} else {		/* need an argument */
+
+		if (*(opts->place)) {	/* no white space */
+			(opts->optarg) = (opts->place);
+		} else {
+			if (argc <= ++(opts->optind)) {	/* no arg */
+				(opts->place) = EMSG;
+				if (*ostr == ':') {
+					return (BADARG);
+				}
+				p = strchr(*argv, '/');
+				if (!p) {
+					p = *argv;
+				} else {
+					++p;
+				}
+				if ((opts->opterr)) {
+					DT_Mdep_printf
+					    ("%s: option requires an argument -- %c\n",
+					     p, (opts->optopt));
+				}
+				return (BADCH);
+			} else {	/* white space */
+
+				(opts->optarg) = argv[(opts->optind)];
+			}
+		}
+		(opts->place) = EMSG;
+		++(opts->optind);
+	}
+	return (opts->optopt);	/* dump back option letter */
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_limit_cmd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_limit_cmd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_limit_cmd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,205 +31,192 @@
 #include "dapl_proto.h"
 
 /* --------------------------------------------------- */
-void
-DT_Limit_Cmd_Init (Limit_Cmd_t * cmd)
+void DT_Limit_Cmd_Init(Limit_Cmd_t * cmd)
 {
-    memset ((void *) cmd, 0, sizeof (Limit_Cmd_t));
-    cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
-    cmd->width = 1;
-    cmd->maximum = ~0U;
+	memset((void *)cmd, 0, sizeof(Limit_Cmd_t));
+	cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
+	cmd->width = 1;
+	cmd->maximum = ~0U;
 }
 
 /* --------------------------------------------------- */
 bool
-DT_Limit_Cmd_Parse ( Limit_Cmd_t * cmd,
-		    int my_argc,
-		    char **my_argv,
-		    mygetopt_t * opts)
+DT_Limit_Cmd_Parse(Limit_Cmd_t * cmd,
+		   int my_argc, char **my_argv, mygetopt_t * opts)
 {
-    int             c;
-    int             i;
+	int c;
+	int i;
 
-    for (;;)
-    {
-	c = DT_mygetopt_r (my_argc, my_argv, "dm:w:D:R:", opts);
-	if (c == EOF)
-	{
-	    break;
-	}
-	switch (c)
-	{
-	    case 'D':		/* device name */
-	    {
-		strcpy (cmd->device_name, opts->optarg);
-		break;
-	    }
-	    case 'R':		/* Service Reliability Level */
-	    {
-		cmd->ReliabilityLevel = DT_ParseQoS (opts->optarg);
-		break;
-	    }
-	    case 'd':		    /* print debug messages */
-	    {
-		DT_dapltest_debug++;
-		cmd->debug = true;
-		break;
-	    }
-	    case 'm':		/* maximum for exhaustion testing */
-	    {
-		unsigned int len = strspn (opts->optarg, "0123456789");
-
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -m<maximum> option\n");
-		    DT_Limit_Cmd_Usage ();
-		    return (false);
+	for (;;) {
+		c = DT_mygetopt_r(my_argc, my_argv, "dm:w:D:R:", opts);
+		if (c == EOF) {
+			break;
 		}
-		cmd->maximum = atol (opts->optarg);
-		break;
-	    }
-	    case 'w':		/* width (number of {ia,evd,ep,...} sets) */
-	    {
-		unsigned int len = strspn (opts->optarg, "0123456789");
+		switch (c) {
+		case 'D':	/* device name */
+			{
+				strcpy(cmd->device_name, opts->optarg);
+				break;
+			}
+		case 'R':	/* Service Reliability Level */
+			{
+				cmd->ReliabilityLevel =
+				    DT_ParseQoS(opts->optarg);
+				break;
+			}
+		case 'd':	/* print debug messages */
+			{
+				DT_dapltest_debug++;
+				cmd->debug = true;
+				break;
+			}
+		case 'm':	/* maximum for exhaustion testing */
+			{
+				unsigned int len =
+				    strspn(opts->optarg, "0123456789");
 
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -w<width> option\n");
-		    DT_Limit_Cmd_Usage ();
-		    return (false);
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -m<maximum> option\n");
+					DT_Limit_Cmd_Usage();
+					return (false);
+				}
+				cmd->maximum = atol(opts->optarg);
+				break;
+			}
+		case 'w':	/* width (number of {ia,evd,ep,...} sets) */
+			{
+				unsigned int len =
+				    strspn(opts->optarg, "0123456789");
+
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -w<width> option\n");
+					DT_Limit_Cmd_Usage();
+					return (false);
+				}
+				cmd->width = atol(opts->optarg);
+				break;
+			}
+		case '?':
+		default:
+			{
+				DT_Mdep_printf
+				    ("Invalid Limit Test Parameter: %c\n", c);
+				DT_Limit_Cmd_Usage();
+				return (false);
+			}
 		}
-		cmd->width = atol (opts->optarg);
-		break;
-	    }
-	    case '?':
-	    default:
-	    {
-		DT_Mdep_printf ("Invalid Limit Test Parameter: %c\n", c);
-		DT_Limit_Cmd_Usage ();
-		return (false);
-	    }
 	}
-    }
-    if (cmd->device_name[0] == '\0')
-    {
-	if (!DT_Mdep_GetDefaultDeviceName (cmd->device_name))
-	{
-	    DT_Mdep_printf ("can't get default device name\n");
-	    DT_Limit_Cmd_Usage ();
-	    return (false);
+	if (cmd->device_name[0] == '\0') {
+		if (!DT_Mdep_GetDefaultDeviceName(cmd->device_name)) {
+			DT_Mdep_printf("can't get default device name\n");
+			DT_Limit_Cmd_Usage();
+			return (false);
+		}
 	}
-    }
 
-    /*
-     * by default: test all limit tests
-     * otherwise:  parse the remaining limit test arguments
-     */
-    if (opts->optind == my_argc)
-    {
-	for (i = 0;  i < LIM_NUM_TESTS;  i++)
-	{
-	    cmd->Test_List[i] = 1;
-	}
-    }
-    else
-    {
-	for (i = opts->optind;  i < my_argc;  i++)
-	{
+	/*
+	 * by default: test all limit tests
+	 * otherwise:  parse the remaining limit test arguments
+	 */
+	if (opts->optind == my_argc) {
+		for (i = 0; i < LIM_NUM_TESTS; i++) {
+			cmd->Test_List[i] = 1;
+		}
+	} else {
+		for (i = opts->optind; i < my_argc; i++) {
 
-	    if (strcmp (my_argv[i], "limit_ia") == 0)
-	    {
-		cmd->Test_List[LIM_IA] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_pz") == 0)
-	    {
-		cmd->Test_List[LIM_PZ] = 1;
-		continue;
-	    }
+			if (strcmp(my_argv[i], "limit_ia") == 0) {
+				cmd->Test_List[LIM_IA] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_pz") == 0) {
+				cmd->Test_List[LIM_PZ] = 1;
+				continue;
+			}
 #ifndef __KDAPLTEST__
-	    if (strcmp (my_argv[i], "limit_cno") == 0)
-	    {
-		cmd->Test_List[LIM_CNO] = 1;
-		continue;
-	    }
+			if (strcmp(my_argv[i], "limit_cno") == 0) {
+				cmd->Test_List[LIM_CNO] = 1;
+				continue;
+			}
 #endif
-	    if (strcmp (my_argv[i], "limit_evd") == 0)
-	    {
-		cmd->Test_List[LIM_EVD] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_ep") == 0)
-	    {
-		cmd->Test_List[LIM_EP] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_rsp") == 0)
-	    {
-		cmd->Test_List[LIM_RSP] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_psp") == 0)
-	    {
-		cmd->Test_List[LIM_PSP] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_lmr") == 0)
-	    {
-		cmd->Test_List[LIM_LMR] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_rpost") == 0)
-	    {
-		cmd->Test_List[LIM_RPOST] = 1;
-		continue;
-	    }
-	    if (strcmp (my_argv[i], "limit_size_lmr") == 0)
-	    {
-		cmd->Test_List[LIM_SIZE_LMR] = 1;
-		continue;
-	    }
+			if (strcmp(my_argv[i], "limit_evd") == 0) {
+				cmd->Test_List[LIM_EVD] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_ep") == 0) {
+				cmd->Test_List[LIM_EP] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_rsp") == 0) {
+				cmd->Test_List[LIM_RSP] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_psp") == 0) {
+				cmd->Test_List[LIM_PSP] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_lmr") == 0) {
+				cmd->Test_List[LIM_LMR] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_rpost") == 0) {
+				cmd->Test_List[LIM_RPOST] = 1;
+				continue;
+			}
+			if (strcmp(my_argv[i], "limit_size_lmr") == 0) {
+				cmd->Test_List[LIM_SIZE_LMR] = 1;
+				continue;
+			}
 
-	    DT_Mdep_printf ("Cannot find this limit test: %s\n", my_argv[i]);
-	    DT_Limit_Cmd_Usage ();
-	    return (false);
+			DT_Mdep_printf("Cannot find this limit test: %s\n",
+				       my_argv[i]);
+			DT_Limit_Cmd_Usage();
+			return (false);
 
-	}	/* end foreach remaining argv */
-    }
+		}		/* end foreach remaining argv */
+	}
 
-    return (true);
+	return (true);
 }
 
 /* --------------------------------------------------- */
-void
-DT_Limit_Cmd_Usage (void)
+void DT_Limit_Cmd_Usage(void)
 {
-    DT_Mdep_printf ("USAGE: ---- LIMIT TEST ----\n");
-    DT_Mdep_printf ("USAGE:     dapltest -T L\n");
-    DT_Mdep_printf ("USAGE:              [-D <device Name>]\n");
-    DT_Mdep_printf ("USAGE:              [-d] : debug (zero)\n");
-    DT_Mdep_printf ("USAGE:              [-w <width_of_resource_sets>]\n");
-    DT_Mdep_printf ("USAGE:              [-m <maximum_for_exhaustion_tests>]\n");
-    DT_Mdep_printf ("USAGE:              [-R <service reliability>]\n");
-    DT_Mdep_printf ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
-    DT_Mdep_printf ("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
-    DT_Mdep_printf ("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
-    DT_Mdep_printf ("USAGE:                  (EC == QOS_ECONOMY)\n");
-    DT_Mdep_printf ("USAGE:                  (PM == QOS_PREMIUM)\n");
-    DT_Mdep_printf ("USAGE:              [limit_ia [limit_pz] [limit_evd] ... ]\n");
-    DT_Mdep_printf ("NOTE: If test is not specified, do all the limit tests\n");
-    DT_Mdep_printf ("NOTE: Else, just do the specified tests\n");
-    DT_Mdep_printf ("NOTE: Each test is separated by space, the test can be:\n");
+	DT_Mdep_printf("USAGE: ---- LIMIT TEST ----\n");
+	DT_Mdep_printf("USAGE:     dapltest -T L\n");
+	DT_Mdep_printf("USAGE:              [-D <device Name>]\n");
+	DT_Mdep_printf("USAGE:              [-d] : debug (zero)\n");
+	DT_Mdep_printf("USAGE:              [-w <width_of_resource_sets>]\n");
+	DT_Mdep_printf
+	    ("USAGE:              [-m <maximum_for_exhaustion_tests>]\n");
+	DT_Mdep_printf("USAGE:              [-R <service reliability>]\n");
+	DT_Mdep_printf
+	    ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
+	DT_Mdep_printf("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
+	DT_Mdep_printf("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
+	DT_Mdep_printf("USAGE:                  (EC == QOS_ECONOMY)\n");
+	DT_Mdep_printf("USAGE:                  (PM == QOS_PREMIUM)\n");
+	DT_Mdep_printf
+	    ("USAGE:              [limit_ia [limit_pz] [limit_evd] ... ]\n");
+	DT_Mdep_printf
+	    ("NOTE: If test is not specified, do all the limit tests\n");
+	DT_Mdep_printf("NOTE: Else, just do the specified tests\n");
+	DT_Mdep_printf
+	    ("NOTE: Each test is separated by space, the test can be:\n");
 
-    DT_Mdep_printf ("NOTE: [limit_ia]         test max num  of  open IAs\n");
-    DT_Mdep_printf ("NOTE: [limit_pz]         test max num  of  PZs\n");
+	DT_Mdep_printf("NOTE: [limit_ia]         test max num  of  open IAs\n");
+	DT_Mdep_printf("NOTE: [limit_pz]         test max num  of  PZs\n");
 #ifndef __KDAPLTEST__
-    DT_Mdep_printf ("NOTE: [limit_cno]        test max num  of  CNOs\n");
+	DT_Mdep_printf("NOTE: [limit_cno]        test max num  of  CNOs\n");
 #endif
-    DT_Mdep_printf ("NOTE: [limit_evd]        test max num  of  EVDs\n");
-    DT_Mdep_printf ("NOTE: [limit_rsp]        test max num  of  RSPs\n");
-    DT_Mdep_printf ("NOTE: [limit_psp]        test max num  of  PSPs\n");
-    DT_Mdep_printf ("NOTE: [limit_ep]         test max num  of  EPs\n");
-    DT_Mdep_printf ("NOTE: [limit_lmr]        test max num  of  LMRs\n");
-    DT_Mdep_printf ("NOTE: [limit_rpost]      test max num  of  recvs posted\n");
-    DT_Mdep_printf ("NOTE: [limit_size_lmr]   test max size of  LMR\n");
+	DT_Mdep_printf("NOTE: [limit_evd]        test max num  of  EVDs\n");
+	DT_Mdep_printf("NOTE: [limit_rsp]        test max num  of  RSPs\n");
+	DT_Mdep_printf("NOTE: [limit_psp]        test max num  of  PSPs\n");
+	DT_Mdep_printf("NOTE: [limit_ep]         test max num  of  EPs\n");
+	DT_Mdep_printf("NOTE: [limit_lmr]        test max num  of  LMRs\n");
+	DT_Mdep_printf
+	    ("NOTE: [limit_rpost]      test max num  of  recvs posted\n");
+	DT_Mdep_printf("NOTE: [limit_size_lmr]   test max size of  LMR\n");
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_main.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_main.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_main.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,112 +31,113 @@
 #include "dapl_proto.h"
 
 /* Main Entry Point */
-int
-main (int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-    return ( dapltest (argc, argv) );
+	return (dapltest(argc, argv));
 }
 
-
 /*
  * dapltest main program
  */
-int
-dapltest (int argc, char *argv[])
+int dapltest(int argc, char *argv[])
 {
-    Params_t       	*params_ptr;
+	Params_t *params_ptr;
+	DAT_RETURN rc = DAT_SUCCESS;
 
-    /* check memory leaking */
-    /*
-     * DT_Mdep_LockInit(&Alloc_Count_Lock); alloc_count = 0;
-     */
+	/* check memory leaking */
+	/*
+	 * DT_Mdep_LockInit(&Alloc_Count_Lock); alloc_count = 0;
+	 */
 
 #if defined(_WIN32) || defined(_WIN64)
-    {
-        /* Cannot be done from DT_Mdep_Init as dapl_init makes some socket
-         * calls....So need to do this before calling dapl_init */
-        WSADATA         wsaData;
-        int             i;
+	{
+		/* Cannot be done from DT_Mdep_Init as dapl_init makes some socket
+		 * calls....So need to do this before calling dapl_init */
+		WSADATA wsaData;
+		int i;
 
-        i = WSAStartup (MAKEWORD(2,2), &wsaData);
-	if ( i != 0 ) {
-            printf("%s WSAStartup(2.2) failed? (0x%x)\n",argv[0],i);
-            exit(1);
-        }
-    }
+		i = WSAStartup(MAKEWORD(2, 2), &wsaData);
+		if (i != 0) {
+			printf("%s WSAStartup(2.2) failed? (0x%x)\n", argv[0],
+			       i);
+			exit(1);
+		}
+	}
 #endif
 
 #ifdef GPROF
-    {
-	extern void dapl_init (void);
-	dapl_init ();
-    }
+	{
+		extern void dapl_init(void);
+		dapl_init();
+	}
 #endif
-    DT_dapltest_debug = 0;
+	DT_dapltest_debug = 0;
 
-    params_ptr = (Params_t *) DT_Mdep_Malloc (sizeof (Params_t));
-    if (!params_ptr)
-    {
-	DT_Mdep_printf ("Cannot allocate memory for Params structure\n");
-	return ( 1 );
-    }
+	params_ptr = (Params_t *) DT_Mdep_Malloc(sizeof(Params_t));
+	if (!params_ptr) {
+		DT_Mdep_printf("Cannot allocate memory for Params structure\n");
+		return (1);
+	}
 
-    DT_Tdep_Init ();	/* init (kdapl/udapl)test-dependent code */
-    DT_Endian_Init ();	/* init endian of local machine */
-    DT_Mdep_Init ();	/* init OS, libraries, etc.     */
+	DT_Tdep_Init();		/* init (kdapl/udapl)test-dependent code */
+	DT_Endian_Init();	/* init endian of local machine */
+	DT_Mdep_Init();		/* init OS, libraries, etc.     */
 
-    params_ptr->local_is_little_endian = DT_local_is_little_endian;
+	params_ptr->local_is_little_endian = DT_local_is_little_endian;
 
-    /*
-     * parse command line arguments
-     */
-    if (!DT_Params_Parse (argc, argv, params_ptr))
-    {
-	DT_Mdep_printf ("Command line syntax error\n");
-	return 1;
-    }
-    params_ptr->cpu_mhz = DT_Mdep_GetCpuMhz ();
-    /* call the test-dependent code for invoking the actual test */
-    DT_Tdep_Execute_Test (params_ptr);
+	/*
+	 * parse command line arguments
+	 */
+	if (!DT_Params_Parse(argc, argv, params_ptr)) {
+		DT_Mdep_printf("Command line syntax error\n");
+		return 1;
+	}
+	params_ptr->cpu_mhz = DT_Mdep_GetCpuMhz();
+	/* call the test-dependent code for invoking the actual test */
+	rc = DT_Tdep_Execute_Test(params_ptr);
 
-    /* cleanup */
+	/* cleanup */
 
-    DT_Mdep_End ();
-    DT_Mdep_Free (params_ptr);
-    DT_Tdep_End ();
+	DT_Mdep_End();
+	DT_Mdep_Free(params_ptr);
+	DT_Tdep_End();
 #ifdef GPROF
-    {
-	extern void dapl_fini (void);
-	dapl_fini ();
-    }
+	{
+		extern void dapl_fini(void);
+		dapl_fini();
+	}
 #endif
 
-    /*
-     * check memory leaking DT_Mdep_printf("App allocated Memory left: %d\n",
-     * alloc_count); DT_Mdep_LockDestroy(&Alloc_Count_Lock);
-     */
+	/*
+	 * check memory leaking DT_Mdep_printf("App allocated Memory left: %d\n",
+	 * alloc_count); DT_Mdep_LockDestroy(&Alloc_Count_Lock);
+	 */
 
-    return ( 0 );
+	return (rc);
 }
 
-
-void
-Dapltest_Main_Usage (void)
+void Dapltest_Main_Usage(void)
 {
-    DT_Mdep_printf ("USAGE:\n");
-    DT_Mdep_printf ("USAGE:     dapltest -T <Test_Type> [test-specific args]\n");
-    DT_Mdep_printf ("USAGE:         where <Test_Type>\n");
-    DT_Mdep_printf ("USAGE:         S = Run as a server\n");
-    DT_Mdep_printf ("USAGE:         T = Transaction Test\n");
-    DT_Mdep_printf ("USAGE:         Q = Quit Test\n");
-    DT_Mdep_printf ("USAGE:         P = Performance Test\n");
-    DT_Mdep_printf ("USAGE:         L = Limit Test\n");
-    DT_Mdep_printf ("USAGE:         F = FFT Test\n");
-    DT_Mdep_printf ("USAGE:\n");
-    DT_Mdep_printf ("NOTE:\tRun as server taking defaults (dapltest -T S)\n");
-    DT_Mdep_printf ("NOTE:         dapltest\n");
-    DT_Mdep_printf ("NOTE:\n");
-    DT_Mdep_printf ("NOTE:\tdapltest arguments may be supplied in a script file\n");
-    DT_Mdep_printf ("NOTE:\tdapltest -f <script_file>\n");
-    DT_Mdep_printf ("USAGE:\n");
+	DT_Mdep_printf("USAGE:\n");
+	DT_Mdep_printf
+	    ("USAGE:     dapltest -T <Test_Type> [-D IA_name] [test-specific args]\n");
+	DT_Mdep_printf("USAGE:         where <Test_Type>\n");
+	DT_Mdep_printf("USAGE:         S = Run as a server\n");
+	DT_Mdep_printf("USAGE:         T = Transaction Test\n");
+	DT_Mdep_printf("USAGE:         Q = Quit Test\n");
+	DT_Mdep_printf("USAGE:         P = Performance Test\n");
+	DT_Mdep_printf("USAGE:         L = Limit Test\n");
+	DT_Mdep_printf("USAGE:         F = FFT Test\n");
+	DT_Mdep_printf("USAGE:\n");
+	DT_Mdep_printf
+	    ("USAGE:         -D Interface_Adapter {default ibnic0v2}\n");
+	DT_Mdep_printf("USAGE:\n");
+	DT_Mdep_printf
+	    ("NOTE:\tRun as server taking defaults (dapltest -T S [-D ibnic0v2])\n");
+	DT_Mdep_printf("NOTE:         dapltest\n");
+	DT_Mdep_printf("NOTE:\n");
+	DT_Mdep_printf
+	    ("NOTE:\tdapltest arguments may be supplied in a script file\n");
+	DT_Mdep_printf("NOTE:\tdapltest -f <script_file>\n");
+	DT_Mdep_printf("USAGE:\n");
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_netaddr.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_netaddr.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_netaddr.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,115 +30,108 @@
 
 #include "dapl_proto.h"
 
-DAT_IA_ADDRESS_PTR
-DT_NetAddrAlloc (Per_Test_Data_t * pt_ptr)
+DAT_IA_ADDRESS_PTR DT_NetAddrAlloc(Per_Test_Data_t * pt_ptr)
 {
-    DAT_IA_ADDRESS_PTR netaddr;
+	DAT_IA_ADDRESS_PTR netaddr;
 
-    netaddr = (DAT_IA_ADDRESS_PTR) DT_Mdep_Malloc (sizeof (DAT_SOCK_ADDR));
-    if (!netaddr)
-    {
-	DT_Mdep_printf ("dapltest: No Memory to create netaddr!\n");
-    }
-    return netaddr;
+	netaddr = (DAT_IA_ADDRESS_PTR) DT_Mdep_Malloc(sizeof(DAT_SOCK_ADDR));
+	if (!netaddr) {
+		DT_Mdep_printf("dapltest: No Memory to create netaddr!\n");
+	}
+	return netaddr;
 }
 
-
-void
-DT_NetAddrFree (Per_Test_Data_t * pt_ptr, DAT_IA_ADDRESS_PTR netaddr)
+void DT_NetAddrFree(Per_Test_Data_t * pt_ptr, DAT_IA_ADDRESS_PTR netaddr)
 {
-    DT_Mdep_Free (netaddr);
+	DT_Mdep_Free(netaddr);
 }
 
-
 bool
-DT_NetAddrLookupHostAddress (DAT_IA_ADDRESS_PTR	to_netaddr,
-			    DAT_NAME_PTR 	hostname)
+DT_NetAddrLookupHostAddress(DAT_IA_ADDRESS_PTR to_netaddr,
+			    DAT_NAME_PTR hostname)
 {
-    struct addrinfo *target;
-    int rval;
+	struct addrinfo *target;
+	int rval;
 
-    rval = getaddrinfo (hostname, NULL, NULL, &target);
-    if (rval != 0)
-    {
-	char *whatzit = "unknown error return";
+	rval = getaddrinfo(hostname, NULL, NULL, &target);
+	if (rval != 0) {
+		char *whatzit = "unknown error return";
 
-	switch (rval)
-	{
-	    case EAI_FAMILY:
-	    {
-		whatzit = "unsupported address family";
-		break;
-	    }
-	    case EAI_SOCKTYPE:
-	    {
-		whatzit = "unsupported socket type";
-		break;
-	    }
-	    case EAI_BADFLAGS:
-	    {
-		whatzit = "invalid flags";
-		break;
-	    }
-	    case EAI_NONAME:
-	    {
-		whatzit = "unknown node name";
-		break;
-	    }
-	    case EAI_SERVICE:
-	    {
-		whatzit = "service unavailable";
-		break;
-	    }
+		switch (rval) {
+		case EAI_FAMILY:
+			{
+				whatzit = "unsupported address family";
+				break;
+			}
+		case EAI_SOCKTYPE:
+			{
+				whatzit = "unsupported socket type";
+				break;
+			}
+		case EAI_BADFLAGS:
+			{
+				whatzit = "invalid flags";
+				break;
+			}
+		case EAI_NONAME:
+			{
+				whatzit = "unknown node name";
+				break;
+			}
+		case EAI_SERVICE:
+			{
+				whatzit = "service unavailable";
+				break;
+			}
 #if !defined(WIN32) && defined(__USE_GNU)
-	    case EAI_ADDRFAMILY:
-	    {
-		whatzit = "node has no address in this family";
-		break;
-	    }
-	    case EAI_NODATA:
-	    {
-		whatzit = "node has no addresses defined";
-		break;
-	    }
+		case EAI_ADDRFAMILY:
+			{
+				whatzit = "node has no address in this family";
+				break;
+			}
+		case EAI_NODATA:
+			{
+				whatzit = "node has no addresses defined";
+				break;
+			}
 #endif
-	    case EAI_MEMORY:
-	    {
-		whatzit = "out of memory";
-		break;
-	    }
-	    case EAI_FAIL:
-	    {
-		whatzit = "permanent name server failure";
-		break;
-	    }
-	    case EAI_AGAIN:
-	    {
-		whatzit = "temporary name server failure";
-		break;
-	    }
+		case EAI_MEMORY:
+			{
+				whatzit = "out of memory";
+				break;
+			}
+		case EAI_FAIL:
+			{
+				whatzit = "permanent name server failure";
+				break;
+			}
+		case EAI_AGAIN:
+			{
+				whatzit = "temporary name server failure";
+				break;
+			}
 #if !defined(WIN32)
-	    case EAI_SYSTEM:
-	    {
-		whatzit = "system error";
-		break;
-	    }
+		case EAI_SYSTEM:
+			{
+				whatzit = "system error";
+				break;
+			}
 #endif
+		}
+
+		DT_Mdep_printf("getaddrinfo (%s) failed (%s)\n",
+			       hostname, whatzit);
+		return DAT_FALSE;
 	}
 
-	DT_Mdep_printf ("getaddrinfo (%s) failed (%s)\n",
-			hostname, whatzit);
-	return DAT_FALSE;
-    }
+	/* Pull out IP address and print it as a sanity check */
+	DT_Mdep_printf("Server Name: %s \n", hostname);
+	DT_Mdep_printf("Server Net Address: %s\n",
+		       inet_ntoa(((struct sockaddr_in *)target->ai_addr)->
+				 sin_addr));
 
-    /* Pull out IP address and print it as a sanity check */
-    DT_Mdep_printf ("Server Name: %s \n", hostname);
-    DT_Mdep_printf ("Server Net Address: %s\n",
-		    inet_ntoa(((struct sockaddr_in *)target->ai_addr)->sin_addr));
+	*to_netaddr = *((DAT_IA_ADDRESS_PTR) target->ai_addr);
+	freeaddrinfo(target);
 
-    *to_netaddr = * ((DAT_IA_ADDRESS_PTR) target->ai_addr);
-    freeaddrinfo(target);
-
-    return ( DAT_TRUE );
+	return (DAT_TRUE);
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_params.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_params.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_params.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -33,273 +33,249 @@
 #define MAX_ARGC    500
 #define MAX_ARG_LEN 100
 
-
 /* Parse command line arguments */
-bool
-DT_Params_Parse (int argc, char *argv[], Params_t * params_ptr)
+bool DT_Params_Parse(int argc, char *argv[], Params_t * params_ptr)
 {
-    Server_Cmd_t   	*Server_Cmd;
-    Transaction_Cmd_t 	*Transaction_Cmd;
-    Quit_Cmd_t	    	*Quit_Cmd;
-    Limit_Cmd_t         *Limit_Cmd;
-    Performance_Cmd_t 	*Performance_Cmd;
-    FFT_Cmd_t	    	*FFT_Cmd;
+	Server_Cmd_t *Server_Cmd;
+	Transaction_Cmd_t *Transaction_Cmd;
+	Quit_Cmd_t *Quit_Cmd;
+	Limit_Cmd_t *Limit_Cmd;
+	Performance_Cmd_t *Performance_Cmd;
+	FFT_Cmd_t *FFT_Cmd;
 
-    char           *filename;
-    FILE           *fd;
-    mygetopt_t      opts;
-    int             c;
-    char           *cp;
-    char           *sp;
-    char            line[256];
-    char           *my_argv[MAX_ARGC];
-    int             my_argc;
-    int             i;
-    DT_mygetopt_init (&opts);
-    opts.opterr = 0;		/* turn off automatical error handler */
+	char *filename;
+	FILE *fd;
+	mygetopt_t opts;
+	int c;
+	char *cp;
+	char *sp;
+	char line[256];
+	char *my_argv[MAX_ARGC];
+	int my_argc;
+	int i;
+	DT_mygetopt_init(&opts);
+	opts.opterr = 0;	/* turn off automatical error handler */
 
-    fd = 0;
-    my_argc = 0;
-    for (i = 0; i < MAX_ARGC; i++)
-    {
-	my_argv[i] = NULL;
-    }
+	fd = 0;
+	my_argc = 0;
+	for (i = 0; i < MAX_ARGC; i++) {
+		my_argv[i] = NULL;
+	}
 
-    /* dapltest with no arguments means run as a server with default values */
-    if (argc == 1)
-    {
-	params_ptr->test_type = SERVER_TEST;
-	params_ptr->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
-	Server_Cmd = &params_ptr->u.Server_Cmd;
-	DT_Server_Cmd_Init (Server_Cmd);
-	if (!DT_Mdep_GetDefaultDeviceName (Server_Cmd->dapl_name))
-	{
-	    DT_Mdep_printf ("can't get default device name\n");
-	    return false;
+	/* dapltest with no arguments means run as a server with default values */
+	if (argc == 1) {
+		params_ptr->test_type = SERVER_TEST;
+		params_ptr->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
+		Server_Cmd = &params_ptr->u.Server_Cmd;
+		DT_Server_Cmd_Init(Server_Cmd);
+		if (!DT_Mdep_GetDefaultDeviceName(Server_Cmd->dapl_name)) {
+			DT_Mdep_printf("can't get default device name\n");
+			return false;
+		}
+		return true;
 	}
-	return true;
-    }
-    /* check for a script file */
-    if (strncmp (argv[1], "-f", 2) == 0)
-    {
-	if (argc == 2)	      /* dapltest -fdata  */
-	{
-	    filename = argv[1] + 2;
+	/* check for a script file */
+	if (strncmp(argv[1], "-f", 2) == 0) {
+		if (argc == 2) {	/* dapltest -fdata  */
+			filename = argv[1] + 2;
+		} else {
+			if (argc == 3 && strcmp(argv[1], "-f") == 0) {	/* dapltest -f data */
+				filename = argv[2];
+			} else {
+				DT_Mdep_printf
+				    ("-f <script_file> allows no additional options\n");
+				goto main_usage;
+			}
+		}
+
+		if (!filename || strlen(filename) == 0) {
+			DT_Mdep_printf
+			    ("Missing <script_file> with -f option\n");
+			goto main_usage;
+		}
+		/* read the script file and create a fake argc, argv */
+		fd = fopen(filename, "r");
+		if (fd == 0) {
+			DT_Mdep_printf("Cannot open script file: %s\n",
+				       filename);
+			goto main_usage;
+		}
+		my_argc = 1;
+		my_argv[0] = DT_Mdep_Malloc(MAX_ARG_LEN);
+		if (!my_argv[0]) {
+			DT_Mdep_printf("No Memory\n");
+			goto error_return;
+		}
+		strcpy(my_argv[0], argv[0]);
+		while (fgets(&line[0], 256, fd)) {
+			sp = &line[0];
+			for (;;) {
+				cp = strtok(sp, " \t\n");
+				sp = 0;	/* so can continue to parse this string */
+				if (!cp) {	/* no more token found */
+					break;
+				}
+				if (*cp == '#') {	/* Comment; go to next line.  */
+					break;
+				}
+				my_argv[my_argc] = DT_Mdep_Malloc(MAX_ARG_LEN);
+				if (!my_argv[my_argc]) {
+					DT_Mdep_printf("No Memory\n");
+					goto error_return;
+				}
+				strcpy(my_argv[my_argc], cp);
+				my_argc++;
+			}
+		}
+	} else {
+		my_argc = argc;
+		for (i = 0; i < argc; i++) {
+			my_argv[i] = argv[i];
+		}
 	}
-	else
-	{
-	    if (argc == 3 && strcmp (argv[1], "-f") == 0)      /* dapltest -f data */
-	    {
-		filename = argv[2];
-	    }
-	    else
-	    {
-		DT_Mdep_printf ("-f <script_file> allows no additional options\n");
-		goto main_usage;
-	    }
+
+#if 0
+	for (i = 0; i < my_argc; i++) {
+		DT_Mdep_printf("ARG %s\n", my_argv[i]);
 	}
+	exit(1);
+#endif
 
-	if (!filename || strlen (filename) == 0)
-	{
-	    DT_Mdep_printf ("Missing <script_file> with -f option\n");
-	    goto main_usage;
+	/* get test type - which must be the first arg */
+	c = DT_mygetopt_r(my_argc, my_argv, "T:", &opts);
+	if (c != 'T') {
+		DT_Mdep_printf("Must Specify Test (-T) option first\n");
+		goto main_usage;
 	}
-	/* read the script file and create a fake argc, argv */
-	fd = fopen (filename, "r");
-	if (fd == 0)
-	{
-	    DT_Mdep_printf ("Cannot open script file: %s\n", filename);
-	    goto main_usage;
+	if ((opts.optarg == 0) || strlen(opts.optarg) == 0
+	    || *opts.optarg == '-') {
+		DT_Mdep_printf("Must specify test type\n");
+		goto main_usage;
 	}
-	my_argc = 1;
-	my_argv[0] = DT_Mdep_Malloc (MAX_ARG_LEN);
-	if (!my_argv[0])
-	{
-	    DT_Mdep_printf ("No Memory\n");
-	    goto error_return;
-	}
-	strcpy (my_argv[0], argv[0]);
-	while (fgets (&line[0], 256, fd))
-	{
-	    sp = &line[0];
-	    for (;;)
-	    {
-		cp = strtok (sp, " \t\n");
-		sp = 0;		/* so can continue to parse this string */
-		if (!cp)      /* no more token found */
+	switch (*opts.optarg) {
+	case 'S':		/* Server Test */
 		{
-		    break;
+			params_ptr->test_type = SERVER_TEST;
+			Server_Cmd = &params_ptr->u.Server_Cmd;
+			DT_Server_Cmd_Init(Server_Cmd);
+			if (!DT_Server_Cmd_Parse(Server_Cmd,
+						 my_argc, my_argv, &opts)) {
+				goto error_return;
+			}
+			params_ptr->ReliabilityLevel =
+			    Server_Cmd->ReliabilityLevel;
+			params_ptr->debug = Server_Cmd->debug;
+			break;
 		}
-		if (*cp == '#') /* Comment; go to next line.  */
+	case 'T':		/* Transaction Test */
 		{
-		    break;
+			params_ptr->test_type = TRANSACTION_TEST;
+			Transaction_Cmd = &params_ptr->u.Transaction_Cmd;
+			DT_Transaction_Cmd_Init(Transaction_Cmd);
+			if (!DT_Transaction_Cmd_Parse(Transaction_Cmd,
+						      my_argc, my_argv, &opts))
+			{
+				goto error_return;
+			}
+			params_ptr->ReliabilityLevel =
+			    Transaction_Cmd->ReliabilityLevel;
+			params_ptr->debug = Transaction_Cmd->debug;
+			DT_NetAddrLookupHostAddress(&params_ptr->server_netaddr,
+						    Transaction_Cmd->
+						    server_name);
+			break;
 		}
-		my_argv[my_argc] = DT_Mdep_Malloc (MAX_ARG_LEN);
-		if (!my_argv[my_argc])
+	case 'Q':		/* Quit server Test */
 		{
-		    DT_Mdep_printf ("No Memory\n");
-		    goto error_return;
+			params_ptr->test_type = QUIT_TEST;
+			Quit_Cmd = &params_ptr->u.Quit_Cmd;
+			DT_Quit_Cmd_Init(Quit_Cmd);
+			if (!DT_Quit_Cmd_Parse(Quit_Cmd,
+					       my_argc, my_argv, &opts)) {
+				goto error_return;
+			}
+			params_ptr->ReliabilityLevel =
+			    Quit_Cmd->ReliabilityLevel;
+			params_ptr->debug = Quit_Cmd->debug;
+			DT_NetAddrLookupHostAddress(&params_ptr->server_netaddr,
+						    Quit_Cmd->server_name);
+			break;
 		}
-		strcpy (my_argv[my_argc], cp);
-		my_argc++;
-	    }
-	}
-    }
-    else
-    {
-	my_argc = argc;
-	for (i = 0; i < argc; i++)
-	{
-	    my_argv[i] = argv[i];
-	}
-    }
+	case 'L':		/* Limit Test */
+		{
+			params_ptr->test_type = LIMIT_TEST;
+			Limit_Cmd = &params_ptr->u.Limit_Cmd;
+			DT_Limit_Cmd_Init(Limit_Cmd);
+			if (!DT_Limit_Cmd_Parse
+			    (Limit_Cmd, my_argc, my_argv, &opts)) {
+				goto error_return;
+			}
+			params_ptr->ReliabilityLevel =
+			    Limit_Cmd->ReliabilityLevel;
+			params_ptr->debug = Limit_Cmd->debug;
+			break;
+		}
+	case 'P':		/* Performance Test */
+		{
+			params_ptr->test_type = PERFORMANCE_TEST;
+			Performance_Cmd = &params_ptr->u.Performance_Cmd;
 
-#if 0
-    for (i = 0; i < my_argc; i++)
-    {
-	DT_Mdep_printf ("ARG %s\n", my_argv[i]);
-    }
-    exit (1);
-#endif
+			if (!DT_Performance_Cmd_Init(Performance_Cmd)) {
+				goto error_return;
+			}
 
-    /* get test type - which must be the first arg */
-    c = DT_mygetopt_r (my_argc, my_argv, "T:", &opts);
-    if (c != 'T')
-    {
-	DT_Mdep_printf ("Must Specify Test (-T) option first\n");
-	goto main_usage;
-    }
-    if ((opts.optarg == 0) || strlen (opts.optarg) == 0 || *opts.optarg == '-')
-    {
-	DT_Mdep_printf ("Must specify test type\n");
-	goto main_usage;
-    }
-    switch (*opts.optarg)
-    {
-	case 'S':		    /* Server Test */
-	{
-	    params_ptr->test_type = SERVER_TEST;
-	    Server_Cmd = &params_ptr->u.Server_Cmd;
-	    DT_Server_Cmd_Init (Server_Cmd);
-	    if (!DT_Server_Cmd_Parse (	Server_Cmd,
-					my_argc, my_argv, &opts))
-	    {
-		goto error_return;
-	    }
-	    params_ptr->ReliabilityLevel = Server_Cmd->ReliabilityLevel;
-	    params_ptr->debug = Server_Cmd->debug;
-	    break;
-	}
-	case 'T':		    /* Transaction Test */
-	{
-	    params_ptr->test_type = TRANSACTION_TEST;
-	    Transaction_Cmd = &params_ptr->u.Transaction_Cmd;
-	    DT_Transaction_Cmd_Init (Transaction_Cmd);
-	    if (!DT_Transaction_Cmd_Parse (  Transaction_Cmd,
-					    my_argc, my_argv, &opts))
-	    {
-		goto error_return;
-	    }
-	    params_ptr->ReliabilityLevel = Transaction_Cmd->ReliabilityLevel;
-	    params_ptr->debug = Transaction_Cmd->debug;
-	    DT_NetAddrLookupHostAddress (&params_ptr->server_netaddr,
-					 Transaction_Cmd->server_name);
-	    break;
-	}
-    case 'Q':		    /* Quit server Test */
-    {
-        params_ptr->test_type = QUIT_TEST;
-        Quit_Cmd = &params_ptr->u.Quit_Cmd;
-        DT_Quit_Cmd_Init (Quit_Cmd);
-        if (!DT_Quit_Cmd_Parse ( Quit_Cmd,
-                    my_argc, my_argv, &opts))
-        {
-        goto error_return;
-        }
-        params_ptr->ReliabilityLevel = Quit_Cmd->ReliabilityLevel;
-        params_ptr->debug = Quit_Cmd->debug;
-        DT_NetAddrLookupHostAddress (&params_ptr->server_netaddr,
-                     Quit_Cmd->server_name);
-        break;
-    }
-    case 'L':              /* Limit Test */
-    {	                
-	params_ptr->test_type = LIMIT_TEST;
-	Limit_Cmd = &params_ptr->u.Limit_Cmd;
-	DT_Limit_Cmd_Init (Limit_Cmd);
-	if (!DT_Limit_Cmd_Parse (Limit_Cmd,my_argc, my_argv, &opts))
-	{
-		goto error_return;
-        }
-        params_ptr->ReliabilityLevel = Limit_Cmd->ReliabilityLevel;
-        params_ptr->debug = Limit_Cmd->debug;
-        break;
-    }
-	case 'P':		    /* Performance Test */
-	{
-	    params_ptr->test_type = PERFORMANCE_TEST;
-	    Performance_Cmd = &params_ptr->u.Performance_Cmd;
+			if (!DT_Performance_Cmd_Parse(Performance_Cmd,
+						      my_argc, my_argv, &opts))
+			{
+				goto error_return;
+			}
 
-	    if (!DT_Performance_Cmd_Init (Performance_Cmd))
-	    {
-		goto error_return;
-	    }
-
-	    if (!DT_Performance_Cmd_Parse (  Performance_Cmd,
-					    my_argc, my_argv, &opts))
-	    {
-		goto error_return;
-	    }
-
-	    params_ptr->ReliabilityLevel = Performance_Cmd->qos;
-	    params_ptr->debug = Performance_Cmd->debug;
-	    DT_NetAddrLookupHostAddress (&params_ptr->server_netaddr,
-					 Performance_Cmd->server_name);
-	    break;
-	}
+			params_ptr->ReliabilityLevel = Performance_Cmd->qos;
+			params_ptr->debug = Performance_Cmd->debug;
+			DT_NetAddrLookupHostAddress(&params_ptr->server_netaddr,
+						    Performance_Cmd->
+						    server_name);
+			break;
+		}
 	case 'F':
-	{
-	    params_ptr->test_type = FFT_TEST;
-	    FFT_Cmd = &params_ptr->u.FFT_Cmd;
-	    DT_FFT_Cmd_Init (FFT_Cmd);
-	    if (!DT_FFT_Cmd_Parse (FFT_Cmd, my_argc, my_argv, &opts))
-	    {
-		goto error_return;
-	    }
-	    params_ptr->ReliabilityLevel = FFT_Cmd->ReliabilityLevel;
-            DT_NetAddrLookupHostAddress (&params_ptr->server_netaddr,
-                                         FFT_Cmd->server_name);
-	    params_ptr->debug = false;
-	    break;
-	}
-	
+		{
+			params_ptr->test_type = FFT_TEST;
+			FFT_Cmd = &params_ptr->u.FFT_Cmd;
+			DT_FFT_Cmd_Init(FFT_Cmd);
+			if (!DT_FFT_Cmd_Parse(FFT_Cmd, my_argc, my_argv, &opts)) {
+				goto error_return;
+			}
+			params_ptr->ReliabilityLevel =
+			    FFT_Cmd->ReliabilityLevel;
+			DT_NetAddrLookupHostAddress(&params_ptr->server_netaddr,
+						    FFT_Cmd->server_name);
+			params_ptr->debug = false;
+			break;
+		}
+
 	default:
-	{
-	    DT_Mdep_printf ("Invalid Test Type\n");
-	    goto main_usage;
+		{
+			DT_Mdep_printf("Invalid Test Type\n");
+			goto main_usage;
+		}
 	}
-    }
 
-    if (fd)
-    {
-	for (i = 0; i < my_argc; i++)
-	{
-	    DT_Mdep_Free (my_argv[i]);
+	if (fd) {
+		for (i = 0; i < my_argc; i++) {
+			DT_Mdep_Free(my_argv[i]);
+		}
+		fclose(fd);
 	}
-	fclose (fd);
-    }
-    return true;
+	return true;
 
-main_usage:
-    Dapltest_Main_Usage ();
-error_return:
-    if (fd)
-    {
-	for (i = 0; i < my_argc; i++)
-	{
-	    DT_Mdep_Free (my_argv[i]);
+      main_usage:
+	Dapltest_Main_Usage();
+      error_return:
+	if (fd) {
+		for (i = 0; i < my_argc; i++) {
+			DT_Mdep_Free(my_argv[i]);
+		}
+		fclose(fd);
 	}
-	fclose (fd);
-    }
-    return false;
+	return false;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_performance_cmd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_performance_cmd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_performance_cmd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,291 +30,268 @@
 
 #include "dapl_proto.h"
 
-static void
-DT_Performance_Cmd_Usage (void)
+static void DT_Performance_Cmd_Usage(void)
 {
-    DT_Mdep_printf ("USAGE: ---- PERFORMANCE TEST ----\n");
-    DT_Mdep_printf ("USAGE:     dapltest -T P\n");
-    DT_Mdep_printf ("USAGE:              -s <server Name>\n");
-    DT_Mdep_printf ("USAGE:              [-m b|p]\n");
-    DT_Mdep_printf ("USAGE:              [-D <device Name>]\n");
-    DT_Mdep_printf ("USAGE:              [-d] : debug (zero)\n");
-    DT_Mdep_printf ("USAGE:              [-i <num iterations>]     : (1, 000)\n");
-    DT_Mdep_printf ("USAGE:              [-p <pipline>]\n");
-    DT_Mdep_printf ("USAGE:              [-R <service reliability>]\n");
-    DT_Mdep_printf ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
-    DT_Mdep_printf ("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
-    DT_Mdep_printf ("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
-    DT_Mdep_printf ("USAGE:                  (EC == QOS_ECONOMY)\n");
-    DT_Mdep_printf ("USAGE:                  (PM == QOS_PREMIUM)\n");
-    DT_Mdep_printf ("USAGE:           <OP>\n");
-    DT_Mdep_printf ("USAGE:\n");
-    DT_Mdep_printf ("USAGE: Each OP consists of:\n");
-    DT_Mdep_printf ("USAGE:     <transfer_type> : \"RR\" (RDMA READ)\n");
-    DT_Mdep_printf ("USAGE:                     : \"RW\" (RDMA WRITE)\n");
-    DT_Mdep_printf ("USAGE:     [seg_size [num_segs] ]      : (4096, 1)\n");
+	DT_Mdep_printf("USAGE: ---- PERFORMANCE TEST ----\n");
+	DT_Mdep_printf("USAGE:     dapltest -T P\n");
+	DT_Mdep_printf("USAGE:              -s <server Name>\n");
+	DT_Mdep_printf("USAGE:              [-m b|p]\n");
+	DT_Mdep_printf("USAGE:              [-D <device Name>]\n");
+	DT_Mdep_printf("USAGE:              [-d] : debug (zero)\n");
+	DT_Mdep_printf
+	    ("USAGE:              [-i <num iterations>]     : (1, 000)\n");
+	DT_Mdep_printf("USAGE:              [-p <pipline>]\n");
+	DT_Mdep_printf("USAGE:              [-R <service reliability>]\n");
+	DT_Mdep_printf
+	    ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
+	DT_Mdep_printf("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
+	DT_Mdep_printf("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
+	DT_Mdep_printf("USAGE:                  (EC == QOS_ECONOMY)\n");
+	DT_Mdep_printf("USAGE:                  (PM == QOS_PREMIUM)\n");
+	DT_Mdep_printf("USAGE:           <OP>\n");
+	DT_Mdep_printf("USAGE:\n");
+	DT_Mdep_printf("USAGE: Each OP consists of:\n");
+	DT_Mdep_printf("USAGE:     <transfer_type> : \"RR\" (RDMA READ)\n");
+	DT_Mdep_printf("USAGE:                     : \"RW\" (RDMA WRITE)\n");
+	DT_Mdep_printf("USAGE:     [seg_size [num_segs] ]      : (4096, 1)\n");
 }
 
 static bool
-DT_Performance_Cmd_Parse_Op (
-    Performance_Cmd_t * cmd,
-    int 		index,
-    int 		my_argc,
-    char 		**my_argv)
+DT_Performance_Cmd_Parse_Op(Performance_Cmd_t * cmd,
+			    int index, int my_argc, char **my_argv)
 {
-    int 		i;
+	int i;
 
-    /*
-     * Op Format: <RR/RW> [seg_size] [num_segs]
-     */
+	/*
+	 * Op Format: <RR/RW> [seg_size] [num_segs]
+	 */
 
-    if ( index == my_argc )
-    {
-	DT_Mdep_printf ("Operation Missing Transfer Type\n");
-	return (false);
-    }
+	if (index == my_argc) {
+		DT_Mdep_printf("Operation Missing Transfer Type\n");
+		return (false);
+	}
 
-    for ( i = 0; index < my_argc; i++, index++ )
-    {
-	switch ( i )
-	{
-	    case 0:
-	    {
-		if ( 0 == strncmp (my_argv[index], "RR", strlen ("RR")) )
-		{
-		    cmd->op.transfer_type = RDMA_READ;
+	for (i = 0; index < my_argc; i++, index++) {
+		switch (i) {
+		case 0:
+			{
+				if (0 ==
+				    strncmp(my_argv[index], "RR",
+					    strlen("RR"))) {
+					cmd->op.transfer_type = RDMA_READ;
+				} else if (0 ==
+					   strncmp(my_argv[index], "RW",
+						   strlen("RW"))) {
+					cmd->op.transfer_type = RDMA_WRITE;
+				} else {
+					DT_Mdep_printf
+					    ("OP type must be <RR/RW/SR>\n");
+					return (false);
+				}
+				break;
+			}
+		case 1:
+			{
+				cmd->op.seg_size = atoi(my_argv[index]);
+				break;
+			}
+		case 2:
+			{
+				cmd->op.num_segs = atoi(my_argv[index]);
+				break;
+			}
+		default:
+			{
+				DT_Mdep_printf("Too many OP args\n");
+				return (false);
+			}
 		}
-		else if ( 0 == strncmp (my_argv[index], "RW", strlen ("RW")) )
-		{
-		    cmd->op.transfer_type = RDMA_WRITE;
-		}
-		else
-		{
-		    DT_Mdep_printf ("OP type must be <RR/RW/SR>\n");
-		    return (false);
-		}
-		break;
-	    }
-	    case 1:
-	    {
-		cmd->op.seg_size = atoi (my_argv[index]);
-		break;
-	    }
-	    case 2:
-	    {
-		cmd->op.num_segs = atoi (my_argv[index]);
-		break;
-	    }
-	    default:
-	    {
-		DT_Mdep_printf ("Too many OP args\n");
-		return (false);
-	    }
 	}
-    }
 
-    return (true);
+	return (true);
 }
 
-
-static bool
-DT_Performance_Cmd_Validate (
-    Performance_Cmd_t 		*cmd)
+static bool DT_Performance_Cmd_Validate(Performance_Cmd_t * cmd)
 {
-    if ( '\0' == cmd->server_name[0] )
-    {
-	DT_Mdep_printf ("Must specify server_name in command line or scriptfile\n");
-	return (false);
-    }
+	if ('\0' == cmd->server_name[0]) {
+		DT_Mdep_printf
+		    ("Must specify server_name in command line or scriptfile\n");
+		return (false);
+	}
 
-    if ( '\0' == cmd->dapl_name[0] )
-    {
-	DT_Mdep_printf ("Must specify device_name in command line or scriptfile\n");
-	return (false);
-    }
+	if ('\0' == cmd->dapl_name[0]) {
+		DT_Mdep_printf
+		    ("Must specify device_name in command line or scriptfile\n");
+		return (false);
+	}
 
-    if ( 0 == cmd->pipeline_len )
-    {
-	DT_Mdep_printf ("Pipeline size must not be 0\n");
-	return (false);
-    }
+	if (0 == cmd->pipeline_len) {
+		DT_Mdep_printf("Pipeline size must not be 0\n");
+		return (false);
+	}
 
-    if ( cmd->debug )
-    {
-	DT_Performance_Cmd_Print (cmd);
-    }
+	if (cmd->debug) {
+		DT_Performance_Cmd_Print(cmd);
+	}
 
-    return true;
+	return true;
 }
 
 bool
-DT_Performance_Cmd_Parse (
-    Performance_Cmd_t 	*cmd,
-    int 		my_argc,
-    char 		**my_argv,
-    mygetopt_t 		*opts)
+DT_Performance_Cmd_Parse(Performance_Cmd_t * cmd,
+			 int my_argc, char **my_argv, mygetopt_t * opts)
 {
-    int             c;
-    unsigned int    len;
+	int c;
+	unsigned int len;
 
-    for (;;)
-    {
-	c = DT_mygetopt_r (my_argc, my_argv, "D:dm:i:p:R:s:", opts);
+	for (;;) {
+		c = DT_mygetopt_r(my_argc, my_argv, "D:dm:i:p:R:s:", opts);
 
-	if ( EOF == c )
-	{
-	    break;
-	}
-
-	switch ( c )
-	{
-	    case 'D':		    /* device name */
-	    {
-		strncpy (cmd->dapl_name, opts->optarg, NAME_SZ);
-		break;
-	    }
-	    case 'd':		    /* print debug messages */
-	    {
-		DT_dapltest_debug++;
-		cmd->debug = true;
-		break;
-	    }
-	    case 'm':		/* mode */
-	    {
-		if ( !strncmp (opts->optarg, "b", strlen ("b")) )
-		{
-		    cmd->mode = BLOCKING_MODE;
+		if (EOF == c) {
+			break;
 		}
-		else if ( !strncmp (opts->optarg, "p", strlen ("p")) )
-		{
-		    cmd->mode = POLLING_MODE;
-		}
-		else
-		{
-		    DT_Mdep_printf ("Syntax Error -m <mode> option\n");
-		    DT_Performance_Cmd_Usage ();
-		    return (false);
-		}
 
-		break;
-	    }
-	    case 'i':		    /* num iterations */
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -i <iterations> option\n");
-		    DT_Performance_Cmd_Usage ();
-		    return (false);
+		switch (c) {
+		case 'D':	/* device name */
+			{
+				strncpy(cmd->dapl_name, opts->optarg, NAME_SZ);
+				break;
+			}
+		case 'd':	/* print debug messages */
+			{
+				DT_dapltest_debug++;
+				cmd->debug = true;
+				break;
+			}
+		case 'm':	/* mode */
+			{
+				if (!strncmp(opts->optarg, "b", strlen("b"))) {
+					cmd->mode = BLOCKING_MODE;
+				} else
+				    if (!strncmp
+					(opts->optarg, "p", strlen("p"))) {
+					cmd->mode = POLLING_MODE;
+				} else {
+					DT_Mdep_printf
+					    ("Syntax Error -m <mode> option\n");
+					DT_Performance_Cmd_Usage();
+					return (false);
+				}
+
+				break;
+			}
+		case 'i':	/* num iterations */
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -i <iterations> option\n");
+					DT_Performance_Cmd_Usage();
+					return (false);
+				}
+				cmd->num_iterations = atol(opts->optarg);
+				break;
+			}
+		case 'p':	/* pipline size */
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -p <piplein> option\n");
+					DT_Performance_Cmd_Usage();
+					return (false);
+				}
+				cmd->pipeline_len = atol(opts->optarg);
+				break;
+			}
+		case 'R':	/* Service Reliability Level */
+			{
+				cmd->qos = DT_ParseQoS(opts->optarg);
+				break;
+			}
+		case 's':	/* server name */
+			{
+				if ((opts->optarg == 0) ||
+				    strlen(opts->optarg) == 0 ||
+				    *opts->optarg == '-') {
+					DT_Mdep_printf
+					    ("must specify server name\n");
+					DT_Performance_Cmd_Usage();
+					return (false);
+				}
+
+				strncpy(cmd->server_name, opts->optarg,
+					NAME_SZ);
+				break;
+			}
+		default:
+			{
+				DT_Mdep_printf
+				    ("Invalid Performance Test Parameter: %c\n",
+				     c);
+				DT_Performance_Cmd_Usage();
+				return (false);
+			}
 		}
-		cmd->num_iterations = atol (opts->optarg);
-		break;
-	    }
-	    case 'p':		    /* pipline size */
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -p <piplein> option\n");
-		    DT_Performance_Cmd_Usage ();
-		    return (false);
-		}
-		cmd->pipeline_len = atol (opts->optarg);
-		break;
-	    }
-	    case 'R':		    /* Service Reliability Level */
-	    {
-		cmd->qos = DT_ParseQoS (opts->optarg);
-		break;
-	    }
-	    case 's':		    /* server name */
-	    {
-		if ((opts->optarg == 0) ||
-		    strlen (opts->optarg) == 0 ||
-		    *opts->optarg == '-')
-		{
-		    DT_Mdep_printf ("must specify server name\n");
-		    DT_Performance_Cmd_Usage ();
-		    return (false);
-		}
+	}
 
-		strncpy (cmd->server_name, opts->optarg, NAME_SZ);
-		break;
-	    }
-	    default:
-	    {
-		DT_Mdep_printf ("Invalid Performance Test Parameter: %c\n", c);
-		DT_Performance_Cmd_Usage ();
+	/*
+	 * now parse the op
+	 */
+	if (!DT_Performance_Cmd_Parse_Op(cmd, opts->optind, my_argc, my_argv)) {
+		DT_Performance_Cmd_Usage();
 		return (false);
-	    }
 	}
-    }
 
-    /*
-     * now parse the op
-     */
-    if ( !DT_Performance_Cmd_Parse_Op (cmd, opts->optind, my_argc, my_argv) )
-    {
-	DT_Performance_Cmd_Usage ();
-	return (false);
-    }
+	if (!DT_Performance_Cmd_Validate(cmd)) {
+		DT_Performance_Cmd_Usage();
+		return (false);
+	}
 
-    if ( !DT_Performance_Cmd_Validate (cmd) )
-    {
-	DT_Performance_Cmd_Usage ();
-	return (false);
-    }
-
-    return (true);
+	return (true);
 }
 
-
-bool
-DT_Performance_Cmd_Init (Performance_Cmd_t * cmd)
+bool DT_Performance_Cmd_Init(Performance_Cmd_t * cmd)
 {
-    memset (cmd, 0, sizeof (Performance_Cmd_t));
-    cmd->dapltest_version = DAPLTEST_VERSION;
-    cmd->client_is_little_endian = DT_local_is_little_endian;
-    cmd->qos = DAT_QOS_BEST_EFFORT;
-    cmd->debug = false;
-    cmd->num_iterations = 1000;
-    cmd->pipeline_len = ~0;
+	memset(cmd, 0, sizeof(Performance_Cmd_t));
+	cmd->dapltest_version = DAPLTEST_VERSION;
+	cmd->client_is_little_endian = DT_local_is_little_endian;
+	cmd->qos = DAT_QOS_BEST_EFFORT;
+	cmd->debug = false;
+	cmd->num_iterations = 1000;
+	cmd->pipeline_len = ~0;
 
-    cmd->op.transfer_type = RDMA_WRITE;
-    cmd->op.seg_size = 4096;
-    cmd->op.num_segs = 1;
+	cmd->op.transfer_type = RDMA_WRITE;
+	cmd->op.seg_size = 4096;
+	cmd->op.num_segs = 1;
 
-    if ( !DT_Mdep_GetDefaultDeviceName (cmd->dapl_name) )
-    {
-	DT_Mdep_printf ("can't get default device name\n");
-	return (false);
-    }
+	if (!DT_Mdep_GetDefaultDeviceName(cmd->dapl_name)) {
+		DT_Mdep_printf("can't get default device name\n");
+		return (false);
+	}
 
-    return (true);
+	return (true);
 }
 
-void
-DT_Performance_Cmd_Print (
-    Performance_Cmd_t   *cmd)
+void DT_Performance_Cmd_Print(Performance_Cmd_t * cmd)
 {
-    DT_Mdep_printf ("-------------------------------------\n");
-    DT_Mdep_printf ("PerfCmd.server_name              : %s\n",
-                   cmd->server_name);
-    DT_Mdep_printf ("PerfCmd.dapl_name                : %s\n",
-                   cmd->dapl_name);
-    DT_Mdep_printf ("PerfCmd.mode                     : %s\n",
-                   (cmd->mode == BLOCKING_MODE) ? "BLOCKING" : "POLLING");
-    DT_Mdep_printf ("PerfCmd.num_iterations           : %d\n",
-                   cmd->num_iterations);
-    DT_Mdep_printf ("PerfCmd.pipeline_len             : %d\n",
-                   cmd->pipeline_len);
-    DT_Mdep_printf ("PerfCmd.op.transfer_type         : %s\n",
-                   cmd->op.transfer_type == RDMA_READ ? "RDMA_READ" :
-                   cmd->op.transfer_type == RDMA_WRITE ? "RDMA_WRITE" :
-                   "SEND_RECV");
-    DT_Mdep_printf ("PerfCmd.op.num_segs              : %d\n",
-                   cmd->op.num_segs);
-    DT_Mdep_printf ("PerfCmd.op.seg_size              : %d\n",
-                   cmd->op.seg_size);
+	DT_Mdep_printf("-------------------------------------\n");
+	DT_Mdep_printf("PerfCmd.server_name              : %s\n",
+		       cmd->server_name);
+	DT_Mdep_printf("PerfCmd.dapl_name                : %s\n",
+		       cmd->dapl_name);
+	DT_Mdep_printf("PerfCmd.mode                     : %s\n",
+		       (cmd->mode == BLOCKING_MODE) ? "BLOCKING" : "POLLING");
+	DT_Mdep_printf("PerfCmd.num_iterations           : %d\n",
+		       cmd->num_iterations);
+	DT_Mdep_printf("PerfCmd.pipeline_len             : %d\n",
+		       cmd->pipeline_len);
+	DT_Mdep_printf("PerfCmd.op.transfer_type         : %s\n",
+		       cmd->op.transfer_type == RDMA_READ ? "RDMA_READ" :
+		       cmd->op.transfer_type == RDMA_WRITE ? "RDMA_WRITE" :
+		       "SEND_RECV");
+	DT_Mdep_printf("PerfCmd.op.num_segs              : %d\n",
+		       cmd->op.num_segs);
+	DT_Mdep_printf("PerfCmd.op.seg_size              : %d\n",
+		       cmd->op.seg_size);
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_qos_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_qos_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_qos_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -35,31 +35,25 @@
  *
  * Returns no errors: defaults to best effort.
  */
-DAT_QOS
-DT_ParseQoS (char *arg)
+DAT_QOS DT_ParseQoS(char *arg)
 {
-    if (0 == strcmp (arg, "HT"))
-    {
-	return ( DAT_QOS_HIGH_THROUGHPUT );
-    }
+	if (0 == strcmp(arg, "HT")) {
+		return (DAT_QOS_HIGH_THROUGHPUT);
+	}
 
-    if (0 == strcmp (arg, "LL"))
-    {
-	return ( DAT_QOS_LOW_LATENCY );
-    }
+	if (0 == strcmp(arg, "LL")) {
+		return (DAT_QOS_LOW_LATENCY);
+	}
 
-    if (0 == strcmp (arg, "EC"))
-    {
-	return ( DAT_QOS_ECONOMY );
-    }
+	if (0 == strcmp(arg, "EC")) {
+		return (DAT_QOS_ECONOMY);
+	}
 
-    if (0 == strcmp (arg, "PM"))
-    {
-	return ( DAT_QOS_PREMIUM );
-    }
-    /*
-     * Default to "BE" so no point in checking further
-     */
-    return ( DAT_QOS_BEST_EFFORT );
+	if (0 == strcmp(arg, "PM")) {
+		return (DAT_QOS_PREMIUM);
+	}
+	/*
+	 * Default to "BE" so no point in checking further
+	 */
+	return (DAT_QOS_BEST_EFFORT);
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_quit_cmd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_quit_cmd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_quit_cmd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,112 +31,102 @@
 #include "dapl_proto.h"
 
 /*--------------------------------------------------------- */
-void
-DT_Quit_Cmd_Init (Quit_Cmd_t * cmd)
+void DT_Quit_Cmd_Init(Quit_Cmd_t * cmd)
 {
-    memset ((void *)cmd, 0, sizeof (Quit_Cmd_t));
-    cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
+	memset((void *)cmd, 0, sizeof(Quit_Cmd_t));
+	cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
 }
 
 /*--------------------------------------------------------- */
 bool
-DT_Quit_Cmd_Parse (Quit_Cmd_t * cmd,
-	       int my_argc,
-	       char **my_argv,
-	       mygetopt_t * opts)
+DT_Quit_Cmd_Parse(Quit_Cmd_t * cmd,
+		  int my_argc, char **my_argv, mygetopt_t * opts)
 {
-    int             c;
+	int c;
 
-    for (;;)
-    {
-	c = DT_mygetopt_r (my_argc, my_argv, "ds:D:R:", opts);
-	if (c == EOF)
-	{
-	    break;
+	for (;;) {
+		c = DT_mygetopt_r(my_argc, my_argv, "ds:D:R:", opts);
+		if (c == EOF) {
+			break;
+		}
+		switch (c) {
+		case 'D':
+			{
+				strcpy(cmd->device_name, opts->optarg);
+				break;
+			}
+		case 's':
+			{
+				strcpy(cmd->server_name, opts->optarg);
+				break;
+			}
+		case 'd':	/* print debug messages */
+			{
+				DT_dapltest_debug++;
+				cmd->debug = true;
+				break;
+			}
+		case 'R':	/* Service Reliability Level */
+			{
+				cmd->ReliabilityLevel =
+				    DT_ParseQoS(opts->optarg);
+				break;
+			}
+		case '?':
+		default:
+			{
+				DT_Mdep_printf("Invalid Quit option: %c\n",
+					       opts->optopt);
+				DT_Quit_Cmd_Usage();
+				return (false);
+			}
+		}
 	}
-	switch (c)
-	{
-	    case 'D':
-	    {
-		strcpy (cmd->device_name, opts->optarg);
-		break;
-	    }
-	    case 's':
-	    {
-		strcpy (cmd->server_name, opts->optarg);
-		break;
-	    }
-	    case 'd':		    /* print debug messages */
-	    {
-		DT_dapltest_debug++;
-		cmd->debug = true;
-		break;
-	    }
-	    case 'R':		    /* Service Reliability Level */
-	    {
-		cmd->ReliabilityLevel= DT_ParseQoS (opts->optarg);
-		break;
-	    }
-	    case '?':
-	    default:
-	    {
-		DT_Mdep_printf ("Invalid Quit option: %c\n", opts->optopt);
-		DT_Quit_Cmd_Usage ();
+	if (cmd->device_name[0] == '\0') {
+		if (!DT_Mdep_GetDefaultDeviceName(cmd->device_name)) {
+			DT_Mdep_printf("can't get default device name\n");
+			DT_Quit_Cmd_Usage();
+			return (false);
+		}
+	}
+	if (!DT_Quit_Cmd_Validate(cmd)) {
+		DT_Quit_Cmd_Usage();
 		return (false);
-	    }
 	}
-    }
-    if (cmd->device_name[0] == '\0')
-    {
-	if (!DT_Mdep_GetDefaultDeviceName (cmd->device_name))
-	{
-	    DT_Mdep_printf ("can't get default device name\n");
-	    DT_Quit_Cmd_Usage ();
-	    return (false);
-	}
-    }
-    if (!DT_Quit_Cmd_Validate (cmd))
-    {
-	DT_Quit_Cmd_Usage ();
-	return (false);
-    }
-    return (true);
+	return (true);
 }
 
 /*------------------------------------------------------------------------------ */
-bool
-DT_Quit_Cmd_Validate (Quit_Cmd_t * cmd)
+bool DT_Quit_Cmd_Validate(Quit_Cmd_t * cmd)
 {
-    if (cmd->server_name[0] == '\0')
-    {
-	DT_Mdep_printf ("Must specify server_name in command line or scriptfile\n");
-	return (false);
-    }
-    return (true);
+	if (cmd->server_name[0] == '\0') {
+		DT_Mdep_printf
+		    ("Must specify server_name in command line or scriptfile\n");
+		return (false);
+	}
+	return (true);
 }
 
 /*--------------------------------------------------------- */
-void
-DT_Quit_Cmd_Usage (void)
+void DT_Quit_Cmd_Usage(void)
 {
-    DT_Mdep_printf ("USAGE: ---- QUIT TEST ----\n");
-    DT_Mdep_printf ("USAGE:     dapltest -T Q\n");
-    DT_Mdep_printf ("USAGE:              -s <server Name>\n");
-    DT_Mdep_printf ("USAGE:              [-D <device Name>]\n");
-    DT_Mdep_printf ("USAGE:              [-d] : debug (zero)\n");
-    DT_Mdep_printf ("USAGE:              [-R <service reliability>]\n");
-    DT_Mdep_printf ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
-    DT_Mdep_printf ("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
-    DT_Mdep_printf ("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
-    DT_Mdep_printf ("USAGE:                  (EC == QOS_ECONOMY)\n");
-    DT_Mdep_printf ("USAGE:                  (PM == QOS_PREMIUM)\n");
+	DT_Mdep_printf("USAGE: ---- QUIT TEST ----\n");
+	DT_Mdep_printf("USAGE:     dapltest -T Q\n");
+	DT_Mdep_printf("USAGE:              -s <server Name>\n");
+	DT_Mdep_printf("USAGE:              [-D <device Name>]\n");
+	DT_Mdep_printf("USAGE:              [-d] : debug (zero)\n");
+	DT_Mdep_printf("USAGE:              [-R <service reliability>]\n");
+	DT_Mdep_printf
+	    ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
+	DT_Mdep_printf("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
+	DT_Mdep_printf("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
+	DT_Mdep_printf("USAGE:                  (EC == QOS_ECONOMY)\n");
+	DT_Mdep_printf("USAGE:                  (PM == QOS_PREMIUM)\n");
 }
 
 /*--------------------------------------------------------- */
-void
-DT_Quit_Cmd_Print (Quit_Cmd_t * cmd)
+void DT_Quit_Cmd_Print(Quit_Cmd_t * cmd)
 {
-    DT_Mdep_printf ("Quit_Cmd.server_name: %s\n", cmd->server_name);
-    DT_Mdep_printf ("Quit_Cmd.device_name: %s\n", cmd->device_name);
+	DT_Mdep_printf("Quit_Cmd.server_name: %s\n", cmd->server_name);
+	DT_Mdep_printf("Quit_Cmd.device_name: %s\n", cmd->device_name);
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_server_cmd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_server_cmd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_server_cmd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,94 +30,85 @@
 
 #include "dapl_proto.h"
 
-void
-DT_Server_Cmd_Init (Server_Cmd_t * Server_Cmd)
+void DT_Server_Cmd_Init(Server_Cmd_t * Server_Cmd)
 {
-    DT_dapltest_debug = 0;
-    Server_Cmd->debug = false;
-    Server_Cmd->dapl_name[0] = '\0';
-    Server_Cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
+	DT_dapltest_debug = 0;
+	Server_Cmd->debug = false;
+	Server_Cmd->dapl_name[0] = '\0';
+	Server_Cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
 }
 
-
 bool
-DT_Server_Cmd_Parse (Server_Cmd_t * Server_Cmd,
-		 int my_argc,
-		 char **my_argv,
-		 mygetopt_t * opts)
+DT_Server_Cmd_Parse(Server_Cmd_t * Server_Cmd,
+		    int my_argc, char **my_argv, mygetopt_t * opts)
 {
-    int            c;
-    for (;;)
-    {
-	c = DT_mygetopt_r (my_argc, my_argv, "dD:R:", opts);
-	if (c == EOF)
-	{
-	    break;
+	int c;
+	for (;;) {
+		c = DT_mygetopt_r(my_argc, my_argv, "dD:R:", opts);
+		if (c == EOF) {
+			break;
+		}
+		switch (c) {
+		case 'D':
+			{
+				strcpy(Server_Cmd->dapl_name, opts->optarg);
+				break;
+			}
+		case 'd':
+			{
+				DT_dapltest_debug++;
+				Server_Cmd->debug = true;
+				break;
+			}
+		case 'R':	/* Service Reliability Level */
+			{
+				Server_Cmd->ReliabilityLevel =
+				    DT_ParseQoS(opts->optarg);
+				if (0 == Server_Cmd->ReliabilityLevel) {
+					return (false);
+				}
+				break;
+			}
+		case '?':
+		default:
+			{
+				DT_Mdep_printf("Invalid Server option: %c\n",
+					       opts->optopt);
+				DT_Server_Cmd_Usage();
+				return (false);
+			}
+		}
 	}
-	switch (c)
-	{
-	    case 'D':
-	    {
-		strcpy (Server_Cmd->dapl_name, opts->optarg);
-		break;
-	    }
-	    case 'd':
-	    {
-		DT_dapltest_debug++;
-		Server_Cmd->debug = true;
-		break;
-	    }
-	    case 'R':		    /* Service Reliability Level */
-	    {
-		Server_Cmd->ReliabilityLevel = DT_ParseQoS (opts->optarg);
-		if (0 == Server_Cmd->ReliabilityLevel)
-		{
-		    return (false);
+	if (Server_Cmd->dapl_name == '\0') {
+		if (!DT_Mdep_GetDefaultDeviceName(Server_Cmd->dapl_name)) {
+			DT_Mdep_printf("can't get default device name\n");
+			DT_Server_Cmd_Usage();
+			return (false);
 		}
-		break;
-	    }
-	    case '?':
-	    default:
-	    {
-		DT_Mdep_printf ("Invalid Server option: %c\n", opts->optopt);
-		DT_Server_Cmd_Usage ();
-		return (false);
-	    }
 	}
-    }
-    if (Server_Cmd->dapl_name == '\0')
-    {
-	if (!DT_Mdep_GetDefaultDeviceName (Server_Cmd->dapl_name))
-	{
-	    DT_Mdep_printf ("can't get default device name\n");
-	    DT_Server_Cmd_Usage ();
-	    return (false);
-	}
-    }
-    return (true);
+	return (true);
 }
 
-void
-DT_Server_Cmd_Usage (void)
+void DT_Server_Cmd_Usage(void)
 {
-    DT_Mdep_printf ("USAGE: ---- SERVER MODE ----\n");
-    DT_Mdep_printf ("USAGE:     dapltest -T S\n");
-    DT_Mdep_printf ("USAGE:              [-D <device Name>]\n");
-    DT_Mdep_printf ("USAGE:              [-d] : debug (zero)\n");
-    DT_Mdep_printf ("USAGE:              [-R <service reliability>]\n");
-    DT_Mdep_printf ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
-    DT_Mdep_printf ("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
-    DT_Mdep_printf ("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
-    DT_Mdep_printf ("USAGE:                  (EC == QOS_ECONOMY)\n");
-    DT_Mdep_printf ("USAGE:                  (PM == QOS_PREMIUM)\n");
-    DT_Mdep_printf ("USAGE: Run as server using default parameters\n");
-    DT_Mdep_printf ("USAGE:     dapltest\n");
-    DT_Mdep_printf ("USAGE:\n");
+	DT_Mdep_printf("USAGE: ---- SERVER MODE ----\n");
+	DT_Mdep_printf("USAGE:     dapltest -T S\n");
+	DT_Mdep_printf("USAGE:              [-D <device Name>]\n");
+	DT_Mdep_printf("USAGE:              [-d] : debug (zero)\n");
+	DT_Mdep_printf("USAGE:              [-R <service reliability>]\n");
+	DT_Mdep_printf
+	    ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
+	DT_Mdep_printf("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
+	DT_Mdep_printf("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
+	DT_Mdep_printf("USAGE:                  (EC == QOS_ECONOMY)\n");
+	DT_Mdep_printf("USAGE:                  (PM == QOS_PREMIUM)\n");
+	DT_Mdep_printf("USAGE: Run as server using default parameters\n");
+	DT_Mdep_printf("USAGE:     dapltest\n");
+	DT_Mdep_printf("USAGE:\n");
 }
 
-void
-DT_Server_Cmd_Print (Server_Cmd_t * Server_Cmd)
+void DT_Server_Cmd_Print(Server_Cmd_t * Server_Cmd)
 {
-    DT_Mdep_printf ("Server_Cmd.debug:       %d\n", Server_Cmd->debug);
-    DT_Mdep_printf ("Server_Cmd.dapl_name: %s\n", Server_Cmd->dapl_name);
+	DT_Mdep_printf("Server_Cmd.debug:       %d\n", Server_Cmd->debug);
+	DT_Mdep_printf("Server_Cmd.dapl_name: %s\n", Server_Cmd->dapl_name);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_transaction_cmd.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_transaction_cmd.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/cmd/dapl_transaction_cmd.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,471 +30,424 @@
 
 #include "dapl_proto.h"
 
-static bool
-DT_Transaction_Cmd_Parse_Op (Transaction_Cmd_t * cmd, char *arg)
+static bool DT_Transaction_Cmd_Parse_Op(Transaction_Cmd_t * cmd, char *arg)
 {
-    char           *c_ptr;
-    int             op;
-    if (cmd->num_ops >= MAX_OPS)
-    {
-	DT_Mdep_printf ("Client: Too Many Ops - Max %d\n", MAX_OPS);
-	goto error_return;
-    }
-    op = cmd->num_ops;
-    cmd->num_ops++;
+	char *c_ptr;
+	int op;
+	if (cmd->num_ops >= MAX_OPS) {
+		DT_Mdep_printf("Client: Too Many Ops - Max %d\n", MAX_OPS);
+		goto error_return;
+	}
+	op = cmd->num_ops;
+	cmd->num_ops++;
 
-    /* set some defaults */
-    cmd->op[op].seg_size = 4096;
-    cmd->op[op].num_segs = 1;
-    cmd->op[op].reap_send_on_recv = false;
+	/* set some defaults */
+	cmd->op[op].seg_size = 4096;
+	cmd->op[op].num_segs = 1;
+	cmd->op[op].reap_send_on_recv = false;
 
-    /*
-     * packet format: <server/client> <RR/RW/SR> [seg_size] [num_segs]
-     */
-    c_ptr = strtok (arg, " \t");
-    if (!c_ptr)
-    {
-	DT_Mdep_printf ("OP first arg must <server/client>\n");
-	goto error_return;
-    }
-    /* first token is <who>: */
-    if (strcmp (c_ptr, "server") == 0)
-    {
-	cmd->op[op].server_initiated = true;
-    }
-    else
-    {
-	if (strcmp (c_ptr, "client") == 0)
-	{
-	    cmd->op[op].server_initiated = false;
+	/*
+	 * packet format: <server/client> <RR/RW/SR> [seg_size] [num_segs]
+	 */
+	c_ptr = strtok(arg, " \t");
+	if (!c_ptr) {
+		DT_Mdep_printf("OP first arg must <server/client>\n");
+		goto error_return;
 	}
-	else
-	{
-	    DT_Mdep_printf ("OP first arg must <server/client>\n");
-	    goto error_return;
+	/* first token is <who>: */
+	if (strcmp(c_ptr, "server") == 0) {
+		cmd->op[op].server_initiated = true;
+	} else {
+		if (strcmp(c_ptr, "client") == 0) {
+			cmd->op[op].server_initiated = false;
+		} else {
+			DT_Mdep_printf("OP first arg must <server/client>\n");
+			goto error_return;
+		}
 	}
-    }
 
-    c_ptr = strtok (0, " \t");
-    if (!c_ptr)
-    {
-	DT_Mdep_printf ("OP Second arg must be <RR/RW/SR>\n");
-	goto error_return;
-    }
-    /* second token is <transfer_type>: */
-    if (strcmp (c_ptr, "RR") == 0)
-    {
-	cmd->op[op].transfer_type = RDMA_READ;
-    }
-    else
-    {
-	if (strcmp (c_ptr, "RW") == 0)
-	{
-	    cmd->op[op].transfer_type = RDMA_WRITE;
-	}
-	else
-	{
-	    if (strcmp (c_ptr, "SR") == 0)
-	    {
-		cmd->op[op].transfer_type = SEND_RECV;
-	    }
-	    else
-	    {
-		DT_Mdep_printf ("OP Second arg must be <RR/RW/SR>\n");
+	c_ptr = strtok(0, " \t");
+	if (!c_ptr) {
+		DT_Mdep_printf("OP Second arg must be <RR/RW/SR>\n");
 		goto error_return;
-	    }
 	}
-    }
-    /*
-     * there may or may not be additional parameters... [seg_size] [num_segs]
-     * [-f]
-     */
-    c_ptr = strtok (0, " \t");
-    if (c_ptr && strspn (c_ptr, "0123456789") != 0)
-    {
-	cmd->op[op].seg_size = atoi (c_ptr);
-	c_ptr = strtok (0, " \t");
-    }
-    if (c_ptr && strspn (c_ptr, "0123456789") != 0)
-    {
-	cmd->op[op].num_segs = atoi (c_ptr);
-	c_ptr = strtok (0, " \t");
-    }
-    if (c_ptr && strcmp (c_ptr, "-f") == 0)
-    {
-	cmd->op[op].reap_send_on_recv = true;
-	if (cmd->op[op].transfer_type != SEND_RECV)
-	{
-	    DT_Mdep_printf ("OP: -f only valid on SEND_RECV\n");
-	    goto error_return;
+	/* second token is <transfer_type>: */
+	if (strcmp(c_ptr, "RR") == 0) {
+		cmd->op[op].transfer_type = RDMA_READ;
+	} else {
+		if (strcmp(c_ptr, "RW") == 0) {
+			cmd->op[op].transfer_type = RDMA_WRITE;
+		} else {
+			if (strcmp(c_ptr, "SR") == 0) {
+				cmd->op[op].transfer_type = SEND_RECV;
+			} else {
+				DT_Mdep_printf
+				    ("OP Second arg must be <RR/RW/SR>\n");
+				goto error_return;
+			}
+		}
 	}
-	c_ptr = strtok (0, " \t");
-    }
-    if (c_ptr)
-    {
-	DT_Mdep_printf ("OP too many args \n");
-	goto error_return;
-    }
-    return true;
+	/*
+	 * there may or may not be additional parameters... [seg_size] [num_segs]
+	 * [-f]
+	 */
+	c_ptr = strtok(0, " \t");
+	if (c_ptr && strspn(c_ptr, "0123456789") != 0) {
+		cmd->op[op].seg_size = atoi(c_ptr);
+		c_ptr = strtok(0, " \t");
+	}
+	if (c_ptr && strspn(c_ptr, "0123456789") != 0) {
+		cmd->op[op].num_segs = atoi(c_ptr);
+		c_ptr = strtok(0, " \t");
+	}
+	if (c_ptr && strcmp(c_ptr, "-f") == 0) {
+		cmd->op[op].reap_send_on_recv = true;
+		if (cmd->op[op].transfer_type != SEND_RECV) {
+			DT_Mdep_printf("OP: -f only valid on SEND_RECV\n");
+			goto error_return;
+		}
+		c_ptr = strtok(0, " \t");
+	}
+	if (c_ptr) {
+		DT_Mdep_printf("OP too many args \n");
+		goto error_return;
+	}
+	return true;
 
-error_return:
-    return false;
+      error_return:
+	return false;
 }
 
-static bool
-DT_Transaction_Cmd_Validate (Transaction_Cmd_t * cmd)
+static bool DT_Transaction_Cmd_Validate(Transaction_Cmd_t * cmd)
 {
-    unsigned int    i;
-    bool            has_server_send;
-    bool            has_client_send;
-    unsigned int    reap_count;
-    has_server_send = false;
-    has_client_send = false;
-    reap_count = 0;
+	unsigned int i;
+	bool has_server_send;
+	bool has_client_send;
+	unsigned int reap_count;
+	has_server_send = false;
+	has_client_send = false;
+	reap_count = 0;
 
-    if (cmd->server_name[0] == '\0')
-    {
-	DT_Mdep_printf ("Must specify server_name in command line or scriptfile\n");
-	return (false);
-    }
-    for (i = 0; i < cmd->num_ops; i++)
-    {
-	switch (cmd->op[i].transfer_type)
-	{
-	    case SEND_RECV:
-	    {
-		if (cmd->op[i].server_initiated)
-		{
-		    has_server_send = true;
-		}
-		else
-		{
-		    has_client_send = true;
-		}
-		if (cmd->op[i].reap_send_on_recv)
-		{
-		    if (!cmd->op[i].server_initiated)
-		    {
-			/* client */
-			reap_count++;
-		    }
-		    else
-		    {
-			/* server */
-			if (reap_count > 0)
+	if (cmd->server_name[0] == '\0') {
+		DT_Mdep_printf
+		    ("Must specify server_name in command line or scriptfile\n");
+		return (false);
+	}
+	for (i = 0; i < cmd->num_ops; i++) {
+		switch (cmd->op[i].transfer_type) {
+		case SEND_RECV:
 			{
-			    reap_count--;
+				if (cmd->op[i].server_initiated) {
+					has_server_send = true;
+				} else {
+					has_client_send = true;
+				}
+				if (cmd->op[i].reap_send_on_recv) {
+					if (!cmd->op[i].server_initiated) {
+						/* client */
+						reap_count++;
+					} else {
+						/* server */
+						if (reap_count > 0) {
+							reap_count--;
+						} else {
+							DT_Mdep_printf
+							    ("OP: Unbalanced -f options\n");
+							return false;
+						}
+					}
+				}
+				break;
 			}
-			else
+		case RDMA_READ:
 			{
-			    DT_Mdep_printf ("OP: Unbalanced -f options\n");
-			    return false;
+				break;
 			}
-		    }
+		case RDMA_WRITE:
+			{
+				break;
+			}
 		}
-		break;
-	    }
-	    case RDMA_READ:
-	    {
-		break;
-	    }
-	    case RDMA_WRITE:
-	    {
-		break;
-	    }
 	}
-    }
 
-    if (!has_server_send || !has_client_send)
-    {
-	DT_Mdep_printf ("Error: Transaction test requires \n");
-	DT_Mdep_printf ("Error: At least one server SR and one client SR Operation\n");
-	return false;
-    }
-    if (reap_count != 0)
-    {
-	DT_Mdep_printf ("OP: Unbalanced -f options\n");
-	return false;
-    }
-    if (cmd->debug)
-    {
-	DT_Transaction_Cmd_Print (cmd);
-    }
-    return true;
+	if (!has_server_send || !has_client_send) {
+		DT_Mdep_printf("Error: Transaction test requires \n");
+		DT_Mdep_printf
+		    ("Error: At least one server SR and one client SR Operation\n");
+		return false;
+	}
+	if (reap_count != 0) {
+		DT_Mdep_printf("OP: Unbalanced -f options\n");
+		return false;
+	}
+	if (cmd->debug) {
+		DT_Transaction_Cmd_Print(cmd);
+	}
+	return true;
 }
 
-
-static void
-DT_Transaction_Cmd_Usage (void)
+static void DT_Transaction_Cmd_Usage(void)
 {
-    DT_Mdep_printf ("USAGE: ---- TRANSACTION TEST ----\n");
-    DT_Mdep_printf ("USAGE:     dapltest -T T\n");
-    DT_Mdep_printf ("USAGE:              -s <server Name>\n");
-    DT_Mdep_printf ("USAGE:              [-D <device Name>]\n");
-    DT_Mdep_printf ("USAGE:              [-d] : debug (zero)\n");
-    DT_Mdep_printf ("USAGE:              [-i <num iterations>]     : (1, 000)\n");
-    DT_Mdep_printf ("USAGE:              [-t <num threads>]        : (1)\n");
-    DT_Mdep_printf ("USAGE:              [-w <num EPs per thread>] : (1)\n");
-    DT_Mdep_printf ("USAGE:              [-V ] : Validate data: (false)\n");
-    DT_Mdep_printf ("USAGE:              [-P ] : DTO Completion Polling: (false)\n");
-    DT_Mdep_printf ("USAGE:              [-r ] : Use RSPs: (false)\n");
-    DT_Mdep_printf ("USAGE:              [-R <service reliability>]\n");
-    DT_Mdep_printf ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
-    DT_Mdep_printf ("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
-    DT_Mdep_printf ("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
-    DT_Mdep_printf ("USAGE:                  (EC == QOS_ECONOMY)\n");
-    DT_Mdep_printf ("USAGE:                  (PM == QOS_PREMIUM)\n");
-    DT_Mdep_printf ("USAGE:           <OP [OP...]\n");
-    DT_Mdep_printf ("USAGE:\n");
-    DT_Mdep_printf ("USAGE: Each OP consists of:\n");
-    DT_Mdep_printf ("USAGE:     <who>       : \"server\"/\"client\"\n");
-    DT_Mdep_printf ("USAGE:     <transfer_type> : \"SR\" (SEND/RECV)\n");
-    DT_Mdep_printf ("USAGE:                     : \"RR\" (RDMA READ)\n");
-    DT_Mdep_printf ("USAGE:                     : \"RW\" (RDMA WRITE)\n");
-    DT_Mdep_printf ("USAGE:     [seg_size [num_segs] ]      : (4096, 1)\n");
-    DT_Mdep_printf ("USAGE:     [-f]                 : Reap sends on recv\n");
-    DT_Mdep_printf ("USAGE:\n");
-    DT_Mdep_printf ("NOTE: -f is only allowed on \"SR\" OPs\n");
-    DT_Mdep_printf ("NOTE: -f must appear in pairs (one client, one server)\n");
-    DT_Mdep_printf (
-	"NOTE: At least one server SR and one client SR OP are required\n");
-    DT_Mdep_printf (
-	"NOTE: and use of -V results in the use of three extra OPs\n");
+	DT_Mdep_printf("USAGE: ---- TRANSACTION TEST ----\n");
+	DT_Mdep_printf("USAGE:     dapltest -T T\n");
+	DT_Mdep_printf("USAGE:              -s <server Name>\n");
+	DT_Mdep_printf("USAGE:              [-D <device Name>]\n");
+	DT_Mdep_printf("USAGE:              [-d] : debug (zero)\n");
+	DT_Mdep_printf
+	    ("USAGE:              [-i <num iterations>]     : (1, 000)\n");
+	DT_Mdep_printf("USAGE:              [-t <num threads>]        : (1)\n");
+	DT_Mdep_printf("USAGE:              [-w <num EPs per thread>] : (1)\n");
+	DT_Mdep_printf("USAGE:              [-V ] : Validate data: (false)\n");
+	DT_Mdep_printf
+	    ("USAGE:              [-P ] : DTO Completion Polling: (false)\n");
+	DT_Mdep_printf("USAGE:              [-r ] : Use RSPs: (false)\n");
+	DT_Mdep_printf("USAGE:              [-R <service reliability>]\n");
+	DT_Mdep_printf
+	    ("USAGE:                  (BE == QOS_BEST_EFFORT - Default)\n");
+	DT_Mdep_printf("USAGE:                  (HT == QOS_HIGH_THROUGHPUT)\n");
+	DT_Mdep_printf("USAGE:                  (LL == QOS_LOW_LATENCY)\n");
+	DT_Mdep_printf("USAGE:                  (EC == QOS_ECONOMY)\n");
+	DT_Mdep_printf("USAGE:                  (PM == QOS_PREMIUM)\n");
+	DT_Mdep_printf("USAGE:           <OP [OP...]\n");
+	DT_Mdep_printf("USAGE:\n");
+	DT_Mdep_printf("USAGE: Each OP consists of:\n");
+	DT_Mdep_printf("USAGE:     <who>       : \"server\"/\"client\"\n");
+	DT_Mdep_printf("USAGE:     <transfer_type> : \"SR\" (SEND/RECV)\n");
+	DT_Mdep_printf("USAGE:                     : \"RR\" (RDMA READ)\n");
+	DT_Mdep_printf("USAGE:                     : \"RW\" (RDMA WRITE)\n");
+	DT_Mdep_printf("USAGE:     [seg_size [num_segs] ]      : (4096, 1)\n");
+	DT_Mdep_printf
+	    ("USAGE:     [-f]                 : Reap sends on recv\n");
+	DT_Mdep_printf("USAGE:\n");
+	DT_Mdep_printf("NOTE: -f is only allowed on \"SR\" OPs\n");
+	DT_Mdep_printf
+	    ("NOTE: -f must appear in pairs (one client, one server)\n");
+	DT_Mdep_printf
+	    ("NOTE: At least one server SR and one client SR OP are required\n");
+	DT_Mdep_printf
+	    ("NOTE: and use of -V results in the use of three extra OPs\n");
 }
 
-
-void
-DT_Transaction_Cmd_Init (Transaction_Cmd_t * cmd)
+void DT_Transaction_Cmd_Init(Transaction_Cmd_t * cmd)
 {
-    memset ((void *)cmd, 0, sizeof (Transaction_Cmd_t));
-    cmd->dapltest_version = DAPLTEST_VERSION;
-    cmd->client_is_little_endian = DT_local_is_little_endian;
-    cmd->num_iterations = 1000;
-    cmd->num_threads = 1;
-    cmd->eps_per_thread = 1;
-    cmd->debug = false;
-    cmd->validate = false;
-    cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
+	memset((void *)cmd, 0, sizeof(Transaction_Cmd_t));
+	cmd->dapltest_version = DAPLTEST_VERSION;
+	cmd->client_is_little_endian = DT_local_is_little_endian;
+	cmd->num_iterations = 1000;
+	cmd->num_threads = 1;
+	cmd->eps_per_thread = 1;
+	cmd->debug = false;
+	cmd->validate = false;
+	cmd->ReliabilityLevel = DAT_QOS_BEST_EFFORT;
 }
 
-
 bool
-DT_Transaction_Cmd_Parse (Transaction_Cmd_t * cmd,
-		      int my_argc,
-		      char **my_argv,
-		      mygetopt_t * opts)
+DT_Transaction_Cmd_Parse(Transaction_Cmd_t * cmd,
+			 int my_argc, char **my_argv, mygetopt_t * opts)
 {
-    int             c;
-    unsigned int    len;
-    int             i;
-    char            op[100];
-    for (;;)
-    {
-	c = DT_mygetopt_r (my_argc, my_argv, "rQVPdw:s:D:i:t:v:R:", opts);
-	if (c == EOF)
-	{
-	    break;
-	}
-	switch (c)
-	{
-	    case 's':		    /* server name */
-	    {
-		if ((opts->optarg == 0) || strlen (opts->optarg) == 0
-		    || *opts->optarg == '-')
-		{
-		    DT_Mdep_printf ("must specify server name\n");
-		    DT_Transaction_Cmd_Usage ();
-		    return (false);
+	int c;
+	unsigned int len;
+	int i;
+	char op[100];
+	for (;;) {
+		c = DT_mygetopt_r(my_argc, my_argv, "rQVPdw:s:D:i:t:v:R:",
+				  opts);
+		if (c == EOF) {
+			break;
 		}
-		strcpy (cmd->server_name, opts->optarg);
-		break;
-	    }
-	    case 'D':		    /* device name */
-	    {
-		strcpy (cmd->dapl_name, opts->optarg);
-		break;
-	    }
+		switch (c) {
+		case 's':	/* server name */
+			{
+				if ((opts->optarg == 0)
+				    || strlen(opts->optarg) == 0
+				    || *opts->optarg == '-') {
+					DT_Mdep_printf
+					    ("must specify server name\n");
+					DT_Transaction_Cmd_Usage();
+					return (false);
+				}
+				strcpy(cmd->server_name, opts->optarg);
+				break;
+			}
+		case 'D':	/* device name */
+			{
+				strcpy(cmd->dapl_name, opts->optarg);
+				break;
+			}
 
-	    case 'i':		    /* num iterations */
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -i<iterations> option\n");
-		    DT_Transaction_Cmd_Usage ();
-		    return (false);
-		}
-		cmd->num_iterations = atol (opts->optarg);
+		case 'i':	/* num iterations */
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -i<iterations> option\n");
+					DT_Transaction_Cmd_Usage();
+					return (false);
+				}
+				cmd->num_iterations = atol(opts->optarg);
 
-		break;
-	    }
-	    case 't':		    /* num threads */
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -t<num threads> option\n");
-		    DT_Transaction_Cmd_Usage ();
-		    return (false);
+				break;
+			}
+		case 't':	/* num threads */
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -t<num threads> option\n");
+					DT_Transaction_Cmd_Usage();
+					return (false);
+				}
+				cmd->num_threads = atol(opts->optarg);
+				break;
+			}
+		case 'w':	/* num EPs per thread */
+			{
+				len = strspn(opts->optarg, "0123456789");
+				if (len == 0 || len != strlen(opts->optarg)) {
+					DT_Mdep_printf
+					    ("Syntax Error -w<EPs/thread> option\n");
+					DT_Transaction_Cmd_Usage();
+					return (false);
+				}
+				cmd->eps_per_thread = atol(opts->optarg);
+				break;
+			}
+		case 'd':	/* print debug messages */
+			{
+				DT_dapltest_debug++;
+				cmd->debug = true;
+				break;
+			}
+		case 'r':	/* use RSP instead of PSP */
+			{
+				cmd->use_rsp = true;
+				break;
+			}
+		case 'V':	/* validate data being sent/received */
+			{
+				cmd->validate = true;
+				break;
+			}
+		case 'P':	/* use completion polling */
+			{
+				cmd->poll = true;
+				break;
+			}
+		case 'R':	/* Service Reliability Level */
+			{
+				cmd->ReliabilityLevel =
+				    DT_ParseQoS(opts->optarg);
+				break;
+			}
+		case '?':
+		default:
+			{
+				DT_Mdep_printf
+				    ("Invalid Transaction Test Parameter: %c\n",
+				     c);
+				DT_Transaction_Cmd_Usage();
+				return (false);
+			}
 		}
-		cmd->num_threads = atol (opts->optarg);
-		break;
-	    }
-	    case 'w':		    /* num EPs per thread */
-	    {
-		len = strspn (opts->optarg, "0123456789");
-		if (len == 0 || len != strlen (opts->optarg))
-		{
-		    DT_Mdep_printf ("Syntax Error -w<EPs/thread> option\n");
-		    DT_Transaction_Cmd_Usage ();
-		    return (false);
+	}
+	if (cmd->dapl_name[0] == '\0') {
+		if (!DT_Mdep_GetDefaultDeviceName(cmd->dapl_name)) {
+			DT_Mdep_printf("can't get default device name\n");
+			DT_Transaction_Cmd_Usage();
+			return (false);
 		}
-		cmd->eps_per_thread = atol (opts->optarg);
-		break;
-	    }
-	    case 'd':		    /* print debug messages */
-	    {
-		DT_dapltest_debug++;
-		cmd->debug = true;
-		break;
-	    }
-	    case 'r':		    /* use RSP instead of PSP */
-	    {
-		cmd->use_rsp = true;
-		break;
-	    }
-	    case 'V':		    /* validate data being sent/received */
-	    {
-		cmd->validate = true;
-		break;
-	    }
-	    case 'P':		    /* use completion polling */
-	    {
-		cmd->poll = true;
-		break;
-	    }
-	    case 'R':		    /* Service Reliability Level */
-	    {
-		cmd->ReliabilityLevel = DT_ParseQoS (opts->optarg);
-		break;
-	    }
-	    case '?':
-	    default:
-	    {
-		DT_Mdep_printf ("Invalid Transaction Test Parameter: %c\n", c);
-		DT_Transaction_Cmd_Usage ();
-		return (false);
-	    }
 	}
-    }
-    if (cmd->dapl_name[0] == '\0')
-    {
-	if (!DT_Mdep_GetDefaultDeviceName (cmd->dapl_name))
-	{
-	    DT_Mdep_printf ("can't get default device name\n");
-	    DT_Transaction_Cmd_Usage ();
-	    return (false);
+	/*
+	 * now parse the transaction ops this is ugly, but it's easier to gather
+	 * each transaction into a single string
+	 */
+	for (i = opts->optind; i < my_argc; i++) {
+		strcpy(&op[0], my_argv[i]);
+		while (i < my_argc - 1) {
+			i++;
+			if ((strncmp(my_argv[i], "client", 6) == 0) ||
+			    strncmp(my_argv[i], "server", 6) == 0) {
+				i--;
+				break;
+			}
+			strcat(op, " ");
+			strcat(op, my_argv[i]);
+		}
+		if (!DT_Transaction_Cmd_Parse_Op(cmd, op)) {
+			DT_Transaction_Cmd_Usage();
+			return (false);
+		}
 	}
-    }
-    /*
-     * now parse the transaction ops this is ugly, but it's easier to gather
-     * each transaction into a single string
-     */
-    for (i = opts->optind; i < my_argc; i++)
-    {
-	strcpy (&op[0], my_argv[i]);
-	while (i < my_argc - 1)
-	{
-	    i++;
-	    if ((strncmp (my_argv[i], "client", 6) == 0) ||
-		strncmp (my_argv[i], "server", 6) == 0)
-	    {
-		i--;
-		break;
-	    }
-	    strcat (op, " ");
-	    strcat (op, my_argv[i]);
-	}
-	if (!DT_Transaction_Cmd_Parse_Op (cmd, op))
-	{
-	    DT_Transaction_Cmd_Usage ();
-	    return (false);
-	}
-    }
 
-    /*
-     * If we're going to validate the data, we append 3 OPs that
-     * serve as barriers so that both the client and server can
-     * validate their entire set of recv transactions without
-     * interference.
-     *
-     * The first op appended serves to notify the client that the
-     * server is at the rendezvous and will transfer nothing else,
-     * so the client can validate all recv buffers.  The second op
-     * notifies the server that the client is quiescent, so the
-     * server can safely validate its recv buffers.  The final op
-     * tells the client that the server is done, and both can
-     * proceed with the next iteration.
-     */
-    if (cmd->validate)
-    {
-	DT_Mdep_printf ("NOTE: Adding OP \"server SR\" - for validation\n");
-	memcpy (op, "server SR", strlen ("server SR") + 1);
-	DT_Transaction_Cmd_Parse_Op (cmd, op);
+	/*
+	 * If we're going to validate the data, we append 3 OPs that
+	 * serve as barriers so that both the client and server can
+	 * validate their entire set of recv transactions without
+	 * interference.
+	 *
+	 * The first op appended serves to notify the client that the
+	 * server is at the rendezvous and will transfer nothing else,
+	 * so the client can validate all recv buffers.  The second op
+	 * notifies the server that the client is quiescent, so the
+	 * server can safely validate its recv buffers.  The final op
+	 * tells the client that the server is done, and both can
+	 * proceed with the next iteration.
+	 */
+	if (cmd->validate) {
+		DT_Mdep_printf
+		    ("NOTE: Adding OP \"server SR\" - for validation\n");
+		memcpy(op, "server SR", strlen("server SR") + 1);
+		DT_Transaction_Cmd_Parse_Op(cmd, op);
 
-	DT_Mdep_printf ("NOTE: Adding OP \"client SR\" - for validation\n");
-	memcpy (op, "client SR", strlen ("client SR") + 1);
-	DT_Transaction_Cmd_Parse_Op (cmd, op);
+		DT_Mdep_printf
+		    ("NOTE: Adding OP \"client SR\" - for validation\n");
+		memcpy(op, "client SR", strlen("client SR") + 1);
+		DT_Transaction_Cmd_Parse_Op(cmd, op);
 
-	DT_Mdep_printf ("NOTE: Adding OP \"server SR\" - for validation\n");
-	memcpy (op, "server SR", strlen ("server SR") + 1);
-	DT_Transaction_Cmd_Parse_Op (cmd, op);
-    }
-    if (!DT_Transaction_Cmd_Validate (cmd))
-    {
-	DT_Transaction_Cmd_Usage ();
-	return (false);
-    }
-    return (true);
+		DT_Mdep_printf
+		    ("NOTE: Adding OP \"server SR\" - for validation\n");
+		memcpy(op, "server SR", strlen("server SR") + 1);
+		DT_Transaction_Cmd_Parse_Op(cmd, op);
+	}
+	if (!DT_Transaction_Cmd_Validate(cmd)) {
+		DT_Transaction_Cmd_Usage();
+		return (false);
+	}
+	return (true);
 }
 
-void
-DT_Transaction_Cmd_Print (Transaction_Cmd_t * cmd)
+void DT_Transaction_Cmd_Print(Transaction_Cmd_t * cmd)
 {
-    unsigned int    i;
-    DT_Mdep_printf ("-------------------------------------\n");
-    DT_Mdep_printf ("TransCmd.server_name              : %s\n",
-		cmd->server_name);
-    DT_Mdep_printf ("TransCmd.num_iterations           : %d\n",
-		cmd->num_iterations);
-    DT_Mdep_printf ("TransCmd.num_threads              : %d\n",
-		cmd->num_threads);
-    DT_Mdep_printf ("TransCmd.eps_per_thread           : %d\n",
-		cmd->eps_per_thread);
-    DT_Mdep_printf ("TransCmd.validate                 : %d\n",
-		cmd->validate);
-    DT_Mdep_printf ("TransCmd.dapl_name                : %s\n",
-		cmd->dapl_name);
-    DT_Mdep_printf ("TransCmd.num_ops                  : %d\n",
-		cmd->num_ops);
+	unsigned int i;
+	DT_Mdep_printf("-------------------------------------\n");
+	DT_Mdep_printf("TransCmd.server_name              : %s\n",
+		       cmd->server_name);
+	DT_Mdep_printf("TransCmd.num_iterations           : %d\n",
+		       cmd->num_iterations);
+	DT_Mdep_printf("TransCmd.num_threads              : %d\n",
+		       cmd->num_threads);
+	DT_Mdep_printf("TransCmd.eps_per_thread           : %d\n",
+		       cmd->eps_per_thread);
+	DT_Mdep_printf("TransCmd.validate                 : %d\n",
+		       cmd->validate);
+	DT_Mdep_printf("TransCmd.dapl_name                : %s\n",
+		       cmd->dapl_name);
+	DT_Mdep_printf("TransCmd.num_ops                  : %d\n",
+		       cmd->num_ops);
 
-    for (i = 0; i < cmd->num_ops; i++)
-    {
-	DT_Mdep_printf ("TransCmd.op[%d].transfer_type      : %s %s\n",
-		    i,
-		    cmd->op[i].transfer_type == 0 ? "RDMA_READ" :
-		    cmd->op[i].transfer_type == 1 ? "RDMA_WRITE" :
-		    "SEND_RECV",
-		    cmd->op[i].server_initiated ? " (server)" : " (client)" );
-	DT_Mdep_printf ("TransCmd.op[%d].seg_size           : %d\n",
-		    i,
-		    cmd->op[i].seg_size);
-	DT_Mdep_printf ("TransCmd.op[%d].num_segs           : %d\n",
-		    i,
-		    cmd->op[i].num_segs);
-	DT_Mdep_printf ("TransCmd.op[%d].reap_send_on_recv  : %d\n",
-		    i,
-		    cmd->op[i].reap_send_on_recv);
-    }
+	for (i = 0; i < cmd->num_ops; i++) {
+		DT_Mdep_printf("TransCmd.op[%d].transfer_type      : %s %s\n",
+			       i,
+			       cmd->op[i].transfer_type == 0 ? "RDMA_READ" :
+			       cmd->op[i].transfer_type == 1 ? "RDMA_WRITE" :
+			       "SEND_RECV",
+			       cmd->op[i].
+			       server_initiated ? " (server)" : " (client)");
+		DT_Mdep_printf("TransCmd.op[%d].seg_size           : %d\n", i,
+			       cmd->op[i].seg_size);
+		DT_Mdep_printf("TransCmd.op[%d].num_segs           : %d\n", i,
+			       cmd->op[i].num_segs);
+		DT_Mdep_printf("TransCmd.op[%d].reap_send_on_recv  : %d\n", i,
+			       cmd->op[i].reap_send_on_recv);
+	}
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_endian.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_endian.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_endian.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,12 +30,11 @@
 
 #include "dapl_proto.h"
 
-void
-DT_Endian_Init (void)
+void DT_Endian_Init(void)
 {
-    int             endian;
-    endian = 1;
-    DT_local_is_little_endian = * ((unsigned char *) (&endian)) == 1;
+	int endian;
+	endian = 1;
+	DT_local_is_little_endian = *((unsigned char *)(&endian)) == 1;
 }
 
 /*
@@ -55,50 +54,45 @@
 #define c3a64 ((DAT_UINT64)0xFFFFFFFF)
 #define c3b64 (c3a64 << 32)
 
-DAT_UINT32
-DT_Endian32 (DAT_UINT32 val)
+DAT_UINT32 DT_Endian32(DAT_UINT32 val)
 {
-    if (DT_local_is_little_endian)
-    {
-	return val;
-    }
-    val = ((val & c1a32) << 8) | ((val & c1b32) >> 8);
-    val = ((val & c2a32) << 16) | ((val & c2b32) >> 16);
-    return (val);
+	if (DT_local_is_little_endian) {
+		return val;
+	}
+	val = ((val & c1a32) << 8) | ((val & c1b32) >> 8);
+	val = ((val & c2a32) << 16) | ((val & c2b32) >> 16);
+	return (val);
 }
 
-DAT_UINT64
-DT_Endian64 (DAT_UINT64 val)
+DAT_UINT64 DT_Endian64(DAT_UINT64 val)
 {
-    if (DT_local_is_little_endian)
-    {
-	return val;
-    }
-    val = ((val & c1a64) << 8) | ((val & c1b64) >> 8);
-    val = ((val & c2a64) << 16) | ((val & c2b64) >> 16);
-    val = ((val & c3a64) << 32) | ((val & c3b64) >> 32);
-    return (val);
+	if (DT_local_is_little_endian) {
+		return val;
+	}
+	val = ((val & c1a64) << 8) | ((val & c1b64) >> 8);
+	val = ((val & c2a64) << 16) | ((val & c2b64) >> 16);
+	val = ((val & c3a64) << 32) | ((val & c3b64) >> 32);
+	return (val);
 }
 
-DAT_UINT32
-DT_EndianMemHandle (DAT_UINT32 val)
+DAT_UINT32 DT_EndianMemHandle(DAT_UINT32 val)
 {
-    if (DT_local_is_little_endian)
-	return val;
-    val = ((val & c1a32) << 8) | ((val & c1b32) >> 8);
-    val = ((val & c2a32) << 16) | ((val & c2b32) >> 16);
-    return (val);
+	if (DT_local_is_little_endian)
+		return val;
+	val = ((val & c1a32) << 8) | ((val & c1b32) >> 8);
+	val = ((val & c2a32) << 16) | ((val & c2b32) >> 16);
+	return (val);
 }
 
-DAT_UINT64
-DT_EndianMemAddress (DAT_UINT64 val)
+DAT_UINT64 DT_EndianMemAddress(DAT_UINT64 val)
 {
-    DAT_UINT64      val64;
-    if (DT_local_is_little_endian)
-	return val;
-    val64 = val;
-    val64 = ((val64 & c1a64) << 8) | ((val64 & c1b64) >> 8);
-    val64 = ((val64 & c2a64) << 16) | ((val64 & c2b64) >> 16);
-    val64 = ((val64 & c3a64) << 32) | ((val64 & c3b64) >> 32);
-    return val64;
+	DAT_UINT64 val64;
+
+	if (DT_local_is_little_endian)
+		return val;
+	val64 = val;
+	val64 = ((val64 & c1a64) << 8) | ((val64 & c1b64) >> 8);
+	val64 = ((val64 & c2a64) << 16) | ((val64 & c2b64) >> 16);
+	val64 = ((val64 & c3a64) << 32) | ((val64 & c3b64) >> 32);
+	return val64;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_global.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_global.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_global.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,7 +30,5 @@
 
 #include "dapl_proto.h"
 
-bool            DT_local_is_little_endian;
-DAT_COUNT       DT_dapltest_debug = 0;
-
-
+bool DT_local_is_little_endian;
+DAT_COUNT DT_dapltest_debug = 0;

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_performance_cmd_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_performance_cmd_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_performance_cmd_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,35 +30,28 @@
 
 #include "dapl_proto.h"
 
-void
-DT_Performance_Cmd_Endian (Performance_Cmd_t * cmd)
+void DT_Performance_Cmd_Endian(Performance_Cmd_t * cmd)
 {
-    cmd->dapltest_version = DT_Endian32 (cmd->dapltest_version);
-    cmd->qos = DT_Endian32 (cmd->qos);
-    cmd->num_iterations = DT_Endian32 (cmd->num_iterations);
-    cmd->debug = DT_Endian32 (cmd->debug);
+	cmd->dapltest_version = DT_Endian32(cmd->dapltest_version);
+	cmd->qos = DT_Endian32(cmd->qos);
+	cmd->num_iterations = DT_Endian32(cmd->num_iterations);
+	cmd->debug = DT_Endian32(cmd->debug);
 
-    cmd->op.transfer_type = DT_Endian32 (cmd->op.transfer_type);
-    cmd->op.seg_size = DT_Endian32 (cmd->op.seg_size);
-    cmd->op.num_segs = DT_Endian32 (cmd->op.num_segs);
+	cmd->op.transfer_type = DT_Endian32(cmd->op.transfer_type);
+	cmd->op.seg_size = DT_Endian32(cmd->op.seg_size);
+	cmd->op.num_segs = DT_Endian32(cmd->op.num_segs);
 }
+
 /*
  *  * Map Performance_Mode_Type values to readable strings
  *   */
-const char *
-DT_PerformanceModeToString (Performance_Mode_Type mode)
+const char *DT_PerformanceModeToString(Performance_Mode_Type mode)
 {
-    if ( BLOCKING_MODE == mode )
-    {
-        return "blocking";
-    }
-    else if ( POLLING_MODE == mode )
-    {
-        return "polling";
-    }
-    else
-    {
-	return "error: unkown mode";
-    }
+	if (BLOCKING_MODE == mode) {
+		return "blocking";
+	} else if (POLLING_MODE == mode) {
+		return "polling";
+	} else {
+		return "error: unkown mode";
+	}
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_quit_cmd_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_quit_cmd_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_quit_cmd_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,10 +31,7 @@
 #include "dapl_proto.h"
 
 /*--------------------------------------------------------- */
-void
-DT_Quit_Cmd_Endian (Quit_Cmd_t * cmd,
-		bool to_wire)
+void DT_Quit_Cmd_Endian(Quit_Cmd_t * cmd, bool to_wire)
 {
-    /* do nothing */
+	/* do nothing */
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_transaction_cmd_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_transaction_cmd_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/common/dapl_transaction_cmd_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,36 +30,33 @@
 
 #include "dapl_proto.h"
 
-
-void
-DT_Transaction_Cmd_Endian (Transaction_Cmd_t * cmd, bool to_wire)
+void DT_Transaction_Cmd_Endian(Transaction_Cmd_t * cmd, bool to_wire)
 {
-    unsigned int    i;
+	unsigned int i;
 
-    cmd->dapltest_version = DT_Endian32 (cmd->dapltest_version);
-    cmd->num_iterations = DT_Endian32 (cmd->num_iterations);
-    cmd->num_threads = DT_Endian32 (cmd->num_threads);
-    cmd->eps_per_thread = DT_Endian32 (cmd->eps_per_thread);
-    cmd->use_rsp = DT_Endian32 (cmd->use_rsp);
-    cmd->debug = DT_Endian32 (cmd->debug);
-    cmd->validate = DT_Endian32 (cmd->validate);
-    cmd->ReliabilityLevel = DT_Endian32 (cmd->ReliabilityLevel);
+	cmd->dapltest_version = DT_Endian32(cmd->dapltest_version);
+	cmd->num_iterations = DT_Endian32(cmd->num_iterations);
+	cmd->num_threads = DT_Endian32(cmd->num_threads);
+	cmd->eps_per_thread = DT_Endian32(cmd->eps_per_thread);
+	cmd->use_rsp = DT_Endian32(cmd->use_rsp);
+	cmd->debug = DT_Endian32(cmd->debug);
+	cmd->validate = DT_Endian32(cmd->validate);
+	cmd->ReliabilityLevel = DT_Endian32(cmd->ReliabilityLevel);
 
-    if (!to_wire)
-    {
-	cmd->num_ops = DT_Endian32 (cmd->num_ops);
-    }
-    for (i = 0; i < cmd->num_ops; i++)
-    {
-	cmd->op[i].server_initiated = DT_Endian32 (cmd->op[i].server_initiated);
-	cmd->op[i].transfer_type = DT_Endian32 (cmd->op[i].transfer_type);
-	cmd->op[i].num_segs = DT_Endian32 (cmd->op[i].num_segs);
-	cmd->op[i].seg_size = DT_Endian32 (cmd->op[i].seg_size);
-	cmd->op[i].reap_send_on_recv =
-				DT_Endian32 (cmd->op[i].reap_send_on_recv);
-    }
-    if (to_wire)
-    {
-	cmd->num_ops = DT_Endian32 (cmd->num_ops);
-    }
+	if (!to_wire) {
+		cmd->num_ops = DT_Endian32(cmd->num_ops);
+	}
+	for (i = 0; i < cmd->num_ops; i++) {
+		cmd->op[i].server_initiated =
+		    DT_Endian32(cmd->op[i].server_initiated);
+		cmd->op[i].transfer_type =
+		    DT_Endian32(cmd->op[i].transfer_type);
+		cmd->op[i].num_segs = DT_Endian32(cmd->op[i].num_segs);
+		cmd->op[i].seg_size = DT_Endian32(cmd->op[i].seg_size);
+		cmd->op[i].reap_send_on_recv =
+		    DT_Endian32(cmd->op[i].reap_send_on_recv);
+	}
+	if (to_wire) {
+		cmd->num_ops = DT_Endian32(cmd->num_ops);
+	}
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_execute.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_execute.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_execute.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,7 +34,7 @@
 #include "dapl_proto.h"
 #include "dapl_params.h"
 
-void
+DAT_RETURN
 DT_Execute_Test ( Params_t *params_ptr ) ;
 
 #endif

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_proto.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_proto.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_proto.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -67,6 +67,8 @@
 #include "dapl_transaction_stats.h"
 #include "dapl_version.h"
 
+#define DAT_ERROR(Type,SubType) ((DAT_RETURN)(DAT_CLASS_ERROR | Type | SubType))
+
 /*
  * Prototypes
  */
@@ -101,7 +103,7 @@
 				 	 DAT_EP_HANDLE ep_handle);
 
 /* dapl_client.c */
-void            DT_cs_Client (Params_t * params_ptr,
+DAT_RETURN      DT_cs_Client (Params_t * params_ptr,
 			      char *dapl_name,
 			      char *server_name,
 			      DAT_UINT32 total_threads);
@@ -237,7 +239,7 @@
 void            DT_Performance_Cmd_Endian (Performance_Cmd_t * cmd);
 
 /* dapl_performance_client.c */
-void            DT_Performance_Test_Client (   Params_t	*params_ptr,
+DAT_RETURN      DT_Performance_Test_Client ( Params_t	*params_ptr,
 					       Per_Test_Data_t * pt_ptr,
 					       DAT_IA_HANDLE * ia_handle,
 					       DAT_IA_ADDRESS_PTR remote);
@@ -249,7 +251,7 @@
 bool            DT_Performance_Test_Client_Exchange (
 	Params_t	   *params_ptr,
 	DT_Tdep_Print_Head *phead,
-	Performance_Test_t *test_ptr);
+					Performance_Test_t *test_ptr );
 
 /* dapl_performance_server.c */
 void            DT_Performance_Test_Server (void * pt_ptr);
@@ -467,7 +469,7 @@
 void            DT_Transaction_Cmd_Endian (Transaction_Cmd_t * cmd,
 					   bool to_wire);
 /* dapl_transaction_test.c */
-void            DT_Transaction_Test_Client (Per_Test_Data_t * pt_ptr,
+DAT_RETURN      DT_Transaction_Test_Client (Per_Test_Data_t * pt_ptr,
 					    DAT_IA_HANDLE ia_handle,
 					    DAT_IA_ADDRESS_PTR remote);
 
@@ -502,15 +504,12 @@
 
 bool            DT_handle_send_op (DT_Tdep_Print_Head* phead, 
 					Ep_Context_t * ep_context,
-					DAT_EVD_HANDLE reqt_evd_hdl,
 					unsigned int num_eps,
 					int op_indx,
 					bool poll);
 
 bool            DT_handle_recv_op (DT_Tdep_Print_Head* phead, 
 					Ep_Context_t * ep_context,
-					DAT_EVD_HANDLE recv_evd_hdl,
-					DAT_EVD_HANDLE reqt_evd_hdl,
 					unsigned int num_eps,
 					int op_indx,
 					bool poll,
@@ -518,7 +517,6 @@
 
 bool            DT_handle_rdma_op (DT_Tdep_Print_Head* phead, 
 					Ep_Context_t * ep_context,
-					DAT_EVD_HANDLE reqt_evd_hdl,
 					unsigned int num_eps,
 					DT_Transfer_Type opcode,
 					int op_indx,
@@ -557,7 +555,7 @@
 void	    DT_Limit_Cmd_Usage (void);
 
 /* dapl_limit.c */
-void        DT_cs_Limit (Params_t *params, Limit_Cmd_t * cmd);
+DAT_RETURN  DT_cs_Limit (Params_t *params, Limit_Cmd_t * cmd);
 
 /* dapl_fft_cmd.c */
 void	    DT_FFT_Cmd_Init ( FFT_Cmd_t * cmd);
@@ -570,7 +568,7 @@
 void	    DT_FFT_Cmd_Usage (void);
 
 /* dapl_fft_test.c */
-void	    DT_cs_FFT (Params_t *params, FFT_Cmd_t * cmd);
+DAT_RETURN  DT_cs_FFT (Params_t *params, FFT_Cmd_t * cmd);
 
 /* dapl_fft_hwconn.c */
 void	    DT_hwconn_test (Params_t *params_ptr, FFT_Cmd_t *cmd);

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_tdep.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_tdep.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_tdep.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -44,7 +44,7 @@
 void
 DT_Tdep_End ( void ) ;
 
-void
+DAT_RETURN
 DT_Tdep_Execute_Test ( Params_t *params_ptr ) ;
 
 DAT_RETURN

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_transaction_test.h
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_transaction_test.h	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/include/dapl_transaction_test.h	2009-05-28 20:23:18 UTC (rev 260)
@@ -59,6 +59,10 @@
     Transaction_Test_Op_t   op[ MAX_OPS ];
     DAT_RSP_HANDLE          rsp_handle;
     DAT_PSP_HANDLE          psp_handle;
+    DAT_EVD_HANDLE          recv_evd_hdl;   /* receive	    */
+    DAT_EVD_HANDLE          reqt_evd_hdl;   /* request+rmr  */
+    DAT_EVD_HANDLE          conn_evd_hdl;   /* connect	    */
+    DAT_EVD_HANDLE          creq_evd_hdl;   /* "" request   */
 
 } Ep_Context_t;
 
@@ -88,10 +92,6 @@
 
     /* This group set up by each thread in DT_Transaction_Main() */
     DAT_PZ_HANDLE           pz_handle;
-    DAT_EVD_HANDLE          recv_evd_hdl;   /* receive	    */
-    DAT_EVD_HANDLE          reqt_evd_hdl;   /* request+rmr  */
-    DAT_EVD_HANDLE          conn_evd_hdl;   /* connect	    */
-    DAT_EVD_HANDLE          creq_evd_hdl;   /* "" request   */
     Ep_Context_t            *ep_context;
 
     /* Statistics set by DT_Transaction_Run() */

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/mdep/linux/dapl_mdep_user.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/mdep/linux/dapl_mdep_user.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/mdep/linux/dapl_mdep_user.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,10 +31,10 @@
 #include "dapl_mdep.h"
 #include "dapl_proto.h"
 
-#include <pthread.h>			/* needed for pthread_atfork() */
+#include <pthread.h>		/* needed for pthread_atfork() */
 #include <sys/time.h>
-#include <stdlib.h>			/* needed for getenv() */
-#include <signal.h>			/* needed for thread setup */
+#include <stdlib.h>		/* needed for getenv() */
+#include <signal.h>		/* needed for thread setup */
 
 #include <assert.h>
 #include <errno.h>
@@ -43,10 +43,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdarg.h>			/* for printf */
+#include <stdarg.h>		/* for printf */
 #include <sys/time.h>
 #include <syslog.h>
-#include <netdb.h>			/* for getaddrinfo */
+#include <netdb.h>		/* for getaddrinfo */
 
 /*
  * Include files for setting up a network name
@@ -61,130 +61,115 @@
 
 #include "dapl_test_data.h"	/* for alloc_count */
 
-
 /*
  * Machine dependant initialization
  */
 
-void
-DT_Mdep_Init (void)
+void DT_Mdep_Init(void)
 {
-    Stat_Fp = fopen (DT_STAT_FILE, "r");
-    if ( NULL == Stat_Fp )
-    {
-	perror ("fopen of " DT_STAT_FILE " failed");
-	exit (1);
-    }
+	Stat_Fp = fopen(DT_STAT_FILE, "r");
+	if (NULL == Stat_Fp) {
+		perror("fopen of " DT_STAT_FILE " failed");
+		exit(1);
+	}
 }
 
 /*
  * Machine dependant deinitialization
  */
 
-void
-DT_Mdep_End (void)
+void DT_Mdep_End(void)
 {
-    if ( 0 != fclose (Stat_Fp) )
-    {
-	perror ("fclose of " DT_STAT_FILE " failed");
-	exit (1);
-    }
+	if (0 != fclose(Stat_Fp)) {
+		perror("fclose of " DT_STAT_FILE " failed");
+		exit(1);
+	}
 }
 
 /*
  * Generate name of IB device
  */
 
-bool
-DT_Mdep_GetDefaultDeviceName (char *dapl_name)
+bool DT_Mdep_GetDefaultDeviceName(char *dapl_name)
 {
-    strcpy (dapl_name, DT_MdepDeviceName);
-    return true;
+	strcpy(dapl_name, DT_MdepDeviceName);
+	return true;
 }
 
 /*
  * Sleep specified number of milliseconds
  */
 
-void
-DT_Mdep_Sleep (int msec)
+void DT_Mdep_Sleep(int msec)
 {
-    struct timespec t;
-    t.tv_sec = msec / 1000;	/* Whole seconds */
-    t.tv_nsec = (msec % 1000) * 1000 * 1000;
-    nanosleep (&t, 0);
+	struct timespec t;
+	t.tv_sec = msec / 1000;	/* Whole seconds */
+	t.tv_nsec = (msec % 1000) * 1000 * 1000;
+	nanosleep(&t, 0);
 }
 
-void
-DT_Mdep_Schedule (void)
+void DT_Mdep_Schedule(void)
 {
-    /* nothing here */
+	/* nothing here */
 }
+
 /*
  * Get system statistics including uptime and idle time
  */
 
-bool
-DT_Mdep_GetCpuStat (
-    DT_CpuStat 			*cpu_stat )
+bool DT_Mdep_GetCpuStat(DT_CpuStat * cpu_stat)
 {
 
 #define DT_CPU_STAT_STR		"cpu"
 #define DT_CPU_STAT_BUFFER_SIZE	1024
 #define DT_CPU_STAT_DELIMITER	" "
 
-    static char buffer[DT_CPU_STAT_BUFFER_SIZE];
+	static char buffer[DT_CPU_STAT_BUFFER_SIZE];
 
-    cpu_stat->user = 0;
-    cpu_stat->system = 0;
-    cpu_stat->idle = 0;
-		    
-    if ( 0 != fflush (Stat_Fp) )
-    {
-	perror ("fflush of " DT_STAT_FILE " failed");
-	exit (1);
-    }
+	cpu_stat->user = 0;
+	cpu_stat->system = 0;
+	cpu_stat->idle = 0;
 
-    for (;;)
-    {
-	if ( NULL == fgets (buffer, DT_CPU_STAT_BUFFER_SIZE, Stat_Fp) )
-	{
-	    printf (DT_CPU_STAT_STR " not found\n");
-	    exit (1);
+	if (0 != fflush(Stat_Fp)) {
+		perror("fflush of " DT_STAT_FILE " failed");
+		exit(1);
 	}
 
-	if ( !strncmp (buffer, DT_CPU_STAT_STR, strlen (DT_CPU_STAT_STR) ) )
-	{
-	    break;
+	for (;;) {
+		if (NULL == fgets(buffer, DT_CPU_STAT_BUFFER_SIZE, Stat_Fp)) {
+			printf(DT_CPU_STAT_STR " not found\n");
+			exit(1);
+		}
+
+		if (!strncmp(buffer, DT_CPU_STAT_STR, strlen(DT_CPU_STAT_STR))) {
+			break;
+		}
 	}
-    }
 
-    (void) strtok (buffer, DT_CPU_STAT_DELIMITER);
-    cpu_stat->user   = strtoul (strtok (NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
-    cpu_stat->user  += strtoul (strtok (NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
-    cpu_stat->system = strtoul (strtok (NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
-    cpu_stat->idle   = strtoul (strtok (NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
+	(void)strtok(buffer, DT_CPU_STAT_DELIMITER);
+	cpu_stat->user = strtoul(strtok(NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
+	cpu_stat->user += strtoul(strtok(NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
+	cpu_stat->system =
+	    strtoul(strtok(NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
+	cpu_stat->idle = strtoul(strtok(NULL, DT_CPU_STAT_DELIMITER), NULL, 0);
 
-    rewind (Stat_Fp);
+	rewind(Stat_Fp);
 
-    return true;
+	return true;
 }
 
 /*
  * Get current time in milliseconds (relative to some fixed point)
  */
-unsigned long
-DT_Mdep_GetTime (void)
+unsigned long DT_Mdep_GetTime(void)
 {
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
 }
 
 #ifdef RDTSC_TIMERS
-double
-DT_Mdep_GetCpuMhz (
-    void )
+double DT_Mdep_GetCpuMhz(void)
 {
 #define DT_TSC_BUFFER_SIZE 	128
 #if defined (__PPC__) || defined (__PPC64__)
@@ -196,124 +181,108 @@
 #endif
 #define DT_TSC_DELIMITER	":"
 
-    FILE *fp;
-    char buffer[DT_TSC_BUFFER_SIZE];
-    char *mhz_str;
+	FILE *fp;
+	char buffer[DT_TSC_BUFFER_SIZE];
+	char *mhz_str;
 
-    fp = fopen ("/proc/cpuinfo", "r");
-    if ( NULL == fp )
-    {
-	perror ("fopen of /proc/cpuinfo failed");
-	exit (1);
-    }
-
-    for (;;)
-    {
-	if ( NULL == fgets (buffer, DT_TSC_BUFFER_SIZE, fp) )
-	{
-	    printf ("cpu MHZ not found\n");
-	    exit (1);
+	fp = fopen("/proc/cpuinfo", "r");
+	if (NULL == fp) {
+		perror("fopen of /proc/cpuinfo failed");
+		exit(1);
 	}
 
-	if ( !strncmp (buffer, DT_TSC_RATE, strlen (DT_TSC_RATE) ) )
-	{
-	    (void) strtok (buffer, DT_TSC_DELIMITER);
-	    mhz_str = strtok (NULL, DT_TSC_DELIMITER);
+	for (;;) {
+		if (NULL == fgets(buffer, DT_TSC_BUFFER_SIZE, fp)) {
+			printf("cpu MHZ not found\n");
+			exit(1);
+		}
 
-	    break;
+		if (!strncmp(buffer, DT_TSC_RATE, strlen(DT_TSC_RATE))) {
+			(void)strtok(buffer, DT_TSC_DELIMITER);
+			mhz_str = strtok(NULL, DT_TSC_DELIMITER);
+
+			break;
+		}
 	}
-    }
 
-    if ( 0 != fclose (fp) )
-    {
-	perror ("fclose of /proc/cpuinfo failed");
-	exit (1);
-    }
+	if (0 != fclose(fp)) {
+		perror("fclose of /proc/cpuinfo failed");
+		exit(1);
+	}
 
-    return strtod (mhz_str, NULL) / DT_TSC_BASE;
+	return strtod(mhz_str, NULL) / DT_TSC_BASE;
 }
-#else /* !RDTSC_TIMERS */
+#else				/* !RDTSC_TIMERS */
 
-double
-DT_Mdep_GetCpuMhz (
-    void )
+double DT_Mdep_GetCpuMhz(void)
 {
-    return 1;
+	return 1;
 }
 #endif
 
-
-unsigned long
-DT_Mdep_GetContextSwitchNum (void )
+unsigned long DT_Mdep_GetContextSwitchNum(void)
 {
 
 #define DT_CTXT_STR		"ctxt"
 #define DT_CTXT_BUFFER_SIZE	1024
 #define DT_CTXT_DELIMITER	" "
 
-    static char buffer[DT_CTXT_BUFFER_SIZE];
-    char *ctxt_str;
+	static char buffer[DT_CTXT_BUFFER_SIZE];
+	char *ctxt_str;
 
-    if ( 0 != fflush (Stat_Fp) )
-    {
-	perror ("fflush of " DT_STAT_FILE " failed");
-	exit (1);
-    }
-
-    for (;;)
-    {
-	if ( NULL == fgets (buffer, DT_CTXT_BUFFER_SIZE, Stat_Fp) )
-	{
-	    printf (DT_CTXT_STR " not found\n");
-	    exit (1);
+	if (0 != fflush(Stat_Fp)) {
+		perror("fflush of " DT_STAT_FILE " failed");
+		exit(1);
 	}
 
-	if ( !strncmp (buffer, DT_CTXT_STR, strlen (DT_CTXT_STR) ) )
-	{
-	    (void) strtok (buffer, DT_CTXT_DELIMITER);
-	    ctxt_str = strtok (NULL, DT_CTXT_DELIMITER);
+	for (;;) {
+		if (NULL == fgets(buffer, DT_CTXT_BUFFER_SIZE, Stat_Fp)) {
+			printf(DT_CTXT_STR " not found\n");
+			exit(1);
+		}
 
-	    break;
+		if (!strncmp(buffer, DT_CTXT_STR, strlen(DT_CTXT_STR))) {
+			(void)strtok(buffer, DT_CTXT_DELIMITER);
+			ctxt_str = strtok(NULL, DT_CTXT_DELIMITER);
+
+			break;
+		}
 	}
-    }
 
-    rewind (Stat_Fp);
+	rewind(Stat_Fp);
 
-    return strtoul (ctxt_str, NULL, 0);
+	return strtoul(ctxt_str, NULL, 0);
 }
 
 /*
  * Memory allocate and free routines for control blocks (objects) - regular
  * memory, always zeroed.
  */
-void           *
-DT_Mdep_Malloc (size_t l_)
+void *DT_Mdep_Malloc(size_t l_)
 {
-    void *rval;
+	void *rval;
 
-    /*
-     * check memory leaking DT_Mdep_Lock(&Alloc_Count_Lock); alloc_count++;
-     * DT_Mdep_Unlock(&Alloc_Count_Lock);
-     */
+	/*
+	 * check memory leaking DT_Mdep_Lock(&Alloc_Count_Lock); alloc_count++;
+	 * DT_Mdep_Unlock(&Alloc_Count_Lock);
+	 */
 
-    rval = malloc (l_);
+	rval = malloc(l_);
 
-    if (rval)
-    {
-	memset (rval, 0, l_);
-    }
-    return ( rval );
+	if (rval) {
+		memset(rval, 0, l_);
+	}
+	return (rval);
 }
 
-void
-DT_Mdep_Free (void *a_)
+void DT_Mdep_Free(void *a_)
 {
-    /*
-     * check memory leaking DT_Mdep_Lock(&Alloc_Count_Lock); alloc_count--;
-     * DT_Mdep_Unlock(&Alloc_Count_Lock);
-     */
+	/*
+	 * check memory leaking DT_Mdep_Lock(&Alloc_Count_Lock); alloc_count--;
+	 * DT_Mdep_Unlock(&Alloc_Count_Lock);
+	 */
 
-    free (a_);
+	free(a_);
 }
 
 /*
@@ -321,85 +290,77 @@
  *
  * Lock object constructor
  */
-bool
-DT_Mdep_LockInit (DT_Mdep_LockType * lock_ptr)
+bool DT_Mdep_LockInit(DT_Mdep_LockType * lock_ptr)
 {
-    return pthread_mutex_init (lock_ptr, 0) ? false : true;
+	return pthread_mutex_init(lock_ptr, 0) ? false : true;
 }
 
 /*
  * Lock object destructor
  */
-void
-DT_Mdep_LockDestroy (DT_Mdep_LockType * lock_ptr)
+void DT_Mdep_LockDestroy(DT_Mdep_LockType * lock_ptr)
 {
-    pthread_mutex_destroy (lock_ptr);
+	pthread_mutex_destroy(lock_ptr);
 }
 
 /*
  * Lock
  */
-void
-DT_Mdep_Lock (DT_Mdep_LockType * lock_ptr)
+void DT_Mdep_Lock(DT_Mdep_LockType * lock_ptr)
 {
-    pthread_mutex_lock (lock_ptr);
+	pthread_mutex_lock(lock_ptr);
 }
 
 /*
  * unlock
  */
-void
-DT_Mdep_Unlock (DT_Mdep_LockType * lock_ptr)
+void DT_Mdep_Unlock(DT_Mdep_LockType * lock_ptr)
 {
-    pthread_mutex_unlock (lock_ptr);
+	pthread_mutex_unlock(lock_ptr);
 }
 
 /*
  * Init Thread Attributes
  */
-void
-DT_Mdep_Thread_Init_Attributes (Thread * thread_ptr)
+void DT_Mdep_Thread_Init_Attributes(Thread * thread_ptr)
 {
-    pthread_attr_init (&thread_ptr->attr);
-    pthread_attr_setstacksize (&thread_ptr->attr, thread_ptr->stacksize);
-    /* Create thread in detached state to free resources on termination;
-     * this precludes doing a pthread_join, but we don't do it
-     */
-    pthread_attr_setdetachstate (&thread_ptr->attr, PTHREAD_CREATE_DETACHED);
+	pthread_attr_init(&thread_ptr->attr);
+	pthread_attr_setstacksize(&thread_ptr->attr, thread_ptr->stacksize);
+	/* Create thread in detached state to free resources on termination;
+	 * this precludes doing a pthread_join, but we don't do it
+	 */
+	pthread_attr_setdetachstate(&thread_ptr->attr, PTHREAD_CREATE_DETACHED);
 }
 
 /*
  * Destroy Thread Attributes
  */
-void
-DT_Mdep_Thread_Destroy_Attributes (Thread * thread_ptr)
+void DT_Mdep_Thread_Destroy_Attributes(Thread * thread_ptr)
 {
-    pthread_attr_destroy (&thread_ptr->attr);
+	pthread_attr_destroy(&thread_ptr->attr);
 }
 
 /*
  * Start the thread
  */
-bool
-DT_Mdep_Thread_Start (Thread * thread_ptr)
+bool DT_Mdep_Thread_Start(Thread * thread_ptr)
 {
-    return pthread_create (&thread_ptr->thread_handle,
-			  &thread_ptr->attr,
-			  DT_Mdep_Thread_Start_Routine,
-			  thread_ptr) == 0;
+	return pthread_create(&thread_ptr->thread_handle,
+			      &thread_ptr->attr,
+			      DT_Mdep_Thread_Start_Routine, thread_ptr) == 0;
 }
 
 /*
  * Thread execution entry point function
  */
 DT_Mdep_Thread_Start_Routine_Return_Type
-DT_Mdep_Thread_Start_Routine (void *thread_handle)
+DT_Mdep_Thread_Start_Routine(void *thread_handle)
 {
-    Thread         *thread_ptr;
-    thread_ptr = (Thread *) thread_handle;
+	Thread *thread_ptr;
+	thread_ptr = (Thread *) thread_handle;
 
-    thread_ptr->function (thread_ptr->param);
-    return 0;
+	thread_ptr->function(thread_ptr->param);
+	return 0;
 }
 
 /*
@@ -407,9 +368,9 @@
  * interface to clean up resources properly at
  * thread's end.
  */
-void DT_Mdep_Thread_Detach ( DT_Mdep_ThreadHandleType thread_id )  /* AMM */
-{
-    pthread_detach (thread_id);
+void DT_Mdep_Thread_Detach(DT_Mdep_ThreadHandleType thread_id)
+{				/* AMM */
+	pthread_detach(thread_id);
 }
 
 /*
@@ -418,19 +379,18 @@
  *  upon themselves.
  */
 
-DT_Mdep_ThreadHandleType DT_Mdep_Thread_SELF (void)	/* AMM */
-{
-    return (pthread_self ());
+DT_Mdep_ThreadHandleType DT_Mdep_Thread_SELF(void)
+{				/* AMM */
+	return (pthread_self());
 }
 
-
 /*
  *  Allow a thread to exit and cleanup resources.
  */
 
-void  DT_Mdep_Thread_EXIT ( void * thread_handle )  /* AMM */
-{
-    pthread_exit ( thread_handle );
+void DT_Mdep_Thread_EXIT(void *thread_handle)
+{				/* AMM */
+	pthread_exit(thread_handle);
 }
 
 /*
@@ -445,23 +405,19 @@
  *	0 if successful
  *	-1 if unsuccessful
  */
-int
-DT_Mdep_wait_object_init (
-	IN DT_WAIT_OBJECT *wait_obj)
+int DT_Mdep_wait_object_init(IN DT_WAIT_OBJECT * wait_obj)
 {
 
-    wait_obj->signaled = DAT_FALSE;
-    if ( 0 != pthread_cond_init ( &wait_obj->cv, NULL ) )
-    {
-	return (-1);
-    }
+	wait_obj->signaled = DAT_FALSE;
+	if (0 != pthread_cond_init(&wait_obj->cv, NULL)) {
+		return (-1);
+	}
 
-    /* Always returns 0.  */
-    pthread_mutex_init ( &wait_obj->lock, NULL );
-    return 0;
+	/* Always returns 0.  */
+	pthread_mutex_init(&wait_obj->lock, NULL);
+	return 0;
 }
 
-
 /* Wait on the supplied wait object, up to the specified time_out.
  * A timeout of DAT_TIMEOUT_INFINITE will wait indefinitely.
  * Timeout should be specified in micro seconds.
@@ -475,88 +431,72 @@
  *	-1 -- the specified time limit was reached.
  */
 
-int
-DT_Mdep_wait_object_wait (
-	IN	DT_WAIT_OBJECT *wait_obj,
-	IN  int timeout_val)
+int DT_Mdep_wait_object_wait(IN DT_WAIT_OBJECT * wait_obj, IN int timeout_val)
 {
-    int 		dat_status;
-    int 		pthread_status;
-    struct timespec 	future;
+	int dat_status;
+	int pthread_status;
+	struct timespec future;
 
-    dat_status = 0;
-    pthread_status = 0;
+	dat_status = 0;
+	pthread_status = 0;
 
-    if ( timeout_val != DAT_TIMEOUT_INFINITE )
-    {
-	struct timeval now;
-	struct timezone tz;
-	unsigned int microsecs;
+	if (timeout_val != DAT_TIMEOUT_INFINITE) {
+		struct timeval now;
+		struct timezone tz;
+		unsigned int microsecs;
 
-	gettimeofday (&now, &tz);
-	microsecs = now.tv_usec + (timeout_val % 1000000);
-	if (microsecs > 1000000)
-	{
-	    now.tv_sec = now.tv_sec + timeout_val / 1000000 + 1;
-	    now.tv_usec = microsecs - 1000000;
-	}
-	else
-	{
-	    now.tv_sec = now.tv_sec + timeout_val / 1000000;
-	    now.tv_usec = microsecs;
-	}
+		gettimeofday(&now, &tz);
+		microsecs = now.tv_usec + (timeout_val % 1000000);
+		if (microsecs > 1000000) {
+			now.tv_sec = now.tv_sec + timeout_val / 1000000 + 1;
+			now.tv_usec = microsecs - 1000000;
+		} else {
+			now.tv_sec = now.tv_sec + timeout_val / 1000000;
+			now.tv_usec = microsecs;
+		}
 
-	/* Convert timeval to timespec */
-	future.tv_sec = now.tv_sec;
-	future.tv_nsec = now.tv_usec * 1000;
+		/* Convert timeval to timespec */
+		future.tv_sec = now.tv_sec;
+		future.tv_nsec = now.tv_usec * 1000;
 
-	pthread_mutex_lock (&wait_obj->lock);
-	while ( wait_obj->signaled == DAT_FALSE && pthread_status == 0)
-	{
-	    pthread_status = pthread_cond_timedwait (
-		    &wait_obj->cv, &wait_obj->lock, &future );
+		pthread_mutex_lock(&wait_obj->lock);
+		while (wait_obj->signaled == DAT_FALSE && pthread_status == 0) {
+			pthread_status =
+			    pthread_cond_timedwait(&wait_obj->cv,
+						   &wait_obj->lock, &future);
 
-	    /*
-		 * No need to reset &future if we go around the loop;
-		 * It's an absolute time.
-		 */
+			/*
+			 * No need to reset &future if we go around the loop;
+			 * It's an absolute time.
+			 */
+		}
+		/* Reset the signaled status if we were woken up.  */
+		if (pthread_status == 0) {
+			wait_obj->signaled = false;
+		}
+		pthread_mutex_unlock(&wait_obj->lock);
+	} else {
+		pthread_mutex_lock(&wait_obj->lock);
+		while (wait_obj->signaled == DAT_FALSE && pthread_status == 0) {
+			pthread_status =
+			    pthread_cond_wait(&wait_obj->cv, &wait_obj->lock);
+		}
+		/* Reset the signaled status if we were woken up.  */
+		if (pthread_status == 0) {
+			wait_obj->signaled = false;
+		}
+		pthread_mutex_unlock(&wait_obj->lock);
 	}
-	/* Reset the signaled status if we were woken up.  */
-	if (pthread_status == 0)
-	{
-	    wait_obj->signaled = false;
+
+	if (ETIMEDOUT == pthread_status) {
+		return (-1);
+	} else if (0 != pthread_status) {
+		return (-1);
 	}
-	pthread_mutex_unlock (&wait_obj->lock);
-    }
-    else
-    {
-	pthread_mutex_lock (&wait_obj->lock);
-	while ( wait_obj->signaled == DAT_FALSE && pthread_status == 0)
-	{
-	    pthread_status = pthread_cond_wait (
-		    &wait_obj->cv, &wait_obj->lock );
-	}
-	/* Reset the signaled status if we were woken up.  */
-	if (pthread_status == 0)
-	{
-	    wait_obj->signaled = false;
-	}
-	pthread_mutex_unlock (&wait_obj->lock);
-    }
 
-    if (ETIMEDOUT == pthread_status)
-    {
-	return (-1);
-    }
-    else if ( 0 != pthread_status)
-    {
-	return (-1);
-    }
-
-    return 0;
+	return 0;
 }
 
-
 /*
  * DT_Mdep_wait_object_wakeup
  *
@@ -569,19 +509,16 @@
  *	0 if successful
  *	-1 if not successful
  */
-int
-DT_Mdep_wait_object_wakeup (
-	DT_WAIT_OBJECT *wait_obj )
+int DT_Mdep_wait_object_wakeup(DT_WAIT_OBJECT * wait_obj)
 {
-    pthread_mutex_lock ( &wait_obj->lock );
-    wait_obj->signaled = true;
-    pthread_mutex_unlock ( &wait_obj->lock );
-    if ( 0 != pthread_cond_signal ( &wait_obj->cv ) )
-    {
-	return (-1);
-    }
+	pthread_mutex_lock(&wait_obj->lock);
+	wait_obj->signaled = true;
+	pthread_mutex_unlock(&wait_obj->lock);
+	if (0 != pthread_cond_signal(&wait_obj->cv)) {
+		return (-1);
+	}
 
-    return 0;
+	return 0;
 }
 
 /*
@@ -596,20 +533,14 @@
  *	0 if successful
  *	-1 if not successful
  */
-int
-DT_Mdep_wait_object_destroy (
-	IN	DT_WAIT_OBJECT *wait_obj)
+int DT_Mdep_wait_object_destroy(IN DT_WAIT_OBJECT * wait_obj)
 {
-    if ( 0 != pthread_cond_destroy ( &wait_obj->cv ) )
-    {
-	return (-1);
-    }
-    if ( 0 != pthread_mutex_destroy ( &wait_obj->lock ) )
-    {
-	return (-1);
-    }
+	if (0 != pthread_cond_destroy(&wait_obj->cv)) {
+		return (-1);
+	}
+	if (0 != pthread_mutex_destroy(&wait_obj->lock)) {
+		return (-1);
+	}
 
-    return 0;
+	return 0;
 }
-
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_bpool.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_bpool.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_bpool.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -42,350 +42,318 @@
  *  use the buffers separately, or as one contiguous segment, so
  *  we allocate IOV entries enough to support either usage.
  */
-Bpool          *
-DT_BpoolAlloc (
-	   Per_Test_Data_t    *pt_ptr,
-	   DT_Tdep_Print_Head *phead,
-	   DAT_IA_HANDLE      ia_handle,
-	   DAT_PZ_HANDLE      pz_handle,
-	   DAT_EP_HANDLE      ep_handle,
-	   DAT_EVD_HANDLE     rmr_evd_handle,
-	   DAT_COUNT          seg_size,
-	   DAT_COUNT          num_segs,
-	   DAT_COUNT          alignment,
-	   DAT_BOOLEAN        enable_rdma_write,
-	   DAT_BOOLEAN        enable_rdma_read)
+Bpool *DT_BpoolAlloc(Per_Test_Data_t * pt_ptr,
+		     DT_Tdep_Print_Head * phead,
+		     DAT_IA_HANDLE ia_handle,
+		     DAT_PZ_HANDLE pz_handle,
+		     DAT_EP_HANDLE ep_handle,
+		     DAT_EVD_HANDLE rmr_evd_handle,
+		     DAT_COUNT seg_size,
+		     DAT_COUNT num_segs,
+		     DAT_COUNT alignment,
+		     DAT_BOOLEAN enable_rdma_write,
+		     DAT_BOOLEAN enable_rdma_read)
 {
-    char                    *module = "DT_BpoolAlloc";
-    unsigned char           *alloc_ptr = 0;
-    Bpool                   *bpool_ptr = 0;
-    DAT_COUNT                alloc_size;
-    DAT_REGION_DESCRIPTION  region;
-    DAT_RETURN              ret;
+	char *module = "DT_BpoolAlloc";
+	unsigned char *alloc_ptr = 0;
+	Bpool *bpool_ptr = 0;
+	DAT_COUNT alloc_size;
+	DAT_REGION_DESCRIPTION region;
+	DAT_RETURN ret;
 
-    /* We'll hand out aligned buffers, compensate here */
-    seg_size = DT_RoundSize (seg_size, alignment);
-    alloc_size = seg_size * num_segs + alignment;
+	/* We'll hand out aligned buffers, compensate here */
+	seg_size = DT_RoundSize(seg_size, alignment);
+	alloc_size = seg_size * num_segs + alignment;
 
-    alloc_ptr = (unsigned char *) DT_MemListAlloc ( pt_ptr, "bpool", BUFF,
-					       alloc_size);
-    if (!alloc_ptr)
-    {
-	DT_Tdep_PT_Printf (phead, "No Memory to create bpool buffer!\n");
-	goto err;
-    }
+	alloc_ptr = (unsigned char *)DT_MemListAlloc(pt_ptr, "bpool", BUFF,
+						     alloc_size);
+	if (!alloc_ptr) {
+		DT_Tdep_PT_Printf(phead, "No Memory to create bpool buffer!\n");
+		goto err;
+	}
 
-    bpool_ptr = (Bpool *) DT_MemListAlloc (pt_ptr, "bpool", BPOOL, sizeof (Bpool)
-					+ num_segs * sizeof (DAT_LMR_TRIPLET));
-    if (!bpool_ptr)
-    {
-	DT_Tdep_PT_Printf (phead,"No Memory to create Bpool!\n");
-	goto err;
-    }
+	bpool_ptr =
+	    (Bpool *) DT_MemListAlloc(pt_ptr, "bpool", BPOOL, sizeof(Bpool)
+				      + num_segs * sizeof(DAT_LMR_TRIPLET));
+	if (!bpool_ptr) {
+		DT_Tdep_PT_Printf(phead, "No Memory to create Bpool!\n");
+		goto err;
+	}
 
-    bpool_ptr->alloc_ptr    = alloc_ptr;
-    bpool_ptr->alloc_size   = alloc_size;
-    bpool_ptr->pz_handle    = pz_handle;
-    bpool_ptr->num_segs     = num_segs;
-    bpool_ptr->ep_handle    = ep_handle;
-    bpool_ptr->buffer_size  = seg_size * num_segs;
-    bpool_ptr->buffer_start = DT_AlignPtr (alloc_ptr, alignment);
-    bpool_ptr->tripl_start  = (DAT_LMR_TRIPLET *) (bpool_ptr + 1);
-    bpool_ptr->seg_size     = seg_size;
-    bpool_ptr->enable_rdma_write = enable_rdma_write;
-    bpool_ptr->enable_rdma_read  = enable_rdma_read;
-    bpool_ptr->rmr_evd_handle    = rmr_evd_handle;
+	bpool_ptr->alloc_ptr = alloc_ptr;
+	bpool_ptr->alloc_size = alloc_size;
+	bpool_ptr->pz_handle = pz_handle;
+	bpool_ptr->num_segs = num_segs;
+	bpool_ptr->ep_handle = ep_handle;
+	bpool_ptr->buffer_size = seg_size * num_segs;
+	bpool_ptr->buffer_start = DT_AlignPtr(alloc_ptr, alignment);
+	bpool_ptr->tripl_start = (DAT_LMR_TRIPLET *) (bpool_ptr + 1);
+	bpool_ptr->seg_size = seg_size;
+	bpool_ptr->enable_rdma_write = enable_rdma_write;
+	bpool_ptr->enable_rdma_read = enable_rdma_read;
+	bpool_ptr->rmr_evd_handle = rmr_evd_handle;
 
-    DT_Tdep_PT_Debug (3,
-		  (phead, 
-		  "lmr_create    [%p, " F64x "]\n",
-		  bpool_ptr->buffer_start,
-		  bpool_ptr->buffer_size));
+	DT_Tdep_PT_Debug(3,
+			 (phead,
+			  "lmr_create    [%p, " F64x "]\n",
+			  bpool_ptr->buffer_start, bpool_ptr->buffer_size));
 
-    memset (&region, 0, sizeof (region));
-    region.for_va = bpool_ptr->buffer_start;
-    ret = DT_Tdep_lmr_create (ia_handle,
-			      DAT_MEM_TYPE_VIRTUAL,
-			      region,
-			      bpool_ptr->buffer_size,
-			      pz_handle,
-			      DAT_MEM_PRIV_ALL_FLAG,
-			      &bpool_ptr->lmr_handle,
-			      &bpool_ptr->lmr_context,
-			      &bpool_ptr->rmr_context,
-			      &bpool_ptr->reg_size,
-			      &bpool_ptr->reg_addr);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "%s: dat_lmr_create failed %s\n",
-		    module, DT_RetToString (ret));
-	goto err;
-    }
-    /* verify that the outputs are reasonable */
-    if (((uintptr_t)bpool_ptr->reg_addr > (uintptr_t)bpool_ptr->buffer_start)
-	|| (bpool_ptr->reg_size < bpool_ptr->buffer_size +
-	((uintptr_t)bpool_ptr->buffer_start - (uintptr_t)bpool_ptr->reg_addr)))
-    {
-	DT_Tdep_PT_Printf (phead, "%s: dat_lmr_create bogus"
-			 "in: 0x%p, " F64x " out 0x" F64x ", " F64x "\n",
-			 module,
-			 bpool_ptr->buffer_start,
-			 bpool_ptr->buffer_size,
-			 bpool_ptr->reg_addr,
-			 bpool_ptr->reg_size);
-	goto err;
-    }
+	memset(&region, 0, sizeof(region));
+	region.for_va = bpool_ptr->buffer_start;
+	ret = DT_Tdep_lmr_create(ia_handle,
+				 DAT_MEM_TYPE_VIRTUAL,
+				 region,
+				 bpool_ptr->buffer_size,
+				 pz_handle,
+				 DAT_MEM_PRIV_ALL_FLAG,
+				 &bpool_ptr->lmr_handle,
+				 &bpool_ptr->lmr_context,
+				 &bpool_ptr->rmr_context,
+				 &bpool_ptr->reg_size, &bpool_ptr->reg_addr);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "%s: dat_lmr_create failed %s\n",
+				  module, DT_RetToString(ret));
+		goto err;
+	}
+	/* verify that the outputs are reasonable */
+	if (((uintptr_t) bpool_ptr->reg_addr >
+	     (uintptr_t) bpool_ptr->buffer_start)
+	    || (bpool_ptr->reg_size <
+		bpool_ptr->buffer_size + ((uintptr_t) bpool_ptr->buffer_start -
+					  (uintptr_t) bpool_ptr->reg_addr))) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_lmr_create bogus" "in: 0x%p, " F64x
+				  " out 0x" F64x ", " F64x "\n", module,
+				  bpool_ptr->buffer_start,
+				  bpool_ptr->buffer_size, bpool_ptr->reg_addr,
+				  bpool_ptr->reg_size);
+		goto err;
+	}
 
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "lmr_create OK [0x" F64x ", " F64x ", lctx=%x]\n",
-		      bpool_ptr->reg_addr, 
-		      bpool_ptr->reg_size, 
-		      bpool_ptr->lmr_context));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "lmr_create OK [0x" F64x ", " F64x ", lctx=%x]\n",
+			     bpool_ptr->reg_addr,
+			     bpool_ptr->reg_size, bpool_ptr->lmr_context));
 
-    /* Enable RDMA if requested */
-    if (enable_memory_windows && (enable_rdma_write || enable_rdma_read))
-    {
-	DAT_LMR_TRIPLET iov;
-	DAT_RMR_COOKIE  cookie;
-	DAT_MEM_PRIV_FLAGS mflags;
-	DAT_RMR_BIND_COMPLETION_EVENT_DATA rmr_stat;
+	/* Enable RDMA if requested */
+	if (enable_memory_windows && (enable_rdma_write || enable_rdma_read)) {
+		DAT_LMR_TRIPLET iov;
+		DAT_RMR_COOKIE cookie;
+		DAT_MEM_PRIV_FLAGS mflags;
+		DAT_RMR_BIND_COMPLETION_EVENT_DATA rmr_stat;
 
-	/* create the RMR */
-	ret = dat_rmr_create (pz_handle, &bpool_ptr->rmr_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "%s: dat_rmr_create failed %s\n",
-			module, DT_RetToString (ret));
-	    goto err;
-	}
+		/* create the RMR */
+		ret = dat_rmr_create(pz_handle, &bpool_ptr->rmr_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_rmr_create failed %s\n",
+					  module, DT_RetToString(ret));
+			goto err;
+		}
 
-	/* bind the RMR */
-	iov.virtual_address = bpool_ptr->reg_addr;
-	iov.segment_length  = bpool_ptr->reg_size;
-	iov.lmr_context     = bpool_ptr->lmr_context;
-	cookie.as_64        = (DAT_UINT64)0UL;
-	cookie.as_ptr       = (DAT_PVOID) (uintptr_t) bpool_ptr->reg_addr;
-	mflags = (enable_rdma_write && enable_rdma_read ? DAT_MEM_PRIV_ALL_FLAG
-		    : (enable_rdma_write ?  DAT_MEM_PRIV_WRITE_FLAG
-			: (enable_rdma_read ?  DAT_MEM_PRIV_READ_FLAG : 0)));
+		/* bind the RMR */
+		iov.virtual_address = bpool_ptr->reg_addr;
+		iov.segment_length = bpool_ptr->reg_size;
+		iov.lmr_context = bpool_ptr->lmr_context;
+		cookie.as_64 = (DAT_UINT64) 0UL;
+		cookie.as_ptr = (DAT_PVOID) (uintptr_t) bpool_ptr->reg_addr;
+		mflags = (enable_rdma_write
+			  && enable_rdma_read ? DAT_MEM_PRIV_ALL_FLAG
+			  : (enable_rdma_write ? DAT_MEM_PRIV_WRITE_FLAG
+			     : (enable_rdma_read ? DAT_MEM_PRIV_READ_FLAG :
+				0)));
 
-	DT_Tdep_PT_Debug (3, (phead, "rmr_bind [" F64x ", " F64x "]\n",
-			bpool_ptr->reg_addr, bpool_ptr->reg_size));
+		DT_Tdep_PT_Debug(3, (phead, "rmr_bind [" F64x ", " F64x "]\n",
+				     bpool_ptr->reg_addr, bpool_ptr->reg_size));
 
-	ret = dat_rmr_bind ( bpool_ptr->rmr_handle,
-			    bpool_ptr->lmr_handle,
-			    &iov,
-			    mflags,
-			    DAT_VA_TYPE_VA,
-			    bpool_ptr->ep_handle,
-			    cookie,
-			    DAT_COMPLETION_DEFAULT_FLAG,
-			    &bpool_ptr->rmr_context);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead,"%s: dat_rmr_bind failed %s\n",
-			module, DT_RetToString (ret));
-	    goto err;
-	}
+		ret = dat_rmr_bind(bpool_ptr->rmr_handle,
+				   bpool_ptr->lmr_handle,
+				   &iov,
+				   mflags,
+				   DAT_VA_TYPE_VA,
+				   bpool_ptr->ep_handle,
+				   cookie,
+				   DAT_COMPLETION_DEFAULT_FLAG,
+				   &bpool_ptr->rmr_context);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead, "%s: dat_rmr_bind failed %s\n",
+					  module, DT_RetToString(ret));
+			goto err;
+		}
 
-	DT_Tdep_PT_Debug (3, (phead, "rmr_bind-wait\n"));
+		DT_Tdep_PT_Debug(3, (phead, "rmr_bind-wait\n"));
 
-	/* await the bind result */
-	if (!DT_rmr_event_wait (phead, 
-		    		bpool_ptr->rmr_evd_handle, 
-				&rmr_stat) ||
-	    !DT_rmr_check (phead, 
-			   &rmr_stat,
-			   bpool_ptr->rmr_handle,
-			   (DAT_PVOID) (uintptr_t) bpool_ptr->reg_addr,
-			   "Bpool"))
-	{
-	    goto err;
+		/* await the bind result */
+		if (!DT_rmr_event_wait(phead,
+				       bpool_ptr->rmr_evd_handle,
+				       &rmr_stat) ||
+		    !DT_rmr_check(phead,
+				  &rmr_stat,
+				  bpool_ptr->rmr_handle,
+				  (DAT_PVOID) (uintptr_t) bpool_ptr->reg_addr,
+				  "Bpool")) {
+			goto err;
+		}
+
+		DT_Tdep_PT_Debug(3,
+				 (phead, "rmr_bound [OK Rctx=%x]\n",
+				  bpool_ptr->rmr_context));
 	}
 
-	DT_Tdep_PT_Debug (3, (phead, "rmr_bound [OK Rctx=%x]\n", bpool_ptr->rmr_context));
-    }
+	/*
+	 * Finally!  Return the newly created Bpool.
+	 */
+	return (bpool_ptr);
 
-    /*
-     * Finally!  Return the newly created Bpool.
-     */
-    return ( bpool_ptr );
-
-
-    /* *********************************
-     * Whoops - clean up and return NULL
-     */
-err:
-    if (bpool_ptr)
-    {
-	if (bpool_ptr->rmr_handle)
-	{
-	    ret = dat_rmr_free (bpool_ptr->rmr_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead,
-				 "%s: dat_rmr_free failed %s\n",
-			         module, 
-				 DT_RetToString (ret));
-	    }
+	/* *********************************
+	 * Whoops - clean up and return NULL
+	 */
+      err:
+	if (bpool_ptr) {
+		if (bpool_ptr->rmr_handle) {
+			ret = dat_rmr_free(bpool_ptr->rmr_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_rmr_free failed %s\n",
+						  module, DT_RetToString(ret));
+			}
+		}
+		if (bpool_ptr->lmr_handle) {
+			ret = dat_lmr_free(bpool_ptr->lmr_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_lmr_free failed %s\n",
+						  module, DT_RetToString(ret));
+			}
+		}
+		DT_MemListFree(pt_ptr, bpool_ptr);
 	}
-	if (bpool_ptr->lmr_handle)
-	{
-	    ret = dat_lmr_free (bpool_ptr->lmr_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead,
-				 "%s: dat_lmr_free failed %s\n",
-			         module, 
-				 DT_RetToString (ret));
-	    }
+	if (alloc_ptr) {
+		DT_MemListFree(pt_ptr, alloc_ptr);
 	}
-	DT_MemListFree (pt_ptr, bpool_ptr);
-    }
-    if (alloc_ptr)
-    {
-	DT_MemListFree (pt_ptr, alloc_ptr);
-    }
 
-    return ( 0 );
+	return (0);
 }
 
 /*****************************************************************************/
 bool
-DT_Bpool_Destroy (Per_Test_Data_t * pt_ptr,
-		  DT_Tdep_Print_Head *phead,
-		  Bpool * bpool_ptr)
+DT_Bpool_Destroy(Per_Test_Data_t * pt_ptr,
+		 DT_Tdep_Print_Head * phead, Bpool * bpool_ptr)
 {
-    char           *module = "DT_Bpool_Destroy";
-    bool 	   rval = true;
+	char *module = "DT_Bpool_Destroy";
+	bool rval = true;
 
-    if (bpool_ptr)
-    {
-	if (bpool_ptr->alloc_ptr)
-	{
-	    if (bpool_ptr->rmr_handle)
-	    {
-		DAT_LMR_TRIPLET iov;
-		DAT_RMR_COOKIE  cookie;
-		DAT_RETURN	ret;
+	if (bpool_ptr) {
+		if (bpool_ptr->alloc_ptr) {
+			if (bpool_ptr->rmr_handle) {
+				DAT_LMR_TRIPLET iov;
+				DAT_RMR_COOKIE cookie;
+				DAT_RETURN ret;
 
-		iov.virtual_address = bpool_ptr->reg_addr;
-		iov.segment_length  = 0; /* un-bind */
-		iov.lmr_context     = bpool_ptr->lmr_context;
-		cookie.as_64        = (DAT_UINT64)0UL;
-		cookie.as_ptr       = (DAT_PVOID) (uintptr_t)bpool_ptr->reg_addr;
+				iov.virtual_address = bpool_ptr->reg_addr;
+				iov.segment_length = 0;	/* un-bind */
+				iov.lmr_context = bpool_ptr->lmr_context;
+				cookie.as_64 = (DAT_UINT64) 0UL;
+				cookie.as_ptr =
+				    (DAT_PVOID) (uintptr_t) bpool_ptr->reg_addr;
 
-		/*
-		 * Do not attempt to unbind here. The remote node
-		 * is going through the same logic and may disconnect
-		 * before an unbind completes. Any bind/unbind
-		 * operation requires a CONNECTED QP to complete,
-		 * a disconnect will cause problems. Unbind is
-		 * a simple optimization to allow rebinding of
-		 * an RMR, doing an rmr_free will pull the plug
-		 * and cleanup properly.
-		 */
-		ret = dat_rmr_free (bpool_ptr->rmr_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead,
-			    	    "%s: dat_rmr_free failed %s\n",
-				    module, 
-				    DT_RetToString (ret));
-		    rval = false;
-		}
-	    }
+				/*
+				 * Do not attempt to unbind here. The remote node
+				 * is going through the same logic and may disconnect
+				 * before an unbind completes. Any bind/unbind
+				 * operation requires a CONNECTED QP to complete,
+				 * a disconnect will cause problems. Unbind is
+				 * a simple optimization to allow rebinding of
+				 * an RMR, doing an rmr_free will pull the plug
+				 * and cleanup properly.
+				 */
+				ret = dat_rmr_free(bpool_ptr->rmr_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_rmr_free failed %s\n",
+							  module,
+							  DT_RetToString(ret));
+					rval = false;
+				}
+			}
 
-	    if (bpool_ptr->lmr_handle)
-	    {
-		DAT_RETURN ret = dat_lmr_free (bpool_ptr->lmr_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead,
-			    	     "%s: dat_lmr_free failed %s\n",
-				     module, 
-				     DT_RetToString (ret));
-		    rval = false;
+			if (bpool_ptr->lmr_handle) {
+				DAT_RETURN ret =
+				    dat_lmr_free(bpool_ptr->lmr_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_lmr_free failed %s\n",
+							  module,
+							  DT_RetToString(ret));
+					rval = false;
+				}
+			}
+			DT_MemListFree(pt_ptr, bpool_ptr->alloc_ptr);
 		}
-	    }
-	    DT_MemListFree (pt_ptr, bpool_ptr->alloc_ptr);
+		DT_MemListFree(pt_ptr, bpool_ptr);
 	}
-	DT_MemListFree (pt_ptr, bpool_ptr);
-    }
 
-    return (rval);
+	return (rval);
 }
 
 /*****************************************************************************/
-unsigned char  *
-DT_Bpool_GetBuffer (Bpool * bpool_ptr, int index)
+unsigned char *DT_Bpool_GetBuffer(Bpool * bpool_ptr, int index)
 {
-    return ( bpool_ptr->buffer_start + index * bpool_ptr->seg_size );
+	return (bpool_ptr->buffer_start + index * bpool_ptr->seg_size);
 }
 
 /*****************************************************************************/
-DAT_COUNT
-DT_Bpool_GetBuffSize (Bpool * bpool_ptr, int index)
+DAT_COUNT DT_Bpool_GetBuffSize(Bpool * bpool_ptr, int index)
 {
-    return ( bpool_ptr->seg_size );
+	return (bpool_ptr->seg_size);
 }
 
 /*****************************************************************************/
-DAT_LMR_TRIPLET *
-DT_Bpool_GetIOV (Bpool * bpool_ptr, int index)
+DAT_LMR_TRIPLET *DT_Bpool_GetIOV(Bpool * bpool_ptr, int index)
 {
-    return ( bpool_ptr->tripl_start + index );
+	return (bpool_ptr->tripl_start + index);
 }
 
 /*****************************************************************************/
-DAT_LMR_CONTEXT
-DT_Bpool_GetLMR (Bpool * bpool_ptr, int index)
+DAT_LMR_CONTEXT DT_Bpool_GetLMR(Bpool * bpool_ptr, int index)
 {
-    return ( bpool_ptr->lmr_context );
+	return (bpool_ptr->lmr_context);
 }
 
 /*****************************************************************************/
-DAT_RMR_CONTEXT
-DT_Bpool_GetRMR (Bpool * bpool_ptr, int index)
+DAT_RMR_CONTEXT DT_Bpool_GetRMR(Bpool * bpool_ptr, int index)
 {
-    return ( bpool_ptr->rmr_context );
+	return (bpool_ptr->rmr_context);
 }
 
 /*****************************************************************************/
-void
-DT_Bpool_print (DT_Tdep_Print_Head *phead, Bpool * bpool_ptr)
+void DT_Bpool_print(DT_Tdep_Print_Head * phead, Bpool * bpool_ptr)
 {
-    DT_Tdep_PT_Printf (phead,
-	    	     "BPOOL                %p\n",
-		     bpool_ptr);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL alloc_ptr      %p\n",
-		      bpool_ptr->alloc_ptr);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL alloc_size     %x\n",
-		     (int) bpool_ptr->alloc_size);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL pz_handle      %p\n",
-		     bpool_ptr->pz_handle);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL num_segs       %x\n",
-		     (int) bpool_ptr->num_segs);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL seg_size       %x\n",
-		     (int) bpool_ptr->seg_size);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL tripl_start    %p\n",
-		     bpool_ptr->tripl_start);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL buffer_start   %p\n",
-		     bpool_ptr->buffer_start);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL buffer_size    %x\n",
-		     (int) bpool_ptr->buffer_size);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL rdma_write     %x\n",
-		     (int) bpool_ptr->enable_rdma_write);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "BPOOL rdmaread       %x\n",
-		     (int) bpool_ptr->enable_rdma_read);
+	DT_Tdep_PT_Printf(phead, "BPOOL                %p\n", bpool_ptr);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL alloc_ptr      %p\n", bpool_ptr->alloc_ptr);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL alloc_size     %x\n",
+			  (int)bpool_ptr->alloc_size);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL pz_handle      %p\n", bpool_ptr->pz_handle);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL num_segs       %x\n",
+			  (int)bpool_ptr->num_segs);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL seg_size       %x\n",
+			  (int)bpool_ptr->seg_size);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL tripl_start    %p\n", bpool_ptr->tripl_start);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL buffer_start   %p\n", bpool_ptr->buffer_start);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL buffer_size    %x\n",
+			  (int)bpool_ptr->buffer_size);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL rdma_write     %x\n",
+			  (int)bpool_ptr->enable_rdma_write);
+	DT_Tdep_PT_Printf(phead,
+			  "BPOOL rdmaread       %x\n",
+			  (int)bpool_ptr->enable_rdma_read);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,608 +34,526 @@
 #undef DFLT_QLEN
 #endif
 
-#define DFLT_QLEN      8        /* default event queue length */
+#define DFLT_QLEN      8	/* default event queue length */
 #define MAX_CONN_RETRY 8
 
 /*
  * Client control routine Connect to the server, send the command across.
  * Then start the client-side of the test - creating threads as needed
  */
-void
-DT_cs_Client (Params_t * params_ptr,
-	  char *dapl_name,
-	  char *server_name,
-	  DAT_UINT32 total_threads)
+DAT_RETURN
+DT_cs_Client(Params_t * params_ptr,
+	     char *dapl_name, char *server_name, DAT_UINT32 total_threads)
 {
-    Per_Test_Data_t     *pt_ptr             = NULL;
-    DAT_IA_HANDLE       ia_handle           = DAT_HANDLE_NULL;
-    DAT_PZ_HANDLE       pz_handle           = DAT_HANDLE_NULL;
-    DAT_EVD_HANDLE      recv_evd_hdl        = DAT_HANDLE_NULL;
-    DAT_EVD_HANDLE      reqt_evd_hdl        = DAT_HANDLE_NULL;
-    DAT_EVD_HANDLE      conn_evd_hdl        = DAT_HANDLE_NULL;
-    DAT_EVD_HANDLE      async_evd_hdl       = DAT_HANDLE_NULL;
-    DAT_EP_HANDLE       ep_handle           = DAT_HANDLE_NULL;
-    Server_Info_t       *sinfo              = NULL;
-    Transaction_Cmd_t   *Transaction_Cmd    = NULL;
-    Quit_Cmd_t          *Quit_Cmd           = NULL;
-    Performance_Cmd_t   *Performance_Cmd    = NULL;
-    Bpool               *bpool              = NULL;
-    DAT_IA_ADDRESS_PTR  server_netaddr      = NULL;
-    char                *module             = "DT_cs_Client";
-    unsigned int	did_connect	    = 0;
-    unsigned int	retry_cnt	    = 0;
-    DAT_DTO_COOKIE	dto_cookie;
+	Per_Test_Data_t *pt_ptr = NULL;
+	DAT_IA_HANDLE ia_handle = DAT_HANDLE_NULL;
+	DAT_PZ_HANDLE pz_handle = DAT_HANDLE_NULL;
+	DAT_EVD_HANDLE recv_evd_hdl = DAT_HANDLE_NULL;
+	DAT_EVD_HANDLE reqt_evd_hdl = DAT_HANDLE_NULL;
+	DAT_EVD_HANDLE conn_evd_hdl = DAT_HANDLE_NULL;
+	DAT_EVD_HANDLE async_evd_hdl = DAT_HANDLE_NULL;
+	DAT_EP_HANDLE ep_handle = DAT_HANDLE_NULL;
+	Server_Info_t *sinfo = NULL;
+	Transaction_Cmd_t *Transaction_Cmd = NULL;
+	Quit_Cmd_t *Quit_Cmd = NULL;
+	Performance_Cmd_t *Performance_Cmd = NULL;
+	Bpool *bpool = NULL;
+	DAT_IA_ADDRESS_PTR server_netaddr = NULL;
+	char *module = "DT_cs_Client";
+	unsigned int did_connect = 0;
+	unsigned int retry_cnt = 0;
+	DAT_DTO_COOKIE dto_cookie;
 
-    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-    DAT_EVENT_NUMBER    event_num;
-    unsigned char *     buffp;
-    DAT_RETURN          ret;
-    DT_Tdep_Print_Head	*phead;
+	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+	DAT_EVENT_NUMBER event_num;
+	unsigned char *buffp;
+	DAT_RETURN ret, rc;
+	DT_Tdep_Print_Head *phead;
 
-    phead = params_ptr->phead;
+	phead = params_ptr->phead;
 
-    dto_cookie.as_64 = LZERO;
+	dto_cookie.as_64 = LZERO;
 
-    DT_Tdep_PT_Printf (phead, "%s: Starting Test ... \n", module);
-    DT_Mdep_Schedule ();
-    /* Set up the  Per_Test_Data */
-    pt_ptr = DT_Alloc_Per_Test_Data (phead);
-    if (!pt_ptr)
-    {
-	DT_Tdep_PT_Printf (phead, "%s: no memory for Per_Test_Data\n", module);
-	return;
-    }
-    DT_MemListInit (pt_ptr);	    /* init MemlistLock and memListHead */
-    DT_Thread_Init (pt_ptr);	    /* init ThreadLock and threadcount */
-    pt_ptr->local_is_server                 = false;
-    pt_ptr->Client_Info.dapltest_version    = DAPLTEST_VERSION;
-    pt_ptr->Client_Info.is_little_endian    = DT_local_is_little_endian;
-    pt_ptr->Client_Info.test_type           = params_ptr->test_type;
-    pt_ptr->Client_Info.total_threads       = total_threads;
-    memcpy ( (void *) (uintptr_t) &pt_ptr->Params,
-	    (const void *) params_ptr,
-	    sizeof (Params_t));
+	DT_Tdep_PT_Printf(phead, "%s: Starting Test ... \n", module);
+	DT_Mdep_Schedule();
+	/* Set up the  Per_Test_Data */
+	pt_ptr = DT_Alloc_Per_Test_Data(phead);
+	if (!pt_ptr) {
+		DT_Tdep_PT_Printf(phead, "%s: no memory for Per_Test_Data\n",
+				  module);
+		return DAT_INSUFFICIENT_RESOURCES;
+	}
+	DT_MemListInit(pt_ptr);	/* init MemlistLock and memListHead */
+	DT_Thread_Init(pt_ptr);	/* init ThreadLock and threadcount */
+	pt_ptr->local_is_server = false;
+	pt_ptr->Client_Info.dapltest_version = DAPLTEST_VERSION;
+	pt_ptr->Client_Info.is_little_endian = DT_local_is_little_endian;
+	pt_ptr->Client_Info.test_type = params_ptr->test_type;
+	pt_ptr->Client_Info.total_threads = total_threads;
+	memcpy((void *)(uintptr_t) & pt_ptr->Params,
+	       (const void *)params_ptr, sizeof(Params_t));
 
-    /* Allocate and fill in the Server's address */
-    server_netaddr = &params_ptr->server_netaddr;
+	/* Allocate and fill in the Server's address */
+	server_netaddr = &params_ptr->server_netaddr;
 
-    /* Open the IA */
-    ret = dat_ia_open (dapl_name,
-		      DFLT_QLEN,
-		      &async_evd_hdl,
-		      &ia_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: Could not open %s (%s)\n",
-		         module, 
-			 dapl_name, 
-			 DT_RetToString (ret));
-	ia_handle = DAT_HANDLE_NULL;
-	goto client_exit;
-    }
-    DT_Tdep_PT_Debug (1,(phead, "%s: IA %s opened\n", module, dapl_name));
+	/* Open the IA */
+	ret = dat_ia_open(dapl_name, DFLT_QLEN, &async_evd_hdl, &ia_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: Could not open %s (%s)\n",
+				  module, dapl_name, DT_RetToString(ret));
+		ia_handle = DAT_HANDLE_NULL;
+		goto client_exit;
+	}
+	DT_Tdep_PT_Debug(1, (phead, "%s: IA %s opened\n", module, dapl_name));
 
-    /* Create a PZ */
-    ret = dat_pz_create (ia_handle, &pz_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: dat_pz_create error: %s\n",
-		    	 module, 
-			 DT_RetToString (ret));
-	pz_handle = DAT_HANDLE_NULL;
-	goto client_exit;
-    }
+	/* Create a PZ */
+	ret = dat_pz_create(ia_handle, &pz_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_pz_create error: %s\n",
+				  module, DT_RetToString(ret));
+		pz_handle = DAT_HANDLE_NULL;
+		goto client_exit;
+	}
 
-    /* Create 3 events - recv, request, connect */
+	/* Create 3 events - recv, request, connect */
 
-    ret = DT_Tdep_evd_create (ia_handle,
-			      DFLT_QLEN,
-			      NULL,
-			      DAT_EVD_DTO_FLAG,
-			      &recv_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: dat_evd_create (recv) failed %s\n",
-		         module, 
-			 DT_RetToString (ret));
-	recv_evd_hdl = DAT_HANDLE_NULL;
-	goto client_exit;
-    }
-    ret = DT_Tdep_evd_create (ia_handle,
-			      DFLT_QLEN,
-			      NULL,
-			      DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			      &reqt_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: dat_evd_create (send) failed %s\n",
-			 module, 
-			 DT_RetToString (ret));
-	reqt_evd_hdl = DAT_HANDLE_NULL;
-	goto client_exit;
-    }
-    ret = DT_Tdep_evd_create (ia_handle,
-			      DFLT_QLEN,
-			      NULL,
-			      DAT_EVD_CONNECTION_FLAG,
-			      &conn_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: dat_evd_create (conn) failed %s\n",
-		    	 module, 
-			 DT_RetToString (ret));
-	conn_evd_hdl = DAT_HANDLE_NULL;
-	goto client_exit;
-    }
+	ret = DT_Tdep_evd_create(ia_handle,
+				 DFLT_QLEN,
+				 NULL, DAT_EVD_DTO_FLAG, &recv_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (recv) failed %s\n",
+				  module, DT_RetToString(ret));
+		recv_evd_hdl = DAT_HANDLE_NULL;
+		goto client_exit;
+	}
+	ret = DT_Tdep_evd_create(ia_handle,
+				 DFLT_QLEN,
+				 NULL,
+				 DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
+				 &reqt_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (send) failed %s\n",
+				  module, DT_RetToString(ret));
+		reqt_evd_hdl = DAT_HANDLE_NULL;
+		goto client_exit;
+	}
+	ret = DT_Tdep_evd_create(ia_handle,
+				 DFLT_QLEN,
+				 NULL, DAT_EVD_CONNECTION_FLAG, &conn_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (conn) failed %s\n",
+				  module, DT_RetToString(ret));
+		conn_evd_hdl = DAT_HANDLE_NULL;
+		goto client_exit;
+	}
 
-    /* Create an EP */
-    ret = dat_ep_create (ia_handle,		 /* IA       */
-			pz_handle,		/* PZ       */
-			recv_evd_hdl,		/* recv     */
-			reqt_evd_hdl,		/* request  */
-			conn_evd_hdl,		/* connect  */
-			(DAT_EP_ATTR *) NULL,
-			&ep_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: dat_ep_create error: %s\n",
-		    	 module,
-		         DT_RetToString (ret));
-	ep_handle = DAT_HANDLE_NULL;
-	goto client_exit;
-    }
-    DT_Tdep_PT_Debug (1, (phead, "%s: EP created\n", module));
+	/* Create an EP */
+	ret = dat_ep_create(ia_handle,	/* IA       */
+			    pz_handle,	/* PZ       */
+			    recv_evd_hdl,	/* recv     */
+			    reqt_evd_hdl,	/* request  */
+			    conn_evd_hdl,	/* connect  */
+			    (DAT_EP_ATTR *) NULL, &ep_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_ep_create error: %s\n",
+				  module, DT_RetToString(ret));
+		ep_handle = DAT_HANDLE_NULL;
+		goto client_exit;
+	}
+	DT_Tdep_PT_Debug(1, (phead, "%s: EP created\n", module));
 
-    /*
-     * Gather whatever info we want about defaults,
-     * and check that we can handle the requested parameters.
-     */
-    if (!DT_query (pt_ptr, ia_handle, ep_handle) ||
-	!DT_check_params (pt_ptr, module))
-    {
-	goto client_exit;
-    }
+	/*
+	 * Gather whatever info we want about defaults,
+	 * and check that we can handle the requested parameters.
+	 */
+	if (!DT_query(pt_ptr, ia_handle, ep_handle) ||
+	    !DT_check_params(pt_ptr, module)) {
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
 
-    bpool = DT_BpoolAlloc (pt_ptr,
-	    	       phead,
-		       ia_handle,
-		       pz_handle,
-		       ep_handle,
-		       DAT_HANDLE_NULL, /* no RMR */
-		       DT_RoundSize (sizeof (Transaction_Cmd_t), 8192),
-		       3,	/* num_buffers */
-		       DAT_OPTIMAL_ALIGNMENT,
-		       false,
-		       false);
-    if (bpool == 0)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: no memory for command buffer pool.\n", 
-			 module);
-	goto client_exit;
-    }
+	bpool = DT_BpoolAlloc(pt_ptr, phead, ia_handle, pz_handle, ep_handle, DAT_HANDLE_NULL,	/* no RMR */
+			      DT_RoundSize(sizeof(Transaction_Cmd_t), 8192), 3,	/* num_buffers */
+			      DAT_OPTIMAL_ALIGNMENT, false, false);
+	if (bpool == 0) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: no memory for command buffer pool.\n",
+				  module);
+		ret =
+		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
+		goto client_exit;
+	}
 
-    DT_Tdep_PT_Debug (3, (phead, 
-		     "RecvSrvInfo 0  %p\n", 
-		     (DAT_PVOID) DT_Bpool_GetBuffer (bpool, 0)));
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "SndCliInfo 1  %p\n",
-		      (DAT_PVOID) DT_Bpool_GetBuffer (bpool, 1)));
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "SndCommand 2  %p\n", 
-		      (DAT_PVOID) DT_Bpool_GetBuffer (bpool, 2)));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "RecvSrvInfo 0  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(bpool, 0)));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "SndCliInfo 1  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(bpool, 1)));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "SndCommand 2  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(bpool, 2)));
 
-    /* Post recv buffer for Server_Info (1st buffer in pool) */
-    DT_Tdep_PT_Debug (1,(phead, "%s: Posting 1 recv buffer\n", module));
-retry_repost:
-    if (!DT_post_recv_buffer (phead,
-			       ep_handle,
-			       bpool,
-			       0,
-			       DT_Bpool_GetBuffSize (bpool, 0)))
-    {
-	DT_Tdep_PT_Printf (phead,
-			 "%s: cannot post Server_Info recv buffer.\n", 
-			 module);
-	goto client_exit;
-    }
+	/* Post recv buffer for Server_Info (1st buffer in pool) */
+	DT_Tdep_PT_Debug(1, (phead, "%s: Posting 1 recv buffer\n", module));
+      retry_repost:
+	if (!DT_post_recv_buffer(phead,
+				 ep_handle,
+				 bpool, 0, DT_Bpool_GetBuffSize(bpool, 0))) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: cannot post Server_Info recv buffer.\n",
+				  module);
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
 
-    DT_Tdep_PT_Debug (1,(phead, "%s: Connect Endpoint\n", module));
-retry:
-    ret = dat_ep_connect (ep_handle,
-			 server_netaddr,
-			 SERVER_PORT_NUMBER,
-			 DAT_TIMEOUT_INFINITE,
-			 0, (DAT_PVOID) 0,  /* no private data */
-			 params_ptr->ReliabilityLevel,
-			 DAT_CONNECT_DEFAULT_FLAG);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: Cannot connect Endpoint %s\n",
-			 module, 
-			 DT_RetToString (ret));
-	goto client_exit;
-    }
+	DT_Tdep_PT_Debug(1, (phead, "%s: Connect Endpoint\n", module));
+      retry:
+	ret = dat_ep_connect(ep_handle, server_netaddr, SERVER_PORT_NUMBER, DAT_TIMEOUT_INFINITE, 0, (DAT_PVOID) 0,	/* no private data */
+			     params_ptr->ReliabilityLevel,
+			     DAT_CONNECT_DEFAULT_FLAG);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: Cannot connect Endpoint %s\n",
+				  module, DT_RetToString(ret));
+		goto client_exit;
+	}
 
-    DT_Tdep_PT_Debug (1,(phead, "%s: Await connection ...\n", module));
-    if (!DT_conn_event_wait (phead, ep_handle, conn_evd_hdl, &event_num))
-    {
-	if ( event_num == DAT_CONNECTION_EVENT_PEER_REJECTED )
-	{
-	    DAT_EVENT       event;
-	    DAT_COUNT	    drained = 0;
+	DT_Tdep_PT_Debug(1, (phead, "%s: Await connection ...\n", module));
+	if (!DT_conn_event_wait(phead, ep_handle, conn_evd_hdl, &event_num)) {
+		if (event_num == DAT_CONNECTION_EVENT_PEER_REJECTED) {
+			DAT_EVENT event;
+			DAT_COUNT drained = 0;
 
-	    DT_Mdep_Sleep (1000);
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: retrying connection...\n", 
-			     module);
-	    retry_cnt++;
-	    /*
-	     * See if any buffers were flushed as a result of
-	     * the REJECT; clean them up and repost if so
-	     */
-	    dat_ep_reset (ep_handle);
-	    do
-	    {
+			DT_Mdep_Sleep(1000);
+			DT_Tdep_PT_Printf(phead,
+					  "%s: retrying connection...\n",
+					  module);
+			retry_cnt++;
+			/*
+			 * See if any buffers were flushed as a result of
+			 * the REJECT; clean them up and repost if so
+			 */
+			dat_ep_reset(ep_handle);
+			do {
+				rc = DT_Tdep_evd_dequeue(recv_evd_hdl, &event);
+				drained++;
+			} while (DAT_GET_TYPE(rc) != DAT_QUEUE_EMPTY);
 
-		ret = DT_Tdep_evd_dequeue ( recv_evd_hdl,
-					&event);
-		drained++;
-	    } while (DAT_GET_TYPE(ret) != DAT_QUEUE_EMPTY);
-
-	    if (drained > 1 && retry_cnt < MAX_CONN_RETRY)
-	    {
-		DT_Tdep_PT_Printf (phead, "Reposting!!! %d\n", drained);
-		goto retry_repost;
-	    }
-	    else if (retry_cnt < MAX_CONN_RETRY)
-	    {
-		goto retry;
-	    }
+			if (drained > 1 && retry_cnt < MAX_CONN_RETRY) {
+				DT_Tdep_PT_Printf(phead, "Reposting!!! %d\n",
+						  drained);
+				goto retry_repost;
+			} else if (retry_cnt < MAX_CONN_RETRY) {
+				goto retry;
+			}
+		}
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		DT_Tdep_PT_Printf(phead, "%s: bad connection event\n", module);
+		goto client_exit;
 	}
-	DT_Tdep_PT_Printf (phead, "%s: bad connection event\n", module);
-	goto client_exit;
-    }
 
-    did_connect++;
-    if (DT_dapltest_debug)
-    {
-	DT_Tdep_PT_Debug (1,(phead, "%s: Connected!\n", module));
-	get_ep_connection_state (phead, ep_handle);
-    }
-
+	did_connect++;
+	if (DT_dapltest_debug) {
+		DT_Tdep_PT_Debug(1, (phead, "%s: Connected!\n", module));
+		get_ep_connection_state(phead, ep_handle);
+	}
 #ifdef CM_BUSTED
     /*****  XXX Chill out a bit to give the kludged CM a chance ...
-     *****/DT_Mdep_Sleep (1000);
+     *****/ DT_Mdep_Sleep(1000);
 #endif
 
+	/* Send Client_Info (using 2nd buffer in the pool) */
+	DT_Tdep_PT_Debug(1, (phead, "%s: Sending Client_Info\n", module));
+	buffp = DT_Bpool_GetBuffer(bpool, 1);
+	memcpy((void *)buffp,
+	       (const void *)&pt_ptr->Client_Info, sizeof(Client_Info_t));
+	DT_Client_Info_Endian((Client_Info_t *) buffp);
+	if (!DT_post_send_buffer(phead,
+				 ep_handle,
+				 bpool, 1, DT_Bpool_GetBuffSize(bpool, 1))) {
+		DT_Tdep_PT_Printf(phead, "%s: cannot send Client_Info\n",
+				  module);
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
+	/* reap the send and verify it */
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(bpool, 1);
+	DT_Tdep_PT_Debug(1,
+			 (phead, "%s: Sent Client_Info - awaiting completion\n",
+			  module));
+	if (!DT_dto_event_wait(phead, reqt_evd_hdl, &dto_stat)
+	    || !DT_dto_check(phead, &dto_stat, ep_handle,
+			     DT_Bpool_GetBuffSize(bpool, 1), dto_cookie,
+			     "Client_Info_Send")) {
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
 
-    /* Send Client_Info (using 2nd buffer in the pool) */
-    DT_Tdep_PT_Debug (1,(phead, "%s: Sending Client_Info\n", module));
-    buffp = DT_Bpool_GetBuffer (bpool, 1);
-    memcpy ( (void *)buffp,
-	    (const void *) &pt_ptr->Client_Info,
-	    sizeof (Client_Info_t));
-    DT_Client_Info_Endian ((Client_Info_t *) buffp);
-    if (!DT_post_send_buffer ( phead,
-				ep_handle,
-				bpool,
-				1,
-				DT_Bpool_GetBuffSize (bpool, 1)))
-    {
-	DT_Tdep_PT_Printf (phead, "%s: cannot send Client_Info\n", module);
-	goto client_exit;
-    }
-    /* reap the send and verify it */
-    dto_cookie.as_ptr = (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( bpool, 1);
-    DT_Tdep_PT_Debug (1,(phead, 
-		   "%s: Sent Client_Info - awaiting completion\n", 
-		   module));
-    if (!DT_dto_event_wait (phead, reqt_evd_hdl, &dto_stat) ||
-	!DT_dto_check ( phead,
-	    		&dto_stat,
-			ep_handle,
-			DT_Bpool_GetBuffSize (bpool, 1),
-			dto_cookie,
-			"Client_Info_Send"))
-    {
-	goto client_exit;
-    }
-
-    /* Set up the Command (using 3rd buffer in pool) */
-    DT_Tdep_PT_Debug (1,(phead, "%s: Sending Command\n", module));
-    buffp = DT_Bpool_GetBuffer (bpool, 2);
-    switch (pt_ptr->Client_Info.test_type)
-    {
+	/* Set up the Command (using 3rd buffer in pool) */
+	DT_Tdep_PT_Debug(1, (phead, "%s: Sending Command\n", module));
+	buffp = DT_Bpool_GetBuffer(bpool, 2);
+	switch (pt_ptr->Client_Info.test_type) {
 	case TRANSACTION_TEST:
-	{
-	    Transaction_Cmd = &pt_ptr->Params.u.Transaction_Cmd;
-	    memcpy ( (void *)buffp,
-		    (const void *)Transaction_Cmd,
-		    sizeof (Transaction_Cmd_t));
-	    DT_Transaction_Cmd_Endian ((Transaction_Cmd_t *)buffp, true);
-	    break;
-	}
+		{
+			Transaction_Cmd = &pt_ptr->Params.u.Transaction_Cmd;
+			memcpy((void *)buffp,
+			       (const void *)Transaction_Cmd,
+			       sizeof(Transaction_Cmd_t));
+			DT_Transaction_Cmd_Endian((Transaction_Cmd_t *) buffp,
+						  true);
+			break;
+		}
 
-    case QUIT_TEST:
-    {
-        Quit_Cmd = &pt_ptr->Params.u.Quit_Cmd;
-        memcpy ( (void *)buffp,
-            (const void *)Quit_Cmd,
-            sizeof (Quit_Cmd_t));
-        DT_Quit_Cmd_Endian ((Quit_Cmd_t *) buffp, true);
-        break;
-    }
+	case QUIT_TEST:
+		{
+			Quit_Cmd = &pt_ptr->Params.u.Quit_Cmd;
+			memcpy((void *)buffp,
+			       (const void *)Quit_Cmd, sizeof(Quit_Cmd_t));
+			DT_Quit_Cmd_Endian((Quit_Cmd_t *) buffp, true);
+			break;
+		}
 
 	case PERFORMANCE_TEST:
-	{
-	    Performance_Cmd = &pt_ptr->Params.u.Performance_Cmd;
-	    memcpy ( (void *)buffp,
-		    (const void *)Performance_Cmd,
-		    sizeof (Performance_Cmd_t));
-	    DT_Performance_Cmd_Endian ((Performance_Cmd_t *)buffp);
-	    break;
-	}
+		{
+			Performance_Cmd = &pt_ptr->Params.u.Performance_Cmd;
+			memcpy((void *)buffp,
+			       (const void *)Performance_Cmd,
+			       sizeof(Performance_Cmd_t));
+			DT_Performance_Cmd_Endian((Performance_Cmd_t *) buffp);
+			break;
+		}
 	default:
-	{
-	    DT_Tdep_PT_Printf (phead, "Unknown Test Type\n");
-	    goto client_exit;
+		{
+			DT_Tdep_PT_Printf(phead, "Unknown Test Type\n");
+			ret = DAT_INVALID_PARAMETER;
+			goto client_exit;
+		}
 	}
-    }
 
-    /* Send the Command buffer */
-    if (!DT_post_send_buffer ( phead,
-				ep_handle,
-				bpool,
-				2,
-				DT_Bpool_GetBuffSize (bpool, 2)))
-    {
-	DT_Tdep_PT_Printf (phead, "%s: cannot send Command\n", module);
-	goto client_exit;
-    }
-    /* reap the send and verify it */
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr = (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( bpool, 2);
-    DT_Tdep_PT_Debug (1,(phead, 
-		   "%s: Sent Command - awaiting completion\n", 
-		   module));
-    if (!DT_dto_event_wait (phead, reqt_evd_hdl, &dto_stat) ||
-	!DT_dto_check ( phead,
-	    		&dto_stat,
-			ep_handle,
-			DT_Bpool_GetBuffSize (bpool, 2),
-			dto_cookie,
-			"Client_Cmd_Send"))
-    {
-	goto client_exit;
-    }
+	/* Send the Command buffer */
+	if (!DT_post_send_buffer(phead,
+				 ep_handle,
+				 bpool, 2, DT_Bpool_GetBuffSize(bpool, 2))) {
+		DT_Tdep_PT_Printf(phead, "%s: cannot send Command\n", module);
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
+	/* reap the send and verify it */
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(bpool, 2);
+	DT_Tdep_PT_Debug(1,
+			 (phead, "%s: Sent Command - awaiting completion\n",
+			  module));
+	if (!DT_dto_event_wait(phead, reqt_evd_hdl, &dto_stat)
+	    || !DT_dto_check(phead, &dto_stat, ep_handle,
+			     DT_Bpool_GetBuffSize(bpool, 2), dto_cookie,
+			     "Client_Cmd_Send")) {
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
 
     /************************************************************************/
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr = (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( bpool, 0);
-    DT_Tdep_PT_Debug (1,(phead, "%s: Waiting for Server_Info\n", module));
-    if (!DT_dto_event_wait (phead, recv_evd_hdl, &dto_stat) ||
-	!DT_dto_check ( phead,
-	    		&dto_stat,
-			ep_handle,
-			DT_Bpool_GetBuffSize (bpool, 0),
-			dto_cookie,
-			"Server_Info_Recv"))
-    {
-	goto client_exit;
-    }
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(bpool, 0);
+	DT_Tdep_PT_Debug(1, (phead, "%s: Waiting for Server_Info\n", module));
+	if (!DT_dto_event_wait(phead, recv_evd_hdl, &dto_stat) ||
+	    !DT_dto_check(phead,
+			  &dto_stat,
+			  ep_handle,
+			  DT_Bpool_GetBuffSize(bpool, 0),
+			  dto_cookie, "Server_Info_Recv")) {
+		ret = DAT_INSUFFICIENT_RESOURCES;
+		goto client_exit;
+	}
 
-    DT_Tdep_PT_Debug (1,(phead, "%s: Server_Info Received\n", module));
-    sinfo = (Server_Info_t*) DT_Bpool_GetBuffer (bpool, 0);
-    DT_Server_Info_Endian (sinfo);
-    memcpy ( (void *) (uintptr_t)&pt_ptr->Server_Info,
-	    (const void *)sinfo,
-	    sizeof (Server_Info_t));
+	DT_Tdep_PT_Debug(1, (phead, "%s: Server_Info Received\n", module));
+	sinfo = (Server_Info_t *) DT_Bpool_GetBuffer(bpool, 0);
+	DT_Server_Info_Endian(sinfo);
+	memcpy((void *)(uintptr_t) & pt_ptr->Server_Info,
+	       (const void *)sinfo, sizeof(Server_Info_t));
 
-    /* Perform obligatory version check */
-    if (pt_ptr->Server_Info.dapltest_version != DAPLTEST_VERSION)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		 "%s: DAPLTEST VERSION MISMATCH: Server %d, Client %d\n",
-		 module,
-		 pt_ptr->Server_Info.dapltest_version,
-		 DAPLTEST_VERSION);
-	goto client_exit;
-    }
-    DT_Tdep_PT_Debug (1,(phead, "%s: Version OK!\n", module));
+	/* Perform obligatory version check */
+	if (pt_ptr->Server_Info.dapltest_version != DAPLTEST_VERSION) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: DAPLTEST VERSION MISMATCH: Server %d, Client %d\n",
+				  module,
+				  pt_ptr->Server_Info.dapltest_version,
+				  DAPLTEST_VERSION);
+		ret = DAT_MODEL_NOT_SUPPORTED;
+		goto client_exit;
+	}
+	DT_Tdep_PT_Debug(1, (phead, "%s: Version OK!\n", module));
 
-    /* Dump out what we know, if requested */
-    if (DT_dapltest_debug)
-    {
-	DT_Server_Info_Print (phead, &pt_ptr->Server_Info);
-	DT_Client_Info_Print (phead, &pt_ptr->Client_Info);
-    }
+	/* Dump out what we know, if requested */
+	if (DT_dapltest_debug) {
+		DT_Server_Info_Print(phead, &pt_ptr->Server_Info);
+		DT_Client_Info_Print(phead, &pt_ptr->Client_Info);
+	}
 
-    /* Onward to running the actual test requested */
-    switch (pt_ptr->Client_Info.test_type)
-    {
+	/* Onward to running the actual test requested */
+	switch (pt_ptr->Client_Info.test_type) {
 	case TRANSACTION_TEST:
-	{
-	    if (Transaction_Cmd->debug)
-	    {
-		DT_Transaction_Cmd_PT_Print (phead, Transaction_Cmd);
-	    }
-	    DT_Transaction_Test_Client (pt_ptr,
-				    ia_handle,
-				    server_netaddr);
-	    break;
-	}
+		{
+			if (Transaction_Cmd->debug) {
+				DT_Transaction_Cmd_PT_Print(phead,
+							    Transaction_Cmd);
+			}
+			ret = DT_Transaction_Test_Client(pt_ptr,
+							 ia_handle,
+							 server_netaddr);
+			break;
+		}
 
-    case QUIT_TEST:
-    {
-	DT_Quit_Cmd_PT_Print (phead, Quit_Cmd);
-        break;
-    }
+	case QUIT_TEST:
+		{
+			DT_Quit_Cmd_PT_Print(phead, Quit_Cmd);
+			ret = DAT_SUCCESS;
+			break;
+		}
 
 	case PERFORMANCE_TEST:
-	{
-	    if (Performance_Cmd->debug)
-	    {
-		DT_Performance_Cmd_PT_Print (phead, Performance_Cmd);
-	    }
-			
-	    DT_Performance_Test_Client (params_ptr,
-				        pt_ptr,
-				       ia_handle,
-				       server_netaddr);
-	    break;
+		{
+			if (Performance_Cmd->debug) {
+				DT_Performance_Cmd_PT_Print(phead,
+							    Performance_Cmd);
+			}
+
+			ret = DT_Performance_Test_Client(params_ptr,
+							 pt_ptr,
+							 ia_handle,
+							 server_netaddr);
+			break;
+		}
 	}
-    }
 
     /*********************************************************************
      * Done - clean up and go home
+     * ret == function DAT_RETURN return code
      */
-client_exit:
-    DT_Tdep_PT_Debug (1,(phead, "%s: Cleaning Up ...\n", module));
+      client_exit:
+	DT_Tdep_PT_Debug(1, (phead, "%s: Cleaning Up ...\n", module));
 
-    /* Disconnect the EP */
-    if (ep_handle)
-    {
-	/*
-	 * graceful attempt might fail because we got here due to
-	 * some error above, so we may as well try harder.
-	 */
-	ret = dat_ep_disconnect (ep_handle, DAT_CLOSE_ABRUPT_FLAG);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	    "%s: dat_ep_disconnect (abrupt) error: %s\n",
-			    module,
-			    DT_RetToString (ret));
+	/* Disconnect the EP */
+	if (ep_handle) {
+		/*
+		 * graceful attempt might fail because we got here due to
+		 * some error above, so we may as well try harder.
+		 */
+		rc = dat_ep_disconnect(ep_handle, DAT_CLOSE_ABRUPT_FLAG);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_ep_disconnect (abrupt) error: %s\n",
+					  module, DT_RetToString(rc));
+		} else if (did_connect &&
+			   !DT_disco_event_wait(phead, conn_evd_hdl, NULL)) {
+			DT_Tdep_PT_Printf(phead, "%s: bad disconnect event\n",
+					  module);
+		}
 	}
-	else if (did_connect &&
-		    !DT_disco_event_wait (phead, conn_evd_hdl, NULL))
-	{
-	    DT_Tdep_PT_Printf (phead, "%s: bad disconnect event\n", module);
-	}
-    }
 
-    /* Free the bpool (if any) */
-    DT_Bpool_Destroy (pt_ptr, phead, bpool);
+	/* Free the bpool (if any) */
+	DT_Bpool_Destroy(pt_ptr, phead, bpool);
 
-    /* Free the EP */
-    if (ep_handle)
-    {
-	DAT_EVENT       		event;
-	/*
-	 * Drain off outstanding DTOs that may have been
-	 * generated by racing disconnects
-	 */
-	do
-	{
-	    ret = DT_Tdep_evd_dequeue ( recv_evd_hdl,
-				   &event);
-	} while (ret == DAT_SUCCESS);
+	/* Free the EP */
+	if (ep_handle) {
+		DAT_EVENT event;
+		/*
+		 * Drain off outstanding DTOs that may have been
+		 * generated by racing disconnects
+		 */
+		do {
+			rc = DT_Tdep_evd_dequeue(recv_evd_hdl, &event);
+		} while (rc == DAT_SUCCESS);
 
-	ret = dat_ep_free (ep_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: dat_ep_free error: %s\n",
-			      module, 
-			      DT_RetToString (ret));
-	    /* keep going */
+		rc = dat_ep_free(ep_handle);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_ep_free error: %s\n",
+					  module, DT_RetToString(rc));
+			/* keep going */
+		}
 	}
-    }
 
-    /* Free the 3 EVDs */
-    if (conn_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (conn_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: dat_evd_free (conn) error: %s\n",
-			     module, 
-			     DT_RetToString (ret));
-	    /* keep going */
+	/* Free the 3 EVDs */
+	if (conn_evd_hdl) {
+		rc = DT_Tdep_evd_free(conn_evd_hdl);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_evd_free (conn) error: %s\n",
+					  module, DT_RetToString(rc));
+			/* keep going */
+		}
 	}
-    }
-    if (reqt_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (reqt_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: dat_evd_free (reqt) error: %s\n",
-			     module, 
-			     DT_RetToString (ret));
-	    /* keep going */
+	if (reqt_evd_hdl) {
+		rc = DT_Tdep_evd_free(reqt_evd_hdl);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_evd_free (reqt) error: %s\n",
+					  module, DT_RetToString(rc));
+			/* keep going */
+		}
 	}
-    }
-    if (recv_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (recv_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: dat_evd_free (recv) error: %s\n",
-			     module, 
-			     DT_RetToString (ret));
-	    /* keep going */
+	if (recv_evd_hdl) {
+		rc = DT_Tdep_evd_free(recv_evd_hdl);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_evd_free (recv) error: %s\n",
+					  module, DT_RetToString(rc));
+			/* keep going */
+		}
 	}
-    }
 
-    /* Free the PZ */
-    if (pz_handle)
-    {
-	ret = dat_pz_free (pz_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: dat_pz_free error: %s\n",
-			     module, 
-			     DT_RetToString (ret));
-	    /* keep going */
+	/* Free the PZ */
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_pz_free error: %s\n",
+					  module, DT_RetToString(rc));
+			/* keep going */
+		}
 	}
-    }
 
-    /* Close the IA */
-    if (ia_handle)
-    {
-	/* dat_ia_close cleans up async evd handle, too */
-	ret = dat_ia_close (ia_handle, DAT_CLOSE_GRACEFUL_FLAG);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: dat_ia_close (graceful) error: %s\n",
-			     module, 
-			     DT_RetToString (ret));
-	    ret = dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				 "%s: dat_ia_close (abrupt) error: %s\n",
-			         module, 
-				 DT_RetToString (ret));
-	    }
-	    /* keep going */
+	/* Close the IA */
+	if (ia_handle) {
+		/* dat_ia_close cleans up async evd handle, too */
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_GRACEFUL_FLAG);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_ia_close (graceful) error: %s\n",
+					  module, DT_RetToString(rc));
+			rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+			if (rc != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_ia_close (abrupt) error: %s\n",
+						  module, DT_RetToString(rc));
+			}
+			/* keep going */
+		} else {
+			DT_Tdep_PT_Debug(1,
+					 (phead, "%s: IA %s closed\n", module,
+					  dapl_name));
+		}
 	}
-	else
-	{
-	    DT_Tdep_PT_Debug (1,(phead, "%s: IA %s closed\n", module, dapl_name));
-	}
-    }
 
-    /* Free the Per_Test_Data */
-    DT_Mdep_LockDestroy (&pt_ptr->Thread_counter_lock);
-    DT_PrintMemList (pt_ptr);	    /* check if we return all space allocated  */
-    DT_Mdep_LockDestroy (&pt_ptr->MemListLock);
-    DT_Free_Per_Test_Data (pt_ptr);
+	/* Free the Per_Test_Data */
+	DT_Mdep_LockDestroy(&pt_ptr->Thread_counter_lock);
+	DT_PrintMemList(pt_ptr);	/* check if we return all space allocated  */
+	DT_Mdep_LockDestroy(&pt_ptr->MemListLock);
+	DT_Free_Per_Test_Data(pt_ptr);
 
-    DT_Tdep_PT_Printf (phead, 
-	    	     "%s: ========== End of Work -- Client Exiting\n", 
-		     module);
+	DT_Tdep_PT_Printf(phead,
+			  "%s: ========== End of Work -- Client Exiting\n",
+			  module);
+	return ret;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client_info.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client_info.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_client_info.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,28 +30,27 @@
 
 #include "dapl_proto.h"
 
-void
-DT_Client_Info_Endian (Client_Info_t * client_info)
+void DT_Client_Info_Endian(Client_Info_t * client_info)
 {
-    client_info->dapltest_version = DT_Endian32 (client_info->dapltest_version);
-    client_info->is_little_endian = DT_Endian32 (client_info->is_little_endian);
-    client_info->test_type        = DT_Endian32 (client_info->test_type);
-    client_info->total_threads    = DT_Endian32 (client_info->total_threads);
+	client_info->dapltest_version =
+	    DT_Endian32(client_info->dapltest_version);
+	client_info->is_little_endian =
+	    DT_Endian32(client_info->is_little_endian);
+	client_info->test_type = DT_Endian32(client_info->test_type);
+	client_info->total_threads = DT_Endian32(client_info->total_threads);
 }
 
-
 void
-DT_Client_Info_Print (DT_Tdep_Print_Head *phead, Client_Info_t * client_info)
+DT_Client_Info_Print(DT_Tdep_Print_Head * phead, Client_Info_t * client_info)
 {
-    DT_Tdep_PT_Printf (phead, 
-	    	     "-------------------------------------\n");
-    DT_Tdep_PT_Printf (phead, 
-	   	     "Client_Info.dapltest_version   : %d\n",
-		     client_info->dapltest_version);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "Client_Info.is_little_endian   : %d\n",
-		     client_info->is_little_endian);
-    DT_Tdep_PT_Printf (phead, 
-	    	     "Client_Info.test_type          : %d\n",
-		     client_info->test_type);
+	DT_Tdep_PT_Printf(phead, "-------------------------------------\n");
+	DT_Tdep_PT_Printf(phead,
+			  "Client_Info.dapltest_version   : %d\n",
+			  client_info->dapltest_version);
+	DT_Tdep_PT_Printf(phead,
+			  "Client_Info.is_little_endian   : %d\n",
+			  client_info->is_little_endian);
+	DT_Tdep_PT_Printf(phead,
+			  "Client_Info.test_type          : %d\n",
+			  client_info->test_type);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_cnxn.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_cnxn.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_cnxn.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,47 +31,38 @@
 #include "dapl_proto.h"
 
 /****************************************************************************/
-int
-get_ep_connection_state (DT_Tdep_Print_Head *phead, DAT_EP_HANDLE ep_handle)
+int get_ep_connection_state(DT_Tdep_Print_Head * phead, DAT_EP_HANDLE ep_handle)
 {
-    DAT_EP_STATE    ep_state;
-    DAT_BOOLEAN     in_dto_idle;
-    DAT_BOOLEAN     out_dto_idle;
-    DAT_RETURN      ret;
-    char           *recv_status = "Idle";
-    char           *req_status = "Idle";
+	DAT_EP_STATE ep_state;
+	DAT_BOOLEAN in_dto_idle;
+	DAT_BOOLEAN out_dto_idle;
+	DAT_RETURN ret;
+	char *recv_status = "Idle";
+	char *req_status = "Idle";
 
-
-    ret = dat_ep_get_status (ep_handle, &ep_state, &in_dto_idle,
+	ret = dat_ep_get_status(ep_handle, &ep_state, &in_dto_idle,
 				&out_dto_idle);
-    if (ret != 0)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "DAT_ERROR: Can't get Connection State %s\n",
-	       		 DT_RetToString (ret));
-    }
-    else
-    {
-	if (in_dto_idle == 0)
-	{
-	    recv_status = "Active";
+	if (ret != 0) {
+		DT_Tdep_PT_Printf(phead,
+				  "DAT_ERROR: Can't get Connection State %s\n",
+				  DT_RetToString(ret));
+	} else {
+		if (in_dto_idle == 0) {
+			recv_status = "Active";
+		}
+		if (out_dto_idle == 0) {
+			req_status = "Active";
+		}
+
+		DT_Tdep_PT_Printf(phead,
+				  "DAT_STATE: %s\n", DT_State2Str(ep_state));
+		DT_Tdep_PT_Printf(phead,
+				  "DAT_STATE: Inbound DTO Status: %s \n",
+				  recv_status);
+		DT_Tdep_PT_Printf(phead,
+				  "DAT_STATE: Outbound DTO Status: %s\n",
+				  req_status);
 	}
-	if (out_dto_idle == 0)
-	{
-	    req_status = "Active";
-	}
 
-	DT_Tdep_PT_Printf (phead, 
-			 "DAT_STATE: %s\n", 
-			 DT_State2Str (ep_state));
-	DT_Tdep_PT_Printf (phead, 
-			 "DAT_STATE: Inbound DTO Status: %s \n", 
-			 recv_status);
-	DT_Tdep_PT_Printf (phead, 
-			 "DAT_STATE: Outbound DTO Status: %s\n", 
-			 req_status);
-    }
-
-    return 0;
+	return 0;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_execute.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_execute.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_execute.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -35,68 +35,64 @@
 #include "dapl_quit_cmd.h"
 #include "dapl_limit_cmd.h"
 
-void
-DT_Execute_Test (Params_t *params_ptr)
+DAT_RETURN DT_Execute_Test(Params_t * params_ptr)
 {
-    Transaction_Cmd_t   *Transaction_Cmd;
-    Quit_Cmd_t          *Quit_Cmd;
-    Limit_Cmd_t         *Limit_Cmd;
-    Performance_Cmd_t   *Performance_Cmd;
-    FFT_Cmd_t           *FFT_Cmd;
+	DAT_RETURN rc = DAT_SUCCESS;
+	Transaction_Cmd_t *Transaction_Cmd;
+	Quit_Cmd_t *Quit_Cmd;
+	Limit_Cmd_t *Limit_Cmd;
+	Performance_Cmd_t *Performance_Cmd;
+	FFT_Cmd_t *FFT_Cmd;
 
-    /* re init global data - for kdapltest, we are now in the kernel */
-    DT_local_is_little_endian = params_ptr->local_is_little_endian;
-    DT_dapltest_debug = params_ptr->debug;
+	/* re init global data - for kdapltest, we are now in the kernel */
+	DT_local_is_little_endian = params_ptr->local_is_little_endian;
+	DT_dapltest_debug = params_ptr->debug;
 
-    switch (params_ptr->test_type)
-    {
+	switch (params_ptr->test_type) {
 	case SERVER_TEST:
-	{
-	    DT_cs_Server (params_ptr);
-	    break;
-	}
+		{
+			DT_cs_Server(params_ptr);
+			break;
+		}
 	case TRANSACTION_TEST:
-	{
-	    Transaction_Cmd = &params_ptr->u.Transaction_Cmd;
-	    DT_cs_Client ( params_ptr,
-			  Transaction_Cmd->dapl_name,
-			  Transaction_Cmd->server_name,
-			  Transaction_Cmd->num_threads *
-			  Transaction_Cmd->eps_per_thread);
-	    break;
-	}
+		{
+			Transaction_Cmd = &params_ptr->u.Transaction_Cmd;
+			rc = DT_cs_Client(params_ptr,
+					  Transaction_Cmd->dapl_name,
+					  Transaction_Cmd->server_name,
+					  Transaction_Cmd->num_threads *
+					  Transaction_Cmd->eps_per_thread);
+			break;
+		}
 	case QUIT_TEST:
-	{
-	    Quit_Cmd = &params_ptr->u.Quit_Cmd;
-	    DT_cs_Client ( params_ptr,
-			  Quit_Cmd->device_name,
-			  Quit_Cmd->server_name,
-			  0);
-	    break;
-	}
+		{
+			Quit_Cmd = &params_ptr->u.Quit_Cmd;
+			(void)DT_cs_Client(params_ptr,
+					   Quit_Cmd->device_name,
+					   Quit_Cmd->server_name, 0);
+			break;
+		}
 	case LIMIT_TEST:
-	{
-	    Limit_Cmd = &params_ptr->u.Limit_Cmd;
-	    DT_cs_Limit (params_ptr, 
-		    	 Limit_Cmd);
-	    break;
-	}
+		{
+			Limit_Cmd = &params_ptr->u.Limit_Cmd;
+			rc = DT_cs_Limit(params_ptr, Limit_Cmd);
+			break;
+		}
 	case PERFORMANCE_TEST:
-	{
-	    Performance_Cmd = &params_ptr->u.Performance_Cmd;
-	    DT_cs_Client ( params_ptr,
-			  Performance_Cmd->dapl_name,
-			  Performance_Cmd->server_name,
-			  1);
-	    break;
-	}
+		{
+			Performance_Cmd = &params_ptr->u.Performance_Cmd;
+			rc = DT_cs_Client(params_ptr,
+					  Performance_Cmd->dapl_name,
+					  Performance_Cmd->server_name, 1);
+			break;
+		}
 
 	case FFT_TEST:
-	{
-	    FFT_Cmd = &params_ptr->u.FFT_Cmd;
-	    DT_cs_FFT (params_ptr, 
-		       FFT_Cmd);
-	    break;
+		{
+			FFT_Cmd = &params_ptr->u.FFT_Cmd;
+			rc = DT_cs_FFT(params_ptr, FFT_Cmd);
+			break;
+		}
 	}
-    }
+	return rc;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_connmgt.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_connmgt.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_connmgt.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,97 +30,89 @@
 
 #include "dapl_proto.h"
 
-int DT_connmgt_case0 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_connmgt_case0(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    FFT_Connection_t conn;
-    int res = 1;
-    DAT_RETURN rc = 0;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	FFT_Connection_t conn;
+	int res = 1;
+	DAT_RETURN rc = 0;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Ensure time in dat_evd_wait works correctly\n");
 
-    DT_fft_init_server (params_ptr, cmd, &conn);
-    DT_assert (phead, NULL != conn.ia_handle);
-    rc = DT_Tdep_evd_wait (conn.cr_evd, 10000, &conn.event);
-    DT_assert_dat (phead, DAT_GET_TYPE (rc) == DAT_TIMEOUT_EXPIRED);
+	DT_fft_init_server(params_ptr, cmd, &conn);
+	DT_assert(phead, NULL != conn.ia_handle);
+	rc = DT_Tdep_evd_wait(conn.cr_evd, 10000, &conn.event);
+	DT_assert_dat(phead, DAT_GET_TYPE(rc) == DAT_TIMEOUT_EXPIRED);
 
-cleanup:
-    rc = DT_fft_destroy_conn_struct (params_ptr, &conn);
-    DT_assert_clean (phead, rc == DAT_SUCCESS);
+      cleanup:
+	rc = DT_fft_destroy_conn_struct(params_ptr, &conn);
+	DT_assert_clean(phead, rc == DAT_SUCCESS);
 
-    return res;
+	return res;
 }
 
-int DT_connmgt_case1 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_connmgt_case1(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    FFT_Connection_t conn;
-    int res = 1;
-    DAT_RETURN rc;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	FFT_Connection_t conn;
+	int res = 1;
+	DAT_RETURN rc;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Attempt to use timeout of 0 in dat_evd_wait\n");
 
-    DT_fft_init_server (params_ptr, cmd, &conn);
-    DT_assert (phead, NULL != conn.ia_handle);
+	DT_fft_init_server(params_ptr, cmd, &conn);
+	DT_assert(phead, NULL != conn.ia_handle);
 
-    rc = DT_Tdep_evd_wait (conn.cr_evd, 0, &conn.event);
-    DT_assert_dat (phead, DAT_GET_TYPE (rc) == DAT_TIMEOUT_EXPIRED);
+	rc = DT_Tdep_evd_wait(conn.cr_evd, 0, &conn.event);
+	DT_assert_dat(phead, DAT_GET_TYPE(rc) == DAT_TIMEOUT_EXPIRED);
 
-cleanup:
-    rc = DT_fft_destroy_conn_struct (params_ptr, &conn);
-    DT_assert_clean (phead, rc == DAT_SUCCESS);
-    return res;
+      cleanup:
+	rc = DT_fft_destroy_conn_struct(params_ptr, &conn);
+	DT_assert_clean(phead, rc == DAT_SUCCESS);
+	return res;
 
 }
 
-
-void DT_connmgt_test (Params_t *params_ptr, FFT_Cmd_t *cmd)
+void DT_connmgt_test(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    int i;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    FFT_Testfunc_t cases_func[] =
-    {
-	{ DT_connmgt_case0 },
-	{ DT_connmgt_case1 },
-    };
-    phead = params_ptr->phead;
-    for (i = 0; i < cmd->size; i++)
-    {
-	if (cmd->cases_flag[i])
-	{
-	    if (cmd->cases_flag[i])
-	    {
+	int i;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	FFT_Testfunc_t cases_func[] = {
+		{DT_connmgt_case0},
+		{DT_connmgt_case1},
+	};
+	phead = params_ptr->phead;
+	for (i = 0; i < cmd->size; i++) {
+		if (cmd->cases_flag[i]) {
+			if (cmd->cases_flag[i]) {
 
-		DT_Tdep_PT_Printf (phead, "\
+				DT_Tdep_PT_Printf(phead, "\
 		    *********************************************************************\n");
-		DT_Tdep_PT_Printf (phead, "\
+				DT_Tdep_PT_Printf(phead, "\
 		    Function feature: Connect Management (Server side)     case: %d\n", i);
-		res = cases_func[i].fun (params_ptr, cmd);
-		if (res==1)
-		{
-		    DT_Tdep_PT_Printf (phead, "Result: PASS\n");
-		}
-		else if (res ==0)
-		{
-		    DT_Tdep_PT_Printf (phead, "Result: FAIL\n");
-		}
-		else if (res ==-1)
-		{
-		    DT_Tdep_PT_Printf (phead, "Result: use other test tool\n");
-		}
-		else if (res ==-2)
-		{
-		    DT_Tdep_PT_Printf (phead, "Result: not support or next stage to develop\n");
-		}
+				res = cases_func[i].fun(params_ptr, cmd);
+				if (res == 1) {
+					DT_Tdep_PT_Printf(phead,
+							  "Result: PASS\n");
+				} else if (res == 0) {
+					DT_Tdep_PT_Printf(phead,
+							  "Result: FAIL\n");
+				} else if (res == -1) {
+					DT_Tdep_PT_Printf(phead,
+							  "Result: use other test tool\n");
+				} else if (res == -2) {
+					DT_Tdep_PT_Printf(phead,
+							  "Result: not support or next stage to develop\n");
+				}
 
-		DT_Tdep_PT_Printf (phead, "\
+				DT_Tdep_PT_Printf(phead, "\
 		    *********************************************************************\n");
-	    }
+			}
+		}
 	}
-    }
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_endpoint.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_endpoint.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_endpoint.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,263 +34,231 @@
 #define BUFFSIZE 1024
 #define DEFAULT_QUEUE_LEN 10
 
-int DT_endpoint_generic (Params_t *params_ptr,
-			 FFT_Cmd_t *cmd,
-			 bool destroy_pz_early)
+int DT_endpoint_generic(Params_t * params_ptr,
+			FFT_Cmd_t * cmd, bool destroy_pz_early)
 {
-    char *dev_name;
-    DAT_IA_HANDLE ia_handle;
-    DAT_PZ_HANDLE pz_handle;
-    DAT_EP_HANDLE ep_handle;
-    DAT_EVD_HANDLE evd_handle;
-    DAT_EVD_HANDLE conn_evd_handle;
-    DAT_EVD_HANDLE send_evd_handle;
-    DAT_EVD_HANDLE recv_evd_handle;
-    DAT_RETURN rc, wanted;
-    int res;
-    DT_Tdep_Print_Head *phead;
+	char *dev_name;
+	DAT_IA_HANDLE ia_handle;
+	DAT_PZ_HANDLE pz_handle;
+	DAT_EP_HANDLE ep_handle;
+	DAT_EVD_HANDLE evd_handle;
+	DAT_EVD_HANDLE conn_evd_handle;
+	DAT_EVD_HANDLE send_evd_handle;
+	DAT_EVD_HANDLE recv_evd_handle;
+	DAT_RETURN rc, wanted;
+	int res;
+	DT_Tdep_Print_Head *phead;
 
-    res = 1;
-    ia_handle = NULL;
-    pz_handle = NULL;
-    ep_handle = NULL;
-    evd_handle = NULL;
-    conn_evd_handle = NULL;
-    send_evd_handle = NULL;
-    recv_evd_handle = NULL;
-    dev_name = cmd->device_name;
-    evd_handle = DAT_HANDLE_NULL;
-    phead = params_ptr->phead;
+	res = 1;
+	ia_handle = NULL;
+	pz_handle = NULL;
+	ep_handle = NULL;
+	evd_handle = NULL;
+	conn_evd_handle = NULL;
+	send_evd_handle = NULL;
+	recv_evd_handle = NULL;
+	dev_name = cmd->device_name;
+	evd_handle = DAT_HANDLE_NULL;
+	phead = params_ptr->phead;
 
-    rc = dat_ia_open ((const DAT_NAME_PTR)dev_name,
-	    DEFAULT_QUEUE_LEN, &evd_handle, &ia_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = dat_ia_open((const DAT_NAME_PTR)dev_name,
+			 DEFAULT_QUEUE_LEN, &evd_handle, &ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = dat_pz_create (ia_handle, &pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = dat_pz_create(ia_handle, &pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    if (destroy_pz_early)
-    {
-	if (pz_handle)
-	{
-	    rc = dat_pz_free (pz_handle);
-	    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	if (destroy_pz_early) {
+		if (pz_handle) {
+			rc = dat_pz_free(pz_handle);
+			DT_assert_dat(phead, rc == DAT_SUCCESS);
+		}
 	}
-    }
 
-    rc = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, NULL,
-			 DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			 &send_evd_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, NULL,
+				DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
+				&send_evd_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, NULL, DAT_EVD_DTO_FLAG,
-	    &recv_evd_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, NULL,
+				DAT_EVD_DTO_FLAG, &recv_evd_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, NULL,
-	    DAT_EVD_CONNECTION_FLAG, &conn_evd_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, NULL,
+				DAT_EVD_CONNECTION_FLAG, &conn_evd_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = dat_ep_create (ia_handle, pz_handle, recv_evd_handle, send_evd_handle,
-	    conn_evd_handle, NULL, &ep_handle);
-    if (destroy_pz_early)
-    {
-	wanted = DAT_INVALID_HANDLE;
-    }
-    else
-    {
-	wanted = DAT_SUCCESS;
-    }
-    DT_assert_dat (phead, DAT_GET_TYPE (rc) == wanted);
+	rc = dat_ep_create(ia_handle, pz_handle, recv_evd_handle,
+			   send_evd_handle, conn_evd_handle, NULL, &ep_handle);
+	if (destroy_pz_early) {
+		wanted = DAT_INVALID_HANDLE;
+	} else {
+		wanted = DAT_SUCCESS;
+	}
+	DT_assert_dat(phead, DAT_GET_TYPE(rc) == wanted);
 
-cleanup:
-    if (ep_handle)
-    {
-	rc = dat_ep_free (ep_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+      cleanup:
+	if (ep_handle) {
+		rc = dat_ep_free(ep_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (send_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (send_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (send_evd_handle) {
+		rc = DT_Tdep_evd_free(send_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (recv_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (recv_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (recv_evd_handle) {
+		rc = DT_Tdep_evd_free(recv_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (conn_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (conn_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (conn_evd_handle) {
+		rc = DT_Tdep_evd_free(conn_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (!destroy_pz_early && pz_handle)
-    {
-	rc = dat_pz_free (pz_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (!destroy_pz_early && pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (ia_handle)
-    {
-	rc = dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    return res;
+	if (ia_handle) {
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	return res;
 }
 
-int DT_endpoint_case0 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_endpoint_case0(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
 
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Test if we can normally create endpoint and destory it.\n");
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	The endpoint is not associated with a CQ\n");
-    return DT_endpoint_generic (params_ptr, cmd, false);    /* destroy pz early */
+	return DT_endpoint_generic(params_ptr, cmd, false);	/* destroy pz early */
 }
 
-int DT_endpoint_case1 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_endpoint_case1(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
 
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: try to create endpoint with pz already destroyed\n");
-    return DT_endpoint_generic (params_ptr, cmd, true);	/* destroy pz early */
+	return DT_endpoint_generic(params_ptr, cmd, true);	/* destroy pz early */
 }
 
-int DT_endpoint_case2 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_endpoint_case2(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    char *dev_name;
-    DAT_IA_HANDLE ia_handle;
-    DAT_EP_HANDLE ep_handle;
-    DAT_EVD_HANDLE send_evd, conn_evd, recv_evd, cr_evd;
-    DAT_PZ_HANDLE pz_handle;
-    DAT_EVENT event;
-    Bpool *bpool;
-    int res;
-    DAT_RETURN rc;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	char *dev_name;
+	DAT_IA_HANDLE ia_handle;
+	DAT_EP_HANDLE ep_handle;
+	DAT_EVD_HANDLE send_evd, conn_evd, recv_evd, cr_evd;
+	DAT_PZ_HANDLE pz_handle;
+	DAT_EVENT event;
+	Bpool *bpool;
+	int res;
+	DAT_RETURN rc;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: try to destroy ep with descriptor still in working queue\n");
-    res = 1;
-    bpool = 0;
-    pz_handle = 0;
-    ia_handle = 0;
-    ep_handle = 0;
-    send_evd = 0;
-    conn_evd = 0;
-    recv_evd = 0;
-    cr_evd = 0;
-    dev_name = cmd->device_name;
+	res = 1;
+	bpool = 0;
+	pz_handle = 0;
+	ia_handle = 0;
+	ep_handle = 0;
+	send_evd = 0;
+	conn_evd = 0;
+	recv_evd = 0;
+	cr_evd = 0;
+	dev_name = cmd->device_name;
 
-    rc = DT_ia_open (dev_name, &ia_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
-    rc = dat_pz_create (ia_handle, &pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
-    rc = DT_ep_create (params_ptr, 
-	    	       ia_handle, 
-		       pz_handle, 
-		       &cr_evd, 
-		       &conn_evd, 
-		       &send_evd,
-		       &recv_evd, 
-		       &ep_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
-    bpool = DT_BpoolAlloc (0, phead, ia_handle, pz_handle, NULL, NULL, 4096, 1,
-	    DAT_OPTIMAL_ALIGNMENT, false, false);
-    DT_assert (phead, bpool != 0);
-    DT_assert (phead, DT_post_recv_buffer (phead, 
-				    ep_handle, 
-				    bpool, 
-				    0, 
-				    4096) == true);
-    if (ep_handle)
-    {
-	rc = dat_ep_free (ep_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
+	rc = DT_ia_open(dev_name, &ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
+	rc = dat_pz_create(ia_handle, &pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
+	rc = DT_ep_create(params_ptr,
+			  ia_handle,
+			  pz_handle,
+			  &cr_evd, &conn_evd, &send_evd, &recv_evd, &ep_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
+	bpool =
+	    DT_BpoolAlloc(0, phead, ia_handle, pz_handle, NULL, NULL, 4096, 1,
+			  DAT_OPTIMAL_ALIGNMENT, false, false);
+	DT_assert(phead, bpool != 0);
+	DT_assert(phead, DT_post_recv_buffer(phead,
+					     ep_handle,
+					     bpool, 0, 4096) == true);
+	if (ep_handle) {
+		rc = dat_ep_free(ep_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+	}
 
-    /*
-     * Remove all DTOs. The disconnect above may have
-     * flushed all posted operations, so this is just a
-     * clean up.
-     */
-    do
-    {
-	rc = DT_Tdep_evd_dequeue ( recv_evd,
-			       &event);
-    } while (rc == DAT_SUCCESS);
-cleanup:
-    if (bpool)
-    {
-	rc = DT_Bpool_Destroy (0, phead, bpool);
-	DT_assert_clean (phead, rc != false);
-    }
-    if (pz_handle)
-    {
-	rc = dat_pz_free (pz_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (ia_handle)
-    {
-	rc = dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    return res;
+	/*
+	 * Remove all DTOs. The disconnect above may have
+	 * flushed all posted operations, so this is just a
+	 * clean up.
+	 */
+	do {
+		rc = DT_Tdep_evd_dequeue(recv_evd, &event);
+	} while (rc == DAT_SUCCESS);
+      cleanup:
+	if (bpool) {
+		rc = DT_Bpool_Destroy(0, phead, bpool);
+		DT_assert_clean(phead, rc != false);
+	}
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (ia_handle) {
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	return res;
 
 }
 
 /*-------------------------------------------------------------*/
-void DT_endpoint_test (Params_t *params_ptr, FFT_Cmd_t *cmd)
+void DT_endpoint_test(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    int i;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    FFT_Testfunc_t cases_func[] =
-    {
-	{ DT_endpoint_case0 },
-	{ DT_endpoint_case1 },
-	{ DT_endpoint_case2 },
-    };
+	int i;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	FFT_Testfunc_t cases_func[] = {
+		{DT_endpoint_case0},
+		{DT_endpoint_case1},
+		{DT_endpoint_case2},
+	};
 
-    phead = params_ptr->phead;
-    for (i=0; i<cmd->size; i++)
-    {
-	if (cmd->cases_flag[i])
-	{
-	    DT_Tdep_PT_Printf (phead, "\
+	phead = params_ptr->phead;
+	for (i = 0; i < cmd->size; i++) {
+		if (cmd->cases_flag[i]) {
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
-	    DT_Tdep_PT_Printf (phead, "\
-		Function feature: EndPoint management           case: %d\n", i
-		);
-	    res = cases_func[i].fun (params_ptr, cmd);
-	    if (res==1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: PASS\n");
-	    }
-	    else if (res ==0)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: FAIL\n");
-	    }
-	    else if (res ==-1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: use other test tool\n");
-	    }
-	    else if (res ==-2)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: not support or next stage to develop\n");
-	    }
+			DT_Tdep_PT_Printf(phead, "\
+		Function feature: EndPoint management           case: %d\n", i);
+			res = cases_func[i].fun(params_ptr, cmd);
+			if (res == 1) {
+				DT_Tdep_PT_Printf(phead, "Result: PASS\n");
+			} else if (res == 0) {
+				DT_Tdep_PT_Printf(phead, "Result: FAIL\n");
+			} else if (res == -1) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: use other test tool\n");
+			} else if (res == -2) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: not support or next stage to develop\n");
+			}
 
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
+		}
 	}
-    }
-    return;
+	return;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_hwconn.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_hwconn.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_hwconn.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,199 +31,187 @@
 #include "dapl_proto.h"
 
 /*--------------------------------------------------------*/
-int DT_hwconn_case0 ( Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_hwconn_case0(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    char* dev_name;
-    DAT_IA_HANDLE  nic_handle;
-    DAT_EVD_HANDLE evd_handle;
-    DAT_RETURN rc;
-    int res = 1;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	char *dev_name;
+	DAT_IA_HANDLE nic_handle;
+	DAT_EVD_HANDLE evd_handle;
+	DAT_RETURN rc;
+	int res = 1;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Test if we can normally Open NIC and then close it\n");
 
-    dev_name= cmd->device_name;
-    nic_handle=0;
-    evd_handle = DAT_HANDLE_NULL;
+	dev_name = cmd->device_name;
+	nic_handle = 0;
+	evd_handle = DAT_HANDLE_NULL;
 
-    rc=dat_ia_open ((const DAT_NAME_PTR)dev_name, 10, &evd_handle, &nic_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = dat_ia_open((const DAT_NAME_PTR)dev_name, 10, &evd_handle,
+			 &nic_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc=dat_ia_close (nic_handle, DAT_CLOSE_ABRUPT_FLAG);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
-cleanup:
+	rc = dat_ia_close(nic_handle, DAT_CLOSE_ABRUPT_FLAG);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
+      cleanup:
 
-    return res;
+	return res;
 }
 
 /*--------------------------------------------------------*/
-int DT_hwconn_case1 ( Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_hwconn_case1(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DAT_IA_HANDLE  nic_handle;
-    DAT_RETURN rc;
-    DAT_EVD_HANDLE evd_handle;
-    char dev_name[100];
-    int i;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	DAT_IA_HANDLE nic_handle;
+	DAT_RETURN rc;
+	DAT_EVD_HANDLE evd_handle;
+	char dev_name[100];
+	int i;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "Description: try to open NIC with incorrect device name\n");
-    DT_Tdep_PT_Printf (phead, " (just num, one letter, multiple letter, num_letter\n");
-    DT_Tdep_PT_Printf (phead, "letter_num). You alse can do this test manually\n");
-    DT_Tdep_PT_Printf (phead, "dapltest -T F -D <device_name> -f hwconn <case>\n");
+	DT_Tdep_PT_Printf(phead,
+			  "Description: try to open NIC with incorrect device name\n");
+	DT_Tdep_PT_Printf(phead,
+			  " (just num, one letter, multiple letter, num_letter\n");
+	DT_Tdep_PT_Printf(phead,
+			  "letter_num). You alse can do this test manually\n");
+	DT_Tdep_PT_Printf(phead,
+			  "dapltest -T F -D <device_name> -f hwconn <case>\n");
 
-    for (i=0; i< 5; i++)
-    {
-	if (i==0)
-	{
-	    sprintf (dev_name, "%s", "40"); /* just number */
-	}
-	else if (i==1)
-	{
-	    sprintf (dev_name, "%s", "x"); /* just letter */
-	}
-	else if (i==2)
-	{
-	    sprintf (dev_name, "%s", "xsdf"); /* multiple letter */
-	}
-	else if (i==3)
-	{
-	    sprintf (dev_name, "%s", "x34"); /* letter_number */
-	}
-	else if (i==4)
-	{
-	    sprintf (dev_name, "%s", "34df"); /* number_letter */
-	}
+	for (i = 0; i < 5; i++) {
+		if (i == 0) {
+			sprintf(dev_name, "%s", "40");	/* just number */
+		} else if (i == 1) {
+			sprintf(dev_name, "%s", "x");	/* just letter */
+		} else if (i == 2) {
+			sprintf(dev_name, "%s", "xsdf");	/* multiple letter */
+		} else if (i == 3) {
+			sprintf(dev_name, "%s", "x34");	/* letter_number */
+		} else if (i == 4) {
+			sprintf(dev_name, "%s", "34df");	/* number_letter */
+		}
 
-	evd_handle = DAT_HANDLE_NULL;
-	rc=dat_ia_open ((const DAT_NAME_PTR)dev_name, 10, &evd_handle, &nic_handle);
-	if (DAT_GET_TYPE (rc) != DAT_PROVIDER_NOT_FOUND)
-	{
-	    const char *major_msg, *minor_msg;
+		evd_handle = DAT_HANDLE_NULL;
+		rc = dat_ia_open((const DAT_NAME_PTR)dev_name, 10, &evd_handle,
+				 &nic_handle);
+		if (DAT_GET_TYPE(rc) != DAT_PROVIDER_NOT_FOUND) {
+			const char *major_msg, *minor_msg;
 
-	    DT_Tdep_PT_Printf (phead, " \
+			DT_Tdep_PT_Printf(phead, " \
 		fff not get expected result when open NIC with device name: %s\n", dev_name);
-	    dat_strerror (rc, &major_msg, &minor_msg);
-	    DT_Tdep_PT_Printf (phead, "ERROR: %s (%s)\n", major_msg, minor_msg);
+			dat_strerror(rc, &major_msg, &minor_msg);
+			DT_Tdep_PT_Printf(phead, "ERROR: %s (%s)\n", major_msg,
+					  minor_msg);
 
-
-	    if (rc==DAT_SUCCESS)
-	    {
-		rc = dat_ia_close (nic_handle, DAT_CLOSE_ABRUPT_FLAG);
-		DT_assert_clean (phead, rc == DAT_SUCCESS);
-	    }
-	    return 0;
+			if (rc == DAT_SUCCESS) {
+				rc = dat_ia_close(nic_handle,
+						  DAT_CLOSE_ABRUPT_FLAG);
+				DT_assert_clean(phead, rc == DAT_SUCCESS);
+			}
+			return 0;
+		}
 	}
-    }
-    return 1;
+	return 1;
 }
 
 /*--------------------------------------------------------*/
-int DT_hwconn_case2 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_hwconn_case2(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DAT_IA_HANDLE  nic_handle;
-    DAT_RETURN rc;
-    int res=1;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	DAT_IA_HANDLE nic_handle;
+	DAT_RETURN rc;
+	int res = 1;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Try to close nic with Nic handle is null (NIC not open)\n");
-    nic_handle=0;
-    rc=dat_ia_close (nic_handle, DAT_CLOSE_ABRUPT_FLAG);
-    DT_assert_dat (phead, DAT_GET_TYPE (rc) ==DAT_INVALID_HANDLE);
+	nic_handle = 0;
+	rc = dat_ia_close(nic_handle, DAT_CLOSE_ABRUPT_FLAG);
+	DT_assert_dat(phead, DAT_GET_TYPE(rc) == DAT_INVALID_HANDLE);
 
-cleanup:
-    return res;
+      cleanup:
+	return res;
 }
 
 /*--------------------------------------------------------*/
-int DT_hwconn_case3 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_hwconn_case3(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    FFT_Connection_t conn;
-    DAT_RETURN rc;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	FFT_Connection_t conn;
+	DAT_RETURN rc;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "Description: Test if we can close NIC when the created \n");
-    DT_Tdep_PT_Printf (phead, "endpoint has not been destroyed.\n");
-    DT_Tdep_PT_Printf (phead, "The problem for this case is that once the hca is closed, \n");
-    DT_Tdep_PT_Printf (phead, "there is no way to destroy the endpoint's resources\n");
-    DT_Tdep_PT_Printf (phead, "thus the test leaks a small amount of memory\n");
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Test if we can close NIC when the created \n");
+	DT_Tdep_PT_Printf(phead, "endpoint has not been destroyed.\n");
+	DT_Tdep_PT_Printf(phead,
+			  "The problem for this case is that once the hca is closed, \n");
+	DT_Tdep_PT_Printf(phead,
+			  "there is no way to destroy the endpoint's resources\n");
+	DT_Tdep_PT_Printf(phead,
+			  "thus the test leaks a small amount of memory\n");
 
-    res=1;
+	res = 1;
 
-    DT_fft_init_client (params_ptr, cmd, &conn);
+	DT_fft_init_client(params_ptr, cmd, &conn);
 
-    /* try to close nic when vi have not destroyed */
-    if (conn.ia_handle)
-    {
-	rc= dat_ia_close (conn.ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	if (rc !=DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Warning: dat_ia_close fails %s, reboot for cleanup\n",
-		DT_RetToString (rc));
-	    return 0;
+	/* try to close nic when vi have not destroyed */
+	if (conn.ia_handle) {
+		rc = dat_ia_close(conn.ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		if (rc != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Warning: dat_ia_close fails %s, reboot for cleanup\n",
+					  DT_RetToString(rc));
+			return 0;
+		}
+	} else {
+		res = 0;
 	}
-    } else
-    {
-	res = 0;
-    }
-    /* if nic is closed, it is impossible to destory vi and ptag */
-    //DT_fft_destroy_conn_struct(&conn);
-    return res;
+	/* if nic is closed, it is impossible to destory vi and ptag */
+	//DT_fft_destroy_conn_struct(&conn);
+	return res;
 
 }
 
-
 /*-------------------------------------------------------------*/
-void DT_hwconn_test (Params_t *params_ptr, FFT_Cmd_t *cmd)
+void DT_hwconn_test(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    int i;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    
-    FFT_Testfunc_t cases_func[] =
-    {
-	{ DT_hwconn_case0 },
-	{ DT_hwconn_case1 },
-	{ DT_hwconn_case2 },
-	{ DT_hwconn_case3 },
-    };
+	int i;
+	int res;
+	DT_Tdep_Print_Head *phead;
 
-    phead = params_ptr->phead;
-    for (i=0; i<cmd->size; i++)
-    {
-	if (cmd->cases_flag[i])
-	{
-	    DT_Tdep_PT_Printf (phead, "\
+	FFT_Testfunc_t cases_func[] = {
+		{DT_hwconn_case0},
+		{DT_hwconn_case1},
+		{DT_hwconn_case2},
+		{DT_hwconn_case3},
+	};
+
+	phead = params_ptr->phead;
+	for (i = 0; i < cmd->size; i++) {
+		if (cmd->cases_flag[i]) {
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		Function feature: Hardware connection        case: %d\n", i);
-	    res = cases_func[i].fun (params_ptr, cmd);
-	    if (res==1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: PASS\n");
-	    }
-	    else if (res ==0)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: FAIL\n");
-	    }
-	    else if (res ==-1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: use other test tool\n");
-	    }
-	    else if (res ==-2)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: next stage to develop\n");
-	    }
+			res = cases_func[i].fun(params_ptr, cmd);
+			if (res == 1) {
+				DT_Tdep_PT_Printf(phead, "Result: PASS\n");
+			} else if (res == 0) {
+				DT_Tdep_PT_Printf(phead, "Result: FAIL\n");
+			} else if (res == -1) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: use other test tool\n");
+			} else if (res == -2) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: next stage to develop\n");
+			}
 
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
+		}
 	}
-    }
-    return;
+	return;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_mem.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_mem.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_mem.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,220 +34,183 @@
 #define BUFFSIZE 1024
 
 /*--------------------------------------------------------*/
-int DT_mem_generic (Params_t *params_ptr, FFT_Cmd_t *cmd, int flag)
+int DT_mem_generic(Params_t * params_ptr, FFT_Cmd_t * cmd, int flag)
 {
-    DAT_RETURN rc, expect;
-    FFT_Connection_t conn;
-    DAT_REGION_DESCRIPTION region;
-    DAT_VLEN reg_size;
-    DAT_LMR_HANDLE lmr_handle;
-    DAT_LMR_CONTEXT lmr_context;
-    DAT_VADDR reg_addr;
-    unsigned char *alloc_ptr;
-    int res;
-    DAT_VLEN buffer_size;
-    DAT_IA_HANDLE ia_handle;
-    DAT_PZ_HANDLE pz_handle;
-    DT_Tdep_Print_Head *phead; 
-    phead = params_ptr->phead;
-    rc = 0;
-    expect = 0;
-    res = 1;
-    lmr_handle = 0;
-    lmr_context = 0;
-    reg_addr = 0;
-    alloc_ptr = 0;
-    ia_handle = 0;
-    pz_handle = 0;
+	DAT_RETURN rc, expect;
+	FFT_Connection_t conn;
+	DAT_REGION_DESCRIPTION region;
+	DAT_VLEN reg_size;
+	DAT_LMR_HANDLE lmr_handle;
+	DAT_LMR_CONTEXT lmr_context;
+	DAT_VADDR reg_addr;
+	unsigned char *alloc_ptr;
+	int res;
+	DAT_VLEN buffer_size;
+	DAT_IA_HANDLE ia_handle;
+	DAT_PZ_HANDLE pz_handle;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	rc = 0;
+	expect = 0;
+	res = 1;
+	lmr_handle = 0;
+	lmr_context = 0;
+	reg_addr = 0;
+	alloc_ptr = 0;
+	ia_handle = 0;
+	pz_handle = 0;
 
-    DT_fft_init_client (params_ptr, cmd, &conn);
-    DT_assert (phead, NULL != conn.ia_handle);
+	DT_fft_init_client(params_ptr, cmd, &conn);
+	DT_assert(phead, NULL != conn.ia_handle);
 
-    if (flag == 2)
-    {
-	buffer_size = 0;
-	alloc_ptr = 0;
-    }
-    else
-    {
-	buffer_size = BUFFSIZE * sizeof (unsigned char);
-	alloc_ptr = (unsigned char *)DT_Mdep_Malloc ((size_t)buffer_size);
-	DT_assert (phead, alloc_ptr);
-    }
+	if (flag == 2) {
+		buffer_size = 0;
+		alloc_ptr = 0;
+	} else {
+		buffer_size = BUFFSIZE * sizeof(unsigned char);
+		alloc_ptr =
+		    (unsigned char *)DT_Mdep_Malloc((size_t) buffer_size);
+		DT_assert(phead, alloc_ptr);
+	}
 
+	memset(&region, 0, sizeof(region));
+	region.for_va = alloc_ptr;
 
-    memset (&region, 0, sizeof (region));
-    region.for_va = alloc_ptr;
+	ia_handle = conn.ia_handle;
 
-    ia_handle = conn.ia_handle;
+	if (flag != 3) {
+		pz_handle = conn.pz_handle;
+	}
 
-    if (flag != 3)
-    {
-	pz_handle = conn.pz_handle;
-    }
+	if (flag != 4) {
+		DT_Tdep_PT_Printf(phead, "Registering memory\n");
+		rc = DT_Tdep_lmr_create(ia_handle, DAT_MEM_TYPE_VIRTUAL, region, buffer_size, conn.pz_handle, DAT_MEM_PRIV_ALL_FLAG, &lmr_handle, &lmr_context, NULL,	/* FIXME */
+					&reg_size, &reg_addr);
+		if (flag == 2) {
+			expect = DAT_LENGTH_ERROR;
+		} else {
+			expect = DAT_SUCCESS;
+		}
+		DT_assert_dat(phead, DAT_GET_TYPE(rc) == expect);
+	}
+	if (flag == 1) {
+		if (lmr_handle) {
+			rc = dat_lmr_free(lmr_handle);
+			DT_assert_dat(phead, rc == DAT_SUCCESS);
+		}
+		lmr_handle = 0;
 
-    if (flag != 4)
-    {
-	DT_Tdep_PT_Printf (phead, "Registering memory\n");
-	rc = DT_Tdep_lmr_create (ia_handle,
-				DAT_MEM_TYPE_VIRTUAL,
-				region,
-				buffer_size,
-				conn.pz_handle,
-				DAT_MEM_PRIV_ALL_FLAG,
-				&lmr_handle,
-				&lmr_context,
-				NULL,	/* FIXME */
-				&reg_size,
-				&reg_addr);
-	if (flag == 2)
-	{
-	    expect = DAT_LENGTH_ERROR;
+		rc = DT_Tdep_lmr_create(conn.ia_handle, DAT_MEM_TYPE_VIRTUAL, region, buffer_size, conn.pz_handle, DAT_MEM_PRIV_ALL_FLAG, &lmr_handle, &lmr_context, NULL,	/* FIXME */
+					&reg_size, &reg_addr);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
 	}
-	else
-	{
-	    expect = DAT_SUCCESS;
+
+      cleanup:
+	if (lmr_handle) {
+		rc = dat_lmr_free(lmr_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
 	}
-	DT_assert_dat (phead, DAT_GET_TYPE (rc) == expect);
-    }
-    if (flag == 1)
-    {
-	if (lmr_handle)
-	{
-	    rc = dat_lmr_free (lmr_handle);
-	    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	if (alloc_ptr) {
+		DT_Mdep_Free(alloc_ptr);
 	}
-	lmr_handle = 0;
+	rc = DT_fft_destroy_conn_struct(params_ptr, &conn);
+	DT_assert_clean(phead, rc == DAT_SUCCESS);
 
-	rc = DT_Tdep_lmr_create (conn.ia_handle,
-				DAT_MEM_TYPE_VIRTUAL,
-				region,
-				buffer_size,
-				conn.pz_handle,
-				DAT_MEM_PRIV_ALL_FLAG,
-				&lmr_handle,
-				&lmr_context,
-				NULL,	/* FIXME */
-				&reg_size,
-				&reg_addr);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
+	return res;
 
-cleanup:
-    if (lmr_handle)
-    {
-	rc = dat_lmr_free (lmr_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (alloc_ptr)
-    {
-	DT_Mdep_Free (alloc_ptr);
-    }
-    rc = DT_fft_destroy_conn_struct (params_ptr, &conn);
-    DT_assert_clean (phead, rc == DAT_SUCCESS);
-
-    return res;
-
 }
-int DT_mem_case0 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+
+int DT_mem_case0(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead; 
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Test if we can register typical size of memory\n");
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	then deregister it.\n");
-    return DT_mem_generic (params_ptr, cmd, 0);
+	return DT_mem_generic(params_ptr, cmd, 0);
 }
 
 /*--------------------------------------------------------*/
-int DT_mem_case1 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_mem_case1(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead; 
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Test if we can register typical size of memory\n");
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	deregister, then register it again.\n");
-    return DT_mem_generic (params_ptr,cmd, 1);
+	return DT_mem_generic(params_ptr, cmd, 1);
 }
 
 /*--------------------------------------------------------*/
-int DT_mem_case2 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_mem_case2(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead; 
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Try to register memory with memory size 0\n");
-    return DT_mem_generic (params_ptr, cmd, 2);
+	return DT_mem_generic(params_ptr, cmd, 2);
 }
 
 /*--------------------------------------------------------*/
-int DT_mem_case3 ( Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_mem_case3(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead; 
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Try to register memory with null pz\n");
-    return DT_mem_generic (params_ptr, cmd, 3);
+	return DT_mem_generic(params_ptr, cmd, 3);
 }
 
 /*--------------------------------------------------------*/
-int DT_mem_case4 ( Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_mem_case4(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead; 
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Try to deregister memory with null lmr_handle\n");
-    return DT_mem_generic (params_ptr, cmd, 4);
+	return DT_mem_generic(params_ptr, cmd, 4);
 }
 
 /*-------------------------------------------------------------*/
-void DT_mem_test (Params_t *params_ptr, FFT_Cmd_t *cmd)
+void DT_mem_test(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    int i;
-    int res;
-    DT_Tdep_Print_Head *phead; 
-    
-    FFT_Testfunc_t cases_func[] =
-    {
-	{ DT_mem_case0 },
-	{ DT_mem_case1 },
-	{ DT_mem_case2 },
-	{ DT_mem_case3 },
-	{ DT_mem_case4 },
-    };
+	int i;
+	int res;
+	DT_Tdep_Print_Head *phead;
 
-    phead = params_ptr->phead;
-    for (i=0; i<cmd->size; i++)
-    {
-	if (cmd->cases_flag[i])
-	{
-	    DT_Tdep_PT_Printf (phead, "\
+	FFT_Testfunc_t cases_func[] = {
+		{DT_mem_case0},
+		{DT_mem_case1},
+		{DT_mem_case2},
+		{DT_mem_case3},
+		{DT_mem_case4},
+	};
+
+	phead = params_ptr->phead;
+	for (i = 0; i < cmd->size; i++) {
+		if (cmd->cases_flag[i]) {
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		Function feature: Memory register/deregister       case: %d\n", i);
-	    res = cases_func[i].fun (params_ptr, cmd);
-	    if (res==1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: PASS\n");
-	    }
-	    else if (res ==0)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: FAIL\n");
-	    }
-	    else if (res ==-1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: use other test tool\n");
-	    }
-	    else if (res ==-2)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: not support or next stage to develop\n");
-	    }
+			res = cases_func[i].fun(params_ptr, cmd);
+			if (res == 1) {
+				DT_Tdep_PT_Printf(phead, "Result: PASS\n");
+			} else if (res == 0) {
+				DT_Tdep_PT_Printf(phead, "Result: FAIL\n");
+			} else if (res == -1) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: use other test tool\n");
+			} else if (res == -2) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: not support or next stage to develop\n");
+			}
 
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
+		}
 	}
-    }
-    return;
+	return;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_pz.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_pz.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_pz.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,239 +34,214 @@
 #define BUFFSIZE 1024
 
 /*--------------------------------------------------------*/
-int DT_pz_case0 ( Params_t *params_ptr, 
-		FFT_Cmd_t *cmd)
+int DT_pz_case0(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    char* dev_name;
-    DAT_IA_HANDLE  ia_handle;
-    DAT_PZ_HANDLE pz_handle;
-    DAT_EVD_HANDLE evd_handle;
-    DAT_RETURN rc;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead; 
+	char *dev_name;
+	DAT_IA_HANDLE ia_handle;
+	DAT_PZ_HANDLE pz_handle;
+	DAT_EVD_HANDLE evd_handle;
+	DAT_RETURN rc;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: Test if we can normally create pz and destroy it.\n");
 
-    res=1;
-    ia_handle=0;
-    pz_handle =0;
-    evd_handle = DAT_HANDLE_NULL;
-    dev_name= cmd->device_name;
+	res = 1;
+	ia_handle = 0;
+	pz_handle = 0;
+	evd_handle = DAT_HANDLE_NULL;
+	dev_name = cmd->device_name;
 
-    rc = DT_ia_open (dev_name, &ia_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
-    rc = dat_pz_create (ia_handle, &pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_ia_open(dev_name, &ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
+	rc = dat_pz_create(ia_handle, &pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-cleanup:
-    if (pz_handle)
-    {
-	rc = dat_pz_free (pz_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
-    if (ia_handle)
-    {
-	rc = dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
-    return res;
+      cleanup:
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+	}
+	if (ia_handle) {
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+	}
+	return res;
 }
 
 /*--------------------------------------------------------*/
-int DT_pz_case1 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_pz_case1(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    char* dev_name;
-    DAT_IA_HANDLE  ia_handle;
-    DAT_PZ_HANDLE pz_handle;
-    DAT_EP_HANDLE ep_handle;
-    DAT_EVD_HANDLE conn_evd, send_evd, recv_evd, cr_evd;
-    DAT_RETURN rc;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead; 
+	char *dev_name;
+	DAT_IA_HANDLE ia_handle;
+	DAT_PZ_HANDLE pz_handle;
+	DAT_EP_HANDLE ep_handle;
+	DAT_EVD_HANDLE conn_evd, send_evd, recv_evd, cr_evd;
+	DAT_RETURN rc;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: try to destroy pz with vi still associated with it\n");
 
-    res=1;
-    ia_handle=0;
-    pz_handle =0;
-    ep_handle=0;
-    conn_evd = 0;
-    send_evd = 0;
-    recv_evd = 0;
-    cr_evd = 0;
-    dev_name= cmd->device_name;
+	res = 1;
+	ia_handle = 0;
+	pz_handle = 0;
+	ep_handle = 0;
+	conn_evd = 0;
+	send_evd = 0;
+	recv_evd = 0;
+	cr_evd = 0;
+	dev_name = cmd->device_name;
 
-    rc = DT_ia_open (dev_name, &ia_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_ia_open(dev_name, &ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = dat_pz_create (ia_handle, &pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = dat_pz_create(ia_handle, &pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = DT_ep_create (params_ptr, 
-	    	       ia_handle, 
-		       pz_handle, 
-		       &cr_evd, 
-		       &conn_evd, 
-		       &send_evd,
-		       &recv_evd, 
-		       &ep_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_ep_create(params_ptr,
+			  ia_handle,
+			  pz_handle,
+			  &cr_evd, &conn_evd, &send_evd, &recv_evd, &ep_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    if (pz_handle)
-    {
-	rc = dat_pz_free (pz_handle);
-	DT_assert_dat (phead, DAT_GET_TYPE (rc) == DAT_INVALID_STATE);
-    }
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_dat(phead, DAT_GET_TYPE(rc) == DAT_INVALID_STATE);
+	}
 
-cleanup:
-    /* corrrect order */
-    if (ep_handle)
-    {
-	rc=dat_ep_free (ep_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn_evd)
-    {
-	rc = DT_Tdep_evd_free (conn_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (send_evd)
-    {
-	rc = DT_Tdep_evd_free (send_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (recv_evd)
-    {
-	rc = DT_Tdep_evd_free (recv_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (pz_handle)
-    {
-	rc=dat_pz_free (pz_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+      cleanup:
+	/* corrrect order */
+	if (ep_handle) {
+		rc = dat_ep_free(ep_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn_evd) {
+		rc = DT_Tdep_evd_free(conn_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (send_evd) {
+		rc = DT_Tdep_evd_free(send_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (recv_evd) {
+		rc = DT_Tdep_evd_free(recv_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (ia_handle)
-    {
-	rc=dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (ia_handle) {
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    return res;
+	return res;
 }
 
 /*--------------------------------------------------------*/
-int DT_pz_case2 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_pz_case2(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    char* dev_name;
-    DAT_IA_HANDLE  ia_handle;
-    DAT_PZ_HANDLE pz_handle;
-    Bpool *bpool;
-    DAT_RETURN rc;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead; 
+	char *dev_name;
+	DAT_IA_HANDLE ia_handle;
+	DAT_PZ_HANDLE pz_handle;
+	Bpool *bpool;
+	DAT_RETURN rc;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	Description: try to destroy pz with registered memory still\n");
-    DT_Tdep_PT_Printf (phead, "\
+	DT_Tdep_PT_Printf(phead, "\
 	associated with it\n");
 
-    res=1;
-    ia_handle=0;
-    pz_handle =0;
-    bpool=0;
-    dev_name= cmd->device_name;
+	res = 1;
+	ia_handle = 0;
+	pz_handle = 0;
+	bpool = 0;
+	dev_name = cmd->device_name;
 
-    rc = DT_ia_open (dev_name, &ia_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = DT_ia_open(dev_name, &ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    rc = dat_pz_create (ia_handle, &pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	rc = dat_pz_create(ia_handle, &pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* allocate and register bpool */
-    bpool = DT_BpoolAlloc (0, phead, ia_handle, pz_handle, NULL,
-			  NULL, BUFFSIZE, 1, DAT_OPTIMAL_ALIGNMENT,
-			  false, false);
-    DT_assert (phead, bpool != 0);
+	/* allocate and register bpool */
+	bpool = DT_BpoolAlloc(0, phead, ia_handle, pz_handle, NULL,
+			      NULL, BUFFSIZE, 1, DAT_OPTIMAL_ALIGNMENT,
+			      false, false);
+	DT_assert(phead, bpool != 0);
 
-    if (pz_handle)
-    {
-	rc = dat_pz_free (pz_handle);
-	DT_assert_dat (phead, DAT_GET_TYPE (rc) == DAT_INVALID_STATE);
-    }
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_dat(phead, DAT_GET_TYPE(rc) == DAT_INVALID_STATE);
+	}
 
-cleanup:
+      cleanup:
 
-    /* deregister and free bpool */
-    if (DT_Bpool_Destroy (0, phead, bpool)==false)
-    {
-	DT_Tdep_PT_Printf (phead, "Warning: Destroy bpool fails, reboot for cleanup\n");
-	return 0;
-    }
-    if (pz_handle)
-    {
-	rc=dat_pz_free (pz_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	/* deregister and free bpool */
+	if (DT_Bpool_Destroy(0, phead, bpool) == false) {
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: Destroy bpool fails, reboot for cleanup\n");
+		return 0;
+	}
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (ia_handle)
-    {
-	rc=dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (ia_handle) {
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    return res;
+	return res;
 }
 
 /*-------------------------------------------------------------*/
-void DT_pz_test (Params_t *params_ptr, FFT_Cmd_t *cmd)
+void DT_pz_test(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    int i;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    
-    FFT_Testfunc_t cases_func[] =
-    {
-	{ DT_pz_case0 },
-	{ DT_pz_case1 },
-	{ DT_pz_case2 },
-    };
+	int i;
+	int res;
+	DT_Tdep_Print_Head *phead;
 
-    phead = params_ptr->phead; 
-    for (i=0; i<cmd->size; i++)
-    {
-	if (cmd->cases_flag[i])
-	{
-	    DT_Tdep_PT_Printf (phead, "\
+	FFT_Testfunc_t cases_func[] = {
+		{DT_pz_case0},
+		{DT_pz_case1},
+		{DT_pz_case2},
+	};
+
+	phead = params_ptr->phead;
+	for (i = 0; i < cmd->size; i++) {
+		if (cmd->cases_flag[i]) {
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		Function feature: Protection Zone management         case: %d\n", i);
-	    res = cases_func[i].fun (params_ptr, cmd);
-	    if (res==1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: PASS\n");
-	    }
-	    else if (res ==0)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: FAIL\n");
-	    }
-	    else if (res ==-1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: use other test tool\n");
-	    }
-	    else if (res ==-2)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: not support or next stage to develop\n");
-	    }
+			res = cases_func[i].fun(params_ptr, cmd);
+			if (res == 1) {
+				DT_Tdep_PT_Printf(phead, "Result: PASS\n");
+			} else if (res == 0) {
+				DT_Tdep_PT_Printf(phead, "Result: FAIL\n");
+			} else if (res == -1) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: use other test tool\n");
+			} else if (res == -2) {
+				DT_Tdep_PT_Printf(phead,
+						  "Result: not support or next stage to develop\n");
+			}
 
-	    DT_Tdep_PT_Printf (phead, "\
+			DT_Tdep_PT_Printf(phead, "\
 		*********************************************************************\n");
+		}
 	}
-    }
-    return;
+	return;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_queryinfo.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_queryinfo.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_queryinfo.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -35,630 +35,562 @@
 #define DEFAULT_QUEUE_LEN 10
 
 #if defined(WIN32)
-static DAT_OS_WAIT_PROXY_AGENT NULLPROXY =
-{
-    (DAT_PVOID) NULL, (DAT_AGENT_FUNC) NULL
+static DAT_OS_WAIT_PROXY_AGENT NULLPROXY = {
+	(DAT_PVOID) NULL, (DAT_AGENT_FUNC) NULL
 };
 #endif
 
-int DT_queryinfo_basic (Params_t *params_ptr,
-			FFT_Cmd_t *cmd,
-			FFT_query_enum object_to_query,
-			DAT_RETURN  result_wanted)
+int DT_queryinfo_basic(Params_t * params_ptr,
+		       FFT_Cmd_t * cmd,
+		       FFT_query_enum object_to_query, DAT_RETURN result_wanted)
 {
-    char *dev_name;
-    DAT_IA_HANDLE ia_handle;
-    DAT_IA_ATTR ia_attributes;
-    DAT_PROVIDER_ATTR provider_attributes;
-    DAT_EVD_HANDLE evd_handle;
-    DAT_EVD_HANDLE conn_evd_handle;
-    DAT_EVD_HANDLE cr_evd_handle;
-    DAT_EVD_HANDLE send_evd_handle;
-    DAT_EVD_HANDLE recv_evd_handle;
-    DAT_EP_HANDLE ep_handle;
-    DAT_EP_PARAM ep_param;
-    DAT_CNO_HANDLE cno_handle;
+	char *dev_name;
+	DAT_IA_HANDLE ia_handle;
+	DAT_IA_ATTR ia_attributes;
+	DAT_PROVIDER_ATTR provider_attributes;
+	DAT_EVD_HANDLE evd_handle;
+	DAT_EVD_HANDLE conn_evd_handle;
+	DAT_EVD_HANDLE cr_evd_handle;
+	DAT_EVD_HANDLE send_evd_handle;
+	DAT_EVD_HANDLE recv_evd_handle;
+	DAT_EP_HANDLE ep_handle;
+	DAT_EP_PARAM ep_param;
+	DAT_CNO_HANDLE cno_handle;
 #ifndef __KDAPLTEST__
-    DAT_CNO_PARAM  cno_param;
+	DAT_CNO_PARAM cno_param;
 #endif
-    DAT_EVD_PARAM  evd_param;
-    DAT_PSP_HANDLE  psp_handle;
-    DAT_PSP_PARAM  psp_param;
-    DAT_RSP_HANDLE  rsp_handle;
-    DAT_RSP_PARAM  rsp_param;
-    DAT_PZ_HANDLE pz_handle;
-    DAT_PZ_PARAM  pz_param;
-    DAT_LMR_HANDLE lmr_handle;
-    DAT_LMR_PARAM lmr_param;
-    DAT_LMR_CONTEXT lmr_context;
-    DAT_RMR_HANDLE rmr_handle;
-    DAT_RMR_PARAM  rmr_param;
-    DAT_REGION_DESCRIPTION region;
-    DAT_VLEN reg_size;
-    DAT_VADDR reg_addr;
-    DAT_VLEN buffer_size;
-    unsigned char *alloc_ptr;
-    DT_Tdep_Print_Head *phead;
+	DAT_EVD_PARAM evd_param;
+	DAT_PSP_HANDLE psp_handle;
+	DAT_PSP_PARAM psp_param;
+	DAT_RSP_HANDLE rsp_handle;
+	DAT_RSP_PARAM rsp_param;
+	DAT_PZ_HANDLE pz_handle;
+	DAT_PZ_PARAM pz_param;
+	DAT_LMR_HANDLE lmr_handle;
+	DAT_LMR_PARAM lmr_param;
+	DAT_LMR_CONTEXT lmr_context;
+	DAT_RMR_HANDLE rmr_handle;
+	DAT_RMR_PARAM rmr_param;
+	DAT_REGION_DESCRIPTION region;
+	DAT_VLEN reg_size;
+	DAT_VADDR reg_addr;
+	DAT_VLEN buffer_size;
+	unsigned char *alloc_ptr;
+	DT_Tdep_Print_Head *phead;
 
-    DAT_RETURN rc;
-    int res = 1;
-    buffer_size = BUFFSIZE * sizeof (unsigned char);
-    phead = params_ptr->phead;
-    reg_addr = 0;
-    alloc_ptr = 0;
+	DAT_RETURN rc;
+	int res = 1;
+	buffer_size = BUFFSIZE * sizeof(unsigned char);
+	phead = params_ptr->phead;
+	reg_addr = 0;
+	alloc_ptr = 0;
 
-    ia_handle = NULL;
-    pz_handle = NULL;
-    ep_handle = NULL;
-    lmr_handle = NULL;
-    rmr_handle = NULL;
-    pz_handle = NULL;
-    psp_handle = NULL;
-    rsp_handle = NULL;
-    cno_handle = NULL;
-    evd_handle = DAT_HANDLE_NULL;
-    conn_evd_handle = DAT_HANDLE_NULL;
-    cr_evd_handle = DAT_HANDLE_NULL;
-    recv_evd_handle = DAT_HANDLE_NULL;
-    send_evd_handle = DAT_HANDLE_NULL;
-    dev_name = cmd->device_name;
+	ia_handle = NULL;
+	pz_handle = NULL;
+	ep_handle = NULL;
+	lmr_handle = NULL;
+	rmr_handle = NULL;
+	pz_handle = NULL;
+	psp_handle = NULL;
+	rsp_handle = NULL;
+	cno_handle = NULL;
+	evd_handle = DAT_HANDLE_NULL;
+	conn_evd_handle = DAT_HANDLE_NULL;
+	cr_evd_handle = DAT_HANDLE_NULL;
+	recv_evd_handle = DAT_HANDLE_NULL;
+	send_evd_handle = DAT_HANDLE_NULL;
+	dev_name = cmd->device_name;
 
-    /* All functions require an ia_handle to be created */
-    rc = dat_ia_open ((const DAT_NAME_PTR)dev_name,
-		       DEFAULT_QUEUE_LEN,
-		       &evd_handle,
-		       &ia_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* All functions require an ia_handle to be created */
+	rc = dat_ia_open((const DAT_NAME_PTR)dev_name,
+			 DEFAULT_QUEUE_LEN, &evd_handle, &ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* These functions require a pz_handle to be created */
-    if ( (object_to_query == QUERY_EVD) ||
-	 (object_to_query == QUERY_RMR) ||
-	 (object_to_query == QUERY_LMR) ||
-	 (object_to_query == QUERY_EP)  ||
-	 (object_to_query == QUERY_RSP) ||
-	 (object_to_query == QUERY_PZ) )
-    {
-	rc = dat_pz_create (ia_handle,
-			    &pz_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
+	/* These functions require a pz_handle to be created */
+	if ((object_to_query == QUERY_EVD) ||
+	    (object_to_query == QUERY_RMR) ||
+	    (object_to_query == QUERY_LMR) ||
+	    (object_to_query == QUERY_EP) ||
+	    (object_to_query == QUERY_RSP) || (object_to_query == QUERY_PZ)) {
+		rc = dat_pz_create(ia_handle, &pz_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+	}
 
-    /* These functions require a ep_handle to be created */
-    if ( (object_to_query == QUERY_EP) ||
-	 (object_to_query == QUERY_RSP) )
-    {
-	rc = DT_Tdep_evd_create (ia_handle,
-			     DEFAULT_QUEUE_LEN,
-			     cno_handle,
-			     DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			     &send_evd_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* These functions require a ep_handle to be created */
+	if ((object_to_query == QUERY_EP) || (object_to_query == QUERY_RSP)) {
+		rc = DT_Tdep_evd_create(ia_handle,
+					DEFAULT_QUEUE_LEN,
+					cno_handle,
+					DAT_EVD_DTO_FLAG |
+					DAT_EVD_RMR_BIND_FLAG,
+					&send_evd_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-	rc = DT_Tdep_evd_create (ia_handle,
-			     DEFAULT_QUEUE_LEN,
-			     cno_handle,
-			     DAT_EVD_DTO_FLAG,
-			     &recv_evd_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
+		rc = DT_Tdep_evd_create(ia_handle,
+					DEFAULT_QUEUE_LEN,
+					cno_handle,
+					DAT_EVD_DTO_FLAG, &recv_evd_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-	rc = DT_Tdep_evd_create (ia_handle,
-			     DEFAULT_QUEUE_LEN,
-			     cno_handle,
-			     DAT_EVD_CONNECTION_FLAG,
-			     &conn_evd_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
+		rc = DT_Tdep_evd_create(ia_handle,
+					DEFAULT_QUEUE_LEN,
+					cno_handle,
+					DAT_EVD_CONNECTION_FLAG,
+					&conn_evd_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-	rc = dat_ep_create (ia_handle,
-			    pz_handle,
-			    recv_evd_handle,
-			    send_evd_handle,
-			    conn_evd_handle,
-			    NULL,
-			    &ep_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
+		rc = dat_ep_create(ia_handle,
+				   pz_handle,
+				   recv_evd_handle,
+				   send_evd_handle,
+				   conn_evd_handle, NULL, &ep_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+	}
 
-    /* These functions require a CR EVD to be created.  */
-    if ( (object_to_query == QUERY_PSP) ||
-	 (object_to_query == QUERY_RSP) )
-    {
-	rc = DT_Tdep_evd_create (ia_handle,
-			     DEFAULT_QUEUE_LEN,
-			     cno_handle,
-			     DAT_EVD_CR_FLAG,
-			     &cr_evd_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-    }
+	/* These functions require a CR EVD to be created.  */
+	if ((object_to_query == QUERY_PSP) || (object_to_query == QUERY_RSP)) {
+		rc = DT_Tdep_evd_create(ia_handle,
+					DEFAULT_QUEUE_LEN,
+					cno_handle,
+					DAT_EVD_CR_FLAG, &cr_evd_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+	}
 
-    /* Test dat_ia_query function */
-    if (object_to_query == QUERY_IA)
-    {
-	if (result_wanted == DAT_SUCCESS)
-	{
-	    rc = dat_ia_query (ia_handle,
-			       &evd_handle,
-			       DAT_IA_ALL,
-			       &ia_attributes,
-			       DAT_PROVIDER_FIELD_ALL,
-			       &provider_attributes);
+	/* Test dat_ia_query function */
+	if (object_to_query == QUERY_IA) {
+		if (result_wanted == DAT_SUCCESS) {
+			rc = dat_ia_query(ia_handle,
+					  &evd_handle,
+					  DAT_IA_ALL,
+					  &ia_attributes,
+					  DAT_PROVIDER_FIELD_ALL,
+					  &provider_attributes);
+		} else if (result_wanted == DAT_INVALID_PARAMETER) {
+			/*
+			 * The only way to get an invalid parameter is to
+			 * NULL out ia_attr and for the DAT_IA_ATTR_MASK to
+			 * have values
+			 */
+			rc = dat_ia_query(ia_handle,
+					  &evd_handle,
+					  DAT_IA_ALL,
+					  NULL,
+					  DAT_PROVIDER_FIELD_ALL,
+					  &provider_attributes);
+		} else if (result_wanted == DAT_INVALID_HANDLE) {
+			rc = dat_ia_query(evd_handle,
+					  &evd_handle,
+					  DAT_IA_ALL,
+					  &ia_attributes,
+					  DAT_PROVIDER_FIELD_ALL,
+					  &provider_attributes);
+		}
 	}
-	else if (result_wanted == DAT_INVALID_PARAMETER)
-	{
-	    /*
-	     * The only way to get an invalid parameter is to
-	     * NULL out ia_attr and for the DAT_IA_ATTR_MASK to
-	     * have values
-	     */
-	    rc = dat_ia_query (ia_handle,
-			       &evd_handle,
-			       DAT_IA_ALL,
-			       NULL,
-			       DAT_PROVIDER_FIELD_ALL,
-			       &provider_attributes);
-	}
-	else if (result_wanted == DAT_INVALID_HANDLE)
-	{
-	    rc = dat_ia_query (evd_handle,
-			       &evd_handle,
-			       DAT_IA_ALL,
-			       &ia_attributes,
-			       DAT_PROVIDER_FIELD_ALL,
-			       &provider_attributes);
-	}
-    }
 
-    /* Test dat_cno_query function */
-    else if (object_to_query == QUERY_CNO)
-    {
+	/* Test dat_cno_query function */
+	else if (object_to_query == QUERY_CNO) {
 
 #ifndef __KDAPLTEST__
 #if defined(WIN32)
-	rc = dat_cno_create (ia_handle,
-						NULLPROXY,
-						&cno_handle);
+		rc = dat_cno_create(ia_handle, NULLPROXY, &cno_handle);
 #else
-	rc = dat_cno_create (ia_handle,
-			     DAT_OS_WAIT_PROXY_AGENT_NULL,
-			     &cno_handle);
+		rc = dat_cno_create(ia_handle,
+				    DAT_OS_WAIT_PROXY_AGENT_NULL, &cno_handle);
 #endif
 
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-	if (result_wanted == DAT_SUCCESS)
-	{
-	    rc = dat_cno_query (cno_handle,
-				DAT_CNO_FIELD_ALL,
-				&cno_param);
-	}
-	else if (result_wanted == DAT_INVALID_PARAMETER)
-	{
-	    rc = dat_cno_query (cno_handle,
-				DAT_CNO_FIELD_ALL,
-				NULL);
-	}
-	else if (result_wanted == DAT_INVALID_HANDLE)
-	{
-	    rc = dat_cno_query (ia_handle,
-				DAT_CNO_FIELD_ALL,
-				&cno_param);
-	}
+		if (result_wanted == DAT_SUCCESS) {
+			rc = dat_cno_query(cno_handle,
+					   DAT_CNO_FIELD_ALL, &cno_param);
+		} else if (result_wanted == DAT_INVALID_PARAMETER) {
+			rc = dat_cno_query(cno_handle, DAT_CNO_FIELD_ALL, NULL);
+		} else if (result_wanted == DAT_INVALID_HANDLE) {
+			rc = dat_cno_query(ia_handle,
+					   DAT_CNO_FIELD_ALL, &cno_param);
+		}
 #endif
-    }
-    /* Test dat_evd_query function */
-    else if (object_to_query == QUERY_EVD)
-    {
-	if (result_wanted == DAT_SUCCESS)
-	{
-	    rc = dat_evd_query (evd_handle,
-				DAT_EVD_FIELD_ALL,
-				&evd_param);
 	}
-	else if (result_wanted == DAT_INVALID_PARAMETER)
-	{
-	    rc = dat_evd_query (evd_handle,
-				DAT_EVD_FIELD_ALL,
-				NULL);
+	/* Test dat_evd_query function */
+	else if (object_to_query == QUERY_EVD) {
+		if (result_wanted == DAT_SUCCESS) {
+			rc = dat_evd_query(evd_handle,
+					   DAT_EVD_FIELD_ALL, &evd_param);
+		} else if (result_wanted == DAT_INVALID_PARAMETER) {
+			rc = dat_evd_query(evd_handle, DAT_EVD_FIELD_ALL, NULL);
+		} else if (result_wanted == DAT_INVALID_HANDLE) {
+			rc = dat_evd_query(ia_handle,
+					   DAT_EVD_FIELD_ALL, &evd_param);
+		}
 	}
-	else if (result_wanted == DAT_INVALID_HANDLE)
-	{
-	    rc = dat_evd_query (ia_handle,
-				DAT_EVD_FIELD_ALL,
-				&evd_param);
+
+	/* Test dat_psp_query function */
+	else if (object_to_query == QUERY_PSP) {
+		rc = dat_psp_create(ia_handle,
+				    SERVER_PORT_NUMBER,
+				    cr_evd_handle,
+				    DAT_PSP_PROVIDER_FLAG, &psp_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+		if (result_wanted == DAT_SUCCESS) {
+			rc = dat_psp_query(psp_handle,
+					   DAT_PSP_FIELD_ALL, &psp_param);
+		} else if (result_wanted == DAT_INVALID_PARAMETER) {
+			rc = dat_psp_query(psp_handle, DAT_PSP_FIELD_ALL, NULL);
+		} else if (result_wanted == DAT_INVALID_HANDLE) {
+			rc = dat_psp_query(evd_handle,
+					   DAT_PSP_FIELD_ALL, &psp_param);
+		}
 	}
-    }
 
-    /* Test dat_psp_query function */
-    else if (object_to_query == QUERY_PSP)
-    {
-	rc = dat_psp_create (ia_handle,
-			     SERVER_PORT_NUMBER,
-			     cr_evd_handle,
-			     DAT_PSP_PROVIDER_FLAG,
-			     &psp_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-	if (result_wanted == DAT_SUCCESS)
-	{
-	    rc = dat_psp_query (psp_handle,
-				DAT_PSP_FIELD_ALL,
-				&psp_param);
+	/* Test dat_rsp_query function */
+	else if (object_to_query == QUERY_RSP) {
+		rc = dat_rsp_create(ia_handle,
+				    SERVER_PORT_NUMBER,
+				    ep_handle, cr_evd_handle, &rsp_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+		rc = dat_rsp_query(rsp_handle, DAT_RSP_FIELD_ALL, &rsp_param);
 	}
-	else if (result_wanted == DAT_INVALID_PARAMETER)
-	{
-	    rc = dat_psp_query (psp_handle,
-				DAT_PSP_FIELD_ALL,
-				NULL);
+
+	/* Test dat_cr_query function */
+	else if (object_to_query == QUERY_CR) {
+		/* This query is tested in the conmgt test */
+		res = -1;
 	}
-	else if (result_wanted == DAT_INVALID_HANDLE)
-	{
-	    rc = dat_psp_query (evd_handle,
-				DAT_PSP_FIELD_ALL,
-				&psp_param);
+
+	/* Test dat_ep_query function */
+	else if (object_to_query == QUERY_EP) {
+		rc = dat_ep_query(ep_handle, DAT_EP_FIELD_ALL, &ep_param);
 	}
-    }
 
-    /* Test dat_rsp_query function */
-    else if (object_to_query == QUERY_RSP)
-    {
-	rc = dat_rsp_create (ia_handle,
-			     SERVER_PORT_NUMBER,
-			     ep_handle,
-			     cr_evd_handle,
-			     &rsp_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-	rc = dat_rsp_query (rsp_handle,
-			    DAT_RSP_FIELD_ALL,
-			    &rsp_param);
-    }
+	/* Test dat_pz_query function */
+	else if (object_to_query == QUERY_PZ) {
+		rc = dat_pz_query(pz_handle, DAT_PZ_FIELD_ALL, &pz_param);
+	}
 
-    /* Test dat_cr_query function */
-    else if (object_to_query == QUERY_CR)
-    {
-	/* This query is tested in the conmgt test */
-	res = -1;
-    }
+	/* Test dat_lmr_query function */
+	else if (object_to_query == QUERY_LMR) {
+		alloc_ptr =
+		    (unsigned char *)DT_Mdep_Malloc((size_t) buffer_size);
+		DT_assert(phead, alloc_ptr);
+		memset(&region, 0, sizeof(region));
+		region.for_va = alloc_ptr;
+		rc = DT_Tdep_lmr_create(ia_handle, DAT_MEM_TYPE_VIRTUAL, region, buffer_size, pz_handle, DAT_MEM_PRIV_ALL_FLAG, &lmr_handle, &lmr_context, NULL,	/* FIXME */
+					&reg_size, &reg_addr);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+		rc = dat_lmr_query(lmr_handle, DAT_LMR_FIELD_ALL, &lmr_param);
+	}
 
-    /* Test dat_ep_query function */
-    else if (object_to_query == QUERY_EP)
-    {
-	rc = dat_ep_query (ep_handle,
-			   DAT_EP_FIELD_ALL,
-			   &ep_param);
-    }
+	/* Test dat_rmr_query function */
+	else if (object_to_query == QUERY_RMR) {
+		rc = dat_rmr_create(pz_handle, &rmr_handle);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
+		/* We don't bind the RMR to anything, so don't ask for the
+		 * LMR_TRIPLET flag
+		 */
+		rc = dat_rmr_query(rmr_handle,
+				   DAT_RMR_FIELD_ALL -
+				   DAT_RMR_FIELD_LMR_TRIPLET, &rmr_param);
+	}
 
-    /* Test dat_pz_query function */
-    else if (object_to_query == QUERY_PZ)
-    {
-	rc = dat_pz_query (pz_handle,
-			   DAT_PZ_FIELD_ALL,
-			   &pz_param);
-    }
+	DT_assert_dat(phead, DAT_GET_TYPE(rc) == result_wanted);
 
-    /* Test dat_lmr_query function */
-    else if (object_to_query == QUERY_LMR)
-    {
-	alloc_ptr = (unsigned char *)DT_Mdep_Malloc ((size_t)buffer_size);
-	DT_assert (phead, alloc_ptr);
-	memset (&region, 0, sizeof (region));
-	region.for_va = alloc_ptr;
-	rc = DT_Tdep_lmr_create (ia_handle,
-				 DAT_MEM_TYPE_VIRTUAL,
-				 region,
-				 buffer_size,
-				 pz_handle,
-				 DAT_MEM_PRIV_ALL_FLAG,
-				 &lmr_handle,
-				 &lmr_context,
-				 NULL,	/* FIXME */
-				 &reg_size,
-				 &reg_addr);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-	rc = dat_lmr_query (lmr_handle,
-			    DAT_LMR_FIELD_ALL,
-			    &lmr_param);
-    }
+      cleanup:
+	if (rsp_handle) {
+		rc = dat_rsp_free(rsp_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    /* Test dat_rmr_query function */
-    else if (object_to_query == QUERY_RMR)
-    {
-	rc = dat_rmr_create (pz_handle,
-			     &rmr_handle);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
-	/* We don't bind the RMR to anything, so don't ask for the
-	 * LMR_TRIPLET flag
-	 */
-	rc = dat_rmr_query (rmr_handle,
-			    DAT_RMR_FIELD_ALL - DAT_RMR_FIELD_LMR_TRIPLET,
-			    &rmr_param);
-    }
+	if (ep_handle) {
+		rc = dat_ep_free(ep_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    DT_assert_dat (phead, DAT_GET_TYPE (rc) == result_wanted);
+	if (send_evd_handle) {
+		rc = DT_Tdep_evd_free(send_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-cleanup:
-    if (rsp_handle)
-    {
-	rc = dat_rsp_free (rsp_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (recv_evd_handle) {
+		rc = DT_Tdep_evd_free(recv_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (ep_handle)
-    {
-	rc = dat_ep_free (ep_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (conn_evd_handle) {
+		rc = DT_Tdep_evd_free(conn_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (send_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (send_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (lmr_handle) {
+		rc = dat_lmr_free(lmr_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (recv_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (recv_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-
-    if (conn_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (conn_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-
-    if (lmr_handle)
-    {
-	rc = dat_lmr_free (lmr_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-
-    if (rmr_handle)
-    {
-	rc = dat_rmr_free (rmr_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-
+	if (rmr_handle) {
+		rc = dat_rmr_free(rmr_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 #ifndef __KDAPLTEST__
-    if (cno_handle)
-    {
-	rc = dat_cno_free (cno_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (cno_handle) {
+		rc = dat_cno_free(cno_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 #endif
-    if (psp_handle)
-    {
-	rc = dat_psp_free (psp_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (psp_handle) {
+		rc = dat_psp_free(psp_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (cr_evd_handle)
-    {
-	rc = DT_Tdep_evd_free (cr_evd_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (cr_evd_handle) {
+		rc = DT_Tdep_evd_free(cr_evd_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (pz_handle)
-    {
-	rc = dat_pz_free (pz_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (pz_handle) {
+		rc = dat_pz_free(pz_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    if (ia_handle)
-    {
-	rc = dat_ia_close (ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
+	if (ia_handle) {
+		rc = dat_ia_close(ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
 
-    return res;
+	return res;
 }
 
-int DT_queryinfo_case0 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case0(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify IA Querying information is successful using\nDAT_IA_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_IA, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify IA Querying information is successful using\nDAT_IA_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_IA, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case1 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case1(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify CNO Querying information is successful using\nDAT_CNO_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_CNO, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify CNO Querying information is successful using\nDAT_CNO_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_CNO, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case2 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case2(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify EVD Querying information is successful using\nDAT_EVD_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_EVD, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify EVD Querying information is successful using\nDAT_EVD_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_EVD, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case3 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case3(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify PSP Querying information is successful using\nDAT_PSP_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_PSP, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify PSP Querying information is successful using\nDAT_PSP_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_PSP, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case4 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case4(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify RSP Querying information is successful using\nDAT_RSP_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_RSP, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify RSP Querying information is successful using\nDAT_RSP_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_RSP, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case5 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case5(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify CR Querying information is successful using\nDAT_CR_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_CR, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify CR Querying information is successful using\nDAT_CR_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_CR, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case6 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case6(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify EP Querying information is successful using\nDAT_EP_QUERY.\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_EP, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify EP Querying information is successful using\nDAT_EP_QUERY.\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_EP, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case7 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case7(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify PZ Querying information is successful using\n");
-    DT_Tdep_PT_Printf (phead, "DAT_PZ_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_PZ, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify PZ Querying information is successful using\n");
+	DT_Tdep_PT_Printf(phead, "DAT_PZ_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_PZ, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case8 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case8(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify LMR Querying information is successful using\n");
-    DT_Tdep_PT_Printf (phead, "DAT_LMR_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_LMR, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify LMR Querying information is successful using\n");
+	DT_Tdep_PT_Printf(phead, "DAT_LMR_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_LMR, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case9 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case9(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify RMR Querying information is successful using\n");
-    DT_Tdep_PT_Printf (phead, "DAT_RMR_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_RMR, DAT_SUCCESS);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify RMR Querying information is successful using\n");
+	DT_Tdep_PT_Printf(phead, "DAT_RMR_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_RMR, DAT_SUCCESS);
 }
 
-int DT_queryinfo_case10 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case10(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify IA Querying fails with DAT_INVALID_PARAMETER when\n");
-    DT_Tdep_PT_Printf (phead, "passing a bad parameter to DAT_IA_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_IA, DAT_INVALID_PARAMETER);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify IA Querying fails with DAT_INVALID_PARAMETER when\n");
+	DT_Tdep_PT_Printf(phead, "passing a bad parameter to DAT_IA_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_IA,
+				  DAT_INVALID_PARAMETER);
 }
 
-int DT_queryinfo_case11 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case11(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify IA Querying fails with DAT_INVALID_HANDLE when\n");
-    DT_Tdep_PT_Printf (phead, "passing an invalid handle to DAT_IA_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_IA, DAT_INVALID_HANDLE);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify IA Querying fails with DAT_INVALID_HANDLE when\n");
+	DT_Tdep_PT_Printf(phead, "passing an invalid handle to DAT_IA_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_IA,
+				  DAT_INVALID_HANDLE);
 }
 
-int DT_queryinfo_case12 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case12(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify CNO Querying fails with DAT_INVALID_PARAMETER when\n");
-    DT_Tdep_PT_Printf (phead, "passing a bad parameter to DAT_CNO_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_CNO, DAT_INVALID_PARAMETER);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify CNO Querying fails with DAT_INVALID_PARAMETER when\n");
+	DT_Tdep_PT_Printf(phead, "passing a bad parameter to DAT_CNO_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_CNO,
+				  DAT_INVALID_PARAMETER);
 }
 
-int DT_queryinfo_case13 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case13(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify CNO Querying fails with DAT_INVALID_HANDLE when\n");
-    DT_Tdep_PT_Printf (phead, "passing an invalid handle to DAT_CNO_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_CNO, DAT_INVALID_HANDLE);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify CNO Querying fails with DAT_INVALID_HANDLE when\n");
+	DT_Tdep_PT_Printf(phead,
+			  "passing an invalid handle to DAT_CNO_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_CNO,
+				  DAT_INVALID_HANDLE);
 }
 
-int DT_queryinfo_case14 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case14(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify EVD Querying fails with DAT_INVALID_PARAMETER when\n");
-    DT_Tdep_PT_Printf (phead, "passing a bad parameter to DAT_EVD_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_EVD, DAT_INVALID_PARAMETER);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify EVD Querying fails with DAT_INVALID_PARAMETER when\n");
+	DT_Tdep_PT_Printf(phead, "passing a bad parameter to DAT_EVD_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_EVD,
+				  DAT_INVALID_PARAMETER);
 }
 
-int DT_queryinfo_case15 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case15(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify EVD Querying fails with DAT_INVALID_HANDLE when\n");
-    DT_Tdep_PT_Printf (phead, "passing an invalid handle to DAT_EVD_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_EVD, DAT_INVALID_HANDLE);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify EVD Querying fails with DAT_INVALID_HANDLE when\n");
+	DT_Tdep_PT_Printf(phead,
+			  "passing an invalid handle to DAT_EVD_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_EVD,
+				  DAT_INVALID_HANDLE);
 }
 
-int DT_queryinfo_case16 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case16(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify PSP Querying fails with DAT_INVALID_PARAMETER when\n");
-    DT_Tdep_PT_Printf (phead, "passing a bad parameter to DAT_PSP_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_PSP, DAT_INVALID_PARAMETER);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify PSP Querying fails with DAT_INVALID_PARAMETER when\n");
+	DT_Tdep_PT_Printf(phead, "passing a bad parameter to DAT_PSP_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_PSP,
+				  DAT_INVALID_PARAMETER);
 }
 
-int DT_queryinfo_case17 (Params_t *params_ptr, FFT_Cmd_t *cmd)
+int DT_queryinfo_case17(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    DT_Tdep_PT_Printf (phead, "Description: Verify PSP Querying fails with DAT_INVALID_HANDLE when\n");
-    DT_Tdep_PT_Printf (phead, "passing an invalid handle to DAT_PSP_QUERY\n");
-    return DT_queryinfo_basic (params_ptr, cmd, QUERY_PSP, DAT_INVALID_HANDLE);
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
+	DT_Tdep_PT_Printf(phead,
+			  "Description: Verify PSP Querying fails with DAT_INVALID_HANDLE when\n");
+	DT_Tdep_PT_Printf(phead,
+			  "passing an invalid handle to DAT_PSP_QUERY\n");
+	return DT_queryinfo_basic(params_ptr, cmd, QUERY_PSP,
+				  DAT_INVALID_HANDLE);
 }
 
 /*-------------------------------------------------------------*/
-void DT_queryinfo_test (Params_t *params_ptr, FFT_Cmd_t *cmd)
+void DT_queryinfo_test(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    int i;
-    int res;
-    DT_Tdep_Print_Head *phead;
-    FFT_Testfunc_t cases_func[] =
-    {
-	{ DT_queryinfo_case0 },
-	{ DT_queryinfo_case1 },
-	{ DT_queryinfo_case2 },
-	{ DT_queryinfo_case3 },
-	{ DT_queryinfo_case4 },
-	{ DT_queryinfo_case5 },
-	{ DT_queryinfo_case6 },
-	{ DT_queryinfo_case7 },
-	{ DT_queryinfo_case8 },
-	{ DT_queryinfo_case9 },
-	{ DT_queryinfo_case10 },
-	{ DT_queryinfo_case11 },
+	int i;
+	int res;
+	DT_Tdep_Print_Head *phead;
+	FFT_Testfunc_t cases_func[] = {
+		{DT_queryinfo_case0},
+		{DT_queryinfo_case1},
+		{DT_queryinfo_case2},
+		{DT_queryinfo_case3},
+		{DT_queryinfo_case4},
+		{DT_queryinfo_case5},
+		{DT_queryinfo_case6},
+		{DT_queryinfo_case7},
+		{DT_queryinfo_case8},
+		{DT_queryinfo_case9},
+		{DT_queryinfo_case10},
+		{DT_queryinfo_case11},
 #ifndef __KDAPLTEST__
-	{ DT_queryinfo_case12 },
-	{ DT_queryinfo_case13 },
+		{DT_queryinfo_case12},
+		{DT_queryinfo_case13},
 #endif
-	{ DT_queryinfo_case14 },
-	{ DT_queryinfo_case15 },
-	{ DT_queryinfo_case16 },
-	{ DT_queryinfo_case17 },
-    };
+		{DT_queryinfo_case14},
+		{DT_queryinfo_case15},
+		{DT_queryinfo_case16},
+		{DT_queryinfo_case17},
+	};
 
-    phead = params_ptr->phead;
-    for (i=0; i < cmd->size; i++)
-    {
-	if (cmd->cases_flag[i])
-	{
-	    DT_Tdep_PT_Printf (phead, "*********************************************************************\n");
-	    DT_Tdep_PT_Printf (phead, "Function feature: Queryinfo                                  case: %d\n", i
-		);
-	    res = cases_func[i].fun (params_ptr, cmd);
-	    if (res==1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: PASS\n");
-	    }
-	    else if (res ==0)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: FAIL\n");
-	    }
-	    else if (res == -1)
-	    {
-		DT_Tdep_PT_Printf (phead, "Result: UNSUPP\n");
-	    }
+	phead = params_ptr->phead;
+	for (i = 0; i < cmd->size; i++) {
+		if (cmd->cases_flag[i]) {
+			DT_Tdep_PT_Printf(phead,
+					  "*********************************************************************\n");
+			DT_Tdep_PT_Printf(phead,
+					  "Function feature: Queryinfo                                  case: %d\n",
+					  i);
+			res = cases_func[i].fun(params_ptr, cmd);
+			if (res == 1) {
+				DT_Tdep_PT_Printf(phead, "Result: PASS\n");
+			} else if (res == 0) {
+				DT_Tdep_PT_Printf(phead, "Result: FAIL\n");
+			} else if (res == -1) {
+				DT_Tdep_PT_Printf(phead, "Result: UNSUPP\n");
+			}
 
-	    DT_Tdep_PT_Printf (phead, "*********************************************************************\n");
+			DT_Tdep_PT_Printf(phead,
+					  "*********************************************************************\n");
+		}
 	}
-    }
-    return;
+	return;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_test.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_test.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_test.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,46 +30,45 @@
 
 #include "dapl_proto.h"
 
-void
-DT_cs_FFT (Params_t *params_ptr, FFT_Cmd_t * cmd)
+DAT_RETURN DT_cs_FFT(Params_t * params_ptr, FFT_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head *phead;
+	DT_Tdep_Print_Head *phead;
+	DAT_RETURN rc = DAT_SUCCESS;
 
-    phead = params_ptr->phead;
+	phead = params_ptr->phead;
 
-    switch (cmd->fft_type)
-    {
+	switch (cmd->fft_type) {
 	case HWCONN:
-	{
-	    DT_hwconn_test (params_ptr, cmd);
-	    break;
-	}
+		{
+			DT_hwconn_test(params_ptr, cmd);
+			break;
+		}
 	case ENDPOINT:
-	{
-	    DT_endpoint_test (params_ptr, cmd);
-	    break;
-	}
+		{
+			DT_endpoint_test(params_ptr, cmd);
+			break;
+		}
 	case PTAGMGT:
-	{
-	    DT_pz_test (params_ptr, cmd);
-	    break;
-	}
+		{
+			DT_pz_test(params_ptr, cmd);
+			break;
+		}
 	case MEMMGT:
-	{
-	    DT_mem_test (params_ptr, cmd);
-	    break;
-	}
+		{
+			DT_mem_test(params_ptr, cmd);
+			break;
+		}
 	case CONNMGT:
-	{
-	    DT_connmgt_test (params_ptr, cmd);
-	    break;
-	}
+		{
+			DT_connmgt_test(params_ptr, cmd);
+			break;
+		}
 	case QUERYINFO:
-	{
-	    DT_queryinfo_test (params_ptr, cmd);
-	    break;
-	}
-#if 0 // not yet implemented
+		{
+			DT_queryinfo_test(params_ptr, cmd);
+			break;
+		}
+#if 0				// not yet implemented
 	case CONNMGT_CLIENT:
 	case NS:
 	case ERRHAND:
@@ -77,16 +76,17 @@
 	case STRESS:
 	case STRESS_CLIENT:
 	case CQMGT:
-	{
-	    DT_Tdep_PT_Printf (phead, "Not Yet Implemented\n");
-	    break;
-	}
+		{
+			DT_Tdep_PT_Printf(phead, "Not Yet Implemented\n");
+			break;
+		}
 #endif
 	default:
-	{
-	    DT_Tdep_PT_Printf (phead, "don't know this test\n");
-	    break;
+		{
+			DT_Tdep_PT_Printf(phead, "don't know this test\n");
+			rc = DAT_INVALID_PARAMETER;
+			break;
+		}
 	}
-    }
+	return rc;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_fft_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -32,351 +32,329 @@
 
 #define DEFAULT_QUEUE_LEN 10
 
-
 /* function that is called when an assertion fails, printing out the line
  * that failed vi DT_Tdep_PT_Printf
  */
-void DT_assert_fail (DT_Tdep_Print_Head *phead, char *exp, char *file, char *baseFile, int line)
+void DT_assert_fail(DT_Tdep_Print_Head * phead, char *exp, char *file,
+		    char *baseFile, int line)
 {
-    if (!strcmp (file, baseFile))
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s failed in file %s, line %d\n", 
-			 exp, 
-			 file, 
-			 line);
-    }
-    else
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s failed in file %s (included from %s), line %d\n",
-			 exp, 
-			 file, 
-			 baseFile, 
-			 line);
-    }
+	if (!strcmp(file, baseFile)) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s failed in file %s, line %d\n",
+				  exp, file, line);
+	} else {
+		DT_Tdep_PT_Printf(phead,
+				  "%s failed in file %s (included from %s), line %d\n",
+				  exp, file, baseFile, line);
+	}
 }
 
 /* helper function to open an IA */
-int DT_ia_open (DAT_NAME_PTR dev_name, DAT_IA_HANDLE *ia_handle)
+int DT_ia_open(DAT_NAME_PTR dev_name, DAT_IA_HANDLE * ia_handle)
 {
-    DAT_EVD_HANDLE evd_handle;
-    evd_handle = DAT_HANDLE_NULL;
-    return dat_ia_open (dev_name, DEFAULT_QUEUE_LEN, &evd_handle, ia_handle);
+	DAT_EVD_HANDLE evd_handle;
+	evd_handle = DAT_HANDLE_NULL;
+	return dat_ia_open(dev_name, DEFAULT_QUEUE_LEN, &evd_handle, ia_handle);
 }
 
 /* helper function to create an endpoint and its associated EVDs */
-int DT_ep_create (Params_t *params_ptr,
-		  DAT_IA_HANDLE ia_handle, 
-		  DAT_PZ_HANDLE pz_handle,
-		  DAT_EVD_HANDLE *cr_evd,
-		  DAT_EVD_HANDLE *conn_evd, 
-		  DAT_EVD_HANDLE *send_evd,
-		  DAT_EVD_HANDLE *recv_evd, 
-		  DAT_EP_HANDLE *ep_handle)
+int DT_ep_create(Params_t * params_ptr,
+		 DAT_IA_HANDLE ia_handle,
+		 DAT_PZ_HANDLE pz_handle,
+		 DAT_EVD_HANDLE * cr_evd,
+		 DAT_EVD_HANDLE * conn_evd,
+		 DAT_EVD_HANDLE * send_evd,
+		 DAT_EVD_HANDLE * recv_evd, DAT_EP_HANDLE * ep_handle)
 {
-    DAT_RETURN status;
-    DT_Tdep_Print_Head *phead;
-    *conn_evd= 0;
-    *send_evd= 0;
-    *recv_evd= 0;
-    *cr_evd= 0;
-    phead = params_ptr->phead;
+	DAT_RETURN status;
+	DT_Tdep_Print_Head *phead;
+	*conn_evd = 0;
+	*send_evd = 0;
+	*recv_evd = 0;
+	*cr_evd = 0;
+	phead = params_ptr->phead;
 
-    status = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
-			    DAT_EVD_CR_FLAG, cr_evd);
-    if (status != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "dat_evd_create failed %s\n", DT_RetToString (status));
-	return status;
-    }
+	status =
+	    DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
+			       DAT_EVD_CR_FLAG, cr_evd);
+	if (status != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "dat_evd_create failed %s\n",
+				  DT_RetToString(status));
+		return status;
+	}
 
-    status = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
-			    DAT_EVD_CONNECTION_FLAG, conn_evd);
-    if (status != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "dat_evd_create failed %s\n", DT_RetToString (status));
-	return status;
-    }
+	status =
+	    DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
+			       DAT_EVD_CONNECTION_FLAG, conn_evd);
+	if (status != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "dat_evd_create failed %s\n",
+				  DT_RetToString(status));
+		return status;
+	}
 
-    status = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
-			     DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			     send_evd);
-    if (status != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "dat_evd_create failed %s\n", DT_RetToString (status));
-	return status;
-    }
+	status =
+	    DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
+			       DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
+			       send_evd);
+	if (status != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "dat_evd_create failed %s\n",
+				  DT_RetToString(status));
+		return status;
+	}
 
-    status = DT_Tdep_evd_create (ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
-			    DAT_EVD_DTO_FLAG, recv_evd);
-    if (status != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "dat_evd_create failed %s\n", DT_RetToString (status));
-	return status;
-    }
+	status =
+	    DT_Tdep_evd_create(ia_handle, DEFAULT_QUEUE_LEN, DAT_HANDLE_NULL,
+			       DAT_EVD_DTO_FLAG, recv_evd);
+	if (status != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "dat_evd_create failed %s\n",
+				  DT_RetToString(status));
+		return status;
+	}
 
-    status = dat_ep_create (ia_handle, pz_handle, *recv_evd,
-	    *send_evd, *conn_evd, NULL, ep_handle);
-    if (status != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "dat_ep_create failed %s\n", DT_RetToString (status));
-    }
-    return status;
+	status = dat_ep_create(ia_handle, pz_handle, *recv_evd,
+			       *send_evd, *conn_evd, NULL, ep_handle);
+	if (status != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "dat_ep_create failed %s\n",
+				  DT_RetToString(status));
+	}
+	return status;
 }
 
 /* function that initializes the connection struct */
-void DT_fft_init_conn_struct (FFT_Connection_t *conn)
+void DT_fft_init_conn_struct(FFT_Connection_t * conn)
 {
-    conn->ia_handle = 0;
-    conn->pz_handle = 0;
-    conn->psp_handle = 0;
-    conn->ep_handle = 0;
-    conn->cr_evd = 0;
-    conn->send_evd = 0;
-    conn->conn_evd = 0;
-    conn->recv_evd = 0;
-    conn->cr_handle = 0;
-    conn->remote_netaddr = 0;
-    conn->bpool = 0;
-    conn->pt_ptr = 0;
-    conn->connected = false;
+	conn->ia_handle = 0;
+	conn->pz_handle = 0;
+	conn->psp_handle = 0;
+	conn->ep_handle = 0;
+	conn->cr_evd = 0;
+	conn->send_evd = 0;
+	conn->conn_evd = 0;
+	conn->recv_evd = 0;
+	conn->cr_handle = 0;
+	conn->remote_netaddr = 0;
+	conn->bpool = 0;
+	conn->pt_ptr = 0;
+	conn->connected = false;
 }
 
 /* helper function that simplifies many dat calls for the initiialization of a
  * dat "client"
  */
-void DT_fft_init_client (Params_t *params_ptr, FFT_Cmd_t *cmd, FFT_Connection_t *conn)
+void DT_fft_init_client(Params_t * params_ptr, FFT_Cmd_t * cmd,
+			FFT_Connection_t * conn)
 {
-    int res;
-    DAT_RETURN rc=0;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	int res;
+	DAT_RETURN rc = 0;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    /* initialize the struct's members */
-    DT_fft_init_conn_struct (conn);
+	/* initialize the struct's members */
+	DT_fft_init_conn_struct(conn);
 
-    /* open the IA */
-    rc = DT_ia_open (cmd->device_name, &conn->ia_handle);
-    if (rc != DAT_SUCCESS)
-    {
-	/* make sure the handle has an invalid value */
-	conn->ia_handle = NULL;
-    }
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* open the IA */
+	rc = DT_ia_open(cmd->device_name, &conn->ia_handle);
+	if (rc != DAT_SUCCESS) {
+		/* make sure the handle has an invalid value */
+		conn->ia_handle = NULL;
+	}
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* create a PZ */
-    rc = dat_pz_create (conn->ia_handle, &conn->pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* create a PZ */
+	rc = dat_pz_create(conn->ia_handle, &conn->pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* create an EP and its EVDs */
-    rc =DT_ep_create (params_ptr, 
-	    	      conn->ia_handle, 
-		      conn->pz_handle, 
-		      &conn->cr_evd,
-		      &conn->conn_evd, 
-		      &conn->send_evd, 
-		      &conn->recv_evd,
-		      &conn->ep_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* create an EP and its EVDs */
+	rc = DT_ep_create(params_ptr,
+			  conn->ia_handle,
+			  conn->pz_handle,
+			  &conn->cr_evd,
+			  &conn->conn_evd,
+			  &conn->send_evd, &conn->recv_evd, &conn->ep_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* if a server name is given, allocate memory for a net address and set it
-     * up appropriately
-     */
-    if (cmd->server_name && strlen (cmd->server_name))
-    {
-	conn->remote_netaddr = &params_ptr->server_netaddr;
-    }
-cleanup:
-    return;
+	/* if a server name is given, allocate memory for a net address and set it
+	 * up appropriately
+	 */
+	if (cmd->server_name && strlen(cmd->server_name)) {
+		conn->remote_netaddr = &params_ptr->server_netaddr;
+	}
+      cleanup:
+	return;
 }
 
 /* helper function to break down a client or server created with one of the
  * init helper functions
  */
-int DT_fft_destroy_conn_struct (Params_t *params_ptr, 
-				FFT_Connection_t *conn)
+int DT_fft_destroy_conn_struct(Params_t * params_ptr, FFT_Connection_t * conn)
 {
-    DAT_RETURN rc = DAT_SUCCESS;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
-    
-    if (conn->ep_handle)
-    {
-	if (conn->connected)
-	{
-	    rc = dat_ep_disconnect (conn->ep_handle, DAT_CLOSE_DEFAULT);
-	    DT_assert_clean (phead, rc == DAT_SUCCESS);
+	DAT_RETURN rc = DAT_SUCCESS;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-	    if (!DT_disco_event_wait ( phead, conn->cr_evd, NULL ))
+	if (conn->ep_handle) {
+		if (conn->connected) {
+			rc = dat_ep_disconnect(conn->ep_handle,
+					       DAT_CLOSE_DEFAULT);
+			DT_assert_clean(phead, rc == DAT_SUCCESS);
 
-	    {
-		DT_Tdep_PT_Printf (phead, "DT_fft_destroy_conn_struct: bad disconnect event\n");
-	    }
+			if (!DT_disco_event_wait(phead, conn->cr_evd, NULL))
+			{
+				DT_Tdep_PT_Printf(phead,
+						  "DT_fft_destroy_conn_struct: bad disconnect event\n");
+			}
+		}
+		rc = dat_ep_free(conn->ep_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
 	}
-	rc = dat_ep_free (conn->ep_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->bpool)
-    {
-	DT_Bpool_Destroy (0, phead, conn->bpool);
-    }
-    if (conn->psp_handle)
-    {
-	rc = dat_psp_free (conn->psp_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->cr_evd)
-    {
-	rc = DT_Tdep_evd_free (conn->cr_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->conn_evd)
-    {
-	rc = DT_Tdep_evd_free (conn->conn_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->send_evd)
-    {
-	rc = DT_Tdep_evd_free (conn->send_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->recv_evd)
-    {
-	rc = DT_Tdep_evd_free (conn->recv_evd);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->pt_ptr)
-    {
-	DT_Free_Per_Test_Data (conn->pt_ptr);
-    }
-    if (conn->pz_handle)
-    {
-	rc = dat_pz_free (conn->pz_handle);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    if (conn->ia_handle)
-    {
-	rc = dat_ia_close (conn->ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-	DT_assert_clean (phead, rc == DAT_SUCCESS);
-    }
-    return rc;
+	if (conn->bpool) {
+		DT_Bpool_Destroy(0, phead, conn->bpool);
+	}
+	if (conn->psp_handle) {
+		rc = dat_psp_free(conn->psp_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn->cr_evd) {
+		rc = DT_Tdep_evd_free(conn->cr_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn->conn_evd) {
+		rc = DT_Tdep_evd_free(conn->conn_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn->send_evd) {
+		rc = DT_Tdep_evd_free(conn->send_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn->recv_evd) {
+		rc = DT_Tdep_evd_free(conn->recv_evd);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn->pt_ptr) {
+		DT_Free_Per_Test_Data(conn->pt_ptr);
+	}
+	if (conn->pz_handle) {
+		rc = dat_pz_free(conn->pz_handle);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	if (conn->ia_handle) {
+		rc = dat_ia_close(conn->ia_handle, DAT_CLOSE_ABRUPT_FLAG);
+		DT_assert_clean(phead, rc == DAT_SUCCESS);
+	}
+	return rc;
 }
 
 /* helper function to init a dat "server" */
-void DT_fft_init_server (Params_t *params_ptr, FFT_Cmd_t *cmd, FFT_Connection_t *conn)
+void DT_fft_init_server(Params_t * params_ptr, FFT_Cmd_t * cmd,
+			FFT_Connection_t * conn)
 {
-    int res;
-    DAT_RETURN rc=0;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	int res;
+	DAT_RETURN rc = 0;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    /* init the connection struct's members */
-    DT_fft_init_conn_struct (conn);
+	/* init the connection struct's members */
+	DT_fft_init_conn_struct(conn);
 
-    /* open the IA */
-    rc = DT_ia_open (cmd->device_name, &conn->ia_handle);
-    DT_assert_dat (phead, rc ==  DAT_SUCCESS);
+	/* open the IA */
+	rc = DT_ia_open(cmd->device_name, &conn->ia_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* create a PZ */
-    rc = dat_pz_create (conn->ia_handle, &conn->pz_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* create a PZ */
+	rc = dat_pz_create(conn->ia_handle, &conn->pz_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* create an EP and its EVDs */
-    rc =DT_ep_create (params_ptr, 
-	    	      conn->ia_handle, 
-		      conn->pz_handle, 
-		      &conn->cr_evd,
-		      &conn->conn_evd, 
-		      &conn->send_evd, 
-		      &conn->recv_evd,
-		      &conn->ep_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* create an EP and its EVDs */
+	rc = DT_ep_create(params_ptr,
+			  conn->ia_handle,
+			  conn->pz_handle,
+			  &conn->cr_evd,
+			  &conn->conn_evd,
+			  &conn->send_evd, &conn->recv_evd, &conn->ep_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* create a PSP */
-    rc = dat_psp_create (conn->ia_handle, SERVER_PORT_NUMBER, conn->cr_evd,
-		DAT_PSP_CONSUMER_FLAG, &conn->psp_handle);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* create a PSP */
+	rc = dat_psp_create(conn->ia_handle, SERVER_PORT_NUMBER, conn->cr_evd,
+			    DAT_PSP_CONSUMER_FLAG, &conn->psp_handle);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* allocate memory for buffers */
-    conn->bpool = DT_BpoolAlloc (0, phead, conn->ia_handle, conn->pz_handle, NULL, NULL,
-	    8192, 2, DAT_OPTIMAL_ALIGNMENT, false, false);
-    DT_assert (phead, conn->bpool);
-cleanup:
-    return;
+	/* allocate memory for buffers */
+	conn->bpool =
+	    DT_BpoolAlloc(0, phead, conn->ia_handle, conn->pz_handle, NULL,
+			  NULL, 8192, 2, DAT_OPTIMAL_ALIGNMENT, false, false);
+	DT_assert(phead, conn->bpool);
+      cleanup:
+	return;
 }
 
 /* helper function that allows a server to listen for a connection */
-void DT_fft_listen (Params_t *params_ptr, FFT_Connection_t *conn)
+void DT_fft_listen(Params_t * params_ptr, FFT_Connection_t * conn)
 {
-    int res;
-    DAT_RETURN rc=0;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	int res;
+	DAT_RETURN rc = 0;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    /* wait on a CR event via the CR EVD */
-    DT_assert_dat (phead, DT_cr_event_wait (phead, conn->cr_evd, &conn->cr_stat) &&
-	    DT_cr_check (phead, 
-			 &conn->cr_stat, 
-			 conn->psp_handle, 
-			 SERVER_PORT_NUMBER,
-			 &conn->cr_handle, 
-			 "DT_fft_listen"));
+	/* wait on a CR event via the CR EVD */
+	DT_assert_dat(phead,
+		      DT_cr_event_wait(phead, conn->cr_evd, &conn->cr_stat)
+		      && DT_cr_check(phead, &conn->cr_stat, conn->psp_handle,
+				     SERVER_PORT_NUMBER, &conn->cr_handle,
+				     "DT_fft_listen"));
 
-    /* accept the connection */
-    rc =dat_cr_accept (conn->cr_handle, conn->ep_handle, 0, (DAT_PVOID)0);
-    DT_assert_dat (phead, rc == DAT_SUCCESS);
+	/* accept the connection */
+	rc = dat_cr_accept(conn->cr_handle, conn->ep_handle, 0, (DAT_PVOID) 0);
+	DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-    /* wait on a conn event via the conn EVD */
-    DT_assert (phead, 
-	       DT_conn_event_wait (phead, 
-		   		   conn->ep_handle, 
-				   conn->conn_evd,
-				   &conn->event_num) == true);
-    conn->connected = true;
-cleanup:
-    return;
+	/* wait on a conn event via the conn EVD */
+	DT_assert(phead,
+		  DT_conn_event_wait(phead,
+				     conn->ep_handle,
+				     conn->conn_evd, &conn->event_num) == true);
+	conn->connected = true;
+      cleanup:
+	return;
 }
 
 /* helper function that allows a client to connect to a server */
-int DT_fft_connect (Params_t *params_ptr, FFT_Connection_t *conn)
+int DT_fft_connect(Params_t * params_ptr, FFT_Connection_t * conn)
 {
-    int wait_count;
-    int res;
-    DAT_RETURN rc=0;
-    DT_Tdep_Print_Head *phead;
-    phead = params_ptr->phead;
+	int wait_count;
+	int res;
+	DAT_RETURN rc = 0;
+	DT_Tdep_Print_Head *phead;
+	phead = params_ptr->phead;
 
-    /* try 10 times to connect */
-    for (wait_count = 0; wait_count < 10; wait_count++)
-    {
-	DT_Tdep_PT_Printf (phead, "Connection to server, attempt #%d\n", wait_count+1);
+	/* try 10 times to connect */
+	for (wait_count = 0; wait_count < 10; wait_count++) {
+		DT_Tdep_PT_Printf(phead, "Connection to server, attempt #%d\n",
+				  wait_count + 1);
 
-	/* attempt to connect, timeout = 10 secs */
-	rc = dat_ep_connect (conn->ep_handle, conn->remote_netaddr,
-		    SERVER_PORT_NUMBER, 10*1000000, 0, (DAT_PVOID)0,
-		    DAT_QOS_BEST_EFFORT, DAT_CONNECT_DEFAULT_FLAG);
-	DT_assert_dat (phead, rc == DAT_SUCCESS);
+		/* attempt to connect, timeout = 10 secs */
+		rc = dat_ep_connect(conn->ep_handle, conn->remote_netaddr,
+				    SERVER_PORT_NUMBER, 10 * 1000000, 0,
+				    (DAT_PVOID) 0, DAT_QOS_BEST_EFFORT,
+				    DAT_CONNECT_DEFAULT_FLAG);
+		DT_assert_dat(phead, rc == DAT_SUCCESS);
 
-	/* wait on conn event */
-	DT_assert (phead, 
-		   DT_conn_event_wait (phead, 
-		       		       conn->ep_handle, 
-				       conn->conn_evd,
-				       &conn->event_num) == true);
+		/* wait on conn event */
+		DT_assert(phead,
+			  DT_conn_event_wait(phead,
+					     conn->ep_handle,
+					     conn->conn_evd,
+					     &conn->event_num) == true);
 
-	/* make sure we weren't rejected by the peer */
-	if (conn->event_num == DAT_CONNECTION_EVENT_PEER_REJECTED)
-	{
-	    DT_Mdep_Sleep (1000);
-	    DT_Tdep_PT_Printf (phead, "Connection rejected by peer; retrying\n");
+		/* make sure we weren't rejected by the peer */
+		if (conn->event_num == DAT_CONNECTION_EVENT_PEER_REJECTED) {
+			DT_Mdep_Sleep(1000);
+			DT_Tdep_PT_Printf(phead,
+					  "Connection rejected by peer; retrying\n");
+		}
 	}
-    }
-cleanup:
-    if (conn->event_num == DAT_CONNECTION_EVENT_ESTABLISHED)
-    {
-	conn->connected = true;
-    }
-    /* returns true if connected, false otherwise */
-    return (conn->connected);
+      cleanup:
+	if (conn->event_num == DAT_CONNECTION_EVENT_ESTABLISHED) {
+		conn->connected = true;
+	}
+	/* returns true if connected, false otherwise */
+	return (conn->connected);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_limit.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_limit.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_limit.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,30 +34,27 @@
  * Increase the size of an array of handles
  */
 
-static bool
-more_handles (DT_Tdep_Print_Head *phead,
-	     void **old_ptrptr,	/* pointer to current pointer	*/
-	     unsigned int *old_count,	/* number  pointed to	     	*/
-	     unsigned int size)		/* size of one datum		*/
-{
-    unsigned int count	     = *old_count;
-    void *old_handles = *old_ptrptr;
-    void *handle_tmp  = DT_Mdep_Malloc (count * 2 * size);
+static bool more_handles(DT_Tdep_Print_Head * phead, DAT_HANDLE ** old_ptrptr,	/* pointer to current pointer   */
+			 unsigned int *old_count,	/* number  pointed to           */
+			 unsigned int size)
+{				/* size of one datum              */
+	unsigned int count = *old_count;
+	DAT_HANDLE *old_handles = *old_ptrptr;
+	DAT_HANDLE *handle_tmp = DT_Mdep_Malloc(count * 2 * size);
 
-    if (!handle_tmp)
-    {
-	DT_Tdep_PT_Printf (phead, "Out of memory for more DAT_HANDLEs\n");
-	return (false);
-    }
+	if (!handle_tmp) {
+		DT_Tdep_PT_Printf(phead,
+				  "Out of memory for more DAT_HANDLEs\n");
+		return (false);
+	}
 
-    memcpy (handle_tmp, old_handles, count*size);
-    DT_Mdep_Free (old_handles);
-    *old_ptrptr = handle_tmp;
-    *old_count  = count * 2;
-    return (true);
+	memcpy(handle_tmp, old_handles, count * size);
+	DT_Mdep_Free(old_handles);
+	*old_ptrptr = handle_tmp;
+	*old_count = count * 2;
+	return (true);
 }
 
-
 /*
  * Limit test workhorse.
  *
@@ -73,1475 +70,1467 @@
  *  increased (or at least different) stress on the DAPL.
  */
 static bool
-limit_test ( DT_Tdep_Print_Head *phead,
-	    Limit_Cmd_t *cmd,
-	    Limit_Index depth)
+limit_test(DT_Tdep_Print_Head * phead, Limit_Cmd_t * cmd, Limit_Index depth)
 {
-    DAT_EVD_HANDLE	conn_handle;
-    typedef struct obj_set
-    {
-	DAT_IA_HANDLE	ia_handle;
-	DAT_EVD_HANDLE	ia_async_handle;
-	DAT_PZ_HANDLE	pz_handle;
-	DAT_CNO_HANDLE	cno_handle;
-	DAT_EVD_HANDLE	evd_handle;
-	DAT_EP_HANDLE	ep_handle;
-	DAT_LMR_HANDLE	lmr_handle;
-	char * 		lmr_buffer;
-	DAT_LMR_CONTEXT	lmr_context;
-	DAT_RMR_HANDLE	rmr_handle;
-	DAT_RMR_CONTEXT	rmr_context;
-    } Obj_Set;
+	DAT_EVD_HANDLE conn_handle;
+	typedef struct obj_set {
+		DAT_IA_HANDLE ia_handle;
+		DAT_EVD_HANDLE ia_async_handle;
+		DAT_PZ_HANDLE pz_handle;
+		DAT_CNO_HANDLE cno_handle;
+		DAT_EVD_HANDLE evd_handle;
+		DAT_EP_HANDLE ep_handle;
+		DAT_LMR_HANDLE lmr_handle;
+		char *lmr_buffer;
+		DAT_LMR_CONTEXT lmr_context;
+		DAT_RMR_HANDLE rmr_handle;
+		DAT_RMR_CONTEXT rmr_context;
+	} Obj_Set;
 
-    Obj_Set *hdl_sets	    = (Obj_Set *) NULL;
-    bool     retval	    = false;
-    char    *module	    = "LimitTest";
+	Obj_Set *hdl_sets = (Obj_Set *) NULL;
+	bool retval = false;
+	char *module = "LimitTest";
 
 #if defined (WIN32)
-    /*
-     * The Windows compiler will not deal with complex definitions
-     * in macros, so create a variable here.
-     */
+	/*
+	 * The Windows compiler will not deal with complex definitions
+	 * in macros, so create a variable here.
+	 */
 #if defined (DAT_OS_WAIT_PROXY_AGENT_NULL)
 #undef DAT_OS_WAIT_PROXY_AGENT_NULL
 #endif
-    DAT_OS_WAIT_PROXY_AGENT DAT_OS_WAIT_PROXY_AGENT_NULL = {NULL, NULL};
+	DAT_OS_WAIT_PROXY_AGENT DAT_OS_WAIT_PROXY_AGENT_NULL = { NULL, NULL };
 #endif
 
-    DAT_RETURN	ret;
+	DAT_RETURN ret;
 
 #ifdef DFLT_QLEN
 #undef DFLT_QLEN
 #endif
 
-#   define DFLT_QLEN	  10	/* a small event queue size	*/
-#   define START_COUNT	1024	/* initial # handles		*/
-#   define DFLT_BUFFSZ	4096	/* default size for buffer	*/
+#   define DFLT_QLEN	  10	/* a small event queue size     */
+#   define START_COUNT	1024	/* initial # handles            */
+#   define DFLT_BUFFSZ	4096	/* default size for buffer      */
 #   define CONN_QUAL0	0xAffab1e
 
-    /* Allocate 'width' Obj_Sets */
-    if (depth && ! (hdl_sets = DT_Mdep_Malloc (sizeof (Obj_Set) * cmd->width)))
-    {
-	DT_Tdep_PT_Printf (phead, "%s: No memory for handle array!\n", module);
-	goto clean_up_now;
-    }
-
-    /* -----------
-     * IA handling
-     */
-    if (depth > LIM_IA)
-    {
-	/*
-	 * The abuse is not for us this time, just prep Obj_Set.
-	 */
-	unsigned int w;
-
-	DT_Tdep_PT_Debug (1, (phead,
-		       "%s: dat_ia_open X %d\n", 
-		       module, 
-		       cmd->width));
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    /* Specify that we want to get back an async EVD.  */
-	    hdl_sets[w].ia_async_handle = DAT_HANDLE_NULL;
-	    ret = dat_ia_open (cmd->device_name,
-			      DFLT_QLEN,
-			      &hdl_sets[w].ia_async_handle,
-			      &hdl_sets[w].ia_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_ia_open (%s) #%d fails: %s\n",
-				module,  cmd->device_name,
-				w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		hdl_sets[w].ia_async_handle = DAT_HANDLE_NULL;
-		hdl_sets[w].ia_handle = DAT_HANDLE_NULL;
+	/* Allocate 'width' Obj_Sets */
+	if (depth && !(hdl_sets = DT_Mdep_Malloc(sizeof(Obj_Set) * cmd->width))) {
+		DT_Tdep_PT_Printf(phead, "%s: No memory for handle array!\n",
+				  module);
 		goto clean_up_now;
-	    }
 	}
-    }
-    else if (depth == LIM_IA)
-    {
-	/*
-	 * See how many IAs we can create
+
+	/* -----------
+	 * IA handling
 	 */
-	typedef struct _ia
-	{
-	    DAT_IA_HANDLE   ia_handle;
-	    DAT_EVD_HANDLE  ia_async_handle;
-	}
-	OneOpen;
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc (count * sizeof(OneOpen));
-	OneOpen	*hdlptr	= (OneOpen *)hptr;
+	if (depth > LIM_IA) {
+		/*
+		 * The abuse is not for us this time, just prep Obj_Set.
+		 */
+		unsigned int w;
 
-	/* IA Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
-
-	    DT_Tdep_PT_Debug (1,(phead, "%s: Exhausting dat_ia_open\n", module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles (phead, &hptr, &count, sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: IAs opened: %d\n", module, w);
-		    retval = true;
-		    break;
+		DT_Tdep_PT_Debug(1, (phead,
+				     "%s: dat_ia_open X %d\n",
+				     module, cmd->width));
+		for (w = 0; w < cmd->width; w++) {
+			/* Specify that we want to get back an async EVD.  */
+			hdl_sets[w].ia_async_handle = DAT_HANDLE_NULL;
+			ret = dat_ia_open(cmd->device_name,
+					  DFLT_QLEN,
+					  &hdl_sets[w].ia_async_handle,
+					  &hdl_sets[w].ia_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_ia_open (%s) #%d fails: %s\n",
+						  module, cmd->device_name,
+						  w + 1, DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				hdl_sets[w].ia_async_handle = DAT_HANDLE_NULL;
+				hdl_sets[w].ia_handle = DAT_HANDLE_NULL;
+				goto clean_up_now;
+			}
 		}
-		hdlptr	= (OneOpen *)hptr;
-		/* Specify that we want to get back an async EVD.  */
-		hdlptr[w].ia_async_handle = DAT_HANDLE_NULL;
-		ret = dat_ia_open (cmd->device_name,
-				  DFLT_QLEN,
-				  &hdlptr[w].ia_async_handle,
-				  &hdlptr[w].ia_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ia_open (%s) #%d fails: %s\n",
-				    module,  cmd->device_name,
-				    w+1,  DT_RetToString (ret));
-		    retval = true;
-		    break;
-		}
-	    }
+	} else if (depth == LIM_IA) {
+		/*
+		 * See how many IAs we can create
+		 */
+		typedef struct _ia {
+			DAT_IA_HANDLE ia_handle;
+			DAT_EVD_HANDLE ia_async_handle;
+		} OneOpen;
+		unsigned int count = START_COUNT;
+		OneOpen *hdlptr = (OneOpen *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
 
-	    DT_Tdep_PT_Printf (phead, "%s: IAs opened: %d\n", module, w);
-	    retval = true;
+		/* IA Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    /* IA Cleanup loop */
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();
-		ret = dat_ia_close (hdlptr[tmp].ia_handle,
-				    DAT_CLOSE_GRACEFUL_FLAG);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ia_close (graceful) fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
-		    ret = dat_ia_close (hdlptr[tmp].ia_handle,
-					DAT_CLOSE_ABRUPT_FLAG);
-		    if (ret != DAT_SUCCESS)
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: dat_ia_close (abrupt) fails: %s\n",
-					module,  DT_RetToString (ret));
-		    }
+			DT_Tdep_PT_Debug(1,
+					 (phead, "%s: Exhausting dat_ia_open\n",
+					  module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: IAs opened: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				/* Specify that we want to get back an async EVD.  */
+				hdlptr[w].ia_async_handle = DAT_HANDLE_NULL;
+				ret = dat_ia_open(cmd->device_name,
+						  DFLT_QLEN,
+						  &hdlptr[w].ia_async_handle,
+						  &hdlptr[w].ia_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ia_open (%s) #%d fails: %s\n",
+							  module,
+							  cmd->device_name,
+							  w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					break;
+				}
+			}
+
+			DT_Tdep_PT_Printf(phead, "%s: IAs opened: %d\n", module,
+					  w);
+			retval = true;
+
+			/* IA Cleanup loop */
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = dat_ia_close(hdlptr[tmp].ia_handle,
+						   DAT_CLOSE_GRACEFUL_FLAG);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ia_close (graceful) fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+					ret =
+					    dat_ia_close(hdlptr[tmp].ia_handle,
+							 DAT_CLOSE_ABRUPT_FLAG);
+					if (ret != DAT_SUCCESS) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: dat_ia_close (abrupt) fails: %s\n",
+								  module,
+								  DT_RetToString
+								  (ret));
+					}
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End IA handling */
 
-    /* -----------
-     * PZ handling
-     */
-    if (depth > LIM_PZ)
-    {
-	/*
-	 * The abuse is not for us this time, just prep Obj_Set.
+	/* End IA handling */
+	/* -----------
+	 * PZ handling
 	 */
-	unsigned int w;
+	if (depth > LIM_PZ) {
+		/*
+		 * The abuse is not for us this time, just prep Obj_Set.
+		 */
+		unsigned int w;
 
-	DT_Tdep_PT_Debug (1,(phead, 
-		       "%s: dat_pz_create X %d\n", 
-		       module, 
-		       cmd->width));
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    ret = dat_pz_create (hdl_sets[w].ia_handle,
-				&hdl_sets[w].pz_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_pz_create #%d fails: %s\n",
-				module,  w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		hdl_sets[w].pz_handle = DAT_HANDLE_NULL;
-		goto clean_up_now;
-	    }
-	}
-    }
-    else if (depth == LIM_PZ)
-    {
-	/*
-	 * See how many PZs we can create
-	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc (count * sizeof(DAT_PZ_HANDLE));
-	DAT_PZ_HANDLE *hdlptr = (DAT_PZ_HANDLE *)hptr;
+		DT_Tdep_PT_Debug(1, (phead,
+				     "%s: dat_pz_create X %d\n",
+				     module, cmd->width));
+		for (w = 0; w < cmd->width; w++) {
+			ret = dat_pz_create(hdl_sets[w].ia_handle,
+					    &hdl_sets[w].pz_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_pz_create #%d fails: %s\n",
+						  module, w + 1,
+						  DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				hdl_sets[w].pz_handle = DAT_HANDLE_NULL;
+				goto clean_up_now;
+			}
+		}
+	} else if (depth == LIM_PZ) {
+		/*
+		 * See how many PZs we can create
+		 */
+		unsigned int count = START_COUNT;
+		DAT_PZ_HANDLE *hdlptr = (DAT_PZ_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
 
-	/* PZ Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
+		/* PZ Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    DT_Tdep_PT_Debug (1,(phead, 
-			   "%s: Exhausting dat_pz_create\n", 
-			   module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles(phead, &hptr, &count, sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: PZs created: %d\n", module, w);
-		    retval = true;
-		    break;
-		}
-		hdlptr = (DAT_PZ_HANDLE *)hptr;
-		ret = dat_pz_create (hdl_sets[w % cmd->width].ia_handle,
-				    &hdlptr[w]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_pz_create #%d fails: %s\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    retval = true;
-		    break;
-		}
-	    }
+			DT_Tdep_PT_Debug(1, (phead,
+					     "%s: Exhausting dat_pz_create\n",
+					     module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: PZs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				ret =
+				    dat_pz_create(hdl_sets[w % cmd->width].
+						  ia_handle, &hdlptr[w]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_pz_create #%d fails: %s\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					break;
+				}
+			}
 
-	    DT_Tdep_PT_Printf (phead, "%s: PZs created: %d\n", module, w);
-	    retval = true;
+			DT_Tdep_PT_Printf(phead, "%s: PZs created: %d\n",
+					  module, w);
+			retval = true;
 
-	    /* PZ Cleanup loop */
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();
-		ret = dat_pz_free (hdlptr[tmp]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_pz_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+			/* PZ Cleanup loop */
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = dat_pz_free(hdlptr[tmp]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_pz_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End PZ handling */
-
+	/* End PZ handling */
 #ifndef __KDAPLTEST__
-    /* -----------
-     * CNO handling
-     */
-
-    if (depth > LIM_CNO)
-    {
-	/*
-	 * The abuse is not for us this time, just prep Obj_Set.
+	/* -----------
+	 * CNO handling
 	 */
-	unsigned int w;
 
-	DT_Tdep_PT_Debug (1,(phead,
-		       "%s: dat_cno_create X %d\n", 
-		       module, 
-		       cmd->width));
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    ret = dat_cno_create (hdl_sets[w].ia_handle,
-				DAT_OS_WAIT_PROXY_AGENT_NULL,
-				&hdl_sets[w].cno_handle);
-	    if (DAT_GET_TYPE (ret) == DAT_NOT_IMPLEMENTED)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_cno_create unimplemented\n", module);
-		hdl_sets[w].cno_handle = DAT_HANDLE_NULL;
-		/* ignore this error */
-		break;
-	    }
-	    else if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_cno_create #%d fails: %s\n",
-				module,  w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		hdl_sets[w].cno_handle = DAT_HANDLE_NULL;
-		goto clean_up_now;
-	    }
-	}
-    }
-    else if (depth == LIM_CNO)
-    {
-	/*
-	 * See how many CNOs we can create
-	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc (count * sizeof(DAT_CNO_HANDLE));
-	DAT_CNO_HANDLE *hdlptr = (DAT_CNO_HANDLE *)hptr;
-				    
-	/* CNO Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
+	if (depth > LIM_CNO) {
+		/*
+		 * The abuse is not for us this time, just prep Obj_Set.
+		 */
+		unsigned int w;
 
-	    DT_Tdep_PT_Debug (1,(phead, 
-			   "%s: Exhausting dat_cno_create\n",
-			   module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles(phead, &hptr, &count, sizeof (*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: CNOs created: %d\n", module, w);
-		    retval = true;
-		    break;
+		DT_Tdep_PT_Debug(1, (phead,
+				     "%s: dat_cno_create X %d\n",
+				     module, cmd->width));
+		for (w = 0; w < cmd->width; w++) {
+			ret = dat_cno_create(hdl_sets[w].ia_handle,
+					     DAT_OS_WAIT_PROXY_AGENT_NULL,
+					     &hdl_sets[w].cno_handle);
+			if (DAT_GET_TYPE(ret) == DAT_NOT_IMPLEMENTED) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_cno_create unimplemented\n",
+						  module);
+				hdl_sets[w].cno_handle = DAT_HANDLE_NULL;
+				/* ignore this error */
+				break;
+			} else if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_cno_create #%d fails: %s\n",
+						  module, w + 1,
+						  DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				hdl_sets[w].cno_handle = DAT_HANDLE_NULL;
+				goto clean_up_now;
+			}
 		}
-		hdlptr = (DAT_CNO_HANDLE *)hptr;
-		ret = dat_cno_create (hdl_sets[w % cmd->width].ia_handle,
-				    DAT_OS_WAIT_PROXY_AGENT_NULL,
-				    &hdlptr[w]);
-		if (DAT_GET_TYPE (ret) == DAT_NOT_IMPLEMENTED)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_cno_create unimplemented\n",
-				    module);
-		    retval = true;
-		    break;
-		}
-		else if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_cno_create #%d fails: %s\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    retval = true;
-		    break;
-		}
-	    }
+	} else if (depth == LIM_CNO) {
+		/*
+		 * See how many CNOs we can create
+		 */
+		unsigned int count = START_COUNT;
+		DAT_CNO_HANDLE *hdlptr = (DAT_CNO_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
 
-	    DT_Tdep_PT_Printf (phead, "%s: CNOs created: %d\n", module, w);
-	    retval = true;
+		/* CNO Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    /* CNO Cleanup loop */
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();
-		ret = dat_cno_free (hdlptr[tmp]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_cno_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
-		}
-	    }
-	    DT_Mdep_Free (hdlptr);
-	}
-    } /* End CNO handling */
-#endif  /*  __KDAPLTEST__ */
+			DT_Tdep_PT_Debug(1, (phead,
+					     "%s: Exhausting dat_cno_create\n",
+					     module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: CNOs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				ret =
+				    dat_cno_create(hdl_sets[w % cmd->width].
+						   ia_handle,
+						   DAT_OS_WAIT_PROXY_AGENT_NULL,
+						   &hdlptr[w]);
+				if (DAT_GET_TYPE(ret) == DAT_NOT_IMPLEMENTED) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_cno_create unimplemented\n",
+							  module);
+					retval = true;
+					break;
+				} else if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_cno_create #%d fails: %s\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					break;
+				}
+			}
 
-    /* -----------
-     * EVD handling
-     */
-    if (depth > LIM_EVD)
-    {
-	/*
-	 * The abuse is not for us this time, just prep Obj_Set.
-	 */
-	unsigned int w=0;
-	DAT_EVD_FLAGS flags = (   DAT_EVD_DTO_FLAG
-			     /* | DAT_EVD_SOFTWARE_FLAG */
-				| DAT_EVD_CR_FLAG
-				| DAT_EVD_RMR_BIND_FLAG );  /* not ASYNC */
+			DT_Tdep_PT_Printf(phead, "%s: CNOs created: %d\n",
+					  module, w);
+			retval = true;
 
-	DT_Tdep_PT_Debug (1,(phead, 
-			     "%s: dat_evd_create X %d\n",
-			     module,
-			     cmd->width));
-	/*
-	 * First create a connection EVD to be used for EP creation
-	 */
+			/* CNO Cleanup loop */
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = dat_cno_free(hdlptr[tmp]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_cno_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			DT_Mdep_Free(hdlptr);
+		}
+	}			/* End CNO handling */
+#endif				/*  __KDAPLTEST__ */
 
-	ret = DT_Tdep_evd_create (hdl_sets[0].ia_handle,
-			      DFLT_QLEN,
-			      NULL,
-			      DAT_EVD_CONNECTION_FLAG,
-			      &conn_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "%s: conn dat_evd_create #%d fails: %s\n",
-			    module,  w+1,  DT_RetToString (ret));
-	    /* handle contents undefined on failure */
-	    conn_handle = DAT_HANDLE_NULL;
-	    goto clean_up_now;
-	}
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    ret = DT_Tdep_evd_create (hdl_sets[w].ia_handle,
-				DFLT_QLEN,
-				hdl_sets[w].cno_handle,
-				flags,
-				&hdl_sets[w].evd_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_evd_create #%d fails: %s\n",
-				module,  w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		hdl_sets[w].evd_handle = DAT_HANDLE_NULL;
-		goto clean_up_now;
-	    }
-	}
-    }
-    else if (depth == LIM_EVD)
-    {
-	/*
-	 * See how many EVDs we can create
+	/* -----------
+	 * EVD handling
 	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc(count * sizeof(DAT_EVD_HANDLE));
-	DAT_EVD_HANDLE *hdlptr = (DAT_EVD_HANDLE *)hptr;
-				    
-	DAT_EVD_FLAGS flags	= (   DAT_EVD_DTO_FLAG
-				    | DAT_EVD_RMR_BIND_FLAG
-				    | DAT_EVD_CR_FLAG);
+	if (depth > LIM_EVD) {
+		/*
+		 * The abuse is not for us this time, just prep Obj_Set.
+		 */
+		unsigned int w = 0;
+		DAT_EVD_FLAGS flags = (DAT_EVD_DTO_FLAG
+				       /* | DAT_EVD_SOFTWARE_FLAG */
+				       | DAT_EVD_CR_FLAG | DAT_EVD_RMR_BIND_FLAG);	/* not ASYNC */
 
-	/* EVD Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
+		DT_Tdep_PT_Debug(1, (phead,
+				     "%s: dat_evd_create X %d\n",
+				     module, cmd->width));
+		/*
+		 * First create a connection EVD to be used for EP creation
+		 */
 
-	    DT_Tdep_PT_Debug (1,(phead, 
-				 "%s: Exhausting dat_evd_create\n",
-				 module));
-	    /*
-	     * First create a connection EVD to be used for EP creation
-	     */
-	    ret = DT_Tdep_evd_create (hdl_sets[0].ia_handle,
-				  DFLT_QLEN,
-				  NULL,
-				  DAT_EVD_CONNECTION_FLAG,
-				  &conn_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: conn dat_evd_create #%d fails: %s\n",
-				module,  w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		conn_handle = DAT_HANDLE_NULL;
-	    }
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles(phead, &hptr, &count, sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: EVDs created: %d\n", module, w);
-		    retval = true;
-		    break;
+		ret = DT_Tdep_evd_create(hdl_sets[0].ia_handle,
+					 DFLT_QLEN,
+					 NULL,
+					 DAT_EVD_CONNECTION_FLAG, &conn_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: conn dat_evd_create #%d fails: %s\n",
+					  module, w + 1, DT_RetToString(ret));
+			/* handle contents undefined on failure */
+			conn_handle = DAT_HANDLE_NULL;
+			goto clean_up_now;
 		}
-		hdlptr = (DAT_EVD_HANDLE *)hptr;
-		ret = DT_Tdep_evd_create (hdl_sets[w % cmd->width].ia_handle,
-				    DFLT_QLEN,
-				    hdl_sets[w % cmd->width].cno_handle,
-				    flags,
-				    &hdlptr[w]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_evd_create #%d fails: %s\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    retval = true;
-		    break;
+		for (w = 0; w < cmd->width; w++) {
+			ret = DT_Tdep_evd_create(hdl_sets[w].ia_handle,
+						 DFLT_QLEN,
+						 hdl_sets[w].cno_handle,
+						 flags,
+						 &hdl_sets[w].evd_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_evd_create #%d fails: %s\n",
+						  module, w + 1,
+						  DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				hdl_sets[w].evd_handle = DAT_HANDLE_NULL;
+				goto clean_up_now;
+			}
 		}
-	    }
+	} else if (depth == LIM_EVD) {
+		/*
+		 * See how many EVDs we can create
+		 */
+		unsigned int count = START_COUNT;
+		DAT_EVD_HANDLE *hdlptr = (DAT_EVD_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
+		DAT_EVD_FLAGS flags = (DAT_EVD_DTO_FLAG
+				       | DAT_EVD_RMR_BIND_FLAG
+				       | DAT_EVD_CR_FLAG);
 
-	    DT_Tdep_PT_Printf (phead, "%s: EVDs created: %d\n", module, w);
-	    retval = true;
+		/* EVD Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    /* EVD Cleanup loop */
-	    if (conn_handle != DAT_HANDLE_NULL)
-	    {
-	        ret = DT_Tdep_evd_free (conn_handle);
-		conn_handle = DAT_HANDLE_NULL;
-	    }
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();    
-		ret = DT_Tdep_evd_free (hdlptr[tmp]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_evd_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+			DT_Tdep_PT_Debug(1, (phead,
+					     "%s: Exhausting dat_evd_create\n",
+					     module));
+			/*
+			 * First create a connection EVD to be used for EP creation
+			 */
+			ret = DT_Tdep_evd_create(hdl_sets[0].ia_handle,
+						 DFLT_QLEN,
+						 NULL,
+						 DAT_EVD_CONNECTION_FLAG,
+						 &conn_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: conn dat_evd_create #%d fails: %s\n",
+						  module, w + 1,
+						  DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				conn_handle = DAT_HANDLE_NULL;
+			}
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: EVDs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				ret =
+				    DT_Tdep_evd_create(hdl_sets[w % cmd->width].
+						       ia_handle, DFLT_QLEN,
+						       hdl_sets[w %
+								cmd->width].
+						       cno_handle, flags,
+						       &hdlptr[w]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_evd_create #%d fails: %s\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					break;
+				}
+			}
+
+			DT_Tdep_PT_Printf(phead, "%s: EVDs created: %d\n",
+					  module, w);
+			retval = true;
+
+			/* EVD Cleanup loop */
+			if (conn_handle != DAT_HANDLE_NULL) {
+				ret = DT_Tdep_evd_free(conn_handle);
+				conn_handle = DAT_HANDLE_NULL;
+			}
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = DT_Tdep_evd_free(hdlptr[tmp]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_evd_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End EVD handling */
 
-    /* -----------
-     * EP handling
-     */
-    if (depth > LIM_EP)
-    {
-	/*
-	 * The abuse is not for us this time, just prep Obj_Set.
+	/* End EVD handling */
+	/* -----------
+	 * EP handling
 	 */
-	unsigned int w;
+	if (depth > LIM_EP) {
+		/*
+		 * The abuse is not for us this time, just prep Obj_Set.
+		 */
+		unsigned int w;
 
-	DT_Tdep_PT_Debug (1,(phead,
-		        "%s: dat_ep_create X %d\n", 
-			module, 
-			cmd->width));
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    ret = dat_ep_create (hdl_sets[w].ia_handle,
-				hdl_sets[w].pz_handle,
-				hdl_sets[w].evd_handle,	/* recv	    */
-				hdl_sets[w].evd_handle,	/* request  */
-				conn_handle,		/* connect  */
-				(DAT_EP_ATTR *) NULL,
-				&hdl_sets[w].ep_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_ep_create #%d fails: %s\n",
-				module,  w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		hdl_sets[w].ep_handle = DAT_HANDLE_NULL;
-		goto clean_up_now;
-	    }
-	}
-    }
-    else if (depth == LIM_EP)
-    {
-	/*
-	 * See how many EPs we can create
-	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc(count * sizeof(DAT_EP_HANDLE));
-	DAT_EP_HANDLE *hdlptr = (DAT_EP_HANDLE *)hptr;
+		DT_Tdep_PT_Debug(1, (phead,
+				     "%s: dat_ep_create X %d\n",
+				     module, cmd->width));
+		for (w = 0; w < cmd->width; w++) {
+			ret = dat_ep_create(hdl_sets[w].ia_handle, hdl_sets[w].pz_handle, hdl_sets[w].evd_handle,	/* recv     */
+					    hdl_sets[w].evd_handle,	/* request  */
+					    conn_handle,	/* connect  */
+					    (DAT_EP_ATTR *) NULL,
+					    &hdl_sets[w].ep_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_ep_create #%d fails: %s\n",
+						  module, w + 1,
+						  DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				hdl_sets[w].ep_handle = DAT_HANDLE_NULL;
+				goto clean_up_now;
+			}
+		}
+	} else if (depth == LIM_EP) {
+		/*
+		 * See how many EPs we can create
+		 */
+		unsigned int count = START_COUNT;
+		DAT_EP_HANDLE *hdlptr = (DAT_EP_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
 
-	/* EP Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
+		/* EP Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    DT_Tdep_PT_Debug (1,(phead,"%s: Exhausting dat_ep_create\n", module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles(phead, &hptr, &count, sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: EPs created: %d\n", module, w);
-		    retval = true;
-		    break;
-		}
-		hdlptr = (DAT_EP_HANDLE *)hptr;
-		ret = dat_ep_create (hdl_sets[w % cmd->width].ia_handle,
-				    hdl_sets[w % cmd->width].pz_handle,
-				    hdl_sets[w % cmd->width].evd_handle,
-				    hdl_sets[w % cmd->width].evd_handle,
-				     conn_handle,		/* connect  */
-				    (DAT_EP_ATTR *) NULL,
-				    &hdlptr[w]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_create #%d fails: %s\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    retval = true;
-		    break;
-		}
-	    }
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "%s: Exhausting dat_ep_create\n",
+					  module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: EPs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				ret = dat_ep_create(hdl_sets[w % cmd->width].ia_handle, hdl_sets[w % cmd->width].pz_handle, hdl_sets[w % cmd->width].evd_handle, hdl_sets[w % cmd->width].evd_handle, conn_handle,	/* connect  */
+						    (DAT_EP_ATTR *) NULL,
+						    &hdlptr[w]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_create #%d fails: %s\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					break;
+				}
+			}
 
-	    DT_Tdep_PT_Printf (phead, "%s: EPs created: %d\n", module, w);
-	    retval = true;
+			DT_Tdep_PT_Printf(phead, "%s: EPs created: %d\n",
+					  module, w);
+			retval = true;
 
-	    /* EP Cleanup loop */
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();
-		ret = dat_ep_free (hdlptr[tmp]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+			/* EP Cleanup loop */
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = dat_ep_free(hdlptr[tmp]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End EP handling */
 
-    /* -----------
-     * RSP handling
-     *
-     * if (depth > LIM_RSP) {
-     *	    Since RSPs are not part of the Obj_Set,
-     *	    there's nothing to do.
-     * } else ...
-     */
-    if (depth == LIM_RSP)
-    {
-	/*
-	 * See how many RSPs we can create
+	/* End EP handling */
+	/* -----------
+	 * RSP handling
+	 *
+	 * if (depth > LIM_RSP) {
+	 *         Since RSPs are not part of the Obj_Set,
+	 *         there's nothing to do.
+	 * } else ...
 	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc(count * sizeof (DAT_RSP_HANDLE));
-	DAT_RSP_HANDLE *hdlptr	= (DAT_RSP_HANDLE *)hptr;
-	void *eptr = DT_Mdep_Malloc(count * sizeof (DAT_EP_HANDLE));			   
-	DAT_EP_HANDLE *epptr = (DAT_EP_HANDLE *)eptr;
+	if (depth == LIM_RSP) {
+		/*
+		 * See how many RSPs we can create
+		 */
+		unsigned int count = START_COUNT;
+		DAT_RSP_HANDLE *hdlptr = (DAT_RSP_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
+		DAT_EP_HANDLE *epptr = (DAT_EP_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*epptr));
 
-	/* RSP Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
+		/* RSP Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    DT_Tdep_PT_Debug (1,(phead,"%s: Exhausting dat_rsp_create\n", module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count)
-		{
-		    unsigned int count1 = count;
-		    unsigned int count2 = count;
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "%s: Exhausting dat_rsp_create\n",
+					  module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count) {
+					unsigned int count1 = count;
+					unsigned int count2 = count;
 
-		    if (!more_handles(phead, &hptr, &count1, sizeof(*hdlptr)))
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: RSPs created: %d\n", module, w);
-			retval = true;
-			break;
-		    }
-		    hdlptr = (DAT_RSP_HANDLE *)hptr;
-		    
-		    if (!more_handles (phead, &eptr, &count2, sizeof(*epptr)))
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: RSPs created: %d\n", module, w);
-			retval = true;
-			break;
-		    }
-		    epptr = (DAT_EP_HANDLE *)eptr;
-		    if (count1 != count2)
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: Mismatch in allocation of handle arrays at point %d\n",
-					module, w);
-			retval = true;
-			break;
-		    }
+					if (!more_handles
+					    (phead, (DAT_HANDLE **) & hdlptr,
+					     &count1, sizeof(*hdlptr))) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: RSPs created: %d\n",
+								  module, w);
+						retval = true;
+						break;
+					}
+					if (!more_handles
+					    (phead, (DAT_HANDLE **) & epptr,
+					     &count2, sizeof(*epptr))) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: RSPs created: %d\n",
+								  module, w);
+						retval = true;
+						break;
+					}
 
-		    count = count1;
-		}
+					if (count1 != count2) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: Mismatch in allocation of handle arrays at point %d\n",
+								  module, w);
+						retval = true;
+						break;
+					}
 
-		/*
-		 * Each RSP needs a unique EP, so create one first
-		 */
-		ret = dat_ep_create (hdl_sets[w % cmd->width].ia_handle,
-				    hdl_sets[w % cmd->width].pz_handle,
-				    hdl_sets[w % cmd->width].evd_handle,
-				    hdl_sets[w % cmd->width].evd_handle,
-				    conn_handle,
-				    (DAT_EP_ATTR *) NULL,
-				    &epptr[w]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_create #%d fails: %s testing RSPs\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    retval = true;
-		    break;
-		}
+					count = count1;
+				}
 
-		ret = dat_rsp_create (hdl_sets[w % cmd->width].ia_handle,
-				    CONN_QUAL0 + w,
-				    epptr[w],
-				    hdl_sets[w % cmd->width].evd_handle,
-				    &hdlptr[w]);
-		if (DAT_GET_TYPE (ret) == DAT_NOT_IMPLEMENTED)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_rsp_create unimplemented\n",
-				    module);
-		    /* ignore this error */
-		    retval = true;
-		    break;
-		}
-		else if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_rsp_create #%d fails: %s\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    /* Cleanup the EP; no-one else will.  */
-		    ret = dat_ep_free (epptr[w]);
-		    if (ret != DAT_SUCCESS)
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: dat_ep_free (internal cleanup @ #%d) fails: %s\n",
-					module, w+1, DT_RetToString (ret));
-		    }
-		    retval = true;
-		    break;
-		}
-	    }
+				/*
+				 * Each RSP needs a unique EP, so create one first
+				 */
+				ret =
+				    dat_ep_create(hdl_sets[w % cmd->width].
+						  ia_handle,
+						  hdl_sets[w %
+							   cmd->width].
+						  pz_handle,
+						  hdl_sets[w %
+							   cmd->width].
+						  evd_handle,
+						  hdl_sets[w %
+							   cmd->width].
+						  evd_handle, conn_handle,
+						  (DAT_EP_ATTR *) NULL,
+						  &epptr[w]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_create #%d fails: %s testing RSPs\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					break;
+				}
 
-	    DT_Tdep_PT_Printf (phead, "%s: RSPs created: %d\n", module, w);
-	    retval = true;
+				ret =
+				    dat_rsp_create(hdl_sets[w % cmd->width].
+						   ia_handle, CONN_QUAL0 + w,
+						   epptr[w],
+						   hdl_sets[w %
+							    cmd->width].
+						   evd_handle, &hdlptr[w]);
+				if (DAT_GET_TYPE(ret) == DAT_NOT_IMPLEMENTED) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_rsp_create unimplemented\n",
+							  module);
+					/* ignore this error */
+					retval = true;
+					break;
+				} else if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_rsp_create #%d fails: %s\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					/* Cleanup the EP; no-one else will.  */
+					ret = dat_ep_free(epptr[w]);
+					if (ret != DAT_SUCCESS) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: dat_ep_free (internal cleanup @ #%d) fails: %s\n",
+								  module, w + 1,
+								  DT_RetToString
+								  (ret));
+					}
+					retval = true;
+					break;
+				}
+			}
 
-	    /* RSP Cleanup loop */
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();
-		ret = dat_rsp_free (hdlptr[tmp]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_rsp_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+			DT_Tdep_PT_Printf(phead, "%s: RSPs created: %d\n",
+					  module, w);
+			retval = true;
+
+			/* RSP Cleanup loop */
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = dat_rsp_free(hdlptr[tmp]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_rsp_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+				/* Free EPs */
+				ret = dat_ep_free(epptr[tmp]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_free fails: %s for RSPs\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-		/* Free EPs */
-		ret = dat_ep_free (epptr[tmp]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_free fails: %s for RSPs\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
-		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End RSP handling */
 
-    /* -----------
-     * PSP handling
-     *
-     * if (depth > LIM_PSP) {
-     *	    Since PSPs are not part of the Obj_Set,
-     *	    there's nothing to do.
-     * } else ...
-     */
-    if (depth == LIM_PSP)
-    {
-	/*
-	 * See how many PSPs we can create
+	/* End RSP handling */
+	/* -----------
+	 * PSP handling
+	 *
+	 * if (depth > LIM_PSP) {
+	 *         Since PSPs are not part of the Obj_Set,
+	 *         there's nothing to do.
+	 * } else ...
 	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc (count * sizeof (DAT_PSP_HANDLE));
-	DAT_PSP_HANDLE *hdlptr	= (DAT_PSP_HANDLE *)hptr;
+	if (depth == LIM_PSP) {
+		/*
+		 * See how many PSPs we can create
+		 */
+		unsigned int count = START_COUNT;
+		DAT_PSP_HANDLE *hdlptr = (DAT_PSP_HANDLE *)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
 
-	/* PSP Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
+		/* PSP Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    DT_Tdep_PT_Debug (1,(phead,"%s: Exhausting dat_psp_create\n", module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();    
-		if (w == count
-		    && !more_handles (phead, &hptr, &count, sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: PSPs created: %d\n", module, w);
-		    retval = true;
-		    break;
-		}
-		hdlptr = (DAT_PSP_HANDLE *)hptr;
-		ret = dat_psp_create (hdl_sets[w % cmd->width].ia_handle,
-				    CONN_QUAL0 + w,
-				    hdl_sets[w % cmd->width].evd_handle,
-				    DAT_PSP_CONSUMER_FLAG,
-				    &hdlptr[w]);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_psp_create #%d fails: %s\n",
-				    module,  w+1,  DT_RetToString (ret));
-		    retval = true;
-		    hdlptr[w] = DAT_HANDLE_NULL;
-		    break;
-		}
-	    }
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "%s: Exhausting dat_psp_create\n",
+					  module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: PSPs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				ret =
+				    dat_psp_create(hdl_sets[w % cmd->width].
+						   ia_handle, CONN_QUAL0 + w,
+						   hdl_sets[w %
+							    cmd->width].
+						   evd_handle,
+						   DAT_PSP_CONSUMER_FLAG,
+						   &hdlptr[w]);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_psp_create #%d fails: %s\n",
+							  module, w + 1,
+							  DT_RetToString(ret));
+					retval = true;
+					hdlptr[w] = DAT_HANDLE_NULL;
+					break;
+				}
+			}
 
-	    DT_Tdep_PT_Printf (phead, "%s: PSPs created: %d\n", module, w);
-	    retval = true;
+			DT_Tdep_PT_Printf(phead, "%s: PSPs created: %d\n",
+					  module, w);
+			retval = true;
 
-	    /* PSP Cleanup loop */
-	    for (tmp = 0;  tmp < w;  tmp++)
-	    {
-		DT_Mdep_Schedule();
-		ret = dat_psp_free (hdlptr[tmp]);
-		if (DAT_GET_TYPE (ret) == DAT_NOT_IMPLEMENTED)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_psp_free unimplemented\n"
-				   "\tNB: Expect EVD+IA cleanup errors!\n",
-				   module);
-		    break;
+			/* PSP Cleanup loop */
+			for (tmp = 0; tmp < w; tmp++) {
+				DT_Mdep_Schedule();
+				ret = dat_psp_free(hdlptr[tmp]);
+				if (DAT_GET_TYPE(ret) == DAT_NOT_IMPLEMENTED) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_psp_free unimplemented\n"
+							  "\tNB: Expect EVD+IA cleanup errors!\n",
+							  module);
+					break;
+				} else if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_psp_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-		else if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_psp_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
-		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End PSP handling */
 
-    /* -----------
-     * LMR handling
-     */
-    if (depth > LIM_LMR)
-    {
-	/*
-	 * The abuse is not for us this time, just prep Obj_Set.
+	/* End PSP handling */
+	/* -----------
+	 * LMR handling
 	 */
-	unsigned int w;
+	if (depth > LIM_LMR) {
+		/*
+		 * The abuse is not for us this time, just prep Obj_Set.
+		 */
+		unsigned int w;
 
-	DT_Tdep_PT_Debug (1,(phead,"%s: dat_lmr_create X %d\n", module, cmd->width));
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    DAT_REGION_DESCRIPTION  region;
-	    DAT_VLEN   		    reg_size;
-	    DAT_VADDR  		    reg_addr;
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: dat_lmr_create X %d\n", module,
+				  cmd->width));
+		for (w = 0; w < cmd->width; w++) {
+			DAT_REGION_DESCRIPTION region;
+			DAT_VLEN reg_size;
+			DAT_VADDR reg_addr;
 
-	    hdl_sets[w].lmr_buffer = DT_Mdep_Malloc (DFLT_BUFFSZ);
-	    if (!hdl_sets[w].lmr_buffer)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: no memory for LMR buffers\n", module);
-		goto clean_up_now;
-	    }
-	    memset (&region, 0, sizeof (region));
-	    region.for_va = hdl_sets[w].lmr_buffer;
+			hdl_sets[w].lmr_buffer = DT_Mdep_Malloc(DFLT_BUFFSZ);
+			if (!hdl_sets[w].lmr_buffer) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: no memory for LMR buffers\n",
+						  module);
+				goto clean_up_now;
+			}
+			memset(&region, 0, sizeof(region));
+			region.for_va = hdl_sets[w].lmr_buffer;
 
-	    ret = DT_Tdep_lmr_create (hdl_sets[w].ia_handle,
-				    DAT_MEM_TYPE_VIRTUAL,
-				    region,
-				    DFLT_BUFFSZ,
-				    hdl_sets[w].pz_handle,
-				    DAT_MEM_PRIV_ALL_FLAG,
-				    &hdl_sets[w].lmr_handle,
-				    &hdl_sets[w].lmr_context,
-				      NULL,	/* FIXME */
-				    &reg_size, &reg_addr);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_lmr_create #%d fails: %s\n",
-				module,  w+1,  DT_RetToString (ret));
-		/* handle contents undefined on failure */
-		hdl_sets[w].lmr_handle = DAT_HANDLE_NULL;
-		goto clean_up_now;
-	    }
-	    if ((uintptr_t)reg_addr > (uintptr_t)hdl_sets[w].lmr_buffer
-		|| (reg_size < DFLT_BUFFSZ + ((uintptr_t)reg_addr
-					- (uintptr_t)hdl_sets[w].lmr_buffer)))
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_lmr_create bogus outputs "
-				"in: 0x%p, %x out 0x%llx, %llx\n",
-				module,
-				hdl_sets[w].lmr_buffer, DFLT_BUFFSZ,
-				reg_addr, reg_size);
-		goto clean_up_now;
-	    }
-	}
-    }
-    else if (depth == LIM_LMR)
-    {
-	/*
-	 * See how many LMRs we can create
-	 */
-	unsigned int count = START_COUNT;
-	void *hptr = DT_Mdep_Malloc (count * sizeof(Bpool*)); 
-	Bpool **hdlptr = (Bpool **)hptr;
-				    
-	/* LMR Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w		= 0;
-	    unsigned int  tmp;
-
-	    DT_Tdep_PT_Debug (1,(phead,"%s: Exhausting dat_lmr_create\n", module));
-	    for (w = 0;  w < cmd->maximum;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles (phead, &hptr, &count, sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: no memory for LMR handles\n",
-					module);
-		    DT_Tdep_PT_Printf (phead, "%s: LMRs created: %d\n", module, w);
-		    retval = true;
-		    break;
+			ret = DT_Tdep_lmr_create(hdl_sets[w].ia_handle, DAT_MEM_TYPE_VIRTUAL, region, DFLT_BUFFSZ, hdl_sets[w].pz_handle, DAT_MEM_PRIV_ALL_FLAG, &hdl_sets[w].lmr_handle, &hdl_sets[w].lmr_context, NULL,	/* FIXME */
+						 &reg_size, &reg_addr);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_lmr_create #%d fails: %s\n",
+						  module, w + 1,
+						  DT_RetToString(ret));
+				/* handle contents undefined on failure */
+				hdl_sets[w].lmr_handle = DAT_HANDLE_NULL;
+				goto clean_up_now;
+			}
+			if ((uintptr_t) reg_addr >
+			    (uintptr_t) hdl_sets[w].lmr_buffer
+			    || (reg_size <
+				DFLT_BUFFSZ + ((uintptr_t) reg_addr -
+					       (uintptr_t) hdl_sets[w].
+					       lmr_buffer))) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_lmr_create bogus outputs "
+						  "in: 0x%p, %x out 0x%llx, %llx\n",
+						  module,
+						  hdl_sets[w].lmr_buffer,
+						  DFLT_BUFFSZ, reg_addr,
+						  reg_size);
+				goto clean_up_now;
+			}
 		}
-		hdlptr = (Bpool **)hptr;
+	} else if (depth == LIM_LMR) {
 		/*
-		 * Let BpoolAlloc do the hard work; this means that
-		 * we're testing unique memory registrations rather
-		 * than repeatedly binding the same buffer set.
+		 * See how many LMRs we can create
 		 */
-		hdlptr[w] = DT_BpoolAlloc ((Per_Test_Data_t *)0,
-					  phead,
-					  hdl_sets[w % cmd->width].ia_handle,
-					  hdl_sets[w % cmd->width].pz_handle,
-					  hdl_sets[w % cmd->width].ep_handle,
-					  hdl_sets[w % cmd->width].evd_handle,
-					  DFLT_BUFFSZ,
-					  1,
-					  DAT_OPTIMAL_ALIGNMENT,
-					  false,
-					  false);
-		if (!hdlptr[w])
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: LMRs created: %d\n", module, w);
-		    retval = true;
-		    break;
-		}
-	    }
+		unsigned int count = START_COUNT;
+		Bpool **hdlptr = (Bpool **)
+		    DT_Mdep_Malloc(count * sizeof(*hdlptr));
 
-	    DT_Tdep_PT_Printf (phead, "%s: LMRs created: %d\n", module, w);
-	    retval = true;
+		/* LMR Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int tmp;
 
-	    /* LMR Cleanup loop */
-	    for (tmp = 0;  tmp <= w;  tmp++)
-	    {
-		DT_Mdep_Schedule();    
-		if (hdlptr[tmp])
-		{
-		    /* ignore rval - DT_Bpool_Destroy will complain */
-		    (void) DT_Bpool_Destroy ((Per_Test_Data_t *)0, phead, hdlptr[tmp]);
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "%s: Exhausting dat_lmr_create\n",
+					  module));
+			for (w = 0; w < cmd->maximum; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count, sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: no memory for LMR handles\n",
+							  module);
+					DT_Tdep_PT_Printf(phead,
+							  "%s: LMRs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+				/*
+				 * Let BpoolAlloc do the hard work; this means that
+				 * we're testing unique memory registrations rather
+				 * than repeatedly binding the same buffer set.
+				 */
+				hdlptr[w] = DT_BpoolAlloc((Per_Test_Data_t *) 0,
+							  phead,
+							  hdl_sets[w %
+								   cmd->width].
+							  ia_handle,
+							  hdl_sets[w %
+								   cmd->width].
+							  pz_handle,
+							  hdl_sets[w %
+								   cmd->width].
+							  ep_handle,
+							  hdl_sets[w %
+								   cmd->width].
+							  evd_handle,
+							  DFLT_BUFFSZ, 1,
+							  DAT_OPTIMAL_ALIGNMENT,
+							  false, false);
+				if (!hdlptr[w]) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: LMRs created: %d\n",
+							  module, w);
+					retval = true;
+					break;
+				}
+			}
+
+			DT_Tdep_PT_Printf(phead, "%s: LMRs created: %d\n",
+					  module, w);
+			retval = true;
+
+			/* LMR Cleanup loop */
+			for (tmp = 0; tmp <= w; tmp++) {
+				DT_Mdep_Schedule();
+				if (hdlptr[tmp]) {
+					/* ignore rval - DT_Bpool_Destroy will complain */
+					(void)
+					    DT_Bpool_Destroy((Per_Test_Data_t *)
+							     0, phead,
+							     hdlptr[tmp]);
+				}
+			}
+			DT_Mdep_Free(hdlptr);
 		}
-	    }
-	    DT_Mdep_Free (hdlptr);
 	}
-    } /* End LMR handling */
 
-    /* -----------
-     * Posted receive buffer handling
-     */
-    if (depth == LIM_RPOST)
-    {
-	/*
-	 * See how many receive buffers we can post (to each EP).
-	 * We are posting the same buffer 'cnt' times, deliberately,
-	 * but that should be OK.
+	/* End LMR handling */
+	/* -----------
+	 * Posted receive buffer handling
 	 */
-	unsigned int count = START_COUNT;
-	void *hptr = 
-		DT_Mdep_Malloc(count * cmd->width * sizeof(DAT_LMR_TRIPLET));
-	DAT_LMR_TRIPLET *hdlptr	= (DAT_LMR_TRIPLET *)hptr;
+	if (depth == LIM_RPOST) {
+		/*
+		 * See how many receive buffers we can post (to each EP).
+		 * We are posting the same buffer 'cnt' times, deliberately,
+		 * but that should be OK.
+		 */
+		unsigned int count = START_COUNT;
+		DAT_LMR_TRIPLET *hdlptr = (DAT_LMR_TRIPLET *)
+		    DT_Mdep_Malloc(count * cmd->width * sizeof(*hdlptr));
 
-	/* Recv-Post Exhaustion test loop */
-	if (hdlptr)
-	{
-	    unsigned int  w	= 0;
-	    unsigned int  i  	= 0;
-	    unsigned int  done	= 0;
+		/* Recv-Post Exhaustion test loop */
+		if (hdlptr) {
+			unsigned int w = 0;
+			unsigned int i = 0;
+			unsigned int done = 0;
 
-	    DT_Tdep_PT_Debug (1,(phead,"%s: Exhausting posting of recv buffers\n", module));
-	    for (w = 0;  w < cmd->maximum && !done;  w++)
-	    {
-		DT_Mdep_Schedule();
-		if (w == count
-		    && !more_handles (phead, &hptr, &count,
-				    cmd->width * sizeof(*hdlptr)))
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: no memory for IOVs \n",
-					module);
-		    DT_Tdep_PT_Printf (phead, "%s: recv buffers posted per EP: %d\n"
-					"\t\t (total posted: %d)\n",
-					module,
-					w,
-					w * cmd->width);
-		    done = retval = true;
-		    break;
-		}
-		hdlptr = (DAT_LMR_TRIPLET *)hptr;
-		for (i = 0;  i < cmd->width;  i++)
-		{
-		    DAT_LMR_TRIPLET  *iovp = &hdlptr[w * cmd->width + i];
-		    DAT_DTO_COOKIE   cookie;
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "%s: Exhausting posting of recv buffers\n",
+					  module));
+			for (w = 0; w < cmd->maximum && !done; w++) {
+				DT_Mdep_Schedule();
+				if (w == count
+				    && !more_handles(phead,
+						     (DAT_HANDLE **) & hdlptr,
+						     &count,
+						     cmd->width *
+						     sizeof(*hdlptr))) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: no memory for IOVs \n",
+							  module);
+					DT_Tdep_PT_Printf(phead,
+							  "%s: recv buffers posted per EP: %d\n"
+							  "\t\t (total posted: %d)\n",
+							  module, w,
+							  w * cmd->width);
+					done = retval = true;
+					break;
+				}
+				for (i = 0; i < cmd->width; i++) {
+					DAT_LMR_TRIPLET *iovp =
+					    &hdlptr[w * cmd->width + i];
+					DAT_DTO_COOKIE cookie;
 
-		    iovp->virtual_address = (DAT_VADDR) (uintptr_t)
-							hdl_sets[i].lmr_buffer;
-		    iovp->segment_length  = DFLT_BUFFSZ;
-		    iovp->lmr_context	  = hdl_sets[i].lmr_context;
-		    cookie.as_64          = (DAT_UINT64)0UL;
-		    cookie.as_ptr         = (DAT_PVOID) hdl_sets[i].lmr_buffer;
+					iovp->virtual_address =
+					    (DAT_VADDR) (uintptr_t)
+					    hdl_sets[i].lmr_buffer;
+					iovp->segment_length = DFLT_BUFFSZ;
+					iovp->lmr_context =
+					    hdl_sets[i].lmr_context;
+					cookie.as_64 = (DAT_UINT64) 0UL;
+					cookie.as_ptr =
+					    (DAT_PVOID) hdl_sets[i].lmr_buffer;
 
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_post_recv #%d\n", module,
-					w * cmd->width + i + 1);
-		    ret = dat_ep_post_recv (hdl_sets[i].ep_handle,
-					   1,
-					   iovp,
-					   cookie,
-					   DAT_COMPLETION_DEFAULT_FLAG);
-		    if (ret != DAT_SUCCESS)
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: dat_ep_post_recv fails: %s\n",
-					module, DT_RetToString (ret));
-			DT_Tdep_PT_Printf (phead, "%s: recv buffers posted per EP: %d\n"
-					"\t\t (total posted: %d)\n",
-					module,
-					w,
-					w * cmd->width + i);
-			done = retval = true;
-			break;
-		    }
-		}   /* end for each EP wide */
-	    }	/* end forever (!done) loop */
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_post_recv #%d\n",
+							  module,
+							  w * cmd->width + i +
+							  1);
+					ret =
+					    dat_ep_post_recv(hdl_sets[i].
+							     ep_handle, 1, iovp,
+							     cookie,
+							     DAT_COMPLETION_DEFAULT_FLAG);
+					if (ret != DAT_SUCCESS) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: dat_ep_post_recv fails: %s\n",
+								  module,
+								  DT_RetToString
+								  (ret));
+						DT_Tdep_PT_Printf(phead,
+								  "%s: recv buffers posted per EP: %d\n"
+								  "\t\t (total posted: %d)\n",
+								  module, w,
+								  w *
+								  cmd->width +
+								  i);
+						done = retval = true;
+						break;
+					}
+				}	/* end for each EP wide */
+			}	/* end forever (!done) loop */
 
-	    retval = true;
-	    DT_Tdep_PT_Printf (phead, "%s: recv buffers posted per EP: %d\n"
-			    "\t\t (total posted: %d)\n",
-			    module,
-			    w,
-			    w * cmd->width);
+			retval = true;
+			DT_Tdep_PT_Printf(phead,
+					  "%s: recv buffers posted per EP: %d\n"
+					  "\t\t (total posted: %d)\n", module,
+					  w, w * cmd->width);
 
-	    /* Rpost Cleanup loop */
-	    for (i = 0;  i < cmd->width;  i++)
-	    {
-		DAT_EVENT       		event;
+			/* Rpost Cleanup loop */
+			for (i = 0; i < cmd->width; i++) {
+				DAT_EVENT event;
 
-		/*
-		 * Disconnecting an unconnected EP should complete
-		 * outstanding recv DTOs in error, and otherwise
-		 * be a no-op.
-		 */
-		ret = dat_ep_reset (hdl_sets[i].ep_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_disconnect (abrupt) fails: %s\n",
-				    module,  DT_RetToString (ret));
-		    retval = false;
-		}
-		else
-		{
-		    /*
-		     * Remove all DTOs. The disconnect above should have
-		     * flushed all posted operations, so this is just a
-		     * clean up.
-		     */
-		    do
-		    {
-			ret = DT_Tdep_evd_dequeue ( hdl_sets[i].evd_handle,
-					       &event);
-		    } while (ret == DAT_SUCCESS);
-		}
+				/*
+				 * Disconnecting an unconnected EP should complete
+				 * outstanding recv DTOs in error, and otherwise
+				 * be a no-op.
+				 */
+				ret = dat_ep_reset(hdl_sets[i].ep_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_disconnect (abrupt) fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				} else {
+					/*
+					 * Remove all DTOs. The disconnect above should have
+					 * flushed all posted operations, so this is just a
+					 * clean up.
+					 */
+					do {
+						ret =
+						    DT_Tdep_evd_dequeue(hdl_sets
+									[i].
+									evd_handle,
+									&event);
+					} while (ret == DAT_SUCCESS);
+				}
 
-	    }
-	    DT_Mdep_Free (hdlptr);
+			}
+			DT_Mdep_Free(hdlptr);
+		}
 	}
-    }	    /* end depth == LIM_RPOST */
 
-    /* -----------
-     * Test maximum size of LMR allowed
-     */
-    if (depth == LIM_SIZE_LMR)
-    {
-	DAT_COUNT    last_size	= 0;
-	DAT_COUNT    test_size	= DFLT_BUFFSZ;
-        Bpool	     *test_bpool;
-	for (;;)
-	{
-            DT_Mdep_Schedule();
-	    test_bpool = DT_BpoolAlloc ((Per_Test_Data_t *)0,
-		    			  phead,
-					  hdl_sets[0].ia_handle,
-					  hdl_sets[0].pz_handle,
-					  hdl_sets[0].ep_handle,
-					  hdl_sets[0].evd_handle,
-					  test_size,
-					  1,
-					  DAT_OPTIMAL_ALIGNMENT,
-					  false,
-					  false);
+	/* end depth == LIM_RPOST */
+	/* -----------
+	 * Test maximum size of LMR allowed
+	 */
+	if (depth == LIM_SIZE_LMR) {
+		DAT_COUNT last_size = 0;
+		DAT_COUNT test_size = DFLT_BUFFSZ;
+		Bpool *test_bpool;
+		for (;;) {
+			DT_Mdep_Schedule();
+			test_bpool = DT_BpoolAlloc((Per_Test_Data_t *) 0,
+						   phead,
+						   hdl_sets[0].ia_handle,
+						   hdl_sets[0].pz_handle,
+						   hdl_sets[0].ep_handle,
+						   hdl_sets[0].evd_handle,
+						   test_size,
+						   1,
+						   DAT_OPTIMAL_ALIGNMENT,
+						   false, false);
 
-	    if (!test_bpool)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: Largest LMR was 0x%x bytes\n"
-			       "\t (failed attempting 0x%x bytes)\n",
-			       module, last_size, test_size);
-		retval = true;
-		break;
-	    }
-	    else if (!DT_Bpool_Destroy ((Per_Test_Data_t *)0, phead, test_bpool))
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: Largest LMR was 0x%x bytes\n",
-			       module, test_size);
-		retval = true;
-		break;
-	    }
+			if (!test_bpool) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: Largest LMR was 0x%x bytes\n"
+						  "\t (failed attempting 0x%x bytes)\n",
+						  module, last_size, test_size);
+				retval = true;
+				break;
+			} else
+			    if (!DT_Bpool_Destroy
+				((Per_Test_Data_t *) 0, phead, test_bpool)) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: Largest LMR was 0x%x bytes\n",
+						  module, test_size);
+				retval = true;
+				break;
+			}
 
-	    last_size  = test_size;
-	    test_size <<= 1;
-	    if (test_size < last_size)
-	    {
-		/* could conceivably wrap on 32-bit architectures */
-		DT_Tdep_PT_Printf (phead, "%s: LMR of 0x%x bytes OK - %s\n",
-			       module, last_size, "stopping now.");
-		retval = true;
-		break;
-	    }
-	}   /* end forever loop */
-    }	    /* end depth == LIM_SIZE_LMR */
+			last_size = test_size;
+			test_size <<= 1;
+			if (test_size < last_size) {
+				/* could conceivably wrap on 32-bit architectures */
+				DT_Tdep_PT_Printf(phead,
+						  "%s: LMR of 0x%x bytes OK - %s\n",
+						  module, last_size,
+						  "stopping now.");
+				retval = true;
+				break;
+			}
+		}		/* end forever loop */
+	}
+	/* end depth == LIM_SIZE_LMR */
+	DT_Tdep_PT_Debug(1, (phead, "%s: Limit Testing Completed - %s\n",
+			     module, retval ? "Successfully" : "with errors"));
 
-    DT_Tdep_PT_Debug (1,(phead,"%s: Limit Testing Completed - %s\n",
-		    module,
-		    retval ? "Successfully" : "with errors"));
+	/* ----------------------------------------------------------
+	 * Clean up and go home
+	 */
+      clean_up_now:
 
-    /* ----------------------------------------------------------
-     * Clean up and go home
-     */
-clean_up_now:
+	DT_Tdep_PT_Debug(1, (phead, "%s: Cleaning up ...\n", module));
+	if (depth > LIM_LMR) {
+		unsigned int w;
 
-    DT_Tdep_PT_Debug (1,(phead,"%s: Cleaning up ...\n", module));
-    if (depth > LIM_LMR)
-    {
-	unsigned int  w;
-
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    if (hdl_sets[w].lmr_handle)
-	    {
-		ret = dat_lmr_free (hdl_sets[w].lmr_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_lmr_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+		for (w = 0; w < cmd->width; w++) {
+			if (hdl_sets[w].lmr_handle) {
+				ret = dat_lmr_free(hdl_sets[w].lmr_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_lmr_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+			if ((void *)hdl_sets[w].lmr_buffer) {
+				DT_Mdep_Free((void *)hdl_sets[w].lmr_buffer);
+			}
 		}
-	    }
-	    if ((void *) hdl_sets[w].lmr_buffer)
-	    {
-		DT_Mdep_Free ((void *) hdl_sets[w].lmr_buffer);
-	    }
 	}
-    }	/* end LIM_LMR cleanup */
 
-    /*
-     * if (depth == LIM_PSP) {
-     *	    Since PSPs are not part of the Obj_Set,
-     *	    there's no cleanup to do.
-     * }
-     *
-     * if (depth == LIM_RSP) {
-     *	    Since RSPs are not part of the Obj_Set,
-     *	    there'no cleanup nothing to do.
-     * }
-     */
+	/* end LIM_LMR cleanup */
+	/*
+	 * if (depth == LIM_PSP) {
+	 *         Since PSPs are not part of the Obj_Set,
+	 *         there's no cleanup to do.
+	 * }
+	 *
+	 * if (depth == LIM_RSP) {
+	 *         Since RSPs are not part of the Obj_Set,
+	 *         there'no cleanup nothing to do.
+	 * }
+	 */
+	if (depth > LIM_EP) {
+		unsigned int w;
 
-    if (depth > LIM_EP)
-    {
-	unsigned int  w;
-
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    if (hdl_sets[w].ep_handle)
-	    {
-		ret = dat_ep_free (hdl_sets[w].ep_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ep_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+		for (w = 0; w < cmd->width; w++) {
+			if (hdl_sets[w].ep_handle) {
+				ret = dat_ep_free(hdl_sets[w].ep_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ep_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
 		}
-	    }
 	}
-    }	/* end LIM_EP cleanup */
+	/* end LIM_EP cleanup */
+	if (depth > LIM_EVD) {
+		unsigned int w;
 
-    if (depth > LIM_EVD)
-    {
-	unsigned int  w;
-
-	if (conn_handle != DAT_HANDLE_NULL)
-	{
-	    ret = DT_Tdep_evd_free (conn_handle);
-	    conn_handle = DAT_HANDLE_NULL;
-	}
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    if (hdl_sets[w].evd_handle)
-	    {
-		ret = DT_Tdep_evd_free (hdl_sets[w].evd_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_evd_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+		if (conn_handle != DAT_HANDLE_NULL) {
+			ret = DT_Tdep_evd_free(conn_handle);
+			conn_handle = DAT_HANDLE_NULL;
 		}
-	    }
+		for (w = 0; w < cmd->width; w++) {
+			if (hdl_sets[w].evd_handle) {
+				ret = DT_Tdep_evd_free(hdl_sets[w].evd_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_evd_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
+		}
 	}
-    }	/* end LIM_EVD cleanup */
-
+	/* end LIM_EVD cleanup */
 #ifndef __KDAPLTEST__
-    if (depth > LIM_CNO)
-    {
-	unsigned int  w;
+	if (depth > LIM_CNO) {
+		unsigned int w;
 
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    if (hdl_sets[w].cno_handle)
-	    {
-		ret = dat_cno_free (hdl_sets[w].cno_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_cno_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+		for (w = 0; w < cmd->width; w++) {
+			if (hdl_sets[w].cno_handle) {
+				ret = dat_cno_free(hdl_sets[w].cno_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_cno_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
 		}
-	    }
-	}
-    }	/* end LIM_CNO cleanup */
+	}			/* end LIM_CNO cleanup */
 #endif
 
-    if (depth > LIM_PZ)
-    {
-	unsigned int  w;
+	if (depth > LIM_PZ) {
+		unsigned int w;
 
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    if (hdl_sets[w].pz_handle)
-	    {
-		ret = dat_pz_free (hdl_sets[w].pz_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_pz_free fails: %s\n",
-			    module,  DT_RetToString (ret));
-		    retval = false;
+		for (w = 0; w < cmd->width; w++) {
+			if (hdl_sets[w].pz_handle) {
+				ret = dat_pz_free(hdl_sets[w].pz_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_pz_free fails: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					retval = false;
+				}
+			}
 		}
-	    }
 	}
-    }	/* end LIM_PZ cleanup */
+	/* end LIM_PZ cleanup */
+	if (depth > LIM_IA) {
+		unsigned int w;
 
-    if (depth > LIM_IA)
-    {
-	unsigned int  w;
-
-	for (w = 0;  w < cmd->width;  w++)
-	{
-	    if (hdl_sets[w].ia_handle)
-	    {
-		/* dat_ia_close cleans up async evd handle, too */
-		ret = dat_ia_close (hdl_sets[w].ia_handle,
-				    DAT_CLOSE_GRACEFUL_FLAG);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "%s: dat_ia_close (graceful) error: %s\n",
-				module, DT_RetToString (ret));
-		    /*
-		     * Since we take some pains to clean up properly,
-		     * this really is an error.  But if we get here,
-		     * we may as well try the largest hammer we have.
-		     */
-		    retval = false;
-		    ret = dat_ia_close (hdl_sets[w].ia_handle,
-					DAT_CLOSE_ABRUPT_FLAG);
-		    if (ret != DAT_SUCCESS)
-		    {
-			DT_Tdep_PT_Printf (phead, "%s: dat_ia_close (abrupt) error: %s\n",
-					module, DT_RetToString (ret));
-		    }
+		for (w = 0; w < cmd->width; w++) {
+			if (hdl_sets[w].ia_handle) {
+				/* dat_ia_close cleans up async evd handle, too */
+				ret = dat_ia_close(hdl_sets[w].ia_handle,
+						   DAT_CLOSE_GRACEFUL_FLAG);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ia_close (graceful) error: %s\n",
+							  module,
+							  DT_RetToString(ret));
+					/*
+					 * Since we take some pains to clean up properly,
+					 * this really is an error.  But if we get here,
+					 * we may as well try the largest hammer we have.
+					 */
+					retval = false;
+					ret =
+					    dat_ia_close(hdl_sets[w].ia_handle,
+							 DAT_CLOSE_ABRUPT_FLAG);
+					if (ret != DAT_SUCCESS) {
+						DT_Tdep_PT_Printf(phead,
+								  "%s: dat_ia_close (abrupt) error: %s\n",
+								  module,
+								  DT_RetToString
+								  (ret));
+					}
+				}
+			}
 		}
-	    }
 	}
-    }	/* end LIM_IA cleanup */
+	/* end LIM_IA cleanup */
+	if (depth && hdl_sets) {
+		DT_Mdep_Free(hdl_sets);
+	}
 
-    if (depth && hdl_sets)
-    {
-	DT_Mdep_Free (hdl_sets);
-    }
+	DT_Tdep_PT_Debug(1,
+			 (phead, "%s: testing and cleanup complete.\n",
+			  module));
 
-    DT_Tdep_PT_Debug (1,(phead,"%s: testing and cleanup complete.\n", module));
-
-    return ( retval );
+	return (retval);
 }
 
-
 /*********************************************************************
  * Framework to run through all of the limit tests
  */
-void
-DT_cs_Limit (Params_t *params, Limit_Cmd_t * cmd)
+DAT_RETURN DT_cs_Limit(Params_t * params, Limit_Cmd_t * cmd)
 {
-    DT_Tdep_Print_Head	*phead;
-    char 		*star =
-	"**********************************************************************" ;
+	DT_Tdep_Print_Head *phead;
+	char *star =
+	    "**********************************************************************";
 
-    phead = params->phead;
+	phead = params->phead;
 
-    if (cmd->Test_List[ LIM_IA ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_ia\n"
-	    "Description:  Test max num of opens for the same physical IA"
-	}
-	;
+	if (cmd->Test_List[LIM_IA]) {
+		char list[] = {
+			"Limitation Test                      limit_ia\n"
+			    "Description:  Test max num of opens for the same physical IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_IA))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_IA)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_PZ ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_pz\n"
-	    "Description:  Test max num of PZs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_PZ]) {
+		char list[] = {
+			"Limitation Test                      limit_pz\n"
+			    "Description:  Test max num of PZs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_PZ))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_PZ)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
-
 #ifndef __KDAPLTEST__
-    if (cmd->Test_List[ LIM_CNO ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_cno\n"
-	    "Description:  Test max num of CNOs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_CNO]) {
+		char list[] = {
+			"Limitation Test                      limit_cno\n"
+			    "Description:  Test max num of CNOs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_CNO))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_CNO)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 #endif
 
-    if (cmd->Test_List[ LIM_EVD ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_evd\n"
-	    "Description:  Test max num of EVDs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_EVD]) {
+		char list[] = {
+			"Limitation Test                      limit_evd\n"
+			    "Description:  Test max num of EVDs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_EVD))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_EVD)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_EP ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_ep\n"
-	    "Description:  Test max num of EPs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_EP]) {
+		char list[] = {
+			"Limitation Test                      limit_ep\n"
+			    "Description:  Test max num of EPs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_EP))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_EP)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_RSP ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_rsp\n"
-	    "Description:  Test max num of RSPs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_RSP]) {
+		char list[] = {
+			"Limitation Test                      limit_rsp\n"
+			    "Description:  Test max num of RSPs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_RSP))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_RSP)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_PSP ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_psp\n"
-	    "Description:  Test max num of PSPs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_PSP]) {
+		char list[] = {
+			"Limitation Test                      limit_psp\n"
+			    "Description:  Test max num of PSPs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_PSP))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_PSP)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_LMR ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_lmr\n"
-	    "Description:  Test max num of LMRs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_LMR]) {
+		char list[] = {
+			"Limitation Test                      limit_lmr\n"
+			    "Description:  Test max num of LMRs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_LMR))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_LMR)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_RPOST ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_rpost\n"
-	    "Description:  Test max num of receive buffers posted to an EP"
-	}
-	;
+	if (cmd->Test_List[LIM_RPOST]) {
+		char list[] = {
+			"Limitation Test                      limit_rpost\n"
+			    "Description:  Test max num of receive buffers posted to an EP"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_RPOST))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_RPOST)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    if (cmd->Test_List[ LIM_SIZE_LMR ])
-    {
-	char list[] =
-	{
-	    "Limitation Test                      limit_size_lmr\n"
-	    "Description:  Test max size of LMRs that are supported by an IA"
-	}
-	;
+	if (cmd->Test_List[LIM_SIZE_LMR]) {
+		char list[] = {
+			"Limitation Test                      limit_size_lmr\n"
+			    "Description:  Test max size of LMRs that are supported by an IA"
+		}
+		;
 
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-	DT_Tdep_PT_Printf (phead, "%s\n", list);
-	if (!limit_test (phead, cmd, LIM_SIZE_LMR))
-	{
-	    goto error;
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
+		DT_Tdep_PT_Printf(phead, "%s\n", list);
+		if (!limit_test(phead, cmd, LIM_SIZE_LMR)) {
+			goto error;
+		}
+		DT_Tdep_PT_Printf(phead, "%s\n", star);
 	}
-	DT_Tdep_PT_Printf (phead, "%s\n", star);
-    }
 
-    /* More tests TBS ... */
+	/* More tests TBS ... */
 
-    return;
+	return DAT_SUCCESS;
 
-error:
-    DT_Tdep_PT_Printf (phead, "error occurs, can not continue with limit test\n");
-    DT_Tdep_PT_Printf (phead, "%s\n", star);
-    return;
+      error:
+	DT_Tdep_PT_Printf(phead,
+			  "error occurs, can not continue with limit test\n");
+	DT_Tdep_PT_Printf(phead, "%s\n", star);
+	return DAT_INSUFFICIENT_RESOURCES;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_memlist.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_memlist.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_memlist.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,111 +30,94 @@
 
 #include "dapl_proto.h"
 
-void
-DT_MemListInit (Per_Test_Data_t * pt_ptr)
+void DT_MemListInit(Per_Test_Data_t * pt_ptr)
 {
-    DT_Mdep_LockInit (&pt_ptr->MemListLock);
-    pt_ptr->MemListHead = 0;
+	DT_Mdep_LockInit(&pt_ptr->MemListLock);
+	pt_ptr->MemListHead = 0;
 }
 
-void           *
-DT_MemListAlloc (Per_Test_Data_t * pt_ptr,
-		 char *file,
-		 mem_type_e t,
-		 int size)
+void *DT_MemListAlloc(Per_Test_Data_t * pt_ptr,
+		      char *file, mem_type_e t, int size)
 {
-    void           *buffptr;
-    MemListEntry_t *entry_ptr;
-    buffptr = 0;
-    entry_ptr = 0;
+	void *buffptr;
+	MemListEntry_t *entry_ptr;
+	buffptr = 0;
+	entry_ptr = 0;
 
-    buffptr = DT_Mdep_Malloc (size);
-    if (buffptr == 0)
-    {
-	return 0;
-    }
-    if (pt_ptr == 0)	      /* not use mem_list */
-    {
-	return buffptr;
-    }
-    entry_ptr = (MemListEntry_t *) DT_Mdep_Malloc (sizeof (MemListEntry_t));
-    if (entry_ptr == 0)
-    {
-	DT_Mdep_Free (buffptr);
-	return 0;
-    }
-    strcpy (entry_ptr->filename, file);
-    entry_ptr->MemType = t;
-    entry_ptr->mem_ptr = buffptr;
+	buffptr = DT_Mdep_Malloc(size);
+	if (buffptr == 0) {
+		return 0;
+	}
+	if (pt_ptr == 0) {	/* not use mem_list */
+		return buffptr;
+	}
+	entry_ptr = (MemListEntry_t *) DT_Mdep_Malloc(sizeof(MemListEntry_t));
+	if (entry_ptr == 0) {
+		DT_Mdep_Free(buffptr);
+		return 0;
+	}
+	strcpy(entry_ptr->filename, file);
+	entry_ptr->MemType = t;
+	entry_ptr->mem_ptr = buffptr;
 
-    DT_Mdep_Lock (&pt_ptr->MemListLock);
-    entry_ptr->next = pt_ptr->MemListHead;
-    pt_ptr->MemListHead = entry_ptr;
-    DT_Mdep_Unlock (&pt_ptr->MemListLock);
+	DT_Mdep_Lock(&pt_ptr->MemListLock);
+	entry_ptr->next = pt_ptr->MemListHead;
+	pt_ptr->MemListHead = entry_ptr;
+	DT_Mdep_Unlock(&pt_ptr->MemListLock);
 
-    return buffptr;
+	return buffptr;
 }
 
-void
-DT_MemListFree (Per_Test_Data_t * pt_ptr, void *ptr)
+void DT_MemListFree(Per_Test_Data_t * pt_ptr, void *ptr)
 {
-    MemListEntry_t *pre, *cur;
-    if (pt_ptr == 0)	      /* not use mem_list */
-    {
-	DT_Mdep_Free (ptr);
-	return;
-    }
-    DT_Mdep_Lock (&pt_ptr->MemListLock);
-    pre = 0;
-    cur = pt_ptr->MemListHead;
-    while (cur)
-    {
-	if (cur->mem_ptr == ptr)
-	{
-	    if (!pre)	      /* first entry */
-	    {
-		pt_ptr->MemListHead = cur->next;
-		cur->next = 0;
-	    }
-	    else
-	    {
-		pre->next = cur->next;
-		cur->next = 0;
-	    }
-	    DT_Mdep_Free (ptr);
-	    DT_Mdep_Free (cur);
-	    goto unlock_and_return;
+	MemListEntry_t *pre, *cur;
+	if (pt_ptr == 0) {	/* not use mem_list */
+		DT_Mdep_Free(ptr);
+		return;
 	}
-	pre = cur;
-	cur = cur->next;
-    }
-unlock_and_return:
-    DT_Mdep_Unlock (&pt_ptr->MemListLock);
+	DT_Mdep_Lock(&pt_ptr->MemListLock);
+	pre = 0;
+	cur = pt_ptr->MemListHead;
+	while (cur) {
+		if (cur->mem_ptr == ptr) {
+			if (!pre) {	/* first entry */
+				pt_ptr->MemListHead = cur->next;
+				cur->next = 0;
+			} else {
+				pre->next = cur->next;
+				cur->next = 0;
+			}
+			DT_Mdep_Free(ptr);
+			DT_Mdep_Free(cur);
+			goto unlock_and_return;
+		}
+		pre = cur;
+		cur = cur->next;
+	}
+      unlock_and_return:
+	DT_Mdep_Unlock(&pt_ptr->MemListLock);
 }
 
-void
-DT_PrintMemList (Per_Test_Data_t * pt_ptr)
+void DT_PrintMemList(Per_Test_Data_t * pt_ptr)
 {
-    char           *type[10] =
-    {
-	"BPOOL", "BUFF", "PERTESTDATA", "NIC", "NETADDRESS",
-	"TRANSACTIONTEST", "THREAD", "EPCONTEXT"
-    };
-    DT_Tdep_Print_Head *phead;
-    MemListEntry_t *cur;
+	char *type[10] = {
+		"BPOOL", "BUFF", "PERTESTDATA", "NIC", "NETADDRESS",
+		"TRANSACTIONTEST", "THREAD", "EPCONTEXT"
+	};
+	DT_Tdep_Print_Head *phead;
+	MemListEntry_t *cur;
 
-    phead = pt_ptr->Params.phead;
-    DT_Mdep_Lock (&pt_ptr->MemListLock);
-    cur = pt_ptr->MemListHead;
-    if (cur != 0)
-    {
-	DT_Tdep_PT_Printf (phead, "the allocated memory that have not been returned are:\n");
-    }
-    while (cur)
-    {
-	DT_Tdep_PT_Printf (phead, "file: dapl_%s, \tMemType:%s\n",
-		    cur->filename, type[cur->MemType]);
-	cur = cur->next;
-    }
-    DT_Mdep_Unlock (&pt_ptr->MemListLock);
+	phead = pt_ptr->Params.phead;
+	DT_Mdep_Lock(&pt_ptr->MemListLock);
+	cur = pt_ptr->MemListHead;
+	if (cur != 0) {
+		DT_Tdep_PT_Printf(phead,
+				  "the allocated memory that have not been returned are:\n");
+	}
+	while (cur) {
+		DT_Tdep_PT_Printf(phead, "file: dapl_%s, \tMemType:%s\n",
+				  cur->filename, type[cur->MemType]);
+		cur = cur->next;
+	}
+	DT_Mdep_Unlock(&pt_ptr->MemListLock);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_client.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_client.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_client.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -33,488 +33,458 @@
 #define MAX_CONN_RETRY 8
 
 /****************************************************************************/
-void
-DT_Performance_Test_Client (
-    Params_t		*params_ptr,
-    Per_Test_Data_t 	*pt_ptr,
-    DAT_IA_HANDLE  	*ia_handle,
-    DAT_IA_ADDRESS_PTR 	remote_ia_addr)
+DAT_RETURN
+DT_Performance_Test_Client(Params_t * params_ptr,
+			   Per_Test_Data_t * pt_ptr,
+			   DAT_IA_HANDLE * ia_handle,
+			   DAT_IA_ADDRESS_PTR remote_ia_addr)
 {
-    Performance_Test_t 		*test_ptr = NULL;
-    int 			connected = 1;
-    DT_Tdep_Print_Head		*phead;
+	Performance_Test_t *test_ptr = NULL;
+	int connected = 1;
+	DT_Tdep_Print_Head *phead;
+	DAT_RETURN rc;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    DT_Tdep_PT_Debug (1,(phead,"Client: Starting performance test\n"));
+	DT_Tdep_PT_Debug(1, (phead, "Client: Starting performance test\n"));
 
-    if ( !DT_Performance_Test_Create (pt_ptr,
-				     ia_handle,
-				     remote_ia_addr,
-				     false,
-				     pt_ptr->Server_Info.is_little_endian,
-				     &test_ptr) )
-    {
-	DT_Tdep_PT_Debug (1,(phead,"Client: Resource Creation Failed\n"));
-	connected = 0;
-    }
-    else if ( !DT_Performance_Test_Client_Connect (phead, test_ptr) )
-    {
-	DT_Tdep_PT_Debug (1,(phead,"Client: Connection Failed\n"));
-	connected = 0;
-    }
+	if (!DT_Performance_Test_Create(pt_ptr,
+					ia_handle,
+					remote_ia_addr,
+					false,
+					pt_ptr->Server_Info.is_little_endian,
+					&test_ptr)) {
+		DT_Tdep_PT_Debug(1,
+				 (phead, "Client: Resource Creation Failed\n"));
+		connected = 0;
+	} else if (!DT_Performance_Test_Client_Connect(phead, test_ptr)) {
+		DT_Tdep_PT_Debug(1, (phead, "Client: Connection Failed\n"));
+		connected = 0;
+	}
 
-    if ( connected )
-    {
-	if ( !DT_Performance_Test_Client_Exchange (params_ptr,phead, test_ptr) )
-	{
-	    DT_Tdep_PT_Debug (1,(phead,"Client: Test Failed\n"));
+	if (connected) {
+		if (!DT_Performance_Test_Client_Exchange
+		    (params_ptr, phead, test_ptr)) {
+			DT_Tdep_PT_Debug(1, (phead, "Client: Test Failed\n"));
+		}
 	}
-    }
-    /* If we never connected, then the test will hang here
-     *  because in the destroy of the test it waits for a
-     *  disconnect event which will never arrive, simply
-     *  because there was never a connection.
-     */
+	/* If we never connected, then the test will hang here
+	 *  because in the destroy of the test it waits for a
+	 *  disconnect event which will never arrive, simply
+	 *  because there was never a connection.
+	 */
 
-    DT_Performance_Test_Destroy (pt_ptr, test_ptr, false);
+	DT_Performance_Test_Destroy(pt_ptr, test_ptr, false);
 
 #ifdef CM_BUSTED
     /*****  XXX Chill out a bit to give the kludged CM a chance ...
-     *****/DT_Mdep_Sleep (5000);
+     *****/ DT_Mdep_Sleep(5000);
 #endif
 
-    DT_Tdep_PT_Debug (1,(phead,"Client: Finished performance test\n"));
+	DT_Tdep_PT_Debug(1, (phead, "Client: Finished performance test\n"));
+
+	return (connected ? DAT_SUCCESS : DAT_INSUFFICIENT_RESOURCES);
 }
 
-
 /****************************************************************************/
 bool
-DT_Performance_Test_Client_Connect (
-    DT_Tdep_Print_Head		*phead,
-    Performance_Test_t 		*test_ptr)
+DT_Performance_Test_Client_Connect(DT_Tdep_Print_Head * phead,
+				   Performance_Test_t * test_ptr)
 {
-    DAT_RETURN          	ret;
-    DAT_EVENT_NUMBER            event_num;
-    unsigned int		retry_cnt = 0;
+	DAT_RETURN ret;
+	DAT_EVENT_NUMBER event_num;
+	unsigned int retry_cnt = 0;
 
-    /*
-     * Client - connect
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Client[" F64x "]: Connect on port 0x" F64x "\n",
-		   test_ptr->base_port, test_ptr->ep_context.port));
+	/*
+	 * Client - connect
+	 */
+	DT_Tdep_PT_Debug(1,
+			 (phead,
+			  "Client[" F64x "]: Connect on port 0x" F64x "\n",
+			  test_ptr->base_port, test_ptr->ep_context.port));
 
-retry:
-    ret = dat_ep_connect (test_ptr->ep_context.ep_handle,
-			 test_ptr->remote_ia_addr,
-			 test_ptr->ep_context.port,
-			 DAT_TIMEOUT_INFINITE,
-			 0,
-			 (DAT_PVOID) 0,	  /* no private data */
-			 test_ptr->cmd->qos,
-			 DAT_CONNECT_DEFAULT_FLAG);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ep_connect error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	return false;
-    }
-
-    /* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
-    if (!DT_conn_event_wait (phead, 
-			     test_ptr->ep_context.ep_handle,
-			     test_ptr->conn_evd_hdl,
-			     &event_num))
-    {
-	if ( event_num == DAT_CONNECTION_EVENT_PEER_REJECTED )
-	{
-	    DT_Mdep_Sleep (1000);
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: retrying connection...\n",
-			    test_ptr->base_port);
-	    retry_cnt++;
-	    if (retry_cnt < MAX_CONN_RETRY)
-	    {
-		goto retry;
-	    }
+      retry:
+	ret = dat_ep_connect(test_ptr->ep_context.ep_handle, test_ptr->remote_ia_addr, test_ptr->ep_context.port, DAT_TIMEOUT_INFINITE, 0, (DAT_PVOID) 0,	/* no private data */
+			     test_ptr->cmd->qos, DAT_CONNECT_DEFAULT_FLAG);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: dat_ep_connect error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		return false;
 	}
-	/* error message printed by DT_cr_event_wait */
-	return false;
-    }
 
+	/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
+	if (!DT_conn_event_wait(phead,
+				test_ptr->ep_context.ep_handle,
+				test_ptr->conn_evd_hdl, &event_num)) {
+		if (event_num == DAT_CONNECTION_EVENT_PEER_REJECTED) {
+			DT_Mdep_Sleep(1000);
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: retrying connection...\n",
+					  test_ptr->base_port);
+			retry_cnt++;
+			if (retry_cnt < MAX_CONN_RETRY) {
+				goto retry;
+			}
+		}
+		/* error message printed by DT_cr_event_wait */
+		return false;
+	}
 #ifdef CM_BUSTED
     /*****  XXX Chill out a bit to give the kludged CM a chance ...
-     *****/DT_Mdep_Sleep (5000);
+     *****/ DT_Mdep_Sleep(5000);
 #endif
 
-    DT_Tdep_PT_Debug (1,(phead,"Client[" F64x "]: Got Connection\n", test_ptr->base_port));
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Client[" F64x "]: Got Connection\n",
+			  test_ptr->base_port));
 
-    return true;
+	return true;
 }
 
-
 /****************************************************************************/
 static bool
-DT_Performance_Test_Client_Phase1 (
-    DT_Tdep_Print_Head		*phead,
-    Performance_Test_t 		*test_ptr,
-    Performance_Stats_t 	*stats )
+DT_Performance_Test_Client_Phase1(DT_Tdep_Print_Head * phead,
+				  Performance_Test_t * test_ptr,
+				  Performance_Stats_t * stats)
 {
-    DT_Mdep_TimeStamp 			pre_ts;
-    DT_Mdep_TimeStamp 			post_ts;
-    DT_CpuStat				pre_cpu_stat;
-    DT_CpuStat 				post_cpu_stat;
-    unsigned int    			post_cnt;
-    unsigned int    			reap_cnt;
+	DT_Mdep_TimeStamp pre_ts;
+	DT_Mdep_TimeStamp post_ts;
+	DT_CpuStat pre_cpu_stat;
+	DT_CpuStat post_cpu_stat;
+	unsigned int post_cnt;
+	unsigned int reap_cnt;
 
-    /*
-     * measure bandwidth, OPS, and CPU utilization
-     */
+	/*
+	 * measure bandwidth, OPS, and CPU utilization
+	 */
 
-    if ( !DT_Mdep_GetCpuStat (&pre_cpu_stat) )
-    {
-	return false;
-    }
+	if (!DT_Mdep_GetCpuStat(&pre_cpu_stat)) {
+		return false;
+	}
 
-    pre_ts = DT_Mdep_GetTimeStamp ();
+	pre_ts = DT_Mdep_GetTimeStamp();
 
-    /*
-     * Fill the pipe
-     */
+	/*
+	 * Fill the pipe
+	 */
 
-    for ( post_cnt = 0; post_cnt < (unsigned int)test_ptr->ep_context.pipeline_len; post_cnt++ )
-    {
-	if ( !DT_performance_post_rdma_op (&test_ptr->ep_context,
-					  test_ptr->reqt_evd_hdl,
-					  stats) )
-	{
-	    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Post %i failed\n",
-			   test_ptr->base_port,
-			   post_cnt));
-	    return false;
+	for (post_cnt = 0;
+	     post_cnt < (unsigned int)test_ptr->ep_context.pipeline_len;
+	     post_cnt++) {
+		if (!DT_performance_post_rdma_op
+		    (&test_ptr->ep_context, test_ptr->reqt_evd_hdl, stats)) {
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "Test[" F64x "]: Post %i failed\n",
+					  test_ptr->base_port, post_cnt));
+			return false;
+		}
 	}
-    }
 
-    /*
-     * Reap completions and repost
-     */
+	/*
+	 * Reap completions and repost
+	 */
 
-    for ( reap_cnt = 0; reap_cnt < test_ptr->cmd->num_iterations; )
-    {
-	unsigned int cur_reap_cnt;
-	unsigned int cur_post_cnt;
-	unsigned int cur_post_i;
+	for (reap_cnt = 0; reap_cnt < test_ptr->cmd->num_iterations;) {
+		unsigned int cur_reap_cnt;
+		unsigned int cur_post_cnt;
+		unsigned int cur_post_i;
 
-	cur_reap_cnt = DT_performance_reap (phead,
-					    test_ptr->reqt_evd_hdl,
-					    test_ptr->cmd->mode,
-					    stats);
+		cur_reap_cnt = DT_performance_reap(phead,
+						   test_ptr->reqt_evd_hdl,
+						   test_ptr->cmd->mode, stats);
 
-	if ( 0 == cur_reap_cnt )
-	{
-	    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Poll %i failed\n",
-			    test_ptr->base_port,
-			    reap_cnt));
-	    return false;
+		if (0 == cur_reap_cnt) {
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "Test[" F64x "]: Poll %i failed\n",
+					  test_ptr->base_port, reap_cnt));
+			return false;
+		}
+
+		/* repost */
+		cur_post_cnt = DT_min(test_ptr->cmd->num_iterations - post_cnt,
+				      cur_reap_cnt);
+
+		for (cur_post_i = 0; cur_post_i < cur_post_cnt; cur_post_i++) {
+			if (!DT_performance_post_rdma_op(&test_ptr->ep_context,
+							 test_ptr->reqt_evd_hdl,
+							 stats)) {
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Test[" F64x
+						  "]: Post %i failed\n",
+						  test_ptr->base_port,
+						  post_cnt));
+				return false;
+			}
+		}
+
+		reap_cnt += cur_reap_cnt;
+		post_cnt += cur_post_cnt;
 	}
 
-	/* repost */
-	cur_post_cnt = DT_min (test_ptr->cmd->num_iterations - post_cnt,
-			      cur_reap_cnt);
+	/* end time and update stats */
+	post_ts = DT_Mdep_GetTimeStamp();
+	stats->time_ts = post_ts - pre_ts;
+	stats->num_ops = test_ptr->cmd->num_iterations;
 
-	for ( cur_post_i = 0; cur_post_i < cur_post_cnt; cur_post_i++)
-	{
-	    if ( !DT_performance_post_rdma_op (&test_ptr->ep_context,
-					      test_ptr->reqt_evd_hdl,
-					      stats) )
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Post %i failed\n",
-				test_ptr->base_port,
-				post_cnt));
+	if (!DT_Mdep_GetCpuStat(&post_cpu_stat)) {
 		return false;
-	    }
 	}
 
-	reap_cnt += cur_reap_cnt;
-	post_cnt += cur_post_cnt;
-    }
+	/* calculate CPU utilization */
+	{
+		unsigned long int system;
+		unsigned long int user;
+		unsigned long int idle;
+		unsigned long int total;
 
-    /* end time and update stats */
-    post_ts = DT_Mdep_GetTimeStamp ();
-    stats->time_ts = post_ts - pre_ts;
-    stats->num_ops = test_ptr->cmd->num_iterations;
+		system = post_cpu_stat.system - pre_cpu_stat.system;
+		user = post_cpu_stat.user - pre_cpu_stat.user;
+		idle = post_cpu_stat.idle - pre_cpu_stat.idle;
 
-    if ( !DT_Mdep_GetCpuStat (&post_cpu_stat) )
-    {
-	return false;
-    }
+		total = system + user + idle;
 
-    /* calculate CPU utilization */
-    {
-	unsigned long int system;
-	unsigned long int user;
-	unsigned long int idle;
-	unsigned long int total;
-
-	system = post_cpu_stat.system - pre_cpu_stat.system;
-	user = post_cpu_stat.user - pre_cpu_stat.user;
-	idle = post_cpu_stat.idle - pre_cpu_stat.idle;
-
-	total = system + user + idle;
-
-	if ( 0 == total )
-	{
-	    stats->cpu_utilization =  0.0;
+		if (0 == total) {
+			stats->cpu_utilization = 0.0;
+		} else {
+			stats->cpu_utilization =
+			    (double)1.0 - ((double)idle / (double)total);
+			stats->cpu_utilization *= 100.0;
+		}
 	}
-	else
-	{
-	    stats->cpu_utilization = (double)1.0 - ((double) idle / (double) total );
-	    stats->cpu_utilization *= 100.0;
-	}
-    }
 
-    return true;
+	return true;
 }
 
-
 /****************************************************************************/
 static bool
-DT_Performance_Test_Client_Phase2 (
-    DT_Tdep_Print_Head		*phead, 
-    Performance_Test_t 		*test_ptr,
-    Performance_Stats_t 	*stats )
+DT_Performance_Test_Client_Phase2(DT_Tdep_Print_Head * phead,
+				  Performance_Test_t * test_ptr,
+				  Performance_Stats_t * stats)
 {
-    DAT_LMR_TRIPLET         	*iov;
-    DAT_RMR_TRIPLET         	rmr_triplet;
-    DAT_DTO_COOKIE 		cookie;
-    DAT_EVENT       		event;
-    DAT_RETURN      		ret;
-    Performance_Ep_Context_t 	*ep_context;
-    Performance_Test_Op_t   	*op;
-    DT_Mdep_TimeStamp 		pre_ts;
-    DT_Mdep_TimeStamp 		post_ts;
-    unsigned long int		bytes;
-    unsigned int 		i;
+	DAT_LMR_TRIPLET *iov;
+	DAT_RMR_TRIPLET rmr_triplet;
+	DAT_DTO_COOKIE cookie;
+	DAT_EVENT event;
+	DAT_RETURN ret;
+	Performance_Ep_Context_t *ep_context;
+	Performance_Test_Op_t *op;
+	DT_Mdep_TimeStamp pre_ts;
+	DT_Mdep_TimeStamp post_ts;
+	unsigned long int bytes;
+	unsigned int i;
 
-    /*
-     * measure latency
-     */
+	/*
+	 * measure latency
+	 */
 
-    ep_context = &test_ptr->ep_context;
-    op = &ep_context->op;
-    iov = DT_Bpool_GetIOV (op->bp, 0);
+	ep_context = &test_ptr->ep_context;
+	op = &ep_context->op;
+	iov = DT_Bpool_GetIOV(op->bp, 0);
 
-    bytes = op->seg_size * op->num_segs;
+	bytes = op->seg_size * op->num_segs;
 
-    /* Prep the inputs */
-    for (i = 0;  i < op->num_segs;  i++)
-    {
-	iov[i].virtual_address = (DAT_VADDR) (uintptr_t)
-	    DT_Bpool_GetBuffer (op->bp, i);
-	iov[i].segment_length  = op->seg_size;
-	iov[i].lmr_context     = DT_Bpool_GetLMR (op->bp, i);
-    }
+	/* Prep the inputs */
+	for (i = 0; i < op->num_segs; i++) {
+		iov[i].virtual_address = (DAT_VADDR) (uintptr_t)
+		    DT_Bpool_GetBuffer(op->bp, i);
+		iov[i].segment_length = op->seg_size;
+		iov[i].lmr_context = DT_Bpool_GetLMR(op->bp, i);
+	}
 
-    rmr_triplet.virtual_address  = op->Rdma_Address;
-    rmr_triplet.segment_length  = op->seg_size * op->num_segs;
-    rmr_triplet.rmr_context     = op->Rdma_Context;
+	rmr_triplet.virtual_address = op->Rdma_Address;
+	rmr_triplet.segment_length = op->seg_size * op->num_segs;
+	rmr_triplet.rmr_context = op->Rdma_Context;
 
-    cookie.as_ptr = NULL;
+	cookie.as_ptr = NULL;
 
-    for ( i = 0; i < test_ptr->cmd->num_iterations; i++ )
-    {
-	if ( RDMA_WRITE == op->transfer_type )
-	{
-	    pre_ts = DT_Mdep_GetTimeStamp ();
+	for (i = 0; i < test_ptr->cmd->num_iterations; i++) {
+		if (RDMA_WRITE == op->transfer_type) {
+			pre_ts = DT_Mdep_GetTimeStamp();
 
-	    ret = dat_ep_post_rdma_write (ep_context->ep_handle,
-					  op->num_segs,
-					  iov,
-					  cookie,
-					  &rmr_triplet,
-					  DAT_COMPLETION_DEFAULT_FLAG);
-	}
-	else
-	{
-	    pre_ts = DT_Mdep_GetTimeStamp ();
+			ret = dat_ep_post_rdma_write(ep_context->ep_handle,
+						     op->num_segs,
+						     iov,
+						     cookie,
+						     &rmr_triplet,
+						     DAT_COMPLETION_DEFAULT_FLAG);
+		} else {
+			pre_ts = DT_Mdep_GetTimeStamp();
 
-	    ret = dat_ep_post_rdma_read (ep_context->ep_handle,
-					 op->num_segs,
-					 iov,
-					 cookie,
-					 &rmr_triplet,
-					 DAT_COMPLETION_DEFAULT_FLAG);
-	}
+			ret = dat_ep_post_rdma_read(ep_context->ep_handle,
+						    op->num_segs,
+						    iov,
+						    cookie,
+						    &rmr_triplet,
+						    DAT_COMPLETION_DEFAULT_FLAG);
+		}
 
-	if ( DAT_SUCCESS != ret )
-	{
-	    return false;
-	}
+		if (DAT_SUCCESS != ret) {
+			return false;
+		}
 
-	for (;;)
-	{
-            DT_Mdep_Schedule();
-	    ret = DT_Tdep_evd_dequeue ( test_ptr->reqt_evd_hdl,
-				    &event);
+		for (;;) {
+			DT_Mdep_Schedule();
+			ret = DT_Tdep_evd_dequeue(test_ptr->reqt_evd_hdl,
+						  &event);
 
-	    post_ts = DT_Mdep_GetTimeStamp ();
+			post_ts = DT_Mdep_GetTimeStamp();
 
-	    if (DAT_GET_TYPE (ret) == DAT_QUEUE_EMPTY)
-	    {
-		continue;
-	    }
-	    else if ( DAT_SUCCESS != ret )
-	    {
-		DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_dequeue failed: %s\n",
-				DT_RetToString (ret));
-		return false;
-	    }
-	    else if (event.event_number == DAT_DTO_COMPLETION_EVENT)
-	    {
-		DT_performance_stats_record_latency (stats, post_ts - pre_ts);
-		break;
-	    }
-	    else /* error */
-	    {
-		DT_Tdep_PT_Printf (
-		    phead,
-		    "Warning: dapl_performance_wait swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
+			if (DAT_GET_TYPE(ret) == DAT_QUEUE_EMPTY) {
+				continue;
+			} else if (DAT_SUCCESS != ret) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test Error: dapl_event_dequeue failed: %s\n",
+						  DT_RetToString(ret));
+				return false;
+			} else if (event.event_number ==
+				   DAT_DTO_COMPLETION_EVENT) {
+				DT_performance_stats_record_latency(stats,
+								    post_ts -
+								    pre_ts);
+				break;
+			} else {	/* error */
 
-		return false;
-	    }
+				DT_Tdep_PT_Printf(phead,
+						  "Warning: dapl_performance_wait swallowing %s event\n",
+						  DT_EventToSTr(event.
+								event_number));
+
+				return false;
+			}
+		}
 	}
-    }
 
-    return true;
+	return true;
 }
 
-
 /****************************************************************************/
 bool
-DT_Performance_Test_Client_Exchange (
-    Params_t			*params_ptr,
-    DT_Tdep_Print_Head		*phead,
-    Performance_Test_t 		*test_ptr)
+DT_Performance_Test_Client_Exchange(Params_t * params_ptr,
+				    DT_Tdep_Print_Head * phead,
+				    Performance_Test_t * test_ptr)
 {
-    DAT_DTO_COMPLETION_EVENT_DATA 	dto_stat;
-    DAT_DTO_COOKIE			dto_cookie;
-    Performance_Stats_t 		stats;
-    RemoteMemoryInfo            	*rmi;
+	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+	DAT_DTO_COOKIE dto_cookie;
+	Performance_Stats_t stats;
+	RemoteMemoryInfo *rmi;
 
-    test_ptr->ep_context.op.bp =
-	DT_BpoolAlloc (test_ptr->pt_ptr,
-		      phead,
-		      test_ptr->ia_handle,
-		      test_ptr->pz_handle,
-		      test_ptr->ep_context.ep_handle,
-		      test_ptr->reqt_evd_hdl,
-		      test_ptr->ep_context.op.seg_size,
-		      test_ptr->ep_context.op.num_segs,
-		      DAT_OPTIMAL_ALIGNMENT,
-		      false,
-		      false);
+	test_ptr->ep_context.op.bp =
+	    DT_BpoolAlloc(test_ptr->pt_ptr,
+			  phead,
+			  test_ptr->ia_handle,
+			  test_ptr->pz_handle,
+			  test_ptr->ep_context.ep_handle,
+			  test_ptr->reqt_evd_hdl,
+			  test_ptr->ep_context.op.seg_size,
+			  test_ptr->ep_context.op.num_segs,
+			  DAT_OPTIMAL_ALIGNMENT, false, false);
 
-    if ( !test_ptr->ep_context.op.bp )
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for buffers (RDMA/RD)\n",
-		       test_ptr->base_port);
-	return false;
-    }
+	if (!test_ptr->ep_context.op.bp) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x
+				  "]: no memory for buffers (RDMA/RD)\n",
+				  test_ptr->base_port);
+		return false;
+	}
 
-    /*
-     * Recv the other side's info
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Waiting for Sync Msg\n",
-		   test_ptr->base_port));
+	/*
+	 * Recv the other side's info
+	 */
+	DT_Tdep_PT_Debug(1, (phead, "Test[" F64x "]: Waiting for Sync Msg\n",
+			     test_ptr->base_port));
 
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr =
-	(DAT_PVOID) DT_Bpool_GetBuffer (
-	    test_ptr->ep_context.bp,
-	    DT_PERF_SYNC_RECV_BUFFER_ID);
-    if ( !DT_dto_event_wait (phead, test_ptr->recv_evd_hdl, &dto_stat) ||
-	 !DT_dto_check ( phead,
-	     		&dto_stat,
-			test_ptr->ep_context.ep_handle,
-			DT_PERF_SYNC_BUFF_SIZE,
-			dto_cookie,
-			"Received Sync_Msg") )
-    {
-	return false;
-    }
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->ep_context.bp,
+					   DT_PERF_SYNC_RECV_BUFFER_ID);
+	if (!DT_dto_event_wait(phead, test_ptr->recv_evd_hdl, &dto_stat) ||
+	    !DT_dto_check(phead,
+			  &dto_stat,
+			  test_ptr->ep_context.ep_handle,
+			  DT_PERF_SYNC_BUFF_SIZE,
+			  dto_cookie, "Received Sync_Msg")) {
+		return false;
+	}
 
-    /*
-     * Extract what we need
-     */
-    DT_Tdep_PT_Debug (1, (phead,"Test[" F64x "]: Sync Msg Received\n", test_ptr->base_port));
-    rmi = (RemoteMemoryInfo *) DT_Bpool_GetBuffer (test_ptr->ep_context.bp,
-						  DT_PERF_SYNC_RECV_BUFFER_ID);
+	/*
+	 * Extract what we need
+	 */
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: Sync Msg Received\n",
+			  test_ptr->base_port));
+	rmi =
+	    (RemoteMemoryInfo *) DT_Bpool_GetBuffer(test_ptr->ep_context.bp,
+						    DT_PERF_SYNC_RECV_BUFFER_ID);
 
-    /*
-     * If the client and server are of different endiannesses,
-     * we must correct the endianness of the handle and address
-     * we pass to the other side.  The other side cannot (and
-     * better not) interpret these values.
-     */
-    if (DT_local_is_little_endian != test_ptr->is_remote_little_endian)
-    {
-	rmi->rmr_context = DT_EndianMemHandle (rmi->rmr_context);
-	rmi->mem_address.as_64 =DT_EndianMemAddress (rmi->mem_address.as_64);
-    }
+	/*
+	 * If the client and server are of different endiannesses,
+	 * we must correct the endianness of the handle and address
+	 * we pass to the other side.  The other side cannot (and
+	 * better not) interpret these values.
+	 */
+	if (DT_local_is_little_endian != test_ptr->is_remote_little_endian) {
+		rmi->rmr_context = DT_EndianMemHandle(rmi->rmr_context);
+		rmi->mem_address.as_64 =
+		    DT_EndianMemAddress(rmi->mem_address.as_64);
+	}
 
-    test_ptr->ep_context.op.Rdma_Context = rmi->rmr_context;
-    test_ptr->ep_context.op.Rdma_Address = rmi->mem_address.as_64;
+	test_ptr->ep_context.op.Rdma_Context = rmi->rmr_context;
+	test_ptr->ep_context.op.Rdma_Address = rmi->mem_address.as_64;
 
-    DT_Tdep_PT_Debug (3, (phead, 
-		     "Got RemoteMemInfo [ va=" F64x ", ctx=%x ]\n",
-		     test_ptr->ep_context.op.Rdma_Address,
-		     test_ptr->ep_context.op.Rdma_Context));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "Got RemoteMemInfo [ va=" F64x ", ctx=%x ]\n",
+			     test_ptr->ep_context.op.Rdma_Address,
+			     test_ptr->ep_context.op.Rdma_Context));
 
-    /*
-     * Get to work ...
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Begin...\n", test_ptr->base_port));
+	/*
+	 * Get to work ...
+	 */
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: Begin...\n",
+			  test_ptr->base_port));
 
-    DT_performance_stats_init (&stats);
+	DT_performance_stats_init(&stats);
 
-    if ( !DT_Performance_Test_Client_Phase1 (phead, test_ptr, &stats) )
-    {
-	return false;
-    }
+	if (!DT_Performance_Test_Client_Phase1(phead, test_ptr, &stats)) {
+		return false;
+	}
 
-    if ( !DT_Performance_Test_Client_Phase2 (phead, test_ptr, &stats) )
-    {
-	return false;
-    }
+	if (!DT_Performance_Test_Client_Phase2(phead, test_ptr, &stats)) {
+		return false;
+	}
 
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Sending Sync Msg\n", test_ptr->base_port));
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: Sending Sync Msg\n",
+			  test_ptr->base_port));
 
-    if (!DT_post_send_buffer (phead,
-			     test_ptr->ep_context.ep_handle,
-			     test_ptr->ep_context.bp,
-			     DT_PERF_SYNC_SEND_BUFFER_ID,
-			     DT_PERF_SYNC_BUFF_SIZE))
-    {
-	/* error message printed by DT_post_send_buffer */
-	return false;
-    }
+	if (!DT_post_send_buffer(phead,
+				 test_ptr->ep_context.ep_handle,
+				 test_ptr->ep_context.bp,
+				 DT_PERF_SYNC_SEND_BUFFER_ID,
+				 DT_PERF_SYNC_BUFF_SIZE)) {
+		/* error message printed by DT_post_send_buffer */
+		return false;
+	}
 
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr =
-	(DAT_PVOID) DT_Bpool_GetBuffer (
-	    test_ptr->ep_context.bp,
-	    DT_PERF_SYNC_SEND_BUFFER_ID);
-    if (!DT_dto_event_wait (phead, test_ptr->reqt_evd_hdl, &dto_stat) ||
-	!DT_dto_check ( phead,
-	    		&dto_stat,
-		       test_ptr->ep_context.ep_handle,
-		       DT_PERF_SYNC_BUFF_SIZE,
-		       dto_cookie,
-		       "Client_Sync_Send"))
-    {
-	return false;
-    }
-    DT_performance_stats_print (params_ptr,phead, &stats, test_ptr->cmd, test_ptr);
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->ep_context.bp,
+					   DT_PERF_SYNC_SEND_BUFFER_ID);
+	if (!DT_dto_event_wait(phead, test_ptr->reqt_evd_hdl, &dto_stat) ||
+	    !DT_dto_check(phead,
+			  &dto_stat,
+			  test_ptr->ep_context.ep_handle,
+			  DT_PERF_SYNC_BUFF_SIZE,
+			  dto_cookie, "Client_Sync_Send")) {
+		return false;
+	}
+	DT_performance_stats_print(params_ptr, phead, &stats, test_ptr->cmd,
+				   test_ptr);
 
-    return true;
+	return true;
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_server.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_server.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_server.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,382 +31,361 @@
 #include "dapl_proto.h"
 
 /****************************************************************************/
-void
-DT_Performance_Test_Server (
-    void 		*var)
+void DT_Performance_Test_Server(void *var)
 {
-    Per_Test_Data_t 		*pt_ptr = var;
-    Performance_Test_t 		*test_ptr = NULL;
-    DT_Tdep_Print_Head		*phead;
-    int				 success = 1;
+	Per_Test_Data_t *pt_ptr = var;
+	Performance_Test_t *test_ptr = NULL;
+	DT_Tdep_Print_Head *phead;
+	int success = 1;
 
-    phead = pt_ptr->Params.phead;
-    DT_Tdep_PT_Debug (1,(phead,"Server: Starting performance test\n"));
+	phead = pt_ptr->Params.phead;
+	DT_Tdep_PT_Debug(1, (phead, "Server: Starting performance test\n"));
 
-    if ( !DT_Performance_Test_Create (pt_ptr,
-				     pt_ptr->ps_ptr->ia_handle,
-				     (DAT_IA_ADDRESS_PTR) 0,
-				     true,
-				     pt_ptr->Client_Info.is_little_endian,
-				     &test_ptr) )
-    {
-	DT_Tdep_PT_Printf (phead, "Server: Resource Creation Failed\n");
-	success = 0;
-    }
-    if ( 1 == success )
-    {
-	if (! DT_Performance_Test_Server_Connect (phead, test_ptr) )
-	{
-	    success = 0;
-	    DT_Tdep_PT_Printf (phead, "Server: Connection Failed\n");
+	if (!DT_Performance_Test_Create(pt_ptr,
+					pt_ptr->ps_ptr->ia_handle,
+					(DAT_IA_ADDRESS_PTR) 0,
+					true,
+					pt_ptr->Client_Info.is_little_endian,
+					&test_ptr)) {
+		DT_Tdep_PT_Printf(phead, "Server: Resource Creation Failed\n");
+		success = 0;
 	}
-    }
-
-    if ( 1 == success )
-    {
-	if ( ! DT_Performance_Test_Server_Exchange (phead, test_ptr) )
-	{
-	    success = 0;
-	    DT_Tdep_PT_Printf (phead, "Server: Test Failed\n");
+	if (1 == success) {
+		if (!DT_Performance_Test_Server_Connect(phead, test_ptr)) {
+			success = 0;
+			DT_Tdep_PT_Printf(phead, "Server: Connection Failed\n");
+		}
 	}
-    }
 
+	if (1 == success) {
+		if (!DT_Performance_Test_Server_Exchange(phead, test_ptr)) {
+			success = 0;
+			DT_Tdep_PT_Printf(phead, "Server: Test Failed\n");
+		}
+	}
 #ifdef CM_BUSTED
     /*****  XXX Chill out a bit to give the kludged CM a chance ...
-     *****/DT_Mdep_Sleep (5000);
+     *****/ DT_Mdep_Sleep(5000);
 #endif
 
+	DT_Performance_Test_Destroy(pt_ptr, test_ptr, true);
 
+	DT_Tdep_PT_Printf(phead,
+			  "Server: Finished performance test.  Detaching.\n");
 
-    DT_Performance_Test_Destroy (pt_ptr, test_ptr, true);
+	DT_Mdep_Thread_Detach(DT_Mdep_Thread_SELF());	/* AMM */
+	DT_Thread_Destroy(pt_ptr->thread, pt_ptr);	/* destroy Master thread */
 
-    DT_Tdep_PT_Printf (phead, "Server: Finished performance test.  Detaching.\n");
+	DT_Mdep_Lock(&pt_ptr->ps_ptr->num_clients_lock);
+	pt_ptr->ps_ptr->num_clients--;
+	DT_Mdep_Unlock(&pt_ptr->ps_ptr->num_clients_lock);
 
-    DT_Mdep_Thread_Detach (DT_Mdep_Thread_SELF ());	 /* AMM */
-    DT_Thread_Destroy (pt_ptr->thread, pt_ptr);	    /* destroy Master thread */
+	DT_PrintMemList(pt_ptr);	/* check if we return all space allocated */
+	DT_Mdep_LockDestroy(&pt_ptr->Thread_counter_lock);
+	DT_Mdep_LockDestroy(&pt_ptr->MemListLock);
+	DT_Free_Per_Test_Data(pt_ptr);
 
-    DT_Mdep_Lock (&pt_ptr->ps_ptr->num_clients_lock);
-    pt_ptr->ps_ptr->num_clients--;
-    DT_Mdep_Unlock (&pt_ptr->ps_ptr->num_clients_lock);
+	DT_Mdep_Unlock(&g_PerfTestLock);
+	DT_Tdep_PT_Printf(phead,
+			  "Server: Finished performance test.  Exiting.\n");
 
-    DT_PrintMemList (pt_ptr);	    /* check if we return all space allocated */
-    DT_Mdep_LockDestroy (&pt_ptr->Thread_counter_lock);
-    DT_Mdep_LockDestroy (&pt_ptr->MemListLock);
-    DT_Free_Per_Test_Data (pt_ptr);
-
-    DT_Mdep_Unlock (&g_PerfTestLock);
-    DT_Tdep_PT_Printf (phead, "Server: Finished performance test.  Exiting.\n");
-
-    DT_Mdep_Thread_EXIT (NULL);
+	DT_Mdep_Thread_EXIT(NULL);
 }
 
-
 /****************************************************************************/
 bool
-DT_Performance_Test_Server_Connect (
-    DT_Tdep_Print_Head		*phead,
-    Performance_Test_t 		*test_ptr)
+DT_Performance_Test_Server_Connect(DT_Tdep_Print_Head * phead,
+				   Performance_Test_t * test_ptr)
 {
-    DAT_RETURN 			ret;
-    bool			status;
-    DAT_RSP_HANDLE              rsp_handle;
-    DAT_PSP_HANDLE              psp_handle;
+	DAT_RETURN ret;
+	bool status;
+	DAT_RSP_HANDLE rsp_handle;
+	DAT_PSP_HANDLE psp_handle;
 
-    DAT_CR_ARRIVAL_EVENT_DATA   cr_stat;
-    DAT_CR_HANDLE               cr_handle;
-    DAT_EVENT_NUMBER            event_num;
+	DAT_CR_ARRIVAL_EVENT_DATA cr_stat;
+	DAT_CR_HANDLE cr_handle;
+	DAT_EVENT_NUMBER event_num;
 
-    rsp_handle = DAT_HANDLE_NULL;
-    psp_handle = DAT_HANDLE_NULL;
-#if 0 /* FIXME */
-    if (test_ptr->cmd->use_rsp)
-    {
-	/*
-	 * Server - create a single-use RSP and
-	 *	    await a connection for this EP
-	 */
-	ret = dat_rsp_create (test_ptr->ia_handle,
-			     test_ptr->ep_context.port,
-			     test_ptr->ep_context.ep_handle,
-			     test_ptr->creq_evd_hdl,
-			     &rsp_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_rsp_create error: %s\n",
-			   test_ptr->base_port, DT_RetToString (ret));
-	    status = false;
-	    goto psp_free;
-	}
+	rsp_handle = DAT_HANDLE_NULL;
+	psp_handle = DAT_HANDLE_NULL;
+#if 0				/* FIXME */
+	if (test_ptr->cmd->use_rsp) {
+		/*
+		 * Server - create a single-use RSP and
+		 *          await a connection for this EP
+		 */
+		ret = dat_rsp_create(test_ptr->ia_handle,
+				     test_ptr->ep_context.port,
+				     test_ptr->ep_context.ep_handle,
+				     test_ptr->creq_evd_hdl, &rsp_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_rsp_create error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			status = false;
+			goto psp_free;
+		}
 
-	DT_Tdep_PT_Debug (1,(phead,"Server[" F64x "]: Listen on RSP port 0x" F64x "\n",
-		       test_ptr->base_port, test_ptr->ep_context.port));
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Server[" F64x "]: Listen on RSP port 0x" F64x
+				  "\n", test_ptr->base_port,
+				  test_ptr->ep_context.port));
 
-	/* wait for the connection request */
-	if (!DT_cr_event_wait (test_ptr->conn_evd_hdl, &cr_stat) ||
-	    !DT_cr_check ( &cr_stat,
-			  DAT_HANDLE_NULL,
-			  test_ptr->ep_context.port,
-			  &cr_handle,
-			  "Server") )
-	{
-	    status = false;
-	    goto psp_free;
-	}
+		/* wait for the connection request */
+		if (!DT_cr_event_wait(test_ptr->conn_evd_hdl, &cr_stat) ||
+		    !DT_cr_check(&cr_stat,
+				 DAT_HANDLE_NULL,
+				 test_ptr->ep_context.port,
+				 &cr_handle, "Server")) {
+			status = false;
+			goto psp_free;
+		}
 
-	/* what, me query?  just try to accept the connection */
-	ret = dat_cr_accept (cr_handle,
-			    test_ptr->ep_context.ep_handle,
-			    0, (DAT_PVOID)0 /* no private data */ );
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_cr_accept error: %s\n",
-			   test_ptr->base_port, DT_RetToString (ret));
-	    /* cr_handle consumed on failure */
-	    status = false;
-	    goto psp_free;
-	}
+		/* what, me query?  just try to accept the connection */
+		ret = dat_cr_accept(cr_handle,
+				    test_ptr->ep_context.ep_handle,
+				    0, (DAT_PVOID) 0 /* no private data */ );
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_cr_accept error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* cr_handle consumed on failure */
+			status = false;
+			goto psp_free;
+		}
 
-	/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
-	if (!DT_conn_event_wait (  test_ptr->ep_context.ep_handle,
-				  test_ptr->conn_evd_hdl,
-				  &event_num))
+		/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
+		if (!DT_conn_event_wait(test_ptr->ep_context.ep_handle,
+					test_ptr->conn_evd_hdl, &event_num)) {
+			/* error message printed by DT_conn_event_wait */
+			status = false;
+			goto psp_free;
+		}
+
+	} else
+#endif				/* FIXME */
 	{
-	    /* error message printed by DT_conn_event_wait */
-	    status = false;
-	    goto psp_free;
+		/*
+		 * Server - use a short-lived PSP instead of an RSP
+		 */
+		status = true;
+
+		ret = dat_psp_create(test_ptr->ia_handle,
+				     test_ptr->ep_context.port,
+				     test_ptr->creq_evd_hdl,
+				     DAT_PSP_CONSUMER_FLAG, &psp_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_psp_create error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			status = false;
+			psp_handle = DAT_HANDLE_NULL;
+			return (status);
+		}
+
 	}
 
-    }
-    else
-#endif /* FIXME */
-    {
 	/*
-	 * Server - use a short-lived PSP instead of an RSP
+	 * Here's where we tell the main server process that
+	 * this thread is ready to wait for a connection request
+	 * from the remote end.
 	 */
-	status = true;
+	DT_Mdep_wait_object_wakeup(&test_ptr->pt_ptr->synch_wait_object);
 
-	ret = dat_psp_create (test_ptr->ia_handle,
-			      test_ptr->ep_context.port,
-			      test_ptr->creq_evd_hdl,
-			      DAT_PSP_CONSUMER_FLAG,
-			      &psp_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_psp_create error: %s\n",
-			   test_ptr->base_port, DT_RetToString (ret));
-	    status = false;
-	    psp_handle = DAT_HANDLE_NULL;
-	    return (status);
+	DT_Tdep_PT_Debug(1,
+			 (phead,
+			  "Server[" F64x "]: Listen on PSP port 0x" F64x "\n",
+			  test_ptr->base_port, test_ptr->ep_context.port));
+
+	/* wait for a connection request */
+	if (!DT_cr_event_wait(phead, test_ptr->creq_evd_hdl, &cr_stat) ||
+	    !DT_cr_check(phead,
+			 &cr_stat,
+			 psp_handle,
+			 test_ptr->ep_context.port, &cr_handle, "Server")) {
+		status = false;
+		goto psp_free;
 	}
 
-    }
+	/* what, me query?  just try to accept the connection */
+	ret = dat_cr_accept(cr_handle,
+			    test_ptr->ep_context.ep_handle,
+			    0, (DAT_PVOID) 0 /* no private data */ );
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: dat_cr_accept error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		/* cr_handle consumed on failure */
+		status = false;
+		goto psp_free;
+	}
 
-    /*
-     * Here's where we tell the main server process that
-     * this thread is ready to wait for a connection request
-     * from the remote end.
-     */
-    DT_Mdep_wait_object_wakeup (&test_ptr->pt_ptr->synch_wait_object);
+	/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
+	if (!DT_conn_event_wait(phead,
+				test_ptr->ep_context.ep_handle,
+				test_ptr->conn_evd_hdl, &event_num)) {
+		/* error message printed by DT_cr_event_wait */
+		status = false;
+		goto psp_free;
+	}
 
-    DT_Tdep_PT_Debug (1,(phead,"Server[" F64x "]: Listen on PSP port 0x" F64x "\n",
-		       test_ptr->base_port, test_ptr->ep_context.port));
-
-    /* wait for a connection request */
-    if (!DT_cr_event_wait (phead, test_ptr->creq_evd_hdl, &cr_stat) ||
-	!DT_cr_check ( phead,
-	    		&cr_stat,
-		       psp_handle,
-		       test_ptr->ep_context.port,
-		       &cr_handle,
-		       "Server") )
-    {
-	status = false;
-	goto psp_free;
-    }
-
-    /* what, me query?  just try to accept the connection */
-    ret = dat_cr_accept (cr_handle,
-			 test_ptr->ep_context.ep_handle,
-			 0,
-			 (DAT_PVOID)0 /* no private data */ );
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_cr_accept error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	/* cr_handle consumed on failure */
-	status = false;
-	goto psp_free;
-    }
-
-    /* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
-    if (!DT_conn_event_wait (phead, 
-			     test_ptr->ep_context.ep_handle,
-			     test_ptr->conn_evd_hdl,
-			     &event_num ) )
-    {
-	/* error message printed by DT_cr_event_wait */
-	status = false;
-	goto psp_free;
-    }
-
-    DT_Tdep_PT_Debug (1, (phead,"Server[" F64x "]: Accept on port 0x" F64x "\n",
-		    test_ptr->base_port, test_ptr->ep_context.port));
-psp_free:
-    if ( DAT_HANDLE_NULL != psp_handle )
-    {
-	/* throw away single-use PSP */
-	ret = dat_psp_free (psp_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_psp_free error: %s\n",
-			    test_ptr->base_port, DT_RetToString (ret));
-	    status = false;
+	DT_Tdep_PT_Debug(1,
+			 (phead,
+			  "Server[" F64x "]: Accept on port 0x" F64x "\n",
+			  test_ptr->base_port, test_ptr->ep_context.port));
+      psp_free:
+	if (DAT_HANDLE_NULL != psp_handle) {
+		/* throw away single-use PSP */
+		ret = dat_psp_free(psp_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_psp_free error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			status = false;
+		}
 	}
-    }
-    if ( DAT_HANDLE_NULL != rsp_handle )
-    {
-	/* throw away single-use PSP */
-	ret = dat_rsp_free (rsp_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_rsp_free error: %s\n",
-			    test_ptr->base_port, DT_RetToString (ret));
-	    status = false;
+	if (DAT_HANDLE_NULL != rsp_handle) {
+		/* throw away single-use PSP */
+		ret = dat_rsp_free(rsp_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_rsp_free error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			status = false;
+		}
 	}
-    }	/* end short-lived PSP */
-
+	/* end short-lived PSP */
 #ifdef CM_BUSTED
     /*****  XXX Chill out a bit to give the kludged CM a chance ...
-     *****/DT_Mdep_Sleep (5000);
+     *****/ DT_Mdep_Sleep(5000);
 #endif
 
-    return status;
+	return status;
 }
 
-
-
 /****************************************************************************/
 bool
-DT_Performance_Test_Server_Exchange (
-    DT_Tdep_Print_Head		*phead,
-    Performance_Test_t 		*test_ptr)
+DT_Performance_Test_Server_Exchange(DT_Tdep_Print_Head * phead,
+				    Performance_Test_t * test_ptr)
 {
-    DAT_DTO_COMPLETION_EVENT_DATA 	dto_stat;
-    RemoteMemoryInfo            	*rmi;
-    DAT_DTO_COOKIE			dto_cookie;
+	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+	RemoteMemoryInfo *rmi;
+	DAT_DTO_COOKIE dto_cookie;
 
-    test_ptr->ep_context.op.bp =
-	DT_BpoolAlloc (test_ptr->pt_ptr,
-		      phead,
-		      test_ptr->ia_handle,
-		      test_ptr->pz_handle,
-		      test_ptr->ep_context.ep_handle,
-		      test_ptr->reqt_evd_hdl,
-		      test_ptr->ep_context.op.seg_size,
-		      test_ptr->ep_context.op.num_segs,
-		      DAT_OPTIMAL_ALIGNMENT,
-		      true,
-		      true);
+	test_ptr->ep_context.op.bp =
+	    DT_BpoolAlloc(test_ptr->pt_ptr,
+			  phead,
+			  test_ptr->ia_handle,
+			  test_ptr->pz_handle,
+			  test_ptr->ep_context.ep_handle,
+			  test_ptr->reqt_evd_hdl,
+			  test_ptr->ep_context.op.seg_size,
+			  test_ptr->ep_context.op.num_segs,
+			  DAT_OPTIMAL_ALIGNMENT, true, true);
 
-    if ( !test_ptr->ep_context.op.bp )
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for buffers (RDMA/RD)\n",
-		       test_ptr->base_port);
-	return false;
-    }
+	if (!test_ptr->ep_context.op.bp) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x
+				  "]: no memory for buffers (RDMA/RD)\n",
+				  test_ptr->base_port);
+		return false;
+	}
 
-    test_ptr->ep_context.op.Rdma_Context =
-	DT_Bpool_GetRMR (test_ptr->ep_context.op.bp, 0);
-    test_ptr->ep_context.op.Rdma_Address = (DAT_VADDR) (uintptr_t)
-        DT_Bpool_GetBuffer (test_ptr->ep_context.op.bp, 0);
+	test_ptr->ep_context.op.Rdma_Context =
+	    DT_Bpool_GetRMR(test_ptr->ep_context.op.bp, 0);
+	test_ptr->ep_context.op.Rdma_Address = (DAT_VADDR) (uintptr_t)
+	    DT_Bpool_GetBuffer(test_ptr->ep_context.op.bp, 0);
 
-    /*
-     * Prep send buffer with memory information
-     */
-    rmi = (RemoteMemoryInfo *) DT_Bpool_GetBuffer (test_ptr->ep_context.bp,
-						  DT_PERF_SYNC_SEND_BUFFER_ID);
+	/*
+	 * Prep send buffer with memory information
+	 */
+	rmi = (RemoteMemoryInfo *) DT_Bpool_GetBuffer(test_ptr->ep_context.bp,
+						      DT_PERF_SYNC_SEND_BUFFER_ID);
 
-    rmi->rmr_context = test_ptr->ep_context.op.Rdma_Context;
-    rmi->mem_address.as_64 =test_ptr->ep_context.op.Rdma_Address;
+	rmi->rmr_context = test_ptr->ep_context.op.Rdma_Context;
+	rmi->mem_address.as_64 = test_ptr->ep_context.op.Rdma_Address;
 
-    if ( rmi->mem_address.as_ptr )
-    {
-	DT_Tdep_PT_Debug (3, (phead,
-		    	 "RemoteMemInfo va=" F64x ", ctx=%x\n",
-			 rmi->mem_address.as_64,
-			 rmi->rmr_context));
-    }
+	if (rmi->mem_address.as_ptr) {
+		DT_Tdep_PT_Debug(3, (phead,
+				     "RemoteMemInfo va=" F64x ", ctx=%x\n",
+				     rmi->mem_address.as_64, rmi->rmr_context));
+	}
 
-    /*
-     * If the client and server are of different endiannesses,
-     * we must correct the endianness of the handle and address
-     * we pass to the other side.  The other side cannot (and
-     * better not) interpret these values.
-     */
-    if (DT_local_is_little_endian != test_ptr->is_remote_little_endian)
-    {
-	rmi->rmr_context = DT_EndianMemHandle (rmi->rmr_context);
-	rmi->mem_address.as_64 =DT_EndianMemAddress (rmi->mem_address.as_64);
-    }
+	/*
+	 * If the client and server are of different endiannesses,
+	 * we must correct the endianness of the handle and address
+	 * we pass to the other side.  The other side cannot (and
+	 * better not) interpret these values.
+	 */
+	if (DT_local_is_little_endian != test_ptr->is_remote_little_endian) {
+		rmi->rmr_context = DT_EndianMemHandle(rmi->rmr_context);
+		rmi->mem_address.as_64 =
+		    DT_EndianMemAddress(rmi->mem_address.as_64);
+	}
 
-    /*
-     * Send our memory info
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Sending Sync Msg\n", test_ptr->base_port));
+	/*
+	 * Send our memory info
+	 */
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: Sending Sync Msg\n",
+			  test_ptr->base_port));
 
-    /* post the send buffer */
-    if (!DT_post_send_buffer (phead,
-			     test_ptr->ep_context.ep_handle,
-			     test_ptr->ep_context.bp,
-			     DT_PERF_SYNC_SEND_BUFFER_ID,
-			     DT_PERF_SYNC_BUFF_SIZE))
-    {
-	/* error message printed by DT_post_send_buffer */
-	return false;
-    }
+	/* post the send buffer */
+	if (!DT_post_send_buffer(phead,
+				 test_ptr->ep_context.ep_handle,
+				 test_ptr->ep_context.bp,
+				 DT_PERF_SYNC_SEND_BUFFER_ID,
+				 DT_PERF_SYNC_BUFF_SIZE)) {
+		/* error message printed by DT_post_send_buffer */
+		return false;
+	}
 
-    /* reap the send and verify it */
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr =
-	(DAT_PVOID) DT_Bpool_GetBuffer (
-	    test_ptr->ep_context.bp,
-	    DT_PERF_SYNC_SEND_BUFFER_ID);
-    if ( !DT_dto_event_wait (phead, test_ptr->reqt_evd_hdl, &dto_stat) ||
-	 !DT_dto_check (phead,
-	     		&dto_stat,
-		       test_ptr->ep_context.ep_handle,
-		       DT_PERF_SYNC_BUFF_SIZE,
-		       dto_cookie,
-		       "Send Sync_Msg") )
-    {
-	return false;
-    }
+	/* reap the send and verify it */
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->ep_context.bp,
+					   DT_PERF_SYNC_SEND_BUFFER_ID);
+	if (!DT_dto_event_wait(phead, test_ptr->reqt_evd_hdl, &dto_stat) ||
+	    !DT_dto_check(phead,
+			  &dto_stat,
+			  test_ptr->ep_context.ep_handle,
+			  DT_PERF_SYNC_BUFF_SIZE,
+			  dto_cookie, "Send Sync_Msg")) {
+		return false;
+	}
 
-    /*
-     * Recv the other side's info
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Waiting for Sync Msg\n",
-		   test_ptr->base_port));
+	/*
+	 * Recv the other side's info
+	 */
+	DT_Tdep_PT_Debug(1, (phead, "Test[" F64x "]: Waiting for Sync Msg\n",
+			     test_ptr->base_port));
 
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr =
-	(DAT_PVOID) DT_Bpool_GetBuffer (
-	    test_ptr->ep_context.bp,
-	    DT_PERF_SYNC_RECV_BUFFER_ID);
-    if ( !DT_dto_event_wait (phead, test_ptr->recv_evd_hdl, &dto_stat) ||
-	 !DT_dto_check ( phead,
-	     		&dto_stat,
-			test_ptr->ep_context.ep_handle,
-			DT_PERF_SYNC_BUFF_SIZE,
-			dto_cookie,
-			"Received Sync_Msg") )
-    {
-	return false;
-    }
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->ep_context.bp,
+					   DT_PERF_SYNC_RECV_BUFFER_ID);
+	if (!DT_dto_event_wait(phead, test_ptr->recv_evd_hdl, &dto_stat) ||
+	    !DT_dto_check(phead,
+			  &dto_stat,
+			  test_ptr->ep_context.ep_handle,
+			  DT_PERF_SYNC_BUFF_SIZE,
+			  dto_cookie, "Received Sync_Msg")) {
+		return false;
+	}
 
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Received Sync Msg\n",
-		    test_ptr->base_port));
+	DT_Tdep_PT_Debug(1, (phead, "Test[" F64x "]: Received Sync Msg\n",
+			     test_ptr->base_port));
 
-    return true;
+	return true;
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_stats.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_stats.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_stats.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,370 +30,345 @@
 
 #include "dapl_proto.h"
 
-void
-DT_performance_stats_init (
-    Performance_Stats_t 		*stats)
+void DT_performance_stats_init(Performance_Stats_t * stats)
 {
-    stats->num_ops = 0;
-    stats->bytes = 0;
-    stats->post_ctxt_switch_num = 0;
-    stats->reap_ctxt_switch_num = 0;
+	stats->num_ops = 0;
+	stats->bytes = 0;
+	stats->post_ctxt_switch_num = 0;
+	stats->reap_ctxt_switch_num = 0;
 
-    stats->cpu_utilization = 0.0;
-    stats->time_ts = 0;
+	stats->cpu_utilization = 0.0;
+	stats->time_ts = 0;
 
-    stats->posts_sans_ctxt.num = 0;
-    stats->posts_sans_ctxt.total_ts = 0;
-    stats->posts_sans_ctxt.max_ts = 0;
-    stats->posts_sans_ctxt.min_ts = ~0;
+	stats->posts_sans_ctxt.num = 0;
+	stats->posts_sans_ctxt.total_ts = 0;
+	stats->posts_sans_ctxt.max_ts = 0;
+	stats->posts_sans_ctxt.min_ts = ~0;
 
-    stats->posts_with_ctxt.num = 0;
-    stats->posts_with_ctxt.total_ts = 0;
-    stats->posts_with_ctxt.max_ts = 0;
-    stats->posts_with_ctxt.min_ts = ~0;
+	stats->posts_with_ctxt.num = 0;
+	stats->posts_with_ctxt.total_ts = 0;
+	stats->posts_with_ctxt.max_ts = 0;
+	stats->posts_with_ctxt.min_ts = ~0;
 
-    stats->reaps_sans_ctxt.num = 0;
-    stats->reaps_sans_ctxt.total_ts = 0;
-    stats->reaps_sans_ctxt.max_ts = 0;
-    stats->reaps_sans_ctxt.min_ts = ~0;
+	stats->reaps_sans_ctxt.num = 0;
+	stats->reaps_sans_ctxt.total_ts = 0;
+	stats->reaps_sans_ctxt.max_ts = 0;
+	stats->reaps_sans_ctxt.min_ts = ~0;
 
-    stats->reaps_with_ctxt.num = 0;
-    stats->reaps_with_ctxt.total_ts = 0;
-    stats->reaps_with_ctxt.max_ts = 0;
-    stats->reaps_with_ctxt.min_ts = ~0;
+	stats->reaps_with_ctxt.num = 0;
+	stats->reaps_with_ctxt.total_ts = 0;
+	stats->reaps_with_ctxt.max_ts = 0;
+	stats->reaps_with_ctxt.min_ts = ~0;
 
-    stats->latency.num = 0;
-    stats->latency.total_ts = 0;
-    stats->latency.max_ts = 0;
-    stats->latency.min_ts = ~0;
+	stats->latency.num = 0;
+	stats->latency.total_ts = 0;
+	stats->latency.max_ts = 0;
+	stats->latency.min_ts = ~0;
 }
 
-
 void
-DT_performance_stats_record_post (
-    Performance_Stats_t 		*stats,
-    unsigned long 			ctxt_switch_num,
-    DT_Mdep_TimeStamp 			ts)
+DT_performance_stats_record_post(Performance_Stats_t * stats,
+				 unsigned long ctxt_switch_num,
+				 DT_Mdep_TimeStamp ts)
 {
-    if ( ctxt_switch_num )
-    {
-	stats->posts_with_ctxt.num++;
-	stats->posts_with_ctxt.total_ts += ts;
-	stats->posts_with_ctxt.max_ts =
-	    DT_max (stats->posts_with_ctxt.max_ts, ts);
-	stats->posts_with_ctxt.min_ts =
-	    DT_min (stats->posts_with_ctxt.min_ts, ts);
+	if (ctxt_switch_num) {
+		stats->posts_with_ctxt.num++;
+		stats->posts_with_ctxt.total_ts += ts;
+		stats->posts_with_ctxt.max_ts =
+		    DT_max(stats->posts_with_ctxt.max_ts, ts);
+		stats->posts_with_ctxt.min_ts =
+		    DT_min(stats->posts_with_ctxt.min_ts, ts);
 
-	stats->post_ctxt_switch_num += ctxt_switch_num;
-    }
-    else
-    {
-	stats->posts_sans_ctxt.num++;
-	stats->posts_sans_ctxt.total_ts += ts;
-	stats->posts_sans_ctxt.max_ts =
-	    DT_max (stats->posts_sans_ctxt.max_ts, ts);
-	stats->posts_sans_ctxt.min_ts =
-	    DT_min (stats->posts_sans_ctxt.min_ts, ts);
-    }
+		stats->post_ctxt_switch_num += ctxt_switch_num;
+	} else {
+		stats->posts_sans_ctxt.num++;
+		stats->posts_sans_ctxt.total_ts += ts;
+		stats->posts_sans_ctxt.max_ts =
+		    DT_max(stats->posts_sans_ctxt.max_ts, ts);
+		stats->posts_sans_ctxt.min_ts =
+		    DT_min(stats->posts_sans_ctxt.min_ts, ts);
+	}
 }
 
-
 void
-DT_performance_stats_record_reap (
-    Performance_Stats_t 		*stats,
-    unsigned long 			ctxt_switch_num,
-    DT_Mdep_TimeStamp 			ts)
+DT_performance_stats_record_reap(Performance_Stats_t * stats,
+				 unsigned long ctxt_switch_num,
+				 DT_Mdep_TimeStamp ts)
 {
-    if ( ctxt_switch_num )
-    {
-	stats->reaps_with_ctxt.num++;
-	stats->reaps_with_ctxt.total_ts += ts;
-	stats->reaps_with_ctxt.max_ts =
-	    DT_max (stats->reaps_with_ctxt.max_ts, ts);
-	stats->reaps_with_ctxt.min_ts =
-	    DT_min (stats->reaps_with_ctxt.min_ts, ts);
+	if (ctxt_switch_num) {
+		stats->reaps_with_ctxt.num++;
+		stats->reaps_with_ctxt.total_ts += ts;
+		stats->reaps_with_ctxt.max_ts =
+		    DT_max(stats->reaps_with_ctxt.max_ts, ts);
+		stats->reaps_with_ctxt.min_ts =
+		    DT_min(stats->reaps_with_ctxt.min_ts, ts);
 
-	stats->reap_ctxt_switch_num += ctxt_switch_num;
-    }
-    else
-    {
-	stats->reaps_sans_ctxt.num++;
-	stats->reaps_sans_ctxt.total_ts += ts;
-	stats->reaps_sans_ctxt.max_ts =
-	    DT_max (stats->reaps_sans_ctxt.max_ts, ts);
-	stats->reaps_sans_ctxt.min_ts =
-	    DT_min (stats->reaps_sans_ctxt.min_ts, ts);
-    }
+		stats->reap_ctxt_switch_num += ctxt_switch_num;
+	} else {
+		stats->reaps_sans_ctxt.num++;
+		stats->reaps_sans_ctxt.total_ts += ts;
+		stats->reaps_sans_ctxt.max_ts =
+		    DT_max(stats->reaps_sans_ctxt.max_ts, ts);
+		stats->reaps_sans_ctxt.min_ts =
+		    DT_min(stats->reaps_sans_ctxt.min_ts, ts);
+	}
 }
 
-
 void
-DT_performance_stats_record_latency (
-    Performance_Stats_t 		*stats,
-    DT_Mdep_TimeStamp 			ts)
+DT_performance_stats_record_latency(Performance_Stats_t * stats,
+				    DT_Mdep_TimeStamp ts)
 {
-    stats->latency.num++;
-    stats->latency.total_ts += ts;
-    stats->latency.max_ts =
-	DT_max (stats->latency.max_ts, ts);
-    stats->latency.min_ts =
-	DT_min (stats->latency.min_ts, ts);
+	stats->latency.num++;
+	stats->latency.total_ts += ts;
+	stats->latency.max_ts = DT_max(stats->latency.max_ts, ts);
+	stats->latency.min_ts = DT_min(stats->latency.min_ts, ts);
 }
 
 void
-DT_performance_stats_data_combine (
-    Performance_Stats_Data_t 		*dest,
-    Performance_Stats_Data_t 		*src_a,
-    Performance_Stats_Data_t 		*src_b)
+DT_performance_stats_data_combine(Performance_Stats_Data_t * dest,
+				  Performance_Stats_Data_t * src_a,
+				  Performance_Stats_Data_t * src_b)
 {
-    dest->num = src_a->num + src_b->num;
-    dest->total_ts = src_a->total_ts + src_b->total_ts;
-    dest->max_ts = DT_max (src_a->max_ts, src_b->max_ts);
-    dest->min_ts = DT_min (src_a->min_ts, src_b->min_ts);
+	dest->num = src_a->num + src_b->num;
+	dest->total_ts = src_a->total_ts + src_b->total_ts;
+	dest->max_ts = DT_max(src_a->max_ts, src_b->max_ts);
+	dest->min_ts = DT_min(src_a->min_ts, src_b->min_ts);
 }
 
-
 void
-DT_performance_stats_combine (
-    Performance_Stats_t 		*dest,
-    Performance_Stats_t 		*src_a,
-    Performance_Stats_t 		*src_b)
+DT_performance_stats_combine(Performance_Stats_t * dest,
+			     Performance_Stats_t * src_a,
+			     Performance_Stats_t * src_b)
 {
-    dest->num_ops =
-	src_a->num_ops + src_b->num_ops;
+	dest->num_ops = src_a->num_ops + src_b->num_ops;
 
-    dest->bytes =
-	src_a->bytes + src_b->bytes;
+	dest->bytes = src_a->bytes + src_b->bytes;
 
-    dest->post_ctxt_switch_num =
-	src_a->post_ctxt_switch_num + src_b->post_ctxt_switch_num;
+	dest->post_ctxt_switch_num =
+	    src_a->post_ctxt_switch_num + src_b->post_ctxt_switch_num;
 
-    dest->reap_ctxt_switch_num =
-	src_b->reap_ctxt_switch_num + src_b->reap_ctxt_switch_num;
+	dest->reap_ctxt_switch_num =
+	    src_b->reap_ctxt_switch_num + src_b->reap_ctxt_switch_num;
 
-    dest->cpu_utilization = DT_max (src_a->cpu_utilization,
-				   src_b->cpu_utilization);
-    dest->time_ts = DT_max (src_a->time_ts, src_b->time_ts);
+	dest->cpu_utilization = DT_max(src_a->cpu_utilization,
+				       src_b->cpu_utilization);
+	dest->time_ts = DT_max(src_a->time_ts, src_b->time_ts);
 
-    DT_performance_stats_data_combine (&dest->posts_sans_ctxt,
-				      &src_a->posts_sans_ctxt,
-				      &src_b->posts_sans_ctxt);
+	DT_performance_stats_data_combine(&dest->posts_sans_ctxt,
+					  &src_a->posts_sans_ctxt,
+					  &src_b->posts_sans_ctxt);
 
-    DT_performance_stats_data_combine (&dest->posts_with_ctxt,
-				      &src_a->posts_with_ctxt,
-				      &src_b->posts_with_ctxt);
+	DT_performance_stats_data_combine(&dest->posts_with_ctxt,
+					  &src_a->posts_with_ctxt,
+					  &src_b->posts_with_ctxt);
 
-    DT_performance_stats_data_combine (&dest->reaps_sans_ctxt,
-				      &src_a->reaps_sans_ctxt,
-				      &src_b->reaps_sans_ctxt);
+	DT_performance_stats_data_combine(&dest->reaps_sans_ctxt,
+					  &src_a->reaps_sans_ctxt,
+					  &src_b->reaps_sans_ctxt);
 
-    DT_performance_stats_data_combine (&dest->reaps_with_ctxt,
-				      &src_a->reaps_with_ctxt,
-				      &src_b->reaps_with_ctxt);
+	DT_performance_stats_data_combine(&dest->reaps_with_ctxt,
+					  &src_a->reaps_with_ctxt,
+					  &src_b->reaps_with_ctxt);
 
-    DT_performance_stats_data_combine (&dest->latency,
-				      &src_a->latency,
-				      &src_b->latency);
+	DT_performance_stats_data_combine(&dest->latency,
+					  &src_a->latency, &src_b->latency);
 }
 
-
 double
-DT_performance_stats_data_print (
-    DT_Tdep_Print_Head			*phead,
-    Performance_Stats_Data_t 		*data,
-    double          			cpu_mhz)
+DT_performance_stats_data_print(DT_Tdep_Print_Head * phead,
+				Performance_Stats_Data_t * data, double cpu_mhz)
 {
-    double 				average;
+	double average;
 
-    average = (int64_t)data->total_ts / (data->num * cpu_mhz);
+	average = (int64_t) data->total_ts / (data->num * cpu_mhz);
 
-    DT_Tdep_PT_Printf (phead,
-	    	   "    Arithmetic mean      : %d.%d us\n"
-		   "    maximum              : %d.%d us\n"
-		   "    minimum              : %d.%d us\n",
-		   DT_whole(average),DT_hundredths(average),
-		   DT_whole((int64_t)data->max_ts / cpu_mhz),DT_hundredths((int64_t)data->max_ts / cpu_mhz),
-		   DT_whole((int64_t)data->min_ts / cpu_mhz),DT_hundredths((int64_t)data->min_ts / cpu_mhz));
-    return average;
+	DT_Tdep_PT_Printf(phead,
+			  "    Arithmetic mean      : %d.%d us\n"
+			  "    maximum              : %d.%d us\n"
+			  "    minimum              : %d.%d us\n",
+			  DT_whole(average), DT_hundredths(average),
+			  DT_whole((int64_t) data->max_ts / cpu_mhz),
+			  DT_hundredths((int64_t) data->max_ts / cpu_mhz),
+			  DT_whole((int64_t) data->min_ts / cpu_mhz),
+			  DT_hundredths((int64_t) data->min_ts / cpu_mhz));
+	return average;
 }
 
-
 void
-DT_performance_stats_print (
-    Params_t				*params_ptr,
-    DT_Tdep_Print_Head			*phead, 
-    Performance_Stats_t 		*stats,
-    Performance_Cmd_t           	*cmd,
-    Performance_Test_t			*test)
+DT_performance_stats_print(Params_t * params_ptr,
+			   DT_Tdep_Print_Head * phead,
+			   Performance_Stats_t * stats,
+			   Performance_Cmd_t * cmd, Performance_Test_t * test)
 {
-    double          			cpu_mhz;
-    double          			time_s;
-    double          			mbytes;
-    double 				ops_per_sec;
-    double 				bandwidth;
-    double 				latency;
-    double 				time_per_post;
-    double 				time_per_reap;
+	double cpu_mhz;
+	double time_s;
+	double mbytes;
+	double ops_per_sec;
+	double bandwidth;
+	double latency;
+	double time_per_post;
+	double time_per_reap;
 
-    cpu_mhz = params_ptr->cpu_mhz;
-    latency = 0;
+	cpu_mhz = params_ptr->cpu_mhz;
+	latency = 0;
 #if defined(WIN32)
-    /*
-     * The Microsoft compiler is unable to do a 64 bit conversion when
-     * working with double. time_ts is a 64 bit value, so we
-     * potentially lose precision, so limit it to the Windows
-     * platform. Trying to do the operation below without casting
-     * a 64 bit value to an unsigned int results in the error when
-     * using Visual C 6.0:
-     *
-     *    Compiler Error C2520: conversion from unsigned __int64 to
-     *    double not implemented, use signed __int64.
-     *
-     * Note that signed __int64 doesn't work either!
-     */
-    time_s = (double) ((unsigned int)stats->time_ts / (1000000.0 * cpu_mhz));
+	/*
+	 * The Microsoft compiler is unable to do a 64 bit conversion when
+	 * working with double. time_ts is a 64 bit value, so we
+	 * potentially lose precision, so limit it to the Windows
+	 * platform. Trying to do the operation below without casting
+	 * a 64 bit value to an unsigned int results in the error when
+	 * using Visual C 6.0:
+	 *
+	 *    Compiler Error C2520: conversion from unsigned __int64 to
+	 *    double not implemented, use signed __int64.
+	 *
+	 * Note that signed __int64 doesn't work either!
+	 */
+	time_s = (double)((unsigned int)stats->time_ts / (1000000.0 * cpu_mhz));
 #else
-    time_s = (double) (stats->time_ts / (1000000.0 * cpu_mhz));
+	time_s = (double)(stats->time_ts / (1000000.0 * cpu_mhz));
 #endif
-    mbytes = (double) (1.0 * stats->bytes) / 1024 / 1024;
+	mbytes = (double)(1.0 * stats->bytes) / 1024 / 1024;
 
-    if ( 0.0 == time_s )
-    {
-	DT_Tdep_PT_Printf (phead, "Error determining time\n");
-	return;
-    }
-    else if ( 0 ==  stats->num_ops )
-    {
-	DT_Tdep_PT_Printf (phead, "Error determining number of operations\n");
-	return;
-    }
-    else if ( 0.0 == cpu_mhz )
-    {
-	DT_Tdep_PT_Printf (phead, "Error determining CPU speed\n");
-	return;
-    }
+	if (0.0 == time_s) {
+		DT_Tdep_PT_Printf(phead, "Error determining time\n");
+		return;
+	} else if (0 == stats->num_ops) {
+		DT_Tdep_PT_Printf(phead,
+				  "Error determining number of operations\n");
+		return;
+	} else if (0.0 == cpu_mhz) {
+		DT_Tdep_PT_Printf(phead, "Error determining CPU speed\n");
+		return;
+	}
 
-    ops_per_sec = stats->num_ops / time_s;
-    bandwidth = mbytes / time_s;
-    DT_Tdep_PT_Printf (phead, "------------------------- Statistics -------------------------\n");
-    DT_Tdep_PT_Printf (phead,
-		   "    Mode                 : %s\n"
-		   "    Operation Type       : %s\n"
-		   "    Number of Operations : %u\n"
-		   "    Segment Size         : %u\n"
-		   "    Number of Segments   : %u \n"
-		   "    Pipeline Length      : %u\n\n",
-		   DT_PerformanceModeToString (cmd->mode),
-		   DT_TransferTypeToString (cmd->op.transfer_type),
-		   cmd->num_iterations,
-		   cmd->op.seg_size,
-		   cmd->op.num_segs,
-		   test->ep_context.pipeline_len);
+	ops_per_sec = stats->num_ops / time_s;
+	bandwidth = mbytes / time_s;
+	DT_Tdep_PT_Printf(phead,
+			  "------------------------- Statistics -------------------------\n");
+	DT_Tdep_PT_Printf(phead,
+			  "    Mode                 : %s\n"
+			  "    Operation Type       : %s\n"
+			  "    Number of Operations : %u\n"
+			  "    Segment Size         : %u\n"
+			  "    Number of Segments   : %u \n"
+			  "    Pipeline Length      : %u\n\n",
+			  DT_PerformanceModeToString(cmd->mode),
+			  DT_TransferTypeToString(cmd->op.transfer_type),
+			  cmd->num_iterations, cmd->op.seg_size,
+			  cmd->op.num_segs, test->ep_context.pipeline_len);
 
-    DT_Tdep_PT_Printf (phead,
-		    "    Total Time           : %d.%d sec\n"
-		    "    Total Data Exchanged : %d.%d MB\n"
-		    "    CPU Utilization      : %d.%d\n"
-		    "    Operation Throughput : %d.%d ops/sec\n"
-		    "    Bandwidth            : %d.%d MB/sec\n", 
-		    DT_whole(time_s),DT_hundredths(time_s),
-		    DT_whole(mbytes),DT_hundredths(mbytes),
-		    DT_whole(stats->cpu_utilization),DT_hundredths(stats->cpu_utilization),
-		    DT_whole(ops_per_sec),DT_hundredths(ops_per_sec),
-		    DT_whole(bandwidth),DT_hundredths(bandwidth));
+	DT_Tdep_PT_Printf(phead,
+			  "    Total Time           : %d.%d sec\n"
+			  "    Total Data Exchanged : %d.%d MB\n"
+			  "    CPU Utilization      : %d.%d\n"
+			  "    Operation Throughput : %d.%d ops/sec\n"
+			  "    Bandwidth            : %d.%d MB/sec\n",
+			  DT_whole(time_s), DT_hundredths(time_s),
+			  DT_whole(mbytes), DT_hundredths(mbytes),
+			  DT_whole(stats->cpu_utilization),
+			  DT_hundredths(stats->cpu_utilization),
+			  DT_whole(ops_per_sec), DT_hundredths(ops_per_sec),
+			  DT_whole(bandwidth), DT_hundredths(bandwidth));
 
-    DT_Tdep_PT_Printf (phead, "\nLatency\n");
+	DT_Tdep_PT_Printf(phead, "\nLatency\n");
 
-    if ( stats->latency.num )
-    {
-	latency = DT_performance_stats_data_print (phead, 
-						   &stats->latency, 
-						   cpu_mhz);
-    }
-    DT_Tdep_PT_Printf (phead, "\n"
-		   "Time Per Post\n"
-		   "    %u posts without context switches\n",
-		   stats->posts_sans_ctxt.num);
+	if (stats->latency.num) {
+		latency = DT_performance_stats_data_print(phead,
+							  &stats->latency,
+							  cpu_mhz);
+	}
+	DT_Tdep_PT_Printf(phead, "\n"
+			  "Time Per Post\n"
+			  "    %u posts without context switches\n",
+			  stats->posts_sans_ctxt.num);
 
-    if ( stats->posts_sans_ctxt.num )
-    {
-	DT_performance_stats_data_print (phead, 
-					 &stats->posts_sans_ctxt, 
-					 cpu_mhz);
-    }
+	if (stats->posts_sans_ctxt.num) {
+		DT_performance_stats_data_print(phead,
+						&stats->posts_sans_ctxt,
+						cpu_mhz);
+	}
 
-    DT_Tdep_PT_Printf (phead, "\n"
-		   "    %u posts with context switches\n",
-		   stats->posts_with_ctxt.num);
+	DT_Tdep_PT_Printf(phead, "\n"
+			  "    %u posts with context switches\n",
+			  stats->posts_with_ctxt.num);
 
-    if ( stats->posts_with_ctxt.num )
-    {
-	DT_Tdep_PT_Printf (phead, "    %u number of context switches\n",
-		       stats->post_ctxt_switch_num);
-	DT_performance_stats_data_print (phead,
-					 &stats->posts_with_ctxt, 
-					 cpu_mhz);
-    }
+	if (stats->posts_with_ctxt.num) {
+		DT_Tdep_PT_Printf(phead, "    %u number of context switches\n",
+				  stats->post_ctxt_switch_num);
+		DT_performance_stats_data_print(phead,
+						&stats->posts_with_ctxt,
+						cpu_mhz);
+	}
 
-    DT_Tdep_PT_Printf (phead, "\n"
-		   "Time Per Reap\n"
-		   "    %u reaps without context switches\n",
-		   stats->reaps_sans_ctxt.num);
+	DT_Tdep_PT_Printf(phead, "\n"
+			  "Time Per Reap\n"
+			  "    %u reaps without context switches\n",
+			  stats->reaps_sans_ctxt.num);
 
-    if ( stats->reaps_sans_ctxt.num )
-    {
-	DT_performance_stats_data_print (phead,
-					 &stats->reaps_sans_ctxt, 
-					 cpu_mhz);
-    }
+	if (stats->reaps_sans_ctxt.num) {
+		DT_performance_stats_data_print(phead,
+						&stats->reaps_sans_ctxt,
+						cpu_mhz);
+	}
 
+	DT_Tdep_PT_Printf(phead, "\n"
+			  "    %u reaps with context switches\n",
+			  stats->reaps_with_ctxt.num);
 
-    DT_Tdep_PT_Printf (phead, "\n"
-		   "    %u reaps with context switches\n",
-		   stats->reaps_with_ctxt.num);
+	if (stats->reaps_with_ctxt.num) {
+		DT_Tdep_PT_Printf(phead, "\n"
+				  "    %u number of context switches\n",
+				  stats->reap_ctxt_switch_num);
 
-    if ( stats->reaps_with_ctxt.num )
-    {
-	DT_Tdep_PT_Printf (phead, "\n"
-		       "    %u number of context switches\n",
-		       stats->reap_ctxt_switch_num);
+		DT_performance_stats_data_print(phead,
+						&stats->reaps_with_ctxt,
+						cpu_mhz);
+	}
 
-	DT_performance_stats_data_print (phead,
-					 &stats->reaps_with_ctxt, 
-					 cpu_mhz);
-    }
+	time_per_post =
+	    (int64_t) (stats->posts_sans_ctxt.total_ts +
+		       stats->posts_with_ctxt.total_ts) / (cpu_mhz *
+							   (stats->
+							    posts_sans_ctxt.
+							    num +
+							    stats->
+							    posts_with_ctxt.
+							    num));
 
-    time_per_post =
-	(int64_t) (stats->posts_sans_ctxt.total_ts + stats->posts_with_ctxt.total_ts) /
-	(cpu_mhz * (stats->posts_sans_ctxt.num + stats->posts_with_ctxt.num));
+	time_per_reap =
+	    (int64_t) (stats->reaps_sans_ctxt.total_ts +
+		       stats->reaps_with_ctxt.total_ts) / (cpu_mhz *
+							   (stats->
+							    reaps_sans_ctxt.
+							    num +
+							    stats->
+							    reaps_with_ctxt.
+							    num));
 
-    time_per_reap =
-	(int64_t) (stats->reaps_sans_ctxt.total_ts + stats->reaps_with_ctxt.total_ts) /
-	(cpu_mhz * (stats->reaps_sans_ctxt.num + stats->reaps_with_ctxt.num));
-
-    DT_Tdep_PT_Printf (phead, 
-	               "\nNOTE: 1 MB = 1024 KB = 1048576 B \n");
-    DT_Tdep_PT_Printf (phead, 
-     "---------------------------------------------------------------------\n");
-    DT_Tdep_PT_Printf (phead, 
-        "raw: %s, %u, %u, %u, %u, %d.%d, %d.%d, %d.%d, %d.%d, %d.%d, %d.%d \n",
-		   DT_TransferTypeToString (cmd->op.transfer_type),
-		   cmd->num_iterations,
-		   cmd->op.seg_size,
-		   cmd->op.num_segs,
-		   test->ep_context.pipeline_len,
-		   DT_whole      (stats->cpu_utilization),
-		   DT_hundredths (stats->cpu_utilization),
-		   DT_whole      (ops_per_sec),
-		   DT_hundredths (ops_per_sec),
-		   DT_whole      (bandwidth),
-		   DT_hundredths (bandwidth),
-		   DT_whole      (latency),
-		   DT_hundredths (latency),
-		   DT_whole      (time_per_post),
-		   DT_hundredths (time_per_post),
-		   DT_whole      (time_per_reap),
-		   DT_hundredths (time_per_reap));
-    DT_Tdep_PT_Printf (phead, 
-     "---------------------------------------------------------------------\n");
+	DT_Tdep_PT_Printf(phead, "\nNOTE: 1 MB = 1024 KB = 1048576 B \n");
+	DT_Tdep_PT_Printf(phead,
+			  "---------------------------------------------------------------------\n");
+	DT_Tdep_PT_Printf(phead,
+			  "raw: %s, %u, %u, %u, %u, %d.%d, %d.%d, %d.%d, %d.%d, %d.%d, %d.%d \n",
+			  DT_TransferTypeToString(cmd->op.transfer_type),
+			  cmd->num_iterations,
+			  cmd->op.seg_size,
+			  cmd->op.num_segs,
+			  test->ep_context.pipeline_len,
+			  DT_whole(stats->cpu_utilization),
+			  DT_hundredths(stats->cpu_utilization),
+			  DT_whole(ops_per_sec),
+			  DT_hundredths(ops_per_sec),
+			  DT_whole(bandwidth),
+			  DT_hundredths(bandwidth),
+			  DT_whole(latency),
+			  DT_hundredths(latency),
+			  DT_whole(time_per_post),
+			  DT_hundredths(time_per_post),
+			  DT_whole(time_per_reap),
+			  DT_hundredths(time_per_reap));
+	DT_Tdep_PT_Printf(phead,
+			  "---------------------------------------------------------------------\n");
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_performance_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,649 +30,589 @@
 
 #include "dapl_proto.h"
 
-#define DT_Mdep_GetContextSwitchNum() 0 /* FIXME */
+#define DT_Mdep_GetContextSwitchNum() 0	/* FIXME */
 
 /****************************************************************************/
 bool
-DT_Performance_Test_Create (
-    Per_Test_Data_t 		*pt_ptr,
-    DAT_IA_HANDLE 		*ia_handle,
-    DAT_IA_ADDRESS_PTR 		remote_ia_addr,
-    DAT_BOOLEAN 		is_server,
-    DAT_BOOLEAN			is_remote_little_endian,
-    Performance_Test_t 		**perf_test)
+DT_Performance_Test_Create(Per_Test_Data_t * pt_ptr,
+			   DAT_IA_HANDLE * ia_handle,
+			   DAT_IA_ADDRESS_PTR remote_ia_addr,
+			   DAT_BOOLEAN is_server,
+			   DAT_BOOLEAN is_remote_little_endian,
+			   Performance_Test_t ** perf_test)
 {
-    Performance_Test_t 		*test_ptr;
-    DAT_COUNT			pipeline_len;
-    DAT_RETURN 			ret;
-    DT_Tdep_Print_Head		*phead;
+	Performance_Test_t *test_ptr;
+	DAT_COUNT pipeline_len;
+	DAT_RETURN ret;
+	DT_Tdep_Print_Head *phead;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    test_ptr = DT_MemListAlloc (pt_ptr,
-			       "transaction_test_t",
-			       TRANSACTIONTEST,
-			       sizeof (Performance_Test_t));
-    if ( NULL == test_ptr )
-    {
-	return false;
-    }
+	test_ptr = DT_MemListAlloc(pt_ptr,
+				   "transaction_test_t",
+				   TRANSACTIONTEST, sizeof(Performance_Test_t));
+	if (NULL == test_ptr) {
+		return false;
+	}
 
-    *perf_test = test_ptr;
+	*perf_test = test_ptr;
 
-    test_ptr->pt_ptr = pt_ptr;
-    test_ptr->remote_ia_addr = remote_ia_addr;
-    test_ptr->is_remote_little_endian = is_remote_little_endian;
-    test_ptr->base_port = (DAT_CONN_QUAL) pt_ptr->Server_Info.first_port_number;
-    test_ptr->ia_handle = ia_handle;
-    test_ptr->cmd = &pt_ptr->Params.u.Performance_Cmd;
+	test_ptr->pt_ptr = pt_ptr;
+	test_ptr->remote_ia_addr = remote_ia_addr;
+	test_ptr->is_remote_little_endian = is_remote_little_endian;
+	test_ptr->base_port =
+	    (DAT_CONN_QUAL) pt_ptr->Server_Info.first_port_number;
+	test_ptr->ia_handle = ia_handle;
+	test_ptr->cmd = &pt_ptr->Params.u.Performance_Cmd;
 
-    ret = dat_ia_query (test_ptr->ia_handle,
-			NULL,
-			DAT_IA_ALL,
-			&test_ptr->ia_attr,
-			0,
-			NULL);
-    if ( DAT_SUCCESS != ret)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ia_query error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	return false;
-    }
+	ret = dat_ia_query(test_ptr->ia_handle,
+			   NULL, DAT_IA_ALL, &test_ptr->ia_attr, 0, NULL);
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: dat_ia_query error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		return false;
+	}
 
-    pipeline_len = DT_min (
-	DT_min (test_ptr->cmd->num_iterations,
-	       test_ptr->cmd->pipeline_len),
-	DT_min (test_ptr->ia_attr.max_dto_per_ep,
-	       test_ptr->ia_attr.max_evd_qlen));
+	pipeline_len = DT_min(DT_min(test_ptr->cmd->num_iterations,
+				     test_ptr->cmd->pipeline_len),
+			      DT_min(test_ptr->ia_attr.max_dto_per_ep,
+				     test_ptr->ia_attr.max_evd_qlen));
 
-    if ( RDMA_READ == test_ptr->cmd->op.transfer_type )
-    {
-	pipeline_len = DT_min (pipeline_len,
-			      test_ptr->ia_attr.max_rdma_read_per_ep);
-    }
+	if (RDMA_READ == test_ptr->cmd->op.transfer_type) {
+		pipeline_len = DT_min(pipeline_len,
+				      test_ptr->ia_attr.max_rdma_read_per_ep);
+	}
 
-    test_ptr->reqt_evd_length = pipeline_len;
-    test_ptr->recv_evd_length = DT_PERF_DFLT_EVD_LENGTH;
-    test_ptr->conn_evd_length = DT_PERF_DFLT_EVD_LENGTH;
-    test_ptr->creq_evd_length = DT_PERF_DFLT_EVD_LENGTH;
+	test_ptr->reqt_evd_length = pipeline_len;
+	test_ptr->recv_evd_length = DT_PERF_DFLT_EVD_LENGTH;
+	test_ptr->conn_evd_length = DT_PERF_DFLT_EVD_LENGTH;
+	test_ptr->creq_evd_length = DT_PERF_DFLT_EVD_LENGTH;
 
-    /* create a protection zone */
-    ret = dat_pz_create (test_ptr->ia_handle, &test_ptr->pz_handle);
-    if ( DAT_SUCCESS != ret)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_pz_create error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->pz_handle = DAT_HANDLE_NULL;
-	return false;
-    }
+	/* create a protection zone */
+	ret = dat_pz_create(test_ptr->ia_handle, &test_ptr->pz_handle);
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: dat_pz_create error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		test_ptr->pz_handle = DAT_HANDLE_NULL;
+		return false;
+	}
 
-    /* create 4 EVDs - recv, request+RMR, conn-request, connect */
-    ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			  test_ptr->recv_evd_length,
-			  test_ptr->cno_handle,
-			  DAT_EVD_DTO_FLAG,
-			  &test_ptr->recv_evd_hdl);  /* recv */
-    if ( DAT_SUCCESS != ret)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (recv) error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->recv_evd_hdl = DAT_HANDLE_NULL;
-	return false;
-    }
+	/* create 4 EVDs - recv, request+RMR, conn-request, connect */
+	ret = DT_Tdep_evd_create(test_ptr->ia_handle, test_ptr->recv_evd_length, test_ptr->cno_handle, DAT_EVD_DTO_FLAG, &test_ptr->recv_evd_hdl);	/* recv */
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x
+				  "]: dat_evd_create (recv) error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		test_ptr->recv_evd_hdl = DAT_HANDLE_NULL;
+		return false;
+	}
 
-    ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			  test_ptr->reqt_evd_length,
-			  test_ptr->cno_handle,
-			  DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			  &test_ptr->reqt_evd_hdl);  /* request + rmr bind */
-    if ( DAT_SUCCESS != ret)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (request) error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->reqt_evd_hdl = DAT_HANDLE_NULL;
-	return false;
-    }
+	ret = DT_Tdep_evd_create(test_ptr->ia_handle, test_ptr->reqt_evd_length, test_ptr->cno_handle, DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG, &test_ptr->reqt_evd_hdl);	/* request + rmr bind */
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x
+				  "]: dat_evd_create (request) error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		test_ptr->reqt_evd_hdl = DAT_HANDLE_NULL;
+		return false;
+	}
 
+	if (is_server) {
+		/* Client-side doesn't need CR events */
+		ret = DT_Tdep_evd_create(test_ptr->ia_handle, test_ptr->creq_evd_length, DAT_HANDLE_NULL, DAT_EVD_CR_FLAG, &test_ptr->creq_evd_hdl);	/* cr */
+		if (DAT_SUCCESS != ret) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_create (cr) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			test_ptr->creq_evd_hdl = DAT_HANDLE_NULL;
+			return false;
+		}
+	}
 
-    if ( is_server )
-    {
-	/* Client-side doesn't need CR events */
-	ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			      test_ptr->creq_evd_length,
-			      DAT_HANDLE_NULL,
-			      DAT_EVD_CR_FLAG,
-			      &test_ptr->creq_evd_hdl);	 /* cr */
-	if ( DAT_SUCCESS != ret)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (cr) error: %s\n",
-			   test_ptr->base_port, DT_RetToString (ret));
-	    test_ptr->creq_evd_hdl = DAT_HANDLE_NULL;
-	    return false;
+	ret = DT_Tdep_evd_create(test_ptr->ia_handle, test_ptr->conn_evd_length, DAT_HANDLE_NULL, DAT_EVD_CONNECTION_FLAG, &test_ptr->conn_evd_hdl);	/* conn */
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x
+				  "]: dat_evd_create (conn) error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		test_ptr->conn_evd_hdl = DAT_HANDLE_NULL;
+		return false;
 	}
-    }
 
-    ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			  test_ptr->conn_evd_length,
-			  DAT_HANDLE_NULL,
-			  DAT_EVD_CONNECTION_FLAG,
-			  &test_ptr->conn_evd_hdl);  /* conn */
-    if ( DAT_SUCCESS != ret)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (conn) error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->conn_evd_hdl = DAT_HANDLE_NULL;
-	return false;
-    }
+	/*
+	 * Set up the EP context:
+	 *          create the EP
+	 *          allocate buffers for remote memory info and sync message
+	 *          post the receive buffers
+	 *          connect
+	 *          set up buffers and remote memory info
+	 *          send across our info
+	 *          recv the other side's info and extract what we need
+	 */
+	test_ptr->ep_context.ep_attr = test_ptr->pt_ptr->ep_attr;
+	test_ptr->ep_context.ep_attr.max_request_dtos = pipeline_len;
 
-    /*
-     * Set up the EP context:
-     *          create the EP
-     *          allocate buffers for remote memory info and sync message
-     *          post the receive buffers
-     *          connect
-     *          set up buffers and remote memory info
-     *          send across our info
-     *          recv the other side's info and extract what we need
-     */
-    test_ptr->ep_context.ep_attr = test_ptr->pt_ptr->ep_attr;
-    test_ptr->ep_context.ep_attr.max_request_dtos = pipeline_len;
+	/* Create EP */
+	ret = dat_ep_create(test_ptr->ia_handle,	/* IA       */
+			    test_ptr->pz_handle,	/* PZ       */
+			    test_ptr->recv_evd_hdl,	/* recv     */
+			    test_ptr->reqt_evd_hdl,	/* request  */
+			    test_ptr->conn_evd_hdl,	/* connect  */
+			    &test_ptr->ep_context.ep_attr,	/* EP attrs */
+			    &test_ptr->ep_context.ep_handle);
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: dat_ep_create error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		test_ptr->ep_context.ep_handle = DAT_HANDLE_NULL;
+		return false;
+	}
 
-    /* Create EP */
-    ret = dat_ep_create (test_ptr->ia_handle,	 /* IA       */
-			 test_ptr->pz_handle,	 /* PZ       */
-			 test_ptr->recv_evd_hdl, /* recv     */
-			 test_ptr->reqt_evd_hdl, /* request  */
-			 test_ptr->conn_evd_hdl, /* connect  */
-			 &test_ptr->ep_context.ep_attr, /* EP attrs */
-			 &test_ptr->ep_context.ep_handle);
-    if ( DAT_SUCCESS != ret)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ep_create error: %s\n",
-		       test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->ep_context.ep_handle = DAT_HANDLE_NULL;
-	return false;
-    }
+	/*
+	 * Allocate a buffer pool so we can exchange the
+	 * remote memory info and initialize.
+	 */
+	test_ptr->ep_context.bp = DT_BpoolAlloc(test_ptr->pt_ptr, phead, test_ptr->ia_handle, test_ptr->pz_handle, test_ptr->ep_context.ep_handle, DAT_HANDLE_NULL,	/* rmr */
+						DT_PERF_SYNC_BUFF_SIZE, 2,	/* 2 RMIs */
+						DAT_OPTIMAL_ALIGNMENT,
+						false, false);
+	if (!test_ptr->ep_context.bp) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x
+				  "]: no memory for remote memory buffers\n",
+				  test_ptr->base_port);
+		return false;
+	}
 
-    /*
-     * Allocate a buffer pool so we can exchange the
-     * remote memory info and initialize.
-     */
-    test_ptr->ep_context.bp = DT_BpoolAlloc (test_ptr->pt_ptr,
-	    				    phead,
-					    test_ptr->ia_handle,
-					    test_ptr->pz_handle,
-					    test_ptr->ep_context.ep_handle,
-					    DAT_HANDLE_NULL, /* rmr */
-					    DT_PERF_SYNC_BUFF_SIZE,
-					    2, /* 2 RMIs */
-					    DAT_OPTIMAL_ALIGNMENT,
-					    false,
-					    false);
-    if ( !test_ptr->ep_context.bp )
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for remote memory buffers\n",
-		       test_ptr->base_port);
-	return false;
-    }
+	DT_Tdep_PT_Debug(3, (phead,
+			     "0: SYNC_SEND  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+							    ep_context.bp,
+							    DT_PERF_SYNC_SEND_BUFFER_ID)));
+	DT_Tdep_PT_Debug(3,
+			 (phead, "1: SYNC_RECV  %p\n",
+			  (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->ep_context.
+							 bp,
+							 DT_PERF_SYNC_RECV_BUFFER_ID)));
 
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "0: SYNC_SEND  %p\n", 
-		      (DAT_PVOID) DT_Bpool_GetBuffer (test_ptr->ep_context.bp,
-					      DT_PERF_SYNC_SEND_BUFFER_ID)));
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "1: SYNC_RECV  %p\n", 
-		      (DAT_PVOID) DT_Bpool_GetBuffer (test_ptr->ep_context.bp, 
-					      DT_PERF_SYNC_RECV_BUFFER_ID)));
+	/*
+	 * Post recv and sync buffers
+	 */
+	if (!DT_post_recv_buffer(phead,
+				 test_ptr->ep_context.ep_handle,
+				 test_ptr->ep_context.bp,
+				 DT_PERF_SYNC_RECV_BUFFER_ID,
+				 DT_PERF_SYNC_BUFF_SIZE)) {
+		/* error message printed by DT_post_recv_buffer */
+		return false;
+	}
 
-    /*
-     * Post recv and sync buffers
-     */
-    if ( !DT_post_recv_buffer (phead,
-			      test_ptr->ep_context.ep_handle,
-			      test_ptr->ep_context.bp,
-			      DT_PERF_SYNC_RECV_BUFFER_ID,
-			      DT_PERF_SYNC_BUFF_SIZE) )
-    {
-	/* error message printed by DT_post_recv_buffer */
-	return false;
-    }
+	/*
+	 * Fill in the test_ptr with relevant command info
+	 */
+	test_ptr->ep_context.op.transfer_type = test_ptr->cmd->op.transfer_type;
+	test_ptr->ep_context.op.num_segs = test_ptr->cmd->op.num_segs;
+	test_ptr->ep_context.op.seg_size = test_ptr->cmd->op.seg_size;
 
-    /*
-     * Fill in the test_ptr with relevant command info
-     */
-    test_ptr->ep_context.op.transfer_type
-	= test_ptr->cmd->op.transfer_type;
-    test_ptr->ep_context.op.num_segs
-	= test_ptr->cmd->op.num_segs;
-    test_ptr->ep_context.op.seg_size
-	= test_ptr->cmd->op.seg_size;
+	/*
+	 * Exchange remote memory info:  If we're going to participate
+	 * in an RDMA, we need to allocate memory buffers and advertise
+	 * them to the other side.
+	 */
+	test_ptr->ep_context.op.Rdma_Context = (DAT_RMR_CONTEXT) 0;
+	test_ptr->ep_context.op.Rdma_Address = 0;
+	test_ptr->ep_context.port = test_ptr->base_port;
+	test_ptr->ep_context.pipeline_len = pipeline_len;
 
-    /*
-     * Exchange remote memory info:  If we're going to participate
-     * in an RDMA, we need to allocate memory buffers and advertise
-     * them to the other side.
-     */
-    test_ptr->ep_context.op.Rdma_Context = (DAT_RMR_CONTEXT) 0;
-    test_ptr->ep_context.op.Rdma_Address = 0;
-    test_ptr->ep_context.port = test_ptr->base_port;
-    test_ptr->ep_context.pipeline_len = pipeline_len;
-
-    return true;
+	return true;
 }
 
-
 /****************************************************************************/
 void
-DT_Performance_Test_Destroy (
-    Per_Test_Data_t 		*pt_ptr,
-    Performance_Test_t 		*test_ptr,
-    DAT_BOOLEAN 		is_server)
+DT_Performance_Test_Destroy(Per_Test_Data_t * pt_ptr,
+			    Performance_Test_t * test_ptr,
+			    DAT_BOOLEAN is_server)
 {
-    DAT_RETURN 			ret;
-    DAT_EP_HANDLE               ep_handle;
-    DT_Tdep_Print_Head		*phead;
+	DAT_RETURN ret;
+	DAT_EP_HANDLE ep_handle;
+	DT_Tdep_Print_Head *phead;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    ep_handle = DAT_HANDLE_NULL;
+	ep_handle = DAT_HANDLE_NULL;
 
-    /* Free the per-op buffers */
-    if (test_ptr->ep_context.op.bp)
-    {
-	if (!DT_Bpool_Destroy (test_ptr->pt_ptr,
-		    	       phead,
-			      test_ptr->ep_context.op.bp))
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Warning: Bpool destroy fails\n",
-			   test_ptr->base_port);
-	    /* carry on trying, regardless */
+	/* Free the per-op buffers */
+	if (test_ptr->ep_context.op.bp) {
+		if (!DT_Bpool_Destroy(test_ptr->pt_ptr,
+				      phead, test_ptr->ep_context.op.bp)) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: Warning: Bpool destroy fails\n",
+					  test_ptr->base_port);
+			/* carry on trying, regardless */
+		}
 	}
-    }
 
-    /* Free the remote memory info exchange buffers */
-    if (test_ptr->ep_context.bp)
-    {
-	if (!DT_Bpool_Destroy (test_ptr->pt_ptr,
-		    	       phead,
-			      test_ptr->ep_context.bp))
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Warning: Bpool destroy fails\n",
-			   test_ptr->base_port);
-	    /* carry on trying, regardless */
+	/* Free the remote memory info exchange buffers */
+	if (test_ptr->ep_context.bp) {
+		if (!DT_Bpool_Destroy(test_ptr->pt_ptr,
+				      phead, test_ptr->ep_context.bp)) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: Warning: Bpool destroy fails\n",
+					  test_ptr->base_port);
+			/* carry on trying, regardless */
+		}
 	}
-    }
 
-    /*
-     * Disconnect -- we may have left recv buffers posted, if we
-     *		     bailed out mid-setup, or ran to completion
-     *		     normally, so we use abrupt closure.
-     */
-    if (test_ptr->ep_context.ep_handle)
-    {
-	ret = dat_ep_disconnect (test_ptr->ep_context.ep_handle,
-				DAT_CLOSE_ABRUPT_FLAG);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Warning: dat_ep_disconnect error %s\n",
-			   test_ptr->base_port,
-			   DT_RetToString (ret));
-	    /* carry on trying, regardless */
+	/*
+	 * Disconnect -- we may have left recv buffers posted, if we
+	 *               bailed out mid-setup, or ran to completion
+	 *               normally, so we use abrupt closure.
+	 */
+	if (test_ptr->ep_context.ep_handle) {
+		ret = dat_ep_disconnect(test_ptr->ep_context.ep_handle,
+					DAT_CLOSE_ABRUPT_FLAG);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: Warning: dat_ep_disconnect error %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* carry on trying, regardless */
+		} else if (!DT_disco_event_wait(phead, test_ptr->conn_evd_hdl,
+						&ep_handle)) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: bad disconnect event\n",
+					  test_ptr->base_port);
+		}
 	}
-	else if (!DT_disco_event_wait ( phead, test_ptr->conn_evd_hdl,
-				       &ep_handle))
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: bad disconnect event\n",
-			    test_ptr->base_port);
-	}
-    }
 
-    if ( DAT_HANDLE_NULL != ep_handle)
-    {
-	/* Destroy the EP */
-	ret = dat_ep_free (ep_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ep_free error: %s\n",
-			   test_ptr->base_port, DT_RetToString (ret));
-	    /* carry on trying, regardless */
+	if (DAT_HANDLE_NULL != ep_handle) {
+		/* Destroy the EP */
+		ret = dat_ep_free(ep_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_ep_free error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* carry on trying, regardless */
+		}
 	}
-    }
 
-    /* clean up the EVDs */
-    if (test_ptr->conn_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (test_ptr->conn_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (conn) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
+	/* clean up the EVDs */
+	if (test_ptr->conn_evd_hdl) {
+		ret = DT_Tdep_evd_free(test_ptr->conn_evd_hdl);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_free (conn) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* fall through, keep trying */
+		}
 	}
-    }
-    if (is_server)
-    {
-	if (test_ptr->creq_evd_hdl)
-	{
-	    ret = DT_Tdep_evd_free (test_ptr->creq_evd_hdl);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (creq) error: %s\n",
-			    test_ptr->base_port, DT_RetToString (ret));
-		/* fall through, keep trying */
-	    }
+	if (is_server) {
+		if (test_ptr->creq_evd_hdl) {
+			ret = DT_Tdep_evd_free(test_ptr->creq_evd_hdl);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test[" F64x
+						  "]: dat_evd_free (creq) error: %s\n",
+						  test_ptr->base_port,
+						  DT_RetToString(ret));
+				/* fall through, keep trying */
+			}
+		}
 	}
-    }
-    if (test_ptr->reqt_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (test_ptr->reqt_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (reqt) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
+	if (test_ptr->reqt_evd_hdl) {
+		ret = DT_Tdep_evd_free(test_ptr->reqt_evd_hdl);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_free (reqt) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* fall through, keep trying */
+		}
 	}
-    }
-    if (test_ptr->recv_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (test_ptr->recv_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (recv) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
+	if (test_ptr->recv_evd_hdl) {
+		ret = DT_Tdep_evd_free(test_ptr->recv_evd_hdl);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_free (recv) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* fall through, keep trying */
+		}
 	}
-    }
 
-    /* clean up the PZ */
-    if (test_ptr->pz_handle)
-    {
-	ret = dat_pz_free (test_ptr->pz_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_pz_free error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
+	/* clean up the PZ */
+	if (test_ptr->pz_handle) {
+		ret = dat_pz_free(test_ptr->pz_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_pz_free error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* fall through, keep trying */
+		}
 	}
-    }
 
-    DT_MemListFree (test_ptr->pt_ptr, test_ptr);
-    DT_Tdep_PT_Debug (1, (phead,"Test[" F64x "]: cleanup is done\n", test_ptr->base_port));
+	DT_MemListFree(test_ptr->pt_ptr, test_ptr);
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: cleanup is done\n",
+			  test_ptr->base_port));
 
 }
 
-
 /****************************************************************************/
 bool
-DT_performance_post_rdma_op (
-    Performance_Ep_Context_t 	*ep_context,
-    DAT_EVD_HANDLE 		reqt_evd_hdl,
-    Performance_Stats_t 	*stats)
+DT_performance_post_rdma_op(Performance_Ep_Context_t * ep_context,
+			    DAT_EVD_HANDLE reqt_evd_hdl,
+			    Performance_Stats_t * stats)
 {
-    unsigned int 		j;
-    unsigned long int		bytes;
-    unsigned long 		pre_ctxt_num;
-    unsigned long 		post_ctxt_num;
-    DT_Mdep_TimeStamp 		pre_ts;
-    DT_Mdep_TimeStamp 		post_ts;
-    DAT_DTO_COOKIE 		cookie;
-    DAT_RETURN      		ret;
-    Performance_Test_Op_t   	*op = &ep_context->op;
-    DAT_LMR_TRIPLET         	*iov  = DT_Bpool_GetIOV (op->bp, 0);
-    DAT_RMR_TRIPLET         	rmr_triplet;
+	unsigned int j;
+	unsigned long int bytes;
+	unsigned long pre_ctxt_num;
+	unsigned long post_ctxt_num;
+	DT_Mdep_TimeStamp pre_ts;
+	DT_Mdep_TimeStamp post_ts;
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN ret;
+	Performance_Test_Op_t *op = &ep_context->op;
+	DAT_LMR_TRIPLET *iov = DT_Bpool_GetIOV(op->bp, 0);
+	DAT_RMR_TRIPLET rmr_triplet;
 
-    bytes = op->seg_size * op->num_segs;
+	bytes = op->seg_size * op->num_segs;
 
-    /* Prep the inputs */
-    for (j = 0;  j < op->num_segs;  j++)
-    {
-	iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
-	    DT_Bpool_GetBuffer (op->bp, j);
-	iov[j].segment_length  = op->seg_size;
-	iov[j].lmr_context     = DT_Bpool_GetLMR (op->bp, j);
-    }
+	/* Prep the inputs */
+	for (j = 0; j < op->num_segs; j++) {
+		iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
+		    DT_Bpool_GetBuffer(op->bp, j);
+		iov[j].segment_length = op->seg_size;
+		iov[j].lmr_context = DT_Bpool_GetLMR(op->bp, j);
+	}
 
-    rmr_triplet.virtual_address  = op->Rdma_Address;
-    rmr_triplet.segment_length  = op->seg_size * op->num_segs;
-    rmr_triplet.rmr_context     = op->Rdma_Context;
+	rmr_triplet.virtual_address = op->Rdma_Address;
+	rmr_triplet.segment_length = op->seg_size * op->num_segs;
+	rmr_triplet.rmr_context = op->Rdma_Context;
 
-    cookie.as_ptr = NULL;
+	cookie.as_ptr = NULL;
 
-    if ( RDMA_WRITE == op->transfer_type )
-    {
-	pre_ctxt_num = DT_Mdep_GetContextSwitchNum ();
-	pre_ts = DT_Mdep_GetTimeStamp ();
+	if (RDMA_WRITE == op->transfer_type) {
+		pre_ctxt_num = DT_Mdep_GetContextSwitchNum();
+		pre_ts = DT_Mdep_GetTimeStamp();
 
-	ret = dat_ep_post_rdma_write (ep_context->ep_handle,
-				     op->num_segs,
-				     iov,
-				     cookie,
-				     &rmr_triplet,
-				     DAT_COMPLETION_DEFAULT_FLAG);
+		ret = dat_ep_post_rdma_write(ep_context->ep_handle,
+					     op->num_segs,
+					     iov,
+					     cookie,
+					     &rmr_triplet,
+					     DAT_COMPLETION_DEFAULT_FLAG);
 
-	post_ts = DT_Mdep_GetTimeStamp ();
-	post_ctxt_num = DT_Mdep_GetContextSwitchNum ();
+		post_ts = DT_Mdep_GetTimeStamp();
+		post_ctxt_num = DT_Mdep_GetContextSwitchNum();
 
-	stats->bytes += bytes;
-    }
-    else
-    {
-	pre_ctxt_num = DT_Mdep_GetContextSwitchNum ();
-	pre_ts = DT_Mdep_GetTimeStamp ();
+		stats->bytes += bytes;
+	} else {
+		pre_ctxt_num = DT_Mdep_GetContextSwitchNum();
+		pre_ts = DT_Mdep_GetTimeStamp();
 
-	ret = dat_ep_post_rdma_read (ep_context->ep_handle,
-				    op->num_segs,
-				    iov,
-				    cookie,
-				    &rmr_triplet,
-				    DAT_COMPLETION_DEFAULT_FLAG);
+		ret = dat_ep_post_rdma_read(ep_context->ep_handle,
+					    op->num_segs,
+					    iov,
+					    cookie,
+					    &rmr_triplet,
+					    DAT_COMPLETION_DEFAULT_FLAG);
 
-	post_ts = DT_Mdep_GetTimeStamp ();
-	post_ctxt_num = DT_Mdep_GetContextSwitchNum ();
+		post_ts = DT_Mdep_GetTimeStamp();
+		post_ctxt_num = DT_Mdep_GetContextSwitchNum();
 
-	stats->bytes += bytes;
-    }
+		stats->bytes += bytes;
+	}
 
-    if ( DAT_SUCCESS != ret )
-    {
-	return false;
-    }
+	if (DAT_SUCCESS != ret) {
+		return false;
+	}
 
-    DT_performance_stats_record_post (stats,
-				     post_ctxt_num - pre_ctxt_num,
-				     post_ts - pre_ts);
+	DT_performance_stats_record_post(stats,
+					 post_ctxt_num - pre_ctxt_num,
+					 post_ts - pre_ts);
 
-    return true;
+	return true;
 }
 
 /****************************************************************************/
 unsigned int
-DT_performance_reap (
-    DT_Tdep_Print_Head			*phead,
-    DAT_EVD_HANDLE 			evd_handle,
-    Performance_Mode_Type		mode,
-    Performance_Stats_t 		*stats)
+DT_performance_reap(DT_Tdep_Print_Head * phead,
+		    DAT_EVD_HANDLE evd_handle,
+		    Performance_Mode_Type mode, Performance_Stats_t * stats)
 {
-    if ( BLOCKING_MODE == mode )
-    {
-	return DT_performance_wait (phead, evd_handle, stats);
-    }
-    else
-    {
-	return DT_performance_poll (phead, evd_handle, stats);
-    }
+	if (BLOCKING_MODE == mode) {
+		return DT_performance_wait(phead, evd_handle, stats);
+	} else {
+		return DT_performance_poll(phead, evd_handle, stats);
+	}
 }
 
 /****************************************************************************/
 unsigned int
-DT_performance_wait (
-    DT_Tdep_Print_Head			*phead,
-    DAT_EVD_HANDLE 			evd_handle,
-    Performance_Stats_t 		*stats)
+DT_performance_wait(DT_Tdep_Print_Head * phead,
+		    DAT_EVD_HANDLE evd_handle, Performance_Stats_t * stats)
 {
-    DAT_COUNT			i;
-    DAT_COUNT			queue_size;
-    DAT_RETURN      		ret;
-    DAT_EVENT       		event;
-    unsigned long 		pre_ctxt_num;
-    unsigned long 		post_ctxt_num;
-    DT_Mdep_TimeStamp 		pre_ts;
-    DT_Mdep_TimeStamp 		post_ts;
+	DAT_COUNT i;
+	DAT_COUNT queue_size;
+	DAT_RETURN ret;
+	DAT_EVENT event;
+	unsigned long pre_ctxt_num;
+	unsigned long post_ctxt_num;
+	DT_Mdep_TimeStamp pre_ts;
+	DT_Mdep_TimeStamp post_ts;
 
-    queue_size = 0;
+	queue_size = 0;
 
-    pre_ctxt_num = DT_Mdep_GetContextSwitchNum ();
-    pre_ts = DT_Mdep_GetTimeStamp ();
+	pre_ctxt_num = DT_Mdep_GetContextSwitchNum();
+	pre_ts = DT_Mdep_GetTimeStamp();
 
-    ret = DT_Tdep_evd_wait ( evd_handle,
-			DAT_TIMEOUT_INFINITE,
-			&event);
+	ret = DT_Tdep_evd_wait(evd_handle, DAT_TIMEOUT_INFINITE, &event);
 
-    post_ts = DT_Mdep_GetTimeStamp ();
-    post_ctxt_num = DT_Mdep_GetContextSwitchNum ();
+	post_ts = DT_Mdep_GetTimeStamp();
+	post_ctxt_num = DT_Mdep_GetContextSwitchNum();
 
-    if ( DAT_SUCCESS != ret )
-    {
-	DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_dequeue failed: %s\n",
-		       DT_RetToString (ret));
-	return 0;
-    }
-    else if (event.event_number == DAT_DTO_COMPLETION_EVENT)
-    {
-	DT_performance_stats_record_reap (stats,
-					 post_ctxt_num - pre_ctxt_num,
-					 post_ts - pre_ts);
-    }
-    else
-    {
-	/* This should not happen. There has been an error if it does. */
+	if (DAT_SUCCESS != ret) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test Error: dapl_event_dequeue failed: %s\n",
+				  DT_RetToString(ret));
+		return 0;
+	} else if (event.event_number == DAT_DTO_COMPLETION_EVENT) {
+		DT_performance_stats_record_reap(stats,
+						 post_ctxt_num - pre_ctxt_num,
+						 post_ts - pre_ts);
+	} else {
+		/* This should not happen. There has been an error if it does. */
 
-	DT_Tdep_PT_Printf (phead, "Warning: dapl_performance_wait swallowing %s event\n",
-		       DT_EventToSTr (event.event_number));
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: dapl_performance_wait swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 
-	return 0;
-    }
+		return 0;
+	}
 
-    for ( i = 0; i < queue_size; i++ )
-    {
-	pre_ctxt_num = DT_Mdep_GetContextSwitchNum ();
-	pre_ts = DT_Mdep_GetTimeStamp ();
+	for (i = 0; i < queue_size; i++) {
+		pre_ctxt_num = DT_Mdep_GetContextSwitchNum();
+		pre_ts = DT_Mdep_GetTimeStamp();
 
-	ret = DT_Tdep_evd_dequeue ( evd_handle,
-			       &event);
+		ret = DT_Tdep_evd_dequeue(evd_handle, &event);
 
-	post_ts = DT_Mdep_GetTimeStamp ();
-	post_ctxt_num = DT_Mdep_GetContextSwitchNum ();
+		post_ts = DT_Mdep_GetTimeStamp();
+		post_ctxt_num = DT_Mdep_GetContextSwitchNum();
 
-	if (DAT_GET_TYPE (ret) == DAT_QUEUE_EMPTY)
-	{
-	    continue;
-	}
-	else if ( DAT_SUCCESS != ret )
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_dequeue failed: %s\n",
-			   DT_RetToString (ret));
-	    return 0;
-	}
-	else if (event.event_number == DAT_DTO_COMPLETION_EVENT)
-	{
-	    DT_performance_stats_record_reap (stats,
-					     post_ctxt_num - pre_ctxt_num,
-					     post_ts - pre_ts);
-	}
-	else
-	{
-	    /* This should not happen. There has been an error if it does. */
+		if (DAT_GET_TYPE(ret) == DAT_QUEUE_EMPTY) {
+			continue;
+		} else if (DAT_SUCCESS != ret) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_dequeue failed: %s\n",
+					  DT_RetToString(ret));
+			return 0;
+		} else if (event.event_number == DAT_DTO_COMPLETION_EVENT) {
+			DT_performance_stats_record_reap(stats,
+							 post_ctxt_num -
+							 pre_ctxt_num,
+							 post_ts - pre_ts);
+		} else {
+			/* This should not happen. There has been an error if it does. */
 
-	    DT_Tdep_PT_Printf (phead, "Warning: dapl_performance_wait swallowing %s event\n",
-			   DT_EventToSTr (event.event_number));
+			DT_Tdep_PT_Printf(phead,
+					  "Warning: dapl_performance_wait swallowing %s event\n",
+					  DT_EventToSTr(event.event_number));
 
-	    return 0;
+			return 0;
+		}
 	}
-    }
 
-    return ++queue_size;
+	return ++queue_size;
 }
 
 /****************************************************************************/
 unsigned int
-DT_performance_poll (
-    DT_Tdep_Print_Head			*phead,
-    DAT_EVD_HANDLE 			evd_handle,
-    Performance_Stats_t 		*stats)
+DT_performance_poll(DT_Tdep_Print_Head * phead,
+		    DAT_EVD_HANDLE evd_handle, Performance_Stats_t * stats)
 {
-    DAT_RETURN      		ret;
-    DAT_EVENT       		event;
-    unsigned long 		pre_ctxt_num;
-    unsigned long 		post_ctxt_num;
-    DT_Mdep_TimeStamp 		pre_ts;
-    DT_Mdep_TimeStamp 		post_ts;
+	DAT_RETURN ret;
+	DAT_EVENT event;
+	unsigned long pre_ctxt_num;
+	unsigned long post_ctxt_num;
+	DT_Mdep_TimeStamp pre_ts;
+	DT_Mdep_TimeStamp post_ts;
 
-    for (;;)
-    {
-	pre_ctxt_num = DT_Mdep_GetContextSwitchNum ();
-	pre_ts = DT_Mdep_GetTimeStamp ();
+	for (;;) {
+		pre_ctxt_num = DT_Mdep_GetContextSwitchNum();
+		pre_ts = DT_Mdep_GetTimeStamp();
 
-	ret = DT_Tdep_evd_dequeue ( evd_handle,
-			       &event);
+		ret = DT_Tdep_evd_dequeue(evd_handle, &event);
 
-	post_ts = DT_Mdep_GetTimeStamp ();
-	post_ctxt_num = DT_Mdep_GetContextSwitchNum ();
+		post_ts = DT_Mdep_GetTimeStamp();
+		post_ctxt_num = DT_Mdep_GetContextSwitchNum();
 
-	if (DAT_GET_TYPE (ret) == DAT_QUEUE_EMPTY)
-	{
-	    continue;
-	}
-	else if ( DAT_SUCCESS != ret )
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_dequeue failed: %s\n",
-			   DT_RetToString (ret));
-	    return 0;
-	}
-	else if (event.event_number == DAT_DTO_COMPLETION_EVENT)
-	{
-	    DT_performance_stats_record_reap (stats,
-					     post_ctxt_num - pre_ctxt_num,
-					     post_ts - pre_ts);
-	    return 1;
-	}
-	else
-	{
-	    /* This should not happen. There has been an error if it does. */
+		if (DAT_GET_TYPE(ret) == DAT_QUEUE_EMPTY) {
+			continue;
+		} else if (DAT_SUCCESS != ret) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_dequeue failed: %s\n",
+					  DT_RetToString(ret));
+			return 0;
+		} else if (event.event_number == DAT_DTO_COMPLETION_EVENT) {
+			DT_performance_stats_record_reap(stats,
+							 post_ctxt_num -
+							 pre_ctxt_num,
+							 post_ts - pre_ts);
+			return 1;
+		} else {
+			/* This should not happen. There has been an error if it does. */
 
-	    DT_Tdep_PT_Printf (phead, "Warning: dapl_performance_wait swallowing %s event\n",
-			   DT_EventToSTr (event.event_number));
+			DT_Tdep_PT_Printf(phead,
+					  "Warning: dapl_performance_wait swallowing %s event\n",
+					  DT_EventToSTr(event.event_number));
 
-	    return 0;
+			return 0;
+		}
 	}
-    }
 
-    /*never reached */
-    return 0;
+	/*never reached */
+	return 0;
 }
- 
+
 void
-DT_Performance_Cmd_PT_Print ( DT_Tdep_Print_Head *phead, 
-    Performance_Cmd_t   *cmd)
+DT_Performance_Cmd_PT_Print(DT_Tdep_Print_Head * phead, Performance_Cmd_t * cmd)
 {
-    DT_Tdep_PT_Printf (phead, "-------------------------------------\n");
-    DT_Tdep_PT_Printf (phead, "PerfCmd.server_name              : %s\n",
-                   cmd->server_name);
-    DT_Tdep_PT_Printf (phead, "PerfCmd.dapl_name                : %s\n",
-                   cmd->dapl_name);
-    DT_Tdep_PT_Printf (phead, "PerfCmd.mode                     : %s\n",
-                   (cmd->mode == BLOCKING_MODE) ? "BLOCKING" : "POLLING");
-    DT_Tdep_PT_Printf (phead, "PerfCmd.num_iterations           : %d\n",
-                   cmd->num_iterations);
-    DT_Tdep_PT_Printf (phead, "PerfCmd.pipeline_len             : %d\n",
-                   cmd->pipeline_len);
-    DT_Tdep_PT_Printf (phead, "PerfCmd.op.transfer_type         : %s\n",
-                   cmd->op.transfer_type == RDMA_READ ? "RDMA_READ" :
-                   cmd->op.transfer_type == RDMA_WRITE ? "RDMA_WRITE" :
-                   "SEND_RECV");
-    DT_Tdep_PT_Printf (phead, "PerfCmd.op.num_segs              : %d\n",
-                   cmd->op.num_segs);
-    DT_Tdep_PT_Printf (phead, "PerfCmd.op.seg_size              : %d\n",
-                   cmd->op.seg_size);
+	DT_Tdep_PT_Printf(phead, "-------------------------------------\n");
+	DT_Tdep_PT_Printf(phead, "PerfCmd.server_name              : %s\n",
+			  cmd->server_name);
+	DT_Tdep_PT_Printf(phead, "PerfCmd.dapl_name                : %s\n",
+			  cmd->dapl_name);
+	DT_Tdep_PT_Printf(phead, "PerfCmd.mode                     : %s\n",
+			  (cmd->mode ==
+			   BLOCKING_MODE) ? "BLOCKING" : "POLLING");
+	DT_Tdep_PT_Printf(phead, "PerfCmd.num_iterations           : %d\n",
+			  cmd->num_iterations);
+	DT_Tdep_PT_Printf(phead, "PerfCmd.pipeline_len             : %d\n",
+			  cmd->pipeline_len);
+	DT_Tdep_PT_Printf(phead, "PerfCmd.op.transfer_type         : %s\n",
+			  cmd->op.transfer_type ==
+			  RDMA_READ ? "RDMA_READ" : cmd->op.transfer_type ==
+			  RDMA_WRITE ? "RDMA_WRITE" : "SEND_RECV");
+	DT_Tdep_PT_Printf(phead, "PerfCmd.op.num_segs              : %d\n",
+			  cmd->op.num_segs);
+	DT_Tdep_PT_Printf(phead, "PerfCmd.op.seg_size              : %d\n",
+			  cmd->op.seg_size);
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_quit_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_quit_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_quit_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,15 +30,14 @@
 
 #include "dapl_proto.h"
 
-void
-DT_Quit_Cmd_PT_Print (DT_Tdep_Print_Head *phead, Quit_Cmd_t * cmd)
+void DT_Quit_Cmd_PT_Print(DT_Tdep_Print_Head * phead, Quit_Cmd_t * cmd)
 {
-  /*  DT_Mdep_printf ("Quit_Cmd.server_name: %s\n", cmd->server_name);
-    DT_Mdep_printf ("Quit_Cmd.device_name: %s\n", cmd->device_name);
-  */
-    DT_Tdep_PT_Printf (phead,"Quit_Cmd.server_name: %s\n", cmd->server_name);
-    DT_Tdep_PT_Printf (phead,"Quit_Cmd.device_name: %s\n", cmd->device_name);
+	/*  DT_Mdep_printf ("Quit_Cmd.server_name: %s\n", cmd->server_name);
+	   DT_Mdep_printf ("Quit_Cmd.device_name: %s\n", cmd->device_name);
+	 */
+	DT_Tdep_PT_Printf(phead, "Quit_Cmd.server_name: %s\n",
+			  cmd->server_name);
+	DT_Tdep_PT_Printf(phead, "Quit_Cmd.device_name: %s\n",
+			  cmd->device_name);
 
 }
-
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,852 +34,822 @@
 #undef DFLT_QLEN
 #endif
 
-#define DFLT_QLEN 8	/* default event queue length */
+#define DFLT_QLEN 8		/* default event queue length */
 
-int send_control_data (DT_Tdep_Print_Head  *phead,
-		       unsigned char       *buffp,
-		       Per_Server_Data_t   *ps_ptr,
-		       Per_Test_Data_t     *pt_ptr);
+int send_control_data(DT_Tdep_Print_Head * phead,
+		      unsigned char *buffp,
+		      Per_Server_Data_t * ps_ptr, Per_Test_Data_t * pt_ptr);
 
-void
-DT_cs_Server (Params_t * params_ptr)
+void DT_cs_Server(Params_t * params_ptr)
 {
-    Server_Cmd_t        *Server_Cmd     = &params_ptr->u.Server_Cmd;
-    Client_Info_t       *Client_Info    = NULL;
-    Transaction_Cmd_t   *Transaction_Cmd= NULL;
-    Quit_Cmd_t          *Quit_Cmd       = NULL;
-    Performance_Cmd_t   *Performance_Cmd= NULL;
-    Per_Server_Data_t   *ps_ptr         = NULL;
-    Per_Test_Data_t     *pt_ptr         = NULL;
-    Started_server_t    *temp_list      = NULL;
-    Started_server_t    *pre_list       = NULL;
-    unsigned char       *buffp          = NULL;
-    char                *module         = "DT_cs_Server";
+	Server_Cmd_t *Server_Cmd = &params_ptr->u.Server_Cmd;
+	Client_Info_t *Client_Info = NULL;
+	Transaction_Cmd_t *Transaction_Cmd = NULL;
+	Quit_Cmd_t *Quit_Cmd = NULL;
+	Performance_Cmd_t *Performance_Cmd = NULL;
+	Per_Server_Data_t *ps_ptr = NULL;
+	Per_Test_Data_t *pt_ptr = NULL;
+	Started_server_t *temp_list = NULL;
+	Started_server_t *pre_list = NULL;
+	unsigned char *buffp = NULL;
+	char *module = "DT_cs_Server";
 
-    DAT_DTO_COOKIE	dto_cookie;
-    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-    DAT_RETURN          ret;
-    DT_Tdep_Print_Head *phead;
+	DAT_DTO_COOKIE dto_cookie;
+	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+	DAT_RETURN ret;
+	DT_Tdep_Print_Head *phead;
 
-    phead = params_ptr->phead;
+	phead = params_ptr->phead;
 
-    /* Check if device from command line already in use */
-    temp_list = DT_started_server_list;
-    while (temp_list)
-    {
-	if (strcmp (temp_list->devicename, Server_Cmd->dapl_name) == 0)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		        "NOTICE: server already started for this NIC: %s\n",
-			Server_Cmd->dapl_name);
-	    return;
+	/* Check if device from command line already in use */
+	temp_list = DT_started_server_list;
+	while (temp_list) {
+		if (strcmp(temp_list->devicename, Server_Cmd->dapl_name) == 0) {
+			DT_Tdep_PT_Printf(phead,
+					  "NOTICE: server already started for this NIC: %s\n",
+					  Server_Cmd->dapl_name);
+			return;
+		}
+		temp_list = temp_list->next;
 	}
-	temp_list = temp_list->next;
-    }
 
-    /* Alloc memory for server list */
-    temp_list = (Started_server_t *) DT_Mdep_Malloc (sizeof (Started_server_t));
-    if (temp_list == 0)
-    {
-	DT_Tdep_PT_Printf (phead, "no memory for server_list\n");
-	return;
-    }
-    strcpy (temp_list->devicename, Server_Cmd->dapl_name);
-    temp_list->next = DT_started_server_list;
-    DT_started_server_list = temp_list;
+	/* Alloc memory for server list */
+	temp_list =
+	    (Started_server_t *) DT_Mdep_Malloc(sizeof(Started_server_t));
+	if (temp_list == 0) {
+		DT_Tdep_PT_Printf(phead, "no memory for server_list\n");
+		return;
+	}
+	strcpy(temp_list->devicename, Server_Cmd->dapl_name);
+	temp_list->next = DT_started_server_list;
+	DT_started_server_list = temp_list;
 
-    if (Server_Cmd->debug)
-    {
-	/* Echo our inputs if debugging */
-	DT_Server_Cmd_PT_Print (phead, Server_Cmd);
-    }
+	if (Server_Cmd->debug) {
+		/* Echo our inputs if debugging */
+		DT_Server_Cmd_PT_Print(phead, Server_Cmd);
+	}
 
-    /* Allocate memory for Per_Server_Data */
-    ps_ptr = (Per_Server_Data_t *) DT_Mdep_Malloc (sizeof (Per_Server_Data_t));
-    if (ps_ptr == 0)
-    {
-	DT_Tdep_PT_Printf (phead, "no memory for ps_data\n");
-	goto server_exit;
-    }
-    DT_Mdep_LockInit (&ps_ptr->num_clients_lock);
-    ps_ptr->NextPortNumber = SERVER_PORT_NUMBER + 1;
-    ps_ptr->num_clients = 0;
+	/* Allocate memory for Per_Server_Data */
+	ps_ptr =
+	    (Per_Server_Data_t *) DT_Mdep_Malloc(sizeof(Per_Server_Data_t));
+	if (ps_ptr == 0) {
+		DT_Tdep_PT_Printf(phead, "no memory for ps_data\n");
+		goto server_exit;
+	}
+	DT_Mdep_LockInit(&ps_ptr->num_clients_lock);
+	ps_ptr->NextPortNumber = SERVER_PORT_NUMBER + 1;
+	ps_ptr->num_clients = 0;
 
-    /* Open the IA */
-    ret = dat_ia_open (Server_Cmd->dapl_name,
-		      DFLT_QLEN,
-		      &ps_ptr->async_evd_hdl,
-		      &ps_ptr->ia_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: Could not open %s (%s)\n",
-		    module,
-		    Server_Cmd->dapl_name,
-		    DT_RetToString (ret));
-	ps_ptr->ia_handle = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    DT_Tdep_PT_Debug (1,(phead,"%s: IA %s opened\n", module, Server_Cmd->dapl_name));
+	/* Open the IA */
+	ret = dat_ia_open(Server_Cmd->dapl_name,
+			  DFLT_QLEN,
+			  &ps_ptr->async_evd_hdl, &ps_ptr->ia_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: Could not open %s (%s)\n",
+				  module,
+				  Server_Cmd->dapl_name, DT_RetToString(ret));
+		ps_ptr->ia_handle = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	DT_Tdep_PT_Debug(1,
+			 (phead, "%s: IA %s opened\n", module,
+			  Server_Cmd->dapl_name));
 
-    /* Create a PZ */
-    ret = dat_pz_create (ps_ptr->ia_handle, &ps_ptr->pz_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_pz_create error: %s\n",
-		    module,
-		    DT_RetToString (ret));
-	ps_ptr->pz_handle = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    DT_Tdep_PT_Debug (1,(phead,"%s: PZ created\n", module));
+	/* Create a PZ */
+	ret = dat_pz_create(ps_ptr->ia_handle, &ps_ptr->pz_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_pz_create error: %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->pz_handle = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	DT_Tdep_PT_Debug(1, (phead, "%s: PZ created\n", module));
 
-    /* Create 4 events - recv, request, connection-request, connect */
-    ret = DT_Tdep_evd_create (ps_ptr->ia_handle,
-			 DFLT_QLEN,
-			 NULL,
-			 DAT_EVD_DTO_FLAG,
-			 &ps_ptr->recv_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_evd_create (recv) failed %s\n",
-		    module, DT_RetToString (ret));
-	ps_ptr->recv_evd_hdl = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    ret = DT_Tdep_evd_create (ps_ptr->ia_handle,
-			 DFLT_QLEN,
-			 NULL,
-			 DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			 &ps_ptr->reqt_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_evd_create (send) failed %s\n",
-		    module, DT_RetToString (ret));
-	ps_ptr->reqt_evd_hdl = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    ret = DT_Tdep_evd_create (ps_ptr->ia_handle,
-			 DFLT_QLEN,
-			 NULL,
-			 DAT_EVD_CR_FLAG,
-			 &ps_ptr->creq_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_evd_create (cr) failed %s\n",
-		    module, DT_RetToString (ret));
-	ps_ptr->creq_evd_hdl = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    ret = DT_Tdep_evd_create (ps_ptr->ia_handle,
-			 DFLT_QLEN,
-			 NULL,
-			 DAT_EVD_CONNECTION_FLAG,
-			 &ps_ptr->conn_evd_hdl);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_evd_create (conn) failed %s\n",
-		    module, DT_RetToString (ret));
-	ps_ptr->conn_evd_hdl = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
+	/* Create 4 events - recv, request, connection-request, connect */
+	ret = DT_Tdep_evd_create(ps_ptr->ia_handle,
+				 DFLT_QLEN,
+				 NULL, DAT_EVD_DTO_FLAG, &ps_ptr->recv_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (recv) failed %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->recv_evd_hdl = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	ret = DT_Tdep_evd_create(ps_ptr->ia_handle,
+				 DFLT_QLEN,
+				 NULL,
+				 DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
+				 &ps_ptr->reqt_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (send) failed %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->reqt_evd_hdl = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	ret = DT_Tdep_evd_create(ps_ptr->ia_handle,
+				 DFLT_QLEN,
+				 NULL, DAT_EVD_CR_FLAG, &ps_ptr->creq_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (cr) failed %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->creq_evd_hdl = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	ret = DT_Tdep_evd_create(ps_ptr->ia_handle,
+				 DFLT_QLEN,
+				 NULL,
+				 DAT_EVD_CONNECTION_FLAG,
+				 &ps_ptr->conn_evd_hdl);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_evd_create (conn) failed %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->conn_evd_hdl = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
 
-    /* Create the EP */
-    ret = dat_ep_create (ps_ptr->ia_handle,	 /* IA       */
-			 ps_ptr->pz_handle,	 /* PZ       */
-			 ps_ptr->recv_evd_hdl,	 /* recv     */
-			 ps_ptr->reqt_evd_hdl,	 /* request  */
-			 ps_ptr->conn_evd_hdl,	 /* connect  */
-			 (DAT_EP_ATTR *) NULL,
-			 &ps_ptr->ep_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_ep_create error: %s\n",
-		    module,
-		    DT_RetToString (ret));
-	ps_ptr->ep_handle = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    DT_Tdep_PT_Debug (1,(phead,"%s: EP created\n", module));
+	/* Create the EP */
+	ret = dat_ep_create(ps_ptr->ia_handle,	/* IA       */
+			    ps_ptr->pz_handle,	/* PZ       */
+			    ps_ptr->recv_evd_hdl,	/* recv     */
+			    ps_ptr->reqt_evd_hdl,	/* request  */
+			    ps_ptr->conn_evd_hdl,	/* connect  */
+			    (DAT_EP_ATTR *) NULL, &ps_ptr->ep_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_ep_create error: %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->ep_handle = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	DT_Tdep_PT_Debug(1, (phead, "%s: EP created\n", module));
 
-    /* Create PSP */
-    ret = dat_psp_create (ps_ptr->ia_handle,
-			SERVER_PORT_NUMBER,
-			ps_ptr->creq_evd_hdl,
-			DAT_PSP_CONSUMER_FLAG,
-			&ps_ptr->psp_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_psp_create error: %s\n",
-		    module,
-		    DT_RetToString (ret));
-	ps_ptr->psp_handle = DAT_HANDLE_NULL;
-	goto server_exit;
-    }
-    DT_Tdep_PT_Debug (1,(phead,"%s: PSP created\n", module));
+	/* Create PSP */
+	ret = dat_psp_create(ps_ptr->ia_handle,
+			     SERVER_PORT_NUMBER,
+			     ps_ptr->creq_evd_hdl,
+			     DAT_PSP_CONSUMER_FLAG, &ps_ptr->psp_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: dat_psp_create error: %s\n",
+				  module, DT_RetToString(ret));
+		ps_ptr->psp_handle = DAT_HANDLE_NULL;
+		goto server_exit;
+	}
+	DT_Tdep_PT_Debug(1, (phead, "%s: PSP created\n", module));
 
-    /*
-     * Create two buffers, large enough to hold ClientInfo and the largest
-     * command we'll use.
-     */
-    ps_ptr->bpool = DT_BpoolAlloc (NULL,
-	    		       phead,
-			       ps_ptr->ia_handle,
-			       ps_ptr->pz_handle,
-			       ps_ptr->ep_handle,
-			       DAT_HANDLE_NULL, /* no RMR */
-			       DT_RoundSize (sizeof (Transaction_Cmd_t), 8192),
-			       3,	/* num_buffers */
-			       DAT_OPTIMAL_ALIGNMENT,
-			       false,
-			       false);
-    if (ps_ptr->bpool == 0)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			 "%s: no memory for command buffer pool.\n", 
-			 module);
-	goto server_exit;
-    }
+	/*
+	 * Create two buffers, large enough to hold ClientInfo and the largest
+	 * command we'll use.
+	 */
+	ps_ptr->bpool = DT_BpoolAlloc(NULL, phead, ps_ptr->ia_handle, ps_ptr->pz_handle, ps_ptr->ep_handle, DAT_HANDLE_NULL,	/* no RMR */
+				      DT_RoundSize(sizeof(Transaction_Cmd_t), 8192), 3,	/* num_buffers */
+				      DAT_OPTIMAL_ALIGNMENT, false, false);
+	if (ps_ptr->bpool == 0) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: no memory for command buffer pool.\n",
+				  module);
+		goto server_exit;
+	}
 
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "Recv 0  %p\n", 
-		      (DAT_PVOID) DT_Bpool_GetBuffer (ps_ptr->bpool, 0)));
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "Recv 1  %p\n", 
-		      (DAT_PVOID) DT_Bpool_GetBuffer (ps_ptr->bpool, 1)));
-    DT_Tdep_PT_Debug (3, (phead, 
-		      "SrvInfo 2  %p\n", 
-		      (DAT_PVOID) DT_Bpool_GetBuffer (ps_ptr->bpool, 2)));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "Recv 0  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(ps_ptr->bpool, 0)));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "Recv 1  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(ps_ptr->bpool, 1)));
+	DT_Tdep_PT_Debug(3, (phead,
+			     "SrvInfo 2  %p\n",
+			     (DAT_PVOID) DT_Bpool_GetBuffer(ps_ptr->bpool, 2)));
 
-    /* Initialize the performance test lock in case an incoming test
-     * is a performance test, so we can allow only one at a time.
-     * Otherwise, multiple performance tests cause a race condition
-     * between the server creating a new thread trying to allocate a
-     * PSP with the same ID as another thread that is either running
-     * a test on that same ID or hasn't yet destroyed it.  Only one
-     * PSP with a particular ID can exist at a time.  It's a
-     * de-facto shared resource that must be protected.
-     */
+	/* Initialize the performance test lock in case an incoming test
+	 * is a performance test, so we can allow only one at a time.
+	 * Otherwise, multiple performance tests cause a race condition
+	 * between the server creating a new thread trying to allocate a
+	 * PSP with the same ID as another thread that is either running
+	 * a test on that same ID or hasn't yet destroyed it.  Only one
+	 * PSP with a particular ID can exist at a time.  It's a
+	 * de-facto shared resource that must be protected.
+	 */
     /************************************************************************
      * Loop accepting connections and acting on them
      */
-    for (;/* EVER */;)
-    {
-	DAT_CR_HANDLE               cr_handle;
-	DAT_CR_ARRIVAL_EVENT_DATA   cr_stat;
-	DAT_EVENT_NUMBER            event_num;
+	for (; /* EVER */ ;) {
+		DAT_CR_HANDLE cr_handle;
+		DAT_CR_ARRIVAL_EVENT_DATA cr_stat;
+		DAT_EVENT_NUMBER event_num;
 
-	/* Set up the Per_Test_Data */
-	pt_ptr = DT_Alloc_Per_Test_Data (phead);
-	if (!pt_ptr)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: no memory for Per_Test_Data\n", 
-			     module);
-	    goto server_exit;
-	}
-	DT_MemListInit (pt_ptr);
-	DT_Thread_Init (pt_ptr);
-	pt_ptr->local_is_server = true;
-	pt_ptr->ps_ptr = ps_ptr;
-	memcpy ( (void *) (uintptr_t) &pt_ptr->Params,
-		(const void *) params_ptr,
-		sizeof (Params_t));
+		/* Set up the Per_Test_Data */
+		pt_ptr = DT_Alloc_Per_Test_Data(phead);
+		if (!pt_ptr) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: no memory for Per_Test_Data\n",
+					  module);
+			goto server_exit;
+		}
+		DT_MemListInit(pt_ptr);
+		DT_Thread_Init(pt_ptr);
+		pt_ptr->local_is_server = true;
+		pt_ptr->ps_ptr = ps_ptr;
+		memcpy((void *)(uintptr_t) & pt_ptr->Params,
+		       (const void *)params_ptr, sizeof(Params_t));
 
-	/* Server_Info, Client_Info, Params set up below */
+		/* Server_Info, Client_Info, Params set up below */
 
-	/* Gather whatever info we want about defaults */
-	if (!DT_query (pt_ptr, ps_ptr->ia_handle, ps_ptr->ep_handle))
-	{
-	    goto server_exit;
-	}
+		/* Gather whatever info we want about defaults */
+		if (!DT_query(pt_ptr, ps_ptr->ia_handle, ps_ptr->ep_handle)) {
+			goto server_exit;
+		}
 
-	/* Post recv buffers for ClientInfo and Transaction_Cmd_t */
-	DT_Tdep_PT_Debug (1,(phead,"%s: Posting 2 recvs\n", module));
-	if (!DT_post_recv_buffer (phead,
-		    		   ps_ptr->ep_handle,
-				   ps_ptr->bpool,
-				   0,
-				   DT_Bpool_GetBuffSize (ps_ptr->bpool, 0)))
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	     "%s: cannot post ClientInfo recv buffer\n", 
-			     module);
-	    goto server_exit;
-	}
-	if (!DT_post_recv_buffer (phead,
-		    		   ps_ptr->ep_handle,
-				   ps_ptr->bpool,
-				   1,
-				   DT_Bpool_GetBuffSize (ps_ptr->bpool, 1)))
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		        "%s: cannot post Transaction_Cmd_t recv buffer\n",
-			module);
-	    goto server_exit;
-	}
+		/* Post recv buffers for ClientInfo and Transaction_Cmd_t */
+		DT_Tdep_PT_Debug(1, (phead, "%s: Posting 2 recvs\n", module));
+		if (!DT_post_recv_buffer(phead,
+					 ps_ptr->ep_handle,
+					 ps_ptr->bpool,
+					 0,
+					 DT_Bpool_GetBuffSize(ps_ptr->bpool,
+							      0))) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: cannot post ClientInfo recv buffer\n",
+					  module);
+			goto server_exit;
+		}
+		if (!DT_post_recv_buffer(phead,
+					 ps_ptr->ep_handle,
+					 ps_ptr->bpool,
+					 1,
+					 DT_Bpool_GetBuffSize(ps_ptr->bpool,
+							      1))) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: cannot post Transaction_Cmd_t recv buffer\n",
+					  module);
+			goto server_exit;
+		}
 
-	/* message to help automated test scripts know when to start the client */
-	DT_Tdep_PT_Printf (phead, 
-		        "Dapltest: Service Point Ready - %s\n",
-			Server_Cmd->dapl_name);
+		/* message to help automated test scripts know when to start the client */
+		DT_Tdep_PT_Printf(phead,
+				  "Dapltest: Service Point Ready - %s\n",
+				  Server_Cmd->dapl_name);
 
-	DT_Mdep_flush ();
+		DT_Mdep_flush();
 
-	DT_Tdep_PT_Debug (1,(phead,"%s: Waiting for Connection Request\n", module));
-	if (!DT_cr_event_wait (phead, ps_ptr->creq_evd_hdl, &cr_stat) ||
-	    !DT_cr_check (phead,
-			    &cr_stat,
-			    ps_ptr->psp_handle,
-			    SERVER_PORT_NUMBER,
-			    &cr_handle,
-			    module))
-	{
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Waiting for Connection Request\n",
+				  module));
+		if (!DT_cr_event_wait(phead, ps_ptr->creq_evd_hdl, &cr_stat)
+		    || !DT_cr_check(phead, &cr_stat, ps_ptr->psp_handle,
+				    SERVER_PORT_NUMBER, &cr_handle, module)) {
 
-	    DT_Tdep_PT_Printf (phead, 
-		    "CR Check failed, file %s line %d\n", __FILE__,
-		    __LINE__);
-	    goto server_exit;
-	}
+			DT_Tdep_PT_Printf(phead,
+					  "CR Check failed, file %s line %d\n",
+					  __FILE__, __LINE__);
+			goto server_exit;
+		}
 
-	DT_Tdep_PT_Debug (1,(phead,"%s: Accepting Connection Request\n", module));
-	ret = dat_cr_accept (cr_handle, ps_ptr->ep_handle, 0, (DAT_PVOID)0);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    "%s: dat_cr_accept error: %s\n",
-		    module,
-		    DT_RetToString (ret));
-	    goto server_exit;
-	}
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Accepting Connection Request\n",
+				  module));
+		ret =
+		    dat_cr_accept(cr_handle, ps_ptr->ep_handle, 0,
+				  (DAT_PVOID) 0);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_cr_accept error: %s\n",
+					  module, DT_RetToString(ret));
+			goto server_exit;
+		}
 
-	DT_Tdep_PT_Debug (1,(phead,"%s: Awaiting connection ...\n", module));
-	if (!DT_conn_event_wait (phead,
-		    		 ps_ptr->ep_handle, 
-				 ps_ptr->conn_evd_hdl,
-				 &event_num))
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		        "%s: error awaiting conn-established event\n",
-			module);
-	    goto server_exit;
-	}
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Awaiting connection ...\n",
+				  module));
+		if (!DT_conn_event_wait
+		    (phead, ps_ptr->ep_handle, ps_ptr->conn_evd_hdl,
+		     &event_num)) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: error awaiting conn-established event\n",
+					  module);
+			goto server_exit;
+		}
 
-	if (DT_dapltest_debug)
-	{
-	    DT_Tdep_PT_Debug (1,(phead, "%s: Connected!\n", module));
-	    get_ep_connection_state (phead, ps_ptr->ep_handle);
-	}
+		if (DT_dapltest_debug) {
+			DT_Tdep_PT_Debug(1,
+					 (phead, "%s: Connected!\n", module));
+			get_ep_connection_state(phead, ps_ptr->ep_handle);
+		}
 
-	/* Wait for Client_Info */
-	dto_cookie.as_64 = LZERO;
-	dto_cookie.as_ptr =
-	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( ps_ptr->bpool, 0);
-	DT_Tdep_PT_Debug (1,(phead,"%s: Waiting for Client_Info\n", module));
-	if (!DT_dto_event_wait (phead, ps_ptr->recv_evd_hdl, &dto_stat) ||
-	    !DT_dto_check ( phead,
-			    &dto_stat,
-			    ps_ptr->ep_handle,
-			    DT_Bpool_GetBuffSize (ps_ptr->bpool, 0),
-			    dto_cookie,
-			    "Client_Info_Recv"))
-	{
-	    goto server_exit;
-	}
-	DT_Tdep_PT_Debug (1,(phead,"%s: Got Client_Info\n", module));
+		/* Wait for Client_Info */
+		dto_cookie.as_64 = LZERO;
+		dto_cookie.as_ptr =
+		    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(ps_ptr->bpool,
+							       0);
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Waiting for Client_Info\n",
+				  module));
+		if (!DT_dto_event_wait(phead, ps_ptr->recv_evd_hdl, &dto_stat)
+		    || !DT_dto_check(phead, &dto_stat, ps_ptr->ep_handle,
+				     DT_Bpool_GetBuffSize(ps_ptr->bpool, 0),
+				     dto_cookie, "Client_Info_Recv")) {
+			goto server_exit;
+		}
+		DT_Tdep_PT_Debug(1, (phead, "%s: Got Client_Info\n", module));
 
-	/* Extract the Client_Info */
-	Client_Info = (Client_Info_t*) DT_Bpool_GetBuffer (ps_ptr->bpool, 0);
-	DT_Client_Info_Endian (Client_Info);
-	memcpy ( (void *) (uintptr_t)&pt_ptr->Client_Info,
-		(const void *)Client_Info,
-		sizeof (Client_Info_t));
+		/* Extract the Client_Info */
+		Client_Info =
+		    (Client_Info_t *) DT_Bpool_GetBuffer(ps_ptr->bpool, 0);
+		DT_Client_Info_Endian(Client_Info);
+		memcpy((void *)(uintptr_t) & pt_ptr->Client_Info,
+		       (const void *)Client_Info, sizeof(Client_Info_t));
 
-	/* Wait for client's command info */
-	dto_cookie.as_64 = LZERO;
-	dto_cookie.as_ptr =
-	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( ps_ptr->bpool, 1);
-	DT_Tdep_PT_Debug (1,(phead,"%s: Waiting for Client_Cmd_Info\n", module));
-	if (!DT_dto_event_wait (phead, ps_ptr->recv_evd_hdl, &dto_stat) ||
-	    !DT_dto_check ( phead,
-			    &dto_stat,
-			    ps_ptr->ep_handle,
-			    DT_Bpool_GetBuffSize (ps_ptr->bpool, 1),
-			    dto_cookie,
-			    "Client_Cmd_Recv"))
-	{
-	    goto server_exit;
-	}
+		/* Wait for client's command info */
+		dto_cookie.as_64 = LZERO;
+		dto_cookie.as_ptr =
+		    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(ps_ptr->bpool,
+							       1);
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Waiting for Client_Cmd_Info\n",
+				  module));
+		if (!DT_dto_event_wait(phead, ps_ptr->recv_evd_hdl, &dto_stat)
+		    || !DT_dto_check(phead, &dto_stat, ps_ptr->ep_handle,
+				     DT_Bpool_GetBuffSize(ps_ptr->bpool, 1),
+				     dto_cookie, "Client_Cmd_Recv")) {
+			goto server_exit;
+		}
 
-	/* Extract the client's command info */
-	switch (Client_Info->test_type)
-	{
-	    case TRANSACTION_TEST:
-	    {
-		Transaction_Cmd = (Transaction_Cmd_t *)
-					DT_Bpool_GetBuffer (ps_ptr->bpool, 1);
-		DT_Transaction_Cmd_Endian (Transaction_Cmd, false);
-		memcpy ( (void *) (uintptr_t)&pt_ptr->Params.u.Transaction_Cmd,
-		    (const void *)Transaction_Cmd,
-		    sizeof (Transaction_Cmd_t));
-		break;
-	    }
+		/* Extract the client's command info */
+		switch (Client_Info->test_type) {
+		case TRANSACTION_TEST:
+			{
+				Transaction_Cmd = (Transaction_Cmd_t *)
+				    DT_Bpool_GetBuffer(ps_ptr->bpool, 1);
+				DT_Transaction_Cmd_Endian(Transaction_Cmd,
+							  false);
+				memcpy((void *)(uintptr_t) & pt_ptr->Params.u.
+				       Transaction_Cmd,
+				       (const void *)Transaction_Cmd,
+				       sizeof(Transaction_Cmd_t));
+				break;
+			}
 
-            case QUIT_TEST:
-            {
-        	Quit_Cmd = (Quit_Cmd_t*)DT_Bpool_GetBuffer (ps_ptr->bpool, 1);
-        	DT_Quit_Cmd_Endian (Quit_Cmd, false);
-        	memcpy ( (void *) (uintptr_t)&pt_ptr->Params.u.Quit_Cmd,
-            	(const void *)Quit_Cmd,
-		sizeof (Quit_Cmd_t));
-        	break;
-	    }
+		case QUIT_TEST:
+			{
+				Quit_Cmd =
+				    (Quit_Cmd_t *) DT_Bpool_GetBuffer(ps_ptr->
+								      bpool, 1);
+				DT_Quit_Cmd_Endian(Quit_Cmd, false);
+				memcpy((void *)(uintptr_t) & pt_ptr->Params.u.
+				       Quit_Cmd, (const void *)Quit_Cmd,
+				       sizeof(Quit_Cmd_t));
+				break;
+			}
 
-	    case PERFORMANCE_TEST:
-	    {
-		Performance_Cmd = (Performance_Cmd_t *)
-					DT_Bpool_GetBuffer (ps_ptr->bpool, 1);
-		DT_Performance_Cmd_Endian (Performance_Cmd);
-		memcpy ( (void *) (uintptr_t)&pt_ptr->Params.u.Performance_Cmd,
-			(const void *)Performance_Cmd,
-			sizeof (Performance_Cmd_t));
-		break;
-	    }
+		case PERFORMANCE_TEST:
+			{
+				Performance_Cmd = (Performance_Cmd_t *)
+				    DT_Bpool_GetBuffer(ps_ptr->bpool, 1);
+				DT_Performance_Cmd_Endian(Performance_Cmd);
+				memcpy((void *)(uintptr_t) & pt_ptr->Params.u.
+				       Performance_Cmd,
+				       (const void *)Performance_Cmd,
+				       sizeof(Performance_Cmd_t));
+				break;
+			}
 
-	    default:
-	    {
-		DT_Tdep_PT_Printf (phead, "Unknown TestType received\n");
-		goto server_exit;
-		break;
-	    }
-	}
+		default:
+			{
+				DT_Tdep_PT_Printf(phead,
+						  "Unknown TestType received\n");
+				goto server_exit;
+				break;
+			}
+		}
 
-	/* Setup Server Info */
-	DT_Tdep_PT_Debug (1,(phead,"%s: Send Server_Info\n", module));
-	pt_ptr->Server_Info.dapltest_version = DAPLTEST_VERSION;
-	pt_ptr->Server_Info.is_little_endian = DT_local_is_little_endian;
-	pt_ptr->Server_Info.first_port_number = ps_ptr->NextPortNumber;
-	ps_ptr->NextPortNumber += pt_ptr->Client_Info.total_threads;
+		/* Setup Server Info */
+		DT_Tdep_PT_Debug(1, (phead, "%s: Send Server_Info\n", module));
+		pt_ptr->Server_Info.dapltest_version = DAPLTEST_VERSION;
+		pt_ptr->Server_Info.is_little_endian =
+		    DT_local_is_little_endian;
+		/* reset port, don't eat up port space on long runs */
+		if (ps_ptr->NextPortNumber >= SERVER_PORT_NUMBER + 1000)
+			ps_ptr->NextPortNumber = SERVER_PORT_NUMBER + 1;
+		pt_ptr->Server_Info.first_port_number = ps_ptr->NextPortNumber;
+		ps_ptr->NextPortNumber += pt_ptr->Client_Info.total_threads;
 
-	/* This had to be done here because the pt_ptr is being fed to
-	 * the thread as its context, and if it isn't properly
-	 * initialized before the thread spawns then the thread may
-	 * incorrectly set up its PSP and the server will be listening
-	 * on the WRONG PORT!
-	 */
+		/* This had to be done here because the pt_ptr is being fed to
+		 * the thread as its context, and if it isn't properly
+		 * initialized before the thread spawns then the thread may
+		 * incorrectly set up its PSP and the server will be listening
+		 * on the WRONG PORT!
+		 */
 
-	switch (Client_Info->test_type)
-	{
-	    case TRANSACTION_TEST:
-	    {
-		/* create a thread to handle this pt_ptr; */
-		DT_Tdep_PT_Debug (1,(phead,"%s: Creating Transaction Test Thread\n", module));
-		pt_ptr->thread = DT_Thread_Create (pt_ptr,
-					   DT_Transaction_Test_Server,
-					   pt_ptr,
-					   DT_MDEP_DEFAULT_STACK_SIZE);
-		if (pt_ptr->thread == 0)
-		{
-		    DT_Tdep_PT_Printf (phead, "no memory to create thread\n");
-		    goto server_exit;
-		}
-		break;
-	    }
+		switch (Client_Info->test_type) {
+		case TRANSACTION_TEST:
+			{
+				/* create a thread to handle this pt_ptr; */
+				ps_ptr->NextPortNumber +=
+				    (pt_ptr->Params.u.Transaction_Cmd.
+				     eps_per_thread -
+				     1) * pt_ptr->Client_Info.total_threads;
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "%s: Creating Transaction Test Thread\n",
+						  module));
+				pt_ptr->thread =
+				    DT_Thread_Create(pt_ptr,
+						     DT_Transaction_Test_Server,
+						     pt_ptr,
+						     DT_MDEP_DEFAULT_STACK_SIZE);
+				if (pt_ptr->thread == 0) {
+					DT_Tdep_PT_Printf(phead,
+							  "no memory to create thread\n");
+					goto server_exit;
+				}
+				break;
+			}
 
-           case QUIT_TEST:
-           {
-        	DT_Tdep_PT_Debug (1,(phead,"Client Requests Server to Quit\n"));
-        	(void) send_control_data (phead, buffp, ps_ptr, pt_ptr);
-        	goto server_exit;
-        	break;
-           }
+		case QUIT_TEST:
+			{
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Client Requests Server to Quit\n"));
+				(void)send_control_data(phead, buffp, ps_ptr,
+							pt_ptr);
+				goto server_exit;
+				break;
+			}
 
-	   case LIMIT_TEST:
-	   {
-	        DT_Tdep_PT_Debug (1,(phead,"Limit Test is Client-side Only!\n"));
-	        (void) send_control_data (phead, buffp, ps_ptr, pt_ptr);
-		goto server_exit;
-		break;
-	   }
-		       
-	    case PERFORMANCE_TEST:
-	    {
-		/* create a thread to handle this pt_ptr; */
-		DT_Tdep_PT_Debug (1,(phead,"%s: Creating Performance Test Thread\n", module));
-		pt_ptr->thread = DT_Thread_Create (pt_ptr,
-						  DT_Performance_Test_Server,
-						  pt_ptr,
-						  DT_MDEP_DEFAULT_STACK_SIZE);
-		if (pt_ptr->thread == 0)
-		{
-		    DT_Tdep_PT_Printf (phead, "no memory to create thread\n");
-		    goto server_exit;
-		}
-		/* take the performance test lock to serialize */
-		DT_Mdep_Lock ( &g_PerfTestLock );
+		case LIMIT_TEST:
+			{
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Limit Test is Client-side Only!\n"));
+				(void)send_control_data(phead, buffp, ps_ptr,
+							pt_ptr);
+				goto server_exit;
+				break;
+			}
 
-		break;
-	    }
+		case PERFORMANCE_TEST:
+			{
+				/* create a thread to handle this pt_ptr; */
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "%s: Creating Performance Test Thread\n",
+						  module));
+				pt_ptr->thread =
+				    DT_Thread_Create(pt_ptr,
+						     DT_Performance_Test_Server,
+						     pt_ptr,
+						     DT_MDEP_DEFAULT_STACK_SIZE);
+				if (pt_ptr->thread == 0) {
+					DT_Tdep_PT_Printf(phead,
+							  "no memory to create thread\n");
+					goto server_exit;
+				}
+				/* take the performance test lock to serialize */
+				DT_Mdep_Lock(&g_PerfTestLock);
 
-	    case FFT_TEST:
+				break;
+			}
 
-	    default:
-	    {
-		DT_Tdep_PT_Printf (phead, "Unknown TestType received\n");
-		(void) send_control_data (phead, buffp, ps_ptr, pt_ptr);
-		goto server_exit;
-		break;
-	    }
-	}
+		case FFT_TEST:
 
-	/* Start the new test thread */
-	DT_Tdep_PT_Debug (1,(phead,"%s: Starting Test Thread\n", module));
-	if (DT_Thread_Start (pt_ptr->thread) == false)
-	{
-	    DT_Tdep_PT_Debug (1,(phead,"failed to start test thread\n"));
-	    goto server_exit;
-	}
+		default:
+			{
+				DT_Tdep_PT_Printf(phead,
+						  "Unknown TestType received\n");
+				(void)send_control_data(phead, buffp, ps_ptr,
+							pt_ptr);
+				goto server_exit;
+				break;
+			}
+		}
 
-	buffp = DT_Bpool_GetBuffer (ps_ptr->bpool, 2); /* 3rd buffer */
-	memcpy ( (void *)buffp,
-		(const void *)&pt_ptr->Server_Info,
-		sizeof (Server_Info_t));
-	DT_Server_Info_Endian ((Server_Info_t *) buffp);
+		/* Start the new test thread */
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Starting Test Thread\n", module));
+		if (DT_Thread_Start(pt_ptr->thread) == false) {
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "failed to start test thread\n"));
+			goto server_exit;
+		}
 
-	/* Perform obligatory version check */
-	if (pt_ptr->Client_Info.dapltest_version != DAPLTEST_VERSION)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    "%s: %s: Server %d, Client %d\n",
-		    module,
-		    "DAPLTEST VERSION MISMATCH",
-		    DAPLTEST_VERSION,
-		    pt_ptr->Client_Info.dapltest_version);
-	    goto server_exit;
-	}
-	DT_Tdep_PT_Debug (1,(phead,"%s: Version OK!\n", module));
+		buffp = DT_Bpool_GetBuffer(ps_ptr->bpool, 2);	/* 3rd buffer */
+		memcpy((void *)buffp,
+		       (const void *)&pt_ptr->Server_Info,
+		       sizeof(Server_Info_t));
+		DT_Server_Info_Endian((Server_Info_t *) buffp);
 
-	DT_Mdep_wait_object_wait (
-		&pt_ptr->synch_wait_object,
-		DAT_TIMEOUT_INFINITE);
+		/* Perform obligatory version check */
+		if (pt_ptr->Client_Info.dapltest_version != DAPLTEST_VERSION) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: %s: Server %d, Client %d\n",
+					  module,
+					  "DAPLTEST VERSION MISMATCH",
+					  DAPLTEST_VERSION,
+					  pt_ptr->Client_Info.dapltest_version);
+			goto server_exit;
+		}
+		DT_Tdep_PT_Debug(1, (phead, "%s: Version OK!\n", module));
 
-	/* Send the Server_Info */
-	DT_Tdep_PT_Debug (1,(phead,"%s: Send Server_Info\n", module));
+		DT_Mdep_wait_object_wait(&pt_ptr->synch_wait_object,
+					 DAT_TIMEOUT_INFINITE);
 
-	if (!DT_post_send_buffer ( phead, ps_ptr->ep_handle,
-		ps_ptr->bpool,
-		2,
-		DT_Bpool_GetBuffSize (ps_ptr->bpool, 2)))
-	{
-	    DT_Tdep_PT_Printf (phead, "%s: cannot send Server_Info\n", module);
-	    goto server_exit;
-	}
-	/* reap the send and verify it */
-	dto_cookie.as_64 = LZERO;
-	dto_cookie.as_ptr =
-		(DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( ps_ptr->bpool, 2);
-	if (!DT_dto_event_wait (phead, ps_ptr->reqt_evd_hdl, &dto_stat) ||
-		!DT_dto_check ( phead,
-		    	    &dto_stat,
-		ps_ptr->ep_handle,
-		DT_Bpool_GetBuffSize (ps_ptr->bpool, 2),
-		dto_cookie,
-		"Server_Info_Send"))
-	{
-	    goto server_exit;
-	}
+		/* Send the Server_Info */
+		DT_Tdep_PT_Debug(1, (phead, "%s: Send Server_Info\n", module));
 
+		if (!DT_post_send_buffer(phead, ps_ptr->ep_handle,
+					 ps_ptr->bpool,
+					 2,
+					 DT_Bpool_GetBuffSize(ps_ptr->bpool,
+							      2))) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: cannot send Server_Info\n",
+					  module);
+			goto server_exit;
+		}
+		/* reap the send and verify it */
+		dto_cookie.as_64 = LZERO;
+		dto_cookie.as_ptr =
+		    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(ps_ptr->bpool,
+							       2);
+		if (!DT_dto_event_wait(phead, ps_ptr->reqt_evd_hdl, &dto_stat)
+		    || !DT_dto_check(phead, &dto_stat, ps_ptr->ep_handle,
+				     DT_Bpool_GetBuffSize(ps_ptr->bpool, 2),
+				     dto_cookie, "Server_Info_Send")) {
+			goto server_exit;
+		}
 
-	/* Count this new client and get ready for the next */
-	DT_Mdep_Lock (&ps_ptr->num_clients_lock);
-	ps_ptr->num_clients++;
-	DT_Mdep_Unlock (&ps_ptr->num_clients_lock);
+		/* Count this new client and get ready for the next */
+		DT_Mdep_Lock(&ps_ptr->num_clients_lock);
+		ps_ptr->num_clients++;
+		DT_Mdep_Unlock(&ps_ptr->num_clients_lock);
 
-	/* we passed the pt_ptr to the thread and must now 'forget' it */
-	pt_ptr = 0;
+		/* we passed the pt_ptr to the thread and must now 'forget' it */
+		pt_ptr = 0;
 
 #ifdef CM_BUSTED
-	DT_Tdep_PT_Debug (1,(phead,"%s: Server exiting because provider does not support\n"
-			" multiple connections to the same service point\n",
-			module));
-	/* Until connections are healthier we run just one test */
-	break;
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "%s: Server exiting because provider does not support\n"
+				  " multiple connections to the same service point\n",
+				  module));
+		/* Until connections are healthier we run just one test */
+		break;
 #else
-	ret = dat_ep_disconnect (ps_ptr->ep_handle, DAT_CLOSE_GRACEFUL_FLAG);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "%s: dat_ep_disconnect fails: %s\n",
-			    module, DT_RetToString (ret));
-	    goto server_exit;
-	}
-	if (!DT_disco_event_wait ( phead, ps_ptr->conn_evd_hdl, NULL))
-	{
-	    DT_Tdep_PT_Printf (phead, "%s: bad disconnect event\n", module);
-	    goto server_exit;
-	}
+		ret =
+		    dat_ep_disconnect(ps_ptr->ep_handle,
+				      DAT_CLOSE_GRACEFUL_FLAG);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "%s: dat_ep_disconnect fails: %s\n",
+					  module, DT_RetToString(ret));
+			goto server_exit;
+		}
+		if (!DT_disco_event_wait(phead, ps_ptr->conn_evd_hdl, NULL)) {
+			DT_Tdep_PT_Printf(phead, "%s: bad disconnect event\n",
+					  module);
+			goto server_exit;
+		}
 
-	/* reset the EP to get back into the game */
-	dat_ep_reset (ps_ptr->ep_handle);
-	DT_Tdep_PT_Debug (1,(phead,"%s: Waiting for another client...\n", module));
+		/* reset the EP to get back into the game */
+		dat_ep_reset(ps_ptr->ep_handle);
+		DT_Tdep_PT_Debug(1,
+				 (phead, "%s: Waiting for another client...\n",
+				  module));
 #endif
-    }	/* end loop accepting connections */
+	}			/* end loop accepting connections */
 
     /************************************************************************
      * Finished (or had an error) so clean up and go home
      */
-server_exit:
+      server_exit:
 
-    /* Wait until all of our clients are gone */
-    DT_Tdep_PT_Debug (1,(phead,"%s: Waiting for clients to all go away...\n", module));
-    while (ps_ptr && ps_ptr->num_clients > 0)
-    {
-	DT_Mdep_Sleep (100);
-    }
-
-    /* Clean up the Per_Test_Data (if any) */
-    DT_Tdep_PT_Debug (1,(phead,"%s: Cleaning up ...\n", module));
-    if (pt_ptr)
-    {
-	DT_Mdep_LockDestroy (&pt_ptr->Thread_counter_lock);
-	DT_Mdep_LockDestroy (&pt_ptr->MemListLock);
-	DT_Free_Per_Test_Data (pt_ptr);
-    }
-
-    /* Clean up the Per_Server_Data */
-    if (ps_ptr)
-    {
-	/*
-	 * disconnect the most recent EP
-	 *
-	 * we also get here on error, hence abrupt closure to
-	 * flush any lingering buffers posted.
-	 */
-	if (ps_ptr->ep_handle)
-	{
-	    ret = dat_ep_disconnect (ps_ptr->ep_handle,
-				    DAT_CLOSE_ABRUPT_FLAG);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_ep_disconnect fails: %s\n",
-				module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	    else if (!DT_disco_event_wait ( phead,
-					    ps_ptr->conn_evd_hdl,
-					    NULL))
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				 "%s: bad disconnect event\n", 
-				 module);
-	    }
+	/* Wait until all of our clients are gone */
+	DT_Tdep_PT_Debug(1,
+			 (phead, "%s: Waiting for clients to all go away...\n",
+			  module));
+	while (ps_ptr && ps_ptr->num_clients > 0) {
+		DT_Mdep_Sleep(100);
 	}
 
-	/* Destroy the Bpool */
-	if (ps_ptr->bpool)
-	{
-	    if (!DT_Bpool_Destroy (NULL, phead, ps_ptr->bpool))
-	    {
-		DT_Tdep_PT_Printf (phead, 
-			"%s: error destroying buffer pool\n", module);
-		/* keep trying */
-	    }
+	/* Clean up the Per_Test_Data (if any) */
+	DT_Tdep_PT_Debug(1, (phead, "%s: Cleaning up ...\n", module));
+	if (pt_ptr) {
+		DT_Mdep_LockDestroy(&pt_ptr->Thread_counter_lock);
+		DT_Mdep_LockDestroy(&pt_ptr->MemListLock);
+		DT_Free_Per_Test_Data(pt_ptr);
 	}
 
-	/* Free the PSP */
-	if (ps_ptr->psp_handle)
-	{
-	    ret = dat_psp_free (ps_ptr->psp_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_psp_free error: %s\n",
-			    module,
-			    DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
+	/* Clean up the Per_Server_Data */
+	if (ps_ptr) {
+		/*
+		 * disconnect the most recent EP
+		 *
+		 * we also get here on error, hence abrupt closure to
+		 * flush any lingering buffers posted.
+		 */
+		if (ps_ptr->ep_handle) {
+			ret = dat_ep_disconnect(ps_ptr->ep_handle,
+						DAT_CLOSE_ABRUPT_FLAG);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_ep_disconnect fails: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			} else if (!DT_disco_event_wait(phead,
+							ps_ptr->conn_evd_hdl,
+							NULL)) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: bad disconnect event\n",
+						  module);
+			}
+		}
 
-	/* Free the EP */
-	if (ps_ptr->ep_handle)
-	{
-	    ret = dat_ep_free (ps_ptr->ep_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_ep_free error: %s\n",
-			    module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
+		/* Destroy the Bpool */
+		if (ps_ptr->bpool) {
+			if (!DT_Bpool_Destroy(NULL, phead, ps_ptr->bpool)) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: error destroying buffer pool\n",
+						  module);
+				/* keep trying */
+			}
+		}
 
-	/* Free the 4 EVDs */
-	if (ps_ptr->conn_evd_hdl)
-	{
-	    ret = DT_Tdep_evd_free (ps_ptr->conn_evd_hdl);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-			    "%s: dat_evd_free (conn) error: %s\n",
-			    module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
-	if (ps_ptr->creq_evd_hdl)
-	{
-	    ret = DT_Tdep_evd_free (ps_ptr->creq_evd_hdl);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-			    "%s: dat_evd_free (creq) error: %s\n",
-			    module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
-	if (ps_ptr->reqt_evd_hdl)
-	{
-	    ret = DT_Tdep_evd_free (ps_ptr->reqt_evd_hdl);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-			    "%s: dat_evd_free (reqt) error: %s\n",
-			    module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
-	if (ps_ptr->recv_evd_hdl)
-	{
-	    ret = DT_Tdep_evd_free (ps_ptr->recv_evd_hdl);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-			    "%s: dat_evd_free (recv) error: %s\n",
-			    module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
+		/* Free the PSP */
+		if (ps_ptr->psp_handle) {
+			ret = dat_psp_free(ps_ptr->psp_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_psp_free error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
+		}
 
-	/* Free the PZ */
-	if (ps_ptr->pz_handle)
-	{
-	    ret = dat_pz_free (ps_ptr->pz_handle);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "%s: dat_pz_free error: %s\n",
-			    module, DT_RetToString (ret));
-		/* keep trying */
-	    }
-	}
+		/* Free the EP */
+		if (ps_ptr->ep_handle) {
+			ret = dat_ep_free(ps_ptr->ep_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_ep_free error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
+		}
 
-	/* Close the IA */
-	if (ps_ptr->ia_handle)
-	{
-	    /* dat_ia_close cleans up async evd handle, too */
-	    ret = dat_ia_close (ps_ptr->ia_handle, DAT_CLOSE_GRACEFUL_FLAG);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-			    "%s: dat_ia_close (graceful) error: %s\n",
-			    module, DT_RetToString (ret));
-		ret = dat_ia_close (ps_ptr->ia_handle, DAT_CLOSE_ABRUPT_FLAG);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, 
-			    	"%s: dat_ia_close (abrupt) error: %s\n",
-				module, DT_RetToString (ret));
+		/* Free the 4 EVDs */
+		if (ps_ptr->conn_evd_hdl) {
+			ret = DT_Tdep_evd_free(ps_ptr->conn_evd_hdl);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_evd_free (conn) error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
 		}
-		/* keep trying */
-	    }
-	    else
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"%s: IA %s closed\n",
-				module,
-				Server_Cmd->dapl_name));
-	    }
-	}
+		if (ps_ptr->creq_evd_hdl) {
+			ret = DT_Tdep_evd_free(ps_ptr->creq_evd_hdl);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_evd_free (creq) error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
+		}
+		if (ps_ptr->reqt_evd_hdl) {
+			ret = DT_Tdep_evd_free(ps_ptr->reqt_evd_hdl);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_evd_free (reqt) error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
+		}
+		if (ps_ptr->recv_evd_hdl) {
+			ret = DT_Tdep_evd_free(ps_ptr->recv_evd_hdl);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_evd_free (recv) error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
+		}
 
-	/* Destroy the ps_ptr */
-	DT_Mdep_LockDestroy (&ps_ptr->num_clients_lock);
-	DT_Mdep_Free (ps_ptr);
-    }	/* end if ps_ptr */
+		/* Free the PZ */
+		if (ps_ptr->pz_handle) {
+			ret = dat_pz_free(ps_ptr->pz_handle);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_pz_free error: %s\n",
+						  module, DT_RetToString(ret));
+				/* keep trying */
+			}
+		}
 
-    /* Clean up the server list */
-    pre_list = 0;
-    temp_list = DT_started_server_list;
-    while (temp_list)
-    {
-	if (strcmp (temp_list->devicename, Server_Cmd->dapl_name) == 0)
-	{
-	    if (pre_list == 0) /* first one */
-	    {
-		DT_started_server_list = temp_list->next;
-	    }
-	    else
-	    {
-		pre_list->next = temp_list->next;
-	    }
-	    DT_Mdep_Free (temp_list);
-	    break;
+		/* Close the IA */
+		if (ps_ptr->ia_handle) {
+			/* dat_ia_close cleans up async evd handle, too */
+			ret =
+			    dat_ia_close(ps_ptr->ia_handle,
+					 DAT_CLOSE_GRACEFUL_FLAG);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "%s: dat_ia_close (graceful) error: %s\n",
+						  module, DT_RetToString(ret));
+				ret =
+				    dat_ia_close(ps_ptr->ia_handle,
+						 DAT_CLOSE_ABRUPT_FLAG);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "%s: dat_ia_close (abrupt) error: %s\n",
+							  module,
+							  DT_RetToString(ret));
+				}
+				/* keep trying */
+			} else {
+				DT_Tdep_PT_Debug(1,
+						 (phead, "%s: IA %s closed\n",
+						  module,
+						  Server_Cmd->dapl_name));
+			}
+		}
+
+		/* Destroy the ps_ptr */
+		DT_Mdep_LockDestroy(&ps_ptr->num_clients_lock);
+		DT_Mdep_Free(ps_ptr);
 	}
-	pre_list = temp_list;
-	temp_list = temp_list->next;
-    }
 
-    DT_Tdep_PT_Printf (phead, 
-	    	    "%s (%s):  Exiting.\n", module, Server_Cmd->dapl_name);
+	/* end if ps_ptr */
+	/* Clean up the server list */
+	pre_list = 0;
+	temp_list = DT_started_server_list;
+	while (temp_list) {
+		if (strcmp(temp_list->devicename, Server_Cmd->dapl_name) == 0) {
+			if (pre_list == 0) {	/* first one */
+				DT_started_server_list = temp_list->next;
+			} else {
+				pre_list->next = temp_list->next;
+			}
+			DT_Mdep_Free(temp_list);
+			break;
+		}
+		pre_list = temp_list;
+		temp_list = temp_list->next;
+	}
+
+	DT_Tdep_PT_Printf(phead,
+			  "%s (%s):  Exiting.\n", module,
+			  Server_Cmd->dapl_name);
 }
 
-
 int
-send_control_data (
-	DT_Tdep_Print_Head  *phead,
-	unsigned char       *buffp,
-	Per_Server_Data_t   *ps_ptr,
-	Per_Test_Data_t     *pt_ptr)
+send_control_data(DT_Tdep_Print_Head * phead,
+		  unsigned char *buffp,
+		  Per_Server_Data_t * ps_ptr, Per_Test_Data_t * pt_ptr)
 {
-    char                *module         = "send_control_data";
-    DAT_DTO_COOKIE	dto_cookie;
-    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+	char *module = "send_control_data";
+	DAT_DTO_COOKIE dto_cookie;
+	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
 
-    buffp = DT_Bpool_GetBuffer (ps_ptr->bpool, 2); /* 3rd buffer */
-    memcpy ( (void *)buffp,
-	     (const void *)&pt_ptr->Server_Info,
-	     sizeof (Server_Info_t));
-    DT_Server_Info_Endian ((Server_Info_t *) buffp);
+	buffp = DT_Bpool_GetBuffer(ps_ptr->bpool, 2);	/* 3rd buffer */
+	memcpy((void *)buffp,
+	       (const void *)&pt_ptr->Server_Info, sizeof(Server_Info_t));
+	DT_Server_Info_Endian((Server_Info_t *) buffp);
 
-    if (!DT_post_send_buffer ( phead, ps_ptr->ep_handle,
-			       ps_ptr->bpool,
-			       2,
-			       DT_Bpool_GetBuffSize (ps_ptr->bpool, 2)))
-    {
-	DT_Tdep_PT_Printf (phead, "%s: cannot send Server_Info\n", module);
-	return 1;
-    }
-    /* reap the send and verify it */
-    dto_cookie.as_64 = LZERO;
-    dto_cookie.as_ptr =
-	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer ( ps_ptr->bpool, 2);
-    if (!DT_dto_event_wait (phead, ps_ptr->reqt_evd_hdl, &dto_stat) ||
-	!DT_dto_check (phead,
-	    	    &dto_stat,
-			ps_ptr->ep_handle,
-			DT_Bpool_GetBuffSize (ps_ptr->bpool, 2),
-			dto_cookie,
-			"Server_Info_Send"))
-    {
-	return 1;
-    }
+	if (!DT_post_send_buffer(phead, ps_ptr->ep_handle,
+				 ps_ptr->bpool,
+				 2, DT_Bpool_GetBuffSize(ps_ptr->bpool, 2))) {
+		DT_Tdep_PT_Printf(phead, "%s: cannot send Server_Info\n",
+				  module);
+		return 1;
+	}
+	/* reap the send and verify it */
+	dto_cookie.as_64 = LZERO;
+	dto_cookie.as_ptr =
+	    (DAT_PVOID) (uintptr_t) DT_Bpool_GetBuffer(ps_ptr->bpool, 2);
+	if (!DT_dto_event_wait(phead, ps_ptr->reqt_evd_hdl, &dto_stat) ||
+	    !DT_dto_check(phead,
+			  &dto_stat,
+			  ps_ptr->ep_handle,
+			  DT_Bpool_GetBuffSize(ps_ptr->bpool, 2),
+			  dto_cookie, "Server_Info_Send")) {
+		return 1;
+	}
 
-    return 0;
+	return 0;
 }
 
 void
-DT_Server_Cmd_PT_Print (DT_Tdep_Print_Head *phead, Server_Cmd_t * Server_Cmd)
+DT_Server_Cmd_PT_Print(DT_Tdep_Print_Head * phead, Server_Cmd_t * Server_Cmd)
 {
-    DT_Tdep_PT_Printf (phead, "Server_Cmd.debug:       %d\n", Server_Cmd->debug);
-    DT_Tdep_PT_Printf (phead, "Server_Cmd.dapl_name: %s\n", Server_Cmd->dapl_name);
+	DT_Tdep_PT_Printf(phead, "Server_Cmd.debug:       %d\n",
+			  Server_Cmd->debug);
+	DT_Tdep_PT_Printf(phead, "Server_Cmd.dapl_name: %s\n",
+			  Server_Cmd->dapl_name);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server_info.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server_info.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_server_info.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -32,20 +32,22 @@
 
 Started_server_t *DT_started_server_list = 0;
 
-void
-DT_Server_Info_Endian (Server_Info_t * server_info)
+void DT_Server_Info_Endian(Server_Info_t * server_info)
 {
-    server_info->dapltest_version = DT_Endian32 (server_info->dapltest_version);
-    server_info->is_little_endian = DT_Endian32 (server_info->is_little_endian);
-    server_info->first_port_number= DT_Endian32 (server_info->first_port_number);
+	server_info->dapltest_version =
+	    DT_Endian32(server_info->dapltest_version);
+	server_info->is_little_endian =
+	    DT_Endian32(server_info->is_little_endian);
+	server_info->first_port_number =
+	    DT_Endian32(server_info->first_port_number);
 }
 
 void
-DT_Server_Info_Print (DT_Tdep_Print_Head *phead, Server_Info_t * server_info)
+DT_Server_Info_Print(DT_Tdep_Print_Head * phead, Server_Info_t * server_info)
 {
-    DT_Tdep_PT_Printf (phead, "-------------------------------------\n");
-    DT_Tdep_PT_Printf (phead, "Server_Info.dapltest_version   : %d\n",
-		server_info->dapltest_version);
-    DT_Tdep_PT_Printf (phead, "Server_Info.is_little_endian   : %d\n",
-		server_info->is_little_endian);
+	DT_Tdep_PT_Printf(phead, "-------------------------------------\n");
+	DT_Tdep_PT_Printf(phead, "Server_Info.dapltest_version   : %d\n",
+			  server_info->dapltest_version);
+	DT_Tdep_PT_Printf(phead, "Server_Info.is_little_endian   : %d\n",
+			  server_info->is_little_endian);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_data.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_data.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_data.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,29 +30,27 @@
 
 #include "dapl_proto.h"
 
-DT_Mdep_LockType     g_PerfTestLock;
+DT_Mdep_LockType g_PerfTestLock;
 /*
  * check memory leaking int             alloc_count; DT_Mdep_LockType
  * Alloc_Count_Lock;
  */
 
-Per_Test_Data_t *
-DT_Alloc_Per_Test_Data (DT_Tdep_Print_Head *phead)
+Per_Test_Data_t *DT_Alloc_Per_Test_Data(DT_Tdep_Print_Head * phead)
 {
-    Per_Test_Data_t *pt_ptr;
-    pt_ptr = 0;
+	Per_Test_Data_t *pt_ptr;
+	pt_ptr = 0;
 
-    pt_ptr = DT_Mdep_Malloc (sizeof (Per_Test_Data_t));
-    if (!pt_ptr)
-    {
-	DT_Tdep_PT_Printf (phead, "No Memory to create per_test_data!\n");
-    }
+	pt_ptr = DT_Mdep_Malloc(sizeof(Per_Test_Data_t));
+	if (!pt_ptr) {
+		DT_Tdep_PT_Printf(phead,
+				  "No Memory to create per_test_data!\n");
+	}
 
-    return (pt_ptr);
+	return (pt_ptr);
 }
 
-void
-DT_Free_Per_Test_Data (Per_Test_Data_t * pt_ptr)
+void DT_Free_Per_Test_Data(Per_Test_Data_t * pt_ptr)
 {
-    DT_Mdep_Free (pt_ptr);
+	DT_Mdep_Free(pt_ptr);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_test_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,681 +34,647 @@
  * Gather info about default attributes
  */
 DAT_BOOLEAN
-DT_query (   Per_Test_Data_t *pt_ptr,
-	    DAT_IA_HANDLE   ia_handle,
-	    DAT_EP_HANDLE   ep_handle)
+DT_query(Per_Test_Data_t * pt_ptr,
+	 DAT_IA_HANDLE ia_handle, DAT_EP_HANDLE ep_handle)
 {
-    char            *module = "DT_query";
-    DAT_EVD_HANDLE  async_evd_hdl;  /* not used */
-    DAT_EP_PARAM    ep_params;
-    DAT_RETURN      ret;
-    DT_Tdep_Print_Head *phead;
+	char *module = "DT_query";
+	DAT_EVD_HANDLE async_evd_hdl;	/* not used */
+	DAT_EP_PARAM ep_params;
+	DAT_RETURN ret;
+	DT_Tdep_Print_Head *phead;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    /* Query the IA */
-    ret = dat_ia_query (ia_handle,
-		       &async_evd_hdl,
-		       DAT_IA_ALL,
-		       &pt_ptr->ia_attr,
-		       DAT_PROVIDER_FIELD_ALL,
-		       &pt_ptr->provider_attr);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "%s: dat_ia_query error: %s\n",
-		    module,
-		    DT_RetToString (ret));
-	return ( false );
-    }
+	/* Query the IA */
+	ret = dat_ia_query(ia_handle,
+			   &async_evd_hdl,
+			   DAT_IA_ALL,
+			   &pt_ptr->ia_attr,
+			   DAT_PROVIDER_FIELD_ALL, &pt_ptr->provider_attr);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "%s: dat_ia_query error: %s\n",
+				  module, DT_RetToString(ret));
+		return (false);
+	}
 
-    /* Query the EP */
-    ret = dat_ep_query (	ep_handle,
-			DAT_EP_FIELD_ALL,
-			&ep_params);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "%s: dat_ep_query error: %s\n",
-		    module,
-		    DT_RetToString (ret));
-	return ( false );
-    }
-    pt_ptr->ep_attr = ep_params.ep_attr;
+	/* Query the EP */
+	ret = dat_ep_query(ep_handle, DAT_EP_FIELD_ALL, &ep_params);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead, "%s: dat_ep_query error: %s\n",
+				  module, DT_RetToString(ret));
+		return (false);
+	}
+	pt_ptr->ep_attr = ep_params.ep_attr;
 
-    /*
-     * If debugging, print out some interesting attributes
-     */
-    if (DT_dapltest_debug)
-    {
-	DAT_SOCK_ADDR6		*ip6_addr;
-	struct sockaddr_in	*ip_addr;
+	/*
+	 * If debugging, print out some interesting attributes
+	 */
+	if (DT_dapltest_debug) {
+		DAT_SOCK_ADDR6 *ip6_addr;
+		struct sockaddr_in *ip_addr;
 
-	DT_Tdep_PT_Printf (phead, "*****  DAPL  Characteristics  *****\n");
-	DT_Tdep_PT_Printf (phead, "Provider: %s  Version %d.%d  DAPL %d.%d\n",
-			pt_ptr->provider_attr.provider_name,
-			pt_ptr->provider_attr.provider_version_major,
-			pt_ptr->provider_attr.provider_version_minor,
-			pt_ptr->provider_attr.dapl_version_major,
-			pt_ptr->provider_attr.dapl_version_minor );
-	DT_Tdep_PT_Printf (phead, "Adapter: %s by %s Version %d.%d\n",
-			pt_ptr->ia_attr.adapter_name,
-			pt_ptr->ia_attr.vendor_name,
-			pt_ptr->ia_attr.hardware_version_major,
-			pt_ptr->ia_attr.hardware_version_minor );
-	DT_Tdep_PT_Printf (phead, "Supporting:\n");
-	DT_Tdep_PT_Printf (phead, "\t%d EPs with %d DTOs and %d RDMA/RDs each\n",
-			pt_ptr->ia_attr.max_eps,
-			pt_ptr->ia_attr.max_dto_per_ep,
-			pt_ptr->ia_attr.max_rdma_read_per_ep );
-	DT_Tdep_PT_Printf (phead, "\t%d EVDs of up to %d entries "
-			" (default S/R size is %d/%d)\n",
-			pt_ptr->ia_attr.max_evds,
-			pt_ptr->ia_attr.max_evd_qlen,
-			pt_ptr->ep_attr.max_request_dtos,
-			pt_ptr->ep_attr.max_recv_dtos );
-	DT_Tdep_PT_Printf (phead, "\tIOVs of up to %d elements\n",
-			pt_ptr->ia_attr.max_iov_segments_per_dto );
-	DT_Tdep_PT_Printf (phead, "\t%d LMRs (and %d RMRs) of up to 0x" F64x " bytes\n",
-			pt_ptr->ia_attr.max_lmrs,
-			pt_ptr->ia_attr.max_rmrs,
-			pt_ptr->ia_attr.max_lmr_block_size );
-	DT_Tdep_PT_Printf (phead, "\tMaximum MTU 0x" F64x " bytes, RDMA 0x" F64x " bytes\n",
-			pt_ptr->ia_attr.max_mtu_size,
-			pt_ptr->ia_attr.max_rdma_size );
-	DT_Tdep_PT_Printf (phead, "\tMaximum Private data size %d bytes\n",
-			pt_ptr->provider_attr.max_private_data_size );
+		DT_Tdep_PT_Printf(phead,
+				  "*****  DAPL  Characteristics  *****\n");
+		DT_Tdep_PT_Printf(phead,
+				  "Provider: %s  Version %d.%d  DAPL %d.%d\n",
+				  pt_ptr->provider_attr.provider_name,
+				  pt_ptr->provider_attr.provider_version_major,
+				  pt_ptr->provider_attr.provider_version_minor,
+				  pt_ptr->provider_attr.dapl_version_major,
+				  pt_ptr->provider_attr.dapl_version_minor);
+		DT_Tdep_PT_Printf(phead, "Adapter: %s by %s Version %d.%d\n",
+				  pt_ptr->ia_attr.adapter_name,
+				  pt_ptr->ia_attr.vendor_name,
+				  pt_ptr->ia_attr.hardware_version_major,
+				  pt_ptr->ia_attr.hardware_version_minor);
+		DT_Tdep_PT_Printf(phead, "Supporting:\n");
+		DT_Tdep_PT_Printf(phead,
+				  "\t%d EPs with %d DTOs and %d RDMA/RDs each\n",
+				  pt_ptr->ia_attr.max_eps,
+				  pt_ptr->ia_attr.max_dto_per_ep,
+				  pt_ptr->ia_attr.max_rdma_read_per_ep);
+		DT_Tdep_PT_Printf(phead,
+				  "\t%d EVDs of up to %d entries "
+				  " (default S/R size is %d/%d)\n",
+				  pt_ptr->ia_attr.max_evds,
+				  pt_ptr->ia_attr.max_evd_qlen,
+				  pt_ptr->ep_attr.max_request_dtos,
+				  pt_ptr->ep_attr.max_recv_dtos);
+		DT_Tdep_PT_Printf(phead, "\tIOVs of up to %d elements\n",
+				  pt_ptr->ia_attr.max_iov_segments_per_dto);
+		DT_Tdep_PT_Printf(phead,
+				  "\t%d LMRs (and %d RMRs) of up to 0x" F64x
+				  " bytes\n", pt_ptr->ia_attr.max_lmrs,
+				  pt_ptr->ia_attr.max_rmrs,
+				  pt_ptr->ia_attr.max_lmr_block_size);
+		DT_Tdep_PT_Printf(phead,
+				  "\tMaximum MTU 0x" F64x " bytes, RDMA 0x" F64x
+				  " bytes\n", pt_ptr->ia_attr.max_mtu_size,
+				  pt_ptr->ia_attr.max_rdma_size);
+		DT_Tdep_PT_Printf(phead,
+				  "\tMaximum Private data size %d bytes\n",
+				  pt_ptr->provider_attr.max_private_data_size);
 
-	ip6_addr = (DAT_SOCK_ADDR6 *)pt_ptr->ia_attr.ia_address_ptr;
-	if (ip6_addr->sin6_family == AF_INET6 )
-	{
-	    DT_Tdep_PT_Printf (phead, "\tLocal IP address  %x:%x:%x:%x:%x:%x:%x:%x:\n",
-			  ip6_addr->sin6_addr.s6_addr[0],
-			  ip6_addr->sin6_addr.s6_addr[1],
-			  ip6_addr->sin6_addr.s6_addr[2],
-			  ip6_addr->sin6_addr.s6_addr[3],
-			  ip6_addr->sin6_addr.s6_addr[4],
-			  ip6_addr->sin6_addr.s6_addr[5],
-			  ip6_addr->sin6_addr.s6_addr[6],
-			  ip6_addr->sin6_addr.s6_addr[7]);
-	    DT_Tdep_PT_Printf (phead, "%x:%x:%x:%x:%x:%x:%x:%x\n",
-			  ip6_addr->sin6_addr.s6_addr[8],
-			  ip6_addr->sin6_addr.s6_addr[9],
-			  ip6_addr->sin6_addr.s6_addr[10],
-			  ip6_addr->sin6_addr.s6_addr[11],
-			  ip6_addr->sin6_addr.s6_addr[12],
-			  ip6_addr->sin6_addr.s6_addr[13],
-			  ip6_addr->sin6_addr.s6_addr[14],
-			  ip6_addr->sin6_addr.s6_addr[15]);
-	}
-	else if (ip6_addr->sin6_family == AF_INET )
+		ip6_addr = (DAT_SOCK_ADDR6 *) pt_ptr->ia_attr.ia_address_ptr;
+		if (ip6_addr->sin6_family == AF_INET6) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tLocal IP address  %x:%x:%x:%x:%x:%x:%x:%x:\n",
+					  ip6_addr->sin6_addr.s6_addr[0],
+					  ip6_addr->sin6_addr.s6_addr[1],
+					  ip6_addr->sin6_addr.s6_addr[2],
+					  ip6_addr->sin6_addr.s6_addr[3],
+					  ip6_addr->sin6_addr.s6_addr[4],
+					  ip6_addr->sin6_addr.s6_addr[5],
+					  ip6_addr->sin6_addr.s6_addr[6],
+					  ip6_addr->sin6_addr.s6_addr[7]);
+			DT_Tdep_PT_Printf(phead, "%x:%x:%x:%x:%x:%x:%x:%x\n",
+					  ip6_addr->sin6_addr.s6_addr[8],
+					  ip6_addr->sin6_addr.s6_addr[9],
+					  ip6_addr->sin6_addr.s6_addr[10],
+					  ip6_addr->sin6_addr.s6_addr[11],
+					  ip6_addr->sin6_addr.s6_addr[12],
+					  ip6_addr->sin6_addr.s6_addr[13],
+					  ip6_addr->sin6_addr.s6_addr[14],
+					  ip6_addr->sin6_addr.s6_addr[15]);
+		} else if (ip6_addr->sin6_family == AF_INET)
+		{
+			ip_addr =
+			    (struct sockaddr_in *)pt_ptr->ia_attr.
+			    ia_address_ptr;
 
-	{
-	    ip_addr = (struct sockaddr_in *)pt_ptr->ia_attr.ia_address_ptr;
+			DT_Tdep_PT_Printf(phead, "\tLocal IP address %s\n",
+					  inet_ntoa(ip_addr->sin_addr));
+		}
 
-	    DT_Tdep_PT_Printf (phead, "\tLocal IP address %s\n",
-			  inet_ntoa(ip_addr->sin_addr));
+		DT_Tdep_PT_Printf(phead,
+				  "***** ***** ***** ***** ***** *****\n");
 	}
 
-	DT_Tdep_PT_Printf (phead, "***** ***** ***** ***** ***** *****\n");
-    }
-
-    return ( true );
+	return (true);
 }
 
-
 /* -----------------------------------------------------------
  * Post a recv buffer
  */
 DAT_BOOLEAN
-DT_post_recv_buffer (DT_Tdep_Print_Head *phead,
-		     DAT_EP_HANDLE ep_handle,
-		     Bpool * bp,
-		     int index,
-		     int size)
+DT_post_recv_buffer(DT_Tdep_Print_Head * phead,
+		    DAT_EP_HANDLE ep_handle, Bpool * bp, int index, int size)
 {
-    unsigned char   *buff = DT_Bpool_GetBuffer (bp, index);
-    DAT_LMR_TRIPLET *iov  = DT_Bpool_GetIOV (bp, index);
-    DAT_LMR_CONTEXT lmr_c = DT_Bpool_GetLMR (bp, index);
-    DAT_DTO_COOKIE  cookie;
-    DAT_RETURN      ret;
+	unsigned char *buff = DT_Bpool_GetBuffer(bp, index);
+	DAT_LMR_TRIPLET *iov = DT_Bpool_GetIOV(bp, index);
+	DAT_LMR_CONTEXT lmr_c = DT_Bpool_GetLMR(bp, index);
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN ret;
 
-    /*
-     * Prep the inputs
-     */
-    iov->virtual_address = (DAT_VADDR) (uintptr_t) buff;
-    iov->segment_length  = size;
-    iov->lmr_context     = lmr_c;
-    cookie.as_64         = (DAT_UINT64)0UL;
-    cookie.as_ptr        = (DAT_PVOID) buff;
+	/*
+	 * Prep the inputs
+	 */
+	iov->virtual_address = (DAT_VADDR) (uintptr_t) buff;
+	iov->segment_length = size;
+	iov->lmr_context = lmr_c;
+	cookie.as_64 = (DAT_UINT64) 0UL;
+	cookie.as_ptr = (DAT_PVOID) buff;
 
-    DT_Tdep_PT_Debug (3, (phead, "Post-Recv #%d [%p, %x]\n", index, buff, size));
+	DT_Tdep_PT_Debug(3,
+			 (phead, "Post-Recv #%d [%p, %x]\n", index, buff,
+			  size));
 
-    /* Post the recv buffer */
-    ret = dat_ep_post_recv (ep_handle,
-			    1,
-			    iov,
-			    cookie,
-			    DAT_COMPLETION_DEFAULT_FLAG);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test Error: dat_ep_post_recv failed: %s\n",
-		    DT_RetToString (ret));
-	DT_Test_Error ();
-	return false;
-    }
-    return true;
+	/* Post the recv buffer */
+	ret = dat_ep_post_recv(ep_handle,
+			       1, iov, cookie, DAT_COMPLETION_DEFAULT_FLAG);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test Error: dat_ep_post_recv failed: %s\n",
+				  DT_RetToString(ret));
+		DT_Test_Error();
+		return false;
+	}
+	return true;
 }
 
-
 /* -----------------------------------------------------------
  * Post a send buffer
  */
 DAT_BOOLEAN
-DT_post_send_buffer (DT_Tdep_Print_Head *phead, 
-		     DAT_EP_HANDLE ep_handle,
-		     Bpool * bp,
-		     int index,
-		     int size)
+DT_post_send_buffer(DT_Tdep_Print_Head * phead,
+		    DAT_EP_HANDLE ep_handle, Bpool * bp, int index, int size)
 {
-    unsigned char   *buff = DT_Bpool_GetBuffer (bp, index);
-    DAT_LMR_TRIPLET *iov  = DT_Bpool_GetIOV (bp, index);
-    DAT_LMR_CONTEXT lmr_c = DT_Bpool_GetLMR (bp, index);
-    DAT_DTO_COOKIE  cookie;
-    DAT_RETURN      ret;
+	unsigned char *buff = DT_Bpool_GetBuffer(bp, index);
+	DAT_LMR_TRIPLET *iov = DT_Bpool_GetIOV(bp, index);
+	DAT_LMR_CONTEXT lmr_c = DT_Bpool_GetLMR(bp, index);
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN ret;
 
-    /*
-     * Prep the inputs
-     */
-    iov->virtual_address = (DAT_VADDR) (uintptr_t) buff;
-    iov->segment_length  = size;
-    iov->lmr_context     = lmr_c;
-    cookie.as_64         = (DAT_UINT64)0UL;
-    cookie.as_ptr        = (DAT_PVOID) buff;
+	/*
+	 * Prep the inputs
+	 */
+	iov->virtual_address = (DAT_VADDR) (uintptr_t) buff;
+	iov->segment_length = size;
+	iov->lmr_context = lmr_c;
+	cookie.as_64 = (DAT_UINT64) 0UL;
+	cookie.as_ptr = (DAT_PVOID) buff;
 
-    DT_Tdep_PT_Debug (3, (phead, "Post-Send #%d [%p, %x]\n", index, buff, size));
+	DT_Tdep_PT_Debug(3,
+			 (phead, "Post-Send #%d [%p, %x]\n", index, buff,
+			  size));
 
-    /* Post the recv buffer */
-    ret = dat_ep_post_send (ep_handle,
-			    1,
-			    iov,
-			    cookie,
-			    DAT_COMPLETION_DEFAULT_FLAG);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test Error: dat_ep_post_send failed: %s\n",
-		    DT_RetToString (ret));
-	DT_Test_Error ();
-	return false;
-    }
-    return true;
+	/* Post the recv buffer */
+	ret = dat_ep_post_send(ep_handle,
+			       1, iov, cookie, DAT_COMPLETION_DEFAULT_FLAG);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test Error: dat_ep_post_send failed: %s\n",
+				  DT_RetToString(ret));
+		DT_Test_Error();
+		return false;
+	}
+	return true;
 }
 
-
 /* -----------------------------------------------------------
  * Wait for a CR event, returning false on error.
  */
 bool
-DT_cr_event_wait ( DT_Tdep_Print_Head *phead,
-		   DAT_EVD_HANDLE evd_handle,
-		   DAT_CR_ARRIVAL_EVENT_DATA *cr_stat_p)
+DT_cr_event_wait(DT_Tdep_Print_Head * phead,
+		 DAT_EVD_HANDLE evd_handle,
+		 DAT_CR_ARRIVAL_EVENT_DATA * cr_stat_p)
 {
-    int err_cnt;
+	int err_cnt;
 
-    err_cnt = 0;
+	err_cnt = 0;
 
-    for (;;)
-    {
-	DAT_RETURN      ret;
-	DAT_EVENT       event;
+	for (;;) {
+		DAT_RETURN ret;
+		DAT_EVENT event;
 
-	ret = DT_Tdep_evd_wait (evd_handle, DAT_TIMEOUT_INFINITE, &event);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_wait (CR) failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    /*
-	     * If we get an error due to the client breaking the
-	     * connection early or some transients, just ignore it
-	     * and keep going. If we get a bunch of errors, bail
-	     * out.
-	     */
-	    /* 	    if ( err_cnt++ < 10 ) */
-	    /* 	    { */
-	    /* 		    continue; */
-	    /* 	    } */
+		ret =
+		    DT_Tdep_evd_wait(evd_handle, DAT_TIMEOUT_INFINITE, &event);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_wait (CR) failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			/*
+			 * If we get an error due to the client breaking the
+			 * connection early or some transients, just ignore it
+			 * and keep going. If we get a bunch of errors, bail
+			 * out.
+			 */
+			/*      if ( err_cnt++ < 10 ) */
+			/*      { */
+			/*              continue; */
+			/*      } */
 
-	    break;
-	}
+			break;
+		}
 
-	if (event.event_number == DAT_CONNECTION_REQUEST_EVENT)
-	{
-	    /*
-	     * Pass back what we know, if requested.
-	     */
-	    if (cr_stat_p)
-	    {
-		*cr_stat_p = event.event_data.cr_arrival_event_data;
-	    }
-	    return (true);
+		if (event.event_number == DAT_CONNECTION_REQUEST_EVENT) {
+			/*
+			 * Pass back what we know, if requested.
+			 */
+			if (cr_stat_p) {
+				*cr_stat_p =
+				    event.event_data.cr_arrival_event_data;
+			}
+			return (true);
+		}
+
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: cr_event_wait swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 	}
 
-	DT_Tdep_PT_Printf (phead, "Warning: cr_event_wait swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
-    }
-
-    return (false);
+	return (false);
 }
 
-
 /* -----------------------------------------------------------
  * Wait for a connection event, returning false on error.
  */
 bool
-DT_conn_event_wait (DT_Tdep_Print_Head *phead,
-		    DAT_EP_HANDLE  ep_handle,
-		    DAT_EVD_HANDLE evd_handle,
-		    DAT_EVENT_NUMBER *event_number)
-
+DT_conn_event_wait(DT_Tdep_Print_Head * phead,
+		   DAT_EP_HANDLE ep_handle,
+		   DAT_EVD_HANDLE evd_handle, DAT_EVENT_NUMBER * event_number)
 {
-    for (;;)
-    {
-	DAT_RETURN      ret;
-	DAT_EVENT       event;
+	for (;;) {
+		DAT_RETURN ret;
+		DAT_EVENT event;
 
-	ret = DT_Tdep_evd_wait (evd_handle, DAT_TIMEOUT_INFINITE, &event);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_wait (CONN) failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    break;
+		ret =
+		    DT_Tdep_evd_wait(evd_handle, DAT_TIMEOUT_INFINITE, &event);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_wait (CONN) failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			break;
+		}
+		*event_number = event.event_number;
+		if (event.event_number == DAT_CONNECTION_EVENT_PEER_REJECTED
+		    || event.event_number ==
+		    DAT_CONNECTION_EVENT_NON_PEER_REJECTED
+		    || event.event_number ==
+		    DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR
+		    || event.event_number == DAT_CONNECTION_EVENT_DISCONNECTED
+		    || event.event_number == DAT_CONNECTION_EVENT_BROKEN
+		    || event.event_number == DAT_CONNECTION_EVENT_UNREACHABLE
+		    || event.event_number == DAT_CONNECTION_EVENT_TIMED_OUT) {
+			DT_Tdep_PT_Printf(phead,
+					  "Warning: conn_event_wait %s\n",
+					  DT_EventToSTr(event.event_number));
+			break;
+		}
+		if (event.event_number == DAT_CONNECTION_EVENT_ESTABLISHED) {
+			/*
+			 * Could return DAT_CONNECTION_EVENT_DATA and verify:
+			 *      event.event_data.connect_event_data.ep_handle
+			 *      event.event_data.connect_event_data.private_data_size
+			 *      event.event_data.connect_event_data.private_data
+			 */
+			return (true);
+		}
+
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: conn_event_wait swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 	}
-	*event_number = event.event_number;
-	if (event.event_number == DAT_CONNECTION_EVENT_PEER_REJECTED
-	    || event.event_number == DAT_CONNECTION_EVENT_NON_PEER_REJECTED
-	    || event.event_number == DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR
-	    || event.event_number == DAT_CONNECTION_EVENT_DISCONNECTED
-	    || event.event_number == DAT_CONNECTION_EVENT_BROKEN
-	    || event.event_number == DAT_CONNECTION_EVENT_UNREACHABLE
-	    || event.event_number == DAT_CONNECTION_EVENT_TIMED_OUT)
-	{
-	    DT_Tdep_PT_Printf (phead, "Warning: conn_event_wait %s\n",
-			DT_EventToSTr (event.event_number));
-	    break;
-	}
-	if (event.event_number == DAT_CONNECTION_EVENT_ESTABLISHED)
-	{
-	    /*
-	     * Could return DAT_CONNECTION_EVENT_DATA and verify:
-	     *      event.event_data.connect_event_data.ep_handle
-	     *      event.event_data.connect_event_data.private_data_size
-	     *      event.event_data.connect_event_data.private_data
-	     */
-	    return (true);
-	}
 
-	DT_Tdep_PT_Printf (phead, "Warning: conn_event_wait swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
-    }
-
-    return (false);
+	return (false);
 }
 
-
 /* -----------------------------------------------------------
  * Wait for a disconnection event, returning false on error.
  */
 bool
-DT_disco_event_wait ( DT_Tdep_Print_Head *phead,
-		      DAT_EVD_HANDLE evd_handle,
-		      DAT_EP_HANDLE  *ep_handle )
+DT_disco_event_wait(DT_Tdep_Print_Head * phead,
+		    DAT_EVD_HANDLE evd_handle, DAT_EP_HANDLE * ep_handle)
 {
-    for (;;)
-    {
-	DAT_RETURN      ret;
-	DAT_EVENT       event;
+	for (;;) {
+		DAT_RETURN ret;
+		DAT_EVENT event;
 
-	ret = DT_Tdep_evd_wait (evd_handle, DAT_TIMEOUT_INFINITE, &event);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_wait (DISCONN) failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    break;
-	}
-	if (event.event_number == DAT_CONNECTION_EVENT_PEER_REJECTED
-	    || event.event_number == DAT_CONNECTION_EVENT_NON_PEER_REJECTED
-	    || event.event_number == DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR
-	    || event.event_number == DAT_CONNECTION_EVENT_BROKEN
-	    || event.event_number == DAT_CONNECTION_EVENT_UNREACHABLE
-	    || event.event_number == DAT_CONNECTION_EVENT_TIMED_OUT)
-	{
-	    DT_Tdep_PT_Printf (phead, "Warning: disconn_event_wait %s\n",
-			DT_EventToSTr (event.event_number));
-	    break;
-	}
+		ret =
+		    DT_Tdep_evd_wait(evd_handle, DAT_TIMEOUT_INFINITE, &event);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_wait (DISCONN) failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			break;
+		}
+		if (event.event_number == DAT_CONNECTION_EVENT_PEER_REJECTED
+		    || event.event_number ==
+		    DAT_CONNECTION_EVENT_NON_PEER_REJECTED
+		    || event.event_number ==
+		    DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR
+		    || event.event_number == DAT_CONNECTION_EVENT_BROKEN
+		    || event.event_number == DAT_CONNECTION_EVENT_UNREACHABLE
+		    || event.event_number == DAT_CONNECTION_EVENT_TIMED_OUT) {
+			DT_Tdep_PT_Printf(phead,
+					  "Warning: disconn_event_wait %s\n",
+					  DT_EventToSTr(event.event_number));
+			break;
+		}
 
+		if (event.event_number == DAT_CONNECTION_EVENT_DISCONNECTED) {
+			if (ep_handle != NULL) {
+				*ep_handle =
+				    event.event_data.connect_event_data.
+				    ep_handle;
+			}
+			return (true);
+		}
 
-	if (event.event_number == DAT_CONNECTION_EVENT_DISCONNECTED)
-	{
-	    if ( ep_handle != NULL )
-	    {
-		*ep_handle = event.event_data.connect_event_data.ep_handle;
-	    }
-	    return (true);
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: conn_event_wait swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 	}
 
-	DT_Tdep_PT_Printf (phead, "Warning: conn_event_wait swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
-    }
-
-    return (false);
+	return (false);
 }
 
-
 /* -----------------------------------------------------------
  * Reap a DTO event using a wait or polling, returning false on error.
  */
 bool
-DT_dto_event_reap (DT_Tdep_Print_Head *phead,
+DT_dto_event_reap(DT_Tdep_Print_Head * phead,
 		  DAT_EVD_HANDLE evd_handle,
-		  bool poll,
-		  DAT_DTO_COMPLETION_EVENT_DATA *dto_statusp)
+		  bool poll, DAT_DTO_COMPLETION_EVENT_DATA * dto_statusp)
 {
-    if (poll)
-    {
-	return DT_dto_event_poll (phead, evd_handle, dto_statusp);
-    }
-    else
-    {
-	return DT_dto_event_wait (phead, evd_handle, dto_statusp);
-    }
+	if (poll) {
+		return DT_dto_event_poll(phead, evd_handle, dto_statusp);
+	} else {
+		return DT_dto_event_wait(phead, evd_handle, dto_statusp);
+	}
 }
 
-
 /* -----------------------------------------------------------
  * Poll for a DTO event, returning false on error.
  */
 bool
-DT_dto_event_poll (DT_Tdep_Print_Head *phead,
+DT_dto_event_poll(DT_Tdep_Print_Head * phead,
 		  DAT_EVD_HANDLE evd_handle,
-		  DAT_DTO_COMPLETION_EVENT_DATA *dto_statusp)
+		  DAT_DTO_COMPLETION_EVENT_DATA * dto_statusp)
 {
-    for (;;)
-    {
-	DAT_RETURN      ret;
-	DAT_EVENT       event;
+	for (;;) {
+		DAT_RETURN ret;
+		DAT_EVENT event;
 
-	ret = DT_Tdep_evd_dequeue ( evd_handle,
-			       &event);
+		ret = DT_Tdep_evd_dequeue(evd_handle, &event);
 
-	if (DAT_GET_TYPE (ret) == DAT_QUEUE_EMPTY)
-	{
-	    continue;
-	}
+		if (DAT_GET_TYPE(ret) == DAT_QUEUE_EMPTY) {
+			continue;
+		}
 
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_wait (DTO) failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    break;
-	}
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_wait (DTO) failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			break;
+		}
 
-	if (event.event_number == DAT_DTO_COMPLETION_EVENT)
-	{
-	    /*
-	     * Pass back all the useful bits if requested:
-	     *      ep_handle,  user_cookie.as_ptr
-	     *      status,     transfered_length
-	     */
-	    if (dto_statusp)
-	    {
-		*dto_statusp = event.event_data.dto_completion_event_data;
-	    }
+		if (event.event_number == DAT_DTO_COMPLETION_EVENT) {
+			/*
+			 * Pass back all the useful bits if requested:
+			 *      ep_handle,  user_cookie.as_ptr
+			 *      status,     transfered_length
+			 */
+			if (dto_statusp) {
+				*dto_statusp =
+				    event.event_data.dto_completion_event_data;
+			}
 
-	    return (true);
+			return (true);
+		}
+
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: dto_event_poll swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 	}
 
-	DT_Tdep_PT_Printf (phead, "Warning: dto_event_poll swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
-    }
-
-    return (false);
+	return (false);
 }
 
-
 /* -----------------------------------------------------------
  * Wait for a DTO event, returning false on error.
  */
 bool
-DT_dto_event_wait (DT_Tdep_Print_Head *phead,
-		    DAT_EVD_HANDLE evd_handle,
-		    DAT_DTO_COMPLETION_EVENT_DATA *dto_statusp)
+DT_dto_event_wait(DT_Tdep_Print_Head * phead,
+		  DAT_EVD_HANDLE evd_handle,
+		  DAT_DTO_COMPLETION_EVENT_DATA * dto_statusp)
 {
-    for (;;)
-    {
-	DAT_RETURN      ret;
-	DAT_EVENT       event;
+	for (;;) {
+		DAT_RETURN ret;
+		DAT_EVENT event;
 
-	ret = DT_Tdep_evd_wait (evd_handle, DAT_TIMEOUT_INFINITE, &event);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_wait (DTO) failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    break;
-	}
+		ret =
+		    DT_Tdep_evd_wait(evd_handle, DAT_TIMEOUT_INFINITE, &event);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_wait (DTO) failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			break;
+		}
 
-	if (event.event_number == DAT_DTO_COMPLETION_EVENT)
-	{
-	    /*
-	     * Pass back all the useful bits if requested:
-	     *      ep_handle,  user_cookie.as_ptr
-	     *      status,     transfered_length
-	     */
-	    if (dto_statusp)
-	    {
-		*dto_statusp = event.event_data.dto_completion_event_data;
-	    }
-	    return (true);
+		if (event.event_number == DAT_DTO_COMPLETION_EVENT) {
+			/*
+			 * Pass back all the useful bits if requested:
+			 *      ep_handle,  user_cookie.as_ptr
+			 *      status,     transfered_length
+			 */
+			if (dto_statusp) {
+				*dto_statusp =
+				    event.event_data.dto_completion_event_data;
+			}
+			return (true);
+		}
+
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: dto_event_wait swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 	}
 
-	DT_Tdep_PT_Printf (phead, "Warning: dto_event_wait swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
-    }
-
-    return (false);
+	return (false);
 }
 
-
 /* -----------------------------------------------------------
  * Wait for a RMR event, returning false on error.
  */
 bool
-DT_rmr_event_wait (DT_Tdep_Print_Head *phead,
-		    DAT_EVD_HANDLE evd_handle,
-		    DAT_RMR_BIND_COMPLETION_EVENT_DATA *rmr_statusp)
+DT_rmr_event_wait(DT_Tdep_Print_Head * phead,
+		  DAT_EVD_HANDLE evd_handle,
+		  DAT_RMR_BIND_COMPLETION_EVENT_DATA * rmr_statusp)
 {
-    for (;;)
-    {
-	DAT_RETURN      ret;
-	DAT_EVENT       event;
+	for (;;) {
+		DAT_RETURN ret;
+		DAT_EVENT event;
 
-	ret = DT_Tdep_evd_wait (evd_handle, DAT_TIMEOUT_INFINITE, &event);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dapl_event_wait (RMR) failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    break;
-	}
+		ret =
+		    DT_Tdep_evd_wait(evd_handle, DAT_TIMEOUT_INFINITE, &event);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dapl_event_wait (RMR) failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			break;
+		}
 
-	if (event.event_number == DAT_RMR_BIND_COMPLETION_EVENT)
-	{
-	    /*
-	     * Pass back all the useful bits if requested:
-	     *      rmr_handle,  user_cookie, status
-	     */
-	    if (rmr_statusp)
-	    {
-		*rmr_statusp = event.event_data.rmr_completion_event_data;
-	    }
-	    return (true);
+		if (event.event_number == DAT_RMR_BIND_COMPLETION_EVENT) {
+			/*
+			 * Pass back all the useful bits if requested:
+			 *      rmr_handle,  user_cookie, status
+			 */
+			if (rmr_statusp) {
+				*rmr_statusp =
+				    event.event_data.rmr_completion_event_data;
+			}
+			return (true);
+		}
+
+		DT_Tdep_PT_Printf(phead,
+				  "Warning: rmr_event_wait swallowing %s event\n",
+				  DT_EventToSTr(event.event_number));
 	}
 
-	DT_Tdep_PT_Printf (phead, "Warning: rmr_event_wait swallowing %s event\n",
-		    DT_EventToSTr (event.event_number));
-    }
-
-    return (false);
+	return (false);
 }
 
-
 /* -----------------------------------------------------------
  * Check a DTO and print some debug info if anything is amiss.
  */
 bool
-DT_dto_check ( DT_Tdep_Print_Head *phead,
-	       DAT_DTO_COMPLETION_EVENT_DATA *dto_p,
-	       DAT_EP_HANDLE   ep_expected,
-	       DAT_COUNT       len_expected,
-	       DAT_DTO_COOKIE  cookie_expected,
-	       char           *message )
+DT_dto_check(DT_Tdep_Print_Head * phead,
+	     DAT_DTO_COMPLETION_EVENT_DATA * dto_p,
+	     DAT_EP_HANDLE ep_expected,
+	     DAT_COUNT len_expected,
+	     DAT_DTO_COOKIE cookie_expected, char *message)
 {
-    if ( ( (ep_expected != NULL) && (dto_p->ep_handle != ep_expected) )
-	 || dto_p->transfered_length != len_expected
-	 || dto_p->user_cookie.as_64 != cookie_expected.as_64
-	 || dto_p->status != DAT_DTO_SUCCESS )
-    {
-	DT_Tdep_PT_Printf (phead, "Test Error: %s-reaping DTO problem, status = %s\n",
-		      message,
-		      (dto_p->status == DAT_DTO_SUCCESS ? "OK"
-		       : (dto_p->status == DAT_DTO_FAILURE ? "FAILURE"
-			  : "LengthError")));
-	DT_Test_Error ();
-	if ( (ep_expected != NULL) && (dto_p->ep_handle != ep_expected) )
-	{
-	    DT_Tdep_PT_Printf (phead, "\tEndPoint mismatch (got %p wanted %p)\n",
-			    dto_p->ep_handle,
-			    ep_expected);
+	if (((ep_expected != NULL) && (dto_p->ep_handle != ep_expected))
+	    || dto_p->transfered_length != len_expected
+	    || dto_p->user_cookie.as_64 != cookie_expected.as_64
+	    || dto_p->status != DAT_DTO_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test Error: %s-reaping DTO problem, status = %s\n",
+				  message,
+				  (dto_p->status ==
+				   DAT_DTO_SUCCESS ? "OK" : (dto_p->status ==
+							     DAT_DTO_FAILURE ?
+							     "FAILURE" :
+							     "LengthError")));
+		DT_Test_Error();
+		if ((ep_expected != NULL) && (dto_p->ep_handle != ep_expected)) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tEndPoint mismatch (got %p wanted %p)\n",
+					  dto_p->ep_handle, ep_expected);
+		}
+		if (dto_p->transfered_length != len_expected) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tLength mismatch (xfer 0x" F64x
+					  " wanted 0x%x)\n",
+					  dto_p->transfered_length,
+					  len_expected);
+		}
+		if (dto_p->user_cookie.as_64 != cookie_expected.as_64) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tCookie mismatch (got " F64x
+					  " wanted " F64x ")\n",
+					  dto_p->user_cookie.as_64,
+					  cookie_expected.as_64);
+		}
+		return (false);
 	}
-	if (dto_p->transfered_length != len_expected)
-	{
-	    DT_Tdep_PT_Printf ( phead,
-		"\tLength mismatch (xfer 0x" F64x " wanted 0x%x)\n",
-		dto_p->transfered_length,
-		len_expected);
-	}
-	if (dto_p->user_cookie.as_64 != cookie_expected.as_64)
-	{
-	    DT_Tdep_PT_Printf (phead, "\tCookie mismatch (got " F64x " wanted " F64x ")\n",
-			   dto_p->user_cookie.as_64,
-			   cookie_expected.as_64);
-	}
-	return ( false );
-    }
 
-    return ( true );
+	return (true);
 }
 
-
 /* -----------------------------------------------------------
  * Check an RMR Bind  and print some debug info if anything is amiss.
  */
 bool
-DT_rmr_check ( DT_Tdep_Print_Head *phead,
-		DAT_RMR_BIND_COMPLETION_EVENT_DATA *rmr_p,
-		DAT_RMR_HANDLE  rmr_expected,
-		DAT_PVOID       cookie_expected,
-		char            *message)
+DT_rmr_check(DT_Tdep_Print_Head * phead,
+	     DAT_RMR_BIND_COMPLETION_EVENT_DATA * rmr_p,
+	     DAT_RMR_HANDLE rmr_expected,
+	     DAT_PVOID cookie_expected, char *message)
 {
-    if ( rmr_p->rmr_handle != rmr_expected
-	 || rmr_p->user_cookie.as_ptr != cookie_expected
-	 || rmr_p->status != DAT_RMR_BIND_SUCCESS )
-    {
+	if (rmr_p->rmr_handle != rmr_expected
+	    || rmr_p->user_cookie.as_ptr != cookie_expected
+	    || rmr_p->status != DAT_RMR_BIND_SUCCESS) {
 
-	DT_Tdep_PT_Printf (phead, "Test Error: %s RMR bind problem, status = %s\n",
-		      message,
-		      (rmr_p->status == DAT_RMR_BIND_SUCCESS
-		       ? "OK" : "FAILURE"));
-	DT_Test_Error ();
-	if (rmr_p->rmr_handle != rmr_expected)
-	{
-	    DT_Tdep_PT_Printf (phead, "\tRMR handle mismatch (got 0x%p wanted 0x%p)\n",
-			    rmr_p->rmr_handle,
-			    rmr_expected);
+		DT_Tdep_PT_Printf(phead,
+				  "Test Error: %s RMR bind problem, status = %s\n",
+				  message,
+				  (rmr_p->status ==
+				   DAT_RMR_BIND_SUCCESS ? "OK" : "FAILURE"));
+		DT_Test_Error();
+		if (rmr_p->rmr_handle != rmr_expected) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tRMR handle mismatch (got 0x%p wanted 0x%p)\n",
+					  rmr_p->rmr_handle, rmr_expected);
+		}
+		if (rmr_p->user_cookie.as_ptr != cookie_expected) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tCookie mismatch (got %p wanted %p)\n",
+					  rmr_p->user_cookie.as_ptr,
+					  cookie_expected);
+		}
+		return (false);
 	}
-	if (rmr_p->user_cookie.as_ptr != cookie_expected)
-	{
-	    DT_Tdep_PT_Printf (phead, "\tCookie mismatch (got %p wanted %p)\n",
-			    rmr_p->user_cookie.as_ptr,
-			    cookie_expected);
-	}
-	return ( false );
-    }
 
-    return ( true );
+	return (true);
 }
 
-
 /* -----------------------------------------------------------
  * Check a CR and print some debug info if anything is amiss.
  */
 bool
-DT_cr_check (  DT_Tdep_Print_Head *phead,
-		DAT_CR_ARRIVAL_EVENT_DATA *cr_stat_p,
-		DAT_PSP_HANDLE  psp_handle_expected,
-		DAT_CONN_QUAL   port_expected,
-		DAT_CR_HANDLE   *cr_handlep,
-		char            *message)
+DT_cr_check(DT_Tdep_Print_Head * phead,
+	    DAT_CR_ARRIVAL_EVENT_DATA * cr_stat_p,
+	    DAT_PSP_HANDLE psp_handle_expected,
+	    DAT_CONN_QUAL port_expected,
+	    DAT_CR_HANDLE * cr_handlep, char *message)
 {
-    DAT_RETURN ret;
+	DAT_RETURN ret;
 
-    if (cr_handlep)
-    {
-	*cr_handlep = (DAT_CR_HANDLE) 0;
-    }
+	if (cr_handlep) {
+		*cr_handlep = (DAT_CR_HANDLE) 0;
+	}
 
-    if (cr_stat_p->conn_qual != port_expected ||
-	(psp_handle_expected &&
-	    cr_stat_p->sp_handle.psp_handle != psp_handle_expected))
-    {
+	if (cr_stat_p->conn_qual != port_expected ||
+	    (psp_handle_expected &&
+	     cr_stat_p->sp_handle.psp_handle != psp_handle_expected)) {
 
-	DT_Tdep_PT_Printf (phead, "Test Error: %s CR data problem\n", message);
-	DT_Test_Error ();
-	if (cr_stat_p->conn_qual != port_expected)
-	{
-	    DT_Tdep_PT_Printf (phead, "\tCR conn_qual mismatch "
-			   " (got 0x" F64x " wanted 0x" F64x ")\n",
-			    cr_stat_p->conn_qual, port_expected);
+		DT_Tdep_PT_Printf(phead, "Test Error: %s CR data problem\n",
+				  message);
+		DT_Test_Error();
+		if (cr_stat_p->conn_qual != port_expected) {
+			DT_Tdep_PT_Printf(phead, "\tCR conn_qual mismatch "
+					  " (got 0x" F64x " wanted 0x" F64x
+					  ")\n", cr_stat_p->conn_qual,
+					  port_expected);
+		}
+		if (psp_handle_expected &&
+		    cr_stat_p->sp_handle.psp_handle != psp_handle_expected) {
+			DT_Tdep_PT_Printf(phead,
+					  "\tPSP mismatch (got 0x%p wanted 0x%p)\n",
+					  cr_stat_p->sp_handle.psp_handle,
+					  psp_handle_expected);
+		}
+		if (!cr_stat_p->cr_handle) {
+			DT_Tdep_PT_Printf(phead, "\tGot NULL cr_handle\n");
+		} else {
+			ret = dat_cr_reject(cr_stat_p->cr_handle, 0, NULL);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "\tdat_cr_reject error: %s\n",
+						  DT_RetToString(ret));
+			}
+		}
+		return (false);
 	}
-	if (psp_handle_expected &&
-		cr_stat_p->sp_handle.psp_handle != psp_handle_expected)
-	{
-	    DT_Tdep_PT_Printf (phead, "\tPSP mismatch (got 0x%p wanted 0x%p)\n",
-			    cr_stat_p->sp_handle.psp_handle,
-			    psp_handle_expected);
-	}
-	if (!cr_stat_p->cr_handle)
-	{
-	    DT_Tdep_PT_Printf (phead, "\tGot NULL cr_handle\n");
-	}
-	else
-	{
-	    ret = dat_cr_reject (cr_stat_p->cr_handle, 0, NULL);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "\tdat_cr_reject error: %s\n",
-				    DT_RetToString (ret));
-	    }
-	}
-	return ( false );
-    }
 
-    if (cr_handlep)
-    {
-	*cr_handlep = cr_stat_p->cr_handle;
-    }
-    return ( true );
+	if (cr_handlep) {
+		*cr_handlep = cr_stat_p->cr_handle;
+	}
+	return (true);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_thread.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_thread.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_thread.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,42 +34,39 @@
  *
  * Threads subsystem initialization
  */
-void
-DT_Thread_Init (Per_Test_Data_t * pt_ptr)
+void DT_Thread_Init(Per_Test_Data_t * pt_ptr)
 {
-    DT_Mdep_LockInit (&pt_ptr->Thread_counter_lock);
-    pt_ptr->Thread_counter = 0;
+	DT_Mdep_LockInit(&pt_ptr->Thread_counter_lock);
+	pt_ptr->Thread_counter = 0;
 
-    /*
-     * Initialize the synchronization event in the pt_ptr so it's ready
-     * to be signalled when the time comes.  The countdown counter
-     * lets me coordinate with all the test threads so that the server
-     * thread doesn't get notified that the test endpoints are ready
-     * until they actually are.  Only transaction tests use this *
-     * functionality; if the performance test gets changed to use
-     * multiple threads on the server side then that code semantic
-     * will need to be added for final test endpoint setup
-     * notification or there will continue  to be a race condition
-     * between the main server thread and the server test threads.
-     */
-    DT_Mdep_wait_object_init (&pt_ptr->synch_wait_object);
-    pt_ptr->Countdown_Counter	= 0;
+	/*
+	 * Initialize the synchronization event in the pt_ptr so it's ready
+	 * to be signalled when the time comes.  The countdown counter
+	 * lets me coordinate with all the test threads so that the server
+	 * thread doesn't get notified that the test endpoints are ready
+	 * until they actually are.  Only transaction tests use this *
+	 * functionality; if the performance test gets changed to use
+	 * multiple threads on the server side then that code semantic
+	 * will need to be added for final test endpoint setup
+	 * notification or there will continue  to be a race condition
+	 * between the main server thread and the server test threads.
+	 */
+	DT_Mdep_wait_object_init(&pt_ptr->synch_wait_object);
+	pt_ptr->Countdown_Counter = 0;
 
 }
 
 /*
  * Threads subsystem destroying
  */
-void
-DT_Thread_End (Per_Test_Data_t * pt_ptr)
+void DT_Thread_End(Per_Test_Data_t * pt_ptr)
 {
-    DT_Mdep_LockDestroy (&pt_ptr->Thread_counter_lock);
+	DT_Mdep_LockDestroy(&pt_ptr->Thread_counter_lock);
 
-    /*
-     * destroy the wait object created by init.
-     */
-    DT_Mdep_wait_object_destroy (
-	&pt_ptr->synch_wait_object );
+	/*
+	 * destroy the wait object created by init.
+	 */
+	DT_Mdep_wait_object_destroy(&pt_ptr->synch_wait_object);
 
 }
 
@@ -79,47 +76,44 @@
  * NOTE: This routine does NOT create a thread as the name implies. The thread
  * is created in DT_Thread_Start (which is counter intuitive)
  */
-Thread         *
-DT_Thread_Create (Per_Test_Data_t * pt_ptr,
-	      void (*fn) (void *),
-	      void *param,
-	      unsigned int stacksize)
+Thread *DT_Thread_Create(Per_Test_Data_t * pt_ptr,
+			 void (*fn) (void *),
+			 void *param, unsigned int stacksize)
 {
-    Thread         *thread_ptr;
-    thread_ptr = (Thread *) DT_MemListAlloc (pt_ptr, "thread.c", THREAD, sizeof (Thread));
-    if (thread_ptr == NULL)
-    {
-	return NULL;
-    }
-    thread_ptr->param = param;
-    thread_ptr->function = fn;
-    thread_ptr->thread_handle = 0;
-    thread_ptr->stacksize = stacksize;
+	Thread *thread_ptr;
+	thread_ptr =
+	    (Thread *) DT_MemListAlloc(pt_ptr, "thread.c", THREAD,
+				       sizeof(Thread));
+	if (thread_ptr == NULL) {
+		return NULL;
+	}
+	thread_ptr->param = param;
+	thread_ptr->function = fn;
+	thread_ptr->thread_handle = 0;
+	thread_ptr->stacksize = stacksize;
 
-    DT_Mdep_Lock (&pt_ptr->Thread_counter_lock);
-    pt_ptr->Thread_counter++;
-    DT_Mdep_Unlock (&pt_ptr->Thread_counter_lock);
+	DT_Mdep_Lock(&pt_ptr->Thread_counter_lock);
+	pt_ptr->Thread_counter++;
+	DT_Mdep_Unlock(&pt_ptr->Thread_counter_lock);
 
-    DT_Mdep_Thread_Init_Attributes (thread_ptr);
+	DT_Mdep_Thread_Init_Attributes(thread_ptr);
 
-    return thread_ptr;
+	return thread_ptr;
 }
 
 /*
  * Thread destructor
  */
-void
-DT_Thread_Destroy (Thread * thread_ptr, Per_Test_Data_t * pt_ptr)
+void DT_Thread_Destroy(Thread * thread_ptr, Per_Test_Data_t * pt_ptr)
 {
-    if (thread_ptr)
-    {
-	DT_Mdep_Lock (&pt_ptr->Thread_counter_lock);
-	pt_ptr->Thread_counter--;
-	DT_Mdep_Unlock (&pt_ptr->Thread_counter_lock);
+	if (thread_ptr) {
+		DT_Mdep_Lock(&pt_ptr->Thread_counter_lock);
+		pt_ptr->Thread_counter--;
+		DT_Mdep_Unlock(&pt_ptr->Thread_counter_lock);
 
-	DT_Mdep_Thread_Destroy_Attributes (thread_ptr);
-	DT_MemListFree (pt_ptr, thread_ptr);
-    }
+		DT_Mdep_Thread_Destroy_Attributes(thread_ptr);
+		DT_MemListFree(pt_ptr, thread_ptr);
+	}
 }
 
 /*
@@ -127,8 +121,7 @@
  * to starting it whereas DT_Thread_Create just sets up some data structures.
  * (this is counter-intuitive)
  */
-bool
-DT_Thread_Start (Thread * thread_ptr)
+bool DT_Thread_Start(Thread * thread_ptr)
 {
-    return DT_Mdep_Thread_Start (thread_ptr);
+	return DT_Mdep_Thread_Start(thread_ptr);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_stats.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_stats.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_stats.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -31,146 +31,146 @@
 #include "dapl_proto.h"
 
 void
-DT_init_transaction_stats (Transaction_Stats_t * transaction_stats, unsigned int num)
+DT_init_transaction_stats(Transaction_Stats_t * transaction_stats,
+			  unsigned int num)
 {
-    DT_Mdep_LockInit (&transaction_stats->lock);
+	DT_Mdep_LockInit(&transaction_stats->lock);
 
-    transaction_stats->wait_count = num;
-    transaction_stats->num_ops = 0;
-    transaction_stats->time_ms = 0;
-    transaction_stats->bytes_send = 0;
-    transaction_stats->bytes_recv = 0;
-    transaction_stats->bytes_rdma_read = 0;
-    transaction_stats->bytes_rdma_write = 0;
+	transaction_stats->wait_count = num;
+	transaction_stats->num_ops = 0;
+	transaction_stats->time_ms = 0;
+	transaction_stats->bytes_send = 0;
+	transaction_stats->bytes_recv = 0;
+	transaction_stats->bytes_rdma_read = 0;
+	transaction_stats->bytes_rdma_write = 0;
 }
 
 void
-DT_transaction_stats_set_ready (DT_Tdep_Print_Head *phead, 
-				Transaction_Stats_t * transaction_stats)
+DT_transaction_stats_set_ready(DT_Tdep_Print_Head * phead,
+			       Transaction_Stats_t * transaction_stats)
 {
-    DT_Mdep_Lock (&transaction_stats->lock);
-    transaction_stats->wait_count--;
+	DT_Mdep_Lock(&transaction_stats->lock);
+	transaction_stats->wait_count--;
 
-    DT_Tdep_PT_Debug (1,(phead,"Received Sync Message from server (%d left)\n",
-		    transaction_stats->wait_count));
-    DT_Mdep_Unlock (&transaction_stats->lock);
+	DT_Tdep_PT_Debug(1,
+			 (phead,
+			  "Received Sync Message from server (%d left)\n",
+			  transaction_stats->wait_count));
+	DT_Mdep_Unlock(&transaction_stats->lock);
 }
 
 bool
-DT_transaction_stats_wait_for_all (DT_Tdep_Print_Head *phead,
-				   Transaction_Stats_t * transaction_stats)
+DT_transaction_stats_wait_for_all(DT_Tdep_Print_Head * phead,
+				  Transaction_Stats_t * transaction_stats)
 {
-    unsigned int    loop_count;
-    loop_count = 100 * 10;	/* 100 * 10ms * 10  = 10 seconds */
-    while (transaction_stats->wait_count != 0 && loop_count != 0)
-    {
-	DT_Mdep_Sleep (10);
-	loop_count--;
-    }
-    if (loop_count == 0)
-    {
-	DT_Tdep_PT_Printf (phead, "FAIL: %d Server test connections did not report ready.\n",
-		    transaction_stats->wait_count);
-	return false;
-    }
-    return true;
+	unsigned int loop_count;
+	loop_count = 100 * 10;	/* 100 * 10ms * 10  = 10 seconds */
+	while (transaction_stats->wait_count != 0 && loop_count != 0) {
+		DT_Mdep_Sleep(10);
+		loop_count--;
+	}
+	if (loop_count == 0) {
+		DT_Tdep_PT_Printf(phead,
+				  "FAIL: %d Server test connections did not report ready.\n",
+				  transaction_stats->wait_count);
+		return false;
+	}
+	return true;
 }
 
-
 /*
  *
  */
 void
-DT_update_transaction_stats (Transaction_Stats_t * transaction_stats,
-		       unsigned int num_ops,
-		       unsigned int time_ms,
-		       unsigned int bytes_send,
-		       unsigned int bytes_recv,
-		       unsigned int bytes_rdma_read,
-		       unsigned int bytes_rdma_write)
+DT_update_transaction_stats(Transaction_Stats_t * transaction_stats,
+			    unsigned int num_ops,
+			    unsigned int time_ms,
+			    unsigned int bytes_send,
+			    unsigned int bytes_recv,
+			    unsigned int bytes_rdma_read,
+			    unsigned int bytes_rdma_write)
 {
-    DT_Mdep_Lock (&transaction_stats->lock);
+	DT_Mdep_Lock(&transaction_stats->lock);
 
-    /* look for the longest time... */
-    if (time_ms > transaction_stats->time_ms)
-    {
-	transaction_stats->time_ms = time_ms;
-    }
+	/* look for the longest time... */
+	if (time_ms > transaction_stats->time_ms) {
+		transaction_stats->time_ms = time_ms;
+	}
 
-    transaction_stats->num_ops += num_ops;
-    transaction_stats->bytes_send += bytes_send;
-    transaction_stats->bytes_recv += bytes_recv;
-    transaction_stats->bytes_rdma_read += bytes_rdma_read;
-    transaction_stats->bytes_rdma_write += bytes_rdma_write;
-    DT_Mdep_Unlock (&transaction_stats->lock);
+	transaction_stats->num_ops += num_ops;
+	transaction_stats->bytes_send += bytes_send;
+	transaction_stats->bytes_recv += bytes_recv;
+	transaction_stats->bytes_rdma_read += bytes_rdma_read;
+	transaction_stats->bytes_rdma_write += bytes_rdma_write;
+	DT_Mdep_Unlock(&transaction_stats->lock);
 }
 
 /*
  *
  */
 void
-DT_print_transaction_stats (DT_Tdep_Print_Head *phead,
-		   Transaction_Stats_t * transaction_stats,
-		   unsigned int num_threads,
-		   unsigned int num_EPs)
+DT_print_transaction_stats(DT_Tdep_Print_Head * phead,
+			   Transaction_Stats_t * transaction_stats,
+			   unsigned int num_threads, unsigned int num_EPs)
 {
-    double          time_s;
-    double          mbytes_send;
-    double          mbytes_recv;
-    double          mbytes_rdma_read;
-    double          mbytes_rdma_write;
-    int             total_ops;
-    DT_Mdep_Lock (&transaction_stats->lock);
-    time_s = (double) (transaction_stats->time_ms) / 1000;
-    if (time_s == 0.0)
-    {
-	DT_Tdep_PT_Printf (phead, 
-			"----- Test completed successfully, but cannot calculate stats as not\n"
-			"----- enough time has lapsed.\n"
-			"----- Try running the test with more iterations.\n");
-	goto unlock_and_return;
-    }
-    mbytes_send = (double) transaction_stats->bytes_send / 1000 / 1000;
-    mbytes_recv = (double) transaction_stats->bytes_recv / 1000 / 1000;
-    mbytes_rdma_read = (double) transaction_stats->bytes_rdma_read / 1000 / 1000;
-    mbytes_rdma_write = (double) transaction_stats->bytes_rdma_write / 1000 / 1000;
-    total_ops = transaction_stats->num_ops;
+	double time_s;
+	double mbytes_send;
+	double mbytes_recv;
+	double mbytes_rdma_read;
+	double mbytes_rdma_write;
+	int total_ops;
+	DT_Mdep_Lock(&transaction_stats->lock);
+	time_s = (double)(transaction_stats->time_ms) / 1000;
+	if (time_s == 0.0) {
+		DT_Tdep_PT_Printf(phead,
+				  "----- Test completed successfully, but cannot calculate stats as not\n"
+				  "----- enough time has lapsed.\n"
+				  "----- Try running the test with more iterations.\n");
+		goto unlock_and_return;
+	}
+	mbytes_send = (double)transaction_stats->bytes_send / 1000 / 1000;
+	mbytes_recv = (double)transaction_stats->bytes_recv / 1000 / 1000;
+	mbytes_rdma_read =
+	    (double)transaction_stats->bytes_rdma_read / 1000 / 1000;
+	mbytes_rdma_write =
+	    (double)transaction_stats->bytes_rdma_write / 1000 / 1000;
+	total_ops = transaction_stats->num_ops;
 
-    if ( 0 == total_ops )
-    {
-	DT_Tdep_PT_Printf (phead, "----- Test completed successfully, but no operations!\n");
-	goto unlock_and_return;
-    }
+	if (0 == total_ops) {
+		DT_Tdep_PT_Printf(phead,
+				  "----- Test completed successfully, but no operations!\n");
+		goto unlock_and_return;
+	}
 
-    DT_Tdep_PT_Printf (phead, "----- Stats ---- : %u threads, %u EPs\n",
-		   num_threads, num_EPs);
-    DT_Tdep_PT_Printf (phead, "Total WQE        : %7d.%02d WQE/Sec\n",
-		   whole (total_ops / time_s),
-		   hundredths (total_ops / time_s));
-    DT_Tdep_PT_Printf (phead, "Total Time       : %7d.%02d sec\n",
-		   whole (time_s),
-		   hundredths (time_s));
-    DT_Tdep_PT_Printf (phead, "Total Send       : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		   whole (mbytes_send),
-		   hundredths (mbytes_send),
-		   whole (mbytes_send / time_s),
-		   hundredths (mbytes_send / time_s));
-    DT_Tdep_PT_Printf (phead, "Total Recv       : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		   whole (mbytes_recv),
-		   hundredths (mbytes_recv),
-		   whole (mbytes_recv / time_s),
-		   hundredths (mbytes_recv / time_s));
-    DT_Tdep_PT_Printf (phead, "Total RDMA Read  : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		   whole (mbytes_rdma_read),
-		   hundredths (mbytes_rdma_read),
-		   whole (mbytes_rdma_read / time_s),
-		   hundredths (mbytes_rdma_read / time_s));
-    DT_Tdep_PT_Printf (phead, "Total RDMA Write : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		   whole (mbytes_rdma_write),
-		   hundredths (mbytes_rdma_write),
-		   whole (mbytes_rdma_write / time_s),
-		   hundredths (mbytes_rdma_write / time_s));
+	DT_Tdep_PT_Printf(phead, "----- Stats ---- : %u threads, %u EPs\n",
+			  num_threads, num_EPs);
+	DT_Tdep_PT_Printf(phead, "Total WQE        : %7d.%02d WQE/Sec\n",
+			  whole(total_ops / time_s),
+			  hundredths(total_ops / time_s));
+	DT_Tdep_PT_Printf(phead, "Total Time       : %7d.%02d sec\n",
+			  whole(time_s), hundredths(time_s));
+	DT_Tdep_PT_Printf(phead,
+			  "Total Send       : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_send), hundredths(mbytes_send),
+			  whole(mbytes_send / time_s),
+			  hundredths(mbytes_send / time_s));
+	DT_Tdep_PT_Printf(phead,
+			  "Total Recv       : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_recv), hundredths(mbytes_recv),
+			  whole(mbytes_recv / time_s),
+			  hundredths(mbytes_recv / time_s));
+	DT_Tdep_PT_Printf(phead,
+			  "Total RDMA Read  : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_rdma_read), hundredths(mbytes_rdma_read),
+			  whole(mbytes_rdma_read / time_s),
+			  hundredths(mbytes_rdma_read / time_s));
+	DT_Tdep_PT_Printf(phead,
+			  "Total RDMA Write : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_rdma_write),
+			  hundredths(mbytes_rdma_write),
+			  whole(mbytes_rdma_write / time_s),
+			  hundredths(mbytes_rdma_write / time_s));
 
-unlock_and_return:
-    DT_Mdep_Unlock (&transaction_stats->lock);
+      unlock_and_return:
+	DT_Mdep_Unlock(&transaction_stats->lock);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_test.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_test.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_test.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -43,123 +43,117 @@
  */
 #define SYNC_BUFF_SIZE		64
 
-#define DFLT_QLEN      8        /* default event queue length */
-#define DFLT_TMO      10        /* default timeout (seconds)  */
+#define DFLT_QLEN      8	/* default event queue length */
+#define DFLT_TMO      10	/* default timeout (seconds)  */
 #define MAX_CONN_RETRY 8
 
 /****************************************************************************/
-void
-DT_Transaction_Test_Client (Per_Test_Data_t * pt_ptr,
-			DAT_IA_HANDLE ia_handle,
-			DAT_IA_ADDRESS_PTR remote_ia_addr)
+DAT_RETURN
+DT_Transaction_Test_Client(Per_Test_Data_t * pt_ptr,
+			   DAT_IA_HANDLE ia_handle,
+			   DAT_IA_ADDRESS_PTR remote_ia_addr)
 {
-    Transaction_Cmd_t *cmd = &pt_ptr->Params.u.Transaction_Cmd;
-    unsigned int    i;
-    DT_Tdep_Print_Head *phead;
+	Transaction_Cmd_t *cmd = &pt_ptr->Params.u.Transaction_Cmd;
+	unsigned int i;
+	DT_Tdep_Print_Head *phead;
+	DAT_RETURN rc = DAT_SUCCESS;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    DT_init_transaction_stats (&pt_ptr->Client_Stats,
-		      cmd->num_threads * cmd->eps_per_thread);
+	DT_init_transaction_stats(&pt_ptr->Client_Stats,
+				  cmd->num_threads * cmd->eps_per_thread);
 
-    /* Now go set up the client test threads */
-    for (i = 0;  i < cmd->num_threads;  i++)
-    {
-	unsigned int port_num = pt_ptr->Server_Info.first_port_number
-					+ i * cmd->eps_per_thread;
+	/* Now go set up the client test threads */
+	for (i = 0; i < cmd->num_threads; i++) {
+		unsigned int port_num = pt_ptr->Server_Info.first_port_number
+		    + i * cmd->eps_per_thread;
 
-	DT_Tdep_PT_Debug (1,(phead,"Client: Starting Client side of test\n"));
-	if (!DT_Transaction_Create_Test (pt_ptr,
-				     ia_handle,
-				     false,
-				     port_num,
-				     pt_ptr->Server_Info.is_little_endian,
-				     remote_ia_addr))
-	{
-	    DT_Tdep_PT_Printf (phead, "Client: Cannot Create Test!\n");
-	    break;
-	}
-
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Client: Starting Client side of test\n"));
+		if (!DT_Transaction_Create_Test
+		    (pt_ptr, ia_handle, false, port_num,
+		     pt_ptr->Server_Info.is_little_endian, remote_ia_addr)) {
+			DT_Tdep_PT_Printf(phead,
+					  "Client: Cannot Create Test!\n");
+			rc = DAT_INSUFFICIENT_RESOURCES;
+			break;
+		}
 #ifdef CM_BUSTED
 	/*****  XXX Chill out a bit to give the kludged CM a chance ...
-	 *****/DT_Mdep_Sleep (5000);
+	 *****/ DT_Mdep_Sleep(5000);
 #endif
 
-    }
+	}
 
-    /* Wait until end of all threads */
-    while (pt_ptr->Thread_counter > 0)
-    {
-	DT_Mdep_Sleep (100);
-    }
+	/* Wait until end of all threads */
+	while (pt_ptr->Thread_counter > 0) {
+		DT_Mdep_Sleep(100);
+	}
 
-    DT_print_transaction_stats (phead,
-	    			    &pt_ptr->Client_Stats,
-				    cmd->num_threads,
-				    cmd->eps_per_thread);
+	DT_print_transaction_stats(phead,
+				   &pt_ptr->Client_Stats,
+				   cmd->num_threads, cmd->eps_per_thread);
+	return rc;
 }
 
-
 /****************************************************************************/
-void
-DT_Transaction_Test_Server (void *params)
+void DT_Transaction_Test_Server(void *params)
 {
-    Per_Test_Data_t *pt_ptr     = (Per_Test_Data_t *) params;
-    Transaction_Cmd_t *cmd      = &pt_ptr->Params.u.Transaction_Cmd;
-    unsigned int      i;
-    DT_Tdep_Print_Head *phead;
+	Per_Test_Data_t *pt_ptr = (Per_Test_Data_t *) params;
+	Transaction_Cmd_t *cmd = &pt_ptr->Params.u.Transaction_Cmd;
+	unsigned int i;
+	DT_Tdep_Print_Head *phead;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    pt_ptr->Countdown_Counter = cmd->num_threads;
+	pt_ptr->Countdown_Counter = cmd->num_threads;
 
-    for (i = 0;  i < cmd->num_threads;  i++)
-    {
-	unsigned int port_num = pt_ptr->Server_Info.first_port_number
-					+ i * cmd->eps_per_thread;
+	for (i = 0; i < cmd->num_threads; i++) {
+		unsigned int port_num = pt_ptr->Server_Info.first_port_number
+		    + i * cmd->eps_per_thread;
 
-	if (!DT_Transaction_Create_Test (pt_ptr,
-				     pt_ptr->ps_ptr->ia_handle,
-				     true,
-				     port_num,
-				     pt_ptr->Client_Info.is_little_endian,
-				     (DAT_IA_ADDRESS_PTR) 0))
-	{
-	    DT_Tdep_PT_Printf (phead, "Server: Cannot Create Test!\n");
-	    break;
-	}
-
+		if (!DT_Transaction_Create_Test(pt_ptr,
+						pt_ptr->ps_ptr->ia_handle,
+						true,
+						port_num,
+						pt_ptr->Client_Info.
+						is_little_endian,
+						(DAT_IA_ADDRESS_PTR) 0)) {
+			DT_Tdep_PT_Printf(phead,
+					  "Server: Cannot Create Test!\n");
+			break;
+		}
 #ifdef CM_BUSTED
 	/*****  XXX Chill out a bit to give the kludged CM a chance ...
-	 *****/DT_Mdep_Sleep (5000);
+	 *****/ DT_Mdep_Sleep(5000);
 #endif
 
-    }
+	}
 
-    /* Wait until end of all sub-threads */
-    while (pt_ptr->Thread_counter > 1)
-    {
-	DT_Mdep_Sleep (100);
-    }
-    DT_Thread_Destroy (pt_ptr->thread, pt_ptr);	    /* destroy Master thread */
+	/* Wait until end of all sub-threads */
+	while (pt_ptr->Thread_counter > 1) {
+		DT_Mdep_Sleep(100);
+	}
+	DT_Thread_Destroy(pt_ptr->thread, pt_ptr);	/* destroy Master thread */
 
-    DT_Mdep_Lock (&pt_ptr->ps_ptr->num_clients_lock);
-    pt_ptr->ps_ptr->num_clients--;
-    DT_Mdep_Unlock (&pt_ptr->ps_ptr->num_clients_lock);
+	DT_Mdep_Lock(&pt_ptr->ps_ptr->num_clients_lock);
+	pt_ptr->ps_ptr->num_clients--;
+	DT_Mdep_Unlock(&pt_ptr->ps_ptr->num_clients_lock);
 
-    /* NB: Server has no pt_ptr->remote_netaddr */
-    DT_PrintMemList (pt_ptr);	    /* check if we return all space allocated */
-    DT_Mdep_LockDestroy (&pt_ptr->Thread_counter_lock);
-    DT_Mdep_LockDestroy (&pt_ptr->MemListLock);
-    DT_Free_Per_Test_Data (pt_ptr);
-    DT_Tdep_PT_Printf (phead, "Server: Transaction Test Finished for this client\n");
-    /*
-     * check memory leaking DT_Tdep_PT_Printf(phead, "Server: App allocated Memory Left:
-     * %d\n", alloc_count);
-     */
+	/* NB: Server has no pt_ptr->remote_netaddr */
+	DT_PrintMemList(pt_ptr);	/* check if we return all space allocated */
+	DT_Mdep_LockDestroy(&pt_ptr->Thread_counter_lock);
+	DT_Mdep_LockDestroy(&pt_ptr->MemListLock);
+	DT_Free_Per_Test_Data(pt_ptr);
+	DT_Tdep_PT_Printf(phead,
+			  "Server: Transaction Test Finished for this client\n");
+	/*
+	 * check memory leaking DT_Tdep_PT_Printf(phead, "Server: App allocated Memory Left:
+	 * %d\n", alloc_count);
+	 */
 }
 
-
 /****************************************************************************/
 /*
  * DT_Transaction_Create_Test()
@@ -169,64 +163,63 @@
  */
 
 bool
-DT_Transaction_Create_Test (Per_Test_Data_t * pt_ptr,
-			DAT_IA_HANDLE *ia_handle,
-			DAT_BOOLEAN is_server,
-			unsigned int port_num,
-			DAT_BOOLEAN remote_is_little_endian,
-			DAT_IA_ADDRESS_PTR remote_ia_addr)
+DT_Transaction_Create_Test(Per_Test_Data_t * pt_ptr,
+			   DAT_IA_HANDLE * ia_handle,
+			   DAT_BOOLEAN is_server,
+			   unsigned int port_num,
+			   DAT_BOOLEAN remote_is_little_endian,
+			   DAT_IA_ADDRESS_PTR remote_ia_addr)
 {
-    Transaction_Test_t *test_ptr;
-    DT_Tdep_Print_Head *phead;
+	Transaction_Test_t *test_ptr;
+	DT_Tdep_Print_Head *phead;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    test_ptr = (Transaction_Test_t *) DT_MemListAlloc (pt_ptr,
-						   "transaction_test_t",
-						   TRANSACTIONTEST,
-						sizeof (Transaction_Test_t));
-    if (!test_ptr)
-    {
-	DT_Tdep_PT_Printf (phead, "No Memory to create transaction test structure!\n");
-	return false;
-    }
+	test_ptr = (Transaction_Test_t *) DT_MemListAlloc(pt_ptr,
+							  "transaction_test_t",
+							  TRANSACTIONTEST,
+							  sizeof
+							  (Transaction_Test_t));
+	if (!test_ptr) {
+		DT_Tdep_PT_Printf(phead,
+				  "No Memory to create transaction test structure!\n");
+		return false;
+	}
 
-    /* Unused fields zeroed by allocator */
-    test_ptr->remote_is_little_endian = remote_is_little_endian;
-    test_ptr->is_server	     = is_server;
-    test_ptr->pt_ptr	     = pt_ptr;
-    test_ptr->ia_handle	     = ia_handle;
-    test_ptr->base_port     = (DAT_CONN_QUAL) port_num;
-    test_ptr->cmd	     = &pt_ptr->Params.u.Transaction_Cmd;
-    test_ptr->time_out	     = DFLT_TMO * 1000;	    /* DFLT_TMO seconds  */
+	/* Unused fields zeroed by allocator */
+	test_ptr->remote_is_little_endian = remote_is_little_endian;
+	test_ptr->is_server = is_server;
+	test_ptr->pt_ptr = pt_ptr;
+	test_ptr->ia_handle = ia_handle;
+	test_ptr->base_port = (DAT_CONN_QUAL) port_num;
+	test_ptr->cmd = &pt_ptr->Params.u.Transaction_Cmd;
+	test_ptr->time_out = DFLT_TMO * 1000;	/* DFLT_TMO seconds  */
 
-    /* FIXME more analysis needs to go into determining the minimum  */
-    /* possible value for DFLT_QLEN. This evd_length value will be   */
-    /* used for all EVDs. There are a number of dependencies imposed */
-    /* by this design (ex. min(cr_evd_len) != min(recv_evd_len) ).   */
-    /* In the future it may be best to use individual values.        */
-    test_ptr->evd_length     = DT_max (
-	DFLT_QLEN,
-	test_ptr->cmd->eps_per_thread * test_ptr->cmd->num_ops);
+	/* FIXME more analysis needs to go into determining the minimum  */
+	/* possible value for DFLT_QLEN. This evd_length value will be   */
+	/* used for all EVDs. There are a number of dependencies imposed */
+	/* by this design (ex. min(cr_evd_len) != min(recv_evd_len) ).   */
+	/* In the future it may be best to use individual values.        */
+	test_ptr->evd_length = DT_max(DFLT_QLEN,
+				      test_ptr->cmd->eps_per_thread *
+				      test_ptr->cmd->num_ops);
 
-    test_ptr->remote_ia_addr = remote_ia_addr;
+	test_ptr->remote_ia_addr = remote_ia_addr;
 
-    test_ptr->thread = DT_Thread_Create (pt_ptr,
-				     DT_Transaction_Main,
-				     test_ptr,
-				     DT_MDEP_DEFAULT_STACK_SIZE);
-    if (test_ptr->thread == 0)
-    {
-	DT_Tdep_PT_Printf (phead, "No memory!\n");
-	DT_MemListFree (test_ptr->pt_ptr, test_ptr);
-	return false;
-    }
-    DT_Thread_Start (test_ptr->thread);
+	test_ptr->thread = DT_Thread_Create(pt_ptr,
+					    DT_Transaction_Main,
+					    test_ptr,
+					    DT_MDEP_DEFAULT_STACK_SIZE);
+	if (test_ptr->thread == 0) {
+		DT_Tdep_PT_Printf(phead, "No memory!\n");
+		DT_MemListFree(test_ptr->pt_ptr, test_ptr);
+		return false;
+	}
+	DT_Thread_Start(test_ptr->thread);
 
-    return true;
+	return true;
 }
 
-
 /****************************************************************************/
 /*
  * Main Transaction Test Execution Routine
@@ -237,1790 +230,2036 @@
  * buffers and local data structures.  When ready, the two sides
  * synchronize, then testing begins.
  */
-void
-DT_Transaction_Main (void *param)
+void DT_Transaction_Main(void *param)
 {
-    Transaction_Test_t  *test_ptr = (Transaction_Test_t *) param;
-    DAT_RETURN          ret;
-    DAT_UINT32          i, j;
-    bool		success = false;
-    Per_Test_Data_t     *pt_ptr;
-    Thread              *thread;
-    DAT_DTO_COOKIE	dto_cookie;
-    char		*private_data_str;
-    DAT_EVENT_NUMBER    event_num;
-    DT_Tdep_Print_Head *phead;
+	Transaction_Test_t *test_ptr = (Transaction_Test_t *) param;
+	DAT_RETURN ret;
+	DAT_UINT32 i, j;
+	bool success = false;
+	Per_Test_Data_t *pt_ptr;
+	Thread *thread;
+	DAT_DTO_COOKIE dto_cookie;
+	char *private_data_str;
+	DAT_EVENT_NUMBER event_num;
+	DT_Tdep_Print_Head *phead;
 
-    pt_ptr = test_ptr->pt_ptr;
-    thread = test_ptr->thread;
-    phead = pt_ptr->Params.phead;
+	pt_ptr = test_ptr->pt_ptr;
+	thread = test_ptr->thread;
+	phead = pt_ptr->Params.phead;
 #ifdef CM_BUSTED
-    private_data_str = "";
+	private_data_str = "";
 #else
-    private_data_str = "DAPL and RDMA rule! Test 4321.";
+	private_data_str = "DAPL and RDMA rule! Test 4321.";
 #endif
 
-    /* create a protection zone */
-    ret = dat_pz_create (test_ptr->ia_handle, &test_ptr->pz_handle);
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_pz_create error: %s\n",
-		    test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->pz_handle = DAT_HANDLE_NULL;
-	goto test_failure;
-    }
+	/* create a protection zone */
+	ret = dat_pz_create(test_ptr->ia_handle, &test_ptr->pz_handle);
+	if (ret != DAT_SUCCESS) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: dat_pz_create error: %s\n",
+				  test_ptr->base_port, DT_RetToString(ret));
+		test_ptr->pz_handle = DAT_HANDLE_NULL;
+		goto test_failure;
+	}
 
-    /* create 4 EVDs - recv, request+RMR, conn-request, connect */
-    ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			      test_ptr->evd_length,
-			      NULL,
-			      DAT_EVD_DTO_FLAG,
-			      &test_ptr->recv_evd_hdl);	 /* recv */
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (recv) error: %s\n",
-		    test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->recv_evd_hdl = DAT_HANDLE_NULL;
-	goto test_failure;
-    }
-
-    ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			      test_ptr->evd_length,
-			      NULL,
-			      DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
-			      &test_ptr->reqt_evd_hdl);	 /* request + rmr bind */
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (request) error: %s\n",
-		    test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->reqt_evd_hdl = DAT_HANDLE_NULL;
-	goto test_failure;
-    }
-
-    if (pt_ptr->local_is_server)
-    {
-	/* Client-side doesn't need CR events */
-	ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-				  test_ptr->evd_length,
-				  NULL,
-				  DAT_EVD_CR_FLAG,
-				  &test_ptr->creq_evd_hdl);  /* cr */
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (cr) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    test_ptr->creq_evd_hdl = DAT_HANDLE_NULL;
-	    goto test_failure;
+	/* Allocate per-EP data */
+	test_ptr->ep_context = (Ep_Context_t *)
+	    DT_MemListAlloc(pt_ptr,
+			    "transaction_test",
+			    EPCONTEXT,
+			    test_ptr->cmd->eps_per_thread
+			    * sizeof(Ep_Context_t));
+	if (!test_ptr->ep_context) {
+		DT_Tdep_PT_Printf(phead,
+				  "Test[" F64x "]: no memory for EP context\n",
+				  test_ptr->base_port);
+		goto test_failure;
 	}
-    }
 
-    ret = DT_Tdep_evd_create (test_ptr->ia_handle,
-			      test_ptr->evd_length,
-			      NULL,
-			      DAT_EVD_CONNECTION_FLAG,
-			      &test_ptr->conn_evd_hdl);	 /* conn */
-    if (ret != DAT_SUCCESS)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_create (conn) error: %s\n",
-		    test_ptr->base_port, DT_RetToString (ret));
-	test_ptr->conn_evd_hdl = DAT_HANDLE_NULL;
-	goto test_failure;
-    }
-
-    /* Allocate per-EP data */
-    test_ptr->ep_context = (Ep_Context_t *)
-			    DT_MemListAlloc (pt_ptr,
-					"transaction_test",
-					EPCONTEXT,
-					test_ptr->cmd->eps_per_thread
-						* sizeof (Ep_Context_t));
-    if (!test_ptr->ep_context)
-    {
-	DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for EP context\n",
-			test_ptr->base_port);
-	goto test_failure;
-    }
-
-    /*
-     * Set up the per-EP contexts:
-     *          create the EP
-     *          allocate buffers for remote memory info exchange
-     *          post the receive buffers
-     *          connect
-     *          set up buffers and remote memory info
-     *          send across our info
-     *          recv the other side's info and extract what we need
-     */
-    for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-    {
-	DAT_EP_ATTR	    ep_attr;
-	DAT_UINT32	    buff_size  =  MAX_OPS * sizeof (RemoteMemoryInfo);
-
 	/*
-	 * Adjust default EP attributes to fit the requested test.
-	 * This is simplistic; in that we don't count ops of each
-	 * type and direction, checking EP limits.  We just try to
-	 * be sure the EP's WQs are large enough.  The "+2" is for
-	 * the RemoteMemInfo and Sync receive buffers.
+	 * Set up the per-EP contexts:
+	 *          create the EP
+	 *          allocate buffers for remote memory info exchange
+	 *          post the receive buffers
+	 *          connect
+	 *          set up buffers and remote memory info
+	 *          send across our info
+	 *          recv the other side's info and extract what we need
 	 */
-	ep_attr = pt_ptr->ep_attr;
-	if (ep_attr.max_recv_dtos < test_ptr->cmd->num_ops + 2)
-	{
-	    ep_attr.max_recv_dtos = test_ptr->cmd->num_ops + 2;
-	}
-	if (ep_attr.max_request_dtos < test_ptr->cmd->num_ops + 2)
-	{
-	    ep_attr.max_request_dtos = test_ptr->cmd->num_ops + 2;
-	}
+	for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+		DAT_EP_ATTR ep_attr;
+		DAT_UINT32 buff_size = MAX_OPS * sizeof(RemoteMemoryInfo);
 
-	/* Create EP */
-	ret = dat_ep_create (test_ptr->ia_handle,    /* IA       */
-			    test_ptr->pz_handle,    /* PZ       */
-			    test_ptr->recv_evd_hdl, /* recv     */
-			    test_ptr->reqt_evd_hdl, /* request  */
-			    test_ptr->conn_evd_hdl, /* connect  */
-			    &ep_attr,		    /* EP attrs */
-			    &test_ptr->ep_context[i].ep_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ep_create #%d error: %s\n",
-			test_ptr->base_port, i, DT_RetToString (ret));
-	    test_ptr->ep_context[i].ep_handle = DAT_HANDLE_NULL;
-	    goto test_failure;
-	}
+		/* create 4 EVDs - recv, request+RMR, conn-request, connect */
+		ret =
+		    DT_Tdep_evd_create(test_ptr->ia_handle,
+				       test_ptr->evd_length, NULL,
+				       DAT_EVD_DTO_FLAG,
+				       &test_ptr->ep_context[i].recv_evd_hdl);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_create (recv) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			test_ptr->ep_context[i].recv_evd_hdl = DAT_HANDLE_NULL;
+			goto test_failure;
+		}
 
-	/*
-	 * Allocate a buffer pool so we can exchange the
-	 * remote memory info and initialize.
-	 */
-	test_ptr->ep_context[i].bp = DT_BpoolAlloc (pt_ptr,
-						phead,
-						test_ptr->ia_handle,
-						test_ptr->pz_handle,
-					    test_ptr->ep_context[i].ep_handle,
-						DAT_HANDLE_NULL, /* rmr */
-						buff_size,
-						4,
-						DAT_OPTIMAL_ALIGNMENT,
-						false,
-						false);
-	if (!test_ptr->ep_context[i].bp)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for remote memory buffers\n",
-			test_ptr->base_port);
-	    goto test_failure;
-	}
+		ret =
+		    DT_Tdep_evd_create(test_ptr->ia_handle,
+				       test_ptr->evd_length, NULL,
+				       DAT_EVD_DTO_FLAG | DAT_EVD_RMR_BIND_FLAG,
+				       &test_ptr->ep_context[i].reqt_evd_hdl);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_create (request) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			test_ptr->ep_context[i].reqt_evd_hdl = DAT_HANDLE_NULL;
+			goto test_failure;
+		}
 
-	DT_Tdep_PT_Debug (3, (phead,
-		    	  "0: RMI_SEND  %p\n", 
-			  (DAT_PVOID) DT_Bpool_GetBuffer (
-					  test_ptr->ep_context[i].bp, 0)));
-	DT_Tdep_PT_Debug (3, (phead,
-		    	  "1: RMI_RECV  %p\n",
-			  (DAT_PVOID) DT_Bpool_GetBuffer (
-					  test_ptr->ep_context[i].bp, 1)));
-	DT_Tdep_PT_Debug (3, (phead,
-		    	  "2: SYNC_SEND %p\n", 
-			  (DAT_PVOID) DT_Bpool_GetBuffer (
-					  test_ptr->ep_context[i].bp, 2)));
-	DT_Tdep_PT_Debug (3, (phead,
-		    	  "3: SYNC_RECV %p\n", 
-			  (DAT_PVOID) DT_Bpool_GetBuffer (
-					  test_ptr->ep_context[i].bp, 3)));
+		if (pt_ptr->local_is_server) {
+			/* Client-side doesn't need CR events */
+			ret =
+			    DT_Tdep_evd_create(test_ptr->ia_handle,
+					       test_ptr->evd_length, NULL,
+					       DAT_EVD_CR_FLAG,
+					       &test_ptr->ep_context[i].
+					       creq_evd_hdl);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test[" F64x
+						  "]: dat_evd_create (cr) error: %s\n",
+						  test_ptr->base_port,
+						  DT_RetToString(ret));
+				test_ptr->ep_context[i].creq_evd_hdl =
+				    DAT_HANDLE_NULL;
+				goto test_failure;
+			}
+		}
 
-	/*
-	 * Post recv and sync buffers
-	 */
-	if (!DT_post_recv_buffer ( phead,
-		    		    test_ptr->ep_context[i].ep_handle,
-				    test_ptr->ep_context[i].bp,
-				    RMI_RECV_BUFFER_ID,
-				    buff_size))
-	{
-	    /* error message printed by DT_post_recv_buffer */
-	    goto test_failure;
-	}
-	if (!DT_post_recv_buffer ( phead,
-		    		    test_ptr->ep_context[i].ep_handle,
-				    test_ptr->ep_context[i].bp,
-				    SYNC_RECV_BUFFER_ID,
-				    SYNC_BUFF_SIZE))
-	{
-	    /* error message printed by DT_post_recv_buffer */
-	    goto test_failure;
-	}
+		ret =
+		    DT_Tdep_evd_create(test_ptr->ia_handle,
+				       test_ptr->evd_length, NULL,
+				       DAT_EVD_CONNECTION_FLAG,
+				       &test_ptr->ep_context[i].conn_evd_hdl);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_evd_create (conn) error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			test_ptr->ep_context[i].conn_evd_hdl = DAT_HANDLE_NULL;
+			goto test_failure;
+		}
 
-	/*
-	 * Establish the connection
-	 */
-	test_ptr->ep_context[i].ia_port = test_ptr->base_port + i;
-
-	if (pt_ptr->local_is_server)
-	{
-	    if (test_ptr->cmd->use_rsp)
-	    {
 		/*
-		 * Server - create a single-use RSP and
-		 *	    await a connection for this EP
+		 * Adjust default EP attributes to fit the requested test.
+		 * This is simplistic; in that we don't count ops of each
+		 * type and direction, checking EP limits.  We just try to
+		 * be sure the EP's WQs are large enough.  The "+2" is for
+		 * the RemoteMemInfo and Sync receive buffers.
 		 */
-
-		ret = dat_rsp_create (test_ptr->ia_handle,
-				     test_ptr->ep_context[i].ia_port,
-				     test_ptr->ep_context[i].ep_handle,
-				     test_ptr->creq_evd_hdl,
-					&test_ptr->ep_context[i].rsp_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_rsp_create #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    goto test_failure;
+		ep_attr = pt_ptr->ep_attr;
+		if (ep_attr.max_recv_dtos < test_ptr->cmd->num_ops + 2) {
+			ep_attr.max_recv_dtos = test_ptr->cmd->num_ops + 2;
 		}
-	    }
-	    else
-	    {
-		ret = dat_psp_create (test_ptr->ia_handle,
-				      test_ptr->ep_context[i].ia_port,
-				      test_ptr->creq_evd_hdl,
-				      DAT_PSP_CONSUMER_FLAG,
-				      &test_ptr->ep_context[i].psp_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_psp_create #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    goto test_failure;
+		if (ep_attr.max_request_dtos < test_ptr->cmd->num_ops + 2) {
+			ep_attr.max_request_dtos = test_ptr->cmd->num_ops + 2;
 		}
 
-		DT_Tdep_PT_Debug (1,(phead,"Server[" F64x "]: Listen #%d on PSP port 0x" F64x "\n",
-				test_ptr->base_port, i,
-				test_ptr->ep_context[i].ia_port));
-	    }
-	}
-    }
+		/* Create EP */
+		ret = dat_ep_create(test_ptr->ia_handle,	/* IA       */
+				    test_ptr->pz_handle,	/* PZ       */
+				    test_ptr->ep_context[i].recv_evd_hdl,	/* recv     */
+				    test_ptr->ep_context[i].reqt_evd_hdl,	/* request  */
+				    test_ptr->ep_context[i].conn_evd_hdl,	/* connect  */
+				    &ep_attr,	/* EP attrs */
+				    &test_ptr->ep_context[i].ep_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_ep_create #%d error: %s\n",
+					  test_ptr->base_port, i,
+					  DT_RetToString(ret));
+			test_ptr->ep_context[i].ep_handle = DAT_HANDLE_NULL;
+			goto test_failure;
+		}
 
-    /* Here's where we tell the server process that this thread is
-     * ready to wait for connection requests from the remote end.
-     * Modify the synch wait semantics at your own risk - if these
-     * signals and waits aren't here, there will be chronic
-     * connection rejection timing problems.
-     */
-    if (pt_ptr->local_is_server)
-    {
-	DT_Mdep_Lock (&pt_ptr->Thread_counter_lock);
-	pt_ptr->Countdown_Counter--;
-	/* Deliberate pre-decrement.  Post decrement won't
-	 * work here, so don't do it.
-	 */
-	if (pt_ptr->Countdown_Counter <= 0 )
-	{
-	    DT_Mdep_wait_object_wakeup (&pt_ptr->synch_wait_object);
-	}
+		/*
+		 * Allocate a buffer pool so we can exchange the
+		 * remote memory info and initialize.
+		 */
+		test_ptr->ep_context[i].bp = DT_BpoolAlloc(pt_ptr, phead, test_ptr->ia_handle, test_ptr->pz_handle, test_ptr->ep_context[i].ep_handle, DAT_HANDLE_NULL,	/* rmr */
+							   buff_size,
+							   4,
+							   DAT_OPTIMAL_ALIGNMENT,
+							   false, false);
+		if (!test_ptr->ep_context[i].bp) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: no memory for remote memory buffers\n",
+					  test_ptr->base_port);
+			goto test_failure;
+		}
 
-	DT_Mdep_Unlock (&pt_ptr->Thread_counter_lock);
-    }
+		DT_Tdep_PT_Debug(3, (phead,
+				     "0: RMI_SEND  %p\n",
+				     (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+								    ep_context
+								    [i].bp,
+								    0)));
+		DT_Tdep_PT_Debug(3,
+				 (phead, "1: RMI_RECV  %p\n",
+				  (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+								 ep_context[i].
+								 bp, 1)));
+		DT_Tdep_PT_Debug(3,
+				 (phead, "2: SYNC_SEND %p\n",
+				  (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+								 ep_context[i].
+								 bp, 2)));
+		DT_Tdep_PT_Debug(3,
+				 (phead, "3: SYNC_RECV %p\n",
+				  (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+								 ep_context[i].
+								 bp, 3)));
 
-    for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-    {
-	DAT_UINT32          buff_size  =  MAX_OPS * sizeof (RemoteMemoryInfo);
-	RemoteMemoryInfo    *RemoteMemInfo;
-	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-	DAT_CR_ARRIVAL_EVENT_DATA   cr_stat;
-	DAT_CR_HANDLE               cr_handle;
+		/*
+		 * Post recv and sync buffers
+		 */
+		if (!DT_post_recv_buffer(phead,
+					 test_ptr->ep_context[i].ep_handle,
+					 test_ptr->ep_context[i].bp,
+					 RMI_RECV_BUFFER_ID, buff_size)) {
+			/* error message printed by DT_post_recv_buffer */
+			goto test_failure;
+		}
+		if (!DT_post_recv_buffer(phead,
+					 test_ptr->ep_context[i].ep_handle,
+					 test_ptr->ep_context[i].bp,
+					 SYNC_RECV_BUFFER_ID, SYNC_BUFF_SIZE)) {
+			/* error message printed by DT_post_recv_buffer */
+			goto test_failure;
+		}
 
-	/*
-	 * Establish the connection
-	 */
+		/*
+		 * Establish the connection
+		 */
+		test_ptr->ep_context[i].ia_port = test_ptr->base_port + i;
 
-	if (pt_ptr->local_is_server)
-	{
-	    DAT_CR_PARAM   		    cr_param;
+		if (pt_ptr->local_is_server) {
+			if (test_ptr->cmd->use_rsp) {
+				/*
+				 * Server - create a single-use RSP and
+				 *          await a connection for this EP
+				 */
 
-	    if (test_ptr->cmd->use_rsp)
-	    {
+				ret = dat_rsp_create(test_ptr->ia_handle,
+						     test_ptr->ep_context[i].
+						     ia_port,
+						     test_ptr->ep_context[i].
+						     ep_handle,
+						     test_ptr->ep_context[i].
+						     creq_evd_hdl,
+						     &test_ptr->ep_context[i].
+						     rsp_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_rsp_create #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					goto test_failure;
+				}
+			} else {
+				ret = dat_psp_create(test_ptr->ia_handle,
+						     test_ptr->ep_context[i].
+						     ia_port,
+						     test_ptr->ep_context[i].
+						     creq_evd_hdl,
+						     DAT_PSP_CONSUMER_FLAG,
+						     &test_ptr->ep_context[i].
+						     psp_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_psp_create #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					goto test_failure;
+				}
 
-		/* wait for the connection request */
-		if (!DT_cr_event_wait (phead,
-			    	       test_ptr->creq_evd_hdl, 
-				       &cr_stat) ||
-		    !DT_cr_check ( phead,
-				   &cr_stat,
-				   test_ptr->ep_context[i].rsp_handle,
-				    test_ptr->ep_context[i].ia_port,
-				    &cr_handle,
-				    "Server") )
-		{
-		    goto test_failure;
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Server[" F64x
+						  "]: Listen #%d on PSP port 0x"
+						  F64x "\n",
+						  test_ptr->base_port, i,
+						  test_ptr->ep_context[i].
+						  ia_port));
+			}
 		}
+	}
 
-		ret = dat_cr_query (cr_handle,
-				    DAT_CR_FIELD_ALL,
-				    &cr_param);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_cr_query #%d error:(%x) %s\n",
-				test_ptr->base_port, i, ret, DT_RetToString (ret));
+	/* Here's where we tell the server process that this thread is
+	 * ready to wait for connection requests from the remote end.
+	 * Modify the synch wait semantics at your own risk - if these
+	 * signals and waits aren't here, there will be chronic
+	 * connection rejection timing problems.
+	 */
+	if (pt_ptr->local_is_server) {
+		DT_Mdep_Lock(&pt_ptr->Thread_counter_lock);
+		pt_ptr->Countdown_Counter--;
+		/* Deliberate pre-decrement.  Post decrement won't
+		 * work here, so don't do it.
+		 */
+		if (pt_ptr->Countdown_Counter <= 0) {
+			DT_Mdep_wait_object_wakeup(&pt_ptr->synch_wait_object);
 		}
-		else
-		{
-		    if ( strncmp ((char *)cr_param.private_data,
-				  private_data_str,
-				  strlen(private_data_str) ) != 0 )
-		    {
-			DT_Tdep_PT_Printf (phead, "--Private Data mismatch!\n");
-		    }
-		    else
-		    {
-			DT_Tdep_PT_Debug (1, (phead,"--Private Data: %d: <%s>\n",
-				cr_param.private_data_size,
-				(char *)cr_param.private_data) );
-		    }
-		}
 
-		/* what, me query?  just try to accept the connection */
-		ret = dat_cr_accept (cr_handle,
-				     0, /* NULL for RSP */
-				     0, (DAT_PVOID)0 /* no private data */ );
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_cr_accept #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    /* cr_handle consumed on failure */
-		    goto test_failure;
-		}
+		DT_Mdep_Unlock(&pt_ptr->Thread_counter_lock);
+	}
 
-		/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
-		if (!DT_conn_event_wait (  phead,
-			    		   test_ptr->ep_context[i].ep_handle,
-					   test_ptr->conn_evd_hdl,
-					   &event_num))
-		{
-		    /* error message printed by DT_conn_event_wait */
-		    goto test_failure;
-		}
-		/* throw away single-use PSP */
-		ret = dat_rsp_free (test_ptr->ep_context[i].rsp_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_rsp_free #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    goto test_failure;
-		}
+	for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+		DAT_UINT32 buff_size = MAX_OPS * sizeof(RemoteMemoryInfo);
+		RemoteMemoryInfo *RemoteMemInfo;
+		DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+		DAT_CR_ARRIVAL_EVENT_DATA cr_stat;
+		DAT_CR_HANDLE cr_handle;
 
-	    }
-	    else
-	    {
 		/*
-		 * Server - use a short-lived PSP instead of an RSP
+		 * Establish the connection
 		 */
-		/* wait for a connection request */
-		if (!DT_cr_event_wait (phead,
-			    	       test_ptr->creq_evd_hdl,
-				       &cr_stat) )
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_psp_create #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    goto test_failure;
-		}
 
-		if (  !DT_cr_check ( phead,
-			    	   &cr_stat,
-				     test_ptr->ep_context[i].psp_handle,
-				     test_ptr->ep_context[i].ia_port,
-				     &cr_handle,
-				     "Server") )
-		{
-		    goto test_failure;
-		}
+		if (pt_ptr->local_is_server) {
+			DAT_CR_PARAM cr_param;
 
-		ret = dat_cr_query (cr_handle,
-				    DAT_CR_FIELD_ALL,
-				    &cr_param);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_cr_query #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		}
-		else
-		{
-		    if ( strncmp ((char *)cr_param.private_data,
-				  private_data_str,
-				  strlen(private_data_str) ) != 0 )
-		    {
-			DT_Tdep_PT_Printf (phead, "--Private Data mismatch!\n");
-		    }
-		    else
-		    {
-			DT_Tdep_PT_Debug (1, (phead,"--Private Data: %d: <%s>\n",
-				cr_param.private_data_size,
-				(char *)cr_param.private_data) );
-		    }
-		}
+			if (test_ptr->cmd->use_rsp) {
 
+				/* wait for the connection request */
+				if (!DT_cr_event_wait(phead,
+						      test_ptr->ep_context[i].
+						      creq_evd_hdl, &cr_stat)
+				    || !DT_cr_check(phead, &cr_stat,
+						    test_ptr->ep_context[i].
+						    rsp_handle,
+						    test_ptr->ep_context[i].
+						    ia_port, &cr_handle,
+						    "Server")) {
+					goto test_failure;
+				}
 
-		/* what, me query?  just try to accept the connection */
-		ret = dat_cr_accept (cr_handle,
-				    test_ptr->ep_context[i].ep_handle,
-				    0, (DAT_PVOID)0 /* no private data */ );
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_cr_accept #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    /* cr_handle consumed on failure */
-		    (void) dat_psp_free (test_ptr->ep_context[i].psp_handle);
-		    goto test_failure;
-		}
+				ret = dat_cr_query(cr_handle,
+						   DAT_CR_FIELD_ALL, &cr_param);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_cr_query #%d error:(%x) %s\n",
+							  test_ptr->base_port,
+							  i, ret,
+							  DT_RetToString(ret));
+				} else {
+					if (strncmp
+					    ((char *)cr_param.private_data,
+					     private_data_str,
+					     strlen(private_data_str)) != 0) {
+						DT_Tdep_PT_Printf(phead,
+								  "--Private Data mismatch!\n");
+					} else {
+						DT_Tdep_PT_Debug(1,
+								 (phead,
+								  "--Private Data: %d: <%s>\n",
+								  cr_param.
+								  private_data_size,
+								  (char *)
+								  cr_param.
+								  private_data));
+					}
+				}
 
-		/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
-		if (!DT_conn_event_wait (  phead,
-			    		    test_ptr->ep_context[i].ep_handle,
-					    test_ptr->conn_evd_hdl,
-					   &event_num))
-		{
-		    /* error message printed by DT_cr_event_wait */
-		    (void) dat_psp_free (&test_ptr->ep_context[i].psp_handle);
-		    goto test_failure;
-		}
+				/* what, me query?  just try to accept the connection */
+				ret = dat_cr_accept(cr_handle, 0,	/* NULL for RSP */
+						    0,
+						    (DAT_PVOID) 0
+						    /* no private data */ );
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_cr_accept #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					/* cr_handle consumed on failure */
+					goto test_failure;
+				}
 
-		/* throw away single-use PSP */
-		ret = dat_psp_free (test_ptr->ep_context[i].psp_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_psp_free #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    goto test_failure;
-		}
-	    }	/* end short-lived PSP */
+				/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
+				if (!DT_conn_event_wait(phead,
+							test_ptr->ep_context[i].
+							ep_handle,
+							test_ptr->ep_context[i].
+							conn_evd_hdl,
+							&event_num)) {
+					/* error message printed by DT_conn_event_wait */
+					goto test_failure;
+				}
+				/* throw away single-use PSP */
+				ret =
+				    dat_rsp_free(test_ptr->ep_context[i].
+						 rsp_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_rsp_free #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					goto test_failure;
+				}
 
-	    DT_Tdep_PT_Debug (1,(phead,"Server[" F64x "]: Accept #%d on port 0x" F64x "\n",
-			    test_ptr->base_port, i,
-			    test_ptr->ep_context[i].ia_port));
-	}
-	else
-	{
-	    /*
-	     * Client - connect
-	     */
-	    unsigned int retry_cnt = 0;
-	    DAT_UINT32      buff_size  =  MAX_OPS * sizeof (RemoteMemoryInfo);
+			} else {
+				/*
+				 * Server - use a short-lived PSP instead of an RSP
+				 */
+				/* wait for a connection request */
+				if (!DT_cr_event_wait(phead,
+						      test_ptr->ep_context[i].
+						      creq_evd_hdl, &cr_stat)) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_psp_create #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					goto test_failure;
+				}
+				if (!DT_cr_check(phead,
+						 &cr_stat,
+						 test_ptr->ep_context[i].
+						 psp_handle,
+						 test_ptr->ep_context[i].
+						 ia_port, &cr_handle,
+						 "Server")) {
+					goto test_failure;
+				}
 
-	    DT_Tdep_PT_Debug (1,(phead,"Client[" F64x "]: Connect #%d on port 0x" F64x "\n",
-			    test_ptr->base_port, i,
-			    test_ptr->ep_context[i].ia_port));
+				ret = dat_cr_query(cr_handle,
+						   DAT_CR_FIELD_ALL, &cr_param);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_cr_query #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+				} else {
+					if (strncmp
+					    ((char *)cr_param.private_data,
+					     private_data_str,
+					     strlen(private_data_str)) != 0) {
+						DT_Tdep_PT_Printf(phead,
+								  "--Private Data mismatch!\n");
+					} else {
+						DT_Tdep_PT_Debug(1,
+								 (phead,
+								  "--Private Data: %d: <%s>\n",
+								  cr_param.
+								  private_data_size,
+								  (char *)
+								  cr_param.
+								  private_data));
+					}
+				}
 
+				/* what, me query?  just try to accept the connection */
+				ret = dat_cr_accept(cr_handle,
+						    test_ptr->ep_context[i].
+						    ep_handle, 0,
+						    (DAT_PVOID) 0
+						    /* no private data */ );
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_cr_accept #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					/* cr_handle consumed on failure */
+					(void)dat_psp_free(test_ptr->
+							   ep_context[i].
+							   psp_handle);
+					goto test_failure;
+				}
+
+				/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
+				if (!DT_conn_event_wait(phead,
+							test_ptr->ep_context[i].
+							ep_handle,
+							test_ptr->ep_context[i].
+							conn_evd_hdl,
+							&event_num)) {
+					/* error message printed by DT_cr_event_wait */
+					(void)dat_psp_free(&test_ptr->
+							   ep_context[i].
+							   psp_handle);
+					goto test_failure;
+				}
+
+				/* throw away single-use PSP */
+				ret =
+				    dat_psp_free(test_ptr->ep_context[i].
+						 psp_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_psp_free #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					goto test_failure;
+				}
+			}	/* end short-lived PSP */
+
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "Server[" F64x
+					  "]: Accept #%d on port 0x" F64x "\n",
+					  test_ptr->base_port, i,
+					  test_ptr->ep_context[i].ia_port));
+		} else {
+			/*
+			 * Client - connect
+			 */
+			unsigned int retry_cnt = 0;
+			DAT_UINT32 buff_size =
+			    MAX_OPS * sizeof(RemoteMemoryInfo);
+
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "Client[" F64x
+					  "]: Connect #%d on port 0x" F64x "\n",
+					  test_ptr->base_port, i,
+					  test_ptr->ep_context[i].ia_port));
+
 #ifdef CM_BUSTED
 	    /*****  XXX Chill out a bit to give the kludged CM a chance ...
-	     *****/DT_Mdep_Sleep (5000);
+	     *****/ DT_Mdep_Sleep(5000);
 #endif
 
-retry:
-	    ret = dat_ep_connect (test_ptr->ep_context[i].ep_handle,
-				 test_ptr->remote_ia_addr,
-				 test_ptr->ep_context[i].ia_port,
-				 DAT_TIMEOUT_INFINITE,
-				  strlen (private_data_str), private_data_str,
-				 pt_ptr->Params.ReliabilityLevel,
-				 DAT_CONNECT_DEFAULT_FLAG);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ep_connect #%d error: %s (0x%x)\n",
-			    test_ptr->base_port, i, DT_RetToString (ret), ret);
-		goto test_failure;
-	    }
+		      retry:
+			ret = dat_ep_connect(test_ptr->ep_context[i].ep_handle,
+					     test_ptr->remote_ia_addr,
+					     test_ptr->ep_context[i].ia_port,
+					     DAT_TIMEOUT_INFINITE,
+					     strlen(private_data_str),
+					     private_data_str,
+					     pt_ptr->Params.ReliabilityLevel,
+					     DAT_CONNECT_DEFAULT_FLAG);
+			if (ret != DAT_SUCCESS) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test[" F64x
+						  "]: dat_ep_connect #%d error: %s (0x%x)\n",
+						  test_ptr->base_port, i,
+						  DT_RetToString(ret), ret);
+				goto test_failure;
+			}
 
-	    /* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
-	    if (!DT_conn_event_wait (  phead,
-				       test_ptr->ep_context[i].ep_handle,
-				       test_ptr->conn_evd_hdl,
-				       &event_num))
-	    {
-		/* error message printed by DT_cr_event_wait */
-		if ( event_num == DAT_CONNECTION_EVENT_PEER_REJECTED )
-		{
-		    DT_Mdep_Sleep (1000);
-		    /*
-		     * See if any buffers were flushed as a result of
-		     * the REJECT; clean them up and repost if so
-		     */
-		    {
-			DAT_EVENT       event;
-			DAT_COUNT	drained = 0;
+			/* wait for DAT_CONNECTION_EVENT_ESTABLISHED */
+			if (!DT_conn_event_wait(phead,
+						test_ptr->ep_context[i].
+						ep_handle,
+						test_ptr->ep_context[i].
+						conn_evd_hdl, &event_num)) {
+				/* error message printed by DT_cr_event_wait */
+				if (event_num ==
+				    DAT_CONNECTION_EVENT_PEER_REJECTED) {
+					DT_Mdep_Sleep(1000);
+					/*
+					 * See if any buffers were flushed as a result of
+					 * the REJECT; clean them up and repost if so
+					 */
+					{
+						DAT_EVENT event;
+						DAT_COUNT drained = 0;
 
-			dat_ep_reset (test_ptr->ep_context[i].ep_handle);
-			do
-			{
-			    ret = DT_Tdep_evd_dequeue ( test_ptr->recv_evd_hdl,
-						    &event);
-			    drained++;
-			} while (DAT_GET_TYPE(ret) != DAT_QUEUE_EMPTY);
+						dat_ep_reset(test_ptr->
+							     ep_context[i].
+							     ep_handle);
+						do {
+							ret =
+							    DT_Tdep_evd_dequeue
+							    (test_ptr->
+							     ep_context[i].
+							     recv_evd_hdl,
+							     &event);
+							drained++;
+						} while (DAT_GET_TYPE(ret) !=
+							 DAT_QUEUE_EMPTY);
 
-			if (drained > 1)
-			{
-			    /*
-			     * Post recv and sync buffers
-			     */
-			    if (!DT_post_recv_buffer ( phead,
-							test_ptr->ep_context[i].ep_handle,
-						       test_ptr->ep_context[i].bp,
-						       RMI_RECV_BUFFER_ID,
-						       buff_size))
-			    {
-				/* error message printed by DT_post_recv_buffer */
+						if (drained > 1) {
+							/*
+							 * Post recv and sync buffers
+							 */
+							if (!DT_post_recv_buffer
+							    (phead,
+							     test_ptr->
+							     ep_context[i].
+							     ep_handle,
+							     test_ptr->
+							     ep_context[i].bp,
+							     RMI_RECV_BUFFER_ID,
+							     buff_size)) {
+								/* error message printed by DT_post_recv_buffer */
+								goto test_failure;
+							}
+							if (!DT_post_recv_buffer
+							    (phead,
+							     test_ptr->
+							     ep_context[i].
+							     ep_handle,
+							     test_ptr->
+							     ep_context[i].bp,
+							     SYNC_RECV_BUFFER_ID,
+							     SYNC_BUFF_SIZE)) {
+								/* error message printed by DT_post_recv_buffer */
+								goto test_failure;
+							}
+						}
+					}
+					DT_Tdep_PT_Printf(phead,
+							  "Client[" F64x
+							  "]: retrying connection...\n",
+							  test_ptr->base_port);
+					retry_cnt++;
+					if (retry_cnt < MAX_CONN_RETRY) {
+						goto retry;
+					}
+				}
+				/* error message printed by DT_cr_event_wait */
 				goto test_failure;
-			    }
-			    if (!DT_post_recv_buffer ( phead,
-							test_ptr->ep_context[i].ep_handle,
-						       test_ptr->ep_context[i].bp,
-						       SYNC_RECV_BUFFER_ID,
-						       SYNC_BUFF_SIZE))
-			    {
-				/* error message printed by DT_post_recv_buffer */
-				goto test_failure;
-			    }
 			}
-		    }
-		    DT_Tdep_PT_Printf (phead, "Client[" F64x "]: retrying connection...\n",
-				    test_ptr->base_port);
-		    retry_cnt++;
-		    if (retry_cnt < MAX_CONN_RETRY)
-		    {
-			goto retry;
-		    }
+
+			DT_Tdep_PT_Debug(1,
+					 (phead,
+					  "Client[" F64x
+					  "]: Got Connection #%d\n",
+					  test_ptr->base_port, i));
 		}
-		/* error message printed by DT_cr_event_wait */
-		goto test_failure;
-	    }
 
-	    DT_Tdep_PT_Debug (1,(phead,"Client[" F64x "]: Got Connection #%d\n",
-			    test_ptr->base_port, i));
-	}
-
 #ifdef CM_BUSTED
 	/*****  XXX Chill out a bit to give the kludged CM a chance ...
-	 *****/DT_Mdep_Sleep (5000);
+	 *****/ DT_Mdep_Sleep(5000);
 #endif
 
-	/*
-	 * Fill in the test_ptr with relevant command info
-	 */
-	for (j = 0;  j < test_ptr->cmd->num_ops;  j++)
-	{
-	    test_ptr->ep_context[i].op[j].server_initiated
-		   = test_ptr->cmd->op[j].server_initiated;
-	    test_ptr->ep_context[i].op[j].transfer_type
-		   = test_ptr->cmd->op[j].transfer_type;
-	    test_ptr->ep_context[i].op[j].num_segs
-		   = test_ptr->cmd->op[j].num_segs;
-	    test_ptr->ep_context[i].op[j].seg_size
-		   = test_ptr->cmd->op[j].seg_size;
-	    test_ptr->ep_context[i].op[j].reap_send_on_recv
-		   = test_ptr->cmd->op[j].reap_send_on_recv;
-	}
+		/*
+		 * Fill in the test_ptr with relevant command info
+		 */
+		for (j = 0; j < test_ptr->cmd->num_ops; j++) {
+			test_ptr->ep_context[i].op[j].server_initiated
+			    = test_ptr->cmd->op[j].server_initiated;
+			test_ptr->ep_context[i].op[j].transfer_type
+			    = test_ptr->cmd->op[j].transfer_type;
+			test_ptr->ep_context[i].op[j].num_segs
+			    = test_ptr->cmd->op[j].num_segs;
+			test_ptr->ep_context[i].op[j].seg_size
+			    = test_ptr->cmd->op[j].seg_size;
+			test_ptr->ep_context[i].op[j].reap_send_on_recv
+			    = test_ptr->cmd->op[j].reap_send_on_recv;
+		}
 
-	/*
-	 * Exchange remote memory info:  If we're going to participate
-	 * in an RDMA, we need to allocate memory buffers and advertise
-	 * them to the other side.
-	 */
-	for (j = 0;  j < test_ptr->cmd->num_ops;  j++)
-	{
-	    DAT_BOOLEAN     us;
+		/*
+		 * Exchange remote memory info:  If we're going to participate
+		 * in an RDMA, we need to allocate memory buffers and advertise
+		 * them to the other side.
+		 */
+		for (j = 0; j < test_ptr->cmd->num_ops; j++) {
+			DAT_BOOLEAN us;
 
-	    us = (pt_ptr->local_is_server &&
-		  test_ptr->ep_context[i].op[j].server_initiated) ||
-		(!pt_ptr->local_is_server &&
-		 !test_ptr->ep_context[i].op[j].server_initiated);
+			us = (pt_ptr->local_is_server &&
+			      test_ptr->ep_context[i].op[j].server_initiated) ||
+			    (!pt_ptr->local_is_server &&
+			     !test_ptr->ep_context[i].op[j].server_initiated);
 
-	    test_ptr->ep_context[i].op[j].Rdma_Context = (DAT_RMR_CONTEXT) 0;
-	    test_ptr->ep_context[i].op[j].Rdma_Address = 0;
+			test_ptr->ep_context[i].op[j].Rdma_Context =
+			    (DAT_RMR_CONTEXT) 0;
+			test_ptr->ep_context[i].op[j].Rdma_Address = 0;
 
-	    switch (test_ptr->ep_context[i].op[j].transfer_type)
-	    {
-		case RDMA_READ:
-		{
-		    test_ptr->ep_context[i].op[j].bp =
-			DT_BpoolAlloc (pt_ptr,
-				   phead,
-				   test_ptr->ia_handle,
-				   test_ptr->pz_handle,
-				   test_ptr->ep_context[i].ep_handle,
-				   test_ptr->reqt_evd_hdl,
-				   test_ptr->ep_context[i].op[j].seg_size,
-				   test_ptr->ep_context[i].op[j].num_segs,
-				   DAT_OPTIMAL_ALIGNMENT,
-				   false,
-				   !us ? true : false);
-		    if (!test_ptr->ep_context[i].op[j].bp)
-		    {
-			DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for buffers (RDMA/RD)\n",
-				test_ptr->base_port);
-			goto test_failure;
-		    }
-		    if (!us)
-		    {
-			test_ptr->ep_context[i].op[j].Rdma_Context =
-			    DT_Bpool_GetRMR (test_ptr->ep_context[i].op[j].bp, 0);
-			test_ptr->ep_context[i].op[j].Rdma_Address =
-			    (DAT_VADDR) (uintptr_t)
-			    DT_Bpool_GetBuffer (test_ptr->ep_context[i].op[j].bp,
-					    0);
-			DT_Tdep_PT_Debug (3, (phead,
-			        "not-us: RDMA/RD [ va=" F64x ", ctxt=%x ]\n",
-				test_ptr->ep_context[i].op[j].Rdma_Address,
-				test_ptr->ep_context[i].op[j].Rdma_Context));
-		    }
-		    break;
+			switch (test_ptr->ep_context[i].op[j].transfer_type) {
+			case RDMA_READ:
+				{
+					test_ptr->ep_context[i].op[j].bp =
+					    DT_BpoolAlloc(pt_ptr,
+							  phead,
+							  test_ptr->ia_handle,
+							  test_ptr->pz_handle,
+							  test_ptr->
+							  ep_context[i].
+							  ep_handle,
+							  test_ptr->
+							  ep_context[i].
+							  reqt_evd_hdl,
+							  test_ptr->
+							  ep_context[i].op[j].
+							  seg_size,
+							  test_ptr->
+							  ep_context[i].op[j].
+							  num_segs,
+							  DAT_OPTIMAL_ALIGNMENT,
+							  false,
+							  !us ? true : false);
+					if (!test_ptr->ep_context[i].op[j].bp) {
+						DT_Tdep_PT_Printf(phead,
+								  "Test[" F64x
+								  "]: no memory for buffers (RDMA/RD)\n",
+								  test_ptr->
+								  base_port);
+						goto test_failure;
+					}
+					if (!us) {
+						test_ptr->ep_context[i].op[j].
+						    Rdma_Context =
+						    DT_Bpool_GetRMR(test_ptr->
+								    ep_context
+								    [i].op[j].
+								    bp, 0);
+						test_ptr->ep_context[i].op[j].
+						    Rdma_Address =
+						    (DAT_VADDR) (uintptr_t)
+						    DT_Bpool_GetBuffer
+						    (test_ptr->ep_context[i].
+						     op[j].bp, 0);
+						DT_Tdep_PT_Debug(3,
+								 (phead,
+								  "not-us: RDMA/RD [ va="
+								  F64x
+								  ", ctxt=%x ]\n",
+								  test_ptr->
+								  ep_context[i].
+								  op[j].
+								  Rdma_Address,
+								  test_ptr->
+								  ep_context[i].
+								  op[j].
+								  Rdma_Context));
+					}
+					break;
+				}
+
+			case RDMA_WRITE:
+				{
+					test_ptr->ep_context[i].op[j].bp =
+					    DT_BpoolAlloc(pt_ptr,
+							  phead,
+							  test_ptr->ia_handle,
+							  test_ptr->pz_handle,
+							  test_ptr->
+							  ep_context[i].
+							  ep_handle,
+							  test_ptr->
+							  ep_context[i].
+							  reqt_evd_hdl,
+							  test_ptr->
+							  ep_context[i].op[j].
+							  seg_size,
+							  test_ptr->
+							  ep_context[i].op[j].
+							  num_segs,
+							  DAT_OPTIMAL_ALIGNMENT,
+							  !us ? true : false,
+							  false);
+					if (!test_ptr->ep_context[i].op[j].bp) {
+						DT_Tdep_PT_Printf(phead,
+								  "Test[" F64x
+								  "]: no memory for buffers (RDMA/WR)\n",
+								  test_ptr->
+								  base_port);
+						goto test_failure;
+					}
+					if (!us) {
+						test_ptr->ep_context[i].op[j].
+						    Rdma_Context =
+						    DT_Bpool_GetRMR(test_ptr->
+								    ep_context
+								    [i].op[j].
+								    bp, 0);
+						test_ptr->ep_context[i].op[j].
+						    Rdma_Address =
+						    (DAT_VADDR) (uintptr_t)
+						    DT_Bpool_GetBuffer
+						    (test_ptr->ep_context[i].
+						     op[j].bp, 0);
+						DT_Tdep_PT_Debug(3,
+								 (phead,
+								  "not-us: RDMA/WR [ va="
+								  F64x
+								  ", ctxt=%x ]\n",
+								  test_ptr->
+								  ep_context[i].
+								  op[j].
+								  Rdma_Address,
+								  test_ptr->
+								  ep_context[i].
+								  op[j].
+								  Rdma_Context));
+					}
+					break;
+				}
+
+			case SEND_RECV:
+				{
+					test_ptr->ep_context[i].op[j].bp = DT_BpoolAlloc(pt_ptr, phead, test_ptr->ia_handle, test_ptr->pz_handle, test_ptr->ep_context[i].ep_handle, DAT_HANDLE_NULL,	/* rmr */
+											 test_ptr->
+											 ep_context
+											 [i].
+											 op
+											 [j].
+											 seg_size,
+											 test_ptr->
+											 ep_context
+											 [i].
+											 op
+											 [j].
+											 num_segs,
+											 DAT_OPTIMAL_ALIGNMENT,
+											 false,
+											 false);
+					if (!test_ptr->ep_context[i].op[j].bp) {
+						DT_Tdep_PT_Printf(phead,
+								  "Test[" F64x
+								  "]: no memory for buffers (S/R)\n",
+								  test_ptr->
+								  base_port);
+						goto test_failure;
+					}
+
+					DT_Tdep_PT_Debug(3, (phead,
+							     "%d: S/R [ va=%p ]\n",
+							     j, (DAT_PVOID)
+							     DT_Bpool_GetBuffer
+							     (test_ptr->
+							      ep_context[i].
+							      op[j].bp, 0)));
+					break;
+				}
+			}
+		}		/* end foreach op */
+
+		/*
+		 * Prep send buffer with memory information
+		 */
+		RemoteMemInfo = (RemoteMemoryInfo *)
+		    DT_Bpool_GetBuffer(test_ptr->ep_context[i].bp,
+				       RMI_SEND_BUFFER_ID);
+
+		for (j = 0; j < test_ptr->cmd->num_ops; j++) {
+			RemoteMemInfo[j].rmr_context =
+			    test_ptr->ep_context[i].op[j].Rdma_Context;
+			RemoteMemInfo[j].mem_address.as_64 =
+			    test_ptr->ep_context[i].op[j].Rdma_Address;
+			if (RemoteMemInfo[j].mem_address.as_64) {
+				DT_Tdep_PT_Debug(3, (phead,
+						     "RemoteMemInfo[%d] va="
+						     F64x ", ctx=%x\n", j,
+						     RemoteMemInfo[j].
+						     mem_address.as_64,
+						     RemoteMemInfo[j].
+						     rmr_context));
+			}
+			/*
+			 * If the client and server are of different endiannesses,
+			 * we must correct the endianness of the handle and address
+			 * we pass to the other side.  The other side cannot (and
+			 * better not) interpret these values.
+			 */
+			if (DT_local_is_little_endian !=
+			    test_ptr->remote_is_little_endian) {
+				RemoteMemInfo[j].rmr_context =
+				    DT_EndianMemHandle(RemoteMemInfo[j].
+						       rmr_context);
+				RemoteMemInfo[j].mem_address.as_64 =
+				    DT_EndianMemAddress(RemoteMemInfo[j].
+							mem_address.as_64);
+			}
+		}		/* end foreach op */
+
+		/*
+		 * Send our memory info. The client performs the first send to comply
+		 * with the iWARP MPA protocol's "Connection Startup Rules".
+		 */
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Test[" F64x "]: Sending %s Memory Info\n",
+				  test_ptr->base_port,
+				  test_ptr->is_server ? "Server" : "Client"));
+
+		if (!test_ptr->is_server) {
+
+			/* post the send buffer */
+			if (!DT_post_send_buffer(phead,
+						 test_ptr->ep_context[i].
+						 ep_handle,
+						 test_ptr->ep_context[i].bp,
+						 RMI_SEND_BUFFER_ID,
+						 buff_size)) {
+				/* error message printed by DT_post_send_buffer */
+				goto test_failure;
+			}
+			/* reap the send and verify it */
+			dto_cookie.as_64 = LZERO;
+			dto_cookie.as_ptr =
+			    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+							   ep_context[i].bp,
+							   RMI_SEND_BUFFER_ID);
+			if (!DT_dto_event_wait
+			    (phead, test_ptr->ep_context[i].reqt_evd_hdl,
+			     &dto_stat)
+			    || !DT_dto_check(phead, &dto_stat,
+					     test_ptr->ep_context[i].ep_handle,
+					     buff_size, dto_cookie,
+					     test_ptr->
+					     is_server ? "Client_Mem_Info_Send"
+					     : "Server_Mem_Info_Send")) {
+				goto test_failure;
+			}
 		}
 
-		case RDMA_WRITE:
-		{
-		    test_ptr->ep_context[i].op[j].bp =
-			DT_BpoolAlloc (pt_ptr,
-				   phead,
-				   test_ptr->ia_handle,
-				   test_ptr->pz_handle,
-				   test_ptr->ep_context[i].ep_handle,
-				   test_ptr->reqt_evd_hdl,
-				   test_ptr->ep_context[i].op[j].seg_size,
-				   test_ptr->ep_context[i].op[j].num_segs,
-				   DAT_OPTIMAL_ALIGNMENT,
-				   !us ? true : false,
-				   false);
-		    if (!test_ptr->ep_context[i].op[j].bp)
-		    {
-			DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for buffers (RDMA/WR)\n",
-				test_ptr->base_port);
+		/*
+		 * Recv the other side's info
+		 */
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Test[" F64x
+				  "]: Waiting for %s Memory Info\n",
+				  test_ptr->base_port,
+				  test_ptr->is_server ? "Client" : "Server"));
+		dto_cookie.as_64 = LZERO;
+		dto_cookie.as_ptr =
+		    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->ep_context[i].bp,
+						   RMI_RECV_BUFFER_ID);
+		if (!DT_dto_event_wait
+		    (phead, test_ptr->ep_context[i].recv_evd_hdl, &dto_stat)
+		    || !DT_dto_check(phead, &dto_stat,
+				     test_ptr->ep_context[i].ep_handle,
+				     buff_size, dto_cookie,
+				     test_ptr->
+				     is_server ? "Client_Mem_Info_Recv" :
+				     "Server_Mem_Info_Recv")) {
 			goto test_failure;
-		    }
-		    if (!us)
-		    {
-			test_ptr->ep_context[i].op[j].Rdma_Context =
-			    DT_Bpool_GetRMR (test_ptr->ep_context[i].op[j].bp, 0);
-			test_ptr->ep_context[i].op[j].Rdma_Address =
-			    (DAT_VADDR) (uintptr_t)
-			    DT_Bpool_GetBuffer (test_ptr->ep_context[i].op[j].bp,
-					    0);
-			DT_Tdep_PT_Debug (3, (phead, 
-			        "not-us: RDMA/WR [ va=" F64x ", ctxt=%x ]\n",
-				test_ptr->ep_context[i].op[j].Rdma_Address,
-				test_ptr->ep_context[i].op[j].Rdma_Context));
-		    }
-		    break;
 		}
 
-		case SEND_RECV:
-		{
-		    test_ptr->ep_context[i].op[j].bp =
-			DT_BpoolAlloc (pt_ptr,
-				   phead,
-				   test_ptr->ia_handle,
-				   test_ptr->pz_handle,
-				   test_ptr->ep_context[i].ep_handle,
-				   DAT_HANDLE_NULL, /* rmr */
-				   test_ptr->ep_context[i].op[j].seg_size,
-				   test_ptr->ep_context[i].op[j].num_segs,
-				   DAT_OPTIMAL_ALIGNMENT,
-				   false,
-				   false);
-		    if (!test_ptr->ep_context[i].op[j].bp)
-		    {
-			DT_Tdep_PT_Printf (phead, "Test[" F64x "]: no memory for buffers (S/R)\n",
-				test_ptr->base_port);
-			goto test_failure;
-		    }
-
-		    DT_Tdep_PT_Debug (3, (phead,
-			"%d: S/R [ va=%p ]\n", j, (DAT_PVOID)
-			DT_Bpool_GetBuffer ( test_ptr->ep_context[i].op[j].bp, 0)));
-		    break;
+		if (test_ptr->is_server) {
+			/* post the send buffer */
+			if (!DT_post_send_buffer(phead,
+						 test_ptr->ep_context[i].
+						 ep_handle,
+						 test_ptr->ep_context[i].bp,
+						 RMI_SEND_BUFFER_ID,
+						 buff_size)) {
+				/* error message printed by DT_post_send_buffer */
+				goto test_failure;
+			}
+			/* reap the send and verify it */
+			dto_cookie.as_64 = LZERO;
+			dto_cookie.as_ptr =
+			    (DAT_PVOID) DT_Bpool_GetBuffer(test_ptr->
+							   ep_context[i].bp,
+							   RMI_SEND_BUFFER_ID);
+			if (!DT_dto_event_wait
+			    (phead, test_ptr->ep_context[i].reqt_evd_hdl,
+			     &dto_stat)
+			    || !DT_dto_check(phead, &dto_stat,
+					     test_ptr->ep_context[i].ep_handle,
+					     buff_size, dto_cookie,
+					     test_ptr->
+					     is_server ? "Client_Mem_Info_Send"
+					     : "Server_Mem_Info_Send")) {
+				goto test_failure;
+			}
 		}
-	    }
-	}   /* end foreach op */
 
-	/*
-	 * Prep send buffer with memory information
-	 */
-	RemoteMemInfo = (RemoteMemoryInfo *)
-			DT_Bpool_GetBuffer (test_ptr->ep_context[i].bp,
-					RMI_SEND_BUFFER_ID);
+		/*
+		 * Extract what we need
+		 */
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Test[" F64x "]: Memory Info received \n",
+				  test_ptr->base_port));
+		RemoteMemInfo = (RemoteMemoryInfo *)
+		    DT_Bpool_GetBuffer(test_ptr->ep_context[i].bp,
+				       RMI_RECV_BUFFER_ID);
+		for (j = 0; j < test_ptr->cmd->num_ops; j++) {
+			DAT_BOOLEAN us;
 
-	for (j = 0;  j < test_ptr->cmd->num_ops;  j++)
-	{
-	    RemoteMemInfo[j].rmr_context =
-				test_ptr->ep_context[i].op[j].Rdma_Context;
-	    RemoteMemInfo[j].mem_address.as_64 =
-				    test_ptr->ep_context[i].op[j].Rdma_Address;
-	    if (RemoteMemInfo[j].mem_address.as_64)
-	    {
-		DT_Tdep_PT_Debug (3, (phead,
-				"RemoteMemInfo[%d] va=" F64x ", ctx=%x\n",
-				j,
-				RemoteMemInfo[j].mem_address.as_64,
-				RemoteMemInfo[j].rmr_context));
-	    }
-	    /*
-	     * If the client and server are of different endiannesses,
-	     * we must correct the endianness of the handle and address
-	     * we pass to the other side.  The other side cannot (and
-	     * better not) interpret these values.
-	     */
-	    if (DT_local_is_little_endian != test_ptr->remote_is_little_endian)
-	    {
-		RemoteMemInfo[j].rmr_context =
-			DT_EndianMemHandle (RemoteMemInfo[j].rmr_context);
-		RemoteMemInfo[j].mem_address.as_64 =
-			DT_EndianMemAddress (RemoteMemInfo[j].mem_address.as_64);
-	    }
-	}   /* end foreach op */
+			us = (pt_ptr->local_is_server &&
+			      test_ptr->ep_context[i].op[j].server_initiated) ||
+			    (!pt_ptr->local_is_server &&
+			     !test_ptr->ep_context[i].op[j].server_initiated);
+			if (us &&
+			    (test_ptr->ep_context[i].op[j].transfer_type ==
+			     RDMA_READ
+			     || test_ptr->ep_context[i].op[j].transfer_type ==
+			     RDMA_WRITE)) {
+				test_ptr->ep_context[i].op[j].Rdma_Context =
+				    RemoteMemInfo[j].rmr_context;
+				test_ptr->ep_context[i].op[j].Rdma_Address =
+				    RemoteMemInfo[j].mem_address.as_64;
+				DT_Tdep_PT_Debug(3,
+						 (phead,
+						  "Got RemoteMemInfo [ va=" F64x
+						  ", ctx=%x ]\n",
+						  test_ptr->ep_context[i].op[j].
+						  Rdma_Address,
+						  test_ptr->ep_context[i].op[j].
+						  Rdma_Context));
+			}
+		}
+	}			/* end foreach EP context */
 
 	/*
-	 * Send our memory info. The client performs the first send to comply
-	 * with the iWARP MPA protocol's "Connection Startup Rules".
+	 * Dump out the state of the world if we're debugging
 	 */
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Sending %s Memory Info\n",
-			test_ptr->base_port,
-			test_ptr->is_server ? "Server" : "Client"));
-
-	if (!test_ptr->is_server ) {
-
-	    /* post the send buffer */
-	    if (!DT_post_send_buffer (phead,
-		    		  test_ptr->ep_context[i].ep_handle,
-				  test_ptr->ep_context[i].bp,
-				  RMI_SEND_BUFFER_ID,
-				  buff_size))
-	    {
-	        /* error message printed by DT_post_send_buffer */
-	        goto test_failure;
-	    }
-	    /* reap the send and verify it */
-	    dto_cookie.as_64 = LZERO;
-	    dto_cookie.as_ptr =
-	        (DAT_PVOID) DT_Bpool_GetBuffer (
-		    test_ptr->ep_context[i].bp,
-		    RMI_SEND_BUFFER_ID);
-	    if (!DT_dto_event_wait (phead, test_ptr->reqt_evd_hdl, &dto_stat) ||
-	        !DT_dto_check ( phead,
-			    &dto_stat,
-			    test_ptr->ep_context[i].ep_handle,
-			    buff_size,
-			    dto_cookie,
-			    test_ptr->is_server ? "Client_Mem_Info_Send"
-						: "Server_Mem_Info_Send"))
-	    {
-	        goto test_failure;
-	    }
+	if (test_ptr->cmd->debug) {
+		DT_Print_Transaction_Test(phead, test_ptr);
 	}
 
 	/*
-	 * Recv the other side's info
+	 * Finally!  Run the test.
 	 */
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Waiting for %s Memory Info\n",
-			test_ptr->base_port,
-			test_ptr->is_server ? "Client" : "Server"));
-	dto_cookie.as_64 = LZERO;
-	dto_cookie.as_ptr =
-	    (DAT_PVOID) DT_Bpool_GetBuffer (
-		test_ptr->ep_context[i].bp,
-		RMI_RECV_BUFFER_ID);
-	if (!DT_dto_event_wait (phead, test_ptr->recv_evd_hdl, &dto_stat) ||
-	    !DT_dto_check ( phead,
-		 	    &dto_stat,
-			    test_ptr->ep_context[i].ep_handle,
-			    buff_size,
-			    dto_cookie,
-			    test_ptr->is_server ? "Client_Mem_Info_Recv"
-						: "Server_Mem_Info_Recv"))
-	{
-	    goto test_failure;
-	}
+	success = DT_Transaction_Run(phead, test_ptr);
 
-	if (test_ptr->is_server ) {
-	    /* post the send buffer */
-	    if (!DT_post_send_buffer (phead,
-		    		  test_ptr->ep_context[i].ep_handle,
-				  test_ptr->ep_context[i].bp,
-				  RMI_SEND_BUFFER_ID,
-				  buff_size))
-	    {
-	        /* error message printed by DT_post_send_buffer */
-	        goto test_failure;
-	    }
-	    /* reap the send and verify it */
-	    dto_cookie.as_64 = LZERO;
-	    dto_cookie.as_ptr =
-	        (DAT_PVOID) DT_Bpool_GetBuffer (
-		    test_ptr->ep_context[i].bp,
-		    RMI_SEND_BUFFER_ID);
-	    if (!DT_dto_event_wait (phead, test_ptr->reqt_evd_hdl, &dto_stat) ||
-	        !DT_dto_check ( phead,
-			    &dto_stat,
-			    test_ptr->ep_context[i].ep_handle,
-			    buff_size,
-			    dto_cookie,
-			    test_ptr->is_server ? "Client_Mem_Info_Send"
-						: "Server_Mem_Info_Send"))
-	    {
-	        goto test_failure;
-	    }
-	}
-
 	/*
-	 * Extract what we need
+	 * Now clean up and go home
 	 */
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Memory Info received \n",
-			test_ptr->base_port));
-	RemoteMemInfo = (RemoteMemoryInfo *)
-			DT_Bpool_GetBuffer (test_ptr->ep_context[i].bp,
-					RMI_RECV_BUFFER_ID);
-	for (j = 0;  j < test_ptr->cmd->num_ops;  j++)
-	{
-	    DAT_BOOLEAN     us;
+      test_failure:
+	if (test_ptr->ep_context) {
 
-	    us = (pt_ptr->local_is_server &&
-		  test_ptr->ep_context[i].op[j].server_initiated) ||
-		(!pt_ptr->local_is_server &&
-		 !test_ptr->ep_context[i].op[j].server_initiated);
-	    if (us &&
-		(test_ptr->ep_context[i].op[j].transfer_type == RDMA_READ ||
-		 test_ptr->ep_context[i].op[j].transfer_type == RDMA_WRITE))
-	    {
-		test_ptr->ep_context[i].op[j].Rdma_Context =
-					    RemoteMemInfo[j].rmr_context;
-		test_ptr->ep_context[i].op[j].Rdma_Address =
-					    RemoteMemInfo[j].mem_address.as_64;
-		DT_Tdep_PT_Debug (3, (phead,
-			    	"Got RemoteMemInfo [ va=" F64x ", ctx=%x ]\n",
-				test_ptr->ep_context[i].op[j].Rdma_Address,
-				test_ptr->ep_context[i].op[j].Rdma_Context));
-	    }
-	}
-    }	/* end foreach EP context */
+		/* Foreach EP */
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			DAT_EP_HANDLE ep_handle;
 
-    /*
-     * Dump out the state of the world if we're debugging
-     */
-    if (test_ptr->cmd->debug)
-    {
-	DT_Print_Transaction_Test (phead, test_ptr);
-    }
+			ep_handle = DAT_HANDLE_NULL;
 
-    /*
-     * Finally!  Run the test.
-     */
-    success = DT_Transaction_Run (phead, test_ptr);
+			/* Free the per-op buffers */
+			for (j = 0; j < test_ptr->cmd->num_ops; j++) {
+				if (test_ptr->ep_context[i].op[j].bp) {
+					if (!DT_Bpool_Destroy(pt_ptr,
+							      phead,
+							      test_ptr->
+							      ep_context[i].
+							      op[j].bp)) {
+						DT_Tdep_PT_Printf(phead,
+								  "test[" F64x
+								  "]: Warning: Bpool destroy fails\n",
+								  test_ptr->
+								  base_port);
+						/* carry on trying, regardless */
+					}
+				}
+			}
 
-    /* no sync at end of transaction run, wait before cleanup */
-    sleep(1);
+			/* Free the remote memory info exchange buffers */
+			if (test_ptr->ep_context[i].bp) {
+				if (!DT_Bpool_Destroy(pt_ptr,
+						      phead,
+						      test_ptr->ep_context[i].
+						      bp)) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: Warning: Bpool destroy fails\n",
+							  test_ptr->base_port);
+					/* carry on trying, regardless */
+				}
+			}
 
-    /*
-     * Now clean up and go home
-     */
-test_failure:
-    if (test_ptr->ep_context)
-    {
+			/*
+			 * Disconnect -- we may have left recv buffers posted, if we
+			 *               bailed out mid-setup, or ran to completion
+			 *               normally, so we use abrupt closure.
+			 */
+			if (test_ptr->ep_context[i].ep_handle) {
+				ret =
+				    dat_ep_disconnect(test_ptr->ep_context[i].
+						      ep_handle,
+						      DAT_CLOSE_ABRUPT_FLAG);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: Warning: dat_ep_disconnect (%s) "
+							  "#%d error %s\n",
+							  test_ptr->base_port,
+							  success ? "graceful" :
+							  "abrupt", i,
+							  DT_RetToString(ret));
+					/* carry on trying, regardless */
+				}
+			}
 
-	/* Foreach EP */
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    DAT_EP_HANDLE               ep_handle;
+			/*
+			 * Wait on each of the outstanding EP handles. Some of them
+			 * may be disconnected by the remote side, we are racing
+			 * here.
+			 */
 
-	    ep_handle = DAT_HANDLE_NULL;
+			if (success) {	/* Ensure DT_Transaction_Run did not return error otherwise may get stuck waiting for disconnect event */
+				if (!DT_disco_event_wait(phead,
+							 test_ptr->
+							 ep_context[i].
+							 conn_evd_hdl,
+							 &ep_handle)) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: bad disconnect event\n",
+							  test_ptr->base_port);
+				}
+			}
+			ep_handle = test_ptr->ep_context[i].ep_handle;
 
-	    /* Free the per-op buffers */
-	    for (j = 0;  j < test_ptr->cmd->num_ops;  j++)
-	    {
-		if (test_ptr->ep_context[i].op[j].bp)
-		{
-		    if (!DT_Bpool_Destroy (pt_ptr,
-					  phead,
-					  test_ptr->ep_context[i].op[j].bp))
-		    {
-			DT_Tdep_PT_Printf (phead, "test[" F64x "]: Warning: Bpool destroy fails\n",
-			test_ptr->base_port);
-			/* carry on trying, regardless */
-		    }
-		}
-	    }
-
-	    /* Free the remote memory info exchange buffers */
-	    if (test_ptr->ep_context[i].bp)
-	    {
-		if (!DT_Bpool_Destroy (pt_ptr,
-			    	       phead,
-				      test_ptr->ep_context[i].bp))
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Warning: Bpool destroy fails\n",
-				test_ptr->base_port);
-		    /* carry on trying, regardless */
-		}
-	    }
-
-	    /*
-	     * Disconnect -- we may have left recv buffers posted, if we
-	     *		     bailed out mid-setup, or ran to completion
-	     *		     normally, so we use abrupt closure.
-	     */
-	    if (test_ptr->ep_context[i].ep_handle)
-	    {
-		ret = dat_ep_disconnect (test_ptr->ep_context[i].ep_handle,
-					DAT_CLOSE_ABRUPT_FLAG);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Warning: dat_ep_disconnect (%s) "
-				"#%d error %s\n",
-				test_ptr->base_port,
-				success ?  "graceful" : "abrupt",
-				i,  DT_RetToString (ret));
-		    /* carry on trying, regardless */
-		}
-	    }
-
-	    /*
-	     * Wait on each of the outstanding EP handles. Some of them
-	     * may be disconnected by the remote side, we are racing
-	     * here.
-	     */
-
-	    if ( success ) /* Ensure DT_Transaction_Run did not return error otherwise may get stuck waiting for disconnect event*/
-	    {
-		if (!DT_disco_event_wait ( phead,
-			    		   test_ptr->conn_evd_hdl,
-						    &ep_handle))
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: bad disconnect event\n",
-				    test_ptr->base_port);
-		}
-		else
-		{
-		    /*
-		     * We have successfully obtained a completed EP. We are
-		     * racing with the remote node on disconnects, so we
-		     * don't know which EP this is. Run the list and
-		     * remove it so we don't disconnect a disconnected EP
-		     */
-		    for (j = 0;  j < test_ptr->cmd->eps_per_thread;  j++)
-		    {
-			if ( test_ptr->ep_context[j].ep_handle == ep_handle )
-			{
-			    test_ptr->ep_context[j].ep_handle = NULL;
-			    break;
+			/*
+			 * Free the handle returned by the disconnect event.
+			 * With multiple EPs, it may not be the EP we just
+			 * disconnected as we are racing with the remote side
+			 * disconnects.
+			 */
+			if (DAT_HANDLE_NULL != ep_handle) {
+				DAT_EVENT event;
+				/*
+				 * Drain off outstanding DTOs that may have been
+				 * generated by racing disconnects
+				 */
+				do {
+					ret =
+					    DT_Tdep_evd_dequeue(test_ptr->
+								ep_context[i].
+								recv_evd_hdl,
+								&event);
+				} while (ret == DAT_SUCCESS);
+				/* Destroy the EP */
+				ret = dat_ep_free(ep_handle);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_ep_free #%d error: %s\n",
+							  test_ptr->base_port,
+							  i,
+							  DT_RetToString(ret));
+					/* carry on trying, regardless */
+				}
 			}
-		    }
-                    if (j == test_ptr->cmd->eps_per_thread)
-                    {
-                        /* invalid ep_handle returned */
-                        DT_Tdep_PT_Printf(phead,
-                                          "Test[" F64x "]: disconnect"
-                                          " event with unknown EP=%p "
-                                          " possible duplicate\n",
-                                          test_ptr->base_port,
-                                          ep_handle);
-                        ep_handle = NULL;
-                    }
+			/* clean up the EVDs */
+			if (test_ptr->ep_context[i].conn_evd_hdl) {
+				ret =
+				    DT_Tdep_evd_free(test_ptr->ep_context[i].
+						     conn_evd_hdl);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_evd_free (conn) error: %s\n",
+							  test_ptr->base_port,
+							  DT_RetToString(ret));
+				}
+			}
+			if (pt_ptr->local_is_server) {
+				if (test_ptr->ep_context[i].creq_evd_hdl) {
+					ret =
+					    DT_Tdep_evd_free(test_ptr->
+							     ep_context[i].
+							     creq_evd_hdl);
+					if (ret != DAT_SUCCESS) {
+						DT_Tdep_PT_Printf(phead,
+								  "Test[" F64x
+								  "]: dat_evd_free (creq) error: %s\n",
+								  test_ptr->
+								  base_port,
+								  DT_RetToString
+								  (ret));
+					}
+				}
+			}
+			if (test_ptr->ep_context[i].reqt_evd_hdl) {
+				ret =
+				    DT_Tdep_evd_free(test_ptr->ep_context[i].
+						     reqt_evd_hdl);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_evd_free (reqt) error: %s\n",
+							  test_ptr->base_port,
+							  DT_RetToString(ret));
+				}
+			}
+			if (test_ptr->ep_context[i].recv_evd_hdl) {
+				ret =
+				    DT_Tdep_evd_free(test_ptr->ep_context[i].
+						     recv_evd_hdl);
+				if (ret != DAT_SUCCESS) {
+					DT_Tdep_PT_Printf(phead,
+							  "Test[" F64x
+							  "]: dat_evd_free (recv) error: %s\n",
+							  test_ptr->base_port,
+							  DT_RetToString(ret));
+				}
+			}
+		}		/* end foreach per-EP context */
 
-		}
-	    }
-	    else /* !success - QP may be in error state */
-	    {
-		ep_handle =  test_ptr->ep_context[i].ep_handle;
-	    }
+		DT_MemListFree(pt_ptr, test_ptr->ep_context);
+	}
 
-	    /*
-	     * Free the handle returned by the disconnect event.
-	     * With multiple EPs, it may not be the EP we just
-	     * disconnected as we are racing with the remote side
-	     * disconnects.
-	     */
-	    if ( DAT_HANDLE_NULL != ep_handle)
-	    {
-		DAT_EVENT       		event;
-		/*
-		 * Drain off outstanding DTOs that may have been
-		 * generated by racing disconnects
-		 */
-		do
-		{
-		    ret = DT_Tdep_evd_dequeue ( test_ptr->recv_evd_hdl,
-					   &event);
-		} while (ret == DAT_SUCCESS);
-		/* Destroy the EP */
-		ret = dat_ep_free (ep_handle);
-		if (ret != DAT_SUCCESS)
-		{
-		    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_ep_free #%d error: %s\n",
-				test_ptr->base_port, i, DT_RetToString (ret));
-		    /* carry on trying, regardless */
+	/* clean up the PZ */
+	if (test_ptr->pz_handle) {
+		ret = dat_pz_free(test_ptr->pz_handle);
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test[" F64x
+					  "]: dat_pz_free error: %s\n",
+					  test_ptr->base_port,
+					  DT_RetToString(ret));
+			/* fall through, keep trying */
 		}
-	    }
-	}   /* end foreach per-EP context */
-
-	DT_MemListFree (pt_ptr, test_ptr->ep_context);
-    }
-
-    /* clean up the EVDs */
-    if (test_ptr->conn_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (test_ptr->conn_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (conn) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
 	}
-    }
-    if (pt_ptr->local_is_server)
-    {
-	if (test_ptr->creq_evd_hdl)
-	{
-	    ret = DT_Tdep_evd_free (test_ptr->creq_evd_hdl);
-	    if (ret != DAT_SUCCESS)
-	    {
-		DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (creq) error: %s\n",
-			    test_ptr->base_port, DT_RetToString (ret));
-		/* fall through, keep trying */
-	    }
-	}
-    }
-    if (test_ptr->reqt_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (test_ptr->reqt_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (reqt) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
-	}
-    }
-    if (test_ptr->recv_evd_hdl)
-    {
-	ret = DT_Tdep_evd_free (test_ptr->recv_evd_hdl);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_evd_free (recv) error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
-	}
-    }
 
-    /* clean up the PZ */
-    if (test_ptr->pz_handle)
-    {
-	ret = dat_pz_free (test_ptr->pz_handle);
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: dat_pz_free error: %s\n",
-			test_ptr->base_port, DT_RetToString (ret));
-	    /* fall through, keep trying */
-	}
-    }
-
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: cleanup is done\n", test_ptr->base_port));
-    DT_MemListFree ( pt_ptr, test_ptr );
-    DT_Thread_Destroy ( thread, pt_ptr );
-    DT_Mdep_Thread_Detach ( DT_Mdep_Thread_SELF () );	     /* AMM */
-    DT_Mdep_Thread_EXIT (NULL);					    /* AMM */
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: cleanup is done\n",
+			  test_ptr->base_port));
+	DT_MemListFree(pt_ptr, test_ptr);
+	DT_Thread_Destroy(thread, pt_ptr);
+	DT_Mdep_Thread_Detach(DT_Mdep_Thread_SELF());	/* AMM */
+	DT_Mdep_Thread_EXIT(NULL);	/* AMM */
 }
 
-
 /* -----------------------------------------------------------------------
  * The actual performance test
  */
 bool
-DT_Transaction_Run (DT_Tdep_Print_Head *phead, Transaction_Test_t * test_ptr)
+DT_Transaction_Run(DT_Tdep_Print_Head * phead, Transaction_Test_t * test_ptr)
 {
-    unsigned int    op;
-    unsigned int    iteration;
-    int             bytes;
-    bool            ours;
-    bool	    success = false;
-    bool	    repost_recv;
-    unsigned int    i;
+	unsigned int op;
+	unsigned int iteration;
+	int bytes;
+	bool ours;
+	bool success = false;
+	bool repost_recv;
+	unsigned int i;
 
-    /* pre-post all receive buffers */
-    for (op = 0;  op < test_ptr->cmd->num_ops;  op++)
-    {
-	/* if it is a SEND/RECV, we must post receive buffers */
-	if (test_ptr->ep_context[0].op[op].transfer_type == SEND_RECV)
-	{
-	    ours = (test_ptr->is_server ==
-		    test_ptr->ep_context[0].op[op].server_initiated);
-	    if (!ours)
-	    {
-		if (!DT_handle_post_recv_buf (phead,
-			    		      test_ptr->ep_context,
-					      test_ptr->cmd->eps_per_thread,
-					      op))
-		{
-		    goto bail;
+	/* pre-post all receive buffers */
+	for (op = 0; op < test_ptr->cmd->num_ops; op++) {
+		/* if it is a SEND/RECV, we must post receive buffers */
+		if (test_ptr->ep_context[0].op[op].transfer_type == SEND_RECV) {
+			ours = (test_ptr->is_server ==
+				test_ptr->ep_context[0].op[op].
+				server_initiated);
+			if (!ours) {
+				if (!DT_handle_post_recv_buf(phead,
+							     test_ptr->
+							     ep_context,
+							     test_ptr->cmd->
+							     eps_per_thread,
+							     op)) {
+					goto bail;
+				}
+			}
 		}
-	    }
 	}
-    }
 
-    /* initialize data if we are validating it */
-    if (test_ptr->cmd->validate)
-    {
-	DT_Transaction_Validation_Fill (phead, test_ptr, 0);
-    }
+	/* initialize data if we are validating it */
+	if (test_ptr->cmd->validate) {
+		DT_Transaction_Validation_Fill(phead, test_ptr, 0);
+	}
 
-    /*
-     * Now that we've posted our receive buffers...
-     * synchronize with the other side.
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Synchronize with the other side\n",
-		    test_ptr->base_port));
-
-
-    /*
-     * Each server thread sends a sync message to the corresponding
-     * client thread.  All clients wait until all server threads
-     * have sent their sync messages. Then all clients send
-     * sync message.
-     *
-     * Since all of the events are directed to the same EVD,
-     * we do not use DT_dto_check(.) to verify the attributes
-     * of the sync message event. DT_dto_check(.) requires the
-     * comsumer to pass the expected EP, but we do not know
-     * what to expect. DAPL does not guarantee the order of
-     * completions across EPs. Therfore we only know that
-     * test_ptr->cmd->eps_per_thread number of completion events
-     * will be generated but not the order in which they will
-     * complete.
-     */
-
-    if (test_ptr->is_server)
-    {
 	/*
-	 * Server
+	 * Now that we've posted our receive buffers...
+	 * synchronize with the other side.
 	 */
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Send Sync to Client\n",
-			test_ptr->base_port));
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    if (!DT_post_send_buffer (phead,
-				      test_ptr->ep_context[i].ep_handle,
-				     test_ptr->ep_context[i].bp,
-				     SYNC_SEND_BUFFER_ID,
-				     SYNC_BUFF_SIZE))
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Server sync send error\n",
-				test_ptr->base_port));
-		goto bail;
-	    }
-	}
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+	DT_Tdep_PT_Debug(1,
+			 (phead,
+			  "Test[" F64x "]: Synchronize with the other side\n",
+			  test_ptr->base_port));
 
-	    if ( !DT_dto_event_wait (phead, 
-				     test_ptr->reqt_evd_hdl, 
-				     &dto_stat) )
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Server sync send error\n",
-				test_ptr->base_port));
-
-		goto bail;
-	    }
-	}
-
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Wait for Sync Message\n",
-			test_ptr->base_port));
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-
-	    if ( !DT_dto_event_wait (phead,
-				     test_ptr->recv_evd_hdl, 
-				     &dto_stat) )
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Server sync recv error\n",
-				test_ptr->base_port));
-		goto bail;
-	    }
-	}
-    }
-    else
-    {
 	/*
-	 * Client
+	 * Each server thread sends a sync message to the corresponding
+	 * client thread.  All clients wait until all server threads
+	 * have sent their sync messages. Then all clients send
+	 * sync message.
+	 *
+	 * Since all of the events are directed to the same EVD,
+	 * we do not use DT_dto_check(.) to verify the attributes
+	 * of the sync message event. DT_dto_check(.) requires the
+	 * comsumer to pass the expected EP, but we do not know
+	 * what to expect. DAPL does not guarantee the order of
+	 * completions across EPs. Therfore we only know that
+	 * test_ptr->cmd->eps_per_thread number of completion events
+	 * will be generated but not the order in which they will
+	 * complete.
 	 */
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Wait for Sync Message\n",
-			test_ptr->base_port));
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
 
-	    if ( !DT_dto_event_wait (phead,
-				     test_ptr->recv_evd_hdl, 
-				     &dto_stat) )
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Client sync recv error\n",
-				test_ptr->base_port));
-		goto bail;
-	    }
-	    DT_transaction_stats_set_ready (phead,
-		    &test_ptr->pt_ptr->Client_Stats);
-	}
+	if (test_ptr->is_server) {
+		/*
+		 * Server
+		 */
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Test[" F64x "]: Send Sync to Client\n",
+				  test_ptr->base_port));
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			if (!DT_post_send_buffer(phead,
+						 test_ptr->ep_context[i].
+						 ep_handle,
+						 test_ptr->ep_context[i].bp,
+						 SYNC_SEND_BUFFER_ID,
+						 SYNC_BUFF_SIZE)) {
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Test[" F64x
+						  "]: Server sync send error\n",
+						  test_ptr->base_port));
+				goto bail;
+			}
+		}
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
 
-	/* check if it is time for client to send sync */
-	if (!DT_transaction_stats_wait_for_all (phead,
-					    &test_ptr->pt_ptr->Client_Stats))
-	{
-	    goto bail;
-	}
+			if (!DT_dto_event_wait(phead,
+					       test_ptr->ep_context[i].
+					       reqt_evd_hdl, &dto_stat)) {
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Test[" F64x
+						  "]: Server sync send error\n",
+						  test_ptr->base_port));
 
-	DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Send Sync Msg\n", test_ptr->base_port));
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    if (!DT_post_send_buffer (phead,
-				     test_ptr->ep_context[i].ep_handle,
-				     test_ptr->ep_context[i].bp,
-				     SYNC_SEND_BUFFER_ID,
-				     SYNC_BUFF_SIZE))
-	    {
-		DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Client sync send error\n",
-				test_ptr->base_port));
-		goto bail;
-	    }
-	}
-	for (i = 0;  i < test_ptr->cmd->eps_per_thread;  i++)
-	{
-	    DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+				goto bail;
+			}
+		}
 
-	    if ( !DT_dto_event_wait (phead,
-				     test_ptr->reqt_evd_hdl, 
-				     &dto_stat) )
-	    {
-		goto bail;
-	    }
-	}
-    }
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Test[" F64x "]: Wait for Sync Message\n",
+				  test_ptr->base_port));
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
 
-    /*
-     * Get to work ...
-     */
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: Begin...\n", test_ptr->base_port));
-    test_ptr->stats.start_time = DT_Mdep_GetTime ();
+			if (!DT_dto_event_wait(phead,
+					       test_ptr->ep_context[i].
+					       recv_evd_hdl, &dto_stat)) {
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Test[" F64x
+						  "]: Server sync recv error\n",
+						  test_ptr->base_port));
+				goto bail;
+			}
+		}
+	} else {
+		/*
+		 * Client
+		 */
+		DT_Tdep_PT_Debug(1,
+				 (phead,
+				  "Test[" F64x "]: Wait for Sync Message\n",
+				  test_ptr->base_port));
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
 
-    for (iteration = 0;
-	iteration < test_ptr->cmd->num_iterations;
-	iteration++)
-    {
+			if (!DT_dto_event_wait(phead,
+					       test_ptr->ep_context[i].
+					       recv_evd_hdl, &dto_stat)) {
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Test[" F64x
+						  "]: Client sync recv error\n",
+						  test_ptr->base_port));
+				goto bail;
+			}
+			DT_transaction_stats_set_ready(phead,
+						       &test_ptr->pt_ptr->
+						       Client_Stats);
+		}
 
-	DT_Tdep_PT_Debug (1,(phead,"iteration: %d\n", iteration));
+		/* check if it is time for client to send sync */
+		if (!DT_transaction_stats_wait_for_all(phead,
+						       &test_ptr->pt_ptr->
+						       Client_Stats)) {
+			goto bail;
+		}
 
-	/* repost unless this is the last iteration */
-	repost_recv = (iteration + 1 != test_ptr->cmd->num_iterations);
-
-	for (op = 0;  op < test_ptr->cmd->num_ops;  op++)
-	{
-	    ours = (test_ptr->is_server ==
-		    test_ptr->ep_context[0].op[op].server_initiated);
-	    bytes = (test_ptr->ep_context[0].op[op].seg_size *
-		     test_ptr->ep_context[0].op[op].num_segs *
-		     test_ptr->cmd->eps_per_thread);
-
-	    switch (test_ptr->ep_context[0].op[op].transfer_type)
-	    {
-		case RDMA_READ:
-		{
-		    test_ptr->stats.stat_bytes_rdma_read += bytes;
-		    if (ours)
-		    {
-			DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: RdmaRead [%d]\n",
-				    test_ptr->base_port,
-				    op));
-			if (!DT_handle_rdma_op (phead,
-				    	     test_ptr->ep_context,
-					     test_ptr->reqt_evd_hdl,
-					     test_ptr->cmd->eps_per_thread,
-					     RDMA_READ,
-					     op,
-					     test_ptr->cmd->poll))
-			{
-			    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: RdmaRead error[%d]\n",
-				    test_ptr->base_port, op);
-			    goto bail;
+		DT_Tdep_PT_Debug(1,
+				 (phead, "Test[" F64x "]: Send Sync Msg\n",
+				  test_ptr->base_port));
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			if (!DT_post_send_buffer(phead,
+						 test_ptr->ep_context[i].
+						 ep_handle,
+						 test_ptr->ep_context[i].bp,
+						 SYNC_SEND_BUFFER_ID,
+						 SYNC_BUFF_SIZE)) {
+				DT_Tdep_PT_Debug(1,
+						 (phead,
+						  "Test[" F64x
+						  "]: Client sync send error\n",
+						  test_ptr->base_port));
+				goto bail;
 			}
-		    }
-		    break;
 		}
+		for (i = 0; i < test_ptr->cmd->eps_per_thread; i++) {
+			DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
 
-		case RDMA_WRITE:
-		{
-		    test_ptr->stats.stat_bytes_rdma_write += bytes;
-		    if (ours)
-		    {
-			DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: RdmaWrite [%d]\n",
-				    test_ptr->base_port,
-				    op));
-			if (!DT_handle_rdma_op (phead,
-				    	     test_ptr->ep_context,
-					     test_ptr->reqt_evd_hdl,
-					     test_ptr->cmd->eps_per_thread,
-					     RDMA_WRITE,
-					     op,
-					     test_ptr->cmd->poll))
-			{
-			    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: RdmaWrite error[%d]\n",
-					test_ptr->base_port, op);
-			    goto bail;
+			if (!DT_dto_event_wait(phead,
+					       test_ptr->ep_context[i].
+					       reqt_evd_hdl, &dto_stat)) {
+				goto bail;
 			}
-		    }
-		    break;
 		}
+	}
 
-		case SEND_RECV:
-		{
-		    if (ours)
-		    {
-			test_ptr->stats.stat_bytes_send += bytes;
-			DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: postsend [%d] \n",
-				    test_ptr->base_port, op));
-			/* send data */
-			if (!DT_handle_send_op (phead,
-				    		test_ptr->ep_context,
-					      test_ptr->reqt_evd_hdl,
-					      test_ptr->cmd->eps_per_thread,
-					      op,
-					      test_ptr->cmd->poll))
-			{
-			    goto bail;
-			}
-		    }
-		    else
-		    {
-			test_ptr->stats.stat_bytes_recv += bytes;
-			DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: RecvWait and Re-Post [%d] \n",
-				    test_ptr->base_port, op));
+	/*
+	 * Get to work ...
+	 */
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: Begin...\n",
+			  test_ptr->base_port));
+	test_ptr->stats.start_time = DT_Mdep_GetTime();
 
-			if (!DT_handle_recv_op (phead,
-				    	      test_ptr->ep_context,
-					      test_ptr->recv_evd_hdl,
-					      test_ptr->reqt_evd_hdl,
-					      test_ptr->cmd->eps_per_thread,
-					      op,
-					      test_ptr->cmd->poll,
-					      repost_recv))
-			{
-			    goto bail;
-			}
-		    }
+	for (iteration = 0;
+	     iteration < test_ptr->cmd->num_iterations; iteration++) {
 
-		    /* now before going on, is it time to validate? */
-		    if (test_ptr->cmd->validate)
-		    {
-			if (!test_ptr->pt_ptr->local_is_server)	  /* CLIENT */
-			{
-			    /* the client validates on the third to last op */
-			    if (op == test_ptr->cmd->num_ops - 3)
-			    {
-				if (!DT_Transaction_Validation_Check (phead,
-					    			 test_ptr,
-								 iteration))
+		DT_Tdep_PT_Debug(1, (phead, "iteration: %d\n", iteration));
+
+		/* repost unless this is the last iteration */
+		repost_recv = (iteration + 1 != test_ptr->cmd->num_iterations);
+
+		for (op = 0; op < test_ptr->cmd->num_ops; op++) {
+			ours = (test_ptr->is_server ==
+				test_ptr->ep_context[0].op[op].
+				server_initiated);
+			bytes =
+			    (test_ptr->ep_context[0].op[op].seg_size *
+			     test_ptr->ep_context[0].op[op].num_segs *
+			     test_ptr->cmd->eps_per_thread);
+
+			switch (test_ptr->ep_context[0].op[op].transfer_type) {
+			case RDMA_READ:
 				{
-				    goto bail;
+					test_ptr->stats.stat_bytes_rdma_read +=
+					    bytes;
+					if (ours) {
+						DT_Tdep_PT_Debug(1,
+								 (phead,
+								  "Test[" F64x
+								  "]: RdmaRead [%d]\n",
+								  test_ptr->
+								  base_port,
+								  op));
+						if (!DT_handle_rdma_op
+						    (phead,
+						     test_ptr->ep_context,
+						     test_ptr->cmd->
+						     eps_per_thread, RDMA_READ,
+						     op, test_ptr->cmd->poll)) {
+							DT_Tdep_PT_Printf(phead,
+									  "Test["
+									  F64x
+									  "]: RdmaRead error[%d]\n",
+									  test_ptr->
+									  base_port,
+									  op);
+							goto bail;
+						}
+					}
+					break;
 				}
-				DT_Transaction_Validation_Fill (phead, 
-							test_ptr,
-							iteration + 1);
-			    }
-			}
-			else					/* SERVER */
-			{
-			    /* the server validates on the second to last op */
-			    if (op == test_ptr->cmd->num_ops - 2)
-			    {
-				if (!DT_Transaction_Validation_Check (phead,
-					    			 test_ptr,
-								 iteration))
+
+			case RDMA_WRITE:
 				{
-				    goto bail;
+					test_ptr->stats.stat_bytes_rdma_write +=
+					    bytes;
+					if (ours) {
+						DT_Tdep_PT_Debug(1,
+								 (phead,
+								  "Test[" F64x
+								  "]: RdmaWrite [%d]\n",
+								  test_ptr->
+								  base_port,
+								  op));
+						if (!DT_handle_rdma_op
+						    (phead,
+						     test_ptr->ep_context,
+						     test_ptr->cmd->
+						     eps_per_thread, RDMA_WRITE,
+						     op, test_ptr->cmd->poll)) {
+							DT_Tdep_PT_Printf(phead,
+									  "Test["
+									  F64x
+									  "]: RdmaWrite error[%d]\n",
+									  test_ptr->
+									  base_port,
+									  op);
+							goto bail;
+						}
+					}
+					break;
 				}
-				DT_Transaction_Validation_Fill (phead,
-							    test_ptr,
-							    iteration + 1);
-			    }
-			}
-		    }		    /* end validate */
-		    break;
-		}
-	    }			/* end switch for transfer type */
-	}			/* end loop for each op */
-    }				/* end loop for iteration */
 
-    /* end time and print stats */
-    test_ptr->stats.end_time = DT_Mdep_GetTime ();
-    if (!test_ptr->pt_ptr->local_is_server)
-    {
-	DT_update_transaction_stats (&test_ptr->pt_ptr->Client_Stats,
-		    test_ptr->cmd->eps_per_thread * test_ptr->cmd->num_ops *
-		    test_ptr->cmd->num_iterations,
-		    test_ptr->stats.end_time - test_ptr->stats.start_time,
-		    test_ptr->stats.stat_bytes_send,
-		    test_ptr->stats.stat_bytes_recv,
-		    test_ptr->stats.stat_bytes_rdma_read,
-		    test_ptr->stats.stat_bytes_rdma_write);
-    }
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: End Successfully\n", test_ptr->base_port));
-    success = true;
+			case SEND_RECV:
+				{
+					if (ours) {
+						test_ptr->stats.
+						    stat_bytes_send += bytes;
+						DT_Tdep_PT_Debug(1,
+								 (phead,
+								  "Test[" F64x
+								  "]: postsend [%d] \n",
+								  test_ptr->
+								  base_port,
+								  op));
+						/* send data */
+						if (!DT_handle_send_op(phead,
+								       test_ptr->
+								       ep_context,
+								       test_ptr->
+								       cmd->
+								       eps_per_thread,
+								       op,
+								       test_ptr->
+								       cmd->
+								       poll)) {
+							goto bail;
+						}
+					} else {
+						test_ptr->stats.
+						    stat_bytes_recv += bytes;
+						DT_Tdep_PT_Debug(1,
+								 (phead,
+								  "Test[" F64x
+								  "]: RecvWait and Re-Post [%d] \n",
+								  test_ptr->
+								  base_port,
+								  op));
 
-bail:
-    return ( success );
+						if (!DT_handle_recv_op(phead,
+								       test_ptr->
+								       ep_context,
+								       test_ptr->
+								       cmd->
+								       eps_per_thread,
+								       op,
+								       test_ptr->
+								       cmd->
+								       poll,
+								       repost_recv))
+						{
+							goto bail;
+						}
+					}
+
+					/* now before going on, is it time to validate? */
+					if (test_ptr->cmd->validate) {
+						if (!test_ptr->pt_ptr->local_is_server) {	/* CLIENT */
+							/* the client validates on the third to last op */
+							if (op ==
+							    test_ptr->cmd->
+							    num_ops - 3) {
+								if (!DT_Transaction_Validation_Check(phead, test_ptr, iteration)) {
+									goto bail;
+								}
+								DT_Transaction_Validation_Fill
+								    (phead,
+								     test_ptr,
+								     iteration +
+								     1);
+							}
+						} else {	/* SERVER */
+
+							/* the server validates on the second to last op */
+							if (op ==
+							    test_ptr->cmd->
+							    num_ops - 2) {
+								if (!DT_Transaction_Validation_Check(phead, test_ptr, iteration)) {
+									goto bail;
+								}
+								DT_Transaction_Validation_Fill
+								    (phead,
+								     test_ptr,
+								     iteration +
+								     1);
+							}
+						}
+					}	/* end validate */
+					break;
+				}
+			}	/* end switch for transfer type */
+		}		/* end loop for each op */
+	}			/* end loop for iteration */
+
+	/* end time and print stats */
+	test_ptr->stats.end_time = DT_Mdep_GetTime();
+	if (!test_ptr->pt_ptr->local_is_server) {
+		DT_update_transaction_stats(&test_ptr->pt_ptr->Client_Stats,
+					    test_ptr->cmd->eps_per_thread *
+					    test_ptr->cmd->num_ops *
+					    test_ptr->cmd->num_iterations,
+					    test_ptr->stats.end_time -
+					    test_ptr->stats.start_time,
+					    test_ptr->stats.stat_bytes_send,
+					    test_ptr->stats.stat_bytes_recv,
+					    test_ptr->stats.
+					    stat_bytes_rdma_read,
+					    test_ptr->stats.
+					    stat_bytes_rdma_write);
+	}
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: End Successfully\n",
+			  test_ptr->base_port));
+	success = true;
+
+      bail:
+	return (success);
 }
 
-
 /*------------------------------------------------------------------------------ */
 void
-DT_Transaction_Validation_Fill ( DT_Tdep_Print_Head *phead,
-				Transaction_Test_t * test_ptr,
-				unsigned int iteration)
+DT_Transaction_Validation_Fill(DT_Tdep_Print_Head * phead,
+			       Transaction_Test_t * test_ptr,
+			       unsigned int iteration)
 {
-    bool            ours;
-    unsigned int    op;
-    unsigned int    i;
-    unsigned int    j;
-    unsigned int    ind;
-    unsigned char  *buff;
+	bool ours;
+	unsigned int op;
+	unsigned int i;
+	unsigned int j;
+	unsigned int ind;
+	unsigned char *buff;
 
-    if (iteration >= test_ptr->cmd->num_iterations)
-    {
-	return;
-    }
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: FILL Buffers Iteration %d\n",
-		    test_ptr->base_port, iteration));
+	if (iteration >= test_ptr->cmd->num_iterations) {
+		return;
+	}
+	DT_Tdep_PT_Debug(1,
+			 (phead, "Test[" F64x "]: FILL Buffers Iteration %d\n",
+			  test_ptr->base_port, iteration));
 
-    /*
-     * fill all but the last three ops, which
-     * were added to create barriers for data validation
-     */
-    for (ind = 0;  ind < test_ptr->cmd->eps_per_thread;  ind++)
-    {
-	for (op = 0;  op < test_ptr->cmd->num_ops - 3;  op++)
-	{
-	    ours = (test_ptr->is_server ==
-			test_ptr->ep_context[ind].op[op].server_initiated);
+	/*
+	 * fill all but the last three ops, which
+	 * were added to create barriers for data validation
+	 */
+	for (ind = 0; ind < test_ptr->cmd->eps_per_thread; ind++) {
+		for (op = 0; op < test_ptr->cmd->num_ops - 3; op++) {
+			ours = (test_ptr->is_server ==
+				test_ptr->ep_context[ind].op[op].
+				server_initiated);
 
-	    switch (test_ptr->ep_context[ind].op[op].transfer_type)
-
-	    {
-		case RDMA_READ:
-		{
-		    if (!ours)
-		    {
-			for (i = 0;
-			    i < test_ptr->ep_context[ind].op[op].num_segs;
-			    i++)
+			switch (test_ptr->ep_context[ind].op[op].transfer_type)
 			{
+			case RDMA_READ:
+				{
+					if (!ours) {
+						for (i = 0;
+						     i <
+						     test_ptr->ep_context[ind].
+						     op[op].num_segs; i++) {
 
-			    buff = DT_Bpool_GetBuffer (
-				    test_ptr->ep_context[ind].op[op].bp, i);
-			    for (j = 0;
-				j < test_ptr->ep_context[ind].op[op].seg_size;
-				j++)
-			    {
-				/* Avoid using all zero bits the 1st time */
-				buff[j] = (iteration + 1) & 0xFF;
-			    }
-			}
-		    }
-		    break;
-		}
+							buff =
+							    DT_Bpool_GetBuffer
+							    (test_ptr->
+							     ep_context[ind].
+							     op[op].bp, i);
+							for (j = 0;
+							     j <
+							     test_ptr->
+							     ep_context[ind].
+							     op[op].seg_size;
+							     j++) {
+								/* Avoid using all zero bits the 1st time */
+								buff[j] =
+								    (iteration +
+								     1) & 0xFF;
+							}
+						}
+					}
+					break;
+				}
 
-		case RDMA_WRITE:
-		{
-		    if (ours)
-		    {
-			for (i = 0;
-			    i < test_ptr->ep_context[ind].op[op].num_segs;
-			    i++)
-			{
+			case RDMA_WRITE:
+				{
+					if (ours) {
+						for (i = 0;
+						     i <
+						     test_ptr->ep_context[ind].
+						     op[op].num_segs; i++) {
 
-			    buff = DT_Bpool_GetBuffer (
-				    test_ptr->ep_context[ind].op[op].bp, i);
-			    for (j = 0;
-				j < test_ptr->ep_context[ind].op[op].seg_size;
-				j++)
-			    {
-				/* Avoid using all zero bits the 1st time */
-				buff[j] = (iteration + 1) & 0xFF;
-			    }
-			}
-		    }
-		    break;
-		}
+							buff =
+							    DT_Bpool_GetBuffer
+							    (test_ptr->
+							     ep_context[ind].
+							     op[op].bp, i);
+							for (j = 0;
+							     j <
+							     test_ptr->
+							     ep_context[ind].
+							     op[op].seg_size;
+							     j++) {
+								/* Avoid using all zero bits the 1st time */
+								buff[j] =
+								    (iteration +
+								     1) & 0xFF;
+							}
+						}
+					}
+					break;
+				}
 
-		case SEND_RECV:
-		{
-		    if (ours)
-		    {
-			for (i = 0;
-			    i < test_ptr->ep_context[ind].op[op].num_segs;
-			    i++)
-			{
+			case SEND_RECV:
+				{
+					if (ours) {
+						for (i = 0;
+						     i <
+						     test_ptr->ep_context[ind].
+						     op[op].num_segs; i++) {
 
-			    buff = DT_Bpool_GetBuffer (
-				    test_ptr->ep_context[ind].op[op].bp,
-				    i);
+							buff =
+							    DT_Bpool_GetBuffer
+							    (test_ptr->
+							     ep_context[ind].
+							     op[op].bp, i);
 			    /*****
 			       DT_Tdep_PT_Printf(phead, 
 			       "\tFill: wq=%d op=%d seg=%d ptr=[%p, %d]\n",
 			       ind, op, i, buff, j);
 			     *****/
-			    for (j = 0;
-				j < test_ptr->ep_context[ind].op[op].seg_size;
-				j++)
-			    {
-				/* Avoid using all zero bits the 1st time */
-				buff[j] = (iteration + 1) & 0xFF;
-			    }
-			}
-		    }
-		    break;
-		}
-	    }	/* end switch transfer_type */
-	}	/* end for each op */
-    }		/* end for each ep per thread */
+							for (j = 0;
+							     j <
+							     test_ptr->
+							     ep_context[ind].
+							     op[op].seg_size;
+							     j++) {
+								/* Avoid using all zero bits the 1st time */
+								buff[j] =
+								    (iteration +
+								     1) & 0xFF;
+							}
+						}
+					}
+					break;
+				}
+			}	/* end switch transfer_type */
+		}		/* end for each op */
+	}			/* end for each ep per thread */
 }
 
-
 /*------------------------------------------------------------------------------ */
 bool
-DT_Transaction_Validation_Check (DT_Tdep_Print_Head *phead,
-				Transaction_Test_t * test_ptr,
-				int iteration)
+DT_Transaction_Validation_Check(DT_Tdep_Print_Head * phead,
+				Transaction_Test_t * test_ptr, int iteration)
 {
-    bool            ours;
-    bool            success = true;
-    unsigned int    op;
-    unsigned int    i;
-    unsigned int    j;
-    unsigned int    ind;
-    unsigned char  *buff;
-    unsigned char   expect;
-    unsigned char   got;
+	bool ours;
+	bool success = true;
+	unsigned int op;
+	unsigned int i;
+	unsigned int j;
+	unsigned int ind;
+	unsigned char *buff;
+	unsigned char expect;
+	unsigned char got;
 
-    DT_Tdep_PT_Debug (1,(phead,"Test[" F64x "]: VALIDATE Buffers Iteration %d\n",
-		    test_ptr->base_port,
-		    iteration));
+	DT_Tdep_PT_Debug(1,
+			 (phead,
+			  "Test[" F64x "]: VALIDATE Buffers Iteration %d\n",
+			  test_ptr->base_port, iteration));
 
-    /*
-     * fill all but the last three ops, which
-     * were added to create barriers for data validation
-     */
-    for (ind = 0;  ind < test_ptr->cmd->eps_per_thread;  ind++)
-    {
-	for (op = 0;  op < test_ptr->cmd->num_ops - 3;  op++)
-	{
-	    ours = (test_ptr->is_server ==
-		    test_ptr->ep_context[ind].op[op].server_initiated);
+	/*
+	 * fill all but the last three ops, which
+	 * were added to create barriers for data validation
+	 */
+	for (ind = 0; ind < test_ptr->cmd->eps_per_thread; ind++) {
+		for (op = 0; op < test_ptr->cmd->num_ops - 3; op++) {
+			ours = (test_ptr->is_server ==
+				test_ptr->ep_context[ind].op[op].
+				server_initiated);
 
-	    switch (test_ptr->ep_context[ind].op[op].transfer_type)
-	    {
-		case RDMA_READ:
-		{
-		    if (ours)
-		    {
-			for (i = 0;
-			    i < test_ptr->ep_context[ind].op[op].num_segs; i++)
-			{
+			switch (test_ptr->ep_context[ind].op[op].transfer_type) {
+			case RDMA_READ:
+				{
+					if (ours) {
+						for (i = 0;
+						     i <
+						     test_ptr->ep_context[ind].
+						     op[op].num_segs; i++) {
 
-			    buff = DT_Bpool_GetBuffer (
-				    test_ptr->ep_context[ind].op[op].bp, i);
+							buff =
+							    DT_Bpool_GetBuffer
+							    (test_ptr->
+							     ep_context[ind].
+							     op[op].bp, i);
 
-			    for (j = 0;
-				j < test_ptr->ep_context[ind].op[op].seg_size;
-				j++)
-			    {
+							for (j = 0;
+							     j <
+							     test_ptr->
+							     ep_context[ind].
+							     op[op].seg_size;
+							     j++) {
 
-				expect = (iteration + 1) & 0xFF;
-				got = buff[j];
-				if (expect != got)
-				{
-				    DT_Tdep_PT_Printf (phead,
-					"Test[" F64x "]: Validation Error :: %d\n",
-					test_ptr->base_port,
-					op);
-				    DT_Tdep_PT_Printf (phead,
-					    "Test[" F64x "]: Expected %x Got %x\n",
-					    test_ptr->base_port,
-					    expect,
-					    got);
-				    DT_Tdep_PT_Debug (3,
-					(phead,
-					"\twq=%d op=%d seg=%d byte=%d ptr=%p\n",
-					ind, op, i, j, buff));
-				    success = false;
-				    break;
+								expect =
+								    (iteration +
+								     1) & 0xFF;
+								got = buff[j];
+								if (expect !=
+								    got) {
+									DT_Tdep_PT_Printf
+									    (phead,
+									     "Test["
+									     F64x
+									     "]: Validation Error :: %d\n",
+									     test_ptr->
+									     base_port,
+									     op);
+									DT_Tdep_PT_Printf
+									    (phead,
+									     "Test["
+									     F64x
+									     "]: Expected %x Got %x\n",
+									     test_ptr->
+									     base_port,
+									     expect,
+									     got);
+									DT_Tdep_PT_Debug
+									    (3,
+									     (phead,
+									      "\twq=%d op=%d seg=%d byte=%d ptr=%p\n",
+									      ind,
+									      op,
+									      i,
+									      j,
+									      buff));
+									success
+									    =
+									    false;
+									break;
+								}
+							}
+						}
+					}
+					break;
 				}
-			    }
-			}
-		    }
-		    break;
-		}
 
-		case RDMA_WRITE:
-		{
-		    if (!ours)
-		    {
-			for (i = 0;
-			    i < test_ptr->ep_context[ind].op[op].num_segs;
-			    i++)
-			{
+			case RDMA_WRITE:
+				{
+					if (!ours) {
+						for (i = 0;
+						     i <
+						     test_ptr->ep_context[ind].
+						     op[op].num_segs; i++) {
 
-			    buff = DT_Bpool_GetBuffer (
-				    test_ptr->ep_context[ind].op[op].bp, i);
-			    for (j = 0;
-				j < test_ptr->ep_context[ind].op[op].seg_size;
-				j++)
-			    {
+							buff =
+							    DT_Bpool_GetBuffer
+							    (test_ptr->
+							     ep_context[ind].
+							     op[op].bp, i);
+							for (j = 0;
+							     j <
+							     test_ptr->
+							     ep_context[ind].
+							     op[op].seg_size;
+							     j++) {
 
-				expect = (iteration + 1) & 0xFF;
-				got = buff[j];
-				if (expect != got)
-				{
-				    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Validation Error :: %d\n",
-					    test_ptr->base_port,
-					    op);
-				    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Expected %x Got %x\n",
-					    test_ptr->base_port,
-					    expect,
-					    got);
-				    DT_Tdep_PT_Debug (3,
-					(phead,
-					"\twq=%d op=%d seg=%d byte=%d ptr=%p\n",
-					ind, op, i, j, buff));
-				    success = false;
-				    break;
+								expect =
+								    (iteration +
+								     1) & 0xFF;
+								got = buff[j];
+								if (expect !=
+								    got) {
+									DT_Tdep_PT_Printf
+									    (phead,
+									     "Test["
+									     F64x
+									     "]: Validation Error :: %d\n",
+									     test_ptr->
+									     base_port,
+									     op);
+									DT_Tdep_PT_Printf
+									    (phead,
+									     "Test["
+									     F64x
+									     "]: Expected %x Got %x\n",
+									     test_ptr->
+									     base_port,
+									     expect,
+									     got);
+									DT_Tdep_PT_Debug
+									    (3,
+									     (phead,
+									      "\twq=%d op=%d seg=%d byte=%d ptr=%p\n",
+									      ind,
+									      op,
+									      i,
+									      j,
+									      buff));
+									success
+									    =
+									    false;
+									break;
+								}
+							}
+						}
+					}
+					break;
 				}
-			    }
-			}
-		    }
-		    break;
-		}
 
-		case SEND_RECV:
-		{
-		    if (!ours)
-		    {
-			for (i = 0;
-			    i < test_ptr->ep_context[ind].op[op].num_segs;
-			    i++)
-			{
+			case SEND_RECV:
+				{
+					if (!ours) {
+						for (i = 0;
+						     i <
+						     test_ptr->ep_context[ind].
+						     op[op].num_segs; i++) {
 
-			    buff = DT_Bpool_GetBuffer (
-				    test_ptr->ep_context[ind].op[op].bp, i);
-			    DT_Tdep_PT_Debug (3, (
-				phead,
-				"\tCheck:wq=%d op=%d seg=%d ptr=[%p, %d]\n",
-				ind, op, i, buff,
-				test_ptr->ep_context[ind].op[op].seg_size));
+							buff =
+							    DT_Bpool_GetBuffer
+							    (test_ptr->
+							     ep_context[ind].
+							     op[op].bp, i);
+							DT_Tdep_PT_Debug(3,
+									 (phead,
+									  "\tCheck:wq=%d op=%d seg=%d ptr=[%p, %d]\n",
+									  ind,
+									  op, i,
+									  buff,
+									  test_ptr->
+									  ep_context
+									  [ind].
+									  op
+									  [op].
+									  seg_size));
 
-			    for (j = 0;
-				j < test_ptr->ep_context[ind].op[op].seg_size;
-				j++)
-			    {
+							for (j = 0;
+							     j <
+							     test_ptr->
+							     ep_context[ind].
+							     op[op].seg_size;
+							     j++) {
 
-				expect = (iteration + 1) & 0xFF;
-				got = buff[j];
-				if (expect != got)
-				{
-				    DT_Tdep_PT_Printf (phead, 
-					"Test[" F64x "]: Validation Error :: %d\n",
-					test_ptr->base_port,
-					op);
-				    DT_Tdep_PT_Printf (phead, "Test[" F64x "]: Expected %x Got %x\n",
-					    test_ptr->base_port,
-					    expect,
-					    got);
-				    DT_Tdep_PT_Debug (3,
-					(phead,
-					"\twq=%d op=%d seg=%d byte=%d ptr=%p\n",
-					ind, op, i, j, buff));
-				    success = false;
-				    break;
+								expect =
+								    (iteration +
+								     1) & 0xFF;
+								got = buff[j];
+								if (expect !=
+								    got) {
+									DT_Tdep_PT_Printf
+									    (phead,
+									     "Test["
+									     F64x
+									     "]: Validation Error :: %d\n",
+									     test_ptr->
+									     base_port,
+									     op);
+									DT_Tdep_PT_Printf
+									    (phead,
+									     "Test["
+									     F64x
+									     "]: Expected %x Got %x\n",
+									     test_ptr->
+									     base_port,
+									     expect,
+									     got);
+									DT_Tdep_PT_Debug
+									    (3,
+									     (phead,
+									      "\twq=%d op=%d seg=%d byte=%d ptr=%p\n",
+									      ind,
+									      op,
+									      i,
+									      j,
+									      buff));
+									success
+									    =
+									    false;
+									break;
+								}
+							}
+						}
+					}
+					break;
 				}
-			    }
-			}
-		    }
-		    break;
-		}
-	    }	/* end switch transfer_type */
-	}	/* end for each op */
-    }		/* end for each ep per thread */
+			}	/* end switch transfer_type */
+		}		/* end for each op */
+	}			/* end for each ep per thread */
 
-    return ( success );
+	return (success);
 }
 
-
 /*------------------------------------------------------------------------------ */
 void
-DT_Print_Transaction_Test (DT_Tdep_Print_Head *phead, Transaction_Test_t * test_ptr)
+DT_Print_Transaction_Test(DT_Tdep_Print_Head * phead,
+			  Transaction_Test_t * test_ptr)
 {
-    DT_Tdep_PT_Printf (phead, "-------------------------------------\n");
-    DT_Tdep_PT_Printf (phead, "TransTest.is_server              : %d\n",
-		    test_ptr->is_server);
-    DT_Tdep_PT_Printf (phead, "TransTest.remote_little_endian   : %d\n",
-		    test_ptr->remote_is_little_endian);
-    DT_Tdep_PT_Printf (phead, "TransTest.base_port              : " F64x "\n",
-		    test_ptr->base_port);
-    DT_Tdep_PT_Printf (phead, "TransTest.pz_handle              : %p\n",
-		    test_ptr->pz_handle);
-    /* statistics */
-    DT_Tdep_PT_Printf (phead, "TransTest.bytes_send             : %d\n",
-		    test_ptr->stats.stat_bytes_send);
-    DT_Tdep_PT_Printf (phead, "TransTest.bytes_recv             : %d\n",
-		    test_ptr->stats.stat_bytes_recv);
-    DT_Tdep_PT_Printf (phead, "TransTest.bytes_rdma_read        : %d\n",
-		    test_ptr->stats.stat_bytes_rdma_read);
-    DT_Tdep_PT_Printf (phead, "TransTest.bytes_rdma_write       : %d\n",
-		    test_ptr->stats.stat_bytes_rdma_write);
+	DT_Tdep_PT_Printf(phead, "-------------------------------------\n");
+	DT_Tdep_PT_Printf(phead, "TransTest.is_server              : %d\n",
+			  test_ptr->is_server);
+	DT_Tdep_PT_Printf(phead, "TransTest.remote_little_endian   : %d\n",
+			  test_ptr->remote_is_little_endian);
+	DT_Tdep_PT_Printf(phead,
+			  "TransTest.base_port              : " F64x "\n",
+			  test_ptr->base_port);
+	DT_Tdep_PT_Printf(phead, "TransTest.pz_handle              : %p\n",
+			  test_ptr->pz_handle);
+	/* statistics */
+	DT_Tdep_PT_Printf(phead, "TransTest.bytes_send             : %d\n",
+			  test_ptr->stats.stat_bytes_send);
+	DT_Tdep_PT_Printf(phead, "TransTest.bytes_recv             : %d\n",
+			  test_ptr->stats.stat_bytes_recv);
+	DT_Tdep_PT_Printf(phead, "TransTest.bytes_rdma_read        : %d\n",
+			  test_ptr->stats.stat_bytes_rdma_read);
+	DT_Tdep_PT_Printf(phead, "TransTest.bytes_rdma_write       : %d\n",
+			  test_ptr->stats.stat_bytes_rdma_write);
 }
 
-
 /*------------------------------------------------------------------------------ */
 void
-DT_Print_Transaction_Stats (DT_Tdep_Print_Head *phead, Transaction_Test_t * test_ptr)
+DT_Print_Transaction_Stats(DT_Tdep_Print_Head * phead,
+			   Transaction_Test_t * test_ptr)
 {
-    double          time;
-    double          mbytes_send;
-    double          mbytes_recv;
-    double          mbytes_rdma_read;
-    double          mbytes_rdma_write;
-    int             total_ops;
-    time = (double) (test_ptr->stats.end_time - test_ptr->stats.start_time) / 1000;
-    mbytes_send = (double) test_ptr->stats.stat_bytes_send / 1024 / 1024;
-    mbytes_recv = (double) test_ptr->stats.stat_bytes_recv / 1024 / 1024;
-    mbytes_rdma_read = (double) test_ptr->stats.stat_bytes_rdma_read / 1024 / 1024;
-    mbytes_rdma_write = (double) test_ptr->stats.stat_bytes_rdma_write / 1024 / 1024;
-    total_ops = test_ptr->cmd->num_ops * test_ptr->cmd->num_iterations;
+	double time;
+	double mbytes_send;
+	double mbytes_recv;
+	double mbytes_rdma_read;
+	double mbytes_rdma_write;
+	int total_ops;
+	time =
+	    (double)(test_ptr->stats.end_time -
+		     test_ptr->stats.start_time) / 1000;
+	mbytes_send = (double)test_ptr->stats.stat_bytes_send / 1024 / 1024;
+	mbytes_recv = (double)test_ptr->stats.stat_bytes_recv / 1024 / 1024;
+	mbytes_rdma_read =
+	    (double)test_ptr->stats.stat_bytes_rdma_read / 1024 / 1024;
+	mbytes_rdma_write =
+	    (double)test_ptr->stats.stat_bytes_rdma_write / 1024 / 1024;
+	total_ops = test_ptr->cmd->num_ops * test_ptr->cmd->num_iterations;
 
-    DT_Tdep_PT_Printf (phead, "Test[: " F64x "] ---- Stats ----\n", test_ptr->base_port);
-    DT_Tdep_PT_Printf (phead, "Iterations : %u\n", test_ptr->cmd->num_iterations);
-    DT_Tdep_PT_Printf (phead, "Ops     : %7d.%02d Ops/Sec\n",
-		whole (total_ops / time),
-		hundredths (total_ops / time));
-    DT_Tdep_PT_Printf (phead, "Time       : %7d.%02d sec\n",
-		whole (time),
-		hundredths (time));
-    DT_Tdep_PT_Printf (phead, "Sent       : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		whole (mbytes_send),
-		hundredths (mbytes_send),
-		whole (mbytes_send / time),
-		hundredths (mbytes_send / time));
-    DT_Tdep_PT_Printf (phead, "Recv       : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		whole (mbytes_recv),
-		hundredths (mbytes_recv),
-		whole (mbytes_recv / time),
-		hundredths (mbytes_recv / time));
-    DT_Tdep_PT_Printf (phead, "RDMA Read  : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		whole (mbytes_rdma_read),
-		hundredths (mbytes_rdma_read),
-		whole (mbytes_rdma_read / time),
-		hundredths (mbytes_rdma_read / time));
-    DT_Tdep_PT_Printf (phead, "RDMA Write : %7d.%02d MB - %7d.%02d MB/Sec\n",
-		whole (mbytes_rdma_write),
-		hundredths (mbytes_rdma_write),
-		whole (mbytes_rdma_write / time),
-		hundredths (mbytes_rdma_write / time));
+	DT_Tdep_PT_Printf(phead, "Test[: " F64x "] ---- Stats ----\n",
+			  test_ptr->base_port);
+	DT_Tdep_PT_Printf(phead, "Iterations : %u\n",
+			  test_ptr->cmd->num_iterations);
+	DT_Tdep_PT_Printf(phead, "Ops     : %7d.%02d Ops/Sec\n",
+			  whole(total_ops / time),
+			  hundredths(total_ops / time));
+	DT_Tdep_PT_Printf(phead, "Time       : %7d.%02d sec\n", whole(time),
+			  hundredths(time));
+	DT_Tdep_PT_Printf(phead, "Sent       : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_send), hundredths(mbytes_send),
+			  whole(mbytes_send / time),
+			  hundredths(mbytes_send / time));
+	DT_Tdep_PT_Printf(phead, "Recv       : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_recv), hundredths(mbytes_recv),
+			  whole(mbytes_recv / time),
+			  hundredths(mbytes_recv / time));
+	DT_Tdep_PT_Printf(phead, "RDMA Read  : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_rdma_read), hundredths(mbytes_rdma_read),
+			  whole(mbytes_rdma_read / time),
+			  hundredths(mbytes_rdma_read / time));
+	DT_Tdep_PT_Printf(phead, "RDMA Write : %7d.%02d MB - %7d.%02d MB/Sec\n",
+			  whole(mbytes_rdma_write),
+			  hundredths(mbytes_rdma_write),
+			  whole(mbytes_rdma_write / time),
+			  hundredths(mbytes_rdma_write / time));
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_transaction_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,767 +34,714 @@
  * Post a recv buffer on each of this thread's EPs.
  */
 bool
-DT_handle_post_recv_buf (DT_Tdep_Print_Head *phead, 
+DT_handle_post_recv_buf(DT_Tdep_Print_Head * phead,
 			Ep_Context_t * ep_context,
-			unsigned int num_eps,
-			int op_indx)
+			unsigned int num_eps, int op_indx)
 {
-    unsigned int    i, j;
+	unsigned int i, j;
 
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t   *op   = &ep_context[i].op[op_indx];
-	DAT_LMR_TRIPLET         *iov  = DT_Bpool_GetIOV (op->bp, 0);
-	DAT_DTO_COOKIE          cookie;
-	DAT_RETURN              ret;
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op = &ep_context[i].op[op_indx];
+		DAT_LMR_TRIPLET *iov = DT_Bpool_GetIOV(op->bp, 0);
+		DAT_DTO_COOKIE cookie;
+		DAT_RETURN ret;
 
-	/* Prep the inputs */
-	for (j = 0;  j < op->num_segs;  j++)
-	{
-	    iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
-					DT_Bpool_GetBuffer (op->bp, j);
-	    iov[j].segment_length  = op->seg_size;
-	    iov[j].lmr_context     = DT_Bpool_GetLMR (op->bp, j);
-	}
-	cookie.as_64  =
-	    ((((DAT_UINT64) i) << 32)
-	     | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0)) & 0xffffffffUL));
+		/* Prep the inputs */
+		for (j = 0; j < op->num_segs; j++) {
+			iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
+			    DT_Bpool_GetBuffer(op->bp, j);
+			iov[j].segment_length = op->seg_size;
+			iov[j].lmr_context = DT_Bpool_GetLMR(op->bp, j);
+		}
+		cookie.as_64 = ((((DAT_UINT64) i) << 32)
+				| (((uintptr_t) DT_Bpool_GetBuffer(op->bp, 0)) &
+				   0xffffffffUL));
 
-	/* Post the recv */
-	ret = dat_ep_post_recv ( ep_context[i].ep_handle,
-				op->num_segs,
-				iov,
-				cookie,
-				DAT_COMPLETION_DEFAULT_FLAG);
+		/* Post the recv */
+		ret = dat_ep_post_recv(ep_context[i].ep_handle,
+				       op->num_segs,
+				       iov,
+				       cookie, DAT_COMPLETION_DEFAULT_FLAG);
 
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: dat_ep_post_recv failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    return false;
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dat_ep_post_recv failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			return false;
+		}
 	}
-    }
 
-    return true;
+	return true;
 }
 
-
 /* -----------------------------------------------------------
  * Post a send buffer on each of this thread's EPs.
  */
 bool
-DT_handle_send_op (DT_Tdep_Print_Head *phead, 
+DT_handle_send_op(DT_Tdep_Print_Head * phead,
 		  Ep_Context_t * ep_context,
-		  DAT_EVD_HANDLE reqt_evd_hdl,
-		  unsigned int num_eps,
-		  int op_indx,
-		  bool poll)
+		  unsigned int num_eps, int op_indx, bool poll)
 {
-    unsigned int    i, j;
-    unsigned char   *completion_reaped;
+	unsigned int i, j;
+	unsigned char *completion_reaped;
 
-    completion_reaped = DT_Mdep_Malloc (num_eps * sizeof (unsigned char));
+	completion_reaped = DT_Mdep_Malloc(num_eps * sizeof(unsigned char));
 
-    if (!completion_reaped)
-    {
-	return false;
-    }
+	if (!completion_reaped) {
+		return false;
+	}
 
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t   *op   = &ep_context[i].op[op_indx];
-	DAT_LMR_TRIPLET         *iov  = DT_Bpool_GetIOV (op->bp, 0);
-	DAT_DTO_COOKIE          cookie;
-	DAT_RETURN              ret;
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op = &ep_context[i].op[op_indx];
+		DAT_LMR_TRIPLET *iov = DT_Bpool_GetIOV(op->bp, 0);
+		DAT_DTO_COOKIE cookie;
+		DAT_RETURN ret;
 
-	/* Prep the inputs */
-	for (j = 0;  j < op->num_segs;  j++)
-	{
-	    iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
-					DT_Bpool_GetBuffer (op->bp, j);
-	    iov[j].segment_length  = op->seg_size;
-	    iov[j].lmr_context     = DT_Bpool_GetLMR (op->bp, j);
-	}
-	cookie.as_64  =
-	    ((((DAT_UINT64) i) << 32)
-	     | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0)) & 0xffffffffUL));
+		/* Prep the inputs */
+		for (j = 0; j < op->num_segs; j++) {
+			iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
+			    DT_Bpool_GetBuffer(op->bp, j);
+			iov[j].segment_length = op->seg_size;
+			iov[j].lmr_context = DT_Bpool_GetLMR(op->bp, j);
+		}
+		cookie.as_64 = ((((DAT_UINT64) i) << 32)
+				| (((uintptr_t) DT_Bpool_GetBuffer(op->bp, 0)) &
+				   0xffffffffUL));
 
-	/* Post the send */
-	ret = dat_ep_post_send ( ep_context[i].ep_handle,
-				op->num_segs,
-				iov,
-				cookie,
-				DAT_COMPLETION_DEFAULT_FLAG);
+		/* Post the send */
+		ret = dat_ep_post_send(ep_context[i].ep_handle,
+				       op->num_segs,
+				       iov,
+				       cookie, DAT_COMPLETION_DEFAULT_FLAG);
 
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: dat_ep_post_send failed: %s\n",
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return false;
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dat_ep_post_send failed: %s\n",
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return false;
+		}
 	}
-    }
 
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t   *op   = &ep_context[i].op[op_indx];
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op = &ep_context[i].op[op_indx];
 
-	if (op->reap_send_on_recv && !op->server_initiated)
-	{
-	    /* we will reap the send on the recv (Client SR) */
-	    DT_Mdep_Free (completion_reaped);
-	    return true;
+		if (op->reap_send_on_recv && !op->server_initiated) {
+			/* we will reap the send on the recv (Client SR) */
+			DT_Mdep_Free(completion_reaped);
+			return true;
+		}
 	}
-    }
 
-    bzero ((void *) completion_reaped, sizeof (unsigned char) * num_eps);
+	bzero((void *)completion_reaped, sizeof(unsigned char) * num_eps);
 
-    /* reap the send completion */
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t   *op;
-	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-	DAT_DTO_COOKIE dto_cookie;
-	unsigned int epnum;
+	/* reap the send completion */
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op;
+		DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+		DAT_DTO_COOKIE dto_cookie;
+		unsigned int epnum;
 
-	if (!DT_dto_event_reap (phead, reqt_evd_hdl, poll, &dto_stat))
-	{
-	    DT_Mdep_Free (completion_reaped);
-	    return false;
-	}
+		if (!DT_dto_event_reap
+		    (phead, ep_context[i].reqt_evd_hdl, poll, &dto_stat)) {
+			DT_Mdep_Free(completion_reaped);
+			return false;
+		}
 
-	epnum = dto_stat.user_cookie.as_64 >> 32;
-	if (epnum > num_eps)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: Send: Invalid endpoint completion reaped.\n"
-			   "\tEndpoint: 0x%p, Cookie: 0x" F64x ", Length: " F64u "\n",
-			   dto_stat.ep_handle, dto_stat.user_cookie.as_64,
-			   dto_stat.transfered_length);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return false;
-	}
+		epnum = dto_stat.user_cookie.as_64 >> 32;
+		if (epnum > num_eps) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: Send: Invalid endpoint completion reaped.\n"
+					  "\tEndpoint: 0x%p, Cookie: 0x" F64x
+					  ", Length: " F64u "\n",
+					  dto_stat.ep_handle,
+					  dto_stat.user_cookie.as_64,
+					  dto_stat.transfered_length);
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return false;
+		}
 
-	op = &ep_context[epnum].op[op_indx];
+		op = &ep_context[epnum].op[op_indx];
 
-	dto_cookie.as_64 =
-	    ((((DAT_UINT64) epnum) << 32)
-	     | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0)) & 0xffffffffUL));
+		dto_cookie.as_64 = ((((DAT_UINT64) epnum) << 32)
+				    |
+				    (((uintptr_t) DT_Bpool_GetBuffer(op->bp, 0))
+				     & 0xffffffffUL));
 
-	if (!DT_dto_check (phead,
-		    	  &dto_stat,
-			  ep_context[epnum].ep_handle,
-			  op->num_segs * op->seg_size,
-			  dto_cookie,
-			  "Send"))
-	{
-	    DT_Mdep_Free (completion_reaped);
-	    return false;
-	}
+		if (!DT_dto_check(phead,
+				  &dto_stat,
+				  ep_context[epnum].ep_handle,
+				  op->num_segs * op->seg_size,
+				  dto_cookie, "Send")) {
+			DT_Mdep_Free(completion_reaped);
+			return false;
+		}
 
-	if (completion_reaped[epnum])
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: Send: Secondary completion seen for endpoint 0x%p (%d)\n",
-			   ep_context[epnum].ep_handle, epnum);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
+		if (completion_reaped[epnum]) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: Send: Secondary completion seen for endpoint 0x%p (%d)\n",
+					  ep_context[epnum].ep_handle, epnum);
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		}
+		completion_reaped[epnum] = 1;
 	}
-	completion_reaped[epnum] = 1;
-    }
 
-    for (i = 0; i < num_eps; i++)
-    {
-	if (completion_reaped[i] == 0)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: Send: No completion seen for endpoint 0x%p (#%d)\n",
-			   ep_context[i].ep_handle, i);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
+	for (i = 0; i < num_eps; i++) {
+		if (completion_reaped[i] == 0) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: Send: No completion seen for endpoint 0x%p (#%d)\n",
+					  ep_context[i].ep_handle, i);
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		}
 	}
-    }
 
-    DT_Mdep_Free (completion_reaped);
-    return true;
+	DT_Mdep_Free(completion_reaped);
+	return true;
 }
 
-
 /* -----------------------------------------------------------
  * Reap a recv op on each of this thread's EPs,
  * then if requested reap the corresponding send ops,
  * and re-post all of the recv buffers.
  */
 bool
-DT_handle_recv_op (DT_Tdep_Print_Head *phead,
+DT_handle_recv_op(DT_Tdep_Print_Head * phead,
 		  Ep_Context_t * ep_context,
-		  DAT_EVD_HANDLE recv_evd_hdl,
-		  DAT_EVD_HANDLE reqt_evd_hdl,
 		  unsigned int num_eps,
-		  int op_indx,
-		  bool poll,
-		  bool repost_recv)
+		  int op_indx, bool poll, bool repost_recv)
 {
-    unsigned int    i;
-    unsigned char   *recv_completion_reaped;
-    unsigned char   *send_completion_reaped;
+	unsigned int i;
+	unsigned char *recv_completion_reaped;
+	unsigned char *send_completion_reaped;
 
-    recv_completion_reaped = DT_Mdep_Malloc (num_eps);
-    if (recv_completion_reaped == NULL)
-    {
-	return false;
-    }
+	recv_completion_reaped = DT_Mdep_Malloc(num_eps);
+	if (recv_completion_reaped == NULL) {
+		return false;
+	}
 
-    send_completion_reaped = DT_Mdep_Malloc (num_eps);
-    if (send_completion_reaped == NULL)
-    {
-	DT_Mdep_Free (recv_completion_reaped);
-	return false;
-    }
+	send_completion_reaped = DT_Mdep_Malloc(num_eps);
+	if (send_completion_reaped == NULL) {
+		DT_Mdep_Free(recv_completion_reaped);
+		return false;
+	}
 
-    /* Foreach EP, reap */
-    bzero ((void *) recv_completion_reaped, sizeof (unsigned char) * num_eps);
-    bzero ((void *) send_completion_reaped, sizeof (unsigned char) * num_eps);
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t   *op;
-	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-	DAT_DTO_COOKIE dto_cookie;
-	unsigned int epnum;
+	/* Foreach EP, reap */
+	bzero((void *)recv_completion_reaped, sizeof(unsigned char) * num_eps);
+	bzero((void *)send_completion_reaped, sizeof(unsigned char) * num_eps);
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op;
+		DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+		DAT_DTO_COOKIE dto_cookie;
+		unsigned int epnum;
 
-	/* First reap the recv DTO event */
-	if (!DT_dto_event_reap (phead, recv_evd_hdl, poll, &dto_stat))
-	{
-	    DT_Mdep_Free (recv_completion_reaped);
-	    DT_Mdep_Free (send_completion_reaped);
-	    return false;
-	}
+		/* First reap the recv DTO event */
+		if (!DT_dto_event_reap
+		    (phead, ep_context[i].recv_evd_hdl, poll, &dto_stat)) {
+			DT_Mdep_Free(recv_completion_reaped);
+			DT_Mdep_Free(send_completion_reaped);
+			return false;
+		}
 
-	epnum = dto_stat.user_cookie.as_64 >> 32;
-	if (epnum > num_eps)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: Receive: Invalid endpoint completion reaped.\n"
-			   "\tEndpoint: 0x%p, Cookie: 0x" F64x ", Length: " F64u "\n",
-			   dto_stat.ep_handle, dto_stat.user_cookie.as_64,
-			   dto_stat.transfered_length);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (recv_completion_reaped);
-	    DT_Mdep_Free (send_completion_reaped);
-	    return false;
-	}
+		epnum = dto_stat.user_cookie.as_64 >> 32;
+		if (epnum > num_eps) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: Receive: Invalid endpoint completion reaped.\n"
+					  "\tEndpoint: 0x%p, Cookie: 0x" F64x
+					  ", Length: " F64u "\n",
+					  dto_stat.ep_handle,
+					  dto_stat.user_cookie.as_64,
+					  dto_stat.transfered_length);
+			DT_Test_Error();
+			DT_Mdep_Free(recv_completion_reaped);
+			DT_Mdep_Free(send_completion_reaped);
+			return false;
+		}
 
-	op = &ep_context[epnum].op[op_indx];
-	dto_cookie.as_64 =
-	    ((((DAT_UINT64) epnum) << 32)
-	     | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0)) & 0xffffffffUL));
+		op = &ep_context[epnum].op[op_indx];
+		dto_cookie.as_64 = ((((DAT_UINT64) epnum) << 32)
+				    |
+				    (((uintptr_t) DT_Bpool_GetBuffer(op->bp, 0))
+				     & 0xffffffffUL));
 
-	if (!DT_dto_check (phead,
-		    	   &dto_stat,
-			  ep_context[epnum].ep_handle,
-			  op->num_segs * op->seg_size,
-			  dto_cookie,
-			  "Recv"))
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: recv DTO problem\n");
-	    DT_Test_Error ();
-	    DT_Mdep_Free (recv_completion_reaped);
-	    DT_Mdep_Free (send_completion_reaped);
-	    return false;
-	}
+		if (!DT_dto_check(phead,
+				  &dto_stat,
+				  ep_context[epnum].ep_handle,
+				  op->num_segs * op->seg_size,
+				  dto_cookie, "Recv")) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: recv DTO problem\n");
+			DT_Test_Error();
+			DT_Mdep_Free(recv_completion_reaped);
+			DT_Mdep_Free(send_completion_reaped);
+			return false;
+		}
 
-	if (recv_completion_reaped[epnum])
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: Receive: Secondary completion seen for endpoint 0x%p (%d)\n",
-			   ep_context[epnum].ep_handle, epnum);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (recv_completion_reaped);
-	    DT_Mdep_Free (send_completion_reaped);
-	    return ( false );
-	}
-	recv_completion_reaped[epnum] = 1;
+		if (recv_completion_reaped[epnum]) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: Receive: Secondary completion seen for endpoint 0x%p (%d)\n",
+					  ep_context[epnum].ep_handle, epnum);
+			DT_Test_Error();
+			DT_Mdep_Free(recv_completion_reaped);
+			DT_Mdep_Free(send_completion_reaped);
+			return (false);
+		}
+		recv_completion_reaped[epnum] = 1;
 
-	/*
-	 * Check the current op to see whether we are supposed
-	 * to reap the previous send op now.
-	 */
-	if (op->reap_send_on_recv && op->server_initiated)
-	{
-	    if (op_indx <= 0)
-	    /* shouldn't happen, but let's be certain */
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				"Internal Error: reap_send_on_recv"
-				" but current op == #%d\n", op_indx);
-		DT_Mdep_Free (recv_completion_reaped);
-		DT_Mdep_Free (send_completion_reaped);
-		return false;
-	    }
+		/*
+		 * Check the current op to see whether we are supposed
+		 * to reap the previous send op now.
+		 */
+		if (op->reap_send_on_recv && op->server_initiated) {
+			if (op_indx <= 0)
+				/* shouldn't happen, but let's be certain */
+			{
+				DT_Tdep_PT_Printf(phead,
+						  "Internal Error: reap_send_on_recv"
+						  " but current op == #%d\n",
+						  op_indx);
+				DT_Mdep_Free(recv_completion_reaped);
+				DT_Mdep_Free(send_completion_reaped);
+				return false;
+			}
 
-	    if (!DT_dto_event_reap (phead, reqt_evd_hdl, poll, &dto_stat))
-	    {
-		DT_Mdep_Free (recv_completion_reaped);
-		DT_Mdep_Free (send_completion_reaped);
-		return false;
-	    }
+			if (!DT_dto_event_reap
+			    (phead, ep_context[i].reqt_evd_hdl, poll,
+			     &dto_stat)) {
+				DT_Mdep_Free(recv_completion_reaped);
+				DT_Mdep_Free(send_completion_reaped);
+				return false;
+			}
 
-	    epnum = dto_stat.user_cookie.as_64 >> 32;
-	    if (epnum > num_eps)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				"Test Error: Send (ror): Invalid endpoint completion reaped.\n"
-			       "\tEndpoint: 0x%p, Cookie: 0x" F64x ", Length: "F64u "\n",
-			       dto_stat.ep_handle, dto_stat.user_cookie.as_64,
-			       dto_stat.transfered_length);
-		DT_Test_Error ();
-		DT_Mdep_Free (recv_completion_reaped);
-		DT_Mdep_Free (send_completion_reaped);
-		return false;
-	    }
+			epnum = dto_stat.user_cookie.as_64 >> 32;
+			if (epnum > num_eps) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test Error: Send (ror): Invalid endpoint completion reaped.\n"
+						  "\tEndpoint: 0x%p, Cookie: 0x"
+						  F64x ", Length: " F64u "\n",
+						  dto_stat.ep_handle,
+						  dto_stat.user_cookie.as_64,
+						  dto_stat.transfered_length);
+				DT_Test_Error();
+				DT_Mdep_Free(recv_completion_reaped);
+				DT_Mdep_Free(send_completion_reaped);
+				return false;
+			}
 
-	    /*
-	     * We're reaping the last transaction, a
-	     * send completion that we skipped when it was sent.
-	     */
-	    op = &ep_context[epnum].op[op_indx - 1];
+			/*
+			 * We're reaping the last transaction, a
+			 * send completion that we skipped when it was sent.
+			 */
+			op = &ep_context[epnum].op[op_indx - 1];
 
-	    dto_cookie.as_64 =
-		((((DAT_UINT64) epnum) << 32)
-		 | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0))
-		    & 0xffffffffUL));
+			dto_cookie.as_64 = ((((DAT_UINT64) epnum) << 32)
+					    |
+					    (((uintptr_t)
+					      DT_Bpool_GetBuffer(op->bp, 0))
+					     & 0xffffffffUL));
 
-	    /*
-	     * If we have multiple EPs we can't guarantee the order of
-	     * completions, so disable ep_handle check
-	     */
-	    if (!DT_dto_check (phead, 
-			      &dto_stat,
-			      num_eps == 1?ep_context[i].ep_handle: NULL,
-			      op->num_segs * op->seg_size,
-			      dto_cookie,
-			      "Send-reaped-on-recv"))
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				"Test Error: send DTO problem\n");
-		DT_Test_Error ();
-		DT_Mdep_Free (recv_completion_reaped);
-		DT_Mdep_Free (send_completion_reaped);
-		return false;
-	    }
+			/*
+			 * If we have multiple EPs we can't guarantee the order of
+			 * completions, so disable ep_handle check
+			 */
+			if (!DT_dto_check(phead,
+					  &dto_stat,
+					  num_eps ==
+					  1 ? ep_context[i].ep_handle : NULL,
+					  op->num_segs * op->seg_size,
+					  dto_cookie, "Send-reaped-on-recv")) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test Error: send DTO problem\n");
+				DT_Test_Error();
+				DT_Mdep_Free(recv_completion_reaped);
+				DT_Mdep_Free(send_completion_reaped);
+				return false;
+			}
 
-	    if (send_completion_reaped[epnum])
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				"Test Error: Send (ror): Secondary completion seen for endpoint 0x%p (%d)\n",
-			       ep_context[epnum].ep_handle, epnum);
-		DT_Test_Error ();
-		DT_Mdep_Free (recv_completion_reaped);
-		DT_Mdep_Free (send_completion_reaped);
-		return ( false );
-	    }
-	    send_completion_reaped[epnum] = 1;
+			if (send_completion_reaped[epnum]) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test Error: Send (ror): Secondary completion seen for endpoint 0x%p (%d)\n",
+						  ep_context[epnum].ep_handle,
+						  epnum);
+				DT_Test_Error();
+				DT_Mdep_Free(recv_completion_reaped);
+				DT_Mdep_Free(send_completion_reaped);
+				return (false);
+			}
+			send_completion_reaped[epnum] = 1;
+		}
 	}
-    }
 
-    for (i = 0; i < num_eps; i++)
-    {
-	if (recv_completion_reaped[i] == 0)
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: Receive: No completion seen for endpoint 0x%p (#%d)\n",
-			   ep_context[i].ep_handle, i);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (recv_completion_reaped);
-	    DT_Mdep_Free (send_completion_reaped);
-	    return ( false );
+	for (i = 0; i < num_eps; i++) {
+		if (recv_completion_reaped[i] == 0) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: Receive: No completion seen for endpoint 0x%p (#%d)\n",
+					  ep_context[i].ep_handle, i);
+			DT_Test_Error();
+			DT_Mdep_Free(recv_completion_reaped);
+			DT_Mdep_Free(send_completion_reaped);
+			return (false);
+		}
 	}
-    }
 
-    if (ep_context[0].op[op_indx].reap_send_on_recv
-	&& ep_context[0].op[op_indx].server_initiated)
-    {
-	for (i = 0; i < num_eps; i++)
-	{
-	    if (send_completion_reaped[i] == 0)
-	    {
-		DT_Tdep_PT_Printf (phead, 
-				"Test Error: Send (ror): No completion seen for endpoint 0x%p (#%d)\n",
-			       ep_context[i].ep_handle, i);
-		DT_Test_Error ();
-		DT_Mdep_Free (recv_completion_reaped);
-		DT_Mdep_Free (send_completion_reaped);
-		return ( false );
-	    }
+	if (ep_context[0].op[op_indx].reap_send_on_recv
+	    && ep_context[0].op[op_indx].server_initiated) {
+		for (i = 0; i < num_eps; i++) {
+			if (send_completion_reaped[i] == 0) {
+				DT_Tdep_PT_Printf(phead,
+						  "Test Error: Send (ror): No completion seen for endpoint 0x%p (#%d)\n",
+						  ep_context[i].ep_handle, i);
+				DT_Test_Error();
+				DT_Mdep_Free(recv_completion_reaped);
+				DT_Mdep_Free(send_completion_reaped);
+				return (false);
+			}
+		}
 	}
-    }
 
-    if (repost_recv)
-    {
-	/* repost the receive buffer */
-	if (!DT_handle_post_recv_buf (phead, ep_context, num_eps, op_indx))
-	{
-	    DT_Tdep_PT_Printf (phead, 
-		    	"Test Error: recv re-post problem\n");
-	    DT_Test_Error ();
-	    DT_Mdep_Free (recv_completion_reaped);
-	    DT_Mdep_Free (send_completion_reaped);
-	    return false;
+	if (repost_recv) {
+		/* repost the receive buffer */
+		if (!DT_handle_post_recv_buf
+		    (phead, ep_context, num_eps, op_indx)) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: recv re-post problem\n");
+			DT_Test_Error();
+			DT_Mdep_Free(recv_completion_reaped);
+			DT_Mdep_Free(send_completion_reaped);
+			return false;
+		}
 	}
-    }
 
-    DT_Mdep_Free (recv_completion_reaped);
-    DT_Mdep_Free (send_completion_reaped);
-    return true;
+	DT_Mdep_Free(recv_completion_reaped);
+	DT_Mdep_Free(send_completion_reaped);
+	return true;
 }
 
-
 /* -----------------------------------------------------------
  * Initiate an RDMA op (synchronous) on each of this thread's EPs.
  */
 bool
-DT_handle_rdma_op (DT_Tdep_Print_Head *phead,
+DT_handle_rdma_op(DT_Tdep_Print_Head * phead,
 		  Ep_Context_t * ep_context,
-		  DAT_EVD_HANDLE reqt_evd_hdl,
 		  unsigned int num_eps,
-		  DT_Transfer_Type opcode,
-		  int op_indx,
-		  bool poll)
+		  DT_Transfer_Type opcode, int op_indx, bool poll)
 {
-    unsigned int    i, j;
-    DAT_RETURN      ret;
-    unsigned char   *completion_reaped;
+	unsigned int i, j;
+	DAT_RETURN ret;
+	unsigned char *completion_reaped;
 
-    completion_reaped = DT_Mdep_Malloc (num_eps * sizeof (unsigned char));
+	completion_reaped = DT_Mdep_Malloc(num_eps * sizeof(unsigned char));
 
-    if (!completion_reaped)
-    {
-	return false;
-    }
+	if (!completion_reaped) {
+		return false;
+	}
 
-    /* Initiate the operation */
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t   *op = &ep_context[i].op[op_indx];
-	DAT_LMR_TRIPLET         *iov  = DT_Bpool_GetIOV (op->bp, 0);
-	DAT_DTO_COOKIE          cookie;
-	DAT_RMR_TRIPLET         rmr_triplet;
+	/* Initiate the operation */
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op = &ep_context[i].op[op_indx];
+		DAT_LMR_TRIPLET *iov = DT_Bpool_GetIOV(op->bp, 0);
+		DAT_DTO_COOKIE cookie;
+		DAT_RMR_TRIPLET rmr_triplet;
 
-	/* Prep the inputs */
-	for (j = 0;  j < op->num_segs;  j++)
-	{
-	    iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
-					DT_Bpool_GetBuffer (op->bp, j);
-	    iov[j].segment_length  = op->seg_size;
-	    iov[j].lmr_context     = DT_Bpool_GetLMR (op->bp, j);
-	}
-	cookie.as_64  =
-	    ((((DAT_UINT64) i) << 32)
-	     | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0)) & 0xffffffffUL));
+		/* Prep the inputs */
+		for (j = 0; j < op->num_segs; j++) {
+			iov[j].virtual_address = (DAT_VADDR) (uintptr_t)
+			    DT_Bpool_GetBuffer(op->bp, j);
+			iov[j].segment_length = op->seg_size;
+			iov[j].lmr_context = DT_Bpool_GetLMR(op->bp, j);
+		}
+		cookie.as_64 = ((((DAT_UINT64) i) << 32)
+				| (((uintptr_t) DT_Bpool_GetBuffer(op->bp, 0)) &
+				   0xffffffffUL));
 
-	rmr_triplet.virtual_address  = (DAT_VADDR) (uintptr_t) op->Rdma_Address;
-	rmr_triplet.segment_length  = op->seg_size * op->num_segs;
-	rmr_triplet.rmr_context     = op->Rdma_Context;
+		rmr_triplet.virtual_address =
+		    (DAT_VADDR) (uintptr_t) op->Rdma_Address;
+		rmr_triplet.segment_length = op->seg_size * op->num_segs;
+		rmr_triplet.rmr_context = op->Rdma_Context;
 
-	DT_Tdep_PT_Debug (3, (phead,
-		"Call dat_ep_post_rdma_%s [" F64x ", sz=" F64x ", ctxt=%x]\n",
-		(opcode == RDMA_WRITE ? "write" : "read"),
-		rmr_triplet.virtual_address,
-		rmr_triplet.segment_length,
-		rmr_triplet.rmr_context ));
+		DT_Tdep_PT_Debug(3, (phead,
+				     "Call dat_ep_post_rdma_%s [" F64x ", sz="
+				     F64x ", ctxt=%x]\n",
+				     (opcode == RDMA_WRITE ? "write" : "read"),
+				     rmr_triplet.virtual_address,
+				     rmr_triplet.segment_length,
+				     rmr_triplet.rmr_context));
 
-	/* Post the operation */
-	if (opcode == RDMA_WRITE)
-	{
+		/* Post the operation */
+		if (opcode == RDMA_WRITE) {
 
-	    ret = dat_ep_post_rdma_write (ep_context[i].ep_handle,
-					 op->num_segs,
-					 iov,
-					 cookie,
-					 &rmr_triplet,
-					 DAT_COMPLETION_DEFAULT_FLAG);
+			ret = dat_ep_post_rdma_write(ep_context[i].ep_handle,
+						     op->num_segs,
+						     iov,
+						     cookie,
+						     &rmr_triplet,
+						     DAT_COMPLETION_DEFAULT_FLAG);
 
-	}
-	else /* opcode == RDMA_READ */
-	{
+		} else {	/* opcode == RDMA_READ */
 
-	    ret = dat_ep_post_rdma_read ( ep_context[i].ep_handle,
-					 op->num_segs,
-					 iov,
-					 cookie,
-					 &rmr_triplet,
-					 DAT_COMPLETION_DEFAULT_FLAG);
+			ret = dat_ep_post_rdma_read(ep_context[i].ep_handle,
+						    op->num_segs,
+						    iov,
+						    cookie,
+						    &rmr_triplet,
+						    DAT_COMPLETION_DEFAULT_FLAG);
 
+		}
+		if (ret != DAT_SUCCESS) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: dat_ep_post_rdma_%s failed: %s\n",
+					  (opcode ==
+					   RDMA_WRITE ? "write" : "read"),
+					  DT_RetToString(ret));
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		} else {
+			DT_Tdep_PT_Debug(3, (phead,
+					     "Done dat_ep_post_rdma_%s %s\n",
+					     (opcode ==
+					      RDMA_WRITE ? "write" : "read"),
+					     " ()  Waiting ..."));
+		}
 	}
-	if (ret != DAT_SUCCESS)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: dat_ep_post_rdma_%s failed: %s\n",
-			(opcode == RDMA_WRITE ? "write" : "read"),
-			DT_RetToString (ret));
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
-	}
-	else
-	{
-	    DT_Tdep_PT_Debug (3, (phead,
-			"Done dat_ep_post_rdma_%s %s\n",
-			(opcode == RDMA_WRITE ? "write" : "read"),
-			" ()  Waiting ..."));
-	}
-    }
 
-    bzero ((void *) completion_reaped, sizeof (unsigned char) * num_eps);
-    /* Wait for it to happen */
-    for (i = 0;  i < num_eps;  i++)
-    {
-	Transaction_Test_Op_t *op;
-	DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
-	DAT_DTO_COOKIE dto_cookie;
-	unsigned int epnum;
+	bzero((void *)completion_reaped, sizeof(unsigned char) * num_eps);
+	/* Wait for it to happen */
+	for (i = 0; i < num_eps; i++) {
+		Transaction_Test_Op_t *op;
+		DAT_DTO_COMPLETION_EVENT_DATA dto_stat;
+		DAT_DTO_COOKIE dto_cookie;
+		unsigned int epnum;
 
-	if (!DT_dto_event_reap (phead, reqt_evd_hdl, poll, &dto_stat))
-	{
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
-	}
+		if (!DT_dto_event_reap
+		    (phead, ep_context[i].reqt_evd_hdl, poll, &dto_stat)) {
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		}
 
-	epnum = dto_stat.user_cookie.as_64 >> 32;
-	if (epnum > num_eps)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: %s: Invalid endpoint completion reaped.\n"
-			   "\tEndpoint: 0x%p, Cookie: 0x" F64x ", Length: " F64u "\n",
-			   opcode == RDMA_WRITE ? "RDMA/WR" : "RDMA/RD",
-			   dto_stat.ep_handle, dto_stat.user_cookie.as_64,
-			   dto_stat.transfered_length);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return false;
-	}
-	op = &ep_context[epnum].op[op_indx];
+		epnum = dto_stat.user_cookie.as_64 >> 32;
+		if (epnum > num_eps) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: %s: Invalid endpoint completion reaped.\n"
+					  "\tEndpoint: 0x%p, Cookie: 0x" F64x
+					  ", Length: " F64u "\n",
+					  opcode ==
+					  RDMA_WRITE ? "RDMA/WR" : "RDMA/RD",
+					  dto_stat.ep_handle,
+					  dto_stat.user_cookie.as_64,
+					  dto_stat.transfered_length);
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return false;
+		}
+		op = &ep_context[epnum].op[op_indx];
 
-	dto_cookie.as_64 =
-	    ((((DAT_UINT64) epnum) << 32)
-	     | (((uintptr_t) DT_Bpool_GetBuffer (op->bp, 0)) & 0xffffffffUL));
+		dto_cookie.as_64 = ((((DAT_UINT64) epnum) << 32)
+				    |
+				    (((uintptr_t) DT_Bpool_GetBuffer(op->bp, 0))
+				     & 0xffffffffUL));
 
-	if (!DT_dto_check (phead, 
-		    	    &dto_stat,
-			    ep_context[epnum].ep_handle,
-			    op->num_segs * op->seg_size,
-			    dto_cookie,
-			    (opcode == RDMA_WRITE ? "RDMA/WR" : "RDMA/RD")))
-	{
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
-	}
+		if (!DT_dto_check(phead,
+				  &dto_stat,
+				  ep_context[epnum].ep_handle,
+				  op->num_segs * op->seg_size,
+				  dto_cookie,
+				  (opcode ==
+				   RDMA_WRITE ? "RDMA/WR" : "RDMA/RD"))) {
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		}
 
-	if (completion_reaped[epnum])
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: %s: Secondary completion seen for endpoint 0x%p (%d)\n",
-			   opcode == RDMA_WRITE ? "RDMA/WR" : "RDMA/RD",
-			   ep_context[epnum].ep_handle, epnum);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
+		if (completion_reaped[epnum]) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: %s: Secondary completion seen for endpoint 0x%p (%d)\n",
+					  opcode ==
+					  RDMA_WRITE ? "RDMA/WR" : "RDMA/RD",
+					  ep_context[epnum].ep_handle, epnum);
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		}
+		completion_reaped[epnum] = 1;
+
+		DT_Tdep_PT_Debug(3, (phead,
+				     "dat_ep_post_rdma_%s OK\n",
+				     (opcode ==
+				      RDMA_WRITE ? "RDMA/WR" : "RDMA/RD")));
 	}
-	completion_reaped[epnum] = 1;
 
-	DT_Tdep_PT_Debug (3, (phead, 
-		    	 "dat_ep_post_rdma_%s OK\n",
-			 (opcode == RDMA_WRITE ? "RDMA/WR" : "RDMA/RD")));
-    }
-
-    for (i = 0; i < num_eps; i++)
-    {
-	if (completion_reaped[i] == 0)
-	{
-	    DT_Tdep_PT_Printf (phead, "Test Error: %s: No completion seen for endpoint 0x%p (#%d)\n",
-			   opcode == RDMA_WRITE ? "RDMA/WR" : "RDMA/RD",
-			   ep_context[i].ep_handle, i);
-	    DT_Test_Error ();
-	    DT_Mdep_Free (completion_reaped);
-	    return ( false );
+	for (i = 0; i < num_eps; i++) {
+		if (completion_reaped[i] == 0) {
+			DT_Tdep_PT_Printf(phead,
+					  "Test Error: %s: No completion seen for endpoint 0x%p (#%d)\n",
+					  opcode ==
+					  RDMA_WRITE ? "RDMA/WR" : "RDMA/RD",
+					  ep_context[i].ep_handle, i);
+			DT_Test_Error();
+			DT_Mdep_Free(completion_reaped);
+			return (false);
+		}
 	}
-    }
 
-    DT_Mdep_Free (completion_reaped);
+	DT_Mdep_Free(completion_reaped);
 
-    return ( true );
+	return (true);
 }
 
-
 /* -----------------------------------------------------------
  * Verify whether we (the client side) can support
  * the requested 'T' test.
  */
-bool
-DT_check_params (Per_Test_Data_t  *pt_ptr,
-		 char 		  *module)
+bool DT_check_params(Per_Test_Data_t * pt_ptr, char *module)
 {
-    Transaction_Cmd_t * cmd	    = &pt_ptr->Params.u.Transaction_Cmd;
-    unsigned long	num_recvs   = 0U;
-    unsigned long	num_sends   = 0U;
-    unsigned long	num_rdma_rd = 0U;
-    unsigned long	num_rdma_wr = 0U;
-    unsigned long	max_size    = 0U;
-    unsigned long	max_segs    = 0U;
-    bool		rval	    = true;
-    unsigned int	i;
-    DT_Tdep_Print_Head *phead;
+	Transaction_Cmd_t *cmd = &pt_ptr->Params.u.Transaction_Cmd;
+	unsigned long num_recvs = 0U;
+	unsigned long num_sends = 0U;
+	unsigned long num_rdma_rd = 0U;
+	unsigned long num_rdma_wr = 0U;
+	unsigned long max_size = 0U;
+	unsigned long max_segs = 0U;
+	bool rval = true;
+	unsigned int i;
+	DT_Tdep_Print_Head *phead;
 
-    phead = pt_ptr->Params.phead;
+	phead = pt_ptr->Params.phead;
 
-    /* Count up what's requested (including -V appended sync points) */
-    for (i = 0;  i < cmd->num_ops;  i++)
-    {
-	unsigned int	xfer_size;
+	/* Count up what's requested (including -V appended sync points) */
+	for (i = 0; i < cmd->num_ops; i++) {
+		unsigned int xfer_size;
 
-	xfer_size = cmd->op[i].num_segs * cmd->op[i].seg_size;
-	if (xfer_size > max_size)
-	{
-	    max_size = xfer_size;
-	}
-	if (cmd->op[i].num_segs > max_segs)
-	{
-	    max_segs = cmd->op[i].num_segs;
-	}
-
-	switch (cmd->op[i].transfer_type)
-	{
-	    case SEND_RECV:
-	    {
-		if (cmd->op[i].server_initiated)
-		{
-		    num_recvs++;
+		xfer_size = cmd->op[i].num_segs * cmd->op[i].seg_size;
+		if (xfer_size > max_size) {
+			max_size = xfer_size;
 		}
-		else
-		{
-		    num_sends++;
+		if (cmd->op[i].num_segs > max_segs) {
+			max_segs = cmd->op[i].num_segs;
 		}
-		break;
-	    }
 
-	    case RDMA_READ:
-	    {
-		num_rdma_rd++;
-		break;
-	    }
+		switch (cmd->op[i].transfer_type) {
+		case SEND_RECV:
+			{
+				if (cmd->op[i].server_initiated) {
+					num_recvs++;
+				} else {
+					num_sends++;
+				}
+				break;
+			}
 
-	    case RDMA_WRITE:
-	    {
-		num_rdma_wr++;
-		break;
-	    }
+		case RDMA_READ:
+			{
+				num_rdma_rd++;
+				break;
+			}
+
+		case RDMA_WRITE:
+			{
+				num_rdma_wr++;
+				break;
+			}
+		}
 	}
-    }
 
-    /*
-     * Now check the IA and EP attributes, and check for some of the
-     * more obvious resource problems.  This is hardly exhaustive,
-     * and some things will inevitably fall through to run-time.
-     *
-     * We don't compare
-     *	    num_rdma_rd > pt_ptr->ia_attr.max_rdma_read_per_ep
-     *	    num_rdma_wr > pt_ptr->ia_attr.max_dto_per_ep
-     * because each thread has its own EPs, and transfers are issued
-     * synchronously (across a thread's EPs, and ignoring -f, which allows
-     * a per-EP pipeline depth of at most 2 and applies only to SR ops),
-     * so dapltest actually attempts almost no pipelining on a single EP.
-     * But we do check that pre-posted recv buffers will all fit.
-     */
-    if (num_recvs > pt_ptr->ia_attr.max_dto_per_ep ||
-	num_sends > pt_ptr->ia_attr.max_dto_per_ep)
-    {
-	DT_Tdep_PT_Printf (
-			phead, 
-			"%s: S/R: cannot supply %ld SR ops (maximum: %d)\n",
-			module,
-			num_recvs > num_sends ? num_recvs : num_sends,
-			pt_ptr->ia_attr.max_dto_per_ep);
-	rval = false;
-    }
-    if (max_size > pt_ptr->ia_attr.max_lmr_block_size)
-    {
-	DT_Tdep_PT_Printf (
-			phead,
-			"%s: buffer too large: 0x%lx (maximum: " F64x " bytes)\n",
-			module,
-			max_size,
-			pt_ptr->ia_attr.max_lmr_block_size);
-	rval = false;
-    }
-    if (max_segs > pt_ptr->ep_attr.max_recv_iov ||
-	max_segs > pt_ptr->ep_attr.max_request_iov)
-    {
 	/*
-	 * In an ideal world, we'd just ask for more segments
-	 * when creating the EPs for the test, rather than
-	 * checking against default EP attributes.
+	 * Now check the IA and EP attributes, and check for some of the
+	 * more obvious resource problems.  This is hardly exhaustive,
+	 * and some things will inevitably fall through to run-time.
+	 *
+	 * We don't compare
+	 *      num_rdma_rd > pt_ptr->ia_attr.max_rdma_read_per_ep
+	 *      num_rdma_wr > pt_ptr->ia_attr.max_dto_per_ep
+	 * because each thread has its own EPs, and transfers are issued
+	 * synchronously (across a thread's EPs, and ignoring -f, which allows
+	 * a per-EP pipeline depth of at most 2 and applies only to SR ops),
+	 * so dapltest actually attempts almost no pipelining on a single EP.
+	 * But we do check that pre-posted recv buffers will all fit.
 	 */
-	DT_Tdep_PT_Printf (
-			phead,
-			"%s: cannot use %ld segments (maxima: S %d, R %d)\n",
-			module,
-			max_segs,
-			pt_ptr->ep_attr.max_request_iov,
-			pt_ptr->ep_attr.max_recv_iov );
-	rval = false;
-    }
+	if (num_recvs > pt_ptr->ia_attr.max_dto_per_ep ||
+	    num_sends > pt_ptr->ia_attr.max_dto_per_ep) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: S/R: cannot supply %ld SR ops (maximum: %d)\n",
+				  module,
+				  num_recvs > num_sends ? num_recvs : num_sends,
+				  pt_ptr->ia_attr.max_dto_per_ep);
+		rval = false;
+	}
+	if (max_size > pt_ptr->ia_attr.max_lmr_block_size) {
+		DT_Tdep_PT_Printf(phead,
+				  "%s: buffer too large: 0x%lx (maximum: " F64x
+				  " bytes)\n", module, max_size,
+				  pt_ptr->ia_attr.max_lmr_block_size);
+		rval = false;
+	}
+	if (max_segs > pt_ptr->ep_attr.max_recv_iov ||
+	    max_segs > pt_ptr->ep_attr.max_request_iov) {
+		/*
+		 * In an ideal world, we'd just ask for more segments
+		 * when creating the EPs for the test, rather than
+		 * checking against default EP attributes.
+		 */
+		DT_Tdep_PT_Printf(phead,
+				  "%s: cannot use %ld segments (maxima: S %d, R %d)\n",
+				  module,
+				  max_segs,
+				  pt_ptr->ep_attr.max_request_iov,
+				  pt_ptr->ep_attr.max_recv_iov);
+		rval = false;
+	}
 
-    return ( rval );
+	return (rval);
 }
 
 /* Empty function in which to set breakpoints.  */
-void
-DT_Test_Error (void)
+void DT_Test_Error(void)
 {
-    ;
+	;
 }
 
 void
-DT_Transaction_Cmd_PT_Print (DT_Tdep_Print_Head *phead, Transaction_Cmd_t * cmd)
+DT_Transaction_Cmd_PT_Print(DT_Tdep_Print_Head * phead, Transaction_Cmd_t * cmd)
 {
-    unsigned int    i;
-    DT_Tdep_PT_Printf (phead, "-------------------------------------\n");
-    DT_Tdep_PT_Printf (phead, "TransCmd.server_name              : %s\n",
-		cmd->server_name);
-    DT_Tdep_PT_Printf (phead, "TransCmd.num_iterations           : %d\n",
-		cmd->num_iterations);
-    DT_Tdep_PT_Printf (phead, "TransCmd.num_threads              : %d\n",
-		cmd->num_threads);
-    DT_Tdep_PT_Printf (phead, "TransCmd.eps_per_thread           : %d\n",
-		cmd->eps_per_thread);
-    DT_Tdep_PT_Printf (phead, "TransCmd.validate                 : %d\n",
-		cmd->validate);
-    DT_Tdep_PT_Printf (phead, "TransCmd.dapl_name                : %s\n",
-		cmd->dapl_name);
-    DT_Tdep_PT_Printf (phead, "TransCmd.num_ops                  : %d\n",
-		cmd->num_ops);
+	unsigned int i;
+	DT_Tdep_PT_Printf(phead, "-------------------------------------\n");
+	DT_Tdep_PT_Printf(phead, "TransCmd.server_name              : %s\n",
+			  cmd->server_name);
+	DT_Tdep_PT_Printf(phead, "TransCmd.num_iterations           : %d\n",
+			  cmd->num_iterations);
+	DT_Tdep_PT_Printf(phead, "TransCmd.num_threads              : %d\n",
+			  cmd->num_threads);
+	DT_Tdep_PT_Printf(phead, "TransCmd.eps_per_thread           : %d\n",
+			  cmd->eps_per_thread);
+	DT_Tdep_PT_Printf(phead, "TransCmd.validate                 : %d\n",
+			  cmd->validate);
+	DT_Tdep_PT_Printf(phead, "TransCmd.dapl_name                : %s\n",
+			  cmd->dapl_name);
+	DT_Tdep_PT_Printf(phead, "TransCmd.num_ops                  : %d\n",
+			  cmd->num_ops);
 
-    for (i = 0; i < cmd->num_ops; i++)
-    {
-	DT_Tdep_PT_Printf (phead, "TransCmd.op[%d].transfer_type      : %s %s\n",
-		    i,
-		    cmd->op[i].transfer_type == 0 ? "RDMA_READ" :
-		    cmd->op[i].transfer_type == 1 ? "RDMA_WRITE" :
-		    "SEND_RECV",
-		    cmd->op[i].server_initiated ? " (server)" : " (client)" );
-	DT_Tdep_PT_Printf (phead, "TransCmd.op[%d].seg_size           : %d\n",
-		    i,
-		    cmd->op[i].seg_size);
-	DT_Tdep_PT_Printf (phead, "TransCmd.op[%d].num_segs           : %d\n",
-		    i,
-		    cmd->op[i].num_segs);
-	DT_Tdep_PT_Printf (phead, "TransCmd.op[%d].reap_send_on_recv  : %d\n",
-		    i,
-		    cmd->op[i].reap_send_on_recv);
-    }
+	for (i = 0; i < cmd->num_ops; i++) {
+		DT_Tdep_PT_Printf(phead,
+				  "TransCmd.op[%d].transfer_type      : %s %s\n",
+				  i,
+				  cmd->op[i].transfer_type ==
+				  0 ? "RDMA_READ" : cmd->op[i].transfer_type ==
+				  1 ? "RDMA_WRITE" : "SEND_RECV",
+				  cmd->op[i].
+				  server_initiated ? " (server)" : " (client)");
+		DT_Tdep_PT_Printf(phead,
+				  "TransCmd.op[%d].seg_size           : %d\n",
+				  i, cmd->op[i].seg_size);
+		DT_Tdep_PT_Printf(phead,
+				  "TransCmd.op[%d].num_segs           : %d\n",
+				  i, cmd->op[i].num_segs);
+		DT_Tdep_PT_Printf(phead,
+				  "TransCmd.op[%d].reap_send_on_recv  : %d\n",
+				  i, cmd->op[i].reap_send_on_recv);
+	}
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_util.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_util.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/test/dapl_util.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -34,214 +34,186 @@
  * Map DAT_RETURN values to readable strings,
  * but don't assume the values are zero-based or contiguous.
  */
-const char *
-DT_RetToString (DAT_RETURN ret_value)
+const char *DT_RetToString(DAT_RETURN ret_value)
 {
-    const char *major_msg, *minor_msg;
-    int sz;
-    char *errmsg;
+	const char *major_msg, *minor_msg;
+	int sz;
+	char *errmsg;
 
-    dat_strerror (ret_value, &major_msg, &minor_msg);
+	dat_strerror(ret_value, &major_msg, &minor_msg);
 
-    sz = strlen (major_msg) + strlen (minor_msg) + 2;
+	sz = strlen(major_msg) + strlen(minor_msg) + 2;
 /*
  * FIXME: The callers of this function are not freeing
  * the errmsg string. Hence there is a memory leak 
  * (this function is likely only used on error paths, 
  *  so the consequences may not be that dire).
  */
-    errmsg = DT_Mdep_Malloc (sz);
-    strcpy (errmsg, major_msg);
-    strcat (errmsg, " ");
-    strcat (errmsg, minor_msg);
+	errmsg = DT_Mdep_Malloc(sz);
+	strcpy(errmsg, major_msg);
+	strcat(errmsg, " ");
+	strcat(errmsg, minor_msg);
 
-    return errmsg;
+	return errmsg;
 }
 
 /*
  * Map DAT_RETURN values to readable strings,
  * but don't assume the values are zero-based or contiguous.
  */
-const char *
-DT_TransferTypeToString (DT_Transfer_Type type)
+const char *DT_TransferTypeToString(DT_Transfer_Type type)
 {
-    static char *DT_Type[] =
-    {
-	"RR",
-	"RW",
-	"SR"
-    };
+	static char *DT_Type[] = {
+		"RR",
+		"RW",
+		"SR"
+	};
 
-    if ( (0 <= type) && (type <= 2) )
-    {
-	return DT_Type[type];
-    }
-    else
-    {
-	return "Error: Unkown Transfer Type";
-    }
+	if ((0 <= type) && (type <= 2)) {
+		return DT_Type[type];
+	} else {
+		return "Error: Unkown Transfer Type";
+	}
 }
 
-
 /*
  * Map DAT_ASYNC_ERROR_CODE values to readable strings
  */
-const char *
-DT_AsyncErr2Str (DAT_EVENT_NUMBER error_code)
+const char *DT_AsyncErr2Str(DAT_EVENT_NUMBER error_code)
 {
-    unsigned int i;
-    static struct
-    {
-	const char  *name;
-	DAT_RETURN  value;
-    } dat_errors[] =
-    {
+	unsigned int i;
+	static struct {
+		const char *name;
+		DAT_RETURN value;
+	} dat_errors[] = {
 #   define DATxx(x) { # x, x }
-	DATxx (DAT_DTO_COMPLETION_EVENT),
-	DATxx (DAT_RMR_BIND_COMPLETION_EVENT),
-	DATxx (DAT_CONNECTION_REQUEST_EVENT),
-	DATxx (DAT_CONNECTION_EVENT_ESTABLISHED),
-	DATxx (DAT_CONNECTION_EVENT_PEER_REJECTED),
-	DATxx (DAT_CONNECTION_EVENT_NON_PEER_REJECTED),
-	DATxx (DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR),
-	DATxx (DAT_CONNECTION_EVENT_DISCONNECTED),
-	DATxx (DAT_CONNECTION_EVENT_BROKEN),
-	DATxx (DAT_CONNECTION_EVENT_TIMED_OUT),
-	DATxx (DAT_ASYNC_ERROR_EVD_OVERFLOW),
-	DATxx (DAT_ASYNC_ERROR_IA_CATASTROPHIC),
-	DATxx (DAT_ASYNC_ERROR_EP_BROKEN),
-	DATxx (DAT_ASYNC_ERROR_TIMED_OUT),
-	DATxx (DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR),
-	DATxx (DAT_SOFTWARE_EVENT)
+		DATxx(DAT_DTO_COMPLETION_EVENT),
+		    DATxx(DAT_RMR_BIND_COMPLETION_EVENT),
+		    DATxx(DAT_CONNECTION_REQUEST_EVENT),
+		    DATxx(DAT_CONNECTION_EVENT_ESTABLISHED),
+		    DATxx(DAT_CONNECTION_EVENT_PEER_REJECTED),
+		    DATxx(DAT_CONNECTION_EVENT_NON_PEER_REJECTED),
+		    DATxx(DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR),
+		    DATxx(DAT_CONNECTION_EVENT_DISCONNECTED),
+		    DATxx(DAT_CONNECTION_EVENT_BROKEN),
+		    DATxx(DAT_CONNECTION_EVENT_TIMED_OUT),
+		    DATxx(DAT_ASYNC_ERROR_EVD_OVERFLOW),
+		    DATxx(DAT_ASYNC_ERROR_IA_CATASTROPHIC),
+		    DATxx(DAT_ASYNC_ERROR_EP_BROKEN),
+		    DATxx(DAT_ASYNC_ERROR_TIMED_OUT),
+		    DATxx(DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR),
+		    DATxx(DAT_SOFTWARE_EVENT)
 #   undef DATxx
-    };
+	};
 #   define NUM_ERRORS (sizeof (dat_errors)/sizeof (dat_errors[0]))
 
-    for (i = 0;  i < NUM_ERRORS;  i++)
-    {
-	if (dat_errors[i].value == error_code)
-	{
-	    return ( dat_errors[i].name );
+	for (i = 0; i < NUM_ERRORS; i++) {
+		if (dat_errors[i].value == error_code) {
+			return (dat_errors[i].name);
+		}
 	}
-    }
 
-    return ( "Invalid_DAT_EVENT_NUMBER" );
+	return ("Invalid_DAT_EVENT_NUMBER");
 }
 
 /*
  * Map DAT_EVENT_CODE values to readable strings
  */
-const char *
-DT_EventToSTr (DAT_EVENT_NUMBER event_code)
+const char *DT_EventToSTr(DAT_EVENT_NUMBER event_code)
 {
-    unsigned int i;
-    static struct
-    {
-	const char  *name;
-	DAT_RETURN  value;
-    }
-    dat_events[] =
-    {
+	unsigned int i;
+	static struct {
+		const char *name;
+		DAT_RETURN value;
+	} dat_events[] = {
 #   define DATxx(x) { # x, x }
-	DATxx (DAT_DTO_COMPLETION_EVENT),
-	DATxx (DAT_RMR_BIND_COMPLETION_EVENT),
-	DATxx (DAT_CONNECTION_REQUEST_EVENT),
-	DATxx (DAT_CONNECTION_EVENT_ESTABLISHED),
-	DATxx (DAT_CONNECTION_EVENT_PEER_REJECTED),
-	DATxx (DAT_CONNECTION_EVENT_NON_PEER_REJECTED),
-	DATxx (DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR),
-	DATxx (DAT_CONNECTION_EVENT_DISCONNECTED),
-	DATxx (DAT_CONNECTION_EVENT_BROKEN),
-	DATxx (DAT_CONNECTION_EVENT_TIMED_OUT),
-	DATxx (DAT_CONNECTION_EVENT_UNREACHABLE),
-	DATxx (DAT_ASYNC_ERROR_EVD_OVERFLOW),
-	DATxx (DAT_ASYNC_ERROR_IA_CATASTROPHIC),
-	DATxx (DAT_ASYNC_ERROR_EP_BROKEN),
-	DATxx (DAT_ASYNC_ERROR_TIMED_OUT),
-	DATxx (DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR),
-	DATxx (DAT_SOFTWARE_EVENT)
+		DATxx(DAT_DTO_COMPLETION_EVENT),
+		    DATxx(DAT_RMR_BIND_COMPLETION_EVENT),
+		    DATxx(DAT_CONNECTION_REQUEST_EVENT),
+		    DATxx(DAT_CONNECTION_EVENT_ESTABLISHED),
+		    DATxx(DAT_CONNECTION_EVENT_PEER_REJECTED),
+		    DATxx(DAT_CONNECTION_EVENT_NON_PEER_REJECTED),
+		    DATxx(DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR),
+		    DATxx(DAT_CONNECTION_EVENT_DISCONNECTED),
+		    DATxx(DAT_CONNECTION_EVENT_BROKEN),
+		    DATxx(DAT_CONNECTION_EVENT_TIMED_OUT),
+		    DATxx(DAT_CONNECTION_EVENT_UNREACHABLE),
+		    DATxx(DAT_ASYNC_ERROR_EVD_OVERFLOW),
+		    DATxx(DAT_ASYNC_ERROR_IA_CATASTROPHIC),
+		    DATxx(DAT_ASYNC_ERROR_EP_BROKEN),
+		    DATxx(DAT_ASYNC_ERROR_TIMED_OUT),
+		    DATxx(DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR),
+		    DATxx(DAT_SOFTWARE_EVENT)
 #   undef DATxx
-    };
+	};
 #   define NUM_EVENTS (sizeof (dat_events)/sizeof (dat_events[0]))
 
-    for (i = 0;  i < NUM_EVENTS;  i++)
-    {
-	if (dat_events[i].value == event_code)
-	{
-	    return ( dat_events[i].name );
+	for (i = 0; i < NUM_EVENTS; i++) {
+		if (dat_events[i].value == event_code) {
+			return (dat_events[i].name);
+		}
 	}
-    }
 
-    return ( "Invalid_DAT_EVENT_NUMBER" );
+	return ("Invalid_DAT_EVENT_NUMBER");
 }
 
-
 /*
  * Map DAT_EP_STATE_CODE values to readable strings
  */
-const char *
-DT_State2Str (DAT_EP_STATE state_code)
+const char *DT_State2Str(DAT_EP_STATE state_code)
 {
-    unsigned int i;
-    static struct
-    {
-	const char  *name;
-	DAT_RETURN  value;
-    }
-    dat_state[] =
-    {
+	unsigned int i;
+	static struct {
+		const char *name;
+		DAT_RETURN value;
+	} dat_state[] = {
 #   define DATxx(x) { # x, x }
-	DATxx (DAT_EP_STATE_UNCONNECTED),
-	DATxx (DAT_EP_STATE_RESERVED),
-	DATxx (DAT_EP_STATE_PASSIVE_CONNECTION_PENDING),
-	DATxx (DAT_EP_STATE_ACTIVE_CONNECTION_PENDING),
-	DATxx (DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING),
-	DATxx (DAT_EP_STATE_CONNECTED),
-	DATxx (DAT_EP_STATE_DISCONNECT_PENDING),
-	DATxx (DAT_EP_STATE_ERROR)
+		DATxx(DAT_EP_STATE_UNCONNECTED),
+		    DATxx(DAT_EP_STATE_RESERVED),
+		    DATxx(DAT_EP_STATE_PASSIVE_CONNECTION_PENDING),
+		    DATxx(DAT_EP_STATE_ACTIVE_CONNECTION_PENDING),
+		    DATxx(DAT_EP_STATE_TENTATIVE_CONNECTION_PENDING),
+		    DATxx(DAT_EP_STATE_CONNECTED),
+		    DATxx(DAT_EP_STATE_DISCONNECT_PENDING),
+		    DATxx(DAT_EP_STATE_ERROR)
 #   undef DATxx
-    };
+	};
 #   define NUM_STATES (sizeof (dat_state)/sizeof (dat_state[0]))
 
-    for (i = 0;  i < NUM_STATES;  i++)
-    {
-	if (dat_state[i].value == state_code)
-	{
-	    return ( dat_state[i].name );
+	for (i = 0; i < NUM_STATES; i++) {
+		if (dat_state[i].value == state_code) {
+			return (dat_state[i].name);
+		}
 	}
-    }
 
-    return ( "Invalid_DAT_STATE_NUMBER" );
+	return ("Invalid_DAT_STATE_NUMBER");
 }
 
-
 /*
  * A couple of round-up routines (for pointers and counters)
  * which both assume a power-of-two 'align' factor,
  * and do the correct thing if align == 0.
  */
-unsigned char *
-DT_AlignPtr (void * val, DAT_COUNT align)
+unsigned char *DT_AlignPtr(void *val, DAT_COUNT align)
 {
-    if (align)
-    {
+	if (align) {
 #if defined(_WIN64)
-	return ( (unsigned char *) 
-	       (((uint64_t)val+((uint64_t)align) - 1) & ~ (((uint64_t)align) - 1)));
+		return ((unsigned char *)
+			(((uint64_t) val + ((uint64_t) align) -
+			  1) & ~(((uint64_t) align) - 1)));
 #else
-	return ( (unsigned char *)
-	       (((unsigned long)val + ((unsigned long)align) - 1) & ~ (((unsigned long)align) - 1)));
+		return ((unsigned char *)
+			(((unsigned long)val + ((unsigned long)align) -
+			  1) & ~(((unsigned long)align) - 1)));
 #endif
-    }
-    return (val);
+	}
+	return (val);
 }
 
-DAT_COUNT
-DT_RoundSize (DAT_COUNT val, DAT_COUNT align)
+DAT_COUNT DT_RoundSize(DAT_COUNT val, DAT_COUNT align)
 {
-    if (align)
-    {
-	return ( ((val + align - 1) & ~ (align - 1)) );
-    }
-    return ( val );
+	if (align) {
+		return (((val + align - 1) & ~(align - 1)));
+	}
+	return (val);
 }

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/udapl/udapl_tdep.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/udapl/udapl_tdep.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dapltest/udapl/udapl_tdep.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -30,103 +30,83 @@
 
 #include "dapl_proto.h"
 
-void
-DT_Tdep_Init (void)
+void DT_Tdep_Init(void)
 {
-    DT_Mdep_LockInit (&g_PerfTestLock); /* For kDAPL, this is done in kdapl_module.c */
+	DT_Mdep_LockInit(&g_PerfTestLock);	/* For kDAPL, this is done in kdapl_module.c */
 }
 
-void
-DT_Tdep_End (void)
+void DT_Tdep_End(void)
 {
-    DT_Mdep_LockDestroy (&g_PerfTestLock); /* For kDAPL, this is done in kdapl_module.c */
+	DT_Mdep_LockDestroy(&g_PerfTestLock);	/* For kDAPL, this is done in kdapl_module.c */
 }
 
-void
-DT_Tdep_Execute_Test (Params_t *params_ptr)
+DAT_RETURN DT_Tdep_Execute_Test(Params_t * params_ptr)
 {
-    DT_Execute_Test (params_ptr);
+	return DT_Execute_Test(params_ptr);
 }
 
 DAT_RETURN
-DT_Tdep_lmr_create (DAT_IA_HANDLE		ia_handle,
-		    DAT_MEM_TYPE		mem_type,
-		    DAT_REGION_DESCRIPTION	region,
-		    DAT_VLEN			len,
-		    DAT_PZ_HANDLE		pz_handle,
-		    DAT_MEM_PRIV_FLAGS		priv_flag,
-		    DAT_LMR_HANDLE		*lmr_handle_ptr,
-		    DAT_LMR_CONTEXT		*lmr_context_ptr,
-		    DAT_RMR_CONTEXT		*rmr_context_ptr,
-		    DAT_VLEN			*reg_size_ptr,
-		    DAT_VADDR			*reg_addr_ptr)
+DT_Tdep_lmr_create(DAT_IA_HANDLE ia_handle,
+		   DAT_MEM_TYPE mem_type,
+		   DAT_REGION_DESCRIPTION region,
+		   DAT_VLEN len,
+		   DAT_PZ_HANDLE pz_handle,
+		   DAT_MEM_PRIV_FLAGS priv_flag,
+		   DAT_LMR_HANDLE * lmr_handle_ptr,
+		   DAT_LMR_CONTEXT * lmr_context_ptr,
+		   DAT_RMR_CONTEXT * rmr_context_ptr,
+		   DAT_VLEN * reg_size_ptr, DAT_VADDR * reg_addr_ptr)
 {
-    return dat_lmr_create (ia_handle,
-			   mem_type,
-			   region,
-			   len,
-			   pz_handle,
-			   priv_flag,
-			   DAT_VA_TYPE_VA,
-			   lmr_handle_ptr,
-			   lmr_context_ptr,
-			   rmr_context_ptr,
-			   reg_size_ptr,
-			   reg_addr_ptr);
+	return dat_lmr_create(ia_handle,
+			      mem_type,
+			      region,
+			      len,
+			      pz_handle,
+			      priv_flag,
+			      DAT_VA_TYPE_VA,
+			      lmr_handle_ptr,
+			      lmr_context_ptr,
+			      rmr_context_ptr, reg_size_ptr, reg_addr_ptr);
 }
 
 DAT_RETURN
-DT_Tdep_evd_create (DAT_IA_HANDLE		ia_handle,
-		    DAT_COUNT			evd_min_qlen,
-		    DAT_CNO_HANDLE		cno_handle,
-		    DAT_EVD_FLAGS		evd_flags,
-		    DAT_EVD_HANDLE 		*evd_handle_ptr)
+DT_Tdep_evd_create(DAT_IA_HANDLE ia_handle,
+		   DAT_COUNT evd_min_qlen,
+		   DAT_CNO_HANDLE cno_handle,
+		   DAT_EVD_FLAGS evd_flags, DAT_EVD_HANDLE * evd_handle_ptr)
 {
-    return dat_evd_create (ia_handle,
-			   evd_min_qlen,
-			   DAT_HANDLE_NULL,
-			   evd_flags,
-			   evd_handle_ptr);
+	return dat_evd_create(ia_handle,
+			      evd_min_qlen,
+			      DAT_HANDLE_NULL, evd_flags, evd_handle_ptr);
 }
 
-DAT_RETURN
-DT_Tdep_evd_free (DAT_EVD_HANDLE 		evd_handle)
+DAT_RETURN DT_Tdep_evd_free(DAT_EVD_HANDLE evd_handle)
 {
-    return dat_evd_free (evd_handle);
+	return dat_evd_free(evd_handle);
 }
 
 DAT_RETURN
-DT_Tdep_evd_wait (DAT_EVD_HANDLE evd_handle,
-		  DAT_TIMEOUT    timeout,
-		  DAT_EVENT      *event)
+DT_Tdep_evd_wait(DAT_EVD_HANDLE evd_handle,
+		 DAT_TIMEOUT timeout, DAT_EVENT * event)
 {
-    DAT_COUNT       count;
+	DAT_COUNT count;
 
-    return dat_evd_wait (evd_handle,
-			 timeout,
-			 1,
-			 event,
-			 &count);
+	return dat_evd_wait(evd_handle, timeout, 1, event, &count);
 }
 
-
-void
-DT_Tdep_PT_Printf (DT_Tdep_Print_Head *phead, const char * fmt, ...)
+void DT_Tdep_PT_Printf(DT_Tdep_Print_Head * phead, const char *fmt, ...)
 {
-    char buffer[256];
-    va_list args;
+	char buffer[256];
+	va_list args;
 
-    va_start (args, fmt);
-    vsprintf (buffer, fmt, args);
-    va_end (args);
+	va_start(args, fmt);
+	vsprintf(buffer, fmt, args);
+	va_end(args);
 
-    printf (buffer);
+	printf(buffer);
 }
 
-DAT_RETURN
-DT_Tdep_evd_dequeue (DAT_EVD_HANDLE evd_handle,
-		     DAT_EVENT      *event)
+DAT_RETURN DT_Tdep_evd_dequeue(DAT_EVD_HANDLE evd_handle, DAT_EVENT * event)
 {
-    return dat_evd_dequeue (evd_handle, event);	
+	return dat_evd_dequeue(evd_handle, event);
 }
-

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.am
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.am	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.am	2009-05-28 20:23:18 UTC (rev 260)
@@ -6,9 +6,9 @@
 bin_PROGRAMS += dtestx
 dtestx_SOURCES = dtestx.c
 dtestx_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAT_EXTENSIONS
-dtestx_LDADD = $(srcdir)/../../dat/udat/libdat2.la
+dtestx_LDADD = $(top_builddir)/dat/udat/libdat2.la
 endif
 
 INCLUDES =  -I $(srcdir)/../../dat/include 
-dtest_LDADD = $(srcdir)/../../dat/udat/libdat2.la
+dtest_LDADD = $(top_builddir)/dat/udat/libdat2.la
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.in
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.in	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/Makefile.in	2009-05-28 20:23:18 UTC (rev 260)
@@ -53,12 +53,12 @@
 PROGRAMS = $(bin_PROGRAMS)
 am_dtest_OBJECTS = dtest-dtest.$(OBJEXT)
 dtest_OBJECTS = $(am_dtest_OBJECTS)
-dtest_DEPENDENCIES = $(srcdir)/../../dat/udat/libdat2.la
+dtest_DEPENDENCIES = $(top_builddir)/dat/udat/libdat2.la
 am__dtestx_SOURCES_DIST = dtestx.c
 @EXT_TYPE_IB_TRUE at am_dtestx_OBJECTS = dtestx-dtestx.$(OBJEXT)
 dtestx_OBJECTS = $(am_dtestx_OBJECTS)
 @EXT_TYPE_IB_TRUE at dtestx_DEPENDENCIES =  \
- at EXT_TYPE_IB_TRUE@	$(srcdir)/../../dat/udat/libdat2.la
+ at EXT_TYPE_IB_TRUE@	$(top_builddir)/dat/udat/libdat2.la
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
 am__depfiles_maybe = depfiles
@@ -126,6 +126,8 @@
 OS_RHEL4_TRUE = @OS_RHEL4_TRUE@
 OS_RHEL5_FALSE = @OS_RHEL5_FALSE@
 OS_RHEL5_TRUE = @OS_RHEL5_TRUE@
+OS_SUSE11_FALSE = @OS_SUSE11_FALSE@
+OS_SUSE11_TRUE = @OS_SUSE11_TRUE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -186,9 +188,9 @@
 dtest_CFLAGS = -g -Wall -D_GNU_SOURCE 
 @EXT_TYPE_IB_TRUE at dtestx_SOURCES = dtestx.c
 @EXT_TYPE_IB_TRUE at dtestx_CFLAGS = -g -Wall -D_GNU_SOURCE -DDAT_EXTENSIONS
- at EXT_TYPE_IB_TRUE@dtestx_LDADD = $(srcdir)/../../dat/udat/libdat2.la
+ at EXT_TYPE_IB_TRUE@dtestx_LDADD = $(top_builddir)/dat/udat/libdat2.la
 INCLUDES = -I $(srcdir)/../../dat/include 
-dtest_LDADD = $(srcdir)/../../dat/udat/libdat2.la
+dtest_LDADD = $(top_builddir)/dat/udat/libdat2.la
 all: all-am
 
 .SUFFIXES:

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtest.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtest.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtest.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -46,11 +46,11 @@
 #include <ws2tcpip.h>
 #include <io.h>
 #include <process.h>
-#include <getopt.h>
 #include <complib/cl_types.h>
+#include "..\..\..\..\etc\user\getopt.c"
 
-#define getpid _getpid
-#define F64x "%I64x" 
+#define getpid() ((int)GetCurrentProcessId())
+#define F64x "%I64x"
 
 #ifdef DBG
 #define DAPL_PROVIDER "ibnic0v2d"
@@ -58,8 +58,11 @@
 #define DAPL_PROVIDER "ibnic0v2"
 #endif
 
-#else
+#define ntohll _byteswap_uint64
+#define htonll _byteswap_uint64
 
+#else // _WIN32 || _WIN64
+
 #include <endian.h>
 #include <byteswap.h>
 #include <netdb.h>
@@ -77,39 +80,17 @@
 #define DAPL_PROVIDER "ofa-v2-ib0"
 
 #define F64x "%"PRIx64""
-#endif 
 
-/* byte swap helpers from Complib */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define ntoh16(x) (uint16_t)( \
-	(((uint16_t)(x) & 0x00FF) << 8) | \
-        (((uint16_t)(x) & 0xFF00) >> 8))
-#define hton16(x) ntoh16(x)
-#define ntoh32(x) (uint32_t)( \
-        (((uint32_t)(x) & 0x000000FF) << 24)| \
-        (((uint32_t)(x) & 0x0000FF00) << 8) | \
-        (((uint32_t)(x) & 0x00FF0000) >> 8) | \
-        (((uint32_t)(x) & 0xFF000000) >> 24))
-#define hton32(x) ntoh32(x)
-#define ntoh64(x) (uint64_t)( \
-        (((uint64_t)x & 0x00000000000000FFULL) << 56) | \
-        (((uint64_t)x & 0x000000000000FF00ULL) << 40) | \
-        (((uint64_t)x & 0x0000000000FF0000ULL) << 24) | \
-        (((uint64_t)x & 0x00000000FF000000ULL) << 8 ) | \
-        (((uint64_t)x & 0x000000FF00000000ULL) >> 8 ) | \
-        (((uint64_t)x & 0x0000FF0000000000ULL) >> 24) | \
-        (((uint64_t)x & 0x00FF000000000000ULL) >> 40) | \
-        (((uint64_t)x & 0xFF00000000000000ULL) >> 56))
-#define hton64(x) ntoh64(x)
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define hton16(x) (x)
-#define ntoh16(x) (x)
-#define hton32(x) (x)
-#define ntoh32(x) (x)
-#define hton64(x) (x)
-#define ntoh64(x) (x)
-#endif  /* __BYTE_ORDER == __BIG_ENDIAN */
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define htonll(x) (x)
+#define ntohll(x) (x)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define htonll(x)  bswap_64(x)
+#define ntohll(x)  bswap_64(x)
+#endif
 
+#endif // _WIN32 || _WIN64
+
 /* Debug: 1 == connect & close only, otherwise full-meal deal */
 #define CONNECT_ONLY 0
 
@@ -129,494 +110,524 @@
 #define RDMA_BUFFER_SIZE  (64)
 
 /* Global DAT vars */
-static DAT_IA_HANDLE      h_ia = DAT_HANDLE_NULL;
-static DAT_PZ_HANDLE      h_pz = DAT_HANDLE_NULL;
-static DAT_EP_HANDLE      h_ep = DAT_HANDLE_NULL;
-static DAT_PSP_HANDLE     h_psp = DAT_HANDLE_NULL;
-static DAT_CR_HANDLE      h_cr = DAT_HANDLE_NULL;
+static DAT_IA_HANDLE h_ia = DAT_HANDLE_NULL;
+static DAT_PZ_HANDLE h_pz = DAT_HANDLE_NULL;
+static DAT_EP_HANDLE h_ep = DAT_HANDLE_NULL;
+static DAT_PSP_HANDLE h_psp = DAT_HANDLE_NULL;
+static DAT_CR_HANDLE h_cr = DAT_HANDLE_NULL;
 
-static DAT_EVD_HANDLE     h_async_evd = DAT_HANDLE_NULL;
-static DAT_EVD_HANDLE     h_dto_req_evd = DAT_HANDLE_NULL;
-static DAT_EVD_HANDLE     h_dto_rcv_evd = DAT_HANDLE_NULL;
-static DAT_EVD_HANDLE     h_cr_evd = DAT_HANDLE_NULL;
-static DAT_EVD_HANDLE     h_conn_evd = DAT_HANDLE_NULL;
-static DAT_CNO_HANDLE     h_dto_cno = DAT_HANDLE_NULL;
+static DAT_EVD_HANDLE h_async_evd = DAT_HANDLE_NULL;
+static DAT_EVD_HANDLE h_dto_req_evd = DAT_HANDLE_NULL;
+static DAT_EVD_HANDLE h_dto_rcv_evd = DAT_HANDLE_NULL;
+static DAT_EVD_HANDLE h_cr_evd = DAT_HANDLE_NULL;
+static DAT_EVD_HANDLE h_conn_evd = DAT_HANDLE_NULL;
+static DAT_CNO_HANDLE h_dto_cno = DAT_HANDLE_NULL;
 
 /* RDMA buffers */
-static DAT_LMR_HANDLE     h_lmr_send = DAT_HANDLE_NULL;
-static DAT_LMR_HANDLE     h_lmr_recv = DAT_HANDLE_NULL;
-static DAT_LMR_CONTEXT    lmr_context_send;
-static DAT_LMR_CONTEXT    lmr_context_recv;
-static DAT_RMR_CONTEXT    rmr_context_send;
-static DAT_RMR_CONTEXT    rmr_context_recv;
-static DAT_VLEN           registered_size_send;
-static DAT_VLEN           registered_size_recv;
-static DAT_VADDR          registered_addr_send;
-static DAT_VADDR          registered_addr_recv;
+static DAT_LMR_HANDLE h_lmr_send = DAT_HANDLE_NULL;
+static DAT_LMR_HANDLE h_lmr_recv = DAT_HANDLE_NULL;
+static DAT_LMR_CONTEXT lmr_context_send;
+static DAT_LMR_CONTEXT lmr_context_recv;
+static DAT_RMR_CONTEXT rmr_context_send;
+static DAT_RMR_CONTEXT rmr_context_recv;
+static DAT_VLEN registered_size_send;
+static DAT_VLEN registered_size_recv;
+static DAT_VADDR registered_addr_send;
+static DAT_VADDR registered_addr_recv;
 
 /* Initial msg receive buf, RMR exchange, and Rdma-write notification */
 #define MSG_BUF_COUNT     3
 #define MSG_IOV_COUNT     2
-static DAT_RMR_TRIPLET    rmr_recv_msg[MSG_BUF_COUNT];
-static DAT_LMR_HANDLE     h_lmr_recv_msg = DAT_HANDLE_NULL;
-static DAT_LMR_CONTEXT    lmr_context_recv_msg;
-static DAT_RMR_CONTEXT    rmr_context_recv_msg;
-static DAT_VLEN           registered_size_recv_msg;
-static DAT_VADDR          registered_addr_recv_msg;
+static DAT_RMR_TRIPLET rmr_recv_msg[MSG_BUF_COUNT];
+static DAT_LMR_HANDLE h_lmr_recv_msg = DAT_HANDLE_NULL;
+static DAT_LMR_CONTEXT lmr_context_recv_msg;
+static DAT_RMR_CONTEXT rmr_context_recv_msg;
+static DAT_VLEN registered_size_recv_msg;
+static DAT_VADDR registered_addr_recv_msg;
 
 /* message send buffer */
-static DAT_RMR_TRIPLET    rmr_send_msg;
-static DAT_LMR_HANDLE     h_lmr_send_msg = DAT_HANDLE_NULL;
-static DAT_LMR_CONTEXT    lmr_context_send_msg;
-static DAT_RMR_CONTEXT    rmr_context_send_msg;
-static DAT_VLEN           registered_size_send_msg;
-static DAT_VADDR          registered_addr_send_msg;
-static DAT_EP_ATTR        ep_attr;
-char                      hostname[256] = {0};
-char                      provider[64] = DAPL_PROVIDER;
-char                      addr_str[INET_ADDRSTRLEN];
+static DAT_RMR_TRIPLET rmr_send_msg;
+static DAT_LMR_HANDLE h_lmr_send_msg = DAT_HANDLE_NULL;
+static DAT_LMR_CONTEXT lmr_context_send_msg;
+static DAT_RMR_CONTEXT rmr_context_send_msg;
+static DAT_VLEN registered_size_send_msg;
+static DAT_VADDR registered_addr_send_msg;
+static DAT_EP_ATTR ep_attr;
+char hostname[256] = { 0 };
+char provider[64] = DAPL_PROVIDER;
+char addr_str[INET_ADDRSTRLEN];
 
 /* rdma pointers */
-char   *rbuf = NULL;
-char   *sbuf = NULL;
-int     status;
+char *rbuf = NULL;
+char *sbuf = NULL;
+int status;
 
 /* timers */
-double start,stop,total_us,total_sec;
+double start, stop, total_us, total_sec;
 
 struct dt_time {
-    double  total;
-    double  open;
-    double  reg;
-    double  unreg;
-    double  pzc;
-    double  pzf;
-    double  evdc;
-    double  evdf;
-    double  cnoc;
-    double  cnof;
-    double  epc;
-    double  epf;
-    double  rdma_wr;
-    double  rdma_rd[MAX_RDMA_RD];
-    double  rdma_rd_total;
-    double  rtt;
-    double  close;
+	double total;
+	double open;
+	double reg;
+	double unreg;
+	double pzc;
+	double pzf;
+	double evdc;
+	double evdf;
+	double cnoc;
+	double cnof;
+	double epc;
+	double epf;
+	double rdma_wr;
+	double rdma_rd[MAX_RDMA_RD];
+	double rdma_rd_total;
+	double rtt;
+	double close;
 };
 
 struct dt_time time;
 
 /* defaults */
-static int  failed=0;
-static int  performance_times=0;
-static int  connected=0;
-static int  burst=10;
-static int  server=1;
-static int  verbose=0;
-static int  polling=0;
-static int  poll_count=0;
-static int  rdma_wr_poll_count=0;
-static int  rdma_rd_poll_count[MAX_RDMA_RD]={0};
-static int  delay=0;
-static int  buf_len=RDMA_BUFFER_SIZE;
-static int  use_cno=0;
-static int  recv_msg_index=0;
-static int  burst_msg_posted=0;
-static int  burst_msg_index=0;
+static int failed = 0;
+static int performance_times = 0;
+static int connected = 0;
+static int burst = 10;
+static int server = 1;
+static int verbose = 0;
+static int polling = 0;
+static int poll_count = 0;
+static int rdma_wr_poll_count = 0;
+static int rdma_rd_poll_count[MAX_RDMA_RD] = { 0 };
+static int delay = 0;
+static int buf_len = RDMA_BUFFER_SIZE;
+static int use_cno = 0;
+static int recv_msg_index = 0;
+static int burst_msg_posted = 0;
+static int burst_msg_index = 0;
 
 /* forward prototypes */
-const char * DT_RetToString (DAT_RETURN ret_value);
-const char * DT_EventToSTr (DAT_EVENT_NUMBER event_code);
-void       print_usage(void);
-double     get_time(void);
-void       init_data(void);
+const char *DT_RetToString(DAT_RETURN ret_value);
+const char *DT_EventToSTr(DAT_EVENT_NUMBER event_code);
+void print_usage(void);
+double get_time(void);
+void init_data(void);
 
-DAT_RETURN     send_msg(   void                    *data,
-                           DAT_COUNT               size,
-                           DAT_LMR_CONTEXT         context,
-                           DAT_DTO_COOKIE          cookie,
-                           DAT_COMPLETION_FLAGS    flags );
+DAT_RETURN send_msg(void *data,
+		    DAT_COUNT size,
+		    DAT_LMR_CONTEXT context,
+		    DAT_DTO_COOKIE cookie, DAT_COMPLETION_FLAGS flags);
 
-DAT_RETURN     connect_ep( char *hostname, DAT_CONN_QUAL conn_id );
-void           disconnect_ep( void );
-DAT_RETURN     register_rdma_memory( void );
-DAT_RETURN     unregister_rdma_memory( void );
-DAT_RETURN     create_events( void );
-DAT_RETURN     destroy_events(void);
-DAT_RETURN     do_rdma_write_with_msg( void );
-DAT_RETURN     do_rdma_read_with_msg( void );
-DAT_RETURN     do_ping_pong_msg( void );
+DAT_RETURN connect_ep(char *hostname, DAT_CONN_QUAL conn_id);
+void disconnect_ep(void);
+DAT_RETURN register_rdma_memory(void);
+DAT_RETURN unregister_rdma_memory(void);
+DAT_RETURN create_events(void);
+DAT_RETURN destroy_events(void);
+DAT_RETURN do_rdma_write_with_msg(void);
+DAT_RETURN do_rdma_read_with_msg(void);
+DAT_RETURN do_ping_pong_msg(void);
 
 #define LOGPRINTF if (verbose) printf
 
-int
-main(int argc, char **argv)
+void flush_evds(void)
 {
-       int i,c;
-       DAT_RETURN  ret;
-       DAT_EP_PARAM ep_param;
+	DAT_EVENT event;
 
-       /* parse arguments */
-       while ((c = getopt(argc, argv, "tscvpb:d:B:h:P:")) != -1)
-       {
-               switch(c)
-               {
-		       case 't':
-                               performance_times = 1;
-                               fflush(stdout);
-                               break;
-                       case 's':
-                               server = 1;
-                               fflush(stdout);
-                               break;
-                       case 'c':
-                               use_cno = 1;
-                               printf("%d Creating CNO for DTO EVD's\n",getpid());
-                               fflush(stdout);
-                               break;
-                       case 'v':
-                               verbose = 1;
-                               printf("%d Verbose\n",getpid());
-                               fflush(stdout);
-                               break;
-                       case 'p':
-                               polling = 1;
-                               printf("%d Polling\n",getpid());
-                               fflush(stdout);
-                               break;
-                       case 'B':
-                               burst = atoi(optarg);
-                               break;
-                       case 'd':
-                               delay = atoi(optarg);
-                               break;
-                       case 'b':
-                               buf_len = atoi(optarg);
-                               break;
-                       case 'h':
-                               server = 0;
-                               strcpy (hostname, optarg);
-                               break;
-                       case 'P':
-                               strcpy (provider, optarg);
-                               break;
-                       default:
-                               print_usage();
-                               exit(-12);
-               }
-       }
+	/* Flush async error queue */
+	printf("%d ERR: Checking ASYNC EVD...\n", getpid());
+	while (dat_evd_dequeue(h_async_evd, &event) == DAT_SUCCESS) {
+		printf(" ASYNC EVD ENTRY: handle=%p reason=%d\n",
+			event.event_data.asynch_error_event_data.dat_handle,
+			event.event_data.asynch_error_event_data.reason);
+	}
+	/* Flush receive queue */
+	printf("%d ERR: Checking RECEIVE EVD...\n", getpid());
+	while (dat_evd_dequeue(h_dto_rcv_evd, &event) == DAT_SUCCESS) {
+		printf(" RCV EVD ENTRY: op=%d stat=%d ln=%d ck="F64x"\n",
+			event.event_data.dto_completion_event_data.operation,
+			event.event_data.dto_completion_event_data.status,
+			event.event_data.dto_completion_event_data.transfered_length,
+			event.event_data.dto_completion_event_data.user_cookie.as_64);
+	}
+	/* Flush request queue */
+	printf("%d ERR: Checking REQUEST EVD...\n", getpid());
+	while (dat_evd_dequeue(h_dto_req_evd, &event) == DAT_SUCCESS) {
+		printf(" REQ EVD ENTRY: op=%d stat=%d ln=%d ck="F64x"\n",
+			event.event_data.dto_completion_event_data.operation,
+			event.event_data.dto_completion_event_data.status,
+			event.event_data.dto_completion_event_data.transfered_length,
+			event.event_data.dto_completion_event_data.user_cookie.as_64);
+	}
+}
 
+int main(int argc, char **argv)
+{
+	int i, c;
+	DAT_RETURN ret;
+	DAT_EP_PARAM ep_param;
+
+	/* parse arguments */
+	while ((c = getopt(argc, argv, "tscvpb:d:B:h:P:")) != -1) {
+		switch (c) {
+		case 't':
+			performance_times = 1;
+			fflush(stdout);
+			break;
+		case 's':
+			server = 1;
+			fflush(stdout);
+			break;
+		case 'c':
+			use_cno = 1;
+			printf("%d Creating CNO for DTO EVD's\n", getpid());
+			fflush(stdout);
+			break;
+		case 'v':
+			verbose = 1;
+			printf("%d Verbose\n", getpid());
+			fflush(stdout);
+			break;
+		case 'p':
+			polling = 1;
+			printf("%d Polling\n", getpid());
+			fflush(stdout);
+			break;
+		case 'B':
+			burst = atoi(optarg);
+			break;
+		case 'd':
+			delay = atoi(optarg);
+			break;
+		case 'b':
+			buf_len = atoi(optarg);
+			break;
+		case 'h':
+			server = 0;
+			strcpy(hostname, optarg);
+			break;
+		case 'P':
+			strcpy(provider, optarg);
+			break;
+		default:
+			print_usage();
+			exit(-12);
+		}
+	}
+
 #if defined(_WIN32) || defined(_WIN64)
-    {
-        WSADATA wsaData; 
+	{
+		WSADATA wsaData;
 
-        i = WSAStartup ( MAKEWORD(2,2), &wsaData );
-        if ( i != 0 ) {
-               printf("%s WSAStartup(2.2) failed? (0x%x)\n",argv[0],i);
-               fflush(stdout);
-               exit(1);
-        }
-    }
+		i = WSAStartup(MAKEWORD(2, 2), &wsaData);
+		if (i != 0) {
+			printf("%s WSAStartup(2.2) failed? (0x%x)\n", argv[0],
+			       i);
+			fflush(stdout);
+			exit(1);
+		}
+	}
 #endif
 
-    if (!server) {
-            printf("%d Running as client - %s\n",getpid(),provider);
-    } else {
-            printf("%d Running as server - %s\n",getpid(),provider);
-    }
-    fflush(stdout);
+	if (!server) {
+		printf("%d Running as client - %s\n", getpid(), provider);
+	} else {
+		printf("%d Running as server - %s\n", getpid(), provider);
+	}
+	fflush(stdout);
 
-    /* allocate send and receive buffers */
-    if (((rbuf = malloc(buf_len*burst)) == NULL) ||
-           ((sbuf = malloc(buf_len*burst)) == NULL)) {
-               perror("malloc");
-               exit(1);
-    }
-    memset( &time, 0, sizeof(struct dt_time) );
-    LOGPRINTF("%d Allocated RDMA buffers (r:%p,s:%p) len %d \n",
-                       getpid(), rbuf, sbuf, buf_len);
+	/* allocate send and receive buffers */
+	if (((rbuf = malloc(buf_len * (burst+1))) == NULL) ||
+	    ((sbuf = malloc(buf_len * (burst+1))) == NULL)) {
+		perror("malloc");
+		exit(1);
+	}
+	memset(&time, 0, sizeof(struct dt_time));
+	LOGPRINTF("%d Allocated RDMA buffers (r:%p,s:%p) len %d \n",
+		  getpid(), rbuf, sbuf, buf_len);
 
-    /* dat_ia_open, dat_pz_create */
-    h_async_evd = DAT_HANDLE_NULL;
-    start = get_time();
-    ret = dat_ia_open( provider, 8, &h_async_evd, &h_ia );
-    stop = get_time();
-    time.open += ((stop - start)*1.0e6);
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d: Error Adaptor open: %s\n",
-                       getpid(),DT_RetToString(ret));
-         exit(1);
-    } else
-       LOGPRINTF("%d Opened Interface Adaptor\n",getpid());
+	/* dat_ia_open, dat_pz_create */
+	h_async_evd = DAT_HANDLE_NULL;
+	start = get_time();
+	ret = dat_ia_open(provider, 8, &h_async_evd, &h_ia);
+	stop = get_time();
+	time.open += ((stop - start) * 1.0e6);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d: Error Adaptor open: %s\n",
+			getpid(), DT_RetToString(ret));
+		exit(1);
+	} else
+		LOGPRINTF("%d Opened Interface Adaptor\n", getpid());
 
-    /* Create Protection Zone */
-    start = get_time();
-    LOGPRINTF("%d Create Protection Zone\n",getpid());
-    ret = dat_pz_create(h_ia, &h_pz);
-    stop = get_time();
-    time.pzc += ((stop - start)*1.0e6);
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error creating Protection Zone: %s\n",
-                       getpid(),DT_RetToString(ret));
-         exit(1);
-    } else
-         LOGPRINTF("%d Created Protection Zone\n",getpid());
+	/* Create Protection Zone */
+	start = get_time();
+	LOGPRINTF("%d Create Protection Zone\n", getpid());
+	ret = dat_pz_create(h_ia, &h_pz);
+	stop = get_time();
+	time.pzc += ((stop - start) * 1.0e6);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error creating Protection Zone: %s\n",
+			getpid(), DT_RetToString(ret));
+		exit(1);
+	} else
+		LOGPRINTF("%d Created Protection Zone\n", getpid());
 
-    /* Register memory */
-    LOGPRINTF("%d Register RDMA memory\n", getpid());
-    ret = register_rdma_memory();
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error registering RDMA memory: %s\n",
-                               getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else
-         LOGPRINTF("%d Register RDMA memory done\n", getpid());
+	/* Register memory */
+	LOGPRINTF("%d Register RDMA memory\n", getpid());
+	ret = register_rdma_memory();
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error registering RDMA memory: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else
+		LOGPRINTF("%d Register RDMA memory done\n", getpid());
 
-    LOGPRINTF("%d Create events\n", getpid());
-    ret = create_events();
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error creating events: %s\n",
-                       getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else {
-         LOGPRINTF("%d Create events done\n", getpid());
-    }
+	LOGPRINTF("%d Create events\n", getpid());
+	ret = create_events();
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error creating events: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else {
+		LOGPRINTF("%d Create events done\n", getpid());
+	}
 
-    /* create EP */
-    memset( &ep_attr, 0, sizeof(ep_attr) );
-    ep_attr.service_type                = DAT_SERVICE_TYPE_RC;
-    ep_attr.max_rdma_size               = 0x10000;
-    ep_attr.qos                         = 0;
-    ep_attr.recv_completion_flags       = 0;
-    ep_attr.max_recv_dtos               = MSG_BUF_COUNT + (burst*3);
-    ep_attr.max_request_dtos            = MSG_BUF_COUNT + (burst*3) + MAX_RDMA_RD; 
-    ep_attr.max_recv_iov                = MSG_IOV_COUNT;
-    ep_attr.max_request_iov             = MSG_IOV_COUNT;
-    ep_attr.max_rdma_read_in            = MAX_RDMA_RD;
-    ep_attr.max_rdma_read_out           = MAX_RDMA_RD;
-    ep_attr.request_completion_flags    = DAT_COMPLETION_DEFAULT_FLAG;
-    ep_attr.ep_transport_specific_count = 0;
-    ep_attr.ep_transport_specific       = NULL;
-    ep_attr.ep_provider_specific_count  = 0;
-    ep_attr.ep_provider_specific        = NULL;
+	/* create EP */
+	memset(&ep_attr, 0, sizeof(ep_attr));
+	ep_attr.service_type = DAT_SERVICE_TYPE_RC;
+	ep_attr.max_rdma_size = 0x10000;
+	ep_attr.qos = 0;
+	ep_attr.recv_completion_flags = 0;
+	ep_attr.max_recv_dtos = MSG_BUF_COUNT + (burst * 3);
+	ep_attr.max_request_dtos = MSG_BUF_COUNT + (burst * 3) + MAX_RDMA_RD;
+	ep_attr.max_recv_iov = MSG_IOV_COUNT;
+	ep_attr.max_request_iov = MSG_IOV_COUNT;
+	ep_attr.max_rdma_read_in = MAX_RDMA_RD;
+	ep_attr.max_rdma_read_out = MAX_RDMA_RD;
+	ep_attr.request_completion_flags = DAT_COMPLETION_DEFAULT_FLAG;
+	ep_attr.ep_transport_specific_count = 0;
+	ep_attr.ep_transport_specific = NULL;
+	ep_attr.ep_provider_specific_count = 0;
+	ep_attr.ep_provider_specific = NULL;
 
-    start = get_time();
-    ret = dat_ep_create( h_ia, h_pz, h_dto_rcv_evd, 
-                         h_dto_req_evd, h_conn_evd, &ep_attr, &h_ep );
-    stop = get_time();
-    time.epc += ((stop - start)*1.0e6);
-    time.total += time.epc;
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error dat_ep_create: %s\n",
-                       getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else
-         LOGPRINTF("%d EP created %p \n", getpid(), h_ep);
+	start = get_time();
+	ret = dat_ep_create(h_ia, h_pz, h_dto_rcv_evd,
+			    h_dto_req_evd, h_conn_evd, &ep_attr, &h_ep);
+	stop = get_time();
+	time.epc += ((stop - start) * 1.0e6);
+	time.total += time.epc;
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_ep_create: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else
+		LOGPRINTF("%d EP created %p \n", getpid(), h_ep);
 
-    /*
-     * register message buffers, establish connection, and
-     * exchange DMA RMR information info via messages
-     */
-    ret = connect_ep( hostname, SERVER_CONN_QUAL );
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error connect_ep: %s\n",
-                               getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else
-         LOGPRINTF("%d connect_ep complete\n", getpid());
+	/*
+	 * register message buffers, establish connection, and
+	 * exchange DMA RMR information info via messages
+	 */
+	ret = connect_ep(hostname, SERVER_CONN_QUAL);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error connect_ep: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else
+		LOGPRINTF("%d connect_ep complete\n", getpid());
 
-    /* Query EP for local and remote address information, print */
-    ret = dat_ep_query(h_ep, DAT_EP_FIELD_ALL, &ep_param);
-    if(ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d Error dat_ep_query: %s\n",
-                getpid(),DT_RetToString(ret));
-        goto cleanup;
-    } else
-        LOGPRINTF("%d EP queried %p \n", getpid(), h_ep);
+	/* Query EP for local and remote address information, print */
+	ret = dat_ep_query(h_ep, DAT_EP_FIELD_ALL, &ep_param);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_ep_query: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else
+		LOGPRINTF("%d EP queried %p \n", getpid(), h_ep);
 #if defined(_WIN32)
-    printf("\n%d Query EP: LOCAL addr %s port %lld\n", getpid(),
-         inet_ntoa(((struct sockaddr_in *)
-                    ep_param.local_ia_address_ptr)->sin_addr),
-         (ep_param.local_port_qual));
+	printf("\n%d Query EP: LOCAL addr %s port %lld\n", getpid(),
+	       inet_ntoa(((struct sockaddr_in *)
+			  ep_param.local_ia_address_ptr)->sin_addr),
+	       (ep_param.local_port_qual));
 #else
-    inet_ntop(AF_INET,
-         &((struct sockaddr_in *)ep_param.local_ia_address_ptr)->sin_addr,
-         addr_str, sizeof(addr_str));
-    printf("\n%d Query EP: LOCAL addr %s port "F64x"\n", getpid(),
-         addr_str, (ep_param.local_port_qual));
+	inet_ntop(AF_INET,
+		  &((struct sockaddr_in *)ep_param.local_ia_address_ptr)->
+		  sin_addr, addr_str, sizeof(addr_str));
+	printf("\n%d Query EP: LOCAL addr %s port " F64x "\n", getpid(),
+	       addr_str, (ep_param.local_port_qual));
 #endif
 #if defined(_WIN32)
-    printf("%d Query EP: REMOTE addr %s port %lld\n", getpid(),
-         inet_ntoa(((struct sockaddr_in *)
-                    ep_param.local_ia_address_ptr)->sin_addr),
-         (ep_param.remote_port_qual));
+	printf("%d Query EP: REMOTE addr %s port %lld\n", getpid(),
+	       inet_ntoa(((struct sockaddr_in *)
+			  ep_param.local_ia_address_ptr)->sin_addr),
+	       (ep_param.remote_port_qual));
 #else
-    inet_ntop(AF_INET,
-        &((struct sockaddr_in *)ep_param.remote_ia_address_ptr)->sin_addr,
-        addr_str, sizeof(addr_str));
-    printf("%d Query EP: REMOTE addr %s port "F64x"\n", getpid(),
-           addr_str, (ep_param.remote_port_qual));
+	inet_ntop(AF_INET,
+		  &((struct sockaddr_in *)ep_param.remote_ia_address_ptr)->
+		  sin_addr, addr_str, sizeof(addr_str));
+	printf("%d Query EP: REMOTE addr %s port " F64x "\n", getpid(),
+	       addr_str, (ep_param.remote_port_qual));
 #endif
-    fflush(stdout);
+	fflush(stdout);
 
 #if CONNECT_ONLY
 #if defined(_WIN32) || defined(_WIN64)
-    Sleep(1*1000);
+	Sleep(1 * 1000);
 #else
-    sleep(1);
+	sleep(1);
 #endif
-    goto cleanup;
+	goto cleanup;
 #endif
 
-    /*********** RDMA write data *************/
-    ret = do_rdma_write_with_msg();
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error do_rdma_write_with_msg: %s\n",
-                               getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else
-         LOGPRINTF("%d do_rdma_write_with_msg complete\n", getpid());
+	/*********** RDMA write data *************/
+	ret = do_rdma_write_with_msg();
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error do_rdma_write_with_msg: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else
+		LOGPRINTF("%d do_rdma_write_with_msg complete\n", getpid());
 
-    /*********** RDMA read data *************/
-    ret = do_rdma_read_with_msg();
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error do_rdma_read_with_msg: %s\n",
-                               getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else
-         LOGPRINTF("%d do_rdma_read_with_msg complete\n", getpid());
+	/*********** RDMA read data *************/
+	ret = do_rdma_read_with_msg();
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error do_rdma_read_with_msg: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else
+		LOGPRINTF("%d do_rdma_read_with_msg complete\n", getpid());
 
-    /*********** PING PING messages ************/
-    ret = do_ping_pong_msg();
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error do_ping_pong_msg: %s\n",
-                               getpid(),DT_RetToString(ret));
-         goto cleanup;
-    } else {
-         LOGPRINTF("%d do_ping_pong_msg complete\n", getpid());
-	 goto complete;
-    }
+	/*********** PING PING messages ************/
+	ret = do_ping_pong_msg();
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error do_ping_pong_msg: %s\n",
+			getpid(), DT_RetToString(ret));
+		goto cleanup;
+	} else {
+		LOGPRINTF("%d do_ping_pong_msg complete\n", getpid());
+		goto complete;
+	}
 
 cleanup:
-       failed++;
+	flush_evds();
+	failed++;
 complete:
 
-    /* disconnect and free EP resources */
-    if ( h_ep != DAT_HANDLE_NULL ) {
-         /* unregister message buffers and tear down connection */
-         LOGPRINTF("%d Disconnect and Free EP %p \n",getpid(),h_ep);
-         disconnect_ep();
-    
-        /* free EP */
-        LOGPRINTF("%d Free EP %p \n",getpid(),h_ep);
-        start = get_time();
-        ret = dat_ep_free( h_ep );
-        stop = get_time();
-        time.epf += ((stop - start)*1.0e6);
-        time.total += time.epf;
-        if(ret != DAT_SUCCESS) {
-            fprintf(stderr, "%d Error freeing EP: %s\n",
-                    getpid(), DT_RetToString(ret));
-        } else {
-            LOGPRINTF("%d Freed EP\n",getpid());
-            h_ep = DAT_HANDLE_NULL;
-        }   
-    }
-    
-    /* free EVDs */
-    LOGPRINTF("%d destroy events\n", getpid());
-    ret = destroy_events();
-    if(ret != DAT_SUCCESS)
-         fprintf(stderr, "%d Error destroy_events: %s\n",
-                       getpid(),DT_RetToString(ret));
-    else
-         LOGPRINTF("%d destroy events done\n", getpid());
+	/* disconnect and free EP resources */
+	if (h_ep != DAT_HANDLE_NULL) {
+		/* unregister message buffers and tear down connection */
+		LOGPRINTF("%d Disconnect and Free EP %p \n", getpid(), h_ep);
+		disconnect_ep();
 
+		/* free EP */
+		LOGPRINTF("%d Free EP %p \n", getpid(), h_ep);
+		start = get_time();
+		ret = dat_ep_free(h_ep);
+		stop = get_time();
+		time.epf += ((stop - start) * 1.0e6);
+		time.total += time.epf;
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error freeing EP: %s\n",
+				getpid(), DT_RetToString(ret));
+		} else {
+			LOGPRINTF("%d Freed EP\n", getpid());
+			h_ep = DAT_HANDLE_NULL;
+		}
+	}
 
-    ret = unregister_rdma_memory();
-    LOGPRINTF("%d unregister_rdma_memory \n", getpid());
-    if(ret != DAT_SUCCESS)
-         fprintf(stderr, "%d Error unregister_rdma_memory: %s\n",
-                       getpid(),DT_RetToString(ret));
-    else
-         LOGPRINTF("%d unregister_rdma_memory done\n", getpid());
+	/* free EVDs */
+	LOGPRINTF("%d destroy events\n", getpid());
+	ret = destroy_events();
+	if (ret != DAT_SUCCESS)
+		fprintf(stderr, "%d Error destroy_events: %s\n",
+			getpid(), DT_RetToString(ret));
+	else
+		LOGPRINTF("%d destroy events done\n", getpid());
 
-    /* Free protection domain */
-    LOGPRINTF("%d Freeing pz\n",getpid());
-    start = get_time();
-    ret = dat_pz_free( h_pz );
-    stop = get_time();
-    time.pzf += ((stop - start)*1.0e6);
-    if (ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error freeing PZ: %s\n",
-               getpid(), DT_RetToString(ret));
-    } else {
-         LOGPRINTF("%d Freed pz\n",getpid());
-         h_pz = NULL;
-    }
+	ret = unregister_rdma_memory();
+	LOGPRINTF("%d unregister_rdma_memory \n", getpid());
+	if (ret != DAT_SUCCESS)
+		fprintf(stderr, "%d Error unregister_rdma_memory: %s\n",
+			getpid(), DT_RetToString(ret));
+	else
+		LOGPRINTF("%d unregister_rdma_memory done\n", getpid());
 
-    /* close the device */
-    LOGPRINTF("%d Closing Interface Adaptor\n",getpid());
-    start = get_time();
-    ret = dat_ia_close( h_ia, DAT_CLOSE_ABRUPT_FLAG );
-    stop = get_time();
-    time.close += ((stop - start)*1.0e6);
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d: Error Adaptor close: %s\n",
-                       getpid(),DT_RetToString(ret));
-         exit(1);
-    } else
-         LOGPRINTF("%d Closed Interface Adaptor\n",getpid());
+	/* Free protection domain */
+	LOGPRINTF("%d Freeing pz\n", getpid());
+	start = get_time();
+	ret = dat_pz_free(h_pz);
+	stop = get_time();
+	time.pzf += ((stop - start) * 1.0e6);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error freeing PZ: %s\n",
+			getpid(), DT_RetToString(ret));
+	} else {
+		LOGPRINTF("%d Freed pz\n", getpid());
+		h_pz = NULL;
+	}
 
-    /* free rdma buffers */
-    free(rbuf);
-    free(sbuf);
+	/* close the device */
+	LOGPRINTF("%d Closing Interface Adaptor\n", getpid());
+	start = get_time();
+	ret = dat_ia_close(h_ia, DAT_CLOSE_ABRUPT_FLAG);
+	stop = get_time();
+	time.close += ((stop - start) * 1.0e6);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d: Error Adaptor close: %s\n",
+			getpid(), DT_RetToString(ret));
+	} else
+		LOGPRINTF("%d Closed Interface Adaptor\n", getpid());
 
-    printf("\n%d: DAPL Test Complete. %s\n\n",
-           getpid(), failed?"FAILED":"PASSED");
-    
-    if (!performance_times) 
-        exit(0);
+	/* free rdma buffers */
+	free(rbuf);
+	free(sbuf);
 
-    printf( "\n%d: DAPL Test Complete.\n\n",getpid());
-    printf( "%d: Message RTT: Total=%10.2lf usec, %d bursts, itime=%10.2lf"
-		" usec, pc=%d\n", 
-		getpid(), time.rtt, burst, time.rtt/burst, poll_count );
-    printf( "%d: RDMA write:  Total=%10.2lf usec, %d bursts, itime=%10.2lf"
-		" usec, pc=%d\n", 
-		getpid(), time.rdma_wr, burst, 
-		time.rdma_wr/burst, rdma_wr_poll_count );
-    for(i=0;i<MAX_RDMA_RD;i++) {
-	    printf( "%d: RDMA read:   Total=%10.2lf usec,   %d bursts, "
-		    "itime=%10.2lf usec, pc=%d\n", 
-	           getpid(),time.rdma_rd_total,MAX_RDMA_RD,
-		   time.rdma_rd[i],rdma_rd_poll_count[i] );
-    }
-    printf( "%d: open:      %10.2lf usec\n", getpid(), time.open  );
-    printf( "%d: close:     %10.2lf usec\n", getpid(), time.close );
-    printf( "%d: PZ create: %10.2lf usec\n", getpid(), time.pzc );
-    printf( "%d: PZ free:   %10.2lf usec\n", getpid(), time.pzf );
-    printf( "%d: LMR create:%10.2lf usec\n", getpid(), time.reg );
-    printf( "%d: LMR free:  %10.2lf usec\n", getpid(), time.unreg );
-    printf( "%d: EVD create:%10.2lf usec\n", getpid(), time.evdc );
-    printf( "%d: EVD free:  %10.2lf usec\n", getpid(), time.evdf );
-    if (use_cno) {
-       printf( "%d: CNO create:  %10.2lf usec\n", getpid(), time.cnoc );
-       printf( "%d: CNO free:    %10.2lf usec\n", getpid(), time.cnof );
-    }
-    printf( "%d: EP create: %10.2lf usec\n",getpid(), time.epc );
-    printf( "%d: EP free:   %10.2lf usec\n",getpid(), time.epf );
-    printf( "%d: TOTAL:     %10.2lf usec\n",getpid(), time.total );
+	printf("\n%d: DAPL Test Complete. %s\n\n",
+	       getpid(), failed ? "FAILED" : "PASSED");
 
+	fflush(stderr);
+	fflush(stdout);
+
+	if (!performance_times)
+		exit(0);
+
+	printf("\n%d: DAPL Test Complete.\n\n", getpid());
+	printf("%d: Message RTT: Total=%10.2lf usec, %d bursts, itime=%10.2lf"
+	       " usec, pc=%d\n",
+	       getpid(), time.rtt, burst, time.rtt / burst, poll_count);
+	printf("%d: RDMA write:  Total=%10.2lf usec, %d bursts, itime=%10.2lf"
+	       " usec, pc=%d\n",
+	       getpid(), time.rdma_wr, burst,
+	       time.rdma_wr / burst, rdma_wr_poll_count);
+	for (i = 0; i < MAX_RDMA_RD; i++) {
+		printf("%d: RDMA read:   Total=%10.2lf usec,   %d bursts, "
+		       "itime=%10.2lf usec, pc=%d\n",
+		       getpid(), time.rdma_rd_total, MAX_RDMA_RD,
+		       time.rdma_rd[i], rdma_rd_poll_count[i]);
+	}
+	printf("%d: open:      %10.2lf usec\n", getpid(), time.open);
+	printf("%d: close:     %10.2lf usec\n", getpid(), time.close);
+	printf("%d: PZ create: %10.2lf usec\n", getpid(), time.pzc);
+	printf("%d: PZ free:   %10.2lf usec\n", getpid(), time.pzf);
+	printf("%d: LMR create:%10.2lf usec\n", getpid(), time.reg);
+	printf("%d: LMR free:  %10.2lf usec\n", getpid(), time.unreg);
+	printf("%d: EVD create:%10.2lf usec\n", getpid(), time.evdc);
+	printf("%d: EVD free:  %10.2lf usec\n", getpid(), time.evdf);
+	if (use_cno) {
+		printf("%d: CNO create:  %10.2lf usec\n", getpid(), time.cnoc);
+		printf("%d: CNO free:    %10.2lf usec\n", getpid(), time.cnof);
+	}
+	printf("%d: EP create: %10.2lf usec\n", getpid(), time.epc);
+	printf("%d: EP free:   %10.2lf usec\n", getpid(), time.epf);
+	printf("%d: TOTAL:     %10.2lf usec\n", getpid(), time.total);
+
 #if defined(_WIN32) || defined(_WIN64)
-    WSACleanup();
+	WSACleanup();
 #endif
-    return(0);
+	return (0);
 }
 
 #if defined(_WIN32) || defined(_WIN64)
 
-void gettimeofday( struct timeval *t, char *jnk)
+void gettimeofday(struct timeval *t, char *jnk)
 {
 	SYSTEMTIME now;
 	GetLocalTime(&now);
@@ -629,1489 +640,1508 @@
 
 double get_time(void)
 {
-       struct timeval tp;
+	struct timeval tp;
 
-       gettimeofday(&tp, NULL);
-       return ((double) tp.tv_sec + (double) tp.tv_usec * 1e-6);
+	gettimeofday(&tp, NULL);
+	return ((double)tp.tv_sec + (double)tp.tv_usec * 1e-6);
 }
 
 void init_data(void)
 {
-       memset(rbuf, 'a', buf_len);
-       memset(sbuf, 'b', buf_len);
+	memset(rbuf, 'a', buf_len);
+	memset(sbuf, 'b', buf_len);
 }
 
-
 DAT_RETURN
-send_msg(  void                   *data,
-           DAT_COUNT               size,
-           DAT_LMR_CONTEXT         context,
-           DAT_DTO_COOKIE          cookie,
-           DAT_COMPLETION_FLAGS    flags )
+send_msg(void *data,
+	 DAT_COUNT size,
+	 DAT_LMR_CONTEXT context,
+	 DAT_DTO_COOKIE cookie, DAT_COMPLETION_FLAGS flags)
 {
-    DAT_LMR_TRIPLET    iov;
-    DAT_EVENT          event;
-    DAT_COUNT          nmore;
-    DAT_RETURN         ret;
+	DAT_LMR_TRIPLET iov;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_RETURN ret;
 
-    iov.lmr_context     = context;
+	iov.lmr_context = context;
 #if defined(_WIN32)
-    iov.virtual_address = (DAT_VADDR)data;
+	iov.virtual_address = (DAT_VADDR) data;
 #else
-    iov.virtual_address = (DAT_VADDR)(unsigned long)data;
+	iov.virtual_address = (DAT_VADDR) (unsigned long)data;
 #endif
-    iov.segment_length  = size;
-    
-    LOGPRINTF("%d calling post_send\n", getpid());
-    cookie.as_64 = 0xaaaa;
-    ret = dat_ep_post_send( h_ep,
-                           1,
-                           &iov,
-                           cookie,
-                           flags );
+	iov.segment_length = size;
 
-    if (ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d: ERROR: dat_ep_post_send() %s\n",
-                           getpid(),DT_RetToString(ret));
-        return ret;
-    }
+	LOGPRINTF("%d calling post_send\n", getpid());
+	cookie.as_64 = 0xaaaa;
+	ret = dat_ep_post_send(h_ep, 1, &iov, cookie, flags);
 
-    if (!(flags & DAT_COMPLETION_SUPPRESS_FLAG)) {
-       if ( polling ) {
-           printf("%d Polling post send completion...\n",getpid());
-           while (dat_evd_dequeue(h_dto_req_evd, &event) == DAT_QUEUE_EMPTY) ;
-       }
-       else {
-           LOGPRINTF("%d waiting for post_send completion event\n", getpid());
-           if (use_cno) {
-               DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
-               ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );
-               LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);
-               if ( evd != h_dto_req_evd ) {
-                   fprintf(stderr,
-                       "%d Error waiting on h_dto_cno: evd != h_dto_req_evd\n",
-                       getpid());
-                   return( DAT_ABORT );
-               }
-           }
-           /* use wait to dequeue */
-           ret = dat_evd_wait( h_dto_req_evd, DTO_TIMEOUT, 1, &event, &nmore );
-           if (ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",
-                       getpid(),DT_RetToString(ret));
-               return ret;
-           }
-       }
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d: ERROR: dat_ep_post_send() %s\n",
+			getpid(), DT_RetToString(ret));
+		return ret;
+	}
 
-       /* validate event number, len, cookie, and status */
-       if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {
-           fprintf(stderr, "%d: ERROR: DTO event number %s\n",
-                   getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-       }
+	if (!(flags & DAT_COMPLETION_SUPPRESS_FLAG)) {
+		if (polling) {
+			printf("%d Polling post send completion...\n",
+			       getpid());
+			while (dat_evd_dequeue(h_dto_req_evd, &event) ==
+			       DAT_QUEUE_EMPTY) ;
+		} else {
+			LOGPRINTF("%d waiting for post_send completion event\n",
+				  getpid());
+			if (use_cno) {
+				DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
+				ret =
+				    dat_cno_wait(h_dto_cno, DTO_TIMEOUT, &evd);
+				LOGPRINTF("%d cno wait return evd_handle=%p\n",
+					  getpid(), evd);
+				if (evd != h_dto_req_evd) {
+					fprintf(stderr,
+						"%d Error waiting on h_dto_cno: evd != h_dto_req_evd\n",
+						getpid());
+					return (DAT_ABORT);
+				}
+			}
+			/* use wait to dequeue */
+			ret =
+			    dat_evd_wait(h_dto_req_evd, DTO_TIMEOUT, 1, &event,
+					 &nmore);
+			if (ret != DAT_SUCCESS) {
+				fprintf(stderr,
+					"%d: ERROR: DTO dat_evd_wait() %s\n",
+					getpid(), DT_RetToString(ret));
+				return ret;
+			}
+		}
 
-       if ((event.event_data.dto_completion_event_data.transfered_length != size ) ||
-           (event.event_data.dto_completion_event_data.user_cookie.as_64 != 0xaaaa )) {
-           fprintf(stderr, "%d: ERROR: DTO len %d or cookie "F64x" \n",
-               getpid(),
-               event.event_data.dto_completion_event_data.transfered_length,
-               event.event_data.dto_completion_event_data.user_cookie.as_64 );
-           return( DAT_ABORT );
+		/* validate event number, len, cookie, and status */
+		if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+			fprintf(stderr, "%d: ERROR: DTO event number %s\n",
+				getpid(), DT_EventToSTr(event.event_number));
+			return (DAT_ABORT);
+		}
 
-       }
-       if (event.event_data.dto_completion_event_data.status != DAT_SUCCESS) {
-           fprintf(stderr, "%d: ERROR: DTO event status %s\n",
-                   getpid(),DT_RetToString(ret));
-           return( DAT_ABORT );
-       }
-    }
+		if ((event.event_data.dto_completion_event_data.
+		     transfered_length != size)
+		    || (event.event_data.dto_completion_event_data.user_cookie.
+			as_64 != 0xaaaa)) {
+			fprintf(stderr,
+				"%d: ERROR: DTO len %d or cookie " F64x " \n",
+				getpid(),
+				event.event_data.dto_completion_event_data.
+				transfered_length,
+				event.event_data.dto_completion_event_data.
+				user_cookie.as_64);
+			return (DAT_ABORT);
 
-    return DAT_SUCCESS;
+		}
+		if (event.event_data.dto_completion_event_data.status !=
+		    DAT_SUCCESS) {
+			fprintf(stderr, "%d: ERROR: DTO event status %s\n",
+				getpid(), DT_RetToString(ret));
+			return (DAT_ABORT);
+		}
+	}
+
+	return DAT_SUCCESS;
 }
 
-DAT_RETURN
-connect_ep( char *hostname, DAT_CONN_QUAL conn_id )
+DAT_RETURN connect_ep(char *hostname, DAT_CONN_QUAL conn_id)
 {
-    DAT_SOCK_ADDR           remote_addr;
-    DAT_RETURN              ret;
-    DAT_REGION_DESCRIPTION  region;
-    DAT_EVENT               event;
-    DAT_COUNT               nmore;
-    DAT_LMR_TRIPLET         l_iov;
-    DAT_RMR_TRIPLET         r_iov;
-    DAT_DTO_COOKIE          cookie;
-    int                     i;
-    unsigned char           *buf;
-    DAT_CR_PARAM            cr_param = { 0 };
-    unsigned char	    pdata[48] = { 0 };
-    
-     /* Register send message buffer */
-    LOGPRINTF("%d Registering send Message Buffer %p, len %d\n",
-               getpid(), &rmr_send_msg, (int)sizeof(DAT_RMR_TRIPLET) );
-    region.for_va = &rmr_send_msg;
-    ret = dat_lmr_create(  h_ia,
-                           DAT_MEM_TYPE_VIRTUAL,
-                           region,
-                           sizeof(DAT_RMR_TRIPLET),
-                           h_pz,
-                           DAT_MEM_PRIV_LOCAL_WRITE_FLAG,
-			   DAT_VA_TYPE_VA,
-                           &h_lmr_send_msg,
-                           &lmr_context_send_msg,
-                           &rmr_context_send_msg,
-                           &registered_size_send_msg,
-                           &registered_addr_send_msg );
+	DAT_SOCK_ADDR remote_addr;
+	DAT_RETURN ret;
+	DAT_REGION_DESCRIPTION region;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET l_iov;
+	DAT_RMR_TRIPLET r_iov;
+	DAT_DTO_COOKIE cookie;
+	int i;
+	unsigned char *buf;
+	DAT_CR_PARAM cr_param = { 0 };
+	unsigned char pdata[48] = { 0 };
 
-     if (ret != DAT_SUCCESS) {
-       fprintf(stderr, "%d Error registering send msg buffer: %s\n",
-               getpid(),DT_RetToString(ret));
-       return(ret);
-    }
-    else
-       LOGPRINTF("%d Registered send Message Buffer %p \n",
-               getpid(),region.for_va );
+	/* Register send message buffer */
+	LOGPRINTF("%d Registering send Message Buffer %p, len %d\n",
+		  getpid(), &rmr_send_msg, (int)sizeof(DAT_RMR_TRIPLET));
+	region.for_va = &rmr_send_msg;
+	ret = dat_lmr_create(h_ia,
+			     DAT_MEM_TYPE_VIRTUAL,
+			     region,
+			     sizeof(DAT_RMR_TRIPLET),
+			     h_pz,
+			     DAT_MEM_PRIV_LOCAL_WRITE_FLAG,
+			     DAT_VA_TYPE_VA,
+			     &h_lmr_send_msg,
+			     &lmr_context_send_msg,
+			     &rmr_context_send_msg,
+			     &registered_size_send_msg,
+			     &registered_addr_send_msg);
 
-    /* Register Receive buffers */
-    LOGPRINTF("%d Registering Receive Message Buffer %p\n",
-               getpid(), rmr_recv_msg );
-    region.for_va = rmr_recv_msg;
-    ret = dat_lmr_create(  h_ia,
-                           DAT_MEM_TYPE_VIRTUAL,
-                           region,
-                           sizeof(DAT_RMR_TRIPLET)*MSG_BUF_COUNT,
-                           h_pz,
-                           DAT_MEM_PRIV_LOCAL_WRITE_FLAG,
-			   DAT_VA_TYPE_VA,
-                           &h_lmr_recv_msg,
-                           &lmr_context_recv_msg,
-                           &rmr_context_recv_msg,
-                           &registered_size_recv_msg,
-                           &registered_addr_recv_msg );
-    if(ret != DAT_SUCCESS) {
-       fprintf(stderr, "%d Error registering recv msg buffer: %s\n",
-               getpid(),DT_RetToString(ret));
-       return(ret);
-    }
-    else
-       LOGPRINTF("%d Registered Receive Message Buffer %p\n",
-               getpid(),region.for_va);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error registering send msg buffer: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else
+		LOGPRINTF("%d Registered send Message Buffer %p \n",
+			  getpid(), region.for_va);
 
-    for ( i = 0; i < MSG_BUF_COUNT; i++ ) {
-       cookie.as_64          = i;
-       l_iov.lmr_context     = lmr_context_recv_msg;
+	/* Register Receive buffers */
+	LOGPRINTF("%d Registering Receive Message Buffer %p\n",
+		  getpid(), rmr_recv_msg);
+	region.for_va = rmr_recv_msg;
+	ret = dat_lmr_create(h_ia,
+			     DAT_MEM_TYPE_VIRTUAL,
+			     region,
+			     sizeof(DAT_RMR_TRIPLET) * MSG_BUF_COUNT,
+			     h_pz,
+			     DAT_MEM_PRIV_LOCAL_WRITE_FLAG,
+			     DAT_VA_TYPE_VA,
+			     &h_lmr_recv_msg,
+			     &lmr_context_recv_msg,
+			     &rmr_context_recv_msg,
+			     &registered_size_recv_msg,
+			     &registered_addr_recv_msg);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error registering recv msg buffer: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else
+		LOGPRINTF("%d Registered Receive Message Buffer %p\n",
+			  getpid(), region.for_va);
+
+	for (i = 0; i < MSG_BUF_COUNT; i++) {
+		cookie.as_64 = i;
+		l_iov.lmr_context = lmr_context_recv_msg;
 #if defined(_WIN32)
-       l_iov.virtual_address = (DAT_VADDR)&rmr_recv_msg[ i ];
+		l_iov.virtual_address = (DAT_VADDR) & rmr_recv_msg[i];
 #else
-       l_iov.virtual_address = (DAT_VADDR)(unsigned long)&rmr_recv_msg[ i ];
+		l_iov.virtual_address =
+		    (DAT_VADDR) (unsigned long)&rmr_recv_msg[i];
 #endif
-       l_iov.segment_length  = sizeof(DAT_RMR_TRIPLET);
+		l_iov.segment_length = sizeof(DAT_RMR_TRIPLET);
 
-       LOGPRINTF("%d Posting Receive Message Buffer %p\n",
-                   getpid(), &rmr_recv_msg[ i ]);
-       ret = dat_ep_post_recv( h_ep,
-                               1,
-                               &l_iov,
-                               cookie,
-                               DAT_COMPLETION_DEFAULT_FLAG );
+		LOGPRINTF("%d Posting Receive Message Buffer %p\n",
+			  getpid(), &rmr_recv_msg[i]);
+		ret = dat_ep_post_recv(h_ep,
+				       1,
+				       &l_iov,
+				       cookie, DAT_COMPLETION_DEFAULT_FLAG);
 
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error registering recv msg buffer: %s\n",
-                           getpid(),DT_RetToString(ret));
-           return(ret);
-        }
-       else
-           LOGPRINTF("%d Registered Receive Message Buffer %p\n",
-                                   getpid(),region.for_va);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d Error registering recv msg buffer: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else
+			LOGPRINTF("%d Registered Receive Message Buffer %p\n",
+				  getpid(), region.for_va);
 
-    }
+	}
 
-    /* setup receive rdma buffer to initial string to be overwritten */
-    strcpy( (char*)rbuf, "blah, blah, blah\n" );
+	/* setup receive rdma buffer to initial string to be overwritten */
+	strcpy((char *)rbuf, "blah, blah, blah\n");
 
-    if ( server ) {  /* SERVER */
+	if (server) {		/* SERVER */
 
-        /* create the service point for server listen */
-        LOGPRINTF("%d Creating service point for listen\n",getpid());
-       ret = dat_psp_create(   h_ia,
-                               conn_id,
-                               h_cr_evd,
-                               DAT_PSP_CONSUMER_FLAG,
-                               &h_psp );
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_psp_create: %s\n",
-                           getpid(),DT_RetToString(ret));
-           return(ret);
-       }
-       else
-           LOGPRINTF("%d dat_psp_created for server listen\n", getpid());
+		/* create the service point for server listen */
+		LOGPRINTF("%d Creating service point for listen\n", getpid());
+		ret = dat_psp_create(h_ia,
+				     conn_id,
+				     h_cr_evd, DAT_PSP_CONSUMER_FLAG, &h_psp);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_psp_create: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else
+			LOGPRINTF("%d dat_psp_created for server listen\n",
+				  getpid());
 
-       printf("%d Server waiting for connect request on port "F64x"\n", 
-		getpid(), conn_id);
-       
-       ret = dat_evd_wait( h_cr_evd, SERVER_TIMEOUT, 1, &event, &nmore );
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_evd_wait: %s\n",
-                           getpid(),DT_RetToString(ret));
-           return(ret);
-       }
-       else
-           LOGPRINTF("%d dat_evd_wait for cr_evd completed\n", getpid());
+		printf("%d Server waiting for connect request on port " F64x
+		       "\n", getpid(), conn_id);
 
-       if ( event.event_number != DAT_CONNECTION_REQUEST_EVENT ) {
-            fprintf(stderr, "%d Error unexpected cr event : %s\n",
-                                   getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-       }
-       if ( (event.event_data.cr_arrival_event_data.conn_qual != SERVER_CONN_QUAL) ||
-            (event.event_data.cr_arrival_event_data.sp_handle.psp_handle != h_psp) ) {
-            fprintf(stderr, "%d Error wrong cr event data : %s\n",
-                   getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-       }
-       
-       /* use to test rdma_cma timeout logic */
+		ret = dat_evd_wait(h_cr_evd, SERVER_TIMEOUT, 1, &event, &nmore);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_evd_wait: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else
+			LOGPRINTF("%d dat_evd_wait for cr_evd completed\n",
+				  getpid());
+
+		if (event.event_number != DAT_CONNECTION_REQUEST_EVENT) {
+			fprintf(stderr, "%d Error unexpected cr event : %s\n",
+				getpid(), DT_EventToSTr(event.event_number));
+			return (DAT_ABORT);
+		}
+		if ((event.event_data.cr_arrival_event_data.conn_qual !=
+		     SERVER_CONN_QUAL)
+		    || (event.event_data.cr_arrival_event_data.sp_handle.
+			psp_handle != h_psp)) {
+			fprintf(stderr, "%d Error wrong cr event data : %s\n",
+				getpid(), DT_EventToSTr(event.event_number));
+			return (DAT_ABORT);
+		}
+
+		/* use to test rdma_cma timeout logic */
 #if defined(_WIN32) || defined(_WIN64)
-       if (delay) Sleep(delay*1000);
+		if (delay)
+			Sleep(delay * 1000);
 #else
-       if (delay) sleep(delay);
+		if (delay)
+			sleep(delay);
 #endif
 
-        /* accept connect request from client */
-       h_cr = event.event_data.cr_arrival_event_data.cr_handle;
-       LOGPRINTF("%d Accepting connect request from client\n",getpid());
+		/* accept connect request from client */
+		h_cr = event.event_data.cr_arrival_event_data.cr_handle;
+		LOGPRINTF("%d Accepting connect request from client\n",
+			  getpid());
 
-       /* private data - check and send it back */
-       dat_cr_query( h_cr, DAT_CSP_FIELD_ALL, &cr_param); 
+		/* private data - check and send it back */
+		dat_cr_query(h_cr, DAT_CSP_FIELD_ALL, &cr_param);
 
-       buf = (unsigned char*)cr_param.private_data;
-       LOGPRINTF("%d CONN REQUEST Private Data %p[0]=%d [47]=%d\n",
-                 getpid(),buf,buf[0],buf[47]);
-       for (i=0;i<48;i++) {
-           if (buf[i] != i+1) {
-               fprintf(stderr, "%d Error with CONNECT REQUEST"
-                       " private data: %p[%d]=%d s/be %d\n",
-                       getpid(), buf, i, buf[i], i+1);
-               dat_cr_reject(h_cr, 0, NULL);
-               return(DAT_ABORT);
-           }
-	   buf[i]++; /* change for trip back */
-       }	
+		buf = (unsigned char *)cr_param.private_data;
+		LOGPRINTF("%d CONN REQUEST Private Data %p[0]=%d [47]=%d\n",
+			  getpid(), buf, buf[0], buf[47]);
+		for (i = 0; i < 48; i++) {
+			if (buf[i] != i + 1) {
+				fprintf(stderr, "%d Error with CONNECT REQUEST"
+					" private data: %p[%d]=%d s/be %d\n",
+					getpid(), buf, i, buf[i], i + 1);
+				dat_cr_reject(h_cr, 0, NULL);
+				return (DAT_ABORT);
+			}
+			buf[i]++;	/* change for trip back */
+		}
 
 #ifdef TEST_REJECT_WITH_PRIVATE_DATA
-       printf("%d REJECT request with 48 bytes of private data\n", getpid());
-       ret = dat_cr_reject(h_cr, 48, cr_param.private_data);
-       printf("\n%d: DAPL Test Complete. %s\n\n",
-	      getpid(), ret?"FAILED":"PASSED");
-       exit(0);
+		printf("%d REJECT request with 48 bytes of private data\n",
+		       getpid());
+		ret = dat_cr_reject(h_cr, 48, cr_param.private_data);
+		printf("\n%d: DAPL Test Complete. %s\n\n",
+		       getpid(), ret ? "FAILED" : "PASSED");
+		exit(0);
 #endif
 
-       ret = dat_cr_accept(h_cr, h_ep, 48, cr_param.private_data);
+		ret = dat_cr_accept(h_cr, h_ep, 48, cr_param.private_data);
 
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_cr_accept: %s\n",
-                   getpid(),DT_RetToString(ret));
-           return(ret);
-       }
-       else
-           LOGPRINTF("%d dat_cr_accept completed\n", getpid());
-    }
-    else {  /* CLIENT */
-       struct addrinfo *target;
-       int             rval;
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_cr_accept: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else
+			LOGPRINTF("%d dat_cr_accept completed\n", getpid());
+	} else {		/* CLIENT */
+		struct addrinfo *target;
+		int rval;
 
 #if defined(_WIN32) || defined(_WIN64)
-       if ((rval=getaddrinfo (hostname, "ftp", NULL, &target)) != 0) {
-           printf("\n remote name resolution failed! %s\n",gai_strerror(rval));
-           exit ( 1 );
-       }
-       rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;
+		if ((rval = getaddrinfo(hostname, "ftp", NULL, &target)) != 0) {
+			printf("\n remote name resolution failed! %s\n",
+			       gai_strerror(rval));
+			exit(1);
+		}
+		rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;
 #else
-       if (getaddrinfo (hostname, NULL, NULL, &target) != 0) {
-           perror("\n remote name resolution failed!");
-           exit ( 1 );
-       }
-       rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;
+		if (getaddrinfo(hostname, NULL, NULL, &target) != 0) {
+			perror("\n remote name resolution failed!");
+			exit(1);
+		}
+		rval = ((struct sockaddr_in *)target->ai_addr)->sin_addr.s_addr;
 #endif
-       printf ("%d Server Name: %s \n", getpid(), hostname);
-       printf ("%d Server Net Address: %d.%d.%d.%d port "F64x"\n", getpid(),
-               (rval >>  0) & 0xff, (rval >>  8) & 0xff,
-               (rval >> 16) & 0xff, (rval >> 24) & 0xff, conn_id);
+		printf("%d Server Name: %s \n", getpid(), hostname);
+		printf("%d Server Net Address: %d.%d.%d.%d port " F64x "\n",
+		       getpid(), (rval >> 0) & 0xff, (rval >> 8) & 0xff,
+		       (rval >> 16) & 0xff, (rval >> 24) & 0xff, conn_id);
 
-       remote_addr = *((DAT_IA_ADDRESS_PTR)target->ai_addr);
-       freeaddrinfo(target);
+		remote_addr = *((DAT_IA_ADDRESS_PTR) target->ai_addr);
+		freeaddrinfo(target);
 
-       for (i=0;i<48;i++) /* simple pattern in private data */
-           pdata[i]=i+1;
+		for (i = 0; i < 48; i++)	/* simple pattern in private data */
+			pdata[i] = i + 1;
 
-       LOGPRINTF("%d Connecting to server\n",getpid());
-       ret = dat_ep_connect(   h_ep,
-                               &remote_addr,
-                               conn_id,
-                               CONN_TIMEOUT,
-                               48,
-                               (DAT_PVOID)pdata,
-                               0,
-                               DAT_CONNECT_DEFAULT_FLAG  );
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_ep_connect: %s\n",
-                               getpid(), DT_RetToString(ret));
-           return(ret);
-       }
-       else
-           LOGPRINTF("%d dat_ep_connect completed\n", getpid());
-    }
+		LOGPRINTF("%d Connecting to server\n", getpid());
+		ret = dat_ep_connect(h_ep,
+				     &remote_addr,
+				     conn_id,
+				     CONN_TIMEOUT,
+				     48,
+				     (DAT_PVOID) pdata,
+				     0, DAT_CONNECT_DEFAULT_FLAG);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_ep_connect: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else
+			LOGPRINTF("%d dat_ep_connect completed\n", getpid());
+	}
 
-    printf("%d Waiting for connect response\n",getpid());
+	printf("%d Waiting for connect response\n", getpid());
 
-    ret = dat_evd_wait( h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore );
-    if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_evd_wait: %s\n",
-                           getpid(),DT_RetToString(ret));
-           return(ret);
-    }
-    else
-           LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n", getpid());
+	ret = dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_evd_wait: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else
+		LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n",
+			  getpid());
 
 #ifdef TEST_REJECT_WITH_PRIVATE_DATA
-    if (event.event_number != DAT_CONNECTION_EVENT_PEER_REJECTED) {
-           fprintf(stderr, "%d expected conn reject event : %s\n",
-                               getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-    }
-    /* get the reject private data and validate */
-    buf = (unsigned char*)event.event_data.connect_event_data.private_data;
-    printf("%d Received REJECT with private data %p[0]=%d [47]=%d\n",
-           getpid(),buf,buf[0],buf[47]);
-    for (i=0;i<48;i++) {
-        if (buf[i] != i+2) {
-            fprintf(stderr, "%d client: Error with REJECT event"
-                    " private data: %p[%d]=%d s/be %d\n",
-                    getpid(), buf, i, buf[i], i+2);
-            dat_ep_disconnect( h_ep, DAT_CLOSE_ABRUPT_FLAG);
-            return(DAT_ABORT);
-        }
-    }
-    printf("\n%d: DAPL Test Complete. PASSED\n\n", getpid());
-    exit(0);
+	if (event.event_number != DAT_CONNECTION_EVENT_PEER_REJECTED) {
+		fprintf(stderr, "%d expected conn reject event : %s\n",
+			getpid(), DT_EventToSTr(event.event_number));
+		return (DAT_ABORT);
+	}
+	/* get the reject private data and validate */
+	buf = (unsigned char *)event.event_data.connect_event_data.private_data;
+	printf("%d Received REJECT with private data %p[0]=%d [47]=%d\n",
+	       getpid(), buf, buf[0], buf[47]);
+	for (i = 0; i < 48; i++) {
+		if (buf[i] != i + 2) {
+			fprintf(stderr, "%d client: Error with REJECT event"
+				" private data: %p[%d]=%d s/be %d\n",
+				getpid(), buf, i, buf[i], i + 2);
+			dat_ep_disconnect(h_ep, DAT_CLOSE_ABRUPT_FLAG);
+			return (DAT_ABORT);
+		}
+	}
+	printf("\n%d: DAPL Test Complete. PASSED\n\n", getpid());
+	exit(0);
 #endif
 
-    if ( event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED ) {
-           fprintf(stderr, "%d Error unexpected conn event : %s\n",
-                               getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-    }
+	if (event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED) {
+		fprintf(stderr, "%d Error unexpected conn event : %s\n",
+			getpid(), DT_EventToSTr(event.event_number));
+		return (DAT_ABORT);
+	}
 
-    /* check private data back from server  */
-    if (!server) {
-        buf = (unsigned char*)event.event_data.connect_event_data.private_data;
-        LOGPRINTF("%d CONN Private Data %p[0]=%d [47]=%d\n",
-                  getpid(),buf,buf[0],buf[47]);
-        for (i=0;i<48;i++) {
-            if (buf[i] != i+2) {
-                fprintf(stderr, "%d Error with CONNECT event"
-                        " private data: %p[%d]=%d s/be %d\n",
-                        getpid(), buf, i, buf[i], i+2);
-                dat_ep_disconnect(h_ep, DAT_CLOSE_ABRUPT_FLAG);
-                LOGPRINTF("%d waiting for disconnect event...\n", getpid());
-                dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore);
-                return(DAT_ABORT);
-            }
-        }
-    }
+	/* check private data back from server  */
+	if (!server) {
+		buf =
+		    (unsigned char *)event.event_data.connect_event_data.
+		    private_data;
+		LOGPRINTF("%d CONN Private Data %p[0]=%d [47]=%d\n", getpid(),
+			  buf, buf[0], buf[47]);
+		for (i = 0; i < 48; i++) {
+			if (buf[i] != i + 2) {
+				fprintf(stderr, "%d Error with CONNECT event"
+					" private data: %p[%d]=%d s/be %d\n",
+					getpid(), buf, i, buf[i], i + 2);
+				dat_ep_disconnect(h_ep, DAT_CLOSE_ABRUPT_FLAG);
+				LOGPRINTF
+				    ("%d waiting for disconnect event...\n",
+				     getpid());
+				dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE,
+					     1, &event, &nmore);
+				return (DAT_ABORT);
+			}
+		}
+	}
 
-    printf("\n%d CONNECTED!\n\n",getpid());
-    connected = 1;
+	printf("\n%d CONNECTED!\n\n", getpid());
+	connected = 1;
 
 #if CONNECT_ONLY
-    return 0;
+	return 0;
 #endif
 
-    /*
-     *  Setup our remote memory and tell the other side about it
-     */
-    rmr_send_msg.virtual_address = hton64((DAT_VADDR)(uintptr_t)rbuf);
-    rmr_send_msg.segment_length  = hton32(RDMA_BUFFER_SIZE);
-    rmr_send_msg.rmr_context     = hton32(rmr_context_recv);
+	/*
+	 *  Setup our remote memory and tell the other side about it
+	 */
+	rmr_send_msg.virtual_address = htonll((DAT_VADDR) (uintptr_t) rbuf);
+	rmr_send_msg.segment_length = htonl(RDMA_BUFFER_SIZE);
+	rmr_send_msg.rmr_context = htonl(rmr_context_recv);
 
-    printf("%d Send RMR msg to remote: r_key_ctx=0x%x,va=%p,len=0x%x\n",
-           getpid(), rmr_context_recv, rbuf, RDMA_BUFFER_SIZE );
+	printf("%d Send RMR msg to remote: r_key_ctx=0x%x,va=%p,len=0x%x\n",
+	       getpid(), rmr_context_recv, rbuf, RDMA_BUFFER_SIZE);
 
-    ret = send_msg(&rmr_send_msg,
-                   sizeof( DAT_RMR_TRIPLET ),
-                   lmr_context_send_msg,
-                   cookie,
-                   DAT_COMPLETION_SUPPRESS_FLAG);
+	ret = send_msg(&rmr_send_msg,
+		       sizeof(DAT_RMR_TRIPLET),
+		       lmr_context_send_msg,
+		       cookie, DAT_COMPLETION_SUPPRESS_FLAG);
 
-    if(ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d Error send_msg: %s\n",
-               getpid(),DT_RetToString(ret));
-       return(ret);
-    }
-    else
-       LOGPRINTF("%d send_msg completed\n", getpid());
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error send_msg: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else
+		LOGPRINTF("%d send_msg completed\n", getpid());
 
-    /*
-     *  Wait for remote RMR information for RDMA
-     */
-    if ( polling ) {
-       printf("%d Polling for remote to send RMR data\n",getpid());
-       while (  dat_evd_dequeue( h_dto_rcv_evd, &event ) == DAT_QUEUE_EMPTY );
-    }
-    else  {
-       printf("%d Waiting for remote to send RMR data\n",getpid());
-       if (use_cno)
-       {
-           DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
-           ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );
-           LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);
-           if ( evd != h_dto_rcv_evd ) {
-               fprintf(stderr,
-                       "%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",
-                       getpid());
-               return( DAT_ABORT );
-           }
-       }
-       /* use wait to dequeue */
-       ret = dat_evd_wait( h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore );
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error waiting on h_dto_rcv_evd: %s\n",
-                   getpid(),DT_RetToString(ret));
-           return(ret);
-       }
-       else {
-           LOGPRINTF("%d dat_evd_wait h_dto_rcv_evd completed\n", getpid());
-       }
-    }
+	/*
+	 *  Wait for remote RMR information for RDMA
+	 */
+	if (polling) {
+		printf("%d Polling for remote to send RMR data\n", getpid());
+		while (dat_evd_dequeue(h_dto_rcv_evd, &event) ==
+		       DAT_QUEUE_EMPTY) ;
+	} else {
+		printf("%d Waiting for remote to send RMR data\n", getpid());
+		if (use_cno) {
+			DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
+			ret = dat_cno_wait(h_dto_cno, DTO_TIMEOUT, &evd);
+			LOGPRINTF("%d cno wait return evd_handle=%p\n",
+				  getpid(), evd);
+			if (evd != h_dto_rcv_evd) {
+				fprintf(stderr,
+					"%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",
+					getpid());
+				return (DAT_ABORT);
+			}
+		}
+		/* use wait to dequeue */
+		ret =
+		    dat_evd_wait(h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d Error waiting on h_dto_rcv_evd: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d dat_evd_wait h_dto_rcv_evd completed\n",
+				  getpid());
+		}
+	}
 
-    printf("%d remote RMR data arrived!\n",getpid());
+	printf("%d remote RMR data arrived!\n", getpid());
 
-    if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {
-        fprintf(stderr, "%d Error unexpected DTO event : %s\n",
-               getpid(),DT_EventToSTr(event.event_number));
-        return( DAT_ABORT );
-    }
-    if ((event.event_data.dto_completion_event_data.transfered_length !=
-               sizeof( DAT_RMR_TRIPLET )) ||
-       (event.event_data.dto_completion_event_data.user_cookie.as_64 !=
-               recv_msg_index) ) {
-       fprintf(stderr,"ERR recv event: len=%d cookie="F64x" expected %d/%d\n",
-           (int)event.event_data.dto_completion_event_data.transfered_length,
-           event.event_data.dto_completion_event_data.user_cookie.as_64,
-           (int)sizeof(DAT_RMR_TRIPLET), recv_msg_index );
-       return( DAT_ABORT );
-    }
+	if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+		fprintf(stderr, "%d Error unexpected DTO event : %s\n",
+			getpid(), DT_EventToSTr(event.event_number));
+		return (DAT_ABORT);
+	}
+	if ((event.event_data.dto_completion_event_data.transfered_length !=
+	     sizeof(DAT_RMR_TRIPLET)) ||
+	    (event.event_data.dto_completion_event_data.user_cookie.as_64 !=
+	     recv_msg_index)) {
+		fprintf(stderr,
+			"ERR recv event: len=%d cookie=" F64x
+			" expected %d/%d\n",
+			(int)event.event_data.dto_completion_event_data.
+			transfered_length,
+			event.event_data.dto_completion_event_data.user_cookie.
+			as_64, (int)sizeof(DAT_RMR_TRIPLET), recv_msg_index);
+		return (DAT_ABORT);
+	}
 
-    /* swap received RMR msg: network order to host order */
-    r_iov = rmr_recv_msg[recv_msg_index];
-    rmr_recv_msg[recv_msg_index].rmr_context = 
-	    ntoh32(r_iov.rmr_context);
-    rmr_recv_msg[recv_msg_index].virtual_address = 
-	    ntoh64(r_iov.virtual_address);
-    rmr_recv_msg[recv_msg_index].segment_length = 
-	    ntoh32(r_iov.segment_length);
+	/* swap received RMR msg: network order to host order */
+	r_iov = rmr_recv_msg[recv_msg_index];
+	rmr_recv_msg[recv_msg_index].rmr_context = ntohl(r_iov.rmr_context);
+	rmr_recv_msg[recv_msg_index].virtual_address =
+	    ntohll(r_iov.virtual_address);
+	rmr_recv_msg[recv_msg_index].segment_length =
+	    ntohl(r_iov.segment_length);
 
-    printf("%d Received RMR from remote: "
-           "r_iov: r_key_ctx=%x,va="F64x",len=0x%x\n",
-           getpid(), rmr_recv_msg[recv_msg_index].rmr_context,
-           rmr_recv_msg[recv_msg_index].virtual_address,
-           rmr_recv_msg[recv_msg_index].segment_length );
+	printf("%d Received RMR from remote: "
+	       "r_iov: r_key_ctx=%x,va=" F64x ",len=0x%x\n",
+	       getpid(), rmr_recv_msg[recv_msg_index].rmr_context,
+	       rmr_recv_msg[recv_msg_index].virtual_address,
+	       rmr_recv_msg[recv_msg_index].segment_length);
 
-    recv_msg_index++;
+	recv_msg_index++;
 
-    return ( DAT_SUCCESS );
+	return (DAT_SUCCESS);
 }
 
-void
-disconnect_ep( void )
+void disconnect_ep(void)
 {
-    DAT_RETURN ret;
-    DAT_EVENT  event;
-    DAT_COUNT  nmore;
+	DAT_RETURN ret;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
 
-    if (connected) {
+	if (connected) {
 
-       /* 
-        * Only the client needs to call disconnect. The server _should_ be able
-        * to just wait on the EVD associated with connection events for a
-        * disconnect request and then exit.
-        */
-       if ( !server ) {
-           LOGPRINTF("%d dat_ep_disconnect\n", getpid());
-           ret = dat_ep_disconnect( h_ep, DAT_CLOSE_DEFAULT );
-           if(ret != DAT_SUCCESS)  {
-                   fprintf(stderr, "%d Error dat_ep_disconnect: %s\n",
-                           getpid(),DT_RetToString(ret));
-           }
-           else {
-               LOGPRINTF("%d dat_ep_disconnect completed\n", getpid());
-           }
-       }
-       else {
-           LOGPRINTF("%d Server waiting for disconnect...\n", getpid());
-       }
+		/* 
+		 * Only the client needs to call disconnect. The server _should_ be able
+		 * to just wait on the EVD associated with connection events for a
+		 * disconnect request and then exit.
+		 */
+		if (!server) {
+			LOGPRINTF("%d dat_ep_disconnect\n", getpid());
+			ret = dat_ep_disconnect(h_ep, DAT_CLOSE_DEFAULT);
+			if (ret != DAT_SUCCESS) {
+				fprintf(stderr,
+					"%d Error dat_ep_disconnect: %s\n",
+					getpid(), DT_RetToString(ret));
+			} else {
+				LOGPRINTF("%d dat_ep_disconnect completed\n",
+					  getpid());
+			}
+		} else {
+			LOGPRINTF("%d Server waiting for disconnect...\n",
+				  getpid());
+		}
 
-       ret = dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event, &nmore);
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_evd_wait: %s\n",
-                           	getpid(),DT_RetToString(ret));
-    	}
-    	else {
-           LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n", getpid());
-    	}
-    }
+		ret =
+		    dat_evd_wait(h_conn_evd, DAT_TIMEOUT_INFINITE, 1, &event,
+				 &nmore);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_evd_wait: %s\n",
+				getpid(), DT_RetToString(ret));
+		} else {
+			LOGPRINTF("%d dat_evd_wait for h_conn_evd completed\n",
+				  getpid());
+		}
+	}
 
-    /* destroy service point */
-    if (( server ) && ( h_psp != DAT_HANDLE_NULL )) {
-       ret = dat_psp_free( h_psp );
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_psp_free: %s\n",
-                   getpid(),DT_RetToString(ret));
-       }
-       else {
-           LOGPRINTF("%d dat_psp_free completed\n", getpid());
-       }
-    }
+	/* destroy service point */
+	if ((server) && (h_psp != DAT_HANDLE_NULL)) {
+		ret = dat_psp_free(h_psp);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_psp_free: %s\n",
+				getpid(), DT_RetToString(ret));
+		} else {
+			LOGPRINTF("%d dat_psp_free completed\n", getpid());
+		}
+	}
 
-    /* Unregister Send message Buffer */
-    if ( h_lmr_send_msg != DAT_HANDLE_NULL ) {
-       LOGPRINTF("%d Unregister send message h_lmr %p \n",getpid(),h_lmr_send_msg);
-       ret = dat_lmr_free(h_lmr_send_msg);
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error deregistering send msg mr: %s\n",
-           getpid(), DT_RetToString(ret));
-       } else {
-           LOGPRINTF("%d Unregistered send message Buffer\n",getpid());
-           h_lmr_send_msg = NULL;
-       }
-    }
+	/* Unregister Send message Buffer */
+	if (h_lmr_send_msg != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Unregister send message h_lmr %p \n", getpid(),
+			  h_lmr_send_msg);
+		ret = dat_lmr_free(h_lmr_send_msg);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d Error deregistering send msg mr: %s\n",
+				getpid(), DT_RetToString(ret));
+		} else {
+			LOGPRINTF("%d Unregistered send message Buffer\n",
+				  getpid());
+			h_lmr_send_msg = NULL;
+		}
+	}
 
-    /* Unregister recv message Buffer */
-    if ( h_lmr_recv_msg != DAT_HANDLE_NULL ) {
-       LOGPRINTF("%d Unregister recv message h_lmr %p \n",getpid(),h_lmr_recv_msg);
-       ret = dat_lmr_free(h_lmr_recv_msg);
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error deregistering recv msg mr: %s\n",
-                           getpid(), DT_RetToString(ret));
-       } else {
-           LOGPRINTF("%d Unregistered recv message Buffer\n",getpid());
-           h_lmr_recv_msg = NULL;
-       }
-    }
-    return;
+	/* Unregister recv message Buffer */
+	if (h_lmr_recv_msg != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Unregister recv message h_lmr %p \n", getpid(),
+			  h_lmr_recv_msg);
+		ret = dat_lmr_free(h_lmr_recv_msg);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d Error deregistering recv msg mr: %s\n",
+				getpid(), DT_RetToString(ret));
+		} else {
+			LOGPRINTF("%d Unregistered recv message Buffer\n",
+				  getpid());
+			h_lmr_recv_msg = NULL;
+		}
+	}
+	return;
 }
 
-
-DAT_RETURN
-do_rdma_write_with_msg( void )
+DAT_RETURN do_rdma_write_with_msg(void)
 {
-       DAT_EVENT               event;
-       DAT_COUNT               nmore;
-       DAT_LMR_TRIPLET         l_iov[MSG_IOV_COUNT];
-       DAT_RMR_TRIPLET         r_iov;
-       DAT_DTO_COOKIE          cookie;
-       DAT_RETURN              ret;
-       int                     i;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET l_iov[MSG_IOV_COUNT];
+	DAT_RMR_TRIPLET r_iov;
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN ret;
+	int i;
 
-       printf("\n %d RDMA WRITE DATA with SEND MSG\n\n",getpid());
+	printf("\n %d RDMA WRITE DATA with SEND MSG\n\n", getpid());
 
-       cookie.as_64 = 0x5555;
+	cookie.as_64 = 0x5555;
 
-       if ( recv_msg_index >= MSG_BUF_COUNT )
-               return( DAT_ABORT );
+	if (recv_msg_index >= MSG_BUF_COUNT)
+		return (DAT_ABORT);
 
-       /* get RMR information from previously received message */
-       r_iov = rmr_recv_msg[ recv_msg_index-1 ];
+	/* get RMR information from previously received message */
+	r_iov = rmr_recv_msg[recv_msg_index - 1];
 
-       if ( server )
-           strcpy( (char*)sbuf, "server RDMA write data..." );
-       else
-           strcpy( (char*)sbuf, "client RDMA write data..." );
+	if (server)
+		strcpy((char *)sbuf, "server RDMA write data...");
+	else
+		strcpy((char *)sbuf, "client RDMA write data...");
 
-       for (i=0;i<MSG_IOV_COUNT;i++) {
-	   l_iov[i].lmr_context     = lmr_context_send;
-	   l_iov[i].segment_length  = buf_len/MSG_IOV_COUNT;
-	   l_iov[i].virtual_address = (DAT_VADDR)(uintptr_t)
-					(&sbuf[l_iov[i].segment_length*i]);
+	for (i = 0; i < MSG_IOV_COUNT; i++) {
+		l_iov[i].lmr_context = lmr_context_send;
+		l_iov[i].segment_length = buf_len / MSG_IOV_COUNT;
+		l_iov[i].virtual_address = (DAT_VADDR) (uintptr_t)
+		    (&sbuf[l_iov[i].segment_length * i]);
 
-	   LOGPRINTF("%d rdma_write iov[%d] buf=%p,len=%d\n", 
-			getpid(), i, &sbuf[l_iov[i].segment_length*i],
-			l_iov[i].segment_length);
-       }
+		LOGPRINTF("%d rdma_write iov[%d] buf=%p,len=%d\n",
+			  getpid(), i, &sbuf[l_iov[i].segment_length * i],
+			  l_iov[i].segment_length);
+	}
 
-       start = get_time();
-       for (i=0;i<burst;i++) {
-           cookie.as_64 = 0x9999;
-           ret = dat_ep_post_rdma_write(   h_ep,               // ep_handle
-                                           MSG_IOV_COUNT,      // num_segments
-                                           l_iov,              // LMR
-                                           cookie,             // user_cookie
-                                           &r_iov,             // RMR
-                                           DAT_COMPLETION_SUPPRESS_FLAG );
-           if (ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d: ERROR: dat_ep_post_rdma_write() %s\n",
-                                       getpid(),DT_RetToString(ret));
-               return( DAT_ABORT );
-           }
-           LOGPRINTF("%d rdma_write # %d completed\n", getpid(),i+1);
-       }
+	start = get_time();
+	for (i = 0; i < burst; i++) {
+		cookie.as_64 = 0x9999;
+		ret = dat_ep_post_rdma_write(h_ep,	// ep_handle
+					     MSG_IOV_COUNT,	// num_segments
+					     l_iov,	// LMR
+					     cookie,	// user_cookie
+					     &r_iov,	// RMR
+					     DAT_COMPLETION_SUPPRESS_FLAG);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d: ERROR: dat_ep_post_rdma_write() %s\n",
+				getpid(), DT_RetToString(ret));
+			return (DAT_ABORT);
+		}
+		LOGPRINTF("%d rdma_write # %d completed\n", getpid(), i + 1);
+	}
 
-       /*
-        *  Send RMR information a 2nd time to indicate completion
-        *  NOTE: already swapped to network order in connect_ep
-        */
-       printf("%d Sending RDMA WRITE completion message\n",getpid());
+	/*
+	 *  Send RMR information a 2nd time to indicate completion
+	 *  NOTE: already swapped to network order in connect_ep
+	 */
+	printf("%d Sending RDMA WRITE completion message\n", getpid());
 
-       ret = send_msg( &rmr_send_msg,
-                       sizeof( DAT_RMR_TRIPLET ),
-                       lmr_context_send_msg,
-                       cookie,
-                       DAT_COMPLETION_SUPPRESS_FLAG );
+	ret = send_msg(&rmr_send_msg,
+		       sizeof(DAT_RMR_TRIPLET),
+		       lmr_context_send_msg,
+		       cookie, DAT_COMPLETION_SUPPRESS_FLAG);
 
-       if(ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d Error send_msg: %s\n",
-                               getpid(),DT_RetToString(ret));
-               return(ret);
-       } else {
-               LOGPRINTF("%d send_msg completed\n", getpid());
-       }
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error send_msg: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d send_msg completed\n", getpid());
+	}
 
-       /*
-        *  Collect first event, write completion or the inbound recv 
-        */
-       if (polling) {
-           while (dat_evd_dequeue(h_dto_rcv_evd, &event) == DAT_QUEUE_EMPTY)
-               rdma_wr_poll_count++;
-       }
-       else {
-           LOGPRINTF("%d waiting for message receive event\n", getpid());
-           if (use_cno)  {
-                   DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
-                   ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );
-                   LOGPRINTF("%d cno wait return evd_handle=%p\n",
-				getpid(),evd);
-                   if ( evd != h_dto_rcv_evd ) {
-                           fprintf(stderr, "%d Error waiting on h_dto_cno: "
-				   "evd != h_dto_rcv_evd\n",
-                                   getpid());
-                           return( ret );
-                   }
-           }
-           /* use wait to dequeue */
-           ret = dat_evd_wait(h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore);
-           if (ret != DAT_SUCCESS) {
-                   fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",
-                                           getpid(),DT_RetToString(ret));
-                   return( ret );
-           }
-       }
-       stop = get_time();
-       time.rdma_wr = ((stop - start)*1.0e6);
+	/*
+	 *  Collect first event, write completion or the inbound recv 
+	 */
+	if (polling) {
+		while (dat_evd_dequeue(h_dto_rcv_evd, &event) ==
+		       DAT_QUEUE_EMPTY)
+			rdma_wr_poll_count++;
+	} else {
+		LOGPRINTF("%d waiting for message receive event\n", getpid());
+		if (use_cno) {
+			DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
+			ret = dat_cno_wait(h_dto_cno, DTO_TIMEOUT, &evd);
+			LOGPRINTF("%d cno wait return evd_handle=%p\n",
+				  getpid(), evd);
+			if (evd != h_dto_rcv_evd) {
+				fprintf(stderr,
+					"%d Error waiting on h_dto_cno: "
+					"evd != h_dto_rcv_evd\n", getpid());
+				return (ret);
+			}
+		}
+		/* use wait to dequeue */
+		ret =
+		    dat_evd_wait(h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		}
+	}
+	stop = get_time();
+	time.rdma_wr = ((stop - start) * 1.0e6);
 
-       /* validate event number and status */
-       printf("%d inbound rdma_write; send message arrived!\n",getpid());
-       if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {
-           fprintf(stderr, "%d Error unexpected DTO event : %s\n",
-                               getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-       }
+	/* validate event number and status */
+	printf("%d inbound rdma_write; send message arrived!\n", getpid());
+	if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+		fprintf(stderr, "%d Error unexpected DTO event : %s\n",
+			getpid(), DT_EventToSTr(event.event_number));
+		return (DAT_ABORT);
+	}
 
-       if ( (event.event_data.dto_completion_event_data.transfered_length != sizeof( DAT_RMR_TRIPLET )) ||
-            (event.event_data.dto_completion_event_data.user_cookie.as_64 != recv_msg_index) ) {
-           fprintf(stderr,"unexpected event data for receive: len=%d cookie="F64x" exp %d/%d\n",
-               (int)event.event_data.dto_completion_event_data.transfered_length,
-               event.event_data.dto_completion_event_data.user_cookie.as_64,
-               (int)sizeof(DAT_RMR_TRIPLET), recv_msg_index );
+	if ((event.event_data.dto_completion_event_data.transfered_length !=
+	     sizeof(DAT_RMR_TRIPLET))
+	    || (event.event_data.dto_completion_event_data.user_cookie.as_64 !=
+		recv_msg_index)) {
+		fprintf(stderr,
+			"unexpected event data for receive: len=%d cookie=" F64x
+			" exp %d/%d\n",
+			(int)event.event_data.dto_completion_event_data.
+			transfered_length,
+			event.event_data.dto_completion_event_data.user_cookie.
+			as_64, (int)sizeof(DAT_RMR_TRIPLET), recv_msg_index);
 
-           return( DAT_ABORT );
-       }
+		return (DAT_ABORT);
+	}
 
-       /* swap received RMR msg: network order to host order */
-       r_iov = rmr_recv_msg[recv_msg_index];
-       rmr_recv_msg[recv_msg_index].virtual_address =
-    		ntoh64(rmr_recv_msg[recv_msg_index].virtual_address);
-       rmr_recv_msg[recv_msg_index].segment_length =
-    		ntoh32(rmr_recv_msg[recv_msg_index].segment_length);
-       rmr_recv_msg[recv_msg_index].rmr_context =
-    		ntoh32(rmr_recv_msg[recv_msg_index].rmr_context);
+	/* swap received RMR msg: network order to host order */
+	r_iov = rmr_recv_msg[recv_msg_index];
+	rmr_recv_msg[recv_msg_index].virtual_address =
+	    ntohll(rmr_recv_msg[recv_msg_index].virtual_address);
+	rmr_recv_msg[recv_msg_index].segment_length =
+	    ntohl(rmr_recv_msg[recv_msg_index].segment_length);
+	rmr_recv_msg[recv_msg_index].rmr_context =
+	    ntohl(rmr_recv_msg[recv_msg_index].rmr_context);
 
-       printf("%d Received RMR from remote: "
-              "r_iov: r_key_ctx=%x,va="F64x",len=0x%x\n",
-              getpid(), rmr_recv_msg[recv_msg_index].rmr_context,
-              rmr_recv_msg[recv_msg_index].virtual_address,
-              rmr_recv_msg[recv_msg_index].segment_length);
+	printf("%d Received RMR from remote: "
+	       "r_iov: r_key_ctx=%x,va=" F64x ",len=0x%x\n",
+	       getpid(), rmr_recv_msg[recv_msg_index].rmr_context,
+	       rmr_recv_msg[recv_msg_index].virtual_address,
+	       rmr_recv_msg[recv_msg_index].segment_length);
 
-       LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",
-	         getpid());
+	LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",
+		  getpid());
 
-       printf("%d %s RDMA write buffer contains: %s\n",
-                       getpid(),
-                       server ? "SERVER:" : "CLIENT:",
-                       rbuf );
+	printf("%d %s RDMA write buffer contains: %s\n",
+	       getpid(), server ? "SERVER:" : "CLIENT:", rbuf);
 
-       recv_msg_index++;
+	recv_msg_index++;
 
-       return ( DAT_SUCCESS );
+	return (DAT_SUCCESS);
 }
 
-DAT_RETURN
-do_rdma_read_with_msg( void )
+DAT_RETURN do_rdma_read_with_msg(void)
 {
-       DAT_EVENT               event;
-       DAT_COUNT               nmore;
-       DAT_LMR_TRIPLET         l_iov;
-       DAT_RMR_TRIPLET         r_iov;
-       DAT_DTO_COOKIE          cookie;
-       DAT_RETURN              ret;
-       int                     i;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET l_iov;
+	DAT_RMR_TRIPLET r_iov;
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN ret;
+	int i;
 
-       printf("\n %d RDMA READ DATA with SEND MSG\n\n",getpid());
+	printf("\n %d RDMA READ DATA with SEND MSG\n\n", getpid());
 
-       if (recv_msg_index >= MSG_BUF_COUNT)
-               return( DAT_ABORT );
+	if (recv_msg_index >= MSG_BUF_COUNT)
+		return (DAT_ABORT);
 
-       /* get RMR information from previously received message */
-       r_iov = rmr_recv_msg[recv_msg_index-1];
+	/* get RMR information from previously received message */
+	r_iov = rmr_recv_msg[recv_msg_index - 1];
 
-       /* setup rdma read buffer to initial string to be overwritten */
-       strcpy((char*)sbuf, "blah, blah, blah\n");
+	/* setup rdma read buffer to initial string to be overwritten */
+	strcpy((char *)sbuf, "blah, blah, blah\n");
 
-       if (server)
-           strcpy((char*)rbuf, "server RDMA read data...");
-       else
-           strcpy((char*)rbuf, "client RDMA read data...");
+	if (server)
+		strcpy((char *)rbuf, "server RDMA read data...");
+	else
+		strcpy((char *)rbuf, "client RDMA read data...");
 
-       l_iov.lmr_context     = lmr_context_send;
-       l_iov.virtual_address = (DAT_VADDR)(uintptr_t)sbuf;
-       l_iov.segment_length  = buf_len;
- 	
-       for (i=0;i<MAX_RDMA_RD;i++) {
-	    cookie.as_64 = 0x9999;
-	    start = get_time();
-	    ret = dat_ep_post_rdma_read(h_ep,		// ep_handle
-					1,		// num_segments
-					&l_iov,		// LMR
-					cookie,		// user_cookie
-					&r_iov,		// RMR
-					DAT_COMPLETION_DEFAULT_FLAG );
-	    if (ret != DAT_SUCCESS) {
-		fprintf(stderr, "%d: ERROR: dat_ep_post_rdma_read() %s\n", 
-					getpid(),DT_RetToString(ret));
-		return(DAT_ABORT);
-	    }
-	    
-	    if (polling) {
-		while (dat_evd_dequeue(h_dto_req_evd, &event) == DAT_QUEUE_EMPTY)
-			rdma_rd_poll_count[i]++;
-	    } 
-	    else {
-		LOGPRINTF("%d waiting for rdma_read completion event\n", getpid());
-		if (use_cno) {
-			DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
-			ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );
-			LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);
-			if ( evd != h_dto_req_evd ) {
-	    			fprintf(stderr, 
-				"%d Error waiting on h_dto_cno: evd != h_dto_req_evd\n", 
-				getpid());
-				return( DAT_ABORT );
+	l_iov.lmr_context = lmr_context_send;
+	l_iov.virtual_address = (DAT_VADDR) (uintptr_t) sbuf;
+	l_iov.segment_length = buf_len;
+
+	for (i = 0; i < MAX_RDMA_RD; i++) {
+		cookie.as_64 = 0x9999;
+		start = get_time();
+		ret = dat_ep_post_rdma_read(h_ep,	// ep_handle
+					    1,	// num_segments
+					    &l_iov,	// LMR
+					    cookie,	// user_cookie
+					    &r_iov,	// RMR
+					    DAT_COMPLETION_DEFAULT_FLAG);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d: ERROR: dat_ep_post_rdma_read() %s\n",
+				getpid(), DT_RetToString(ret));
+			return (DAT_ABORT);
+		}
+
+		if (polling) {
+			while (dat_evd_dequeue(h_dto_req_evd, &event) ==
+			       DAT_QUEUE_EMPTY)
+				rdma_rd_poll_count[i]++;
+		} else {
+			LOGPRINTF("%d waiting for rdma_read completion event\n",
+				  getpid());
+			if (use_cno) {
+				DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
+				ret =
+				    dat_cno_wait(h_dto_cno, DTO_TIMEOUT, &evd);
+				LOGPRINTF("%d cno wait return evd_handle=%p\n",
+					  getpid(), evd);
+				if (evd != h_dto_req_evd) {
+					fprintf(stderr,
+						"%d Error waiting on h_dto_cno: evd != h_dto_req_evd\n",
+						getpid());
+					return (DAT_ABORT);
+				}
 			}
+			/* use wait to dequeue */
+			ret =
+			    dat_evd_wait(h_dto_req_evd, DTO_TIMEOUT, 1, &event,
+					 &nmore);
+			if (ret != DAT_SUCCESS) {
+				fprintf(stderr,
+					"%d: ERROR: DTO dat_evd_wait() %s\n",
+					getpid(), DT_RetToString(ret));
+				return ret;
+			}
 		}
-		/* use wait to dequeue */
-		ret = dat_evd_wait( h_dto_req_evd, DTO_TIMEOUT, 1, &event, &nmore );
-		if (ret != DAT_SUCCESS) {
-			fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n", 
-				getpid(),DT_RetToString(ret));
-			return ret;
+		/* validate event number, len, cookie, and status */
+		if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+			fprintf(stderr, "%d: ERROR: DTO event number %s\n",
+				getpid(), DT_EventToSTr(event.event_number));
+			return (DAT_ABORT);
 		}
-	    }
-	    /* validate event number, len, cookie, and status */
-	    if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
-		fprintf(stderr, "%d: ERROR: DTO event number %s\n", 
-			getpid(),DT_EventToSTr(event.event_number));
-		return( DAT_ABORT );
-	    }
-	    if ((event.event_data.dto_completion_event_data.transfered_length != buf_len ) ||
-		(event.event_data.dto_completion_event_data.user_cookie.as_64 != 0x9999 )) {
-		fprintf(stderr, "%d: ERROR: DTO len %d or cookie "F64x"\n", 
-			getpid(),
-			event.event_data.dto_completion_event_data.transfered_length,
-			event.event_data.dto_completion_event_data.user_cookie.as_64 );
-		return( DAT_ABORT );
-	    }
-	    if (event.event_data.dto_completion_event_data.status != DAT_SUCCESS) {
-		fprintf(stderr, "%d: ERROR: DTO event status %s\n", 
-			getpid(),DT_RetToString(ret));
-		return( DAT_ABORT );
-	    }
-	    stop = get_time();
-	    time.rdma_rd[i] = ((stop - start)*1.0e6);
-	    time.rdma_rd_total += time.rdma_rd[i];
+		if ((event.event_data.dto_completion_event_data.
+		     transfered_length != buf_len)
+		    || (event.event_data.dto_completion_event_data.user_cookie.
+			as_64 != 0x9999)) {
+			fprintf(stderr,
+				"%d: ERROR: DTO len %d or cookie " F64x "\n",
+				getpid(),
+				event.event_data.dto_completion_event_data.
+				transfered_length,
+				event.event_data.dto_completion_event_data.
+				user_cookie.as_64);
+			return (DAT_ABORT);
+		}
+		if (event.event_data.dto_completion_event_data.status !=
+		    DAT_SUCCESS) {
+			fprintf(stderr, "%d: ERROR: DTO event status %s\n",
+				getpid(), DT_RetToString(ret));
+			return (DAT_ABORT);
+		}
+		stop = get_time();
+		time.rdma_rd[i] = ((stop - start) * 1.0e6);
+		time.rdma_rd_total += time.rdma_rd[i];
 
-	    LOGPRINTF("%d rdma_read # %d completed\n", getpid(),i+1);
-       }
+		LOGPRINTF("%d rdma_read # %d completed\n", getpid(), i + 1);
+	}
 
-       /*
-        *  Send RMR information a 3rd time to indicate completion
-        *  NOTE: already swapped to network order in connect_ep
-        */
-       printf("%d Sending RDMA read completion message\n",getpid());
+	/*
+	 *  Send RMR information a 3rd time to indicate completion
+	 *  NOTE: already swapped to network order in connect_ep
+	 */
+	printf("%d Sending RDMA read completion message\n", getpid());
 
-       ret = send_msg( &rmr_send_msg,
-                       sizeof( DAT_RMR_TRIPLET ),
-                       lmr_context_send_msg,
-                       cookie,
-                       DAT_COMPLETION_SUPPRESS_FLAG );
+	ret = send_msg(&rmr_send_msg,
+		       sizeof(DAT_RMR_TRIPLET),
+		       lmr_context_send_msg,
+		       cookie, DAT_COMPLETION_SUPPRESS_FLAG);
 
-       if(ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d Error send_msg: %s\n",
-                               getpid(),DT_RetToString(ret));
-               return(ret);
-       } else {
-               LOGPRINTF("%d send_msg completed\n", getpid());
-       }
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error send_msg: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d send_msg completed\n", getpid());
+	}
 
-       /*
-        *  Collect first event, write completion or the inbound recv with immed
-        */
-       printf("%d Waiting for inbound message....\n",getpid());
-       if ( polling ) {
-           while (  dat_evd_dequeue( h_dto_rcv_evd, &event ) == DAT_QUEUE_EMPTY );
-       }
-       else {
-           LOGPRINTF("%d waiting for message receive event\n", getpid());
-           if (use_cno) {
-                   DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
-                   ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );
-                   LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);
-                   if ( evd != h_dto_rcv_evd ) {
-                           fprintf(stderr, 
-				   "%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",
-                                   getpid());
-                           return( ret );
-                   }
-           }
-           /* use wait to dequeue */
-           ret = dat_evd_wait( h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore );
-           if (ret != DAT_SUCCESS) {
-                   fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",
-                                           getpid(),DT_RetToString(ret));
-                   return( ret );
-           }
-       }
+	/*
+	 *  Collect first event, write completion or the inbound recv with immed
+	 */
+	printf("%d Waiting for inbound message....\n", getpid());
+	if (polling) {
+		while (dat_evd_dequeue(h_dto_rcv_evd, &event) ==
+		       DAT_QUEUE_EMPTY) ;
+	} else {
+		LOGPRINTF("%d waiting for message receive event\n", getpid());
+		if (use_cno) {
+			DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
+			ret = dat_cno_wait(h_dto_cno, DTO_TIMEOUT, &evd);
+			LOGPRINTF("%d cno wait return evd_handle=%p\n",
+				  getpid(), evd);
+			if (evd != h_dto_rcv_evd) {
+				fprintf(stderr,
+					"%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",
+					getpid());
+				return (ret);
+			}
+		}
+		/* use wait to dequeue */
+		ret =
+		    dat_evd_wait(h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		}
+	}
 
-       /* validate event number and status */
-       printf("%d inbound rdma_read; send message arrived!\n",getpid());
-       if (event.event_number != DAT_DTO_COMPLETION_EVENT ) {
-           fprintf(stderr, "%d Error unexpected DTO event : %s\n",
-                               getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-       }
+	/* validate event number and status */
+	printf("%d inbound rdma_read; send message arrived!\n", getpid());
+	if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+		fprintf(stderr, "%d Error unexpected DTO event : %s\n",
+			getpid(), DT_EventToSTr(event.event_number));
+		return (DAT_ABORT);
+	}
 
-       if ((event.event_data.dto_completion_event_data.transfered_length != sizeof( DAT_RMR_TRIPLET)) ||
-            (event.event_data.dto_completion_event_data.user_cookie.as_64 != recv_msg_index)) {
+	if ((event.event_data.dto_completion_event_data.transfered_length !=
+	     sizeof(DAT_RMR_TRIPLET))
+	    || (event.event_data.dto_completion_event_data.user_cookie.as_64 !=
+		recv_msg_index)) {
 
-           fprintf(stderr,"unexpected event data for receive: len=%d cookie="F64x" exp %d/%d\n",
-               (int)event.event_data.dto_completion_event_data.transfered_length,
-               event.event_data.dto_completion_event_data.user_cookie.as_64,
-               (int)sizeof(DAT_RMR_TRIPLET), recv_msg_index );
+		fprintf(stderr,
+			"unexpected event data for receive: len=%d cookie=" F64x
+			" exp %d/%d\n",
+			(int)event.event_data.dto_completion_event_data.
+			transfered_length,
+			event.event_data.dto_completion_event_data.user_cookie.
+			as_64, (int)sizeof(DAT_RMR_TRIPLET), recv_msg_index);
 
-           return( DAT_ABORT );
-       }
+		return (DAT_ABORT);
+	}
 
-       /* swap received RMR msg: network order to host order */
-       r_iov = rmr_recv_msg[recv_msg_index];
-       rmr_recv_msg[recv_msg_index].virtual_address =
-    		ntoh64(rmr_recv_msg[recv_msg_index].virtual_address);
-       rmr_recv_msg[recv_msg_index].segment_length =
-    		ntoh32(rmr_recv_msg[ recv_msg_index].segment_length);
-       rmr_recv_msg[recv_msg_index].rmr_context =
-    		ntoh32(rmr_recv_msg[recv_msg_index].rmr_context);
+	/* swap received RMR msg: network order to host order */
+	r_iov = rmr_recv_msg[recv_msg_index];
+	rmr_recv_msg[recv_msg_index].virtual_address =
+	    ntohll(rmr_recv_msg[recv_msg_index].virtual_address);
+	rmr_recv_msg[recv_msg_index].segment_length =
+	    ntohl(rmr_recv_msg[recv_msg_index].segment_length);
+	rmr_recv_msg[recv_msg_index].rmr_context =
+	    ntohl(rmr_recv_msg[recv_msg_index].rmr_context);
 
-       printf("%d Received RMR from remote: "
-              "r_iov: r_key_ctx=%x,va="F64x",len=0x%x\n",
-              getpid(), rmr_recv_msg[recv_msg_index].rmr_context,
-              rmr_recv_msg[recv_msg_index].virtual_address,
-              rmr_recv_msg[recv_msg_index].segment_length);
+	printf("%d Received RMR from remote: "
+	       "r_iov: r_key_ctx=%x,va=" F64x ",len=0x%x\n",
+	       getpid(), rmr_recv_msg[recv_msg_index].rmr_context,
+	       rmr_recv_msg[recv_msg_index].virtual_address,
+	       rmr_recv_msg[recv_msg_index].segment_length);
 
-       LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",getpid());
+	LOGPRINTF("%d inbound rdma_write; send msg event SUCCESS!!\n",
+		  getpid());
 
-       printf("%d %s RCV RDMA read buffer contains: %s\n",
-                       getpid(),
-                       server ? "SERVER:" : "CLIENT:",
-                       sbuf );
+	printf("%d %s RCV RDMA read buffer contains: %s\n",
+	       getpid(), server ? "SERVER:" : "CLIENT:", sbuf);
 
-       recv_msg_index++;
+	recv_msg_index++;
 
-       return ( DAT_SUCCESS );
+	return (DAT_SUCCESS);
 }
 
-
-DAT_RETURN
-do_ping_pong_msg( )
+DAT_RETURN do_ping_pong_msg()
 {
-    DAT_EVENT          event;
-    DAT_COUNT          nmore;
-    DAT_DTO_COOKIE     cookie;
-    DAT_LMR_TRIPLET    l_iov;
-    DAT_RETURN         ret;
-    int                i;
-    char               *snd_buf;
-    char               *rcv_buf;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_DTO_COOKIE cookie;
+	DAT_LMR_TRIPLET l_iov;
+	DAT_RETURN ret;
+	int i;
+	char *snd_buf;
+	char *rcv_buf;
 
-    printf("\n %d PING DATA with SEND MSG\n\n",getpid());
+	printf("\n %d PING DATA with SEND MSG\n\n", getpid());
 
-    snd_buf = sbuf;
-    rcv_buf = rbuf;
+	snd_buf = sbuf;
+	rcv_buf = rbuf;
 
-    /* pre-post all buffers */
-    for ( i=0; i < burst; i++ ) {
-       burst_msg_posted++;
-       cookie.as_64          = i;
-       l_iov.lmr_context     = lmr_context_recv;
-       l_iov.virtual_address = (DAT_VADDR)(uintptr_t)rcv_buf;
-       l_iov.segment_length  = buf_len;
+	/* pre-post all buffers */
+	for (i = 0; i < burst; i++) {
+		burst_msg_posted++;
+		cookie.as_64 = i;
+		l_iov.lmr_context = lmr_context_recv;
+		l_iov.virtual_address = (DAT_VADDR) (uintptr_t) rcv_buf;
+		l_iov.segment_length = buf_len;
 
-       LOGPRINTF("%d Pre-posting Receive Message Buffers %p\n",
-                   getpid(), rcv_buf );
+		LOGPRINTF("%d Pre-posting Receive Message Buffers %p\n",
+			  getpid(), rcv_buf);
 
-       ret = dat_ep_post_recv( h_ep,
-                               1,
-                               &l_iov,
-                               cookie,
-                               DAT_COMPLETION_DEFAULT_FLAG );
+		ret = dat_ep_post_recv(h_ep,
+				       1,
+				       &l_iov,
+				       cookie, DAT_COMPLETION_DEFAULT_FLAG);
 
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error posting recv msg buffer: %s\n",
-                           getpid(),DT_RetToString(ret));
-           return(ret);
-        }
-       else {
-           LOGPRINTF("%d Posted Receive Message Buffer %p\n",getpid(),rcv_buf);
-        }
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr,
+				"%d Error posting recv msg buffer: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Posted Receive Message Buffer %p\n",
+				  getpid(), rcv_buf);
+		}
 
-       /* next buffer */
-       rcv_buf += buf_len;
-    }
+		/* next buffer */
+		rcv_buf += buf_len;
+	}
 #if defined(_WIN32) || defined(_WIN64)
-    Sleep(1000);
+	Sleep(1000);
 #else
-    sleep(1);
+	sleep(1);
 #endif
 
-    /* Initialize recv_buf and index to beginning */
-    rcv_buf = rbuf;
-    burst_msg_index=0;
+	/* Initialize recv_buf and index to beginning */
+	rcv_buf = rbuf;
+	burst_msg_index = 0;
 
-    /* client ping 0x55, server pong 0xAA in first byte */
-    start = get_time();
-    for ( i=0;i<burst;i++ ) {
-       /* walk the send and recv buffers */
-       if ( !server ) {
-           *snd_buf = 0x55;
+	/* client ping 0x55, server pong 0xAA in first byte */
+	start = get_time();
+	for (i = 0; i < burst; i++) {
+		/* walk the send and recv buffers */
+		if (!server) {
+			*snd_buf = 0x55;
 
-           LOGPRINTF("%d %s SND buffer %p contains: 0x%x len=%d\n",
-                   getpid(), server ? "SERVER:" : "CLIENT:",
-                   snd_buf, *snd_buf, buf_len );
+			LOGPRINTF("%d %s SND buffer %p contains: 0x%x len=%d\n",
+				  getpid(), server ? "SERVER:" : "CLIENT:",
+				  snd_buf, *snd_buf, buf_len);
 
-           ret = send_msg( snd_buf,
-                           buf_len,
-                           lmr_context_send,
-                           cookie,
-                           DAT_COMPLETION_SUPPRESS_FLAG );
+			ret = send_msg(snd_buf,
+				       buf_len,
+				       lmr_context_send,
+				       cookie, DAT_COMPLETION_SUPPRESS_FLAG);
 
-           if(ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d Error send_msg: %s\n",
-                                   getpid(),DT_RetToString(ret));
-               return(ret);
-           }
-           else {
-               LOGPRINTF("%d send_msg completed\n", getpid());
-           }
-       }
+			if (ret != DAT_SUCCESS) {
+				fprintf(stderr, "%d Error send_msg: %s\n",
+					getpid(), DT_RetToString(ret));
+				return (ret);
+			} else {
+				LOGPRINTF("%d send_msg completed\n", getpid());
+			}
+		}
 
-       /* Wait for recv message */
-       if ( polling ) {
-           poll_count=0;
-           LOGPRINTF("%d Polling for message receive event\n", getpid());
-           while (  dat_evd_dequeue( h_dto_rcv_evd, &event ) == DAT_QUEUE_EMPTY )
-               poll_count++;
-       }
-       else {
-           LOGPRINTF("%d waiting for message receive event\n", getpid());
-           if (use_cno) {
-               DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
-               ret = dat_cno_wait( h_dto_cno, DTO_TIMEOUT, &evd );
-               LOGPRINTF("%d cno wait return evd_handle=%p\n", getpid(),evd);
-               if ( evd != h_dto_rcv_evd )
-               {
-                   fprintf(stderr, 
-			   "%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",
-                           getpid());
-                   return( ret );
-               }
-           }
-           /* use wait to dequeue */
-           ret = dat_evd_wait( h_dto_rcv_evd, DTO_TIMEOUT, 1, &event, &nmore );
-           if (ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d: ERROR: DTO dat_evd_wait() %s\n",
-                                       getpid(),DT_RetToString(ret));
-               return( ret );
-           }
-       }
-       /* start timer after first message arrives on server */
-       if ( i == 0) {
-           start = get_time();
-       }
-       /* validate event number and status */
-       LOGPRINTF("%d inbound message; message arrived!\n",getpid());
-       if ( event.event_number != DAT_DTO_COMPLETION_EVENT ) {
-           fprintf(stderr, "%d Error unexpected DTO event : %s\n",
-                   getpid(),DT_EventToSTr(event.event_number));
-           return( DAT_ABORT );
-       }
-       if ((event.event_data.dto_completion_event_data.transfered_length
-           != buf_len) ||
-           (event.event_data.dto_completion_event_data.user_cookie.as_64
-           != burst_msg_index) )  {
-           fprintf(stderr,"ERR: recv event: len=%d cookie="F64x" exp %d/%d\n",
-               (int)event.event_data.dto_completion_event_data.transfered_length,
-               event.event_data.dto_completion_event_data.user_cookie.as_64,
-               (int)buf_len, (int)burst_msg_index );
+		/* Wait for recv message */
+		if (polling) {
+			poll_count = 0;
+			LOGPRINTF("%d Polling for message receive event\n",
+				  getpid());
+			while (dat_evd_dequeue(h_dto_rcv_evd, &event) ==
+			       DAT_QUEUE_EMPTY)
+				poll_count++;
+		} else {
+			LOGPRINTF("%d waiting for message receive event\n",
+				  getpid());
+			if (use_cno) {
+				DAT_EVD_HANDLE evd = DAT_HANDLE_NULL;
+				ret =
+				    dat_cno_wait(h_dto_cno, DTO_TIMEOUT, &evd);
+				LOGPRINTF("%d cno wait return evd_handle=%p\n",
+					  getpid(), evd);
+				if (evd != h_dto_rcv_evd) {
+					fprintf(stderr,
+						"%d Error waiting on h_dto_cno: evd != h_dto_rcv_evd\n",
+						getpid());
+					return (ret);
+				}
+			}
+			/* use wait to dequeue */
+			ret =
+			    dat_evd_wait(h_dto_rcv_evd, DTO_TIMEOUT, 1, &event,
+					 &nmore);
+			if (ret != DAT_SUCCESS) {
+				fprintf(stderr,
+					"%d: ERROR: DTO dat_evd_wait() %s\n",
+					getpid(), DT_RetToString(ret));
+				return (ret);
+			}
+		}
+		/* start timer after first message arrives on server */
+		if (i == 0) {
+			start = get_time();
+		}
+		/* validate event number and status */
+		LOGPRINTF("%d inbound message; message arrived!\n", getpid());
+		if (event.event_number != DAT_DTO_COMPLETION_EVENT) {
+			fprintf(stderr, "%d Error unexpected DTO event : %s\n",
+				getpid(), DT_EventToSTr(event.event_number));
+			return (DAT_ABORT);
+		}
+		if ((event.event_data.dto_completion_event_data.
+		     transfered_length != buf_len)
+		    || (event.event_data.dto_completion_event_data.user_cookie.
+			as_64 != burst_msg_index)) {
+			fprintf(stderr,
+				"ERR: recv event: len=%d cookie=" F64x
+				" exp %d/%d\n",
+				(int)event.event_data.dto_completion_event_data.
+				transfered_length,
+				event.event_data.dto_completion_event_data.
+				user_cookie.as_64, (int)buf_len,
+				(int)burst_msg_index);
 
-           return( DAT_ABORT );
-       }
+			return (DAT_ABORT);
+		}
 
-       LOGPRINTF("%d %s RCV buffer %p contains: 0x%x len=%d\n",
-                   getpid(), server ? "SERVER:" : "CLIENT:",
-                   rcv_buf, *rcv_buf, buf_len );
+		LOGPRINTF("%d %s RCV buffer %p contains: 0x%x len=%d\n",
+			  getpid(), server ? "SERVER:" : "CLIENT:",
+			  rcv_buf, *rcv_buf, buf_len);
 
-       burst_msg_index++;
+		burst_msg_index++;
 
-       /* If server, change data and send it back to client */
-       if ( server ) {
-           *snd_buf = 0xaa;
+		/* If server, change data and send it back to client */
+		if (server) {
+			*snd_buf = 0xaa;
 
-           LOGPRINTF("%d %s SND buffer %p contains: 0x%x len=%d\n",
-                   getpid(), server ? "SERVER:" : "CLIENT:",
-                   snd_buf, *snd_buf, buf_len );
+			LOGPRINTF("%d %s SND buffer %p contains: 0x%x len=%d\n",
+				  getpid(), server ? "SERVER:" : "CLIENT:",
+				  snd_buf, *snd_buf, buf_len);
 
-           ret = send_msg( snd_buf,
-                           buf_len,
-                           lmr_context_send,
-                           cookie,
-                           DAT_COMPLETION_SUPPRESS_FLAG );
+			ret = send_msg(snd_buf,
+				       buf_len,
+				       lmr_context_send,
+				       cookie, DAT_COMPLETION_SUPPRESS_FLAG);
 
-           if(ret != DAT_SUCCESS) {
-               fprintf(stderr, "%d Error send_msg: %s\n",
-                                   getpid(),DT_RetToString(ret));
-               return(ret);
-           }
-           else {
-               LOGPRINTF("%d send_msg completed\n", getpid());
-           }
-       }
+			if (ret != DAT_SUCCESS) {
+				fprintf(stderr, "%d Error send_msg: %s\n",
+					getpid(), DT_RetToString(ret));
+				return (ret);
+			} else {
+				LOGPRINTF("%d send_msg completed\n", getpid());
+			}
+		}
 
-       /* next buffers */
-       rcv_buf += buf_len;
-       snd_buf += buf_len;
-    }
-    stop = get_time();
-    time.rtt = ((stop - start)*1.0e6);
+		/* next buffers */
+		rcv_buf += buf_len;
+		snd_buf += buf_len;
+	}
+	stop = get_time();
+	time.rtt = ((stop - start) * 1.0e6);
 
-    return ( DAT_SUCCESS );
+	return (DAT_SUCCESS);
 }
 
 /* Register RDMA Receive buffer */
-DAT_RETURN
-register_rdma_memory(void)
+DAT_RETURN register_rdma_memory(void)
 {
-    DAT_RETURN             ret;
-    DAT_REGION_DESCRIPTION region;
+	DAT_RETURN ret;
+	DAT_REGION_DESCRIPTION region;
 
-    region.for_va = rbuf;
-    start = get_time();
-    ret = dat_lmr_create(  h_ia,
-                           DAT_MEM_TYPE_VIRTUAL,
-                           region,
-                           buf_len*burst,
-                           h_pz,
-                           DAT_MEM_PRIV_ALL_FLAG,
-			   DAT_VA_TYPE_VA,
-                           &h_lmr_recv,
-                           &lmr_context_recv,
-                           &rmr_context_recv,
-                           &registered_size_recv,
-                           &registered_addr_recv );
-    stop = get_time();
-    time.reg += ((stop - start)*1.0e6);
-    time.total += time.reg;
+	region.for_va = rbuf;
+	start = get_time();
+	ret = dat_lmr_create(h_ia,
+			     DAT_MEM_TYPE_VIRTUAL,
+			     region,
+			     buf_len * (burst+1),
+			     h_pz,
+			     DAT_MEM_PRIV_ALL_FLAG,
+			     DAT_VA_TYPE_VA,
+			     &h_lmr_recv,
+			     &lmr_context_recv,
+			     &rmr_context_recv,
+			     &registered_size_recv, &registered_addr_recv);
+	stop = get_time();
+	time.reg += ((stop - start) * 1.0e6);
+	time.total += time.reg;
 
-    if(ret != DAT_SUCCESS) {
-       fprintf(stderr, "%d Error registering Receive RDMA buffer: %s\n",
-               getpid(),DT_RetToString(ret));
-       return (ret);
-    } else {
-           LOGPRINTF("%d Registered Receive RDMA Buffer %p\n",
-                       getpid(),region.for_va);
-    }
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr,
+			"%d Error registering Receive RDMA buffer: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d Registered Receive RDMA Buffer %p\n",
+			  getpid(), region.for_va);
+	}
 
-    /* Register RDMA Send buffer */
-    region.for_va = sbuf;
-    ret = dat_lmr_create(   h_ia,
-                           DAT_MEM_TYPE_VIRTUAL,
-                           region,
-                           buf_len*burst,
-                           h_pz,
-                           DAT_MEM_PRIV_ALL_FLAG,
-			   DAT_VA_TYPE_VA,
-                           &h_lmr_send,
-                           &lmr_context_send,
-                           &rmr_context_send,
-                           &registered_size_send,
-                           &registered_addr_send );
-    if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error registering send RDMA buffer: %s\n",
-                           getpid(),DT_RetToString(ret));
-           return (ret);
-    } else {
-           LOGPRINTF("%d Registered Send RDMA Buffer %p\n",
-                   getpid(),region.for_va);
-    }
+	/* Register RDMA Send buffer */
+	region.for_va = sbuf;
+	ret = dat_lmr_create(h_ia,
+			     DAT_MEM_TYPE_VIRTUAL,
+			     region,
+			     buf_len * (burst + 1),
+			     h_pz,
+			     DAT_MEM_PRIV_ALL_FLAG,
+			     DAT_VA_TYPE_VA,
+			     &h_lmr_send,
+			     &lmr_context_send,
+			     &rmr_context_send,
+			     &registered_size_send, &registered_addr_send);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error registering send RDMA buffer: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d Registered Send RDMA Buffer %p\n",
+			  getpid(), region.for_va);
+	}
 
-    return DAT_SUCCESS;
+	return DAT_SUCCESS;
 }
 
 /*
  * Unregister RDMA memory
  */
-DAT_RETURN
-unregister_rdma_memory(void)
+DAT_RETURN unregister_rdma_memory(void)
 {
-    DAT_RETURN ret;
+	DAT_RETURN ret;
 
-    /* Unregister Recv Buffer */
-    if ( h_lmr_recv != DAT_HANDLE_NULL )
-    {
-       LOGPRINTF("%d Unregister h_lmr %p \n",getpid(),h_lmr_recv);
-        start = get_time();
-       ret = dat_lmr_free(h_lmr_recv);
-        stop = get_time();
-       time.unreg += ((stop - start)*1.0e6);
-       time.total += time.unreg;
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error deregistering recv mr: %s\n",
-                       getpid(), DT_RetToString(ret));
-           return (ret);
-       }
-       else {
-           LOGPRINTF("%d Unregistered Recv Buffer\n",getpid());
-           h_lmr_recv = NULL;
-       }
-    }
+	/* Unregister Recv Buffer */
+	if (h_lmr_recv != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Unregister h_lmr %p \n", getpid(), h_lmr_recv);
+		start = get_time();
+		ret = dat_lmr_free(h_lmr_recv);
+		stop = get_time();
+		time.unreg += ((stop - start) * 1.0e6);
+		time.total += time.unreg;
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error deregistering recv mr: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Unregistered Recv Buffer\n", getpid());
+			h_lmr_recv = NULL;
+		}
+	}
 
-    /* Unregister Send Buffer */
-    if ( h_lmr_send != DAT_HANDLE_NULL ) {
-       LOGPRINTF("%d Unregister h_lmr %p \n",getpid(),h_lmr_send);
-       ret = dat_lmr_free(h_lmr_send);
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error deregistering send mr: %s\n",
-                           getpid(), DT_RetToString(ret));
-           return (ret);
-       }
-       else {
-           LOGPRINTF("%d Unregistered send Buffer\n",getpid());
-           h_lmr_send = NULL;
-       }
-    }
-    return DAT_SUCCESS;
+	/* Unregister Send Buffer */
+	if (h_lmr_send != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Unregister h_lmr %p \n", getpid(), h_lmr_send);
+		ret = dat_lmr_free(h_lmr_send);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error deregistering send mr: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Unregistered send Buffer\n", getpid());
+			h_lmr_send = NULL;
+		}
+	}
+	return DAT_SUCCESS;
 }
 
  /*
   * Create CNO, CR, CONN, and DTO events
   */
-DAT_RETURN
-create_events(void)
+DAT_RETURN create_events(void)
 {
-    DAT_RETURN ret;
-    DAT_EVD_PARAM param;
+	DAT_RETURN ret;
+	DAT_EVD_PARAM param;
 
-    /* create CNO */
-    if (use_cno) {
-        start = get_time();
+	/* create CNO */
+	if (use_cno) {
+		start = get_time();
 #if defined(_WIN32) || defined(_WIN64)
-        { DAT_OS_WAIT_PROXY_AGENT pa = {NULL, NULL};
-          ret = dat_cno_create(h_ia, pa, &h_dto_cno);
-        }
+		{
+			DAT_OS_WAIT_PROXY_AGENT pa = { NULL, NULL };
+			ret = dat_cno_create(h_ia, pa, &h_dto_cno);
+		}
 #else
-        ret = dat_cno_create(h_ia, DAT_OS_WAIT_PROXY_AGENT_NULL, &h_dto_cno);
+		ret =
+		    dat_cno_create(h_ia, DAT_OS_WAIT_PROXY_AGENT_NULL,
+				   &h_dto_cno);
 #endif
-        stop = get_time();
-       time.cnoc += ((stop - start)*1.0e6);
-       time.total += time.cnoc;
-       if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error dat_cno_create: %s\n",
-                               getpid(),DT_RetToString(ret));
-           return (ret);
-       }
-       else {
-           LOGPRINTF("%d cr_evd created, %p\n", getpid(), h_dto_cno);
-       }
-    }
+		stop = get_time();
+		time.cnoc += ((stop - start) * 1.0e6);
+		time.total += time.cnoc;
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error dat_cno_create: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d cr_evd created, %p\n", getpid(),
+				  h_dto_cno);
+		}
+	}
 
-    /* create cr EVD */
-    start = get_time();
-    ret = dat_evd_create(h_ia, 10, DAT_HANDLE_NULL, DAT_EVD_CR_FLAG, &h_cr_evd);
-    stop = get_time();
-    time.evdc += ((stop - start)*1.0e6);
-    time.total += time.evdc;
-    if(ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d Error dat_evd_create: %s\n",
-                           getpid(),DT_RetToString(ret));
-        return (ret);
-    }
-    else {
-        LOGPRINTF("%d cr_evd created %p\n", getpid(),h_cr_evd);
-    }
+	/* create cr EVD */
+	start = get_time();
+	ret =
+	    dat_evd_create(h_ia, 10, DAT_HANDLE_NULL, DAT_EVD_CR_FLAG,
+			   &h_cr_evd);
+	stop = get_time();
+	time.evdc += ((stop - start) * 1.0e6);
+	time.total += time.evdc;
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_evd_create: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d cr_evd created %p\n", getpid(), h_cr_evd);
+	}
 
-    /* create conn EVD */
-    ret = dat_evd_create( h_ia,
-                          10,
-                          DAT_HANDLE_NULL,
-                          DAT_EVD_CONNECTION_FLAG,
-                          &h_conn_evd );
-    if(ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d Error dat_evd_create: %s\n",
-                           getpid(),DT_RetToString(ret));
-        return (ret);
-    }
-    else {
-        LOGPRINTF("%d con_evd created %p\n", getpid(),h_conn_evd);
-    }
+	/* create conn EVD */
+	ret = dat_evd_create(h_ia,
+			     10,
+			     DAT_HANDLE_NULL,
+			     DAT_EVD_CONNECTION_FLAG, &h_conn_evd);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_evd_create: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d con_evd created %p\n", getpid(), h_conn_evd);
+	}
 
-    /* create dto SND EVD, with CNO if use_cno was set */
-    ret = dat_evd_create( h_ia,
-                         (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2,
-                         h_dto_cno,
-                         DAT_EVD_DTO_FLAG,
-                         &h_dto_req_evd  );
-    if(ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d Error dat_evd_create REQ: %s\n",
-                           getpid(),DT_RetToString(ret));
-        return (ret);
-    }
-    else {
-        LOGPRINTF("%d dto_req_evd created %p\n", getpid(), h_dto_req_evd );
-    }
+	/* create dto SND EVD, with CNO if use_cno was set */
+	ret = dat_evd_create(h_ia,
+			     (MSG_BUF_COUNT + MAX_RDMA_RD + burst) * 2,
+			     h_dto_cno, DAT_EVD_DTO_FLAG, &h_dto_req_evd);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_evd_create REQ: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d dto_req_evd created %p\n", getpid(),
+			  h_dto_req_evd);
+	}
 
-    /* create dto RCV EVD, with CNO if use_cno was set */
-    ret = dat_evd_create( h_ia,
-                         MSG_BUF_COUNT,
-                         h_dto_cno,
-                         DAT_EVD_DTO_FLAG,
-                         &h_dto_rcv_evd  );
-    if(ret != DAT_SUCCESS) {
-        fprintf(stderr, "%d Error dat_evd_create RCV: %s\n",
-                           getpid(),DT_RetToString(ret));
-        return (ret);
-    }
-    else {
-        LOGPRINTF("%d dto_rcv_evd created %p\n", getpid(), h_dto_rcv_evd );
-    }
+	/* create dto RCV EVD, with CNO if use_cno was set */
+	ret = dat_evd_create(h_ia,
+			     MSG_BUF_COUNT + burst,
+			     h_dto_cno, DAT_EVD_DTO_FLAG, &h_dto_rcv_evd);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_evd_create RCV: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else {
+		LOGPRINTF("%d dto_rcv_evd created %p\n", getpid(),
+			  h_dto_rcv_evd);
+	}
 
-    /* query DTO req EVD and check size */
-    ret = dat_evd_query( h_dto_req_evd,
-                          DAT_EVD_FIELD_EVD_QLEN,
-                          &param  );
-    if(ret != DAT_SUCCESS) {
-         fprintf(stderr, "%d Error dat_evd_query request evd: %s\n",
-                            getpid(),DT_RetToString(ret));
-         return (ret);
-    }
-    else if (param.evd_qlen < (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2) {
-         fprintf(stderr, "%d Error dat_evd qsize too small: %d < %d\n",
-                 getpid(), param.evd_qlen, 
-                 (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2);
-         return (ret);
-    }
-  
-    LOGPRINTF("%d dto_req_evd QLEN - requested %d and actual %d\n", 
-              getpid(), (MSG_BUF_COUNT+MAX_RDMA_RD+burst)*2,
-              param.evd_qlen);
+	/* query DTO req EVD and check size */
+	ret = dat_evd_query(h_dto_req_evd, DAT_EVD_FIELD_EVD_QLEN, &param);
+	if (ret != DAT_SUCCESS) {
+		fprintf(stderr, "%d Error dat_evd_query request evd: %s\n",
+			getpid(), DT_RetToString(ret));
+		return (ret);
+	} else if (param.evd_qlen < (MSG_BUF_COUNT + MAX_RDMA_RD + burst) * 2) {
+		fprintf(stderr, "%d Error dat_evd qsize too small: %d < %d\n",
+			getpid(), param.evd_qlen,
+			(MSG_BUF_COUNT + MAX_RDMA_RD + burst) * 2);
+		return (ret);
+	}
 
-    return DAT_SUCCESS;
+	LOGPRINTF("%d dto_req_evd QLEN - requested %d and actual %d\n",
+		  getpid(), (MSG_BUF_COUNT + MAX_RDMA_RD + burst) * 2,
+		  param.evd_qlen);
+
+	return DAT_SUCCESS;
 }
 
 /*
  * Destroy CR, CONN, CNO, and DTO events
  */
 
-DAT_RETURN
-destroy_events(void)
+DAT_RETURN destroy_events(void)
 {
-    DAT_RETURN      ret;
+	DAT_RETURN ret;
 
-       /* free cr EVD */
-    if ( h_cr_evd != DAT_HANDLE_NULL ) {
-        LOGPRINTF("%d Free cr EVD %p \n",getpid(),h_cr_evd);
-        ret = dat_evd_free( h_cr_evd );
-        if(ret != DAT_SUCCESS) {
-                   fprintf(stderr, "%d Error freeing cr EVD: %s\n",
-                           getpid(), DT_RetToString(ret));
-                       return (ret);
-           } else {
-                   LOGPRINTF("%d Freed cr EVD\n",getpid());
-            h_cr_evd = DAT_HANDLE_NULL;
-           }
-    }
+	/* free cr EVD */
+	if (h_cr_evd != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Free cr EVD %p \n", getpid(), h_cr_evd);
+		ret = dat_evd_free(h_cr_evd);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error freeing cr EVD: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Freed cr EVD\n", getpid());
+			h_cr_evd = DAT_HANDLE_NULL;
+		}
+	}
 
-    /* free conn EVD */
-    if ( h_conn_evd != DAT_HANDLE_NULL ) {
-        LOGPRINTF("%d Free conn EVD %p \n",getpid(),h_conn_evd);
-        ret = dat_evd_free( h_conn_evd );
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error freeing conn EVD: %s\n",
-                       getpid(), DT_RetToString(ret));
-           return (ret);
-       }
-       else {
-           LOGPRINTF("%d Freed conn EVD\n",getpid());
-           h_conn_evd = DAT_HANDLE_NULL;
-       }
-    }
+	/* free conn EVD */
+	if (h_conn_evd != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Free conn EVD %p \n", getpid(), h_conn_evd);
+		ret = dat_evd_free(h_conn_evd);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error freeing conn EVD: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Freed conn EVD\n", getpid());
+			h_conn_evd = DAT_HANDLE_NULL;
+		}
+	}
 
-    /* free RCV dto EVD */
-    if ( h_dto_rcv_evd != DAT_HANDLE_NULL ) {
-        LOGPRINTF("%d Free RCV dto EVD %p \n",getpid(),h_dto_rcv_evd);
-        start = get_time();
-        ret = dat_evd_free( h_dto_rcv_evd );
-        stop = get_time();
-        time.evdf += ((stop - start)*1.0e6);
-        time.total += time.evdf;
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error freeing dto EVD: %s\n",
-                           getpid(), DT_RetToString(ret));
-           return (ret);
-        }
-        else {
-           LOGPRINTF("%d Freed dto EVD\n",getpid());
-            h_dto_rcv_evd = DAT_HANDLE_NULL;
-        }
-     }
+	/* free RCV dto EVD */
+	if (h_dto_rcv_evd != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Free RCV dto EVD %p \n", getpid(), h_dto_rcv_evd);
+		start = get_time();
+		ret = dat_evd_free(h_dto_rcv_evd);
+		stop = get_time();
+		time.evdf += ((stop - start) * 1.0e6);
+		time.total += time.evdf;
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error freeing dto EVD: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Freed dto EVD\n", getpid());
+			h_dto_rcv_evd = DAT_HANDLE_NULL;
+		}
+	}
 
-    /* free REQ dto EVD */
-    if ( h_dto_req_evd != DAT_HANDLE_NULL ) {
-        LOGPRINTF("%d Free REQ dto EVD %p \n",getpid(),h_dto_req_evd);
-        ret = dat_evd_free( h_dto_req_evd );
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error freeing dto EVD: %s\n",
-                           getpid(), DT_RetToString(ret));
-           return (ret);
-       }
-       else {
-           LOGPRINTF("%d Freed dto EVD\n",getpid());
-            h_dto_req_evd = DAT_HANDLE_NULL;
-       }
-    }
+	/* free REQ dto EVD */
+	if (h_dto_req_evd != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Free REQ dto EVD %p \n", getpid(), h_dto_req_evd);
+		ret = dat_evd_free(h_dto_req_evd);
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error freeing dto EVD: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Freed dto EVD\n", getpid());
+			h_dto_req_evd = DAT_HANDLE_NULL;
+		}
+	}
 
-    /* free CNO */
-    if ( h_dto_cno != DAT_HANDLE_NULL ) {
-        LOGPRINTF("%d Free dto CNO %p \n",getpid(),h_dto_cno);
-        start = get_time();
-        ret = dat_cno_free( h_dto_cno );
-        stop = get_time();
-        time.cnof += ((stop - start)*1.0e6);
-        time.total += time.cnof;
-        if(ret != DAT_SUCCESS) {
-           fprintf(stderr, "%d Error freeing dto CNO: %s\n",
-                   getpid(), DT_RetToString(ret));
-           return (ret);
-       }
-       else {
-           LOGPRINTF("%d Freed dto CNO\n",getpid());
-            h_dto_cno = DAT_HANDLE_NULL;
-       }
-    }
-    return DAT_SUCCESS;
+	/* free CNO */
+	if (h_dto_cno != DAT_HANDLE_NULL) {
+		LOGPRINTF("%d Free dto CNO %p \n", getpid(), h_dto_cno);
+		start = get_time();
+		ret = dat_cno_free(h_dto_cno);
+		stop = get_time();
+		time.cnof += ((stop - start) * 1.0e6);
+		time.total += time.cnof;
+		if (ret != DAT_SUCCESS) {
+			fprintf(stderr, "%d Error freeing dto CNO: %s\n",
+				getpid(), DT_RetToString(ret));
+			return (ret);
+		} else {
+			LOGPRINTF("%d Freed dto CNO\n", getpid());
+			h_dto_cno = DAT_HANDLE_NULL;
+		}
+	}
+	return DAT_SUCCESS;
 }
 
 /*
  * Map DAT_RETURN values to readable strings,
  * but don't assume the values are zero-based or contiguous.
  */
-char    errmsg[512] = {0};
-const char *
-DT_RetToString (DAT_RETURN ret_value)
+char errmsg[512] = { 0 };
+const char *DT_RetToString(DAT_RETURN ret_value)
 {
-    const char *major_msg, *minor_msg;
+	const char *major_msg, *minor_msg;
 
-    dat_strerror (ret_value, &major_msg, &minor_msg);
+	dat_strerror(ret_value, &major_msg, &minor_msg);
 
-    strcpy(errmsg, major_msg);
-    strcat(errmsg, " ");
-    strcat(errmsg, minor_msg);
+	strcpy(errmsg, major_msg);
+	strcat(errmsg, " ");
+	strcat(errmsg, minor_msg);
 
-    return errmsg;
+	return errmsg;
 }
 
 /*
  * Map DAT_EVENT_CODE values to readable strings
  */
-const char *
-DT_EventToSTr (DAT_EVENT_NUMBER event_code)
+const char *DT_EventToSTr(DAT_EVENT_NUMBER event_code)
 {
-    unsigned int i;
-    static struct {
-           const char  *name;
-           DAT_RETURN  value;
-    }
-    dat_events[] =
-    {
-           #   define DATxx(x) { # x, x }
-           DATxx (DAT_DTO_COMPLETION_EVENT),
-           DATxx (DAT_RMR_BIND_COMPLETION_EVENT),
-           DATxx (DAT_CONNECTION_REQUEST_EVENT),
-           DATxx (DAT_CONNECTION_EVENT_ESTABLISHED),
-           DATxx (DAT_CONNECTION_EVENT_PEER_REJECTED),
-           DATxx (DAT_CONNECTION_EVENT_NON_PEER_REJECTED),
-           DATxx (DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR),
-           DATxx (DAT_CONNECTION_EVENT_DISCONNECTED),
-           DATxx (DAT_CONNECTION_EVENT_BROKEN),
-           DATxx (DAT_CONNECTION_EVENT_TIMED_OUT),
-           DATxx (DAT_CONNECTION_EVENT_UNREACHABLE),
-           DATxx (DAT_ASYNC_ERROR_EVD_OVERFLOW),
-           DATxx (DAT_ASYNC_ERROR_IA_CATASTROPHIC),
-           DATxx (DAT_ASYNC_ERROR_EP_BROKEN),
-           DATxx (DAT_ASYNC_ERROR_TIMED_OUT),
-           DATxx (DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR),
-           DATxx (DAT_SOFTWARE_EVENT)
-           #   undef DATxx
-    };
-    #   define NUM_EVENTS (sizeof(dat_events)/sizeof(dat_events[0]))
+	unsigned int i;
+	static struct {
+		const char *name;
+		DAT_RETURN value;
+	} dat_events[] = {
+#   define DATxx(x) { # x, x }
+		DATxx(DAT_DTO_COMPLETION_EVENT),
+		    DATxx(DAT_RMR_BIND_COMPLETION_EVENT),
+		    DATxx(DAT_CONNECTION_REQUEST_EVENT),
+		    DATxx(DAT_CONNECTION_EVENT_ESTABLISHED),
+		    DATxx(DAT_CONNECTION_EVENT_PEER_REJECTED),
+		    DATxx(DAT_CONNECTION_EVENT_NON_PEER_REJECTED),
+		    DATxx(DAT_CONNECTION_EVENT_ACCEPT_COMPLETION_ERROR),
+		    DATxx(DAT_CONNECTION_EVENT_DISCONNECTED),
+		    DATxx(DAT_CONNECTION_EVENT_BROKEN),
+		    DATxx(DAT_CONNECTION_EVENT_TIMED_OUT),
+		    DATxx(DAT_CONNECTION_EVENT_UNREACHABLE),
+		    DATxx(DAT_ASYNC_ERROR_EVD_OVERFLOW),
+		    DATxx(DAT_ASYNC_ERROR_IA_CATASTROPHIC),
+		    DATxx(DAT_ASYNC_ERROR_EP_BROKEN),
+		    DATxx(DAT_ASYNC_ERROR_TIMED_OUT),
+		    DATxx(DAT_ASYNC_ERROR_PROVIDER_INTERNAL_ERROR),
+		    DATxx(DAT_SOFTWARE_EVENT)
+#   undef DATxx
+	};
+#   define NUM_EVENTS (sizeof(dat_events)/sizeof(dat_events[0]))
 
-    for (i = 0;  i < NUM_EVENTS;  i++) {
-           if (dat_events[i].value == event_code)
-           {
-               return ( dat_events[i].name );
-           }
-    }
+	for (i = 0; i < NUM_EVENTS; i++) {
+		if (dat_events[i].value == event_code) {
+			return (dat_events[i].name);
+		}
+	}
 
-    return ( "Invalid_DAT_EVENT_NUMBER" );
+	return ("Invalid_DAT_EVENT_NUMBER");
 }
 
-
 void print_usage(void)
 {
-    printf("\n DAPL USAGE \n\n");
-    printf("s: server\n");
-    printf("t: performance times\n");
-    printf("c: use cno\n");
-    printf("v: verbose\n");
-    printf("p: polling\n");
-    printf("d: delay before accept\n");
-    printf("b: buf length to allocate\n");
-    printf("B: burst count, rdma and msgs \n");
-    printf("h: hostname/address of server, specified on client\n");
-    printf("P: provider name (default = OpenIB-cma)\n");
-    printf("\n");
+	printf("\n DAPL USAGE \n\n");
+	printf("s: server\n");
+	printf("t: performance times\n");
+	printf("c: use cno\n");
+	printf("v: verbose\n");
+	printf("p: polling\n");
+	printf("d: delay before accept\n");
+	printf("b: buf length to allocate\n");
+	printf("B: burst count, rdma and msgs \n");
+	printf("h: hostname/address of server, specified on client\n");
+	printf("P: provider name (default = OpenIB-cma)\n");
+	printf("\n");
 }
 

Modified: branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtestx.c
===================================================================
--- branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtestx.c	2009-05-28 20:18:53 UTC (rev 259)
+++ branches/ofed-1.4.1upgrade/dapl/branches/upstream/current/test/dtest/dtestx.c	2009-05-28 20:23:18 UTC (rev 260)
@@ -41,10 +41,11 @@
 #include <io.h>
 #include <process.h>
 #include <complib/cl_types.h>
+#include "..\..\..\..\etc\user\getopt.c"
 #define __BYTE_ORDER __LITTLE_ENDIAN
 
-#define getpid _getpid
 #define F64x "%I64x"
+#define F64u "%I64u"
 #define DAPL_PROVIDER "ibnic0v2"
 #else
 #include <netdb.h>
@@ -60,6 +61,7 @@
 
 #define DAPL_PROVIDER "ofa-v2-ib0"
 #define F64x "%"PRIx64""
+#define F64u "%"PRIu64""
 
 #endif
 
@@ -74,6 +76,7 @@
 	if (status != DAT_SUCCESS) {\
 		dat_strerror(status, &maj_msg, &min_msg);\
 		fprintf(stderr, str " returned %s : %s\n", maj_msg, min_msg);\
+		dat_ia_close(ia, DAT_CLOSE_DEFAULT);\
 		exit(1);\
 	} else if (verbose) {\
 		printf("dtestx: %s success\n",str);\
@@ -86,6 +89,7 @@
 	if (status != DAT_SUCCESS) {\
 		dat_strerror(status, &maj_msg, &min_msg);\
 		fprintf(stderr, str " returned %s : %s\n", maj_msg, min_msg);\
+		dat_ia_close(ia, DAT_CLOSE_DEFAULT);\
 		exit(1);\
 	} else if (verbose) {\
 		printf("dtestx: %s\n",str);\
@@ -121,7 +125,7 @@
 #define ntoh32(x) (x)
 #define hton64(x) (x)
 #define ntoh64(x) (x)
-#endif  /* __BYTE_ORDER == __BIG_ENDIAN */
+#endif				/* __BYTE_ORDER == __BIG_ENDIAN */
 
 #define MIN(a, b) ((a < b) ? (a) : (b))
 #define MAX(a, b) ((a > b) ? (a) : (b))
@@ -140,128 +144,130 @@
 #define RECV_BUF_INDEX		3
 #define MAX_EP_COUNT		8
 
-DAT_VADDR 		*atomic_buf;
-DAT_LMR_HANDLE		lmr_atomic;
-DAT_LMR_CONTEXT		lmr_atomic_context;
-DAT_RMR_CONTEXT		rmr_atomic_context;
-DAT_VLEN		reg_atomic_size;
-DAT_VADDR		reg_atomic_addr;
-DAT_LMR_HANDLE		lmr[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_LMR_CONTEXT		lmr_context[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_RMR_TRIPLET		rmr[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_RMR_CONTEXT		rmr_context[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_VLEN		reg_size[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_VADDR		reg_addr[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_RMR_TRIPLET *	buf[ REG_MEM_COUNT*MAX_EP_COUNT ];
-DAT_EP_HANDLE		ep[MAX_EP_COUNT];
-DAT_EVD_HANDLE		async_evd = DAT_HANDLE_NULL;
-DAT_IA_HANDLE		ia = DAT_HANDLE_NULL;
-DAT_PZ_HANDLE		pz = DAT_HANDLE_NULL;
-DAT_EVD_HANDLE		cr_evd = DAT_HANDLE_NULL;
-DAT_EVD_HANDLE		con_evd = DAT_HANDLE_NULL;
-DAT_EVD_HANDLE		dto_evd = DAT_HANDLE_NULL;
-DAT_PSP_HANDLE		psp = DAT_HANDLE_NULL;
-int			server = 1;
-int			ud_test = 0;
-int			multi_eps = 0;
-int			buf_size = BUF_SIZE;
-int			msg_size = sizeof(DAT_RMR_TRIPLET);
-char			provider[64] = DAPL_PROVIDER;
-char			hostname[256] = { 0 };
-DAT_IB_ADDR_HANDLE	remote_ah[MAX_EP_COUNT];
-int			eps = 1;
-int			verbose = 0;
+DAT_VADDR *atomic_buf;
+DAT_LMR_HANDLE lmr_atomic;
+DAT_LMR_CONTEXT lmr_atomic_context;
+DAT_RMR_CONTEXT rmr_atomic_context;
+DAT_VLEN reg_atomic_size;
+DAT_VADDR reg_atomic_addr;
+DAT_LMR_HANDLE lmr[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_LMR_CONTEXT lmr_context[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_RMR_TRIPLET rmr[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_RMR_CONTEXT rmr_context[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_VLEN reg_size[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_VADDR reg_addr[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_RMR_TRIPLET *buf[REG_MEM_COUNT * MAX_EP_COUNT];
+DAT_EP_HANDLE ep[MAX_EP_COUNT];
+DAT_EVD_HANDLE async_evd = DAT_HANDLE_NULL;
+DAT_IA_HANDLE ia = DAT_HANDLE_NULL;
+DAT_PZ_HANDLE pz = DAT_HANDLE_NULL;
+DAT_EVD_HANDLE cr_evd = DAT_HANDLE_NULL;
+DAT_EVD_HANDLE con_evd = DAT_HANDLE_NULL;
+DAT_EVD_HANDLE dto_evd = DAT_HANDLE_NULL;
+DAT_PSP_HANDLE psp = DAT_HANDLE_NULL;
+int server = 1;
+int remote_host = 0;
+int ud_test = 0;
+int multi_eps = 0;
+int buf_size = BUF_SIZE;
+int msg_size = sizeof(DAT_RMR_TRIPLET);
+char provider[64] = DAPL_PROVIDER;
+char hostname[256] = { 0 };
+DAT_IB_ADDR_HANDLE remote_ah[MAX_EP_COUNT];
+int eps = 1;
+int verbose = 0;
+int counters = 0;
+int counters_ok = 0;
 
 #define LOGPRINTF if (verbose) printf
 
 void print_usage(void)
 {
-    printf("\n dtestx usage \n\n");
-    printf("v: verbose\n");
-    printf("u  unreliable datagram test\n");
-    printf("U: unreliable datagram test, UD endpoint count\n");
-    printf("m  unreliable datagram test, multiple Server endpoints\n");
-    printf("b: buf length to allocate\n");
-    printf("h: hostname/address of Server, specified on Client\n");
-    printf("c: Client\n");
-    printf("s: Server, default\n");
-    printf("P: provider name (default = ofa-v2-ib0)\n");
-    printf("\n");
+	printf("\n dtestx usage \n\n");
+	printf("v: verbose\n");
+	printf("p: print counters\n");
+	printf("u  unreliable datagram test\n");
+	printf("U: unreliable datagram test, UD endpoint count\n");
+	printf("m  unreliable datagram test, multiple Server endpoints\n");
+	printf("b: buf length to allocate\n");
+	printf("h: hostname/address of Server, client and UDP server\n");
+	printf("c: Client\n");
+	printf("s: Server, default\n");
+	printf("P: provider name (default = ofa-v2-ib0)\n");
+	printf("\n");
 }
 
 #if defined(_WIN32) || defined(_WIN64)
 static void sleep(int secs)
 {
-	Sleep(secs*1000);
+	Sleep(secs * 1000);
 }
+
 #define _WSACleanup() WSACleanup()
 #else
 #define	_WSACleanup()
 #endif
 
 void
-send_msg(
-	void *data,
-	DAT_COUNT size,
-	DAT_LMR_CONTEXT context,
-	DAT_DTO_COOKIE cookie,
-	DAT_COMPLETION_FLAGS flags)
+send_msg(void *data,
+	 DAT_COUNT size,
+	 DAT_LMR_CONTEXT context,
+	 DAT_DTO_COOKIE cookie, DAT_COMPLETION_FLAGS flags)
 {
-	DAT_LMR_TRIPLET			iov;
-	DAT_EVENT			event;
-	DAT_COUNT			nmore;
-	DAT_RETURN			status;
-	int				i,ep_idx=0,ah_idx=0;
-	DAT_DTO_COMPLETION_EVENT_DATA *dto_event = 
-		&event.event_data.dto_completion_event_data;
+	DAT_LMR_TRIPLET iov;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_RETURN status;
+	int i, ep_idx = 0, ah_idx = 0;
+	DAT_DTO_COMPLETION_EVENT_DATA *dto_event =
+	    &event.event_data.dto_completion_event_data;
 
-	iov.lmr_context     = context;
-	iov.virtual_address = (DAT_VADDR)(uintptr_t)data;
-	iov.segment_length  = (DAT_VLEN)size;
+	iov.lmr_context = context;
+	iov.virtual_address = (DAT_VADDR) (uintptr_t) data;
+	iov.segment_length = (DAT_VLEN) size;
 
-	for (i=0;i<eps;i++) {
+	for (i = 0; i < eps; i++) {
 		if (ud_test) {
 			/* 
 			 * Client and Server: ep[0] and ah[0] on single 
 			 * and ep[i] on multiple (-m) endpoint options. 
-                         */
+			 */
 			if (multi_eps) {
-				ep_idx=i;
-				ah_idx=server?0:i;
-			} 
+				ep_idx = i;
+				ah_idx = server ? 0 : i;
+			}
 			printf("%s sending on ep=%p to remote_ah: ah=%p"
-				" qpn=0x%x addr=%s\n", 
-				server?"Server":"Client", ep[ep_idx],
-				remote_ah[ah_idx].ah, 
-				remote_ah[ah_idx].qpn,
-				inet_ntoa(((struct sockaddr_in *)
-				  &remote_ah[ah_idx].ia_addr)->sin_addr));
+			       " qpn=0x%x addr=%s\n",
+			       server ? "Server" : "Client", ep[ep_idx],
+			       remote_ah[ah_idx].ah,
+			       remote_ah[ah_idx].qpn,
+			       inet_ntoa(((struct sockaddr_in *)
+					  &remote_ah[ah_idx].ia_addr)->
+					 sin_addr));
 
 			/* client expects all data in on first EP */
 			status = dat_ib_post_send_ud(ep[ep_idx],
 						     1,
 						     &iov,
 						     &remote_ah[ah_idx],
-						     cookie,
-						     flags);
-			
+						     cookie, flags);
+
 		} else {
-			status = dat_ep_post_send(ep[0], 1, &iov, 
+			status = dat_ep_post_send(ep[0], 1, &iov,
 						  cookie, flags);
 		}
 		_OK(status, "dat_ep_post_send");
 
 		if (!(flags & DAT_COMPLETION_SUPPRESS_FLAG)) {
-			status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 
-					1, &event, &nmore);
+			status = dat_evd_wait(dto_evd, DTO_TIMEOUT,
+					      1, &event, &nmore);
 			_OK(status, "dat_evd_wait after dat_ep_post_send");
 
 			if (event.event_number != DAT_DTO_COMPLETION_EVENT &&
-			    ud_test && event.event_number != 
-			    DAT_IB_DTO_EVENT) {
+			    ud_test && event.event_number != DAT_IB_DTO_EVENT) {
 				printf("unexpected event waiting post_send "
-					"completion - 0x%x\n", 
-					event.event_number);
+				       "completion - 0x%x\n",
+				       event.event_number);
 				exit(1);
 			}
 			_OK(dto_event->status, "event status for post_send");
@@ -272,32 +278,32 @@
 /* RC - Server only, UD - Server and Client, one per EP */
 void process_cr(int idx)
 {
-	DAT_EVENT	event;
-	DAT_COUNT	nmore;
-	DAT_RETURN	status;
-	int		pdata;
-	DAT_CR_HANDLE	cr = DAT_HANDLE_NULL;
-	DAT_CONN_QUAL	exp_qual = server?SERVER_ID:CLIENT_ID;
-	DAT_CR_PARAM	cr_param;
-        DAT_CR_ARRIVAL_EVENT_DATA *cr_event = 
-		&event.event_data.cr_arrival_event_data;
-	       
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_RETURN status;
+	int pdata;
+	DAT_CR_HANDLE cr = DAT_HANDLE_NULL;
+	DAT_CONN_QUAL exp_qual = server ? SERVER_ID : CLIENT_ID;
+	DAT_CR_PARAM cr_param;
+	DAT_CR_ARRIVAL_EVENT_DATA *cr_event =
+	    &event.event_data.cr_arrival_event_data;
+
 	LOGPRINTF("%s waiting for connect[%d] request\n",
-		  server?"Server":"Client",idx);
+		  server ? "Server" : "Client", idx);
 
 	status = dat_evd_wait(cr_evd, SERVER_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "CR dat_evd_wait");
 
 	if (event.event_number != DAT_CONNECTION_REQUEST_EVENT &&
-		(ud_test && event.event_number != 
-			DAT_IB_UD_CONNECTION_REQUEST_EVENT)) {
+	    (ud_test && event.event_number !=
+	     DAT_IB_UD_CONNECTION_REQUEST_EVENT)) {
 		printf("unexpected event,!conn req: 0x%x\n",
-			event.event_number); 
+		       event.event_number);
 		exit(1);
 	}
 
 	if ((cr_event->conn_qual != exp_qual) ||
-		(cr_event->sp_handle.psp_handle != psp)) {
+	    (cr_event->sp_handle.psp_handle != psp)) {
 		printf("wrong cr event data\n");
 		exit(1);
 	}
@@ -307,50 +313,47 @@
 	_OK(status, "dat_cr_query");
 
 	/* use private data to select EP */
-	pdata = ntoh32(*((int*)cr_param.private_data));
-		
+	pdata = ntoh32(*((int *)cr_param.private_data));
+
 	LOGPRINTF("%s recvd pdata=0x%x, send pdata=0x%x\n",
-		  server?"Server":"Client",pdata,
-		  *(int*)cr_param.private_data);
-	
+		  server ? "Server" : "Client", pdata,
+		  *(int *)cr_param.private_data);
+
 	status = dat_cr_accept(cr, ep[pdata], 4, cr_param.private_data);
 	_OK(status, "dat_cr_accept");
-	
+
 	printf("%s accepted CR on EP[%d]=%p\n",
-		server?"Server":"Client",
-		pdata, ep[pdata]);
+	       server ? "Server" : "Client", pdata, ep[pdata]);
 }
 
 /* RC - Client and Server: 1, UD - Client: 1 per EP, Server: 2 per EP's */
 void process_conn(int idx)
 {
-	DAT_EVENT	event;
-	DAT_COUNT	nmore;
-	DAT_RETURN	status;
-	int		pdata;
- 	DAT_IB_EXTENSION_EVENT_DATA *ext_event = 
-		(DAT_IB_EXTENSION_EVENT_DATA *)
-			&event.event_extension_data[0];
-	DAT_CONNECTION_EVENT_DATA *conn_event = 
-			&event.event_data.connect_event_data;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_RETURN status;
+	int pdata;
+	DAT_IB_EXTENSION_EVENT_DATA *ext_event = (DAT_IB_EXTENSION_EVENT_DATA *)
+	    & event.event_extension_data[0];
+	DAT_CONNECTION_EVENT_DATA *conn_event =
+	    &event.event_data.connect_event_data;
 
 	LOGPRINTF("%s waiting for connect[%d] establishment\n",
-		  server?"Server":"Client",idx);
+		  server ? "Server" : "Client", idx);
 
 	status = dat_evd_wait(con_evd, CONN_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "CONN dat_evd_wait");
-	
+
 	LOGPRINTF("%s got connect[%d] event, pdata %p sz=%d\n",
-		  server?"Server":"Client",idx,
-		  conn_event->private_data,
-		  conn_event->private_data_size);
+		  server ? "Server" : "Client", idx,
+		  conn_event->private_data, conn_event->private_data_size);
 
 	/* Waiting on CR's or CONN_EST */
 	if (event.event_number != DAT_CONNECTION_EVENT_ESTABLISHED &&
-		(ud_test && event.event_number !=
-			DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED)) {
+	    (ud_test && event.event_number !=
+	     DAT_IB_UD_CONNECTION_EVENT_ESTABLISHED)) {
 		printf("unexpected event, !conn established: 0x%x\n",
-			event.event_number); 
+		       event.event_number);
 		exit(1);
 	}
 
@@ -359,9 +362,9 @@
 		return;
 
 	/* store each remote_ah according to remote EP index */
-	pdata = ntoh32(*((int*)conn_event->private_data));
-	LOGPRINTF(" Client got private data=0x%x\n", pdata);	
-	
+	pdata = ntoh32(*((int *)conn_event->private_data));
+	LOGPRINTF(" Client got private data=0x%x\n", pdata);
+
 	/* UD, get AH for sends. 
 	 * NOTE: bi-directional AH resolution results in a CONN_EST
 	 * for both outbound connect and inbound CR.
@@ -374,63 +377,75 @@
 	if (ext_event->type == DAT_IB_UD_REMOTE_AH) {
 		remote_ah[pdata] = ext_event->remote_ah;
 		printf("remote_ah[%d]: ah=%p, qpn=0x%x "
-			"addr=%s\n",
-			pdata, remote_ah[pdata].ah, 
-			remote_ah[pdata].qpn,
-			inet_ntoa(((struct sockaddr_in*)
-			&remote_ah[pdata].ia_addr)->sin_addr));
+		       "addr=%s\n",
+		       pdata, remote_ah[pdata].ah,
+		       remote_ah[pdata].qpn, inet_ntoa(((struct sockaddr_in *)
+							&remote_ah[pdata].
+							ia_addr)->sin_addr));
 
 	} else if (ext_event->type != DAT_IB_UD_PASSIVE_REMOTE_AH) {
-		printf("unexpected UD ext_event type: 0x%x\n",
-			ext_event->type); 
+		printf("unexpected UD ext_event type: 0x%x\n", ext_event->type);
 		exit(1);
 	}
 }
 
-int
-connect_ep(char *hostname)
+int connect_ep(char *hostname)
 {
-	DAT_SOCK_ADDR		remote_addr;
-	DAT_EP_ATTR		ep_attr;
-	DAT_RETURN		status;
-	DAT_REGION_DESCRIPTION	region;
-	DAT_EVENT		event;
-	DAT_COUNT		nmore;
-	DAT_LMR_TRIPLET		iov;
-	DAT_RMR_TRIPLET		*r_iov;
-	DAT_DTO_COOKIE		cookie;
-	DAT_CONN_QUAL		conn_qual;
-	int			i,ii,pdata,ctx;
-	DAT_PROVIDER_ATTR       prov_attrs;
-        DAT_DTO_COMPLETION_EVENT_DATA *dto_event = 
-		&event.event_data.dto_completion_event_data;
-	
+	DAT_SOCK_ADDR remote_addr;
+	DAT_EP_ATTR ep_attr;
+	DAT_RETURN status;
+	DAT_REGION_DESCRIPTION region;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET iov;
+	DAT_RMR_TRIPLET *r_iov;
+	DAT_DTO_COOKIE cookie;
+	DAT_CONN_QUAL conn_qual;
+	DAT_BOOLEAN in, out;
+	int i, ii, pdata, ctx;
+	DAT_PROVIDER_ATTR prov_attrs;
+	DAT_DTO_COMPLETION_EVENT_DATA *dto_event =
+	    &event.event_data.dto_completion_event_data;
+
 	status = dat_ia_open(provider, 8, &async_evd, &ia);
 	_OK(status, "dat_ia_open");
-	
+
 	memset(&prov_attrs, 0, sizeof(prov_attrs));
-	status = dat_ia_query(ia, NULL, 0, NULL, 
+	status = dat_ia_query(ia, NULL, 0, NULL,
 			      DAT_PROVIDER_FIELD_ALL, &prov_attrs);
 	_OK(status, "dat_ia_query");
 
 	/* Print provider specific attributes */
-	for (i=0;i<prov_attrs.num_provider_specific_attr;i++) {
+	for (i = 0; i < prov_attrs.num_provider_specific_attr; i++) {
 		LOGPRINTF(" Provider Specific Attribute[%d] %s=%s\n",
 			  i, prov_attrs.provider_specific_attr[i].name,
 			  prov_attrs.provider_specific_attr[i].value);
+
+		/* check for counter support */
+		status = strcmp(prov_attrs.provider_specific_attr[i].name,
+				"DAT_COUNTERS");
+		if (!status)
+			counters_ok = 1;
 	}
-	
+
+	/* make sure provider supports counters */
+	if ((counters) && (!counters_ok)) {
+		printf("Disable dat_query_counters:"
+		       " Provider not built with counters\n");
+		counters = 0;
+	}
+
 	status = dat_pz_create(ia, &pz);
 	_OK(status, "dat_pz_create");
 
-	status = dat_evd_create(ia, eps*2, DAT_HANDLE_NULL, DAT_EVD_CR_FLAG,
-				&cr_evd );
+	status = dat_evd_create(ia, eps * 2, DAT_HANDLE_NULL, DAT_EVD_CR_FLAG,
+				&cr_evd);
 	_OK(status, "dat_evd_create CR");
-	status = dat_evd_create(ia, eps*2, DAT_HANDLE_NULL,
-				DAT_EVD_CONNECTION_FLAG, &con_evd );
+	status = dat_evd_create(ia, eps * 2, DAT_HANDLE_NULL,
+				DAT_EVD_CONNECTION_FLAG, &con_evd);
 	_OK(status, "dat_evd_create CR");
-	status = dat_evd_create(ia, eps*10, DAT_HANDLE_NULL, DAT_EVD_DTO_FLAG,
-				&dto_evd );
+	status = dat_evd_create(ia, eps * 10, DAT_HANDLE_NULL, DAT_EVD_DTO_FLAG,
+				&dto_evd);
 	_OK(status, "dat_evd_create DTO");
 
 	memset(&ep_attr, 0, sizeof(ep_attr));
@@ -446,199 +461,196 @@
 		ep_attr.max_rdma_read_in = 4;
 		ep_attr.max_rdma_read_out = 4;
 	}
-	ep_attr.qos                         = 0;
-	ep_attr.recv_completion_flags       = 0;
-	ep_attr.max_recv_dtos               = eps*10;
-	ep_attr.max_request_dtos            = eps*10;
-	ep_attr.max_recv_iov                = 1;
-	ep_attr.max_request_iov             = 1;
-	ep_attr.request_completion_flags    = DAT_COMPLETION_DEFAULT_FLAG;
+	ep_attr.qos = 0;
+	ep_attr.recv_completion_flags = 0;
+	ep_attr.max_recv_dtos = eps * 10;
+	ep_attr.max_request_dtos = eps * 10;
+	ep_attr.max_recv_iov = 1;
+	ep_attr.max_request_iov = 1;
+	ep_attr.request_completion_flags = DAT_COMPLETION_DEFAULT_FLAG;
 	ep_attr.ep_transport_specific_count = 0;
-	ep_attr.ep_transport_specific       = NULL;
-	ep_attr.ep_provider_specific_count  = 0;
-	ep_attr.ep_provider_specific        = NULL;
+	ep_attr.ep_transport_specific = NULL;
+	ep_attr.ep_provider_specific_count = 0;
+	ep_attr.ep_provider_specific = NULL;
 
-	for (i=0;i<eps;i++) {
-		status = dat_ep_create(ia, pz, dto_evd, dto_evd, 
-			       con_evd, &ep_attr, &ep[i]);
+	for (i = 0; i < eps; i++) {
+		status = dat_ep_create(ia, pz, dto_evd, dto_evd,
+				       con_evd, &ep_attr, &ep[i]);
 		_OK(status, "dat_ep_create");
-		LOGPRINTF(" create_ep[%d]=%p\n",i,ep[i]);
+		LOGPRINTF(" create_ep[%d]=%p\n", i, ep[i]);
 	}
 
-	for (i=0;i<REG_MEM_COUNT*eps;i++) {
-		buf[i] = (DAT_RMR_TRIPLET*)malloc(buf_size);
+	for (i = 0; i < REG_MEM_COUNT * eps; i++) {
+		buf[i] = (DAT_RMR_TRIPLET *) malloc(buf_size);
 		region.for_va = buf[i];
 		status = dat_lmr_create(ia,
 					DAT_MEM_TYPE_VIRTUAL,
 					region,
 					buf_size,
 					pz,
-					DAT_MEM_PRIV_ALL_FLAG|
-						DAT_IB_MEM_PRIV_REMOTE_ATOMIC,
+					DAT_MEM_PRIV_ALL_FLAG |
+					DAT_IB_MEM_PRIV_REMOTE_ATOMIC,
 					DAT_VA_TYPE_VA,
 					&lmr[i],
 					&lmr_context[i],
 					&rmr_context[i],
-					&reg_size[i],
-					&reg_addr[i]);
+					&reg_size[i], &reg_addr[i]);
 		_OK(status, "dat_lmr_create");
 	}
 
 	/* register atomic return buffer for original data */
-	atomic_buf = (DAT_UINT64*)malloc(BUF_SIZE_ATOMIC);
+	atomic_buf = (DAT_UINT64 *) malloc(BUF_SIZE_ATOMIC);
 	region.for_va = atomic_buf;
 	status = dat_lmr_create(ia,
 				DAT_MEM_TYPE_VIRTUAL,
 				region,
 				BUF_SIZE_ATOMIC,
 				pz,
-				DAT_MEM_PRIV_ALL_FLAG|
-					DAT_IB_MEM_PRIV_REMOTE_ATOMIC,
+				DAT_MEM_PRIV_ALL_FLAG |
+				DAT_IB_MEM_PRIV_REMOTE_ATOMIC,
 				DAT_VA_TYPE_VA,
 				&lmr_atomic,
 				&lmr_atomic_context,
 				&rmr_atomic_context,
-				&reg_atomic_size,
-				&reg_atomic_addr);
+				&reg_atomic_size, &reg_atomic_addr);
 	_OK(status, "dat_lmr_create atomic");
-	
-	for (ii=0;ii<eps;ii++) {
+
+	for (ii = 0; ii < eps; ii++) {
 		for (i = RECV_BUF_INDEX; i < REG_MEM_COUNT; i++) {
 			int ep_idx = 0;
-			cookie.as_64 = (ii*REG_MEM_COUNT)+i;
-			iov.lmr_context = lmr_context[(ii*REG_MEM_COUNT)+i];
-			iov.virtual_address = 
-				(DAT_VADDR)(uintptr_t)buf[(ii*REG_MEM_COUNT)+i];
-			iov.segment_length  = buf_size;
+			cookie.as_64 = (ii * REG_MEM_COUNT) + i;
+			iov.lmr_context = lmr_context[(ii * REG_MEM_COUNT) + i];
+			iov.virtual_address =
+			    (DAT_VADDR) (uintptr_t) buf[(ii * REG_MEM_COUNT) +
+							i];
+			iov.segment_length = buf_size;
 			LOGPRINTF(" post_recv (%p) on ep[%d]=%p\n",
-				  buf[(ii*REG_MEM_COUNT)+i],ii,ep[ii]);
+				  buf[(ii * REG_MEM_COUNT) + i], ii, ep[ii]);
 			/* ep[0], unless testing Server and multi EP's */
 			if (server && multi_eps) {
 				ep_idx = ii;
 				cookie.as_64 = i;
 			}
 			status = dat_ep_post_recv(ep[ep_idx],
-						1,
-						&iov,
-						cookie,
-						DAT_COMPLETION_DEFAULT_FLAG);
+						  1,
+						  &iov,
+						  cookie,
+						  DAT_COMPLETION_DEFAULT_FLAG);
 			_OK(status, "dat_ep_post_recv");
 		}
 	}
 	/* setup receive buffer to initial string to be overwritten */
-	strcpy((char*)buf[ RCV_RDMA_BUF_INDEX ], "blah, blah, blah\n");
+	strcpy((char *)buf[RCV_RDMA_BUF_INDEX], "blah, blah, blah\n");
 
 	/* ud can resolve_ah and connect both ways, same EP */
 	if (server || (!server && ud_test)) {
 		if (server) {
 			conn_qual = SERVER_ID;
-			strcpy((char*)buf[SND_RDMA_BUF_INDEX],"Server data");
+			strcpy((char *)buf[SND_RDMA_BUF_INDEX], "Server data");
 		} else {
 			conn_qual = CLIENT_ID;
-			strcpy((char*)buf[SND_RDMA_BUF_INDEX],"Client data");
+			strcpy((char *)buf[SND_RDMA_BUF_INDEX], "Client data");
 		}
 		status = dat_psp_create(ia,
 					conn_qual,
-					 cr_evd,
-					 DAT_PSP_CONSUMER_FLAG,
-					 &psp);
+					cr_evd, DAT_PSP_CONSUMER_FLAG, &psp);
 		_OK(status, "dat_psp_create");
 
 		/* Server always waits for first CR from Client */
-		if (server) 
+		if (server)
 			process_cr(0);
 
-	} 
-	
+	}
+
 	/* ud can resolve_ah and connect both ways */
 	if (!server || (server && ud_test)) {
-		struct addrinfo	*target;
+		struct addrinfo *target;
 
-		if (getaddrinfo (hostname, NULL, NULL, &target) != 0) {
+		if (getaddrinfo(hostname, NULL, NULL, &target) != 0) {
 			printf("Error getting remote address.\n");
 			exit(1);
 		}
 
-		printf ("Remote %s Name: %s \n", 
-			server?"Client":"Server", hostname);
-		printf ("Remote %s Net Address: %s\n", 
-			server?"Client":"Server",
-			inet_ntoa(((struct sockaddr_in *)
-				    target->ai_addr)->sin_addr));
+		printf("Remote %s Name: %s \n",
+		       server ? "Client" : "Server", hostname);
+		printf("Remote %s Net Address: %s\n",
+		       server ? "Client" : "Server",
+		       inet_ntoa(((struct sockaddr_in *)
+				  target->ai_addr)->sin_addr));
 
-		remote_addr = *((DAT_IA_ADDRESS_PTR)target->ai_addr);
+		remote_addr = *((DAT_IA_ADDRESS_PTR) target->ai_addr);
 		freeaddrinfo(target);
-		strcpy((char*)buf[SND_RDMA_BUF_INDEX],"Client written data");
+		strcpy((char *)buf[SND_RDMA_BUF_INDEX], "Client written data");
 
 		/* one Client EP, multiple Server EPs, same conn_qual 
 		 * use private data to select EP on Server 
 		 */
-		for (i=0;i<eps;i++) {
+		for (i = 0; i < eps; i++) {
 			/* pdata selects Server EP, 
 			 * support both muliple Server and single EP's 
 			 */
 			if (multi_eps)
-				pdata = hton32(i); 
+				pdata = hton32(i);
 			else
-				pdata = 0; /* just use first EP */
+				pdata = 0;	/* just use first EP */
 
 			status = dat_ep_connect(ep[0],
 						&remote_addr,
-						(server?CLIENT_ID:SERVER_ID),
-						CONN_TIMEOUT,
-						4,
-						(DAT_PVOID)&pdata,
-						0,
-						DAT_CONNECT_DEFAULT_FLAG );
+						(server ? CLIENT_ID :
+						 SERVER_ID), CONN_TIMEOUT, 4,
+						(DAT_PVOID) & pdata, 0,
+						DAT_CONNECT_DEFAULT_FLAG);
 			_OK(status, "dat_ep_connect");
 		}
 	}
 
 	/* UD: process CR's starting with 2nd on server, 1st for client */
 	if (ud_test) {
-		for (i=(server?1:0);i<eps;i++) 
+		for (i = (server ? 1 : 0); i < eps; i++)
 			process_cr(i);
 	}
 
 	/* RC and UD: process CONN EST events */
-	for (i=0;i<eps;i++)
+	for (i = 0; i < eps; i++)
 		process_conn(i);
 
 	/* UD: CONN EST events for CONN's and CR's */
-	if(ud_test) {
-		for (i=0;i<eps;i++)
+	if (ud_test) {
+		for (i = 0; i < eps; i++)
 			process_conn(i);
 	}
-	
+
 	printf("Connected! %d endpoints\n", eps);
 
 	/*
 	 *  Setup our remote memory and tell the other side about it
-         *  Swap to network order.
+	 *  Swap to network order.
 	 */
-	r_iov = (DAT_RMR_TRIPLET*)buf[SEND_BUF_INDEX];
-        r_iov->rmr_context = hton32(rmr_context[RCV_RDMA_BUF_INDEX]);
-	r_iov->virtual_address = hton64((DAT_VADDR)(uintptr_t)buf[RCV_RDMA_BUF_INDEX]);
+	r_iov = (DAT_RMR_TRIPLET *) buf[SEND_BUF_INDEX];
+	r_iov->rmr_context = hton32(rmr_context[RCV_RDMA_BUF_INDEX]);
+	r_iov->virtual_address =
+	    hton64((DAT_VADDR) (uintptr_t) buf[RCV_RDMA_BUF_INDEX]);
 	r_iov->segment_length = hton32(buf_size);
 
-        printf("Send RMR message: r_key_ctx=0x%x,va="F64x",len=0x%x\n",
-		hton32(r_iov->rmr_context), 
-                hton64(r_iov->virtual_address), 
-		hton32(r_iov->segment_length));
+	printf("Send RMR message: r_key_ctx=0x%x,va=" F64x ",len=0x%x\n",
+	       hton32(r_iov->rmr_context),
+	       hton64(r_iov->virtual_address), hton32(r_iov->segment_length));
 
 	send_msg(buf[SEND_BUF_INDEX],
 		 sizeof(DAT_RMR_TRIPLET),
 		 lmr_context[SEND_BUF_INDEX],
-		 cookie,
-		 DAT_COMPLETION_SUPPRESS_FLAG);
+		 cookie, DAT_COMPLETION_SUPPRESS_FLAG);
 
+	dat_ep_get_status(ep[0], NULL, &in, &out);
+	printf("EP[0] status: posted buffers: Req=%d, Rcv=%d\n", in, out);
+
 	/*
 	 *  Wait for their RMR
 	 */
-	for (i=0,ctx=0;i<eps;i++,ctx++) {
+	for (i = 0, ctx = 0; i < eps; i++, ctx++) {
 		/* expected cookie, recv buf idx in every mem pool */
-		ctx = (ctx%REG_MEM_COUNT)?ctx:ctx+RECV_BUF_INDEX;
-                LOGPRINTF("Waiting for remote to send RMR data\n");
+		ctx = (ctx % REG_MEM_COUNT) ? ctx : ctx + RECV_BUF_INDEX;
+		LOGPRINTF("Waiting for remote to send RMR data\n");
 
 		status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
 		_OK(status, "dat_evd_wait after dat_ep_post_send");
@@ -646,7 +658,7 @@
 		if ((event.event_number != DAT_DTO_COMPLETION_EVENT) &&
 		    (ud_test && event.event_number != DAT_IB_DTO_EVENT)) {
 			printf("unexpected event waiting for RMR context "
-				"- 0x%x\n", event.event_number);
+			       "- 0x%x\n", event.event_number);
 			exit(1);
 		}
 		_OK(dto_event->status, "event status for post_recv");
@@ -656,64 +668,64 @@
 		 * Server - not receiving on multiple EP's
 		 */
 		if (!server || (server && !multi_eps)) {
-		    if (dto_event->transfered_length != msg_size ||
-			dto_event->user_cookie.as_64 != ctx) {
+			if (dto_event->transfered_length != msg_size ||
+			    dto_event->user_cookie.as_64 != ctx) {
 				printf("unexpected event data on recv: len=%d"
-					" cookie="F64x" expected %d/%d\n",
-					(int)dto_event->transfered_length,
-					dto_event->user_cookie.as_64,
-					msg_size, ctx);
-			exit(1);
-		    }
-		/* Server - receiving one message each across many EP's */
+				       " cookie=" F64x " expected %d/%d\n",
+				       (int)dto_event->transfered_length,
+				       dto_event->user_cookie.as_64,
+				       msg_size, ctx);
+				exit(1);
+			}
+			/* Server - receiving one message each across many EP's */
 		} else {
-		    if (dto_event->transfered_length != msg_size ||
-			dto_event->user_cookie.as_64 != RECV_BUF_INDEX) {
+			if (dto_event->transfered_length != msg_size ||
+			    dto_event->user_cookie.as_64 != RECV_BUF_INDEX) {
 				printf("unexpected event data on recv: len=%d"
-					"cookie="F64x" expected %d/%d\n",
-					(int)dto_event->transfered_length,
-					dto_event->user_cookie.as_64,
-					msg_size, RECV_BUF_INDEX);
-			exit(1);
-		    }
+				       "cookie=" F64x " expected %d/%d\n",
+				       (int)dto_event->transfered_length,
+				       dto_event->user_cookie.as_64,
+				       msg_size, RECV_BUF_INDEX);
+				exit(1);
+			}
 		}
 
 		/* swap RMR,address info to host order */
 		if (!server || (server && !multi_eps))
-			r_iov = (DAT_RMR_TRIPLET*)buf[ctx];
-		else 
-			r_iov = (DAT_RMR_TRIPLET*)buf[(i*REG_MEM_COUNT)+RECV_BUF_INDEX];
-                
+			r_iov = (DAT_RMR_TRIPLET *) buf[ctx];
+		else
+			r_iov =
+			    (DAT_RMR_TRIPLET *) buf[(i * REG_MEM_COUNT) +
+						    RECV_BUF_INDEX];
+
 		if (ud_test)
-		    r_iov = (DAT_RMR_TRIPLET*)((char*)r_iov + 40);
+			r_iov = (DAT_RMR_TRIPLET *) ((char *)r_iov + 40);
 
 		r_iov->rmr_context = ntoh32(r_iov->rmr_context);
 		r_iov->virtual_address = ntoh64(r_iov->virtual_address);
-		r_iov->segment_length =	ntoh32(r_iov->segment_length);
+		r_iov->segment_length = ntoh32(r_iov->segment_length);
 
 		printf("Recv RMR message: r_iov(%p):"
-			" r_key_ctx=%x,va="F64x",len=0x%x on EP=%p\n",
-			r_iov, r_iov->rmr_context,
-			r_iov->virtual_address,
-			r_iov->segment_length,
-			dto_event->ep_handle);
+		       " r_key_ctx=%x,va=" F64x ",len=0x%x on EP=%p\n",
+		       r_iov, r_iov->rmr_context,
+		       r_iov->virtual_address,
+		       r_iov->segment_length, dto_event->ep_handle);
 	}
-	return(0);
+	return (0);
 }
 
-int
-disconnect_ep(void)
+int disconnect_ep(void)
 {
-	DAT_RETURN	status;
-	DAT_EVENT	event;
-	DAT_COUNT	nmore;
-	int		i;
+	DAT_RETURN status;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	int i;
 
 	if (!ud_test) {
-                status = dat_ep_disconnect(ep[0], DAT_CLOSE_DEFAULT);
+		status = dat_ep_disconnect(ep[0], DAT_CLOSE_DEFAULT);
 		_OK2(status, "dat_ep_disconnect");
-	
-	   	status = dat_evd_wait(con_evd, DAT_TIMEOUT_INFINITE, 1,
+
+		status = dat_evd_wait(con_evd, DAT_TIMEOUT_INFINITE, 1,
 				      &event, &nmore);
 		_OK(status, "dat_evd_wait");
 	}
@@ -721,51 +733,100 @@
 		status = dat_psp_free(psp);
 		_OK2(status, "dat_psp_free");
 	}
-	for (i = 0; i < REG_MEM_COUNT*eps; i++) {
-		status = dat_lmr_free(lmr[ i ]);
+	for (i = 0; i < REG_MEM_COUNT * eps; i++) {
+		status = dat_lmr_free(lmr[i]);
 		_OK2(status, "dat_lmr_free");
 	}
 	if (lmr_atomic) {
 		status = dat_lmr_free(lmr_atomic);
 		_OK2(status, "dat_lmr_free_atomic");
 	}
-	for (i=0;i<eps;i++) {
+	for (i = 0; i < eps; i++) {
+		if (counters) {	/* examples of query and print */
+			int ii;
+			DAT_UINT64 ep_cntrs[DCNT_EP_ALL_COUNTERS];
+
+			dat_query_counters(ep[i], DCNT_EP_ALL_COUNTERS,
+					   ep_cntrs, 0);
+			printf(" EP[%d] Cntrs:", i);
+			for (ii = 0; ii < DCNT_EP_ALL_COUNTERS; ii++)
+				printf(" " F64u "", ep_cntrs[ii]);
+			printf("\n");
+			dat_print_counters(ep[i], DCNT_EP_ALL_COUNTERS, 0);
+		}
 		status = dat_ep_free(ep[i]);
 		_OK2(status, "dat_ep_free");
 	}
+	if (counters) {		/* examples of query and print */
+		int ii;
+		DAT_UINT64 evd_cntrs[DCNT_EVD_ALL_COUNTERS];
+
+		dat_query_counters(dto_evd, DCNT_EVD_ALL_COUNTERS,
+				   evd_cntrs, 0);
+		printf(" DTO_EVD Cntrs:");
+		for (ii = 0; ii < DCNT_EVD_ALL_COUNTERS; ii++)
+			printf(" " F64u "", evd_cntrs[ii]);
+		printf("\n");
+		dat_print_counters(dto_evd, DCNT_EVD_ALL_COUNTERS, 0);
+
+		dat_query_counters(con_evd, DCNT_EVD_ALL_COUNTERS,
+				   evd_cntrs, 0);
+		printf(" CONN_EVD Cntrs:");
+		for (ii = 0; ii < DCNT_EVD_ALL_COUNTERS; ii++)
+			printf(" " F64u "", evd_cntrs[ii]);
+		printf("\n");
+		dat_print_counters(con_evd, DCNT_EVD_ALL_COUNTERS, 0);
+
+		dat_query_counters(cr_evd, DCNT_EVD_ALL_COUNTERS, evd_cntrs, 0);
+		printf(" CR_EVD Cntrs:");
+		for (ii = 0; ii < DCNT_EVD_ALL_COUNTERS; ii++)
+			printf(" " F64u "", evd_cntrs[ii]);
+		printf("\n");
+		dat_print_counters(cr_evd, DCNT_EVD_ALL_COUNTERS, 0);
+	}
 	status = dat_evd_free(dto_evd);
 	_OK2(status, "dat_evd_free DTO");
-	
+
 	status = dat_evd_free(con_evd);
 	_OK2(status, "dat_evd_free CON");
-	
+
 	status = dat_evd_free(cr_evd);
 	_OK2(status, "dat_evd_free CR");
-	
+
 	status = dat_pz_free(pz);
 	_OK2(status, "dat_pz_free");
 
+	if (counters) {		/* examples of query and print */
+		int ii;
+		DAT_UINT64 ia_cntrs[DCNT_IA_ALL_COUNTERS];
+
+		dat_query_counters(ia, DCNT_IA_ALL_COUNTERS, ia_cntrs, 0);
+		printf(" IA Cntrs:");
+		for (ii = 0; ii < DCNT_IA_ALL_COUNTERS; ii++)
+			printf(" " F64u "", ia_cntrs[ii]);
+		printf("\n");
+		dat_print_counters(ia, DCNT_IA_ALL_COUNTERS, 0);
+	}
 	status = dat_ia_close(ia, DAT_CLOSE_DEFAULT);
 	_OK2(status, "dat_ia_close");
 
-	return(0);
+	return (0);
 }
 
-int
-do_immediate()
+int do_immediate()
 {
-	DAT_EVENT		event;
-	DAT_COUNT		nmore;
-	DAT_LMR_TRIPLET		iov;
-	DAT_RMR_TRIPLET		r_iov;
-	DAT_DTO_COOKIE		cookie;
-	DAT_RETURN		status;
-	DAT_UINT32		immed_data;
-	DAT_UINT32		immed_data_recv = 0;
-	DAT_DTO_COMPLETION_EVENT_DATA *dto_event = 
-		&event.event_data.dto_completion_event_data;
-	DAT_IB_EXTENSION_EVENT_DATA *ext_event = 
-		(DAT_IB_EXTENSION_EVENT_DATA *)&event.event_extension_data[0];
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET iov;
+	DAT_RMR_TRIPLET r_iov;
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN status;
+	DAT_UINT32 immed_data;
+	DAT_UINT32 immed_data_recv = 0;
+	DAT_DTO_COMPLETION_EVENT_DATA *dto_event =
+	    &event.event_data.dto_completion_event_data;
+	DAT_IB_EXTENSION_EVENT_DATA *ext_event =
+	    (DAT_IB_EXTENSION_EVENT_DATA *) & event.event_extension_data[0];
 
 	printf("\nDoing RDMA WRITE IMMEDIATE DATA\n");
 
@@ -776,21 +837,21 @@
 	}
 
 	cookie.as_64 = 0x5555;
-	
-        /* RMR info already swapped back to host order in connect_ep */
+
+	/* RMR info already swapped back to host order in connect_ep */
 	r_iov = *buf[RECV_BUF_INDEX];
 
-	iov.lmr_context     = lmr_context[SND_RDMA_BUF_INDEX];
-	iov.virtual_address = (DAT_VADDR)(uintptr_t)buf[SND_RDMA_BUF_INDEX];
-	iov.segment_length  = buf_size;
+	iov.lmr_context = lmr_context[SND_RDMA_BUF_INDEX];
+	iov.virtual_address = (DAT_VADDR) (uintptr_t) buf[SND_RDMA_BUF_INDEX];
+	iov.segment_length = buf_size;
 
 	cookie.as_64 = 0x9999;
-	
-	status = dat_ib_post_rdma_write_immed(ep[0],		// ep_handle
-					      1,		// segments
-					      &iov,		// LMR
-					      cookie,		// user_cookie
-					      &r_iov,		// RMR
+
+	status = dat_ib_post_rdma_write_immed(ep[0],	// ep_handle
+					      1,	// segments
+					      &iov,	// LMR
+					      cookie,	// user_cookie
+					      &r_iov,	// RMR
 					      immed_data,
 					      DAT_COMPLETION_DEFAULT_FLAG);
 	_OK(status, "dat_ib_post_rdma_write_immed");
@@ -800,148 +861,130 @@
 	 */
 	status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "dat_evd_wait after dat_ib_post_rdma_write");
-	if (event.event_number != DAT_IB_DTO_EVENT)
-	{
-		printf("unexpected event #0x%x waiting for WR-IMMED #0x%x\n", 
-			event.event_number,DAT_IB_DTO_EVENT);
+	if (event.event_number != DAT_IB_DTO_EVENT) {
+		printf("unexpected event #0x%x waiting for WR-IMMED #0x%x\n",
+		       event.event_number, DAT_IB_DTO_EVENT);
 		exit(1);
 	}
-	
-	if (nmore) printf("%s() nmore %d\n",__FUNCTION__,nmore);
+
+	if (nmore)
+		printf("%s() nmore %d\n", __FUNCTION__, nmore);
 	_OK(dto_event->status, "DTO event status");
-	if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED)
-	{
-	  if ((dto_event->transfered_length != buf_size) ||
-	     (dto_event->user_cookie.as_64 != 0x9999)) 
-	  {
-              printf("unexpected event data for rdma_write_immed: len=%d "
-			"cookie=0x%x\n",
-			(int)dto_event->transfered_length,
-			(int)dto_event->user_cookie.as_64);
-	      exit(1);
-	  }
-	} 
-	else if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED_DATA)
-        {
-	  if ((dto_event->transfered_length != buf_size) ||
-	     (dto_event->user_cookie.as_64 != RECV_BUF_INDEX+1)) 
-	  {
-		printf("unexpected event data of immediate write: len=%d "
-			"cookie="F64x" expected %d/%d\n",
-			(int)dto_event->transfered_length,
-			dto_event->user_cookie.as_64,
-			(int)sizeof(int), RECV_BUF_INDEX+1);
+	if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED) {
+		if ((dto_event->transfered_length != buf_size) ||
+		    (dto_event->user_cookie.as_64 != 0x9999)) {
+			printf
+			    ("unexpected event data for rdma_write_immed: len=%d "
+			     "cookie=0x%x\n", (int)dto_event->transfered_length,
+			     (int)dto_event->user_cookie.as_64);
+			exit(1);
+		}
+	} else if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED_DATA) {
+		if ((dto_event->transfered_length != buf_size) ||
+		    (dto_event->user_cookie.as_64 != RECV_BUF_INDEX + 1)) {
+			printf
+			    ("unexpected event data of immediate write: len=%d "
+			     "cookie=" F64x " expected %d/%d\n",
+			     (int)dto_event->transfered_length,
+			     dto_event->user_cookie.as_64, (int)sizeof(int),
+			     RECV_BUF_INDEX + 1);
+			exit(1);
+		}
+
+		/* get immediate data from event */
+		immed_data_recv = ext_event->val.immed.data;
+	} else {
+		printf("unexpected extension type for event - 0x%x, 0x%x\n",
+		       event.event_number, ext_event->type);
 		exit(1);
-	  }
-	  
-	  /* get immediate data from event */
-	  immed_data_recv = ext_event->val.immed.data;
 	}
-	else
-	{
-		printf("unexpected extension type for event - 0x%x, 0x%x\n", 
-			event.event_number, ext_event->type);
-		exit(1);
-	}
 
-
 	/*
 	 * Collect second event, write completion or inbound recv with immed
 	 */
 	status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "dat_evd_wait after dat_ib_post_rdma_write");
-	if (event.event_number != DAT_IB_DTO_EVENT)
-	{
-		printf("unexpected event # waiting for WR-IMMED - 0x%x\n", 
-			event.event_number);
+	if (event.event_number != DAT_IB_DTO_EVENT) {
+		printf("unexpected event # waiting for WR-IMMED - 0x%x\n",
+		       event.event_number);
 		exit(1);
 	}
-	
+
 	_OK(dto_event->status, "event status");
-	if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED)
-	{
-	  if ((dto_event->transfered_length != buf_size) ||
-	     (dto_event->user_cookie.as_64 != 0x9999)) 
-	  {
-              printf("unexpected event data for rdma_write_immed: len=%d "
-			"cookie=0x%x\n",
-			(int)dto_event->transfered_length,
-			(int)dto_event->user_cookie.as_64);
-	      exit(1);
-	  }
-	} 
-	else if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED_DATA)
-        {
-	  if ((dto_event->transfered_length != buf_size) ||
-	     (dto_event->user_cookie.as_64 != RECV_BUF_INDEX+1)) 
-	  {
-		printf("unexpected event data of immediate write: len=%d "
-			"cookie="F64x" expected %d/%d\n",
-			(int)dto_event->transfered_length,
-			dto_event->user_cookie.as_64,
-			(int)sizeof(int), RECV_BUF_INDEX+1);
+	if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED) {
+		if ((dto_event->transfered_length != buf_size) ||
+		    (dto_event->user_cookie.as_64 != 0x9999)) {
+			printf
+			    ("unexpected event data for rdma_write_immed: len=%d "
+			     "cookie=0x%x\n", (int)dto_event->transfered_length,
+			     (int)dto_event->user_cookie.as_64);
+			exit(1);
+		}
+	} else if (ext_event->type == DAT_IB_RDMA_WRITE_IMMED_DATA) {
+		if ((dto_event->transfered_length != buf_size) ||
+		    (dto_event->user_cookie.as_64 != RECV_BUF_INDEX + 1)) {
+			printf
+			    ("unexpected event data of immediate write: len=%d "
+			     "cookie=" F64x " expected %d/%d\n",
+			     (int)dto_event->transfered_length,
+			     dto_event->user_cookie.as_64, (int)sizeof(int),
+			     RECV_BUF_INDEX + 1);
+			exit(1);
+		}
+
+		/* get immediate data from event */
+		immed_data_recv = ext_event->val.immed.data;
+	} else {
+		printf("unexpected extension type for event - 0x%x, 0x%x\n",
+		       event.event_number, ext_event->type);
 		exit(1);
-	  }
-	  
-	  /* get immediate data from event */
-	  immed_data_recv = ext_event->val.immed.data;
 	}
-	else
-	{
-		printf("unexpected extension type for event - 0x%x, 0x%x\n", 
-			event.event_number, ext_event->type);
+
+	if ((server) && (immed_data_recv != 0x7777)) {
+		printf("ERROR: Server: unexpected imm_data_recv 0x%x/0x%x\n",
+		       0x7777, immed_data_recv);
 		exit(1);
-	}
-		
-	if ((server) && (immed_data_recv != 0x7777))
-	{
-		printf("ERROR: Server: unexpected imm_data_recv 0x%x/0x%x\n", 
-			0x7777,  immed_data_recv);
+	} else if ((!server) && (immed_data_recv != 0x1111)) {
+		printf("ERROR: Client: unexpected imm_data_recv 0x%x/0x%x\n",
+		       0x1111, immed_data_recv);
 		exit(1);
-	} 
-	else if ((!server) && (immed_data_recv != 0x1111))
-	{
-		printf("ERROR: Client: unexpected imm_data_recv 0x%x/0x%x\n", 
-			0x1111,  immed_data_recv);
-		exit(1);
 	}
 
 	if (server)
-		printf("Server received immed_data=0x%x\n",immed_data_recv);
+		printf("Server received immed_data=0x%x\n", immed_data_recv);
 	else
-		printf("Client received immed_data=0x%x\n",immed_data_recv);
-	
-	printf("rdma buffer %p contains: %s\n", 
-		buf[RCV_RDMA_BUF_INDEX], (char*)buf[RCV_RDMA_BUF_INDEX]);
+		printf("Client received immed_data=0x%x\n", immed_data_recv);
 
+	printf("rdma buffer %p contains: %s\n",
+	       buf[RCV_RDMA_BUF_INDEX], (char *)buf[RCV_RDMA_BUF_INDEX]);
+
 	printf("\n RDMA_WRITE_WITH_IMMEDIATE_DATA test - PASSED\n");
 	return (0);
 }
 
-int
-do_cmp_swap()
+int do_cmp_swap()
 {
-	DAT_DTO_COOKIE	cookie;
-	DAT_RETURN		status;
-	DAT_EVENT		event;
-	DAT_COUNT		nmore;
-	DAT_LMR_TRIPLET		l_iov;
-	DAT_RMR_TRIPLET		r_iov;
-	volatile DAT_UINT64 *target = (DAT_UINT64*)buf[RCV_RDMA_BUF_INDEX];
-	DAT_DTO_COMPLETION_EVENT_DATA *dto_event = 
-		&event.event_data.dto_completion_event_data;
-	DAT_IB_EXTENSION_EVENT_DATA *ext_event = 
-		(DAT_IB_EXTENSION_EVENT_DATA *)&event.event_extension_data[0];
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN status;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET l_iov;
+	DAT_RMR_TRIPLET r_iov;
+	volatile DAT_UINT64 *target = (DAT_UINT64 *) buf[RCV_RDMA_BUF_INDEX];
+	DAT_DTO_COMPLETION_EVENT_DATA *dto_event =
+	    &event.event_data.dto_completion_event_data;
+	DAT_IB_EXTENSION_EVENT_DATA *ext_event =
+	    (DAT_IB_EXTENSION_EVENT_DATA *) & event.event_extension_data[0];
 
 	printf("\nDoing CMP and SWAP\n");
-        
-        /* RMR info already swapped back to host order in connect_ep */
-	r_iov = *buf[ RECV_BUF_INDEX ];
-	
-	l_iov.lmr_context     = lmr_atomic_context;
-	l_iov.virtual_address = (DAT_UINT64)(uintptr_t)atomic_buf;
-	l_iov.segment_length  = BUF_SIZE_ATOMIC;
 
+	/* RMR info already swapped back to host order in connect_ep */
+	r_iov = *buf[RECV_BUF_INDEX];
+
+	l_iov.lmr_context = lmr_atomic_context;
+	l_iov.virtual_address = (DAT_UINT64) (uintptr_t) atomic_buf;
+	l_iov.segment_length = BUF_SIZE_ATOMIC;
+
 	cookie.as_64 = 3333;
 
 	if (server) {
@@ -949,100 +992,96 @@
 		sleep(1);
 		/* Server does not compare and should not swap */
 		printf("dtx svr - starting cmp_swap\n");
-		status = dat_ib_post_cmp_and_swap(
-						ep[0], 
-						(DAT_UINT64)0x654321, 
-						(DAT_UINT64)0x6789A, 
-						&l_iov,
-						cookie, 
-						&r_iov, 
-						DAT_COMPLETION_DEFAULT_FLAG);
+		status = dat_ib_post_cmp_and_swap(ep[0],
+						  (DAT_UINT64) 0x654321,
+						  (DAT_UINT64) 0x6789A,
+						  &l_iov,
+						  cookie,
+						  &r_iov,
+						  DAT_COMPLETION_DEFAULT_FLAG);
 		printf("dtx svr - done cmp_swap, chk status\n");
 	} else {
 		*target = 0x54321;
-		sleep(1); 
+		sleep(1);
 		printf("dtx cli - starting cmp_swap\n");
 		/* Client does compare and should swap */
-		status = dat_ib_post_cmp_and_swap(
-						ep[0], 
-						(DAT_UINT64)0x12345, 
-						(DAT_UINT64)0x98765,
-						&l_iov,
-						cookie, 
-						&r_iov, 
-						DAT_COMPLETION_DEFAULT_FLAG);
+		status = dat_ib_post_cmp_and_swap(ep[0],
+						  (DAT_UINT64) 0x12345,
+						  (DAT_UINT64) 0x98765,
+						  &l_iov,
+						  cookie,
+						  &r_iov,
+						  DAT_COMPLETION_DEFAULT_FLAG);
 		printf("dtx cli - done cmp_swap, chk status\n");
 	}
 	_OK(status, "dat_ib_post_cmp_and_swap");
 	status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "dat_evd_wait for compare and swap");
 	if (event.event_number != DAT_IB_DTO_EVENT) {
-	    printf("unexpected event after post_cmp_and_swap: 0x%x\n", 
-		    event.event_number); 
-	    exit(1);
+		printf("unexpected event after post_cmp_and_swap: 0x%x\n",
+		       event.event_number);
+		exit(1);
 	}
 
 	_OK(dto_event->status, "event status for CMP and SWAP");
 	if (ext_event->type != DAT_IB_CMP_AND_SWAP) {
-  	    printf("unexpected event data of cmp_swap: type=%d cookie=%d "
-		"original "F64x"\n",
-		(int)ext_event->type,
-		(int)dto_event->user_cookie.as_64,
-		*atomic_buf);
-	    exit(1);
+		printf("unexpected event data of cmp_swap: type=%d cookie=%d "
+		       "original " F64x "\n",
+		       (int)ext_event->type,
+		       (int)dto_event->user_cookie.as_64, *atomic_buf);
+		exit(1);
 	}
 
-	sleep(2); /* wait for other side to complete swap */
+	sleep(2);		/* wait for other side to complete swap */
 
 	if (server) {
-	    printf("Server got original data        = "F64x", expected "
-			"0x54321\n", *atomic_buf);
-	    printf("Client final result (on Server) = "F64x", expected "
-			"0x98765\n", *target);
+		printf("Server got original data        = " F64x ", expected "
+		       "0x54321\n", *atomic_buf);
+		printf("Client final result (on Server) = " F64x ", expected "
+		       "0x98765\n", *target);
 
-	    if (*atomic_buf != 0x54321 || *target != 0x98765) {
-	    	printf("ERROR: Server CMP_SWAP\n");
-		exit(1);
-	    }
+		if (*atomic_buf != 0x54321 || *target != 0x98765) {
+			printf("ERROR: Server CMP_SWAP\n");
+			exit(1);
+		}
 	} else {
-	    printf("Client got original data        = "F64x", expected "
-			"0x12345\n",*atomic_buf);
-	    printf("Server final result (on Client) = 0x"F64x", expected "
-			"0x54321\n", *target);
+		printf("Client got original data        = " F64x ", expected "
+		       "0x12345\n", *atomic_buf);
+		printf("Server final result (on Client) = 0x" F64x ", expected "
+		       "0x54321\n", *target);
 
-	    if (*atomic_buf != 0x12345 || *target != 0x54321) {
-	    	printf("ERROR: Client CMP_SWAP\n");
-		exit(1);
-	    }
+		if (*atomic_buf != 0x12345 || *target != 0x54321) {
+			printf("ERROR: Client CMP_SWAP\n");
+			exit(1);
+		}
 	}
 	printf("\n CMP_SWAP test - PASSED\n");
-	return(0);
+	return (0);
 }
 
-int
-do_fetch_add()
+int do_fetch_add()
 {
-	DAT_DTO_COOKIE	cookie;
-	DAT_RETURN		status;
-	DAT_EVENT		event;
-	DAT_COUNT		nmore;
-	DAT_LMR_TRIPLET		l_iov;
-	DAT_RMR_TRIPLET		r_iov;
-	volatile DAT_UINT64 *target = (DAT_UINT64*)buf[RCV_RDMA_BUF_INDEX];
-	DAT_DTO_COMPLETION_EVENT_DATA *dto_event = 
-		&event.event_data.dto_completion_event_data;
-	DAT_IB_EXTENSION_EVENT_DATA *ext_event = 
-		(DAT_IB_EXTENSION_EVENT_DATA *)&event.event_extension_data[0];
+	DAT_DTO_COOKIE cookie;
+	DAT_RETURN status;
+	DAT_EVENT event;
+	DAT_COUNT nmore;
+	DAT_LMR_TRIPLET l_iov;
+	DAT_RMR_TRIPLET r_iov;
+	volatile DAT_UINT64 *target = (DAT_UINT64 *) buf[RCV_RDMA_BUF_INDEX];
+	DAT_DTO_COMPLETION_EVENT_DATA *dto_event =
+	    &event.event_data.dto_completion_event_data;
+	DAT_IB_EXTENSION_EVENT_DATA *ext_event =
+	    (DAT_IB_EXTENSION_EVENT_DATA *) & event.event_extension_data[0];
 
 	printf("\nDoing FETCH and ADD\n");
 
-        /* RMR info already swapped back to host order in connect_ep */
-	r_iov = *buf[ RECV_BUF_INDEX ];
-	
-	l_iov.lmr_context     = lmr_atomic_context;
-	l_iov.virtual_address = (DAT_UINT64)(uintptr_t)atomic_buf;
-	l_iov.segment_length  = BUF_SIZE_ATOMIC;
+	/* RMR info already swapped back to host order in connect_ep */
+	r_iov = *buf[RECV_BUF_INDEX];
 
+	l_iov.lmr_context = lmr_atomic_context;
+	l_iov.virtual_address = (DAT_UINT64) (uintptr_t) atomic_buf;
+	l_iov.segment_length = BUF_SIZE_ATOMIC;
+
 	cookie.as_64 = 0x7777;
 	if (server) {
 		/* Wait for Client to finish cmp_swap */
@@ -1050,186 +1089,182 @@
 			sleep(1);
 		*target = 0x10;
 		sleep(1);
-		status = dat_ib_post_fetch_and_add(
-						ep[0], 
-						(DAT_UINT64)0x100,
-						&l_iov,
-						cookie, 
-						&r_iov, 
-						DAT_COMPLETION_DEFAULT_FLAG);
+		status = dat_ib_post_fetch_and_add(ep[0],
+						   (DAT_UINT64) 0x100,
+						   &l_iov,
+						   cookie,
+						   &r_iov,
+						   DAT_COMPLETION_DEFAULT_FLAG);
 	} else {
 		/* Wait for Server, no swap so nothing to check */
 		*target = 0x100;
 		sleep(1);
-		status = dat_ib_post_fetch_and_add(
-						ep[0], 
-						(DAT_UINT64)0x10, 
-						&l_iov,
-						cookie, 
-						&r_iov, 
-						DAT_COMPLETION_DEFAULT_FLAG);
+		status = dat_ib_post_fetch_and_add(ep[0],
+						   (DAT_UINT64) 0x10,
+						   &l_iov,
+						   cookie,
+						   &r_iov,
+						   DAT_COMPLETION_DEFAULT_FLAG);
 	}
 	_OK(status, "dat_ib_post_fetch_and_add");
 	status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "dat_evd_wait for fetch and add");
 	if (event.event_number != DAT_IB_DTO_EVENT) {
 		printf("unexpected event after post_fetch_and_add: 0x%x\n",
-			event.event_number); 
+		       event.event_number);
 		exit(1);
 	}
 
 	_OK(dto_event->status, "event status for FETCH and ADD");
 	if (ext_event->type != DAT_IB_FETCH_AND_ADD) {
 		printf("unexpected event data of fetch and add : type=%d "
-			"cookie=%d original%d\n",
-			(int)ext_event->type,
-			(int)dto_event->user_cookie.as_64,
-			(int)*atomic_buf);
+		       "cookie=%d original%d\n",
+		       (int)ext_event->type,
+		       (int)dto_event->user_cookie.as_64, (int)*atomic_buf);
 		exit(1);
 	}
 
 	if (server) {
-	    printf("Client original data (on Server) = "F64x", expected "
-			"0x100\n", *atomic_buf);
+		printf("Client original data (on Server) = " F64x ", expected "
+		       "0x100\n", *atomic_buf);
 	} else {
-	    printf("Server original data (on Client) = "F64x", expected "
-			"0x10\n", *atomic_buf);
+		printf("Server original data (on Client) = " F64x ", expected "
+		       "0x10\n", *atomic_buf);
 	}
 
-	sleep(1);	
+	sleep(1);
 
 	if (server) {
-		status = dat_ib_post_fetch_and_add(
-						ep[0], 
-						(DAT_UINT64)0x100, 
-						&l_iov,
-						cookie, 
-						&r_iov, 
-						DAT_COMPLETION_DEFAULT_FLAG);
+		status = dat_ib_post_fetch_and_add(ep[0],
+						   (DAT_UINT64) 0x100,
+						   &l_iov,
+						   cookie,
+						   &r_iov,
+						   DAT_COMPLETION_DEFAULT_FLAG);
 	} else {
-		status = dat_ib_post_fetch_and_add(
-						ep[0], 
-						(DAT_UINT64)0x10,
-						&l_iov,
-						cookie, 
-						&r_iov, 
-						 DAT_COMPLETION_DEFAULT_FLAG);
+		status = dat_ib_post_fetch_and_add(ep[0],
+						   (DAT_UINT64) 0x10,
+						   &l_iov,
+						   cookie,
+						   &r_iov,
+						   DAT_COMPLETION_DEFAULT_FLAG);
 	}
 
 	status = dat_evd_wait(dto_evd, DTO_TIMEOUT, 1, &event, &nmore);
 	_OK(status, "dat_evd_wait for second fetch and add");
 	if (event.event_number != DAT_IB_DTO_EVENT) {
 		printf("unexpected event after second post_fetch_and_add: "
-			"0x%x\n", event.event_number); 
+		       "0x%x\n", event.event_number);
 		exit(1);
 	}
 
 	_OK(dto_event->status, "event status for second FETCH and ADD");
 	if (ext_event->type != DAT_IB_FETCH_AND_ADD) {
 		printf("unexpected event data of second fetch and add : "
-			"type=%d cookie=%d original%p\n",
-			(int)ext_event->type,
-			(int)dto_event->user_cookie.as_64,
-			atomic_buf);
+		       "type=%d cookie=%d original%p\n",
+		       (int)ext_event->type,
+		       (int)dto_event->user_cookie.as_64, atomic_buf);
 		exit(1);
 	}
 
-	sleep(1); /* wait for other side to complete fetch_add */
+	sleep(1);		/* wait for other side to complete fetch_add */
 
 	if (server) {
-	    printf("Server got original data         = "F64x", expected "
-			"0x200\n", *atomic_buf);
-	    printf("Client final result (on Server)  = "F64x", expected "
-			"0x30\n", *target);
+		printf("Server got original data         = " F64x ", expected "
+		       "0x200\n", *atomic_buf);
+		printf("Client final result (on Server)  = " F64x ", expected "
+		       "0x30\n", *target);
 
-    	    if (*atomic_buf != 0x200 || *target != 0x30) {
-	    	printf("ERROR: Server FETCH_ADD\n");
-		exit(1);
-	    }
+		if (*atomic_buf != 0x200 || *target != 0x30) {
+			printf("ERROR: Server FETCH_ADD\n");
+			exit(1);
+		}
 	} else {
-	    printf("Server side original data        = "F64x", expected "
-			"0x20\n", *atomic_buf);
-	    printf("Server final result (on Client)  = "F64x", expected "
-			"0x300\n", *target);
+		printf("Server side original data        = " F64x ", expected "
+		       "0x20\n", *atomic_buf);
+		printf("Server final result (on Client)  = " F64x ", expected "
+		       "0x300\n", *target);
 
-    	    if (*atomic_buf != 0x20 || *target != 0x300) {
-	    	printf("ERROR: Server FETCH_ADD\n");
-		exit(1);
-	    }
+		if (*atomic_buf != 0x20 || *target != 0x300) {
+			printf("ERROR: Server FETCH_ADD\n");
+			exit(1);
+		}
 	}
 	printf("\n FETCH_ADD test - PASSED\n");
-	return(0);
+	return (0);
 }
 
-
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int rc;
-	
+
 	/* parse arguments */
-	while ((rc = getopt(argc, argv, "csvumU:h:b:P:")) != -1)
-	{
-		switch(rc)
-		{
-			case 'u':
-				ud_test = 1;
-				eps = MAX_EP_COUNT/2;
-				break;
-			case 'm':
-				multi_eps = 1;
-				break;
-			case 'c':
-				server = 0;
-				break;
-			case 's':
-				server = 1;
-				break;
-			case 'h':
-				server = 0;
-				strcpy (hostname, optarg);
-				break;
-			case 'b':
-				buf_size = atoi(optarg);
-				break;
-			case 'U':
-				ud_test = 1;
-				eps = MIN(atoi(optarg),MAX_EP_COUNT);
-				break;
-			case 'P':
-				strcpy (provider, optarg);
-				break;
-			case 'v':
-				verbose = 1;
-				break;
-			default:
-                               print_usage();
-                               exit(-12);
+	while ((rc = getopt(argc, argv, "csvumpU:h:b:P:")) != -1) {
+		switch (rc) {
+		case 'u':
+			ud_test = 1;
+			eps = MAX_EP_COUNT / 2;
+			break;
+		case 'm':
+			multi_eps = 1;
+			break;
+		case 'c':
+			server = 0;
+			break;
+		case 's':
+			server = 1;
+			break;
+		case 'p':
+			counters = 1;
+			break;
+		case 'h':
+			remote_host = 1;
+			strcpy(hostname, optarg);
+			break;
+		case 'b':
+			buf_size = atoi(optarg);
+			break;
+		case 'U':
+			ud_test = 1;
+			eps = MIN(atoi(optarg), MAX_EP_COUNT);
+			break;
+		case 'P':
+			strcpy(provider, optarg);
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		default:
+			print_usage();
+			exit(-12);
 		}
 	}
 
-
 #if defined(_WIN32) || defined(_WIN64)
 	{
-		WSADATA wsaData; 
+		WSADATA wsaData;
 		int i;
 
-		i = WSAStartup ( MAKEWORD(2,2), &wsaData );
-		if ( i != 0 ) {
-			printf("%s WSAStartup(2.2) fail? (0x%x)\n",argv[0],i);
+		i = WSAStartup(MAKEWORD(2, 2), &wsaData);
+		if (i != 0) {
+			printf("%s WSAStartup(2.2) fail? (0x%x)\n", argv[0], i);
 			fflush(stdout);
 			exit(1);
 		}
 	}
 #endif
+	/* for non UD tests, -h is always client */
+	if (remote_host && !ud_test)
+		server = 0;
 
 	if (!server) {
 		printf("\nRunning as Client - %s %s %d endpoint(s)\n",
-			provider, ud_test?"UD test":"", eps);
+		       provider, ud_test ? "UD test" : "", eps);
 	} else {
 		printf("\nRunning as Server - %s %s %d endpoint(s)\n",
-			provider, ud_test?"UD test":"", eps);
+		       provider, ud_test ? "UD test" : "", eps);
 	}
+
 	/*
 	 * connect
 	 */
@@ -1237,7 +1272,7 @@
 		_WSACleanup();
 		exit(1);
 	}
-	if (ud_test) 
+	if (ud_test)
 		goto bail;
 
 	if (do_immediate()) {
@@ -1252,12 +1287,12 @@
 		_WSACleanup();
 		exit(1);
 	}
-bail:
+      bail:
 	rc = disconnect_ep();
 	_WSACleanup();
 
 	if (!rc)
 		printf("\n IB extension test - %s test PASSED\n\n",
-			ud_test?"UD":"immed/atomic");
+		       ud_test ? "UD" : "immed/atomic");
 	return rc;
 }




More information about the Pkg-ofed-commits mailing list