Skip to content

libibverbs: Add DMA-buf fd export for ibv_buf#1770

Open
jpirko wants to merge 3 commits into
linux-rdma:masterfrom
jpirko:wip_ibv_buf_fd
Open

libibverbs: Add DMA-buf fd export for ibv_buf#1770
jpirko wants to merge 3 commits into
linux-rdma:masterfrom
jpirko:wip_ibv_buf_fd

Conversation

@jpirko

@jpirko jpirko commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Add ibv_export_buf_dmabuf_fd() so applications can pass DMA-buf-backed provider allocations to APIs that import DMA-buf file descriptors.

Expose it through pyverbs, document the API, and add test coverage.

Jiri Pirko added 3 commits July 14, 2026 16:41
Add ibv_export_buf_dmabuf_fd() so applications can obtain a
caller-owned DMA-buf file descriptor from provider-aware buffers that
are backed by DMA-buf memory.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Allow Python users to retrieve a caller-owned DMA-buf file
descriptor from a Buf's backing memory.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Add buffer API checks for successful fd export on DMA-buf backed
buffers and ENODATA on ordinary memory buffers.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Comment thread libibverbs/verbs.c

int ibv_export_buf_dmabuf_fd(struct ibv_buf *buf)
{
if (buf->dmabuf_fd < 0) {

@10000TB 10000TB Jul 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder how do you feel about a potential view that this conflates (1) *buf is backed by VA, and (2) dmabuf *buf has a bad fd ?

Thinking of sth like enum ibv_buf_alloc_type alloc_type; as part of ibv_buf, so we return EOPNOTSUPP on .type != IBV_BUF_ALLOC_TYPE_DMABUF, and ENODATA on bad dmabuf fd.

But not having a .type within ibv_but does keep it simple, and distinguishing between (1) and (2) may not add much value.

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.

2 participants