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