Fix the calulation of max_inline_data and max_send_sge returned to the
user. Without this fix, the size of the SQ WQEs may increase every
time create QP is called using values returned from a previous call.
For example, here is a quote from the output of the test showing the
problem with a UD QP:
request: cap.max_send_sge = 1, cap.max_inline_data = 0
got: cap.max_send_sge = 5, cap.max_inline_data = 76
request: cap.max_send_sge = 5, cap.max_inline_data = 76
got: cap. max_send_sge = 13, cap.max_inline_data = 204
The problem is that we forgot to subtract the size of the control
segment in mlx4_set_sq_sizes().
Pointed out by Eli Cohen <eli@mellanox.co.il>.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
int max_sq_sge;
qp->rq.max_gs = cap->max_recv_sge;
- qp->sq.max_gs = cap->max_send_sge;
max_sq_sge = align(cap->max_inline_data + sizeof (struct mlx4_wqe_inline_seg),
sizeof (struct mlx4_wqe_data_seg)) / sizeof (struct mlx4_wqe_data_seg);
if (max_sq_sge < cap->max_send_sge)
{
int wqe_size;
- wqe_size = 1 << qp->sq.wqe_shift;
+ wqe_size = (1 << qp->sq.wqe_shift) - sizeof (struct mlx4_wqe_ctrl_seg);
switch (type) {
case IBV_QPT_UD:
wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);
break;
}
- qp->sq.max_gs = wqe_size / sizeof (struct mlx4_wqe_data_seg);
+ qp->sq.max_gs = wqe_size / sizeof (struct mlx4_wqe_data_seg);
cap->max_send_sge = qp->sq.max_gs;
qp->max_inline_data = wqe_size - sizeof (struct mlx4_wqe_inline_seg);
cap->max_inline_data = qp->max_inline_data;