xref: /illumos-gate/usr/src/uts/common/sys/scsi/adapters/iscsi_if.h (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _ISCSI_IF_H
26 #define	_ISCSI_IF_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #ifdef _KERNEL
33 #include <sys/types.h>
34 #include <sys/strsubr.h>	/* for prototype of kstrgetmsg */
35 #include <sys/socket.h>
36 #include <sys/socketvar.h>	/* for struct sonode */
37 #endif
38 #include <sys/param.h>		/* for MAXPATHLEN */
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_TUNABLE_PARAM_GET		(ISCSI_IOCTL | 51)
146 #define	ISCSI_TUNABLE_PARAM_SET		(ISCSI_IOCTL | 52)
147 #define	ISCSI_TARGET_REENUM		(ISCSI_IOCTL | 53)
148 #define	ISCSI_DB_DUMP			(ISCSI_IOCTL | 100) /* DBG */
149 
150 /*
151  * Misc. defines
152  */
153 #define	ISCSI_CHAP_NAME_LEN			512
154 #define	ISCSI_CHAP_SECRET_LEN			16
155 #define	ISCSI_TGT_OID_LIST			0x0001
156 #define	ISCSI_STATIC_TGT_OID_LIST		0x0002
157 #define	ISCSI_TGT_PARAM_OID_LIST		0x0004
158 #define	ISCSI_SESS_PARAM			0x0001
159 #define	ISCSI_CONN_PARAM			0x0002
160 
161 /* digest level defines */
162 #define	ISCSI_DIGEST_NONE		0
163 #define	ISCSI_DIGEST_CRC32C		1
164 #define	ISCSI_DIGEST_CRC32C_NONE	2 /* offer both, prefer CRC32C */
165 #define	ISCSI_DIGEST_NONE_CRC32C	3 /* offer both, prefer None */
166 
167 /*
168  * A last error associated with each target session is returned in the
169  * iscsi_target_t structure.
170  */
171 typedef enum iscsi_error {
172 	NoError, AuthenticationError, LoginParamError, ConnectionReset
173 } iscsi_error_t;
174 
175 /*
176  * The values associated with each enum is based on the IMA specification.
177  */
178 typedef enum	iSCSIDiscoveryMethod {
179 	iSCSIDiscoveryMethodUnknown	= 0,
180 	iSCSIDiscoveryMethodStatic	= 1,
181 	iSCSIDiscoveryMethodSLP		= 2,
182 	iSCSIDiscoveryMethodISNS	= 4,
183 	iSCSIDiscoveryMethodSendTargets	= 8,
184 	/*
185 	 * Since there is no specification about boot discovery method,
186 	 * we should leave a value gap in case of other discovery
187 	 * methods added.
188 	 */
189 	iSCSIDiscoveryMethodBoot	= 128
190 } iSCSIDiscoveryMethod_t;
191 #define	ISCSI_ALL_DISCOVERY_METHODS	(iSCSIDiscoveryMethodStatic |	\
192 					iSCSIDiscoveryMethodSLP |	\
193 					iSCSIDiscoveryMethodISNS |	\
194 					iSCSIDiscoveryMethodSendTargets)
195 
196 /*
197  * Before anything can be done to a target it must have an OID.
198  */
199 typedef struct iscsi_oid {
200 	uint32_t		o_vers;				/* In */
201 	uchar_t			o_name[ISCSI_MAX_NAME_LEN];	/* In */
202 	/*
203 	 * tpgt is only 16 bits per spec.  use 32 in ioctl to reduce
204 	 * packing issue.  Also -1 tpgt denotes default value.  iSCSI
205 	 * stack will detemermine tpgt during login.
206 	 */
207 	int			o_tpgt;				/* In */
208 	uint32_t		o_oid;				/* Out */
209 } iscsi_oid_t;
210 #define	ISCSI_OID_NOTSET	0
211 #define	ISCSI_INITIATOR_OID	1	/* Other OIDs follow > 1 */
212 #define	ISCSI_DEFAULT_TPGT	-1
213 
214 /*
215  * iSCSI Login Parameters - Reference iscsi draft for
216  * definitions of the below login params.
217  */
218 typedef struct iscsi_login_params {
219 	boolean_t	immediate_data;
220 	boolean_t	initial_r2t;
221 	int		first_burst_length;	/* range: 512 - 2**24-1 */
222 	int		max_burst_length;	/* range: 512 - 2**24-1 */
223 	boolean_t	data_pdu_in_order;
224 	boolean_t	data_sequence_in_order;
225 	int		default_time_to_wait;
226 	int		default_time_to_retain;
227 	int		header_digest;
228 	int		data_digest;
229 	int		max_recv_data_seg_len;	/* range: 512 - 2**24-1 */
230 	int		max_xmit_data_seg_len;	/* range: 512 - 2**24-1 */
231 	int		max_connections;
232 	int		max_outstanding_r2t;
233 	int		error_recovery_level;
234 	boolean_t	ifmarker;
235 	boolean_t	ofmarker;
236 } iscsi_login_params_t;
237 
238 #define		ISCSI_TUNABLE_PARAM_RX_TIMEOUT_VALUE		0x0001
239 #define		ISCSI_TUNABLE_PARAM_CONN_LOGIN_MAX		0x0002
240 #define		ISCSI_TUNABLE_PARAM_LOGIN_POLLING_DELAY		0x0004
241 
242 /*
243  * Once parameters have been set via ISCSI_SET_PARAM the login is initiated
244  * by sending an ISCSI_LOGIN ioctl with the following structure filled in.
245  */
246 typedef struct entry {
247 	int			e_vers;
248 	uint32_t		e_oid;
249 	union {
250 		struct in_addr		u_in4;
251 		struct in6_addr		u_in6;
252 	} e_u;
253 	/*
254 	 * e_insize indicates which of the previous structs is valid.
255 	 */
256 	int			e_insize;
257 	int			e_port;
258 	int			e_tpgt;
259 	/* e_boot should be true if a boot session is created. */
260 	boolean_t		e_boot;
261 } entry_t;
262 
263 /*
264  * Used when setting or gettnig the Initiator Name or Alias.
265  */
266 typedef struct node_name {
267 	unsigned char		n_name[ISCSI_MAX_NAME_LEN];
268 	int			n_len;
269 } node_name_t;
270 
271 typedef struct	_iSCSIMinMaxValue {
272 	uint32_t		i_current,
273 				i_default,
274 				i_min,
275 				i_max,
276 				i_incr;
277 } iscsi_int_info_t;
278 
279 typedef struct	_iSCSIBoolValue {
280 	boolean_t		b_current,
281 				b_default;
282 } iscsi_bool_info_t;
283 
284 typedef struct	_iSCSIParamValueGet {
285 	boolean_t		v_valid,
286 				v_settable;
287 	iscsi_int_info_t	v_integer;
288 	iscsi_bool_info_t	v_bool;
289 	uchar_t			v_name[ISCSI_MAX_NAME_LEN];
290 } iscsi_get_value_t;
291 
292 typedef struct	_iSCSILoginParamGet {
293 	uint32_t		g_vers;				/* In */
294 	uint32_t		g_oid;				/* In */
295 	uint32_t		g_param;			/* Out */
296 	iscsi_get_value_t	g_value;			/* Out */
297 	uint32_t		g_conn_cid;			/* In */
298 
299 	/*
300 	 * To indicate whether session or connection related param is
301 	 * being requested.
302 	 */
303 	uint32_t		g_param_type;			/* In */
304 } iscsi_param_get_t;
305 
306 typedef struct	iscsi_set_value {
307 	uint32_t		v_integer;
308 	boolean_t		v_bool;
309 	uchar_t			v_name[ISCSI_MAX_NAME_LEN];
310 } iscsi_set_value_t;
311 
312 /*
313  * All of the members of this structure are set by the user agent and
314  * consumed by the driver.
315  */
316 typedef struct	iSCSILoginParamSet {
317 	uint32_t		s_vers,
318 				s_oid;
319 	uint32_t		s_param;
320 	iscsi_set_value_t	s_value;
321 } iscsi_param_set_t;
322 
323 /* Data structure used for tunable object parameters */
324 typedef struct _iSCSITunableValue {
325 	uint32_t	v_integer;
326 	boolean_t	v_bool;
327 	uchar_t		v_name[ISCSI_MAX_NAME_LEN];
328 } iscsi_tunable_value_t;
329 
330 typedef struct iSCSITunalbeParamObject {
331 	boolean_t		t_set;
332 	uint32_t		t_oid;
333 	uint32_t		t_param;
334 	iscsi_tunable_value_t	t_value;
335 } iscsi_tunable_object_t;
336 
337 /*
338  * Data in this structure is set by the user agent and consumed by
339  * the driver.
340  */
341 typedef struct chap_props {
342 	uint32_t		c_vers,
343 				c_retries,
344 				c_oid;
345 	unsigned char		c_user[ISCSI_MAX_C_USER_LEN];
346 	uint32_t		c_user_len;
347 	unsigned char		c_secret[16];
348 	uint32_t		c_secret_len;
349 } iscsi_chap_props_t;
350 
351 typedef enum	authMethod {
352 	authMethodNone  = 0x00,
353 	authMethodCHAP  = 0x01,
354 	authMethodSRP   = 0x02,
355 	authMethodKRB5  = 0x04,
356 	authMethodSPKM1 = 0x08,
357 	authMethodSPKM2 = 0x10
358 } authMethod_t;
359 
360 /*
361  * Data in this structure is set by the user agent and consumed by
362  * the driver.
363  */
364 typedef struct auth_props {
365 	uint32_t a_vers;
366 	uint32_t a_oid;
367 	boolean_t a_bi_auth;
368 	authMethod_t a_auth_method;
369 } iscsi_auth_props_t;
370 
371 /*
372  * Data in this structure is set by the user agent and consumed by
373  * the driver.
374  */
375 #define	MAX_RAD_SHARED_SECRET_LEN 128
376 typedef struct radius_props {
377 	uint32_t		r_vers;
378 	uint32_t		r_oid;
379 	union {
380 		struct in_addr		u_in4;
381 		struct in6_addr		u_in6;
382 	} r_addr;
383 	/*
384 	 * r_insize indicates which of the previous structs is valid.
385 	 */
386 	int			r_insize;
387 
388 	uint32_t		r_port;
389 	uint8_t			r_shared_secret[MAX_RAD_SHARED_SECRET_LEN];
390 	boolean_t		r_radius_access;
391 	boolean_t		r_radius_config_valid;
392 	uint32_t		r_shared_secret_len;
393 } iscsi_radius_props_t;
394 
395 typedef struct	_IPAddress {
396 	union {
397 		struct in_addr	in4;
398 		struct in6_addr	in6;
399 	} i_addr;
400 	/* i_insize determines which is valid in the union above */
401 	int			i_insize;
402 } iscsi_ipaddr_t;
403 
404 typedef struct	_iSCSITargetAddressKey {
405 	iscsi_ipaddr_t		a_addr;
406 	uint32_t		a_port,
407 				a_oid;
408 } iscsi_addr_t;
409 
410 typedef struct	_iSCSITargetAddressKeyProperties {
411 	uint32_t		al_vers,			/* In */
412 				al_oid;				/* In */
413 	uint32_t		al_in_cnt;			/* In */
414 	uint32_t		al_out_cnt;			/* Out */
415 	uint32_t		al_tpgt;			/* Out */
416 	iscsi_addr_t		al_addrs[1];			/* Out */
417 } iscsi_addr_list_t;
418 
419 typedef struct	_iSCSITargetProperties {
420 	uint32_t		p_vers,				/* In */
421 				p_oid;				/* In */
422 	uchar_t			p_name[ISCSI_MAX_NAME_LEN];	/* Out */
423 	uint_t			p_name_len;			/* Out */
424 	uchar_t			p_alias[ISCSI_MAX_NAME_LEN];	/* Out */
425 	uint_t			p_alias_len;			/* Out */
426 	iSCSIDiscoveryMethod_t	p_discovery;			/* Out */
427 	boolean_t		p_connected;			/* Out */
428 	uint32_t		p_num_of_connections;		/* Out */
429 	/* ---- If connected == B_TRUE then lastErr has no meaning. ---- */
430 	iscsi_error_t		p_last_err;			/* Out */
431 	/*
432 	 * Target portal group tag = -1 value means default.
433 	 */
434 	int			p_tpgt_conf;			/* Out */
435 	int			p_tpgt_nego;			/* Out */
436 	uchar_t			p_isid[ISCSI_ISID_LEN];		/* Out */
437 	uchar_t			p_reserved[128];
438 } iscsi_property_t;
439 
440 typedef struct	_iSCSITargetDeviceList {
441 	uint32_t		tl_vers,			/* In */
442 				tl_in_cnt,			/* In */
443 				tl_tgt_list_type,		/* In */
444 				tl_out_cnt,			/* Out */
445 				tl_oid_list[1];			/* Out */
446 } iscsi_target_list_t;
447 
448 typedef struct	_iSCSIStaticTargetProperties {
449 	uint32_t		p_vers,				/* In */
450 				p_oid;				/* In */
451 	uchar_t			p_name[ISCSI_MAX_NAME_LEN];	/* Out */
452 	uint_t			p_name_len;			/* Out */
453 	iscsi_addr_list_t	p_addr_list;			/* Out */
454 } iscsi_static_property_t;
455 
456 typedef enum iscsi_lun_status {
457 	LunValid, LunDoesNotExist
458 } iscsi_lun_status_t;
459 
460 /*
461  * SCSI inquiry vendor and product identifier buffer length - these values are
462  * defined by the identifier length plus 1 byte for the
463  * null termination.
464  */
465 #define	ISCSI_INQ_VID_BUF_LEN		9	/* 8 byte ID */
466 #define	ISCSI_INQ_PID_BUF_LEN		17	/* 16 byte ID */
467 
468 typedef struct iscsi_lun_props {
469 	uint32_t		lp_vers,			/* In */
470 				lp_tgt_oid,			/* In */
471 				lp_oid,				/* In */
472 				lp_num,				/* Out */
473 				lp_status;			/* Out */
474 	char			lp_pathname[MAXPATHLEN],	/* Out */
475 				lp_vid[ISCSI_INQ_VID_BUF_LEN],	/* Out */
476 				lp_pid[ISCSI_INQ_PID_BUF_LEN];	/* Out */
477 	time_t			lp_time_online;			/* Out */
478 } iscsi_lun_props_t;
479 
480 typedef struct iscsi_if_lun {
481 	uint32_t		l_tgt_oid,
482 				l_oid,
483 				l_num;
484 } iscsi_if_lun_t;
485 
486 typedef struct iscsi_lun_list {
487 	uint32_t		ll_vers;			/* In */
488 	boolean_t		ll_all_tgts;			/* In */
489 	uint32_t		ll_tgt_oid,			/* In */
490 				ll_in_cnt,			/* In */
491 				ll_out_cnt;			/* Out */
492 	iscsi_if_lun_t		ll_luns[1];			/* Out */
493 } iscsi_lun_list_t;
494 
495 typedef struct iscsi_conn_props {
496 	uint32_t		cp_vers,			/* In */
497 				cp_oid,				/* In */
498 				cp_cid,				/* In */
499 				cp_sess_oid;			/* In */
500 	union {
501 		struct	sockaddr_in	soa4;
502 		struct	sockaddr_in6	soa6;
503 	} cp_local;						/* Out */
504 	union {
505 		struct	sockaddr_in	soa4;
506 		struct	sockaddr_in6	soa6;
507 	} cp_peer;						/* Out */
508 
509 
510 	iscsi_login_params_t 	cp_params;
511 	boolean_t 		cp_params_valid;
512 
513 } iscsi_conn_props_t;
514 
515 typedef struct iscsi_if_conn {
516 	uint32_t		c_sess_oid,
517 				c_oid,
518 				c_cid;
519 } iscsi_if_conn_t;
520 
521 typedef struct iscsi_conn_list {
522 	uint32_t		cl_vers;			/* In */
523 	boolean_t		cl_all_sess;			/* In */
524 	uint32_t		cl_sess_oid,			/* In */
525 				cl_in_cnt,			/* In */
526 				cl_out_cnt;			/* Out */
527 	iscsi_if_conn_t		cl_list[1];			/* Out */
528 } iscsi_conn_list_t;
529 
530 typedef enum iSNSDiscoveryMethod {
531 	iSNSDiscoveryMethodStatic	= 0,
532 	iSNSDiscoveryMethodDHCP		= 1,
533 	iSNSDiscoveryMethodSLP		= 2
534 } isns_method_t;
535 
536 typedef struct iSCSIDiscoveryProperties {
537 	uint32_t		vers;
538 	boolean_t		iSNSDiscoverySettable;
539 	boolean_t		iSNSDiscoveryEnabled;
540 	isns_method_t		iSNSDiscoveryMethod;
541 	unsigned char		iSNSDomainName[256];
542 	boolean_t		SLPDiscoverySettable;
543 	boolean_t		SLPDiscoveryEnabled;
544 	boolean_t		StaticDiscoverySettable;
545 	boolean_t		StaticDiscoveryEnabled;
546 	boolean_t		SendTargetsDiscoverySettable;
547 	boolean_t		SendTargetsDiscoveryEnabled;
548 } iSCSIDiscoveryProperties_t;
549 
550 typedef struct iscsi_uscsi {
551 	uint32_t		iu_vers;
552 	uint32_t		iu_oid;
553 	int			iu_tpgt;
554 	uint32_t		iu_len;
555 	uint32_t		iu_lun;
556 	struct uscsi_cmd	iu_ucmd;
557 } iscsi_uscsi_t;
558 
559 #if defined(_SYSCALL32)
560 typedef struct iscsi_uscsi32 {
561 	uint32_t		iu_vers;
562 	uint32_t		iu_oid;
563 	int			iu_tpgt;
564 	uint32_t		iu_len;
565 	uint32_t		iu_lun;
566 	struct uscsi_cmd32	iu_ucmd;
567 } iscsi_uscsi32_t;
568 #endif /* _SYSCALL32 */
569 
570 typedef struct iscsi_sendtgts_entry {
571 	/* ---- Node name, NULL terminated UTF-8 string ---- */
572 	uchar_t			ste_name[ISCSI_MAX_NAME_LEN];
573 
574 	iscsi_addr_t		ste_ipaddr;
575 	int			ste_tpgt;
576 } iscsi_sendtgts_entry_t;
577 
578 typedef struct iscsi_sendtgts_list {
579 	entry_t			stl_entry;			/* In */
580 	uint32_t		stl_in_cnt,			/* In */
581 				stl_out_cnt;			/* Out */
582 	iscsi_sendtgts_entry_t	stl_list[1];			/* Out */
583 } iscsi_sendtgts_list_t;
584 
585 typedef struct iscsi_statictgt_entry {
586 	entry_t			te_entry;			/* In */
587 	uchar_t			te_name[ISCSI_MAX_NAME_LEN];	/* In */
588 } iscsi_target_entry_t;
589 
590 /* iSNS Draft - section 4.1.1. */
591 typedef struct isns_portal_group {
592 	uint8_t pg_iscsi_name[ISCSI_MAX_NAME_LEN];
593 	union {
594 		in_addr_t	u_ip4;
595 		in6_addr_t	u_ip6;
596 	} pg_ip_addr;
597 	int	insize;
598 
599 	in_port_t pg_port;
600 	uint16_t pg_tag;
601 
602 	iscsi_ipaddr_t	isns_server_ip;
603 	uint32_t	isns_server_port;
604 } isns_portal_group_t;
605 
606 typedef struct isns_portal_group_list {
607 	uint32_t		pg_in_cnt,
608 				pg_out_cnt;
609 	isns_portal_group_t	pg_list[1];
610 } isns_portal_group_list_t;
611 
612 typedef struct isns_server_portal_group_list {
613 	iscsi_addr_t		    addr;
614 	isns_portal_group_list_t    addr_port_list;
615 } isns_server_portal_group_list_t;
616 
617 #define	ISCSI_MIN_CONFIG_SESSIONS	1
618 /* lowered max config sessions due to ct_power_cnt >= 0 assert */
619 #define	ISCSI_MAX_CONFIG_SESSIONS	4
620 
621 typedef struct iscsi_config_sess {
622 	uint32_t	ics_ver;
623 	uint32_t	ics_oid;
624 	boolean_t	ics_bound;
625 	uint_t		ics_in;
626 	uint_t		ics_out;
627 	iscsi_ipaddr_t	ics_bindings[1];
628 } iscsi_config_sess_t;
629 
630 /* iscsi re-enumeration */
631 typedef struct iscsi_reen {
632 	uint32_t	re_ver;
633 	uint32_t	re_oid;
634 } iscsi_reen_t;
635 
636 /* iscsi booting prop */
637 typedef struct iscsi_boot_property {
638 	node_name_t	ini_name;
639 	node_name_t	tgt_name;
640 	iscsi_auth_props_t	auth;
641 	iscsi_chap_props_t	ini_chap;
642 	iscsi_chap_props_t	tgt_chap;
643 	int iscsiboot;
644 	boolean_t hba_mpxio_enabled;
645 } iscsi_boot_property_t;
646 
647 #define	ISCSI_SESSION_CONFIG_SIZE(SIZE)		\
648 	(sizeof (iscsi_config_sess_t) +		\
649 	((SIZE - 1) * sizeof (iscsi_ipaddr_t)))
650 
651 /*
652  * Event class and subclass information
653  */
654 #define	EC_ISCSI			"EC_iSCSI"
655 #define	ESC_ISCSI_STATIC_START		"ESC_static_start"
656 #define	ESC_ISCSI_STATIC_END		"ESC_static_end"
657 #define	ESC_ISCSI_SEND_TARGETS_START	"ESC_send_targets_start"
658 #define	ESC_ISCSI_SEND_TARGETS_END	"ESC_send_targets_end"
659 #define	ESC_ISCSI_SLP_START		"ESC_slp_start"
660 #define	ESC_ISCSI_SLP_END		"ESC_slp_end"
661 #define	ESC_ISCSI_ISNS_START		"ESC_isns_start"
662 #define	ESC_ISCSI_ISNS_END		"ESC_isns_end"
663 #define	ESC_ISCSI_PROP_CHANGE		"ESC_prop_change"
664 
665 #ifdef _KERNEL
666 /* ---- iscsi_utils.c ---- */
667 extern int		iscsid_open(char *, int, int);
668 extern int		iscsid_close(int);
669 extern int		iscsid_remove(char *filename);
670 extern int		iscsid_rename(char *oldname, char *newname);
671 extern ssize_t		iscsid_write(int, void *, ssize_t);
672 extern ssize_t		iscsid_read(int, void *, ssize_t);
673 extern ssize_t		iscsid_sendto(struct sonode *, void *, size_t,
674     struct sockaddr *, socklen_t);
675 extern ssize_t		iscsid_recvfrom(struct sonode *, void *buffer,
676     size_t len);
677 extern int		iscsid_errno;
678 #endif
679 
680 /*
681  * Function prototypes for those routines found in the common code
682  */
683 /* ---- utils.c ---- */
684 extern boolean_t	utils_iqn_create(char *, int);
685 extern char		*prt_bitmap(int, char *, char *, int);
686 extern char		*utils_map_param(int);
687 extern boolean_t	parse_addr_port_tpgt(char *in, char **addr,
688 			    int *type, char **port, char **tpgt);
689 
690 #ifdef __cplusplus
691 }
692 #endif
693 
694 #endif /* _ISCSI_IF_H */
695