Friday 27 April 2012



                                                                          SCSI
What is SCSI?
Small Computer System Interface.
Introduced by ANSI in 1986.
An I/O bus interconnecting  computers and peripheral devices.
Why  SCSI?
Industry standard interface.
Generic interface for different  devices from different vendors.
Easy addition of new SCSI  devices.
Allows for faster data input and  output.
Ability to process multiple overlapped commands.
Various  SCSI standards .
Initial version as SCSI-1 .
Introduced in 1986.
Defined the basics of SCSI Bus.
Talked about cable length, signaling  characteristics.
Defined various Commands and  Transfer modes.

Revised and upgraded to SCSI-2 .
Approved in 1990.
Defined the new features as  enhancements to SCSI-1.
Incorporated the backward  compatibility with SCSI-1.
Recent version is SCSI-3
Much more features added to SCSI- 2.
SCSI-1
Defined the basic 8 bit data bus.
Maximum transfer speed was  limited to 5 MB/s.
Had difficulties in acceptance, as  many vendors implemented only  subsets of this protocol.
SCSI-2
Introduced Fast  SCSI
Doubling of the speed of data  transfer to 10MB/s with regular  SCSI.
Introduced Wide SCSI
Increasing the width of the SCSI bus  from 8 bits to 16/32 bits.
This increases the data throughput of  the devices.

More number of devices per bus
On buses with Wide SCSI, 16  devices are supported, as opposed to  8 for regular SCSI.
Improved cables and connections
Incorporated new higher density  connections.
Active termination which provided  the reliable termination of the bus.

Command queuing
Introduced the concept of having  multiple outstanding requests on the  bus at any point of time.
Additional command sets
Included new command sets to  support the use of more devices like  CD-ROMs, scanners and removable  media. SCSI-1 focussed more on  supporting hard disks.
Command set enhancements
SCSI-3
Ultra SCSI
Further doubling of system bus speed  resulting in data transfer rates up to  20MB/s for regular and 40MB/s for  Wide SCSI.
Serial SCSI
Uses Serial SCSI as one of its new  protocol standards (also called  FireWire).
Improved Cabling
Improvements over SCSI-2 for tuhe  use of Wide SCSI.
SCSI - Electrical Signal  types
Single Ended
Conventional signaling as used on  other buses.
A positive voltage indicates a logical  TRUE and no voltage FALSE.
Each signal is carried on one wire.
Flexible and cost effective, as is very  common.
Cable length, however, is highly  limited due to the effect of noise.
Differential
Uses differential signaling.
Each signal is carried by two wires,  each the mirror image of the other.
A positive voltage on one wire and  an equal negative voltage on the  other indicates a TRUE.
Zero voltage(electrical ground) on  both the wires indicates a FALSE.
Use of two conductors makes this  scheme more resilient and immune to  electrical noise.
Longer cable lengths possible.
Cost is much more higher than single  ended.
Back to the technical  jargon!!
Two different classifications
SPEED
BUS WIDTH
Speed of SCSI Bus
Regular
5MB/s data transfer rate.
Fast
10MB/s data transfer rate.
Ultra
20MB/s data transfer rate.
Bus width of SCSI Bus
Narrow
8 bit wide data bus.
Wide
16 bit wide data bus.
All in a nutshell
SCSI ID
Unique identification number  assigned to each device on the bus.
Used to identify devices on the  bus.
For Narrow SCSI, ID ranges from  0 to 7.
For Wide SCSI, ID ranges from 0  to 15.
ID determines the priority of the  device during arbitration.
Larger the ID, higher the priority.
Generally the host adapter is at ID  7 (highest priority).

Termination
Mandatory for SCSI devices.
Used to prevent signal reflections  from entering the SCSI bus.
Provided by using a terminator.

