Commit c95e6d53 authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe

RDMA/mlx5: Use flags_en mechanism to mark QP created with WQE signature

MLX5_QP_FLAG_SIGNATURE is exposed to the users but in the kernel
the create_qp flow treated it differently from other MLX5_QP_FLAG_*s.
Fix it by ditching wq_sig boolean variable and use general flag_en
mechanism.

Link: https://lore.kernel.org/r/20200427154636.381474-16-leon@kernel.orgReviewed-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 2978975c
...@@ -446,7 +446,6 @@ struct mlx5_ib_qp { ...@@ -446,7 +446,6 @@ struct mlx5_ib_qp {
u32 flags; u32 flags;
u8 port; u8 port;
u8 state; u8 state;
int wq_sig;
int scat_cqe; int scat_cqe;
int max_inline_data; int max_inline_data;
struct mlx5_bf bf; struct mlx5_bf bf;
......
...@@ -1190,7 +1190,7 @@ static int mlx5_ib_mr_responder_pfault_handler_rq(struct mlx5_ib_dev *dev, ...@@ -1190,7 +1190,7 @@ static int mlx5_ib_mr_responder_pfault_handler_rq(struct mlx5_ib_dev *dev,
struct mlx5_ib_wq *wq = &qp->rq; struct mlx5_ib_wq *wq = &qp->rq;
int wqe_size = 1 << wq->wqe_shift; int wqe_size = 1 << wq->wqe_shift;
if (qp->wq_sig) { if (qp->flags_en & MLX5_QP_FLAG_SIGNATURE) {
mlx5_ib_err(dev, "ODP fault with WQE signatures is not supported\n"); mlx5_ib_err(dev, "ODP fault with WQE signatures is not supported\n");
return -EFAULT; return -EFAULT;
} }
......
...@@ -41,9 +41,6 @@ ...@@ -41,9 +41,6 @@
#include "cmd.h" #include "cmd.h"
#include "qp.h" #include "qp.h"
/* not supported currently */
static int wq_signature;
enum { enum {
MLX5_IB_ACK_REQ_FREQ = 8, MLX5_IB_ACK_REQ_FREQ = 8,
}; };
...@@ -392,17 +389,26 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap, ...@@ -392,17 +389,26 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap,
cap->max_recv_wr = 0; cap->max_recv_wr = 0;
cap->max_recv_sge = 0; cap->max_recv_sge = 0;
} else { } else {
int wq_sig = !!(qp->flags_en & MLX5_QP_FLAG_SIGNATURE);
if (ucmd) { if (ucmd) {
qp->rq.wqe_cnt = ucmd->rq_wqe_count; qp->rq.wqe_cnt = ucmd->rq_wqe_count;
if (ucmd->rq_wqe_shift > BITS_PER_BYTE * sizeof(ucmd->rq_wqe_shift)) if (ucmd->rq_wqe_shift > BITS_PER_BYTE * sizeof(ucmd->rq_wqe_shift))
return -EINVAL; return -EINVAL;
qp->rq.wqe_shift = ucmd->rq_wqe_shift; qp->rq.wqe_shift = ucmd->rq_wqe_shift;
if ((1 << qp->rq.wqe_shift) / sizeof(struct mlx5_wqe_data_seg) < qp->wq_sig) if ((1 << qp->rq.wqe_shift) /
sizeof(struct mlx5_wqe_data_seg) <
wq_sig)
return -EINVAL; return -EINVAL;
qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof(struct mlx5_wqe_data_seg) - qp->wq_sig; qp->rq.max_gs =
(1 << qp->rq.wqe_shift) /
sizeof(struct mlx5_wqe_data_seg) -
wq_sig;
qp->rq.max_post = qp->rq.wqe_cnt; qp->rq.max_post = qp->rq.wqe_cnt;
} else { } else {
wqe_size = qp->wq_sig ? sizeof(struct mlx5_wqe_signature_seg) : 0; wqe_size =
wq_sig ? sizeof(struct mlx5_wqe_signature_seg) :
0;
wqe_size += cap->max_recv_sge * sizeof(struct mlx5_wqe_data_seg); wqe_size += cap->max_recv_sge * sizeof(struct mlx5_wqe_data_seg);
wqe_size = roundup_pow_of_two(wqe_size); wqe_size = roundup_pow_of_two(wqe_size);
wq_size = roundup_pow_of_two(cap->max_recv_wr) * wqe_size; wq_size = roundup_pow_of_two(cap->max_recv_wr) * wqe_size;
...@@ -416,7 +422,10 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap, ...@@ -416,7 +422,10 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap,
return -EINVAL; return -EINVAL;
} }
qp->rq.wqe_shift = ilog2(wqe_size); qp->rq.wqe_shift = ilog2(wqe_size);
qp->rq.max_gs = (1 << qp->rq.wqe_shift) / sizeof(struct mlx5_wqe_data_seg) - qp->wq_sig; qp->rq.max_gs =
(1 << qp->rq.wqe_shift) /
sizeof(struct mlx5_wqe_data_seg) -
wq_sig;
qp->rq.max_post = qp->rq.wqe_cnt; qp->rq.max_post = qp->rq.wqe_cnt;
} }
} }
...@@ -2008,7 +2017,8 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, ...@@ -2008,7 +2017,8 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
if (err) if (err)
return err; return err;
qp->wq_sig = !!(ucmd->flags & MLX5_QP_FLAG_SIGNATURE); if (ucmd->flags & MLX5_QP_FLAG_SIGNATURE)
qp->flags_en |= MLX5_QP_FLAG_SIGNATURE;
if (MLX5_CAP_GEN(dev->mdev, sctr_data_cqe)) if (MLX5_CAP_GEN(dev->mdev, sctr_data_cqe))
qp->scat_cqe = qp->scat_cqe =
!!(ucmd->flags & MLX5_QP_FLAG_SCATTER_CQE); !!(ucmd->flags & MLX5_QP_FLAG_SCATTER_CQE);
...@@ -2045,8 +2055,6 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, ...@@ -2045,8 +2055,6 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
} }
qp->flags_en |= MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE; qp->flags_en |= MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE;
} }
} else {
qp->wq_sig = !!wq_signature;
} }
if (qp->flags & IB_QP_CREATE_SOURCE_QPN) if (qp->flags & IB_QP_CREATE_SOURCE_QPN)
...@@ -2115,7 +2123,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, ...@@ -2115,7 +2123,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
MLX5_SET(qpc, qpc, latency_sensitive, 1); MLX5_SET(qpc, qpc, latency_sensitive, 1);
if (qp->wq_sig) if (qp->flags_en & MLX5_QP_FLAG_SIGNATURE)
MLX5_SET(qpc, qpc, wq_signature, 1); MLX5_SET(qpc, qpc, wq_signature, 1);
if (qp->flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) if (qp->flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
...@@ -4997,7 +5005,7 @@ static void finish_wqe(struct mlx5_ib_qp *qp, ...@@ -4997,7 +5005,7 @@ static void finish_wqe(struct mlx5_ib_qp *qp,
mlx5_opcode | ((u32)opmod << 24)); mlx5_opcode | ((u32)opmod << 24));
ctrl->qpn_ds = cpu_to_be32(size | (qp->trans_qp.base.mqp.qpn << 8)); ctrl->qpn_ds = cpu_to_be32(size | (qp->trans_qp.base.mqp.qpn << 8));
ctrl->fm_ce_se |= fence; ctrl->fm_ce_se |= fence;
if (unlikely(qp->wq_sig)) if (unlikely(qp->flags_en & MLX5_QP_FLAG_SIGNATURE))
ctrl->signature = wq_sig(ctrl); ctrl->signature = wq_sig(ctrl);
qp->sq.wrid[idx] = wr_id; qp->sq.wrid[idx] = wr_id;
...@@ -5449,7 +5457,7 @@ static int _mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, ...@@ -5449,7 +5457,7 @@ static int _mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
} }
scat = mlx5_frag_buf_get_wqe(&qp->rq.fbc, ind); scat = mlx5_frag_buf_get_wqe(&qp->rq.fbc, ind);
if (qp->wq_sig) if (qp->flags_en & MLX5_QP_FLAG_SIGNATURE)
scat++; scat++;
for (i = 0; i < wr->num_sge; i++) for (i = 0; i < wr->num_sge; i++)
...@@ -5461,7 +5469,7 @@ static int _mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, ...@@ -5461,7 +5469,7 @@ static int _mlx5_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
scat[i].addr = 0; scat[i].addr = 0;
} }
if (qp->wq_sig) { if (qp->flags_en & MLX5_QP_FLAG_SIGNATURE) {
sig = (struct mlx5_rwqe_sig *)scat; sig = (struct mlx5_rwqe_sig *)scat;
set_sig_seg(sig, (qp->rq.max_gs + 1) << 2); set_sig_seg(sig, (qp->rq.max_gs + 1) << 2);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment