xref: /titanic_41/usr/src/uts/common/avs/ns/dsw/dsw.h (revision 2a8d6eba033e4713ab12b61178f0513f1f075482)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_DSW_H
27 #define	_DSW_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Miscellaneous defines
35  */
36 
37 #define	DSW_BITS	8	/* # of bits in a byte */
38 #define	DSW_SIZE	64	/* fba's in a DSW chunk */
39 
40 
41 /*
42  * Ioctl definitions
43  */
44 
45 #define	_D_(x)			(('D'<<16)|('W'<<8)|(x))
46 
47 #define	DSWIOC_ENABLE		_D_(1)	/* Configure DSW pair */
48 #define	DSWIOC_RESUME		_D_(2)	/* Resume a DSW pair */
49 #define	DSWIOC_SUSPEND		_D_(3)	/* Suspend a DSW pair */
50 #define	DSWIOC_COPY		_D_(4)	/* Copy DSW volume over its pair */
51 #define	DSWIOC_BITMAP		_D_(5)	/* Get bitmap */
52 #define	DSWIOC_STAT		_D_(6)	/* Get state of shadow */
53 #define	DSWIOC_DISABLE		_D_(7)	/* Deconfigure DSW pair */
54 #define	DSWIOC_SHUTDOWN		_D_(8)	/* Suspend all DSW pairs */
55 #define	DSWIOC_ABORT		_D_(9)	/* Abort Copy of DSW pair */
56 #define	DSWIOC_VERSION		_D_(10)	/* DataShadow version */
57 #define	DSWIOC_RESET		_D_(11)	/* Reset DataShadow set */
58 #define	DSWIOC_OFFLINE		_D_(12)	/* Offline volumes */
59 #define	DSWIOC_WAIT		_D_(13)	/* Wait for copy to complete */
60 #define	DSWIOC_LIST		_D_(14)	/* List current kernel shadow groups */
61 #define	DSWIOC_ACOPY		_D_(15)	/* Copy DSW volumes over their pairs */
62 #define	DSWIOC_EXPORT		_D_(16)	/* Export the shadow volume */
63 #define	DSWIOC_IMPORT		_D_(17)	/* Import shadow volume */
64 #define	DSWIOC_JOIN		_D_(18)	/* Rejoin previously exported shadow */
65 #define	DSWIOC_COPYP		_D_(19)	/* Set and get copy parameters */
66 #define	DSWIOC_OCREAT		_D_(20)	/* Create overflow volume */
67 #define	DSWIOC_OATTACH		_D_(21)	/* Attach overflow volume */
68 #define	DSWIOC_ODETACH		_D_(22)	/* Detach overflow volume */
69 #define	DSWIOC_OLIST		_D_(23)	/* List overflow volumes */
70 #define	DSWIOC_OSTAT		_D_(24)	/* Stat overflow volume */
71 #define	DSWIOC_SBITSSET		_D_(25)	/* Get # of bits set in shadow bitmap */
72 #define	DSWIOC_CBITSSET		_D_(26)	/* Get # of bits set in copy bitmap */
73 #define	DSWIOC_LISTLEN		_D_(27)	/* length of DSWIOC_LIST data */
74 #define	DSWIOC_OLISTLEN		_D_(28)	/* length of DSWIOC_OLIST data */
75 #define	DSWIOC_SEGMENT		_D_(29) /* Get segemented bitmaps */
76 #define	DSWIOC_MOVEGRP		_D_(30)	/* Move set from one group to another */
77 #define	DSWIOC_CLIST		_D_(31) /* get list of resource groups */
78 #define	DSWIOC_GLIST		_D_(32)	/* get list of groups */
79 #define	DSWIOC_CHANGETAG	_D_(33)	/* change the cluster tag of a set */
80 #define	DSWIOC_OSTAT2		_D_(34) /* Stat overflow volume enhanced */
81 
82 /*
83  * Config and status flags
84  */
85 
86 #define	DSW_GOLDEN	0x0001		/* the set is independent */
87 
88 #define	DSW_COPYINGP	0x0100		/* Copy in progress */
89 #define	DSW_COPYINGM	0x0200		/* Copying master to shadow */
90 #define	DSW_COPYINGS	0x0400		/* Copying shadow to master */
91 #define	DSW_COPYING	0x0600		/* Copying, may be in progress */
92 #define	DSW_COPY_FLAGS	0x0700		/* Copy flags */
93 #define	DSW_COPYINGX	0x0800		/* Copy exit requested */
94 #define	DSW_OFFLINE	0xf000		/* An underlying volume offline */
95 #define	DSW_BMPOFFLINE	0x1000		/* Bitmap volume offline */
96 #define	DSW_SHDOFFLINE	0x2000		/* Shadow volume offline */
97 #define	DSW_MSTOFFLINE	0x4000		/* Master volume offline */
98 #define	DSW_OVROFFLINE	0x8000		/* Overflow volume offline */
99 #define	DSW_TREEMAP	0x10000		/* Shadow volume accessed by an index */
100 #define	DSW_OVERFLOW	0x20000		/* Shadow volume has overflowed */
101 #define	DSW_SHDEXPORT	0x40000		/* Shadow volume has been exported */
102 #define	DSW_SHDIMPORT	0x80000		/* Shadow volume has been imported */
103 #define	DSW_VOVERFLOW	0x100000	/* Shadow volume using overflow vol */
104 #define	DSW_HANGING	0x200000	/* Hanging master structure  */
105 #define	DSW_CFGOFFLINE	0x400000	/* config db is offline */
106 #define	DSW_OVRHDRDRTY	0x800000	/* Overflow header dirty */
107 #define	DSW_RESIZED	0x1000000	/* mst_size != shd_size */
108 #define	DSW_FRECLAIM	0x2000000	/* force the reclaim of an ovr vol */
109 
110 /*
111  * used for SNMP trap only.
112  * These flags help distinguish between enable and resume,
113  * suspend and disable.
114  * Note that DSW_HANGING is set for both suspend and disable
115  */
116 #define	DSW_SNMP_CLR		0	/* no flag is set	*/
117 #define	DSW_SNMP_DISABLE	1	/* Set is disabled	*/
118 #define	DSW_SNMP_SUSPEND	2	/* Set is suspended	*/
119 #define	DSW_SNMP_ENABLE		3	/* Set is enabled	*/
120 #define	DSW_SNMP_RESUME		4	/* Set is resumed	*/
121 #define	DSW_SNMP_OVER_ATTACH	5	/* overflow attached	*/
122 #define	DSW_SNMP_OVER_DETACH	6	/* overflow detached	*/
123 #define	DSW_SNMP_UPDATE		7	/* update operation	*/
124 #define	DSW_SNMP_COPIED		8	/* copy operation	*/
125 
126 	/* Overflow volume flags */
127 #define	IIO_OFFLINE	0x0001		/* Volume is offline */
128 #define	IIO_HDR_WRTN	0x0002		/* Header written */
129 #define	IIO_CNTR_INVLD	0x0004		/* Overflow counters invalid */
130 #define	IIO_VOL_UPDATE	0x0008		/* Performing group update */
131 
132 #define	DSW_NAMELEN	64		/* NSC_MAXPATH - don't change without */
133 					/* amending header version number */
134 
135 #define	DSWDEV		"/dev/ii"
136 #define	II_IMPORTED_SHADOW "<imported_shadow>"
137 
138 /*
139  * Configuration parameter defines
140  * ii_bitmap, ii_throttle_unit, ii_throttle_delay
141  */
142 #define	II_KMEM		0	/* Load/store on resume/suspend, in memory */
143 #define	II_WTHRU	1	/* Read/write bitmap thru to bitmap volume */
144 #define	II_FWC		2	/* Read/write bitmap to FWC, else WTHRU */
145 
146 #define	MIN_THROTTLE_UNIT	100	/* Min. number of units to transfer */
147 #define	MAX_THROTTLE_UNIT	60000	/* Max. number of units to transfer */
148 #define	MIN_THROTTLE_DELAY	2	/* Min. delay between unit transfer */
149 #define	MAX_THROTTLE_DELAY	10000	/* Max. delay between unit transfer */
150 
151 /*
152  * DSW user config structure
153  */
154 
155 typedef struct dsw_config_s {
156 	spcs_s_info_t status;
157 	char master_vol[DSW_NAMELEN];
158 	char shadow_vol[DSW_NAMELEN];
159 	char bitmap_vol[DSW_NAMELEN];
160 	char cluster_tag[DSW_NAMELEN];
161 	char group_name[DSW_NAMELEN];
162 	int flag;
163 } dsw_config_t;
164 
165 /*
166  * DSW segmented bitmap I/O structure
167  */
168 typedef struct dsw_segment_s {
169 	spcs_s_info_t status;
170 	char shadow_vol[DSW_NAMELEN];
171 	unsigned seg_number;		/* 32KB Segment number to start at */
172 	unsigned char   *shd_bitmap;		/* pointer to shadow bitmap */
173 	int	shd_size;			/* size of shadow bitmap */
174 	unsigned char   *cpy_bitmap;		/* pointer to copy bitmap */
175 	int	cpy_size;			/* size of copy bitmap */
176 	unsigned char	*idx_bitmap;		/* pointer to index table */
177 	int	idx_size;			/* size of index table */
178 } dsw_segment_t;
179 
180 /*
181  * DSW user bitmap structure
182  */
183 
184 typedef struct dsw_bitmap_s {
185 	spcs_s_info_t status;
186 	char shadow_vol[DSW_NAMELEN];
187 	unsigned char	*shd_bitmap;		/* pointer to shadow bitmap */
188 	uint64_t shd_size;			/* size of shadow bitmap */
189 	uint64_t copy_size;			/* size of copy bitmap */
190 	unsigned char	*copy_bitmap;		/* pointer to copy bitmap */
191 } dsw_bitmap_t;
192 
193 
194 /*
195  * DSW general ioctl structure
196  */
197 
198 typedef struct dsw_ioctl_s {
199 	spcs_s_info_t status;
200 	char shadow_vol[DSW_NAMELEN];
201 	int flags;
202 	pid_t pid;
203 } dsw_ioctl_t;
204 
205 
206 /*
207  * DSW general atomic ioctl structure operating on several Image sets
208  */
209 
210 typedef struct dsw_aioctl_s {
211 	spcs_s_info_t status;
212 	int flags;
213 	int count;
214 	pid_t pid;
215 	char shadow_vol[DSW_NAMELEN];	/* start of list of image sets */
216 } dsw_aioctl_t;
217 
218 
219 /*
220  * DSW stat ioctl structure
221  */
222 
223 typedef struct dsw_stat_s {
224 	spcs_s_info_t status;
225 	char shadow_vol[DSW_NAMELEN];
226 	int stat;
227 	uint64_t size;
228 	char overflow_vol[DSW_NAMELEN];
229 	uint64_t shdsize;
230 	uint64_t shdused;
231 	char group_name[DSW_NAMELEN];
232 	char cluster_tag[DSW_NAMELEN];
233 	uint64_t mtime;
234 } dsw_stat_t;
235 
236 
237 /*
238  * DSW version ioctl structure
239  */
240 
241 typedef struct dsw_version_s {
242 	spcs_s_info_t status;
243 	int major;			/* Major release number */
244 	int minor;			/* Minor release number */
245 	int micro;			/* Micro release number */
246 	int baseline;			/* Baseline revision number */
247 } dsw_version_t;
248 
249 /*
250  * DSW get bits set in bitmap structure
251  */
252 
253 typedef struct dsw_bitsset_s {
254 	spcs_s_info_t status;
255 	char	shadow_vol[DSW_NAMELEN];
256 	uint64_t tot_size;		/* total number of bits in map */
257 	uint64_t tot_set;		/* number of bitmap bits set */
258 } dsw_bitsset_t;
259 
260 
261 /*
262  * DSW list ioctl structure
263  */
264 
265 typedef struct dsw_list_s {
266 	spcs_s_info_t status;
267 	int list_size;			/* number of elements in list */
268 	int list_used;			/* number of elements returned */
269 	dsw_config_t *list;
270 } dsw_list_t;
271 
272 /*
273  * DSW copy parameter structure
274  */
275 
276 typedef struct dsw_copyp_s {
277 	spcs_s_info_t status;
278 	char shadow_vol[DSW_NAMELEN];
279 	int copy_unit;
280 	int copy_delay;
281 } dsw_copyp_t;
282 
283 /*
284  * DSW ostat ioctl structure
285  */
286 
287 typedef struct dsw_ostat_s {
288 	spcs_s_info_t status;
289 	char overflow_vol[DSW_NAMELEN];
290 	int drefcnt;
291 	uint64_t used;
292 	uint64_t unused;
293 	uint64_t nchunks;
294 	int crefcnt;
295 	int flags;
296 	int hversion;
297 	int hmagic;
298 } dsw_ostat_t;
299 
300 /*
301  * DSW move group structure
302  */
303 
304 typedef struct dsw_movegrp_s {
305 	spcs_s_info_t status;
306 	char shadow_vol[DSW_NAMELEN];
307 	char new_group[DSW_NAMELEN];
308 } dsw_movegrp_t;
309 
310 /*
311  * II_PIT_PROPS structure
312  */
313 typedef struct pit_props_s {
314 	int iirc;
315 	int mstid;
316 	int shdid;
317 	int bmpid;
318 	int ovrid;
319 	char group[DSW_NAMELEN];
320 	char cluster[DSW_NAMELEN];
321 	int  has_overflow;
322 	int  flags;
323 	uint64_t  size;
324 	int64_t  shdchks;
325 	int64_t  copybits;
326 	int64_t  shdbits;
327 } pit_props_t;
328 
329 /*
330  * II_PIT_UPDATE structure
331  */
332 typedef struct pit_update_s {
333 	int iirc;
334 	char direction;
335 } pit_update_t;
336 
337 #ifdef _KERNEL
338 /*
339  * 32 bit versions of ioctl structures
340  */
341 
342 typedef struct dsw_config32_s {
343 	spcs_s_info32_t status;
344 	char master_vol[DSW_NAMELEN];
345 	char shadow_vol[DSW_NAMELEN];
346 	char bitmap_vol[DSW_NAMELEN];
347 	char cluster_tag[DSW_NAMELEN];
348 	char group_name[DSW_NAMELEN];
349 	int flag;
350 } dsw_config32_t;
351 
352 /*
353  * DSW segmented bitmap I/O structure
354  */
355 typedef struct dsw_segment32_s {
356 	spcs_s_info32_t status;
357 	char shadow_vol[DSW_NAMELEN];
358 	uint32_t seg_number;
359 	uint32_t shd_bitmap;
360 	int	 shd_size;
361 	uint32_t cpy_bitmap;
362 	int	 cpy_size;
363 	uint32_t idx_bitmap;
364 	int	 idx_size;
365 } dsw_segment32_t;
366 
367 /*
368  * DSW user bitmap structure
369  */
370 
371 typedef struct dsw_bitmap32_s {
372 	spcs_s_info32_t status;
373 	char shadow_vol[DSW_NAMELEN];
374 	uint32_t shd_bitmap;		/* 32 bit pointer value */
375 	uint64_t shd_size;
376 	uint64_t copy_size;
377 	uint32_t copy_bitmap;		/* 32 bit pointer value */
378 } dsw_bitmap32_t;
379 
380 typedef struct dsw_ioctl32_s {
381 	spcs_s_info32_t status;
382 	char shadow_vol[DSW_NAMELEN];
383 	int flags;
384 	pid_t pid;
385 } dsw_ioctl32_t;
386 
387 typedef struct dsw_stat32_s {
388 	spcs_s_info32_t status;
389 	char shadow_vol[DSW_NAMELEN];
390 	int stat;
391 	uint64_t size;
392 	char overflow_vol[DSW_NAMELEN];
393 	uint64_t shdsize;
394 	uint64_t shdused;
395 	char group_name[DSW_NAMELEN];
396 	char cluster_tag[DSW_NAMELEN];
397 	uint64_t mtime;
398 } dsw_stat32_t;
399 
400 typedef struct dsw_version32_s {
401 	spcs_s_info32_t status;
402 	int major;			/* Major release number */
403 	int minor;			/* Minor release number */
404 	int micro;			/* Micro release number */
405 	int baseline;			/* Baseline revision number */
406 } dsw_version32_t;
407 
408 typedef struct dsw_bitsset32_s {
409 	spcs_s_info32_t status;
410 	char	shadow_vol[DSW_NAMELEN];
411 	uint64_t	tot_size;	/* total number of bits in map */
412 	uint64_t	tot_set;	/* number of bitmap bits set */
413 } dsw_bitsset32_t;
414 
415 typedef struct dsw_list32_s {
416 	spcs_s_info32_t status;
417 	int list_size;
418 	int list_used;
419 	uint32_t list;
420 } dsw_list32_t;
421 
422 typedef struct dsw_aioctl32_s {
423 	spcs_s_info32_t status;
424 	int flags;
425 	int count;
426 	pid_t pid;
427 	char shadow_vol[DSW_NAMELEN];	/* start of list of image sets */
428 } dsw_aioctl32_t;
429 
430 typedef struct dsw_copyp32_s {
431 	spcs_s_info32_t status;
432 	char shadow_vol[DSW_NAMELEN];
433 	int copy_unit;
434 	int copy_delay;
435 } dsw_copyp32_t;
436 
437 typedef struct dsw_ostat32_s {
438 	spcs_s_info32_t status;
439 	char overflow_vol[DSW_NAMELEN];
440 	int drefcnt;
441 	uint64_t used;
442 	uint64_t unused;
443 	uint64_t nchunks;
444 	int crefcnt;
445 	int flags;
446 	int hversion;
447 	int hmagic;
448 } dsw_ostat32_t;
449 
450 /*
451  * DSW move group structure
452  */
453 
454 typedef struct dsw_movegrp32_s {
455 	spcs_s_info32_t status;
456 	char shadow_vol[DSW_NAMELEN];
457 	char new_group[DSW_NAMELEN];
458 } dsw_movegrp32_t;
459 
460 #endif	/* _KERNEL */
461 
462 /* dsw_copy dsw_ioctl_t flag bits */
463 #define	CV_BMP_ONLY	0x00000001	/* copy only chunks flagged by bitmap */
464 #define	CV_SHD2MST	0x00000002	/* copy shadow to master */
465 #define	CV_LOCK_PID	0x00000004	/* On copy/update, lock PIT by PID */
466 #define	CV_CLR_BMP	0x00000010	/* clear bits in bit map during copy */
467 #define	CV_IS_CLUSTER	0x00000020	/* struct refers to cluster */
468 #define	CV_IS_GROUP	0x00000040	/* struct refers to group (cpy/upd) */
469 #define	CV_SIBLING	0x00010000	/* internal copy_on_write flag */
470 
471 /* nsc_control commands */
472 
473 #define	II_CONTROL(x)	('I' << 24 | 'I' << 16 | (x))	/* 0x49490000 */
474 
475 #define	II_PIT_COPY	II_CONTROL(1)	/* Perform an II Copy */
476 #define	II_PIT_UPDATE	II_CONTROL(2)	/* Perform an II Update */
477 #define	II_PIT_ABORT	II_CONTROL(3)	/* Perform an II Abort */
478 #define	II_PIT_WAIT	II_CONTROL(4)	/* Perform an II Wait */
479 #define	II_PIT_PROPS	II_CONTROL(5)	/* Perform an II Properties */
480 
481 #ifdef __cplusplus
482 }
483 #endif
484 
485 #endif	/* _DSW_H */
486