xref: /titanic_51/usr/src/uts/common/avs/ns/rdc/rdc_ioctl.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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	_RDC_IOCTL_H
27 #define	_RDC_IOCTL_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/unistat/spcs_s.h>
34 #include <sys/nsctl/nsctl.h>
35 #ifndef DS_DDICT
36 #include <rpc/rpc.h>
37 #endif
38 
39 #ifdef _SunOS_5_6
40 #define	netbuf32 netbuf
41 #include <sys/nsctl/model.h>
42 #endif
43 
44 typedef struct _rdc_ioctl_s {
45 	long arg0;
46 	long arg1;
47 	long arg2;
48 	long arg3;
49 	long arg4;
50 	long magic;
51 	spcs_s_info_t ustatus;
52 	long pad[1];
53 } _rdc_ioctl_t;
54 
55 #ifdef _SYSCALL32
56 typedef struct _rdc_ioctl32_s {
57 	int32_t arg0;
58 	int32_t arg1;
59 	int32_t arg2;
60 	int32_t arg3;
61 	int32_t arg4;
62 	int32_t magic;
63 	spcs_s_info32_t ustatus;
64 	int32_t pad[1];
65 } _rdc_ioctl32_t;
66 #endif /* _SYSCALL32 */
67 
68 /*
69  * Ioctl command numbers
70  */
71 
72 #define	_RDCI_(x)	(('R'<<16)|('D'<<8)|(x))
73 
74 /*
75  * Generic rdc ioctl arguments structure.
76  * Individual ioctl's will use 0-n of these arguments.
77  *
78  * Each rdc ioctl is described first by the command number
79  * e.g. #define	RDC_CONFIG		_RDCI_(0)
80  *
81  * Followed by a description of each argument (if any).
82  * Each argument is on a single line.
83  *
84  */
85 
86 #define	RDC_CONFIG		_RDCI_(0)
87 /*
88  *	rdc_config_t	*user_configuration;
89  */
90 
91 #define	RDC_ENABLE_SVR		_RDCI_(1)
92 /*
93  *	rdc_svc_args_t	*daemon_configuration;
94  */
95 
96 #define	RDC_STATUS		_RDCI_(2)
97 /*
98  *	rdc_status_t	*rdc_status;
99  */
100 
101 #define	RDC_VERSION		_RDCI_(3)
102 /*
103  *	rdc_version_t	*rdc_version;
104  */
105 
106 #define	RDC_LINK_DOWN		_RDCI_(4)
107 /*
108  *	char 		*rdc_host;
109  */
110 
111 #define	RDC_SYNC_EVENT		_RDCI_(5)
112 /*
113  *	char		*rdc_master;
114  *	char		*rdc_group;
115  */
116 
117 #define	RDC_POOL_CREATE		_RDCI_(6)
118 /*
119  * struct svcpool_args *
120  */
121 
122 #define	RDC_POOL_WAIT		_RDCI_(7)
123 /*
124  * int id
125  */
126 
127 #define	RDC_POOL_RUN		_RDCI_(8)
128 /*
129  * int id
130  */
131 #define	RDC_BITMAPOP		_RDCI_(9)
132 
133 #ifdef	DEBUG
134 #define	RDC_ASYNC6		_RDCI_(20)	/* send async message by hand */
135 #define	RDC_CLRKSTAT		_RDCI_(21)	/* clear kstat_io structure */
136 #define	RDC_STALL0		_RDCI_(22)	/* stall sequence 0 on server */
137 #define	RDC_READGEN		_RDCI_(23)	/* cause a read on server */
138 #endif
139 
140 
141 #define	MAX_RDC_HOST_SIZE	64
142 
143 /*
144  * Change this when the ioctl structure changes
145  */
146 #define	RDC_MAGIC	0xf00d0001
147 
148 typedef struct rdc_addr {
149 	struct netbuf addr;
150 	char intf[MAX_RDC_HOST_SIZE];
151 	char file[NSC_MAXPATH];
152 	char bitmap[NSC_MAXPATH];
153 } rdc_addr_t;
154 
155 #ifdef _SYSCALL32
156 struct rdc_addr32 {
157 	struct netbuf32	addr;
158 	char intf[MAX_RDC_HOST_SIZE];
159 	char file[NSC_MAXPATH];
160 	char bitmap[NSC_MAXPATH];
161 };
162 #endif /* _SYSCALL32 */
163 
164 /*
165  * User level rdc set structure - must be a multiple of 64bits long.
166  */
167 typedef struct rdc_set {
168 	rdc_addr_t primary;
169 	rdc_addr_t secondary;
170 	struct knetconfig *netconfig;
171 	long align1;
172 	double alignfix;
173 	int flags;				/* See RDC flags below */
174 	int sync_flags;				/* See RDC flags below */
175 	int bmap_flags;				/* See RDC flags below */
176 	int mflags;				/* RDC 1-to-many flags */
177 	int index;				/* 0 .. rdc_max_sets - 1 */
178 	int bits_set;				/* Bits set in bitmap */
179 	int autosync;				/* Autosync on (1) or off (0) */
180 	int syshostid;				/* for cluster integration */
181 	int asyncthr;				/* # of async threads */
182 	int setid;				/* unique set id for this set */
183 	uint64_t sync_pos;			/* Progress through sync */
184 	uint64_t volume_size;			/* Size of volume */
185 	int64_t maxqfbas;			/* max # of fbas on async q */
186 	int64_t maxqitems;			/* max # of items on async q */
187 	char group_name[NSC_MAXPATH];		/* Group the set belongs to */
188 	char direct_file[NSC_MAXPATH];		/* Local FCAL direct io file */
189 	char disk_queue[NSC_MAXPATH];	   /* Disk Queue for set|group */
190 } rdc_set_t;
191 
192 #ifdef _SYSCALL32
193 struct rdc_set32 {
194 	struct rdc_addr32 primary;
195 	struct rdc_addr32 secondary;
196 	caddr32_t netconfig;
197 	int32_t align1;
198 	double alignfix;
199 	int32_t flags;				/* See RDC flags below */
200 	int32_t sync_flags;			/* See RDC flags below */
201 	int32_t bmap_flags;			/* See RDC flags below */
202 	int32_t mflags;				/* RDC 1-to-many flags */
203 	int32_t index;				/* 0 .. rdc_max_sets - 1 */
204 	int32_t bits_set;			/* Bits set in bitmap */
205 	int32_t autosync;			/* Autosync on (1) or off (0) */
206 	int32_t syshostid;			/* for cluster integration */
207 	int32_t asyncthr;			/* # of async threads */
208 	int32_t setid;				/* unique set id for this set */
209 	uint64_t sync_pos;			/* Progress through sync */
210 	uint64_t volume_size;			/* Size of volume */
211 	int64_t maxqfbas;			/* max # of fbas on async q */
212 	int64_t maxqitems;			/* max # of items on async q */
213 	char group_name[NSC_MAXPATH];		/* Group the set belongs to */
214 	char direct_file[NSC_MAXPATH];		/* Local FCAL direct io file */
215 	char disk_queue[NSC_MAXPATH];	   /* Disk Queue for set|group */
216 };
217 #endif /* _SYSCALL32 */
218 
219 /*
220  * Parameter structure to pass to RDC_CONFIG
221  */
222 
223 typedef struct rdc_config {
224 	int command;			/* RDC_CMD_XXX */
225 	int options;			/* RDC_OPT_XXX */
226 	int pad[2];			/* Do NOT remove - 32/64-bit padding */
227 	rdc_set_t rdc_set[1];		/* The rdc sets */
228 } rdc_config_t;
229 
230 #ifdef _SYSCALL32
231 struct rdc_config32 {
232 	int32_t command;		/* RDC_CMD_XXX */
233 	int32_t options;		/* RDC_OPT_XXX */
234 	int32_t pad[2];			/* Do NOT remove - 32/64-bit padding */
235 	struct rdc_set32 rdc_set[1];	/* The rdc sets */
236 };
237 #endif /* _SYSCALL32 */
238 
239 #define	RDC_BITMAPSET	0x01
240 #define	RDC_BITMAPOR	0x02
241 typedef struct rdc_bitmap_op {
242 	nsc_off_t	offset;		/* byte offset within bitmap mod fba */
243 	int32_t		op;		/* or/set operation */
244 	char		sechost[MAX_RDC_HOST_SIZE];
245 	char		secfile[NSC_MAXPATH];
246 	int32_t		len;		/* length of bitmap in bytes */
247 	unsigned long   addr;		/* address of bitmap in userland */
248 } rdc_bitmap_op_t;
249 
250 #ifdef _SYSCALL32
251 typedef struct rdc_bitmap_op32 {
252 	nsc_off_t	offset;
253 	int32_t		op;
254 	char		sechost[MAX_RDC_HOST_SIZE];
255 	char		secfile[NSC_MAXPATH];
256 	int32_t		len;
257 	uint32_t	addr;
258 } rdc_bitmap_op32_t;
259 
260 #endif /* _SYSCALL32 */
261 
262 #ifdef	DEBUG
263 /*
264  * structure to initiate an asynchronous send to the secondary,
265  * so we can test the queuing code.
266  */
267 typedef struct rdc_async6 {
268 	char sechost[MAX_RDC_HOST_SIZE];
269 	char secfile[NSC_MAXPATH];
270 	int  pos;		/* Position in file */
271 	int  len;
272 	int  seq;
273 	int  pat;		/* fill data with this */
274 	int  idx;		/* server returned index */
275 	int  spos;		/* sub task start block */
276 	int  slen;		/* sub task length */
277 	int  endind;		/* set when last block in multi request */
278 } rdc_async6_t;
279 /*
280  * structure to initiate a read on the secondary, so we can test the
281  * maxfba break up code.
282  */
283 typedef struct rdc_readgen {
284 	char sechost[MAX_RDC_HOST_SIZE];
285 	char secfile[NSC_MAXPATH];
286 	int  len;
287 	int  pos;
288 	int  idx;
289 	int  flag;
290 	int  rpcversion;
291 	void *data;	/* where to place the data from the read */
292 } rdc_readgen_t;
293 
294 #ifdef _SYSCALL32
295 typedef struct rdc_readgen32 {
296 	char sechost[MAX_RDC_HOST_SIZE];
297 	char secfile[NSC_MAXPATH];
298 	int  len;
299 	int  pos;
300 	int  idx;
301 	int  flag;
302 	int  rpcversion;
303 	caddr32_t data;	/* where to place the data from the read */
304 } rdc_readgen32_t;
305 #endif
306 #endif
307 
308 
309 
310 
311 
312 /*
313  * Config ioctl commands
314  */
315 #define	RDC_CMD_ENABLE		1	/* New enable */
316 #define	RDC_CMD_DISABLE		2	/* Complete disable */
317 #define	RDC_CMD_RESUME		3	/* Local re-enable */
318 #define	RDC_CMD_SUSPEND		4	/* Local clear */
319 #define	RDC_CMD_LOG		5	/* Start logging mode */
320 #define	RDC_CMD_COPY		6	/* Start synching */
321 #define	RDC_CMD_RECONFIG	7	/* Change the rdc set */
322 #define	RDC_CMD_TUNABLE		8	/* Change a tunable parameter */
323 #define	RDC_CMD_WAIT		9	/* Wait for syncs to complete */
324 #define	RDC_CMD_HEALTH		10	/* Return health state */
325 #define	RDC_CMD_STATUS		11	/* Single set status */
326 #define	RDC_CMD_RESET		12	/* reset error or failed status */
327 #define	RDC_CMD_INITQ		14	/* initialise the disk queue */
328 #define	RDC_CMD_FLUSHQ		15	/* flush queue for set */
329 #define	RDC_CMD_ADDQ		16	/* add diskq to a set/group */
330 #define	RDC_CMD_REMQ		17 	/* nice remove a diskq from set/grp */
331 #define	RDC_CMD_KILLQ		18	/* forced disgard of queue */
332 #define	RDC_CMD_REPQ		19	/* replace queue */
333 
334 
335 
336 
337 
338 /*
339  * Config ioctl options
340  */
341 #define	RDC_OPT_SYNC		0x1	/* RDC_CMD_ENABLE, RDC_CMD_RESUME */
342 #define	RDC_OPT_ASYNC		0x2	/* RDC_CMD_ENABLE, RDC_CMD_RESUME */
343 #define	RDC_OPT_PRIMARY		0x4	/* All */
344 #define	RDC_OPT_SECONDARY	0x8	/* All */
345 #define	RDC_OPT_FORWARD		0x10	/* RDC_CMD_COPY */
346 #define	RDC_OPT_REVERSE		0x20	/* RDC_CMD_COPY */
347 #define	RDC_OPT_FULL		0x40	/* RDC_CMD_COPY */
348 #define	RDC_OPT_UPDATE		0x80	/* RDC_CMD_COPY */
349 #define	RDC_OPT_SETBMP		0x100	/* RDC_CMD_ENABLE */
350 #define	RDC_OPT_CLRBMP		0x200	/* RDC_CMD_ENABLE */
351 #define	RDC_OPT_REVERSE_ROLE	0x400	/* RDC_CMD_RECONFIG */
352 #define	RDC_OPT_FORCE_QINIT	0x800	/* RDC_CMD_INITQ */
353 #define	RDC_OPT_SET_QNOBLOCK	0x1000	/* RDC_CMD_TUNABLE */
354 #define	RDC_OPT_CLR_QNOBLOCK	0x2000	/* RDC_CMD_TUNABLE */
355 #define	RDC_OPT_FORCE_DISABLE	0x4000	/* RDC_CMD_DISABLE */
356 
357 /*
358  * RDC flags
359  */
360 
361 /*
362  * Passed out by the kernel (status)
363  */
364 #define	RDC_ENABLED		0x2	/* RDC enabled */
365 #define	RDC_PRIMARY		0x4	/* This node is the primary */
366 #define	RDC_SLAVE		0x8	/* This node is target of the synch */
367 #define	RDC_VOL_FAILED		0x10	/* Volume is failed */
368 #define	RDC_BMP_FAILED		0x20	/* Bitmap is failed */
369 #define	RDC_SYNC_NEEDED		0x40	/* Sync is needed */
370 #define	RDC_RSYNC_NEEDED	0x80	/* Reverse sync is needed */
371 #define	RDC_SYNCING		0x100	/* Synch in progress */
372 #define	RDC_LOGGING		0x200	/* Logging */
373 #define	RDC_FCAL_FAILED		0x400	/* Direct remote I/O failed */
374 #define	RDC_ASYNC		0x800	/* Set is in async replicating mode */
375 #define	RDC_FULL		0x1000	/* Full sync, not an update */
376 #define	RDC_CLR_AFTERSYNC	0x2000	/* clr bitmap on secondary after sync */
377 #define	RDC_DISKQ_FAILED	0x4000  /* Diskq I/O has failed */
378 #define	RDC_QUEUING		0x8000	/* logging, but queueing to disk */
379 #ifndef	RDC_QNOBLOCK
380 #define	RDC_QNOBLOCK		0x10000
381 #endif
382 #define	RDC_SYNC_START		0
383 #define	RDC_SYNC_DONE		1
384 #define	RDC_RSYNC_START		2
385 
386 #ifdef _KERNEL
387 
388 /*
389  * urdc->flags vs urdc->mflags usage:
390  *
391  * All flags are valid in urdc->flags, in which case the condition
392  * holds for the specific urdc.
393  *
394  * The flags in RDC_MFLAGS can also be in urdc->mflags, in which case
395  * the condition holds for a urdc somewhere on the many/multi chains
396  * connected to this urdc.
397  */
398 
399 #define	RDC_GROUP		0x7f8	/* Volume states that affect a group */
400 
401 /*
402  * Mask of volume flags that are valid in urdc->mflags
403  */
404 #define	RDC_MFLAGS		(RDC_SLAVE | RDC_RSYNC_NEEDED)
405 
406 #define	IS_SLAVE(urdc)	  (rdc_get_mflags(urdc) & RDC_SLAVE)
407 
408 /*
409  * Mask of volume flags that are maintained in sync_flags not flags,
410  * and protected by rdc_many_lock rather than the group lock.
411  * This allows code that is operating on one set to change the flags
412  * of another set.
413  */
414 #define	RDC_SFLAGS		(RDC_SYNC_NEEDED | RDC_RSYNC_NEEDED | \
415 				    RDC_VOL_FAILED | RDC_CLR_AFTERSYNC)
416 
417 /*
418  * Mask of volume flags that are maintained in bmap_flags not flags,
419  * and protected by the bmapmutex rather than the group lock.
420  */
421 #define	RDC_BFLAGS		RDC_BMP_FAILED
422 
423 #define	RDC_VFLAGS		(~(RDC_SFLAGS | RDC_BFLAGS))
424 
425 #define	RDC_SYNC_STATE_FLAGS	(RDC_LOGGING | RDC_SYNCING | RDC_QUEUING | \
426 				RDC_ASYNC)
427 
428 #define	IS_ASYNC(urdc)		(rdc_get_vflags(urdc) & RDC_ASYNC)
429 #define	IS_PRIMARY(urdc)	(rdc_get_vflags(urdc) & RDC_PRIMARY)
430 #define	IS_SECONDARY(urdc)	(!IS_PRIMARY(urdc))
431 #define	IS_STATE(urdc, state)   (rdc_get_vflags(urdc) & (state))
432 #define	IS_REPLICATING(urdc)	(!(rdc_get_vflags(urdc) & RDC_LOGGING) && \
433 				    !(rdc_get_vflags(urdc) & RDC_SYNCING))
434 
435 #endif	/* _KERNEL */
436 
437 typedef struct rdc_status {
438 	int nset;			/* Number of sets requested/enabled */
439 	int maxsets;			/* Max # of sets allowed today */
440 	rdc_set_t rdc_set[1];
441 } rdc_status_t;
442 
443 #ifdef _SYSCALL32
444 struct rdc_status32 {
445 	int32_t nset;			/* Number of sets requested/enabled */
446 	int32_t maxsets;		/* Max # of sets allowed today */
447 	struct rdc_set32 rdc_set[1];
448 };
449 #endif /* _SYSCALL32 */
450 
451 typedef struct rdc_svc_args {
452 	int		fd;		/* Connection endpoint */
453 	int		nthr;		/* Number of server threads */
454 	char		netid[128];	/* Identify transport */
455 	struct netbuf	addrmask;	/* Address mask for host */
456 } rdc_svc_args_t;
457 
458 #ifdef _SYSCALL32
459 struct rdc_svc_args32 {
460 	int32_t			fd;
461 	int32_t			nthr;
462 	char			netid[128];
463 	struct	netbuf32	addrmask;
464 };
465 #endif /* _SYSCALL32 */
466 
467 typedef struct rdc_version {
468 	int	major;			/* Major release number */
469 	int	minor;			/* Minor release number */
470 	int	micro;			/* Micro release number */
471 	int	baseline;		/* Baseline revison number */
472 } rdc_version_t;
473 #ifdef _SYSCALL32
474 typedef struct rdc_version32 {
475 	int32_t	major;			/* Major release number */
476 	int32_t minor;			/* Minor release number */
477 	int32_t	micro;			/* Micro release number */
478 	int32_t	baseline;		/* Baseline revison number */
479 } rdc_version32_t;
480 #endif
481 
482 
483 #if !defined(_KERNEL)
484 
485 #define	RDC_IOCTL(cmd, a0, a1, a2, a3, a4, ustatus) \
486 		rdc_ioctl((long)(cmd), (long)(a0), (long)(a1), (long)(a2), \
487 		    (long)(a3), (long)(a4), (ustatus))
488 
489 extern int rdc_ioctl(long, long, long, long, long, long, spcs_s_info_t);
490 extern int rdc_ioctl_simple(long, void *);
491 
492 #endif	/* ! _KERNEL */
493 
494 #ifdef __cplusplus
495 }
496 #endif
497 
498 #endif	/* _RDC_IOCTL_H */
499