dapl_rmr_free.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_free.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#include "dapl_ia_util.h" 44 45/* 46 * dapl_rmr_free 47 * 48 * DAPL Requirements Version xxx, 6.6.4.2 49 * 50 * Destroy an instance of the Remote Memory Region 51 * 52 * Input: 53 * rmr_handle 54 * 55 * Output: 56 * none 57 * 58 * Returns: 59 * DAT_SUCCESS 60 * DAT_INVALID_PARAMETER 61 */ 62DAT_RETURN 63dapl_rmr_free(IN DAT_RMR_HANDLE rmr_handle) 64{ 65 DAPL_RMR *rmr; 66 DAT_RETURN dat_status; 67 68 dat_status = DAT_SUCCESS; 69 70 if (DAPL_BAD_HANDLE(rmr_handle, DAPL_MAGIC_RMR)) { 71 dat_status = DAT_ERROR(DAT_INVALID_HANDLE, 72 DAT_INVALID_HANDLE_RMR); 73 goto bail; 74 } 75 76 rmr = (DAPL_RMR *)rmr_handle; 77 78 /* 79 * If the user did not perform an unbind op, release 80 * counts here. 81 */ 82 if (rmr->param.lmr_triplet.virtual_address != 0) { 83 (void) dapl_os_atomic_dec(&rmr->lmr->lmr_ref_count); 84 rmr->param.lmr_triplet.virtual_address = 0; 85 } 86 87 dat_status = dapls_ib_mw_free(rmr); 88 89 if (dat_status != DAT_SUCCESS) { 90 goto bail; 91 } 92 93 dapl_os_atomic_dec(&rmr->pz->pz_ref_count); 94 95 dapl_rmr_dealloc(rmr); 96 97bail: 98 return (dat_status); 99} 100