diff options
author | Bryan O'Sullivan <bos@pathscale.com> | 2006-07-01 07:35:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-01 12:55:59 -0400 |
commit | fe62546a6afa141c4ab9aef65f5978a1b36cb523 (patch) | |
tree | 44b317774fc0db45e90c394a1575bb19d08c00bb /drivers/infiniband/hw/ipath/ipath_verbs.c | |
parent | e8a88f09f21c55a7e7f570290ecde570e2c37771 (diff) |
[PATCH] IB/ipath: enforce device resource limits
These limits are somewhat artificial in that we don't actually have any
device limits. However, the verbs layer expects that such limits exist
and are enforced, so we make up arbitrary (but sensible) limits.
Signed-off-by: Robert Walsh <robert.walsh@qlogic.com>
Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com>
Cc: "Michael S. Tsirkin" <mst@mellanox.co.il>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_verbs.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_verbs.c | 109 |
1 files changed, 96 insertions, 13 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index e04c7619f9fe..70547d1f5908 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c | |||
@@ -56,6 +56,59 @@ unsigned int ib_ipath_debug; /* debug mask */ | |||
56 | module_param_named(debug, ib_ipath_debug, uint, S_IWUSR | S_IRUGO); | 56 | module_param_named(debug, ib_ipath_debug, uint, S_IWUSR | S_IRUGO); |
57 | MODULE_PARM_DESC(debug, "Verbs debug mask"); | 57 | MODULE_PARM_DESC(debug, "Verbs debug mask"); |
58 | 58 | ||
59 | static unsigned int ib_ipath_max_pds = 0xFFFF; | ||
60 | module_param_named(max_pds, ib_ipath_max_pds, uint, S_IWUSR | S_IRUGO); | ||
61 | MODULE_PARM_DESC(max_pds, | ||
62 | "Maximum number of protection domains to support"); | ||
63 | |||
64 | static unsigned int ib_ipath_max_ahs = 0xFFFF; | ||
65 | module_param_named(max_ahs, ib_ipath_max_ahs, uint, S_IWUSR | S_IRUGO); | ||
66 | MODULE_PARM_DESC(max_ahs, "Maximum number of address handles to support"); | ||
67 | |||
68 | unsigned int ib_ipath_max_cqes = 0x2FFFF; | ||
69 | module_param_named(max_cqes, ib_ipath_max_cqes, uint, S_IWUSR | S_IRUGO); | ||
70 | MODULE_PARM_DESC(max_cqes, | ||
71 | "Maximum number of completion queue entries to support"); | ||
72 | |||
73 | unsigned int ib_ipath_max_cqs = 0x1FFFF; | ||
74 | module_param_named(max_cqs, ib_ipath_max_cqs, uint, S_IWUSR | S_IRUGO); | ||
75 | MODULE_PARM_DESC(max_cqs, "Maximum number of completion queues to support"); | ||
76 | |||
77 | unsigned int ib_ipath_max_qp_wrs = 0x3FFF; | ||
78 | module_param_named(max_qp_wrs, ib_ipath_max_qp_wrs, uint, | ||
79 | S_IWUSR | S_IRUGO); | ||
80 | MODULE_PARM_DESC(max_qp_wrs, "Maximum number of QP WRs to support"); | ||
81 | |||
82 | unsigned int ib_ipath_max_sges = 0x60; | ||
83 | module_param_named(max_sges, ib_ipath_max_sges, uint, S_IWUSR | S_IRUGO); | ||
84 | MODULE_PARM_DESC(max_sges, "Maximum number of SGEs to support"); | ||
85 | |||
86 | unsigned int ib_ipath_max_mcast_grps = 16384; | ||
87 | module_param_named(max_mcast_grps, ib_ipath_max_mcast_grps, uint, | ||
88 | S_IWUSR | S_IRUGO); | ||
89 | MODULE_PARM_DESC(max_mcast_grps, | ||
90 | "Maximum number of multicast groups to support"); | ||
91 | |||
92 | unsigned int ib_ipath_max_mcast_qp_attached = 16; | ||
93 | module_param_named(max_mcast_qp_attached, ib_ipath_max_mcast_qp_attached, | ||
94 | uint, S_IWUSR | S_IRUGO); | ||
95 | MODULE_PARM_DESC(max_mcast_qp_attached, | ||
96 | "Maximum number of attached QPs to support"); | ||
97 | |||
98 | unsigned int ib_ipath_max_srqs = 1024; | ||
99 | module_param_named(max_srqs, ib_ipath_max_srqs, uint, S_IWUSR | S_IRUGO); | ||
100 | MODULE_PARM_DESC(max_srqs, "Maximum number of SRQs to support"); | ||
101 | |||
102 | unsigned int ib_ipath_max_srq_sges = 128; | ||
103 | module_param_named(max_srq_sges, ib_ipath_max_srq_sges, | ||
104 | uint, S_IWUSR | S_IRUGO); | ||
105 | MODULE_PARM_DESC(max_srq_sges, "Maximum number of SRQ SGEs to support"); | ||
106 | |||
107 | unsigned int ib_ipath_max_srq_wrs = 0x1FFFF; | ||
108 | module_param_named(max_srq_wrs, ib_ipath_max_srq_wrs, | ||
109 | uint, S_IWUSR | S_IRUGO); | ||
110 | MODULE_PARM_DESC(max_srq_wrs, "Maximum number of SRQ WRs support"); | ||
111 | |||
59 | MODULE_LICENSE("GPL"); | 112 | MODULE_LICENSE("GPL"); |
60 | MODULE_AUTHOR("QLogic <support@pathscale.com>"); | 113 | MODULE_AUTHOR("QLogic <support@pathscale.com>"); |
61 | MODULE_DESCRIPTION("QLogic InfiniPath driver"); | 114 | MODULE_DESCRIPTION("QLogic InfiniPath driver"); |
@@ -581,24 +634,25 @@ static int ipath_query_device(struct ib_device *ibdev, | |||
581 | props->sys_image_guid = dev->sys_image_guid; | 634 | props->sys_image_guid = dev->sys_image_guid; |
582 | 635 | ||
583 | props->max_mr_size = ~0ull; | 636 | props->max_mr_size = ~0ull; |
584 | props->max_qp = 0xffff; | 637 | props->max_qp = dev->qp_table.max; |
585 | props->max_qp_wr = 0xffff; | 638 | props->max_qp_wr = ib_ipath_max_qp_wrs; |
586 | props->max_sge = 255; | 639 | props->max_sge = ib_ipath_max_sges; |
587 | props->max_cq = 0xffff; | 640 | props->max_cq = ib_ipath_max_cqs; |
588 | props->max_cqe = 0xffff; | 641 | props->max_ah = ib_ipath_max_ahs; |
589 | props->max_mr = 0xffff; | 642 | props->max_cqe = ib_ipath_max_cqes; |
590 | props->max_pd = 0xffff; | 643 | props->max_mr = dev->lk_table.max; |
644 | props->max_pd = ib_ipath_max_pds; | ||
591 | props->max_qp_rd_atom = 1; | 645 | props->max_qp_rd_atom = 1; |
592 | props->max_qp_init_rd_atom = 1; | 646 | props->max_qp_init_rd_atom = 1; |
593 | /* props->max_res_rd_atom */ | 647 | /* props->max_res_rd_atom */ |
594 | props->max_srq = 0xffff; | 648 | props->max_srq = ib_ipath_max_srqs; |
595 | props->max_srq_wr = 0xffff; | 649 | props->max_srq_wr = ib_ipath_max_srq_wrs; |
596 | props->max_srq_sge = 255; | 650 | props->max_srq_sge = ib_ipath_max_srq_sges; |
597 | /* props->local_ca_ack_delay */ | 651 | /* props->local_ca_ack_delay */ |
598 | props->atomic_cap = IB_ATOMIC_HCA; | 652 | props->atomic_cap = IB_ATOMIC_HCA; |
599 | props->max_pkeys = ipath_layer_get_npkeys(dev->dd); | 653 | props->max_pkeys = ipath_layer_get_npkeys(dev->dd); |
600 | props->max_mcast_grp = 0xffff; | 654 | props->max_mcast_grp = ib_ipath_max_mcast_grps; |
601 | props->max_mcast_qp_attach = 0xffff; | 655 | props->max_mcast_qp_attach = ib_ipath_max_mcast_qp_attached; |
602 | props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * | 656 | props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * |
603 | props->max_mcast_grp; | 657 | props->max_mcast_grp; |
604 | 658 | ||
@@ -741,15 +795,30 @@ static struct ib_pd *ipath_alloc_pd(struct ib_device *ibdev, | |||
741 | struct ib_ucontext *context, | 795 | struct ib_ucontext *context, |
742 | struct ib_udata *udata) | 796 | struct ib_udata *udata) |
743 | { | 797 | { |
798 | struct ipath_ibdev *dev = to_idev(ibdev); | ||
744 | struct ipath_pd *pd; | 799 | struct ipath_pd *pd; |
745 | struct ib_pd *ret; | 800 | struct ib_pd *ret; |
746 | 801 | ||
802 | /* | ||
803 | * This is actually totally arbitrary. Some correctness tests | ||
804 | * assume there's a maximum number of PDs that can be allocated. | ||
805 | * We don't actually have this limit, but we fail the test if | ||
806 | * we allow allocations of more than we report for this value. | ||
807 | */ | ||
808 | |||
809 | if (dev->n_pds_allocated == ib_ipath_max_pds) { | ||
810 | ret = ERR_PTR(-ENOMEM); | ||
811 | goto bail; | ||
812 | } | ||
813 | |||
747 | pd = kmalloc(sizeof *pd, GFP_KERNEL); | 814 | pd = kmalloc(sizeof *pd, GFP_KERNEL); |
748 | if (!pd) { | 815 | if (!pd) { |
749 | ret = ERR_PTR(-ENOMEM); | 816 | ret = ERR_PTR(-ENOMEM); |
750 | goto bail; | 817 | goto bail; |
751 | } | 818 | } |
752 | 819 | ||
820 | dev->n_pds_allocated++; | ||
821 | |||
753 | /* ib_alloc_pd() will initialize pd->ibpd. */ | 822 | /* ib_alloc_pd() will initialize pd->ibpd. */ |
754 | pd->user = udata != NULL; | 823 | pd->user = udata != NULL; |
755 | 824 | ||
@@ -762,6 +831,9 @@ bail: | |||
762 | static int ipath_dealloc_pd(struct ib_pd *ibpd) | 831 | static int ipath_dealloc_pd(struct ib_pd *ibpd) |
763 | { | 832 | { |
764 | struct ipath_pd *pd = to_ipd(ibpd); | 833 | struct ipath_pd *pd = to_ipd(ibpd); |
834 | struct ipath_ibdev *dev = to_idev(ibpd->device); | ||
835 | |||
836 | dev->n_pds_allocated--; | ||
765 | 837 | ||
766 | kfree(pd); | 838 | kfree(pd); |
767 | 839 | ||
@@ -780,6 +852,12 @@ static struct ib_ah *ipath_create_ah(struct ib_pd *pd, | |||
780 | { | 852 | { |
781 | struct ipath_ah *ah; | 853 | struct ipath_ah *ah; |
782 | struct ib_ah *ret; | 854 | struct ib_ah *ret; |
855 | struct ipath_ibdev *dev = to_idev(pd->device); | ||
856 | |||
857 | if (dev->n_ahs_allocated == ib_ipath_max_ahs) { | ||
858 | ret = ERR_PTR(-ENOMEM); | ||
859 | goto bail; | ||
860 | } | ||
783 | 861 | ||
784 | /* A multicast address requires a GRH (see ch. 8.4.1). */ | 862 | /* A multicast address requires a GRH (see ch. 8.4.1). */ |
785 | if (ah_attr->dlid >= IPS_MULTICAST_LID_BASE && | 863 | if (ah_attr->dlid >= IPS_MULTICAST_LID_BASE && |
@@ -794,7 +872,7 @@ static struct ib_ah *ipath_create_ah(struct ib_pd *pd, | |||
794 | goto bail; | 872 | goto bail; |
795 | } | 873 | } |
796 | 874 | ||
797 | if (ah_attr->port_num != 1 || | 875 | if (ah_attr->port_num < 1 || |
798 | ah_attr->port_num > pd->device->phys_port_cnt) { | 876 | ah_attr->port_num > pd->device->phys_port_cnt) { |
799 | ret = ERR_PTR(-EINVAL); | 877 | ret = ERR_PTR(-EINVAL); |
800 | goto bail; | 878 | goto bail; |
@@ -806,6 +884,8 @@ static struct ib_ah *ipath_create_ah(struct ib_pd *pd, | |||
806 | goto bail; | 884 | goto bail; |
807 | } | 885 | } |
808 | 886 | ||
887 | dev->n_ahs_allocated++; | ||
888 | |||
809 | /* ib_create_ah() will initialize ah->ibah. */ | 889 | /* ib_create_ah() will initialize ah->ibah. */ |
810 | ah->attr = *ah_attr; | 890 | ah->attr = *ah_attr; |
811 | 891 | ||
@@ -823,8 +903,11 @@ bail: | |||
823 | */ | 903 | */ |
824 | static int ipath_destroy_ah(struct ib_ah *ibah) | 904 | static int ipath_destroy_ah(struct ib_ah *ibah) |
825 | { | 905 | { |
906 | struct ipath_ibdev *dev = to_idev(ibah->device); | ||
826 | struct ipath_ah *ah = to_iah(ibah); | 907 | struct ipath_ah *ah = to_iah(ibah); |
827 | 908 | ||
909 | dev->n_ahs_allocated--; | ||
910 | |||
828 | kfree(ah); | 911 | kfree(ah); |
829 | 912 | ||
830 | return 0; | 913 | return 0; |