xref: /titanic_44/usr/src/uts/common/sys/stmf_ioctl.h (revision a65cd518c5d0f30c53594a7022eb0f7d04c98cef)
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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 #ifndef	_STMF_IOCTL_H
25 #define	_STMF_IOCTL_H
26 
27 #ifdef	__cplusplus
28 extern "C" {
29 #endif
30 
31 #define	STMF_VERSION_1			1
32 
33 #define	STMF_IOCTL			(((uint32_t)'S') << 24)
34 #define	STMF_IOCTL_LU_LIST			(STMF_IOCTL | 1)
35 #define	STMF_IOCTL_TARGET_PORT_LIST		(STMF_IOCTL | 2)
36 #define	STMF_IOCTL_SESSION_LIST			(STMF_IOCTL | 3)
37 #define	STMF_IOCTL_GET_LU_PROPERTIES		(STMF_IOCTL | 4)
38 #define	STMF_IOCTL_GET_TARGET_PORT_PROPERTIES	(STMF_IOCTL | 5)
39 #define	STMF_IOCTL_SET_STMF_STATE		(STMF_IOCTL | 6)
40 #define	STMF_IOCTL_GET_STMF_STATE		(STMF_IOCTL | 7)
41 #define	STMF_IOCTL_SET_LU_STATE			(STMF_IOCTL | 8)
42 #define	STMF_IOCTL_SET_TARGET_PORT_STATE	(STMF_IOCTL | 9)
43 #define	STMF_IOCTL_CREATE_HOST_GROUP		(STMF_IOCTL | 10)
44 #define	STMF_IOCTL_REMOVE_HOST_GROUP		(STMF_IOCTL | 11)
45 #define	STMF_IOCTL_ADD_HG_ENTRY			(STMF_IOCTL | 12)
46 #define	STMF_IOCTL_REMOVE_HG_ENTRY		(STMF_IOCTL | 13)
47 #define	STMF_IOCTL_CREATE_TARGET_GROUP		(STMF_IOCTL | 14)
48 #define	STMF_IOCTL_REMOVE_TARGET_GROUP		(STMF_IOCTL | 15)
49 #define	STMF_IOCTL_ADD_TG_ENTRY			(STMF_IOCTL | 16)
50 #define	STMF_IOCTL_REMOVE_TG_ENTRY		(STMF_IOCTL | 17)
51 #define	STMF_IOCTL_ADD_VIEW_ENTRY		(STMF_IOCTL | 18)
52 #define	STMF_IOCTL_REMOVE_VIEW_ENTRY		(STMF_IOCTL | 19)
53 #define	STMF_IOCTL_GET_HG_LIST			(STMF_IOCTL | 20)
54 #define	STMF_IOCTL_GET_TG_LIST			(STMF_IOCTL | 21)
55 #define	STMF_IOCTL_GET_HG_ENTRIES		(STMF_IOCTL | 22)
56 #define	STMF_IOCTL_GET_TG_ENTRIES		(STMF_IOCTL | 23)
57 #define	STMF_IOCTL_GET_VE_LIST			(STMF_IOCTL | 24)
58 #define	STMF_IOCTL_LOAD_PP_DATA			(STMF_IOCTL | 25)
59 #define	STMF_IOCTL_CLEAR_PP_DATA		(STMF_IOCTL | 26)
60 #define	STMF_IOCTL_GET_PP_DATA			(STMF_IOCTL | 27)
61 #define	STMF_IOCTL_CLEAR_TRACE			(STMF_IOCTL | 28)
62 #define	STMF_IOCTL_ADD_TRACE			(STMF_IOCTL | 29)
63 #define	STMF_IOCTL_GET_TRACE_POSITION		(STMF_IOCTL | 30)
64 #define	STMF_IOCTL_GET_TRACE			(STMF_IOCTL | 31)
65 #define	STMF_IOCTL_REG_LU_LIST			(STMF_IOCTL | 32)
66 #define	STMF_IOCTL_VE_LU_LIST			(STMF_IOCTL | 33)
67 #define	STMF_IOCTL_LU_VE_LIST			(STMF_IOCTL | 34)
68 #define	STMF_IOCTL_VALIDATE_VIEW		(STMF_IOCTL | 35)
69 #define	STMF_IOCTL_SET_ALUA_STATE		(STMF_IOCTL | 36)
70 #define	STMF_IOCTL_GET_ALUA_STATE		(STMF_IOCTL | 37)
71 #define	STMF_IOCTL_SET_STMF_PROPS		(STMF_IOCTL | 38)
72 
73 typedef	struct stmf_iocdata {
74 	uint32_t	stmf_version;
75 	uint32_t	stmf_error;
76 	uint32_t	stmf_ibuf_size;
77 	uint32_t	stmf_obuf_size;
78 	uint32_t	stmf_obuf_nentries;	/* # entries xferred */
79 	uint32_t	stmf_obuf_max_nentries;	/* #,could have been xferred */
80 	uint64_t	stmf_ibuf;
81 	uint64_t	stmf_obuf;
82 } stmf_iocdata_t;
83 
84 typedef	struct slist_lu {
85 	uint8_t		lu_guid[16];
86 } slist_lu_t;
87 
88 typedef	struct slist_target_port {
89 	uint8_t		target[260];
90 } slist_target_port_t;
91 
92 typedef	struct slist_scsi_session {
93 	uint8_t		initiator[260];
94 	/* creation_time is really time_t. But time_t is defined as long. */
95 	uint32_t	creation_time;
96 	char		alias[256];
97 } slist_scsi_session_t;
98 
99 /*
100  * States for LUs and LPORTs
101  */
102 #define	STMF_STATE_OFFLINE		0
103 #define	STMF_STATE_ONLINING		1
104 #define	STMF_STATE_ONLINE		2
105 #define	STMF_STATE_OFFLINING		3
106 
107 /*
108  * States for the STMF config.
109  */
110 #define	STMF_CONFIG_NONE		0
111 #define	STMF_CONFIG_INIT		1
112 #define	STMF_CONFIG_INIT_DONE		2
113 
114 typedef struct sioc_lu_props {
115 	uint8_t		lu_guid[16];
116 	uint8_t		lu_state:4,
117 			lu_present:1,
118 			lu_rsvd:3;
119 	char		lu_provider_name[255];
120 	char		lu_alias[256];
121 } sioc_lu_props_t;
122 
123 typedef struct sioc_target_port_props {
124 	uint8_t		tgt_id[260];
125 	uint8_t		tgt_state:4,
126 			tgt_present:1,
127 			tgt_rsvd:3;
128 	char		tgt_provider_name[255];
129 	char		tgt_alias[256];
130 } sioc_target_port_props_t;
131 
132 /*
133  * This struct is used for getting and setting state of LU/LPORT or STMF.
134  */
135 typedef struct stmf_state_desc {
136 	uint8_t		ident[260];	/* N/A for STMF itself */
137 	uint8_t		state;
138 	uint8_t		config_state;	/* N/A for LU/LPORTs */
139 } stmf_state_desc_t;
140 
141 /*
142  * This struct is used for setting the alua state
143  */
144 typedef struct stmf_alua_state_desc {
145 	uint8_t		alua_state;
146 	uint16_t	alua_node;
147 } stmf_alua_state_desc_t;
148 
149 /* Error definitions for group/view entry/provider dataioctls */
150 #define	STMF_IOCERR_NONE			0
151 #define	STMF_IOCERR_HG_EXISTS			1
152 #define	STMF_IOCERR_INVALID_HG			2
153 #define	STMF_IOCERR_TG_EXISTS			3
154 #define	STMF_IOCERR_INVALID_TG			4
155 #define	STMF_IOCERR_HG_ENTRY_EXISTS		5
156 #define	STMF_IOCERR_INVALID_HG_ENTRY		6
157 #define	STMF_IOCERR_TG_ENTRY_EXISTS		7
158 #define	STMF_IOCERR_INVALID_TG_ENTRY		8
159 #define	STMF_IOCERR_TG_UPDATE_NEED_SVC_OFFLINE	9
160 #define	STMF_IOCERR_LU_NUMBER_IN_USE		10
161 #define	STMF_IOCERR_INVALID_LU_ID		11
162 #define	STMF_IOCERR_VIEW_ENTRY_CONFLICT		12
163 #define	STMF_IOCERR_HG_IN_USE			13
164 #define	STMF_IOCERR_TG_IN_USE			14
165 #define	STMF_IOCERR_INVALID_VIEW_ENTRY		15
166 #define	STMF_IOCERR_INVALID_VE_ID		16
167 #define	STMF_IOCERR_UPDATE_NEED_CFG_INIT	17
168 #define	STMF_IOCERR_PPD_UPDATED			18
169 #define	STMF_IOCERR_INSUFFICIENT_BUF		19
170 #define	STMF_IOCERR_TG_NEED_TG_OFFLINE		20
171 
172 
173 typedef struct stmf_group_name {
174 	uint16_t	name_size;	/* in bytes */
175 	uint16_t	rsvd_1;
176 	uint32_t	rsvd_2;
177 	uint8_t		name[512];	/* 256 * wchar_t */
178 } stmf_group_name_t;
179 
180 /*
181  * struct used to operate (add/remove entry) on a group.
182  */
183 
184 typedef struct stmf_ge_ident {
185 	uint16_t    ident_size;
186 	uint8_t	    ident[256];
187 } stmf_ge_ident_t;
188 
189 typedef struct stmf_group_op_data {
190 	stmf_group_name_t	group;
191 	uint8_t			ident[260];
192 } stmf_group_op_data_t;
193 
194 typedef struct stmf_view_op_entry {
195 	uint32_t		ve_ndx_valid:1,
196 				ve_lu_number_valid:1,
197 				ve_all_hosts:1,
198 				ve_all_targets:1,
199 				rsvd:28;
200 	uint32_t		ve_ndx;
201 	uint8_t			ve_lu_nbr[8];
202 	uint8_t			ve_guid[16];
203 	stmf_group_name_t	ve_host_group;
204 	stmf_group_name_t	ve_target_group;
205 } stmf_view_op_entry_t;
206 
207 typedef struct stmf_ppioctl_data {
208 	char		ppi_name[255];	/* Provider name including \0 */
209 	uint8_t		ppi_port_provider:1,
210 			ppi_lu_provider:1,
211 			ppi_token_valid:1,
212 			ppt_rsvd:5;
213 	uint64_t	ppi_token;
214 	uint64_t	ppi_data_size;
215 	uint8_t		ppi_data[8];
216 } stmf_ppioctl_data_t;
217 
218 typedef struct stmf_set_props {
219 	uint32_t	default_lu_state_value;
220 	uint32_t	default_target_state_value;
221 } stmf_set_props_t;
222 
223 /*
224  * SCSI device ID descriptor as per SPC3 7.6.3
225  */
226 typedef struct scsi_devid_desc {
227 #ifdef	_BIT_FIELDS_HTOL
228 	uint8_t		protocol_id:4,
229 			code_set:4;
230 	uint8_t		piv:1,
231 			rsvd1:1,
232 			association:2,
233 			ident_type:4;
234 #else
235 	uint8_t		code_set:4,
236 			protocol_id:4;
237 	uint8_t		ident_type:4,
238 			association:2,
239 			rsvd1:1,
240 			piv:1;
241 #endif
242 	uint8_t		rsvd2;
243 	uint8_t		ident_length;
244 	uint8_t		ident[1];
245 } scsi_devid_desc_t;
246 
247 /*
248  * Protocol Identifier
249  */
250 #define	PROTOCOL_FIBRE_CHANNEL		0
251 #define	PROTOCOL_PARALLEL_SCSI		1
252 #define	PROTOCOL_SSA			2
253 #define	PROTOCOL_IEEE_1394		3
254 #define	PROTOCOL_SRP			4
255 #define	PROTOCOL_iSCSI			5
256 #define	PROTOCOL_SAS			6
257 #define	PROTOCOL_ADT			7
258 #define	PROTOCOL_ATAPI			8
259 #define	PROTOCOL_ANY			15
260 
261 /*
262  * Code set definitions
263  */
264 #define	CODE_SET_BINARY			1
265 #define	CODE_SET_ASCII			2
266 #define	CODE_SET_UTF8			3
267 
268 /*
269  * Association values
270  */
271 #define	ID_IS_LOGICAL_UNIT		0
272 #define	ID_IS_TARGET_PORT		1
273 #define	ID_IS_TARGET_CONTAINING_LU	2
274 
275 /*
276  * ident type
277  */
278 #define	ID_TYPE_VENDOR_SPECIFIC		0
279 #define	ID_TYPE_T10_VID			1
280 #define	ID_TYPE_EUI64			2
281 #define	ID_TYPE_NAA			3
282 #define	ID_TYPE_RELATIVE_TARGET_PORT	4
283 #define	ID_TYPE_TARGET_PORT_GROUP	5
284 #define	ID_TYPE_LOGICAL_UNIT_GROUP	6
285 #define	ID_TYPE_MD5_LOGICAL_UNIT	7
286 #define	ID_TYPE_SCSI_NAME_STRING	8
287 
288 int stmf_copyin_iocdata(intptr_t data, int mode, stmf_iocdata_t **iocd,
289     void **ibuf, void **obuf);
290 int stmf_copyout_iocdata(intptr_t data, int mode, stmf_iocdata_t *iocd,
291     void *obuf);
292 
293 #ifdef	__cplusplus
294 }
295 #endif
296 
297 #endif /* _STMF_IOCTL_H */
298