Cap the maximum number of address handles.

Signed-off-by: Bryan O'Sullivan <[EMAIL PROTECTED]>

diff -r def81ab50644 -r e823378bd19c drivers/infiniband/hw/ipath/ipath_verbs.c
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c Fri May 12 15:55:27 2006 -0700
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c Fri May 12 15:55:27 2006 -0700
@@ -59,6 +59,11 @@ module_param_named(max_pds, ib_ipath_max
 module_param_named(max_pds, ib_ipath_max_pds, uint, S_IWUSR | S_IRUGO);
 MODULE_PARM_DESC(max_pds,
                 "Maximum number of protection domains to support");
+
+static unsigned int ib_ipath_max_ahs = 0xFFFF;
+module_param_named(max_ahs, ib_ipath_max_ahs, uint, S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(max_ahs,
+                "Maximum number of address handles to support");
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("PathScale <[EMAIL PROTECTED]>");
@@ -592,6 +597,7 @@ static int ipath_query_device(struct ib_
        props->max_qp_wr = 0xffff;
        props->max_sge = 255;
        props->max_cq = 0xffff;
+       props->max_ah = ib_ipath_max_ahs;
        props->max_cqe = 0xffff;
        props->max_mr = dev->lk_table.max;
        props->max_pd = ib_ipath_max_pds;
@@ -764,13 +770,13 @@ static struct ib_pd *ipath_alloc_pd(stru
                goto bail;
        }
 
-       dev->n_pds_allocated++;
-
        pd = kmalloc(sizeof *pd, GFP_KERNEL);
        if (!pd) {
                ret = ERR_PTR(-ENOMEM);
                goto bail;
        }
+
+       dev->n_pds_allocated++;
 
        /* ib_alloc_pd() will initialize pd->ibpd. */
        pd->user = udata != NULL;
@@ -805,6 +811,12 @@ static struct ib_ah *ipath_create_ah(str
 {
        struct ipath_ah *ah;
        struct ib_ah *ret;
+       struct ipath_ibdev *dev = to_idev(pd->device);
+
+       if (dev->n_ahs_allocated == ib_ipath_max_ahs) {
+               ret = ERR_PTR(-ENOMEM);
+               goto bail;
+       }
 
        /* A multicast address requires a GRH (see ch. 8.4.1). */
        if (ah_attr->dlid >= IPS_MULTICAST_LID_BASE &&
@@ -848,7 +860,10 @@ bail:
  */
 static int ipath_destroy_ah(struct ib_ah *ibah)
 {
+       struct ipath_ibdev *dev = to_idev(ibah->device);
        struct ipath_ah *ah = to_iah(ibah);
+
+       dev->n_ahs_allocated--;
 
        kfree(ah);
 
diff -r def81ab50644 -r e823378bd19c drivers/infiniband/hw/ipath/ipath_verbs.h
--- a/drivers/infiniband/hw/ipath/ipath_verbs.h Fri May 12 15:55:27 2006 -0700
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.h Fri May 12 15:55:27 2006 -0700
@@ -432,6 +432,7 @@ struct ipath_ibdev {
        __be64 gid_prefix;      /* in network order */
        __be64 mkey;
        u32 n_pds_allocated;    /* number of PDs allocated for device */
+       u32 n_ahs_allocated;    /* number of AHs allocated for device */
        u64 ipath_sword;        /* total dwords sent (sample result) */
        u64 ipath_rword;        /* total dwords received (sample result) */
        u64 ipath_spkts;        /* total packets sent (sample result) */
_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to