diff mbox series

[rdma-core,1/3] libhns: Add alloc mw support for hip08

Message ID 1536223798-21227-2-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) allocation support in
the user space driver.

Signed-off-by: Yixian Liu <liuyixian@huawei.com>
---
 providers/hns/hns_roce_u.c       |  1 +
 providers/hns/hns_roce_u.h       |  2 ++
 providers/hns/hns_roce_u_verbs.c | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+)

Comments

Jason Gunthorpe Sept. 6, 2018, 6:40 p.m. UTC | #1
On Thu, Sep 06, 2018 at 04:49:56PM +0800, Yixian Liu wrote:
> This patch adds memory window (mw) allocation support in
> the user space driver.
> 
> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
>  providers/hns/hns_roce_u.c       |  1 +
>  providers/hns/hns_roce_u.h       |  2 ++
>  providers/hns/hns_roce_u_verbs.c | 19 +++++++++++++++++++
>  3 files changed, 22 insertions(+)
> 
> diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
> index 7536646..dd0e8fb 100644
> +++ b/providers/hns/hns_roce_u.c
> @@ -75,6 +75,7 @@ static const struct verbs_context_ops hns_common_ops = {
>  	.query_qp = hns_roce_u_query_qp,
>  	.reg_mr = hns_roce_u_reg_mr,
>  	.rereg_mr = hns_roce_u_rereg_mr,
> +	.alloc_mw = hns_roce_u_alloc_mw,
>  };

This list is supposed to be sorted..

Jason
Yixian Liu Sept. 10, 2018, 8:57 a.m. UTC | #2
On 2018/9/7 2:40, Jason Gunthorpe wrote:
> On Thu, Sep 06, 2018 at 04:49:56PM +0800, Yixian Liu wrote:
>> This patch adds memory window (mw) allocation support in
>> the user space driver.
>>
>> Signed-off-by: Yixian Liu <liuyixian@huawei.com>
>>  providers/hns/hns_roce_u.c       |  1 +
>>  providers/hns/hns_roce_u.h       |  2 ++
>>  providers/hns/hns_roce_u_verbs.c | 19 +++++++++++++++++++
>>  3 files changed, 22 insertions(+)
>>
>> diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
>> index 7536646..dd0e8fb 100644
>> +++ b/providers/hns/hns_roce_u.c
>> @@ -75,6 +75,7 @@ static const struct verbs_context_ops hns_common_ops = {
>>  	.query_qp = hns_roce_u_query_qp,
>>  	.reg_mr = hns_roce_u_reg_mr,
>>  	.rereg_mr = hns_roce_u_rereg_mr,
>> +	.alloc_mw = hns_roce_u_alloc_mw,
>>  };
> 
> This list is supposed to be sorted..
> 
> Jason
> 

Thanks, will fix it next version.
diff mbox series

Patch

diff --git a/providers/hns/hns_roce_u.c b/providers/hns/hns_roce_u.c
index 7536646..dd0e8fb 100644
--- a/providers/hns/hns_roce_u.c
+++ b/providers/hns/hns_roce_u.c
@@ -75,6 +75,7 @@  static const struct verbs_context_ops hns_common_ops = {
 	.query_qp = hns_roce_u_query_qp,
 	.reg_mr = hns_roce_u_reg_mr,
 	.rereg_mr = hns_roce_u_rereg_mr,
+	.alloc_mw = hns_roce_u_alloc_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 6c56bee..f023b6a 100644
--- a/providers/hns/hns_roce_u.h
+++ b/providers/hns/hns_roce_u.h
@@ -275,6 +275,8 @@  int hns_roce_u_rereg_mr(struct verbs_mr *mr, int flags, struct ibv_pd *pd,
 			void *addr, size_t length, int access);
 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);
+
 struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe,
 				    struct ibv_comp_channel *channel,
 				    int comp_vector);
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 14eeb5e..be14430 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -175,6 +175,25 @@  int hns_roce_u_dereg_mr(struct verbs_mr *vmr)
 	return ret;
 }
 
+struct ibv_mw *hns_roce_u_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type)
+{
+	struct ibv_mw *mw;
+	struct ibv_alloc_mw cmd = {};
+	struct ib_uverbs_alloc_mw_resp resp = {};
+
+	mw = malloc(sizeof(*mw));
+	if (!mw)
+		return NULL;
+
+	if (ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd),
+			     &resp, sizeof(resp))) {
+		free(mw);
+		return NULL;
+	}
+
+	return mw;
+}
+
 static int align_cq_size(int req)
 {
 	int nent;