Skip to main content

IdentifyController

Struct IdentifyController 

Source
pub struct IdentifyController { /* private fields */ }
Expand description

Decoded Identify Controller (CNS 01h) data structure.

Owns the 4096-byte buffer returned by libnvme; accessors decode individual fields on demand. Field naming uses the NVMe spec abbreviations where they are widely known (e.g. vendor_id, not vid).

Implementations§

Source§

impl IdentifyController

Source

pub fn vendor_id(&self) -> u16

PCI vendor ID (VID).

Examples found in repository?
examples/id_ctrl.rs (line 25)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn subsystem_vendor_id(&self) -> u16

PCI subsystem vendor ID (SSVID).

Examples found in repository?
examples/id_ctrl.rs (line 26)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn serial_number(&self) -> Result<&str>

20-byte ASCII serial number, trimmed.

Examples found in repository?
examples/id_ctrl.rs (line 28)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn model_number(&self) -> Result<&str>

40-byte ASCII model number, trimmed.

Examples found in repository?
examples/id_ctrl.rs (line 27)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn firmware_revision(&self) -> Result<&str>

8-byte ASCII firmware revision, trimmed.

Examples found in repository?
examples/id_ctrl.rs (line 29)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn ieee_oui(&self) -> [u8; 3]

IEEE OUI (3-byte company identifier), in little-endian byte order.

Source

pub fn max_data_transfer_size_exp(&self) -> u8

Maximum data transfer size, as an exponent of the controller’s minimum memory-page size. 0 means no limit.

Source

pub fn controller_id(&self) -> u16

16-bit controller identifier.

Examples found in repository?
examples/id_ctrl.rs (line 31)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn nvme_version(&self) -> NvmeVersion

NVMe specification version supported by the controller.

Examples found in repository?
examples/id_ctrl.rs (line 30)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn controller_type(&self) -> u8

Controller type: 1 = I/O, 2 = Discovery, 3 = Administrative.

Examples found in repository?
examples/id_ctrl.rs (line 32)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn fru_guid(&self) -> [u8; 16]

16-byte FRU Globally Unique Identifier.

Source

pub fn optional_admin_command_support(&self) -> u16

Optional Admin Command Support bitfield (OACS).

Source

pub fn abort_command_limit(&self) -> u8

Abort command limit (ACL).

Source

pub fn async_event_request_limit(&self) -> u8

Async event request limit (AERL).

Source

pub fn firmware_updates(&self) -> u8

Firmware updates bitfield (FRMW).

Source

pub fn log_page_attributes(&self) -> u8

Log Page Attributes bitfield (LPA).

Source

pub fn error_log_page_entries(&self) -> u8

Number of supported error log page entries (ELPE).

Source

pub fn num_power_states(&self) -> u8

Number of power states supported, zero-based (NPSS).

Source

pub fn warning_temp_threshold_kelvin(&self) -> u16

Warning composite temperature threshold in Kelvin (WCTEMP).

Examples found in repository?
examples/id_ctrl.rs (line 40)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn critical_temp_threshold_kelvin(&self) -> u16

Critical composite temperature threshold in Kelvin (CCTEMP).

Examples found in repository?
examples/id_ctrl.rs (line 44)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn host_memory_buffer_preferred_size(&self) -> u32

Host Memory Buffer preferred size in 4 KiB units (HMPRE).

Source

pub fn host_memory_buffer_min_size(&self) -> u32

Host Memory Buffer minimum size in 4 KiB units (HMMIN).

Source

pub fn total_nvm_capacity_bytes(&self) -> u128

Total NVM Capacity in bytes (TNVMCAP), as a 128-bit little-endian integer.

Examples found in repository?
examples/id_ctrl.rs (line 36)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}
Source

pub fn unallocated_nvm_capacity_bytes(&self) -> u128

Unallocated NVM Capacity in bytes (UNVMCAP).

Source

pub fn submission_queue_entry_size(&self) -> u8

Submission Queue Entry Size encoding (SQES).

Bits 0–3: required size; bits 4–7: maximum size. The actual byte size is 2 ^ value.

Source

pub fn completion_queue_entry_size(&self) -> u8

Completion Queue Entry Size encoding (CQES).

Source

pub fn max_commands_outstanding(&self) -> u16

Maximum outstanding commands (MAXCMD). 0 means no limit reported.

Source

pub fn num_namespaces(&self) -> u32

Number of namespaces supported (NN).

Examples found in repository?
examples/id_ctrl.rs (line 33)
22fn print_controller(ctrl: &libnvme::Controller<'_>) -> Result<(), Box<dyn std::error::Error>> {
23    println!("=== {} ===", ctrl.name()?);
24    let id = ctrl.identify()?;
25    println!("  vendor id          : 0x{:04x}", id.vendor_id());
26    println!("  subsystem vendor   : 0x{:04x}", id.subsystem_vendor_id());
27    println!("  model              : {}", id.model_number()?);
28    println!("  serial             : {}", id.serial_number()?);
29    println!("  firmware           : {}", id.firmware_revision()?);
30    println!("  nvme spec          : {}", id.nvme_version());
31    println!("  controller id      : {}", id.controller_id());
32    println!("  controller type    : {}", id.controller_type());
33    println!("  num namespaces     : {}", id.num_namespaces());
34    println!(
35        "  total nvm capacity : {} bytes",
36        id.total_nvm_capacity_bytes()
37    );
38    println!(
39        "  warn temp threshold: {} K",
40        id.warning_temp_threshold_kelvin()
41    );
42    println!(
43        "  crit temp threshold: {} K",
44        id.critical_temp_threshold_kelvin()
45    );
46    println!();
47    Ok(())
48}

Trait Implementations§

Source§

impl Debug for IdentifyController

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.