The logical unit processes the commands sent by a SCSI initiator. A logical unit has two components, a device server and a task manager. The device server addresses client requests, and the task manager performs management functions. The SCSI initiator device is comprised of an application client and task management function, which initiates device service and task management requests.The I initiates command and task management requests. Depending on the transport protocol and physical interface used, the I may also initiate protocol or interface specific requests.Examples of I requests are: write, read data, format a portion if the disk or return information about the storage device.By contrast, T simply respond to I requests and generally do not originate requests of their own.
SCSI bus can be in only one phase at a given time.
ATN – Attention – Causes a msg out.
Associated with each T are one or more Logical Units(e.g disk drive) that are the ultimate recipient of I requests. A LU is an entity that implements one of the device functional models described in the SCSI command standards and process SCSI commands such as reading from or writing to the media.
Initiator ID - a number from 0 to 15 with the most common value being 7.Target ID - a number from 0 to 15LUN - a number that specifies a device addressable through a target.
Control byte is used for error handling (NACA bit), linked commands and vendor specific bits.sg_raw -r 1k /dev/sdc 12 00 00 00 60 00 (inqury)sg_inq /dev/sdcsg_raw /dev/sdc 28 00 00 00 01 00 00 00 01 00 (read)
The SCSI architecture provides several task management functions that can be used to affect the state of the one or more tasks in the target. The I sends the task management request to the targetand the T returns a response indicating the completion of the request.
The other part you are supposed to know is that the target has generated some sense data, which will explain why the error occurred. And this is where the CAC and Nexus part comes in – the target is supposed to keep the sense information based on the nexus, and that particular command.
While the CAC exists, the T will preserve the sense data for the I.Execution of all tagged I/O processes for the I_T_L nexus for which the CAC exists shall be suspended untill the CAC is cleared.
SCSI Bus Model Analogy
SCSI Parallel Bus Signals
50 Pin Bus (Narrow), 68 Pin Bus (Wide)
DB(0-7,P1) I/T 8 Bit Data Bus with Odd Parity
DB(8-15, P2) I/T 2nd 8 Bit Data Bus with Odd Parity (Wide Only)
REQuest T Asking for data byte to be sent/on bus
ACKnowledge I Indicates data byte on bus/read byte
ATtentionN I Indicates pending message for target
SELect I/T Indicates Selection/Reselection in progress
BuSY I/T Indicates SCSI Bus in use
ReSeT I Resets all SCSI devices
MeSsaGe T Indicates Message Byte
Cmd/Data T Indicates Command/Msg or Data
In/Out T Indicates Data Direction
Communication on the SCSI bus is allowed between only two SCSI
devices at any given time
When two SCSI devices communicate on the SCSI bus, one acts as an
initiator and the other acts as a target.
Initiator originates an operation and the target performs the
Each SCSI device has an SCSI ID bit assigned. When a device is
initialized, SCSI allows for automatic assignment of device IDs on the
bus, which prevents two or more devices from using the same SCSI
Bus SCSI ID Priority
Narrow 7, 6, 5, 4, 3, 2, 1, 0
Wide 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8
SCSI Bus Phases
Devices use this layer to recognize that the bus is available.Initiators or Targets use this layer to resolve bus contention.Initiators use this layer to select the targets to start an I/O process(O)This phase instructs the target what operation to perform(O).This protocol layer transfers data to or from the device.This protocol layer gives an update of the status of the operation(O)Targets use this layer to inform initiators to transmit a message.
SCSI Bus Phases – Flow Chart
Data In or Data
Waiting Phase Bus Control Phase Information Xfer Phase
Bus Phase Transpired I - T
single values represent SCSI ID's, otherwise values
are in hex bytes
1 00.000_000_000 Bus Free Detected 0000
2 26.032_853_700 Arbitration Start 7 0001
2 26.032_856_100 Arb_win 7 0002
2 26.033_514_100 (Atn Assertion) ATN 0003
2 26.033_521_700 Selection Start I → T 7 4 ATN 0004
2 26.033_522_600 Selection Complete I → T ATN 0005
2 26.034_161_850 I → T (Atn Negation) ATN 0006
2 26.034_833_950 Message Out I → T C0h 0007
2 26.039_035_750 Command Out I → T 08 00 01 00 01 00 0008
3 26.055_860_800 Data In I ← T 00 00 00 00 00 00 0009
3 26.055_862_300 I ← T 00 00 00 00 00 00 0010
3 26.056_494_450 I ← T 00 00 00 00 0011
4 26.056_894_350 Status In I ← T 00 0012
4 26.057_852_350 Message In I ← T 00 0013
1 26.058_426_300 Bus Free Detected 0014
1 No One Using Bus
2 Protocol to access peripheral and start process
3 Transfer data
4 Protocol to complete process
Are a physical/virtual peripherial device addressable through a traget.
Are the basic addressable unit on a target.
Have a default number of zero.
Must be sequentially numbered if there are more than one.
Max 8 Lus(64) per target controller in SCSI-2(SCSI-3).
One or more LU names
A Device Server
A Task Manager
One or more Task Sets each of which may contain zero or more untagged
tasks or a combination of zero or more tagged tasks and zero or more
A command is executed by sending a Command Descriptor Block(CDB) to the Target.
For each CDB:
The first byte of the CDB is the Operation Code.
The last byte of the CDB is the Control Byte.
The format of the Operation Code and Control Byte is identical for every SCSI
Command is the SCSI Universe.
CDBs come in various sizes, typically 6, 10, 12, or 16 bytes total.
Where to begin
How many blocks
10-byte READ command.
This command, if successful, will move one block (512 bytes) of data to the
host computer system, from logical block address 100h (hex).
SCSI Status Byte
02 CHECK CONDITION
04 CONDITION MET
14 INTERMEDIATE-CON MET
18 RESERVATION CONFLICT
28 TASK SET FULL
30 ACA ACTIVE
Any time a SCSI command is sent to a
The Initiator expect a completion
This status can reflect successful or un
successful completion of the
Sent during Status Phase, prior to
Command Complete Message, to indicate
success or failure of the command
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 SENSE KEYS
00 No Sense
01 Recovered Error
02 Not Ready
03 Medium Error
04 Hardware Error
05 Illegal Request
06 Unit Attention
07 Data Protect
08 Blank Check
09 Vendor Specific
0A Copy Abort
0B Aborted Cmd
0D Vol OverFlow
Unexpected sense: PD 04(e0xfc/s4) Path 4433221107000000,
CDB: a1 08 0b d0 00 00 4f c2 00 b0 00 ff,
Sense key ASC ASCQ
The message system allows communication between an I and T for the
purpose of INTERFACE management.
Messages are xfered during MESSAGE IN and MESSAGE OUT phases.
One or more messages may be sent during a single MESSAGE phase,
but a message may not be split between multiple MESSAGE phases.
The first msg byte after SELECTION phase shall be an IDENTIFY,
ABORT, or BUS DEVICE RESET msg. If T receives any other msg then
bus will go to BUS FREE state.
The IDENTIFY msg establishes a logical connection, or nexus between
the I and the specified LU, I_T_L nexus, within the target.
06h - ABORT
0Dh - ABORT TAG
24h - ACA QUEUE TAG
OCh - BUS DEVICE RESET
16h - CLEAR ACA
0Eh - CLEAR QUEUE
00h - COMMAND COMPLETES
SCSI Task Management Functions
Abort Task : Abort the specific task(ITLQ or ITL).
Abort Task Set : Abort all tasks for the issuing initiator(ITL).
Clear Task Set : Abort all tasks for the issuing initiator(TL).
Target Reset : Resets the specific target. All tasks in all the logical units
are reset and Unit Attention is set.
Logical Unit Reset : Reset the logical unit. All tasks in the specified logical
unit are reset and Unit Attention is set.
Clear ACA: Clears ACA condition at the specified logical unit.
Because SCSI Task management functions are not commands, the request is
not sent by using a CDB and the response is not indicated by SCSI status.
Contingent Allegiance Condition (CAC)
A Contingent Allegiance Condition is:
a Condition (state) that is Contingent (dependent) upon the Allegiance (connection)
between two entities, or components, in a SCSI-based system.
1. Make a connection (establish a Nexus)
2. Issue a command (from initiator to target)
3. Process the command (Target moves data to or from storage, if needed)
4. Receive GOOD status (00h code)
5. Close the connection (Nexus “goes away”)
What if we do not get GOOD status?
When something goes wrong, then you do NOT receive GOOD status – you most
often get back a CHECK CONDITION status (02h code) from the target. This is how
the initiator is informed that an error occurred.
SAM Error Recovery
Normal Auto Contingent Allegiance
Contingent Allegiance Condition
Auto Contingent Allegiance Condition
Contingent Allegiance Condition(SCSI-2)
Initiator 7 Initiator 6 Initiator n
Target xLogical Unit 0
Ian asked Tom to get a file from Larry, but Larry can’t find it. Tom must
inform Ian that the request has a CAC by returning a CC (02H) code
during the STATUS IN phase. Then Tom will set an internal CAC flag (per
LUN)associated with Ian’s SCSI ID and preserve it until it is cleared by
CAC shall be preserved for I_T_L nexus untill it is cleared.
a hard reset condition
an ABORT message
a BUS DEVICE RESET message
any subsequent commands for the I_T_L nexus, mostly
command will be REQUEST SENSE
Logical Unit 1
Logical Unit n
Auto Contingent Allegiance Condition (SCSI-3)
The ACA (NACA=1) condition shall exist within the task set
when the logical unit completes a command by returning a
CHECK CONDITION status.
Task set boundary.
Preserved untill it is cleared.
Sense data shall be returned using the “Autosense” feature.
Logical Unit Reset
a) LOGICAL UNIT RESET task management request
b) any logical unit reset event (ex: target hard reset)
1) Abort all tasks in the task set.
2) Clear -- ACA(NACA=1 i.e SCSI-3 ) or Contingent Allegiance(NACA=0 i.e SCSI-2)
3) Clear -- Disk Reservation
4) Data Xfer mode -- default async
5) Mode parameters -- restore last saved values
6) Unit Attention -- UA condition shall be set for all other devices.
Unit Attention Condition
Reports to I that operating mode of the T has changed from the last cmd sent to the T.
Reported on all SCSI cmds except INQURY.
Cmd it is reported with is not executed.
Each LU shall generated a UA condition, for each I, whenever the LU has been
1. a hard reset condition
2. by a power-on reset.
3. or a BUS DEVICE RESET message
LU shall also generate a UA condition for each I whenever one of the following
1. A removable medium may have been changed.
2. The mode parameters in effect for this I have been changed by another initiator.
3. The level or version of microcode has changed.
4. Tagged commands queued for the I were cleared by another I.
5. INQURY data has been changed.
6. The LU inventory has been changed.
7. A removable medium may have been changed.
8. The mode parameters in effect for this I have been changed by another initiator.
9. Tagged commands queued for this I were cleared by another I.
10. The version or level of microcode has been changed.