class Controller
Defined at line 967 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
Protected Members
unordered_map block_devs_
Public Methods
fidl::WireSyncClient<fuchsia_driver_framework::Node> & root_node ()
Called by children device of this controller for invoking AddChild() or instantiating
compat::DeviceServer.
std::string_view driver_name ()
const std::shared_ptr<fdf::Namespace> & driver_incoming ()
std::shared_ptr<fdf::OutgoingDirectory> & driver_outgoing ()
const std::optional<std::string> & driver_node_name ()
fdf::Logger & driver_logger ()
size_t BlockOpSize ()
Size of metadata struct required for each command transaction by this controller. This metadata
struct must include scsi::DeviceOp as its first (and possibly only) member.
zx_status_t ExecuteCommandSync (uint8_ttarget,uint16_tlun,ioveccdb,boolis_write,iovecdata)
Synchronously execute a SCSI command on the device at target:lun.
|cdb| contains the SCSI CDB to execute.
|data| and |is_write| specify optional data-out or data-in regions.
Returns ZX_OK if the command was successful at both the transport layer and no check
condition happened.
Typically used for administrative commands where data resides in process memory.
void ExecuteCommandAsync (uint8_ttarget,uint16_tlun,ioveccdb,boolis_write,uint32_tblock_size_bytes,DeviceOp *device_op,iovecdata)
Asynchronously execute a SCSI command on the device at target:lun.
|cdb| contains the SCSI CDB to execute.
|device_op|, |block_size_bytes|, and |is_write| specify optional data-out or data-in regions.
Command execution status is returned by invoking |device_op|->Complete(status).
Typically used for IO commands where data may not reside in process memory.
The |data| is used when there is an additional data buffer to pass. For example, an operation
like TRIM(block_trim_t) does not have a data vmo, but the SCSI UNMAP command requires a data
vmo to record the address and length of the block to be trimmed. In this case, the additional
buffer is passed through |data| and the device driver creates and manages the data vmo.
zx_status_t TestUnitReady (uint8_t target, uint16_t lun)
Test whether the target-lun is ready.
Defined at line 18 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t RequestSense (uint8_ttarget,uint16_tlun,iovecdata)
Read Sense data to |data|.
Defined at line 30 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<InquiryData> Inquiry (uint8_t target, uint16_t lun)
Return InquiryData for the specified lun.
Defined at line 43 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<VPDBlockLimits> InquiryBlockLimits (uint8_t target, uint16_t lun)
Read Block Limits VPD Page (0xB0), if supported and return the max transfer size
(in blocks) supported by the target.
Defined at line 58 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<bool> InquirySupportUnmapCommand (uint8_t target, uint16_t lun)
Read Logical Block Provisioning VPD Page (0xB2), check that it supports the UNMAP command.
Defined at line 102 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<> ModeSense (uint8_ttarget,uint16_tlun,PageCodepage_code,iovecdata,booluse_mode_sense_6)
Return Mode(6|10)ParameterHeader for the specified lun.
Defined at line 147 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<std::tuple<bool, bool>> ModeSenseDpoFuaAndWriteProtectedEnabled (uint8_ttarget,uint16_tlun,booluse_mode_sense_6)
Determine if the lun has DPO FUA available and Write protected.
Defined at line 190 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<bool> ModeSenseWriteCacheEnabled (uint8_ttarget,uint16_tlun,booluse_mode_sense_6)
Determine if the lun has write cache enabled.
Defined at line 218 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t ReadCapacity (uint8_ttarget,uint16_tlun,uint64_t *block_count,uint32_t *block_size_bytes)
Return the block count and block size (in bytes) for the specified lun.
Defined at line 244 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<uint16_t> ReportLuns (uint8_t target)
Count the number of addressable LUNs attached to a target.
Defined at line 284 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t StartStopUnit (uint8_ttarget,uint16_tlun,boolimmed,PowerConditionpower_condition,uint8_tmodifier,std::optional<bool>load_or_unload)
Change the power condition of the logical unit. If |load_or_unload| is true, load the medium,
if false, unload it. If |load_or_unload| is std::nullopt, do not load/unload.
Defined at line 309 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t FormatUnit (uint8_t target, uint16_t lun)
Format the selected LU. Currently only supports type 0 protection, FMTDATA=0 (mandatory), and
does not send a parameter list.
Defined at line 339 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t SendDiagnostic (uint8_ttarget,uint16_tlun,SelfTestCodecode)
Request diagnostic operation to the device.
This function currently only supports the default self-test feature, which is the minimum
requirement.
Defined at line 358 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<uint32_t> ScanAndBindLogicalUnits (uint8_ttarget,uint32_tmax_transfer_bytes,uint16_tmax_lun,LuCallbacklu_callback,DeviceOptionsdevice_options)
Check the status of each LU and bind it. This function returns the number of LUs found.
Defined at line 380 of file ../../src/devices/block/lib/scsi/controller.cc
zx::result<> ScsiComplete (StatusMessage status_message, std::optional<std::reference_wrapper<FixedFormatSenseDataHeader>> sense_data)
This function handles the completion of the SCSI command and runs the ErrorHandler if an error
is found. |StatusMessage| is a struct for passing the HostStatusCode and ScsiStatusCode.
The sequence to check for errors is as follows
- Check HostStatusCode -> Check ScsiStatusCode -> Check SenseData
Currently, the ScsiComplete() does not support retry.
Defined at line 516 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t ReadBuffer (uint8_ttarget,uint16_tlun,uint8_tmod,uint8_tbuffer_id,uint32_tbuffer_offset,iovecdata)
Reads data from the device's internal buffer, used for diagnostics or firmware retrieval.
Defined at line 565 of file ../../src/devices/block/lib/scsi/controller.cc
zx_status_t WriteBuffer (uint8_ttarget,uint16_tlun,uint8_tmod,uint8_tbuffer_id,uint32_tbuffer_offset,iovecdata)
Writes data to the device's internal buffer, used for firmware upload or buffer initialization
Defined at line 586 of file ../../src/devices/block/lib/scsi/controller.cc
void ~Controller ()
Defined at line 969 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
void SetExpectCheckConditionOrUnitAttention (bool value)
Defined at line 1070 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
const std::unordered_map<uint8_t, std::unordered_map<uint16_t, std::unique_ptr<BlockDevice>>> & block_devs ()
Defined at line 1083 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
Friends
class BlockDeviceTest