diff mbox series

[rdma-core,2/3] libhns: Add dealloc mw support for hip08

Message ID 1536223798-21227-3-git-send-email-liuyixian@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series Add mw support for hip08 in user space | expand

Commit Message

Yixian Liu Sept. 6, 2018, 8:49 a.m. UTC
This patch adds memory window (mw) deallocation support in
user space driver.

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
---
 providers/hns/hns_roce_u.c       |  1 +
 providers/hns/hns_roce_u.h       |  1 +
 providers/hns/hns_roce_u_verbs.c | 13 +++++++++++++
 3 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index dd0e8fb..7a59644 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -76,6 +76,7 @@  static const struct verbs_context_ops hns_common_ops = {
 	.reg_mr = hns_roce_u_reg_mr,
 	.rereg_mr = hns_roce_u_rereg_mr,
 	.alloc_mw = hns_roce_u_alloc_mw,
+	.dealloc_mw = hns_roce_u_dealloc_mw,
 };
 
 static struct verbs_context *hns_roce_alloc_context(struct ibv_device *ibdev,
diff --git a/providers/hns/hns_roce_u.h b/providers/hns/hns_roce_u.h
index f023b6a..ac75533 100644
--- a/providers/hns/hns_roce_u.h
+++ b/providers/hns/hns_roce_u.h
@@ -276,6 +276,7 @@  int hns_roce_u_rereg_mr(struct verbs_mr *mr, int flags, struct ibv_pd *pd,
 int hns_roce_u_dereg_mr(struct verbs_mr *mr);
 
 struct ibv_mw *hns_roce_u_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type);
+int hns_roce_u_dealloc_mw(struct ibv_mw *mw);
 
 struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe,
 				    struct ibv_comp_channel *channel,
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index be14430..5a5e767 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -194,6 +194,19 @@  struct ibv_mw *hns_roce_u_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type)
 	return mw;
 }
 
+int hns_roce_u_dealloc_mw(struct ibv_mw *mw)
+{
+	int ret;
+
+	ret = ibv_cmd_dealloc_mw(mw);
+	if (ret)
+		return ret;
+
+	free(mw);
+
+	return ret;
+}
+
 static int align_cq_size(int req)
 {
 	int nent;