xref: /illumos-gate/usr/src/uts/common/sys/scsi/adapters/iscsi_if.h (revision 3afe87ebb25691cb6d158edaa34a6fb9b703a691)
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 _ISCSI_IF_H
27 #define	_ISCSI_IF_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef _KERNEL
34 #include <sys/types.h>
35 #include <sys/strsubr.h>	/* for prototype of kstrgetmsg */
36 #include <sys/socket.h>
37 #include <sys/socketvar.h>	/* for struct sonode */
38 #endif
39 #include <netinet/in.h>
40 #include <sys/scsi/impl/uscsi.h>
41 #include <sys/scsi/adapters/iscsi_protocol.h>
42 
43 /*
44  * Each of the top level structures have a version field as
45  * the first member. That version value will be set by the
46  * caller. The consumer of the structure will check to see
47  * if the version is correct.
48  */
49 #define	ISCSI_INTERFACE_VERSION			3
50 
51 /*
52  * The maximum length of an iSCSI name is 223.  224 is used
53  * to provide space for a null character.
54  */
55 #define	ISCSI_MAX_NAME_LEN			224
56 
57 /*
58  * Login parameter values are used instead of ascii text
59  * between the IMA plug-in and kernel.
60  */
61 #define	ISCSI_LOGIN_PARAM_DATA_SEQUENCE_IN_ORDER	0x0000  /* bool */
62 #define	ISCSI_LOGIN_PARAM_IMMEDIATE_DATA		0x0001  /* bool */
63 #define	ISCSI_LOGIN_PARAM_INITIAL_R2T			0x0002  /* bool */
64 #define	ISCSI_LOGIN_PARAM_DATA_PDU_IN_ORDER		0x0003  /* bool */
65 #define	ISCSI_LOGIN_PARAM_HEADER_DIGEST			0x0004	/* int */
66 #define	ISCSI_LOGIN_PARAM_DATA_DIGEST			0x0005	/* int */
67 #define	ISCSI_LOGIN_PARAM_DEFAULT_TIME_2_RETAIN		0x0006  /* int */
68 #define	ISCSI_LOGIN_PARAM_DEFAULT_TIME_2_WAIT		0x0007  /* int */
69 #define	ISCSI_LOGIN_PARAM_MAX_RECV_DATA_SEGMENT_LENGTH	0x0008  /* int */
70 #define	ISCSI_LOGIN_PARAM_FIRST_BURST_LENGTH		0x0009  /* int */
71 #define	ISCSI_LOGIN_PARAM_MAX_BURST_LENGTH		0x000A  /* int */
72 #define	ISCSI_LOGIN_PARAM_MAX_CONNECTIONS		0x000B  /* int */
73 #define	ISCSI_LOGIN_PARAM_OUTSTANDING_R2T		0x000C  /* int */
74 #define	ISCSI_LOGIN_PARAM_ERROR_RECOVERY_LEVEL		0x000D  /* int */
75 /*
76  * number of login parameters - needs to be updated when new parameter added
77  */
78 #define	ISCSI_NUM_LOGIN_PARAM				0x000E
79 
80 /*
81  * Used internally by the persistent store code. Currently a bitmap is kept of
82  * which params are currently set. This allows for quick a look up instead of
83  * cycling through the possible entries. Using an unsigned int as the bitmap we
84  * can have parameter numbers up through 31. Since the current only has 22
85  * we're okay.
86  */
87 #define	ISCSI_LOGIN_PARAM_DB_ENTRY			0x0020
88 /*
89  * Special case. When this parameter value is set in iscsi_param_set_t
90  * the member s_value (type iscsi_param_set_t) is not used.
91  * The name field contains the InitiatorName for the system which
92  * should be used for all future sessions.
93  */
94 #define	ISCSI_LOGIN_PARAM_INITIATOR_NAME		0x0021
95 #define	ISCSI_LOGIN_PARAM_INITIATOR_ALIAS		0x0022
96 
97 #define	ISCSI_DEVCTL		"devctl"
98 #define	ISCSI_DRIVER_DEVCTL	"/devices/iscsi:" ISCSI_DEVCTL
99 
100 /*
101  * ioctls supported by the driver.
102  */
103 #define	ISCSI_IOCTL		(('i' << 24) | ('S' << 16) | ('C' << 8))
104 #define	ISCSI_CREATE_OID		(ISCSI_IOCTL | 2)
105 #define	ISCSI_LOGIN			(ISCSI_IOCTL | 3)
106 #define	ISCSI_LOGOUT			(ISCSI_IOCTL | 4)
107 #define	ISCSI_PARAM_GET			(ISCSI_IOCTL | 5)
108 #define	ISCSI_PARAM_SET			(ISCSI_IOCTL | 6)
109 #define	ISCSI_TARGET_PARAM_CLEAR	(ISCSI_IOCTL | 8)
110 #define	ISCSI_TARGET_OID_LIST_GET	(ISCSI_IOCTL | 9)
111 #define	ISCSI_TARGET_PROPS_GET		(ISCSI_IOCTL | 10)
112 #define	ISCSI_TARGET_PROPS_SET		(ISCSI_IOCTL | 11)
113 #define	ISCSI_TARGET_ADDRESS_GET	(ISCSI_IOCTL | 12)
114 #define	ISCSI_CHAP_SET			(ISCSI_IOCTL | 13)
115 #define	ISCSI_CHAP_GET			(ISCSI_IOCTL | 14)
116 #define	ISCSI_CHAP_CLEAR		(ISCSI_IOCTL | 15)
117 #define	ISCSI_STATIC_GET		(ISCSI_IOCTL | 16)
118 #define	ISCSI_STATIC_SET		(ISCSI_IOCTL | 17)
119 #define	ISCSI_STATIC_CLEAR		(ISCSI_IOCTL | 18)
120 #define	ISCSI_DISCOVERY_SET		(ISCSI_IOCTL | 19)
121 #define	ISCSI_DISCOVERY_GET		(ISCSI_IOCTL | 20)
122 #define	ISCSI_DISCOVERY_CLEAR		(ISCSI_IOCTL | 21)
123 #define	ISCSI_DISCOVERY_PROPS		(ISCSI_IOCTL | 22)
124 #define	ISCSI_DISCOVERY_ADDR_SET	(ISCSI_IOCTL | 23)
125 #define	ISCSI_DISCOVERY_ADDR_LIST_GET	(ISCSI_IOCTL | 24)
126 #define	ISCSI_DISCOVERY_ADDR_CLEAR	(ISCSI_IOCTL | 25)
127 #define	ISCSI_RADIUS_SET		(ISCSI_IOCTL | 26)
128 #define	ISCSI_RADIUS_GET		(ISCSI_IOCTL | 27)
129 #define	ISCSI_DB_RELOAD			(ISCSI_IOCTL | 28)
130 #define	ISCSI_LUN_OID_LIST_GET		(ISCSI_IOCTL | 29)
131 #define	ISCSI_LUN_PROPS_GET		(ISCSI_IOCTL | 30)
132 #define	ISCSI_CONN_OID_LIST_GET		(ISCSI_IOCTL | 31)
133 #define	ISCSI_CONN_PROPS_GET		(ISCSI_IOCTL | 32)
134 #define	ISCSI_USCSI			(ISCSI_IOCTL | 33)
135 #define	ISCSI_DOOR_HANDLE_SET		(ISCSI_IOCTL | 34)
136 #define	ISCSI_DISCOVERY_EVENTS		(ISCSI_IOCTL | 35)
137 #define	ISCSI_AUTH_SET			(ISCSI_IOCTL | 36)
138 #define	ISCSI_AUTH_GET			(ISCSI_IOCTL | 37)
139 #define	ISCSI_AUTH_CLEAR		(ISCSI_IOCTL | 38)
140 #define	ISCSI_SENDTGTS_GET		(ISCSI_IOCTL | 39)
141 #define	ISCSI_ISNS_SERVER_ADDR_SET	(ISCSI_IOCTL | 40)
142 #define	ISCSI_ISNS_SERVER_ADDR_LIST_GET	(ISCSI_IOCTL | 41)
143 #define	ISCSI_ISNS_SERVER_ADDR_CLEAR	(ISCSI_IOCTL | 42)
144 #define	ISCSI_ISNS_SERVER_GET		(ISCSI_IOCTL | 43)
145 #define	ISCSI_GET_CONFIG_SESSIONS	(ISCSI_IOCTL | 44)
146 #define	ISCSI_SET_CONFIG_SESSIONS	(ISCSI_IOCTL | 45)
147 #define	ISCSI_INIT_NODE_NAME_SET	(ISCSI_IOCTL | 46)
148 #define	ISCSI_IS_ACTIVE			(ISCSI_IOCTL | 47)
149 #define	ISCSI_BOOTPROP_GET		(ISCSI_IOCTL | 48)
150 #define	ISCSI_DB_DUMP			(ISCSI_IOCTL | 100) /* DBG */
151 
152 /*
153  * Misc. defines
154  */
155 #define	ISCSI_CHAP_NAME_LEN			512
156 #define	ISCSI_CHAP_SECRET_LEN			16
157 #define	ISCSI_TGT_OID_LIST			0x0001
158 #define	ISCSI_STATIC_TGT_OID_LIST		0x0002
159 #define	ISCSI_TGT_PARAM_OID_LIST		0x0004
160 #define	ISCSI_SESS_PARAM			0x0001
161 #define	ISCSI_CONN_PARAM			0x0002
162 
163 /* digest level defines */
164 #define	ISCSI_DIGEST_NONE		0
165 #define	ISCSI_DIGEST_CRC32C		1
166 #define	ISCSI_DIGEST_CRC32C_NONE	2 /* offer both, prefer CRC32C */
167 #define	ISCSI_DIGEST_NONE_CRC32C	3 /* offer both, prefer None */
168 
169 /*
170  * A last error associated with each target session is returned in the
171  * iscsi_target_t structure.
172  */
173 typedef enum iscsi_error {
174 	NoError, AuthenticationError, LoginParamError, ConnectionReset
175 } iscsi_error_t;
176 
177 /*
178  * The values associated with each enum is based on the IMA specification.
179  */
180 typedef enum	iSCSIDiscoveryMethod {
181 	iSCSIDiscoveryMethodUnknown	= 0,
182 	iSCSIDiscoveryMethodStatic	= 1,
183 	iSCSIDiscoveryMethodSLP		= 2,
184 	iSCSIDiscoveryMethodISNS	= 4,
185 	iSCSIDiscoveryMethodSendTargets	= 8,
186 	/*
187 	 * Since there is no specification about boot discovery method,
188 	 * we should leave a value gap in case of other discovery
189 	 * methods added.
190 	 */
191 	iSCSIDiscoveryMethodBoot	= 128
192 } iSCSIDiscoveryMethod_t;
193 #define	ISCSI_ALL_DISCOVERY_METHODS	(iSCSIDiscoveryMethodStatic |	\
194 					iSCSIDiscoveryMethodSLP |	\
195 					iSCSIDiscoveryMethodISNS |	\
196 					iSCSIDiscoveryMethodSendTargets)
197 
198 /*
199  * Before anything can be done to a target it must have an OID.
200  */
201 typedef struct iscsi_oid {
202 	uint32_t		o_vers;				/* In */
203 	uchar_t			o_name[ISCSI_MAX_NAME_LEN];	/* In */
204 	/*
205 	 * tpgt is only 16 bits per spec.  use 32 in ioctl to reduce
206 	 * packing issue.  Also -1 tpgt denotes default value.  iSCSI
207 	 * stack will detemermine tpgt during login.
208 	 */
209 	int			o_tpgt;				/* In */
210 	uint32_t		o_oid;				/* Out */
211 } iscsi_oid_t;
212 #define	ISCSI_OID_NOTSET	0
213 #define	ISCSI_INITIATOR_OID	1	/* Other OIDs follow > 1 */
214 #define	ISCSI_DEFAULT_TPGT	-1
215 
216 /*
217  * iSCSI Login Parameters - Reference iscsi draft for
218  * definitions of the below login params.
219  */
220 typedef struct iscsi_login_params {
221 	boolean_t	immediate_data;
222 	boolean_t	initial_r2t;
223 	int		first_burst_length;	/* range: 512 - 2**24-1 */
224 	int		max_burst_length;	/* range: 512 - 2**24-1 */
225 	boolean_t	data_pdu_in_order;
226 	boolean_t	data_sequence_in_order;
227 	int		default_time_to_wait;
228 	int		default_time_to_retain;
229 	int		header_digest;
230 	int		data_digest;
231 	int		max_recv_data_seg_len;	/* range: 512 - 2**24-1 */
232 	int		max_xmit_data_seg_len;	/* range: 512 - 2**24-1 */
233 	int		max_connections;
234 	int		max_outstanding_r2t;
235 	int		error_recovery_level;
236 	boolean_t	ifmarker;
237 	boolean_t	ofmarker;
238 } iscsi_login_params_t;
239 
240 /*
241  * Once parameters have been set via ISCSI_SET_PARAM the login is initiated
242  * by sending an ISCSI_LOGIN ioctl with the following structure filled in.
243  */
244 typedef struct entry {
245 	int			e_vers;
246 	uint32_t		e_oid;
247 	union {
248 		struct in_addr		u_in4;
249 		struct in6_addr		u_in6;
250 	} e_u;
251 	/*
252 	 * e_insize indicates which of the previous structs is valid.
253 	 */
254 	int			e_insize;
255 	int			e_port;
256 	int			e_tpgt;
257 	/* e_boot should be true if a boot session is created. */
258 	boolean_t		e_boot;
259 } entry_t;
260 
261 /*
262  * Used when setting or gettnig the Initiator Name or Alias.
263  */
264 typedef struct node_name {
265 	unsigned char		n_name[ISCSI_MAX_NAME_LEN];
266 	int			n_len;
267 } node_name_t;
268 
269 typedef struct	_iSCSIMinMaxValue {
270 	uint32_t		i_current,
271 				i_default,
272 				i_min,
273 				i_max,
274 				i_incr;
275 } iscsi_int_info_t;
276 
277 typedef struct	_iSCSIBoolValue {
278 	boolean_t		b_current,
279 				b_default;
280 } iscsi_bool_info_t;
281 
282 typedef struct	_iSCSIParamValueGet {
283 	boolean_t		v_valid,
284 				v_settable;
285 	iscsi_int_info_t	v_integer;
286 	iscsi_bool_info_t	v_bool;
287 	uchar_t			v_name[ISCSI_MAX_NAME_LEN];
288 } iscsi_get_value_t;
289 
290 typedef struct	_iSCSILoginParamGet {
291 	uint32_t		g_vers;				/* In */
292 	uint32_t		g_oid;				/* In */
293 	uint32_t		g_param;			/* Out */
294 	iscsi_get_value_t	g_value;			/* Out */
295 	uint32_t		g_conn_cid;			/* In */
296 
297 	/*
298 	 * To indicate whether session or connection related param is
299 	 * being requested.
300 	 */
301 	uint32_t		g_param_type;			/* In */
302 } iscsi_param_get_t;
303 
304 typedef struct	iscsi_set_value {
305 	uint32_t		v_integer;
306 	boolean_t		v_bool;
307 	uchar_t			v_name[ISCSI_MAX_NAME_LEN];
308 } iscsi_set_value_t;
309 
310 /*
311  * All of the members of this structure are set by the user agent and
312  * consumed by the driver.
313  */
314 typedef struct	iSCSILoginParamSet {
315 	uint32_t		s_vers,
316 				s_oid;
317 	uint32_t		s_param;
318 	iscsi_set_value_t	s_value;
319 } iscsi_param_set_t;
320 
321 /*
322  * Data in this structure is set by the user agent and consumed by
323  * the driver.
324  */
325 typedef struct chap_props {
326 	uint32_t		c_vers,
327 				c_retries,
328 				c_oid;
329 	unsigned char		c_user[128];
330 	uint32_t		c_user_len;
331 	unsigned char		c_secret[16];
332 	uint32_t		c_secret_len;
333 } iscsi_chap_props_t;
334 
335 typedef enum	authMethod {
336 	authMethodNone  = 0x00,
337 	authMethodCHAP  = 0x01,
338 	authMethodSRP   = 0x02,
339 	authMethodKRB5  = 0x04,
340 	authMethodSPKM1 = 0x08,
341 	authMethodSPKM2 = 0x10
342 } authMethod_t;
343 
344 /*
345  * Data in this structure is set by the user agent and consumed by
346  * the driver.
347  */
348 typedef struct auth_props {
349 	uint32_t a_vers;
350 	uint32_t a_oid;
351 	boolean_t a_bi_auth;
352 	authMethod_t a_auth_method;
353 } iscsi_auth_props_t;
354 
355 /*
356  * Data in this structure is set by the user agent and consumed by
357  * the driver.
358  */
359 #define	MAX_RAD_SHARED_SECRET_LEN 128
360 typedef struct radius_props {
361 	uint32_t		r_vers;
362 	uint32_t		r_oid;
363 	union {
364 		struct in_addr		u_in4;
365 		struct in6_addr		u_in6;
366 	} r_addr;
367 	/*
368 	 * r_insize indicates which of the previous structs is valid.
369 	 */
370 	int			r_insize;
371 
372 	uint32_t		r_port;
373 	uint8_t			r_shared_secret[MAX_RAD_SHARED_SECRET_LEN];
374 	boolean_t		r_radius_access;
375 	boolean_t		r_radius_config_valid;
376 	uint32_t		r_shared_secret_len;
377 } iscsi_radius_props_t;
378 
379 typedef struct	_IPAddress {
380 	union {
381 		struct in_addr	in4;
382 		struct in6_addr	in6;
383 	} i_addr;
384 	/* i_insize determines which is valid in the union above */
385 	int			i_insize;
386 } iscsi_ipaddr_t;
387 
388 typedef struct	_iSCSITargetAddressKey {
389 	iscsi_ipaddr_t		a_addr;
390 	uint32_t		a_port,
391 				a_oid;
392 } iscsi_addr_t;
393 
394 typedef struct	_iSCSITargetAddressKeyProperties {
395 	uint32_t		al_vers,			/* In */
396 				al_oid;				/* In */
397 	uint32_t		al_in_cnt;			/* In */
398 	uint32_t		al_out_cnt;			/* Out */
399 	uint32_t		al_tpgt;			/* Out */
400 	iscsi_addr_t		al_addrs[1];			/* Out */
401 } iscsi_addr_list_t;
402 
403 typedef struct	_iSCSITargetProperties {
404 	uint32_t		p_vers,				/* In */
405 				p_oid;				/* In */
406 	uchar_t			p_name[ISCSI_MAX_NAME_LEN];	/* Out */
407 	uint_t			p_name_len;			/* Out */
408 	uchar_t			p_alias[ISCSI_MAX_NAME_LEN];	/* Out */
409 	uint_t			p_alias_len;			/* Out */
410 	iSCSIDiscoveryMethod_t	p_discovery;			/* Out */
411 	boolean_t		p_connected;			/* Out */
412 	uint32_t		p_num_of_connections;		/* Out */
413 	/* ---- If connected == B_TRUE then lastErr has no meaning. ---- */
414 	iscsi_error_t		p_last_err;			/* Out */
415 	/*
416 	 * Target portal group tag = -1 value means default.
417 	 */
418 	int			p_tpgt_conf;			/* Out */
419 	int			p_tpgt_nego;			/* Out */
420 	uchar_t			p_isid[ISCSI_ISID_LEN];		/* Out */
421 	uchar_t			p_reserved[128];
422 } iscsi_property_t;
423 
424 typedef struct	_iSCSITargetDeviceList {
425 	uint32_t		tl_vers,			/* In */
426 				tl_in_cnt,			/* In */
427 				tl_tgt_list_type,		/* In */
428 				tl_out_cnt,			/* Out */
429 				tl_oid_list[1];			/* Out */
430 } iscsi_target_list_t;
431 
432 typedef struct	_iSCSIStaticTargetProperties {
433 	uint32_t		p_vers,				/* In */
434 				p_oid;				/* In */
435 	uchar_t			p_name[ISCSI_MAX_NAME_LEN];	/* Out */
436 	uint_t			p_name_len;			/* Out */
437 	iscsi_addr_list_t	p_addr_list;			/* Out */
438 } iscsi_static_property_t;
439 
440 typedef enum iscsi_lun_status {
441 	LunValid, LunDoesNotExist
442 } iscsi_lun_status_t;
443 
444 /*
445  * SCSI inquiry vendor and product identifier buffer length - these values are
446  * defined by the identifier length plus 1 byte for the
447  * null termination.
448  */
449 #define	ISCSI_INQ_VID_BUF_LEN		9	/* 8 byte ID */
450 #define	ISCSI_INQ_PID_BUF_LEN		17	/* 16 byte ID */
451 
452 typedef struct iscsi_lun_props {
453 	uint32_t		lp_vers,			/* In */
454 				lp_tgt_oid,			/* In */
455 				lp_oid,				/* In */
456 				lp_num,				/* Out */
457 				lp_status;			/* Out */
458 	char			lp_pathname[MAXPATHLEN],	/* Out */
459 				lp_vid[ISCSI_INQ_VID_BUF_LEN],	/* Out */
460 				lp_pid[ISCSI_INQ_PID_BUF_LEN];	/* Out */
461 	time_t			lp_time_online;			/* Out */
462 } iscsi_lun_props_t;
463 
464 typedef struct iscsi_if_lun {
465 	uint32_t		l_tgt_oid,
466 				l_oid,
467 				l_num;
468 } iscsi_if_lun_t;
469 
470 typedef struct iscsi_lun_list {
471 	uint32_t		ll_vers;			/* In */
472 	boolean_t		ll_all_tgts;			/* In */
473 	uint32_t		ll_tgt_oid,			/* In */
474 				ll_in_cnt,			/* In */
475 				ll_out_cnt;			/* Out */
476 	iscsi_if_lun_t		ll_luns[1];			/* Out */
477 } iscsi_lun_list_t;
478 
479 typedef struct iscsi_conn_props {
480 	uint32_t		cp_vers,			/* In */
481 				cp_oid,				/* In */
482 				cp_cid,				/* In */
483 				cp_sess_oid;			/* In */
484 	union {
485 		struct	sockaddr_in	soa4;
486 		struct	sockaddr_in6	soa6;
487 	} cp_local;						/* Out */
488 	union {
489 		struct	sockaddr_in	soa4;
490 		struct	sockaddr_in6	soa6;
491 	} cp_peer;						/* Out */
492 
493 
494 	iscsi_login_params_t 	cp_params;
495 	boolean_t 		cp_params_valid;
496 
497 } iscsi_conn_props_t;
498 
499 typedef struct iscsi_if_conn {
500 	uint32_t		c_sess_oid,
501 				c_oid,
502 				c_cid;
503 } iscsi_if_conn_t;
504 
505 typedef struct iscsi_conn_list {
506 	uint32_t		cl_vers;			/* In */
507 	boolean_t		cl_all_sess;			/* In */
508 	uint32_t		cl_sess_oid,			/* In */
509 				cl_in_cnt,			/* In */
510 				cl_out_cnt;			/* Out */
511 	iscsi_if_conn_t		cl_list[1];			/* Out */
512 } iscsi_conn_list_t;
513 
514 typedef enum iSNSDiscoveryMethod {
515 	iSNSDiscoveryMethodStatic	= 0,
516 	iSNSDiscoveryMethodDHCP		= 1,
517 	iSNSDiscoveryMethodSLP		= 2
518 } isns_method_t;
519 
520 typedef struct iSCSIDiscoveryProperties {
521 	uint32_t		vers;
522 	boolean_t		iSNSDiscoverySettable;
523 	boolean_t		iSNSDiscoveryEnabled;
524 	isns_method_t		iSNSDiscoveryMethod;
525 	unsigned char		iSNSDomainName[256];
526 	boolean_t		SLPDiscoverySettable;
527 	boolean_t		SLPDiscoveryEnabled;
528 	boolean_t		StaticDiscoverySettable;
529 	boolean_t		StaticDiscoveryEnabled;
530 	boolean_t		SendTargetsDiscoverySettable;
531 	boolean_t		SendTargetsDiscoveryEnabled;
532 } iSCSIDiscoveryProperties_t;
533 
534 typedef struct iscsi_uscsi {
535 	uint32_t		iu_vers;
536 	uint32_t		iu_oid;
537 	int			iu_tpgt;
538 	uint32_t		iu_len;
539 	uint32_t		iu_lun;
540 	struct uscsi_cmd	iu_ucmd;
541 } iscsi_uscsi_t;
542 
543 #if defined(_SYSCALL32)
544 typedef struct iscsi_uscsi32 {
545 	uint32_t		iu_vers;
546 	uint32_t		iu_oid;
547 	int			iu_tpgt;
548 	uint32_t		iu_len;
549 	uint32_t		iu_lun;
550 	struct uscsi_cmd32	iu_ucmd;
551 } iscsi_uscsi32_t;
552 #endif /* _SYSCALL32 */
553 
554 typedef struct iscsi_sendtgts_entry {
555 	/* ---- Node name, NULL terminated UTF-8 string ---- */
556 	uchar_t			ste_name[ISCSI_MAX_NAME_LEN];
557 
558 	iscsi_addr_t		ste_ipaddr;
559 	int			ste_tpgt;
560 } iscsi_sendtgts_entry_t;
561 
562 typedef struct iscsi_sendtgts_list {
563 	entry_t			stl_entry;			/* In */
564 	uint32_t		stl_in_cnt,			/* In */
565 				stl_out_cnt;			/* Out */
566 	iscsi_sendtgts_entry_t	stl_list[1];			/* Out */
567 } iscsi_sendtgts_list_t;
568 
569 typedef struct iscsi_statictgt_entry {
570 	entry_t			te_entry;			/* In */
571 	uchar_t			te_name[ISCSI_MAX_NAME_LEN];	/* In */
572 } iscsi_target_entry_t;
573 
574 /* iSNS Draft - section 4.1.1. */
575 typedef struct isns_portal_group {
576 	uint8_t pg_iscsi_name[ISCSI_MAX_NAME_LEN];
577 	union {
578 		in_addr_t	u_ip4;
579 		in6_addr_t	u_ip6;
580 	} pg_ip_addr;
581 	int	insize;
582 
583 	in_port_t pg_port;
584 	uint16_t pg_tag;
585 
586 	iscsi_ipaddr_t	isns_server_ip;
587 	uint32_t	isns_server_port;
588 } isns_portal_group_t;
589 
590 typedef struct isns_portal_group_list {
591 	uint32_t		pg_in_cnt,
592 				pg_out_cnt;
593 	isns_portal_group_t	pg_list[1];
594 } isns_portal_group_list_t;
595 
596 typedef struct isns_server_portal_group_list {
597 	iscsi_addr_t		    addr;
598 	isns_portal_group_list_t    addr_port_list;
599 } isns_server_portal_group_list_t;
600 
601 #define	ISCSI_MIN_CONFIG_SESSIONS	1
602 /* lowered max config sessions due to ct_power_cnt >= 0 assert */
603 #define	ISCSI_MAX_CONFIG_SESSIONS	4
604 
605 typedef struct iscsi_config_sess {
606 	uint32_t	ics_ver;
607 	uint32_t	ics_oid;
608 	boolean_t	ics_bound;
609 	uint_t		ics_in;
610 	uint_t		ics_out;
611 	iscsi_ipaddr_t	ics_bindings[1];
612 } iscsi_config_sess_t;
613 
614 /* iscsi booting prop */
615 typedef struct _iSCSIBootProperties {
616 	node_name_t	ini_name;
617 	node_name_t	tgt_name;
618 	iscsi_auth_props_t	auth;
619 	iscsi_chap_props_t	ini_chap;
620 	iscsi_chap_props_t	tgt_chap;
621 	int iscsiboot;
622 	boolean_t hba_mpxio_enabled;
623 } iscsi_boot_property_t;
624 
625 #define	ISCSI_SESSION_CONFIG_SIZE(SIZE)		\
626 	(sizeof (iscsi_config_sess_t) +		\
627 	((SIZE - 1) * sizeof (iscsi_ipaddr_t)))
628 
629 /*
630  * Event class and subclass information
631  */
632 #define	EC_ISCSI			"EC_iSCSI"
633 #define	ESC_ISCSI_STATIC_START		"ESC_static_start"
634 #define	ESC_ISCSI_STATIC_END		"ESC_static_end"
635 #define	ESC_ISCSI_SEND_TARGETS_START	"ESC_send_targets_start"
636 #define	ESC_ISCSI_SEND_TARGETS_END	"ESC_send_targets_end"
637 #define	ESC_ISCSI_SLP_START		"ESC_slp_start"
638 #define	ESC_ISCSI_SLP_END		"ESC_slp_end"
639 #define	ESC_ISCSI_ISNS_START		"ESC_isns_start"
640 #define	ESC_ISCSI_ISNS_END		"ESC_isns_end"
641 #define	ESC_ISCSI_PROP_CHANGE		"ESC_prop_change"
642 
643 #ifdef _KERNEL
644 /* ---- iscsi_utils.c ---- */
645 extern int		iscsid_open(char *, int, int);
646 extern int		iscsid_close(int);
647 extern int		iscsid_remove(char *filename);
648 extern int		iscsid_rename(char *oldname, char *newname);
649 extern ssize_t		iscsid_write(int, void *, ssize_t);
650 extern ssize_t		iscsid_read(int, void *, ssize_t);
651 extern ssize_t		iscsid_sendto(struct sonode *, void *, size_t,
652     struct sockaddr *, socklen_t);
653 extern ssize_t		iscsid_recvfrom(struct sonode *, void *buffer,
654     size_t len);
655 extern int		iscsid_errno;
656 #endif
657 
658 /*
659  * Function prototypes for those routines found in the common code
660  */
661 /* ---- utils.c ---- */
662 extern boolean_t	utils_iqn_create(char *, int);
663 extern char		*prt_bitmap(int, char *, char *, int);
664 extern char		*utils_map_param(int);
665 extern boolean_t	parse_addr_port_tpgt(char *in, char **addr,
666 			    int *type, char **port, char **tpgt);
667 
668 #ifdef __cplusplus
669 }
670 #endif
671 
672 #endif /* _ISCSI_IF_H */
673