Caveats:

a) This code has been tested under Red Hat Enterprise Linux Application
Server 5.2 & 5.3 using SCST release 1.0.1.  This install assumes you
are running one of these Red Hat systems.  If you are not, the install
files under the SCST distribution may provide more insight into the
install process for your kernel.

b) This dialog assumes that all commands are executed as root and that
root has permission to all directories and files needed.

This is a development release of the Emulex lpfc to SCST shim.  Please
send any reports of errors or bugs to elx_support@emulex.com for
incorporation into future releases.  

=====================================================================

1. Create a temporary directory to save downloaded files.
        mkdir /usr/src/SCST

2. From the scst.sourceforge.net website, download the current released
versions of the scst source code and the iscsi-scst source code to the 
temporary directory created above.  Gunzip and untar these files.

Note: iscsi-scst is necessary for the kernel patches to work.

3. Install the kernel source RPM.  Determine the version of your kernel by
running the following command.

        uname -r

Assuming the kernel version is 2.6.18-92.el5, download the kernel rpm with
a name matching the form of kernel-2.6.18-92.1.22.el5.src.rpm.


4. Create a kernel source tree by running the following commands as root.

Note: ignore the error message about directory creation.

        useradd mockbuild
        rpm -i kernel-2.6.18-92.1.22.el5.src.rpm

This will create the kernel spec file in /usr/src/redhat/SPECS and the
source files in /usr/src/redhat/SOURCES.

5. Create the kernel config file and prepare to build the kernel by
running the follow commands.

        rm -rf /usr/src/redhat/BUILD
        mkdir -p /usr/src/redhat/BUILD
        chown mockbuild /usr/src/redhat/BUILD
        sudo -u mockbuild rpmbuild -bp /usr/src/redhat/SPECS/kernel-2.6.spec

   Note: The rpmbuild command requires redhat-rpm-config and unidef packages
      to be installed from the RHEL5.x DVD.

6. Apply the SCST patches to the kernel sources. Change directory and
apply the patch files as follows.  Note that ${SCST_SOURCE_DIR}
represents the location of where you have placed the SCST sources,
such as /usr/src/SCST/scst-1.0.1.

        cd "/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.$(uname -m)"
        patch -p1 < ${SCST_SOURCE_DIR}/kernel/rhel/scst_exec_req_fifo-rhel5.patch
        patch -p1 < ${iSCST_SOURCE_DIR}/kernel/patches/rhel/put_page_callback-rhel5.patch

7. This example uses the scsi_debug kernel module as a ram disk for testing.
On the console, modify the kernel config file to build scsi_debug.ko.

        make xconfig

   Note: This command requires the QT libraries to be installed from the
      RHEL 5.x DVD.

8. Modify the the EXTRAVERSION line in the Makefile.  Change -prep to -scst to
identify the new kernel.

9. Under the menu for "Device Drivers -> SCSI device support -> SCSI low-level drivers"
Scroll down to "SCSI debugging host simulator" and enable the module build by
clicking on the checkbox.  Save the file and exit.  In the terminal window, type:

        make && make modules

10. Install the new kernel and modules

        mkdir -p /lib/modules/2.6.18-scst
        make modules_install && make install

11. Reboot and select your new kernel from the grub menu.  If it boot
successfully and runs, you can edit /boot/grub/grub.conf to make it the
default kernel.

        reboot

12. Change directory to the location where you have installed the lpfc
source. Make and load the lpfc base driver into the kernel.  In this
example, we set all ports as target ports (not initiator) and force
point to point or switched topology.  For further explanation of
lpfc options, see the "Emulex Driver for Linux" manual, available
at www.emulex.com/downloads/emulex.

        make && make install
        rmmod lpfc
        modprobe lpfc lpfc_fcp_mode="-1,2" lpfc_topology=2

13. Change to the location where you have installed the scst source. Edit
src/Makefile and src/dev_handlers/Makefile.  Comment out any EXTRA_FLAGS
which add additional debug information to the compile, especially
-DCONFIG_SCST_TRACING.  Make and install the SCST driver and modules.

        make install

14. Load the SCST driver and the virtual disk handler module into the kernel

        modprobe scst && modprobe scst_vdisk

15. Load the scsi_debug module sized as a 512 MB virtual ram disk.

        modprobe scsi_debug dev_size_mb=512 delay=0

This will create a new scsi disk.  To find it, use lsscsi.  In this example,
the ram disk is at /dev/sdd.

        lsscsi -d
        [0:0:0:0]    disk    ATA      SAMSUNG HE160HJ  0-24  -       
        [0:0:1:0]    disk    ATA      SAMSUNG HE160HJ  0-24  -       
        [0:0:2:0]    disk    ATA      Maxtor 7V250F0   1610  /dev/sda[8:0]
        [0:0:3:0]    disk    ATA      Maxtor 7V250F0   1610  /dev/sdb[8:16]
        [0:1:0:0]    disk    Dell     VIRTUAL DISK     1028  /dev/sdc[8:32]
        [1:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdd[8:48]

   Note: The lsscsi utility must be installed from the RHEL 5.x DVD.

16. Add the scsi_debug ram disk to the SCST virtual disk driver and
set the access control list so the initiators can see it.  Note that 
the output above shows scsi_debug as /dev/sdd.  If your system shows
a different device id, you should change the /dev/sdd in the command
below to match your system.
        
        echo "open vm_disk /dev/sdd" > /proc/scsi_tgt/vdisk/vdisk
        echo "add vm_disk 0" > /proc/scsi_tgt/groups/Default/devices

17. Change directory to the location of the source code for the lpfc to
SCST shim driver (lpfc_scst).  Make and install the driver.

        make && make install
        modprobe lpfc_scst

You should now be able to access the virtual ram disk target from your
initiator.  Note that you may need to rescan the scsi devices, depending
on your initiator's HBA.



