Skip to content

Commit

Permalink
when creating CQ dbrec, route to peer creation and registration funct…
Browse files Browse the repository at this point in the history
…ions

fixes #5
  • Loading branch information
drossetti committed Jan 24, 2017
1 parent 697dfda commit 0672706
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/mlx5.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ struct mlx5_cq {
struct mlx5_buf peer_buf;
struct mlx5_peek_entry **peer_peek_table;
struct mlx5_peek_entry *peer_peek_free;
struct ibv_exp_peer_buf *peer_dbrec_buf;
uint64_t peer_dbrec_id;
};

struct mlx5_srq {
Expand Down
44 changes: 41 additions & 3 deletions src/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,37 @@ static struct ibv_cq *create_cq(struct ibv_context *context,
goto err_buf;
}

cq->dbrec = mlx5_alloc_dbrec(mctx);
if (cq->peer_enabled && cq->peer_ctx->buf_alloc) {
struct ibv_exp_peer_buf_alloc_attr attr;

attr.length = mctx->cache_line_size;
attr.peer_id = cq->peer_ctx->peer_id;
attr.dir = IBV_EXP_PEER_DIRECTION_FROM_PEER |
IBV_EXP_PEER_DIRECTION_TO_HCA;
attr.alignment = mctx->cache_line_size;
cq->peer_dbrec_buf = cq->peer_ctx->buf_alloc(&attr);
if (cq->peer_dbrec_buf)
cq->dbrec = cq->peer_dbrec_buf->addr;
}
if (!cq->dbrec)
cq->dbrec = mlx5_alloc_dbrec(mctx);
if (!cq->dbrec) {
mlx5_dbg(fp, MLX5_DBG_CQ, "\n");
goto err_peer_buf;
}

if (cq->peer_enabled && cq->peer_ctx->register_va) {
cq->peer_dbrec_id =
cq->peer_ctx->register_va((void*)cq->dbrec,
mctx->cache_line_size,
cq->peer_ctx->peer_id,
cq->peer_dbrec_buf);
if (!cq->peer_dbrec_id) {
mlx5_dbg(fp, MLX5_DBG_QP, "\n");
goto err_peer_buf;
}
}

cq->dbrec[MLX5_CQ_SET_CI] = 0;
cq->dbrec[MLX5_CQ_ARM_DB] = 0;
cq->arm_sn = 0;
Expand Down Expand Up @@ -811,8 +836,14 @@ static struct ibv_cq *create_cq(struct ibv_context *context,
mlx5_free_db(mctx, cq->dbrec);

err_peer_buf:
if (cq->peer_enabled)
if (cq->peer_enabled) {
mlx5_free_actual_buf(mctx, &cq->peer_buf);
if (cq->peer_dbrec_buf) {
if (cq->peer_dbrec_id)
cq->peer_ctx->unregister_va(cq->peer_dbrec_id, cq->peer_ctx->peer_id);
cq->peer_ctx->buf_release(cq->peer_dbrec_buf);
}
}

err_buf:
mlx5_free_actual_buf(mctx, &cq->buf_a);
Expand Down Expand Up @@ -935,8 +966,15 @@ int mlx5_destroy_cq(struct ibv_cq *ibcq)

mlx5_free_db(ctx, cq->dbrec);
mlx5_free_actual_buf(ctx, cq->active_buf);
if (cq->peer_enabled)
if (cq->peer_enabled) {
mlx5_free_actual_buf(ctx, &cq->peer_buf);
if (cq->peer_dbrec_buf) {
if (cq->peer_dbrec_id)
cq->peer_ctx->unregister_va(cq->peer_dbrec_id, cq->peer_ctx->peer_id);
cq->peer_ctx->buf_release(cq->peer_dbrec_buf);
}
}

free(cq);

return 0;
Expand Down

0 comments on commit 0672706

Please sign in to comment.