IBM Virtual SCSI Target (ibmvstgt)
==================================


Introduction
------------
The virtual SCSI (VSCSI) protocol as defined in [2] is a protocol that allows
one logical partition (LPAR) to access SCSI targets provided by another LPAR.
The LPAR that provides one or more SCSI targets is called the VIO server or
VIOS. The ibmvstgt driver is a VIOS driver that makes it possible to access
exported target devices via the VSCSI protocol.

Setup
-----
After having configured the LPARs, boot the LPARs and load the ibmvstgt kernel
module in the VIOS. After the target driver has been loaded, verify that a
message similar to the following appears in the initiator kernel log:

ibmvscsi 30000028: partner initialized
ibmvscsi 30000028: host srp version: 16.a, host partition VIOS3-P6 (40), OS 2, max io 67108864
ibmvscsi 30000028: sent SRP login
ibmvscsi 30000028: SRP_LOGIN succeeded

In the above log messages, the number 30000028 refers to the VIOS. The last
two digits, 0x28, refer to the VIOS partition number (0x28 = 40).

The next step is to decide which SCSI devices to export. Here is an example of
a configuration in which 16 RAM disks have been exported (see also [1] for
more information):

# ls /sys/kernel/scst_tgt/devices
2:0:0:0 ram000  ram001  ram002  ram003  ram004  ram005  ram006  ram007
ram008  ram009  ram010  ram011  ram012  ram013  ram014  ram015

Next, set the vendor ID, product ID etc. fields via sysfs. These fields
must be set to the following values to allow AIX initiators to recognize
SCST devices:
* The Vendor ID (t10_vend_id) must be set to "IBM".
* The Product ID (prod_id) must be set either to "VDASD blkdev" for SCSI disks
  or "VOPTA blkdev" for a SCSI CD-ROM.
* The Product Revision Level (prod_rev_lvl) must be set to "0001".
* The Vendor Specific Information in the INQUIRY response (inq_vend_specific)
  must be set to the serial number. The serial number is available in the
  "usn" sysfs attribute.

After this step a LUN has to be assigned to each exported SCSI device. Some
non-Linux initiator operating systems only accept LUN numbes that are
multiples of 256 and require that the LUN addressing method is used.
Assigning LUN numbers is possible e.g. as follows:

  lun=0
  for name in ram000 ram001 ram002 ram003 ram004 ram005 ram006 ram007 \
              ram008 ram009 ram010 ram011 ram012 ram013 ram014 ram015
  do
    lun=$((lun+256))
    echo "add $name $lun" \
      >/sys/kernel/scst_tgt/targets/ibmvstgt/ibmvstgt_target_0/luns/mgmt
  done
  echo 1 >/sys/kernel/scst_tgt/targets/ibmvstgt/ibmvstgt_target_0/enabled

The result of the above commands will be as follows:

# cat /sys/kernel/scst_tgt/targets/ibmvstgt/ibmvstgt_target_0/addr_method
LUN
# ls /sys/kernel/scst_tgt/targets/ibmvstgt/ibmvstgt_target_0/luns
256  512  768  1024 1280 1536 1792 2048 2304 2560 2816 3072 3328 3584 3840 4096
mgmt
# cat /sys/kernel/scst_tgt/targets/ibmvstgt/ibmvstgt_target_0/enabled
1

After SCST has been configured, make the new configuration available to the
initiator by rescanning the SCSI bus, e.g. as follows:

# rescan-scsi-bus --hosts=2 --ids=0-31
# lsscsi 2:
[2:0:1:0]    disk    IBM      VDASD blkdev     0001  /dev/sdb
[2:0:2:0]    disk    IBM      VDASD blkdev     0001  /dev/sdc
[2:0:3:0]    disk    IBM      VDASD blkdev     0001  /dev/sdd
[2:0:4:0]    disk    IBM      VDASD blkdev     0001  /dev/sde
[2:0:5:0]    disk    IBM      VDASD blkdev     0001  /dev/sdf
[2:0:6:0]    disk    IBM      VDASD blkdev     0001  /dev/sdg
[2:0:7:0]    disk    IBM      VDASD blkdev     0001  /dev/sdh
[2:0:8:0]    disk    IBM      VDASD blkdev     0001  /dev/sdi
[2:0:9:0]    disk    IBM      VDASD blkdev     0001  /dev/sdj
[2:0:10:0]   disk    IBM      VDASD blkdev     0001  /dev/sdk
[2:0:11:0]   disk    IBM      VDASD blkdev     0001  /dev/sdl
[2:0:12:0]   disk    IBM      VDASD blkdev     0001  /dev/sdm
[2:0:13:0]   disk    IBM      VDASD blkdev     0001  /dev/sdn
[2:0:14:0]   disk    IBM      VDASD blkdev     0001  /dev/sdo
[2:0:15:0]   disk    IBM      VDASD blkdev     0001  /dev/sdp
[2:0:16:0]   disk    IBM      VDASD blkdev     0001  /dev/sdq


References
----------
[1] SCST Configuration Interface, Documentation/scst/README.scst.
[2] Power.org Standard for Power Architecture Platform Requirements (PAPR)
(Workstation, Server), Version 2.4, December 7, 2009, http://www.power.org.
[3] Virtual I/O (VIO) and Virtualization, IBM Developerworks, 2010,
http://www.ibm.com/developerworks/wikis/display/virtualization/VIO.
