xref: /illumos-gate/usr/src/lib/udapl/udapl_tavor/common/dapl_ia_close.c (revision 5e989a96186a37eb528fb7bb4d28a150874ec799)
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_ia_close.c
34  *
35  * PURPOSE: Interface Adapter management
36  * Description: Interfaces in this file are completely described in
37  *		the DAPL 1.1 API, Chapter 6, section 2
38  *
39  * $Id: dapl_ia_close.c,v 1.9 2003/07/30 18:13:38 hobie16 Exp $
40  */
41 
42 #include "dapl.h"
43 #include "dapl_ia_util.h"
44 
45 /*
46  * dapl_ia_close
47  *
48  * DAPL Requirements Version xxx, 6.2.1.2
49  *
50  * Close a provider, clean up resources, etc.
51  *
52  * Input:
53  *	ia_handle
54  *
55  * Output:
56  *	none
57  *
58  * Return Values:
59  * 	DAT_SUCCESS
60  * 	DAT_INSUFFICIENT_RESOURCES
61  * 	DAT_INVALID_PARAMETER
62  */
63 DAT_RETURN
64 dapl_ia_close(
65 	IN	DAT_IA_HANDLE	ia_handle,
66 	IN	DAT_CLOSE_FLAGS ia_flags)
67 {
68 	DAPL_IA			*ia_ptr;
69 	DAT_RETURN		dat_status;
70 
71 	dapl_dbg_log(DAPL_DBG_TYPE_API,
72 	    "dapl_ia_close (%p, %d)\n",
73 	    ia_handle,
74 	    ia_flags);
75 
76 	ia_ptr = (DAPL_IA *)ia_handle;
77 
78 	if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
79 		dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
80 		    DAT_INVALID_HANDLE_IA);
81 		goto bail;
82 	}
83 
84 	if (DAT_CLOSE_ABRUPT_FLAG == ia_flags) {
85 		dat_status = dapl_ia_abrupt_close(ia_ptr);
86 	} else if (DAT_CLOSE_GRACEFUL_FLAG == ia_flags) {
87 		dat_status = dapl_ia_graceful_close(ia_ptr);
88 	} else {
89 		dat_status = DAT_ERROR(DAT_INVALID_PARAMETER,
90 		    DAT_INVALID_ARG2);
91 	}
92 
93 bail:
94 	return (dat_status);
95 }
96