diff mbox

[PATCH/libmlx4] Return ERRNO codes from ibv_post_send/recv instead of -1

Message ID 4C2744E8AD2982428C5BFE523DF8CDCB4A20BB3C79@MNEXMB1.qlogic.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Michael Heinz March 9, 2011, 2:02 p.m. UTC
None
diff mbox

Patch

diff --git a/src/qp.c b/src/qp.c
index d194ae3..ec138cd 100644
--- a/src/qp.c
+++ b/src/qp.c
@@ -40,6 +40,7 @@ 
 #include <netinet/in.h>
 #include <pthread.h>
 #include <string.h>
+#include <errno.h>

 #include "mlx4.h"
 #include "doorbell.h"
@@ -206,19 +207,19 @@  int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,

        for (nreq = 0; wr; ++nreq, wr = wr->next) {
                if (wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) {
-                       ret = -1;
+                       ret = ENOMEM;
                        *bad_wr = wr;
                        goto out;
                }

                if (wr->num_sge > qp->sq.max_gs) {
-                       ret = -1;
+                       ret = ENOMEM;
                        *bad_wr = wr;
                        goto out;
                }

                if (wr->opcode >= sizeof mlx4_ib_opcode / sizeof mlx4_ib_opcode[0]) {
-                       ret = -1;
+                       ret = EINVAL;
                        *bad_wr = wr;
                        goto out;
                }
@@ -309,7 +310,7 @@  int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,

                                if (inl > qp->max_inline_data) {
                                        inl = 0;
-                                       ret = -1;
+                                       ret = ENOMEM;
                                        *bad_wr = wr;
                                        goto out;
                                }
@@ -450,13 +451,13 @@  int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,

        for (nreq = 0; wr; ++nreq, wr = wr->next) {
                if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) {
-                       ret = -1;
+                       ret = ENOMEM;
                        *bad_wr = wr;
                        goto out;
                }

                if (wr->num_sge > qp->rq.max_gs) {
-                       ret = -1;
+                       ret = ENOMEM;
                        *bad_wr = wr;
                        goto out;
                }