class Controller
Defined at line 1033 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
Protected Members
mutex lock_
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 ()
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 ExecuteCommandsAsync (uint8_ttarget,uint16_tlun,std::span<ScsiRequest>batch)
Asynchronously execute a batch of SCSI commands on the device at target:lun.
Each request must be completed with [`ScsiRequest::Complete(status)`], whether it was
successful or not (even if it was not submitted to hardware).
NOTE: `batch` is a view into a temporary array.
Callers are expected to move the elements out of the span and take ownership of them, retaining
them until the request completes. This is done rather than passing an owned data structure
(like a vector) to avoid a temporary heap allocation if the driver wishes to store them in some
other data structure.
Thread safety: `ExecuteCommandsAsync` is called on the `BlockServer` session worker thread.
Multiple sessions (or requests across multiple targets/LUNs) may invoke this method
concurrently, so implementations must be thread-safe. `ScsiRequest::Complete` may be called
from any thread (synchronously during `ExecuteCommandsAsync` or asynchronously from an
interrupt/dispatcher thread).
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<std::unique_ptr<BlockDevice>> BindBlockDevice (uint8_ttarget,uint16_tlun,uint32_tmax_transfer_bytes,DeviceOptionsdevice_options)
Bind a block device at target:lun.
Defined at line 425 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 528 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 574 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 595 of file ../../src/devices/block/lib/scsi/controller.cc
void ~Controller ()
Defined at line 1035 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
zx::event node_token ()
Defined at line 1045 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
void SetExpectCheckConditionOrUnitAttention (bool value)
Defined at line 1142 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
std::mutex & lock ()
Defined at line 1161 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 1164 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h
Friends
class BlockDeviceTest