Upload
kathar-basha
View
226
Download
0
Embed Size (px)
Citation preview
8/7/2019 scsi command
1/42
SCSI Command Protocol
Communication Interface
When two devices are connected across a bus or a network, their
interaction is accomplished through a communication interface (forexample, a parallel SCSI bus, a Fibre Channel arbitrated loop, or
an Ethernet network).
The communication interface allows multiple devices to share
connections, yet operate and exchange data independently.
The communication interface is comprised of the physical interfaceand the signaling protocol used during communication.
8/7/2019 scsi command
2/42
The physical interface determines the number of devices that can
be attached to a bus or network loop, the maximum length of thecables, and the physical characteristics of the cable itself (for
example, the number of wires, shielding, and so forth).
The signaling protocol defines the electrical characteristics and
timing of signals carried by the cable, the message system
requirements, transmission speeds and maximum data transfer rates,
as well as the encoding and decoding of the individual bit patternsrepresenting commands passing between the individual devices
8/7/2019 scsi command
3/42
Command Protocol
The format and content of the information carried over the
communication interface, as well as how each device uses and
responds to the information, is governed by a command protocol.
The command protocol determines how the host (or initiator)
interacts with the target device (for example, the tape drive) by
issuing commands, transferring data, and responding to status
information.
The command protocol also defines the individual bits in the
command data passing between the individual devices. The targetdevice responds to commands from the host by performing the
requested operation (for example, writing or reading data on
magnetic tape) and returning status information to the host.
8/7/2019 scsi command
4/42
The Command Descriptor Block (CDB)
The standard defines the SCSI commands that are common to
more than one device model.
8/7/2019 scsi command
5/42
CDB usage and structure
A command is communicated by sending a command descriptor
block (CDB) to the device server. For several commands, the CDB
is accompanied by a list of parameters in the Data-Out Buffer.
There are fixed length CDB formats and variable length CDB formats
If device receives CDB containing an operation code that is invalid
or not supported, it shall return CHECK CONDITION status with
the sense key set to ILLEGAL REQUEST and an additional sense
code of INVALID COMMAND OPERATION CODE.
8/7/2019 scsi command
6/42
All fixed length CDBs shall have an OPERATION CODE field astheir first byte and a CONTROL byte as their last byte.
8/7/2019 scsi command
7/42
Typical CDB for 6-byte commands
8/7/2019 scsi command
8/42
Typical CDB for 10-byte commands
8/7/2019 scsi command
9/42
Typical CDB for 12-byte commands
8/7/2019 scsi command
10/42
Operation code
The OPERATION CODE field contains the code value identifyingthe operation being requested by the CDB.
The OPERATION CODE field has a consistently defined
meaning across all commands. The standard specifies the operation
code values used by the commands defined herein.
Service action
All CDB formats except the 6-byte format provide for a SERVICEACTION field containing a coded value identifying a function to be
performed under the more general command function specified in
the OPERATION CODE field.
8/7/2019 scsi command
11/42
Logical block address
The logical block addresses on a logical unit or within a volumepartition shall begin with block zero and be contiguous up to the last
logical block of that logical unit or within that partition.
Transfer length
The TRANSFER LENGTH field specifies the amount of data to be
transferred, usually the number of blocks.
Parameter list length
The PARAMETER LIST LENGTH field is used to specify the
number of bytes sent from the Data-Out Buffer.
8/7/2019 scsi command
12/42
Allocation length
The ALLOCATION LENGTH field specifies the maximum numberof bytes that an application client has allocated for returned data.
Control
The CONTROL field has a consistently defined meaning across
all commands.
8/7/2019 scsi command
13/42
8/7/2019 scsi command
14/42
7 6 5 4 3 2 1 0
Group Code Command Code
Group Code Command Description
0 6 Byte Commands
1 10 Byte Commands
2 10 Byte Commands
3-4 Reserved5 12 Byte commands
6-7 Vendor Specific
SCSI CDB: Byte 0
8/7/2019 scsi command
15/42
7 6 5 4 3 2 1 0
Vendor
UniqueReserved Flag Link
Flag
Indicates Target should return Linked CCw/Flag Msg
Link
Used to continue I/O process across multiple commands
SCSI CDB: Control byte
8/7/2019 scsi command
16/42
Summary of commands implemented by all SCSI devices
This standard defines three commands that all SCSI devices shall
implement - INQUIRY, REQUEST SENSE, and TEST UNIT
READY.
These commands are used to configure the system, to test devices,and to return important information concerning errors and exception
conditions.
8/7/2019 scsi command
17/42
Using the INQUIRY command
The INQUIRY command may be used by an application client to
determine the configuration of the logical unit.
Device servers respond with information that includes their type
and standard version and may include the vendor's identification,model number and other information.
8/7/2019 scsi command
18/42
5
4
3
2
Logical Unit Number1
Operation Code(12h)0
01234567Byte
Bit
Reserved
Reserved
Reserved
Allocation Length : 47 (2Fh)
Reserved EVPD (0)
INQUIRY
8/7/2019 scsi command
19/42
8/7/2019 scsi command
20/42
Using the REQUEST SENSE command
Whenever a command completes with a CHECK CONDITION
status and auto-sense data is not provided, the application client that
received the error status should issue a REQUEST SENSE command
to receive the sense data describing the cause of the condition.
8/7/2019 scsi command
21/42
REQUEST SENSE (03H)
5
4
3
2
Logical Unit Number1
Operation Code(03h)0
01234567Byte
Bit
Reserved
Reserved
Reserved
Allocation Length (12h)
Reserved
8/7/2019 scsi command
22/42
SENSE DATA FORMAT
54
3
2
10
01234567Byte
Bit
Sense KeyReserve
Segment number (00h)
12
11
1098
6
7
Valid Error code ( 70h / 71h )
FileMK ILIEOM
18 ~ N17
1615
1413
Information byte (MSB)
Information byte
Information byte
Information byte (LSB)
Additional Sense Data Length
Command-Specification Information (MSB)Command-Specification Information
Command-Specification Information
Command-Specification Information (LSB)
Additional Sense Codes
Additional Sense Code QualifierField Replaceable Unit Code
SKSV Sense-Key Specific (MSB)
Sense-Key Specific
Sense-Key Specific (LSB)
Additional Sense Bytes
8/7/2019 scsi command
23/42
Using the TEST UNIT READY command
The TEST UNIT READY command allows an application client to
poll a logical unit until it is ready without the need to allocate space
for returned data.
The TEST UNIT READY command may be used to check themedia status of logical units with removable media. Device servers
should respond promptly to indicate the current status of the
SCSI device, delays to achieve GOOD status may adversely affectinitiator performance.
8/7/2019 scsi command
24/42
TEST UNIT READY (00H)
5
4
3
2
Logical Unit Number1
Operation Code(00h)0
01234567Byte
Bit
Reserved
Reserved
Reserved
Reserved
Reserved
8/7/2019 scsi command
25/42
Command for all Device Types
Z5EhPERSISTENT RESERVE IN
ZA7hMOVE MEDIUM ATTACHED aZ5AhMODE SENSE(10)
Z1AhMODE SENSE(6)
Z55hMODE SELECT(10)
Z15hMODE SELECT(6)
O4DhLOG SENSE
O4ChLOG SELECT
M12hINQUIRYO83hEXTENDED COPY
TypeOperation
code
Command name
8/7/2019 scsi command
26/42
8/7/2019 scsi command
27/42
Command for all Device Types
Z16hRESERVE(6)
Z1DhSEND DIAGNOSTIC
OA4h/06h bSET DEVICE IDENTIFIER
M00hTEST UNIT READY
Z3BhWRITE BUFFER
Z03hREQUEST SENSEZ56hRESERVE(10)
TypeOperation
code
Command name
Key: M = Command implementation is mandatory
O = Command implementation is optional
X = Command implementation is defined in a previous
standard
Z = Command implementation is device type specific.
8/7/2019 scsi command
28/42
Command for all Device Types
a The MOVE MEDIUM ATTACHED and READ ELEMENT STATUS
ATTACHED operation codes shown here should be used by devices withattached medium changers.b This command is defined by a combination of operation code and service
action. The operation code value is shown preceding the slash and the service
action value is shown after the slash.
8/7/2019 scsi command
29/42
Force Reserve [0xE4]
- Force Reservation, overriding normal SCSI protocol
Format Unit [0x04]
- Formats disk, according to Mode Parameters
Prefetch [0x34]- Read disk, place data into cache
Read (6,10) [0x08, 0x28]
- Read disk, transfer data to Initiator
Read Capacity [0x25]
- Returns size of disk, in # LBAs
SCSI Disk Commands
8/7/2019 scsi command
30/42
Reassign Blocks [0x07]
- Remaps specified LBA(s)
Reserve, Release [0x16, 0x17]
- Locks Disk for exclusive access by this Initiator
Rezero Unit [0x01]- Seeks to LBA 0
Start/Stop Unit [0x1B]
- Command to spin up/down disk
Synchronize Cache [0x35]
- Flush cache to disk, cache remains enabled
SCSI Disk Commands
8/7/2019 scsi command
31/42
Verify [0x2F]
- Verify LBA(s) on disk with passed data
Write (6,10) [0x0A, 0x2A]
- Write specified LBA(s) with passed data
Write and Verify [0x2E]- Treated the same as a Write command
Write Same [0x41]
- Writes passed sector to multiple LBA(s) on disk
SCSI Disk Commands
8/7/2019 scsi command
32/42
Status Codes
TASK COMPLETETASK ABORTED40h
TASK COMPLETEACA ACTIVE30h
TASK COMPLETETASK SET FULL28h
-Obsolete22h
TASK COMPLETERESERVATION CONFLICT18h
LINKED COMMAND COMPLETEINTERMEDIATE-CONDITIONMET
14h
LINKED COMMAND COMPLETEINTERMEDIATE10h
TASK COMPLETEBUSY08h
TASK COMPLETECONDITION MET04h
TASK COMPLETECHECK CONDITION02h
TASK COMPLETEGOOD00h
Service ResponseStatusStatusCode
8/7/2019 scsi command
33/42
Status shall be sent from the device server to the application client
whenever a command ends with a service response of TASK
COMPLETE or LINKED COMMAND COMPLETE.
GOOD. This status indicates that the device server has successfully
completed the task.
CHECK CONDITION. This status indicates that sense data has
been delivered in the buffer defined by the Sense Data argument
BUSY. This status indicates that the logical unit is busy.
TASK ABORTED. This status shall be returned when a task isaborted by another SCSI initiator port
8/7/2019 scsi command
34/42
Bus Free
Arbitration/80 (7)
Select w/ATN/81 (7,0)
Message Out/80 (Identify)
Command/08 (Read) 00 34 22 01 00
Data In/00 01 02 03 04 05 06 07...
Status/00 (Good)Message In/00 (Command Complete)
Bus Free
Sample SCSI Command
8/7/2019 scsi command
35/42
Bus Free
Arbitration/80 (7)
Select w/ATN/81 (7,0)
Message Out/C0 (Identify)
Command/08 (Read) 00 34 22 01 00
Message In/04 (Disconnect)
Bus FreeArbitration/01 (0)
Reselection/81 (7,0)
Message In/80 (Identify)
Data In/00 01 02 03 04 05 06 07...Status/00 (Good)
Message In/00 (Command Complete)
Bus Free
Sample SCSI Command with Disconnect
8/7/2019 scsi command
36/42
Bus Free
Arbitration/80 (7)
Select w/ATN/81 (7,0)
Message Out/C0 (Identify)Command/08 (Read) 00 34 22 01 00
Message In/04 (Disconnect)
Bus Free
Arbitration/01 (0)
Reselection/81 (7,0)
Message In/80 (Identify)
Data In/00 01 02 03 04* 05+ 06+ 07+...
Message Out/05 (Initiator Detected Error)
Message In/03 (Restore Pointers)Data In/00 01 02 03 04 05 06 07...
Status/00 (Good)
Message In/00 (Command Complete)
Bus Free
Sample SCSI Command with Parity Error
8/7/2019 scsi command
37/42
Bus FreeArbitration/80 (7)Select w/ATN/81 (7,0)Message Out w/ATN /C0 (Identify)Message Out w/ATN /20 (Simple Tag)Message Out/00 (Tag ID)Command/08 (Read) 00 34 22 01 00Message In/04 (Disconnect)
Bus FreeArbitration/01 (0)Reselection/81 (7,0)Message In/80 (Identify)Message In/20 (Simple Tag)
Message In/00 (Tag ID)Data In/00 01 02 03 04 05 06 07...Status/00 (Good)Message In/00 (Command Complete)
Bus Free
Sample SCSI Queued Command
8/7/2019 scsi command
38/42
Bus Free
Arbitration/80 (7)
Select w/ATN/81 (7,0)
Message Out/80 (Identify)
Command/08 (Read) 00 34 22 01 01
Data In/00 01 02 03 04 05 06 07...
Status/10 (Intermediate/Good)Message In/0A (Linked Command Complete)
Command/08 (Read) 03 22 68 01 00
Data In/00 01 02 03 04 05 06 07...
Status/00 (Good)Message In/00 (Command Complete)
Bus Free
Sample SCSI Linked Command
8/7/2019 scsi command
39/42
A special data packet specifying error status and location(s)
Separate copy maintained by Target for each Initiator
Retrieved by Request Sense command
Must be retrieved immediately after a CHECK CONDITION,
or sense data is lost
All queued commands are suspended after CHECK CONDITION,until Sense Data is retrieved (Contingent Allegiance)
SCSI Sense Data
8/7/2019 scsi command
40/42
0 Valid Error Code (0x70 or 0x71)
1 Segment Number
2 FM EOM ILI (R) Sense Key3-6 Information Bytes
7 Additional Sense Length
8-11 Command Specific Information12 Additional Sense Code
13 Additional Sense Code Qualifier
14 Field Replaceable Unit Code15-17 Sense Key Specific
18-xx Additional Sense Bytes
SCSI Sense Data Format
8/7/2019 scsi command
41/42
0x0: No Sense 0x8: Blank Check
0x1: Recovered Error 0x9: Vendor Specific
0x2: Not Ready 0xA: Copy Aborted
0x3: Medium Error 0xB: Aborted Command0x4: Hardware Error 0xC: Equal
0x5: Illegal Request 0xD: Volume Overflow
0x6: Unit Attention 0xE: Miscompare
0x7: Data Protect 0xF: Reserved
Sense Data Shorthand: SKey/ASC/ASCQ
3/11/01: Medium Error, Read Retries Exhausted5/20/00: Illegal Command, Invalid Operation Code
D/47/00: Aborted Command, SCSI Parity Error
SCSI Sense Keys
8/7/2019 scsi command
42/42
First sense packet after any of the following:
- Power-on
- Reset
- Mode/Inquiry parameters changed
- Runtime firmware change
- Commands cleared by another initiator
Reports to initiator that operating mode of the Target has changed
from the last command sent to the Target.
Reported on all SCSI Commands except Inquiry.
Command it is reported with is not executed.
Unit Attention Condition