8828 udapl: value computed is not used
[unleashed.git] / usr / src / lib / udapl / udapl_tavor / common / dapl_psp_create_any.c
blobe73622d7178b9f5ae1fefd8e696f175e0fb83bbd
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
33 * MODULE: dapl_psp_create.c
35 * PURPOSE: Connection management
36 * Description: Interfaces in this file are completely described in
37 * the DAPL 1.1 API, Chapter 6, section 4
39 * $Id: dapl_psp_create_any.c,v 1.4 2003/06/23 12:28:05 sjs2 Exp $
42 #include "dapl.h"
43 #include "dapl_sp_util.h"
44 #include "dapl_ia_util.h"
45 #include "dapl_adapter_util.h"
48 * dapl_psp_create_any
50 * uDAPL: User Direct Access Program Library Version 1.1, 6.4.3.3
52 * Create a persistent Public Service Point that can recieve multiple
53 * requests for connections and generate multiple connection request
54 * instances that wil be delivered to the specified Event Dispatcher
55 * in a notification event. Differs from dapl_psp_create() in that
56 * the conn_qual is selected by the implementation and returned to
57 * the user.
59 * Input:
60 * ia_handle
61 * evd_handle
62 * psp_flags
64 * Output:
65 * conn_qual
66 * psp_handle
68 * Returns:
69 * DAT_SUCCESS
70 * DAT_INSUFFICIENT_RESOURCES
71 * DAT_INVALID_HANDLE
72 * DAT_INVALID_PARAMETER
73 * DAT_CONN_QUAL_IN_USE
74 * DAT_MODEL_NOT_SUPPORTED
76 DAT_RETURN
77 dapl_psp_create_any(
78 IN DAT_IA_HANDLE ia_handle,
79 OUT DAT_CONN_QUAL *conn_qual,
80 IN DAT_EVD_HANDLE evd_handle,
81 IN DAT_PSP_FLAGS psp_flags,
82 OUT DAT_PSP_HANDLE *psp_handle)
84 DAPL_IA *ia_ptr;
85 DAPL_SP *sp_ptr;
86 DAPL_EVD *evd_ptr;
87 DAT_RETURN dat_status;
89 ia_ptr = (DAPL_IA *)ia_handle;
90 dat_status = DAT_SUCCESS;
92 if (DAPL_BAD_HANDLE(ia_ptr, DAPL_MAGIC_IA)) {
93 dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
94 DAT_INVALID_HANDLE_IA);
95 goto bail;
98 if (DAPL_BAD_HANDLE(evd_handle, DAPL_MAGIC_EVD)) {
99 dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
100 DAT_INVALID_HANDLE_EVD_CR);
101 goto bail;
104 if (psp_handle == NULL) {
105 dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG5);
106 goto bail;
109 if (conn_qual == NULL) {
110 dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
111 goto bail;
114 /* check for invalid psp flags */
115 if ((psp_flags != DAT_PSP_CONSUMER_FLAG) &&
116 (psp_flags != DAT_PSP_PROVIDER_FLAG)) {
117 dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG4);
118 goto bail;
121 evd_ptr = (DAPL_EVD *)evd_handle;
122 if (!(evd_ptr->evd_flags & DAT_EVD_CR_FLAG)) {
123 dat_status = DAT_ERROR(DAT_INVALID_HANDLE,
124 DAT_INVALID_HANDLE_EVD_CR);
125 goto bail;
128 /* Allocate PSP */
129 sp_ptr = dapls_sp_alloc(ia_ptr, DAT_TRUE);
130 if (sp_ptr == NULL) {
131 dat_status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
132 DAT_RESOURCE_MEMORY);
133 goto bail;
137 * Fill out the args for a PSP
139 sp_ptr->ia_handle = ia_handle;
140 sp_ptr->evd_handle = evd_handle;
141 sp_ptr->psp_flags = psp_flags;
142 sp_ptr->ep_handle = NULL;
145 * Take a reference on the EVD handle
147 dapl_os_atomic_inc(&((DAPL_EVD *)evd_handle)->evd_ref_count);
149 /* Link it onto the IA */
150 dapl_ia_link_psp(ia_ptr, sp_ptr);
153 * Set up a listener for a connection. Connections can arrive
154 * even before this call returns!
156 sp_ptr->state = DAPL_SP_STATE_PSP_LISTENING;
157 sp_ptr->listening = DAT_TRUE;
159 dat_status = dapls_ib_setup_conn_listener(ia_ptr, 0, sp_ptr);
161 if (dat_status != DAT_SUCCESS) {
163 * Have a problem setting up the connection, something wrong!
165 dapl_os_atomic_dec(&((DAPL_EVD *)evd_handle)->evd_ref_count);
166 sp_ptr->state = DAPL_SP_STATE_FREE;
167 sp_ptr->listening = DAT_FALSE;
168 (void) dapl_psp_free((DAT_PSP_HANDLE)sp_ptr);
170 dapl_dbg_log(DAPL_DBG_TYPE_ERR,
171 "--> dapl_psp_create cannot set up conn listener: %x\n",
172 dat_status);
174 goto bail;
178 * Return handle to the user
180 *conn_qual = sp_ptr->conn_qual;
181 *psp_handle = (DAT_PSP_HANDLE)sp_ptr;
183 bail:
184 return (dat_status);