The sc_buf structure is used for communication between the SCSI device driver and the SCSI 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 sc_buf structure contains certain fields used to pass a SCSI command and associated parameters to the SCSI adapter device driver. Other fields within this structure are used to pass returned status back to the SCSI device driver. The sc_buf structure is defined in the /usr/include/sys/scsi.h file.
Fields in the sc_buf structure are used as follows:
During normal use, the SC_NODISC bit should not be set. Setting this bit allows a device executing commands to monopolize the SCSI bus. Sometimes it is desirable for a particular device to maintain control of the bus once it has successfully arbitrated for it; for instance, when this is the only device on the SCSI bus or the only device that will be in use. For performance reasons, it might not be desirable to go through SCSI selections again to save SCSI bus 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 SCSI bus free condition. This condition is noted as SC_SCSI_BUS_FAULT in the general_card_status field of the sc_cmd structure. Because other errors might also result in the SC_SCSI_BUS_FAULT flag being set, the SC_ASYNC bit should only be set on the last retry of the failed command.
The contents of the resvd1 field, if non-null, must be a pointer to the uio structure that is passed to the SCSI device driver. The SCSI adapter device driver treats the resvd1 field as a pointer to a uio structure that accesses the iovec structures containing pointers to the data. There are no address-alignment restrictions on the data in the iovec structures. The only restriction is that the total transfer length of all the data must not exceed the maximum transfer length for the adapter device driver.
The sc_buf.bufstruct.b_un.b_addr field, which normally contains the starting system-buffer address, is ignored and can be altered by the SCSI adapter device driver when the sc_buf is returned. The sc_buf.bufstruct.b_bcount field should be set by the caller to the total transfer length for the data.
If an error is detected during execution of a SCSI command, and the error prevented the SCSI command from actually being sent to the SCSI bus by the adapter, then the error should be processed or recovered, or both, by the SCSI adapter device driver.
If it is recovered successfully by the SCSI adapter device driver, the error is logged, as appropriate, but is not reflected in the general_card_status byte. If the error cannot be recovered by the SCSI adapter device driver, the appropriate general_card_status bit is set and the sc_buf structure is returned to the SCSI device driver for further processing.
If an error is detected after the command was actually sent to the SCSI device, then it should be processed or recovered, or both, by the SCSI device driver.
For error logging, the SCSI adapter device driver logs SCSI bus- and adapter-related conditions, where as the SCSI device driver logs SCSI device-related errors. In the following description, a capital letter "A" after the error name indicates that the SCSI adapter device driver handles error logging. A capital letter "H" indicates that the SCSI device driver handles error logging.
Some of the following error conditions indicate a SCSI device failure. Others are SCSI bus- or adapter-related.
Logical Unit Numbers (LUNs) | ||
---|---|---|
lun Fields | LUN 0 - 7 | LUN 8 - 31 |
sc_buf.lun | LUN Value | LUN Value |
sc_buf.scsi_command.scsi_cmd.lun | LUN Value | 0 |