xref: /titanic_44/usr/src/lib/librsm/common/rsmgen.c (revision e8031f0a8ed0e45c6d8847c5e09424e66fd34a4b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*e8031f0aSraf 
237c478bd9Sstevel@tonic-gate /*
24*e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25*e8031f0aSraf  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
297c478bd9Sstevel@tonic-gate 
30*e8031f0aSraf #include "c_synonyms.h"
317c478bd9Sstevel@tonic-gate #include <stdio.h>
327c478bd9Sstevel@tonic-gate #include <stdlib.h>
337c478bd9Sstevel@tonic-gate #include <unistd.h>
347c478bd9Sstevel@tonic-gate #include <string.h>
357c478bd9Sstevel@tonic-gate #include <strings.h>
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/stat.h>
387c478bd9Sstevel@tonic-gate #include <sys/mman.h>
397c478bd9Sstevel@tonic-gate #include <sys/uio.h>
407c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
417c478bd9Sstevel@tonic-gate #include <unistd.h>
427c478bd9Sstevel@tonic-gate #include <errno.h>
437c478bd9Sstevel@tonic-gate #include <assert.h>
447c478bd9Sstevel@tonic-gate #include <malloc.h>
457c478bd9Sstevel@tonic-gate #include <fcntl.h>
467c478bd9Sstevel@tonic-gate #include <dlfcn.h>
477c478bd9Sstevel@tonic-gate #include <sched.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #include <rsmapi.h>
507c478bd9Sstevel@tonic-gate #include <sys/rsm/rsmndi.h>
517c478bd9Sstevel@tonic-gate #include <rsmlib_in.h>
527c478bd9Sstevel@tonic-gate #include <sys/rsm/rsm.h>
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /* lint -w2 */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate extern rsm_node_id_t rsm_local_nodeid;
577c478bd9Sstevel@tonic-gate extern int loopback_getv(rsm_scat_gath_t *);
587c478bd9Sstevel@tonic-gate extern int loopback_putv(rsm_scat_gath_t *);
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate static rsm_ndlib_attr_t _rsm_genlib_attr = {
617c478bd9Sstevel@tonic-gate 	B_TRUE,		/* mapping needed for put/get */
627c478bd9Sstevel@tonic-gate 	B_FALSE		/* mapping needed for putv/getv */
637c478bd9Sstevel@tonic-gate };
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate static int
667c478bd9Sstevel@tonic-gate __rsm_import_connect(
677c478bd9Sstevel@tonic-gate     rsmapi_controller_handle_t controller, rsm_node_id_t node_id,
687c478bd9Sstevel@tonic-gate     rsm_memseg_id_t segment_id, rsm_permission_t perm,
697c478bd9Sstevel@tonic-gate     rsm_memseg_import_handle_t *im_memseg) {
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
727c478bd9Sstevel@tonic-gate 	    "__rsm_import_connect: enter\n"));
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	controller = controller;
757c478bd9Sstevel@tonic-gate 	node_id = node_id;
767c478bd9Sstevel@tonic-gate 	segment_id = segment_id;
777c478bd9Sstevel@tonic-gate 	perm = perm;
787c478bd9Sstevel@tonic-gate 	im_memseg = im_memseg;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
817c478bd9Sstevel@tonic-gate 	    "__rsm_import_connect: exit\n"));
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
847c478bd9Sstevel@tonic-gate }
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate static int
877c478bd9Sstevel@tonic-gate __rsm_import_disconnect(rsm_memseg_import_handle_t im_memseg) {
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
907c478bd9Sstevel@tonic-gate 	    "__rsm_import_disconnect: enter\n"));
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	im_memseg = im_memseg;
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
957c478bd9Sstevel@tonic-gate 	    "__rsm_import_disconnect: exit\n"));
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
987c478bd9Sstevel@tonic-gate }
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * XXX: one day we ought to rewrite this stuff based on 64byte atomic access.
1027c478bd9Sstevel@tonic-gate  * We can have a new ops vector that makes that assumption.
1037c478bd9Sstevel@tonic-gate  */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate static int
1067c478bd9Sstevel@tonic-gate __rsm_get8x8(rsm_memseg_import_handle_t im_memseg, off_t off,
1077c478bd9Sstevel@tonic-gate     uint8_t *datap,
1087c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
1097c478bd9Sstevel@tonic-gate     boolean_t swap)
1107c478bd9Sstevel@tonic-gate {
1117c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
1127c478bd9Sstevel@tonic-gate 	uint8_t *data_addr =
1137c478bd9Sstevel@tonic-gate 		(uint8_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
1147c478bd9Sstevel@tonic-gate 	uint_t i = 0;
1157c478bd9Sstevel@tonic-gate 	int	e;
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 	swap = swap;
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
1207c478bd9Sstevel@tonic-gate 	    "__rsm_import_get8x8: enter\n"));
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
1237c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
1247c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
1257c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
1267c478bd9Sstevel@tonic-gate 			return (e);
1277c478bd9Sstevel@tonic-gate 		}
1287c478bd9Sstevel@tonic-gate 	}
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
1317c478bd9Sstevel@tonic-gate 		datap[i] = data_addr[i];
1327c478bd9Sstevel@tonic-gate 	}
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
1357c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
1367c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
1377c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
1387c478bd9Sstevel@tonic-gate 			return (e);
1397c478bd9Sstevel@tonic-gate 		}
1407c478bd9Sstevel@tonic-gate 	}
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
1437c478bd9Sstevel@tonic-gate 	    "__rsm_import_get8x8: exit\n"));
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate static int
1497c478bd9Sstevel@tonic-gate __rsm_get16x16(rsm_memseg_import_handle_t im_memseg, off_t off,
1507c478bd9Sstevel@tonic-gate     uint16_t *datap,
1517c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
1527c478bd9Sstevel@tonic-gate     boolean_t swap)
1537c478bd9Sstevel@tonic-gate {
1547c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
1557c478bd9Sstevel@tonic-gate 	uint16_t *data_addr =
1567c478bd9Sstevel@tonic-gate 	    /* LINTED */
1577c478bd9Sstevel@tonic-gate 	    (uint16_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
1587c478bd9Sstevel@tonic-gate 	uint_t i = 0;
1597c478bd9Sstevel@tonic-gate 	int	e;
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate 	swap = swap;
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
1647c478bd9Sstevel@tonic-gate 	    "__rsm_import_get16x16: enter\n"));
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
1677c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
1687c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
1697c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
1707c478bd9Sstevel@tonic-gate 			return (e);
1717c478bd9Sstevel@tonic-gate 		}
1727c478bd9Sstevel@tonic-gate 	}
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
1757c478bd9Sstevel@tonic-gate 		datap[i] = data_addr[i];
1767c478bd9Sstevel@tonic-gate 	}
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
1797c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
1807c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
1817c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
1827c478bd9Sstevel@tonic-gate 			return (e);
1837c478bd9Sstevel@tonic-gate 		}
1847c478bd9Sstevel@tonic-gate 	}
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
1877c478bd9Sstevel@tonic-gate 	    "__rsm_import_get16x16: exit\n"));
1887c478bd9Sstevel@tonic-gate 
1897c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
1907c478bd9Sstevel@tonic-gate }
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate static int
1937c478bd9Sstevel@tonic-gate __rsm_get32x32(rsm_memseg_import_handle_t im_memseg, off_t off,
1947c478bd9Sstevel@tonic-gate     uint32_t *datap,
1957c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
1967c478bd9Sstevel@tonic-gate     boolean_t swap)
1977c478bd9Sstevel@tonic-gate {
1987c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
1997c478bd9Sstevel@tonic-gate 	uint32_t *data_addr =
2007c478bd9Sstevel@tonic-gate 	    /* LINTED */
2017c478bd9Sstevel@tonic-gate 	    (uint32_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
2027c478bd9Sstevel@tonic-gate 	uint_t i = 0;
2037c478bd9Sstevel@tonic-gate 	int	e;
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate 	swap = swap;
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
2087c478bd9Sstevel@tonic-gate 	    "__rsm_import_get32x32: enter\n"));
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
2117c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
2127c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
2137c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
2147c478bd9Sstevel@tonic-gate 			return (e);
2157c478bd9Sstevel@tonic-gate 		}
2167c478bd9Sstevel@tonic-gate 	}
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
2197c478bd9Sstevel@tonic-gate 		datap[i] = data_addr[i];
2207c478bd9Sstevel@tonic-gate 	}
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
2237c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
2247c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
2257c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
2267c478bd9Sstevel@tonic-gate 			return (e);
2277c478bd9Sstevel@tonic-gate 		}
2287c478bd9Sstevel@tonic-gate 	}
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
2317c478bd9Sstevel@tonic-gate 	    "__rsm_import_get32x32: exit\n"));
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate static int
2377c478bd9Sstevel@tonic-gate __rsm_get64x64(rsm_memseg_import_handle_t im_memseg, off_t off,
2387c478bd9Sstevel@tonic-gate     uint64_t *datap,
2397c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
2407c478bd9Sstevel@tonic-gate     boolean_t swap)
2417c478bd9Sstevel@tonic-gate {
2427c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
2437c478bd9Sstevel@tonic-gate 	uint64_t *data_addr =
2447c478bd9Sstevel@tonic-gate 	    /* LINTED */
2457c478bd9Sstevel@tonic-gate 	    (uint64_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
2467c478bd9Sstevel@tonic-gate 	uint_t i = 0;
2477c478bd9Sstevel@tonic-gate 	int	e;
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate 	swap = swap;
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
2527c478bd9Sstevel@tonic-gate 	    "__rsm_import_get64x64: enter\n"));
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
2557c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
2567c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
2577c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
2587c478bd9Sstevel@tonic-gate 			return (e);
2597c478bd9Sstevel@tonic-gate 		}
2607c478bd9Sstevel@tonic-gate 	}
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
2637c478bd9Sstevel@tonic-gate 		datap[i] = data_addr[i];
2647c478bd9Sstevel@tonic-gate 	}
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
2677c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
2687c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
2697c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
2707c478bd9Sstevel@tonic-gate 			return (e);
2717c478bd9Sstevel@tonic-gate 		}
2727c478bd9Sstevel@tonic-gate 	}
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
2757c478bd9Sstevel@tonic-gate 	    "__rsm_import_get64x64: exit\n"));
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
2787c478bd9Sstevel@tonic-gate }
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 	/*
2817c478bd9Sstevel@tonic-gate 	 * import side memory segment operations (write access functions):
2827c478bd9Sstevel@tonic-gate 	 */
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate /*
2857c478bd9Sstevel@tonic-gate  * XXX: Each one of the following cases ought to be a separate function loaded
2867c478bd9Sstevel@tonic-gate  * into a segment access ops vector. We determine the correct function at
2877c478bd9Sstevel@tonic-gate  * segment connect time. When a new controller is register, we can decode
2887c478bd9Sstevel@tonic-gate  * it's direct_access_size attribute and load the correct function. For
2897c478bd9Sstevel@tonic-gate  * loop back we need to create a special ops vector that bypasses all of
2907c478bd9Sstevel@tonic-gate  * this stuff.
2917c478bd9Sstevel@tonic-gate  *
2927c478bd9Sstevel@tonic-gate  * XXX: We need to create a special interrupt queue for the library to handle
2937c478bd9Sstevel@tonic-gate  * partial writes in the remote process.
2947c478bd9Sstevel@tonic-gate  */
2957c478bd9Sstevel@tonic-gate static int
2967c478bd9Sstevel@tonic-gate __rsm_put8x8(rsm_memseg_import_handle_t im_memseg, off_t off,
2977c478bd9Sstevel@tonic-gate     uint8_t *datap,
2987c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
2997c478bd9Sstevel@tonic-gate     boolean_t swap)
3007c478bd9Sstevel@tonic-gate {
3017c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
3027c478bd9Sstevel@tonic-gate 	uint8_t *data_addr =
3037c478bd9Sstevel@tonic-gate 		(uint8_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
3047c478bd9Sstevel@tonic-gate 	uint_t i = 0;
3057c478bd9Sstevel@tonic-gate 	int	e;
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate 	swap = swap;
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
3107c478bd9Sstevel@tonic-gate 	    "__rsm_put8x8: enter\n"));
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
3137c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
3147c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
3157c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
3167c478bd9Sstevel@tonic-gate 			return (e);
3177c478bd9Sstevel@tonic-gate 		}
3187c478bd9Sstevel@tonic-gate 	}
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
3217c478bd9Sstevel@tonic-gate 		data_addr[i] = datap[i];
3227c478bd9Sstevel@tonic-gate 	}
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
3257c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
3267c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
3277c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
3287c478bd9Sstevel@tonic-gate 			return (e);
3297c478bd9Sstevel@tonic-gate 		}
3307c478bd9Sstevel@tonic-gate 	}
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
3337c478bd9Sstevel@tonic-gate 	    "__rsm_put8x8: exit\n"));
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
3367c478bd9Sstevel@tonic-gate }
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate static int
3397c478bd9Sstevel@tonic-gate __rsm_put16x16(rsm_memseg_import_handle_t im_memseg, off_t off,
3407c478bd9Sstevel@tonic-gate     uint16_t *datap,
3417c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
3427c478bd9Sstevel@tonic-gate     boolean_t swap)
3437c478bd9Sstevel@tonic-gate {
3447c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
3457c478bd9Sstevel@tonic-gate 	uint16_t *data_addr =
3467c478bd9Sstevel@tonic-gate 	    /* LINTED */
3477c478bd9Sstevel@tonic-gate 	    (uint16_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
3487c478bd9Sstevel@tonic-gate 	uint_t i = 0;
3497c478bd9Sstevel@tonic-gate 	int	e;
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate 	swap = swap;
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
3547c478bd9Sstevel@tonic-gate 	    "__rsm_put16x16: enter\n"));
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
3577c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
3587c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
3597c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
3607c478bd9Sstevel@tonic-gate 			return (e);
3617c478bd9Sstevel@tonic-gate 		}
3627c478bd9Sstevel@tonic-gate 	}
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
3657c478bd9Sstevel@tonic-gate 		data_addr[i] = datap[i];
3667c478bd9Sstevel@tonic-gate 	}
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
3697c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
3707c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
3717c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
3727c478bd9Sstevel@tonic-gate 			return (e);
3737c478bd9Sstevel@tonic-gate 		}
3747c478bd9Sstevel@tonic-gate 	}
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
3777c478bd9Sstevel@tonic-gate 	    "__rsm_put16x16: exit\n"));
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
3807c478bd9Sstevel@tonic-gate }
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate static int
3837c478bd9Sstevel@tonic-gate __rsm_put32x32(rsm_memseg_import_handle_t im_memseg, off_t off,
3847c478bd9Sstevel@tonic-gate     uint32_t *datap,
3857c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
3867c478bd9Sstevel@tonic-gate     boolean_t swap)
3877c478bd9Sstevel@tonic-gate {
3887c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
3897c478bd9Sstevel@tonic-gate 	uint32_t *data_addr =
3907c478bd9Sstevel@tonic-gate 	    /* LINTED */
3917c478bd9Sstevel@tonic-gate 	    (uint32_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
3927c478bd9Sstevel@tonic-gate 	uint_t i = 0;
3937c478bd9Sstevel@tonic-gate 	int	e;
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate 	swap = swap;
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
3987c478bd9Sstevel@tonic-gate 	    "__rsm_put32x32: enter\n"));
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
4017c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
4027c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
4037c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
4047c478bd9Sstevel@tonic-gate 			return (e);
4057c478bd9Sstevel@tonic-gate 		}
4067c478bd9Sstevel@tonic-gate 	}
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
4097c478bd9Sstevel@tonic-gate 		data_addr[i] = datap[i];
4107c478bd9Sstevel@tonic-gate 	}
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
4137c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
4147c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
4157c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
4167c478bd9Sstevel@tonic-gate 			return (e);
4177c478bd9Sstevel@tonic-gate 		}
4187c478bd9Sstevel@tonic-gate 	}
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
4217c478bd9Sstevel@tonic-gate 	    "__rsm_put32x32: exit\n"));
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
4247c478bd9Sstevel@tonic-gate }
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate static int
4277c478bd9Sstevel@tonic-gate __rsm_put64x64(rsm_memseg_import_handle_t im_memseg, off_t off,
4287c478bd9Sstevel@tonic-gate     uint64_t *datap,
4297c478bd9Sstevel@tonic-gate     ulong_t rep_cnt,
4307c478bd9Sstevel@tonic-gate     boolean_t swap)
4317c478bd9Sstevel@tonic-gate {
4327c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
4337c478bd9Sstevel@tonic-gate 	uint64_t *data_addr =
4347c478bd9Sstevel@tonic-gate 	    /* LINTED */
4357c478bd9Sstevel@tonic-gate 	    (uint64_t *)&seg->rsmseg_vaddr[off - seg->rsmseg_mapoffset];
4367c478bd9Sstevel@tonic-gate 	uint_t i = 0;
4377c478bd9Sstevel@tonic-gate 	int	e;
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate 	swap = swap;
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
4427c478bd9Sstevel@tonic-gate 	    "__rsm_put64x64: enter\n"));
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
4457c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
4467c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
4477c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
4487c478bd9Sstevel@tonic-gate 			return (e);
4497c478bd9Sstevel@tonic-gate 		}
4507c478bd9Sstevel@tonic-gate 	}
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate 	for (i = 0; i < rep_cnt; i++) {
4537c478bd9Sstevel@tonic-gate 		data_addr[i] = datap[i];
4547c478bd9Sstevel@tonic-gate 	}
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
4577c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
4587c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
4597c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
4607c478bd9Sstevel@tonic-gate 			return (e);
4617c478bd9Sstevel@tonic-gate 		}
4627c478bd9Sstevel@tonic-gate 	}
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
4657c478bd9Sstevel@tonic-gate 	    "__rsm_put64x64: exit\n"));
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
4687c478bd9Sstevel@tonic-gate }
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate static int
4717c478bd9Sstevel@tonic-gate __rsm_get(rsm_memseg_import_handle_t im_memseg, off_t offset, void *dst_addr,
4727c478bd9Sstevel@tonic-gate     size_t length)
4737c478bd9Sstevel@tonic-gate {
4747c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
4757c478bd9Sstevel@tonic-gate 	int		e;
4767c478bd9Sstevel@tonic-gate 
4777c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
4787c478bd9Sstevel@tonic-gate 	    "__rsm_get: enter\n"));
4797c478bd9Sstevel@tonic-gate 
4807c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
4817c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
4827c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
4837c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
4847c478bd9Sstevel@tonic-gate 			return (e);
4857c478bd9Sstevel@tonic-gate 		}
4867c478bd9Sstevel@tonic-gate 	}
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate 	(void) bcopy(seg->rsmseg_vaddr + offset - seg->rsmseg_mapoffset,
4897c478bd9Sstevel@tonic-gate 	    dst_addr, length);
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
4927c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
4937c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
4947c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
4957c478bd9Sstevel@tonic-gate 			return (e);
4967c478bd9Sstevel@tonic-gate 		}
4977c478bd9Sstevel@tonic-gate 	}
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
5007c478bd9Sstevel@tonic-gate 	    "__rsm_get: exit\n"));
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
5037c478bd9Sstevel@tonic-gate }
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate static int
5067c478bd9Sstevel@tonic-gate __rsm_getv(rsm_scat_gath_t *sg_io)
5077c478bd9Sstevel@tonic-gate {
5087c478bd9Sstevel@tonic-gate 	rsm_iovec_t 	*iovec = sg_io->iovec;
5097c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	ka_iovec_arr[RSM_MAX_IOVLEN];
5107c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	*ka_iovec, *ka_iovec_start;
5117c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	l_iovec_arr[RSM_MAX_IOVLEN];
5127c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	*l_iovec, *l_iovec_start;
5137c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *im_seg_hndl = (rsmseg_handle_t *)sg_io->remote_handle;
5147c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg_hndl;
5157c478bd9Sstevel@tonic-gate 	int iovec_size = sizeof (rsmka_iovec_t) * sg_io->io_request_count;
5167c478bd9Sstevel@tonic-gate 	int e, i;
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
5197c478bd9Sstevel@tonic-gate 	    "__rsm_getv: enter\n"));
5207c478bd9Sstevel@tonic-gate 
5217c478bd9Sstevel@tonic-gate 	/*
5227c478bd9Sstevel@tonic-gate 	 * Use loopback for single node operations.
5237c478bd9Sstevel@tonic-gate 	 * replace local handles with virtual addresses
5247c478bd9Sstevel@tonic-gate 	 */
5257c478bd9Sstevel@tonic-gate 
5267c478bd9Sstevel@tonic-gate 	if (im_seg_hndl->rsmseg_nodeid == rsm_local_nodeid) {
5277c478bd9Sstevel@tonic-gate 		/*
5287c478bd9Sstevel@tonic-gate 		 * To use the loopback optimization map the segment
5297c478bd9Sstevel@tonic-gate 		 * here implicitly.
5307c478bd9Sstevel@tonic-gate 		 */
5317c478bd9Sstevel@tonic-gate 		if (im_seg_hndl->rsmseg_state == IMPORT_CONNECT) {
5327c478bd9Sstevel@tonic-gate 			caddr_t	va;
5337c478bd9Sstevel@tonic-gate 			va = mmap(NULL, im_seg_hndl->rsmseg_size,
5347c478bd9Sstevel@tonic-gate 			    PROT_READ|PROT_WRITE,
5357c478bd9Sstevel@tonic-gate 			    MAP_SHARED|MAP_NORESERVE,
5367c478bd9Sstevel@tonic-gate 			    im_seg_hndl->rsmseg_fd, 0);
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate 			if (va == MAP_FAILED) {
5397c478bd9Sstevel@tonic-gate 				DBPRINTF((RSM_LIBRARY, RSM_ERR,
5407c478bd9Sstevel@tonic-gate 				    "implicit map failed:%d\n", errno));
5417c478bd9Sstevel@tonic-gate 				if (errno == EINVAL)
5427c478bd9Sstevel@tonic-gate 					return (RSMERR_BAD_MEM_ALIGNMENT);
5437c478bd9Sstevel@tonic-gate 				else if (errno == ENOMEM || errno == ENXIO ||
5447c478bd9Sstevel@tonic-gate 					errno == EOVERFLOW)
5457c478bd9Sstevel@tonic-gate 						return (RSMERR_BAD_LENGTH);
5467c478bd9Sstevel@tonic-gate 				else if (errno == EAGAIN)
5477c478bd9Sstevel@tonic-gate 					return (RSMERR_INSUFFICIENT_RESOURCES);
5487c478bd9Sstevel@tonic-gate 				else
5497c478bd9Sstevel@tonic-gate 					return (errno);
5507c478bd9Sstevel@tonic-gate 			}
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_vaddr = va;
5537c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_maplen = im_seg_hndl->rsmseg_size;
5547c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_mapoffset = 0;
5557c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_state = IMPORT_MAP;
5567c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_flags |= RSM_IMPLICIT_MAP;
5577c478bd9Sstevel@tonic-gate 		}
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate 		if (sg_io->io_request_count > RSM_MAX_IOVLEN)
5607c478bd9Sstevel@tonic-gate 			l_iovec_start = l_iovec = malloc(iovec_size);
5617c478bd9Sstevel@tonic-gate 		else
5627c478bd9Sstevel@tonic-gate 			l_iovec_start = l_iovec = l_iovec_arr;
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate 		bcopy((caddr_t)iovec, (caddr_t)l_iovec, iovec_size);
5657c478bd9Sstevel@tonic-gate 		for (i = 0; i < sg_io->io_request_count; i++) {
5667c478bd9Sstevel@tonic-gate 			if (l_iovec->io_type == RSM_HANDLE_TYPE) {
5677c478bd9Sstevel@tonic-gate 				/* Get the surrogate export segment handle */
5687c478bd9Sstevel@tonic-gate 				seg_hndl = (rsmseg_handle_t *)
5697c478bd9Sstevel@tonic-gate 				    l_iovec->local.handle;
5707c478bd9Sstevel@tonic-gate 				l_iovec->local.vaddr = seg_hndl->rsmseg_vaddr;
5717c478bd9Sstevel@tonic-gate 				l_iovec->io_type = RSM_VA_TYPE;
5727c478bd9Sstevel@tonic-gate 			}
5737c478bd9Sstevel@tonic-gate 			l_iovec++;
5747c478bd9Sstevel@tonic-gate 		}
5757c478bd9Sstevel@tonic-gate 		sg_io->iovec = (rsm_iovec_t *)l_iovec_start;
5767c478bd9Sstevel@tonic-gate 		e = loopback_getv(sg_io);
5777c478bd9Sstevel@tonic-gate 		sg_io->iovec = iovec;
5787c478bd9Sstevel@tonic-gate 		if (sg_io->io_request_count > RSM_MAX_IOVLEN)
5797c478bd9Sstevel@tonic-gate 			free(l_iovec_start);
5807c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
5817c478bd9Sstevel@tonic-gate 		    "__rsm_getv: exit\n"));
5827c478bd9Sstevel@tonic-gate 		return (e);
5837c478bd9Sstevel@tonic-gate 	}
5847c478bd9Sstevel@tonic-gate 
5857c478bd9Sstevel@tonic-gate 	/* for the Kernel Agent, replace local handles with segment ids */
5867c478bd9Sstevel@tonic-gate 	if (sg_io->io_request_count > RSM_MAX_IOVLEN)
5877c478bd9Sstevel@tonic-gate 		ka_iovec_start = ka_iovec = malloc(iovec_size);
5887c478bd9Sstevel@tonic-gate 	else
5897c478bd9Sstevel@tonic-gate 		ka_iovec_start = ka_iovec = ka_iovec_arr;
5907c478bd9Sstevel@tonic-gate 
5917c478bd9Sstevel@tonic-gate 	bcopy((caddr_t)iovec, (caddr_t)ka_iovec, iovec_size);
5927c478bd9Sstevel@tonic-gate 	for (i = 0; i < sg_io->io_request_count; i++) {
5937c478bd9Sstevel@tonic-gate 		if (ka_iovec->io_type == RSM_HANDLE_TYPE) {
5947c478bd9Sstevel@tonic-gate 			seg_hndl = (rsmseg_handle_t *)ka_iovec->local.handle;
5957c478bd9Sstevel@tonic-gate 			ka_iovec->local.segid = seg_hndl->rsmseg_keyid;
5967c478bd9Sstevel@tonic-gate 		}
5977c478bd9Sstevel@tonic-gate 		ka_iovec++;
5987c478bd9Sstevel@tonic-gate 	}
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate 	sg_io->iovec = (rsm_iovec_t *)ka_iovec_start;
6017c478bd9Sstevel@tonic-gate 	e = ioctl(im_seg_hndl->rsmseg_fd, RSM_IOCTL_GETV, sg_io);
6027c478bd9Sstevel@tonic-gate 	sg_io->iovec = iovec;
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate 	if (sg_io->io_request_count > RSM_MAX_IOVLEN)
6057c478bd9Sstevel@tonic-gate 		free(ka_iovec_start);
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate 	if (e < 0) {
6087c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
6097c478bd9Sstevel@tonic-gate 		    " RSM_IOCTL_GETV failed\n"));
6107c478bd9Sstevel@tonic-gate 		return (errno);
6117c478bd9Sstevel@tonic-gate 	}
6127c478bd9Sstevel@tonic-gate 
6137c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
6147c478bd9Sstevel@tonic-gate 	    "__rsm_getv: exit\n"));
6157c478bd9Sstevel@tonic-gate 
6167c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
6177c478bd9Sstevel@tonic-gate }
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate 
6207c478bd9Sstevel@tonic-gate static int
6217c478bd9Sstevel@tonic-gate __rsm_put(rsm_memseg_import_handle_t im_memseg, off_t offset, void *src_addr,
6227c478bd9Sstevel@tonic-gate     size_t length)
6237c478bd9Sstevel@tonic-gate {
6247c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
6257c478bd9Sstevel@tonic-gate 	int		e;
6267c478bd9Sstevel@tonic-gate 
6277c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
6287c478bd9Sstevel@tonic-gate 	    "__rsm_put: enter\n"));
6297c478bd9Sstevel@tonic-gate 
6307c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
6317c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_open_barrier(
6327c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
6337c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
6347c478bd9Sstevel@tonic-gate 			return (e);
6357c478bd9Sstevel@tonic-gate 		}
6367c478bd9Sstevel@tonic-gate 	}
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate 	bcopy(src_addr, seg->rsmseg_vaddr + offset - seg->rsmseg_mapoffset,
6397c478bd9Sstevel@tonic-gate 		length);
6407c478bd9Sstevel@tonic-gate 
6417c478bd9Sstevel@tonic-gate 	if (seg->rsmseg_barmode == RSM_BARRIER_MODE_IMPLICIT) {
6427c478bd9Sstevel@tonic-gate 		e = seg->rsmseg_ops->rsm_memseg_import_close_barrier(
6437c478bd9Sstevel@tonic-gate 		    (rsm_barrier_handle_t)seg->rsmseg_barrier);
6447c478bd9Sstevel@tonic-gate 		if (e != RSM_SUCCESS) {
6457c478bd9Sstevel@tonic-gate 			return (e);
6467c478bd9Sstevel@tonic-gate 		}
6477c478bd9Sstevel@tonic-gate 	}
6487c478bd9Sstevel@tonic-gate 
6497c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
6507c478bd9Sstevel@tonic-gate 	    "__rsm_put: exit\n"));
6517c478bd9Sstevel@tonic-gate 
6527c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
6537c478bd9Sstevel@tonic-gate }
6547c478bd9Sstevel@tonic-gate 
6557c478bd9Sstevel@tonic-gate static int
6567c478bd9Sstevel@tonic-gate __rsm_putv(rsm_scat_gath_t *sg_io)
6577c478bd9Sstevel@tonic-gate {
6587c478bd9Sstevel@tonic-gate 	rsm_iovec_t 	*iovec = sg_io->iovec;
6597c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	ka_iovec_arr[RSM_MAX_IOVLEN];
6607c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	*ka_iovec, *ka_iovec_start;
6617c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	l_iovec_arr[RSM_MAX_IOVLEN];
6627c478bd9Sstevel@tonic-gate 	rsmka_iovec_t	*l_iovec, *l_iovec_start;
6637c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *im_seg_hndl = (rsmseg_handle_t *)sg_io->remote_handle;
6647c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg_hndl;
6657c478bd9Sstevel@tonic-gate 	int iovec_size = sizeof (rsmka_iovec_t) * sg_io->io_request_count;
6667c478bd9Sstevel@tonic-gate 	int e, i;
6677c478bd9Sstevel@tonic-gate 
6687c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
6697c478bd9Sstevel@tonic-gate 	    "__rsm_putv: enter\n"));
6707c478bd9Sstevel@tonic-gate 
6717c478bd9Sstevel@tonic-gate 	/*
6727c478bd9Sstevel@tonic-gate 	 * Use loopback for single node operations.
6737c478bd9Sstevel@tonic-gate 	 * replace local handles with virtual addresses
6747c478bd9Sstevel@tonic-gate 	 */
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate 	if (im_seg_hndl->rsmseg_nodeid == rsm_local_nodeid) {
6777c478bd9Sstevel@tonic-gate 		/*
6787c478bd9Sstevel@tonic-gate 		 * To use the loopback optimization map the segment
6797c478bd9Sstevel@tonic-gate 		 * here implicitly.
6807c478bd9Sstevel@tonic-gate 		 */
6817c478bd9Sstevel@tonic-gate 		if (im_seg_hndl->rsmseg_state == IMPORT_CONNECT) {
6827c478bd9Sstevel@tonic-gate 			caddr_t	va;
6837c478bd9Sstevel@tonic-gate 			va = mmap(NULL, im_seg_hndl->rsmseg_size,
6847c478bd9Sstevel@tonic-gate 			    PROT_READ|PROT_WRITE,
6857c478bd9Sstevel@tonic-gate 			    MAP_SHARED|MAP_NORESERVE,
6867c478bd9Sstevel@tonic-gate 			    im_seg_hndl->rsmseg_fd, 0);
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate 			if (va == MAP_FAILED) {
6897c478bd9Sstevel@tonic-gate 				DBPRINTF((RSM_LIBRARY, RSM_ERR,
6907c478bd9Sstevel@tonic-gate 				    "implicit map failed:%d\n", errno));
6917c478bd9Sstevel@tonic-gate 				if (errno == EINVAL)
6927c478bd9Sstevel@tonic-gate 					return (RSMERR_BAD_MEM_ALIGNMENT);
6937c478bd9Sstevel@tonic-gate 				else if (errno == ENOMEM || errno == ENXIO ||
6947c478bd9Sstevel@tonic-gate 					errno == EOVERFLOW)
6957c478bd9Sstevel@tonic-gate 						return (RSMERR_BAD_LENGTH);
6967c478bd9Sstevel@tonic-gate 				else if (errno == EAGAIN)
6977c478bd9Sstevel@tonic-gate 					return (RSMERR_INSUFFICIENT_RESOURCES);
6987c478bd9Sstevel@tonic-gate 				else
6997c478bd9Sstevel@tonic-gate 					return (errno);
7007c478bd9Sstevel@tonic-gate 			}
7017c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_vaddr = va;
7027c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_maplen = im_seg_hndl->rsmseg_size;
7037c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_mapoffset = 0;
7047c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_state = IMPORT_MAP;
7057c478bd9Sstevel@tonic-gate 			im_seg_hndl->rsmseg_flags |= RSM_IMPLICIT_MAP;
7067c478bd9Sstevel@tonic-gate 		}
7077c478bd9Sstevel@tonic-gate 
7087c478bd9Sstevel@tonic-gate 		if (sg_io->io_request_count > RSM_MAX_IOVLEN)
7097c478bd9Sstevel@tonic-gate 			l_iovec_start = l_iovec = malloc(iovec_size);
7107c478bd9Sstevel@tonic-gate 		else
7117c478bd9Sstevel@tonic-gate 			l_iovec_start = l_iovec = l_iovec_arr;
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate 		bcopy((caddr_t)iovec, (caddr_t)l_iovec, iovec_size);
7147c478bd9Sstevel@tonic-gate 		for (i = 0; i < sg_io->io_request_count; i++) {
7157c478bd9Sstevel@tonic-gate 			if (l_iovec->io_type == RSM_HANDLE_TYPE) {
7167c478bd9Sstevel@tonic-gate 				/* Get the surrogate export segment handle */
7177c478bd9Sstevel@tonic-gate 				seg_hndl = (rsmseg_handle_t *)
7187c478bd9Sstevel@tonic-gate 							l_iovec->local.handle;
7197c478bd9Sstevel@tonic-gate 				l_iovec->local.vaddr = seg_hndl->rsmseg_vaddr;
7207c478bd9Sstevel@tonic-gate 				l_iovec->io_type = RSM_VA_TYPE;
7217c478bd9Sstevel@tonic-gate 			}
7227c478bd9Sstevel@tonic-gate 			l_iovec++;
7237c478bd9Sstevel@tonic-gate 		}
7247c478bd9Sstevel@tonic-gate 		sg_io->iovec = (rsm_iovec_t *)l_iovec_start;
7257c478bd9Sstevel@tonic-gate 		e = loopback_putv(sg_io);
7267c478bd9Sstevel@tonic-gate 		sg_io->iovec = iovec;
7277c478bd9Sstevel@tonic-gate 
7287c478bd9Sstevel@tonic-gate 		if (sg_io->io_request_count > RSM_MAX_IOVLEN)
7297c478bd9Sstevel@tonic-gate 			free(l_iovec_start);
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
7327c478bd9Sstevel@tonic-gate 		    "__rsm_putv: exit\n"));
7337c478bd9Sstevel@tonic-gate 
7347c478bd9Sstevel@tonic-gate 
7357c478bd9Sstevel@tonic-gate 		return (e);
7367c478bd9Sstevel@tonic-gate 	}
7377c478bd9Sstevel@tonic-gate 
7387c478bd9Sstevel@tonic-gate 	/* for the Kernel Agent, replace local handles with segment ids */
7397c478bd9Sstevel@tonic-gate 	if (sg_io->io_request_count > RSM_MAX_IOVLEN)
7407c478bd9Sstevel@tonic-gate 		ka_iovec_start = ka_iovec = malloc(iovec_size);
7417c478bd9Sstevel@tonic-gate 	else
7427c478bd9Sstevel@tonic-gate 		ka_iovec_start = ka_iovec = ka_iovec_arr;
7437c478bd9Sstevel@tonic-gate 
7447c478bd9Sstevel@tonic-gate 	bcopy((caddr_t)iovec, (caddr_t)ka_iovec, iovec_size);
7457c478bd9Sstevel@tonic-gate 
7467c478bd9Sstevel@tonic-gate 	for (i = 0; i < sg_io->io_request_count; i++) {
7477c478bd9Sstevel@tonic-gate 		if (ka_iovec->io_type == RSM_HANDLE_TYPE) {
7487c478bd9Sstevel@tonic-gate 			seg_hndl = (rsmseg_handle_t *)ka_iovec->local.handle;
7497c478bd9Sstevel@tonic-gate 			ka_iovec->local.segid = seg_hndl->rsmseg_keyid;
7507c478bd9Sstevel@tonic-gate 		}
7517c478bd9Sstevel@tonic-gate 		ka_iovec++;
7527c478bd9Sstevel@tonic-gate 	}
7537c478bd9Sstevel@tonic-gate 
7547c478bd9Sstevel@tonic-gate 	sg_io->iovec = (rsm_iovec_t *)ka_iovec_start;
7557c478bd9Sstevel@tonic-gate 	e = ioctl(im_seg_hndl->rsmseg_fd, RSM_IOCTL_PUTV, sg_io);
7567c478bd9Sstevel@tonic-gate 	sg_io->iovec = iovec;
7577c478bd9Sstevel@tonic-gate 
7587c478bd9Sstevel@tonic-gate 	if (sg_io->io_request_count > RSM_MAX_IOVLEN)
7597c478bd9Sstevel@tonic-gate 		free(ka_iovec_start);
7607c478bd9Sstevel@tonic-gate 
7617c478bd9Sstevel@tonic-gate 	if (e < 0) {
7627c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
7637c478bd9Sstevel@tonic-gate 		    " RSM_IOCTL_PUTV failed\n"));
7647c478bd9Sstevel@tonic-gate 		return (errno);
7657c478bd9Sstevel@tonic-gate 	}
7667c478bd9Sstevel@tonic-gate 
7677c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
7687c478bd9Sstevel@tonic-gate 	    "__rsm_putv: exit\n"));
7697c478bd9Sstevel@tonic-gate 
7707c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
7717c478bd9Sstevel@tonic-gate }
7727c478bd9Sstevel@tonic-gate 
7737c478bd9Sstevel@tonic-gate 	/*
7747c478bd9Sstevel@tonic-gate 	 * import side memory segment operations (barriers):
7757c478bd9Sstevel@tonic-gate 	 */
7767c478bd9Sstevel@tonic-gate static int
7777c478bd9Sstevel@tonic-gate __rsm_memseg_import_init_barrier(rsm_memseg_import_handle_t im_memseg,
7787c478bd9Sstevel@tonic-gate     rsm_barrier_type_t type,
7797c478bd9Sstevel@tonic-gate     rsm_barrier_handle_t barrier)
7807c478bd9Sstevel@tonic-gate {
7817c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg = (rsmseg_handle_t *)im_memseg;
7827c478bd9Sstevel@tonic-gate 	rsmgenbar_handle_t *bar = (rsmgenbar_handle_t *)barrier;
7837c478bd9Sstevel@tonic-gate 
7847c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
7857c478bd9Sstevel@tonic-gate 	    ""
7867c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_init_barrier: enter\n"));
7877c478bd9Sstevel@tonic-gate 
7887c478bd9Sstevel@tonic-gate 	type = type;
7897c478bd9Sstevel@tonic-gate 
7907c478bd9Sstevel@tonic-gate 	if (!seg) {
7917c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
7927c478bd9Sstevel@tonic-gate 		    "invalid segment handle\n"));
7937c478bd9Sstevel@tonic-gate 		return (RSMERR_BAD_SEG_HNDL);
7947c478bd9Sstevel@tonic-gate 	}
7957c478bd9Sstevel@tonic-gate 	if (!bar) {
7967c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
7977c478bd9Sstevel@tonic-gate 		    "invalid barrier handle\n"));
7987c478bd9Sstevel@tonic-gate 		return (RSMERR_BAD_BARRIER_PTR);
7997c478bd9Sstevel@tonic-gate 	}
8007c478bd9Sstevel@tonic-gate 
8017c478bd9Sstevel@tonic-gate 	/* XXX: fix later. We only support span-of-node barriers */
8027c478bd9Sstevel@tonic-gate 
8037c478bd9Sstevel@tonic-gate 	bar->rsmgenbar_data = (rsm_barrier_t *)malloc(sizeof (rsm_barrier_t));
8047c478bd9Sstevel@tonic-gate 	if (bar->rsmgenbar_data == NULL) {
8057c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8067c478bd9Sstevel@tonic-gate 		    "not enough memory\n"));
8077c478bd9Sstevel@tonic-gate 		return (RSMERR_INSUFFICIENT_MEM);
8087c478bd9Sstevel@tonic-gate 	}
8097c478bd9Sstevel@tonic-gate 	bar->rsmgenbar_seg = seg;
8107c478bd9Sstevel@tonic-gate 
8117c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
8127c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_init_barrier: exit\n"));
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
8157c478bd9Sstevel@tonic-gate }
8167c478bd9Sstevel@tonic-gate 
8177c478bd9Sstevel@tonic-gate static int
8187c478bd9Sstevel@tonic-gate __rsm_memseg_import_open_barrier(rsm_barrier_handle_t barrier)
8197c478bd9Sstevel@tonic-gate {
8207c478bd9Sstevel@tonic-gate 	rsmgenbar_handle_t *bar = (rsmgenbar_handle_t *)barrier;
8217c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg;
8227c478bd9Sstevel@tonic-gate 	rsm_ioctlmsg_t msg;
8237c478bd9Sstevel@tonic-gate 
8247c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
8257c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_open_barrier: enter\n"));
8267c478bd9Sstevel@tonic-gate 
8277c478bd9Sstevel@tonic-gate 	if (!bar) {
8287c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8297c478bd9Sstevel@tonic-gate 		    "invalid barrier pointer\n"));
8307c478bd9Sstevel@tonic-gate 		return (RSMERR_BAD_BARRIER_PTR);
8317c478bd9Sstevel@tonic-gate 	}
8327c478bd9Sstevel@tonic-gate 
8337c478bd9Sstevel@tonic-gate 	if ((seg = bar->rsmgenbar_seg) == 0) {
8347c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8357c478bd9Sstevel@tonic-gate 		    "uninitialized barrier\n"));
8367c478bd9Sstevel@tonic-gate 		return (RSMERR_BARRIER_UNINITIALIZED);
8377c478bd9Sstevel@tonic-gate 	}
8387c478bd9Sstevel@tonic-gate 
8397c478bd9Sstevel@tonic-gate /* lint -save -e718 -e746 */
8407c478bd9Sstevel@tonic-gate 	msg.bar = *(bar->rsmgenbar_data);
8417c478bd9Sstevel@tonic-gate 	if (ioctl(seg->rsmseg_fd,
8427c478bd9Sstevel@tonic-gate 	    RSM_IOCTL_BAR_OPEN, &msg) < 0) {
8437c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8447c478bd9Sstevel@tonic-gate 		    " RSM_IOCTL_BAR_OPEN failed\n"));
8457c478bd9Sstevel@tonic-gate /* lint -restore */
8467c478bd9Sstevel@tonic-gate 		return (RSMERR_BARRIER_OPEN_FAILED);
8477c478bd9Sstevel@tonic-gate 	}
8487c478bd9Sstevel@tonic-gate 
8497c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
8507c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_open_barrier: exit\n"));
8517c478bd9Sstevel@tonic-gate 
8527c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
8537c478bd9Sstevel@tonic-gate }
8547c478bd9Sstevel@tonic-gate 
8557c478bd9Sstevel@tonic-gate static int
8567c478bd9Sstevel@tonic-gate __rsm_memseg_import_order_barrier(rsm_barrier_handle_t barrier)
8577c478bd9Sstevel@tonic-gate {
8587c478bd9Sstevel@tonic-gate 	rsmgenbar_handle_t *bar = (rsmgenbar_handle_t *)barrier;
8597c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg;
8607c478bd9Sstevel@tonic-gate 	rsm_ioctlmsg_t msg;
8617c478bd9Sstevel@tonic-gate 
8627c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
8637c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_order_barrier: enter\n"));
8647c478bd9Sstevel@tonic-gate 
8657c478bd9Sstevel@tonic-gate 	if (!bar) {
8667c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8677c478bd9Sstevel@tonic-gate 		    "invalid barrier\n"));
8687c478bd9Sstevel@tonic-gate 		return (RSMERR_BAD_BARRIER_PTR);
8697c478bd9Sstevel@tonic-gate 	}
8707c478bd9Sstevel@tonic-gate 	if ((seg = bar->rsmgenbar_seg) == 0) {
8717c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8727c478bd9Sstevel@tonic-gate 		    "uninitialized barrier\n"));
8737c478bd9Sstevel@tonic-gate 		return (RSMERR_BARRIER_UNINITIALIZED);
8747c478bd9Sstevel@tonic-gate 	}
8757c478bd9Sstevel@tonic-gate 
8767c478bd9Sstevel@tonic-gate 	msg.bar = *(bar->rsmgenbar_data);
8777c478bd9Sstevel@tonic-gate 	if (ioctl(seg->rsmseg_fd, RSM_IOCTL_BAR_ORDER, &msg) < 0) {
8787c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
8797c478bd9Sstevel@tonic-gate 		    "RSM_IOCTL_BAR_ORDER failed\n"));
8807c478bd9Sstevel@tonic-gate 		return (RSMERR_BARRIER_FAILURE);
8817c478bd9Sstevel@tonic-gate 	}
8827c478bd9Sstevel@tonic-gate 
8837c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
8847c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_order_barrier: exit\n"));
8857c478bd9Sstevel@tonic-gate 
8867c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
8877c478bd9Sstevel@tonic-gate }
8887c478bd9Sstevel@tonic-gate 
8897c478bd9Sstevel@tonic-gate static int
8907c478bd9Sstevel@tonic-gate __rsm_memseg_import_close_barrier(rsm_barrier_handle_t barrier)
8917c478bd9Sstevel@tonic-gate {
8927c478bd9Sstevel@tonic-gate 	rsmgenbar_handle_t *bar = (rsmgenbar_handle_t *)barrier;
8937c478bd9Sstevel@tonic-gate 	rsmseg_handle_t *seg;
8947c478bd9Sstevel@tonic-gate 	rsm_ioctlmsg_t msg;
8957c478bd9Sstevel@tonic-gate 
8967c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
8977c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_close_barrier: enter\n"));
8987c478bd9Sstevel@tonic-gate 
8997c478bd9Sstevel@tonic-gate 	if (!bar) {
9007c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
9017c478bd9Sstevel@tonic-gate 		    "invalid barrier\n"));
9027c478bd9Sstevel@tonic-gate 		return (RSMERR_BAD_BARRIER_PTR);
9037c478bd9Sstevel@tonic-gate 	}
9047c478bd9Sstevel@tonic-gate 	if ((seg = bar->rsmgenbar_seg) == 0) {
9057c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
9067c478bd9Sstevel@tonic-gate 		    "uninitialized barrier\n"));
9077c478bd9Sstevel@tonic-gate 		return (RSMERR_BARRIER_UNINITIALIZED);
9087c478bd9Sstevel@tonic-gate 	}
9097c478bd9Sstevel@tonic-gate 
9107c478bd9Sstevel@tonic-gate 	msg.bar = *(bar->rsmgenbar_data);
9117c478bd9Sstevel@tonic-gate 	if (ioctl(seg->rsmseg_fd, RSM_IOCTL_BAR_CLOSE, &msg) < 0) {
9127c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
9137c478bd9Sstevel@tonic-gate 		    " RSM_IOCTL_BAR_CLOSE failed\n"));
9147c478bd9Sstevel@tonic-gate 		return (RSMERR_BARRIER_FAILURE);
9157c478bd9Sstevel@tonic-gate 	}
9167c478bd9Sstevel@tonic-gate 
9177c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9187c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_close_barrier: exit\n"));
9197c478bd9Sstevel@tonic-gate 
9207c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
9217c478bd9Sstevel@tonic-gate }
9227c478bd9Sstevel@tonic-gate 
9237c478bd9Sstevel@tonic-gate static int
9247c478bd9Sstevel@tonic-gate __rsm_memseg_import_destroy_barrier(rsm_barrier_handle_t barrier)
9257c478bd9Sstevel@tonic-gate {
9267c478bd9Sstevel@tonic-gate 	rsmgenbar_handle_t *bar = (rsmgenbar_handle_t *)barrier;
9277c478bd9Sstevel@tonic-gate 
9287c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9297c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_destroy_barrier: enter\n"));
9307c478bd9Sstevel@tonic-gate 
9317c478bd9Sstevel@tonic-gate 	if (!bar) {
9327c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
9337c478bd9Sstevel@tonic-gate 		    "invalid barrier\n"));
9347c478bd9Sstevel@tonic-gate 		return (RSMERR_BAD_BARRIER_PTR);
9357c478bd9Sstevel@tonic-gate 	}
9367c478bd9Sstevel@tonic-gate 
9377c478bd9Sstevel@tonic-gate 	free((void *) bar->rsmgenbar_data);
9387c478bd9Sstevel@tonic-gate 
9397c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9407c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_destroy_barrier: exit\n"));
9417c478bd9Sstevel@tonic-gate 
9427c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
9437c478bd9Sstevel@tonic-gate }
9447c478bd9Sstevel@tonic-gate 
9457c478bd9Sstevel@tonic-gate /* lint -w1 */
9467c478bd9Sstevel@tonic-gate static int
9477c478bd9Sstevel@tonic-gate __rsm_memseg_import_get_mode(rsm_memseg_import_handle_t im_memseg,
9487c478bd9Sstevel@tonic-gate     rsm_barrier_mode_t *mode)
9497c478bd9Sstevel@tonic-gate {
9507c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9517c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_get_mode: enter\n"));
9527c478bd9Sstevel@tonic-gate 
9537c478bd9Sstevel@tonic-gate 	im_memseg = im_memseg; mode = mode;
9547c478bd9Sstevel@tonic-gate 
9557c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9567c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_get_mode: exit\n"));
9577c478bd9Sstevel@tonic-gate 
9587c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
9597c478bd9Sstevel@tonic-gate }
9607c478bd9Sstevel@tonic-gate static int
9617c478bd9Sstevel@tonic-gate __rsm_memseg_import_set_mode(rsm_memseg_import_handle_t im_memseg,
9627c478bd9Sstevel@tonic-gate 				rsm_barrier_mode_t mode)
9637c478bd9Sstevel@tonic-gate {
9647c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9657c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_set_mode: enter\n"));
9667c478bd9Sstevel@tonic-gate 
9677c478bd9Sstevel@tonic-gate 	im_memseg = im_memseg; mode = mode;
9687c478bd9Sstevel@tonic-gate 
9697c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9707c478bd9Sstevel@tonic-gate 	    "__rsm_memseg_import_set_mode: exit\n"));
9717c478bd9Sstevel@tonic-gate 
9727c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
9737c478bd9Sstevel@tonic-gate }
9747c478bd9Sstevel@tonic-gate 
9757c478bd9Sstevel@tonic-gate static int
9767c478bd9Sstevel@tonic-gate __rsm_create_memory_handle(rsmapi_controller_handle_t controller,
9777c478bd9Sstevel@tonic-gate     rsm_localmemory_handle_t *local_hndl_p,
9787c478bd9Sstevel@tonic-gate     caddr_t local_va, size_t len)
9797c478bd9Sstevel@tonic-gate {
9807c478bd9Sstevel@tonic-gate 	rsm_memseg_export_handle_t memseg;
9817c478bd9Sstevel@tonic-gate 	rsmapi_access_entry_t	acl[1];
9827c478bd9Sstevel@tonic-gate 	rsm_memseg_id_t segid = 0;
9837c478bd9Sstevel@tonic-gate 	size_t size;
9847c478bd9Sstevel@tonic-gate 	int e;
9857c478bd9Sstevel@tonic-gate 
9867c478bd9Sstevel@tonic-gate 
9877c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
9887c478bd9Sstevel@tonic-gate 	    "__rsm_create_memory_handle: enter\n"));
9897c478bd9Sstevel@tonic-gate 
9907c478bd9Sstevel@tonic-gate 	/*
9917c478bd9Sstevel@tonic-gate 	 * create a surrogate segment (local memory will be locked down).
9927c478bd9Sstevel@tonic-gate 	 */
9937c478bd9Sstevel@tonic-gate 	size =  roundup(len, PAGESIZE);
9947c478bd9Sstevel@tonic-gate 	e = rsm_memseg_export_create(controller, &memseg,
9957c478bd9Sstevel@tonic-gate 	    (void *)local_va, size,
9967c478bd9Sstevel@tonic-gate 	    RSM_ALLOW_REBIND);
9977c478bd9Sstevel@tonic-gate 	if (e != RSM_SUCCESS) {
9987c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
9997c478bd9Sstevel@tonic-gate 		    "export create failed\n"));
10007c478bd9Sstevel@tonic-gate 		return (e);
10017c478bd9Sstevel@tonic-gate 	}
10027c478bd9Sstevel@tonic-gate 
10037c478bd9Sstevel@tonic-gate 	/*
10047c478bd9Sstevel@tonic-gate 	 * Publish the segment to the local node only.  If the segment
10057c478bd9Sstevel@tonic-gate 	 * length is very large then don't publish to the adapter driver
10067c478bd9Sstevel@tonic-gate 	 * because that will consume too much DVMA space - this is indicated
10077c478bd9Sstevel@tonic-gate 	 * to the Kernel Agent using null permissions.  DVMA binding will
10087c478bd9Sstevel@tonic-gate 	 * be done when the RDMA is set up.
10097c478bd9Sstevel@tonic-gate 	 */
10107c478bd9Sstevel@tonic-gate 	acl[0].ae_node = rsm_local_nodeid;
10117c478bd9Sstevel@tonic-gate 	if (len > RSM_MAX_HANDLE_DVMA)
10127c478bd9Sstevel@tonic-gate 		acl[0].ae_permission = 0;
10137c478bd9Sstevel@tonic-gate 	else
10147c478bd9Sstevel@tonic-gate 		acl[0].ae_permission = RSM_PERM_RDWR;
10157c478bd9Sstevel@tonic-gate 
10167c478bd9Sstevel@tonic-gate 	e = rsm_memseg_export_publish(memseg, &segid, acl, 1);
10177c478bd9Sstevel@tonic-gate 	if (e != RSM_SUCCESS) {
10187c478bd9Sstevel@tonic-gate 		DBPRINTF((RSM_LIBRARY, RSM_ERR,
10197c478bd9Sstevel@tonic-gate 		    "export publish failed\n"));
10207c478bd9Sstevel@tonic-gate 		rsm_memseg_export_destroy(memseg);
10217c478bd9Sstevel@tonic-gate 		return (e);
10227c478bd9Sstevel@tonic-gate 	}
10237c478bd9Sstevel@tonic-gate 
10247c478bd9Sstevel@tonic-gate 	/* Use the surrogate seghandle as the local memory handle */
10257c478bd9Sstevel@tonic-gate 	*local_hndl_p = (rsm_localmemory_handle_t)memseg;
10267c478bd9Sstevel@tonic-gate 
10277c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10287c478bd9Sstevel@tonic-gate 	    "__rsm_create_memory_handle: exit\n"));
10297c478bd9Sstevel@tonic-gate 
10307c478bd9Sstevel@tonic-gate 	return (e);
10317c478bd9Sstevel@tonic-gate }
10327c478bd9Sstevel@tonic-gate 
10337c478bd9Sstevel@tonic-gate static int
10347c478bd9Sstevel@tonic-gate __rsm_free_memory_handle(rsm_localmemory_handle_t local_handle)
10357c478bd9Sstevel@tonic-gate {
10367c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10377c478bd9Sstevel@tonic-gate 	    "__rsm_free_memory_handle: enter\n"));
10387c478bd9Sstevel@tonic-gate 
10397c478bd9Sstevel@tonic-gate 	rsm_memseg_export_destroy((rsm_memseg_export_handle_t)local_handle);
10407c478bd9Sstevel@tonic-gate 
10417c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10427c478bd9Sstevel@tonic-gate 	    "__rsm_free_memory_handle: exit\n"));
10437c478bd9Sstevel@tonic-gate 
10447c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
10457c478bd9Sstevel@tonic-gate }
10467c478bd9Sstevel@tonic-gate 
10477c478bd9Sstevel@tonic-gate static int
10487c478bd9Sstevel@tonic-gate __rsm_get_lib_attr(rsm_ndlib_attr_t **libattrp)
10497c478bd9Sstevel@tonic-gate {
10507c478bd9Sstevel@tonic-gate 
10517c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10527c478bd9Sstevel@tonic-gate 	    "__rsm_get_lib_attr: enter\n"));
10537c478bd9Sstevel@tonic-gate 
10547c478bd9Sstevel@tonic-gate 	*libattrp = &_rsm_genlib_attr;
10557c478bd9Sstevel@tonic-gate 
10567c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10577c478bd9Sstevel@tonic-gate 	    "__rsm_get_lib_attr: exit\n"));
10587c478bd9Sstevel@tonic-gate 
10597c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
10607c478bd9Sstevel@tonic-gate }
10617c478bd9Sstevel@tonic-gate 
10627c478bd9Sstevel@tonic-gate static int
10637c478bd9Sstevel@tonic-gate __rsm_closedevice(rsmapi_controller_handle_t cntr_handle)
10647c478bd9Sstevel@tonic-gate {
10657c478bd9Sstevel@tonic-gate 
10667c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10677c478bd9Sstevel@tonic-gate 	    "__rsm_closedevice: enter\n"));
10687c478bd9Sstevel@tonic-gate 
10697c478bd9Sstevel@tonic-gate 	cntr_handle = cntr_handle;
10707c478bd9Sstevel@tonic-gate 
10717c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10727c478bd9Sstevel@tonic-gate 	    "__rsm_closedevice: exit\n"));
10737c478bd9Sstevel@tonic-gate 
10747c478bd9Sstevel@tonic-gate 	return (RSM_SUCCESS);
10757c478bd9Sstevel@tonic-gate }
10767c478bd9Sstevel@tonic-gate 
10777c478bd9Sstevel@tonic-gate void
10787c478bd9Sstevel@tonic-gate __rsmdefault_setops(rsm_segops_t *segops)
10797c478bd9Sstevel@tonic-gate {
10807c478bd9Sstevel@tonic-gate 
10817c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
10827c478bd9Sstevel@tonic-gate 	    "__rsmdefault_setops: enter\n"));
10837c478bd9Sstevel@tonic-gate 
10847c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_connect == NULL) {
10857c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_connect = __rsm_import_connect;
10867c478bd9Sstevel@tonic-gate 	}
10877c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_disconnect == NULL) {
10887c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_disconnect = __rsm_import_disconnect;
10897c478bd9Sstevel@tonic-gate 	}
10907c478bd9Sstevel@tonic-gate 
10917c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_get8 == NULL) {
10927c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_get8 = __rsm_get8x8;
10937c478bd9Sstevel@tonic-gate 	}
10947c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_get16 == NULL) {
10957c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_get16 = __rsm_get16x16;
10967c478bd9Sstevel@tonic-gate 	}
10977c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_get32 == NULL) {
10987c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_get32 = __rsm_get32x32;
10997c478bd9Sstevel@tonic-gate 	}
11007c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_get64 == NULL) {
11017c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_get64 = __rsm_get64x64;
11027c478bd9Sstevel@tonic-gate 	}
11037c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_get == NULL) {
11047c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_get = __rsm_get;
11057c478bd9Sstevel@tonic-gate 	}
11067c478bd9Sstevel@tonic-gate 
11077c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_put8 == NULL) {
11087c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_put8 = __rsm_put8x8;
11097c478bd9Sstevel@tonic-gate 	}
11107c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_put16 == NULL) {
11117c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_put16 = __rsm_put16x16;
11127c478bd9Sstevel@tonic-gate 	}
11137c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_put32 == NULL) {
11147c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_put32 = __rsm_put32x32;
11157c478bd9Sstevel@tonic-gate 	}
11167c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_put64 == NULL) {
11177c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_put64 = __rsm_put64x64;
11187c478bd9Sstevel@tonic-gate 	}
11197c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_put == NULL) {
11207c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_put = __rsm_put;
11217c478bd9Sstevel@tonic-gate 	}
11227c478bd9Sstevel@tonic-gate 
11237c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_putv == NULL) {
11247c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_putv = __rsm_putv;
11257c478bd9Sstevel@tonic-gate 	}
11267c478bd9Sstevel@tonic-gate 
11277c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_getv == NULL) {
11287c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_getv = __rsm_getv;
11297c478bd9Sstevel@tonic-gate 	}
11307c478bd9Sstevel@tonic-gate 
11317c478bd9Sstevel@tonic-gate 	if (segops->rsm_create_localmemory_handle == NULL) {
11327c478bd9Sstevel@tonic-gate 		segops->rsm_create_localmemory_handle =
11337c478bd9Sstevel@tonic-gate 		    __rsm_create_memory_handle;
11347c478bd9Sstevel@tonic-gate 	}
11357c478bd9Sstevel@tonic-gate 
11367c478bd9Sstevel@tonic-gate 	if (segops->rsm_free_localmemory_handle == NULL) {
11377c478bd9Sstevel@tonic-gate 		segops->rsm_free_localmemory_handle =
11387c478bd9Sstevel@tonic-gate 		    __rsm_free_memory_handle;
11397c478bd9Sstevel@tonic-gate 	}
11407c478bd9Sstevel@tonic-gate 
11417c478bd9Sstevel@tonic-gate 	/* XXX: Need to support barrier functions */
11427c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_init_barrier == NULL) {
11437c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_init_barrier =
11447c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_init_barrier;
11457c478bd9Sstevel@tonic-gate 	}
11467c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_open_barrier == NULL) {
11477c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_open_barrier =
11487c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_open_barrier;
11497c478bd9Sstevel@tonic-gate 	}
11507c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_order_barrier == NULL) {
11517c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_order_barrier =
11527c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_order_barrier;
11537c478bd9Sstevel@tonic-gate 	}
11547c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_close_barrier == NULL) {
11557c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_close_barrier =
11567c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_close_barrier;
11577c478bd9Sstevel@tonic-gate 	}
11587c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_destroy_barrier == NULL) {
11597c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_destroy_barrier =
11607c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_destroy_barrier;
11617c478bd9Sstevel@tonic-gate 	}
11627c478bd9Sstevel@tonic-gate 
11637c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_get_mode == NULL) {
11647c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_get_mode =
11657c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_get_mode;
11667c478bd9Sstevel@tonic-gate 	}
11677c478bd9Sstevel@tonic-gate 	if (segops->rsm_memseg_import_set_mode == NULL) {
11687c478bd9Sstevel@tonic-gate 		segops->rsm_memseg_import_set_mode =
11697c478bd9Sstevel@tonic-gate 		    __rsm_memseg_import_set_mode;
11707c478bd9Sstevel@tonic-gate 	}
11717c478bd9Sstevel@tonic-gate 
11727c478bd9Sstevel@tonic-gate 	if (segops->rsm_get_lib_attr == NULL) {
11737c478bd9Sstevel@tonic-gate 		segops->rsm_get_lib_attr =
11747c478bd9Sstevel@tonic-gate 		    __rsm_get_lib_attr;
11757c478bd9Sstevel@tonic-gate 	}
11767c478bd9Sstevel@tonic-gate 
11777c478bd9Sstevel@tonic-gate 	if (segops->rsm_closedevice == NULL) {
11787c478bd9Sstevel@tonic-gate 		segops->rsm_closedevice =
11797c478bd9Sstevel@tonic-gate 		    __rsm_closedevice;
11807c478bd9Sstevel@tonic-gate 	}
11817c478bd9Sstevel@tonic-gate 
11827c478bd9Sstevel@tonic-gate 
11837c478bd9Sstevel@tonic-gate 	DBPRINTF((RSM_LIBRARY, RSM_DEBUG_VERBOSE,
11847c478bd9Sstevel@tonic-gate 	    "__rsmdefault_setops: exit\n"));
11857c478bd9Sstevel@tonic-gate 
11867c478bd9Sstevel@tonic-gate }
1187