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 2006 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _FIOMP_H
27#define	_FIOMP_H
28
29#pragma ident	"%Z%%M%	%I%	%E% SMI"
30
31#ifdef	__cplusplus
32extern "C" {
33#endif
34
35#define	FIOMP_TRUE  1
36#define	FIOMP_FALSE 0
37
38#define	FIOMP_MAX_STR	1024	/* same as FILENAME_MAX */
39
40#define	FIOMP_PATH_ALL	(-1)
41
42/* ioctl base */
43#define	FIOMPC		('f' << 8)
44
45/*
46 * ioctl for the meta management node
47 */
48
49/* create a new multi-path */
50#define	FIOMPNEW	(FIOMPC|0x0)
51/* encapsulate using devices */
52#define	FIOMPENCAP	(FIOMPC|0x1)
53struct fiompdev {
54	int	api_level;		/* API level = 0 */
55	int	inst_no;		/* instance number */
56	minor_t	inst_minor;		/* instance management node */
57	minor_t	user_minor;		/* user access node */
58	int	num;			/* number of devices */
59	char	**devs;			/* device names */
60	int	mpmode;			/* multi pathing */
61	int	autopath;		/* automatic path change */
62	int	block;			/* able to block physical device */
63	int	needsync;		/* need synchronize path status */
64	void	*ext;			/* for extension = NULL */
65};
66
67/* get an instance device's information */
68#define	FIOMPDEVINFO	(FIOMPC|0x2)
69struct fiomp_devinfo {
70	int	inst_no;		/* instance number */
71	char	real_name[FIOMP_MAX_STR]; /* instance management node */
72	char	user_path[FIOMP_MAX_STR]; /* user access path */
73	int	path_num;		/* number of paths */
74	int	mpmode;			/* multi pathing */
75	int	autopath;		/* automatic path change */
76	int	block;			/* able to block physical device */
77	int	needsync;		/* need synchronize path status */
78	void	*ext;			/* for extension = NULL */
79};
80
81/* get number of all instances */
82#define	FIOMPALLINSTNUM	(FIOMPC|0x3)
83
84/* get all device's informations */
85#define	FIOMPALLDEVINFO	(FIOMPC|0x4)
86struct fiomp_all_devinfo {
87	int	num;			/* number of instances */
88	struct	fiomp_devinfo *devinfo;	/* device informations */
89};
90
91/* keep 0x5 - 0xf for reserve */
92
93/*
94 * ioctl for instance management nodes
95 */
96/* get max number of paths */
97#define	FIOMPMAXPATHNUM	(FIOMPC|0x10)
98
99/* set the device's property */
100#define	FIOMPSETPROP	(FIOMPC|0x11)
101
102/* get the device's property */
103#define	FIOMPGETPROP	(FIOMPC|0x12)
104struct fiompprop {
105	char	*iomp_name;		/* instance name */
106	char	*iomp_real_name;
107				/* instance management node (/devices) */
108	char	*iomp_user_path;	/* instance management node (/dev) */
109	char	*iomp_status;		/* status of the instance */
110	int	num;			/* number of paths */
111	char	**iomp_path;		/* target device nodes (/devices) */
112	char	**iomp_logical_path;	/* target device nodes (/dev) */
113	char	**iomp_path_status;	/* status of target devices */
114	char	**iomp_path_block;	/* access block */
115};
116
117/* destroy the instance */
118#define	FIOMPDESTROY	(FIOMPC|0x13)
119
120/* stop the path */
121#define	FIOMPSTOP	(FIOMPC|0x14)
122
123/* start the path */
124#define	FIOMPSTART	(FIOMPC|0x15)
125
126/* list all paths */
127#define	FIOMPLIST	(FIOMPC|0x16)
128
129/* get the path status */
130#define	FIOMPSTATUS	(FIOMPC|0x17)
131struct fiompstatus {
132	int	pathnum;		/* path number */
133	int	status;			/* FIOMP_STAT_xxxx */
134	char	*message;		/* some messages */
135	int	block_status;		/* access block status */
136	void	*ext;			/* reservesd (= NULL) */
137};
138
139/* status */
140#define	FIOMP_STAT_ACTIVE	PATH_STAT_ACTIVE
141#define	FIOMP_STAT_STANDBY	PATH_STAT_STANDBY
142#define	FIOMP_STAT_STOP		PATH_STAT_STOP
143#define	FIOMP_STAT_FAIL		PATH_STAT_FAIL
144#define	FIOMP_STAT_DISCON	PATH_STAT_DISCON
145#define	FIOMP_STAT_ENCAP	PATH_STAT_ENCAP
146#define	FIOMP_STAT_EMPTY	PATH_STAT_EMPTY
147
148/* access block status */
149#define	FIOMP_BSTAT_BLOCK	1
150#define	FIOMP_BSTAT_UNBLOCK	0
151
152/* add, delete */
153#define	FIOMPADD	(FIOMPC|0x18)
154#define	FIOMPDEL	(FIOMPC|0x19)
155struct fiomppath {
156	int	num;			/* number of paths */
157	char	**devs;			/* device names */
158};
159
160/* active, stabdby */
161#define	FIOMPACTIVE	(FIOMPC|0x1a)
162#define	FIOMPSTANDBY	(FIOMPC|0x1b)
163
164/* block, unblock */
165#define	FIOMPBLOCK	(FIOMPC|0x1c)
166#define	FIOMPUNBLOCK	(FIOMPC|0x1d)
167
168/* diagnostic mode ON,OFF */
169#define	FIOMPDIAGON	(FIOMPC|0x1e)
170#define	FIOMPDIAGOFF	(FIOMPC|0x1f)
171struct fiomp_diag_mode {
172	int	 pathnum;		/* path for diagnostic */
173	int	level;			/* = 0 */
174};
175
176/* get all status */
177#define	FIOMPGETALLSTAT	(FIOMPC|0x20)
178struct fiomp_all_stat {
179	int	num;			/* number of paths */
180	struct	fiompstatus *status;	/* path status */
181};
182
183/* change the status of paths */
184#define	FIOMPCHG	(FIOMPC|0x21)
185struct fiompchg {
186	int num;			/* number of all paths */
187	struct	fiompstatus *set_status; /* setting values */
188	struct	fiompstatus *pre_status; /* previous values */
189	struct	fiompstatus *status;	/* current values */
190};
191
192/* recover the failed path */
193#define	FIOMPRECOVER	(FIOMPC|0x22)
194
195/* disconnect/reconnect the path */
196#define	FIOMPDISCONNECT	(FIOMPC|0x23)
197#define	FIOMPCONNECT	(FIOMPC|0x24)
198
199/* keep 0x25 - 0x2f for reserve */
200
201/*
202 * Common ioctl
203 */
204/* get event */
205#define	FIOMPGETEVENT	(FIOMPC|0x30)
206struct fiompevent {
207	int	event;		/* event type = FIOMP_EVT_xx */
208	int	num;		/* instance number(meta management) or */
209				/* number of all path(instance management) */
210	struct	fiompstatus *pre_status; /* previous status */
211	struct	fiompstatus *status;	/* current status */
212};
213
214/* event type */
215#define	FIOMP_EVT_NONE		0x0
216#define	FIOMP_EVT_NEW		0x1
217#define	FIOMP_EVT_DESTROY	0x2
218#define	FIOMP_EVT_STAT		0x101
219#define	FIOMP_EVT_PATHS		0x102
220
221/*
222 * Device property
223 */
224#define	FIOMP_PROP_NAME		"iomp-name"
225#define	FIOMP_PROP_REAL_NAME	"iomp-real-name"
226#define	FIOMP_PROP_PATH_N	"iomp-path-"
227#define	FIOMP_PROP_USER_PATH	"iomp-user-path"
228#define	FIOMP_PROP_LOGIC_PATH_N	"iomp-logical-path-"
229#define	FIOMP_PROP_STATUS	"iomp-status"
230#define	FIOMP_PROP_PATH_NUM	"iomp-path-num"
231#define	FIOMP_PROP_STATUS_N	"iomp-path-status-"
232
233#define	FIOMP_PROP_BLOCK_N	"iomp-path-block-"
234#define	FIOMP_PROP_BLOCK_DEFAULT "iomp-path-block-default"
235
236#ifdef	__cplusplus
237}
238#endif
239
240#endif /* _FIOMP_H */
241