aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_provider.c
diff options
context:
space:
mode:
authorJack Morgenstein <jackm@mellanox.co.il>2005-10-10 16:48:07 -0400
committerRoland Dreier <rolandd@cisco.com>2005-10-17 18:20:29 -0400
commitefaae8f71f3088cc73c9e5ceabbd314aa82ac768 (patch)
treeb19084ae0a9dc6837cb2837cbd21386c9f1b2e0e /drivers/infiniband/hw/mthca/mthca_provider.c
parent4ab6fb7e5b3d34b65a1c3473d80d9d1a462d3a49 (diff)
[IB] mthca: Better limit checking and reporting
Check the sizes of CQs, QPs and SRQs when creating objects, and fail instead of creating too-big queues. Also return real limits instead of just plausible-sounding values from mthca_query_device(). Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_provider.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 53b29a0841bf..46864d18827d 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -90,17 +90,26 @@ static int mthca_query_device(struct ib_device *ibdev,
90 90
91 props->max_mr_size = ~0ull; 91 props->max_mr_size = ~0ull;
92 props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps; 92 props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps;
93 props->max_qp_wr = 0xffff; 93 props->max_qp_wr = mdev->limits.max_wqes;
94 props->max_sge = mdev->limits.max_sg; 94 props->max_sge = mdev->limits.max_sg;
95 props->max_cq = mdev->limits.num_cqs - mdev->limits.reserved_cqs; 95 props->max_cq = mdev->limits.num_cqs - mdev->limits.reserved_cqs;
96 props->max_cqe = 0xffff; 96 props->max_cqe = mdev->limits.max_cqes;
97 props->max_mr = mdev->limits.num_mpts - mdev->limits.reserved_mrws; 97 props->max_mr = mdev->limits.num_mpts - mdev->limits.reserved_mrws;
98 props->max_pd = mdev->limits.num_pds - mdev->limits.reserved_pds; 98 props->max_pd = mdev->limits.num_pds - mdev->limits.reserved_pds;
99 props->max_qp_rd_atom = 1 << mdev->qp_table.rdb_shift; 99 props->max_qp_rd_atom = 1 << mdev->qp_table.rdb_shift;
100 props->max_qp_init_rd_atom = 1 << mdev->qp_table.rdb_shift; 100 props->max_qp_init_rd_atom = mdev->limits.max_qp_init_rdma;
101 props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp;
102 props->max_srq = mdev->limits.num_srqs - mdev->limits.reserved_srqs;
103 props->max_srq_wr = mdev->limits.max_srq_wqes;
104 props->max_srq_sge = mdev->limits.max_sg;
101 props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay; 105 props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay;
102 props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ? 106 props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ?
103 IB_ATOMIC_HCA : IB_ATOMIC_NONE; 107 IB_ATOMIC_HCA : IB_ATOMIC_NONE;
108 props->max_pkeys = mdev->limits.pkey_table_len;
109 props->max_mcast_grp = mdev->limits.num_mgms + mdev->limits.num_amgms;
110 props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
111 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
112 props->max_mcast_grp;
104 113
105 err = 0; 114 err = 0;
106 out: 115 out:
@@ -640,6 +649,9 @@ static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries,
640 int nent; 649 int nent;
641 int err; 650 int err;
642 651
652 if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes)
653 return ERR_PTR(-EINVAL);
654
643 if (context) { 655 if (context) {
644 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) 656 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
645 return ERR_PTR(-EFAULT); 657 return ERR_PTR(-EFAULT);