[openib-general] [PATCH] libmthca: fix posting lists with 256 entries

Michael S. Tsirkin mst at mellanox.co.il
Thu May 18 08:33:08 PDT 2006


Fix posting lists of 256 entries. Same as previous kernel patch.

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

Index: openib/src/userspace/libmthca/src/qp.c
===================================================================
--- openib/src/userspace/libmthca/src/qp.c	(revision 7317)
+++ openib/src/userspace/libmthca/src/qp.c	(working copy)
@@ -332,25 +332,7 @@ int mthca_tavor_post_recv(struct ibv_qp 
 
 	ind = qp->rq.next_ind;
 
-	for (nreq = 0; wr; ++nreq, wr = wr->next) {
-		if (nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB) {
-			nreq = 0;
-
-			doorbell[0] = htonl((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
-			doorbell[1] = htonl(ibqp->qp_num << 8);
-
-			/*
-			 * Make sure that descriptors are written
-			 * before doorbell is rung.
-			 */
-			mb();
-
-			mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_RECV_DOORBELL);
-
-			qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
-			size0 = 0;
-		}
-
+	for (nreq = 0; wr; wr = wr->next) {
 		if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) {
 			ret = -1;
 			*bad_wr = wr;
@@ -400,6 +382,24 @@ int mthca_tavor_post_recv(struct ibv_qp 
 		++ind;
 		if (ind >= qp->rq.max)
 			ind -= qp->rq.max;
+
+		if (++nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB) {
+			nreq = 0;
+
+			doorbell[0] = htonl((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
+			doorbell[1] = htonl(ibqp->qp_num << 8);
+
+			/*
+			 * Make sure that descriptors are written
+			 * before doorbell is rung.
+			 */
+			mb();
+
+			mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_RECV_DOORBELL);
+
+			qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
+			size0 = 0;
+		}
 	}
 
 out:

-- 
MST



More information about the general mailing list