nvm_addr - Addressing

nvm_addr

struct nvm_addr

Encapsulation of generic physical nvm addressing.

Although the user need not worry about device specific address formats the user has to know and respect addressing within device specific geometric boundaries.

For that purpose one can use the struct nvm_geo of an struct nvm_dev to obtain device specific geometries.

Public Members

uint64_t sec

Sector address.

uint64_t pg

Page address.

uint64_t pl

Plane address.

uint64_t blk

Block address.

uint64_t lun

LUN address.

uint64_t ch

Channel address.

struct nvm_addr::@0::@2 g

Address packing and geometric accessors.

uint64_t sectr

Logical Sector in Chunk.

uint64_t chunk

Chunk in PU.

uint64_t punit

Parallel Unit (PU) in PUG.

uint64_t pugrp

Parallel Unit Group (PUG)

struct nvm_addr::@0::@3 l
uint64_t ppa

Address as raw value.

uint64_t val

Address as raw value.

union nvm_addr::@0 nvm_addr::@1

nvm_addr_erase

ssize_t nvm_addr_erase(struct nvm_dev * dev, struct nvm_addr addrs[], int naddrs, uint16_t flags, struct nvm_ret * ret)

Erase nvm at given addresses.

Note
The addresses given to this function are interpreted as block addresses, in contrast to nvm_addr_mark, nvm_addr_write, and nvm_addr_read for which the address is interpreted as a sector address.
Return
0 on success. On error: returns -1, sets errno accordingly, and fills ret with lower-level result and status codes
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addrs: Array of memory address
  • naddrs: Length of array of memory addresses
  • flags: Access mode
  • ret: Pointer to structure in which to store lower-level status and result.

nvm_addr_read

ssize_t nvm_addr_read(struct nvm_dev * dev, struct nvm_addr addrs[], int naddrs, void * buf, void * meta, uint16_t flags, struct nvm_ret * ret)

Read content of nvm at addresses into buf.

Note
The addresses given to this function are interpreted as sector addresses, in contrast to nvm_addr_mark and nvm_addr_erase for which the address is interpreted as a block address.
Return
0 on success. On error: returns -1, sets errno accordingly, and fills ret with lower-level result and status codes
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addrs: List of memory address
  • naddrs: Length of array of memory addresses
  • buf: Buffer to store result of read into, must be aligned to device granularity min read and size equal to naddrs * geo.sector_nbytes
  • meta: Buffer to store content of metadata, must be of size equal to device naddrs * geo.meta_nbytes
  • flags: Access mode
  • ret: Pointer to structure in which to store lower-level status and result.

nvm_addr_write

ssize_t nvm_addr_write(struct nvm_dev * dev, struct nvm_addr addrs[], int naddrs, const void * buf, const void * meta, uint16_t flags, struct nvm_ret * ret)

Write content of buf to nvm at address(es)

Note
The addresses given to this function are interpreted as sector addresses, in contrast to nvm_addr_mark and nvm_addr_erase for which the address is interpreted as a block address.
Return
0 on success. On error: returns -1, sets errno accordingly, and fills ret with lower-level result and status codes
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addrs: Array of memory address
  • naddrs: Length of array of memory addresses
  • buf: The buffer which content to write, must be aligned to device geometry of minimal write granularity and size equal to naddrs * geo.nbytes
  • meta: Buffer containing metadata, must be of size equal to device naddrs * geo.meta_nbytes
  • flags: Access mode
  • ret: Pointer to structure in which to store lower-level status and result.

nvm_addr_check

int nvm_addr_check(struct nvm_addr addr, const struct nvm_dev * dev)

Checks whether the given address exceeds bounds of the geometry of the given device.

Return
A mask of exceeded boundaries
Parameters
  • addr: The addr to check
  • dev: The device of which to check geometric bounds against

nvm_addr_dev2gen

struct nvm_addr nvm_addr_dev2gen(struct nvm_dev * dev, uint64_t addr)

Converts a given physical address on device-format to generic-format.

Return
Physical address on generic-format
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addr: The physical address on device-format to convert

nvm_addr_gen2dev

uint64_t nvm_addr_gen2dev(struct nvm_dev * dev, struct nvm_addr addr)

Converts a given physical address generic-format to device-format.

Return
Physical address on device-format
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addr: The physical address on generic-format to convert

nvm_addr_gen2lba

uint64_t nvm_addr_gen2lba(struct nvm_dev * dev, struct nvm_addr addr)

Converts a given physical address on generic-format to LBA offset.

Return
Logical address as LBA offset
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addr: The physical address on generic-format to convert

nvm_addr_gen2off

uint64_t nvm_addr_gen2off(struct nvm_dev * dev, struct nvm_addr addr)

Converts a given physical address on generic-format to byte offset.

Return
Logical address as byte offset
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • addr: The physical address on generic-format to convert

nvm_addr_lba2gen

struct nvm_addr nvm_addr_lba2gen(struct nvm_dev * dev, uint64_t off)

Converts a given LBA offset to physical address on generic-format.

Return
Physical address on generic-format
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • off: Logical address as LBA offset to convert

nvm_addr_off2gen

struct nvm_addr nvm_addr_off2gen(struct nvm_dev * dev, uint64_t off)

Converts a given byte offset to physical address on generic-format.

Return
Physical address on generic-format
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • off: Logical address as byte offset to convert

nvm_addr_pr

void nvm_addr_pr(struct nvm_addr addr)

Prints a humanly readable representation of the given address.

Parameters
  • addr: The address to print

nvm_addr_prn

void nvm_addr_prn(struct nvm_addr * addr, unsigned int naddrs)

Prints a humanly readable representation of the given list of addresses.