SCSI_REQUEST_BLOCK


typedef struct _SCSI_REQUEST_BLOCK {
    USHORT Length;
    UCHAR Function;
    UCHAR SrbStatus;
    UCHAR ScsiStatus;
    UCHAR PathId;
    UCHAR TargetId;
    UCHAR Lun;
    UCHAR QueueTag;
    UCHAR QueueAction;
    UCHAR CdbLength;
    UCHAR SenseInfoBufferLength;
    ULONG SrbFlags;
    ULONG DataTransferLength;
    ULONG TimeOutValue;
    PVOID DataBuffer;
    PVOID SenseInfoBuffer;
    struct _SCSI_REQUEST_BLOCK *NextSrb;
    PVOID OriginalRequest;
    PVOID SrbExtension;
    ULONG QueueSortKey;
    UCHAR Cdb[16];
} SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;

Length

Specifies the length, in bytes, of the request block.

Function

Specifies the operation to be performed.

Operation

Meaning

SRB_FUNCTION_EXECUTE_SCSI

A SCSI device I/O request should be executed on the target logical unit.

SRB_FUNCTION_ABORT_COMMAND

A SCSIMESS_ABORT message should be sent to cancel the request pointed to by the NextSrb field. If this is tagged queue request, then a SCSIMESS_ABORT_WITH_TAG message should be used. If the indicated request has been completed, this request should be completed normally. Only the Function, PathId, TargetId, Lun, and NextSrb fields are valid.

SRB_FUNCTION_RESET_DEVICE

The SCSI target controller should be reset using the SCSIMESS_BUS_DEVICE_RESET message. The HBA miniport driver should complete any active requests for the target controller. Only the Function, TargetId and PathId fields are valid.

SRB_FUNCTION_TERMINATE_IO

A SCSIMESS_TERMINATE_IO_PROCESS message should be sent to cancel the request pointed to by the NextSrb field. If the indicated request has already completed, this request should be completed normally. Only the Function, PathId, TargetId, Lun, and NextSrb fields are valid.

SRB_FUNCTION_RELEASE_RECOVERY

A SCSIMESS_RELEASE_RECOVERY message should be sent to the target controller. Only the Function, PathId, TargetId and Lun fields are valid.

SRB_FUNCTION_RECEIVE_EVENT

The HBA should be prepared to receive an Asynchronous Event Notification from the addressed target. The DataBuffer indicates where the data should be placed.

SRB_FUNCTION_SHUTDOWN

The system is being shut down. The request is passed to the miniport driver if CachesData was set to TRUE in the PORT_CONFIGURATION_INFORMATION data. The miniport driver can receive several of these notifications before all system activity is actually stopped; however, the last shutdown notification will occur after the last start I/O. Only the Function, PathId, TargetId and Lun fields are valid.

SRB_FUNCTION_FLUSH

The miniport should flush any cached data for the device. The request is passed to the miniport driver if CachesData is TRUE in the PORT_CONFIGURATION_INFORMATION data. Only the Function, PathId, TargetId and Lun fields are valid.

SRB_FUNCTION_IO_CONTROL

The request is an I/O control request. The SRB DataBuffer points to an SRB_IO_CONTROL header followed by the data area. The value in DataBuffer can be used by the driver, regardless of the value of MapBuffers field. If the HBA miniport driver supports this request, it should execute the request and notify the OS-specific port driver when it has completed it, using the normal mechanism of ScsiPortNotification with RequestComplete and NextRequest. Only the Function, SrbFlags, TimeOutValue, DataBuffer, DataTransferLength and SrbExtension are valid.


SrbStatus

Returns the status of the completed request. This field should be set by the HBA miniport driver before it notifies the OS-specific driver that the request has completed to one of the following:

Status

Meaning

SRB_STATUS_PENDING

Indicates the request in progress. The OS-specific port driver will initialize the SrbStatus to this value. This value should not be set by the HBA miniport driver.

SRB_STATUS_SUCCESS

Indicates the request was completed successfully.

SRB_STATUS_ABORTED

Indicates the request was aborted.

SRB_STATUS_ABORT_FAILED

Indicates an attempt to abort the request failed. This status is returned for a SRB_FUNCTION_ABORT_COMMAND request when the specified request cannot be located.

SRB_STATUS_ERROR

Indicates the request was completed with an error in the SCSI bus status.

SRB_STATUS_BUSY

Indicates the device could not accept the request at this time.

SRB_STATUS_INVALID_REQUEST

Indicates the miniport driver does not support the request.

SRB_STATUS_INVALID_PATH_ID

Indicates the PathId specified in the SRB doesn't exist.

SRB_STATUS_NO_DEVICE

Indicates the device did not respond.

SRB_STATUS_TIMEOUT

Indicates the request timed out.

SRB_STATUS_SELECTION_TIMEOUT

Indicates the SCSI device selection timed out.

SRB_STATUS_COMMAND_TIMEOUT

Indicates the target did not complete the command within the time limit.

SRB_STATUS_MESSAGE_REJECTED

Indicates the target rejected a message. This is normally returned for message type requests such as SRB_FUNCTION_TERMINATE_IO.

SRB_STATUS_BUS_RESET

Indicates a bus reset occurred while this request was being executed.

SRB_STATUS_PARITY_ERROR

Indicates a parity error occurred on the SCSI bus and that a retry failed.

SRB_STATUS_REQUEST_SENSE_FAILED

Indicates the request sense command failed. This is returned only if the controller performs auto request sense.

SRB_STATUS_NO_HBA

