xref: /titanic_41/usr/src/lib/udapl/libdat/common/udat_api.c (revision a2bb96e7d59f447f59bc306e53b7d00e38594667)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24  */
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 
34 /*
35  *
36  * MODULE: udat_api.c
37  *
38  * PURPOSE: DAT Provider and Consumer registry functions.
39  *
40  */
41 
42 #include "dat_osd.h"
43 #include <dat/dat_registry.h>
44 
45 DAT_RETURN dat_lmr_create(
46 	IN	DAT_IA_HANDLE		ia_handle,
47 	IN	DAT_MEM_TYPE		mem_type,
48 	IN	DAT_REGION_DESCRIPTION	region_description,
49 	IN	DAT_VLEN		length,
50 	IN	DAT_PZ_HANDLE		pz_handle,
51 	IN	DAT_MEM_PRIV_FLAGS	privileges,
52 	OUT	DAT_LMR_HANDLE		*lmr_handle,
53 	OUT	DAT_LMR_CONTEXT		*lmr_context,
54 	OUT	DAT_RMR_CONTEXT		*rmr_context,
55 	OUT	DAT_VLEN 		*registered_length,
56 	OUT	DAT_VADDR 		*registered_address)
57 {
58 	if (DAT_BAD_HANDLE(ia_handle)) {
59 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
60 	}
61 	return DAT_LMR_CREATE(ia_handle,
62 			    mem_type,
63 			    region_description,
64 			    length,
65 			    pz_handle,
66 			    privileges,
67 			    lmr_handle,
68 			    lmr_context,
69 			    rmr_context,
70 			    registered_length,
71 			    registered_address);
72 }
73 
74 
75 DAT_RETURN dat_evd_create(
76 	IN	DAT_IA_HANDLE		ia_handle,
77 	IN	DAT_COUNT		evd_min_qlen,
78 	IN	DAT_CNO_HANDLE		cno_handle,
79 	IN	DAT_EVD_FLAGS		evd_flags,
80 	OUT	DAT_EVD_HANDLE		*evd_handle)
81 {
82 	if (DAT_BAD_HANDLE(ia_handle)) {
83 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
84 	}
85 	return DAT_EVD_CREATE(ia_handle,
86 			    evd_min_qlen,
87 			    cno_handle,
88 			    evd_flags,
89 			    evd_handle);
90 }
91 
92 
93 DAT_RETURN dat_evd_modify_cno(
94 	IN	DAT_EVD_HANDLE		evd_handle,
95 	IN	DAT_CNO_HANDLE		cno_handle)
96 {
97 	if (DAT_BAD_HANDLE(evd_handle)) {
98 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
99 	}
100 	return DAT_EVD_MODIFY_CNO(evd_handle,
101 				cno_handle);
102 }
103 
104 
105 DAT_RETURN dat_cno_create(
106 	IN 	DAT_IA_HANDLE		ia_handle,
107 	IN 	DAT_OS_WAIT_PROXY_AGENT agent,
108 	OUT	DAT_CNO_HANDLE		*cno_handle)
109 {
110 	if (DAT_BAD_HANDLE(ia_handle)) {
111 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
112 	}
113 	return DAT_CNO_CREATE(ia_handle,
114 			    agent,
115 			    cno_handle);
116 }
117 
118 
119 DAT_RETURN dat_cno_modify_agent(
120 	IN 	DAT_CNO_HANDLE		 cno_handle,
121 	IN 	DAT_OS_WAIT_PROXY_AGENT	 agent)
122 {
123 	if (DAT_BAD_HANDLE(cno_handle)) {
124 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO));
125 	}
126 	return DAT_CNO_MODIFY_AGENT(cno_handle,
127 				agent);
128 }
129 
130 
131 DAT_RETURN dat_cno_query(
132 	IN	DAT_CNO_HANDLE		cno_handle,
133 	IN	DAT_CNO_PARAM_MASK	cno_param_mask,
134 	OUT	DAT_CNO_PARAM		*cno_param)
135 {
136 	if (DAT_BAD_HANDLE(cno_handle)) {
137 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO));
138 	}
139 	return DAT_CNO_QUERY(cno_handle,
140 			cno_param_mask,
141 			cno_param);
142 }
143 
144 
145 DAT_RETURN dat_cno_free(
146 	IN DAT_CNO_HANDLE		cno_handle)
147 {
148 	if (DAT_BAD_HANDLE(cno_handle)) {
149 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO));
150 	}
151 	return (DAT_CNO_FREE(cno_handle));
152 }
153 
154 
155 DAT_RETURN dat_cno_wait(
156 	IN  	DAT_CNO_HANDLE		cno_handle,
157 	IN  	DAT_TIMEOUT		timeout,
158 	OUT 	DAT_EVD_HANDLE		*evd_handle)
159 {
160 	if (DAT_BAD_HANDLE(cno_handle)) {
161 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CNO));
162 	}
163 	return DAT_CNO_WAIT(cno_handle,
164 			timeout,
165 			evd_handle);
166 }
167 
168 
169 DAT_RETURN dat_evd_enable(
170 	IN	DAT_EVD_HANDLE		evd_handle)
171 {
172 	if (DAT_BAD_HANDLE(evd_handle)) {
173 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
174 	}
175 	return (DAT_EVD_ENABLE(evd_handle));
176 }
177 
178 
179 DAT_RETURN dat_evd_wait(
180 	IN  	DAT_EVD_HANDLE		evd_handle,
181 	IN  	DAT_TIMEOUT		Timeout,
182 	IN  	DAT_COUNT		Threshold,
183 	OUT 	DAT_EVENT		*event,
184 	OUT 	DAT_COUNT		*n_more_events)
185 {
186 	if (DAT_BAD_HANDLE(evd_handle)) {
187 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
188 	}
189 	return DAT_EVD_WAIT(evd_handle,
190 			Timeout,
191 			Threshold,
192 			event,
193 			n_more_events);
194 }
195 
196 
197 DAT_RETURN dat_evd_disable(
198 	IN	DAT_EVD_HANDLE		evd_handle)
199 {
200 	if (DAT_BAD_HANDLE(evd_handle)) {
201 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
202 	}
203 	return (DAT_EVD_DISABLE(evd_handle));
204 }
205 
206 
207 DAT_RETURN dat_evd_set_unwaitable(
208 	IN 	DAT_EVD_HANDLE		 evd_handle)
209 {
210 	if (DAT_BAD_HANDLE(evd_handle)) {
211 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
212 	}
213 	return (DAT_EVD_SET_UNWAITABLE(evd_handle));
214 }
215 
216 DAT_RETURN dat_evd_clear_unwaitable(
217 	IN 	DAT_EVD_HANDLE		 evd_handle)
218 {
219 	if (DAT_BAD_HANDLE(evd_handle)) {
220 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
221 	}
222 	return (DAT_EVD_CLEAR_UNWAITABLE(evd_handle));
223 }
224 
225 DAT_RETURN dat_cr_handoff(
226 	IN	DAT_CR_HANDLE		cr_handle,
227 	IN	DAT_CONN_QUAL		handoff)
228 {
229 	if (DAT_BAD_HANDLE(cr_handle)) {
230 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR));
231 	}
232 	return DAT_CR_HANDOFF(cr_handle,
233 			handoff);
234 }
235 
236 
237 DAT_RETURN dat_psp_create_any(
238 	IN	DAT_IA_HANDLE		ia_handle,
239 	OUT	DAT_CONN_QUAL		*conn_qual,
240 	IN	DAT_EVD_HANDLE		evd_handle,
241 	IN	DAT_PSP_FLAGS		psp_flags,
242 	OUT	DAT_PSP_HANDLE		*psp_handle)
243 {
244 	if (DAT_BAD_HANDLE(ia_handle)) {
245 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
246 	}
247 	return DAT_PSP_CREATE_ANY(ia_handle,
248 			    conn_qual,
249 			    evd_handle,
250 			    psp_flags,
251 			    psp_handle);
252 }
253 
254 
255 DAT_RETURN dat_ia_query(
256 	IN	DAT_IA_HANDLE		ia_handle,
257 	OUT	DAT_EVD_HANDLE		*async_evd_handle,
258 	IN	DAT_IA_ATTR_MASK	ia_attr_mask,
259 	OUT	DAT_IA_ATTR		*ia_attr,
260 	IN	DAT_PROVIDER_ATTR_MASK	provider_attr_mask,
261 	OUT	DAT_PROVIDER_ATTR 	*provider_attr)
262 {
263 	if (DAT_BAD_HANDLE(ia_handle)) {
264 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
265 	}
266 	return DAT_IA_QUERY(ia_handle,
267 			async_evd_handle,
268 			ia_attr_mask,
269 			ia_attr,
270 			provider_attr_mask,
271 			provider_attr);
272 }
273 
274 
275 DAT_RETURN dat_evd_query(
276 	IN	DAT_EVD_HANDLE		evd_handle,
277 	IN	DAT_EVD_PARAM_MASK	evd_param_mask,
278 	OUT	DAT_EVD_PARAM		*evd_param)
279 {
280 	if (DAT_BAD_HANDLE(evd_handle)) {
281 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
282 	}
283 	return DAT_EVD_QUERY(evd_handle,
284 			evd_param_mask,
285 			evd_param);
286 }
287 
288 
289 DAT_RETURN dat_lmr_query(
290 	IN	DAT_LMR_HANDLE		lmr_handle,
291 	IN	DAT_LMR_PARAM_MASK	lmv_param_mask,
292 	OUT	DAT_LMR_PARAM		*lmr_param)
293 {
294 	if (DAT_BAD_HANDLE(lmr_handle)) {
295 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR));
296 	}
297 	return DAT_LMR_QUERY(lmr_handle,
298 		    lmv_param_mask,
299 		    lmr_param);
300 }
301