1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS__MDIO_H
28*0Sstevel@tonic-gate #define	_SYS__MDIO_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/debug.h>
33*0Sstevel@tonic-gate #include <sys/ioctl.h>
34*0Sstevel@tonic-gate #include <sys/types.h>
35*0Sstevel@tonic-gate #include <sys/int_types.h>
36*0Sstevel@tonic-gate #include <sys/dditypes.h>
37*0Sstevel@tonic-gate #ifdef _KERNEL
38*0Sstevel@tonic-gate #include <sys/lvm/md_mdiox.h>
39*0Sstevel@tonic-gate #else /* !_KERNEL */
40*0Sstevel@tonic-gate #include <mdiox.h>
41*0Sstevel@tonic-gate #endif
42*0Sstevel@tonic-gate #include <sys/ddipropdefs.h>
43*0Sstevel@tonic-gate #include <sys/hwconf.h>
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #ifdef	__cplusplus
46*0Sstevel@tonic-gate extern "C" {
47*0Sstevel@tonic-gate #endif
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate /*
50*0Sstevel@tonic-gate  * driver version number
51*0Sstevel@tonic-gate  */
52*0Sstevel@tonic-gate #define	MD_DVERSION	0x00040003	/* major.minor */
53*0Sstevel@tonic-gate #define	MD_SET_SHIFT	(NBITSMINOR32 - MD_BITSSET)
54*0Sstevel@tonic-gate #define	MD_MAXUNITS	(1 << MD_SET_SHIFT)
55*0Sstevel@tonic-gate #define	MD_UNIT_MASK	(MD_MAXUNITS - 1)
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate #define	MD_MIN2UNIT(m)	((m) & MD_UNIT_MASK)
58*0Sstevel@tonic-gate #define	MD_MIN2SET(m)	((m) >> MD_SET_SHIFT)
59*0Sstevel@tonic-gate #define	MD_SID(u)	((u)->c.un_self_id)
60*0Sstevel@tonic-gate #define	MD_RECID(u)	((u)->c.un_record_id)
61*0Sstevel@tonic-gate #define	MD_STATUS(u)	((u)->c.un_status)
62*0Sstevel@tonic-gate #define	MD_PARENT(u)	((u)->c.un_parent)
63*0Sstevel@tonic-gate #define	MD_CAPAB(u)	((u)->c.un_capabilities)
64*0Sstevel@tonic-gate #define	MD_UN2SET(u)	MD_MIN2SET(MD_SID(u))
65*0Sstevel@tonic-gate #define	MD_UL2SET(l)	MD_MIN2SET(MAXMIN32 & ((l)->un_dev))
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate #define	MD_MKMIN(s, u)	((((s) & MD_SETMASK) << MD_SET_SHIFT) | \
68*0Sstevel@tonic-gate 			((u) & MD_UNIT_MASK))
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate #define	HSP_BITSID	31
71*0Sstevel@tonic-gate #define	HSP_SET_SHIFT	(HSP_BITSID - MD_BITSSET)
72*0Sstevel@tonic-gate #define	HSP_SET_MASK	(MD_SETMASK << HSP_SET_SHIFT)
73*0Sstevel@tonic-gate #define	HSP_SET(hspid)	(((hspid) & HSP_SET_MASK) >> HSP_SET_SHIFT)
74*0Sstevel@tonic-gate #define	HSP_ID(hspid)	((hspid) & ~HSP_SET_MASK)
75*0Sstevel@tonic-gate #define	MAKE_HSP_ID(setno, id)  (((setno) << HSP_SET_SHIFT) | (id))
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate /*
78*0Sstevel@tonic-gate  * for did stat ioctl
79*0Sstevel@tonic-gate  */
80*0Sstevel@tonic-gate #define	MD_FIND_INVDID	0x01
81*0Sstevel@tonic-gate #define	MD_GET_INVDID	0x02
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate /*
84*0Sstevel@tonic-gate  * for setting the un_revision
85*0Sstevel@tonic-gate  */
86*0Sstevel@tonic-gate #define	MD_32BIT_META_DEV	0
87*0Sstevel@tonic-gate #define	MD_64BIT_META_DEV	1
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate /*
90*0Sstevel@tonic-gate  * for trans EOF error messages
91*0Sstevel@tonic-gate  */
92*0Sstevel@tonic-gate #define	MD_EOF_TRANS_MSG	"Trans logging has been replaced by UFS" \
93*0Sstevel@tonic-gate 	" Logging.\nSee mount_ufs(1M). Operation failed.\n"
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #define	MD_SHORT_EOF_TRANS_MSG	"#Trans logging has been replaced by UFS" \
96*0Sstevel@tonic-gate 	" Logging.\n#See mount_ufs(1M). Operation failed.\n"
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate #define	MD_EOF_TRANS_WARNING	"Existing Trans devices are not logging; they" \
99*0Sstevel@tonic-gate 	"\npass data directly to the underlying device.\n"
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate #define	MD_SHORT_EOF_TRANS_WARNING	"#Existing Trans devices are not " \
102*0Sstevel@tonic-gate 	"logging; they\n#pass data directly to the underlying device.\n"
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate /*
105*0Sstevel@tonic-gate  * miscname stuff
106*0Sstevel@tonic-gate  */
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate #define	MD_DRIVERNAMELEN	16
109*0Sstevel@tonic-gate #define	MD_SETDRIVERNAME(to, from, setno) \
110*0Sstevel@tonic-gate 	if ((from) != NULL) \
111*0Sstevel@tonic-gate 		(void) strcpy((to)->md_driver.md_drivername, (from)); \
112*0Sstevel@tonic-gate 	(to)->md_driver.md_setno = (setno);
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate #define	MD_GETDRIVERNAME(to, from) \
116*0Sstevel@tonic-gate 	(void) strcpy((to), (from)->md_driver.md_drivername);
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate #define	MD_PNTDRIVERNAME(from) \
119*0Sstevel@tonic-gate 	((from)->md_driver.md_drivername)
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate /*
122*0Sstevel@tonic-gate  * ioctl parameter structures
123*0Sstevel@tonic-gate  */
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
126*0Sstevel@tonic-gate #pragma pack(4)
127*0Sstevel@tonic-gate #endif
128*0Sstevel@tonic-gate typedef struct md_i_driverinfo {
129*0Sstevel@tonic-gate 	MD_DRIVER
130*0Sstevel@tonic-gate 	md_error_t	mde;
131*0Sstevel@tonic-gate 	minor_t		mnum;
132*0Sstevel@tonic-gate } md_i_driverinfo_t;
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate typedef struct md_i_getnext {
135*0Sstevel@tonic-gate 	MD_DRIVER
136*0Sstevel@tonic-gate 	md_error_t	mde;
137*0Sstevel@tonic-gate 	minor_or_hsp_t	id;
138*0Sstevel@tonic-gate } md_i_getnext_t;
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate typedef struct md_i_getnum {
141*0Sstevel@tonic-gate 	MD_DRIVER
142*0Sstevel@tonic-gate 	md_error_t	mde;
143*0Sstevel@tonic-gate 	int		start;
144*0Sstevel@tonic-gate 	int		size;
145*0Sstevel@tonic-gate 	uint64_t	minors;	/* Pointer to minor #'s */
146*0Sstevel@tonic-gate } md_i_getnum_t;
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate typedef struct md_i_get {
149*0Sstevel@tonic-gate 	MD_DRIVER
150*0Sstevel@tonic-gate 	md_error_t	mde;
151*0Sstevel@tonic-gate 	minor_or_hsp_t	id;
152*0Sstevel@tonic-gate 	int		size;
153*0Sstevel@tonic-gate 	uint64_t	mdp;	/* Contains pointer */
154*0Sstevel@tonic-gate } md_i_get_t;
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate typedef struct md_i_reset {
157*0Sstevel@tonic-gate 	MD_DRIVER
158*0Sstevel@tonic-gate 	md_error_t	mde;
159*0Sstevel@tonic-gate 	minor_t		mnum;		/* Unit to clear */
160*0Sstevel@tonic-gate 	int		force;
161*0Sstevel@tonic-gate } md_i_reset_t;
162*0Sstevel@tonic-gate 
163*0Sstevel@tonic-gate /* soft partition reset parameters */
164*0Sstevel@tonic-gate typedef struct md_sp_reset {
165*0Sstevel@tonic-gate 	MD_DRIVER
166*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
167*0Sstevel@tonic-gate 	minor_t		mnum;		/* Unit to clear */
168*0Sstevel@tonic-gate 	int		force;		/* Force reset */
169*0Sstevel@tonic-gate 	md_parent_t	new_parent;	/* New parent for child component */
170*0Sstevel@tonic-gate } md_sp_reset_t;
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate /* soft partition status change parameters */
173*0Sstevel@tonic-gate typedef struct md_sp_statusset {
174*0Sstevel@tonic-gate 	MD_DRIVER
175*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
176*0Sstevel@tonic-gate 	int		num_units;	/* Number of units */
177*0Sstevel@tonic-gate 	int		new_status;	/* New status */
178*0Sstevel@tonic-gate 	int		size;		/* Array size */
179*0Sstevel@tonic-gate 	uint64_t	minors;		/* Pointer to array of minor numbers */
180*0Sstevel@tonic-gate } md_sp_statusset_t;
181*0Sstevel@tonic-gate 
182*0Sstevel@tonic-gate typedef struct md_sp_update_wm {
183*0Sstevel@tonic-gate 	MD_DRIVER
184*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
185*0Sstevel@tonic-gate 	minor_t		mnum;		/* Unit to update */
186*0Sstevel@tonic-gate 	uint_t		count;		/* Number of watermarks */
187*0Sstevel@tonic-gate 	uint64_t	wmp;		/* Pointer to array of watermarks */
188*0Sstevel@tonic-gate 	uint64_t	osp;		/* Pointer to array of offsets */
189*0Sstevel@tonic-gate } md_sp_update_wm_t;
190*0Sstevel@tonic-gate 
191*0Sstevel@tonic-gate typedef struct md_sp_read_wm {
192*0Sstevel@tonic-gate 	MD_DRIVER
193*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
194*0Sstevel@tonic-gate 	md_dev64_t	rdev;		/* Device from which to read */
195*0Sstevel@tonic-gate 	uint64_t	wmp;		/* Pointer to wm buffer */
196*0Sstevel@tonic-gate 	xsp_offset_t	offset;		/* Offset of wm */
197*0Sstevel@tonic-gate } md_sp_read_wm_t;
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate typedef struct md_set_userflags {
200*0Sstevel@tonic-gate 	MD_DRIVER
201*0Sstevel@tonic-gate 	md_error_t	mde;
202*0Sstevel@tonic-gate 	minor_t		mnum;
203*0Sstevel@tonic-gate 	uint_t		userflags;
204*0Sstevel@tonic-gate } md_set_userflags_t;
205*0Sstevel@tonic-gate 
206*0Sstevel@tonic-gate typedef struct md_stripe_params {
207*0Sstevel@tonic-gate 	MD_DRIVER
208*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
209*0Sstevel@tonic-gate 	minor_t		mnum;
210*0Sstevel@tonic-gate 	ms_params_t	params;
211*0Sstevel@tonic-gate } md_stripe_params_t;
212*0Sstevel@tonic-gate 
213*0Sstevel@tonic-gate typedef struct md_raid_params {
214*0Sstevel@tonic-gate 	MD_DRIVER
215*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
216*0Sstevel@tonic-gate 	minor_t		mnum;
217*0Sstevel@tonic-gate 	mr_params_t	params;
218*0Sstevel@tonic-gate } md_raid_params_t;
219*0Sstevel@tonic-gate 
220*0Sstevel@tonic-gate typedef struct md_mirror_params {
221*0Sstevel@tonic-gate 	MD_DRIVER
222*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
223*0Sstevel@tonic-gate 	minor_t		mnum;
224*0Sstevel@tonic-gate 	mm_params_t	params;
225*0Sstevel@tonic-gate } md_mirror_params_t;
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate typedef struct md_grow_params {
228*0Sstevel@tonic-gate 	MD_DRIVER
229*0Sstevel@tonic-gate 	md_error_t	mde;	/* Error return */
230*0Sstevel@tonic-gate 	minor_t		mnum;	/* Unit to grow */
231*0Sstevel@tonic-gate 	int		options; /* create a 64 or 32 bit device */
232*0Sstevel@tonic-gate 	uint64_t	mdp;	/* Optional - pointer to new unit struct */
233*0Sstevel@tonic-gate 	int		size;	/* Optional - size of new unit struct */
234*0Sstevel@tonic-gate 	int		nrows;	/* Optional - original number of rows */
235*0Sstevel@tonic-gate 	int		npar;	/* Optional - number of parents to lock */
236*0Sstevel@tonic-gate 	uint64_t	par;	/* Optional - pointer to parent units */
237*0Sstevel@tonic-gate } md_grow_params_t;
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate /* if the didstat struct changes you will need to change the following macro */
240*0Sstevel@tonic-gate typedef struct md_i_didstat {
241*0Sstevel@tonic-gate 	md_error_t	mde;	/* Error return */
242*0Sstevel@tonic-gate 	set_t		setno;	/* which set to use */
243*0Sstevel@tonic-gate 	side_t		side;	/* which side to use */
244*0Sstevel@tonic-gate 	int		mode;	/* find or get ? */
245*0Sstevel@tonic-gate 	int		cnt;	/* return number of invalid devid's found */
246*0Sstevel@tonic-gate 	int		maxsz;	/* return max size of invalid device id */
247*0Sstevel@tonic-gate 	uint64_t	ctdp;	/* pointer to structure to fill with ctds */
248*0Sstevel@tonic-gate } md_i_didstat_t;
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate typedef struct mdnm_params {
251*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
252*0Sstevel@tonic-gate 	char		drvnm[MD_MAXDRVNM];  /* drvnm for get/set/rem nm */
253*0Sstevel@tonic-gate 	major_t		major;		/* major #, (alternative) for get nm */
254*0Sstevel@tonic-gate 	minor_t		mnum;		/* minor #, for get/set/rem nm */
255*0Sstevel@tonic-gate 	uint_t		devname_len;	/* Length of device name, for set nm */
256*0Sstevel@tonic-gate 	uint64_t	devname;	/* Address of device name for set/get */
257*0Sstevel@tonic-gate 	set_t		setno;		/* Which namespace set to use */
258*0Sstevel@tonic-gate 	side_t		side;		/* -1 == current side, >0 specified */
259*0Sstevel@tonic-gate 	mdkey_t		key;		/* 0 == alloc one, else use this key */
260*0Sstevel@tonic-gate 	mdkey_t		retkey;		/* return key here! */
261*0Sstevel@tonic-gate 	ushort_t	devid_size;	/* 0 == ret size, else use this one */
262*0Sstevel@tonic-gate 	uint64_t	devid;		/* pointer to devid, supplied by user */
263*0Sstevel@tonic-gate 	uint_t		pathname_len;	/* length of pathname */
264*0Sstevel@tonic-gate 	uint64_t	pathname;	/* address of pathname for update */
265*0Sstevel@tonic-gate 	md_dev64_t	devt;		/* devt for updating namespace */
266*0Sstevel@tonic-gate 	ushort_t	minorname_len;	/* length of minor name */
267*0Sstevel@tonic-gate 	uint64_t	minorname;	/* address of minor name */
268*0Sstevel@tonic-gate 	uint_t		ref_count;	/* returned n_count */
269*0Sstevel@tonic-gate } mdnm_params_t;
270*0Sstevel@tonic-gate 
271*0Sstevel@tonic-gate typedef struct md_getdevs_params {
272*0Sstevel@tonic-gate 	MD_DRIVER
273*0Sstevel@tonic-gate 	md_error_t	mde;
274*0Sstevel@tonic-gate 	minor_t		mnum;
275*0Sstevel@tonic-gate 	int		cnt;
276*0Sstevel@tonic-gate 	uint64_t	devs;	/* Pointer to devs */
277*0Sstevel@tonic-gate } md_getdevs_params_t;
278*0Sstevel@tonic-gate 
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate typedef struct md_i_get_tstate {
281*0Sstevel@tonic-gate 	minor_or_hsp_t	id;
282*0Sstevel@tonic-gate 	uint_t		tstate;		/* Transient state */
283*0Sstevel@tonic-gate 	md_error_t	mde;
284*0Sstevel@tonic-gate } md_i_get_tstate_t;
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate typedef struct md_set_state_params {
287*0Sstevel@tonic-gate 	MD_DRIVER
288*0Sstevel@tonic-gate 	md_error_t	mde;
289*0Sstevel@tonic-gate 	minor_t		mnum;
290*0Sstevel@tonic-gate 	uint_t		sm;
291*0Sstevel@tonic-gate 	uint_t		comp;
292*0Sstevel@tonic-gate 	uint_t		state;
293*0Sstevel@tonic-gate 	mddb_recid_t	hs_id;
294*0Sstevel@tonic-gate } md_set_state_params_t;
295*0Sstevel@tonic-gate 
296*0Sstevel@tonic-gate typedef struct md_alloc_hotsp_params {
297*0Sstevel@tonic-gate 	MD_DRIVER
298*0Sstevel@tonic-gate 	md_error_t	mde;
299*0Sstevel@tonic-gate 	minor_t		mnum;
300*0Sstevel@tonic-gate 	uint_t		sm;
301*0Sstevel@tonic-gate 	uint_t		comp;
302*0Sstevel@tonic-gate 	mddb_recid_t	hs_id;
303*0Sstevel@tonic-gate } md_alloc_hotsp_params_t;
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate typedef struct md_suspend_wr_params {
306*0Sstevel@tonic-gate 	MD_DRIVER
307*0Sstevel@tonic-gate 	md_error_t	mde;
308*0Sstevel@tonic-gate 	minor_t		mnum;
309*0Sstevel@tonic-gate } md_suspend_wr_params_t;
310*0Sstevel@tonic-gate 
311*0Sstevel@tonic-gate typedef struct md_mn_req_owner {
312*0Sstevel@tonic-gate 	minor_t		mnum;		/* Mirror metadevice */
313*0Sstevel@tonic-gate 	uint_t		flags;		/* Flags (see below) */
314*0Sstevel@tonic-gate 	md_mn_nodeid_t	owner;		/* New owner of Mirror  */
315*0Sstevel@tonic-gate } md_mn_req_owner_t;
316*0Sstevel@tonic-gate 
317*0Sstevel@tonic-gate #define	MD_MN_MM_PREVENT_CHANGE	0x0001	/* Disallow further ownership change */
318*0Sstevel@tonic-gate #define	MD_MN_MM_ALLOW_CHANGE	0x0002	/* Allow ownership change */
319*0Sstevel@tonic-gate #define	MD_MN_MM_SPAWN_THREAD	0x0004
320*0Sstevel@tonic-gate #define	MD_MN_MM_CHOOSE_OWNER	0x0008	/* Choose a resync owner */
321*0Sstevel@tonic-gate 
322*0Sstevel@tonic-gate #define	MD_MN_MM_RESULT		0x80000000	/* Result contained in LSB */
323*0Sstevel@tonic-gate #define	MD_MN_MM_RESULT_MASK	0xFFFF		/* Mask for result code	   */
324*0Sstevel@tonic-gate #define	MD_MN_MM_RES_OK		0		/* Success */
325*0Sstevel@tonic-gate #define	MD_MN_MM_RES_FAIL	1		/* Failure */
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate typedef struct md_set_mmown_params {
328*0Sstevel@tonic-gate 	MD_DRIVER
329*0Sstevel@tonic-gate 	md_error_t		mde;
330*0Sstevel@tonic-gate 	md_mn_req_owner_t	d;	/* New owner */
331*0Sstevel@tonic-gate } md_set_mmown_params_t;
332*0Sstevel@tonic-gate 
333*0Sstevel@tonic-gate typedef struct md_mn_own_status {
334*0Sstevel@tonic-gate 	MD_DRIVER
335*0Sstevel@tonic-gate 	md_error_t		mde;
336*0Sstevel@tonic-gate 	minor_t			mnum;
337*0Sstevel@tonic-gate 	uint_t			flags;	/* See above *_MM_RESULT flags */
338*0Sstevel@tonic-gate } md_mn_own_status_t;
339*0Sstevel@tonic-gate 
340*0Sstevel@tonic-gate typedef struct md_mn_poke_hotspares {
341*0Sstevel@tonic-gate 	MD_DRIVER
342*0Sstevel@tonic-gate 	md_error_t		mde;
343*0Sstevel@tonic-gate } md_mn_poke_hotspares_t;
344*0Sstevel@tonic-gate 
345*0Sstevel@tonic-gate typedef struct md_mn_rs_params {
346*0Sstevel@tonic-gate 	MD_DRIVER
347*0Sstevel@tonic-gate 	md_error_t	mde;
348*0Sstevel@tonic-gate 	int		msg_type;	/* Type of message */
349*0Sstevel@tonic-gate 	minor_t		mnum;		/* Mirror metadevice */
350*0Sstevel@tonic-gate 	uint_t		rs_type;	/* Type of resync */
351*0Sstevel@tonic-gate 	diskaddr_t	rs_start;	/* 1st block of resync range */
352*0Sstevel@tonic-gate 	diskaddr_t	rs_size;	/* size of resync range */
353*0Sstevel@tonic-gate 	diskaddr_t	rs_done;	/* amount of resync done so far */
354*0Sstevel@tonic-gate 	diskaddr_t	rs_2_do;	/* amount still to be done */
355*0Sstevel@tonic-gate 	md_mn_nodeid_t	rs_originator;	/* Originator of resync message */
356*0Sstevel@tonic-gate 	char		rs_flags;	/* flags */
357*0Sstevel@tonic-gate 	char		rs_first_time;	/* set if first resync-next message */
358*0Sstevel@tonic-gate 	sm_state_t	rs_sm_state[NMIRROR];	/* Submirror state */
359*0Sstevel@tonic-gate 	sm_flags_t	rs_sm_flags[NMIRROR];	/* Submirror flags */
360*0Sstevel@tonic-gate } md_mn_rs_params_t;
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /* flag values for rs_flags */
363*0Sstevel@tonic-gate #define	MD_MN_RS_ERR			0x01 /* Resync err */
364*0Sstevel@tonic-gate #define	MD_MN_RS_CLEAR_OPT_NOT_DONE	0x02 /* Optimized resync done */
365*0Sstevel@tonic-gate #define	MD_MN_RS_FIRST_RESYNC_NEXT	0x04 /* First RESYNC_NEXT message */
366*0Sstevel@tonic-gate 
367*0Sstevel@tonic-gate typedef struct md_mn_setcap_params {
368*0Sstevel@tonic-gate 	MD_DRIVER
369*0Sstevel@tonic-gate 	md_error_t	mde;
370*0Sstevel@tonic-gate 	minor_t		mnum;
371*0Sstevel@tonic-gate 	uint_t		sc_set;		/* Capability settings */
372*0Sstevel@tonic-gate } md_mn_setcap_params_t;
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate typedef struct md_mkdev_params {
375*0Sstevel@tonic-gate 	MD_DRIVER
376*0Sstevel@tonic-gate 	md_error_t	mde;		/* Error return */
377*0Sstevel@tonic-gate 	minor_t		mnum;
378*0Sstevel@tonic-gate } md_mkdev_params_t;
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate /*
381*0Sstevel@tonic-gate  * Flags to coordinate sending device id between kernel and user space.
382*0Sstevel@tonic-gate  * To get devid from kernel:
383*0Sstevel@tonic-gate  *   User calls ioctl with l_devid_flags set to GETSZ flag to get size of
384*0Sstevel@tonic-gate  *   devid which is returned in the l_devid_sz field if the SZ flag is set.
385*0Sstevel@tonic-gate  *   Then user allocs that size and sends same ioctl with SPACE flag set
386*0Sstevel@tonic-gate  *   and l_devid_sz set to alloc'd size.  Kernel either sets the NOSPACE
387*0Sstevel@tonic-gate  *   flag (if alloc'd space is not big enough) or sets the VALID flag and
388*0Sstevel@tonic-gate  *   fills in the devid.
389*0Sstevel@tonic-gate  *
390*0Sstevel@tonic-gate  * To send devid to kernel:
391*0Sstevel@tonic-gate  *   User alloc's space for devid, fills in devid, sets (SPACE|VALID|SZ) flags
392*0Sstevel@tonic-gate  *   and sets size of devid into l_devid_sz field.
393*0Sstevel@tonic-gate  *
394*0Sstevel@tonic-gate  * If MDDB_DEVID_SPACE is set, MDDB_DEVID_GETSZ is ignored.
395*0Sstevel@tonic-gate  * If no flags are set, devid information is ignored.
396*0Sstevel@tonic-gate  */
397*0Sstevel@tonic-gate #define	MDDB_DEVID_SPACE	0x0001	/* l_devid_sz bytes of space alloc'd */
398*0Sstevel@tonic-gate #define	MDDB_DEVID_VALID	0x0002	/* kernel has filled in devid */
399*0Sstevel@tonic-gate #define	MDDB_DEVID_NOSPACE	0x0004	/* not enough alloc'd space for devid */
400*0Sstevel@tonic-gate #define	MDDB_DEVID_GETSZ	0x0008	/* fill in l_devid_sz with devid size */
401*0Sstevel@tonic-gate #define	MDDB_DEVID_SZ		0x0010	/* l_devid_sz filled in with devid sz */
402*0Sstevel@tonic-gate 
403*0Sstevel@tonic-gate 
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate /*
406*0Sstevel@tonic-gate  * Maximum number of replicas (or number of locator blocks) in set.
407*0Sstevel@tonic-gate  */
408*0Sstevel@tonic-gate #define	MDDB_NLB		50
409*0Sstevel@tonic-gate 
410*0Sstevel@tonic-gate /*
411*0Sstevel@tonic-gate  * maximum size of allowable bootlist property string - only used to
412*0Sstevel@tonic-gate  * read in and write out boolist property strings to conf files.
413*0Sstevel@tonic-gate  */
414*0Sstevel@tonic-gate #define	MDDB_BOOTLIST_MAX_LEN	MAX_HWC_LINESIZE
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate /*
417*0Sstevel@tonic-gate  * Percentage of free space left in replica during conversion of non-devid
418*0Sstevel@tonic-gate  * style replica to devid style replica.
419*0Sstevel@tonic-gate  */
420*0Sstevel@tonic-gate #define	MDDB_DEVID_CONV_PERC	5
421*0Sstevel@tonic-gate 
422*0Sstevel@tonic-gate typedef struct mddb_cfg_loc {
423*0Sstevel@tonic-gate 	dev32_t		l_dev;
424*0Sstevel@tonic-gate 	daddr32_t	l_blkno;
425*0Sstevel@tonic-gate 	int		l_flags;
426*0Sstevel@tonic-gate 	char		l_driver[MD_MAXDRVNM];
427*0Sstevel@tonic-gate 	minor_t		l_mnum;
428*0Sstevel@tonic-gate 	int		l_devid_flags;
429*0Sstevel@tonic-gate 	uint64_t	l_devid;	/* pointer to devid */
430*0Sstevel@tonic-gate 	int		l_devid_sz;
431*0Sstevel@tonic-gate 	uint64_t	l_old_devid;
432*0Sstevel@tonic-gate 	int		l_old_devid_sz;
433*0Sstevel@tonic-gate 	char		l_minor_name[MDDB_MINOR_NAME_MAX];
434*0Sstevel@tonic-gate 	char		l_devname[MAXPATHLEN];	/* device name */
435*0Sstevel@tonic-gate } mddb_cfg_loc_t;
436*0Sstevel@tonic-gate 
437*0Sstevel@tonic-gate typedef struct mddb_dtag {
438*0Sstevel@tonic-gate 	md_timeval32_t	dt_tv;
439*0Sstevel@tonic-gate 	int		dt_id;
440*0Sstevel@tonic-gate 	set_t		dt_setno;
441*0Sstevel@tonic-gate 	char		dt_sn[MDDB_SN_LEN];
442*0Sstevel@tonic-gate 	char		dt_hn[MD_MAX_NODENAME_PLUS_1];
443*0Sstevel@tonic-gate } mddb_dtag_t;
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate typedef struct mddb_dtag_lst {
446*0Sstevel@tonic-gate 	struct mddb_dtag_lst	*dtl_nx;
447*0Sstevel@tonic-gate 	mddb_dtag_t		dtl_dt;
448*0Sstevel@tonic-gate } mddb_dtag_lst_t;
449*0Sstevel@tonic-gate 
450*0Sstevel@tonic-gate typedef struct mddb_dtag_get_parm {
451*0Sstevel@tonic-gate 	set_t		dtgp_setno;
452*0Sstevel@tonic-gate 	mddb_dtag_t	dtgp_dt;
453*0Sstevel@tonic-gate 	md_error_t	dtgp_mde;
454*0Sstevel@tonic-gate } mddb_dtag_get_parm_t;
455*0Sstevel@tonic-gate 
456*0Sstevel@tonic-gate typedef struct mddb_dtag_use_parm {
457*0Sstevel@tonic-gate 	int		dtup_id;
458*0Sstevel@tonic-gate 	set_t		dtup_setno;
459*0Sstevel@tonic-gate 	md_error_t	dtup_mde;
460*0Sstevel@tonic-gate } mddb_dtag_use_parm_t;
461*0Sstevel@tonic-gate 
462*0Sstevel@tonic-gate typedef struct mddb_accept_parm {
463*0Sstevel@tonic-gate 	set_t		accp_setno;
464*0Sstevel@tonic-gate 	md_error_t	accp_mde;
465*0Sstevel@tonic-gate } mddb_accept_parm_t;
466*0Sstevel@tonic-gate 
467*0Sstevel@tonic-gate typedef struct mddb_med_parm {
468*0Sstevel@tonic-gate 	set_t		med_setno;
469*0Sstevel@tonic-gate 	md_hi_arr_t	med;
470*0Sstevel@tonic-gate 	md_error_t	med_mde;		/* error return */
471*0Sstevel@tonic-gate } mddb_med_parm_t;
472*0Sstevel@tonic-gate 
473*0Sstevel@tonic-gate typedef struct mddb_med_upd_parm {
474*0Sstevel@tonic-gate 	set_t		med_setno;
475*0Sstevel@tonic-gate 	md_error_t	med_mde;		/* error return */
476*0Sstevel@tonic-gate } mddb_med_upd_parm_t;
477*0Sstevel@tonic-gate 
478*0Sstevel@tonic-gate #define	MED_TE_NM_LEN	64
479*0Sstevel@tonic-gate 
480*0Sstevel@tonic-gate typedef struct mddb_med_t_ent {
481*0Sstevel@tonic-gate 	char		med_te_nm[MED_TE_NM_LEN];
482*0Sstevel@tonic-gate 	md_dev64_t	med_te_dev;		/* fixed size dev_t */
483*0Sstevel@tonic-gate } mddb_med_t_ent_t;
484*0Sstevel@tonic-gate 
485*0Sstevel@tonic-gate typedef struct mddb_med_t_parm {
486*0Sstevel@tonic-gate 	md_error_t		med_tp_mde;		/* error return */
487*0Sstevel@tonic-gate 	int			med_tp_nents;		/* number of entries */
488*0Sstevel@tonic-gate 	int			med_tp_setup;		/* setup flag */
489*0Sstevel@tonic-gate 	mddb_med_t_ent_t	med_tp_ents[1];		/* Var. sized array */
490*0Sstevel@tonic-gate } mddb_med_t_parm_t;
491*0Sstevel@tonic-gate 
492*0Sstevel@tonic-gate #define	MDDB_SETMASTER_MAGIC	0x53544d41	/* Ascii for STMA */
493*0Sstevel@tonic-gate typedef struct mddb_setmaster_config {
494*0Sstevel@tonic-gate 	md_error_t	c_mde;
495*0Sstevel@tonic-gate 	set_t		c_setno;
496*0Sstevel@tonic-gate 	int		c_magic;		/* used to verify ioctl */
497*0Sstevel@tonic-gate 	int		c_current_host_master;
498*0Sstevel@tonic-gate } mddb_setmaster_config_t;
499*0Sstevel@tonic-gate 
500*0Sstevel@tonic-gate /*
501*0Sstevel@tonic-gate  * Structure used to set/reset/get flags in set structure.
502*0Sstevel@tonic-gate  */
503*0Sstevel@tonic-gate #define	MDDB_SETFLAGS_MAGIC	0x5354464c	/* ascii for STFL */
504*0Sstevel@tonic-gate typedef struct mddb_setflags_config {
505*0Sstevel@tonic-gate 	md_error_t	sf_mde;
506*0Sstevel@tonic-gate 	set_t		sf_setno;
507*0Sstevel@tonic-gate 	int		sf_magic;	/* used to verify ioctl */
508*0Sstevel@tonic-gate 	int		sf_flags;	/* Control flags set/reset/get */
509*0Sstevel@tonic-gate 	int		sf_setflags;	/* Flag values */
510*0Sstevel@tonic-gate } mddb_setflags_config_t;
511*0Sstevel@tonic-gate 
512*0Sstevel@tonic-gate typedef struct mddb_set_node_params {
513*0Sstevel@tonic-gate 	md_error_t	sn_mde;
514*0Sstevel@tonic-gate 	set_t		sn_setno;
515*0Sstevel@tonic-gate 	md_mn_nodeid_t	sn_nodeid;
516*0Sstevel@tonic-gate } mddb_set_node_params_t;
517*0Sstevel@tonic-gate 
518*0Sstevel@tonic-gate typedef struct mddb_block_parm {
519*0Sstevel@tonic-gate 	md_error_t	c_mde;
520*0Sstevel@tonic-gate 	set_t		c_setno;
521*0Sstevel@tonic-gate 	int		c_blk_flags;
522*0Sstevel@tonic-gate } mddb_block_parm_t;
523*0Sstevel@tonic-gate 
524*0Sstevel@tonic-gate typedef struct mddb_parse_parm {
525*0Sstevel@tonic-gate 	md_error_t	c_mde;
526*0Sstevel@tonic-gate 	set_t		c_setno;
527*0Sstevel@tonic-gate 	int		c_parse_flags;
528*0Sstevel@tonic-gate 	int		c_lb_flags[MDDB_NLB];
529*0Sstevel@tonic-gate } mddb_parse_parm_t;
530*0Sstevel@tonic-gate 
531*0Sstevel@tonic-gate typedef struct mddb_optrec_parm {
532*0Sstevel@tonic-gate 	md_error_t		c_mde;
533*0Sstevel@tonic-gate 	set_t			c_setno;
534*0Sstevel@tonic-gate 	md_replica_recerr_t	c_recerr[2];
535*0Sstevel@tonic-gate } mddb_optrec_parm_t;
536*0Sstevel@tonic-gate 
537*0Sstevel@tonic-gate typedef struct mddb_config {
538*0Sstevel@tonic-gate 	md_error_t	c_mde;			/* error return */
539*0Sstevel@tonic-gate 	int		c_id;			/* used with getnext locator */
540*0Sstevel@tonic-gate 	md_splitname	c_devname;		/* contains name or keys */
541*0Sstevel@tonic-gate 	int		c_dbcnt;		/* number of dbs */
542*0Sstevel@tonic-gate 	int		c_dbmax;		/* maximum number of dbs */
543*0Sstevel@tonic-gate 	int		c_flags;
544*0Sstevel@tonic-gate 	int		c_dbend;		/* size of database */
545*0Sstevel@tonic-gate 	set_t		c_setno;		/* set number of replica */
546*0Sstevel@tonic-gate 	int		c_multi_node;		/* set if multi_node set */
547*0Sstevel@tonic-gate 	side_t		c_sideno;		/* side number of replica */
548*0Sstevel@tonic-gate 	md_timeval32_t	c_timestamp;		/* creation of set */
549*0Sstevel@tonic-gate 						/* setname */
550*0Sstevel@tonic-gate 	char		c_setname[MD_MAX_SETNAME_PLUS_1];
551*0Sstevel@tonic-gate 	md_hi_arr_t	c_med;			/* Mediator host information */
552*0Sstevel@tonic-gate 	int		c_spare[14];		/* unused must be zero */
553*0Sstevel@tonic-gate 	md_dev64_t	c_devt;			/* devt to get/set */
554*0Sstevel@tonic-gate 	mddb_cfg_loc_t	c_locator;		/* device specific info */
555*0Sstevel@tonic-gate } mddb_config_t;
556*0Sstevel@tonic-gate 
557*0Sstevel@tonic-gate #define	c_subcmd	c_spare[0]
558*0Sstevel@tonic-gate /*
559*0Sstevel@tonic-gate  * Subcommands.
560*0Sstevel@tonic-gate  */
561*0Sstevel@tonic-gate #define	MDDB_CONFIG_ABS	1		/* treat c_id as abs index */
562*0Sstevel@tonic-gate 
563*0Sstevel@tonic-gate typedef	struct mddb_optloc {
564*0Sstevel@tonic-gate 	int	recid;	/* really mddb_recid_t */
565*0Sstevel@tonic-gate 	int	li[2];
566*0Sstevel@tonic-gate } mddb_optloc_t;
567*0Sstevel@tonic-gate 
568*0Sstevel@tonic-gate typedef struct md_gs_stat_parm {
569*0Sstevel@tonic-gate 	set_t		gs_setno;
570*0Sstevel@tonic-gate 	uint_t		gs_status;
571*0Sstevel@tonic-gate 	md_error_t	gs_mde;
572*0Sstevel@tonic-gate } md_gs_stat_parm_t;
573*0Sstevel@tonic-gate 
574*0Sstevel@tonic-gate typedef struct {
575*0Sstevel@tonic-gate 	int	setno;
576*0Sstevel@tonic-gate 	int	owns_set;
577*0Sstevel@tonic-gate } mddb_ownset_t;
578*0Sstevel@tonic-gate 
579*0Sstevel@tonic-gate typedef enum md_rename_operation_t {
580*0Sstevel@tonic-gate 	MDRNOP_UNK = 0, MDRNOP_RENAME, MDRNOP_EXCHANGE
581*0Sstevel@tonic-gate } md_renop_t;
582*0Sstevel@tonic-gate 
583*0Sstevel@tonic-gate typedef struct md_rename {
584*0Sstevel@tonic-gate 	md_error_t	mde;
585*0Sstevel@tonic-gate 	md_renop_t	op;
586*0Sstevel@tonic-gate 	int		revision;
587*0Sstevel@tonic-gate 	uint_t		flags;
588*0Sstevel@tonic-gate 	struct {
589*0Sstevel@tonic-gate 		minor_t	mnum;
590*0Sstevel@tonic-gate 		key_t	key;
591*0Sstevel@tonic-gate 	} from, to;
592*0Sstevel@tonic-gate } md_rename_t;
593*0Sstevel@tonic-gate 
594*0Sstevel@tonic-gate typedef struct md_regen_param {
595*0Sstevel@tonic-gate 	MD_DRIVER
596*0Sstevel@tonic-gate 	md_error_t	mde;
597*0Sstevel@tonic-gate 	minor_t		mnum;   /* Unit to regenerate parity for */
598*0Sstevel@tonic-gate } md_regen_param_t;
599*0Sstevel@tonic-gate 
600*0Sstevel@tonic-gate /* Base ioctl's defined here */
601*0Sstevel@tonic-gate #define	MDIOC		('V' << 8)
602*0Sstevel@tonic-gate #define	ISMDIOC(c)	(((c) >> 8) == 'V')
603*0Sstevel@tonic-gate 
604*0Sstevel@tonic-gate #define	MD_IOCSET	(MDIOC|0)	/* set config    (metainit) */
605*0Sstevel@tonic-gate #define	MD_IOCRESET	(MDIOC|1)	/* reset config  (metaclear) */
606*0Sstevel@tonic-gate #define	MD_IOCGET	(MDIOC|2)	/* get config    (metastat) */
607*0Sstevel@tonic-gate #define	MD_IOCGROW	(MDIOC|3)	/* grow config   (dyn concat) */
608*0Sstevel@tonic-gate #define	MD_IOCCHANGE	(MDIOC|4)	/* change config (metaparam) */
609*0Sstevel@tonic-gate #define	MD_IOCSET_NM	(MDIOC|5)	/* set device name */
610*0Sstevel@tonic-gate #define	MD_IOCGET_NM	(MDIOC|6)	/* get device name */
611*0Sstevel@tonic-gate #define	MD_IOCREM_NM	(MDIOC|7)	/* remove device name */
612*0Sstevel@tonic-gate #define	MD_IOCGET_DRVNM	(MDIOC|8)	/* get driver name */
613*0Sstevel@tonic-gate #define	MD_IOCGET_NEXT	(MDIOC|9)	/* get next unit id */
614*0Sstevel@tonic-gate #define	MD_IOCGET_DEVS	(MDIOC|10)	/* get device list */
615*0Sstevel@tonic-gate #define	MD_DB_NEWDEV	(MDIOC|11)	/* add a db replica */
616*0Sstevel@tonic-gate #define	MD_DB_USEDEV	(MDIOC|12)	/* patch in a db location */
617*0Sstevel@tonic-gate #define	MD_DB_GETDEV	(MDIOC|13)	/* get a db replica */
618*0Sstevel@tonic-gate #define	MD_DB_DELDEV	(MDIOC|14)	/* remove a db replica */
619*0Sstevel@tonic-gate #define	MD_DB_ENDDEV	(MDIOC|15)	/* get db replica and size */
620*0Sstevel@tonic-gate #define	MD_DB_GETDRVNM	(MDIOC|16)	/* get db replica driver name */
621*0Sstevel@tonic-gate #define	MD_HALT		(MDIOC|17)	/* halt driver   (metahalt) */
622*0Sstevel@tonic-gate #define	MD_GRAB_SET	(MDIOC|18)
623*0Sstevel@tonic-gate #define	MD_RELEASE_SET	(MDIOC|20)	/* release a set */
624*0Sstevel@tonic-gate #define	MD_IOCSETSYNC	(MDIOC|21)
625*0Sstevel@tonic-gate #define	MD_IOCGETSYNC	(MDIOC|22)
626*0Sstevel@tonic-gate #define	MD_IOCOFFLINE	(MDIOC|23)
627*0Sstevel@tonic-gate #define	MD_IOCONLINE	(MDIOC|24)
628*0Sstevel@tonic-gate #define	MD_IOCATTACH	(MDIOC|25)
629*0Sstevel@tonic-gate #define	MD_IOCDETACH	(MDIOC|26)
630*0Sstevel@tonic-gate #define	MD_IOCREPLACE	(MDIOC|27)
631*0Sstevel@tonic-gate #define	MD_DB_USERREQ	(MDIOC|28)
632*0Sstevel@tonic-gate #define	MD_DB_GETOPTLOC	(MDIOC|29)	/* get locators for opt resync rec. */
633*0Sstevel@tonic-gate #define	MD_DB_OWNSET	(MDIOC|30)	/* Does caller own the set */
634*0Sstevel@tonic-gate #define	MD_IOCGETNSET	(MDIOC|31)	/* Get the config'd number sets */
635*0Sstevel@tonic-gate #define	MD_IOCNXTKEY_NM	(MDIOC|32)	/* get next key from namespace */
636*0Sstevel@tonic-gate #define	MD_DB_NEWSIDE	(MDIOC|33)	/* add another side to the db replica */
637*0Sstevel@tonic-gate #define	MD_DB_DELSIDE	(MDIOC|34)	/* delete a side from the db replica */
638*0Sstevel@tonic-gate #define	MD_IOCGVERSION	(MDIOC|35)	/* get the driver version */
639*0Sstevel@tonic-gate #define	MD_IOCSET_FLAGS	(MDIOC|36)	/* set the userflags of a metadevice */
640*0Sstevel@tonic-gate #define	MD_IOCGETNUNITS	(MDIOC|37)	/* Get the config'd number units */
641*0Sstevel@tonic-gate #define	MD_IOCNOTIFY	(MDIOC|38)	/* notification */
642*0Sstevel@tonic-gate #define	MD_IOCRENAME	(MDIOC|39)	/* (Ex)Change/Rename unit identities */
643*0Sstevel@tonic-gate #define	MD_IOCISOPEN	(MDIOC|40)	/* Is metadevice open? */
644*0Sstevel@tonic-gate #define	MD_IOCSETREGEN	(MDIOC|41)	/* regen ioctl for raid */
645*0Sstevel@tonic-gate #define	MD_MED_GET_LST	(MDIOC|42)	/* Get the mediator list */
646*0Sstevel@tonic-gate #define	MD_MED_SET_LST	(MDIOC|43)	/* Set the mediator list */
647*0Sstevel@tonic-gate #define	MD_MED_UPD_MED	(MDIOC|44)	/* Have the kernel push mediator data */
648*0Sstevel@tonic-gate #define	MD_MED_GET_NMED	(MDIOC|45)	/* Get the max number of mediators */
649*0Sstevel@tonic-gate #define	MD_MED_GET_TLEN	(MDIOC|46)	/* Get the mediator transport tbl len */
650*0Sstevel@tonic-gate #define	MD_MED_GET_T	(MDIOC|47)	/* Get the mediator transport tbl */
651*0Sstevel@tonic-gate #define	MD_MED_SET_T	(MDIOC|48)	/* Set the mediator transport tbl */
652*0Sstevel@tonic-gate #define	MD_MED_GET_TAG	(MDIOC|49)	/* Get the list of data tags */
653*0Sstevel@tonic-gate #define	MD_MED_USE_TAG	(MDIOC|50)	/* Use one of the data tags */
654*0Sstevel@tonic-gate #define	MD_MED_ACCEPT	(MDIOC|51)	/* Accept 1/2 n 1/2 */
655*0Sstevel@tonic-gate #define	MD_GET_SETSTAT	(MDIOC|52)	/* Get the s_status for a set */
656*0Sstevel@tonic-gate #define	MD_SET_SETSTAT	(MDIOC|53)	/* Set the s_status for a set */
657*0Sstevel@tonic-gate #define	MD_IOCPROBE_DEV (MDIOC|54)	/* Force pseudo opens for metadevices */
658*0Sstevel@tonic-gate #define	MD_IOCGET_DID	(MDIOC|55)	/* Get device id */
659*0Sstevel@tonic-gate #define	MD_IOCUPD_NM	(MDIOC|56)	/* Update namespace */
660*0Sstevel@tonic-gate #define	MD_DB_SETDID	(MDIOC|57)	/* Set device id for a locator block */
661*0Sstevel@tonic-gate #define	MD_IOCUPD_LOCNM	(MDIOC|58)	/* update locator namespace */
662*0Sstevel@tonic-gate #define	MD_SETNMDID	(MDIOC|59)	/* update namespace devid */
663*0Sstevel@tonic-gate #define	MD_IOCDID_STAT	(MDIOC|60)	/* get invalid device id's */
664*0Sstevel@tonic-gate #define	MD_UPGRADE_STAT	(MDIOC|61)	/* get upgrade status information */
665*0Sstevel@tonic-gate #define	MD_IOCGET_NUM	(MDIOC|62)	/* get number of devs and devs */
666*0Sstevel@tonic-gate #define	MD_IOCGET_TSTATE (MDIOC|63)	/* get ui_tstate for metastat */
667*0Sstevel@tonic-gate #define	MD_SETMASTER	(MDIOC|64)
668*0Sstevel@tonic-gate #define	MD_MN_SET_DOORH		(MDIOC|65) /* MN: set the doorhandle */
669*0Sstevel@tonic-gate #define	MD_MN_OPEN_TEST		(MDIOC|66) /* MN: check / (un)lock a md */
670*0Sstevel@tonic-gate #define	MD_MN_SET_MM_OWNER	(MDIOC|67) /* Set mirror owner */
671*0Sstevel@tonic-gate #define	MD_MN_SET_NODEID	(MDIOC|68) /* Set this node's id */
672*0Sstevel@tonic-gate #define	MD_MN_SET_STATE		(MDIOC|69) /* Set mirror state */
673*0Sstevel@tonic-gate #define	MD_MN_SUSPEND_WRITES	(MDIOC|70) /* Blocks writes */
674*0Sstevel@tonic-gate #define	MD_MN_GET_MM_OWNER	(MDIOC|71) /* Get mirror owner */
675*0Sstevel@tonic-gate #define	MD_IOCGUNIQMSGID	(MDIOC|72) /* create a unique message ID */
676*0Sstevel@tonic-gate #define	MD_MN_MM_OWNER_STATUS 	(MDIOC|73) /* Return status of SET_MM_OWNER */
677*0Sstevel@tonic-gate #define	MD_MN_ALLOCATE_HOTSPARE (MDIOC|74) /* Allocate hotspare */
678*0Sstevel@tonic-gate #define	MD_MN_SUBMIRROR_STATE 	(MDIOC|75) /* Submirror state change */
679*0Sstevel@tonic-gate #define	MD_MN_RESYNC		(MDIOC|76) /* Resync ioctl */
680*0Sstevel@tonic-gate #define	MD_MN_SUSPEND_SET	(MDIOC|77) /* suspend IO's for a MN diskset */
681*0Sstevel@tonic-gate #define	MD_MN_RESUME_SET	(MDIOC|78) /* resume IO's for a MN diskset */
682*0Sstevel@tonic-gate #define	MD_MN_MDDB_PARSE	(MDIOC|79) /* Re-parse portion of MNset mddb */
683*0Sstevel@tonic-gate #define	MD_MN_MDDB_BLOCK	(MDIOC|80) /* Block parse or record changes */
684*0Sstevel@tonic-gate #define	MD_MN_MDDB_OPTRECFIX	(MDIOC|81) /* Fix optimized record failure */
685*0Sstevel@tonic-gate #define	MD_MN_SET_CAP		(MDIOC|82) /* set capability, eg ABR, DMR */
686*0Sstevel@tonic-gate #define	MD_MN_CHK_WRT_MDDB	(MDIOC|83) /* New master checks/writes mddb */
687*0Sstevel@tonic-gate #define	MD_MN_SET_SETFLAGS	(MDIOC|84) /* Set/reset set flags */
688*0Sstevel@tonic-gate #define	MD_MN_GET_SETFLAGS	(MDIOC|85) /* Gets set flags */
689*0Sstevel@tonic-gate #define	MD_IOCGET_DIDMIN	(MDIOC|94) /* get the minor name for a devid */
690*0Sstevel@tonic-gate #define	MD_IOCIMP_LOAD		(MDIOC|95) /* load the import replicas */
691*0Sstevel@tonic-gate #define	MD_IOCSET_DID		(MDIOC|96) /* set the devid of a disk */
692*0Sstevel@tonic-gate #define	MD_MN_GET_MIRROR_STATE	(MDIOC|97) /* Get the mirror state MN only */
693*0Sstevel@tonic-gate #define	MD_MN_DB_USERREQ	(MDIOC|98) /* MN MT-version of USERREQ */
694*0Sstevel@tonic-gate #define	MD_IOCMAKE_DEV		(MDIOC|99) /* create device node for unit */
695*0Sstevel@tonic-gate #define	MD_MN_SET_COMMD_RUNNING	(MDIOC|100) /* Commd running or exiting */
696*0Sstevel@tonic-gate #define	MD_MN_COMMD_ERR		(MDIOC|101) /* get a message out */
697*0Sstevel@tonic-gate #define	MD_MN_SETSYNC		(MDIOC|102) /* multi-threaded MD_IOCSETSYNC */
698*0Sstevel@tonic-gate #define	MD_MN_POKE_HOTSPARES	(MDIOC|103) /* poke hotspares */
699*0Sstevel@tonic-gate #define	MD_DB_LBINITTIME	(MDIOC|104) /* get the lb_inittime */
700*0Sstevel@tonic-gate 
701*0Sstevel@tonic-gate #define	MDIOC_MISC	(MDIOC|128)	/* misc module base */
702*0Sstevel@tonic-gate /* Used in DEBUG_TEST code */
703*0Sstevel@tonic-gate #define	MD_MN_CHECK_DOOR1 (MDIOC|126)	/* MN: test door to master */
704*0Sstevel@tonic-gate #define	MD_MN_CHECK_DOOR2 (MDIOC|127)	/* MN: test door master-broadcast */
705*0Sstevel@tonic-gate 
706*0Sstevel@tonic-gate #define	NODBNEEDED(c)	((c) == MD_IOCNOTIFY)
707*0Sstevel@tonic-gate 
708*0Sstevel@tonic-gate typedef struct md_resync_ioctl {
709*0Sstevel@tonic-gate 	MD_DRIVER
710*0Sstevel@tonic-gate 	md_error_t	mde;
711*0Sstevel@tonic-gate 	minor_t		ri_mnum;	    /* mirror to sync */
712*0Sstevel@tonic-gate 	diskaddr_t	ri_copysize;	    /* The size of the copy buffer */
713*0Sstevel@tonic-gate 	int		ri_zerofill;	    /* Zerofill on lec read error */
714*0Sstevel@tonic-gate 	int		ri_percent_done;    /* percent done current phase */
715*0Sstevel@tonic-gate 	int		ri_percent_dirty;
716*0Sstevel@tonic-gate 	md_riflags_t	ri_flags;
717*0Sstevel@tonic-gate } md_resync_ioctl_t;
718*0Sstevel@tonic-gate 
719*0Sstevel@tonic-gate typedef struct md_rrsize {
720*0Sstevel@tonic-gate 	MD_DRIVER
721*0Sstevel@tonic-gate 	md_error_t	mde;		/* error return */
722*0Sstevel@tonic-gate 	minor_t		mnum;		/* unit # to get */
723*0Sstevel@tonic-gate 	ulong_t		rr_num;		/* Number of resync regions */
724*0Sstevel@tonic-gate 	ulong_t		rr_blksize;	/* Blocksize of regions */
725*0Sstevel@tonic-gate } md_rrsize_t;
726*0Sstevel@tonic-gate 
727*0Sstevel@tonic-gate typedef	enum replace_cmd {
728*0Sstevel@tonic-gate 	REPLACE_COMP, ENABLE_COMP, FORCE_REPLACE_COMP, FORCE_ENABLE_COMP
729*0Sstevel@tonic-gate } replace_cmd_t;
730*0Sstevel@tonic-gate 
731*0Sstevel@tonic-gate typedef struct replace_params {
732*0Sstevel@tonic-gate 	MD_DRIVER
733*0Sstevel@tonic-gate 	md_error_t	mde;
734*0Sstevel@tonic-gate 	replace_cmd_t	cmd;		/* what to do */
735*0Sstevel@tonic-gate 	minor_t		mnum;		/* mirror to act upon */
736*0Sstevel@tonic-gate 	md_dev64_t	old_dev;	/* enable/replace use this */
737*0Sstevel@tonic-gate 	md_dev64_t	new_dev;	/* replace only uses this */
738*0Sstevel@tonic-gate 	mdkey_t		new_key;	/* replace only uses this */
739*0Sstevel@tonic-gate 	diskaddr_t	start_blk;	/* start block of new device */
740*0Sstevel@tonic-gate 	int		has_label;	/* has label flag of new device */
741*0Sstevel@tonic-gate 	diskaddr_t	number_blks;	/* # of blocks of new device */
742*0Sstevel@tonic-gate 	uint_t		options;	/* misc options, see MDIOCTL_* below */
743*0Sstevel@tonic-gate } replace_params_t;
744*0Sstevel@tonic-gate 
745*0Sstevel@tonic-gate typedef struct md_i_off_on {
746*0Sstevel@tonic-gate 	MD_DRIVER
747*0Sstevel@tonic-gate 	md_error_t	mde;
748*0Sstevel@tonic-gate 	minor_t		mnum;
749*0Sstevel@tonic-gate 	md_dev64_t	submirror;
750*0Sstevel@tonic-gate 	int		force_offline;
751*0Sstevel@tonic-gate } md_i_off_on_t;
752*0Sstevel@tonic-gate 
753*0Sstevel@tonic-gate typedef struct md_att_struct {
754*0Sstevel@tonic-gate 	MD_DRIVER
755*0Sstevel@tonic-gate 	md_error_t	mde;		/* Normal error */
756*0Sstevel@tonic-gate 	minor_t		mnum;
757*0Sstevel@tonic-gate 	mdkey_t		key;		/* namespace key of sm */
758*0Sstevel@tonic-gate 	md_dev64_t	submirror;	/* The device  to attach */
759*0Sstevel@tonic-gate 	uint_t		options;	/* passed in from the command */
760*0Sstevel@tonic-gate } md_att_struct_t;
761*0Sstevel@tonic-gate 
762*0Sstevel@tonic-gate /* possible values for options above */
763*0Sstevel@tonic-gate #define	MDIOCTL_DRYRUN		0x0001	/* Only check if operation possible */
764*0Sstevel@tonic-gate #define	MDIOCTL_NO_RESYNC_RAID	0x0002	/* if cluster replace we don't */
765*0Sstevel@tonic-gate 					/*    want to resync */
766*0Sstevel@tonic-gate 
767*0Sstevel@tonic-gate typedef struct md_detach_params {
768*0Sstevel@tonic-gate 	MD_DRIVER
769*0Sstevel@tonic-gate 	md_error_t	mde;
770*0Sstevel@tonic-gate 	minor_t		mnum;		/* mirror to act upon */
771*0Sstevel@tonic-gate 	md_dev64_t	submirror;
772*0Sstevel@tonic-gate 	int		force_detach;
773*0Sstevel@tonic-gate } md_detach_params_t;
774*0Sstevel@tonic-gate 
775*0Sstevel@tonic-gate /*
776*0Sstevel@tonic-gate  * Structure for accessing the DB from user land.
777*0Sstevel@tonic-gate  */
778*0Sstevel@tonic-gate typedef struct mddb_userreq {
779*0Sstevel@tonic-gate 	md_error_t		ur_mde;
780*0Sstevel@tonic-gate 	mddb_usercmd_t		ur_cmd;
781*0Sstevel@tonic-gate 	set_t			ur_setno;
782*0Sstevel@tonic-gate 	mddb_type_t		ur_type;
783*0Sstevel@tonic-gate 	uint_t			ur_type2;
784*0Sstevel@tonic-gate 	mddb_recid_t		ur_recid;
785*0Sstevel@tonic-gate 	mddb_recstatus_t	ur_recstat;
786*0Sstevel@tonic-gate 	int			ur_size;
787*0Sstevel@tonic-gate 	uint64_t		ur_data;	/* Pointer to user data */
788*0Sstevel@tonic-gate } mddb_userreq_t;
789*0Sstevel@tonic-gate 
790*0Sstevel@tonic-gate /*
791*0Sstevel@tonic-gate  * Ioctl structure for MD_IOCISOPEN
792*0Sstevel@tonic-gate  */
793*0Sstevel@tonic-gate typedef struct md_isopen {
794*0Sstevel@tonic-gate 	md_error_t	mde;
795*0Sstevel@tonic-gate 	md_dev64_t	dev;
796*0Sstevel@tonic-gate 	int		isopen;
797*0Sstevel@tonic-gate } md_isopen_t;
798*0Sstevel@tonic-gate 
799*0Sstevel@tonic-gate /*
800*0Sstevel@tonic-gate  * Ioctl structure for MD_MN_OPEN_TEST
801*0Sstevel@tonic-gate  * md_clu_open stands for md check/lock/unlock
802*0Sstevel@tonic-gate  * Can't use MD_IOCISOPEN, because it's a contracted inteface.
803*0Sstevel@tonic-gate  */
804*0Sstevel@tonic-gate typedef struct md_clu_open {
805*0Sstevel@tonic-gate 	md_error_t	clu_mde;
806*0Sstevel@tonic-gate 	md_dev64_t	clu_dev;
807*0Sstevel@tonic-gate 	enum {	MD_MN_LCU_CHECK = 0,
808*0Sstevel@tonic-gate 		MD_MN_LCU_LOCK,
809*0Sstevel@tonic-gate 		MD_MN_LCU_UNLOCK } clu_cmd;
810*0Sstevel@tonic-gate 	int		clu_isopen;
811*0Sstevel@tonic-gate } md_clu_open_t;
812*0Sstevel@tonic-gate 
813*0Sstevel@tonic-gate /*
814*0Sstevel@tonic-gate  * Structure to push the message out from commd
815*0Sstevel@tonic-gate  * MAXPATHLEN macro is being overloaded to represent
816*0Sstevel@tonic-gate  * the line size of 1024 characters. i.e. no path
817*0Sstevel@tonic-gate  * is being passed.
818*0Sstevel@tonic-gate  */
819*0Sstevel@tonic-gate typedef struct md_mn_commd_err {
820*0Sstevel@tonic-gate 	int size;
821*0Sstevel@tonic-gate 	uint64_t md_message; /* pointer to array of chars */
822*0Sstevel@tonic-gate } md_mn_commd_err_t;
823*0Sstevel@tonic-gate 
824*0Sstevel@tonic-gate /*
825*0Sstevel@tonic-gate  * Ioctl structure for MD_IOCPROBE_DEV
826*0Sstevel@tonic-gate  */
827*0Sstevel@tonic-gate 
828*0Sstevel@tonic-gate #define	TESTNAME_LEN 32
829*0Sstevel@tonic-gate 
830*0Sstevel@tonic-gate #define	PROBE_SEMA(p)	p->probe_sema
831*0Sstevel@tonic-gate #define	PROBE_MX(p)	p->probe_mx
832*0Sstevel@tonic-gate 
833*0Sstevel@tonic-gate /*
834*0Sstevel@tonic-gate  * To categorize user/kernel structures md_probedev is split into two,
835*0Sstevel@tonic-gate  * one used by user and the other by kernel, thereby hiding the semaphore
836*0Sstevel@tonic-gate  * /mutex pointer members from user, which should be the appropriate one.
837*0Sstevel@tonic-gate  */
838*0Sstevel@tonic-gate 
839*0Sstevel@tonic-gate typedef struct md_probedev {
840*0Sstevel@tonic-gate 	MD_DRIVER
841*0Sstevel@tonic-gate 	md_error_t	mde;		/* return error status */
842*0Sstevel@tonic-gate 	int		nmdevs;		/* number of metadevices */
843*0Sstevel@tonic-gate 	char		test_name[TESTNAME_LEN];
844*0Sstevel@tonic-gate 	uint64_t	mnum_list;	/* pointer to array of minor numbers */
845*0Sstevel@tonic-gate } md_probedev_t;
846*0Sstevel@tonic-gate 
847*0Sstevel@tonic-gate typedef struct md_probedev_impl {
848*0Sstevel@tonic-gate 	ksema_t		*probe_sema;
849*0Sstevel@tonic-gate 	kmutex_t	*probe_mx;
850*0Sstevel@tonic-gate 	md_probedev_t	probe;
851*0Sstevel@tonic-gate } md_probedev_impl_t;
852*0Sstevel@tonic-gate 
853*0Sstevel@tonic-gate /*
854*0Sstevel@tonic-gate  * Ioctl structure for MD_MN_GET_MIRROR_STATE
855*0Sstevel@tonic-gate  */
856*0Sstevel@tonic-gate typedef struct md_mn_get_mir_state {
857*0Sstevel@tonic-gate 	MD_DRIVER
858*0Sstevel@tonic-gate 	minor_t		mnum;		/* Unit to obtain submirror info from */
859*0Sstevel@tonic-gate } md_mn_get_mir_state_t;
860*0Sstevel@tonic-gate 
861*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
862*0Sstevel@tonic-gate #pragma pack()
863*0Sstevel@tonic-gate #endif
864*0Sstevel@tonic-gate /*
865*0Sstevel@tonic-gate  * Per set flags, stored in md_set[n].s_status
866*0Sstevel@tonic-gate  */
867*0Sstevel@tonic-gate #define	MD_SET_HALTED		0x00000001  /* Set is shut down */
868*0Sstevel@tonic-gate #define	MD_SET_SNARFED		0x00000002  /* incores built for set db recs */
869*0Sstevel@tonic-gate #define	MD_SET_SNARFING		0x00000004  /* incores being built for set */
870*0Sstevel@tonic-gate #define	MD_SET_STALE		0x00000008  /* set database not correct */
871*0Sstevel@tonic-gate #define	MD_SET_NM_LOADED	0x00000010  /* set namespace is loaded */
872*0Sstevel@tonic-gate #define	MD_SET_TAGDATA		0x00000020  /* tagged data detected */
873*0Sstevel@tonic-gate #define	MD_SET_ACCOK		0x00000040  /* Accept data is possible */
874*0Sstevel@tonic-gate #define	MD_SET_TOOFEW		0x00000080  /* not enough replicas */
875*0Sstevel@tonic-gate #define	MD_SET_USETAG		0x00000100  /* A tag is selected, use it */
876*0Sstevel@tonic-gate #define	MD_SET_ACCEPT		0x00000200  /* User chose accept 50/50 mode */
877*0Sstevel@tonic-gate #define	MD_SET_OWNERSHIP	0x00000400  /* Set is owned */
878*0Sstevel@tonic-gate #define	MD_SET_BADTAG		0x00000800  /* DT is not valid */
879*0Sstevel@tonic-gate #define	MD_SET_CLRTAG		0x00001000  /* Clear the tags */
880*0Sstevel@tonic-gate #define	MD_SET_KEEPTAG		0x00002000  /* Keep the tag */
881*0Sstevel@tonic-gate #define	MD_SET_PUSHLB		0x00004000  /* Indicate a LB push is needed */
882*0Sstevel@tonic-gate #define	MD_SET_MNSET		0x00008000  /* Set is a multinode diskset */
883*0Sstevel@tonic-gate #define	MD_SET_DIDCLUP		0x00010000  /* Set has cleaned up devids */
884*0Sstevel@tonic-gate #define	MD_SET_MNPARSE_BLK	0x00020000  /* Do not send parse msgs */
885*0Sstevel@tonic-gate #define	MD_SET_MN_NEWMAS_RC	0x00040000  /* Is new master during reconfig */
886*0Sstevel@tonic-gate #define	MD_SET_MN_START_RC	0x00080000  /* Start step executed for set */
887*0Sstevel@tonic-gate #define	MD_SET_IMPORT		0x00100000  /* Indicate set is importing */
888*0Sstevel@tonic-gate #define	MD_SET_MN_MIR_STATE_RC	0x00200000  /* Mirror state gotten for set */
889*0Sstevel@tonic-gate #define	MD_SET_HOLD		0x00400000  /* Hold set during release */
890*0Sstevel@tonic-gate #define	MD_SET_REPLICATED_IMPORT	0x00800000  /* Set importing RC disk */
891*0Sstevel@tonic-gate 
892*0Sstevel@tonic-gate #define	MD_MNSET_SETNO(setno)	(md_set[setno].s_status & MD_SET_MNSET)
893*0Sstevel@tonic-gate 
894*0Sstevel@tonic-gate /*
895*0Sstevel@tonic-gate  * See meta_prbits() in SUNWmd/lib/libmeta/meta_print.c for a description of
896*0Sstevel@tonic-gate  * the way this is used
897*0Sstevel@tonic-gate  */
898*0Sstevel@tonic-gate #define	MD_SET_STAT_BITS "\020\001HALTED\002SNARFED\003SNARFING\004STALE" \
899*0Sstevel@tonic-gate 			    "\005NM_LOADED\006TAGDATA\007ACCOK\010TOOFEW" \
900*0Sstevel@tonic-gate 			    "\011USETAG\012ACCEPT\013OWNERSHIP\014BADTAG" \
901*0Sstevel@tonic-gate 			    "\015CLRTAG\016KEEPTAG\017PUSHLB\020MNSET" \
902*0Sstevel@tonic-gate 			    "\021DIDCLUP\022MNPARSE_BLK\023MN_NEWMAS_RC" \
903*0Sstevel@tonic-gate 			    "\024MN_START_RC\025IMPORT\026MIR_STATE_RC" \
904*0Sstevel@tonic-gate 			    "\027HOLD\030REPLICATED_IMPORT"
905*0Sstevel@tonic-gate 
906*0Sstevel@tonic-gate 
907*0Sstevel@tonic-gate #ifdef	__cplusplus
908*0Sstevel@tonic-gate }
909*0Sstevel@tonic-gate #endif
910*0Sstevel@tonic-gate 
911*0Sstevel@tonic-gate #endif	/* _SYS__MDIO_H */
912