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