2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#include "dapl_mr_util.h"
2N/A
2N/A/*
2N/A *
2N/A * MODULE: dapl_mr_util.c
2N/A *
2N/A * PURPOSE: Common Memory Management functions and data structures
2N/A *
2N/A */
2N/A
2N/A/*
2N/A *
2N/A * Function Definitions
2N/A *
2N/A */
2N/A
2N/A/*
2N/A * dapl_mr_get_address
2N/A *
2N/A * Returns the memory address associated with the given memory descriptor
2N/A *
2N/A */
2N/ADAT_VADDR
2N/Adapl_mr_get_address(DAT_REGION_DESCRIPTION desc, DAT_MEM_TYPE type)
2N/A{
2N/A switch (type) {
2N/A case DAT_MEM_TYPE_VIRTUAL: {
2N/A return ((DAT_VADDR)(uintptr_t)desc.for_va);
2N/A }
2N/A case DAT_MEM_TYPE_LMR: {
2N/A DAPL_LMR *lmr;
2N/A
2N/A lmr = (DAPL_LMR *)desc.for_lmr_handle;
2N/A
2N/A /* Since this function is recoursive we cannot inline it */
2N/A return (dapl_mr_get_address(lmr->param.region_desc,
2N/A lmr->param.mem_type));
2N/A }
2N/A case DAT_MEM_TYPE_SHARED_VIRTUAL: {
2N/A return ((DAT_VADDR)(uintptr_t)
2N/A desc.for_shared_memory.virtual_address);
2N/A }
2N/A default:
2N/A dapl_os_assert(0);
2N/A return (0);
2N/A }
2N/A}
2N/A
2N/A/*
2N/A * dapl_mr_bounds_check
2N/A *
2N/A * Returns true if region B is contained within region A
2N/A * and false otherwise
2N/A *
2N/A */
2N/ADAT_BOOLEAN
2N/Adapl_mr_bounds_check(DAT_VADDR addr_a, DAT_VLEN length_a,
2N/A DAT_VADDR addr_b, DAT_VLEN length_b)
2N/A{
2N/A if ((addr_a <= addr_b) &&
2N/A (addr_b + length_b) <= (addr_a + length_a)) {
2N/A return (DAT_TRUE);
2N/A } else {
2N/A return (DAT_FALSE);
2N/A }
2N/A}