Obtaining device informationΒΆ

To begin with, knowing the physical geometry of a device is essential for working with physical addressing. Device information is obtained by invoking:

nvm_dev info /dev/nvme0n1

Which will yield device information as shown below:

# Device information -- nvm_dev_pr
dev:
  verid: 0x02
  be_id: 0x02
  name: 'nvme0n1'
  path: '/dev/nvme0n1'
  fd: 3
  ssw: 12
  pmode: 'DUAL'
  erase_naddrs_max: 64
  read_naddrs_max: 64
  write_naddrs_max: 64
  meta_mode: 0
  bbts_cached: 0
dev_geo:
  nchannels: 16
  nluns: 8
  nplanes: 2
  nblocks: 1020
  npages: 512
  nsectors: 4
  page_nbytes: 16384
  sector_nbytes: 4096
  meta_nbytes: 16
  tbytes: 2190433320960
  tmbytes: 2088960
dev_ppaf:
  ch_off: 25
  ch_len: 04
  lun_off: 22
  lun_len: 03
  pl_off: 02
  pl_len: 01
  blk_off: 12
  blk_len: 10
  pg_off: 03
  pg_len: 09
  sec_off: 00
  sec_len: 02
dev_ppaf_mask:
  ch:  '0000000000000000000000000000000000011110000000000000000000000000'
  lun: '0000000000000000000000000000000000000001110000000000000000000000'
  pl:  '0000000000000000000000000000000000000000000000000000000000000100'
  blk: '0000000000000000000000000000000000000000001111111111000000000000'
  pg:  '0000000000000000000000000000000000000000000000000000111111111000'
  sec: '0000000000000000000000000000000000000000000000000000000000000011'

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.