Fix calulation of max inline returned to the user. Without this fix,
the size of inline may increase every time create qp is called with
the previous values returned.

For example, here is a quote from the output of the test showing the
problem:

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

Signed-off-by: Eli Cohen <[EMAIL PROTECTED]>

---

Index: libmlx4/src/qp.c
===================================================================
--- libmlx4.orig/src/qp.c       2007-05-29 13:13:57.000000000 +0300
+++ libmlx4/src/qp.c    2007-05-29 14:41:33.000000000 +0300
@@ -396,12 +396,13 @@ int mlx4_alloc_qp_buf(struct ibv_pd *pd,
                cap->max_send_sge = 1;
 
        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)
                max_sq_sge = cap->max_send_sge;
 
+       qp->sq.max_gs = max_sq_sge;
+
        qp->sq.wrid = malloc(qp->sq.max * sizeof (uint64_t));
        if (!qp->sq.wrid)
                return -1;
@@ -419,6 +420,7 @@ int mlx4_alloc_qp_buf(struct ibv_pd *pd,
                ; /* nothing */
 
        size = max_sq_sge * sizeof (struct mlx4_wqe_data_seg);
+       qp->max_inline_data  = size - sizeof (struct mlx4_wqe_inline_seg);
        switch (type) {
        case IBV_QPT_UD:
                size += sizeof (struct mlx4_wqe_datagram_seg);
@@ -482,26 +484,7 @@ int mlx4_alloc_qp_buf(struct ibv_pd *pd,
 void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
                       enum ibv_qp_type type)
 {
-       int wqe_size;
-
-       wqe_size = 1 << qp->sq.wqe_shift;
-       switch (type) {
-       case IBV_QPT_UD:
-               wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);
-               break;
-
-       case IBV_QPT_UC:
-       case IBV_QPT_RC:
-               wqe_size -= sizeof (struct mlx4_wqe_raddr_seg);
-               break;
-
-       default:
-               break;
-       }
-
-       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;
 }
 

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to