Signed-off-by: Tom Duffy <[EMAIL PROTECTED]>

Index: linux-kernel-rmr/dat-provider/dapl_rmr_create.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr_create.c     (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_rmr_create.c     (working copy)
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl_rmr_util.h"
-#include "dapl_openib_util.h"
-
-/*
- * dapl_rmr_create
- *
- * Create a remote memory region for the specified protection zone
- *
- * Input:
- *     pz_handle
- *
- * Output:
- *     rmr_handle
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INSUFFICIENT_RESOURCES
- *     DAT_INVALID_PARAMETER
- */
-u32 dapl_rmr_create(DAT_PZ_HANDLE pz_handle, DAT_RMR_HANDLE *rmr_handle)
-{
-       struct dapl_pz *pz;
-       struct dapl_rmr *rmr;
-       u32 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 = (struct dapl_pz *)pz_handle;
-
-       rmr = dapl_rmr_alloc(pz);
-
-       if (rmr == NULL) {
-               dat_status =
-                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-               goto bail;
-       }
-
-       dat_status = dapl_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;
-       }
-
-       atomic_inc(&pz->pz_ref_count);
-
-       *rmr_handle = rmr;
-
-bail:
-       return dat_status;
-}
Index: linux-kernel-rmr/dat-provider/Makefile
===================================================================
--- linux-kernel-rmr/dat-provider/Makefile      (revision 2483)
+++ linux-kernel-rmr/dat-provider/Makefile      (working copy)
@@ -76,11 +61,7 @@ PROVIDER_MODULES := \
         dapl_psp_query                 \
         dapl_pz                         \
         dapl_ring_buffer_util          \
-        dapl_rmr_bind                  \
-        dapl_rmr_create                \
-        dapl_rmr_free                  \
-        dapl_rmr_query                 \
-        dapl_rmr_util                  \
+        dapl_rmr                       \
         dapl_rsp_create                \
         dapl_rsp_free                  \
         dapl_rsp_query                 \
