Iscsi and Sep: 91.560 Fall 2000
Iscsi and Sep: 91.560 Fall 2000
Iscsi and Sep: 91.560 Fall 2000
SCSI Concepts
The endpoint of most SCSI commands is a "logical unit" (LU) Examples of logical units include hard drives, tape drives, CD and DVD drives, printers and processors An "initiator" creates and sends SCSI commands to the target A "task" is a linked set of SCSI commands Some LUNs support multiple pending (queued) tasks. The target uses a "task tag" to distinguish between tasks A SCSI command results in an optional data phase and a response phase
In the data phase, information travels either from the initiator to the target, as in a WRITE command, or from target to initiator, as in a READ command
In iSCSI, the SCSI layer builds/receives SCSI CDB (Command Data Blocks) and relays/receives them with the remaining command execute parameters (cf. SAM-2) to/from the - iSCSI layer that builds/receives iSCSI PDUs and relays/receives them to/from - one or more TCP connections that form an initiator-target "session Communication between initiator and target occurs over one or more TCP connections
iSCSI Login
The purpose of iSCSI login is to:
enable a TCP connection for iSCSI use authenticate the parties authorize the initiator to send SCSI commands mark the connection as belonging to a iSCSI session
A session is used to identify to a target all the connections with a given initiator The targets listen on a well-known TCP port for incoming connections The initiator begins the login process by connecting to that well-known TCP port s part of the login process, the initiator and target MAY wish to authenticate each other
The login message includes a session ID - composed with an initiator part ISID and a target part TSID As part of the response the target will generate a TSID. Session specific parameters can be specified only for the first login of a session (TSID null)(e.g., the maximum number of connections that can be used for this session)
iSCSI Sessions
Thus a session is operational once it has at least one connection fter authentication and authorization, other parameters may be negotiated using the highly extensible Text Command message that allows arbitrary key:value pairs to be passed Any message sent on a TCP connection before this connection gets into full feature phase at the initiator should be rejected by the initiator A message reaching a target on a TCP connection before the full feature phase will be rejected with an iSCSI check condition
iSCSI Tags
Initiator tags for pending commands are unique initiatorwide for a session. Target tags for pending commands are unique target-wide for the session Each iSCSI session to a target is treated as if it originated from a different initiator
Message Formats
All multi-byte integers specified in formats defined in this material are to be represented in network byte order (i.e., big endian) Template Header and Opcodes
All iSCSI messages and responses have a header of the same length (48 bytes) Additional data may be added, as necessary, beginning with byte 48 The fields of Opcode and Length appear in all message and response headers The other most commonly used fields are Initiator Task Tag, Logical Unit Number, and Flags, which, when used, always appear in the same location of the header
Opcode
The Opcode indicates which iSCSI type of message or response is encapsulated by the header Valid opcodes for messages (sent by initiator to target) are:
0x00 NOP-Out Message (from initiator to target) 0x01 SCSI Command (encapsulates a SCSI Command Descriptor Block) 0x02 SCSI Task Management Command 0x03 Login Command 0x04 Text Command 0x05 SCSI Data (for WRITE operation) 0x09 Ping Command (from initiator to target) 0x0a Map Command
Opcode (contd)
Valid opcodes for responses (sent by target to initiator) are:
0x40 NOP-In Message (from target to initiator) 0x41 SCSI Response (contains SCSI status and possibly sense information or other response information) 0x42 SCSI Task Management Response 0x43 Login Response 0x44 Text Response 0x45 SCSI Data (for READ operation) 0x46 Ready To Transfer (RTT - sent by target to initiator when it is ready to receive data from initiator) 0x47 Asynchronous Event (sent by target to initiator to indicate certain special conditions) 0x48 Opcode Not Understood 0x49 Ping Response (from target to initiator) 0x4a Map Response
Length
The Length field indicates the number of bytes, beyond the first 48 bytes, that are being sent together with this message header. It is anticipated that most iSCSI messages and responses (not counting data transfer messages) will not need more than the 48 byte header, and hence the Length field will contain the value 0. It is expected that larger than 16 byte CDBs and parameter data will follow the header.
LUN
The LUN specifies the Logical Unit for which the command is targeted. If the command does not relate to a Logical Unit, this field is either ignored or may be used for some other purpose. According to [SAM2], a Logical Unit Number can take up to a 64-bit field that identifies the Logical Unit within a target device. The exact format of this field can be found in the [SAM2] document.
Byte
| 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x01) |I I|R| Rsrvd |A| Rsvrd |ATTR | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8| Logical Unit Number (LUN) | + + 12| | +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Expected Data Transfer Length | +---------------+---------------+---------------+---------------+ 24| CmdRN | +---------------+---------------+---------------+---------------+ 28| ExpStatRN | +---------------+---------------+---------------+---------------+ 32/ SCSI Command Descriptor Block (CDB) / / / +---------------+---------------+---------------+---------------+ 48/ Additional Data (Command Dependent) / / / +---------------+---------------+---------------+---------------+
SCSI Command
Flags
The flags field for a SCSI Command consists of two bytes. Byte 1 - iSCSI flags b7-6 (I) Immediate Data from initiator to target (command parameters/ write/control); this field indicates also how to interpret the length field: 00 - Immediate Data Length = Length; CDB Length = 16 01 - CDB Length = Length+16; Immediate Data Length = 0 10 - Immediate Data Length = Length 24 MSB; CDB Length = 16 + Length(8 LSB) 11 - Immediate Data Length = Length 16 MSB; CDB Length = 16 + Length(16 LSB) b5 (R) set when data is expected to flow from target to initiator (read). b0-4 Reserved (should be 0) Byte 2 - SCSI flags b7 (A) set to turn off Autosense for this command b3-6 Reserved (should be 0) b0-2 used to indicate Task Attributes.
Additional Details
Task Attributes
0 1 2 3 4 Untagged Simple Ordered Head of Queue ACA
Command Reference Number (CmdRN) enables ordered delivery ExpStatRN - Expected Status Reference Number: Responses up to ExpStatRN -1 (mod 2**32) have been received The Expected Data Transfer Length field states the number of bytes of data that the initiator expects will be sent for this (READ or WRITE) SCSI operation in SCSI Data packets
Command-Data
Some SCSI commands require additional parameter data to accompany the SCSI command. This data may be placed beyond the 48-byte boundary of the iSCSI header. Alternatively user data can be placed in the same PDU (in both cases we talk about immediate data)
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x41) | Rsvd(0) |O|U| Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8| Reserved (0) | + + 12| | +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Residual Count | +---------------+---------------+---------------+---------------+ 24| StatRN | +---------------+---------------+---------------+---------------+ 28| ExpCmdRN | +---------------+---------------+---------------+---------------+ 32| MaxCmdRN | +---------------+---------------+---------------+---------------+ 36| Command Status|iSCSI Status | Reserved (0) | +---------------+---------------+---------------+---------------+ 40| Res_len | Sense_len +---------------+---------------+---------------+---------------+ 44| Reserved (0) | +---------------+---------------+---------------+---------------+ 48/ Response and/or sense Data (optional) / +/ / +---------------+---------------+---------------+---------------+
SCSI Response
Flags
Byte 1
b0 (U) set for Residual Underflow. In this case, the Residual Count indicates how many bytes were not transferred out of those expected to be transferred. b1 (O) set for Residual Overflow. In this case, the Residual Count indicates how many bytes could not be transferred because the initiator's Expected Data Transfer Length was too small.
b2-7 not used (should be set to 0) The Residual Count field is valid only in case either the Residual Underflow bit or Residual Overflow bit is set The Command Status field is used to report the SCSI status of the command The iSCSI Status field is used to report the status of the command before it was sent by the target to the LUN
Additional Details
iSCSI Status
0 Good status 1 iSCSI check If the iSCSI field is not 0 the command status will indicate CHECK CONDITION
NOP-Out Message
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x00) |P| Reserved (0)| Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 28| ExpStatRN | +---------------+---------------+---------------+---------------+ 32/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48
P - poll bit
NOP-In Message
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x40) |P| Reserved (0)| Reserved(0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 28| ExpCmdRN | +---------------+---------------+---------------+---------------+ 32| MaxCmdRN | +---------------+---------------+---------------+---------------+ 36/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48 P - poll bit
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x47) | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8| Logical Unit Number (LUN) | + + 12| | +---------------+---------------+---------------+---------------+ 16/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 24| StatRN | +---------------+---------------+---------------+---------------+ 28| ExpCmdRN | +---------------+---------------+---------------+---------------+ 32| MaxCmdRN | +---------------+---------------+---------------+---------------+ 36|SCSI Event Ind |iSCSI Event Ind| Reserved (0) | +---------------+---------------+---------------+---------------+ 40/ Reserved (0) / / / +---------------+---------------+---------------+---------------+ 48/ Sense Data / +/ / +---------------+---------------+---------------+---------------+
Asynch Event
iSCSI Event
The codes returned for iSCSI Asynchronous Events are:
2 1 2 3 4 Target is being reset An error condition was encountered after command completion A newly initialized device is available Some other type of unit attention condition has occurred An asynchronous event has occurred
Sense Data accompanying the report identifies the condition. The Length parameter is set to the length of the Sense Data
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x42) | Response | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8| Logical Unit Number (LUN) | + + 12| | +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Reserved (0) | +---------------+---------------+---------------+---------------+ 24| StatRN | +---------------+---------------+---------------+---------------+ 28| ExpCmdRN | +---------------+---------------+---------------+---------------+ 32| MaxCmdRN | +---------------+---------------+---------------+---------------+ 36| Response | Reserved (0) | +---------------+---------------+---------------+---------------+ 40/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x46) | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ RTT 8| Reserved (0) | + + 12| | +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Desired Data Transfer Length | +---------------+---------------+---------------+---------------+ 24| Buffer Offset | +---------------+---------------+---------------+---------------+ 28| ExpCmdRN | +---------------+---------------+---------------+---------------+ 32| MaxCmdRN | +---------------+---------------+---------------+---------------+ 36| Target Transfer Tag | +---------------+---------------+---------------+---------------+ 40/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x05) | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | SCSI +---------------+---------------+---------------+---------------+ Data 8| Buffer Offset | +---------------+---------------+---------------+---------------+ 12| Transfer Tag | +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Reserved (0) | +/ / +---------------+---------------+---------------+---------------+ 28| CmdRN | +---------------+---------------+---------------+---------------+ 28| ExpStatRN | +---------------+---------------+---------------+---------------+ 32/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48/ Payload / +/ / +---------------+---------------+---------------+---------------+
The typical SCSI Data packet for READ (from target to initiator) has the following format:
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x45) | (0) |S|O|U| Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8| Buffer Offset | +---------------+---------------+---------------+---------------+ 12| Transfer Tag | +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Residual Count | +---------------+---------------+---------------+---------------+ 24| StatRN | +---------------+---------------+---------------+---------------+ 28| ExpCmdRN | +---------------+---------------+---------------+---------------+ 32| MaxCmdRN | +---------------+---------------+---------------+---------------+ 36| Command Status|iSCSI Status | Reserved (0) | +---------------+---------------+---------------+---------------+ 40/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48/ Payload / +/ / +---------------+---------------+---------------+---------------+
Text Command
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x04) | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 16| Initiator Task Tag | +---------------+---------------+---------------+---------------+ 20| Reserved (0) | +---------------+---------------+---------------+---------------+ 24| CmdRN | +---------------+---------------+---------------+---------------+ 28| ExpStatRN | +---------------+---------------+---------------+---------------+ 32/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48/ Text / +/ / +---------------+---------------+---------------+---------------+
Text Command
The Text Command is provided to allow the exchange of information and for future extensions. It permits the initiator to inform a target of its capabilities or to request some special operations Length
The length, in bytes, of the Text field
Text
The initiator sends the target a set of key:value pairs in UTF-8 Unicode format. The key and value are separated by a ':' (0x3A) delimiter. Many key:value pairs can be included in the Text block by separating them with null ' ' (0x00) delimiter
Text Response
The Text Response message contains the responses of the target to the initiator's Text Command. The format of the Text field matches that of the Text Command. The Text Response field contains responses in the same key:value format as the Text Command
The target and initiator can then perform some advanced operations based on their common capabilities. Manufacturers may introduce new keys by prefixing them with their (reversed) domain name, for example, com.foo.bar.do_something:0000000000000003 Any key that the target does not understand may be ignored without affecting basic function
Login Command
Byte / 0 | 1 | 2 | 3 | / | | | | |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| +---------------+---------------+---------------+---------------+ 0| Opcode (0x03) | Login Type | Reserved (0) | +---------------+---------------+---------------+---------------+ 4| Length | +---------------+---------------+---------------+---------------+ 8| CID | RecoverCID or 0 | +---------------+---------------+---------------+---------------+ 12| Reserved (0) | +---------------+---------------+---------------+---------------+ 16| ISID |TSID | +---------------+---------------+---------------+---------------+ 24| InitCmdRN or 0 | +---------------+---------------+---------------+---------------+ 28/ Reserved (0) / +/ / +---------------+---------------+---------------+---------------+ 48/ Login Parameters in Text Command Format / +/ / +---------------+---------------+---------------+---------------+
Login Type
Five types of logins are supported: clear text, RSA (Rivest Shamir Adelman) one way (to authenticate the client only), RSA two way (to authenticate both the server and the client), and implicit (in which a separate security protocol provides the credentials). The parameter "AccessID" [AC] is used to identify the specific initiator. 0 no authentication 1 implicit 2 clear text password authentication 3 RSA 1 way 4 RSA 2 way