mlx5: Don't assume that input is rounded to power two
PATCH 1/1 mlx5: Don't assume that input is rounded to power two
From: Leon Romanovsky <[email protected]>
The simple arithmetic can be done in order to stop assume that code provided to ilog32() used in mlx5 is rounded to power two.
Reviewed-by Yishai Hadas <[email protected]>
Signed-off-by Leon Romanovsky <[email protected]>
--- providers/mlx5/dr_devx.c | 4 ++-- providers/mlx5/dr_send.c | 4 ++-- providers/mlx5/srq.c | 2 +- providers/mlx5/verbs.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-)
providers/mlx5/dr_devx.c +2 -2
@@ -324,9 +324,9 @@ struct mlx5dv_devx_obj *dr_devx_create_qp(struct ibv_context *ctx,DEVX_SET (qpc, qpc, uar_page, attr->page_id);DEVX_SET (qpc, qpc, cqn_snd, attr->cqn);DEVX_SET (qpc, qpc, cqn_rcv, attr->cqn); -DEVX_SET (qpc, qpc, log_sq_size,ilog32 (attr->sq_wqe_cnt) -1 ); +DEVX_SET (qpc, qpc, log_sq_size,ilog32 (attr->sq_wqe_cnt -1 ));DEVX_SET (qpc, qpc, log_rq_stride, attr->rq_wqe_shift -4 ); -DEVX_SET (qpc, qpc, log_rq_size,ilog32 (attr->rq_wqe_cnt) -1 ); +DEVX_SET (qpc, qpc, log_rq_size,ilog32 (attr->rq_wqe_cnt -1 ));DEVX_SET (qpc, qpc, dbr_umem_id, attr->db_umem_id);DEVX_SET (create_qp_in, in, wq_umem_id, attr->buff_umem_id);
providers/mlx5/dr_send.c +2 -2
@@ -210,8 +210,8 @@ static int dr_calc_rq_size(struct dr_qp *dr_qp, wq_size =roundup_pow_of_two (attr->cap.max_recv_wr) * wqe_size; wq_size =max (wq_size,MLX5_SEND_WQE_BB ); dr_qp->rq.wqe_cnt = wq_size / wqe_size; - dr_qp->rq.wqe_shift =ilog32 (wqe_size) -1 ; - dr_qp->rq.max_post =1 << (ilog32 (wq_size / wqe_size) -1 ); + dr_qp->rq.wqe_shift =ilog32 (wqe_size -1 ); + dr_qp->rq.max_post =1 <<ilog32 (wq_size / wqe_size -1 ); dr_qp->rq.max_gs = wqe_size /sizeof (struct mlx5_wqe_data_seg );return wq_size;
providers/mlx5/srq.c +1 -1
@@ -291,7 +291,7 @@ int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq, srq->max_gs = (size -sizeof (struct mlx5_wqe_srq_next_seg )) /sizeof (struct mlx5_wqe_data_seg ); - srq->wqe_shift =ilog32 (size) -1 ; + srq->wqe_shift =ilog32 (size -1 ); srq->max =align_queue_size (max_wr); buf_size = srq->max * size;
providers/mlx5/verbs.c +4 -4
@@ -1400,8 +1400,8 @@ static int mlx5_calc_rwq_size(struct mlx5_context *ctx, wq_size =roundup_pow_of_two (attr->max_wr) * wqe_size; wq_size =max (wq_size,MLX5_SEND_WQE_BB ); rwq->rq.wqe_cnt = wq_size / wqe_size; - rwq->rq.wqe_shift =ilog32 (wqe_size) -1 ; - rwq->rq.max_post =1 << (ilog32 (wq_size / wqe_size) -1 ); + rwq->rq.wqe_shift =ilog32 (wqe_size -1 ); + rwq->rq.max_post =1 <<ilog32 (wq_size / wqe_size -1 ); scat_spc = wqe_size - ((rwq->wq_sig) ?sizeof (struct mlx5_rwqe_sig ) :0 ) - is_mprq *sizeof (struct mlx5_wqe_srq_next_seg );
@@ -1436,8 +1436,8 @@ static int mlx5_calc_rq_size(struct mlx5_context *ctx,if (wqe_size) { wq_size =max (wq_size,MLX5_SEND_WQE_BB ); qp->rq.wqe_cnt = wq_size / wqe_size; - qp->rq.wqe_shift =ilog32 (wqe_size) -1 ; - qp->rq.max_post =1 << (ilog32 (wq_size / wqe_size) -1 ); + qp->rq.wqe_shift =ilog32 (wqe_size -1 ); + qp->rq.max_post =1 <<ilog32 (wq_size / wqe_size -1 ); scat_spc = wqe_size - (qp->wq_sig ?sizeof (struct mlx5_rwqe_sig ) :0 ); qp->rq.max_gs = scat_spc /sizeof (struct mlx5_wqe_data_seg );
Signature · 1 line
2.20.1