@@ -98,5 +79,25 @@ PROVIDER_MODULES := \
Index: linux-kernel-rmr/dat-provider/dapl_rmr_free.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr_free.c       (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_rmr_free.c       (working copy)
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl_rmr_util.h"
-#include "dapl_openib_util.h"
-#include "dapl_ia_util.h"
-
-/*
- * dapl_rmr_free
- *
- * Destroy an instance of the Remote Memory Region
- *
- * Input:
- *     rmr_handle
- *
- * Output:
- *     none
- *
- * Returns:
- *     DAT_SUCCESS
- *     DAT_INVALID_PARAMETER
- */
-u32 dapl_rmr_free(DAT_RMR_HANDLE rmr_handle)
-{
-       struct dapl_rmr *rmr;
-       u32 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;
-       }
-
-       rmr = (struct dapl_rmr *)rmr_handle;
-
-       /*
-        * If the user did not perform an unbind op, release
-        * counts here.
-        */
-       if (rmr->param.lmr_triplet.virtual_address != 0) {
-               atomic_dec(&rmr->lmr->lmr_ref_count);
-               rmr->param.lmr_triplet.virtual_address = 0;
-       }
-
-       dat_status = dapl_ib_mw_free(rmr);
-
-       if (dat_status != DAT_SUCCESS)
-               goto bail;
-
-       atomic_dec(&rmr->pz->pz_ref_count);
-
-       dapl_rmr_dealloc(rmr);
-
-bail:
-       return dat_status;
-}
Index: linux-kernel-rmr/dat-provider/dapl_rmr_query.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr_query.c      (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_rmr_query.c      (working copy)
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-
-u32 dapl_rmr_query(DAT_RMR_HANDLE rmr_handle, struct dat_rmr_param *rmr_param)
-{
-       struct dapl_rmr *rmr;
-       u32 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;
-       }
-
-       rmr = (struct dapl_rmr *)rmr_handle;
-
-       memcpy(rmr_param, &rmr->param, sizeof *rmr_param);
-
-bail:
-       return dat_status;
-}
Index: linux-kernel-rmr/dat-provider/dapl_rmr_bind.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr_bind.c       (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_rmr_bind.c       (working copy)
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_rmr_util.h"
-#include "dapl_ep_util.h"
-#include "dapl_cookie.h"
-#include "dapl_openib_util.h"
-
-/*********************************************************************
- *                                                                   *
- * Function Definitions                                              *
- *                                                                   *
- *********************************************************************/
-
-static inline u32 dapl_rmr_bind_fuse(struct dapl_rmr *rmr,
-                                    const struct dat_lmr_triplet *lmr_triplet,
-                                    enum dat_mem_priv_flags mem_priv,
-                                    struct dapl_ep *ep_ptr,
-                                    DAT_RMR_COOKIE user_cookie,
-                                    enum dat_completion_flags completion_flags,
-                                    DAT_RMR_CONTEXT *rmr_context)
-{
-       struct dapl_lmr *lmr;
-       struct dapl_cookie *cookie;
-       u32 status;
-       boolean_t is_signaled;
-
-       status = dapl_hash_search(rmr->header.owner_ia->hca_ptr->lmr_hash_table,
-                                  lmr_triplet->lmr_context,
-                                  (DAPL_HASH_DATA *) &lmr);
-       if (DAT_SUCCESS != status) {
-               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-               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) {
-               status =
-                   DAT_ERROR(DAT_INVALID_STATE, dapl_ep_state_subtype(ep_ptr));
-               goto bail;
-       }
-
-       if (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)) {
-               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)) {
-               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)) {
-               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
-               goto bail;
-       }
-
-       status = dapl_rmr_cookie_alloc(&ep_ptr->req_buffer, rmr, user_cookie,
-                                       &cookie);
-       if (DAT_SUCCESS != status)
-               goto bail;
-
-       is_signaled = (completion_flags & DAT_COMPLETION_SUPPRESS_FLAG) ? 
-                FALSE : TRUE;
-        
-       /*
-        * Take reference before posting to avoid race conditions with
-        * completions
-        */
-       atomic_inc(&ep_ptr->req_count);
-
-       status = dapl_ib_mw_bind(rmr, lmr, ep_ptr, cookie,
-                                 lmr_triplet->virtual_address,
-                                 lmr_triplet->segment_length,
-                                 mem_priv, is_signaled);
-       if (DAT_SUCCESS != status) {
-               atomic_dec(&ep_ptr->req_count);
-               dapl_cookie_dealloc(&ep_ptr->req_buffer, cookie);
-               goto bail;
-       }
-
-       atomic_inc(&lmr->lmr_ref_count);
-
-       /* if the RMR was previously bound */
-       if (NULL != rmr->lmr)
-               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;
-
-       if (NULL != rmr_context)
-               *rmr_context = rmr->param.rmr_context;
-
-bail:
-       return status;
-}
-
-static inline u32 dapl_rmr_bind_unfuse(struct dapl_rmr *rmr,
-                                      struct dapl_ep *ep_ptr,
-                                      DAT_RMR_COOKIE user_cookie,
-                                      enum dat_completion_flags cflags)
-{
-       struct dapl_cookie *cookie;
-       u32 status = DAT_SUCCESS;
-       boolean_t is_signaled;
-
-       /*
-        * 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) {
-               status =
-                   DAT_ERROR(DAT_INVALID_STATE, dapl_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) {
-               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,
-                                              cflags) ||
-           !dapl_rmr_validate_completion_flag(DAT_COMPLETION_UNSIGNALLED_FLAG,
-                                              ep_ptr->param.ep_attr.
-                                              request_completion_flags,
-                                              cflags) ||
-           !dapl_rmr_validate_completion_flag(
-                    DAT_COMPLETION_BARRIER_FENCE_FLAG,
-                    ep_ptr->param.ep_attr.request_completion_flags, cflags)) {
-               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-               goto bail1;
-       }
-
-       status = dapl_rmr_cookie_alloc(&ep_ptr->req_buffer, rmr, user_cookie,
-                                       &cookie);
-       if (DAT_SUCCESS != status)
-               goto bail1;
-
-       is_signaled = (cflags & DAT_COMPLETION_UNSIGNALLED_FLAG) ? FALSE : TRUE;
-
-       /*
-        * Take reference before posting to avoid race conditions with 
-        * completions 
-        */
-       atomic_inc(&ep_ptr->req_count);
-
-       status = dapl_ib_mw_unbind(rmr, ep_ptr, cookie, is_signaled);
-       if (DAT_SUCCESS != status) {
-               atomic_dec(&ep_ptr->req_count);
-               dapl_cookie_dealloc(&ep_ptr->req_buffer, cookie);
-               goto bail1;
-       }
-
-       /* if the RMR was previously bound */
-       if (NULL != rmr->lmr)
-               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;
-
-bail1:
-       return status;
-}
-
-/*
- * dapl_rmr_bind
- *
- * DAPL Requirements Version xxx, 6.6.4.4
- *
- * Bind the RMR to the specified memory region within the LMR and
- * provide a new rmr_context value.
- *
- * Input:
- * Output:
- */
-u32 dapl_rmr_bind(DAT_RMR_HANDLE rmr_handle,
-                 const struct dat_lmr_triplet *lmr_triplet,
-                 enum dat_mem_priv_flags mem_priv, DAT_EP_HANDLE ep_handle,
-                 DAT_RMR_COOKIE user_cookie,
-                 enum dat_completion_flags completion_flags,
-                 DAT_RMR_CONTEXT *rmr_context)
-{
-       struct dapl_rmr *rmr;
-       struct 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);
-
-       rmr = (struct dapl_rmr *)rmr_handle;
-       ep_ptr = (struct dapl_ep *)ep_handle;
-
-       /* if the rmr should be bound */
-       if (0 != lmr_triplet->segment_length)
-               return dapl_rmr_bind_fuse(rmr, lmr_triplet, mem_priv, ep_ptr,
-                                         user_cookie, completion_flags, 
-                                          rmr_context);
-       else /* the rmr should be unbound */
-               return dapl_rmr_bind_unfuse(rmr, ep_ptr, user_cookie, 
-                                            completion_flags);
-}
Index: linux-kernel-rmr/dat-provider/dapl_openib_util.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_openib_util.c    (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_openib_util.c    (working copy)
@@ -37,7 +37,6 @@
 #include "dapl_openib_util.h"
 #include "dapl_evd_util.h"
 #include "dapl_cr_util.h"
-#include "dapl_rmr_util.h"
 #include "dapl_cookie.h"
 #include "dapl_openib_cm.h"
 
Index: linux-kernel-rmr/dat-provider/dapl_rmr_util.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr_util.c       (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_rmr_util.c       (working copy)
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
- */
-
-#include "dapl_rmr_util.h"
-#include "dapl_ia_util.h"
-
-struct dapl_rmr *dapl_rmr_alloc(struct dapl_pz *pz)
-{
-       struct dapl_rmr *rmr;
-
-       /* Allocate LMR */
-       rmr = kmalloc(sizeof *rmr, GFP_ATOMIC);
-       if (!rmr)
-               return NULL;
-
-       /* zero the structure */
-       memset(rmr, 0, sizeof *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 = NULL;
-       dapl_llist_init_entry(&rmr->header.ia_list_entry);
-       dapl_ia_link_rmr(rmr->header.owner_ia, rmr);
-       spin_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.pad = 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;
-}
-
-void dapl_rmr_dealloc(struct dapl_rmr *rmr)
-{
-       /* reset magic to prevent reuse */
-       rmr->header.magic = DAPL_MAGIC_INVALID;
-
-       dapl_ia_unlink_rmr(rmr->header.owner_ia, rmr);
-       /* no need to destroy rmr->header.lock */
-
-       kfree(rmr);
-}
Index: linux-kernel-rmr/dat-provider/dapl_rmr.c
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr.c    (revision 0)
+++ linux-kernel-rmr/dat-provider/dapl_rmr.c    (revision 0)
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
+ */
+
+/*
+ * $Id$
+ */
+
+#include "dapl.h"
+#include "dapl_ep_util.h"
+#include "dapl_ia_util.h"
+#include "dapl_mr_util.h"
+#include "dapl_hash.h"
+#include "dapl_cookie.h"
+#include "dapl_openib_util.h"
+
+static inline boolean_t
+dapl_rmr_validate_completion_flag(enum dat_completion_flags mask,
+                                 enum dat_completion_flags allow,
+                                 enum dat_completion_flags request)
+{
+       if ((mask & request) && !(mask & allow))
+               return FALSE;
+       else
+               return TRUE;
+}
+
+
+static struct dapl_rmr *dapl_rmr_alloc(struct dapl_pz *pz)
+{
+       struct dapl_rmr *rmr;
+
+       /* Allocate LMR */
+       rmr = kmalloc(sizeof *rmr, GFP_ATOMIC);
+       if (!rmr)
+               return NULL;
+
+       /* zero the structure */
+       memset(rmr, 0, sizeof *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 = NULL;
+       dapl_llist_init_entry(&rmr->header.ia_list_entry);
+       dapl_ia_link_rmr(rmr->header.owner_ia, rmr);
+       spin_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.pad = 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;
+}
+
+static void dapl_rmr_dealloc(struct dapl_rmr *rmr)
+{
+       /* reset magic to prevent reuse */
+       rmr->header.magic = DAPL_MAGIC_INVALID;
+
+       dapl_ia_unlink_rmr(rmr->header.owner_ia, rmr);
+       /* no need to destroy rmr->header.lock */
+
+       kfree(rmr);
+}
+
+static inline u32 dapl_rmr_bind_fuse(struct dapl_rmr *rmr,
+                                    const struct dat_lmr_triplet *lmr_triplet,
+                                    enum dat_mem_priv_flags mem_priv,
+                                    struct dapl_ep *ep_ptr,
+                                    DAT_RMR_COOKIE user_cookie,
+                                    enum dat_completion_flags completion_flags,
+                                    DAT_RMR_CONTEXT *rmr_context)
+{
+       struct dapl_lmr *lmr;
+       struct dapl_cookie *cookie;
+       u32 status;
+       boolean_t is_signaled;
+
+       status = dapl_hash_search(rmr->header.owner_ia->hca_ptr->lmr_hash_table,
+                                  lmr_triplet->lmr_context,
+                                  (DAPL_HASH_DATA *) &lmr);
+       if (DAT_SUCCESS != status) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+               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) {
+               status =
+                   DAT_ERROR(DAT_INVALID_STATE, dapl_ep_state_subtype(ep_ptr));
+               goto bail;
+       }
+
+       if (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)) {
+               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)) {
+               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)) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
+               goto bail;
+       }
+
+       status = dapl_rmr_cookie_alloc(&ep_ptr->req_buffer, rmr, user_cookie,
+                                       &cookie);
+       if (DAT_SUCCESS != status)
+               goto bail;
+
+       is_signaled = (completion_flags & DAT_COMPLETION_SUPPRESS_FLAG) ? 
+                FALSE : TRUE;
+        
+       /*
+        * Take reference before posting to avoid race conditions with
+        * completions
+        */
+       atomic_inc(&ep_ptr->req_count);
+
+       status = dapl_ib_mw_bind(rmr, lmr, ep_ptr, cookie,
+                                 lmr_triplet->virtual_address,
+                                 lmr_triplet->segment_length,
+                                 mem_priv, is_signaled);
+       if (DAT_SUCCESS != status) {
+               atomic_dec(&ep_ptr->req_count);
+               dapl_cookie_dealloc(&ep_ptr->req_buffer, cookie);
+               goto bail;
+       }
+
+       atomic_inc(&lmr->lmr_ref_count);
+
+       /* if the RMR was previously bound */
+       if (NULL != rmr->lmr)
+               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;
+
+       if (NULL != rmr_context)
+               *rmr_context = rmr->param.rmr_context;
+
+bail:
+       return status;
+}
+
+static inline u32 dapl_rmr_bind_unfuse(struct dapl_rmr *rmr,
+                                      struct dapl_ep *ep_ptr,
+                                      DAT_RMR_COOKIE user_cookie,
+                                      enum dat_completion_flags cflags)
+{
+       struct dapl_cookie *cookie;
+       u32 status = DAT_SUCCESS;
+       boolean_t is_signaled;
+
+       /*
+        * 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) {
+               status = DAT_ERROR(DAT_INVALID_STATE,
+                                  dapl_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) {
+               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,
+                                              cflags) ||
+           !dapl_rmr_validate_completion_flag(DAT_COMPLETION_UNSIGNALLED_FLAG,
+                                              ep_ptr->param.ep_attr.
+                                              request_completion_flags,
+                                              cflags) ||
+           !dapl_rmr_validate_completion_flag(
+                    DAT_COMPLETION_BARRIER_FENCE_FLAG,
+                    ep_ptr->param.ep_attr.request_completion_flags, cflags)) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
+               goto bail1;
+       }
+
+       status = dapl_rmr_cookie_alloc(&ep_ptr->req_buffer, rmr, user_cookie,
+                                       &cookie);
+       if (DAT_SUCCESS != status)
+               goto bail1;
+
+       is_signaled = (cflags & DAT_COMPLETION_UNSIGNALLED_FLAG) ? FALSE : TRUE;
+
+       /*
+        * Take reference before posting to avoid race conditions with 
+        * completions 
+        */
+       atomic_inc(&ep_ptr->req_count);
+
+       status = dapl_ib_mw_unbind(rmr, ep_ptr, cookie, is_signaled);
+       if (DAT_SUCCESS != status) {
+               atomic_dec(&ep_ptr->req_count);
+               dapl_cookie_dealloc(&ep_ptr->req_buffer, cookie);
+               goto bail1;
+       }
+
+       /* if the RMR was previously bound */
+       if (NULL != rmr->lmr)
+               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;
+
+bail1:
+       return status;
+}
+
+/*
+ * dapl_rmr_bind
+ *
+ * DAPL Requirements Version xxx, 6.6.4.4
+ *
+ * Bind the RMR to the specified memory region within the LMR and
+ * provide a new rmr_context value.
+ *
+ * Input:
+ * Output:
+ */
+u32 dapl_rmr_bind(DAT_RMR_HANDLE rmr_handle,
+                 const struct dat_lmr_triplet *lmr_triplet,
+                 enum dat_mem_priv_flags mem_priv, DAT_EP_HANDLE ep_handle,
+                 DAT_RMR_COOKIE user_cookie,
+                 enum dat_completion_flags completion_flags,
+                 DAT_RMR_CONTEXT *rmr_context)
+{
+       struct dapl_rmr *rmr;
+       struct 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);
+
+       rmr = (struct dapl_rmr *)rmr_handle;
+       ep_ptr = (struct dapl_ep *)ep_handle;
+
+       /* if the rmr should be bound */
+       if (0 != lmr_triplet->segment_length)
+               return dapl_rmr_bind_fuse(rmr, lmr_triplet, mem_priv, ep_ptr,
+                                         user_cookie, completion_flags, 
+                                          rmr_context);
+       else /* the rmr should be unbound */
+               return dapl_rmr_bind_unfuse(rmr, ep_ptr, user_cookie, 
+                                            completion_flags);
+}
+
+/*
+ * dapl_rmr_create
+ *
+ * Create a remote memory region for the specified protection zone
+ *
+ * Input:
+ *     pz_handle
+ *
+ * Output:
+ *     rmr_handle
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INSUFFICIENT_RESOURCES
+ *     DAT_INVALID_PARAMETER
+ */
+u32 dapl_rmr_create(DAT_PZ_HANDLE pz_handle, DAT_RMR_HANDLE *rmr_handle)
+{
+       struct dapl_pz *pz;
+       struct dapl_rmr *rmr;
+       u32 status = DAT_SUCCESS;
+
+       if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
+               goto bail;
+       }
+
+       pz = (struct dapl_pz *)pz_handle;
+
+       rmr = dapl_rmr_alloc(pz);
+
+       if (rmr == NULL) {
+               status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+                                  DAT_RESOURCE_MEMORY);
+               goto bail;
+       }
+
+       status = dapl_ib_mw_alloc(rmr);
+
+       if (status != DAT_SUCCESS) {
+               dapl_rmr_dealloc(rmr);
+               status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+                                  DAT_RESOURCE_MEMORY_REGION);
+               goto bail;
+       }
+
+       atomic_inc(&pz->pz_ref_count);
+
+       *rmr_handle = rmr;
+
+bail:
+       return status;
+}
+
+/*
+ * dapl_rmr_free
+ *
+ * Destroy an instance of the Remote Memory Region
+ *
+ * Input:
+ *     rmr_handle
+ *
+ * Output:
+ *     none
+ *
+ * Returns:
+ *     DAT_SUCCESS
+ *     DAT_INVALID_PARAMETER
+ */
+u32 dapl_rmr_free(DAT_RMR_HANDLE rmr_handle)
+{
+       struct dapl_rmr *rmr;
+       u32 status = DAT_SUCCESS;
+
+       if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+               goto bail;
+       }
+
+       rmr = (struct dapl_rmr *)rmr_handle;
+
+       /*
+        * If the user did not perform an unbind op, release
+        * counts here.
+        */
+       if (rmr->param.lmr_triplet.virtual_address != 0) {
+               atomic_dec(&rmr->lmr->lmr_ref_count);
+               rmr->param.lmr_triplet.virtual_address = 0;
+       }
+
+       status = dapl_ib_mw_free(rmr);
+
+       if (status != DAT_SUCCESS)
+               goto bail;
+
+       atomic_dec(&rmr->pz->pz_ref_count);
+
+       dapl_rmr_dealloc(rmr);
+
+bail:
+       return status;
+}
+
+u32 dapl_rmr_query(DAT_RMR_HANDLE rmr_handle, struct dat_rmr_param *rmr_param)
+{
+       struct dapl_rmr *rmr;
+       u32 status = DAT_SUCCESS;
+
+       if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) {
+               status = DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
+               goto bail;
+       }
+       if (NULL == rmr_param) {
+               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
+               goto bail;
+       }
+
+       rmr = (struct dapl_rmr *)rmr_handle;
+
+       memcpy(rmr_param, &rmr->param, sizeof *rmr_param);
+
+bail:
+       return status;
+}
Index: linux-kernel-rmr/dat-provider/dapl_rmr_util.h
===================================================================
--- linux-kernel-rmr/dat-provider/dapl_rmr_util.h       (revision 2483)
+++ linux-kernel-rmr/dat-provider/dapl_rmr_util.h       (working copy)
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. 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.
- */
-
-/*
- * $Id$
- */
-
-#ifndef DAPL_RMR_UTIL_H
-#define DAPL_RMR_UTIL_H
-
-#include "dapl_mr_util.h"
-
-extern struct dapl_rmr *dapl_rmr_alloc(struct dapl_pz *pz);
-
-extern void dapl_rmr_dealloc(struct dapl_rmr *rmr);
-
-static inline boolean_t
-dapl_rmr_validate_completion_flag(enum dat_completion_flags mask,
-                                 enum dat_completion_flags allow,
-                                 enum dat_completion_flags request)
-{
-       if ((mask & request) && !(mask & allow))
-               return FALSE;
-       else
-               return TRUE;
-}
-
-#endif                         /* DAPL_RMR_UTIL_H */
Index: linux-kernel-rmr/patches/alt_dat_provider_makefile
===================================================================
--- linux-kernel-rmr/patches/alt_dat_provider_makefile  (revision 2483)
+++ linux-kernel-rmr/patches/alt_dat_provider_makefile  (working copy)
@@ -16,7 +16,6 @@ PROVIDER_MODULES := \
         dapl_evd_kquery                \
         dapl_evd_kcreate               \
         dapl_evd_modify_upcall         \
