aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDivy Le Ray <divy@chelsio.com>2007-03-31 03:23:13 -0400
committerJeff Garzik <jeff@garzik.org>2007-04-03 22:31:09 -0400
commit9f238486f5438b2e44f760b11fa3a08714c1ddb6 (patch)
tree4db457aaedba5c4af8f6b397ef34dcc46462bf7b /drivers
parent59117d3f4e3f5a7980353d2f476e516c758ce921 (diff)
cxgb3 - Safeguard TCAM size usage
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/cxgb3/common.h3
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c7
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c4
3 files changed, 11 insertions, 3 deletions
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 85e5543cfb57..38a0565ad1c1 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -358,6 +358,9 @@ enum {
358 MC5_MODE_72_BIT = 2 358 MC5_MODE_72_BIT = 2
359}; 359};
360 360
361/* MC5 min active region size */
362enum { MC5_MIN_TIDS = 16 };
363
361struct vpd_params { 364struct vpd_params {
362 unsigned int cclk; 365 unsigned int cclk;
363 unsigned int mclk; 366 unsigned int mclk;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index d55383610559..b82544e08689 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -485,12 +485,14 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \
485static ssize_t set_nfilters(struct net_device *dev, unsigned int val) 485static ssize_t set_nfilters(struct net_device *dev, unsigned int val)
486{ 486{
487 struct adapter *adap = dev->priv; 487 struct adapter *adap = dev->priv;
488 int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0;
488 489
489 if (adap->flags & FULL_INIT_DONE) 490 if (adap->flags & FULL_INIT_DONE)
490 return -EBUSY; 491 return -EBUSY;
491 if (val && adap->params.rev == 0) 492 if (val && adap->params.rev == 0)
492 return -EINVAL; 493 return -EINVAL;
493 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers) 494 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nservers -
495 min_tids)
494 return -EINVAL; 496 return -EINVAL;
495 adap->params.mc5.nfilters = val; 497 adap->params.mc5.nfilters = val;
496 return 0; 498 return 0;
@@ -508,7 +510,8 @@ static ssize_t set_nservers(struct net_device *dev, unsigned int val)
508 510
509 if (adap->flags & FULL_INIT_DONE) 511 if (adap->flags & FULL_INIT_DONE)
510 return -EBUSY; 512 return -EBUSY;
511 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters) 513 if (val > t3_mc5_size(&adap->mc5) - adap->params.mc5.nfilters -
514 MC5_MIN_TIDS)
512 return -EINVAL; 515 return -EINVAL;
513 adap->params.mc5.nservers = val; 516 adap->params.mc5.nservers = val;
514 return 0; 517 return 0;
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index f6ed033efb56..eed7a48e3111 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -553,7 +553,9 @@ int cxgb3_alloc_atid(struct t3cdev *tdev, struct cxgb3_client *client,
553 struct tid_info *t = &(T3C_DATA(tdev))->tid_maps; 553 struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
554 554
555 spin_lock_bh(&t->atid_lock); 555 spin_lock_bh(&t->atid_lock);
556 if (t->afree) { 556 if (t->afree &&
557 t->atids_in_use + atomic_read(&t->tids_in_use) + MC5_MIN_TIDS <=
558 t->ntids) {
557 union active_open_entry *p = t->afree; 559 union active_open_entry *p = t->afree;
558 560
559 atid = (p - t->atid_tab) + t->atid_base; 561 atid = (p - t->atid_tab) + t->atid_base;