LIBSAS driver for Marvell 88SE63xx/64xx/68xx/94xx SAS controller
======================================================

This driver consists from two parts: the target mode driver itself and
the changed initiator driver from Linux kernel, which is particularly
intended to perform all the initialization and shutdown tasks. This
driver was changed to provide the target mode support and all necessary
callbacks, but it's still capable to work as initiator mode only,
when a host acts as the initiator and the target simultaneously, is
supported as well.

This version is compatible with SCST core version 1.0.0 and higher and
Linux kernel 2.6.25 and higher,  which must include libsas module.

The original initiator driver was taken from the kernel 2.6.25.


See also "ToDo" for list of known issues and unimplemented 
features.


Installation:
------------
Only vanilla kernels from kernel.org are supported, but it should work
on vendors' kernels, if you manage to successfully compile on them. The
main problem with vendor's kernels is that they often contain patches,
which will appear only in the next version of the vanilla kernel,
therefore it's quite hard to track such changes. Thus, if during
compilation for some vendor kernel your compiler complains about
redefinition of some symbol, you should either switch to vanilla kernel,
or change as necessary the corresponding to that symbol "#if
LINUX_VERSION_CODE" statement.

At first, make sure that the link "/lib/modules/`you_kernel_version`/build" 
points to the source code for your currently running kernel.

Second, patch the libsas and then make libsas module to install in in your 
currently running kernel, also you should add ATA support for libsas in the 
kerenl if you want to support SATA device.

The codes have included the SCST code for supportting target, you need patch 
the kernel use the patch file in ./scst/kernel. To compile the target driver,
at first, build scst in scst directory, then insmod scst_disk.ko to support 
real disk, insmod scst_vdisk.ko to support vdisk, etc.
then, you should make sure the make option SUPPORT_TARGET has been enabled
in Makefile of mvsas, and then type 'make' in mvsas/ subdirectory. It will build 
mvsas.ko module.

To install the target driver, type 'make install' in mvsas/
subdirectory. The target driver will be installed in
/lib/modules/`you_kernel_version`/extra. To uninstall it, type 'make
uninstall'.

After the drivers are loaded and adapters are successfully initialized by
the initiator driver, including firmware image load, you can type following
command to show the detailed phy info,
cat /sys/class/scsi_host/hostX/target_mode
X is the host number of the controller, then you can get the info like

phy  dev sas address     attach dev type   attach sas address  target mode
0    5005043011ab004b    SAS  END DEVICE   5000c50008424415    0
1    5005043011ab004b    SAS  END DEVICE   5000c500064c363d    0
2    5005043011ab004b                      0                   0
3    5005043011ab004b    SAS  END DEVICE   500000e0192a37e2    0
4    5005043011ab0000    SAS  EXPANDER     5000155d220bc23f    0
5    5005043011ab0000    SAS  EXPANDER     5000155d220bc23f    0
6    5005043011ab0000    SAS  EXPANDER     5000155d220bc23f    0
7    5005043011ab0000    SAS  EXPANDER     5000155d220bc23f    0

then you can choose the one phy to enable the target mode of it.The target 
mode should be enabled/disable via a sysfs interface on a per card basis. Under 
the appropriate scsi_host there is an entry 'target_mode', where you should
type command like:

echo "enable X" >/sys/class/scsi_host/hostY/target_mode
echo "disable X" >/sys/class/scsi_host/hostY/target_mode

X is the phy number, Y is the host number of controller.

eg: echo "disable 1" >/sys/class/scsi_host/host4/target_mode

when you try to enale one phy of the controller, driver will enable all the
phys which have the same SAS address.

Then you should configure exported devices using the corresponding
interface of SCST core. you can configure the target group
as README file of SCST described, like:

echo "add 1:0:1:0 0" >/proc/scsi_tgt/groups/Default/devices

also you can delete a LUN from target, like:

echo "del 1:0:1:0 0" >/proc/scsi_tgt/groups/Default/devices

for details of configure target disk group, pleae refer to README of SCST.

note: 
1. Appropriate phy should be setted to target mode for initiator to detect 
   disks by this phy.
2. In example "add 2:0:0:0 1" the '1' is the LUN in the target, LUN 0 must 
   exist with a target. 
3. When one device is added to target disk group, target driver will notify
   initator the changing of the phy mode and arriving of the disk, but some
   initiator driver don't support phy mode changing well, so 'rmmod' and 
   'modprobe'/'insmod' the initiator driver is neccessary.


following is an example for configuring the target driver.

> modprobe libsas
> insmod mvsas.ko
> echo 1 >/sys/class/scsi_host/host4/target_mode
> echo "add 4:0:0:0 0" >/proc/scsi_tgt/groups/Default/devices

Compilation options
-------------------

There are the following compilation options, that could be commented
in/out in Makefile:

 - CONFIG_SCST_DEBUG - turns on some debugging code, including some logging.
   Makes the driver considerably bigger and slower, producing large amount of
   log data.

 - CONFIG_SCST_TRACING - turns on ability to log events. Makes the driver
   considerably bigger and leads to some performance loss.

 - MV_DEBUG -  turns on some debugging code for target driver itself.


Send patches and questions about this driver to
scst-devel@lists.sourceforge.net, CC: Andy Yan <ayan@marvell.com>.
