SCSI Driver Extension

A minor weak point of the SCSI Driver interface is the limitation to 8 LUNs (SCSI sub-units) per device, even though SCSI-2 and newer (but not ACSI) permit 32 LUNs. With PiSCSI you can create devices with more than 8 LUNs.
With a small, backwards compatible extension for the SCSI Driver interface the LUN restriction can be removed. This has been tested with a beta version of HDDRIVER. Presumably there will be an official version of HDDRIVER with support for this feature.

SCSI Driver Extension

The screenshot shows two SCSI devices with a LUN > 7: The RaSCSI/PiSCSI host services (ID 4, LUN 15) and a SCSI printer (ID 4, LUN 31).

Technical Details

The bits 8-12 in the flags field of the In and Out calls contain the complete LUN (0-31). Whether a SCSI Driver supports this feature is coded in bit 6 of the bus feature vector for the respective bus. The caller sets bit 6 in the flags field in order to signal that the extended LUN information is available. The SCSI Driver specification explains all data structures and calls in detail.

List of available LUNs

For devices with potentially numerous LUNs it is often useful to query the list of available LUNs from the device. This avoids unnecessarily accessing non-existent LUNs. The SCSI command REPORT LUNS can be used for that, see SPC-2 (SCSI Primary Commands) or newer. The PiSCSI client tools provide an example.