136c5fee3Smcneal /*
236c5fee3Smcneal  * CDDL HEADER START
336c5fee3Smcneal  *
436c5fee3Smcneal  * The contents of this file are subject to the terms of the
536c5fee3Smcneal  * Common Development and Distribution License (the "License").
636c5fee3Smcneal  * You may not use this file except in compliance with the License.
736c5fee3Smcneal  *
836c5fee3Smcneal  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
936c5fee3Smcneal  * or http://www.opensolaris.org/os/licensing.
1036c5fee3Smcneal  * See the License for the specific language governing permissions
1136c5fee3Smcneal  * and limitations under the License.
1236c5fee3Smcneal  *
1336c5fee3Smcneal  * When distributing Covered Code, include this CDDL HEADER in each
1436c5fee3Smcneal  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1536c5fee3Smcneal  * If applicable, add the following below this CDDL HEADER, with the
1636c5fee3Smcneal  * fields enclosed by brackets "[]" replaced with your own identifying
1736c5fee3Smcneal  * information: Portions Copyright [yyyy] [name of copyright owner]
1836c5fee3Smcneal  *
1936c5fee3Smcneal  * CDDL HEADER END
2036c5fee3Smcneal  */
2136c5fee3Smcneal /*
22*2e0fe3efSbing zhao - Sun Microsystems - Beijing China  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2336c5fee3Smcneal  */
2436c5fee3Smcneal 
2536c5fee3Smcneal #ifndef _ISCSI_PROTOCOL_H
2636c5fee3Smcneal #define	_ISCSI_PROTOCOL_H
2736c5fee3Smcneal 
2836c5fee3Smcneal #ifdef __cplusplus
2936c5fee3Smcneal extern "C" {
3036c5fee3Smcneal #endif
3136c5fee3Smcneal 
3236c5fee3Smcneal /*
3336c5fee3Smcneal  * iSCSI connection daemon
3436c5fee3Smcneal  * Copyright (C) 2001 Cisco Systems, Inc.
3536c5fee3Smcneal  * All rights reserved.
3636c5fee3Smcneal  *
3736c5fee3Smcneal  * This file sets up definitions of messages and constants used by the
3836c5fee3Smcneal  * iSCSI protocol.
3936c5fee3Smcneal  *
4036c5fee3Smcneal  */
4136c5fee3Smcneal 
4236c5fee3Smcneal #include <sys/types.h>
4336c5fee3Smcneal #include <sys/isa_defs.h>
4436c5fee3Smcneal 
4536c5fee3Smcneal #define	ISCSI_MAX_NAME_LEN	224
46*2e0fe3efSbing zhao - Sun Microsystems - Beijing China #define	ISCSI_MAX_C_USER_LEN	512
4736c5fee3Smcneal 
4836c5fee3Smcneal /* iSCSI listen port for incoming connections */
4936c5fee3Smcneal #define	ISCSI_LISTEN_PORT 3260
5036c5fee3Smcneal 
5136c5fee3Smcneal /* assumes a pointer to a 3-byte array */
5236c5fee3Smcneal #define	ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
5336c5fee3Smcneal 
5436c5fee3Smcneal /* assumes a pointer to a 3 byte array, and an integer value */
5536c5fee3Smcneal #define	hton24(p, v) {\
5636c5fee3Smcneal 	p[0] = (((v) >> 16) & 0xFF); \
5736c5fee3Smcneal 	p[1] = (((v) >> 8) & 0xFF); \
5836c5fee3Smcneal 	p[2] = ((v) & 0xFF); \
5936c5fee3Smcneal }
6036c5fee3Smcneal 
6136c5fee3Smcneal 
6236c5fee3Smcneal /* for Login min, max, active version fields */
6336c5fee3Smcneal #define	ISCSI_MIN_VERSION	0x00
6436c5fee3Smcneal #define	ISCSI_DRAFT8_VERSION    0x02
6536c5fee3Smcneal #define	ISCSI_DRAFT20_VERSION   0x00
6636c5fee3Smcneal #define	ISCSI_MAX_VERSION	0x02
6736c5fee3Smcneal 
6836c5fee3Smcneal /* Min. and Max. length of a PDU we can support */
6936c5fee3Smcneal #define	ISCSI_MIN_PDU_LENGTH	(8 << 9)	/* 4KB */
7036c5fee3Smcneal #define	ISCSI_MAX_PDU_LENGTH	(0xffffffff)	/* Huge */
7136c5fee3Smcneal 
7236c5fee3Smcneal /* Padding word length */
7336c5fee3Smcneal #define	ISCSI_PAD_WORD_LEN		4
7436c5fee3Smcneal 
7536c5fee3Smcneal /* Max. number of Key=Value pairs in a text message */
7636c5fee3Smcneal #define	ISCSI_MAX_KEY_VALUE_PAIRS	8192
7736c5fee3Smcneal 
7836c5fee3Smcneal /* text separtor between key value pairs exhanged in login */
7936c5fee3Smcneal #define	ISCSI_TEXT_SEPARATOR	'='
8036c5fee3Smcneal 
81a6d42e7dSPeter Dunlap /* reserved text constants for Text Mode Negotiation */
82a6d42e7dSPeter Dunlap #define	ISCSI_TEXT_NONE			"None"
83a6d42e7dSPeter Dunlap #define	ISCSI_TEXT_REJECT		"Reject"
84a6d42e7dSPeter Dunlap #define	ISCSI_TEXT_IRRELEVANT		"Irrelevant"
85a6d42e7dSPeter Dunlap #define	ISCSI_TEXT_NOTUNDERSTOOD	"NotUnderstood"
86a6d42e7dSPeter Dunlap 
8736c5fee3Smcneal /* Reserved value for initiator/target task tag */
8836c5fee3Smcneal #define	ISCSI_RSVD_TASK_TAG	0xffffffff
8936c5fee3Smcneal 
9036c5fee3Smcneal /* maximum length for text keys/values */
9136c5fee3Smcneal #define	KEY_MAXLEN 64
9236c5fee3Smcneal #define	VALUE_MAXLEN 255
9336c5fee3Smcneal #define	TARGET_NAME_MAXLEN    VALUE_MAXLEN
9436c5fee3Smcneal 
9536c5fee3Smcneal /* most PDU types have a final bit */
9636c5fee3Smcneal #define	ISCSI_FLAG_FINAL		0x80
9736c5fee3Smcneal 
9836c5fee3Smcneal /*
9936c5fee3Smcneal  * Strings used during SendTargets requests
10036c5fee3Smcneal  */
10136c5fee3Smcneal #define	ISCSI_TEXT_SEPARATOR	'='
10236c5fee3Smcneal #define	TARGETNAME "TargetName="
10336c5fee3Smcneal #define	TARGETADDRESS "TargetAddress="
10436c5fee3Smcneal 
10536c5fee3Smcneal /* iSCSI Template Message Header */
10636c5fee3Smcneal typedef struct _iscsi_hdr {
10736c5fee3Smcneal 	uint8_t opcode;
10836c5fee3Smcneal 	uint8_t flags;	/* Final bit */
10936c5fee3Smcneal 	uint8_t rsvd2[2];
11036c5fee3Smcneal 	uint8_t hlength;	/* AHSs total length */
11136c5fee3Smcneal 	uint8_t dlength[3];	/* Data length */
11236c5fee3Smcneal 	uint8_t lun[8];
11336c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
11436c5fee3Smcneal 	uint8_t		rsvd3[8];
11536c5fee3Smcneal 	uint32_t	expstatsn;
11636c5fee3Smcneal 	uint8_t		other[16];
11736c5fee3Smcneal } iscsi_hdr_t;
11836c5fee3Smcneal 
11936c5fee3Smcneal typedef struct _iscsi_rsp_hdr {
12036c5fee3Smcneal 	uint8_t		opcode;
12136c5fee3Smcneal 	uint8_t		flags;
12236c5fee3Smcneal 	uint8_t		rsvd1[3];
12336c5fee3Smcneal 	uint8_t		dlength[3];
12436c5fee3Smcneal 	uint8_t		rsvd2[8];
12536c5fee3Smcneal 	uint32_t	itt;
12636c5fee3Smcneal 	uint8_t		rsvd3[4];
12736c5fee3Smcneal 	uint32_t	statsn;
12836c5fee3Smcneal 	uint32_t	expcmdsn;
12936c5fee3Smcneal 	uint32_t	maxcmdsn;
13036c5fee3Smcneal 	uint8_t		rsvd4[12];
13136c5fee3Smcneal } iscsi_rsp_hdr_t;
13236c5fee3Smcneal 
13336c5fee3Smcneal /* Opcode encoding bits */
13436c5fee3Smcneal #define	ISCSI_OP_RETRY			0x80
13536c5fee3Smcneal #define	ISCSI_OP_IMMEDIATE		0x40
13636c5fee3Smcneal #define	ISCSI_OPCODE_MASK		0x3F
13736c5fee3Smcneal 
13836c5fee3Smcneal /* Client to Server Message Opcode values */
13936c5fee3Smcneal #define	ISCSI_OP_NOOP_OUT		0x00
14036c5fee3Smcneal #define	ISCSI_OP_SCSI_CMD		0x01
14136c5fee3Smcneal #define	ISCSI_OP_SCSI_TASK_MGT_MSG	0x02
14236c5fee3Smcneal #define	ISCSI_OP_LOGIN_CMD		0x03
14336c5fee3Smcneal #define	ISCSI_OP_TEXT_CMD		0x04
14436c5fee3Smcneal #define	ISCSI_OP_SCSI_DATA		0x05
14536c5fee3Smcneal #define	ISCSI_OP_LOGOUT_CMD		0x06
14636c5fee3Smcneal #define	ISCSI_OP_SNACK_CMD		0x10
14736c5fee3Smcneal 
14836c5fee3Smcneal /* Server to Client Message Opcode values */
14936c5fee3Smcneal #define	ISCSI_OP_NOOP_IN		0x20
15036c5fee3Smcneal #define	ISCSI_OP_SCSI_RSP		0x21
15136c5fee3Smcneal #define	ISCSI_OP_SCSI_TASK_MGT_RSP	0x22
15236c5fee3Smcneal #define	ISCSI_OP_LOGIN_RSP		0x23
15336c5fee3Smcneal #define	ISCSI_OP_TEXT_RSP		0x24
15436c5fee3Smcneal #define	ISCSI_OP_SCSI_DATA_RSP		0x25
15536c5fee3Smcneal #define	ISCSI_OP_LOGOUT_RSP		0x26
15636c5fee3Smcneal #define	ISCSI_OP_RTT_RSP		0x31
15736c5fee3Smcneal #define	ISCSI_OP_ASYNC_EVENT		0x32
15836c5fee3Smcneal #define	ISCSI_OP_REJECT_MSG		0x3f
15936c5fee3Smcneal 
16036c5fee3Smcneal 
16136c5fee3Smcneal /* SCSI Command Header */
16236c5fee3Smcneal typedef struct _iscsi_scsi_cmd_hdr {
16336c5fee3Smcneal 	uint8_t opcode;
16436c5fee3Smcneal 	uint8_t flags;
16536c5fee3Smcneal 	uint8_t rsvd[2];
16636c5fee3Smcneal 	uint8_t hlength;
16736c5fee3Smcneal 	uint8_t dlength[3];
16836c5fee3Smcneal 	uint8_t lun[8];
16936c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
17036c5fee3Smcneal 	uint32_t data_length;
17136c5fee3Smcneal 	uint32_t cmdsn;
17236c5fee3Smcneal 	uint32_t expstatsn;
17336c5fee3Smcneal 	uint8_t scb[16];	/* SCSI Command Block */
17436c5fee3Smcneal 	/*
17536c5fee3Smcneal 	 * Additional Data (Command Dependent)
17636c5fee3Smcneal 	 */
17736c5fee3Smcneal } iscsi_scsi_cmd_hdr_t;
17836c5fee3Smcneal 
17936c5fee3Smcneal /* Command PDU flags */
18036c5fee3Smcneal #define	ISCSI_FLAG_CMD_READ		0x40
18136c5fee3Smcneal #define	ISCSI_FLAG_CMD_WRITE		0x20
18236c5fee3Smcneal #define	ISCSI_FLAG_CMD_ATTR_MASK	0x07	/* 3 bits */
18336c5fee3Smcneal 
18436c5fee3Smcneal /* SCSI Command Attribute values */
18536c5fee3Smcneal #define	ISCSI_ATTR_UNTAGGED		0
18636c5fee3Smcneal #define	ISCSI_ATTR_SIMPLE		1
18736c5fee3Smcneal #define	ISCSI_ATTR_ORDERED		2
18836c5fee3Smcneal #define	ISCSI_ATTR_HEAD_OF_QUEUE	3
18936c5fee3Smcneal #define	ISCSI_ATTR_ACA			4
19036c5fee3Smcneal 
19136c5fee3Smcneal 
19236c5fee3Smcneal /* SCSI Response Header */
19336c5fee3Smcneal typedef struct _iscsi_scsi_rsp_hdr {
19436c5fee3Smcneal 	uint8_t opcode;
19536c5fee3Smcneal 	uint8_t flags;
19636c5fee3Smcneal 	uint8_t response;
19736c5fee3Smcneal 	uint8_t cmd_status;
19836c5fee3Smcneal 	uint8_t hlength;
19936c5fee3Smcneal 	uint8_t dlength[3];
20036c5fee3Smcneal 	uint8_t rsvd[8];
20136c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
20236c5fee3Smcneal 	uint32_t rsvd1;
20336c5fee3Smcneal 	uint32_t statsn;
20436c5fee3Smcneal 	uint32_t expcmdsn;
20536c5fee3Smcneal 	uint32_t maxcmdsn;
20636c5fee3Smcneal 	uint32_t expdatasn;
20736c5fee3Smcneal 	uint32_t bi_residual_count;
20836c5fee3Smcneal 	uint32_t residual_count;
20936c5fee3Smcneal 	/*
21036c5fee3Smcneal 	 * Response or Sense Data (optional)
21136c5fee3Smcneal 	 */
21236c5fee3Smcneal } iscsi_scsi_rsp_hdr_t;
21336c5fee3Smcneal 
21436c5fee3Smcneal /* 10.2.2.3 - Extended CDB Additional Header Segment */
21536c5fee3Smcneal 
21636c5fee3Smcneal typedef struct _iscsi_addl_hdr {
21736c5fee3Smcneal 	iscsi_scsi_cmd_hdr_t ahs_isch;
21836c5fee3Smcneal 	uint8_t ahs_hlen_hi;
21936c5fee3Smcneal 	uint8_t ahs_hlen_lo;
22036c5fee3Smcneal 	uint8_t ahs_key;
22136c5fee3Smcneal 	uint8_t ahs_resv;
22236c5fee3Smcneal 	uint8_t ahs_extscb[4];
22336c5fee3Smcneal } iscsi_addl_hdr_t;
22436c5fee3Smcneal 
22536c5fee3Smcneal /* Command Response PDU flags */
22636c5fee3Smcneal #define	ISCSI_FLAG_CMD_BIDI_OVERFLOW	0x10
22736c5fee3Smcneal #define	ISCSI_FLAG_CMD_BIDI_UNDERFLOW	0x08
22836c5fee3Smcneal #define	ISCSI_FLAG_CMD_OVERFLOW		0x04
22936c5fee3Smcneal #define	ISCSI_FLAG_CMD_UNDERFLOW	0x02
23036c5fee3Smcneal 
23136c5fee3Smcneal /* iSCSI Status values. Valid if Rsp Selector bit is not set */
23236c5fee3Smcneal #define	ISCSI_STATUS_CMD_COMPLETED	0
23336c5fee3Smcneal #define	ISCSI_STATUS_TARGET_FAILURE	1
23436c5fee3Smcneal #define	ISCSI_STATUS_SUBSYS_FAILURE	2
23536c5fee3Smcneal 
23636c5fee3Smcneal 
23736c5fee3Smcneal /* Asynchronous Event Header */
23836c5fee3Smcneal typedef struct _iscsi_async_evt_hdr {
23936c5fee3Smcneal 	uint8_t opcode;
24036c5fee3Smcneal 	uint8_t flags;
24136c5fee3Smcneal 	uint8_t rsvd2[2];
24236c5fee3Smcneal 	uint8_t rsvd3;
24336c5fee3Smcneal 	uint8_t dlength[3];
24436c5fee3Smcneal 	uint8_t lun[8];
24536c5fee3Smcneal 	uint8_t rsvd4[8];
24636c5fee3Smcneal 	uint32_t statsn;
24736c5fee3Smcneal 	uint32_t expcmdsn;
24836c5fee3Smcneal 	uint32_t maxcmdsn;
24936c5fee3Smcneal 	uint8_t async_event;
25036c5fee3Smcneal 	uint8_t async_vcode;
25136c5fee3Smcneal 	uint16_t param1;
25236c5fee3Smcneal 	uint16_t param2;
25336c5fee3Smcneal 	uint16_t param3;
25436c5fee3Smcneal 	uint8_t rsvd5[4];
25536c5fee3Smcneal } iscsi_async_evt_hdr_t;
25636c5fee3Smcneal 
25736c5fee3Smcneal /* iSCSI Event Indicator values */
25836c5fee3Smcneal #define	ISCSI_ASYNC_EVENT_SCSI_EVENT			0
25936c5fee3Smcneal #define	ISCSI_ASYNC_EVENT_REQUEST_LOGOUT		1
26036c5fee3Smcneal #define	ISCSI_ASYNC_EVENT_DROPPING_CONNECTION		2
26136c5fee3Smcneal #define	ISCSI_ASYNC_EVENT_DROPPING_ALL_CONNECTIONS	3
26236c5fee3Smcneal #define	ISCSI_ASYNC_EVENT_PARAM_NEGOTIATION		4
26336c5fee3Smcneal #define	ISCSI_ASYNC_EVENT_VENDOR_SPECIFIC		255
26436c5fee3Smcneal 
26536c5fee3Smcneal 
26636c5fee3Smcneal /* NOP-Out Message */
26736c5fee3Smcneal typedef struct _iscsi_nop_out_hdr {
26836c5fee3Smcneal 	uint8_t opcode;
26936c5fee3Smcneal 	uint8_t flags;
27036c5fee3Smcneal 	uint16_t rsvd2;
27136c5fee3Smcneal 	uint8_t rsvd3;
27236c5fee3Smcneal 	uint8_t dlength[3];
27336c5fee3Smcneal 	uint8_t lun[8];
27436c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
27536c5fee3Smcneal 	uint32_t ttt;	/* Target Transfer Tag */
27636c5fee3Smcneal 	uint32_t cmdsn;
27736c5fee3Smcneal 	uint32_t expstatsn;
27836c5fee3Smcneal 	uint8_t rsvd4[16];
27936c5fee3Smcneal } iscsi_nop_out_hdr_t;
28036c5fee3Smcneal 
28136c5fee3Smcneal 
28236c5fee3Smcneal /* NOP-In Message */
28336c5fee3Smcneal typedef struct _iscsi_nop_in_hdr {
28436c5fee3Smcneal 	uint8_t opcode;
28536c5fee3Smcneal 	uint8_t flags;
28636c5fee3Smcneal 	uint16_t rsvd2;
28736c5fee3Smcneal 	uint8_t rsvd3;
28836c5fee3Smcneal 	uint8_t dlength[3];
28936c5fee3Smcneal 	uint8_t lun[8];
29036c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
29136c5fee3Smcneal 	uint32_t ttt;	/* Target Transfer Tag */
29236c5fee3Smcneal 	uint32_t statsn;
29336c5fee3Smcneal 	uint32_t expcmdsn;
29436c5fee3Smcneal 	uint32_t maxcmdsn;
29536c5fee3Smcneal 	uint8_t rsvd4[12];
29636c5fee3Smcneal } iscsi_nop_in_hdr_t;
29736c5fee3Smcneal 
29836c5fee3Smcneal /* SCSI Task Management Message Header */
29936c5fee3Smcneal typedef struct _iscsi_scsi_task_mgt_hdr {
30036c5fee3Smcneal 	uint8_t opcode;
30136c5fee3Smcneal 	uint8_t function;
30236c5fee3Smcneal 	uint8_t rsvd1[2];
30336c5fee3Smcneal 	uint8_t hlength;
30436c5fee3Smcneal 	uint8_t dlength[3];
30536c5fee3Smcneal 	uint8_t lun[8];
30636c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
30736c5fee3Smcneal 	uint32_t rtt;	/* Reference Task Tag */
30836c5fee3Smcneal 	uint32_t cmdsn;
30936c5fee3Smcneal 	uint32_t expstatsn;
31036c5fee3Smcneal 	uint32_t refcmdsn;
31136c5fee3Smcneal 	uint32_t expdatasn;
31236c5fee3Smcneal 	uint8_t rsvd2[8];
31336c5fee3Smcneal } iscsi_scsi_task_mgt_hdr_t;
31436c5fee3Smcneal 
31536c5fee3Smcneal #define	ISCSI_FLAG_TASK_MGMT_FUNCTION_MASK  0x7F
31636c5fee3Smcneal 
31736c5fee3Smcneal /* Function values */
31836c5fee3Smcneal #define	ISCSI_TM_FUNC_ABORT_TASK		1
31936c5fee3Smcneal #define	ISCSI_TM_FUNC_ABORT_TASK_SET		2
32036c5fee3Smcneal #define	ISCSI_TM_FUNC_CLEAR_ACA			3
32136c5fee3Smcneal #define	ISCSI_TM_FUNC_CLEAR_TASK_SET		4
32236c5fee3Smcneal #define	ISCSI_TM_FUNC_LOGICAL_UNIT_RESET	5
32336c5fee3Smcneal #define	ISCSI_TM_FUNC_TARGET_WARM_RESET		6
32436c5fee3Smcneal #define	ISCSI_TM_FUNC_TARGET_COLD_RESET		7
32536c5fee3Smcneal #define	ISCSI_TM_FUNC_TASK_REASSIGN		8
32636c5fee3Smcneal 
32736c5fee3Smcneal 
32836c5fee3Smcneal /* SCSI Task Management Response Header */
32936c5fee3Smcneal typedef struct _iscsi_scsi_task_mgt_rsp_hdr {
33036c5fee3Smcneal 	uint8_t opcode;
33136c5fee3Smcneal 	uint8_t flags;
33236c5fee3Smcneal 	uint8_t response;	/* see Response values below */
33336c5fee3Smcneal 	uint8_t qualifier;
33436c5fee3Smcneal 	uint8_t hlength;
33536c5fee3Smcneal 	uint8_t dlength[3];
33636c5fee3Smcneal 	uint8_t rsvd2[8];
33736c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
33836c5fee3Smcneal 	uint32_t rtt;	/* Reference Task Tag */
33936c5fee3Smcneal 	uint32_t statsn;
34036c5fee3Smcneal 	uint32_t expcmdsn;
34136c5fee3Smcneal 	uint32_t maxcmdsn;
34236c5fee3Smcneal 	uint8_t rsvd3[12];
34336c5fee3Smcneal } iscsi_scsi_task_mgt_rsp_hdr_t;
34436c5fee3Smcneal 
34536c5fee3Smcneal 
34636c5fee3Smcneal /* Response values */
34736c5fee3Smcneal #define	SCSI_TCP_TM_RESP_COMPLETE	0x00
34836c5fee3Smcneal #define	SCSI_TCP_TM_RESP_NO_TASK	0x01
34936c5fee3Smcneal #define	SCSI_TCP_TM_RESP_NO_LUN		0x02
35036c5fee3Smcneal #define	SCSI_TCP_TM_RESP_TASK_ALLEGIANT	0x03
351a6d42e7dSPeter Dunlap #define	SCSI_TCP_TM_RESP_NO_ALLG_REASSN	0x04
352a6d42e7dSPeter Dunlap #define	SCSI_TCP_TM_RESP_FUNC_NOT_SUPP	0x05
353a6d42e7dSPeter Dunlap #define	SCSI_TCP_TM_RESP_FUNC_AUTH_FAIL	0x06
35436c5fee3Smcneal #define	SCSI_TCP_TM_RESP_REJECTED	0xff
35536c5fee3Smcneal 
356a6d42e7dSPeter Dunlap /*
357a6d42e7dSPeter Dunlap  * Maintained for backward compatibility.
358a6d42e7dSPeter Dunlap  */
359a6d42e7dSPeter Dunlap 
360a6d42e7dSPeter Dunlap #define	SCSI_TCP_TM_RESP_NO_FAILOVER	SCSI_TCP_TM_RESP_NO_ALLG_REASSN
361a6d42e7dSPeter Dunlap #define	SCSI_TCP_TM_RESP_IN_PRGRESS	SCSI_TCP_TM_RESP_FUNC_NOT_SUPP
362a6d42e7dSPeter Dunlap 
36336c5fee3Smcneal /* Ready To Transfer Header */
36436c5fee3Smcneal typedef struct _iscsi_rtt_hdr {
36536c5fee3Smcneal 	uint8_t opcode;
36636c5fee3Smcneal 	uint8_t flags;
36736c5fee3Smcneal 	uint8_t rsvd2[2];
36836c5fee3Smcneal 	uint8_t rsvd3[12];
36936c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
37036c5fee3Smcneal 	uint32_t ttt;	/* Target Transfer Tag */
37136c5fee3Smcneal 	uint32_t statsn;
37236c5fee3Smcneal 	uint32_t expcmdsn;
37336c5fee3Smcneal 	uint32_t maxcmdsn;
37436c5fee3Smcneal 	uint32_t rttsn;
37536c5fee3Smcneal 	uint32_t data_offset;
37636c5fee3Smcneal 	uint32_t data_length;
37736c5fee3Smcneal } iscsi_rtt_hdr_t;
37836c5fee3Smcneal 
37936c5fee3Smcneal 
38036c5fee3Smcneal /* SCSI Data Hdr */
38136c5fee3Smcneal typedef struct _iscsi_data_hdr {
38236c5fee3Smcneal 	uint8_t opcode;
38336c5fee3Smcneal 	uint8_t flags;
38436c5fee3Smcneal 	uint8_t rsvd2[2];
38536c5fee3Smcneal 	uint8_t rsvd3;
38636c5fee3Smcneal 	uint8_t dlength[3];
38736c5fee3Smcneal 	uint8_t lun[8];
38836c5fee3Smcneal 	uint32_t itt;
38936c5fee3Smcneal 	uint32_t ttt;
39036c5fee3Smcneal 	uint32_t rsvd4;
39136c5fee3Smcneal 	uint32_t expstatsn;
39236c5fee3Smcneal 	uint32_t rsvd5;
39336c5fee3Smcneal 	uint32_t datasn;
39436c5fee3Smcneal 	uint32_t offset;
39536c5fee3Smcneal 	uint32_t rsvd6;
39636c5fee3Smcneal 	/*
39736c5fee3Smcneal 	 * Payload
39836c5fee3Smcneal 	 */
39936c5fee3Smcneal } iscsi_data_hdr_t;
40036c5fee3Smcneal 
40136c5fee3Smcneal /* SCSI Data Response Hdr */
40236c5fee3Smcneal typedef struct _iscsi_data_rsp_hdr {
40336c5fee3Smcneal 	uint8_t opcode;
40436c5fee3Smcneal 	uint8_t flags;
40536c5fee3Smcneal 	uint8_t rsvd2;
40636c5fee3Smcneal 	uint8_t cmd_status;
40736c5fee3Smcneal 	uint8_t hlength;
40836c5fee3Smcneal 	uint8_t dlength[3];
40936c5fee3Smcneal 	uint8_t lun[8];
41036c5fee3Smcneal 	uint32_t itt;
41136c5fee3Smcneal 	uint32_t ttt;
41236c5fee3Smcneal 	uint32_t statsn;
41336c5fee3Smcneal 	uint32_t expcmdsn;
41436c5fee3Smcneal 	uint32_t maxcmdsn;
41536c5fee3Smcneal 	uint32_t datasn;
41636c5fee3Smcneal 	uint32_t offset;
41736c5fee3Smcneal 	uint32_t residual_count;
41836c5fee3Smcneal } iscsi_data_rsp_hdr_t;
41936c5fee3Smcneal 
42036c5fee3Smcneal /* Data Response PDU flags */
42136c5fee3Smcneal #define	ISCSI_FLAG_DATA_ACK		0x40
42236c5fee3Smcneal #define	ISCSI_FLAG_DATA_OVERFLOW	0x04
42336c5fee3Smcneal #define	ISCSI_FLAG_DATA_UNDERFLOW	0x02
42436c5fee3Smcneal #define	ISCSI_FLAG_DATA_STATUS		0x01
42536c5fee3Smcneal 
42636c5fee3Smcneal 
42736c5fee3Smcneal /* Text Header */
42836c5fee3Smcneal typedef struct _iscsi_text_hdr {
42936c5fee3Smcneal 	uint8_t opcode;
43036c5fee3Smcneal 	uint8_t flags;
43136c5fee3Smcneal 	uint8_t rsvd2[2];
43236c5fee3Smcneal 	uint8_t hlength;
43336c5fee3Smcneal 	uint8_t dlength[3];
43436c5fee3Smcneal 	uint8_t rsvd4[8];
43536c5fee3Smcneal 	uint32_t itt;
43636c5fee3Smcneal 	uint32_t ttt;
43736c5fee3Smcneal 	uint32_t cmdsn;
43836c5fee3Smcneal 	uint32_t expstatsn;
43936c5fee3Smcneal 	uint8_t rsvd5[16];
44036c5fee3Smcneal 	/*
44136c5fee3Smcneal 	 * Text - key=value pairs
44236c5fee3Smcneal 	 */
44336c5fee3Smcneal } iscsi_text_hdr_t;
44436c5fee3Smcneal 
44536c5fee3Smcneal #define	ISCSI_FLAG_TEXT_CONTINUE	0x40
44636c5fee3Smcneal 
44736c5fee3Smcneal /* Text Response Header */
44836c5fee3Smcneal typedef struct _iscsi_text_rsp_hdr {
44936c5fee3Smcneal 	uint8_t opcode;
45036c5fee3Smcneal 	uint8_t flags;
45136c5fee3Smcneal 	uint8_t rsvd2[2];
45236c5fee3Smcneal 	uint8_t hlength;
45336c5fee3Smcneal 	uint8_t dlength[3];
45436c5fee3Smcneal 	uint8_t rsvd4[8];
45536c5fee3Smcneal 	uint32_t itt;
45636c5fee3Smcneal 	uint32_t ttt;
45736c5fee3Smcneal 	uint32_t statsn;
45836c5fee3Smcneal 	uint32_t expcmdsn;
45936c5fee3Smcneal 	uint32_t maxcmdsn;
46036c5fee3Smcneal 	uint8_t rsvd5[12];
46136c5fee3Smcneal 	/*
46236c5fee3Smcneal 	 * Text Response - key:value pairs
46336c5fee3Smcneal 	 */
46436c5fee3Smcneal } iscsi_text_rsp_hdr_t;
46536c5fee3Smcneal 
466a6d42e7dSPeter Dunlap #define	ISCSI_ISID_LEN	6
467a6d42e7dSPeter Dunlap 
46836c5fee3Smcneal /* Login Header */
46936c5fee3Smcneal typedef struct _iscsi_login_hdr {
47036c5fee3Smcneal 	uint8_t opcode;
47136c5fee3Smcneal 	uint8_t flags;
47236c5fee3Smcneal 	uint8_t max_version;	/* Max. version supported */
47336c5fee3Smcneal 	uint8_t min_version;	/* Min. version supported */
47436c5fee3Smcneal 	uint8_t hlength;
47536c5fee3Smcneal 	uint8_t dlength[3];
476a6d42e7dSPeter Dunlap 	uint8_t isid[ISCSI_ISID_LEN];	/* Initiator Session ID */
47736c5fee3Smcneal 	uint16_t tsid;	/* Target Session ID */
47836c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
47936c5fee3Smcneal 	uint16_t cid;
48036c5fee3Smcneal 	uint16_t rsvd3;
48136c5fee3Smcneal 	uint32_t cmdsn;
48236c5fee3Smcneal 	uint32_t expstatsn;
48336c5fee3Smcneal 	uint8_t rsvd5[16];
48436c5fee3Smcneal } iscsi_login_hdr_t;
48536c5fee3Smcneal 
48636c5fee3Smcneal /* Login PDU flags */
48736c5fee3Smcneal #define	ISCSI_FLAG_LOGIN_TRANSIT		0x80
48836c5fee3Smcneal #define	ISCSI_FLAG_LOGIN_CONTINUE		0x40
48936c5fee3Smcneal #define	ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK	0x0C	/* 2 bits */
49036c5fee3Smcneal #define	ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK	0x03	/* 2 bits */
49136c5fee3Smcneal 
49236c5fee3Smcneal #define	ISCSI_LOGIN_CURRENT_STAGE(flags) \
49336c5fee3Smcneal 	((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2)
49436c5fee3Smcneal #define	ISCSI_LOGIN_NEXT_STAGE(flags) \
49536c5fee3Smcneal 	(flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK)
49636c5fee3Smcneal 
49736c5fee3Smcneal 
49836c5fee3Smcneal /* Login Response Header */
49936c5fee3Smcneal typedef struct _iscsi_login_rsp_hdr {
50036c5fee3Smcneal 	uint8_t opcode;
50136c5fee3Smcneal 	uint8_t flags;
50236c5fee3Smcneal 	uint8_t max_version;	/* Max. version supported */
50336c5fee3Smcneal 	uint8_t active_version;	/* Active version */
50436c5fee3Smcneal 	uint8_t hlength;
50536c5fee3Smcneal 	uint8_t dlength[3];
506a6d42e7dSPeter Dunlap 	uint8_t isid[ISCSI_ISID_LEN];	/* Initiator Session ID */
50736c5fee3Smcneal 	uint16_t tsid;	/* Target Session ID */
50836c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
50936c5fee3Smcneal 	uint32_t rsvd3;
51036c5fee3Smcneal 	uint32_t statsn;
51136c5fee3Smcneal 	uint32_t expcmdsn;
51236c5fee3Smcneal 	uint32_t maxcmdsn;
51336c5fee3Smcneal 	uint8_t status_class;	/* see Login RSP ststus classes below */
51436c5fee3Smcneal 	uint8_t status_detail;	/* see Login RSP Status details below */
51536c5fee3Smcneal 	uint8_t rsvd4[10];
51636c5fee3Smcneal } iscsi_login_rsp_hdr_t;
51736c5fee3Smcneal 
51836c5fee3Smcneal /* Login stage (phase) codes for CSG, NSG */
51936c5fee3Smcneal #define	ISCSI_SECURITY_NEGOTIATION_STAGE	0
52036c5fee3Smcneal #define	ISCSI_OP_PARMS_NEGOTIATION_STAGE	1
52136c5fee3Smcneal #define	ISCSI_FULL_FEATURE_PHASE		3
52236c5fee3Smcneal 
52336c5fee3Smcneal /* Login Status response classes */
52436c5fee3Smcneal #define	ISCSI_STATUS_CLASS_SUCCESS		0x00
52536c5fee3Smcneal #define	ISCSI_STATUS_CLASS_REDIRECT		0x01
52636c5fee3Smcneal #define	ISCSI_STATUS_CLASS_INITIATOR_ERR	0x02
52736c5fee3Smcneal #define	ISCSI_STATUS_CLASS_TARGET_ERR		0x03
52836c5fee3Smcneal 
52936c5fee3Smcneal /* Login Status response detail codes */
53036c5fee3Smcneal /* Class-0 (Success) */
53136c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_ACCEPT		0x00
53236c5fee3Smcneal 
53336c5fee3Smcneal /* Class-1 (Redirection) */
53436c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP	0x01
53536c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_TGT_MOVED_PERM	0x02
53636c5fee3Smcneal 
53736c5fee3Smcneal /* Class-2 (Initiator Error) */
53836c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_INIT_ERR		0x00
53936c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_AUTH_FAILED		0x01
54036c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_TGT_FORBIDDEN	0x02
54136c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_TGT_NOT_FOUND	0x03
54236c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_TGT_REMOVED		0x04
54336c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_NO_VERSION		0x05
54436c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_ISID_ERROR		0x06
54536c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_MISSING_FIELDS	0x07
54636c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_CONN_ADD_FAILED	0x08
54736c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_NO_SESSION_TYPE	0x09
54836c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_NO_SESSION		0x0a
54936c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_INVALID_REQUEST	0x0b
55036c5fee3Smcneal 
55136c5fee3Smcneal /* Class-3 (Target Error) */
55236c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_TARGET_ERROR		0x00
55336c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE	0x01
55436c5fee3Smcneal #define	ISCSI_LOGIN_STATUS_NO_RESOURCES		0x02
55536c5fee3Smcneal 
55636c5fee3Smcneal /* Logout Header */
55736c5fee3Smcneal typedef struct _iscsi_logout_hdr {
55836c5fee3Smcneal 	uint8_t opcode;
55936c5fee3Smcneal 	uint8_t flags;
56036c5fee3Smcneal 	uint8_t rsvd1[2];
56136c5fee3Smcneal 	uint8_t hlength;
56236c5fee3Smcneal 	uint8_t dlength[3];
56336c5fee3Smcneal 	uint8_t rsvd2[8];
56436c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
56536c5fee3Smcneal 	uint16_t cid;
56636c5fee3Smcneal 	uint8_t rsvd3[2];
56736c5fee3Smcneal 	uint32_t cmdsn;
56836c5fee3Smcneal 	uint32_t expstatsn;
56936c5fee3Smcneal 	uint8_t rsvd4[16];
57036c5fee3Smcneal } iscsi_logout_hdr_t;
57136c5fee3Smcneal 
57236c5fee3Smcneal /* Logout PDU flags */
57336c5fee3Smcneal #define	ISCSI_FLAG_LOGOUT_REASON_MASK		0x7F
57436c5fee3Smcneal 
57536c5fee3Smcneal /* logout reason_code values */
57636c5fee3Smcneal 
57736c5fee3Smcneal #define	ISCSI_LOGOUT_REASON_CLOSE_SESSION	0
57836c5fee3Smcneal #define	ISCSI_LOGOUT_REASON_CLOSE_CONNECTION	1
57936c5fee3Smcneal #define	ISCSI_LOGOUT_REASON_RECOVERY		2
58036c5fee3Smcneal #define	ISCSI_LOGOUT_REASON_AEN_REQUEST		3
58136c5fee3Smcneal 
58236c5fee3Smcneal /* Logout Response Header */
58336c5fee3Smcneal typedef struct _iscsi_logout_rsp_hdr {
58436c5fee3Smcneal 	uint8_t opcode;
58536c5fee3Smcneal 	uint8_t flags;
58636c5fee3Smcneal 	uint8_t response;	/* see Logout response values below */
58736c5fee3Smcneal 	uint8_t rsvd2;
58836c5fee3Smcneal 	uint8_t hlength;
58936c5fee3Smcneal 	uint8_t dlength[3];
59036c5fee3Smcneal 	uint8_t rsvd3[8];
59136c5fee3Smcneal 	uint32_t itt;	/* Initiator Task Tag */
59236c5fee3Smcneal 	uint32_t rsvd4;
59336c5fee3Smcneal 	uint32_t statsn;
59436c5fee3Smcneal 	uint32_t expcmdsn;
59536c5fee3Smcneal 	uint32_t maxcmdsn;
59636c5fee3Smcneal 	uint32_t rsvd5;
59736c5fee3Smcneal 	uint16_t t2wait;
59836c5fee3Smcneal 	uint16_t t2retain;
59936c5fee3Smcneal 	uint32_t rsvd6;
60036c5fee3Smcneal } iscsi_logout_rsp_hdr_t;
60136c5fee3Smcneal 
60236c5fee3Smcneal /* logout response status values */
60336c5fee3Smcneal 
60436c5fee3Smcneal #define	ISCSI_LOGOUT_SUCCESS		  0
60536c5fee3Smcneal #define	ISCSI_LOGOUT_CID_NOT_FOUND	  1
60636c5fee3Smcneal #define	ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2
60736c5fee3Smcneal #define	ISCSI_LOGOUT_CLEANUP_FAILED	  3
60836c5fee3Smcneal 
60936c5fee3Smcneal 
61036c5fee3Smcneal /* SNACK Header */
61136c5fee3Smcneal typedef struct _iscsi_snack_hdr {
61236c5fee3Smcneal 	uint8_t opcode;
61336c5fee3Smcneal 	uint8_t flags;
61436c5fee3Smcneal 	uint8_t rsvd2[14];
61536c5fee3Smcneal 	uint32_t itt;
61636c5fee3Smcneal 	uint32_t begrun;
61736c5fee3Smcneal 	uint32_t runlength;
61836c5fee3Smcneal 	uint32_t expstatsn;
61936c5fee3Smcneal 	uint32_t rsvd3;
62036c5fee3Smcneal 	uint32_t expdatasn;
62136c5fee3Smcneal 	uint8_t rsvd6[8];
62236c5fee3Smcneal } iscsi_snack_hdr_t;
62336c5fee3Smcneal 
62436c5fee3Smcneal /* SNACK PDU flags */
62536c5fee3Smcneal #define	ISCSI_FLAG_SNACK_TYPE_MASK	0x0F	/* 4 bits */
62636c5fee3Smcneal 
62736c5fee3Smcneal /* Reject Message Header */
62836c5fee3Smcneal typedef struct _iscsi_reject_rsp_hdr {
62936c5fee3Smcneal 	uint8_t opcode;
63036c5fee3Smcneal 	uint8_t flags;
63136c5fee3Smcneal 	uint8_t reason;
63236c5fee3Smcneal 	uint8_t rsvd2;
63336c5fee3Smcneal 	uint8_t rsvd3;
63436c5fee3Smcneal 	uint8_t dlength[3];
635a6d42e7dSPeter Dunlap 	uint8_t rsvd4[8];
636a6d42e7dSPeter Dunlap 	uint8_t	must_be_ff[4];
637a6d42e7dSPeter Dunlap 	uint8_t	rsvd4a[4];
63836c5fee3Smcneal 	uint32_t statsn;
63936c5fee3Smcneal 	uint32_t expcmdsn;
64036c5fee3Smcneal 	uint32_t maxcmdsn;
64136c5fee3Smcneal 	uint32_t datasn;
64236c5fee3Smcneal 	uint8_t rsvd5[8];
64336c5fee3Smcneal 	/*
64436c5fee3Smcneal 	 * Text - Rejected hdr
64536c5fee3Smcneal 	 */
64636c5fee3Smcneal } iscsi_reject_rsp_hdr_t;
64736c5fee3Smcneal 
64836c5fee3Smcneal /* Reason for Reject */
64936c5fee3Smcneal #define	ISCSI_REJECT_CMD_BEFORE_LOGIN		1
65036c5fee3Smcneal #define	ISCSI_REJECT_DATA_DIGEST_ERROR		2
65136c5fee3Smcneal #define	ISCSI_REJECT_SNACK_REJECT		3
65236c5fee3Smcneal #define	ISCSI_REJECT_PROTOCOL_ERROR		4
65336c5fee3Smcneal #define	ISCSI_REJECT_CMD_NOT_SUPPORTED		5
65436c5fee3Smcneal #define	ISCSI_REJECT_IMM_CMD_REJECT		6
65536c5fee3Smcneal #define	ISCSI_REJECT_TASK_IN_PROGRESS		7
65636c5fee3Smcneal #define	ISCSI_REJECT_INVALID_DATA_ACK		8
65736c5fee3Smcneal #define	ISCSI_REJECT_INVALID_PDU_FIELD		9
65836c5fee3Smcneal #define	ISCSI_REJECT_LONG_OPERATION_REJECT	10
65936c5fee3Smcneal #define	ISCSI_REJECT_NEGOTIATION_RESET		11
66036c5fee3Smcneal #define	ISCSI_REJECT_WAITING_FOR_LOGOUT		12
66136c5fee3Smcneal 
66236c5fee3Smcneal /* Defaults as defined by the iSCSI specification */
66336c5fee3Smcneal #define	ISCSI_DEFAULT_IMMEDIATE_DATA		TRUE
66436c5fee3Smcneal #define	ISCSI_DEFAULT_INITIALR2T		TRUE
66536c5fee3Smcneal #define	ISCSI_DEFAULT_FIRST_BURST_LENGTH	(64 * 1024) /* 64kbytes */
66636c5fee3Smcneal #define	ISCSI_DEFAULT_MAX_BURST_LENGTH		(256 * 1024) /* 256kbytes */
66736c5fee3Smcneal #define	ISCSI_DEFAULT_DATA_PDU_IN_ORDER		TRUE
66836c5fee3Smcneal #define	ISCSI_DEFAULT_DATA_SEQUENCE_IN_ORDER	TRUE
66936c5fee3Smcneal #define	ISCSI_DEFAULT_TIME_TO_WAIT		2 /* 2 seconds */
67036c5fee3Smcneal #define	ISCSI_DEFAULT_TIME_TO_RETAIN		20 /* 20 seconds */
67136c5fee3Smcneal #define	ISCSI_DEFAULT_HEADER_DIGEST		ISCSI_DIGEST_NONE
67236c5fee3Smcneal #define	ISCSI_DEFAULT_DATA_DIGEST		ISCSI_DIGEST_NONE
6731a1a84a3SPeter Dunlap #define	ISCSI_DEFAULT_MAX_RECV_SEG_LEN		(8 * 1024)
67436c5fee3Smcneal #define	ISCSI_DEFAULT_MAX_XMIT_SEG_LEN		(8 * 1024)
67536c5fee3Smcneal #define	ISCSI_DEFAULT_MAX_CONNECTIONS		1
67636c5fee3Smcneal #define	ISCSI_DEFAULT_MAX_OUT_R2T		1
67736c5fee3Smcneal #define	ISCSI_DEFAULT_ERROR_RECOVERY_LEVEL	0
67836c5fee3Smcneal #define	ISCSI_DEFAULT_IFMARKER			FALSE
67936c5fee3Smcneal #define	ISCSI_DEFAULT_OFMARKER			FALSE
68036c5fee3Smcneal 
681a6d42e7dSPeter Dunlap /*
682a6d42e7dSPeter Dunlap  * Minimum values from the iSCSI specification
683a6d42e7dSPeter Dunlap  */
684a6d42e7dSPeter Dunlap 
685a6d42e7dSPeter Dunlap #define	ISCSI_MIN_TIME2RETAIN			0
686a6d42e7dSPeter Dunlap #define	ISCSI_MIN_TIME2WAIT			0
687a6d42e7dSPeter Dunlap #define	ISCSI_MIN_ERROR_RECOVERY_LEVEL		0
688a6d42e7dSPeter Dunlap #define	ISCSI_MIN_RECV_DATA_SEGMENT_LENGTH	0x200
689a6d42e7dSPeter Dunlap #define	ISCSI_MIN_FIRST_BURST_LENGTH		0x200
690a6d42e7dSPeter Dunlap #define	ISCSI_MIN_MAX_BURST_LENGTH		0x200
691a6d42e7dSPeter Dunlap #define	ISCSI_MIN_CONNECTIONS			1
692a6d42e7dSPeter Dunlap #define	ISCSI_MIN_MAX_OUTSTANDING_R2T		1
693a6d42e7dSPeter Dunlap 
69436c5fee3Smcneal /*
69536c5fee3Smcneal  * Maximum values from the iSCSI specification
69636c5fee3Smcneal  */
69736c5fee3Smcneal #define	ISCSI_MAX_HEADER_DIGEST			3
69836c5fee3Smcneal #define	ISCSI_MAX_DATA_DIGEST			3
69936c5fee3Smcneal #define	ISCSI_MAX_TIME2RETAIN			3600
70036c5fee3Smcneal #define	ISCSI_MAX_TIME2WAIT			3600
70136c5fee3Smcneal #define	ISCSI_MAX_ERROR_RECOVERY_LEVEL		2
70236c5fee3Smcneal #define	ISCSI_MAX_FIRST_BURST_LENGTH		0xffffff
70336c5fee3Smcneal #define	ISCSI_MAX_BURST_LENGTH			0xffffff
70436c5fee3Smcneal #define	ISCSI_MAX_CONNECTIONS			65535
70536c5fee3Smcneal #define	ISCSI_MAX_OUTSTANDING_R2T		65535
70636c5fee3Smcneal #define	ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH	0xffffff
70736c5fee3Smcneal #define	ISCSI_MAX_TPGT_VALUE			65535 /* 16 bit numeric */
70836c5fee3Smcneal 
70936c5fee3Smcneal /*
71036c5fee3Smcneal  * iqn and eui name prefixes and related defines
71136c5fee3Smcneal  */
71236c5fee3Smcneal #define	ISCSI_IQN_NAME_PREFIX			"iqn"
71336c5fee3Smcneal #define	ISCSI_EUI_NAME_PREFIX			"eui"
71436c5fee3Smcneal #define	ISCSI_EUI_NAME_LEN			20 /* eui. plus 16 octets */
71536c5fee3Smcneal 
71636c5fee3Smcneal #ifdef __cplusplus
71736c5fee3Smcneal }
71836c5fee3Smcneal #endif
71936c5fee3Smcneal 
72036c5fee3Smcneal #endif /* _ISCSI_PROTOCOL_H */
721