xref: /illumos-gate/usr/src/uts/common/sys/rsm/rsm_in.h (revision 2d6eb4a5)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _RSM_IN_H
28*7c478bd9Sstevel@tonic-gate #define	_RSM_IN_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
31*7c478bd9Sstevel@tonic-gate extern "C" {
32*7c478bd9Sstevel@tonic-gate #endif
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/rsm/rsm.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/rsm/rsmpi.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #define	DRIVER_NAME	"rsm"
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #define	RSM_DRIVER_MINOR	0
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #define	RSM_CNUM	8
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #define	RSMIPC_SZ	10	/* number of outstanding requests, max: 256 */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #define	RSMIPC_MAX_MESSAGES	64 /* max msgs that receiver can buffer */
49*7c478bd9Sstevel@tonic-gate #define	RSMIPC_LOTSFREE_MSGBUFS	16 /* chunks of credits sent to sender  */
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /*
52*7c478bd9Sstevel@tonic-gate  * The base for Sun RSMAPI Kernel Agent service idenitifiers is RSM_INTR_T_KA
53*7c478bd9Sstevel@tonic-gate  * as defined below. This is as per the RSMPI specification. Thus,
54*7c478bd9Sstevel@tonic-gate  * in the kernel agent, we need to use this value as the service identifier
55*7c478bd9Sstevel@tonic-gate  * while registering the service handlers.
56*7c478bd9Sstevel@tonic-gate  */
57*7c478bd9Sstevel@tonic-gate #define	RSM_INTR_T_KA	0x88
58*7c478bd9Sstevel@tonic-gate #define	RSM_SERVICE	RSM_INTR_T_KA
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate #define	RSM_PRI		2
61*7c478bd9Sstevel@tonic-gate #define	RSM_QUEUE_SZ	256
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate #define	RSM_LOCK	0
64*7c478bd9Sstevel@tonic-gate #define	RSM_NOLOCK	1
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate #define	RSM_MAX_NUM_SEG	4095	/* default value for max imp and exp segs */
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	RSM_MAX_NODE	64	/* maximum number of nodes in the cluster */
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate #define	RSM_MAX_CTRL	32	/* maximum number of controllers per node */
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate  * The following defines UINT_MAX rounded down to a page aligned value.
74*7c478bd9Sstevel@tonic-gate  */
75*7c478bd9Sstevel@tonic-gate #define	RSM_MAXSZ_PAGE_ALIGNED (UINT_MAX & PAGEMASK)
76*7c478bd9Sstevel@tonic-gate /*
77*7c478bd9Sstevel@tonic-gate  * Define TRASHSIZE as the maximum possible size which is page aligned
78*7c478bd9Sstevel@tonic-gate  * This value cannot be 0xffffffffffffe000 since this is taken as a
79*7c478bd9Sstevel@tonic-gate  * negative value in the devmap_umem_remap call, thus causing the call
80*7c478bd9Sstevel@tonic-gate  * to fail.
81*7c478bd9Sstevel@tonic-gate  */
82*7c478bd9Sstevel@tonic-gate #define	TRASHSIZE 0x7fffffffffffe000
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate #define	RSM_ACCESS_READ				0444
85*7c478bd9Sstevel@tonic-gate #define	RSM_ACCESS_WRITE			0222
86*7c478bd9Sstevel@tonic-gate #define	RSM_ACCESS_TRUSTED			0666
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate /* flag values for rsmseg_unload */
89*7c478bd9Sstevel@tonic-gate #define	DISCONNECT	1
90*7c478bd9Sstevel@tonic-gate #define	NO_DISCONNECT	0
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate struct rsm_driver_data {
93*7c478bd9Sstevel@tonic-gate 	kmutex_t	drv_lock;
94*7c478bd9Sstevel@tonic-gate 	kcondvar_t	drv_cv;
95*7c478bd9Sstevel@tonic-gate 	int		drv_state;	/* RSM_DRV_YYYY states */
96*7c478bd9Sstevel@tonic-gate 	int		drv_memdel_cnt; /* number of memdel callbacks */
97*7c478bd9Sstevel@tonic-gate };
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate /* rsm driver state */
100*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_NEW			0
101*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_OK			1
102*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_PREDEL_STARTED		2
103*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_PREDEL_COMPLETED	3
104*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_POSTDEL_IN_PROGRESS	4
105*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_DR_IN_PROGRESS		5
106*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_REG_PROCESSING		6
107*7c478bd9Sstevel@tonic-gate #define	RSM_DRV_UNREG_PROCESSING	7
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /* internal flags */
110*7c478bd9Sstevel@tonic-gate #define	RSM_DR_QUIESCE		0
111*7c478bd9Sstevel@tonic-gate #define	RSM_DR_UNQUIESCE	1
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate typedef enum {
114*7c478bd9Sstevel@tonic-gate 	RSM_STATE_NEW = 0,
115*7c478bd9Sstevel@tonic-gate 	RSM_STATE_NEW_QUIESCED,
116*7c478bd9Sstevel@tonic-gate 	RSM_STATE_BIND,
117*7c478bd9Sstevel@tonic-gate 	RSM_STATE_BIND_QUIESCED,
118*7c478bd9Sstevel@tonic-gate 	RSM_STATE_EXPORT,
119*7c478bd9Sstevel@tonic-gate 	RSM_STATE_EXPORT_QUIESCING,
120*7c478bd9Sstevel@tonic-gate 	RSM_STATE_EXPORT_QUIESCED,
121*7c478bd9Sstevel@tonic-gate 	RSM_STATE_ZOMBIE,
122*7c478bd9Sstevel@tonic-gate 	RSM_STATE_CONNECTING,
123*7c478bd9Sstevel@tonic-gate 	RSM_STATE_ABORT_CONNECT,
124*7c478bd9Sstevel@tonic-gate 	RSM_STATE_CONNECT,
125*7c478bd9Sstevel@tonic-gate 	RSM_STATE_CONN_QUIESCE,
126*7c478bd9Sstevel@tonic-gate 	RSM_STATE_MAPPING,
127*7c478bd9Sstevel@tonic-gate 	RSM_STATE_ACTIVE,
128*7c478bd9Sstevel@tonic-gate 	RSM_STATE_MAP_QUIESCE,
129*7c478bd9Sstevel@tonic-gate 	RSM_STATE_DISCONNECT,
130*7c478bd9Sstevel@tonic-gate 	RSM_STATE_END
131*7c478bd9Sstevel@tonic-gate } rsm_resource_state_t;
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate typedef enum {
134*7c478bd9Sstevel@tonic-gate 	RSM_RESOURCE_EXPORT_SEGMENT,
135*7c478bd9Sstevel@tonic-gate 	RSM_RESOURCE_IMPORT_SEGMENT,
136*7c478bd9Sstevel@tonic-gate 	RSM_RESOURCE_BAR
137*7c478bd9Sstevel@tonic-gate }rsm_resource_type_t;
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate /*
140*7c478bd9Sstevel@tonic-gate  * All resources have the only common info. whether it is a segment or
141*7c478bd9Sstevel@tonic-gate  * a notification queue.
142*7c478bd9Sstevel@tonic-gate  */
143*7c478bd9Sstevel@tonic-gate typedef struct rsm_resource {
144*7c478bd9Sstevel@tonic-gate 	kmutex_t		rsmrc_lock;	/* sync on resource */
145*7c478bd9Sstevel@tonic-gate 	minor_t			rsmrc_num;	/* (minor) number */
146*7c478bd9Sstevel@tonic-gate 	rsm_memseg_id_t		rsmrc_key;	/* user key */
147*7c478bd9Sstevel@tonic-gate 	mode_t			rsmrc_mode;	/* access permission */
148*7c478bd9Sstevel@tonic-gate 	struct adapter		*rsmrc_adapter;	/* controller number */
149*7c478bd9Sstevel@tonic-gate 	rsm_node_id_t		rsmrc_node;	/*  nodeid */
150*7c478bd9Sstevel@tonic-gate 	rsm_resource_type_t	rsmrc_type;	/* type of this resource */
151*7c478bd9Sstevel@tonic-gate 	rsm_resource_state_t	rsmrc_state;	/* segment state */
152*7c478bd9Sstevel@tonic-gate 	struct rsm_resource	*rsmrc_next;
153*7c478bd9Sstevel@tonic-gate } rsmresource_t;
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #define	RSMRC_BLKSZ	16
156*7c478bd9Sstevel@tonic-gate #define	RSMRC_RESERVED	((rsmresource_t *)0x1)
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate #define	RSM_HASHSZ	128
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate #define	RSM_USER_MEMORY		0x1
161*7c478bd9Sstevel@tonic-gate #define	RSM_KERNEL_MEMORY	0x2
162*7c478bd9Sstevel@tonic-gate #define	RSM_EXPORT_WAIT		0x4
163*7c478bd9Sstevel@tonic-gate #define	RSM_SEGMENT_POLL	0x8
164*7c478bd9Sstevel@tonic-gate #define	RSM_FORCE_DISCONNECT	0x10
165*7c478bd9Sstevel@tonic-gate #define	RSM_IMPORT_DUMMY	0x20
166*7c478bd9Sstevel@tonic-gate /*
167*7c478bd9Sstevel@tonic-gate  * The following macro is used within the kernel agent to indicate that
168*7c478bd9Sstevel@tonic-gate  * rebind/unbind is allowed for an exported segment. It is a part of the
169*7c478bd9Sstevel@tonic-gate  * segment's s_flags field.
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate #define	RSMKA_ALLOW_UNBIND_REBIND	0x40
172*7c478bd9Sstevel@tonic-gate #define	RSM_REPUBLISH_WAIT	0x80
173*7c478bd9Sstevel@tonic-gate #define	RSM_DR_INPROGRESS	0x100
174*7c478bd9Sstevel@tonic-gate #define	RSM_FORCE_DESTROY_WAIT	0x200
175*7c478bd9Sstevel@tonic-gate #define	RSMKA_SET_RESOURCE_DONTWAIT	0x400
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate #define	RSMRC_LOCK(p)	mutex_enter(&(p)->rsmrc_lock)
178*7c478bd9Sstevel@tonic-gate #define	RSMRC_UNLOCK(p)	mutex_exit(&(p)->rsmrc_lock)
179*7c478bd9Sstevel@tonic-gate #define	RSMRC_HELD(p)	MUTEX_HELD(&(p)->rsmrc_lock)
180*7c478bd9Sstevel@tonic-gate #define	RSMRC_TRY(p)	mutex_tryenter(&(p)->rsmrc_lock)
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate typedef struct rsm_region {
183*7c478bd9Sstevel@tonic-gate 	caddr_t		r_vaddr;	/* exported virtual address */
184*7c478bd9Sstevel@tonic-gate 	size_t		r_len;		/* length of export region */
185*7c478bd9Sstevel@tonic-gate 	offset_t	r_off;		/* offset of this region in segment */
186*7c478bd9Sstevel@tonic-gate 	struct as	*r_asp;
187*7c478bd9Sstevel@tonic-gate 	struct rsm_region *r_next;	/* next region of segment */
188*7c478bd9Sstevel@tonic-gate }rsm_region;
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate typedef struct rsm_cookie {
191*7c478bd9Sstevel@tonic-gate 	devmap_cookie_t		c_dhp;		/* devmap cookie handle */
192*7c478bd9Sstevel@tonic-gate 	offset_t		c_off;		/* offset of mapping	*/
193*7c478bd9Sstevel@tonic-gate 	size_t			c_len;		/* len of mapping	*/
194*7c478bd9Sstevel@tonic-gate 	struct rsm_cookie	*c_next;	/* next handle		*/
195*7c478bd9Sstevel@tonic-gate }rsmcookie_t;
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate typedef struct rsm_mapinfo {
198*7c478bd9Sstevel@tonic-gate 	dev_info_t	*dip;
199*7c478bd9Sstevel@tonic-gate 	uint_t		dev_register;
200*7c478bd9Sstevel@tonic-gate 	off_t		dev_offset;
201*7c478bd9Sstevel@tonic-gate 	off_t		start_offset;
202*7c478bd9Sstevel@tonic-gate 	size_t		individual_len;
203*7c478bd9Sstevel@tonic-gate 	struct rsm_mapinfo *next;
204*7c478bd9Sstevel@tonic-gate } rsm_mapinfo_t;
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate /*
209*7c478bd9Sstevel@tonic-gate  * Shared Importer data structure
210*7c478bd9Sstevel@tonic-gate  *
211*7c478bd9Sstevel@tonic-gate  */
212*7c478bd9Sstevel@tonic-gate typedef struct rsm_import_share {
213*7c478bd9Sstevel@tonic-gate 	kmutex_t	rsmsi_lock;	/* lock for shared importers	*/
214*7c478bd9Sstevel@tonic-gate 	kcondvar_t	rsmsi_cv;	/* condvar to wait at		*/
215*7c478bd9Sstevel@tonic-gate 	rsm_node_id_t	rsmsi_node;
216*7c478bd9Sstevel@tonic-gate 	rsm_memseg_id_t	rsmsi_segid;
217*7c478bd9Sstevel@tonic-gate 	size_t		rsmsi_seglen;
218*7c478bd9Sstevel@tonic-gate 	rsm_memseg_import_handle_t	rsmsi_handle; /* RSMPI handle */
219*7c478bd9Sstevel@tonic-gate 	uint_t		rsmsi_state;
220*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_NEW			0x0001
221*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_CONNECTING		0x0002
222*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_ABORT_CONNECT	0x0004
223*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_CONNECTED		0x0008
224*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_CONN_QUIESCE	0x0010
225*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_MAPPED		0x0020
226*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_MAP_QUIESCE		0x0040
227*7c478bd9Sstevel@tonic-gate #define	RSMSI_STATE_DISCONNECTED	0x0080
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate 	uint_t		rsmsi_refcnt;	/* ref count of importers	*/
230*7c478bd9Sstevel@tonic-gate 	uint_t		rsmsi_mapcnt;	/* count of mapped importers	*/
231*7c478bd9Sstevel@tonic-gate 	mode_t		rsmsi_mode;	/* mode of last (re)publish	*/
232*7c478bd9Sstevel@tonic-gate 	uid_t		rsmsi_uid;
233*7c478bd9Sstevel@tonic-gate 	gid_t		rsmsi_gid;
234*7c478bd9Sstevel@tonic-gate 	rsm_mapinfo_t	*rsmsi_mapinfo;	/* register, offset, len values */
235*7c478bd9Sstevel@tonic-gate 	uint_t		rsmsi_flags;	/* flags			*/
236*7c478bd9Sstevel@tonic-gate #define	RSMSI_FLAGS_ABORTDONE	0x0001	/* NOT_IMPORTING msg for abort conn */
237*7c478bd9Sstevel@tonic-gate 					/* has been sent		    */
238*7c478bd9Sstevel@tonic-gate 	void		*rsmsi_cookie;	/* cookie of the first seg connect */
239*7c478bd9Sstevel@tonic-gate } rsm_import_share_t;
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate #define	RSMSI_LOCK(sharep)	mutex_enter(&(sharep)->rsmsi_lock)
242*7c478bd9Sstevel@tonic-gate #define	RSMSI_UNLOCK(sharep)	mutex_exit(&(sharep)->rsmsi_lock)
243*7c478bd9Sstevel@tonic-gate #define	RSMSI_HELD(sharep)	MUTEX_HELD(&(sharep)->rsmsi_lock)
244*7c478bd9Sstevel@tonic-gate #define	RSMSI_TRY(sharep)	mutex_tryenter(&(sharep)->rsmsi_lock)
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate typedef struct rsm_seginfo {
247*7c478bd9Sstevel@tonic-gate 	rsmresource_t		s_hdr;		/* resource hdr */
248*7c478bd9Sstevel@tonic-gate #define	s_state	s_hdr.rsmrc_state	/* segment state */
249*7c478bd9Sstevel@tonic-gate #define	s_adapter s_hdr.rsmrc_adapter
250*7c478bd9Sstevel@tonic-gate #define	s_node	s_hdr.rsmrc_node
251*7c478bd9Sstevel@tonic-gate #define	s_lock	s_hdr.rsmrc_lock
252*7c478bd9Sstevel@tonic-gate #define	s_minor	s_hdr.rsmrc_num		/* minor # of segment */
253*7c478bd9Sstevel@tonic-gate #define	s_key	s_hdr.rsmrc_key		/* user segment key */
254*7c478bd9Sstevel@tonic-gate #define	s_mode	s_hdr.rsmrc_mode	/* user segment mode */
255*7c478bd9Sstevel@tonic-gate #define	s_type	s_hdr.rsmrc_type	/* segment type */
256*7c478bd9Sstevel@tonic-gate 	uid_t			s_uid;		/* owner id */
257*7c478bd9Sstevel@tonic-gate 	gid_t			s_gid;		/* owner id */
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate 	size_t			s_len;		/* total segment size */
260*7c478bd9Sstevel@tonic-gate 	rsm_region		s_region;	/* regions of segment */
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate 	int			s_flags;
263*7c478bd9Sstevel@tonic-gate 	int			s_pollflag;	/* indicates poll status */
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate 	kcondvar_t		s_cv;		/* condition to wait on */
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate 	rsm_memseg_id_t		s_segid;	/* NIC segment id */
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate 	int		s_acl_len;		/* length of access list */
270*7c478bd9Sstevel@tonic-gate 	rsmapi_access_entry_t *s_acl;		/* access list */
271*7c478bd9Sstevel@tonic-gate 	rsm_access_entry_t *s_acl_in;		/* access list with hwaddr */
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate 	struct pollhead	s_poll;
274*7c478bd9Sstevel@tonic-gate 	uint32_t	s_pollevent;
275*7c478bd9Sstevel@tonic-gate 	pid_t 		s_pid;
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate 	rsmcookie_t	*s_ckl;		/* list of devmap cookie */
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate 	size_t		s_total_maplen;
280*7c478bd9Sstevel@tonic-gate 	rsm_mapinfo_t	*s_mapinfo;	/* register, offset, len  */
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate 	union {
283*7c478bd9Sstevel@tonic-gate 		rsm_memseg_import_handle_t	in;
284*7c478bd9Sstevel@tonic-gate 		rsm_memseg_export_handle_t	out;
285*7c478bd9Sstevel@tonic-gate 	} s_handle;			/* NIC handle for segment */
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate 	/*
288*7c478bd9Sstevel@tonic-gate 	 * This field is used to indicate the cookie returned by the
289*7c478bd9Sstevel@tonic-gate 	 * ddi_umem_lock when binding pages for an export segment.
290*7c478bd9Sstevel@tonic-gate 	 * Also, for importers on the same node as the export segment,
291*7c478bd9Sstevel@tonic-gate 	 * this field indicates the cookie used during import mapping.
292*7c478bd9Sstevel@tonic-gate 	 */
293*7c478bd9Sstevel@tonic-gate 	ddi_umem_cookie_t	s_cookie;
294*7c478bd9Sstevel@tonic-gate 	rsm_import_share_t	*s_share;	/* shared importer data	    */
295*7c478bd9Sstevel@tonic-gate 	/*
296*7c478bd9Sstevel@tonic-gate 	 * This field in an import segments indicates the number of
297*7c478bd9Sstevel@tonic-gate 	 * putv/getv operations in progress and in an export segment
298*7c478bd9Sstevel@tonic-gate 	 * it is the number of putv/getv ops currently using it as
299*7c478bd9Sstevel@tonic-gate 	 * a handle in the iovec.
300*7c478bd9Sstevel@tonic-gate 	 */
301*7c478bd9Sstevel@tonic-gate 	uint_t			s_rdmacnt;
302*7c478bd9Sstevel@tonic-gate 	struct proc		*s_proc;
303*7c478bd9Sstevel@tonic-gate } rsmseg_t;
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate #define	rsmseglock_acquire(p)	RSMRC_LOCK((rsmresource_t *)(p))
306*7c478bd9Sstevel@tonic-gate #define	rsmseglock_release(p)	RSMRC_UNLOCK((rsmresource_t *)(p))
307*7c478bd9Sstevel@tonic-gate #define	rsmseglock_held(p)	RSMRC_HELD((rsmresource_t *)(p))
308*7c478bd9Sstevel@tonic-gate #define	rsmseglock_try(p)	RSMRC_TRY((rsmresource_t *)(p))
309*7c478bd9Sstevel@tonic-gate 
310*7c478bd9Sstevel@tonic-gate #define	rsmsharelock_acquire(p)	RSMSI_LOCK(p->s_share)
311*7c478bd9Sstevel@tonic-gate #define	rsmsharelock_release(p)	RSMSI_UNLOCK(p->s_share)
312*7c478bd9Sstevel@tonic-gate #define	rsmsharelock_held(p)	RSMSI_HELD(p->s_share)
313*7c478bd9Sstevel@tonic-gate #define	rsmsharelock_try(p)	RSMSI_TRY(p->s_share)
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate /*
316*7c478bd9Sstevel@tonic-gate  * Resource elements structure
317*7c478bd9Sstevel@tonic-gate  */
318*7c478bd9Sstevel@tonic-gate typedef struct {
319*7c478bd9Sstevel@tonic-gate 	int		rsmrcblk_avail;
320*7c478bd9Sstevel@tonic-gate 	rsmresource_t	*rsmrcblk_blks[RSMRC_BLKSZ];
321*7c478bd9Sstevel@tonic-gate }rsmresource_blk_t;
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate struct rsmresource_table {
324*7c478bd9Sstevel@tonic-gate 	krwlock_t	rsmrc_lock;
325*7c478bd9Sstevel@tonic-gate 	int		rsmrc_len;
326*7c478bd9Sstevel@tonic-gate 	int		rsmrc_sz;
327*7c478bd9Sstevel@tonic-gate 	rsmresource_blk_t **rsmrc_root;
328*7c478bd9Sstevel@tonic-gate };
329*7c478bd9Sstevel@tonic-gate 
330*7c478bd9Sstevel@tonic-gate /*
331*7c478bd9Sstevel@tonic-gate  * Struct for advertised resource list
332*7c478bd9Sstevel@tonic-gate  */
333*7c478bd9Sstevel@tonic-gate /*
334*7c478bd9Sstevel@tonic-gate  * Hashtable structs
335*7c478bd9Sstevel@tonic-gate  * bucket points to an array of pointers, each entry in the bucket array
336*7c478bd9Sstevel@tonic-gate  * points to a linked list of resource items.
337*7c478bd9Sstevel@tonic-gate  * bucket index = bucket_address%RSM_HASHSZ
338*7c478bd9Sstevel@tonic-gate  */
339*7c478bd9Sstevel@tonic-gate typedef struct rsmhash_table {
340*7c478bd9Sstevel@tonic-gate 	krwlock_t		rsmhash_rw;
341*7c478bd9Sstevel@tonic-gate 	rsmresource_t		**bucket;
342*7c478bd9Sstevel@tonic-gate } rsmhash_table_t;
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate /*
345*7c478bd9Sstevel@tonic-gate  * Remote messaging related structure
346*7c478bd9Sstevel@tonic-gate  */
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate /*
349*7c478bd9Sstevel@tonic-gate  * Flags for ipc slot
350*7c478bd9Sstevel@tonic-gate  */
351*7c478bd9Sstevel@tonic-gate #define	RSMIPC_FREE	0x1			/* slot is free */
352*7c478bd9Sstevel@tonic-gate #define	RSMIPC_PENDING	0x2			/* slot has pending request */
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate #define	RSMIPC_SET(x, v)	((x)->rsmipc_flags |= (v))
355*7c478bd9Sstevel@tonic-gate #define	RSMIPC_GET(x, v)	((x)->rsmipc_flags & (v))
356*7c478bd9Sstevel@tonic-gate #define	RSMIPC_CLEAR(x, v)	((x)->rsmipc_flags &= ~(v))
357*7c478bd9Sstevel@tonic-gate 
358*7c478bd9Sstevel@tonic-gate typedef struct rsmipc_slot {
359*7c478bd9Sstevel@tonic-gate 	kmutex_t 	rsmipc_lock;		/* lock for remote msgs */
360*7c478bd9Sstevel@tonic-gate 	kcondvar_t	rsmipc_cv;		/* condition var to wait on */
361*7c478bd9Sstevel@tonic-gate 	int		rsmipc_flags;
362*7c478bd9Sstevel@tonic-gate 	rsmipc_cookie_t	rsmipc_cookie;		/* cookie of request in wire */
363*7c478bd9Sstevel@tonic-gate 	void 		*rsmipc_data;		/* ptr to data to copy */
364*7c478bd9Sstevel@tonic-gate }rsmipc_slot_t;
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate /*
367*7c478bd9Sstevel@tonic-gate  * Messaging struc
368*7c478bd9Sstevel@tonic-gate  */
369*7c478bd9Sstevel@tonic-gate typedef struct {
370*7c478bd9Sstevel@tonic-gate 	kmutex_t	lock;
371*7c478bd9Sstevel@tonic-gate 	kcondvar_t	cv;
372*7c478bd9Sstevel@tonic-gate 	int		count;
373*7c478bd9Sstevel@tonic-gate 	int		wanted;
374*7c478bd9Sstevel@tonic-gate 	int		sequence;
375*7c478bd9Sstevel@tonic-gate 	rsmipc_slot_t	slots[RSMIPC_SZ];
376*7c478bd9Sstevel@tonic-gate }rsm_ipc_t;
377*7c478bd9Sstevel@tonic-gate 
378*7c478bd9Sstevel@tonic-gate /*
379*7c478bd9Sstevel@tonic-gate  * These tokens are used for building the list of remote node importers
380*7c478bd9Sstevel@tonic-gate  * of a segment exported from the local node
381*7c478bd9Sstevel@tonic-gate  */
382*7c478bd9Sstevel@tonic-gate typedef struct importing_token {
383*7c478bd9Sstevel@tonic-gate 	struct importing_token	*next;
384*7c478bd9Sstevel@tonic-gate 	rsm_memseg_id_t		key;
385*7c478bd9Sstevel@tonic-gate 	rsm_node_id_t		importing_node;
386*7c478bd9Sstevel@tonic-gate 	void			*import_segment_cookie;
387*7c478bd9Sstevel@tonic-gate 	rsm_addr_t		importing_adapter_hwaddr;
388*7c478bd9Sstevel@tonic-gate } importing_token_t;
389*7c478bd9Sstevel@tonic-gate 
390*7c478bd9Sstevel@tonic-gate typedef struct {
391*7c478bd9Sstevel@tonic-gate 	kmutex_t		lock;
392*7c478bd9Sstevel@tonic-gate 	importing_token_t	**bucket;
393*7c478bd9Sstevel@tonic-gate } importers_table_t;
394*7c478bd9Sstevel@tonic-gate 
395*7c478bd9Sstevel@tonic-gate /*
396*7c478bd9Sstevel@tonic-gate  * Used by the rsm_send_republish() fn
397*7c478bd9Sstevel@tonic-gate  */
398*7c478bd9Sstevel@tonic-gate typedef struct republish_token {
399*7c478bd9Sstevel@tonic-gate 	struct republish_token	*next;
400*7c478bd9Sstevel@tonic-gate 	rsm_memseg_id_t		key;
401*7c478bd9Sstevel@tonic-gate 	rsm_node_id_t		importing_node;
402*7c478bd9Sstevel@tonic-gate 	rsm_permission_t	permission;
403*7c478bd9Sstevel@tonic-gate } republish_token_t;
404*7c478bd9Sstevel@tonic-gate 
405*7c478bd9Sstevel@tonic-gate /*
406*7c478bd9Sstevel@tonic-gate  * data strucuture for list manipulation
407*7c478bd9Sstevel@tonic-gate  */
408*7c478bd9Sstevel@tonic-gate typedef struct list_element {
409*7c478bd9Sstevel@tonic-gate 	struct list_element	*next;
410*7c478bd9Sstevel@tonic-gate 	rsm_node_id_t		nodeid;
411*7c478bd9Sstevel@tonic-gate 	uint32_t		flags;
412*7c478bd9Sstevel@tonic-gate #define	RSM_SUSPEND_ACKPENDING	0x01
413*7c478bd9Sstevel@tonic-gate #define	RSM_SUSPEND_NODEDEAD	0x02
414*7c478bd9Sstevel@tonic-gate } list_element_t;
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate typedef struct list_head {
417*7c478bd9Sstevel@tonic-gate 	struct list_element	*list_head;
418*7c478bd9Sstevel@tonic-gate 	kmutex_t		list_lock;
419*7c478bd9Sstevel@tonic-gate } list_head_t;
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
422*7c478bd9Sstevel@tonic-gate }
423*7c478bd9Sstevel@tonic-gate #endif
424*7c478bd9Sstevel@tonic-gate 
425*7c478bd9Sstevel@tonic-gate #endif	/* _RSM_IN_H */
426