Device Attributes

To begin with, knowing the geometry and write-contraints of a device is essential for working with hierarchical addressing.

Raw

Device information is obtained by invoking the nvm_cmd idfy in the raw form:

nvm_cmd idfy /dev/nvme0n1

Which will yield device information as shown below:

# nvm_cmd_idfy
idfy:
  verid: 00000010
  verid_minor: 00000000
  mccap: 00000000000000000000000000000001
lbaf:
  pugrp: 3
  punit: 2
  chunk: 11
  sectr: 13
lgeo:
  npugrp: 8
  npunit: 4
  nchunk: 1474
  nsectr: 6144
wrt:
  ws_min: 24
  ws_opt: 24
  mw_cunits: 192
perf:
  trdt: 40000
  trdm: 80000
  twrt: 1900000
  twrm: 3700000
  tcet: 7000000
  tcem: 20000000

Derived

Additional information, included derived attributes is obtained by nvm_dev info:

nvm_dev info /dev/nvme0n1

Which will yield device information as shown below:

# Device information -- nvm_dev_pr
dev_attr:
  verid: 0x02
  be_id: 0x01
  be_name: 'NVM_BE_IOCTL'
  name: 'nvme0n1'
  path: '/dev/nvme0n1'
  fd: 3
  ssw: 12
  mccap: '00000000000000000000000000000001'
  bbts_cached: 0
  quirks: '00000000'
dev_geo:
  verid: 0x02
  npugrp: 8
  npunit: 4
  nchunk: 1474
  nsectr: 6144
  nbytes: 4096
  nbytes_oob: 16
  tbytes: 1187021586432
  tmbytes: 1132032
dev_cmd_opts:
  mask: '00000000000000000000000011001000'
  iomd: 'SYNC'
  addr: 'VECTOR'
  plod: 'PRP'
dev_vblk_opts:
  pmode: 'SNGL'
  erase_naddrs_max: 64
  read_naddrs_max: 64
  write_naddrs_max: 64
  meta_mode: 0
dev_ppaf: ~
dev_ppaf_mask: ~
dev_lbaf:
  pugrp: 3
  punit: 2
  chunk: 11
  sectr: 13
dev_lbaz:
  pugrp: 26
  punit: 24
  chunk: 13
  sectr: 0
dev_lbam:
  pugrp:  '0000000000000000000000000000000000011100000000000000000000000000'
  punit:  '0000000000000000000000000000000000000011000000000000000000000000'
  chunk:  '0000000000000000000000000000000000000000111111111110000000000000'
  sectr:  '0000000000000000000000000000000000000000000000000001111111111111'

The parts involved from the C API are: nvm_dev_open to obtain a device handle, nvm_dev_pr to produce the output above, and lastly nvm_dev_close to terminate the handle properly.

When using the C API, values and structures are retrieved using the attribute getters nvm_dev_get_* e.g. use nvm_dev_get_geo to obtain the geometry of a given device.