[openib-general] Re: [PATCH] kDAPL: consolidate lmr files into one

James Lentini jlentini at netapp.com
Wed May 25 08:33:34 PDT 2005


Committed in revision 2483.

On Tue, 24 May 2005, Tom Duffy wrote:

tduffy> On Tue, 2005-05-24 at 17:53 -0400, James Lentini wrote:
tduffy> > I'd suggest starting with the memory subsystem. Do you want to do the 
tduffy> > lmr files?
tduffy> 
tduffy> OK, here goes.  Remember that you will need to
tduffy> 
tduffy> svn delete dapl_lmr_free.c dapl_lmr_kcreate.c dapl_lmr_query.c \
tduffy> dapl_lmr_sync_rdma_read.c dapl_lmr_sync_rdma_write.c dapl_lmr_util.c \
tduffy> dapl_lmr_util.h
tduffy> 
tduffy> svn add dapl_lmr.c
tduffy> 
tduffy> Signed-off-by: Tom Duffy <tduffy at sun.com>
tduffy> 
tduffy>  dat-provider/Makefile                   |    7
tduffy>  dat-provider/dapl_lmr.c                 |  618 ++++++++++++++++++++++++++++++++
tduffy>  dat-provider/dapl_lmr_free.c            |  119 ------
tduffy>  dat-provider/dapl_lmr_kcreate.c         |  395 --------------------
tduffy>  dat-provider/dapl_lmr_query.c           |   60 ---
tduffy>  dat-provider/dapl_lmr_sync_rdma_read.c  |   75 ---
tduffy>  dat-provider/dapl_lmr_sync_rdma_write.c |   60 ---
tduffy>  dat-provider/dapl_lmr_util.c            |   85 ----
tduffy>  dat-provider/dapl_lmr_util.h            |   45 --
tduffy>  dat-provider/dapl_openib_util.c         |    1
tduffy>  patches/alt_dat_provider_makefile       |   12
tduffy>  11 files changed, 621 insertions(+), 856 deletions(-)
tduffy> 
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_sync_rdma_read.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_sync_rdma_read.c	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_sync_rdma_read.c	(working copy)
tduffy> @@ -1,75 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#include "dapl.h"
tduffy> -#include "dapl_ia_util.h"
tduffy> -
tduffy> -/*
tduffy> - * dat_lmr_sync_rdma_read
tduffy> - *
tduffy> - * Ensure a region of memory is consistent by locally flushing
tduffy> - * non-coherent cache
tduffy> - *
tduffy> - * Input:
tduffy> - *	ia_handle
tduffy> - *	local_segments		Array of buffer segments
tduffy> - *	num_segments		Number of segments in local_segments
tduffy> - *
tduffy> - * Output:
tduffy> - *	none
tduffy> - *
tduffy> - * Return Values:
tduffy> - * 	DAT_SUCCESS
tduffy> - * 	DAT_INVALID_HANDLE
tduffy> - * 	DAT_INVALID_PARAMETER
tduffy> - */
tduffy> -u32 dapl_lmr_sync_rdma_read(DAT_IA_HANDLE ia_handle,
tduffy> -			    const struct dat_lmr_triplet *local_segments,
tduffy> -			    u64 num_segments)
tduffy> -{
tduffy> -	struct dapl_ia *ia_ptr;
tduffy> -	u32 dat_status = DAT_SUCCESS;
tduffy> -
tduffy> -	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> -		     "dat_lmr_sync_rdma_read (%p, %p, %ld)\n",
tduffy> -		     ia_handle, local_segments, num_segments);
tduffy> -
tduffy> -	ia_ptr = (struct dapl_ia *)ia_handle;
tduffy> -
tduffy> -	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_util.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_util.c	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_util.c	(working copy)
tduffy> @@ -1,85 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#include "dapl_lmr_util.h"
tduffy> -#include "dapl_ia_util.h"
tduffy> -
tduffy> -struct dapl_lmr *dapl_lmr_alloc(struct dapl_ia *ia, enum dat_mem_type mem_type,
tduffy> -				DAT_REGION_DESCRIPTION region_desc, u64 length,
tduffy> -				DAT_PZ_HANDLE pz_handle,
tduffy> -				enum dat_mem_priv_flags mem_priv)
tduffy> -{
tduffy> -	struct dapl_lmr *lmr;
tduffy> -
tduffy> -	/* Allocate LMR */
tduffy> -	lmr = kmalloc(sizeof *lmr, GFP_ATOMIC);
tduffy> -	if (!lmr)
tduffy> -		return NULL;
tduffy> -
tduffy> -	/* zero the structure */
tduffy> -	memset(lmr, 0, sizeof *lmr);
tduffy> -
tduffy> -	/*
tduffy> -	 * initialize the header
tduffy> -	 */
tduffy> -	lmr->header.provider = ia->header.provider;
tduffy> -	lmr->header.magic = DAPL_MAGIC_LMR;
tduffy> -	lmr->header.handle_type = DAT_HANDLE_TYPE_LMR;
tduffy> -	lmr->header.owner_ia = ia;
tduffy> -	lmr->header.user_context.as_64 = 0;
tduffy> -	lmr->header.user_context.as_ptr = NULL;
tduffy> -	dapl_llist_init_entry(&lmr->header.ia_list_entry);
tduffy> -	dapl_ia_link_lmr(ia, lmr);
tduffy> -	spin_lock_init(&lmr->header.lock);
tduffy> -
tduffy> -	/* 
tduffy> -	 * initialize the body 
tduffy> -	 */
tduffy> -	lmr->param.ia_handle = (DAT_IA_HANDLE) ia;
tduffy> -	lmr->param.mem_type = mem_type;
tduffy> -	lmr->param.region_desc = region_desc;
tduffy> -	lmr->param.length = length;
tduffy> -	lmr->param.pz_handle = pz_handle;
tduffy> -	lmr->param.mem_priv = mem_priv;
tduffy> -	atomic_set(&lmr->lmr_ref_count, 0);
tduffy> -
tduffy> -	return lmr;
tduffy> -}
tduffy> -
tduffy> -void dapl_lmr_dealloc(struct dapl_lmr *lmr)
tduffy> -{
tduffy> -	/* reset magic to prevent reuse */
tduffy> -	lmr->header.magic = DAPL_MAGIC_INVALID;
tduffy> -	dapl_ia_unlink_lmr(lmr->header.owner_ia, lmr);
tduffy> -	/* no need to destroy lmr->header.lock */
tduffy> -
tduffy> -	kfree(lmr);
tduffy> -}
tduffy> Index: linux-kernel-lmr/dat-provider/Makefile
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/Makefile	(revision 2476)
tduffy> +++ linux-kernel-lmr/dat-provider/Makefile	(working copy)
tduffy> @@ -22,7 +22,6 @@ PROVIDER_MODULES := \
tduffy>          dapl_evd_kquery               	\
tduffy>          dapl_evd_kcreate              	\
tduffy>          dapl_evd_modify_upcall        	\
tduffy> -        dapl_lmr_kcreate		\
tduffy>  	dapl_cookie   		      	\
tduffy>  	dapl_cno_util			\
tduffy>          dapl_cr_accept                	\
tduffy> @@ -67,11 +66,7 @@ PROVIDER_MODULES := \
tduffy>          dapl_ia_query                 	\
tduffy>          dapl_ia_util                  	\
tduffy>          dapl_llist                    	\
tduffy> -        dapl_lmr_free                 	\
tduffy> -        dapl_lmr_query                	\
tduffy> -        dapl_lmr_sync_rdma_read       	\
tduffy> -        dapl_lmr_sync_rdma_write      	\
tduffy> -        dapl_lmr_util                 	\
tduffy> +        dapl_lmr                 	\
tduffy>          dapl_mr_util                  	\
tduffy>          dapl_provider                 	\
tduffy>          dapl_sp_util                  	\
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_util.h
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_util.h	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_util.h	(working copy)
tduffy> @@ -1,45 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#ifndef DAPL_LMR_UTIL_H
tduffy> -#define DAPL_LMR_UTIL_H
tduffy> -
tduffy> -#include "dapl_mr_util.h"
tduffy> -
tduffy> -extern struct dapl_lmr *dapl_lmr_alloc(struct dapl_ia *ia,
tduffy> -				       enum dat_mem_type mem_type,
tduffy> -				       DAT_REGION_DESCRIPTION region_desc,
tduffy> -				       u64 length, DAT_PZ_HANDLE pz_handle,
tduffy> -				       enum dat_mem_priv_flags mem_priv);
tduffy> -
tduffy> -extern void dapl_lmr_dealloc(struct dapl_lmr *lmr);
tduffy> -
tduffy> -#endif /* DAPL_LMR_UTIL_H */
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_query.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_query.c	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_query.c	(working copy)
tduffy> @@ -1,60 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#include "dapl.h"
tduffy> -
tduffy> -u32 dapl_lmr_query(DAT_LMR_HANDLE lmr_handle, struct dat_lmr_param *lmr_param)
tduffy> -{
tduffy> -	struct dapl_lmr *lmr;
tduffy> -	u32 dat_status;
tduffy> -
tduffy> -	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> -		     "dapl_lmr_query (%p, %p)\n",
tduffy> -		     lmr_handle, lmr_param);
tduffy> -
tduffy> -	if (DAPL_BAD_HANDLE(lmr_handle, DAPL_MAGIC_LMR)) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -	if (NULL == lmr_param) {
tduffy> -		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	dat_status = DAT_SUCCESS;
tduffy> -	lmr = (struct dapl_lmr *)lmr_handle;
tduffy> -
tduffy> -	memcpy(lmr_param, &lmr->param, sizeof *lmr_param);
tduffy> -
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_openib_util.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_openib_util.c	(revision 2476)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_openib_util.c	(working copy)
tduffy> @@ -37,7 +37,6 @@
tduffy>  #include "dapl_openib_util.h"
tduffy>  #include "dapl_evd_util.h"
tduffy>  #include "dapl_cr_util.h"
tduffy> -#include "dapl_lmr_util.h"
tduffy>  #include "dapl_rmr_util.h"
tduffy>  #include "dapl_cookie.h"
tduffy>  #include "dapl_openib_cm.h"
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr.c	(revision 0)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr.c	(revision 0)
tduffy> @@ -0,0 +1,618 @@
tduffy> +/*
tduffy> + * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> + *
tduffy> + * This Software is licensed under one of the following licenses:
tduffy> + *
tduffy> + * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> + *    available from the Open Source Initiative, see
tduffy> + *    http://www.opensource.org/licenses/cpl.php.
tduffy> + *
tduffy> + * 2) under the terms of the "The BSD License" a copy of which is
tduffy> + *    available from the Open Source Initiative, see
tduffy> + *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> + *
tduffy> + * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> + *    copy of which is available from the Open Source Initiative, see
tduffy> + *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> + *
tduffy> + * Licensee has the right to choose one of the above licenses.
tduffy> + *
tduffy> + * Redistributions of source code must retain the above copyright
tduffy> + * notice and one of the license notices.
tduffy> + *
tduffy> + * Redistributions in binary form must reproduce both the above copyright
tduffy> + * notice, one of the license notices in the documentation
tduffy> + * and/or other materials provided with the distribution.
tduffy> + */
tduffy> +
tduffy> +/*
tduffy> + * $Id: dapl_lmr.c 2433 2005-05-21 04:11:03Z jlentini $
tduffy> + */
tduffy> +
tduffy> +#include "dapl_openib_util.h"
tduffy> +#include "dapl_ia_util.h"
tduffy> +#include "dapl_hash.h"
tduffy> +
tduffy> +static struct dapl_lmr *dapl_lmr_alloc(struct dapl_ia *ia,
tduffy> +				       enum dat_mem_type mem_type,
tduffy> +				       DAT_REGION_DESCRIPTION region_desc,
tduffy> +				       u64 length, DAT_PZ_HANDLE pz_handle,
tduffy> +				       enum dat_mem_priv_flags mem_priv)
tduffy> +{
tduffy> +	struct dapl_lmr *lmr;
tduffy> +
tduffy> +	/* Allocate LMR */
tduffy> +	lmr = kmalloc(sizeof *lmr, GFP_ATOMIC);
tduffy> +	if (!lmr)
tduffy> +		return NULL;
tduffy> +
tduffy> +	/* zero the structure */
tduffy> +	memset(lmr, 0, sizeof *lmr);
tduffy> +
tduffy> +	/*
tduffy> +	 * initialize the header
tduffy> +	 */
tduffy> +	lmr->header.provider = ia->header.provider;
tduffy> +	lmr->header.magic = DAPL_MAGIC_LMR;
tduffy> +	lmr->header.handle_type = DAT_HANDLE_TYPE_LMR;
tduffy> +	lmr->header.owner_ia = ia;
tduffy> +	lmr->header.user_context.as_64 = 0;
tduffy> +	lmr->header.user_context.as_ptr = NULL;
tduffy> +	dapl_llist_init_entry(&lmr->header.ia_list_entry);
tduffy> +	dapl_ia_link_lmr(ia, lmr);
tduffy> +	spin_lock_init(&lmr->header.lock);
tduffy> +
tduffy> +	/* 
tduffy> +	 * initialize the body 
tduffy> +	 */
tduffy> +	lmr->param.ia_handle = (DAT_IA_HANDLE) ia;
tduffy> +	lmr->param.mem_type = mem_type;
tduffy> +	lmr->param.region_desc = region_desc;
tduffy> +	lmr->param.length = length;
tduffy> +	lmr->param.pz_handle = pz_handle;
tduffy> +	lmr->param.mem_priv = mem_priv;
tduffy> +	atomic_set(&lmr->lmr_ref_count, 0);
tduffy> +
tduffy> +	return lmr;
tduffy> +}
tduffy> +
tduffy> +static void dapl_lmr_dealloc(struct dapl_lmr *lmr)
tduffy> +{
tduffy> +	/* reset magic to prevent reuse */
tduffy> +	lmr->header.magic = DAPL_MAGIC_INVALID;
tduffy> +	dapl_ia_unlink_lmr(lmr->header.owner_ia, lmr);
tduffy> +	/* no need to destroy lmr->header.lock */
tduffy> +
tduffy> +	kfree(lmr);
tduffy> +}
tduffy> +
tduffy> +/*
tduffy> + * dapl_lmr_free
tduffy> + *
tduffy> + * Destroy an instance of the Local Memory Region
tduffy> + *
tduffy> + * Input:
tduffy> + * 	lmr_handle
tduffy> + *
tduffy> + * Output:
tduffy> + *
tduffy> + * Returns:
tduffy> + * 	DAT_SUCCESS
tduffy> + *      DAT_INVALID_HANDLE
tduffy> + * 	DAT_INVALID_PARAMETER
tduffy> + * 	DAT_INVALID_STATE 
tduffy> + */
tduffy> +
tduffy> +u32 dapl_lmr_free(DAT_LMR_HANDLE lmr_handle)
tduffy> +{
tduffy> +	struct dapl_lmr *lmr;
tduffy> +	u32 dat_status;
tduffy> +
tduffy> +	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_lmr_free (%p)\n", lmr_handle);
tduffy> +
tduffy> +	if (DAPL_BAD_HANDLE(lmr_handle, DAPL_MAGIC_LMR)) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	lmr = (struct dapl_lmr *)lmr_handle;
tduffy> +
tduffy> +	switch (lmr->param.mem_type) {
tduffy> +	case DAT_MEM_TYPE_PHYSICAL:
tduffy> +	case DAT_MEM_TYPE_VIRTUAL:
tduffy> +	case DAT_MEM_TYPE_LMR:
tduffy> +		{
tduffy> +			struct dapl_pz *pz;
tduffy> +
tduffy> +			if (0 != atomic_read(&lmr->lmr_ref_count))
tduffy> +				return DAT_INVALID_STATE;
tduffy> +
tduffy> +			dat_status =
tduffy> +			    dapl_hash_remove(lmr->header.owner_ia->hca_ptr->
tduffy> +					     lmr_hash_table,
tduffy> +					     lmr->param.lmr_context, NULL);
tduffy> +			if (dat_status != DAT_SUCCESS)
tduffy> +				goto bail;
tduffy> +
tduffy> +			dat_status = dapl_ib_mr_deregister(lmr);
tduffy> +
tduffy> +			if (dat_status == DAT_SUCCESS) {
tduffy> +
tduffy> +				pz = (struct dapl_pz *)lmr->param.pz_handle;
tduffy> +				atomic_dec(&pz->pz_ref_count);
tduffy> +
tduffy> +				dapl_lmr_dealloc(lmr);
tduffy> +			} else
tduffy> +				/*
tduffy> +				 * Deregister failed; put it back in the
tduffy> +				 * hash table.
tduffy> +				 */
tduffy> +				dapl_hash_insert(lmr->header.owner_ia->
tduffy> +						 hca_ptr->lmr_hash_table,
tduffy> +						 lmr->param.lmr_context, lmr);
tduffy> +
tduffy> +			break;
tduffy> +		}
tduffy> +	case DAT_MEM_TYPE_PLATFORM:
tduffy> +	case DAT_MEM_TYPE_IA:
tduffy> +	case DAT_MEM_TYPE_BYPASS:
tduffy> +		return DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
tduffy> +	default:
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
tduffy> +		break;
tduffy> +	}
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> +
tduffy> +static inline u32 dapl_lmr_create_virtual(struct dapl_ia *ia, void *virt_addr,
tduffy> +					  u64 length, struct dapl_pz *pz,
tduffy> +					  enum dat_mem_priv_flags privileges,
tduffy> +					  DAT_LMR_HANDLE *lmr_handle,
tduffy> +					  DAT_LMR_CONTEXT *lmr_context,
tduffy> +					  DAT_RMR_CONTEXT *rmr_context,
tduffy> +					  u64 *registered_length,
tduffy> +					  u64 *registered_address)
tduffy> +{
tduffy> +	struct dapl_lmr *lmr;
tduffy> +	DAT_REGION_DESCRIPTION reg_desc;
tduffy> +	u32 dat_status = DAT_SUCCESS;
tduffy> +
tduffy> +	reg_desc.for_va = virt_addr;
tduffy> +
tduffy> +	lmr = dapl_lmr_alloc(ia,
tduffy> +			     DAT_MEM_TYPE_VIRTUAL,
tduffy> +			     reg_desc, length, (DAT_PZ_HANDLE) pz, privileges);
tduffy> +
tduffy> +	if (NULL == lmr) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	dat_status = dapl_ib_mr_register(ia,
tduffy> +					 lmr, virt_addr, length, privileges);
tduffy> +
tduffy> +	if (DAT_SUCCESS != dat_status) {
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	/* if the LMR context is already in the hash table */
tduffy> +	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> +				      lmr->param.lmr_context, NULL);
tduffy> +	if (dat_status == DAT_SUCCESS) {
tduffy> +		(void)dapl_ib_mr_deregister(lmr);
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	dat_status = dapl_hash_insert(ia->hca_ptr->lmr_hash_table,
tduffy> +				      lmr->param.lmr_context, lmr);
tduffy> +	if (dat_status != DAT_SUCCESS) {
tduffy> +		(void)dapl_ib_mr_deregister(lmr);
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +
tduffy> +		/* The value returned by dapl_hash_insert(.) is not    */
tduffy> +		/* returned to the consumer because the spec. requires */
tduffy> +		/* that dat_lmr_create(.) return only certain values.  */
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	atomic_inc(&pz->pz_ref_count);
tduffy> +
tduffy> +	if (lmr_handle)
tduffy> +		*lmr_handle = (DAT_LMR_HANDLE) lmr;
tduffy> +	if (lmr_context)
tduffy> +		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
tduffy> +	if (rmr_context)
tduffy> +		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
tduffy> +	if (registered_address)
tduffy> +		*registered_address = (u64)(unsigned long) virt_addr;
tduffy> +	if (registered_length)
tduffy> +		*registered_length = length;
tduffy> +
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +
tduffy> +}
tduffy> +
tduffy> +static inline u32 dapl_lmr_create_physical(struct dapl_ia *ia,
tduffy> +					   DAT_REGION_DESCRIPTION phys_addr,
tduffy> +					   u64 page_count, struct dapl_pz *pz,
tduffy> +					   enum dat_mem_priv_flags privileges,
tduffy> +					   DAT_LMR_HANDLE *lmr_handle,
tduffy> +					   DAT_LMR_CONTEXT *lmr_context,
tduffy> +					   DAT_RMR_CONTEXT *rmr_context,
tduffy> +					   u64 *registered_length,
tduffy> +					   u64 *registered_address)
tduffy> +{
tduffy> +	struct dapl_lmr *lmr;
tduffy> +	u32 dat_status = DAT_SUCCESS;
tduffy> +	u64 *array = phys_addr.for_array;
tduffy> +
tduffy> +	lmr = dapl_lmr_alloc(ia,
tduffy> +			     DAT_MEM_TYPE_PHYSICAL,
tduffy> +			     phys_addr,
tduffy> +			     page_count, (DAT_PZ_HANDLE) pz, privileges);
tduffy> +
tduffy> +	if (NULL == lmr) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	dat_status = dapl_ib_mr_register_physical(ia, lmr, phys_addr.for_array,
tduffy> +						  page_count, privileges);
tduffy> +
tduffy> +	if (DAT_SUCCESS != dat_status) {
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	/* if the LMR context is already in the hash table */
tduffy> +	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> +				      lmr->param.lmr_context, NULL);
tduffy> +	if (dat_status == DAT_SUCCESS) {
tduffy> +		(void)dapl_ib_mr_deregister(lmr);
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	dat_status = dapl_hash_insert(ia->hca_ptr->lmr_hash_table,
tduffy> +				      lmr->param.lmr_context, lmr);
tduffy> +	if (dat_status != DAT_SUCCESS) {
tduffy> +		(void)dapl_ib_mr_deregister(lmr);
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +
tduffy> +		/* The value returned by dapl_hash_insert(.) is not    */
tduffy> +		/* returned to the consumer because the spec. requires */
tduffy> +		/* that dat_lmr_create(.) return only certain values.  */
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	atomic_inc(&pz->pz_ref_count);
tduffy> +
tduffy> +	if (lmr_handle)
tduffy> +		*lmr_handle = (DAT_LMR_HANDLE) lmr;
tduffy> +	if (lmr_context)
tduffy> +		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
tduffy> +	if (rmr_context)
tduffy> +		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
tduffy> +	if (registered_address)
tduffy> +		*registered_address = array[0];
tduffy> +	if (registered_length)
tduffy> +		*registered_length = page_count * PAGE_SIZE;
tduffy> +
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> +
tduffy> +static inline u32 dapl_lmr_create_lmr(struct dapl_ia *ia,
tduffy> +				      struct dapl_lmr *original_lmr,
tduffy> +				      struct dapl_pz *pz,
tduffy> +				      enum dat_mem_priv_flags privileges,
tduffy> +				      DAT_LMR_HANDLE *lmr_handle,
tduffy> +				      DAT_LMR_CONTEXT *lmr_context,
tduffy> +				      DAT_RMR_CONTEXT *rmr_context,
tduffy> +				      u64 *registered_length,
tduffy> +				      u64 *registered_address)
tduffy> +{
tduffy> +	struct dapl_lmr *lmr;
tduffy> +	DAT_REGION_DESCRIPTION reg_desc;
tduffy> +	u32 dat_status;
tduffy> +
tduffy> +	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> +				      original_lmr->param.lmr_context,
tduffy> +				      (DAPL_HASH_DATA *) & lmr);
tduffy> +	if (dat_status != DAT_SUCCESS) {
tduffy> +		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	reg_desc.for_lmr_handle = (DAT_LMR_HANDLE) original_lmr;
tduffy> +
tduffy> +	lmr = dapl_lmr_alloc(ia, DAT_MEM_TYPE_LMR, reg_desc, 0,	/* length is meaningless */
tduffy> +			     (DAT_PZ_HANDLE) pz, privileges);
tduffy> +
tduffy> +	if (NULL == lmr) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +#if 0
tduffy> +	dat_status = dapl_ib_mr_register_shared(ia, lmr, privileges);
tduffy> +#endif
tduffy> +
tduffy> +	if (DAT_SUCCESS != dat_status) {
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	/* if the LMR context is already in the hash table */
tduffy> +	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> +				      lmr->param.lmr_context, NULL);
tduffy> +	if (dat_status == DAT_SUCCESS) {
tduffy> +		dapl_ib_mr_deregister(lmr);
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	dat_status = dapl_hash_insert(ia->hca_ptr->lmr_hash_table,
tduffy> +				      lmr->param.lmr_context, lmr);
tduffy> +	if (dat_status != DAT_SUCCESS) {
tduffy> +		dapl_ib_mr_deregister(lmr);
tduffy> +		dapl_lmr_dealloc(lmr);
tduffy> +
tduffy> +		/* The value returned by dapl_hash_insert(.) is not    */
tduffy> +		/* returned to the consumer because the spec. requires */
tduffy> +		/* that dat_lmr_create(.) return only certain values.  */
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	atomic_inc(&pz->pz_ref_count);
tduffy> +
tduffy> +	if (lmr_handle)
tduffy> +		*lmr_handle = (DAT_LMR_HANDLE) lmr;
tduffy> +	if (lmr_context)
tduffy> +		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
tduffy> +	if (rmr_context)
tduffy> +		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
tduffy> +	if (registered_address)
tduffy> +		*registered_address = (u64) (unsigned long) 
tduffy> +			original_lmr->param.region_desc.for_va;
tduffy> +	if (registered_length)
tduffy> +		*registered_length = original_lmr->param.length;
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> +
tduffy> +/*
tduffy> + * dapl_lmr_kcreate
tduffy> + *
tduffy> + * Register a memory region with an Interface Adaptor.
tduffy> + *
tduffy> + * Input:
tduffy> + *	ia_handle
tduffy> + *	mem_type
tduffy> + *	region_description
tduffy> + *	length
tduffy> + *	pz_handle
tduffy> + *	privileges
tduffy> + *	optimization
tduffy> + *
tduffy> + * Output:
tduffy> + *	lmr_handle
tduffy> + *	lmr_context
tduffy> + *	registered_length
tduffy> + *	registered_address
tduffy> + *
tduffy> + * Returns:
tduffy> + * 	DAT_SUCCESS
tduffy> + * 	DAT_INSUFFICIENT_RESOURCES
tduffy> + * 	DAT_INVALID_PARAMETER
tduffy> + * 	DAT_INVALID_HANDLE
tduffy> + * 	DAT_INVALID_STATE
tduffy> + * 	DAT_MODEL_NOT_SUPPORTED
tduffy> + *
tduffy> + */
tduffy> +u32 dapl_lmr_kcreate(DAT_IA_HANDLE ia_handle, enum dat_mem_type mem_type,
tduffy> +		     DAT_REGION_DESCRIPTION region_description, u64 length,
tduffy> +		     DAT_PZ_HANDLE pz_handle,
tduffy> +		     enum dat_mem_priv_flags privileges,
tduffy> +		     enum dat_mem_optimize_flags optimization, DAT_LMR_HANDLE *lmr_handle,
tduffy> +		     DAT_LMR_CONTEXT *lmr_context, DAT_RMR_CONTEXT *rmr_context,		     u64 *registered_length, u64 *registered_address)
tduffy> +{
tduffy> +	struct dapl_ia *ia;
tduffy> +	struct dapl_pz *pz;
tduffy> +	u32 dat_status;
tduffy> +
tduffy> +	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> +		     "dapl_lmr_kcreate(ia:%p, mem_type:%x, ...)\n",
tduffy> +		     ia_handle, mem_type);
tduffy> +
tduffy> +	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +	if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	ia = (struct dapl_ia *)ia_handle;
tduffy> +	pz = (struct dapl_pz *)pz_handle;
tduffy> +
tduffy> +	switch (mem_type) {
tduffy> +	case DAT_MEM_TYPE_VIRTUAL:
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
tduffy> +		break;
tduffy> +		/*
tduffy> +		 * dat_status = dapl_lmr_create_virtual (
tduffy> +		 * ia, region_description.for_va, length, pz, privileges,
tduffy> +		 * lmr_handle, lmr_context, rmr_context, registered_length,
tduffy> +		 * registered_address);
tduffy> +		 * break;
tduffy> +		 */
tduffy> +	case DAT_MEM_TYPE_PHYSICAL:
tduffy> +		dat_status = dapl_lmr_create_physical(ia, region_description,
tduffy> +						      length, pz, privileges,
tduffy> +						      lmr_handle, lmr_context,
tduffy> +						      rmr_context,
tduffy> +						      registered_length,
tduffy> +						      registered_address);
tduffy> +		break;
tduffy> +	case DAT_MEM_TYPE_LMR:
tduffy> +		{
tduffy> +			struct dapl_lmr *lmr;
tduffy> +
tduffy> +			if (DAPL_BAD_HANDLE
tduffy> +			    (region_description.for_lmr_handle,
tduffy> +			     DAPL_MAGIC_LMR)) {
tduffy> +				dat_status =
tduffy> +				    DAT_ERROR(DAT_INVALID_HANDLE,
tduffy> +					      DAT_INVALID_HANDLE_LMR);
tduffy> +				goto bail;
tduffy> +			}
tduffy> +
tduffy> +			lmr = (struct dapl_lmr *)region_description.for_lmr_handle;
tduffy> +
tduffy> +			dat_status =
tduffy> +			    dapl_lmr_create_lmr(ia, lmr, pz, privileges,
tduffy> +						lmr_handle, lmr_context,
tduffy> +						rmr_context, registered_length,
tduffy> +						registered_address);
tduffy> +			break;
tduffy> +		}
tduffy> +	case DAT_MEM_TYPE_PLATFORM:
tduffy> +	case DAT_MEM_TYPE_IA:
tduffy> +	case DAT_MEM_TYPE_BYPASS:
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
tduffy> +		break;
tduffy> +	default:
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
tduffy> +		break;
tduffy> +	}
tduffy> +
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> +
tduffy> +u32 dapl_lmr_query(DAT_LMR_HANDLE lmr_handle, struct dat_lmr_param *lmr_param)
tduffy> +{
tduffy> +	struct dapl_lmr *lmr;
tduffy> +	u32 dat_status;
tduffy> +
tduffy> +	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> +		     "dapl_lmr_query (%p, %p)\n",
tduffy> +		     lmr_handle, lmr_param);
tduffy> +
tduffy> +	if (DAPL_BAD_HANDLE(lmr_handle, DAPL_MAGIC_LMR)) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +	if (NULL == lmr_param) {
tduffy> +		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +	dat_status = DAT_SUCCESS;
tduffy> +	lmr = (struct dapl_lmr *)lmr_handle;
tduffy> +
tduffy> +	memcpy(lmr_param, &lmr->param, sizeof *lmr_param);
tduffy> +
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> +
tduffy> +/*
tduffy> + * dat_lmr_sync_rdma_read
tduffy> + *
tduffy> + * Ensure a region of memory is consistent by locally flushing
tduffy> + * non-coherent cache
tduffy> + *
tduffy> + * Input:
tduffy> + *	ia_handle
tduffy> + *	local_segments		Array of buffer segments
tduffy> + *	num_segments		Number of segments in local_segments
tduffy> + *
tduffy> + * Output:
tduffy> + *	none
tduffy> + *
tduffy> + * Return Values:
tduffy> + * 	DAT_SUCCESS
tduffy> + * 	DAT_INVALID_HANDLE
tduffy> + * 	DAT_INVALID_PARAMETER
tduffy> + */
tduffy> +u32 dapl_lmr_sync_rdma_read(DAT_IA_HANDLE ia_handle,
tduffy> +			    const struct dat_lmr_triplet *local_segments,
tduffy> +			    u64 num_segments)
tduffy> +{
tduffy> +	struct dapl_ia *ia_ptr;
tduffy> +	u32 dat_status = DAT_SUCCESS;
tduffy> +
tduffy> +	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> +		     "dat_lmr_sync_rdma_read (%p, %p, %ld)\n",
tduffy> +		     ia_handle, local_segments, num_segments);
tduffy> +
tduffy> +	ia_ptr = (struct dapl_ia *)ia_handle;
tduffy> +
tduffy> +	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> +
tduffy> +/*
tduffy> + * Ensure a region of memory is consistent by locally flushing
tduffy> + * non-coherent cache
tduffy> + */
tduffy> +u32 dapl_lmr_sync_rdma_write(DAT_IA_HANDLE ia_handle,
tduffy> +			     const struct dat_lmr_triplet *local_segments,
tduffy> +			     u64 num_segments)
tduffy> +{
tduffy> +	struct dapl_ia *ia_ptr;
tduffy> +	u32 dat_status = DAT_SUCCESS;
tduffy> +
tduffy> +	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> +		     "dat_lmr_sync_rdma_write (%p, %p, %ld)\n",
tduffy> +		     ia_handle, local_segments, num_segments);
tduffy> +
tduffy> +	ia_ptr = (struct dapl_ia *)ia_handle;
tduffy> +
tduffy> +	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
tduffy> +		dat_status =
tduffy> +		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
tduffy> +		goto bail;
tduffy> +	}
tduffy> +
tduffy> +bail:
tduffy> +	return dat_status;
tduffy> +}
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_free.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_free.c	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_free.c	(working copy)
tduffy> @@ -1,119 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#include "dapl_lmr_util.h"
tduffy> -#include "dapl_openib_util.h"
tduffy> -#include "dapl_ia_util.h"
tduffy> -
tduffy> -/*
tduffy> - * dapl_lmr_free
tduffy> - *
tduffy> - * Destroy an instance of the Local Memory Region
tduffy> - *
tduffy> - * Input:
tduffy> - * 	lmr_handle
tduffy> - *
tduffy> - * Output:
tduffy> - *
tduffy> - * Returns:
tduffy> - * 	DAT_SUCCESS
tduffy> - *      DAT_INVALID_HANDLE
tduffy> - * 	DAT_INVALID_PARAMETER
tduffy> - * 	DAT_INVALID_STATE 
tduffy> - */
tduffy> -
tduffy> -u32 dapl_lmr_free(DAT_LMR_HANDLE lmr_handle)
tduffy> -{
tduffy> -	struct dapl_lmr *lmr;
tduffy> -	u32 dat_status;
tduffy> -
tduffy> -	dapl_dbg_log(DAPL_DBG_TYPE_API, "dapl_lmr_free (%p)\n", lmr_handle);
tduffy> -
tduffy> -	if (DAPL_BAD_HANDLE(lmr_handle, DAPL_MAGIC_LMR)) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	lmr = (struct dapl_lmr *)lmr_handle;
tduffy> -
tduffy> -	switch (lmr->param.mem_type) {
tduffy> -	case DAT_MEM_TYPE_PHYSICAL:
tduffy> -	case DAT_MEM_TYPE_VIRTUAL:
tduffy> -	case DAT_MEM_TYPE_LMR:
tduffy> -		{
tduffy> -			struct dapl_pz *pz;
tduffy> -
tduffy> -			if (0 != atomic_read(&lmr->lmr_ref_count))
tduffy> -				return DAT_INVALID_STATE;
tduffy> -
tduffy> -			dat_status =
tduffy> -			    dapl_hash_remove(lmr->header.owner_ia->hca_ptr->
tduffy> -					     lmr_hash_table,
tduffy> -					     lmr->param.lmr_context, NULL);
tduffy> -			if (dat_status != DAT_SUCCESS)
tduffy> -				goto bail;
tduffy> -
tduffy> -			dat_status = dapl_ib_mr_deregister(lmr);
tduffy> -
tduffy> -			if (dat_status == DAT_SUCCESS) {
tduffy> -
tduffy> -				pz = (struct dapl_pz *)lmr->param.pz_handle;
tduffy> -				atomic_dec(&pz->pz_ref_count);
tduffy> -
tduffy> -				dapl_lmr_dealloc(lmr);
tduffy> -			} else
tduffy> -				/*
tduffy> -				 * Deregister failed; put it back in the
tduffy> -				 * hash table.
tduffy> -				 */
tduffy> -				dapl_hash_insert(lmr->header.owner_ia->
tduffy> -						 hca_ptr->lmr_hash_table,
tduffy> -						 lmr->param.lmr_context, lmr);
tduffy> -
tduffy> -			break;
tduffy> -		}
tduffy> -	case DAT_MEM_TYPE_PLATFORM:
tduffy> -	case DAT_MEM_TYPE_IA:
tduffy> -	case DAT_MEM_TYPE_BYPASS:
tduffy> -		{
tduffy> -			return DAT_ERROR(DAT_NOT_IMPLEMENTED, 0);
tduffy> -		}
tduffy> -	default:
tduffy> -		{
tduffy> -			dat_status =
tduffy> -			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1);
tduffy> -			break;
tduffy> -		}
tduffy> -	}
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_sync_rdma_write.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_sync_rdma_write.c	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_sync_rdma_write.c	(working copy)
tduffy> @@ -1,60 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#include "dapl.h"
tduffy> -#include "dapl_ia_util.h"
tduffy> -
tduffy> -/*
tduffy> - * Ensure a region of memory is consistent by locally flushing
tduffy> - * non-coherent cache
tduffy> - */
tduffy> -u32 dapl_lmr_sync_rdma_write(DAT_IA_HANDLE ia_handle,
tduffy> -			     const struct dat_lmr_triplet *local_segments,
tduffy> -			     u64 num_segments)
tduffy> -{
tduffy> -	struct dapl_ia *ia_ptr;
tduffy> -	u32 dat_status = DAT_SUCCESS;
tduffy> -
tduffy> -	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> -		     "dat_lmr_sync_rdma_write (%p, %p, %ld)\n",
tduffy> -		     ia_handle, local_segments, num_segments);
tduffy> -
tduffy> -	ia_ptr = (struct dapl_ia *)ia_handle;
tduffy> -
tduffy> -	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> Index: linux-kernel-lmr/dat-provider/dapl_lmr_kcreate.c
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/dat-provider/dapl_lmr_kcreate.c	(revision 2475)
tduffy> +++ linux-kernel-lmr/dat-provider/dapl_lmr_kcreate.c	(working copy)
tduffy> @@ -1,395 +0,0 @@
tduffy> -/*
tduffy> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
tduffy> - *
tduffy> - * This Software is licensed under one of the following licenses:
tduffy> - *
tduffy> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/cpl.php.
tduffy> - *
tduffy> - * 2) under the terms of the "The BSD License" a copy of which is
tduffy> - *    available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/bsd-license.php.
tduffy> - *
tduffy> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
tduffy> - *    copy of which is available from the Open Source Initiative, see
tduffy> - *    http://www.opensource.org/licenses/gpl-license.php.
tduffy> - *
tduffy> - * Licensee has the right to choose one of the above licenses.
tduffy> - *
tduffy> - * Redistributions of source code must retain the above copyright
tduffy> - * notice and one of the license notices.
tduffy> - *
tduffy> - * Redistributions in binary form must reproduce both the above copyright
tduffy> - * notice, one of the license notices in the documentation
tduffy> - * and/or other materials provided with the distribution.
tduffy> - */
tduffy> -
tduffy> -/*
tduffy> - * $Id$
tduffy> - */
tduffy> -
tduffy> -#include "dapl_lmr_util.h"
tduffy> -#include "dapl_openib_util.h"
tduffy> -
tduffy> -static inline u32 dapl_lmr_create_virtual(struct dapl_ia *ia, void *virt_addr,
tduffy> -					  u64 length, struct dapl_pz *pz,
tduffy> -					  enum dat_mem_priv_flags privileges,
tduffy> -					  DAT_LMR_HANDLE *lmr_handle,
tduffy> -					  DAT_LMR_CONTEXT *lmr_context,
tduffy> -					  DAT_RMR_CONTEXT *rmr_context,
tduffy> -					  u64 *registered_length,
tduffy> -					  u64 *registered_address)
tduffy> -{
tduffy> -	struct dapl_lmr *lmr;
tduffy> -	DAT_REGION_DESCRIPTION reg_desc;
tduffy> -	u32 dat_status = DAT_SUCCESS;
tduffy> -
tduffy> -	reg_desc.for_va = virt_addr;
tduffy> -
tduffy> -	lmr = dapl_lmr_alloc(ia,
tduffy> -			     DAT_MEM_TYPE_VIRTUAL,
tduffy> -			     reg_desc, length, (DAT_PZ_HANDLE) pz, privileges);
tduffy> -
tduffy> -	if (NULL == lmr) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	dat_status = dapl_ib_mr_register(ia,
tduffy> -					 lmr, virt_addr, length, privileges);
tduffy> -
tduffy> -	if (DAT_SUCCESS != dat_status) {
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	/* if the LMR context is already in the hash table */
tduffy> -	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> -				      lmr->param.lmr_context, NULL);
tduffy> -	if (dat_status == DAT_SUCCESS) {
tduffy> -		(void)dapl_ib_mr_deregister(lmr);
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	dat_status = dapl_hash_insert(ia->hca_ptr->lmr_hash_table,
tduffy> -				      lmr->param.lmr_context, lmr);
tduffy> -	if (dat_status != DAT_SUCCESS) {
tduffy> -		(void)dapl_ib_mr_deregister(lmr);
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -
tduffy> -		/* The value returned by dapl_hash_insert(.) is not    */
tduffy> -		/* returned to the consumer because the spec. requires */
tduffy> -		/* that dat_lmr_create(.) return only certain values.  */
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	atomic_inc(&pz->pz_ref_count);
tduffy> -
tduffy> -	if (lmr_handle)
tduffy> -		*lmr_handle = (DAT_LMR_HANDLE) lmr;
tduffy> -	if (lmr_context)
tduffy> -		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
tduffy> -	if (rmr_context)
tduffy> -		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
tduffy> -	if (registered_address)
tduffy> -		*registered_address = (u64)(unsigned long) virt_addr;
tduffy> -	if (registered_length)
tduffy> -		*registered_length = length;
tduffy> -
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -
tduffy> -}
tduffy> -
tduffy> -static inline u32 dapl_lmr_create_physical(struct dapl_ia *ia,
tduffy> -					   DAT_REGION_DESCRIPTION phys_addr,
tduffy> -					   u64 page_count, struct dapl_pz *pz,
tduffy> -					   enum dat_mem_priv_flags privileges,
tduffy> -					   DAT_LMR_HANDLE *lmr_handle,
tduffy> -					   DAT_LMR_CONTEXT *lmr_context,
tduffy> -					   DAT_RMR_CONTEXT *rmr_context,
tduffy> -					   u64 *registered_length,
tduffy> -					   u64 *registered_address)
tduffy> -{
tduffy> -	struct dapl_lmr *lmr;
tduffy> -	u32 dat_status = DAT_SUCCESS;
tduffy> -	u64 *array = phys_addr.for_array;
tduffy> -
tduffy> -	lmr = dapl_lmr_alloc(ia,
tduffy> -			     DAT_MEM_TYPE_PHYSICAL,
tduffy> -			     phys_addr,
tduffy> -			     page_count, (DAT_PZ_HANDLE) pz, privileges);
tduffy> -
tduffy> -	if (NULL == lmr) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	dat_status = dapl_ib_mr_register_physical(ia, lmr, phys_addr.for_array,
tduffy> -						  page_count, privileges);
tduffy> -
tduffy> -	if (DAT_SUCCESS != dat_status) {
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	/* if the LMR context is already in the hash table */
tduffy> -	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> -				      lmr->param.lmr_context, NULL);
tduffy> -	if (dat_status == DAT_SUCCESS) {
tduffy> -		(void)dapl_ib_mr_deregister(lmr);
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	dat_status = dapl_hash_insert(ia->hca_ptr->lmr_hash_table,
tduffy> -				      lmr->param.lmr_context, lmr);
tduffy> -	if (dat_status != DAT_SUCCESS) {
tduffy> -		(void)dapl_ib_mr_deregister(lmr);
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -
tduffy> -		/* The value returned by dapl_hash_insert(.) is not    */
tduffy> -		/* returned to the consumer because the spec. requires */
tduffy> -		/* that dat_lmr_create(.) return only certain values.  */
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	atomic_inc(&pz->pz_ref_count);
tduffy> -
tduffy> -	if (lmr_handle)
tduffy> -		*lmr_handle = (DAT_LMR_HANDLE) lmr;
tduffy> -	if (lmr_context)
tduffy> -		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
tduffy> -	if (rmr_context)
tduffy> -		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
tduffy> -	if (registered_address)
tduffy> -		*registered_address = array[0];
tduffy> -	if (registered_length)
tduffy> -		*registered_length = page_count * PAGE_SIZE;
tduffy> -
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> -
tduffy> -static inline u32 dapl_lmr_create_lmr(struct dapl_ia *ia,
tduffy> -				      struct dapl_lmr *original_lmr,
tduffy> -				      struct dapl_pz *pz,
tduffy> -				      enum dat_mem_priv_flags privileges,
tduffy> -				      DAT_LMR_HANDLE *lmr_handle,
tduffy> -				      DAT_LMR_CONTEXT *lmr_context,
tduffy> -				      DAT_RMR_CONTEXT *rmr_context,
tduffy> -				      u64 *registered_length,
tduffy> -				      u64 *registered_address)
tduffy> -{
tduffy> -	struct dapl_lmr *lmr;
tduffy> -	DAT_REGION_DESCRIPTION reg_desc;
tduffy> -	u32 dat_status;
tduffy> -
tduffy> -	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> -				      original_lmr->param.lmr_context,
tduffy> -				      (DAPL_HASH_DATA *) & lmr);
tduffy> -	if (dat_status != DAT_SUCCESS) {
tduffy> -		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	reg_desc.for_lmr_handle = (DAT_LMR_HANDLE) original_lmr;
tduffy> -
tduffy> -	lmr = dapl_lmr_alloc(ia, DAT_MEM_TYPE_LMR, reg_desc, 0,	/* length is meaningless */
tduffy> -			     (DAT_PZ_HANDLE) pz, privileges);
tduffy> -
tduffy> -	if (NULL == lmr) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -#if 0
tduffy> -	dat_status = dapl_ib_mr_register_shared(ia, lmr, privileges);
tduffy> -#endif
tduffy> -
tduffy> -	if (DAT_SUCCESS != dat_status) {
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	/* if the LMR context is already in the hash table */
tduffy> -	dat_status = dapl_hash_search(ia->hca_ptr->lmr_hash_table,
tduffy> -				      lmr->param.lmr_context, NULL);
tduffy> -	if (dat_status == DAT_SUCCESS) {
tduffy> -		dapl_ib_mr_deregister(lmr);
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_STATE, DAT_INVALID_STATE_LMR_IN_USE);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	dat_status = dapl_hash_insert(ia->hca_ptr->lmr_hash_table,
tduffy> -				      lmr->param.lmr_context, lmr);
tduffy> -	if (dat_status != DAT_SUCCESS) {
tduffy> -		dapl_ib_mr_deregister(lmr);
tduffy> -		dapl_lmr_dealloc(lmr);
tduffy> -
tduffy> -		/* The value returned by dapl_hash_insert(.) is not    */
tduffy> -		/* returned to the consumer because the spec. requires */
tduffy> -		/* that dat_lmr_create(.) return only certain values.  */
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	atomic_inc(&pz->pz_ref_count);
tduffy> -
tduffy> -	if (lmr_handle)
tduffy> -		*lmr_handle = (DAT_LMR_HANDLE) lmr;
tduffy> -	if (lmr_context)
tduffy> -		*lmr_context = (DAT_LMR_CONTEXT) lmr->param.lmr_context;
tduffy> -	if (rmr_context)
tduffy> -		*rmr_context = (DAT_LMR_CONTEXT) lmr->param.rmr_context;
tduffy> -	if (registered_address)
tduffy> -		*registered_address = (u64) (unsigned long) 
tduffy> -			original_lmr->param.region_desc.for_va;
tduffy> -	if (registered_length)
tduffy> -		*registered_length = original_lmr->param.length;
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> -
tduffy> -/*
tduffy> - * dapl_lmr_kcreate
tduffy> - *
tduffy> - * Register a memory region with an Interface Adaptor.
tduffy> - *
tduffy> - * Input:
tduffy> - *	ia_handle
tduffy> - *	mem_type
tduffy> - *	region_description
tduffy> - *	length
tduffy> - *	pz_handle
tduffy> - *	privileges
tduffy> - *	optimization
tduffy> - *
tduffy> - * Output:
tduffy> - *	lmr_handle
tduffy> - *	lmr_context
tduffy> - *	registered_length
tduffy> - *	registered_address
tduffy> - *
tduffy> - * Returns:
tduffy> - * 	DAT_SUCCESS
tduffy> - * 	DAT_INSUFFICIENT_RESOURCES
tduffy> - * 	DAT_INVALID_PARAMETER
tduffy> - * 	DAT_INVALID_HANDLE
tduffy> - * 	DAT_INVALID_STATE
tduffy> - * 	DAT_MODEL_NOT_SUPPORTED
tduffy> - *
tduffy> - */
tduffy> -u32 dapl_lmr_kcreate(DAT_IA_HANDLE ia_handle, enum dat_mem_type mem_type,
tduffy> -		     DAT_REGION_DESCRIPTION region_description, u64 length,
tduffy> -		     DAT_PZ_HANDLE pz_handle,
tduffy> -		     enum dat_mem_priv_flags privileges,
tduffy> -		     enum dat_mem_optimize_flags optimization, DAT_LMR_HANDLE *lmr_handle,
tduffy> -		     DAT_LMR_CONTEXT *lmr_context, DAT_RMR_CONTEXT *rmr_context,		     u64 *registered_length, u64 *registered_address)
tduffy> -{
tduffy> -	struct dapl_ia *ia;
tduffy> -	struct dapl_pz *pz;
tduffy> -	u32 dat_status;
tduffy> -
tduffy> -	dapl_dbg_log(DAPL_DBG_TYPE_API,
tduffy> -		     "dapl_lmr_kcreate(ia:%p, mem_type:%x, ...)\n",
tduffy> -		     ia_handle, mem_type);
tduffy> -
tduffy> -	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -	if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) {
tduffy> -		dat_status =
tduffy> -		    DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ);
tduffy> -		goto bail;
tduffy> -	}
tduffy> -
tduffy> -	ia = (struct dapl_ia *)ia_handle;
tduffy> -	pz = (struct dapl_pz *)pz_handle;
tduffy> -
tduffy> -	switch (mem_type) {
tduffy> -	case DAT_MEM_TYPE_VIRTUAL:
tduffy> -		{
tduffy> -			dat_status =
tduffy> -			    DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
tduffy> -			break;
tduffy> -			/*
tduffy> -			   dat_status = dapl_lmr_create_virtual (
tduffy> -			   ia, region_description.for_va, length, pz, privileges,
tduffy> -			   lmr_handle, lmr_context, rmr_context, registered_length,
tduffy> -			   registered_address);
tduffy> -			   break;
tduffy> -			 */
tduffy> -		}
tduffy> -	case DAT_MEM_TYPE_PHYSICAL:
tduffy> -		{
tduffy> -			dat_status =
tduffy> -			    dapl_lmr_create_physical(ia, region_description,
tduffy> -						     length, pz, privileges,
tduffy> -						     lmr_handle, lmr_context,
tduffy> -						     rmr_context,
tduffy> -						     registered_length,
tduffy> -						     registered_address);
tduffy> -			break;
tduffy> -		}
tduffy> -	case DAT_MEM_TYPE_LMR:
tduffy> -		{
tduffy> -			struct dapl_lmr *lmr;
tduffy> -
tduffy> -			if (DAPL_BAD_HANDLE
tduffy> -			    (region_description.for_lmr_handle,
tduffy> -			     DAPL_MAGIC_LMR)) {
tduffy> -				dat_status =
tduffy> -				    DAT_ERROR(DAT_INVALID_HANDLE,
tduffy> -					      DAT_INVALID_HANDLE_LMR);
tduffy> -				goto bail;
tduffy> -			}
tduffy> -
tduffy> -			lmr = (struct dapl_lmr *)region_description.for_lmr_handle;
tduffy> -
tduffy> -			dat_status =
tduffy> -			    dapl_lmr_create_lmr(ia, lmr, pz, privileges,
tduffy> -						lmr_handle, lmr_context,
tduffy> -						rmr_context, registered_length,
tduffy> -						registered_address);
tduffy> -			break;
tduffy> -		}
tduffy> -	case DAT_MEM_TYPE_PLATFORM:
tduffy> -	case DAT_MEM_TYPE_IA:
tduffy> -	case DAT_MEM_TYPE_BYPASS:
tduffy> -		{
tduffy> -			dat_status =
tduffy> -			    DAT_ERROR(DAT_NOT_IMPLEMENTED, DAT_NO_SUBTYPE);
tduffy> -			break;
tduffy> -		}
tduffy> -	default:
tduffy> -		{
tduffy> -			dat_status =
tduffy> -			    DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
tduffy> -			break;
tduffy> -		}
tduffy> -	}
tduffy> -
tduffy> -bail:
tduffy> -	return dat_status;
tduffy> -}
tduffy> Index: linux-kernel-lmr/patches/alt_dat_provider_makefile
tduffy> ===================================================================
tduffy> --- linux-kernel-lmr/patches/alt_dat_provider_makefile	(revision 2475)
tduffy> +++ linux-kernel-lmr/patches/alt_dat_provider_makefile	(working copy)
tduffy> @@ -16,7 +16,6 @@ PROVIDER_MODULES := \
tduffy>          dapl_evd_kquery               	\
tduffy>          dapl_evd_kcreate              	\
tduffy>          dapl_evd_modify_upcall        	\
tduffy> -        dapl_lmr_kcreate		\
tduffy>  	dapl_cookie   		      	\
tduffy>  	dapl_cno_util			\
tduffy>          dapl_cr_accept                	\
tduffy> @@ -61,11 +60,7 @@ PROVIDER_MODULES := \
tduffy>          dapl_ia_query                 	\
tduffy>          dapl_ia_util                  	\
tduffy>          dapl_llist                    	\
tduffy> -        dapl_lmr_free                 	\
tduffy> -        dapl_lmr_query                	\
tduffy> -        dapl_lmr_sync_rdma_read       	\
tduffy> -        dapl_lmr_sync_rdma_write      	\
tduffy> -        dapl_lmr_util                 	\
tduffy> +        dapl_lmr                 	\
tduffy>          dapl_mr_util                  	\
tduffy>          dapl_provider                 	\
tduffy>          dapl_sp_util                  	\
tduffy> @@ -73,10 +68,7 @@ PROVIDER_MODULES := \
tduffy>          dapl_psp_create_any           	\
tduffy>          dapl_psp_free                 	\
tduffy>          dapl_psp_query                	\
tduffy> -        dapl_pz_create                	\
tduffy> -        dapl_pz_free                  	\
tduffy> -        dapl_pz_query                 	\
tduffy> -        dapl_pz_util                  	\
tduffy> +        dapl_pz                  	\
tduffy>          dapl_ring_buffer_util         	\
tduffy>          dapl_rmr_bind                 	\
tduffy>          dapl_rmr_create               	\
tduffy> 



More information about the general mailing list