SCSI Bus
Communication on the SCSI bus is  allowed between only two SCSI  devices at any given time.
Of the two devices on the SCSI  bus, one acts as the initiator and  the other as target.
Initiator originates an operation.
Target performs the operation.
A device usually has a fixed role  as an initiator or target Some  devices can assume either role.
Certain SCSI bus functions are  assigned to the initiator and certain  to the target.
Data transfer takes place through  the mechanism of handshaking  signals.
SCSI Bus Signals
Total of 47 signals.
11 signals for control, 36 for data.
Important signals:
BSY - Bus being used.
SEL - Used by initiator/target to  select/reselect a target/initiator.
C/D - Control or Data information on  the bus.
I/O - Indicates the direction of data  transfer w.r.t the initiator.
MSG - Used during message phase.
REQ/ACK – Handshaking signals.
REQ –  request for an ACK  handshake
ACK- acknowledgement of a REQ.
DB - Data bus.
ATN- signal driven by an initiator  to indicate to a target that the  initiator has a message ready.
RST – Reset condition
SCSI Bus Phases
SCSI Architecture has 8 distinct  phases.
BUS FREE Phase.
ARBITRATION Phase.
SELECTION Phase.
RESELECTION Phase.
COMMAND Phase.
DATA Phase.
STATUS Phase.
MESSAGE Phase.
BUS FREE Phase
Indicates that there is no current  I/O process on the bus.
SCSI bus is available for  connection.
Devices detect this phase after the  BSY and SEL signals are both  false.
Generally this phase is entered,  when a target releases its BSY  signal.
ARBITRATION Phase
Allows one SCSI device to gain  control of the SCSI bus to initiate  or resume an I/O process.
Following steps occur while a  SCSI device gains control of the  SCSI bus:
Device waits for the BUS FREE  phase to occur.
After the Bus Free phase occurs, the  device waits for a specified amount  of time before driving any signal.
Device then arbitrates for the SCSI  bus by asserting the BSY signal and  its  own SCSI ID bit on the data bus.
Device waits for an arbitration delay,  before examining the data bus.
If a higher priority SCSI ID bit is  found on the data bus, the device has  lost its arbitration and releases the  BSY signal and returns to step 1.
Else, the device has won the  arbitration. It then asserts the SEL  signal.
SELECTION Phase.
Allows an initiator to select a  target to carryout target functions  (READ, WRITE).
I/O signal is negated during this  phase to differentiate it from  RESELECTION phase.
Selection is done by the following  mechanism:
Initiator sets the data bus to a value  that is the OR of its SCSI ID and the  target SCSI ID bit.
It then asserts the ATN signal  indicating a MESSAGE OUT Phase  is to follow.
Then the initiator releases the BSY  signal.
The target shall determine that it is  selected when the SEL and its SCSI  ID are high and BSY and I/O lines  are low.
It then scans the data bus to find the  initiator and asserts the BSY signal.
If more than two SCSI ID bits are on  the data bus, the target shall not  respond to selection.
RESELECTION Phase
Optional Phase
Allows a target to reconnect to an  initiator to continue some I/O  operation that was previously  started by the initiator and  suspended by the target.
Reselection follows the  mechanism stated below:
After Arbitration phase, the winning  device asserts the BSY and SEL  lines.
The winning SCSI device becomes a  target by asserting the I/O signal.
It then puts its SCSI ID on the data  bus OR ed with the ID of the  initiator.
The device then releases the BSY  signal.
The initiator, on seeing its ID on the  data bus along with SEL and I/O  being true and BSY being false,  determines that it is reselected.
It then finds the target by  scanning  the data bus.
The reselected initiator shall then  assert the BSY signal.
After the target finds that BSY signal  is asserted, it releases the SEL signal.
Upon this, the initiator releases the  BSY signal and the target asserts the  same.
The I/O then continues normally  until the target drops the SEL signal.
INFORMATION  TRANSFER Phases
Consists of the Command, Data,  Status and Message Phases.
C/D, I/O, MSG signals are used to  distinguish between the different  phases.
The information transfer phases  use one or more REQ/ACK  handshake signals to control the  information transfer.
During the information transfer  phases, the BSY signal shall be  True and the SEL signal, False.
Two modes of information  transfer.
Asynchronous Information Transfer.
Synchronous Information Transfer.
Asynchronous Information  Transfer
Target controls the direction of  data transfer through the I/O  signal.
I/O signal true indicates data  transfer from target to the initiator.
If I/O is true, target puts data on  the data bus, asserts REQ signal.
Target puts data on the data bus and  drives the REQ signal to true.
Initiator reads the data when it finds  the REQ signal true, then asserts the  ACK signal.
When ACK is true, target may  change the data on the data bus and  then release REQ.
When REQ becomes false, initiator  releases the ACK signal.
After this, the target then can either  continue the data transfer or stop it.
I/O signal false indicates data  transfer from initiator to the target
Initiator requests for data transfer by  asserting the REQ signal.
Initiator puts the data when it finds  the REQ signal true, then asserts the  ACK signal.
Target reads the data when it finds  the ACK signal true, then negates the  REQ signal.
When REQ is false, initiator may  change the data on the data bus and  then negate ACK.
After this, the target then can either  continue the request for data transfer  or stop it.
Synchronous Information  Transfer.
Used generally for Data Transfer  Phase.
Used only if a prior agreement is  reached using messaging phases.
The offset for REQ/ACK signals is  also reached upon then.
Offset specifies the number of  REQ signals the target sends in  advance of the number of ACK  signals received from the initiator.
For each REQ signal, one byte of  data is transferred and an ACK  pulse is sent.
Different phases during  Information Transfer
Command Phase
Allows the target to request  command information from the  initiator.
Data Phase
DATA IN - Allows the target to  request that data be sent to the  initiator from the target.
DATA OUT - Allows the target to  request that data be sent to the target  from the initiator.
Status Phase
Allows the target to request that  status information be sent to the  initiator from the target.
Message Phase
MESSAGE IN - Allows the target to  request that messages be sent to the  initiator from the target.
MESSAGE OUT - Allows the target  to request that messages be sent to  the target from the initiator.
Target invokes Message Out phase in  response to the Attention condition  from the initiator by ATN signal.
SCSI Bus Conditions.
Two conditions, which can cause  the SCSI device to perform certain  actions and alter the phase  sequence.
Attention Condition - Allows the  initiator to inform the target that it  has a message ready. Target reads it  by performing a Message Out Phase.
Reset Condition - Immediately clears  all SCSI devices from the bus. This  condition takes precedence over all  the other phases on the bus.
SCSI bus phase sequences.
Brief description about  messages
Allows communication between  target and initiator for interface  management.
Messages may be of one, two or  multiple bytes in length.
One or more messages may be sent  during a single MESSAGE Phase.
Some of the generally used  messages:
Abort - Sent from initiator to target  for clearing any I/O process.
Command Complete - Sent from  target to initiator to indicate the  completion of an I/O process and that  valid status has been sent to the  initiator.
Disconnect - Sent from T to I  indicating that the present connection  is being broken and will be later  resumed by invoking the  RESELECTION phase.
SCSI Commands
SCSI Commands follow the  pattern of the Command  Descriptor Block (CDB) to the  target.
First byte in any SCSI Command  should contain the valid opcode.
Opcodes are classified into  Optional, Mandatory and Vendor  specific.
Some fields in the CDB are  reserved and are set to zero.
If a target receives a CDB with the  reserved fields not being set to  zero, shall terminate the command  with a CHECK CONDITION  status.
Three groups – 0- 6 byte
                            1,2 -10 byte
                            5- 12 byte
3 and 4 reserved . 6 and 7 are  vendor specific.

Format of a 6-byte CDB

The transfer length field specifies  the amount of data to be  transferred, usually the number of  blocks.
Commands that use one byte for  the transfer length allow up to 256  blocks of data to be transferred by  one command.
SCSI Status
Shall be sent from the target to the  initiator during the STATUS Phase  at the completion of each  command.
General status conditions:
Good - Target successfully  completed the command.
Check condition - Indicates that  contingent allegiance occurred.
Busy - Indicates that target is busy.

Command Terminated - Returned  whenever the target terminates the  I/O process.
SCSI Commands
  Test unit ready : Queries device  to see if it is ready for data  transfers (disk spun up, media  loaded, etc.). Opcode = 0x00
   Inquiry : To obtain basic  information from a target device.  Opcode =12h
  Request sense : Returns any error  codes from the previous command  that returned an error status. 3h.

Send diagnostic  :requests the  target to perform a self test. Test is  standardized and response is  GOOD if all is well or CHECK  CONDITION status if test fails.  1Dh
Start/Stop unit : Spins disks up  and down, load/unload media. 1Bh
Read capacity : Returns storage  capacity. 25h

Format unit : Sets all sectors to all  zeroes, also allocates logical  blocks avoiding defective sectors.
ftp  Read  (four variants): Reads data  from a device.
 Write  (four variants): Writes data  to a device.

 Log sense : Returns current  information from log pages.
 Mode sense : Returns current  device parameters from mode  pages.
 Mode select : Sets device  parameters in a mode page.




No comments:

Post a Comment