diff options
author | hselasky <hselasky@FreeBSD.org> | 2014-11-29 04:18:56 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2014-11-29 04:18:56 +0000 |
commit | 77aefe28bef875fe7b2977e94666ab3dccc72d78 (patch) | |
tree | 26dfe75fe425195667d178569e6f6f7c00e24eb8 /contrib/ofed | |
parent | dc900c05289d2384610bcf974f7c6d4e58a03b44 (diff) | |
download | FreeBSD-src-77aefe28bef875fe7b2977e94666ab3dccc72d78.zip FreeBSD-src-77aefe28bef875fe7b2977e94666ab3dccc72d78.tar.gz |
MFC r275109:
Add support for 64-byte CQE size.
Sponsored by: Mellanox Technologies
Diffstat (limited to 'contrib/ofed')
-rw-r--r-- | contrib/ofed/libmlx4/src/cq.c | 24 | ||||
-rw-r--r-- | contrib/ofed/libmlx4/src/mlx4-abi.h | 2 | ||||
-rw-r--r-- | contrib/ofed/libmlx4/src/mlx4.c | 1 | ||||
-rw-r--r-- | contrib/ofed/libmlx4/src/mlx4.h | 9 | ||||
-rw-r--r-- | contrib/ofed/libmlx4/src/verbs.c | 8 |
5 files changed, 29 insertions, 15 deletions
diff --git a/contrib/ofed/libmlx4/src/cq.c b/contrib/ofed/libmlx4/src/cq.c index eef1e02..ef01fcf 100644 --- a/contrib/ofed/libmlx4/src/cq.c +++ b/contrib/ofed/libmlx4/src/cq.c @@ -109,15 +109,16 @@ struct mlx4_err_cqe { static struct mlx4_cqe *get_cqe(struct mlx4_cq *cq, int entry) { - return cq->buf.buf + entry * MLX4_CQ_ENTRY_SIZE; + return cq->buf.buf + entry * cq->cqe_size; } static void *get_sw_cqe(struct mlx4_cq *cq, int n) { struct mlx4_cqe *cqe = get_cqe(cq, n & cq->ibv_cq.cqe); + struct mlx4_cqe *tcqe = cq->cqe_size == 64 ? cqe + 1 : cqe; - return (!!(cqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^ - !!(n & (cq->ibv_cq.cqe + 1))) ? NULL : cqe; + return (!!(tcqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^ + !!(n & (cq->ibv_cq.cqe + 1))) ? NULL : tcqe; } static struct mlx4_cqe *next_cqe_sw(struct mlx4_cq *cq) @@ -402,6 +403,7 @@ void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq) uint8_t owner_bit; int nfreed = 0; int is_xrc_srq = 0; + int cqe_inc = cq->cqe_size == 64 ? 1 : 0; if (srq && srq->ibv_srq.xrc_cq) is_xrc_srq = 1; @@ -423,6 +425,7 @@ void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq) */ while ((int) --prod_index - (int) cq->cons_index >= 0) { cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe); + cqe += cqe_inc; if (is_xrc_srq && (ntohl(cqe->g_mlpath_rqpn & 0xffffff) == srq->srqn) && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) { @@ -434,6 +437,7 @@ void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq) ++nfreed; } else if (nfreed) { dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe); + dest += cqe_inc; owner_bit = dest->owner_sr_opcode & MLX4_CQE_OWNER_MASK; memcpy(dest, cqe, sizeof *cqe); dest->owner_sr_opcode = owner_bit | @@ -473,28 +477,32 @@ void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int old_cqe) { struct mlx4_cqe *cqe; int i; + int cqe_inc = cq->cqe_size == 64 ? 1 : 0; i = cq->cons_index; cqe = get_cqe(cq, (i & old_cqe)); + cqe += cqe_inc; while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) != MLX4_CQE_OPCODE_RESIZE) { cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) | (((i + 1) & (cq->ibv_cq.cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0); - memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * MLX4_CQ_ENTRY_SIZE, - cqe, MLX4_CQ_ENTRY_SIZE); + memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * cq->cqe_size, + cqe - cqe_inc, cq->cqe_size); ++i; cqe = get_cqe(cq, (i & old_cqe)); + cqe += cqe_inc; } ++cq->cons_index; } -int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent) +int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent, + int entry_size) { - if (mlx4_alloc_buf(buf, align(nent * MLX4_CQ_ENTRY_SIZE, dev->page_size), + if (mlx4_alloc_buf(buf, align(nent * entry_size, dev->page_size), dev->page_size)) return -1; - memset(buf->buf, 0, nent * MLX4_CQ_ENTRY_SIZE); + memset(buf->buf, 0, nent * entry_size); return 0; } diff --git a/contrib/ofed/libmlx4/src/mlx4-abi.h b/contrib/ofed/libmlx4/src/mlx4-abi.h index cc054e4..86be5c7 100644 --- a/contrib/ofed/libmlx4/src/mlx4-abi.h +++ b/contrib/ofed/libmlx4/src/mlx4-abi.h @@ -40,9 +40,11 @@ struct mlx4_alloc_ucontext_resp { struct ibv_get_context_resp ibv_resp; + __u32 dev_caps; __u32 qp_tab_size; __u16 bf_reg_size; __u16 bf_regs_per_page; + __u32 cqe_size; }; struct mlx4_alloc_pd_resp { diff --git a/contrib/ofed/libmlx4/src/mlx4.c b/contrib/ofed/libmlx4/src/mlx4.c index 17adb30..caabced 100644 --- a/contrib/ofed/libmlx4/src/mlx4.c +++ b/contrib/ofed/libmlx4/src/mlx4.c @@ -201,6 +201,7 @@ static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_ context->bf_buf_size = 0; } + context->cqe_size = resp.cqe_size; pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE); context->ibv_ctx.ops = mlx4_ctx_ops; diff --git a/contrib/ofed/libmlx4/src/mlx4.h b/contrib/ofed/libmlx4/src/mlx4.h index a349c5b..cf5b963 100644 --- a/contrib/ofed/libmlx4/src/mlx4.h +++ b/contrib/ofed/libmlx4/src/mlx4.h @@ -103,10 +103,6 @@ #endif enum { - MLX4_CQ_ENTRY_SIZE = 0x20 -}; - -enum { MLX4_STAT_RATE_OFFSET = 5 }; @@ -192,6 +188,7 @@ struct mlx4_context { int max_qp_wr; int max_sge; int max_cqe; + int cqe_size; struct { struct mlx4_srq **table; @@ -226,6 +223,7 @@ struct mlx4_cq { uint32_t *set_ci_db; uint32_t *arm_db; int arm_sn; + int cqe_size; }; struct mlx4_srq { @@ -369,7 +367,8 @@ int mlx4_dereg_mr(struct ibv_mr *mr); struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe, struct ibv_comp_channel *channel, int comp_vector); -int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent); +int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent, + int entry_size); int mlx4_resize_cq(struct ibv_cq *cq, int cqe); int mlx4_destroy_cq(struct ibv_cq *cq); int mlx4_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); diff --git a/contrib/ofed/libmlx4/src/verbs.c b/contrib/ofed/libmlx4/src/verbs.c index 45e8693..1a80698 100644 --- a/contrib/ofed/libmlx4/src/verbs.c +++ b/contrib/ofed/libmlx4/src/verbs.c @@ -168,6 +168,7 @@ struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe, struct mlx4_create_cq_resp resp; struct mlx4_cq *cq; int ret; + struct mlx4_context *mctx = to_mctx(context); /* Sanity check CQ size before proceeding */ if (cqe > 0x3fffff) @@ -184,9 +185,11 @@ struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe, cqe = align_queue_size(cqe + 1); - if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe)) + if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe, mctx->cqe_size)) goto err; + cq->cqe_size = mctx->cqe_size; + cq->set_ci_db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ); if (!cq->set_ci_db) goto err_buf; @@ -247,7 +250,8 @@ int mlx4_resize_cq(struct ibv_cq *ibcq, int cqe) goto out; } - ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe); + ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe, + cq->cqe_size); if (ret) goto out; |