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) 1998-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <stdio.h>
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <sys/mman.h>
33 #include <sys/uio.h>
34 #include <sys/sysmacros.h>
35 #include <unistd.h>
36 #include <fcntl.h>
37 #include <dlfcn.h>
38 #include <sched.h>
39 #include <errno.h>
40 #include <strings.h>
41 
42 #include <rsmapi.h>
43 #include <sys/rsm/rsmndi.h>
44 #include <rsmlib_in.h>
45 #include <sys/rsm/rsm.h>
46 
47 extern int _rsm_memseg_import_map(rsm_memseg_import_handle_t,
48     void **,
49     rsm_attribute_t,
50     rsm_permission_t,
51     off_t, size_t);
52 
53 extern int _rsm_memseg_import_unmap(rsm_memseg_import_handle_t);
54 
55 static rsm_ndlib_attr_t _rsm_loopback_attr = {
56 	B_TRUE,		/* mapping needed for put/get */
57 	B_TRUE		/* mapping needed for putv/getv */
58 };
59 
60 static int
loopback_get8(rsm_memseg_import_handle_t im_memseg,off_t off,uint8_t * datap,ulong_t rep_cnt,boolean_t swap)61 loopback_get8(rsm_memseg_import_handle_t im_memseg, off_t off,
62     uint8_t *datap,
63     ulong_t rep_cnt,
64     boolean_t swap)
65 {
66 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
67 	uint8_t *data_addr =
68 	    (uint8_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
69 	uint_t i = 0;
70 	int	e;
71 
72 	swap = swap;
73 
74 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
75 	    "loopback_get8: enter\n"));
76 
77 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
78 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
79 				(rsm_barrier_handle_t)seg->rsmseg_barrier);
80 		if (e != RSM_SUCCESS) {
81 			return (e);
82 		}
83 	}
84 
85 	for (i = 0; i < rep_cnt; i++) {
86 		datap[i] = data_addr[i];
87 	}
88 
89 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
90 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
91 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
92 		if (e != RSM_SUCCESS) {
93 			return (e);
94 		}
95 	}
96 
97 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
98 	    "loopback_get8: exit\n"));
99 
100 	return (RSM_SUCCESS);
101 }
102 
103 static int
loopback_get16(rsm_memseg_import_handle_t im_memseg,off_t off,uint16_t * datap,ulong_t rep_cnt,boolean_t swap)104 loopback_get16(rsm_memseg_import_handle_t im_memseg, off_t off,
105     uint16_t *datap,
106     ulong_t rep_cnt,
107     boolean_t swap)
108 {
109 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
110 	uint16_t *data_addr =
111 	    /* LINTED */
112 	    (uint16_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
113 	uint_t i = 0;
114 	int	e;
115 
116 	swap = swap;
117 
118 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
119 	    "loopback_get16: enter\n"));
120 
121 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
122 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
123 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
124 		if (e != RSM_SUCCESS) {
125 			return (e);
126 		}
127 	}
128 
129 	for (i = 0; i < rep_cnt; i++) {
130 		datap[i] = data_addr[i];
131 	}
132 
133 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
134 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
135 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
136 		if (e != RSM_SUCCESS) {
137 			return (e);
138 		}
139 	}
140 
141 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
142 	    "loopback_get16: exit\n"));
143 
144 	return (RSM_SUCCESS);
145 }
146 
147 static int
loopback_get32(rsm_memseg_import_handle_t im_memseg,off_t off,uint32_t * datap,ulong_t rep_cnt,boolean_t swap)148 loopback_get32(rsm_memseg_import_handle_t im_memseg, off_t off,
149     uint32_t *datap,
150     ulong_t rep_cnt,
151     boolean_t swap)
152 {
153 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
154 	uint32_t *data_addr =
155 	    /* LINTED */
156 	    (uint32_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
157 	uint_t i = 0;
158 	int	e;
159 
160 	swap = swap;
161 
162 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
163 	    "loopback_get32: enter\n"));
164 
165 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
166 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
167 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
168 		if (e != RSM_SUCCESS) {
169 			return (e);
170 		}
171 	}
172 
173 	for (i = 0; i < rep_cnt; i++) {
174 		datap[i] = data_addr[i];
175 	}
176 
177 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
178 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
179 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
180 		if (e != RSM_SUCCESS) {
181 			return (e);
182 		}
183 	}
184 
185 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
186 	    "loopback_get32: exit\n"));
187 
188 	return (RSM_SUCCESS);
189 }
190 
191 static int
loopback_get64(rsm_memseg_import_handle_t im_memseg,off_t off,uint64_t * datap,ulong_t rep_cnt,boolean_t swap)192 loopback_get64(rsm_memseg_import_handle_t im_memseg, off_t off,
193     uint64_t *datap,
194     ulong_t rep_cnt,
195     boolean_t swap)
196 {
197 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
198 	uint64_t *data_addr =
199 	    /* LINTED */
200 	    (uint64_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
201 	uint_t i = 0;
202 	int	e;
203 
204 	swap = swap;
205 
206 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
207 	    "loopback_get64: enter\n"));
208 
209 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
210 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
211 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
212 		if (e != RSM_SUCCESS) {
213 			return (e);
214 		}
215 	}
216 
217 	for (i = 0; i < rep_cnt; i++) {
218 		datap[i] = data_addr[i];
219 	}
220 
221 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
222 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
223 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
224 		if (e != RSM_SUCCESS) {
225 			return (e);
226 		}
227 	}
228 
229 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
230 	    "loopback_get64: exit\n"));
231 
232 	return (RSM_SUCCESS);
233 }
234 
235 static int
loopback_put8(rsm_memseg_import_handle_t im_memseg,off_t off,uint8_t * datap,ulong_t rep_cnt,boolean_t swap)236 loopback_put8(rsm_memseg_import_handle_t im_memseg, off_t off,
237     uint8_t *datap,
238     ulong_t rep_cnt,
239     boolean_t swap)
240 {
241 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
242 	uint8_t *data_addr =
243 		(uint8_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
244 	uint_t i = 0;
245 	int	e;
246 
247 	swap = swap;
248 
249 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
250 	    "loopback_put8: enter\n"));
251 
252 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
253 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
254 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
255 		if (e != RSM_SUCCESS) {
256 			return (e);
257 		}
258 	}
259 
260 	for (i = 0; i < rep_cnt; i++) {
261 		data_addr[i] = datap[i];
262 	}
263 
264 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
265 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
266 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
267 		if (e != RSM_SUCCESS) {
268 			return (e);
269 		}
270 	}
271 
272 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
273 	    "loopback_put8: exit\n"));
274 
275 	return (RSM_SUCCESS);
276 }
277 
278 static int
loopback_put16(rsm_memseg_import_handle_t im_memseg,off_t off,uint16_t * datap,ulong_t rep_cnt,boolean_t swap)279 loopback_put16(rsm_memseg_import_handle_t im_memseg, off_t off,
280     uint16_t *datap,
281     ulong_t rep_cnt,
282     boolean_t swap)
283 {
284 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
285 	uint16_t *data_addr =
286 	    /* LINTED */
287 	    (uint16_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
288 	uint_t i = 0;
289 	int	e;
290 
291 	swap = swap;
292 
293 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
294 	    "loopback_put16: enter\n"));
295 
296 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
297 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
298 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
299 		if (e != RSM_SUCCESS) {
300 			return (e);
301 		}
302 	}
303 
304 	for (i = 0; i < rep_cnt; i++) {
305 		data_addr[i] = datap[i];
306 	}
307 
308 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
309 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
310 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
311 		if (e != RSM_SUCCESS) {
312 			return (e);
313 		}
314 	}
315 
316 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
317 	    "loopback_put16: exit\n"));
318 
319 	return (RSM_SUCCESS);
320 }
321 
322 static int
loopback_put32(rsm_memseg_import_handle_t im_memseg,off_t off,uint32_t * datap,ulong_t rep_cnt,boolean_t swap)323 loopback_put32(rsm_memseg_import_handle_t im_memseg, off_t off,
324     uint32_t *datap,
325     ulong_t rep_cnt,
326     boolean_t swap)
327 {
328 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
329 	uint32_t *data_addr =
330 	    /* LINTED */
331 	    (uint32_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
332 	uint_t i = 0;
333 	int	e;
334 
335 	swap = swap;
336 
337 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
338 	    "loopback_put32: enter\n"));
339 
340 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
341 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
342 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
343 		if (e != RSM_SUCCESS) {
344 			return (e);
345 		}
346 	}
347 
348 	for (i = 0; i < rep_cnt; i++) {
349 		data_addr[i] = datap[i];
350 	}
351 
352 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
353 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
354 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
355 		if (e != RSM_SUCCESS) {
356 			return (e);
357 		}
358 	}
359 
360 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
361 	    "loopback_put32: exit\n"));
362 
363 	return (RSM_SUCCESS);
364 }
365 
366 static int
loopback_put64(rsm_memseg_import_handle_t im_memseg,off_t off,uint64_t * datap,ulong_t rep_cnt,boolean_t swap)367 loopback_put64(rsm_memseg_import_handle_t im_memseg, off_t off,
368     uint64_t *datap,
369     ulong_t rep_cnt,
370     boolean_t swap)
371 {
372 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
373 	uint64_t *data_addr =
374 	    /* LINTED */
375 	    (uint64_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
376 	uint_t i = 0;
377 	int	e;
378 
379 	swap = swap;
380 
381 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
382 	    "loopback_put64: enter\n"));
383 
384 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
385 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
386 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
387 		if (e != RSM_SUCCESS) {
388 			return (e);
389 		}
390 	}
391 
392 	for (i = 0; i < rep_cnt; i++) {
393 		data_addr[i] = datap[i];
394 	}
395 
396 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
397 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
398 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
399 		if (e != RSM_SUCCESS) {
400 			return (e);
401 		}
402 	}
403 
404 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
405 	    "loopback_put64: exit\n"));
406 
407 	return (RSM_SUCCESS);
408 }
409 
410 static int
loopback_get(rsm_memseg_import_handle_t im_memseg,off_t offset,void * dst_addr,size_t length)411 loopback_get(rsm_memseg_import_handle_t im_memseg, off_t offset, void *dst_addr,
412     size_t length)
413 {
414 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
415 	int	e;
416 
417 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
418 	    "loopback_get: enter\n"));
419 
420 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
421 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
422 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
423 		if (e != RSM_SUCCESS) {
424 			return (e);
425 		}
426 	}
427 
428 	bcopy(seg->rsmseg_vaddr + offset - seg->rsmseg_mapoffset, dst_addr,
429 		length);
430 
431 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
432 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
433 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
434 		if (e != RSM_SUCCESS) {
435 			return (e);
436 		}
437 	}
438 
439 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
440 	    "loopback_get: exit\n"));
441 
442 	return (RSM_SUCCESS);
443 }
444 
445 
446 /*
447  * Move data to each component of the io vector from the remote segment
448  */
449 int
loopback_getv(rsm_scat_gath_t * sg_io)450 loopback_getv(rsm_scat_gath_t *sg_io)
451 {
452 	rsm_iovec_t	*iovec = sg_io->iovec;
453 	rsmseg_handle_t *im_seg = (rsmseg_handle_t *)sg_io->remote_handle;
454 	int i;
455 
456 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
457 	    "loopback_getv: enter\n"));
458 
459 	/* do the vector data transfer */
460 	for (i = 0; i < sg_io->io_request_count; i++) {
461 		(void) bcopy(im_seg->rsmseg_vaddr + iovec->remote_offset,
462 		    iovec->local.vaddr + iovec->local_offset,
463 		    iovec->transfer_length);
464 		iovec++;
465 	}
466 
467 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
468 	    "loopback_getv: exit\n"));
469 
470 	sg_io->io_residual_count = 0;
471 
472 	return (RSM_SUCCESS);
473 }
474 
475 static int
loopback_put(rsm_memseg_import_handle_t im_memseg,off_t offset,void * src_addr,size_t length)476 loopback_put(rsm_memseg_import_handle_t im_memseg, off_t offset, void *src_addr,
477     size_t length)
478 {
479 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
480 	int	e;
481 
482 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
483 	    "loopback_put: enter\n"));
484 
485 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
486 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
487 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
488 		if (e != RSM_SUCCESS) {
489 			return (e);
490 		}
491 	}
492 
493 	bcopy(src_addr, seg->rsmseg_vaddr + offset - seg->rsmseg_mapoffset,
494 		length);
495 
496 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
497 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
498 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
499 		if (e != RSM_SUCCESS) {
500 			return (e);
501 		}
502 	}
503 
504 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
505 	    "loopback_put: exit\n"));
506 
507 	return (RSM_SUCCESS);
508 }
509 
510 
511 /*
512  * Move data from each component of the io vector to the remote segment
513  */
514 int
loopback_putv(rsm_scat_gath_t * sg_io)515 loopback_putv(rsm_scat_gath_t *sg_io)
516 {
517 	rsm_iovec_t	*iovec = sg_io->iovec;
518 	rsmseg_handle_t *im_seg = (rsmseg_handle_t *)sg_io->remote_handle;
519 	int i;
520 
521 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
522 	    "loopback_putv: enter\n"));
523 
524 	/* do the vector data transfer */
525 	for (i = 0; i < sg_io->io_request_count; i++) {
526 		(void) bcopy(iovec->local.vaddr + iovec->local_offset,
527 		    im_seg->rsmseg_vaddr + iovec->remote_offset,
528 		    iovec->transfer_length);
529 		iovec++;
530 	}
531 
532 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
533 	    "loopback_putv: exit\n"));
534 
535 	sg_io->io_residual_count = 0;
536 
537 	return (RSM_SUCCESS);
538 }
539 
540 static int
loopback_create_handle(rsmapi_controller_handle_t controller,rsm_localmemory_handle_t * local_handle,caddr_t vaddr,size_t len)541 loopback_create_handle(rsmapi_controller_handle_t controller,
542     rsm_localmemory_handle_t *local_handle,
543     caddr_t vaddr, size_t len)
544 {
545 
546 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
547 	    "loopback_create_handle: enter\n"));
548 
549 	controller = controller;
550 	len = len;
551 
552 	*local_handle = (rsm_localmemory_handle_t)vaddr;
553 
554 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
555 	    "loopback_create_handle: exit\n"));
556 
557 	return (RSM_SUCCESS);
558 }
559 
560 static int
loopback_free_handle(rsm_localmemory_handle_t handle)561 loopback_free_handle(rsm_localmemory_handle_t handle)
562 {
563 
564 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
565 	    "loopback_free_handle: enter\n"));
566 
567 	handle = handle;
568 
569 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
570 	    "loopback_free_handle: exit\n"));
571 
572 	return (RSM_SUCCESS);
573 }
574 
575 
576 	/*
577 	 * import side memory segment operations (barriers):
578 	 */
579 static int
loopback_init_barrier(rsm_memseg_import_handle_t im_memseg,rsm_barrier_type_t type,rsm_barrier_handle_t barrier)580 loopback_init_barrier(rsm_memseg_import_handle_t im_memseg,
581     rsm_barrier_type_t type,
582     rsm_barrier_handle_t barrier)
583 {
584 
585 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
586 	    "loopback_init_barrier: enter\n"));
587 
588 	type = type; im_memseg = im_memseg; barrier = barrier;
589 
590 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
591 	    "loopback_init_barrier: exit\n"));
592 
593 	return (RSM_SUCCESS);
594 }
595 
596 static int
loopback_open_barrier(rsm_barrier_handle_t barrier)597 loopback_open_barrier(rsm_barrier_handle_t barrier)
598 {
599 
600 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
601 	    "loopback_open_barrier: enter\n"));
602 
603 	barrier = barrier;
604 
605 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
606 	    "loopback_open_barrier: exit\n"));
607 
608 	return (RSM_SUCCESS);
609 }
610 
611 static int
loopback_order_barrier(rsm_barrier_handle_t barrier)612 loopback_order_barrier(rsm_barrier_handle_t barrier)
613 {
614 
615 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
616 	    "loopback_order_barrier: enter\n"));
617 
618 	barrier = barrier;
619 
620 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
621 	    "loopback_order_barrier: exit\n"));
622 
623 	return (RSM_SUCCESS);
624 }
625 
626 static int
loopback_close_barrier(rsm_barrier_handle_t barrier)627 loopback_close_barrier(rsm_barrier_handle_t barrier)
628 {
629 
630 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
631 	    "loopback_close_barrier: enter\n"));
632 
633 	barrier = barrier;
634 
635 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
636 	    "loopback_close_barrier: exit\n"));
637 
638 	return (RSM_SUCCESS);
639 }
640 
641 static int
loopback_destroy_barrier(rsm_barrier_handle_t barrier)642 loopback_destroy_barrier(rsm_barrier_handle_t barrier)
643 {
644 
645 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
646 	    "loopback_destroy_barrier: enter\n"));
647 
648 	barrier = barrier;
649 
650 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
651 	    "loopback_destroy_barrier: exit\n"));
652 
653 	return (RSM_SUCCESS);
654 }
655 
656 static int
loopback_get_lib_attr(rsm_ndlib_attr_t ** libattrp)657 loopback_get_lib_attr(rsm_ndlib_attr_t **libattrp)
658 {
659 
660 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
661 	    "loopback_get_lib_attr: enter\n"));
662 
663 	*libattrp = &_rsm_loopback_attr;
664 
665 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
666 	    "loopback_get_lib_attr: exit\n"));
667 
668 	return (RSM_SUCCESS);
669 }
670 /*
671  * If an entry is NULL, the parent will fill it out with its entry point.
672  */
673 void
__rsmloopback_init_ops(rsm_segops_t * segops)674 __rsmloopback_init_ops(rsm_segops_t *segops)
675 {
676 
677 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
678 	    "__rsmloopback_init_ops: enter\n"));
679 
680 	segops->rsm_memseg_import_get8 = loopback_get8;
681 	segops->rsm_memseg_import_get16 = loopback_get16;
682 	segops->rsm_memseg_import_get32 = loopback_get32;
683 	segops->rsm_memseg_import_get64 = loopback_get64;
684 
685 	segops->rsm_memseg_import_put8 = loopback_put8;
686 	segops->rsm_memseg_import_put16 = loopback_put16;
687 	segops->rsm_memseg_import_put32 = loopback_put32;
688 	segops->rsm_memseg_import_put64 = loopback_put64;
689 
690 	segops->rsm_memseg_import_put = loopback_put;
691 	segops->rsm_memseg_import_get = loopback_get;
692 
693 	segops->rsm_memseg_import_putv = loopback_putv;
694 	segops->rsm_memseg_import_getv = loopback_getv;
695 
696 	segops->rsm_create_localmemory_handle = loopback_create_handle;
697 	segops->rsm_free_localmemory_handle = loopback_free_handle;
698 
699 	segops->rsm_memseg_import_init_barrier = loopback_init_barrier;
700 	segops->rsm_memseg_import_open_barrier = loopback_open_barrier;
701 	segops->rsm_memseg_import_order_barrier = loopback_order_barrier;
702 	segops->rsm_memseg_import_close_barrier = loopback_close_barrier;
703 	segops->rsm_memseg_import_destroy_barrier = loopback_destroy_barrier;
704 
705 	segops->rsm_get_lib_attr = loopback_get_lib_attr;
706 
707 	DBPRINTF((RSM_LIBRARY|RSM_LOOPBACK, RSM_DEBUG_VERBOSE,
708 	    "__rsmloopback_init_ops: exit\n"));
709 
710 }
711