Skip to content

Commit 0dee6b4

Browse files
authored
Merge pull request #1709 from TaranovK/kotaranov/mw
providers/mana: allocate/destroy MWs
2 parents 2b75cb4 + 4c1aee0 commit 0dee6b4

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

providers/mana/mana.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,40 @@ int mana_dealloc_pd(struct ibv_pd *ibpd)
198198
return 0;
199199
}
200200

201+
static struct ibv_mw *
202+
mana_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type)
203+
{
204+
struct ib_uverbs_alloc_mw_resp resp;
205+
struct ibv_alloc_mw cmd;
206+
struct ibv_mw *mw;
207+
int ret;
208+
209+
mw = calloc(1, sizeof(*mw));
210+
if (!mw)
211+
return NULL;
212+
213+
ret = ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd), &resp,
214+
sizeof(resp));
215+
if (ret) {
216+
free(mw);
217+
return NULL;
218+
}
219+
220+
return mw;
221+
}
222+
223+
static int mana_dealloc_mw(struct ibv_mw *mw)
224+
{
225+
int ret;
226+
227+
ret = ibv_cmd_dealloc_mw(mw);
228+
if (ret)
229+
return ret;
230+
231+
free(mw);
232+
return 0;
233+
}
234+
201235
struct ibv_mr *mana_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset,
202236
size_t length, uint64_t iova, int fd,
203237
int access)
@@ -362,6 +396,7 @@ static void mana_async_event(struct ibv_context *context,
362396
}
363397

364398
static const struct verbs_context_ops mana_ctx_ops = {
399+
.alloc_mw = mana_alloc_mw,
365400
.alloc_pd = mana_alloc_pd,
366401
.alloc_dm = mana_alloc_dm,
367402
.async_event = mana_async_event,
@@ -371,6 +406,7 @@ static const struct verbs_context_ops mana_ctx_ops = {
371406
.create_qp_ex = mana_create_qp_ex,
372407
.create_rwq_ind_table = mana_create_rwq_ind_table,
373408
.create_wq = mana_create_wq,
409+
.dealloc_mw = mana_dealloc_mw,
374410
.dealloc_pd = mana_dealloc_pd,
375411
.dereg_mr = mana_dereg_mr,
376412
.destroy_cq = mana_destroy_cq,

0 commit comments

Comments
 (0)