The scsi_buf structure is used for communication between the device driver and the adapter device driver during an initiator I/O request. This structure is passed to and from the strategy routine in the same way a standard driver uses a struct buf structure.
The scsi_buf structure contains certain fields used to pass a command and associated parameters to the adapter device driver. Other fields within this structure are used to pass returned status back to the device driver. The scsi_buf structure is defined in the /usr/include/sys/scsi_buf.h file.
Fields in the scsi_buf structure are used as follows:
During normal use, the SC_NODISC bit should not be set. Setting this bit allows a device running commands to monopolize the transport layer. Sometimes it is desirable for a particular device to maintain control of the transport layer once it has successfully arbitrated for it; for instance, when this is the only device on the transport layer or the only device that will be in use. For performance reasons, it might not be desirable to go through selections again to save transport layer overhead on each command.
Also during normal use, the SC_ASYNC bit must not be set. It should be set only in cases where a previous command to the device ended in an unexpected transport free condition. This condition is noted as SCSI_TRANSPORT_FAULT in the adapter_status field of the scsi_cmd structure. Because other errors might also result in the SCSI_TRANSPORT_FAULT flag being set, the SC_ASYNC bit should only be set on the last retry of the failed command.
If an error is detected while an command is running, and the error prevented the command from actually being sent to the transport layer by the adapter, then the error should be processed or recovered, or both, by the adapter device driver.
If it is recovered successfully by the adapter device driver, the error is logged, as appropriate, but is not reflected in the adapter_status byte. If the error cannot be recovered by the adapter device driver, the appropriate adapter_status bit is set and the scsi_buf structure is returned to the device driver for further processing.
If an error is detected after the command was actually sent to the device, then it should be processed or recovered, or both, by the device driver.
For error logging, the adapter device driver logs transport layer and adapter-related conditions, and the device driver logs device-related errors. In the following description, a capital letter (A) after the error name indicates that the adapter device driver handles error logging. A capital letter (H) indicates that the device driver handles error logging.
Some of the following error conditions indicate a device failure. Others are transport layer or adapter-related.
This transaction must have the SCSI ID field (scsi_buf.scsi_id) and the LUN field (scsi_buf.lun_id) filled in with the device's SCSI ID and logical unit number (LUN). This flag is valid only during error recovery of a check condition or command terminated at a command tag queuing.