[openib-general] [PATCH] libmthca: fix qp max_send_sge calculation

Michael S. Tsirkin mst at mellanox.co.il
Mon Oct 31 01:54:55 PST 2005


Hello, Roland!
Currently, max_send_sge reported for a qp is based not only on the
max_send_sge requested, but also on the max_inline_data requested.
While this may help in the sense that for some combinations of these values
the user may have an actual use for a bigger value of max_send_sge,
this also creates situations where max_send_sge reported exceeds
the maximum s/g value supported by the HCA, so attempts to post
such a work request will fail in strange ways.

A simple fix is to avoid touching max_gs for send, same as we do
for receive.

---

Avoid setting max_send_sge to a value bigger than supported by the HCA.

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

Index: userspace/libmthca/src/qp.c
===================================================================
--- userspace.orig/libmthca/src/qp.c	2005-10-31 11:31:14.000000000 +0200
+++ userspace/libmthca/src/qp.c	2005-10-31 11:31:38.000000000 +0200
@@ -682,13 +682,14 @@ out:
 int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
 		       enum ibv_qp_type type, struct mthca_qp *qp)
 {
-	int size;
+	int size, max_sge;
 
 	qp->rq.max_gs 	 = cap->max_recv_sge;
-	qp->sq.max_gs 	 = align(cap->max_inline_data + sizeof (struct mthca_inline_seg),
+	qp->sq.max_gs 	 = cap->max_send_sge;
+	max_sge 	 = align(cap->max_inline_data + sizeof (struct mthca_inline_seg),
 				 sizeof (struct mthca_data_seg)) / sizeof (struct mthca_data_seg);
-	if (qp->sq.max_gs < cap->max_send_sge)
-		qp->sq.max_gs = cap->max_send_sge;
+	if (max_sge < cap->max_send_sge)
+		max_sge = cap->max_send_sge;
 
 	qp->wrid = malloc((qp->rq.max + qp->sq.max) * sizeof (uint64_t));
 	if (!qp->wrid)
@@ -702,7 +703,7 @@ int mthca_alloc_qp_buf(struct ibv_pd *pd
 		; /* nothing */
 
 	size = sizeof (struct mthca_next_seg) +
-		qp->sq.max_gs * sizeof (struct mthca_data_seg);
+		max_sge * sizeof (struct mthca_data_seg);
 	switch (type) {
 	case IBV_QPT_UD:
 		if (mthca_is_memfree(pd->context))

-- 
MST



More information about the general mailing list