[ewg] [PATCH] IB/libipathverbs - Use the same error return codes as the kernel

Ralph Campbell ralph.campbell at qlogic.com
Fri Nov 16 15:41:51 PST 2007


The ib_post_*() functions return EINVAL when posting too many SGEs
and ENOMEM when posting too many WRs.  This patch matches the
kernel's return values and is consistent with the libibverbs man pages.

Signed-off-by: Ralph Campbell <ralph.campbell at qlogic.com>

diff --git a/src/verbs.c b/src/verbs.c
index 5424e82..dcd8efb 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -466,13 +466,17 @@ static int post_recv(struct ipath_rq *rq, struct ibv_recv_wr *wr,
 	rwq = rq->rwq;
 	head = rwq->head;
 	for (i = wr; i; i = i->next) {
-		if ((unsigned) i->num_sge > rq->max_sge)
+		if ((unsigned) i->num_sge > rq->max_sge) {
+			ret = EINVAL;
 			goto bad;
+		}
 		wqe = get_rwqe_ptr(rq, head);
 		if (++head >= rq->size)
 			head = 0;
-		if (head == rwq->tail)
+		if (head == rwq->tail) {
+			ret = ENOMEM;
 			goto bad;
+		}
 		wqe->wr_id = i->wr_id;
 		wqe->num_sge = i->num_sge;
 		for (n = 0; n < wqe->num_sge; n++)
@@ -485,7 +489,6 @@ static int post_recv(struct ipath_rq *rq, struct ibv_recv_wr *wr,
 	goto done;
 
 bad:
-	ret = -ENOMEM;
 	if (bad_wr)
 		*bad_wr = i;
 done:





More information about the ewg mailing list