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