Skip to content

provider/irdma: Implement CoCo buffer APIs - #1766

Draft
10000TB wants to merge 13 commits into
linux-rdma:masterfrom
10000TB:irdma-CoCo-buffer
Draft

provider/irdma: Implement CoCo buffer APIs#1766
10000TB wants to merge 13 commits into
linux-rdma:masterfrom
10000TB:irdma-CoCo-buffer

Conversation

@10000TB

@10000TB 10000TB commented Jun 26, 2026

Copy link
Copy Markdown

Implement CoCo DMA Bounce buffer APIs defined in #1748

  • alloc parent domain
  • ibv_alloc_buf, ibv_free_buf
  • migration to use verbs_qp in order to be able to use *{qp, cq, srq}_ex{2} cmds
  • irdma-abi.h updated to include irdma driver specific ioctl attributes.
  • Add a ibv_cmd_create_srq_ex2 to libibverbs to support irdma srq creation via ioctl.
  • Migrations
    • QP (push dbl / hw state included)
    • CQ
    • SRQ (shadow area appended at the end for doorbell)
  • irdma driver support ( Review in Progress )
  • Kernel Integrations.

cc: @jakemoroni @jpirko

@10000TB
10000TB marked this pull request as draft June 26, 2026 06:19
@10000TB 10000TB changed the title provider/Irdma: Implement CoCo buffer APIs provider/irdma: Implement CoCo buffer APIs Jun 26, 2026
@10000TB
10000TB force-pushed the irdma-CoCo-buffer branch 2 times, most recently from 8e618f9 to fbd917c Compare June 27, 2026 07:06
@jakemoroni

jakemoroni commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Hi,

Thanks for getting a jump on this. We should probably work out some of the uAPI details since irdma is a bit unusual in that regard.

As you are aware, irdma handles user-allocated QP/CQ/SRQ ring buffers differently from other drivers (from what I can tell). For irdma, QP/CQ/SRQ creation is a two step process where the ring buffers are allocated and registered as special memory regions (indicated via flags in udata) using the normal reg_mr command prior to issuing the actual ibv_cmd_create_qp/cq/srq call. The driver maintains an internal registry to correlate these special MRs with their child ring object when the object is created.

So, I think we have a few options:

  1. Add a flag attribute to irdma's reg_dmabuf_mr command (UVERBS_ATTR_FLAGS_IN) to indicate whether the region is a normal memory region or a user ring region, similar to what is passed for reg_mr today. Then, the provider would follow mostly the same flow, but would just use reg_dmabuf_mr for dmabuf backed rings. This is likely the simplest change in terms of the irdma kernel driver as well since it already shares a lot of code between reg_dmabuf_mr and normal reg_mr.
  2. Change irdma to support providing umem during the actual create_qp/cq/srq call. This is similar to what you've done but would ideally use the new UVERBS_ATTR_UMEM attribute as opposed to adding new fields to the driver udata for each command. This would be a larger change and should probably be treated as a separate endeavor if we decide to go down this route, since it's kind of unrelated to dmabuf ring support (though we would get that for free).
  3. There were also talks of some way to allow for mmap-ed dmabuf VAs to be passed to normal ibv_reg_mr. I don't know if that's still PoR but if so, then we wouldn't need any irdma kernel driver changes at all.

Option 1 is the easiest and probably carries less risk, but I am not sure if the maintainers would prefer option 2 since it's a more standard way.

As a side note, we will probably need to fix a few irdma kernel driver issues before adding new features:

  1. Need to support robust udata. I just sent a patch series for this.
  2. There were some bugs related to this two step user ring process. Specifically, we need to prevent a bad userspace from deregistering these special MRs if there's still a QP/CQ/SRQ object in HW pointing to it. FWIW, this probably wouldn't exist with option 2, but we're still stuck supporting the two step process anyway.

@10000TB

10000TB commented Jun 27, 2026

Copy link
Copy Markdown
Author

SG to clarify and align on uAPIs. Good call.

The simpler the better - Therefore, I also prefer option 1.

