File: providers-mana-Add-dma-buf-support.patch

package info (click to toggle)
rdma-core 56.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,196 kB
  • sloc: ansic: 171,361; python: 13,724; sh: 2,774; perl: 1,465; makefile: 73
file content (71 lines) | stat: -rw-r--r-- 2,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From: Shiraz Saleem <shirazsaleem@microsoft.com>
Date: Thu, 6 Feb 2025 16:05:42 -0600
Subject: providers/mana: Add dma-buf support

Add support for dma-buf MR verb API in mana.

Signed-off-by: Shiraz Saleem <shirazsaleem@microsoft.com>
Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Origin: upstream, https://github.com/linux-rdma/rdma-core/pull/1557
---
 providers/mana/mana.c | 24 ++++++++++++++++++++++++
 providers/mana/mana.h |  4 ++++
 2 files changed, 28 insertions(+)

diff --git a/providers/mana/mana.c b/providers/mana/mana.c
index 581725f..9f8072d 100644
--- a/providers/mana/mana.c
+++ b/providers/mana/mana.c
@@ -158,6 +158,29 @@ int mana_dealloc_pd(struct ibv_pd *ibpd)
 	return 0;
 }
 
+struct ibv_mr *mana_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset,
+				  size_t length, uint64_t iova, int fd,
+				  int access)
+{
+	struct verbs_mr *vmr;
+	int ret;
+
+	vmr = calloc(1, sizeof(*vmr));
+	if (!vmr)
+		return NULL;
+
+	ret = ibv_cmd_reg_dmabuf_mr(pd, offset, length, iova, fd, access, vmr, NULL);
+	if (ret) {
+		verbs_err(verbs_get_ctx(pd->context),
+			  "Failed to register dma-buf MR\n");
+		errno = ret;
+		free(vmr);
+		return NULL;
+	}
+
+	return &vmr->ibv_mr;
+}
+
 struct ibv_mr *mana_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
 			   uint64_t hca_va, int access)
 {
@@ -257,6 +280,7 @@ static const struct verbs_context_ops mana_ctx_ops = {
 	.post_send = mana_post_send,
 	.query_device_ex = mana_query_device_ex,
 	.query_port = mana_query_port,
+	.reg_dmabuf_mr = mana_reg_dmabuf_mr,
 	.reg_mr = mana_reg_mr,
 	.req_notify_cq = mana_arm_cq,
 };
diff --git a/providers/mana/mana.h b/providers/mana/mana.h
index 7d31cae..2800bb2 100644
--- a/providers/mana/mana.h
+++ b/providers/mana/mana.h
@@ -198,6 +198,10 @@ mana_alloc_parent_domain(struct ibv_context *context,
 
 int mana_dealloc_pd(struct ibv_pd *pd);
 
+struct ibv_mr *mana_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset,
+				  size_t length, uint64_t iova, int fd,
+				  int access);
+
 struct ibv_mr *mana_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
 			   uint64_t hca_va, int access);