Add support for 64-byte CQE size.
Sponsored by: Mellanox Technologies MFC after: 3 days
This commit is contained in:
parent
1ac18f08c6
commit
ba783d0a20
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -102,10 +102,6 @@
|
||||
_a < _b ? _a : _b; })
|
||||
#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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user