[openib-general] [PATCH] mthca: fix qp max_send/recv_sge calculation

Michael S. Tsirkin mst at mellanox.co.il
Mon Nov 14 13:11:17 PST 2005


Roland, I think I see a problem in mthca, where qp capability values
we return arent safe.
How does the following look (compile tested only)?

---

Calculation of QP capabilities still isnt exactly right in mthca:
max_send_sge/max_recv_sge fields returned in create_qp
can exceed the handware supported limits.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: linux-2.6.14/drivers/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- linux-2.6.14/drivers/infiniband/hw/mthca/mthca_qp.c	(revision 4042)
+++ linux-2.6.14/drivers/infiniband/hw/mthca/mthca_qp.c	(working copy)
@@ -919,10 +919,12 @@ static void mthca_adjust_qp_caps(struct 
         else
 		qp->max_inline_data = max_data_size - MTHCA_INLINE_HEADER_SIZE;
 
-	qp->sq.max_gs = max_data_size / sizeof (struct mthca_data_seg);
-	qp->rq.max_gs = (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
-			sizeof (struct mthca_next_seg)) /
-			sizeof (struct mthca_data_seg);
+	qp->sq.max_gs = min_t(int, dev->limits.max_sg,
+			      max_data_size / sizeof (struct mthca_data_seg));
+	qp->rq.max_gs = min_t(int, dev->limits.max_sg,
+			       (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
+				sizeof (struct mthca_next_seg)) /
+			       sizeof (struct mthca_data_seg));
 }
 
 /*
-- 
MST



More information about the general mailing list