Linux scsi_debug driver, Diagram

Below is a diagram showing various components within the scsi_debug driver. Firstly, scsi_debug is a lower level driver so it is notionally "below" the SCSI midlevel driver. This means the scsi_debug driver is functionally equivalent to real adapter drivers such as the aic7xxx and advansys drivers. The scsi_debug driver can co-exist with other real and pseudo (e.g. ide-scsi) adapter drivers.

The black boxes within the scsi_debug driver are SCSI initiators. In the hardware world initiators are known as "host bus adapters" (HBAs) or just "hosts". Usually there will only be one host unless more than 7 SCSI devices are specified.

The scsi_debug driver simulates the requested number of SCSI devices which are the red boxes in the diagram. The SCSI devices that respond to commands issued by an initiator are known are as targets.  By default the targets that are simulated by the scsi_debug driver are disks. In SCSI parlance disks are "Direct Access Devices" [D.A.D.] The SCSI targets are given ids from 0 up to 6. All versions of the scsi_debug driver support a device at lun 0, later version will permit more than one lun per target.

The host number used is the next number that is available when the driver is loaded (either at kernel boot time or as a module). If more than one host is required then new host numbers are generated in ascending order. The channel number (sometimes known as bus number) of each host is 0.

Below is an example showing the scsi_debug driver being loaded as a module and asked to simulate 9 devices (with only one lun per target). The simulated scsi_debug devices have a model name of "scsi_debug" and commence in the 'cat /proc/scsi/scsi' output after the 3 real devices: an IBM disk, a PIONEER DVD and a YAMAHA cd writer. The host numbers 0, 3 and 4 have no associated devices connected to them. This makes host number 5 the first one that is available for the scsi_debug driver.

$ modprobe scsi_debug scsi_debug_num_devs=9
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 01 Lun: 00
  Vendor: IBM      Model: DNES-309170W     Rev: SA30
  Type:   Direct-Access                    ANSI SCSI revision: 03
Host: scsi2 Channel: 00 Id: 04 Lun: 00
  Vendor: PIONEER  Model: DVD-ROM DVD-303  Rev: 1.10
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 06 Lun: 00
  Vendor: YAMAHA   Model: CRW4416S         Rev: 1.0g
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 00 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 01 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 02 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 03 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 04 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 05 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi5 Channel: 00 Id: 06 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi6 Channel: 00 Id: 00 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi6 Channel: 00 Id: 01 Lun: 00
  Vendor: Linux    Model: scsi_debug       Rev: 0004
  Type:   Direct-Access                    ANSI SCSI revision: 02

Other SCSI device types can be simulated by changing the DEVICE_TYPE macro in scsi_debug.c . The currently supported SCSI commands responded to by the scsi_debug driver are skewed toward direct access devices such as disks. The driver has been used to simulate CD-ROM and Magneto-Optical devices but is not well suited to simulating tape or scanner devices.
 

 Back  to main scsi_driver page

Doug Gilbert (dgilbert@interlog.com)
Last updated: 16th March 2003