aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@pathscale.com>2006-08-25 14:24:43 -0400
committerRoland Dreier <rolandd@cisco.com>2006-09-22 18:22:38 -0400
commit0b81e4f79af8322c7142701982f40d1431dedf19 (patch)
tree4d1161d8603471cbe8ece750980eb22767a91235
parentca4ce383acfb05b8035453cdbbfd4f8ae36c7a69 (diff)
IB/ipath: put a limit on the number of QPs that can be created
Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c15
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.h4
3 files changed, 25 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index 77391886d2f8..607ba72af2fa 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -833,9 +833,21 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
833 } 833 }
834 } 834 }
835 835
836 spin_lock(&dev->n_qps_lock);
837 if (dev->n_qps_allocated == ib_ipath_max_qps) {
838 spin_unlock(&dev->n_qps_lock);
839 ret = ERR_PTR(-ENOMEM);
840 goto bail_ip;
841 }
842
843 dev->n_qps_allocated++;
844 spin_unlock(&dev->n_qps_lock);
845
836 ret = &qp->ibqp; 846 ret = &qp->ibqp;
837 goto bail; 847 goto bail;
838 848
849bail_ip:
850 kfree(qp->ip);
839bail_rwq: 851bail_rwq:
840 vfree(qp->r_rq.wq); 852 vfree(qp->r_rq.wq);
841bail_qp: 853bail_qp:
@@ -864,6 +876,9 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
864 spin_lock_irqsave(&qp->s_lock, flags); 876 spin_lock_irqsave(&qp->s_lock, flags);
865 qp->state = IB_QPS_ERR; 877 qp->state = IB_QPS_ERR;
866 spin_unlock_irqrestore(&qp->s_lock, flags); 878 spin_unlock_irqrestore(&qp->s_lock, flags);
879 spin_lock(&dev->n_qps_lock);
880 dev->n_qps_allocated--;
881 spin_unlock(&dev->n_qps_lock);
867 882
868 /* Stop the sending tasklet. */ 883 /* Stop the sending tasklet. */
869 tasklet_kill(&qp->s_task); 884 tasklet_kill(&qp->s_task);
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index ab0006288b41..b9be0fd2ed36 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -73,6 +73,10 @@ module_param_named(max_qp_wrs, ib_ipath_max_qp_wrs, uint,
73 S_IWUSR | S_IRUGO); 73 S_IWUSR | S_IRUGO);
74MODULE_PARM_DESC(max_qp_wrs, "Maximum number of QP WRs to support"); 74MODULE_PARM_DESC(max_qp_wrs, "Maximum number of QP WRs to support");
75 75
76unsigned int ib_ipath_max_qps = 16384;
77module_param_named(max_qps, ib_ipath_max_qps, uint, S_IWUSR | S_IRUGO);
78MODULE_PARM_DESC(max_qps, "Maximum number of QPs to support");
79
76unsigned int ib_ipath_max_sges = 0x60; 80unsigned int ib_ipath_max_sges = 0x60;
77module_param_named(max_sges, ib_ipath_max_sges, uint, S_IWUSR | S_IRUGO); 81module_param_named(max_sges, ib_ipath_max_sges, uint, S_IWUSR | S_IRUGO);
78MODULE_PARM_DESC(max_sges, "Maximum number of SGEs to support"); 82MODULE_PARM_DESC(max_sges, "Maximum number of SGEs to support");
@@ -958,7 +962,7 @@ static int ipath_query_device(struct ib_device *ibdev,
958 props->sys_image_guid = dev->sys_image_guid; 962 props->sys_image_guid = dev->sys_image_guid;
959 963
960 props->max_mr_size = ~0ull; 964 props->max_mr_size = ~0ull;
961 props->max_qp = dev->qp_table.max; 965 props->max_qp = ib_ipath_max_qps;
962 props->max_qp_wr = ib_ipath_max_qp_wrs; 966 props->max_qp_wr = ib_ipath_max_qp_wrs;
963 props->max_sge = ib_ipath_max_sges; 967 props->max_sge = ib_ipath_max_sges;
964 props->max_cq = ib_ipath_max_cqs; 968 props->max_cq = ib_ipath_max_cqs;
@@ -1420,6 +1424,7 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
1420 spin_lock_init(&idev->n_pds_lock); 1424 spin_lock_init(&idev->n_pds_lock);
1421 spin_lock_init(&idev->n_ahs_lock); 1425 spin_lock_init(&idev->n_ahs_lock);
1422 spin_lock_init(&idev->n_cqs_lock); 1426 spin_lock_init(&idev->n_cqs_lock);
1427 spin_lock_init(&idev->n_qps_lock);
1423 spin_lock_init(&idev->n_srqs_lock); 1428 spin_lock_init(&idev->n_srqs_lock);
1424 spin_lock_init(&idev->n_mcast_grps_lock); 1429 spin_lock_init(&idev->n_mcast_grps_lock);
1425 1430
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.h b/drivers/infiniband/hw/ipath/ipath_verbs.h
index f2956090d93f..09bbb3f9a217 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.h
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.h
@@ -482,6 +482,8 @@ struct ipath_ibdev {
482 spinlock_t n_ahs_lock; 482 spinlock_t n_ahs_lock;
483 u32 n_cqs_allocated; /* number of CQs allocated for device */ 483 u32 n_cqs_allocated; /* number of CQs allocated for device */
484 spinlock_t n_cqs_lock; 484 spinlock_t n_cqs_lock;
485 u32 n_qps_allocated; /* number of QPs allocated for device */
486 spinlock_t n_qps_lock;
485 u32 n_srqs_allocated; /* number of SRQs allocated for device */ 487 u32 n_srqs_allocated; /* number of SRQs allocated for device */
486 spinlock_t n_srqs_lock; 488 spinlock_t n_srqs_lock;
487 u32 n_mcast_grps_allocated; /* number of mcast groups allocated */ 489 u32 n_mcast_grps_allocated; /* number of mcast groups allocated */
@@ -792,6 +794,8 @@ extern unsigned int ib_ipath_max_cqs;
792 794
793extern unsigned int ib_ipath_max_qp_wrs; 795extern unsigned int ib_ipath_max_qp_wrs;
794 796
797extern unsigned int ib_ipath_max_qps;
798
795extern unsigned int ib_ipath_max_sges; 799extern unsigned int ib_ipath_max_sges;
796 800
797extern unsigned int ib_ipath_max_mcast_grps; 801extern unsigned int ib_ipath_max_mcast_grps;