dapl_rmr_create.c revision 9517:b4839b0aa7a4
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved. 24 */ 25 26/* 27 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31/* 32 * 33 * MODULE: dapl_rmr_create.c 34 * 35 * PURPOSE: Memory management 36 * Description: Interfaces in this file are completely described in 37 * the DAPL 1.1 API, Chapter 6, section 6 38 * 39 */ 40 41#include "dapl_rmr_util.h" 42#include "dapl_adapter_util.h" 43 44/* 45 * dapl_rmr_create 46 * 47 * DAPL Requirements Version xxx, 6.6.4.1 48 * 49 * Create a remote memory region for the specified protection zone 50 * 51 * Input: 52 * pz_handle 53 * 54 * Output: 55 * rmr_handle 56 * 57 * Returns: 58 * DAT_SUCCESS 59 * DAT_INSUFFICIENT_RESOURCES 60 * DAT_INVALID_PARAMETER 61 */ 62DAT_RETURN 63dapl_rmr_create(IN DAT_PZ_HANDLE pz_handle, 64 OUT DAT_RMR_HANDLE * rmr_handle) 65{ 66 DAPL_PZ *pz; 67 DAPL_RMR *rmr; 68 DAT_RETURN dat_status; 69 70 dat_status = DAT_SUCCESS; 71 72 if (DAPL_BAD_HANDLE(pz_handle, DAPL_MAGIC_PZ)) { 73 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 74 DAT_INVALID_HANDLE_PZ); 75 goto bail; 76 } 77 78 pz = (DAPL_PZ *) pz_handle; 79 80 rmr = dapl_rmr_alloc(pz); 81 82 if (rmr == NULL) { 83 dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 84 DAT_RESOURCE_MEMORY); 85 goto bail; 86 } 87 88 dat_status = dapls_ib_mw_alloc(rmr); 89 90 if (dat_status != DAT_SUCCESS) { 91 dapl_rmr_dealloc(rmr); 92 dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, 93 DAT_RESOURCE_MEMORY_REGION); 94 goto bail; 95 } 96 97 (void) dapl_os_atomic_inc(&pz->pz_ref_count); 98 99 *rmr_handle = rmr; 100 101bail: 102 return (dat_status); 103} 104