xref: /titanic_44/usr/src/lib/udapl/libdat/common/dat_api.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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  * MODULE: dat_api.c
36  *
37  * PURPOSE: DAT Provider and Consumer registry functions.
38  *
39  */
40 
41 #include "dat_osd.h"
42 #include <dat/dat_registry.h>
43 
44 
dat_set_consumer_context(IN DAT_HANDLE dat_handle,IN DAT_CONTEXT context)45 DAT_RETURN dat_set_consumer_context(
46 	IN	DAT_HANDLE		dat_handle,
47 	IN	DAT_CONTEXT		context)
48 {
49 	if (DAT_BAD_HANDLE(dat_handle)) {
50 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
51 	}
52 	return DAT_SET_CONSUMER_CONTEXT(dat_handle,
53 				context);
54 }
55 
56 
dat_get_consumer_context(IN DAT_HANDLE dat_handle,OUT DAT_CONTEXT * context)57 DAT_RETURN dat_get_consumer_context(
58 	IN	DAT_HANDLE		dat_handle,
59 	OUT	DAT_CONTEXT		*context)
60 {
61 	if (DAT_BAD_HANDLE(dat_handle)) {
62 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
63 	}
64 	return DAT_GET_CONSUMER_CONTEXT(dat_handle,
65 				context);
66 
67 }
68 
69 
dat_get_handle_type(IN DAT_HANDLE dat_handle,OUT DAT_HANDLE_TYPE * type)70 DAT_RETURN dat_get_handle_type(
71 	IN	DAT_HANDLE		dat_handle,
72 	OUT	DAT_HANDLE_TYPE		*type)
73 {
74 	if (DAT_BAD_HANDLE(dat_handle)) {
75 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
76 	}
77 	return DAT_GET_HANDLE_TYPE(dat_handle,
78 				type);
79 }
80 
81 
dat_cr_query(IN DAT_CR_HANDLE cr_handle,IN DAT_CR_PARAM_MASK cr_param_mask,OUT DAT_CR_PARAM * cr_param)82 DAT_RETURN dat_cr_query(
83 	IN	DAT_CR_HANDLE		cr_handle,
84 	IN	DAT_CR_PARAM_MASK	cr_param_mask,
85 	OUT	DAT_CR_PARAM		*cr_param)
86 {
87 	if (DAT_BAD_HANDLE(cr_handle)) {
88 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR));
89 	}
90 	return DAT_CR_QUERY(cr_handle,
91 			    cr_param_mask,
92 			    cr_param);
93 }
94 
95 
dat_cr_accept(IN DAT_CR_HANDLE cr_handle,IN DAT_EP_HANDLE ep_handle,IN DAT_COUNT private_data_size,IN const DAT_PVOID private_data)96 DAT_RETURN dat_cr_accept(
97 	IN	DAT_CR_HANDLE		cr_handle,
98 	IN	DAT_EP_HANDLE		ep_handle,
99 	IN	DAT_COUNT		private_data_size,
100 	IN	const DAT_PVOID		private_data)
101 {
102 	if (DAT_BAD_HANDLE(cr_handle)) {
103 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR));
104 	}
105 	return DAT_CR_ACCEPT(cr_handle,
106 			    ep_handle,
107 			    private_data_size,
108 			    private_data);
109 }
110 
111 
dat_cr_reject(IN DAT_CR_HANDLE cr_handle)112 DAT_RETURN dat_cr_reject(
113 	IN	DAT_CR_HANDLE 		cr_handle)
114 {
115 	if (DAT_BAD_HANDLE(cr_handle)) {
116 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_CR));
117 	}
118 	return (DAT_CR_REJECT(cr_handle));
119 }
120 
121 
dat_evd_resize(IN DAT_EVD_HANDLE evd_handle,IN DAT_COUNT evd_min_qlen)122 DAT_RETURN dat_evd_resize(
123 	IN	DAT_EVD_HANDLE		evd_handle,
124 	IN	DAT_COUNT		evd_min_qlen)
125 {
126 	if (DAT_BAD_HANDLE(evd_handle)) {
127 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
128 	}
129 	return DAT_EVD_RESIZE(evd_handle,
130 			evd_min_qlen);
131 }
132 
133 
dat_evd_post_se(IN DAT_EVD_HANDLE evd_handle,IN const DAT_EVENT * event)134 DAT_RETURN dat_evd_post_se(
135 	IN	DAT_EVD_HANDLE		evd_handle,
136 	IN	const DAT_EVENT		*event)
137 {
138 	if (DAT_BAD_HANDLE(evd_handle)) {
139 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
140 	}
141 	return DAT_EVD_POST_SE(evd_handle,
142 			    event);
143 }
144 
145 
dat_evd_dequeue(IN DAT_EVD_HANDLE evd_handle,OUT DAT_EVENT * event)146 DAT_RETURN dat_evd_dequeue(
147 	IN	DAT_EVD_HANDLE		evd_handle,
148 	OUT	DAT_EVENT		*event)
149 {
150 	if (DAT_BAD_HANDLE(evd_handle)) {
151 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
152 	}
153 	return DAT_EVD_DEQUEUE(evd_handle,
154 				event);
155 }
156 
157 
dat_evd_free(IN DAT_EVD_HANDLE evd_handle)158 DAT_RETURN dat_evd_free(
159 	IN	DAT_EVD_HANDLE 		evd_handle)
160 {
161 	if (DAT_BAD_HANDLE(evd_handle)) {
162 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE1));
163 	}
164 	return (DAT_EVD_FREE(evd_handle));
165 }
166 
167 
dat_ep_create(IN DAT_IA_HANDLE ia_handle,IN DAT_PZ_HANDLE pz_handle,IN DAT_EVD_HANDLE recv_completion_evd_handle,IN DAT_EVD_HANDLE request_completion_evd_handle,IN DAT_EVD_HANDLE connect_evd_handle,IN const DAT_EP_ATTR * ep_attributes,OUT DAT_EP_HANDLE * ep_handle)168 DAT_RETURN dat_ep_create(
169 	IN	DAT_IA_HANDLE		ia_handle,
170 	IN	DAT_PZ_HANDLE		pz_handle,
171 	IN	DAT_EVD_HANDLE		recv_completion_evd_handle,
172 	IN	DAT_EVD_HANDLE		request_completion_evd_handle,
173 	IN	DAT_EVD_HANDLE		connect_evd_handle,
174 	IN	const DAT_EP_ATTR 	*ep_attributes,
175 	OUT	DAT_EP_HANDLE		*ep_handle)
176 {
177 	if (DAT_BAD_HANDLE(ia_handle)) {
178 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
179 	}
180 	return DAT_EP_CREATE(ia_handle,
181 			    pz_handle,
182 			    recv_completion_evd_handle,
183 			    request_completion_evd_handle,
184 			    connect_evd_handle,
185 			    ep_attributes,
186 			    ep_handle);
187 }
188 
189 
dat_ep_query(IN DAT_EP_HANDLE ep_handle,IN DAT_EP_PARAM_MASK ep_param_mask,OUT DAT_EP_PARAM * ep_param)190 DAT_RETURN dat_ep_query(
191 	IN	DAT_EP_HANDLE		ep_handle,
192 	IN	DAT_EP_PARAM_MASK	ep_param_mask,
193 	OUT	DAT_EP_PARAM		*ep_param)
194 {
195 	if (DAT_BAD_HANDLE(ep_handle)) {
196 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
197 	}
198 	return DAT_EP_QUERY(ep_handle,
199 			    ep_param_mask,
200 			    ep_param);
201 }
202 
203 
dat_ep_modify(IN DAT_EP_HANDLE ep_handle,IN DAT_EP_PARAM_MASK ep_param_mask,IN const DAT_EP_PARAM * ep_param)204 DAT_RETURN dat_ep_modify(
205 	IN	DAT_EP_HANDLE		ep_handle,
206 	IN	DAT_EP_PARAM_MASK	ep_param_mask,
207 	IN	const DAT_EP_PARAM 	*ep_param)
208 {
209 	if (DAT_BAD_HANDLE(ep_handle)) {
210 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
211 	}
212 	return DAT_EP_MODIFY(ep_handle,
213 			    ep_param_mask,
214 			    ep_param);
215 }
216 
217 
dat_ep_connect(IN DAT_EP_HANDLE ep_handle,IN DAT_IA_ADDRESS_PTR remote_ia_address,IN DAT_CONN_QUAL remote_conn_qual,IN DAT_TIMEOUT timeout,IN DAT_COUNT private_data_size,IN const DAT_PVOID private_data,IN DAT_QOS quality_of_service,IN DAT_CONNECT_FLAGS connect_flags)218 DAT_RETURN dat_ep_connect(
219 	IN	DAT_EP_HANDLE		ep_handle,
220 	IN	DAT_IA_ADDRESS_PTR	remote_ia_address,
221 	IN	DAT_CONN_QUAL		remote_conn_qual,
222 	IN	DAT_TIMEOUT		timeout,
223 	IN	DAT_COUNT		private_data_size,
224 	IN	const DAT_PVOID		private_data,
225 	IN	DAT_QOS			quality_of_service,
226 	IN	DAT_CONNECT_FLAGS	connect_flags)
227 {
228 	if (DAT_BAD_HANDLE(ep_handle)) {
229 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
230 	}
231 	return DAT_EP_CONNECT(ep_handle,
232 			    remote_ia_address,
233 			    remote_conn_qual,
234 			    timeout,
235 			    private_data_size,
236 			    private_data,
237 			    quality_of_service,
238 			    connect_flags);
239 }
240 
241 
dat_ep_dup_connect(IN DAT_EP_HANDLE ep_handle,IN DAT_EP_HANDLE ep_dup_handle,IN DAT_TIMEOUT timeout,IN DAT_COUNT private_data_size,IN const DAT_PVOID private_data,IN DAT_QOS quality_of_service)242 DAT_RETURN dat_ep_dup_connect(
243 	IN	DAT_EP_HANDLE		ep_handle,
244 	IN	DAT_EP_HANDLE		ep_dup_handle,
245 	IN	DAT_TIMEOUT		timeout,
246 	IN	DAT_COUNT		private_data_size,
247 	IN	const DAT_PVOID		private_data,
248 	IN	DAT_QOS			quality_of_service)
249 {
250 	if (DAT_BAD_HANDLE(ep_handle)) {
251 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
252 	}
253 	return DAT_EP_DUP_CONNECT(ep_handle,
254 			    ep_dup_handle,
255 			    timeout,
256 			    private_data_size,
257 			    private_data,
258 			    quality_of_service);
259 }
260 
261 
dat_ep_disconnect(IN DAT_EP_HANDLE ep_handle,IN DAT_CLOSE_FLAGS close_flags)262 DAT_RETURN dat_ep_disconnect(
263 	IN	DAT_EP_HANDLE		ep_handle,
264 	IN	DAT_CLOSE_FLAGS		close_flags)
265 {
266 	if (DAT_BAD_HANDLE(ep_handle)) {
267 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
268 	}
269 	return DAT_EP_DISCONNECT(ep_handle,
270 				close_flags);
271 }
272 
273 
dat_ep_post_send(IN DAT_EP_HANDLE ep_handle,IN DAT_COUNT num_segments,IN DAT_LMR_TRIPLET * local_iov,IN DAT_DTO_COOKIE user_cookie,IN DAT_COMPLETION_FLAGS completion_flags)274 DAT_RETURN dat_ep_post_send(
275 	IN	DAT_EP_HANDLE		ep_handle,
276 	IN	DAT_COUNT		num_segments,
277 	IN	DAT_LMR_TRIPLET		*local_iov,
278 	IN	DAT_DTO_COOKIE		user_cookie,
279 	IN	DAT_COMPLETION_FLAGS	completion_flags)
280 {
281 	if (DAT_BAD_HANDLE(ep_handle)) {
282 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
283 	}
284 	return DAT_EP_POST_SEND(ep_handle,
285 			    num_segments,
286 			    local_iov,
287 			    user_cookie,
288 			    completion_flags);
289 }
290 
291 
dat_ep_post_recv(IN DAT_EP_HANDLE ep_handle,IN DAT_COUNT num_segments,IN DAT_LMR_TRIPLET * local_iov,IN DAT_DTO_COOKIE user_cookie,IN DAT_COMPLETION_FLAGS completion_flags)292 DAT_RETURN dat_ep_post_recv(
293 	IN	DAT_EP_HANDLE		ep_handle,
294 	IN	DAT_COUNT		num_segments,
295 	IN	DAT_LMR_TRIPLET		*local_iov,
296 	IN	DAT_DTO_COOKIE		user_cookie,
297 	IN	DAT_COMPLETION_FLAGS	completion_flags)
298 {
299 	if (DAT_BAD_HANDLE(ep_handle)) {
300 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
301 	}
302 	return DAT_EP_POST_RECV(ep_handle,
303 			    num_segments,
304 			    local_iov,
305 			    user_cookie,
306 			    completion_flags);
307 }
308 
309 
dat_ep_post_rdma_read(IN DAT_EP_HANDLE ep_handle,IN DAT_COUNT num_segments,IN DAT_LMR_TRIPLET * local_iov,IN DAT_DTO_COOKIE user_cookie,IN const DAT_RMR_TRIPLET * remote_iov,IN DAT_COMPLETION_FLAGS completion_flags)310 DAT_RETURN dat_ep_post_rdma_read(
311 	IN	DAT_EP_HANDLE		ep_handle,
312 	IN	DAT_COUNT		num_segments,
313 	IN	DAT_LMR_TRIPLET		*local_iov,
314 	IN	DAT_DTO_COOKIE		user_cookie,
315 	IN	const DAT_RMR_TRIPLET	*remote_iov,
316 	IN	DAT_COMPLETION_FLAGS	completion_flags)
317 {
318 	if (DAT_BAD_HANDLE(ep_handle)) {
319 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
320 	}
321 	return DAT_EP_POST_RDMA_READ(ep_handle,
322 				    num_segments,
323 				    local_iov,
324 				    user_cookie,
325 				    remote_iov,
326 				    completion_flags);
327 }
328 
329 
dat_ep_post_rdma_write(IN DAT_EP_HANDLE ep_handle,IN DAT_COUNT num_segments,IN DAT_LMR_TRIPLET * local_iov,IN DAT_DTO_COOKIE user_cookie,IN const DAT_RMR_TRIPLET * remote_iov,IN DAT_COMPLETION_FLAGS completion_flags)330 DAT_RETURN dat_ep_post_rdma_write(
331 	IN	DAT_EP_HANDLE		ep_handle,
332 	IN	DAT_COUNT		num_segments,
333 	IN	DAT_LMR_TRIPLET		*local_iov,
334 	IN	DAT_DTO_COOKIE		user_cookie,
335 	IN	const DAT_RMR_TRIPLET	*remote_iov,
336 	IN	DAT_COMPLETION_FLAGS	completion_flags)
337 {
338 	if (DAT_BAD_HANDLE(ep_handle)) {
339 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
340 	}
341 	return DAT_EP_POST_RDMA_WRITE(ep_handle,
342 				    num_segments,
343 				    local_iov,
344 				    user_cookie,
345 				    remote_iov,
346 				    completion_flags);
347 }
348 
349 
dat_ep_get_status(IN DAT_EP_HANDLE ep_handle,OUT DAT_EP_STATE * ep_state,OUT DAT_BOOLEAN * recv_idle,OUT DAT_BOOLEAN * request_idle)350 DAT_RETURN dat_ep_get_status(
351 	IN	DAT_EP_HANDLE		ep_handle,
352 	OUT	DAT_EP_STATE		*ep_state,
353 	OUT	DAT_BOOLEAN 		*recv_idle,
354 	OUT	DAT_BOOLEAN 		*request_idle)
355 {
356 	if (DAT_BAD_HANDLE(ep_handle)) {
357 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
358 	}
359 	return DAT_EP_GET_STATUS(ep_handle,
360 				ep_state,
361 				recv_idle,
362 				request_idle);
363 }
364 
365 
dat_ep_free(IN DAT_EP_HANDLE ep_handle)366 DAT_RETURN dat_ep_free(
367 	IN	DAT_EP_HANDLE		ep_handle)
368 {
369 	if (DAT_BAD_HANDLE(ep_handle)) {
370 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
371 	}
372 	return (DAT_EP_FREE(ep_handle));
373 }
374 
375 
dat_ep_reset(IN DAT_EP_HANDLE ep_handle)376 DAT_RETURN dat_ep_reset(
377 	IN	DAT_EP_HANDLE		ep_handle)
378 {
379 	if (DAT_BAD_HANDLE(ep_handle)) {
380 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
381 	}
382 	return (DAT_EP_RESET(ep_handle));
383 }
384 
385 
dat_lmr_free(IN DAT_LMR_HANDLE lmr_handle)386 DAT_RETURN dat_lmr_free(
387 	IN	DAT_LMR_HANDLE		lmr_handle)
388 {
389 	if (DAT_BAD_HANDLE(lmr_handle)) {
390 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR));
391 	}
392 	return (DAT_LMR_FREE(lmr_handle));
393 }
394 
395 
dat_rmr_create(IN DAT_PZ_HANDLE pz_handle,OUT DAT_RMR_HANDLE * rmr_handle)396 DAT_RETURN dat_rmr_create(
397 	IN	DAT_PZ_HANDLE		pz_handle,
398 	OUT	DAT_RMR_HANDLE		*rmr_handle)
399 {
400 	if (DAT_BAD_HANDLE(pz_handle)) {
401 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ));
402 	}
403 	return DAT_RMR_CREATE(pz_handle,
404 			rmr_handle);
405 }
406 
407 
dat_rmr_query(IN DAT_RMR_HANDLE rmr_handle,IN DAT_RMR_PARAM_MASK rmr_param_mask,OUT DAT_RMR_PARAM * rmr_param)408 DAT_RETURN dat_rmr_query(
409 	IN	DAT_RMR_HANDLE		rmr_handle,
410 	IN	DAT_RMR_PARAM_MASK	rmr_param_mask,
411 	OUT	DAT_RMR_PARAM		*rmr_param)
412 {
413 	if (DAT_BAD_HANDLE(rmr_handle)) {
414 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR));
415 	}
416 	return DAT_RMR_QUERY(rmr_handle,
417 			    rmr_param_mask,
418 			    rmr_param);
419 }
420 
421 
dat_rmr_bind(IN DAT_RMR_HANDLE rmr_handle,IN const DAT_LMR_TRIPLET * lmr_triplet,IN DAT_MEM_PRIV_FLAGS mem_priv,IN DAT_EP_HANDLE ep_handle,IN DAT_RMR_COOKIE user_cookie,IN DAT_COMPLETION_FLAGS completion_flags,OUT DAT_RMR_CONTEXT * context)422 DAT_RETURN dat_rmr_bind(
423 	IN	DAT_RMR_HANDLE		rmr_handle,
424 	IN	const DAT_LMR_TRIPLET	*lmr_triplet,
425 	IN	DAT_MEM_PRIV_FLAGS	mem_priv,
426 	IN	DAT_EP_HANDLE		ep_handle,
427 	IN	DAT_RMR_COOKIE		user_cookie,
428 	IN	DAT_COMPLETION_FLAGS	completion_flags,
429 	OUT	DAT_RMR_CONTEXT		*context)
430 {
431 	if (DAT_BAD_HANDLE(rmr_handle)) {
432 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR));
433 	}
434 	return DAT_RMR_BIND(rmr_handle,
435 			    lmr_triplet,
436 			    mem_priv,
437 			    ep_handle,
438 			    user_cookie,
439 			    completion_flags,
440 			    context);
441 }
442 
443 
dat_rmr_free(IN DAT_RMR_HANDLE rmr_handle)444 DAT_RETURN dat_rmr_free(
445 	IN	DAT_RMR_HANDLE		rmr_handle)
446 {
447 	if (DAT_BAD_HANDLE(rmr_handle)) {
448 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR));
449 	}
450 	return (DAT_RMR_FREE(rmr_handle));
451 }
452 
453 
dat_psp_create(IN DAT_IA_HANDLE ia_handle,IN DAT_CONN_QUAL conn_qual,IN DAT_EVD_HANDLE evd_handle,IN DAT_PSP_FLAGS psp_flags,OUT DAT_PSP_HANDLE * psp_handle)454 DAT_RETURN dat_psp_create(
455 	IN	DAT_IA_HANDLE		ia_handle,
456 	IN	DAT_CONN_QUAL		conn_qual,
457 	IN	DAT_EVD_HANDLE		evd_handle,
458 	IN	DAT_PSP_FLAGS		psp_flags,
459 	OUT	DAT_PSP_HANDLE		*psp_handle)
460 {
461 	if (DAT_BAD_HANDLE(ia_handle)) {
462 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
463 	}
464 	return DAT_PSP_CREATE(ia_handle,
465 			    conn_qual,
466 			    evd_handle,
467 			    psp_flags,
468 			    psp_handle);
469 }
470 
471 
dat_psp_query(IN DAT_PSP_HANDLE psp_handle,IN DAT_PSP_PARAM_MASK psp_param_mask,OUT DAT_PSP_PARAM * psp_param)472 DAT_RETURN dat_psp_query(
473 	IN	DAT_PSP_HANDLE		psp_handle,
474 	IN	DAT_PSP_PARAM_MASK	psp_param_mask,
475 	OUT	DAT_PSP_PARAM 		*psp_param)
476 {
477 	if (DAT_BAD_HANDLE(psp_handle)) {
478 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP));
479 	}
480 	return DAT_PSP_QUERY(psp_handle,
481 			    psp_param_mask,
482 			    psp_param);
483 }
484 
485 
dat_psp_free(IN DAT_PSP_HANDLE psp_handle)486 DAT_RETURN dat_psp_free(
487 	IN	DAT_PSP_HANDLE	psp_handle)
488 {
489 	if (DAT_BAD_HANDLE(psp_handle)) {
490 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PSP));
491 	}
492 	return (DAT_PSP_FREE(psp_handle));
493 }
494 
495 
dat_rsp_create(IN DAT_IA_HANDLE ia_handle,IN DAT_CONN_QUAL conn_qual,IN DAT_EP_HANDLE ep_handle,IN DAT_EVD_HANDLE evd_handle,OUT DAT_RSP_HANDLE * rsp_handle)496 DAT_RETURN dat_rsp_create(
497 	IN	DAT_IA_HANDLE		ia_handle,
498 	IN	DAT_CONN_QUAL		conn_qual,
499 	IN	DAT_EP_HANDLE		ep_handle,
500 	IN	DAT_EVD_HANDLE		evd_handle,
501 	OUT	DAT_RSP_HANDLE		*rsp_handle)
502 {
503 	if (DAT_BAD_HANDLE(ia_handle)) {
504 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
505 	}
506 	return DAT_RSP_CREATE(ia_handle,
507 			    conn_qual,
508 			    ep_handle,
509 			    evd_handle,
510 			    rsp_handle);
511 }
512 
513 
dat_rsp_query(IN DAT_RSP_HANDLE rsp_handle,IN DAT_RSP_PARAM_MASK rsp_param_mask,OUT DAT_RSP_PARAM * rsp_param)514 DAT_RETURN dat_rsp_query(
515 	IN	DAT_RSP_HANDLE		rsp_handle,
516 	IN	DAT_RSP_PARAM_MASK	rsp_param_mask,
517 	OUT	DAT_RSP_PARAM		*rsp_param)
518 {
519 	if (DAT_BAD_HANDLE(rsp_handle)) {
520 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP));
521 	}
522 	return DAT_RSP_QUERY(rsp_handle,
523 			    rsp_param_mask,
524 			    rsp_param);
525 }
526 
527 
dat_rsp_free(IN DAT_RSP_HANDLE rsp_handle)528 DAT_RETURN dat_rsp_free(
529 	IN	DAT_RSP_HANDLE		rsp_handle)
530 {
531 	if (DAT_BAD_HANDLE(rsp_handle)) {
532 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RSP));
533 	}
534 	return (DAT_RSP_FREE(rsp_handle));
535 }
536 
537 
dat_pz_create(IN DAT_IA_HANDLE ia_handle,OUT DAT_PZ_HANDLE * pz_handle)538 DAT_RETURN dat_pz_create(
539 	IN	DAT_IA_HANDLE		ia_handle,
540 	OUT	DAT_PZ_HANDLE		*pz_handle)
541 {
542 	if (DAT_BAD_HANDLE(ia_handle)) {
543 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
544 	}
545 	return DAT_PZ_CREATE(ia_handle,
546 			pz_handle);
547 }
548 
549 
dat_pz_query(IN DAT_PZ_HANDLE pz_handle,IN DAT_PZ_PARAM_MASK pz_param_mask,OUT DAT_PZ_PARAM * pz_param)550 DAT_RETURN dat_pz_query(
551 	IN	DAT_PZ_HANDLE		pz_handle,
552 	IN	DAT_PZ_PARAM_MASK	pz_param_mask,
553 	OUT	DAT_PZ_PARAM		*pz_param)
554 {
555 	if (DAT_BAD_HANDLE(pz_handle)) {
556 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ));
557 	}
558 	return DAT_PZ_QUERY(pz_handle,
559 			pz_param_mask,
560 			pz_param);
561 }
562 
563 
dat_pz_free(IN DAT_PZ_HANDLE pz_handle)564 DAT_RETURN dat_pz_free(
565 	IN	DAT_PZ_HANDLE		pz_handle)
566 {
567 	if (DAT_BAD_HANDLE(pz_handle)) {
568 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_PZ));
569 	}
570 	return (DAT_PZ_FREE(pz_handle));
571 }
572 
573 /* ARGSUSED */
dat_lmr_sync_rdma_read(IN DAT_IA_HANDLE ia_handle,IN const DAT_LMR_TRIPLET * local_segments,IN DAT_VLEN num_segments)574 DAT_RETURN dat_lmr_sync_rdma_read(
575 	IN	DAT_IA_HANDLE	ia_handle,
576 	IN	const DAT_LMR_TRIPLET *local_segments,
577 	IN	DAT_VLEN num_segments)
578 {
579 	if (DAT_BAD_HANDLE(ia_handle)) {
580 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
581 	}
582 
583 #if defined(__x86)
584 	return (DAT_SUCCESS);
585 #elif defined(__sparc)
586 	return (DAT_LMR_SYNC_RDMA_READ(ia_handle, local_segments,
587 		num_segments));
588 #else
589 #error "ISA not supported"
590 #endif
591 }
592 
593 /* ARGSUSED */
dat_lmr_sync_rdma_write(IN DAT_IA_HANDLE ia_handle,IN const DAT_LMR_TRIPLET * local_segments,IN DAT_VLEN num_segments)594 DAT_RETURN dat_lmr_sync_rdma_write(
595 	IN	DAT_IA_HANDLE	ia_handle,
596 	IN	const DAT_LMR_TRIPLET *local_segments,
597 	IN	DAT_VLEN num_segments)
598 {
599 	if (DAT_BAD_HANDLE(ia_handle)) {
600 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
601 	}
602 
603 #if defined(__x86)
604 	return (DAT_SUCCESS);
605 #elif defined(__sparc)
606 	return (DAT_LMR_SYNC_RDMA_WRITE(ia_handle, local_segments,
607 		num_segments));
608 #else
609 #error "ISA not supported"
610 #endif
611 }
612 
dat_ep_create_with_srq(IN DAT_IA_HANDLE ia_handle,IN DAT_PZ_HANDLE pz_handle,IN DAT_EVD_HANDLE recv_evd_handle,IN DAT_EVD_HANDLE request_evd_handle,IN DAT_EVD_HANDLE connect_evd_handle,IN DAT_SRQ_HANDLE srq_handle,IN const DAT_EP_ATTR * ep_attributes,OUT DAT_EP_HANDLE * ep_handle)613 DAT_RETURN dat_ep_create_with_srq(
614 	IN	DAT_IA_HANDLE	ia_handle,
615 	IN	DAT_PZ_HANDLE	pz_handle,
616 	IN	DAT_EVD_HANDLE	recv_evd_handle,
617 	IN	DAT_EVD_HANDLE	request_evd_handle,
618 	IN	DAT_EVD_HANDLE	connect_evd_handle,
619 	IN	DAT_SRQ_HANDLE	srq_handle,
620 	IN	const DAT_EP_ATTR *ep_attributes,
621 	OUT	DAT_EP_HANDLE	*ep_handle)
622 {
623 	if (DAT_BAD_HANDLE(ia_handle)) {
624 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
625 	}
626 	return DAT_EP_CREATE_WITH_SRQ(ia_handle,
627 				pz_handle,
628 				recv_evd_handle,
629 				request_evd_handle,
630 				connect_evd_handle,
631 				srq_handle,
632 				ep_attributes,
633 				ep_handle);
634 }
635 
dat_ep_recv_query(IN DAT_EP_HANDLE ep_handle,OUT DAT_COUNT * nbufs_allocated,OUT DAT_COUNT * bufs_alloc_span)636 DAT_RETURN dat_ep_recv_query(
637 	IN	DAT_EP_HANDLE	ep_handle,
638 	OUT	DAT_COUNT	*nbufs_allocated,
639 	OUT	DAT_COUNT	*bufs_alloc_span)
640 {
641 	if (DAT_BAD_HANDLE(ep_handle)) {
642 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
643 	}
644 	return DAT_EP_RECV_QUERY(ep_handle,
645 				nbufs_allocated,
646 				bufs_alloc_span);
647 }
648 
dat_ep_set_watermark(IN DAT_EP_HANDLE ep_handle,IN DAT_COUNT soft_high_watermark,IN DAT_COUNT hard_high_watermark)649 DAT_RETURN dat_ep_set_watermark(
650 	IN	DAT_EP_HANDLE	ep_handle,
651 	IN	DAT_COUNT	soft_high_watermark,
652 	IN	DAT_COUNT	hard_high_watermark)
653 {
654 	if (DAT_BAD_HANDLE(ep_handle)) {
655 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP));
656 	}
657 	return DAT_EP_SET_WATERMARK(ep_handle,
658 				soft_high_watermark,
659 				hard_high_watermark);
660 }
661 
dat_srq_create(IN DAT_IA_HANDLE ia_handle,IN DAT_PZ_HANDLE pz_handle,IN DAT_SRQ_ATTR * srq_attr,OUT DAT_SRQ_HANDLE * srq_handle)662 DAT_RETURN dat_srq_create(
663 	IN	DAT_IA_HANDLE	ia_handle,
664 	IN	DAT_PZ_HANDLE	pz_handle,
665 	IN	DAT_SRQ_ATTR	*srq_attr,
666 	OUT	DAT_SRQ_HANDLE	*srq_handle)
667 {
668 	if (DAT_BAD_HANDLE(ia_handle)) {
669 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
670 	}
671 	return DAT_SRQ_CREATE(ia_handle,
672 				pz_handle,
673 				srq_attr,
674 				srq_handle);
675 }
676 
dat_srq_free(IN DAT_SRQ_HANDLE srq_handle)677 DAT_RETURN dat_srq_free(
678 	IN	DAT_SRQ_HANDLE	srq_handle)
679 {
680 	if (DAT_BAD_HANDLE(srq_handle)) {
681 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ));
682 	}
683 	return (DAT_SRQ_FREE(srq_handle));
684 }
685 
dat_srq_post_recv(IN DAT_SRQ_HANDLE srq_handle,IN DAT_COUNT num_segments,IN DAT_LMR_TRIPLET * local_iov,IN DAT_DTO_COOKIE user_cookie)686 DAT_RETURN dat_srq_post_recv(
687 	IN	DAT_SRQ_HANDLE	srq_handle,
688 	IN	DAT_COUNT	num_segments,
689 	IN	DAT_LMR_TRIPLET	*local_iov,
690 	IN	DAT_DTO_COOKIE	user_cookie)
691 {
692 	if (DAT_BAD_HANDLE(srq_handle)) {
693 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ));
694 	}
695 	return DAT_SRQ_POST_RECV(srq_handle,
696 				num_segments,
697 				local_iov,
698 				user_cookie);
699 }
700 
dat_srq_query(IN DAT_SRQ_HANDLE srq_handle,IN DAT_SRQ_PARAM_MASK srq_param_mask,OUT DAT_SRQ_PARAM * srq_param)701 DAT_RETURN dat_srq_query(
702 	IN	DAT_SRQ_HANDLE		srq_handle,
703 	IN	DAT_SRQ_PARAM_MASK	srq_param_mask,
704 	OUT	DAT_SRQ_PARAM		*srq_param)
705 {
706 	if (DAT_BAD_HANDLE(srq_handle)) {
707 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ));
708 	}
709 	return DAT_SRQ_QUERY(srq_handle,
710 			srq_param_mask,
711 			srq_param);
712 }
713 
dat_srq_resize(IN DAT_SRQ_HANDLE srq_handle,IN DAT_COUNT srq_max_recv_dto)714 DAT_RETURN dat_srq_resize(
715 	IN	DAT_SRQ_HANDLE	srq_handle,
716 	IN	DAT_COUNT	srq_max_recv_dto)
717 {
718 	if (DAT_BAD_HANDLE(srq_handle)) {
719 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ));
720 	}
721 	return DAT_SRQ_RESIZE(srq_handle,
722 			srq_max_recv_dto);
723 }
724 
dat_srq_set_lw(IN DAT_SRQ_HANDLE srq_handle,IN DAT_COUNT low_watermark)725 DAT_RETURN dat_srq_set_lw(
726 	IN	DAT_SRQ_HANDLE	srq_handle,
727 	IN	DAT_COUNT	low_watermark)
728 {
729 	if (DAT_BAD_HANDLE(srq_handle)) {
730 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_SRQ));
731 	}
732 	return DAT_SRQ_SET_LW(srq_handle,
733 			low_watermark);
734 }
735