-        dapl_lmr_kcreate               \
        dapl_cookie                     \
        dapl_cno_util                   \
         dapl_cr_accept                 \
@@ -61,11 +60,7 @@ PROVIDER_MODULES := \
         dapl_ia_query                  \
         dapl_ia_util                   \
         dapl_llist                     \
-        dapl_lmr_free                  \
-        dapl_lmr_query                 \
-        dapl_lmr_sync_rdma_read        \
-        dapl_lmr_sync_rdma_write       \
-        dapl_lmr_util                  \
+        dapl_lmr                       \
         dapl_mr_util                   \
         dapl_provider                  \
         dapl_sp_util                   \
@@ -73,16 +68,9 @@ PROVIDER_MODULES := \
         dapl_psp_create_any            \
         dapl_psp_free                  \
         dapl_psp_query                 \
-        dapl_pz_create                 \
-        dapl_pz_free                   \
-        dapl_pz_query                  \
-        dapl_pz_util                   \
+        dapl_pz                        \
         dapl_ring_buffer_util          \
-        dapl_rmr_bind                  \
-        dapl_rmr_create                \
-        dapl_rmr_free                  \
-        dapl_rmr_query                 \
-        dapl_rmr_util                  \
+        dapl_rmr                       \
         dapl_rsp_create                \
         dapl_rsp_free                  \
         dapl_rsp_query                 \
@@ -103,7 +91,7 @@ PROVIDER_OBJS := $(foreach s, $(PROVIDER
 KDAPL_DEBUG = 1
 ifeq (1,$(KDAPL_DEBUG))
   EXTRA_CFLAGS += -O0 -g
-  EXTRA_CFLAGS += -DDAPL_DBG # -DDAPL_DBG_IO_TRC
+  EXTRA_CFLAGS += -DDAPL_DBG
 endif
 
 EXTRA_CFLAGS += -DDAPL_ATS -Idrivers/infiniband/include -I$(obj)/../dat 
-I$(obj)/../patches/
@@ -121,4 +109,4 @@ default:
 endif
 
 clean:
-       rm -f *.o *.ko
+       rm -f *.o *.ko .*.d .*.o.tmp *.mod.* .tmp_versions .*.cmd
Index: linux-kernel-rmr/patches/Makefile
===================================================================
--- linux-kernel-rmr/patches/Makefile   (revision 2483)
+++ linux-kernel-rmr/patches/Makefile   (working copy)
@@ -20,4 +20,4 @@ default:
 endif
 
 clean:
-       rm -f *.o *.ko
+       rm -rf *.o *.ko .*.d .*.o.tmp *.mod.* .tmp_versions .*.cmd

_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to