Skip to content

Conversation

@gcabiddu
Copy link
Contributor

@gcabiddu gcabiddu commented Jan 6, 2026

Introduce two new public APIs to allow users to map their own pre-allocated memory buffers to IOVA addresses for zero-copy DMA operations:

  • qaeMemMapContiguousIova(): Allocates a contiguous IOVA region and maps user-provided virtual memory for DMA operations. Returns the IOVA address on success.

  • qaeMemUnmapContiguousIova(): Unmaps a previously mapped IOVA region and releases the IOVA address space for reuse.

These APIs enable users to avoid unnecessary memory copies when the QAT DMA engine transfers data to/from user-allocated buffers. The user is responsible for ensuring the virtual memory remains valid while the IOVA mapping is active.

@gcabiddu gcabiddu changed the title usdm: Expose IOVA mapping APIs for user memory usdm: expose IOVA mapping APIs for user memory Jan 6, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces two new public APIs (qaeMemMapContiguousIova and qaeMemUnmapContiguousIova) to enable zero-copy DMA operations by allowing users to map their pre-allocated memory buffers directly to IOVA addresses for QAT hardware access.

Key changes:

  • Added qaeMemMapContiguousIova() to allocate contiguous IOVA regions and map user-provided virtual memory for DMA operations
  • Added qaeMemUnmapContiguousIova() to unmap and release previously mapped IOVA regions
  • Both APIs include proper error handling for no-IOMMU mode and unregistered VFIO containers

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
quickassist/utilities/libusdm_drv/user_space/vfio/qae_mem_utils_vfio.c Implements the two new IOVA mapping/unmapping functions with validation checks and error handling
quickassist/utilities/libusdm_drv/qae_mem.h Adds comprehensive API documentation for the new public functions including parameters, return values, and usage notes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gcabiddu
Copy link
Contributor Author

gcabiddu commented Jan 6, 2026

Adding @Wangl56.

@Wangl56
Copy link

Wangl56 commented Jan 7, 2026

Adding @Wangl56.

Thanks @gcabiddu , this change looks good to me.

@gcabiddu gcabiddu force-pushed the iova_apis branch 2 times, most recently from 8482930 to cb71853 Compare January 8, 2026 13:11
Introduce two new public APIs to allow users to map their own
pre-allocated memory buffers to IOVA addresses for zero-copy DMA
operations:

  - qaeMemMapContiguousIova(virt, size): Allocates a contiguous IOVA
    region and maps user-provided virtual memory for DMA operations.
    The IOVA is aligned to IOVA_SLAB_SIZE (2MB) internally. Maximum
    supported size is 2GB. The mapping is registered in the USDM page
    table, enabling qaeVirtToPhysNUMA() lookups on the mapped region.
    Returns the IOVA address on success, 0 on failure.

  - qaeMemUnmapContiguousIova(virt, size): Unmaps a previously mapped
    IOVA region and releases the IOVA address space for reuse. The
    IOVA is automatically looked up from the page table using the
    provided virtual address.

These APIs enable users to avoid unnecessary memory copies when the QAT
DMA engine transfers data to/from user-allocated buffers. The user is
responsible for ensuring the virtual memory remains valid while the
IOVA mapping is active.

Note: These APIs are only available in VFIO mode and will fail if the
system is configured in no-IOMMU mode. Memory allocated through
qaeMemAllocNUMA() should not be mapped or unmapped using these APIs.

Signed-off-by: Giovanni Cabiddu <[email protected]>
@gcabiddu
Copy link
Contributor Author

Merged internally. Will be part of QATlib 26.02. Closing.

@gcabiddu gcabiddu closed this Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants