You are on page 1of 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 (for
example, 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 interface


and the signaling protocol used during communication.
The physical interface determines the number of devices that can
be attached to a bus or network loop, the maximum length of the
cables, 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 patterns
representing commands passing between the individual devices
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 target
device 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.
The Command Descriptor Block (CDB)

The standard defines the SCSI commands that are common to


more than one device model.
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.
All fixed length CDBs shall have an OPERATION CODE field as
their first byte and a CONTROL byte as their last byte.
Typical CDB for 6-byte commands
Typical CDB for 10-byte commands
Typical CDB for 12-byte commands
Operation code
The OPERATION CODE field contains the code value identifying
the 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 SERVICE
ACTION field containing a coded value identifying a function to be
performed under the more general command function specified in
the OPERATION CODE field.
Logical block address
The logical block addresses on a logical unit or within a volume
partition 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.
Allocation length
The ALLOCATION LENGTH field specifies the maximum number
of bytes that an application client has allocated for returned data.

Control
The CONTROL field has a consistently defined meaning across
all commands.
SCSI Commands

Divided into categories based on device type:


- All Device Types
- Direct Access Devices (disks)
- Sequential Access Devices (tapes)

Standardized command set and structure

Some commands mandatory, others optional


SCSI CDB: Byte 0

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 Reserved
5 12 Byte commands
6-7 Vendor Specific
SCSI CDB: Control byte

7 6 5 4 3 2 1 0
Vendor
Unique
Reserved Flag Link

Flag
Indicates Target should return Linked CCw/Flag Msg

Link
Used to continue I/O process across multiple commands
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.
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.
INQUIRY

Bit
Byte 7 6 5 4 3 2 1 0
0 Operation Code(12h)

1 Logical Unit Number Reserved EVPD (0)

2 Reserved
3 Reserved
4 Allocation Length : 47 (2Fh)

5 Reserved
INQUIRY DATA FORMAT

Bit
Byte 7 6 5 4 3 2 1 0
0 Peripheral Qualifier Peripheral Device Type (05h)
1 RMB Reserve
2 0 0 ANSI Version (2)
3 0 TIOP Reserve Response Format (2)
4 Additional Length : 42 (2Ah)
5 Reserve
6 Reserve
7 0 0 0 SYNC 0 Reserve 0 0
8 ~ 15 Vendor Name (8-byte ASCII code) (PIONEER)
16 ~ 31 Product Inquiry Data (16-byte ASCII code)
32 ~ 35 Revision Number (ASCII code) (“XXXX”)
36 Release Version (20h)
37 ~ 46 Revision Date (10-byte ASCII code) (“YYYY/MM/DD”)
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.
REQUEST SENSE (03H)

Bit
Byte 7 6 5 4 3 2 1 0
0 Operation Code(03h)

1 Logical Unit Number Reserved


2 Reserved
3 Reserved
4 Allocation Length (12h)

5 Reserved
SENSE DATA FORMAT
Bit
Byte 7 6 5 4 3 2 1 0
0 Valid Error code ( 70h / 71h )
1 Segment number (00h)
2 FileMK EOM ILI Reserve Sense Key
3 Information byte (MSB)
4 Information byte
5 Information byte
6 Information byte (LSB)
7 Additional Sense Data Length
8 Command-Specification Information (MSB)
9 Command-Specification Information
10 Command-Specification Information
11 Command-Specification Information (LSB)
12 Additional Sense Codes
13 Additional Sense Code Qualifier
14 Field Replaceable Unit Code
15 SKSV Sense-Key Specific (MSB)
16 Sense-Key Specific
17 Sense-Key Specific (LSB)
18 ~ N Additional Sense Bytes
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 the
media 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 affect
initiator performance.
TEST UNIT READY (00H)

Bit
Byte 7 6 5 4 3 2 1 0
0 Operation Code(00h)

1 Logical Unit Number Reserved


2 Reserved
3 Reserved
4 Reserved

5 Reserved
Command for all Device Types
Command name Operation Type
code
EXTENDED COPY 83h O
INQUIRY 12h M
LOG SELECT 4Ch O
LOG SENSE 4Dh O
MODE SELECT(6) 15h Z
MODE SELECT(10) 55h Z
MODE SENSE(6) 1Ah Z
MODE SENSE(10) 5Ah Z
MOVE MEDIUM ATTACHED a A7h Z
PERSISTENT RESERVE IN 5Eh Z
Command for all Device Types
Command name Operation Type
code
PERSISTENT RESERVE OUT 5Fh Z
PREVENT ALLOW MEDIUM 1Eh Z
REMOVAL
READ BUFFER 3Ch O
READ ELEMENT STATUS B4h Z
ATTACHED a
RECEIVE COPY RESULT 84h O
RECEIVE DIAGNOSTIC RESULT 1Ch O
RELEASE(10) 57h Z
RELEASE(6) 17h Z
REPORT DEVICE IDENTIFIER A3h/05h b O
REPORT LUNS A0h X
Command for all Device Types
Command name Operation Type
code
REQUEST SENSE 03h Z
RESERVE(10) 56h Z
RESERVE(6) 16h Z
SEND DIAGNOSTIC 1Dh Z
SET DEVICE IDENTIFIER A4h/06h b O
TEST UNIT READY 00h M
WRITE BUFFER 3Bh Z

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.
Command for all Device Types
a The MOVE MEDIUM ATTACHED and READ ELEMENT STATUS
ATTACHED operation codes shown here should be used by devices with
attached 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.
SCSI Disk Commands
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
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
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
Status Codes
Status Status Service Response
Code
00h GOOD TASK COMPLETE
02h CHECK CONDITION TASK COMPLETE
04h CONDITION MET TASK COMPLETE
08h BUSY TASK COMPLETE
10h INTERMEDIATE LINKED COMMAND COMPLETE
14h INTERMEDIATE-CONDITION LINKED COMMAND COMPLETE
MET
18h RESERVATION CONFLICT TASK COMPLETE
22h Obsolete -
28h TASK SET FULL TASK COMPLETE
30h ACA ACTIVE TASK COMPLETE

40h TASK ABORTED TASK COMPLETE


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 is


aborted by another SCSI initiator port
Sample SCSI Command
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 with Disconnect
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...
Status/00 (Good)
Message In/00 (Command Complete)
Bus Free
Sample SCSI Command with Parity Error
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 Queued Command
Bus Free
Arbitration/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 00
Message In/04 (Disconnect)
Bus Free
Arbitration/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 Linked Command
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
SCSI Sense Data

• 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 Format
0 Valid Error Code (0x70 or 0x71)
1 Segment Number
2 FM EOM ILI (R) Sense Key
3-6 Information Bytes
7 Additional Sense Length
8-11 Command Specific Information
12 Additional Sense Code
13 Additional Sense Code Qualifier
14 Field Replaceable Unit Code
15-17 Sense Key Specific
18-xx Additional Sense Bytes
SCSI Sense Keys
0x0: No Sense 0x8: Blank Check
0x1: Recovered Error 0x9: Vendor Specific
0x2: Not Ready 0xA: Copy Aborted
0x3: Medium Error 0xB: Aborted Command
0x4: 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 Exhausted
5/20/00: Illegal Command, Invalid Operation Code
D/47/00: Aborted Command, SCSI Parity Error
Unit Attention Condition
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.

You might also like