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