]> git.openfabrics.org - ~shefty/libmlx4.git/commitdiff
Fix max_send_sge and max_inline_data returned from create QP
authorRoland Dreier <rolandd@cisco.com>
Tue, 29 May 2007 18:31:04 +0000 (11:31 -0700)
committerRoland Dreier <rolandd@cisco.com>
Tue, 29 May 2007 18:31:04 +0000 (11:31 -0700)
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>
src/qp.c

index fa20dfa26ea6ac1c939817983ddc669039179041..8e2a3d387fe119a7da4059155edfba831bfb422e 100644 (file)
--- a/src/qp.c
+++ b/src/qp.c
@@ -390,7 +390,6 @@ int mlx4_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
        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)
@@ -478,7 +477,7 @@ void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
 {
        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);
@@ -493,7 +492,7 @@ void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
                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;