SCSI protocols. See Section 13.2 of our book for more.
Bus is independent of the devices on it.
Devices may be initiator, target, or both.
Initiator - device that proactively uses bus.
Multiple initiators possible, requiring arbitration.
Target - passive device being acted on.
Host recommended - device acting primarily as an initiator.
Each device is assigned a logical unit number, LUN.
Host interface card often assigned id 1 (?).
Original done with jumpers, often done at the software level.
Device usually has one lun but can have more.
How devices interract :
Initiator starts an interaction with a target by sending a command
in a Command Descriptor Block (operator byte and 5 more or bytes of command
parameters).
Target responds with Status, Success, Busy, Error or check condition.
If initiator detects an error,
perform additional communication to determine more about the error.
Else if busy
Possibly initiate altenative task on another target
Otherwise
Perform task.
Logical protocol (task phases) :
Bus Free - is bus busy? Check BSY control line.
Arbitration - bid for control of bus. ID used to assert authority, with
higher id winning. Devices that are always targets should have low ids.
Selection - target device's address put on data lines. (SEL)lect line
activated.
Target responds by activating BSY line. Initiator deactivates SEL.
Command - when targets sees SEL deactivated, it indicates ready for command
on (C)ommand/(D)ata and the (REQ)uest lines.
Once detected by iniator, initator places command byte on data line and
asserts (ACK)nowledgement.
Target toggles ACK when command byte successfully retrieved. Subsequent
command argument bytes passed by toggling ACK for each byte.
It is possible to release the bus while target device activates and seeks
out targeted storage area, but much of the previous handshaking would
have to be re-performed to re-establish inter-connectivity.
Data - Transfer of data between initiator and target.
Set C/D line to data. Using data lines, input/output control, REQ, and
ACK, pass data in desired direction.
Status - Once data transferred, target toggles C/D to control and asserts
REQ to inform initiator it has completed task.
Message - when target senses initiator's recognition of its state (ACK?),
the target places "command complete" status on data lines and asserts MSG
line.
When initiator detects this, it clears the various status lines marking
the bus as free.
Reselection - if "connection" freed because bus was released with drive
spun up or tape reader searched for records, and now is ready to complete
the task, reselection allows initiator to perform the arbitration step but
skip the selection and command steps to complete the task.
The interaction on the bus are actual byte/word values without clock line or
clock encoding of data (RLL). The various actions on the bus have fairly tight
timing.
If one of the "phases" listed above does not complete in the defined time,
it is considered an error and the phase is repeated from the beginning.
Synchronous transfers possible on devices that are fast enough. The data
step is done as a sequence of data transfers based on an agreed on time
per bytes with a single REQ/ACK performed at end of the block of data.
CRC check of data helpful in confirming good transfer.
There are about 60 commands available and they are designed to be generic
enough to be applicable in some combination to any device likely to be
attached to the bus.
* Similar to channel programming on a mainframe.
Some more common command activities.
Test unit ready - query target to see if it is in responsive state.
Inquiry - get basic information on target.
Request sense - get error code on device that returned error status.
Start/stop - spin device up/down or load/eject media.
Send/Receive diagnostics
Format Unit
Read/Write (6 variants of read and 5 of write).
Variants related to changes in LBA sizes as disks evolve.
Mode sense/select - read/set various device configuration parameters -
Some information retrieved is standardized.
But device specific information would by passed to/from a device driver for
correct interpretation and setting.
Note that SCSI buses are designed to transmit data at certain clock speeds.
However, the target itself may take a long time to determine its own status,
such as a tape drive seeking a particular file.
NCQ provides a way to keep bus busy while waiting for response. NCQ allows
"controller" to rearrange the tasks to optimize the queue to the speed of
the task.
Serial SCSI