Option 2 appear a reasonable step forward to converge with standard ways. Though, non-trivial work to support IOCTl ABIs appears needed. Simply modifying the legacy write syscall ABI structs appears a plausible middle ground. A recent patch for fixing a vulnerability on user triggered NULL deref appears specific to the two step process and a counter argument against the two step process (I think your side is also spot on). Though I don't think the two step process is bad. Converging with standard ways is probably the strongest argument, if the alignment is option 2.

For VA dmabuf, it sounds interesting. I'd be curious to learn more. My limited understanding is that kernel side needs a dmabuf fd to cast it to dmabuf structure. Maybe there is no need to cast it at all in kernel with the mmapped approach.

Comment thread providers/irdma/uverbs.c Outdated
Comment thread providers/irdma/uverbs.c Outdated
Comment thread providers/irdma/uverbs.c Outdated
Comment thread providers/irdma/uverbs.c Outdated
Comment thread kernel-headers/rdma/irdma-abi.h Outdated
@10000TB

10000TB commented Jul 3, 2026

Copy link
Copy Markdown
Author

I am prepping ioctl support for irdma driver. Will refresh this shortly.
I'll also need gather feedback from, and align with other folks on my end, like @jakemoroni.
For now, keeping this as draft.

Regards,
David

@10000TB
10000TB force-pushed the irdma-CoCo-buffer branch 3 times, most recently from 1cbd2e8 to 7ca67f6 Compare July 17, 2026 23:43
@10000TB

10000TB commented Jul 18, 2026

Copy link
Copy Markdown
Author

Hello,

kernel RDMA/irdma series is ready (being reviewed internally). Will send them out shortly.

Regards,
David

10000TB added 13 commits August 3, 2026 01:52
Allocation of system_cc_dmabuf is only carried out if CoCo
DMA bounce feature in device, and cc unprotected attribute are
both present. Proper cleanup is added to cleanup path.

Signed-off-by: David Hu <xuehaohu@google.com>
Add an `irdma_buf` wrapping ibv_buf following existing
pattern, and enables irdma specific contexts and state
handling.

Signed-off-by: David Hu <xuehaohu@google.com>
Cleanup path is also properly updated to be dmabuf aware.
This still only handles legacy write() cmd, with just
incremental defense against dma-buf backed mr for cq.
The else branch for ioctl is in follow up commit.

Signed-off-by: David Hu <xuehaohu@google.com>
Cleanup path is also updated accordingly. Clean up of
buf is consolidated into `irdma_destroy_vmapped_qp()`.

Signed-off-by: David Hu <xuehaohu@google.com>
Cleanup path is also updated accordingly

Signed-off-by: David Hu <xuehaohu@google.com>
irdma provider will be the first consumer.

Signed-off-by: David Hu <xuehaohu@google.com>
irdma driver specific ioctl attributes implemented
by irdma driver, mostly just matching legacy write
cmd req structs.

Signed-off-by: David Hu <xuehaohu@google.com>
Needed for qp and srq creation ex2 cmds, as fallback
mechanisms

Signed-off-by: David Hu <xuehaohu@google.com>
This is needed for modern ex2 qp create command.
Modern ex2 qp create command is needed for pass
in driver attrs.

Signed-off-by: David Hu <xuehaohu@google.com>
Signed-off-by: David Hu <xuehaohu@google.com>
Signed-off-by: David Hu <xuehaohu@google.com>
This switches from `ibv_cmd_create_qp` to modern
`ibv_cmd_create_qp_ex2` so that driver attrs can
be passed in.

Signed-off-by: David Hu <xuehaohu@google.com>
In case of dmabuf backed SRQ, there is not a
separate dmabuf fd for shadow area. Instead, the
shadow shares a same dmabuf fd as SRQ buf, but
with an offset as the size of the SRQ buf size.

Modern ex interfaces are used so that driver
specific attributes can be passed to ioctl.

Signed-off-by: David Hu <xuehaohu@google.com>
@10000TB
10000TB force-pushed the irdma-CoCo-buffer branch from 7ca67f6 to d29e8ad Compare August 3, 2026 01:54
@10000TB
10000TB marked this pull request as ready for review August 3, 2026 03:50
@10000TB
10000TB marked this pull request as draft August 3, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants