-
Notifications
You must be signed in to change notification settings - Fork 38
usdm: expose IOVA mapping APIs for user memory #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.
quickassist/utilities/libusdm_drv/user_space/vfio/qae_mem_utils_vfio.c
Outdated
Show resolved
Hide resolved
|
Adding @Wangl56. |
8482930 to
cb71853
Compare
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]>
|
Merged internally. Will be part of QATlib 26.02. Closing. |
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.