Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc)
  4 *
  5 * Copyright (C) 2005 Dmitry Yusupov
  6 * Copyright (C) 2005 Alex Aizman
  7 * maintained by open-iscsi@googlegroups.com
 
 
 
 
 
 
 
 
 
 
 
 
  8 */
  9
 10#ifndef ISCSI_IF_H
 11#define ISCSI_IF_H
 12
 13#include <scsi/iscsi_proto.h>
 14#include <linux/in.h>
 15#include <linux/in6.h>
 16
 17#define ISCSI_NL_GRP_ISCSID	1
 18#define ISCSI_NL_GRP_UIP	2
 19
 20#define UEVENT_BASE			10
 21#define KEVENT_BASE			100
 22#define ISCSI_ERR_BASE			1000
 23
 24enum iscsi_uevent_e {
 25	ISCSI_UEVENT_UNKNOWN		= 0,
 26
 27	/* down events */
 28	ISCSI_UEVENT_CREATE_SESSION	= UEVENT_BASE + 1,
 29	ISCSI_UEVENT_DESTROY_SESSION	= UEVENT_BASE + 2,
 30	ISCSI_UEVENT_CREATE_CONN	= UEVENT_BASE + 3,
 31	ISCSI_UEVENT_DESTROY_CONN	= UEVENT_BASE + 4,
 32	ISCSI_UEVENT_BIND_CONN		= UEVENT_BASE + 5,
 33	ISCSI_UEVENT_SET_PARAM		= UEVENT_BASE + 6,
 34	ISCSI_UEVENT_START_CONN		= UEVENT_BASE + 7,
 35	ISCSI_UEVENT_STOP_CONN		= UEVENT_BASE + 8,
 36	ISCSI_UEVENT_SEND_PDU		= UEVENT_BASE + 9,
 37	ISCSI_UEVENT_GET_STATS		= UEVENT_BASE + 10,
 38	ISCSI_UEVENT_GET_PARAM		= UEVENT_BASE + 11,
 39
 40	ISCSI_UEVENT_TRANSPORT_EP_CONNECT	= UEVENT_BASE + 12,
 41	ISCSI_UEVENT_TRANSPORT_EP_POLL		= UEVENT_BASE + 13,
 42	ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT	= UEVENT_BASE + 14,
 43
 44	ISCSI_UEVENT_TGT_DSCVR		= UEVENT_BASE + 15,
 45	ISCSI_UEVENT_SET_HOST_PARAM	= UEVENT_BASE + 16,
 46	ISCSI_UEVENT_UNBIND_SESSION	= UEVENT_BASE + 17,
 47	ISCSI_UEVENT_CREATE_BOUND_SESSION		= UEVENT_BASE + 18,
 48	ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST	= UEVENT_BASE + 19,
 49
 50	ISCSI_UEVENT_PATH_UPDATE	= UEVENT_BASE + 20,
 51	ISCSI_UEVENT_SET_IFACE_PARAMS	= UEVENT_BASE + 21,
 52	ISCSI_UEVENT_PING		= UEVENT_BASE + 22,
 53	ISCSI_UEVENT_GET_CHAP		= UEVENT_BASE + 23,
 54	ISCSI_UEVENT_DELETE_CHAP	= UEVENT_BASE + 24,
 55	ISCSI_UEVENT_SET_FLASHNODE_PARAMS	= UEVENT_BASE + 25,
 56	ISCSI_UEVENT_NEW_FLASHNODE	= UEVENT_BASE + 26,
 57	ISCSI_UEVENT_DEL_FLASHNODE	= UEVENT_BASE + 27,
 58	ISCSI_UEVENT_LOGIN_FLASHNODE	= UEVENT_BASE + 28,
 59	ISCSI_UEVENT_LOGOUT_FLASHNODE	= UEVENT_BASE + 29,
 60	ISCSI_UEVENT_LOGOUT_FLASHNODE_SID	= UEVENT_BASE + 30,
 61	ISCSI_UEVENT_SET_CHAP		= UEVENT_BASE + 31,
 62	ISCSI_UEVENT_GET_HOST_STATS	= UEVENT_BASE + 32,
 63	ISCSI_UEVENT_DESTROY_SESSION_ASYNC	= UEVENT_BASE + 33,
 64
 65	/* up events */
 66	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
 67	ISCSI_KEVENT_CONN_ERROR		= KEVENT_BASE + 2,
 68	ISCSI_KEVENT_IF_ERROR		= KEVENT_BASE + 3,
 69	ISCSI_KEVENT_DESTROY_SESSION	= KEVENT_BASE + 4,
 70	ISCSI_KEVENT_UNBIND_SESSION	= KEVENT_BASE + 5,
 71	ISCSI_KEVENT_CREATE_SESSION	= KEVENT_BASE + 6,
 72
 73	ISCSI_KEVENT_PATH_REQ		= KEVENT_BASE + 7,
 74	ISCSI_KEVENT_IF_DOWN		= KEVENT_BASE + 8,
 75	ISCSI_KEVENT_CONN_LOGIN_STATE   = KEVENT_BASE + 9,
 76	ISCSI_KEVENT_HOST_EVENT		= KEVENT_BASE + 10,
 77	ISCSI_KEVENT_PING_COMP		= KEVENT_BASE + 11,
 78};
 79
 80enum iscsi_tgt_dscvr {
 81	ISCSI_TGT_DSCVR_SEND_TARGETS	= 1,
 82	ISCSI_TGT_DSCVR_ISNS		= 2,
 83	ISCSI_TGT_DSCVR_SLP		= 3,
 84};
 85
 86enum iscsi_host_event_code {
 87	ISCSI_EVENT_LINKUP		= 1,
 88	ISCSI_EVENT_LINKDOWN,
 89	/* must always be last */
 90	ISCSI_EVENT_MAX,
 91};
 92
 93struct iscsi_uevent {
 94	uint32_t type; /* k/u events type */
 95	uint32_t iferror; /* carries interface or resource errors */
 96	uint64_t transport_handle;
 97
 98	union {
 99		/* messages u -> k */
100		struct msg_create_session {
101			uint32_t	initial_cmdsn;
102			uint16_t	cmds_max;
103			uint16_t	queue_depth;
104		} c_session;
105		struct msg_create_bound_session {
106			uint64_t	ep_handle;
107			uint32_t	initial_cmdsn;
108			uint16_t	cmds_max;
109			uint16_t	queue_depth;
110		} c_bound_session;
111		struct msg_destroy_session {
112			uint32_t	sid;
113		} d_session;
114		struct msg_create_conn {
115			uint32_t	sid;
116			uint32_t	cid;
117		} c_conn;
118		struct msg_bind_conn {
119			uint32_t	sid;
120			uint32_t	cid;
121			uint64_t	transport_eph;
122			uint32_t	is_leading;
123		} b_conn;
124		struct msg_destroy_conn {
125			uint32_t	sid;
126			uint32_t	cid;
127		} d_conn;
128		struct msg_send_pdu {
129			uint32_t	sid;
130			uint32_t	cid;
131			uint32_t	hdr_size;
132			uint32_t	data_size;
133		} send_pdu;
134		struct msg_set_param {
135			uint32_t	sid;
136			uint32_t	cid;
137			uint32_t	param; /* enum iscsi_param */
138			uint32_t	len;
139		} set_param;
140		struct msg_start_conn {
141			uint32_t	sid;
142			uint32_t	cid;
143		} start_conn;
144		struct msg_stop_conn {
145			uint32_t	sid;
146			uint32_t	cid;
147			uint64_t	conn_handle;
148			uint32_t	flag;
149		} stop_conn;
150		struct msg_get_stats {
151			uint32_t	sid;
152			uint32_t	cid;
153		} get_stats;
154		struct msg_transport_connect {
155			uint32_t	non_blocking;
156		} ep_connect;
157		struct msg_transport_connect_through_host {
158			uint32_t	host_no;
159			uint32_t	non_blocking;
160		} ep_connect_through_host;
161		struct msg_transport_poll {
162			uint64_t	ep_handle;
163			uint32_t	timeout_ms;
164		} ep_poll;
165		struct msg_transport_disconnect {
166			uint64_t	ep_handle;
167		} ep_disconnect;
168		struct msg_tgt_dscvr {
169			enum iscsi_tgt_dscvr	type;
170			uint32_t	host_no;
171			/*
172 			 * enable = 1 to establish a new connection
173			 * with the server. enable = 0 to disconnect
174			 * from the server. Used primarily to switch
175			 * from one iSNS server to another.
176			 */
177			uint32_t	enable;
178		} tgt_dscvr;
179		struct msg_set_host_param {
180			uint32_t	host_no;
181			uint32_t	param; /* enum iscsi_host_param */
182			uint32_t	len;
183		} set_host_param;
184		struct msg_set_path {
185			uint32_t	host_no;
186		} set_path;
187		struct msg_set_iface_params {
188			uint32_t	host_no;
189			uint32_t	count;
190		} set_iface_params;
191		struct msg_iscsi_ping {
192			uint32_t        host_no;
193			uint32_t        iface_num;
194			uint32_t        iface_type;
195			uint32_t        payload_size;
196			uint32_t	pid;	/* unique ping id associated
197						   with each ping request */
198		} iscsi_ping;
199		struct msg_get_chap {
200			uint32_t	host_no;
201			uint32_t	num_entries; /* number of CHAP entries
202						      * on request, number of
203						      * valid CHAP entries on
204						      * response */
205			uint16_t	chap_tbl_idx;
206		} get_chap;
207		struct msg_delete_chap {
208		       uint32_t        host_no;
209		       uint16_t        chap_tbl_idx;
210		} delete_chap;
211		struct msg_set_flashnode_param {
212			uint32_t	host_no;
213			uint32_t	flashnode_idx;
214			uint32_t	count;
215		} set_flashnode;
216		struct msg_new_flashnode {
217			uint32_t	host_no;
218			uint32_t	len;
219		} new_flashnode;
220		struct msg_del_flashnode {
221			uint32_t	host_no;
222			uint32_t	flashnode_idx;
223		} del_flashnode;
224		struct msg_login_flashnode {
225			uint32_t	host_no;
226			uint32_t	flashnode_idx;
227		} login_flashnode;
228		struct msg_logout_flashnode {
229			uint32_t	host_no;
230			uint32_t	flashnode_idx;
231		} logout_flashnode;
232		struct msg_logout_flashnode_sid {
233			uint32_t	host_no;
234			uint32_t	sid;
235		} logout_flashnode_sid;
236		struct msg_get_host_stats {
237			uint32_t host_no;
238		} get_host_stats;
239	} u;
240	union {
241		/* messages k -> u */
242		int			retcode;
243		struct msg_create_session_ret {
244			uint32_t	sid;
245			uint32_t	host_no;
246		} c_session_ret;
247		struct msg_create_conn_ret {
248			uint32_t	sid;
249			uint32_t	cid;
250		} c_conn_ret;
251		struct msg_unbind_session {
252			uint32_t	sid;
253			uint32_t	host_no;
254		} unbind_session;
255		struct msg_recv_req {
256			uint32_t	sid;
257			uint32_t	cid;
258			uint64_t	recv_handle;
259		} recv_req;
260		struct msg_conn_login {
261			uint32_t        sid;
262			uint32_t        cid;
263			uint32_t        state; /* enum iscsi_conn_state */
264		} conn_login;
265		struct msg_conn_error {
266			uint32_t	sid;
267			uint32_t	cid;
268			uint32_t	error; /* enum iscsi_err */
269		} connerror;
270		struct msg_session_destroyed {
271			uint32_t	host_no;
272			uint32_t	sid;
273		} d_session;
274		struct msg_transport_connect_ret {
275			uint64_t	handle;
276		} ep_connect_ret;
277		struct msg_req_path {
278			uint32_t	host_no;
279		} req_path;
280		struct msg_notify_if_down {
281			uint32_t	host_no;
282		} notify_if_down;
283		struct msg_host_event {
284			uint32_t	host_no;
285			uint32_t	data_size;
286			enum iscsi_host_event_code code;
287		} host_event;
288		struct msg_ping_comp {
289			uint32_t        host_no;
290			uint32_t        status; /* enum
291						 * iscsi_ping_status_code */
292			uint32_t	pid;	/* unique ping id associated
293						   with each ping request */
294			uint32_t        data_size;
295		} ping_comp;
296		struct msg_new_flashnode_ret {
297			uint32_t	flashnode_idx;
298		} new_flashnode_ret;
299	} r;
300} __attribute__ ((aligned (sizeof(uint64_t))));
301
302enum iscsi_param_type {
303	ISCSI_PARAM,		/* iscsi_param (session, conn, target, LU) */
304	ISCSI_HOST_PARAM,	/* iscsi_host_param */
305	ISCSI_NET_PARAM,	/* iscsi_net_param */
306	ISCSI_FLASHNODE_PARAM,	/* iscsi_flashnode_param */
307	ISCSI_CHAP_PARAM,	/* iscsi_chap_param */
308	ISCSI_IFACE_PARAM,	/* iscsi_iface_param */
309};
310
311/* structure for minimalist usecase */
312struct iscsi_param_info {
313	uint32_t len;		/* Actual length of the param value */
314	uint16_t param;		/* iscsi param */
315	uint8_t value[];	/* length sized value follows */
316} __packed;
317
318struct iscsi_iface_param_info {
319	uint32_t iface_num;	/* iface number, 0 - n */
320	uint32_t len;		/* Actual length of the param */
321	uint16_t param;		/* iscsi param value */
322	uint8_t iface_type;	/* IPv4 or IPv6 */
323	uint8_t param_type;	/* iscsi_param_type */
324	uint8_t value[];	/* length sized value follows */
325} __packed;
326
327/*
328 * To keep the struct iscsi_uevent size the same for userspace code
329 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
330 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
331 * struct iscsi_uevent in the NETLINK_ISCSI message.
332 */
333struct iscsi_path {
334	uint64_t	handle;
335	uint8_t		mac_addr[6];
336	uint8_t		mac_addr_old[6];
337	uint32_t	ip_addr_len;	/* 4 or 16 */
338	union {
339		struct in_addr	v4_addr;
340		struct in6_addr	v6_addr;
341	} src;
342	union {
343		struct in_addr	v4_addr;
344		struct in6_addr	v6_addr;
345	} dst;
346	uint16_t	vlan_id;
347	uint16_t	pmtu;
348} __attribute__ ((aligned (sizeof(uint64_t))));
349
350/* iscsi iface enabled/disabled setting */
351#define ISCSI_IFACE_DISABLE	0x01
352#define ISCSI_IFACE_ENABLE	0x02
353
354/* ipv4 bootproto */
355#define ISCSI_BOOTPROTO_STATIC		0x01
356#define ISCSI_BOOTPROTO_DHCP		0x02
357
358/* ipv6 addr autoconfig type */
359#define ISCSI_IPV6_AUTOCFG_DISABLE		0x01
360#define ISCSI_IPV6_AUTOCFG_ND_ENABLE		0x02
361#define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE	0x03
362
363/* ipv6 link local addr type */
364#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE	0x01
365#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE	0x02
366
367/* ipv6 router addr type */
368#define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE	0x01
369#define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE	0x02
370
371#define ISCSI_IFACE_TYPE_IPV4		0x01
372#define ISCSI_IFACE_TYPE_IPV6		0x02
373
374#define ISCSI_MAX_VLAN_ID		4095
375#define ISCSI_MAX_VLAN_PRIORITY		7
376
377/* iscsi vlan enable/disabled setting */
378#define ISCSI_VLAN_DISABLE	0x01
379#define ISCSI_VLAN_ENABLE	0x02
380
381/* iscsi generic enable/disabled setting for various features */
382#define ISCSI_NET_PARAM_DISABLE		0x01
383#define ISCSI_NET_PARAM_ENABLE		0x02
384
385/* iSCSI network params */
386enum iscsi_net_param {
387	ISCSI_NET_PARAM_IPV4_ADDR		= 1,
388	ISCSI_NET_PARAM_IPV4_SUBNET,
389	ISCSI_NET_PARAM_IPV4_GW,
390	ISCSI_NET_PARAM_IPV4_BOOTPROTO,
391	ISCSI_NET_PARAM_MAC,
392	ISCSI_NET_PARAM_IPV6_LINKLOCAL,
393	ISCSI_NET_PARAM_IPV6_ADDR,
394	ISCSI_NET_PARAM_IPV6_ROUTER,
395	ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG,
396	ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG,
397	ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG,
398	ISCSI_NET_PARAM_IFACE_ENABLE,
399	ISCSI_NET_PARAM_VLAN_ID,
400	ISCSI_NET_PARAM_VLAN_PRIORITY,
401	ISCSI_NET_PARAM_VLAN_ENABLED,
402	ISCSI_NET_PARAM_VLAN_TAG,
403	ISCSI_NET_PARAM_IFACE_TYPE,
404	ISCSI_NET_PARAM_IFACE_NAME,
405	ISCSI_NET_PARAM_MTU,
406	ISCSI_NET_PARAM_PORT,
407	ISCSI_NET_PARAM_IPADDR_STATE,
408	ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE,
409	ISCSI_NET_PARAM_IPV6_ROUTER_STATE,
410	ISCSI_NET_PARAM_DELAYED_ACK_EN,
411	ISCSI_NET_PARAM_TCP_NAGLE_DISABLE,
412	ISCSI_NET_PARAM_TCP_WSF_DISABLE,
413	ISCSI_NET_PARAM_TCP_WSF,
414	ISCSI_NET_PARAM_TCP_TIMER_SCALE,
415	ISCSI_NET_PARAM_TCP_TIMESTAMP_EN,
416	ISCSI_NET_PARAM_CACHE_ID,
417	ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN,
418	ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN,
419	ISCSI_NET_PARAM_IPV4_TOS_EN,
420	ISCSI_NET_PARAM_IPV4_TOS,
421	ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN,
422	ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN,
423	ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID,
424	ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN,
425	ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN,
426	ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID,
427	ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN,
428	ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE,
429	ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN,
430	ISCSI_NET_PARAM_IPV4_TTL,
431	ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN,
432	ISCSI_NET_PARAM_IPV6_MLD_EN,
433	ISCSI_NET_PARAM_IPV6_FLOW_LABEL,
434	ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS,
435	ISCSI_NET_PARAM_IPV6_HOP_LIMIT,
436	ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO,
437	ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME,
438	ISCSI_NET_PARAM_IPV6_ND_STALE_TMO,
439	ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT,
440	ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU,
441	ISCSI_NET_PARAM_REDIRECT_EN,
442};
443
444enum iscsi_ipaddress_state {
445	ISCSI_IPDDRESS_STATE_UNCONFIGURED,
446	ISCSI_IPDDRESS_STATE_ACQUIRING,
447	ISCSI_IPDDRESS_STATE_TENTATIVE,
448	ISCSI_IPDDRESS_STATE_VALID,
449	ISCSI_IPDDRESS_STATE_DISABLING,
450	ISCSI_IPDDRESS_STATE_INVALID,
451	ISCSI_IPDDRESS_STATE_DEPRECATED,
452};
453
454enum iscsi_router_state {
455	ISCSI_ROUTER_STATE_UNKNOWN,
456	ISCSI_ROUTER_STATE_ADVERTISED,
457	ISCSI_ROUTER_STATE_MANUAL,
458	ISCSI_ROUTER_STATE_STALE,
459};
460
461/* iSCSI specific settings params for iface */
462enum iscsi_iface_param {
463	ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO,
464	ISCSI_IFACE_PARAM_HDRDGST_EN,
465	ISCSI_IFACE_PARAM_DATADGST_EN,
466	ISCSI_IFACE_PARAM_IMM_DATA_EN,
467	ISCSI_IFACE_PARAM_INITIAL_R2T_EN,
468	ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN,
469	ISCSI_IFACE_PARAM_PDU_INORDER_EN,
470	ISCSI_IFACE_PARAM_ERL,
471	ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH,
472	ISCSI_IFACE_PARAM_FIRST_BURST,
473	ISCSI_IFACE_PARAM_MAX_R2T,
474	ISCSI_IFACE_PARAM_MAX_BURST,
475	ISCSI_IFACE_PARAM_CHAP_AUTH_EN,
476	ISCSI_IFACE_PARAM_BIDI_CHAP_EN,
477	ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL,
478	ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN,
479	ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN,
480	ISCSI_IFACE_PARAM_INITIATOR_NAME,
481};
482
483enum iscsi_conn_state {
484	ISCSI_CONN_STATE_FREE,
485	ISCSI_CONN_STATE_XPT_WAIT,
486	ISCSI_CONN_STATE_IN_LOGIN,
487	ISCSI_CONN_STATE_LOGGED_IN,
488	ISCSI_CONN_STATE_IN_LOGOUT,
489	ISCSI_CONN_STATE_LOGOUT_REQUESTED,
490	ISCSI_CONN_STATE_CLEANUP_WAIT,
491};
492
493/*
494 * Common error codes
495 */
496enum iscsi_err {
497	ISCSI_OK			= 0,
498
499	ISCSI_ERR_DATASN		= ISCSI_ERR_BASE + 1,
500	ISCSI_ERR_DATA_OFFSET		= ISCSI_ERR_BASE + 2,
501	ISCSI_ERR_MAX_CMDSN		= ISCSI_ERR_BASE + 3,
502	ISCSI_ERR_EXP_CMDSN		= ISCSI_ERR_BASE + 4,
503	ISCSI_ERR_BAD_OPCODE		= ISCSI_ERR_BASE + 5,
504	ISCSI_ERR_DATALEN		= ISCSI_ERR_BASE + 6,
505	ISCSI_ERR_AHSLEN		= ISCSI_ERR_BASE + 7,
506	ISCSI_ERR_PROTO			= ISCSI_ERR_BASE + 8,
507	ISCSI_ERR_LUN			= ISCSI_ERR_BASE + 9,
508	ISCSI_ERR_BAD_ITT		= ISCSI_ERR_BASE + 10,
509	ISCSI_ERR_CONN_FAILED		= ISCSI_ERR_BASE + 11,
510	ISCSI_ERR_R2TSN			= ISCSI_ERR_BASE + 12,
511	ISCSI_ERR_SESSION_FAILED	= ISCSI_ERR_BASE + 13,
512	ISCSI_ERR_HDR_DGST		= ISCSI_ERR_BASE + 14,
513	ISCSI_ERR_DATA_DGST		= ISCSI_ERR_BASE + 15,
514	ISCSI_ERR_PARAM_NOT_FOUND	= ISCSI_ERR_BASE + 16,
515	ISCSI_ERR_NO_SCSI_CMD		= ISCSI_ERR_BASE + 17,
516	ISCSI_ERR_INVALID_HOST		= ISCSI_ERR_BASE + 18,
517	ISCSI_ERR_XMIT_FAILED		= ISCSI_ERR_BASE + 19,
518	ISCSI_ERR_TCP_CONN_CLOSE	= ISCSI_ERR_BASE + 20,
519	ISCSI_ERR_SCSI_EH_SESSION_RST	= ISCSI_ERR_BASE + 21,
520	ISCSI_ERR_NOP_TIMEDOUT		= ISCSI_ERR_BASE + 22,
521};
522
523/*
524 * iSCSI Parameters (RFC3720)
525 */
526enum iscsi_param {
527	/* passed in using netlink set param */
528	ISCSI_PARAM_MAX_RECV_DLENGTH,
529	ISCSI_PARAM_MAX_XMIT_DLENGTH,
530	ISCSI_PARAM_HDRDGST_EN,
531	ISCSI_PARAM_DATADGST_EN,
532	ISCSI_PARAM_INITIAL_R2T_EN,
533	ISCSI_PARAM_MAX_R2T,
534	ISCSI_PARAM_IMM_DATA_EN,
535	ISCSI_PARAM_FIRST_BURST,
536	ISCSI_PARAM_MAX_BURST,
537	ISCSI_PARAM_PDU_INORDER_EN,
538	ISCSI_PARAM_DATASEQ_INORDER_EN,
539	ISCSI_PARAM_ERL,
540	ISCSI_PARAM_IFMARKER_EN,
541	ISCSI_PARAM_OFMARKER_EN,
542	ISCSI_PARAM_EXP_STATSN,
543	ISCSI_PARAM_TARGET_NAME,
544	ISCSI_PARAM_TPGT,
545	ISCSI_PARAM_PERSISTENT_ADDRESS,
546	ISCSI_PARAM_PERSISTENT_PORT,
547	ISCSI_PARAM_SESS_RECOVERY_TMO,
548
549	/* passed in through bind conn using transport_fd */
550	ISCSI_PARAM_CONN_PORT,
551	ISCSI_PARAM_CONN_ADDRESS,
552
553	ISCSI_PARAM_USERNAME,
554	ISCSI_PARAM_USERNAME_IN,
555	ISCSI_PARAM_PASSWORD,
556	ISCSI_PARAM_PASSWORD_IN,
557
558	ISCSI_PARAM_FAST_ABORT,
559	ISCSI_PARAM_ABORT_TMO,
560	ISCSI_PARAM_LU_RESET_TMO,
561	ISCSI_PARAM_HOST_RESET_TMO,
562
563	ISCSI_PARAM_PING_TMO,
564	ISCSI_PARAM_RECV_TMO,
565
566	ISCSI_PARAM_IFACE_NAME,
567	ISCSI_PARAM_ISID,
568	ISCSI_PARAM_INITIATOR_NAME,
569
570	ISCSI_PARAM_TGT_RESET_TMO,
571	ISCSI_PARAM_TARGET_ALIAS,
572
573	ISCSI_PARAM_CHAP_IN_IDX,
574	ISCSI_PARAM_CHAP_OUT_IDX,
575
576	ISCSI_PARAM_BOOT_ROOT,
577	ISCSI_PARAM_BOOT_NIC,
578	ISCSI_PARAM_BOOT_TARGET,
579
580	ISCSI_PARAM_AUTO_SND_TGT_DISABLE,
581	ISCSI_PARAM_DISCOVERY_SESS,
582	ISCSI_PARAM_PORTAL_TYPE,
583	ISCSI_PARAM_CHAP_AUTH_EN,
584	ISCSI_PARAM_DISCOVERY_LOGOUT_EN,
585	ISCSI_PARAM_BIDI_CHAP_EN,
586	ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL,
587
588	ISCSI_PARAM_DEF_TIME2WAIT,
589	ISCSI_PARAM_DEF_TIME2RETAIN,
590	ISCSI_PARAM_MAX_SEGMENT_SIZE,
591	ISCSI_PARAM_STATSN,
592	ISCSI_PARAM_KEEPALIVE_TMO,
593	ISCSI_PARAM_LOCAL_PORT,
594	ISCSI_PARAM_TSID,
595	ISCSI_PARAM_DEF_TASKMGMT_TMO,
596
597	ISCSI_PARAM_TCP_TIMESTAMP_STAT,
598	ISCSI_PARAM_TCP_WSF_DISABLE,
599	ISCSI_PARAM_TCP_NAGLE_DISABLE,
600	ISCSI_PARAM_TCP_TIMER_SCALE,
601	ISCSI_PARAM_TCP_TIMESTAMP_EN,
602	ISCSI_PARAM_TCP_XMIT_WSF,
603	ISCSI_PARAM_TCP_RECV_WSF,
604	ISCSI_PARAM_IP_FRAGMENT_DISABLE,
605	ISCSI_PARAM_IPV4_TOS,
606	ISCSI_PARAM_IPV6_TC,
607	ISCSI_PARAM_IPV6_FLOW_LABEL,
608	ISCSI_PARAM_IS_FW_ASSIGNED_IPV6,
609
610	ISCSI_PARAM_DISCOVERY_PARENT_IDX,
611	ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
612	ISCSI_PARAM_LOCAL_IPADDR,
613	/* must always be last */
614	ISCSI_PARAM_MAX,
615};
616
617/* iSCSI HBA params */
618enum iscsi_host_param {
619	ISCSI_HOST_PARAM_HWADDRESS,
620	ISCSI_HOST_PARAM_INITIATOR_NAME,
621	ISCSI_HOST_PARAM_NETDEV_NAME,
622	ISCSI_HOST_PARAM_IPADDRESS,
623	ISCSI_HOST_PARAM_PORT_STATE,
624	ISCSI_HOST_PARAM_PORT_SPEED,
625	ISCSI_HOST_PARAM_MAX,
626};
627
628/* portal type */
629#define PORTAL_TYPE_IPV4	"ipv4"
630#define PORTAL_TYPE_IPV6	"ipv6"
631
632/* iSCSI Flash Target params */
633enum iscsi_flashnode_param {
634	ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6,
635	ISCSI_FLASHNODE_PORTAL_TYPE,
636	ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE,
637	ISCSI_FLASHNODE_DISCOVERY_SESS,
638	ISCSI_FLASHNODE_ENTRY_EN,
639	ISCSI_FLASHNODE_HDR_DGST_EN,
640	ISCSI_FLASHNODE_DATA_DGST_EN,
641	ISCSI_FLASHNODE_IMM_DATA_EN,
642	ISCSI_FLASHNODE_INITIAL_R2T_EN,
643	ISCSI_FLASHNODE_DATASEQ_INORDER,
644	ISCSI_FLASHNODE_PDU_INORDER,
645	ISCSI_FLASHNODE_CHAP_AUTH_EN,
646	ISCSI_FLASHNODE_SNACK_REQ_EN,
647	ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN,
648	ISCSI_FLASHNODE_BIDI_CHAP_EN,
649	/* make authentication for discovery sessions optional */
650	ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL,
651	ISCSI_FLASHNODE_ERL,
652	ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT,
653	ISCSI_FLASHNODE_TCP_NAGLE_DISABLE,
654	ISCSI_FLASHNODE_TCP_WSF_DISABLE,
655	ISCSI_FLASHNODE_TCP_TIMER_SCALE,
656	ISCSI_FLASHNODE_TCP_TIMESTAMP_EN,
657	ISCSI_FLASHNODE_IP_FRAG_DISABLE,
658	ISCSI_FLASHNODE_MAX_RECV_DLENGTH,
659	ISCSI_FLASHNODE_MAX_XMIT_DLENGTH,
660	ISCSI_FLASHNODE_FIRST_BURST,
661	ISCSI_FLASHNODE_DEF_TIME2WAIT,
662	ISCSI_FLASHNODE_DEF_TIME2RETAIN,
663	ISCSI_FLASHNODE_MAX_R2T,
664	ISCSI_FLASHNODE_KEEPALIVE_TMO,
665	ISCSI_FLASHNODE_ISID,
666	ISCSI_FLASHNODE_TSID,
667	ISCSI_FLASHNODE_PORT,
668	ISCSI_FLASHNODE_MAX_BURST,
669	ISCSI_FLASHNODE_DEF_TASKMGMT_TMO,
670	ISCSI_FLASHNODE_IPADDR,
671	ISCSI_FLASHNODE_ALIAS,
672	ISCSI_FLASHNODE_REDIRECT_IPADDR,
673	ISCSI_FLASHNODE_MAX_SEGMENT_SIZE,
674	ISCSI_FLASHNODE_LOCAL_PORT,
675	ISCSI_FLASHNODE_IPV4_TOS,
676	ISCSI_FLASHNODE_IPV6_TC,
677	ISCSI_FLASHNODE_IPV6_FLOW_LABEL,
678	ISCSI_FLASHNODE_NAME,
679	ISCSI_FLASHNODE_TPGT,
680	ISCSI_FLASHNODE_LINK_LOCAL_IPV6,
681	ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX,
682	ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE,
683	ISCSI_FLASHNODE_TCP_XMIT_WSF,
684	ISCSI_FLASHNODE_TCP_RECV_WSF,
685	ISCSI_FLASHNODE_CHAP_IN_IDX,
686	ISCSI_FLASHNODE_CHAP_OUT_IDX,
687	ISCSI_FLASHNODE_USERNAME,
688	ISCSI_FLASHNODE_USERNAME_IN,
689	ISCSI_FLASHNODE_PASSWORD,
690	ISCSI_FLASHNODE_PASSWORD_IN,
691	ISCSI_FLASHNODE_STATSN,
692	ISCSI_FLASHNODE_EXP_STATSN,
693	ISCSI_FLASHNODE_IS_BOOT_TGT,
694
695	ISCSI_FLASHNODE_MAX,
696};
697
698struct iscsi_flashnode_param_info {
699	uint32_t len;		/* Actual length of the param */
700	uint16_t param;		/* iscsi param value */
701	uint8_t value[];	/* length sized value follows */
702} __packed;
703
704enum iscsi_discovery_parent_type {
705	ISCSI_DISC_PARENT_UNKNOWN	= 0x1,
706	ISCSI_DISC_PARENT_SENDTGT	= 0x2,
707	ISCSI_DISC_PARENT_ISNS		= 0x3,
708};
709
710/* iSCSI port Speed */
711enum iscsi_port_speed {
712	ISCSI_PORT_SPEED_UNKNOWN	= 0x1,
713	ISCSI_PORT_SPEED_10MBPS		= 0x2,
714	ISCSI_PORT_SPEED_100MBPS	= 0x4,
715	ISCSI_PORT_SPEED_1GBPS		= 0x8,
716	ISCSI_PORT_SPEED_10GBPS		= 0x10,
717	ISCSI_PORT_SPEED_25GBPS         = 0x20,
718	ISCSI_PORT_SPEED_40GBPS         = 0x40,
719};
720
721/* iSCSI port state */
722enum iscsi_port_state {
723	ISCSI_PORT_STATE_DOWN		= 0x1,
724	ISCSI_PORT_STATE_UP		= 0x2,
725};
726
727/* iSCSI PING status/error code */
728enum iscsi_ping_status_code {
729	ISCSI_PING_SUCCESS			= 0,
730	ISCSI_PING_FW_DISABLED			= 0x1,
731	ISCSI_PING_IPADDR_INVALID		= 0x2,
732	ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID	= 0x3,
733	ISCSI_PING_TIMEOUT			= 0x4,
734	ISCSI_PING_INVALID_DEST_ADDR		= 0x5,
735	ISCSI_PING_OVERSIZE_PACKET		= 0x6,
736	ISCSI_PING_ICMP_ERROR			= 0x7,
737	ISCSI_PING_MAX_REQ_EXCEEDED		= 0x8,
738	ISCSI_PING_NO_ARP_RECEIVED		= 0x9,
739};
740
741#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
742#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
743
744/*
745 * These flags presents iSCSI Data-Path capabilities.
746 */
747#define CAP_RECOVERY_L0		0x1
748#define CAP_RECOVERY_L1		0x2
749#define CAP_RECOVERY_L2		0x4
750#define CAP_MULTI_R2T		0x8
751#define CAP_HDRDGST		0x10
752#define CAP_DATADGST		0x20
753#define CAP_MULTI_CONN		0x40
754#define CAP_TEXT_NEGO		0x80
755#define CAP_MARKERS		0x100
756#define CAP_FW_DB		0x200
757#define CAP_SENDTARGETS_OFFLOAD	0x400	/* offload discovery process */
758#define CAP_DATA_PATH_OFFLOAD	0x800	/* offload entire IO path */
759#define CAP_DIGEST_OFFLOAD	0x1000	/* offload hdr and data digests */
760#define CAP_PADDING_OFFLOAD	0x2000	/* offload padding insertion, removal,
761					 and verification */
762#define CAP_LOGIN_OFFLOAD	0x4000  /* offload session login */
763
764/*
765 * These flags describes reason of stop_conn() call
766 */
767#define STOP_CONN_TERM		0x1
768#define STOP_CONN_SUSPEND	0x2
769#define STOP_CONN_RECOVER	0x3
770
771#define ISCSI_STATS_CUSTOM_MAX		32
772#define ISCSI_STATS_CUSTOM_DESC_MAX	64
773struct iscsi_stats_custom {
774	char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
775	uint64_t value;
776};
777
778/*
779 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
780 *
781 * Note: this structure contains counters collected on per-connection basis.
782 */
783struct iscsi_stats {
784	/* octets */
785	uint64_t txdata_octets;
786	uint64_t rxdata_octets;
787
788	/* xmit pdus */
789	uint32_t noptx_pdus;
790	uint32_t scsicmd_pdus;
791	uint32_t tmfcmd_pdus;
792	uint32_t login_pdus;
793	uint32_t text_pdus;
794	uint32_t dataout_pdus;
795	uint32_t logout_pdus;
796	uint32_t snack_pdus;
797
798	/* recv pdus */
799	uint32_t noprx_pdus;
800	uint32_t scsirsp_pdus;
801	uint32_t tmfrsp_pdus;
802	uint32_t textrsp_pdus;
803	uint32_t datain_pdus;
804	uint32_t logoutrsp_pdus;
805	uint32_t r2t_pdus;
806	uint32_t async_pdus;
807	uint32_t rjt_pdus;
808
809	/* errors */
810	uint32_t digest_err;
811	uint32_t timeout_err;
812
813	/*
814	 * iSCSI Custom Statistics support, i.e. Transport could
815	 * extend existing MIB statistics with its own specific statistics
816	 * up to ISCSI_STATS_CUSTOM_MAX
817	 */
818	uint32_t custom_length;
819	struct iscsi_stats_custom custom[]
820		__attribute__ ((aligned (sizeof(uint64_t))));
821};
822
823enum chap_type_e {
824	CHAP_TYPE_OUT,
825	CHAP_TYPE_IN,
826};
827
828enum iscsi_chap_param {
829	ISCSI_CHAP_PARAM_INDEX,
830	ISCSI_CHAP_PARAM_CHAP_TYPE,
831	ISCSI_CHAP_PARAM_USERNAME,
832	ISCSI_CHAP_PARAM_PASSWORD,
833	ISCSI_CHAP_PARAM_PASSWORD_LEN
834};
835
836#define ISCSI_CHAP_AUTH_NAME_MAX_LEN	256
837#define ISCSI_CHAP_AUTH_SECRET_MAX_LEN	256
838struct iscsi_chap_rec {
839	uint16_t chap_tbl_idx;
840	enum chap_type_e chap_type;
841	char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
842	uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
843	uint8_t password_length;
844};
845
846#define ISCSI_HOST_STATS_CUSTOM_MAX             32
847#define ISCSI_HOST_STATS_CUSTOM_DESC_MAX        64
848struct iscsi_host_stats_custom {
849	char desc[ISCSI_HOST_STATS_CUSTOM_DESC_MAX];
850	uint64_t value;
851};
852
853/* struct iscsi_offload_host_stats: Host statistics,
854 * Include statistics for MAC, IP, TCP & iSCSI.
855 */
856struct iscsi_offload_host_stats {
857	/* MAC */
858	uint64_t mactx_frames;
859	uint64_t mactx_bytes;
860	uint64_t mactx_multicast_frames;
861	uint64_t mactx_broadcast_frames;
862	uint64_t mactx_pause_frames;
863	uint64_t mactx_control_frames;
864	uint64_t mactx_deferral;
865	uint64_t mactx_excess_deferral;
866	uint64_t mactx_late_collision;
867	uint64_t mactx_abort;
868	uint64_t mactx_single_collision;
869	uint64_t mactx_multiple_collision;
870	uint64_t mactx_collision;
871	uint64_t mactx_frames_dropped;
872	uint64_t mactx_jumbo_frames;
873	uint64_t macrx_frames;
874	uint64_t macrx_bytes;
875	uint64_t macrx_unknown_control_frames;
876	uint64_t macrx_pause_frames;
877	uint64_t macrx_control_frames;
878	uint64_t macrx_dribble;
879	uint64_t macrx_frame_length_error;
880	uint64_t macrx_jabber;
881	uint64_t macrx_carrier_sense_error;
882	uint64_t macrx_frame_discarded;
883	uint64_t macrx_frames_dropped;
884	uint64_t mac_crc_error;
885	uint64_t mac_encoding_error;
886	uint64_t macrx_length_error_large;
887	uint64_t macrx_length_error_small;
888	uint64_t macrx_multicast_frames;
889	uint64_t macrx_broadcast_frames;
890	/* IP */
891	uint64_t iptx_packets;
892	uint64_t iptx_bytes;
893	uint64_t iptx_fragments;
894	uint64_t iprx_packets;
895	uint64_t iprx_bytes;
896	uint64_t iprx_fragments;
897	uint64_t ip_datagram_reassembly;
898	uint64_t ip_invalid_address_error;
899	uint64_t ip_error_packets;
900	uint64_t ip_fragrx_overlap;
901	uint64_t ip_fragrx_outoforder;
902	uint64_t ip_datagram_reassembly_timeout;
903	uint64_t ipv6tx_packets;
904	uint64_t ipv6tx_bytes;
905	uint64_t ipv6tx_fragments;
906	uint64_t ipv6rx_packets;
907	uint64_t ipv6rx_bytes;
908	uint64_t ipv6rx_fragments;
909	uint64_t ipv6_datagram_reassembly;
910	uint64_t ipv6_invalid_address_error;
911	uint64_t ipv6_error_packets;
912	uint64_t ipv6_fragrx_overlap;
913	uint64_t ipv6_fragrx_outoforder;
914	uint64_t ipv6_datagram_reassembly_timeout;
915	/* TCP */
916	uint64_t tcptx_segments;
917	uint64_t tcptx_bytes;
918	uint64_t tcprx_segments;
919	uint64_t tcprx_byte;
920	uint64_t tcp_duplicate_ack_retx;
921	uint64_t tcp_retx_timer_expired;
922	uint64_t tcprx_duplicate_ack;
923	uint64_t tcprx_pure_ackr;
924	uint64_t tcptx_delayed_ack;
925	uint64_t tcptx_pure_ack;
926	uint64_t tcprx_segment_error;
927	uint64_t tcprx_segment_outoforder;
928	uint64_t tcprx_window_probe;
929	uint64_t tcprx_window_update;
930	uint64_t tcptx_window_probe_persist;
931	/* ECC */
932	uint64_t ecc_error_correction;
933	/* iSCSI */
934	uint64_t iscsi_pdu_tx;
935	uint64_t iscsi_data_bytes_tx;
936	uint64_t iscsi_pdu_rx;
937	uint64_t iscsi_data_bytes_rx;
938	uint64_t iscsi_io_completed;
939	uint64_t iscsi_unexpected_io_rx;
940	uint64_t iscsi_format_error;
941	uint64_t iscsi_hdr_digest_error;
942	uint64_t iscsi_data_digest_error;
943	uint64_t iscsi_sequence_error;
944	/*
945	 * iSCSI Custom Host Statistics support, i.e. Transport could
946	 * extend existing host statistics with its own specific statistics
947	 * up to ISCSI_HOST_STATS_CUSTOM_MAX
948	 */
949	uint32_t custom_length;
950	struct iscsi_host_stats_custom custom[]
951		__aligned(sizeof(uint64_t));
952};
953
954#endif
v4.6
 
  1/*
  2 * iSCSI User/Kernel Shares (Defines, Constants, Protocol definitions, etc)
  3 *
  4 * Copyright (C) 2005 Dmitry Yusupov
  5 * Copyright (C) 2005 Alex Aizman
  6 * maintained by open-iscsi@googlegroups.com
  7 *
  8 * This program is free software; you can redistribute it and/or modify
  9 * it under the terms of the GNU General Public License as published
 10 * by the Free Software Foundation; either version 2 of the License, or
 11 * (at your option) any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful, but
 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 16 * General Public License for more details.
 17 *
 18 * See the file COPYING included with this distribution for more details.
 19 */
 20
 21#ifndef ISCSI_IF_H
 22#define ISCSI_IF_H
 23
 24#include <scsi/iscsi_proto.h>
 25#include <linux/in.h>
 26#include <linux/in6.h>
 27
 28#define ISCSI_NL_GRP_ISCSID	1
 29#define ISCSI_NL_GRP_UIP	2
 30
 31#define UEVENT_BASE			10
 32#define KEVENT_BASE			100
 33#define ISCSI_ERR_BASE			1000
 34
 35enum iscsi_uevent_e {
 36	ISCSI_UEVENT_UNKNOWN		= 0,
 37
 38	/* down events */
 39	ISCSI_UEVENT_CREATE_SESSION	= UEVENT_BASE + 1,
 40	ISCSI_UEVENT_DESTROY_SESSION	= UEVENT_BASE + 2,
 41	ISCSI_UEVENT_CREATE_CONN	= UEVENT_BASE + 3,
 42	ISCSI_UEVENT_DESTROY_CONN	= UEVENT_BASE + 4,
 43	ISCSI_UEVENT_BIND_CONN		= UEVENT_BASE + 5,
 44	ISCSI_UEVENT_SET_PARAM		= UEVENT_BASE + 6,
 45	ISCSI_UEVENT_START_CONN		= UEVENT_BASE + 7,
 46	ISCSI_UEVENT_STOP_CONN		= UEVENT_BASE + 8,
 47	ISCSI_UEVENT_SEND_PDU		= UEVENT_BASE + 9,
 48	ISCSI_UEVENT_GET_STATS		= UEVENT_BASE + 10,
 49	ISCSI_UEVENT_GET_PARAM		= UEVENT_BASE + 11,
 50
 51	ISCSI_UEVENT_TRANSPORT_EP_CONNECT	= UEVENT_BASE + 12,
 52	ISCSI_UEVENT_TRANSPORT_EP_POLL		= UEVENT_BASE + 13,
 53	ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT	= UEVENT_BASE + 14,
 54
 55	ISCSI_UEVENT_TGT_DSCVR		= UEVENT_BASE + 15,
 56	ISCSI_UEVENT_SET_HOST_PARAM	= UEVENT_BASE + 16,
 57	ISCSI_UEVENT_UNBIND_SESSION	= UEVENT_BASE + 17,
 58	ISCSI_UEVENT_CREATE_BOUND_SESSION		= UEVENT_BASE + 18,
 59	ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST	= UEVENT_BASE + 19,
 60
 61	ISCSI_UEVENT_PATH_UPDATE	= UEVENT_BASE + 20,
 62	ISCSI_UEVENT_SET_IFACE_PARAMS	= UEVENT_BASE + 21,
 63	ISCSI_UEVENT_PING		= UEVENT_BASE + 22,
 64	ISCSI_UEVENT_GET_CHAP		= UEVENT_BASE + 23,
 65	ISCSI_UEVENT_DELETE_CHAP	= UEVENT_BASE + 24,
 66	ISCSI_UEVENT_SET_FLASHNODE_PARAMS	= UEVENT_BASE + 25,
 67	ISCSI_UEVENT_NEW_FLASHNODE	= UEVENT_BASE + 26,
 68	ISCSI_UEVENT_DEL_FLASHNODE	= UEVENT_BASE + 27,
 69	ISCSI_UEVENT_LOGIN_FLASHNODE	= UEVENT_BASE + 28,
 70	ISCSI_UEVENT_LOGOUT_FLASHNODE	= UEVENT_BASE + 29,
 71	ISCSI_UEVENT_LOGOUT_FLASHNODE_SID	= UEVENT_BASE + 30,
 72	ISCSI_UEVENT_SET_CHAP		= UEVENT_BASE + 31,
 73	ISCSI_UEVENT_GET_HOST_STATS	= UEVENT_BASE + 32,
 
 74
 75	/* up events */
 76	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
 77	ISCSI_KEVENT_CONN_ERROR		= KEVENT_BASE + 2,
 78	ISCSI_KEVENT_IF_ERROR		= KEVENT_BASE + 3,
 79	ISCSI_KEVENT_DESTROY_SESSION	= KEVENT_BASE + 4,
 80	ISCSI_KEVENT_UNBIND_SESSION	= KEVENT_BASE + 5,
 81	ISCSI_KEVENT_CREATE_SESSION	= KEVENT_BASE + 6,
 82
 83	ISCSI_KEVENT_PATH_REQ		= KEVENT_BASE + 7,
 84	ISCSI_KEVENT_IF_DOWN		= KEVENT_BASE + 8,
 85	ISCSI_KEVENT_CONN_LOGIN_STATE   = KEVENT_BASE + 9,
 86	ISCSI_KEVENT_HOST_EVENT		= KEVENT_BASE + 10,
 87	ISCSI_KEVENT_PING_COMP		= KEVENT_BASE + 11,
 88};
 89
 90enum iscsi_tgt_dscvr {
 91	ISCSI_TGT_DSCVR_SEND_TARGETS	= 1,
 92	ISCSI_TGT_DSCVR_ISNS		= 2,
 93	ISCSI_TGT_DSCVR_SLP		= 3,
 94};
 95
 96enum iscsi_host_event_code {
 97	ISCSI_EVENT_LINKUP		= 1,
 98	ISCSI_EVENT_LINKDOWN,
 99	/* must always be last */
100	ISCSI_EVENT_MAX,
101};
102
103struct iscsi_uevent {
104	uint32_t type; /* k/u events type */
105	uint32_t iferror; /* carries interface or resource errors */
106	uint64_t transport_handle;
107
108	union {
109		/* messages u -> k */
110		struct msg_create_session {
111			uint32_t	initial_cmdsn;
112			uint16_t	cmds_max;
113			uint16_t	queue_depth;
114		} c_session;
115		struct msg_create_bound_session {
116			uint64_t	ep_handle;
117			uint32_t	initial_cmdsn;
118			uint16_t	cmds_max;
119			uint16_t	queue_depth;
120		} c_bound_session;
121		struct msg_destroy_session {
122			uint32_t	sid;
123		} d_session;
124		struct msg_create_conn {
125			uint32_t	sid;
126			uint32_t	cid;
127		} c_conn;
128		struct msg_bind_conn {
129			uint32_t	sid;
130			uint32_t	cid;
131			uint64_t	transport_eph;
132			uint32_t	is_leading;
133		} b_conn;
134		struct msg_destroy_conn {
135			uint32_t	sid;
136			uint32_t	cid;
137		} d_conn;
138		struct msg_send_pdu {
139			uint32_t	sid;
140			uint32_t	cid;
141			uint32_t	hdr_size;
142			uint32_t	data_size;
143		} send_pdu;
144		struct msg_set_param {
145			uint32_t	sid;
146			uint32_t	cid;
147			uint32_t	param; /* enum iscsi_param */
148			uint32_t	len;
149		} set_param;
150		struct msg_start_conn {
151			uint32_t	sid;
152			uint32_t	cid;
153		} start_conn;
154		struct msg_stop_conn {
155			uint32_t	sid;
156			uint32_t	cid;
157			uint64_t	conn_handle;
158			uint32_t	flag;
159		} stop_conn;
160		struct msg_get_stats {
161			uint32_t	sid;
162			uint32_t	cid;
163		} get_stats;
164		struct msg_transport_connect {
165			uint32_t	non_blocking;
166		} ep_connect;
167		struct msg_transport_connect_through_host {
168			uint32_t	host_no;
169			uint32_t	non_blocking;
170		} ep_connect_through_host;
171		struct msg_transport_poll {
172			uint64_t	ep_handle;
173			uint32_t	timeout_ms;
174		} ep_poll;
175		struct msg_transport_disconnect {
176			uint64_t	ep_handle;
177		} ep_disconnect;
178		struct msg_tgt_dscvr {
179			enum iscsi_tgt_dscvr	type;
180			uint32_t	host_no;
181			/*
182 			 * enable = 1 to establish a new connection
183			 * with the server. enable = 0 to disconnect
184			 * from the server. Used primarily to switch
185			 * from one iSNS server to another.
186			 */
187			uint32_t	enable;
188		} tgt_dscvr;
189		struct msg_set_host_param {
190			uint32_t	host_no;
191			uint32_t	param; /* enum iscsi_host_param */
192			uint32_t	len;
193		} set_host_param;
194		struct msg_set_path {
195			uint32_t	host_no;
196		} set_path;
197		struct msg_set_iface_params {
198			uint32_t	host_no;
199			uint32_t	count;
200		} set_iface_params;
201		struct msg_iscsi_ping {
202			uint32_t        host_no;
203			uint32_t        iface_num;
204			uint32_t        iface_type;
205			uint32_t        payload_size;
206			uint32_t	pid;	/* unique ping id associated
207						   with each ping request */
208		} iscsi_ping;
209		struct msg_get_chap {
210			uint32_t	host_no;
211			uint32_t	num_entries; /* number of CHAP entries
212						      * on request, number of
213						      * valid CHAP entries on
214						      * response */
215			uint16_t	chap_tbl_idx;
216		} get_chap;
217		struct msg_delete_chap {
218		       uint32_t        host_no;
219		       uint16_t        chap_tbl_idx;
220		} delete_chap;
221		struct msg_set_flashnode_param {
222			uint32_t	host_no;
223			uint32_t	flashnode_idx;
224			uint32_t	count;
225		} set_flashnode;
226		struct msg_new_flashnode {
227			uint32_t	host_no;
228			uint32_t	len;
229		} new_flashnode;
230		struct msg_del_flashnode {
231			uint32_t	host_no;
232			uint32_t	flashnode_idx;
233		} del_flashnode;
234		struct msg_login_flashnode {
235			uint32_t	host_no;
236			uint32_t	flashnode_idx;
237		} login_flashnode;
238		struct msg_logout_flashnode {
239			uint32_t	host_no;
240			uint32_t	flashnode_idx;
241		} logout_flashnode;
242		struct msg_logout_flashnode_sid {
243			uint32_t	host_no;
244			uint32_t	sid;
245		} logout_flashnode_sid;
246		struct msg_get_host_stats {
247			uint32_t host_no;
248		} get_host_stats;
249	} u;
250	union {
251		/* messages k -> u */
252		int			retcode;
253		struct msg_create_session_ret {
254			uint32_t	sid;
255			uint32_t	host_no;
256		} c_session_ret;
257		struct msg_create_conn_ret {
258			uint32_t	sid;
259			uint32_t	cid;
260		} c_conn_ret;
261		struct msg_unbind_session {
262			uint32_t	sid;
263			uint32_t	host_no;
264		} unbind_session;
265		struct msg_recv_req {
266			uint32_t	sid;
267			uint32_t	cid;
268			uint64_t	recv_handle;
269		} recv_req;
270		struct msg_conn_login {
271			uint32_t        sid;
272			uint32_t        cid;
273			uint32_t        state; /* enum iscsi_conn_state */
274		} conn_login;
275		struct msg_conn_error {
276			uint32_t	sid;
277			uint32_t	cid;
278			uint32_t	error; /* enum iscsi_err */
279		} connerror;
280		struct msg_session_destroyed {
281			uint32_t	host_no;
282			uint32_t	sid;
283		} d_session;
284		struct msg_transport_connect_ret {
285			uint64_t	handle;
286		} ep_connect_ret;
287		struct msg_req_path {
288			uint32_t	host_no;
289		} req_path;
290		struct msg_notify_if_down {
291			uint32_t	host_no;
292		} notify_if_down;
293		struct msg_host_event {
294			uint32_t	host_no;
295			uint32_t	data_size;
296			enum iscsi_host_event_code code;
297		} host_event;
298		struct msg_ping_comp {
299			uint32_t        host_no;
300			uint32_t        status; /* enum
301						 * iscsi_ping_status_code */
302			uint32_t	pid;	/* unique ping id associated
303						   with each ping request */
304			uint32_t        data_size;
305		} ping_comp;
306		struct msg_new_flashnode_ret {
307			uint32_t	flashnode_idx;
308		} new_flashnode_ret;
309	} r;
310} __attribute__ ((aligned (sizeof(uint64_t))));
311
312enum iscsi_param_type {
313	ISCSI_PARAM,		/* iscsi_param (session, conn, target, LU) */
314	ISCSI_HOST_PARAM,	/* iscsi_host_param */
315	ISCSI_NET_PARAM,	/* iscsi_net_param */
316	ISCSI_FLASHNODE_PARAM,	/* iscsi_flashnode_param */
317	ISCSI_CHAP_PARAM,	/* iscsi_chap_param */
318	ISCSI_IFACE_PARAM,	/* iscsi_iface_param */
319};
320
321/* structure for minimalist usecase */
322struct iscsi_param_info {
323	uint32_t len;		/* Actual length of the param value */
324	uint16_t param;		/* iscsi param */
325	uint8_t value[0];	/* length sized value follows */
326} __packed;
327
328struct iscsi_iface_param_info {
329	uint32_t iface_num;	/* iface number, 0 - n */
330	uint32_t len;		/* Actual length of the param */
331	uint16_t param;		/* iscsi param value */
332	uint8_t iface_type;	/* IPv4 or IPv6 */
333	uint8_t param_type;	/* iscsi_param_type */
334	uint8_t value[0];	/* length sized value follows */
335} __packed;
336
337/*
338 * To keep the struct iscsi_uevent size the same for userspace code
339 * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
340 * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
341 * struct iscsi_uevent in the NETLINK_ISCSI message.
342 */
343struct iscsi_path {
344	uint64_t	handle;
345	uint8_t		mac_addr[6];
346	uint8_t		mac_addr_old[6];
347	uint32_t	ip_addr_len;	/* 4 or 16 */
348	union {
349		struct in_addr	v4_addr;
350		struct in6_addr	v6_addr;
351	} src;
352	union {
353		struct in_addr	v4_addr;
354		struct in6_addr	v6_addr;
355	} dst;
356	uint16_t	vlan_id;
357	uint16_t	pmtu;
358} __attribute__ ((aligned (sizeof(uint64_t))));
359
360/* iscsi iface enabled/disabled setting */
361#define ISCSI_IFACE_DISABLE	0x01
362#define ISCSI_IFACE_ENABLE	0x02
363
364/* ipv4 bootproto */
365#define ISCSI_BOOTPROTO_STATIC		0x01
366#define ISCSI_BOOTPROTO_DHCP		0x02
367
368/* ipv6 addr autoconfig type */
369#define ISCSI_IPV6_AUTOCFG_DISABLE		0x01
370#define ISCSI_IPV6_AUTOCFG_ND_ENABLE		0x02
371#define ISCSI_IPV6_AUTOCFG_DHCPV6_ENABLE	0x03
372
373/* ipv6 link local addr type */
374#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_ENABLE	0x01
375#define ISCSI_IPV6_LINKLOCAL_AUTOCFG_DISABLE	0x02
376
377/* ipv6 router addr type */
378#define ISCSI_IPV6_ROUTER_AUTOCFG_ENABLE	0x01
379#define ISCSI_IPV6_ROUTER_AUTOCFG_DISABLE	0x02
380
381#define ISCSI_IFACE_TYPE_IPV4		0x01
382#define ISCSI_IFACE_TYPE_IPV6		0x02
383
384#define ISCSI_MAX_VLAN_ID		4095
385#define ISCSI_MAX_VLAN_PRIORITY		7
386
387/* iscsi vlan enable/disabled setting */
388#define ISCSI_VLAN_DISABLE	0x01
389#define ISCSI_VLAN_ENABLE	0x02
390
391/* iscsi generic enable/disabled setting for various features */
392#define ISCSI_NET_PARAM_DISABLE		0x01
393#define ISCSI_NET_PARAM_ENABLE		0x02
394
395/* iSCSI network params */
396enum iscsi_net_param {
397	ISCSI_NET_PARAM_IPV4_ADDR		= 1,
398	ISCSI_NET_PARAM_IPV4_SUBNET,
399	ISCSI_NET_PARAM_IPV4_GW,
400	ISCSI_NET_PARAM_IPV4_BOOTPROTO,
401	ISCSI_NET_PARAM_MAC,
402	ISCSI_NET_PARAM_IPV6_LINKLOCAL,
403	ISCSI_NET_PARAM_IPV6_ADDR,
404	ISCSI_NET_PARAM_IPV6_ROUTER,
405	ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG,
406	ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG,
407	ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG,
408	ISCSI_NET_PARAM_IFACE_ENABLE,
409	ISCSI_NET_PARAM_VLAN_ID,
410	ISCSI_NET_PARAM_VLAN_PRIORITY,
411	ISCSI_NET_PARAM_VLAN_ENABLED,
412	ISCSI_NET_PARAM_VLAN_TAG,
413	ISCSI_NET_PARAM_IFACE_TYPE,
414	ISCSI_NET_PARAM_IFACE_NAME,
415	ISCSI_NET_PARAM_MTU,
416	ISCSI_NET_PARAM_PORT,
417	ISCSI_NET_PARAM_IPADDR_STATE,
418	ISCSI_NET_PARAM_IPV6_LINKLOCAL_STATE,
419	ISCSI_NET_PARAM_IPV6_ROUTER_STATE,
420	ISCSI_NET_PARAM_DELAYED_ACK_EN,
421	ISCSI_NET_PARAM_TCP_NAGLE_DISABLE,
422	ISCSI_NET_PARAM_TCP_WSF_DISABLE,
423	ISCSI_NET_PARAM_TCP_WSF,
424	ISCSI_NET_PARAM_TCP_TIMER_SCALE,
425	ISCSI_NET_PARAM_TCP_TIMESTAMP_EN,
426	ISCSI_NET_PARAM_CACHE_ID,
427	ISCSI_NET_PARAM_IPV4_DHCP_DNS_ADDR_EN,
428	ISCSI_NET_PARAM_IPV4_DHCP_SLP_DA_EN,
429	ISCSI_NET_PARAM_IPV4_TOS_EN,
430	ISCSI_NET_PARAM_IPV4_TOS,
431	ISCSI_NET_PARAM_IPV4_GRAT_ARP_EN,
432	ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID_EN,
433	ISCSI_NET_PARAM_IPV4_DHCP_ALT_CLIENT_ID,
434	ISCSI_NET_PARAM_IPV4_DHCP_REQ_VENDOR_ID_EN,
435	ISCSI_NET_PARAM_IPV4_DHCP_USE_VENDOR_ID_EN,
436	ISCSI_NET_PARAM_IPV4_DHCP_VENDOR_ID,
437	ISCSI_NET_PARAM_IPV4_DHCP_LEARN_IQN_EN,
438	ISCSI_NET_PARAM_IPV4_FRAGMENT_DISABLE,
439	ISCSI_NET_PARAM_IPV4_IN_FORWARD_EN,
440	ISCSI_NET_PARAM_IPV4_TTL,
441	ISCSI_NET_PARAM_IPV6_GRAT_NEIGHBOR_ADV_EN,
442	ISCSI_NET_PARAM_IPV6_MLD_EN,
443	ISCSI_NET_PARAM_IPV6_FLOW_LABEL,
444	ISCSI_NET_PARAM_IPV6_TRAFFIC_CLASS,
445	ISCSI_NET_PARAM_IPV6_HOP_LIMIT,
446	ISCSI_NET_PARAM_IPV6_ND_REACHABLE_TMO,
447	ISCSI_NET_PARAM_IPV6_ND_REXMIT_TIME,
448	ISCSI_NET_PARAM_IPV6_ND_STALE_TMO,
449	ISCSI_NET_PARAM_IPV6_DUP_ADDR_DETECT_CNT,
450	ISCSI_NET_PARAM_IPV6_RTR_ADV_LINK_MTU,
451	ISCSI_NET_PARAM_REDIRECT_EN,
452};
453
454enum iscsi_ipaddress_state {
455	ISCSI_IPDDRESS_STATE_UNCONFIGURED,
456	ISCSI_IPDDRESS_STATE_ACQUIRING,
457	ISCSI_IPDDRESS_STATE_TENTATIVE,
458	ISCSI_IPDDRESS_STATE_VALID,
459	ISCSI_IPDDRESS_STATE_DISABLING,
460	ISCSI_IPDDRESS_STATE_INVALID,
461	ISCSI_IPDDRESS_STATE_DEPRECATED,
462};
463
464enum iscsi_router_state {
465	ISCSI_ROUTER_STATE_UNKNOWN,
466	ISCSI_ROUTER_STATE_ADVERTISED,
467	ISCSI_ROUTER_STATE_MANUAL,
468	ISCSI_ROUTER_STATE_STALE,
469};
470
471/* iSCSI specific settings params for iface */
472enum iscsi_iface_param {
473	ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO,
474	ISCSI_IFACE_PARAM_HDRDGST_EN,
475	ISCSI_IFACE_PARAM_DATADGST_EN,
476	ISCSI_IFACE_PARAM_IMM_DATA_EN,
477	ISCSI_IFACE_PARAM_INITIAL_R2T_EN,
478	ISCSI_IFACE_PARAM_DATASEQ_INORDER_EN,
479	ISCSI_IFACE_PARAM_PDU_INORDER_EN,
480	ISCSI_IFACE_PARAM_ERL,
481	ISCSI_IFACE_PARAM_MAX_RECV_DLENGTH,
482	ISCSI_IFACE_PARAM_FIRST_BURST,
483	ISCSI_IFACE_PARAM_MAX_R2T,
484	ISCSI_IFACE_PARAM_MAX_BURST,
485	ISCSI_IFACE_PARAM_CHAP_AUTH_EN,
486	ISCSI_IFACE_PARAM_BIDI_CHAP_EN,
487	ISCSI_IFACE_PARAM_DISCOVERY_AUTH_OPTIONAL,
488	ISCSI_IFACE_PARAM_DISCOVERY_LOGOUT_EN,
489	ISCSI_IFACE_PARAM_STRICT_LOGIN_COMP_EN,
490	ISCSI_IFACE_PARAM_INITIATOR_NAME,
491};
492
493enum iscsi_conn_state {
494	ISCSI_CONN_STATE_FREE,
495	ISCSI_CONN_STATE_XPT_WAIT,
496	ISCSI_CONN_STATE_IN_LOGIN,
497	ISCSI_CONN_STATE_LOGGED_IN,
498	ISCSI_CONN_STATE_IN_LOGOUT,
499	ISCSI_CONN_STATE_LOGOUT_REQUESTED,
500	ISCSI_CONN_STATE_CLEANUP_WAIT,
501};
502
503/*
504 * Common error codes
505 */
506enum iscsi_err {
507	ISCSI_OK			= 0,
508
509	ISCSI_ERR_DATASN		= ISCSI_ERR_BASE + 1,
510	ISCSI_ERR_DATA_OFFSET		= ISCSI_ERR_BASE + 2,
511	ISCSI_ERR_MAX_CMDSN		= ISCSI_ERR_BASE + 3,
512	ISCSI_ERR_EXP_CMDSN		= ISCSI_ERR_BASE + 4,
513	ISCSI_ERR_BAD_OPCODE		= ISCSI_ERR_BASE + 5,
514	ISCSI_ERR_DATALEN		= ISCSI_ERR_BASE + 6,
515	ISCSI_ERR_AHSLEN		= ISCSI_ERR_BASE + 7,
516	ISCSI_ERR_PROTO			= ISCSI_ERR_BASE + 8,
517	ISCSI_ERR_LUN			= ISCSI_ERR_BASE + 9,
518	ISCSI_ERR_BAD_ITT		= ISCSI_ERR_BASE + 10,
519	ISCSI_ERR_CONN_FAILED		= ISCSI_ERR_BASE + 11,
520	ISCSI_ERR_R2TSN			= ISCSI_ERR_BASE + 12,
521	ISCSI_ERR_SESSION_FAILED	= ISCSI_ERR_BASE + 13,
522	ISCSI_ERR_HDR_DGST		= ISCSI_ERR_BASE + 14,
523	ISCSI_ERR_DATA_DGST		= ISCSI_ERR_BASE + 15,
524	ISCSI_ERR_PARAM_NOT_FOUND	= ISCSI_ERR_BASE + 16,
525	ISCSI_ERR_NO_SCSI_CMD		= ISCSI_ERR_BASE + 17,
526	ISCSI_ERR_INVALID_HOST		= ISCSI_ERR_BASE + 18,
527	ISCSI_ERR_XMIT_FAILED		= ISCSI_ERR_BASE + 19,
528	ISCSI_ERR_TCP_CONN_CLOSE	= ISCSI_ERR_BASE + 20,
529	ISCSI_ERR_SCSI_EH_SESSION_RST	= ISCSI_ERR_BASE + 21,
530	ISCSI_ERR_NOP_TIMEDOUT		= ISCSI_ERR_BASE + 22,
531};
532
533/*
534 * iSCSI Parameters (RFC3720)
535 */
536enum iscsi_param {
537	/* passed in using netlink set param */
538	ISCSI_PARAM_MAX_RECV_DLENGTH,
539	ISCSI_PARAM_MAX_XMIT_DLENGTH,
540	ISCSI_PARAM_HDRDGST_EN,
541	ISCSI_PARAM_DATADGST_EN,
542	ISCSI_PARAM_INITIAL_R2T_EN,
543	ISCSI_PARAM_MAX_R2T,
544	ISCSI_PARAM_IMM_DATA_EN,
545	ISCSI_PARAM_FIRST_BURST,
546	ISCSI_PARAM_MAX_BURST,
547	ISCSI_PARAM_PDU_INORDER_EN,
548	ISCSI_PARAM_DATASEQ_INORDER_EN,
549	ISCSI_PARAM_ERL,
550	ISCSI_PARAM_IFMARKER_EN,
551	ISCSI_PARAM_OFMARKER_EN,
552	ISCSI_PARAM_EXP_STATSN,
553	ISCSI_PARAM_TARGET_NAME,
554	ISCSI_PARAM_TPGT,
555	ISCSI_PARAM_PERSISTENT_ADDRESS,
556	ISCSI_PARAM_PERSISTENT_PORT,
557	ISCSI_PARAM_SESS_RECOVERY_TMO,
558
559	/* passed in through bind conn using transport_fd */
560	ISCSI_PARAM_CONN_PORT,
561	ISCSI_PARAM_CONN_ADDRESS,
562
563	ISCSI_PARAM_USERNAME,
564	ISCSI_PARAM_USERNAME_IN,
565	ISCSI_PARAM_PASSWORD,
566	ISCSI_PARAM_PASSWORD_IN,
567
568	ISCSI_PARAM_FAST_ABORT,
569	ISCSI_PARAM_ABORT_TMO,
570	ISCSI_PARAM_LU_RESET_TMO,
571	ISCSI_PARAM_HOST_RESET_TMO,
572
573	ISCSI_PARAM_PING_TMO,
574	ISCSI_PARAM_RECV_TMO,
575
576	ISCSI_PARAM_IFACE_NAME,
577	ISCSI_PARAM_ISID,
578	ISCSI_PARAM_INITIATOR_NAME,
579
580	ISCSI_PARAM_TGT_RESET_TMO,
581	ISCSI_PARAM_TARGET_ALIAS,
582
583	ISCSI_PARAM_CHAP_IN_IDX,
584	ISCSI_PARAM_CHAP_OUT_IDX,
585
586	ISCSI_PARAM_BOOT_ROOT,
587	ISCSI_PARAM_BOOT_NIC,
588	ISCSI_PARAM_BOOT_TARGET,
589
590	ISCSI_PARAM_AUTO_SND_TGT_DISABLE,
591	ISCSI_PARAM_DISCOVERY_SESS,
592	ISCSI_PARAM_PORTAL_TYPE,
593	ISCSI_PARAM_CHAP_AUTH_EN,
594	ISCSI_PARAM_DISCOVERY_LOGOUT_EN,
595	ISCSI_PARAM_BIDI_CHAP_EN,
596	ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL,
597
598	ISCSI_PARAM_DEF_TIME2WAIT,
599	ISCSI_PARAM_DEF_TIME2RETAIN,
600	ISCSI_PARAM_MAX_SEGMENT_SIZE,
601	ISCSI_PARAM_STATSN,
602	ISCSI_PARAM_KEEPALIVE_TMO,
603	ISCSI_PARAM_LOCAL_PORT,
604	ISCSI_PARAM_TSID,
605	ISCSI_PARAM_DEF_TASKMGMT_TMO,
606
607	ISCSI_PARAM_TCP_TIMESTAMP_STAT,
608	ISCSI_PARAM_TCP_WSF_DISABLE,
609	ISCSI_PARAM_TCP_NAGLE_DISABLE,
610	ISCSI_PARAM_TCP_TIMER_SCALE,
611	ISCSI_PARAM_TCP_TIMESTAMP_EN,
612	ISCSI_PARAM_TCP_XMIT_WSF,
613	ISCSI_PARAM_TCP_RECV_WSF,
614	ISCSI_PARAM_IP_FRAGMENT_DISABLE,
615	ISCSI_PARAM_IPV4_TOS,
616	ISCSI_PARAM_IPV6_TC,
617	ISCSI_PARAM_IPV6_FLOW_LABEL,
618	ISCSI_PARAM_IS_FW_ASSIGNED_IPV6,
619
620	ISCSI_PARAM_DISCOVERY_PARENT_IDX,
621	ISCSI_PARAM_DISCOVERY_PARENT_TYPE,
622	ISCSI_PARAM_LOCAL_IPADDR,
623	/* must always be last */
624	ISCSI_PARAM_MAX,
625};
626
627/* iSCSI HBA params */
628enum iscsi_host_param {
629	ISCSI_HOST_PARAM_HWADDRESS,
630	ISCSI_HOST_PARAM_INITIATOR_NAME,
631	ISCSI_HOST_PARAM_NETDEV_NAME,
632	ISCSI_HOST_PARAM_IPADDRESS,
633	ISCSI_HOST_PARAM_PORT_STATE,
634	ISCSI_HOST_PARAM_PORT_SPEED,
635	ISCSI_HOST_PARAM_MAX,
636};
637
638/* portal type */
639#define PORTAL_TYPE_IPV4	"ipv4"
640#define PORTAL_TYPE_IPV6	"ipv6"
641
642/* iSCSI Flash Target params */
643enum iscsi_flashnode_param {
644	ISCSI_FLASHNODE_IS_FW_ASSIGNED_IPV6,
645	ISCSI_FLASHNODE_PORTAL_TYPE,
646	ISCSI_FLASHNODE_AUTO_SND_TGT_DISABLE,
647	ISCSI_FLASHNODE_DISCOVERY_SESS,
648	ISCSI_FLASHNODE_ENTRY_EN,
649	ISCSI_FLASHNODE_HDR_DGST_EN,
650	ISCSI_FLASHNODE_DATA_DGST_EN,
651	ISCSI_FLASHNODE_IMM_DATA_EN,
652	ISCSI_FLASHNODE_INITIAL_R2T_EN,
653	ISCSI_FLASHNODE_DATASEQ_INORDER,
654	ISCSI_FLASHNODE_PDU_INORDER,
655	ISCSI_FLASHNODE_CHAP_AUTH_EN,
656	ISCSI_FLASHNODE_SNACK_REQ_EN,
657	ISCSI_FLASHNODE_DISCOVERY_LOGOUT_EN,
658	ISCSI_FLASHNODE_BIDI_CHAP_EN,
659	/* make authentication for discovery sessions optional */
660	ISCSI_FLASHNODE_DISCOVERY_AUTH_OPTIONAL,
661	ISCSI_FLASHNODE_ERL,
662	ISCSI_FLASHNODE_TCP_TIMESTAMP_STAT,
663	ISCSI_FLASHNODE_TCP_NAGLE_DISABLE,
664	ISCSI_FLASHNODE_TCP_WSF_DISABLE,
665	ISCSI_FLASHNODE_TCP_TIMER_SCALE,
666	ISCSI_FLASHNODE_TCP_TIMESTAMP_EN,
667	ISCSI_FLASHNODE_IP_FRAG_DISABLE,
668	ISCSI_FLASHNODE_MAX_RECV_DLENGTH,
669	ISCSI_FLASHNODE_MAX_XMIT_DLENGTH,
670	ISCSI_FLASHNODE_FIRST_BURST,
671	ISCSI_FLASHNODE_DEF_TIME2WAIT,
672	ISCSI_FLASHNODE_DEF_TIME2RETAIN,
673	ISCSI_FLASHNODE_MAX_R2T,
674	ISCSI_FLASHNODE_KEEPALIVE_TMO,
675	ISCSI_FLASHNODE_ISID,
676	ISCSI_FLASHNODE_TSID,
677	ISCSI_FLASHNODE_PORT,
678	ISCSI_FLASHNODE_MAX_BURST,
679	ISCSI_FLASHNODE_DEF_TASKMGMT_TMO,
680	ISCSI_FLASHNODE_IPADDR,
681	ISCSI_FLASHNODE_ALIAS,
682	ISCSI_FLASHNODE_REDIRECT_IPADDR,
683	ISCSI_FLASHNODE_MAX_SEGMENT_SIZE,
684	ISCSI_FLASHNODE_LOCAL_PORT,
685	ISCSI_FLASHNODE_IPV4_TOS,
686	ISCSI_FLASHNODE_IPV6_TC,
687	ISCSI_FLASHNODE_IPV6_FLOW_LABEL,
688	ISCSI_FLASHNODE_NAME,
689	ISCSI_FLASHNODE_TPGT,
690	ISCSI_FLASHNODE_LINK_LOCAL_IPV6,
691	ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX,
692	ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE,
693	ISCSI_FLASHNODE_TCP_XMIT_WSF,
694	ISCSI_FLASHNODE_TCP_RECV_WSF,
695	ISCSI_FLASHNODE_CHAP_IN_IDX,
696	ISCSI_FLASHNODE_CHAP_OUT_IDX,
697	ISCSI_FLASHNODE_USERNAME,
698	ISCSI_FLASHNODE_USERNAME_IN,
699	ISCSI_FLASHNODE_PASSWORD,
700	ISCSI_FLASHNODE_PASSWORD_IN,
701	ISCSI_FLASHNODE_STATSN,
702	ISCSI_FLASHNODE_EXP_STATSN,
703	ISCSI_FLASHNODE_IS_BOOT_TGT,
704
705	ISCSI_FLASHNODE_MAX,
706};
707
708struct iscsi_flashnode_param_info {
709	uint32_t len;		/* Actual length of the param */
710	uint16_t param;		/* iscsi param value */
711	uint8_t value[0];	/* length sized value follows */
712} __packed;
713
714enum iscsi_discovery_parent_type {
715	ISCSI_DISC_PARENT_UNKNOWN	= 0x1,
716	ISCSI_DISC_PARENT_SENDTGT	= 0x2,
717	ISCSI_DISC_PARENT_ISNS		= 0x3,
718};
719
720/* iSCSI port Speed */
721enum iscsi_port_speed {
722	ISCSI_PORT_SPEED_UNKNOWN	= 0x1,
723	ISCSI_PORT_SPEED_10MBPS		= 0x2,
724	ISCSI_PORT_SPEED_100MBPS	= 0x4,
725	ISCSI_PORT_SPEED_1GBPS		= 0x8,
726	ISCSI_PORT_SPEED_10GBPS		= 0x10,
727	ISCSI_PORT_SPEED_25GBPS         = 0x20,
728	ISCSI_PORT_SPEED_40GBPS         = 0x40,
729};
730
731/* iSCSI port state */
732enum iscsi_port_state {
733	ISCSI_PORT_STATE_DOWN		= 0x1,
734	ISCSI_PORT_STATE_UP		= 0x2,
735};
736
737/* iSCSI PING status/error code */
738enum iscsi_ping_status_code {
739	ISCSI_PING_SUCCESS			= 0,
740	ISCSI_PING_FW_DISABLED			= 0x1,
741	ISCSI_PING_IPADDR_INVALID		= 0x2,
742	ISCSI_PING_LINKLOCAL_IPV6_ADDR_INVALID	= 0x3,
743	ISCSI_PING_TIMEOUT			= 0x4,
744	ISCSI_PING_INVALID_DEST_ADDR		= 0x5,
745	ISCSI_PING_OVERSIZE_PACKET		= 0x6,
746	ISCSI_PING_ICMP_ERROR			= 0x7,
747	ISCSI_PING_MAX_REQ_EXCEEDED		= 0x8,
748	ISCSI_PING_NO_ARP_RECEIVED		= 0x9,
749};
750
751#define iscsi_ptr(_handle) ((void*)(unsigned long)_handle)
752#define iscsi_handle(_ptr) ((uint64_t)(unsigned long)_ptr)
753
754/*
755 * These flags presents iSCSI Data-Path capabilities.
756 */
757#define CAP_RECOVERY_L0		0x1
758#define CAP_RECOVERY_L1		0x2
759#define CAP_RECOVERY_L2		0x4
760#define CAP_MULTI_R2T		0x8
761#define CAP_HDRDGST		0x10
762#define CAP_DATADGST		0x20
763#define CAP_MULTI_CONN		0x40
764#define CAP_TEXT_NEGO		0x80
765#define CAP_MARKERS		0x100
766#define CAP_FW_DB		0x200
767#define CAP_SENDTARGETS_OFFLOAD	0x400	/* offload discovery process */
768#define CAP_DATA_PATH_OFFLOAD	0x800	/* offload entire IO path */
769#define CAP_DIGEST_OFFLOAD	0x1000	/* offload hdr and data digests */
770#define CAP_PADDING_OFFLOAD	0x2000	/* offload padding insertion, removal,
771					 and verification */
772#define CAP_LOGIN_OFFLOAD	0x4000  /* offload session login */
773
774/*
775 * These flags describes reason of stop_conn() call
776 */
777#define STOP_CONN_TERM		0x1
778#define STOP_CONN_SUSPEND	0x2
779#define STOP_CONN_RECOVER	0x3
780
781#define ISCSI_STATS_CUSTOM_MAX		32
782#define ISCSI_STATS_CUSTOM_DESC_MAX	64
783struct iscsi_stats_custom {
784	char desc[ISCSI_STATS_CUSTOM_DESC_MAX];
785	uint64_t value;
786};
787
788/*
789 * struct iscsi_stats - iSCSI Statistics (iSCSI MIB)
790 *
791 * Note: this structure contains counters collected on per-connection basis.
792 */
793struct iscsi_stats {
794	/* octets */
795	uint64_t txdata_octets;
796	uint64_t rxdata_octets;
797
798	/* xmit pdus */
799	uint32_t noptx_pdus;
800	uint32_t scsicmd_pdus;
801	uint32_t tmfcmd_pdus;
802	uint32_t login_pdus;
803	uint32_t text_pdus;
804	uint32_t dataout_pdus;
805	uint32_t logout_pdus;
806	uint32_t snack_pdus;
807
808	/* recv pdus */
809	uint32_t noprx_pdus;
810	uint32_t scsirsp_pdus;
811	uint32_t tmfrsp_pdus;
812	uint32_t textrsp_pdus;
813	uint32_t datain_pdus;
814	uint32_t logoutrsp_pdus;
815	uint32_t r2t_pdus;
816	uint32_t async_pdus;
817	uint32_t rjt_pdus;
818
819	/* errors */
820	uint32_t digest_err;
821	uint32_t timeout_err;
822
823	/*
824	 * iSCSI Custom Statistics support, i.e. Transport could
825	 * extend existing MIB statistics with its own specific statistics
826	 * up to ISCSI_STATS_CUSTOM_MAX
827	 */
828	uint32_t custom_length;
829	struct iscsi_stats_custom custom[0]
830		__attribute__ ((aligned (sizeof(uint64_t))));
831};
832
833enum chap_type_e {
834	CHAP_TYPE_OUT,
835	CHAP_TYPE_IN,
836};
837
838enum iscsi_chap_param {
839	ISCSI_CHAP_PARAM_INDEX,
840	ISCSI_CHAP_PARAM_CHAP_TYPE,
841	ISCSI_CHAP_PARAM_USERNAME,
842	ISCSI_CHAP_PARAM_PASSWORD,
843	ISCSI_CHAP_PARAM_PASSWORD_LEN
844};
845
846#define ISCSI_CHAP_AUTH_NAME_MAX_LEN	256
847#define ISCSI_CHAP_AUTH_SECRET_MAX_LEN	256
848struct iscsi_chap_rec {
849	uint16_t chap_tbl_idx;
850	enum chap_type_e chap_type;
851	char username[ISCSI_CHAP_AUTH_NAME_MAX_LEN];
852	uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN];
853	uint8_t password_length;
854};
855
856#define ISCSI_HOST_STATS_CUSTOM_MAX             32
857#define ISCSI_HOST_STATS_CUSTOM_DESC_MAX        64
858struct iscsi_host_stats_custom {
859	char desc[ISCSI_HOST_STATS_CUSTOM_DESC_MAX];
860	uint64_t value;
861};
862
863/* struct iscsi_offload_host_stats: Host statistics,
864 * Include statistics for MAC, IP, TCP & iSCSI.
865 */
866struct iscsi_offload_host_stats {
867	/* MAC */
868	uint64_t mactx_frames;
869	uint64_t mactx_bytes;
870	uint64_t mactx_multicast_frames;
871	uint64_t mactx_broadcast_frames;
872	uint64_t mactx_pause_frames;
873	uint64_t mactx_control_frames;
874	uint64_t mactx_deferral;
875	uint64_t mactx_excess_deferral;
876	uint64_t mactx_late_collision;
877	uint64_t mactx_abort;
878	uint64_t mactx_single_collision;
879	uint64_t mactx_multiple_collision;
880	uint64_t mactx_collision;
881	uint64_t mactx_frames_dropped;
882	uint64_t mactx_jumbo_frames;
883	uint64_t macrx_frames;
884	uint64_t macrx_bytes;
885	uint64_t macrx_unknown_control_frames;
886	uint64_t macrx_pause_frames;
887	uint64_t macrx_control_frames;
888	uint64_t macrx_dribble;
889	uint64_t macrx_frame_length_error;
890	uint64_t macrx_jabber;
891	uint64_t macrx_carrier_sense_error;
892	uint64_t macrx_frame_discarded;
893	uint64_t macrx_frames_dropped;
894	uint64_t mac_crc_error;
895	uint64_t mac_encoding_error;
896	uint64_t macrx_length_error_large;
897	uint64_t macrx_length_error_small;
898	uint64_t macrx_multicast_frames;
899	uint64_t macrx_broadcast_frames;
900	/* IP */
901	uint64_t iptx_packets;
902	uint64_t iptx_bytes;
903	uint64_t iptx_fragments;
904	uint64_t iprx_packets;
905	uint64_t iprx_bytes;
906	uint64_t iprx_fragments;
907	uint64_t ip_datagram_reassembly;
908	uint64_t ip_invalid_address_error;
909	uint64_t ip_error_packets;
910	uint64_t ip_fragrx_overlap;
911	uint64_t ip_fragrx_outoforder;
912	uint64_t ip_datagram_reassembly_timeout;
913	uint64_t ipv6tx_packets;
914	uint64_t ipv6tx_bytes;
915	uint64_t ipv6tx_fragments;
916	uint64_t ipv6rx_packets;
917	uint64_t ipv6rx_bytes;
918	uint64_t ipv6rx_fragments;
919	uint64_t ipv6_datagram_reassembly;
920	uint64_t ipv6_invalid_address_error;
921	uint64_t ipv6_error_packets;
922	uint64_t ipv6_fragrx_overlap;
923	uint64_t ipv6_fragrx_outoforder;
924	uint64_t ipv6_datagram_reassembly_timeout;
925	/* TCP */
926	uint64_t tcptx_segments;
927	uint64_t tcptx_bytes;
928	uint64_t tcprx_segments;
929	uint64_t tcprx_byte;
930	uint64_t tcp_duplicate_ack_retx;
931	uint64_t tcp_retx_timer_expired;
932	uint64_t tcprx_duplicate_ack;
933	uint64_t tcprx_pure_ackr;
934	uint64_t tcptx_delayed_ack;
935	uint64_t tcptx_pure_ack;
936	uint64_t tcprx_segment_error;
937	uint64_t tcprx_segment_outoforder;
938	uint64_t tcprx_window_probe;
939	uint64_t tcprx_window_update;
940	uint64_t tcptx_window_probe_persist;
941	/* ECC */
942	uint64_t ecc_error_correction;
943	/* iSCSI */
944	uint64_t iscsi_pdu_tx;
945	uint64_t iscsi_data_bytes_tx;
946	uint64_t iscsi_pdu_rx;
947	uint64_t iscsi_data_bytes_rx;
948	uint64_t iscsi_io_completed;
949	uint64_t iscsi_unexpected_io_rx;
950	uint64_t iscsi_format_error;
951	uint64_t iscsi_hdr_digest_error;
952	uint64_t iscsi_data_digest_error;
953	uint64_t iscsi_sequence_error;
954	/*
955	 * iSCSI Custom Host Statistics support, i.e. Transport could
956	 * extend existing host statistics with its own specific statistics
957	 * up to ISCSI_HOST_STATS_CUSTOM_MAX
958	 */
959	uint32_t custom_length;
960	struct iscsi_host_stats_custom custom[0]
961		__aligned(sizeof(uint64_t));
962};
963
964#endif