cxgb3 - Safeguard TCAM size usage
authorDivy Le Ray <divy@chelsio.com>
Sat, 31 Mar 2007 07:23:13 +0000 (00:23 -0700)
committerJeff Garzik <jeff@garzik.org>
Wed, 4 Apr 2007 02:31:09 +0000 (22:31 -0400)
Ensure that the TCAM active region size is at least 16.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/cxgb3/common.h
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb3/cxgb3_offload.c

index 85e5543cfb574c4f3815c659577c4e8718b26df8..38a0565ad1c16b49c60a82b10fc4350eb246a846 100644 (file)
@@ -358,6 +358,9 @@ enum {
        MC5_MODE_72_BIT = 2
 };
 
+/* MC5 min active region size */
+enum { MC5_MIN_TIDS = 16 };
+
 struct vpd_params {
        unsigned int cclk;
        unsigned int mclk;
index d553836105591eba8d74a579112e44cbdc992fb1..b82544e08689a45e3997f20d8c578cd671cefc51 100644 (file)
@@ -485,12 +485,14 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \
 static ssize_t set_nfilters(struct net_device *dev, unsigned int val)
 {
        struct adapter *adap = dev->priv;
+       int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0;
 
        if (adap->flags & FULL_INIT_DONE)
                return -EBUSY;
        if (val && adap->params.rev == 0)
                return -EINVAL;
-       if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers)
+       if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers -
+           min_tids)
                return -EINVAL;
        adap->params.mc5.nfilters = val;
        return 0;
@@ -508,7 +510,8 @@ static ssize_t set_nservers(struct net_device *dev, unsigned int val)
 
        if (adap->flags & FULL_INIT_DONE)
                return -EBUSY;
-       if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters)
+       if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters -
+           MC5_MIN_TIDS)
                return -EINVAL;
        adap->params.mc5.nservers = val;
        return 0;
index f6ed033efb56519cb924b790a225d642b7b8cb6d..eed7a48e3111d886292254b6eb6b33e92b19faf6 100644 (file)
@@ -553,7 +553,9 @@ int cxgb3_alloc_atid(struct t3cdev *tdev, struct cxgb3_client *client,
        struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
 
        spin_lock_bh(&t->atid_lock);
-       if (t->afree) {
+       if (t->afree &&
+           t->atids_in_use + atomic_read(&t->tids_in_use) + MC5_MIN_TIDS <=
+           t->ntids) {
                union active_open_entry *p = t->afree;
 
                atid = (p - t->atid_tab) + t->atid_base;