⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iscsi_common.h

📁 iscsi源代码 UNH的progect 有initiator端和target端的源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*	common/iscsi_common.h *  *	vi: set autoindent tabstop=8 shiftwidth=8 : * *	defines stuff common for both iscsi initiator and iscsi target * *	This file contains auxilliary functions for iscsi initiator  *	code that are responsible for dealing with error recovery. * *	Copyright (C) 2001-2004 InterOperability Lab (IOL) *	University of New Hampshire (UNH) *	Durham, NH 03824 * *	This program is free software; you can redistribute it and/or modify *	it under the terms of the GNU General Public License as published by *	the Free Software Foundation; either version 2, or (at your option) *	any later version. * *	This program is distributed in the hope that it will be useful, *	but WITHOUT ANY WARRANTY; without even the implied warranty of *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *	GNU General Public License for more details. * *	You should have received a copy of the GNU General Public License *	along with this program; if not, write to the Free Software *	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, *	USA. * *	The name of IOL and/or UNH may not be used to endorse or promote  *	products derived from this software without specific prior  * 	written permission.*/#ifndef _ISCSI_COMMON_H#define _ISCSI_COMMON_H#define ISCSI_WKP			3260	/* IANA's iSCSI WKP */#define ISCSI_WKP_STRING		"3260"	/* IANA's iSCSI WKP as string */#define ISCSI_SYSTEM_PORT		860	/* IANA's iSCSI system port */#define ISCSI_SYSTEM_PORT_STRING	"860"	/* IANA's system port as strng*/#define ISCSI_HDR_LEN			48	/* Basic Header Len */#define ISCSI_CDB_LEN			16	/* CDB len within BHS */#define CRC_LEN				4	/* Digest length */#define MAX_KEY_NAME_LENGTH		63	/* max len of key name */#define MAX_KEY_VALUE_LENGTH		255	/* max len of key val */#define MAX_ISCSI_NAME_LENGTH		223	/* max len of iSCSI name */#define ALL_ONES			0xFFFFFFFF	/* Reserved Value */#define MASK_24_BITS			0xFFFFFF#define MASK_22_BITS			0x3FFFFF#define MASK_16_BITS			0xFFFF#define MASK_8_BITS			0xFF#define QUEUE_DEPTH_ALLOWED		100#define SERIAL_BITS			31#define WHITE_SPACE			" \t\v\f\n\r"#define TARGETNAME_HEADER	"iqn.2002-10.edu.unh.iol.iscsi.draft20-target:"/* max number of loops allowed during login negotiation */#define LOOP_TIMES			8/* values for "role" and "who_called" parameters */#define INITIATOR			1#define TARGET				2#define MANAGEMENT			4#define TRUE				1#define NOT_TRUE			2/* iSCSI Drafts -- from now on we do only the latest draft (the standard) */#define DRAFT20				2000#define DEFAULT_DRAFT			DRAFT20#define DRAFT_MULTIPLIER		100/* iSCSI version */#define ISCSI_MAX_VERSION		0	/* Draft 20 */#define ISCSI_MIN_VERSION		0	/* Draft 20 *//*************************************************************************//* Bits used in the "neg_info" variable and key field during Login Phase *//* these 2 bits:	are passed by manage in the neg_info parameter to proc_info()	are used by proc_info()	are never stored in param->neg_info	are never used during initiator or target operation		(i.e., they are only used between manage and proc_info())*/#define RESTORE 			0x00000001#define FORCE				0x00000002/* these 2 bits:	are passed by manage in the neg_info parameter to proc_info()	are used by proc_info()	are stored by proc_info() directly in param->neg_info	are tested in param->neg_info during login negotiations	are never used in FFP*/#define KEY_TO_BE_NEGOTIATED	  	0x00000004#define KEY_BREAK_CONN_OR_RJT		0x00000008/* these 6 bits:	are not used by manage	are not used by proc_info()	are set and tested in param->neg_info during login negotiations	are never used in FFP*/#define KEY_SENT_TO_OTHER_SIDE		0x00000010#define KEY_GOT_FROM_OTHER_SIDE		0x00000020#define KEY_REPLY_OPTIONAL		0x00000040#define KEY_IRRELEVANT			0x00000080#define KEY_BAD				0x00000100#define KEY_REJECT			0x00000200#define KEY_WRONG			0x00000400/********************************************************************//* iSCSI opcodes *//* Draft 20, Section 10.2.1.2 Opcode *//* Initiator opcodes */#define ISCSI_INIT_NOP_OUT		0x00#define ISCSI_INIT_SCSI_CMND		0x01#define ISCSI_INIT_TASK_MGMT_CMND	0x02#define ISCSI_INIT_LOGIN_CMND		0x03#define ISCSI_INIT_TEXT_CMND		0x04#define ISCSI_INIT_SCSI_DATA_OUT	0x05#define ISCSI_INIT_LOGOUT_CMND		0x06#define ISCSI_INIT_SNACK		0x10/* Target opcodes */#define ISCSI_TARG_NOP_IN		0x20#define ISCSI_TARG_SCSI_RSP		0x21#define ISCSI_TARG_TASK_MGMT_RSP	0x22#define ISCSI_TARG_LOGIN_RSP		0x23#define ISCSI_TARG_TEXT_RSP		0x24#define ISCSI_TARG_SCSI_DATA_IN		0x25#define ISCSI_TARG_LOGOUT_RSP		0x26#define ISCSI_TARG_R2T			0x31#define ISCSI_TARG_ASYNC_MSG		0x32#define ISCSI_TARG_RJT			0x3f/* bits in connection_flags to control login and FFP */#define USE_FLAT_SPACE_LUN		0x0001#define USE_FULL_REPLIES		0x0002#define USE_SECURITY_PHASE		0x0004#define USE_OPERATIONAL_PHASE		0x0008#define USE_HEADERDIGEST		0x0010#define USE_DATADIGEST			0x0020#define GOT_ACTIVITY			0x0040#define SEND_NO_REPLY_TO_NOP_PING	0x0080	/* test 6 */#define SEND_NO_REPLY_TO_ASYNC_LOGOUT	0x0100	/* test 7 */#define USE_REFLECT_XKEYS		0x0200#define CONN_LOGGED_OUT			0x0400#define NEED_TX_WAKEUP			0x0800#define TX_TIMER_OFF			0x1000#define USE_ONE_KEY_PER_TEXT		0x2000#define CONN_HIT_EOF			0x4000/* chap support - CHONG */#define USE_TARGET_CONFIRMATION		0x01#define USE_BASE64			0x02/* bits and fields in the opcode byte (always byte 0 in a pdu) */#define ISCSI_OPCODE			0x3f#define REPLY_BIT			0x20#define I_BIT                          	0x40#define OLD_X_BIT			0x80	/* used in draft 8 and before *//* bits and fields in the flags byte (always byte 1 in a pdu) */#define F_BIT				0x80#define R_BIT				0x40#define A_BIT				0x40#define C_BIT				0x40#define READ_TYPE_CMND			R_BIT#define W_BIT				0x20#define WRITE_TYPE_CMND			W_BIT#define BRO_BIT				0x10#define BRU_BIT				0x08#define O_BIT				0x04#define U_BIT				0x02#define S_BIT                          	0x01#define T_BIT				0x80#define CSG				0x0C#define CSG1				0x04#define CSG2				0x08#define CSG3				0x0C#define CSG_SHIFT			2#define NSG				0x03#define NSG1				0x01#define NSG2				0x02#define NSG3				0x03/*	Draft 20, Section 10.3.1 Flags and Task Attibutes (byte 1) *//* SCSI Command ATTR value */#define ISCSI_UNTAGGED			0x00#define ISCSI_SIMPLE   	       		0x01#define ISCSI_ORDERED          		0x02#define ISCSI_HEAD_OF_QUEUE    		0x03#define ISCSI_ACA              		0x04#ifndef __SCSI_TARGET__/* RFC 3720 Section 10.5.1 Function (field in TMF Request) * * N.B. These definitions are duplicated in target/scsi_target.h * because there are needed in SCSI but that target file cannot * include this file (iscsi_common.h) */#define TMF_ABORT_TASK			1#define TMF_ABORT_TASK_SET		2#define TMF_CLEAR_ACA			3#define TMF_CLEAR_TASK_SET		4#define TMF_LUN_RESET			5#define TMF_TARGET_WARM_RESET		6#define TMF_TARGET_COLD_RESET		7#define TMF_TASK_REASSIGN		8#endif/*	Mike Christie, mikenc@us.ibm.com */#define ISCSI_SHUTDOWN_SIGNAL			SIGHUP#define ISCSI_SHUTDOWN_SIGBITS			(sigmask(ISCSI_SHUTDOWN_SIGNAL))/*	Draft 20, Section 10.13.5 Status-Class and Status-Detail *//*	Status-Class field in Login Response */#define STAT_CLASS_SUCCESS			0x00#define STAT_CLASS_REDIRECTION			0x01#define STAT_CLASS_INITIATOR			0x02#define STAT_CLASS_TARGET			0x03/*	Status-Detail field in Login Response */#define STAT_DETAIL_TARG_MOVED_TEMP 		0x01#define STAT_DETAIL_TARG_MOVED_PERM 		0x02#define STAT_DETAIL_ERR				0x00#define STAT_DETAIL_NOT_AUTH			0x01#define STAT_DETAIL_NOT_ALLOWED			0x02#define STAT_DETAIL_NOT_FOUND			0x03#define STAT_DETAIL_TARG_REMOVED		0x04#define STAT_DETAIL_VERSION_NOT_SUPPORTED 	0x05#define STAT_DETAIL_TOO_MANY_CONNECTIONS 	0x06#define STAT_DETAIL_MISSING_PARAMETER 		0x07#define STAT_DETAIL_NOT_INCLUDED 		0x08#define STAT_DETAIL_SESSION_TYPE 		0x09#define STAT_DETAIL_SESSION_NOT_EXIST 		0x0a#define STAT_DETAIL_INVALID_DURING_LOGIN	0x0b#define STAT_DETAIL_SERVICE_UNAVAILABLE 	0x01#define STAT_DETAIL_OUT_OF_RESOURCE 		0x02/*	Draft 20, Section 10.6.1 Response (field in TMF Response) */#define FUNCTION_COMPLETE           		0#define TASK_DOES_NOT_EXIST			1#define LUN_DOES_NOT_EXIST			2#define TASK_STILL_ALLEGIANT			3#define TASK_FAILOVER_NOT_SUPPORTED		4#define TASK_MANAGEMENT_FUNCTION_NOT_SUPPORTED	5#define FUNCTION_AUTHORIZATION_FAILED		6#define FUNCTION_REJECTED           		255/*	RFC 3720 Section 10.17.1 Reason (field in Reject Response) */#define REASON_DATA_DIGEST_ERR			0x02#define REASON_DATA_SNACK			0x03#define REASON_PROTOCOL_ERR			0x04#define REASON_COMMAND_NOT_SUPPORTED		0x05#define REASON_TOO_MANY_IMMEDIATE_COMMANDS	0x06#define REASON_TASK_IN_PROGRESS			0x07#define REASON_INVALID_SNACK			0x08#define REASON_INVALID_PDU_FIELD		0x09#define REASON_OUT_OF_RESOURCES			0x0a#define REASON_NEGOTIATION_RESET		0x0b#define REASON_WAITING_FOR_LOGOUT		0x0c/*	Draft 20, Section 10.14.1 Reason Code (field in Logout Request) */#define LOGOUT_REASON				0x7f#define LOGOUT_CLOSE_SESSION			0x00#define LOGOUT_CLOSE_CONNECTION			0x01#define LOGOUT_REMOVE_CONN_FOR_RECOVERY		0x02/*	Draft 20, Section 10.16.1 Type (field in SNACK Request) */#define SNACK_TYPE              0x0f#define DATA_R2T_SNACK          0x00#define STATUS_SNACK            0x01#define DATACK_SNACK            0x02#define R_DATA_SNACK            0x03                                                                                /* connection recovery related macros - SAI *//* ErrorRecoveryLevel values */#define SESSION_RECOVERY			0#define DIGEST_RECOVERY				1#define CONNECTION_RECOVERY			2#define CONNREC_NOT_SUPPORTED			0x02#define TIME2WAIT				0x0001#define TIME2RETAIN				0x0005/* enable bits in the session's snack_flag */#define DATA_SNACK_ENABLE       0x01#define STATUS_SNACK_ENABLE     0x02#define DATACK_SNACK_ENABLE     0x04/* For Text Parameter Negotiation *//* Draft 20, Section 5.3 Login Phase   "The default MaxRecvDataSegmentLength is used during Login."   Draft 20, Section 12.12 MaxRecvDataSegmentLength   "Default is 8192 bytes."*/#define MAX_TEXT_LEN 				8192#define TEXT_FUDGE_LEN				512/* SNACK for Error Recovery - SAI */#define SNACK					0x00000030/* iSCSI PDU formats */struct iscsi_init_scsi_cmnd {	/* Draft 20, Section 10.3 SCSI Command */	__u8 opcode;	__u8 flags;	__u16 rsvd1;	__u32 length;	__u64 lun;	__u32 init_task_tag;	__u32 xfer_len;	__u32 cmd_sn;	__u32 exp_stat_sn;	__u8 cdb[16];	__u32 header_digest;	/* holds header CRC if in use */};struct iscsi_targ_scsi_rsp {	/* Draft 20, Section 10.4 SCSI Response */	__u8 opcode;	__u8 flags;	__u8 response;	__u8 status;	__u32 length;	__u64 lun;		/* reserved */	__u32 init_task_tag;	__u32 target_xfer_tag;	__u32 stat_sn;	__u32 exp_cmd_sn;	__u32 max_cmd_sn;	__u32 exp_data_sn;	__u32 bidi_resid;	__u32 resid;	__u32 header_digest;	/* holds header CRC if in use */};struct iscsi_init_task_mgt_command {	/* Draft 20, Section 10.5 Task Management					   Function Request */	__u8 opcode;	__u8 function;	__u16 rsvd1;	__u32 length;		/* reserved */	__u64 lun;	__u32 init_task_tag;	__u32 ref_task_tag;	__u32 cmd_sn;	__u32 exp_stat_sn;	__u32 ref_cmd_sn;	__u32 exp_data_sn;	__u64 rsvd4;	__u32 header_digest;	/* holds header CRC if in use */};struct iscsi_targ_task_mgt_response {	/* Draft 20, Section 10.6 Task Management					   Function Response */	__u8 opcode;	__u8 flags;	__u8 response;	__u8 rsvd1;	__u32 length;		/* reserved */	__u64 lun;		/* reserved */	__u32 init_task_tag;	__u32 rsvd2;	__u32 stat_sn;	__u32 exp_cmd_sn;	__u32 max_cmd_sn;	__u32 rsvd4;	__u64 rsvd5;	__u32 header_digest;	/* holds header CRC if in use */};struct iscsi_init_scsi_data_out {	/* Draft 20, Section 10.7 SCSI Data-out */	__u8 opcode;	__u8 flags;	__u16 rsvd2;	__u32 length;	__u64 lun;	__u32 init_task_tag;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -