scsi_target - a SCSI target emulator ------- This code is a rewrite of /sys/cam/scsi/scsi_target* and /usr/share/examples/scsi_target/. The kernel driver allows a user process to enable target mode and then pass CCBs to and from the HBA via read(2) and write(2). The included user program uses this to emulate a disk drive (RBC). All reads/writes to and from the emulated drive access data in a file. Requirements --- One or two PCs One SCSI dual bus HBA or two single bus HBAs Cable to connect both HBAs FreeBSD 4.8-RELEASE or 5-CURRENT SCSI Adapters --- The HBA you use for emulating a target must have target mode support. Drivers that have good target mode support are ahc(4) and isp(4). Drivers that may support target mode in the future are sym(4), ahd(4), and mpt(4). 1. Tested HBAs Cards based on Adaptec 7890 (Ultra2), 7899 (Ultra 160) Qlogic SCSI 1280 2. Untested but should work Cards based on Adaptec 7891, 7896, 7897 (Ultra2) Cards based on Adaptec 7892 (Ultra 160) Qlogic Fibre Channel cards (2100, 2200, 2300, 2312) Qlogic SCSI cards 3. May work in the future Other isp(4) cards sym(4) mpt(4) ahd(4) Usage --- 1. Add the following to your kernel config if not present: device scbus device da # SCSI target emulator device targ # Blackhole target driver device targbh options CAMDEBUG # Enable asynch IO (or just do "kldload aio") options VFS_AIO 2. Add the appropriate option for your HBA to enable target mode. For the ahc(4) cards, this is: options AHC_TMODE_ENABLE=0x8 ... where the supplied value is a bitmask of the SCSI target ids you wish to enable target mode support on. If you're using multiple HBAs in the same box or a dual bus HBA, be sure to only enable target mode support for the card you wish to use as the target since some drivers don't support simultaneous initiator/target roles. For the isp(4) cards: options ISP_TARGET_MODE Note that most isp(4) cards can do simultaneous init/target operations and you must use the init id as the target id. For instance, if your card is configured to be initiator id 7 (in the BIOS), you should use 7 as the target id you emulate. 3. Build a kernel with the new driver the ordinary way. 4. Reboot 5. cd /usr/share/examples/scsi_target; make 6. Build a backing store file dd if=/dev/zero of=test_file bs=1m count=20 7. Run the usermode, specifying the appropriate bus/target/lun you wish the emulated drive to appear on: ./scsi_target -d 0:3:0 test_file 8. Go to the initiator HBA and rescan for the new drive using the other HBA's bus number as below: camcontrol rescan 1 9. You should see some debugging messages on the target as commands are received and processed and then the drive should appear on the initiator as shown below: camcontrol devlist at scbus1 target 3 lun 0 (pass0,da0) 12. You can now fdisk, disklabel, newfs, and mount the emulated drive. (Assuming everything is working ok :) Please report any problems to nate AT root.org KNOWN BUGS: none, although much more testing is needed