Repository navigation
verbs: Add parent-domain ibv_buf allocators for dma-buf - #1862
Open
abhijitG-xlnx wants to merge 7 commits into
Open
abhijitG-xlnx wants to merge 7 commits into
abhijitG-xlnx wants to merge 7 commits into
Conversation
ibv_alloc_user_buf() stays IBVERBS_1.19. Add ibv_alloc_user_buf_ex() and ibv_buf_get_context() so an application can recover its own record from the handle without a side table or container_of. The ex function also stores a dma-buf offset, which fill_attr_in_buf_umem() adds when it builds a dma-buf descriptor. The new fields are private, and mlx5 embeds struct ibv_buf, so the provider ABI moves to 67. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Append alloc_buf and free_buf to ibv_parent_domain_init_attr, gated by IBV_PARENT_DOMAIN_INIT_ATTR_BUF_ALLOCATORS. Existing alloc and free pointers stay where they are. alloc_buf returns an ibv_buf, NULL, or IBV_BUF_ALLOCATOR_USE_DEFAULT. Both callbacks are required when the bit is set. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Try alloc_buf when mapping a queue ring, then the existing void* alloc, then the anonymous map. Unmap calls free_buf with the saved handle when that is how the ring was mapped. The bit is stored only when it is set. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
To commit: ("RDMA/ionic: Accept CQ ring buffers as ioctl umem attributes").
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Add a per-UDMA-pipeline driver attribute for create_cq so each enabled CQ ring can be passed to the kernel as a struct ib_uverbs_buffer_desc instead of only as a raw address in the ionic_cq_req payload. The kernel advertises support through IONIC_CTX_CMASK_CQ_QP_BUF_UMEM in the get_context comp_mask. When the bit is set, the CQ is created with ibv_cmd_create_cq_ex2() and one IONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_<n> attribute per set UDMA mask bit. When the bit is clear, the existing ibv_cmd_create_cq() write path is used unchanged. ionic_cq_req and ionic_cq_resp are not changed. The ring address, depth, stride and mask are still filled in the request so that older kernels keep working and the kernel can read the ring geometry. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
When IONIC_CTX_CMASK_CQ_QP_BUF_UMEM is set, pass the send and receive rings to ibv_cmd_create_qp_ex2() as UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM and UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM virtual address descriptors. Describe only the rings the QP has. Without the capability bit, create the QP as before, with no driver attributes. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
When the parent-domain alloc_buf callback returns an ibv_buf that carries a dma-buf fd, pass the CQ, SQ and RQ rings to the kernel as IB_UVERBS_BUFFER_TYPE_DMABUF descriptors. The descriptor offset is the handle's dmabuf_offset, so several rings can share one dma-buf. Handles without a dma-buf fd are passed as virtual address descriptors. Set the ring address in ionic_cq_req and ionic_qp_req to zero for dma-buf rings, so the kernel takes the ring from the descriptor. dma-buf rings require IONIC_CTX_CMASK_CQ_QP_BUF_UMEM. Without it, free the handle and fail queue creation with EOPNOTSUPP. Document dma-buf rings in ionicdv(7). Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A parent-domain allocator can return only a raw pointer. A queue ring that lives in a dma-buf also needs the dma-buf fd, the byte offset of that ring inside the dma-buf, and a way for the application to recover its own record from the handle. Without those, several rings cannot share one dma-buf, and the provider cannot hand the kernel an
ib_uverbs_buffer_desc.libibverbs grows an
ibv_bufparent-domain allocator that carries the fd, the offset, and an application context. The ionic provider uses that handle for CQ, SQ, and RQ rings, and passes it to the kernel as a buffer descriptor when the kernel advertises support.libibverbs
struct ibv_bufis what the provider gives the kernel. These changes make one handle enough to describe either a plain virtual address or a dma-buf slice, including a slice that does not start at byte 0 of the dma-buf.ibv_alloc_user_buf_ex()storesdmabuf_offsetand an opaquecontexton a privateibv_buf.ibv_buf_get_context()returns that pointer.ibv_alloc_user_buf()stays inIBVERBS_1.19and stores offset 0 and a NULL context. The new symbols areIBVERBS_1.20. The private provider ABI moves to 67 because mlx5 embedsstruct ibv_buf.fill_attr_in_buf_umem()writes aIB_UVERBS_BUFFER_TYPE_DMABUFdescriptor whose address isdmabuf_offsetplus the distance frombuf->addrto the requested slice. Each ring can have its own handle and its own offset in one dma-buf. A handle with no dma-buf fd is described asIB_UVERBS_BUFFER_TYPE_VA.ibv_alloc_parent_domain()gainsalloc_bufandfree_buf, selected byIBV_PARENT_DOMAIN_INIT_ATTR_BUF_ALLOCATORS.alloc_bufreturns anibv_buf, NULL on failure, orIBV_BUF_ALLOCATOR_USE_DEFAULTto decline. Both callbacks are required when the bit is set. The existingallocandfreepointers are unchanged. mlx5 rejects the new bit.ionic
ionic takes the handle from
alloc_bufand, when the kernel can accept it, sends the ring as a buffer descriptor instead of only as a raw address.alloc_buf, then the existingvoid *allocator, then an anonymous mapping. Theibv_bufis kept on the queue and passed tofree_bufwhen the queue is destroyed.IONIC_CTX_CMASK_CQ_QP_BUF_UMEMandIONIC_IB_ATTR_CREATE_CQ_BUF_UMEM_0and_1.ibv_cmd_create_cq_ex2()as a buffer descriptor. SQ and RQ rings are passed toibv_cmd_create_qp_ex2()asUVERBS_ATTR_CREATE_QP_SQ_BUF_UMEMandUVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM. Only rings the QP has are described. Ring geometry stays in the existing ionic request.dmabuf_offset, and the request ring address is 0 so the kernel takes the ring from the descriptor. A handle without a dma-buf fd stays a virtual-address descriptor. If the kernel does not advertise the capability, a dma-buf handle is freed and queue creation fails withEOPNOTSUPP.ionicdv(7)documents dma-buf rings, the parent-domain allocator, the kernel capability, the required CPU mapping, and sharing one dma-buf throughdmabuf_offset.