Target (RAMD)
The RAMD target of the OneCore Storage driver implements a non-persistent RAM drive. The driver implements a number of SCSI commands, and appears to initiators as a valid SCSI block device.
The RAMD consists of four main components: the SCSI Target, SCSI Command Processing, RAMD Target IO State Machine, and the RAMdisc.
When the driver is initially loaded, there is a driver-wide initialization for the RAMD (
ocs_scsi_tgt_driver_init()). After the driver is loaded, the devices are enumerated. The ocs_pci_probe() function calls
ocs_scsi_tgt_new_device() to create a new SCSI target.
Memory is allocated to hold the data for a ramdisc instance(s), also called a LUN(s). Each default ramdisc instance (LUN) is 50 MB, consisting of 512-byte blocks. This 50 MB area is further divided into segments of 64K, resulting in a default ramdisc instance size up to 800 segments, each with 128 blocks. The ramdisc size and ramdisc block size can be changed using the ramdisc_size and ramdisc_blocksize module parameters. The ramdisc block size can be also changed using the FORMAT UNIT SCSI command, but reverts to 512-byte blocks if the driver is reloaded.
Once initialized, the target performs the following functions:
-
Command parsing – commands are received as unsolicited FCP frames and the CDB opcode is parsed.
-
Command dispatch – a table of SCSI command handler functions determines the specific functions that are called to handle the specific commands.
-
Data transport – for SCSI READ and SCSI WRITE commands, data is DMA’d directly to and from the memory buffers of the RAM drive.
-
Acts as a SCSI block device – SCSI configuration and informational commands such as TEST UNIT READY, INQUIRY, MODE SELECT, and MODE SENSE are implemented to allow the driver to respond, as if it were an actual SCSI block device.
Supported SCSI Commands
-
FORMAT UNIT
-
INQUIRY (Standard Inquiry, VPD pages 0x00, 0x80, 0x83, 0x86)
-
MODE SELECT (6), MODE SELECT 10 (for setting block size)
-
MODE SENSE (6) (limited pages), MODE SENSE (10) (limited pages)
-
READ (6), READ (10), READ (12), READ (16), READ (32)
-
READ CAPACITY (10), READ CAPACITY (16)
-
READ LONG (10), READ LONG (16)
-
REPORT LUNS
-
REQUEST SENSE
-
TEST UNIT READY
-
WRITE (6), WRITE (10), WRITE (12), WRITE (16), WRITE (32)
-
WRITE AND VERIFY (10), WRITE AND VERIFY (12), WRITE AND VERIFY (16)
-
WRITE LONG (10), WRITE LONG (16)
-
WRITE SAME (10), WRITE SAME (16), WRITE SAME (32)