IB/ipath: Fix sanity checks on QP number of WRs and SGEs
authorRalph Campbell <ralph.campbell@qlogic.com>
Thu, 17 Apr 2008 04:09:25 +0000 (21:09 -0700)
committerRoland Dreier <rolandd@cisco.com>
Thu, 17 Apr 2008 04:09:25 +0000 (21:09 -0700)
The receive queue number of WRs and SGEs shouldn't be checked if a
SRQ is specified.

Signed-off-by: Ralph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ipath/ipath_qp.c

index 9125e02eadaf4b547b43e564500dd56bb4576df7..6a4a5e3b78ba138fe8e35d9481da3eefd220fc00 100644 (file)
@@ -748,19 +748,25 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
        struct ib_qp *ret;
 
        if (init_attr->cap.max_send_sge > ib_ipath_max_sges ||
-           init_attr->cap.max_recv_sge > ib_ipath_max_sges ||
-           init_attr->cap.max_send_wr > ib_ipath_max_qp_wrs ||
-           init_attr->cap.max_recv_wr > ib_ipath_max_qp_wrs) {
-               ret = ERR_PTR(-ENOMEM);
+           init_attr->cap.max_send_wr > ib_ipath_max_qp_wrs) {
+               ret = ERR_PTR(-EINVAL);
                goto bail;
        }
 
-       if (init_attr->cap.max_send_sge +
-           init_attr->cap.max_recv_sge +
-           init_attr->cap.max_send_wr +
-           init_attr->cap.max_recv_wr == 0) {
-               ret = ERR_PTR(-EINVAL);
-               goto bail;
+       /* Check receive queue parameters if no SRQ is specified. */
+       if (!init_attr->srq) {
+               if (init_attr->cap.max_recv_sge > ib_ipath_max_sges ||
+                   init_attr->cap.max_recv_wr > ib_ipath_max_qp_wrs) {
+                       ret = ERR_PTR(-EINVAL);
+                       goto bail;
+               }
+               if (init_attr->cap.max_send_sge +
+                   init_attr->cap.max_send_wr +
+                   init_attr->cap.max_recv_sge +
+                   init_attr->cap.max_recv_wr == 0) {
+                       ret = ERR_PTR(-EINVAL);
+                       goto bail;
+               }
        }
 
        switch (init_attr->qp_type) {