A.4.11 Error Handling in SCSI Miniport Drivers

Every SCSI miniport driver is responsible for handling and for notifying the system port driver of the following kinds of SCSI errors, which should be set in the SrbStatus member before the driver completes the SRB it was processing when the error occurred:

·SRB_STATUS_ERROR (if the HBA returns a nonspecific bus error)

·SRB_STATUS_PARITY_ERROR

·SRB_STATUS_UNEXPECTED_BUS_FREE

·SRB_STATUS_SELECTION_TIMEOUT

·SRB_STATUS_COMMAND_TIMEOUT

·SRB_STATUS_MESSAGE_REJECTED

·SRB_STATUS_NO_DEVICE

·SRB_STATUS_NO_HBA

·SRB_STATUS_DATA_OVERRUN (also returned for underruns)

·SRB_STATUS_PHASE_SEQUENCE_FAILURE

·SRB_STATUS_BUSY (TID busy)

For a data underrun, the miniport driver must update the SRB's DataTransferLength to indicate how much data actually was transferred.

In addition, the miniport driver should log some of the preceding errors by passing the SRB to ScsiPortLogError, according to the following guidelines:

·Log an error at the discretion of the driver writer for SRB_STATUS_ERROR.

·Always log an error for SRB_STATUS_PARITY_ERROR.

·Always log an error for SRB_STATUS_UNEXPECTED_BUS_FREE.

·Always log an error for SRB_STATUS_SELECTION_TIMEOUT.

·Always log an error for SRB_STATUS_COMMAND_TIMEOUT.

·Log an error for SRB_STATUS_DATA_OVERRUN whenever an overrun occurs, but not when an underrun occurs.

·Always log an error for SRB_STATUS_PHASE_SEQUENCE_FAILURE.

·Always log an error for SRB_STATUS_BUSY for hardware errors.

To log an error, a miniport driver calls ScsiPortLogError with one of the following system-defined error or warning codes:

·SP_BUS_PARITY_ERROR maps to SRB_STATUS_PARITY_ERROR.

·SP_UNEXPECTED_DISCONNECT (by the target LU)

·SP_INVALID_RESELECTION maps to SRB_STATUS_PHASE_SEQUENCE_FAILURE or SRB_STATUS_ERROR.

·SP_BUS_TIME_OUT maps to SRB_STATUS_SELECTION_TIMEOUT.

·SP_REQUEST_TIMEOUT maps to SRB_STATUS_COMMAND_TIMEOUT.

·SP_PROTOCOL_ERROR maps to SRB_STATUS_PHASE_SELECTION_FAILURE, SRB_STATUS_UNEXPECTED_BUS_FREE, or SRB_STATUS_DATA_OVERRUN for an overrun condition.

·SP_INTERNAL_ADAPTER_ERROR maps to SRB_STATUS_ERROR.

·SP_IRQ_NOT_RESPONDING (warning that the miniport has detected that the HBA is no longer generating interrupts)

·SP_BAD_FW_ERROR ("FW" stands for "firmware")

·SP_BAD_FW_WARNING

ScsiPortLogError allocates an error-log packet, sets it up, and logs the I/O error in the Windows NT event log on behalf of the miniport driver. System administrators or users can monitor the condition of an HBA by examining the system event log and, if necessary, reconfigure, repair, or replace the HBA before it fails.