class Controller

Defined at line 963 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_t target, uint16_t lun, iovec cdb, bool is_write, iovec data)

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_t target, uint16_t lun, iovec cdb, bool is_write, uint32_t block_size_bytes, DeviceOp * device_op, iovec data)

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 17 of file ../../src/devices/block/lib/scsi/controller.cc

zx_status_t RequestSense (uint8_t target, uint16_t lun, iovec data)

Read Sense data to |data|.

Defined at line 29 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 42 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 57 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 100 of file ../../src/devices/block/lib/scsi/controller.cc

zx::result<> ModeSense (uint8_t target, uint16_t lun, PageCode page_code, iovec data, bool use_mode_sense_6)

Return Mode(6|10)ParameterHeader for the specified lun.

Defined at line 144 of file ../../src/devices/block/lib/scsi/controller.cc

zx::result<std::tuple<bool, bool>> ModeSenseDpoFuaAndWriteProtectedEnabled (uint8_t target, uint16_t lun, bool use_mode_sense_6)

Determine if the lun has DPO FUA available and Write protected.

Defined at line 187 of file ../../src/devices/block/lib/scsi/controller.cc

zx::result<bool> ModeSenseWriteCacheEnabled (uint8_t target, uint16_t lun, bool use_mode_sense_6)

Determine if the lun has write cache enabled.

Defined at line 215 of file ../../src/devices/block/lib/scsi/controller.cc

zx_status_t ReadCapacity (uint8_t target, uint16_t lun, 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 241 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 281 of file ../../src/devices/block/lib/scsi/controller.cc

zx_status_t StartStopUnit (uint8_t target, uint16_t lun, bool immed, PowerCondition power_condition, uint8_t modifier, 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 306 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 335 of file ../../src/devices/block/lib/scsi/controller.cc

zx_status_t SendDiagnostic (uint8_t target, uint16_t lun, SelfTestCode code)

Request diagnostic operation to the device.

This function currently only supports the default self-test feature, which is the minimum

requirement.

Defined at line 354 of file ../../src/devices/block/lib/scsi/controller.cc

zx::result<uint32_t> ScanAndBindLogicalUnits (uint8_t target, uint32_t max_transfer_bytes, uint16_t max_lun, LuCallback lu_callback, DeviceOptions device_options)

Check the status of each LU and bind it. This function returns the number of LUs found.

Defined at line 376 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 512 of file ../../src/devices/block/lib/scsi/controller.cc

zx_status_t ReadBuffer (uint8_t target, uint16_t lun, uint8_t mod, uint8_t buffer_id, uint32_t buffer_offset, iovec data)

Reads data from the device's internal buffer, used for diagnostics or firmware retrieval.

Defined at line 561 of file ../../src/devices/block/lib/scsi/controller.cc

zx_status_t WriteBuffer (uint8_t target, uint16_t lun, uint8_t mod, uint8_t buffer_id, uint32_t buffer_offset, iovec data)

Writes data to the device's internal buffer, used for firmware upload or buffer initialization

Defined at line 582 of file ../../src/devices/block/lib/scsi/controller.cc

void ~Controller ()

Defined at line 965 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h

void SetExpectCheckConditionOrUnitAttention (bool value)

Defined at line 1066 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 1079 of file ../../src/devices/block/lib/scsi/include/lib/scsi/controller.h

Friends

class BlockDeviceTest