Indicates the HBA does not respond.

SRB_STATUS_DATA_OVERRUN

Indicates that a data overrun or underrun error occurred. The SRB's DataTransferLength field should be updated.

SRB_STATUS_UNEXPECTED_BUS_FREE

Indicates the target disconnected unexpectedly.

SRB_STATUS_PHASE_SEQUENCE_FAILURE

Indicates the adapter detected an illegal phase sequence failure error.

SRB_STATUS_BAD_SRB_BLOCK_LENGTH

Indicates the SRB has an invalid length.

SRB_STATUS_REQUEST_FLUSHED

Indicates the request for status was stopped.

SRB_STATUS_INVALID_LUN

Indicates the LUN in the SRB is invalid.

SRB_STATUS_INVALID_TARGET_ID

Indicates the TargetID in the SRB is invalid.

SRB_STATUS_BAD_FUNCTION

Indicates the SRB function code is not supported.

SRB_STATUS_ERROR_RECOVERY

Indicates the request was completed with an error in the SCSI bus status and that the INITIATE RECOVERY message was received.

SRB_STATUS_AUTOSENSE_VALID

Indicates information returned in the SenseInfoBuffer is valid.


ScsiStatus

Returns the SCSI status that was returned by the HBA or target device. If the status is not SUCCESS, the SrbStatus should be set to SRB_STATUS_ERROR.

PathId

Indicates the SCSI port or bus for the request. This value is zero-based.

TargetId

Indicates the target controller on the bus.

Lun

Indicates the logical unit.

QueueTag

Indicates the queue tag, which was assigned by the OS-specific port driver. If this field is used for tagged queuing, the HBA supports internal queueing of requests to LUs.

QueueAction

Indicates the tagged-queuing message to be used when the SRB_FLAGS_QUEUE_ACTION_ENABLE flag is set. These values are defined in the SCSI-II specification.

CdbLength

Indicates the length, in bytes, of the command descriptor block.

SenseInfoBufferLength

Indicates the length, in bytes, of the request-sense buffer.

SrbFlags

Indicates various parameters and options about the request. The following values can be entered.

Value

Meaning

SRB_FLAGS_QUEUE_ACTION_ENABLE

Indicates tagged-queue actions are to be enabled.

SRB_FLAGS_DISABLE_AUTOSENSE

Indicates that request sense information should not be returned.

SRB_FLAGS_DATA_IN

Indicates data will be transferred from the device to the system.

SRB_FLAGS_DATA_OUT

Indicates data will be transferred from the system to the device.

SRB_FLAGS_NO_DATA_TRANSFER

Indicates no data transfer with this request. If this is set, the flags SRB_FLAGS_DATA_OUT and SRB_FLAGS_DATA_IN are both clear.

SRB_FLAGS_DISABLE_SYNCH_TRANSFER

Indicates the HBA should not attempt to negotiate synchronous transfer with this request.

SRB_FLAGS_BYPASS_FROZEN_QUEUE

Not used by the miniport driver.

SRB_FLAGS_NO_QUEUE_FREEZE

Not used by the miniport driver.

SRB_FLAGS_IS_ACTIVE

Not used by the miniport driver.

SRB_FLAGS_ALLOCATED_FROM_ZONE

Indicates whether the SRB was allocated from a zone buffer. If TRUE, a class driver must call ExInterlockedFreeToZone to release the SRB; otherwise, it must call ExFreePool.

SRB_FLAGS_DISABLE_DISCONNECT

Indicates the HBA should not allow the target to disconnect from the SCSI bus during processing of this request.

SRB_FLAGS_ENABLE_ADAPTER_CACHE

Indicates that the HBA can cache the data for this transfer request; otherwise, the data should be read or written to the device before the request has been completed. The adapter is responsible for ensuring that inconsistencies do not occur. For example, if a write occurs with caching enabled and, then, a read occurs without caching enabled, the adapter must return the last data written.


DataTransferLength

Indicates the length, in bytes, of the data buffer. If an underrun occurs, this field should be updated with the number of bytes actually transferred.

TimeOutValue

Indicates the minimum time, in seconds, the request can execute before it is considered to have timed out. HBA miniport drivers are not required to time requests, because the port driver already does.

DataBuffer

Points to the data buffer. HBA miniport drivers should not use this value as a data pointer unless the miniport set MapBuffers to TRUE in the SCSI_HW_INITIALIZATION_DATA structure or for SRB_FUNC_IO_CONTROL requests.

SenseInfoBuffer

Points to the request-sense buffer. HBA-specific drivers are not required to provide request sense data after a CHECK CONDITION. HBA miniport drivers should not use this value as a data pointer unless the miniport set MapBuffers to TRUE in the SCSI_HW_INITIALIZATION_DATA structure. The physical address of the extension can be obtained by calling ScsiPortGetPhysicalAddress.

NextSrb

Indicates the SCSI_REQUEST_BLOCK to which this request applies.

SrbExtension

Points to the Srb extension. This field should not be used if a length of zero was specified in the SCSI_HW_INITIALIZATION_DATA structure. This data extension is not initialized by the OS-specific port driver, and the miniport-determined data can be accessed directly by the HBA. The physical address of the extension can be obtained by calling ScsiPortGetPhysicalAddress.

Cdb

Supplies the SCSI-II command descriptor block to be sent to the target device.

See also HW_INITIALIZATION_DATA, ScsiPortGetPhysicalAddress, ScsiPortGetSrb, ScsiPortNotification, SRB_IO_CONTROL