iova-tree header

The documentation of QEMU’s qemu/iova-tree.h header.

IOVATree * iova_tree_new(void)

Parameters

void
no arguments

Description

Create a new iova tree.

Return

the tree pointer when succeeded, or NULL if error.

int iova_tree_insert(IOVATree * tree, DMAMap * map)

Parameters

IOVATree * tree
the iova tree to insert
DMAMap * map
the mapping to insert

Description

Insert an iova range to the tree. If there is overlapped ranges, IOVA_ERR_OVERLAP will be returned.

Return

0 if succeeded, or <0 if error.

int iova_tree_remove(IOVATree * tree, DMAMap * map)

Parameters

IOVATree * tree
the iova tree to remove range from
DMAMap * map
the map range to remove

Description

Remove mappings from the tree that are covered by the map range provided. The range does not need to be exactly what has inserted, all the mappings that are included in the provided range will be removed from the tree. Here map->translated_addr is meaningless.

Return

0 if succeeded, or <0 if error.

DMAMap * iova_tree_find(IOVATree * tree, DMAMap * map)

Parameters

IOVATree * tree
the iova tree to search from
DMAMap * map
the mapping to search

Description

Search for a mapping in the iova tree that overlaps with the mapping range specified. Only the first found mapping will be returned.

Return

DMAMap pointer if found, or NULL if not found. Note that the returned DMAMap pointer is maintained internally. User should only read the content but never modify or free the content. Also, user is responsible to make sure the pointer is valid (say, no concurrent deletion in progress).

DMAMap * iova_tree_find_address(IOVATree * tree, hwaddr iova)

Parameters

IOVATree * tree
the iova tree to search from
hwaddr iova
the iova address to find

Description

Similar to iova_tree_find(), but it tries to find mapping with range iova=iova & size=0.

Return

same as iova_tree_find().

void iova_tree_foreach(IOVATree * tree, iova_tree_iterator iterator)

Parameters

IOVATree * tree
the iova tree to iterate on
iova_tree_iterator iterator
the interator for the mappings, return true to stop

Description

Iterate over the iova tree.

Return

1 if found any overlap, 0 if not, <0 if error.

void iova_tree_destroy(IOVATree * tree)

Parameters

IOVATree * tree
the iova tree to destroy

Description

Destroy an existing iova tree.

Return

None.