Hierarchical Addressing

Most of the library takes one or more hierarchical addresses as parameter.

Generic format

The hierarchical addresses are represented in generic format by the data-structure struct nvm_addr. One can construct an address by specifying the relative location within the device geometry down to the granularity of a sector.

Construct an address for sector 3 within chunk 142, within parallel unit 2, within parallel group 4.

nvm_addr s20_to_gen /dev/nvme0n1 4 2 142 3

Yielding:

naddrs: 1
addrs:
  - {val: 0x0402008e00000003, pugrp: 04, punit: 02, chunk: 0142, sectr: 0003}

The above hexadecimal-value can be given to any CLI command taking an 0xADDR as parameter.

Note

Addresses are zero-indexed, so channel four is the fifth channel

Note

C API address construction is done by assigning the members of struct nvm_addr

Device format

As the output from the device information shows, then there is a notion of a device format. The library user need not be concerned with the device format as the translation to device format is handled by the library backend nvm_be.

However, if one needs an address on device format for e.g. translating the addresses listed by nvm_cmd_rprt or for another tool such as nvme-cli, then the generic-format can be converted to device format using:

nvm_addr gen2dev /dev/nvme0n1 0x0402008e00000003

Yielding:

- {gen: 0x0402008e00000003, dev: 0x000000001211c003}

Or from device format to generic format:

nvm_addr dev2gen /dev/nvme0n1 0x000000001211c003

Yielding:

- {dev: 0x000000001211c003, gen: 0x0402008e00000003}

Note

C API address format conversion is done using nvm_addr_gen2dev and nvm_addr_dev2gen.

Address scope

An address specifies the relative location of all parts of the geometry, parallel unit group(PUGRP), parallel unit (PUNIT), chunk(CHUNK), and sector(sectr).

PUNIT address
Specify PUGRP and the PUNIT within the PUGRP
CHUNK address
Specify PUGRP, PUNIT within the PUGRP, and CHUNK within the PUNIT
SECTR address
Specify all relative locations of the geometry