SCSI Initiator-Mode Recovery During Command Tag Queuing

If the SCSI device driver is queuing multiple transactions to the device and either a check condition error or a command terminated error occurs, the SCSI adapter driver does not clear all transactions in its queues for the device.

It returns the failed transaction to the SCSI device driver with an indication that the queue for this device is not cleared by setting the SC_DID_NOT_CLEAR_Q flag in the sc_buf.adap_q_status field. The SCSI adapter driver halts the queue for this device awaiting error recovery notification from the SCSI device driver. The SCSI device driver then has three options to recover from this error:

  • Send one error recovery command (request sense) to the device.
  • Clear the SCSI adapter driver's queue for this device.
  • Resume the SCSI adapter driver's queue for this device.

When the SCSI adapter driver's queue is halted, the SCSI device drive can get sense data from a device by setting the SC_RESUME flag in the sc_buf.flags field and the SC_NO_Q flag in sc_buf.q_tag_msg field of the request-sense sc_buf. This action notifies the SCSI adapter driver that this is an error-recovery transaction and should be sent to the device while the remainder of the queue for the device remains halted. When the request sense completes, the SCSI device driver needs to either clear or resume the SCSI adapter driver's queue for this device.

The SCSI device driver can notify the SCSI adapter driver to clear its halted queue by sending a transaction with the SC_Q_CLR flag in the sc_buf.flags field. This transaction must not contain a SCSI command because it is cleared from the SCSI adapter driver's queue without being sent to the adapter. However, this transaction must have the SCSI ID field (sc_buf.scsi_command.scsi_id) and the LUN fields (sc_buf.scsi_command.scsi_cmd.lun and sc_buf.lun) filled in with the device's SCSI ID and logical unit number (LUN). If addressing LUNs 8 - 31, the sc_buf.lun field should be set to the logical unit number and the sc_buf.scsi_command.scsi_cmd.lun field should be zeroed out. See the descriptions of these fields for further explanation. Upon receiving an SC_Q_CLR transaction, the SCSI adapter driver flushes all transactions for this device and sets their sc_buf.bufstruct.b_error fields to ENXIO. The SCSI device driver must wait until the sc_buf with the SC_Q_CLR flag set is returned before it resumes issuing transactions. The first transaction sent by the SCSI device driver after it receives the returned SC_Q_CLR transaction must have the SC_RESUME flag set in the sc_buf.flags fields.

If the SCSI device driver wants the SCSI adapter driver to resume its halted queue, it must send a transaction with the SC_Q_RESUME flag set in the sc_buf.flags field. This transaction can contain an actual SCSI command, but it is not required. However, this transaction must have the sc_buf.scsi_command.scsi_id, sc_buf.scsi_command.scsi_cmd.lun,and the sc_buf.lun fields filled in with the device's SCSI ID and logical unit number. See the description of these fields for further details. If this is the first transaction issued by the SCSI device driver after receiving the error (indicating that the adapter driver's queue is halted), then the SC_RESUME flag must be set as well as the SC_Q_RESUME flag.