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_pz_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  * $Id: dapl_pz_create.c,v 1.7 2003/07/30 18:13:40 hobie16 Exp $
40  */
41 
42 #include "dapl_pz_util.h"
43 #include "dapl_adapter_util.h"
44 
45 /*
46  * dapl_pz_create
47  *
48  * DAPL Requirements Version xxx, 6.6.2.1
49  *
50  * Create an instance of a protection zone
51  *
52  * Input:
53  * 	ia_handle
54  *
55  * Output:
56  * 	pz_handle
57  *
58  * Returns:
59  * 	DAT_SUCCESS
60  * 	DAT_INSUFFICIENT_RESOURCES
61  * 	DAT_INVALID_PARAMETER
62  */
63 DAT_RETURN
dapl_pz_create(IN DAT_IA_HANDLE ia_handle,OUT DAT_PZ_HANDLE * pz_handle)64 dapl_pz_create(
65 	IN	DAT_IA_HANDLE	ia_handle,
66 	OUT	DAT_PZ_HANDLE	*pz_handle)
67 {
68 	DAPL_IA 		*ia;
69 	DAPL_PZ 		*pz;
70 	DAT_RETURN		dat_status;
71 
72 	dapl_dbg_log(DAPL_DBG_TYPE_API,
73 	    "dapl_pz_create (%p, %p)\n",
74 	    ia_handle,
75 	    pz_handle);
76 
77 	dat_status = DAT_SUCCESS;
78 	if (DAPL_BAD_HANDLE(ia_handle, DAPL_MAGIC_IA)) {
79 		dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
80 		    DAT_INVALID_HANDLE_IA);
81 		goto bail;
82 	}
83 
84 	if (NULL == pz_handle) {
85 		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
86 		goto bail;
87 	}
88 
89 	ia = (DAPL_IA *)ia_handle;
90 
91 	pz = dapl_pz_alloc(ia);
92 	if (pz == NULL) {
93 		dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
94 		    DAT_RESOURCE_MEMORY);
95 		goto bail;
96 	}
97 
98 	dat_status = dapls_ib_pd_alloc(ia, pz);
99 
100 	if (dat_status != DAT_SUCCESS) {
101 		dapl_pz_dealloc(pz);
102 		pz = NULL;
103 	}
104 
105 	*pz_handle = pz;
106 
107 bail:
108 	return (dat_status);
109 }
110