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