Commit 9f238486 authored by Divy Le Ray's avatar Divy Le Ray Committed by Jeff Garzik

cxgb3 - Safeguard TCAM size usage

Ensure that the TCAM active region size is at least 16.
Signed-off-by: default avatarDivy Le Ray <divy@chelsio.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 59117d3f
...@@ -358,6 +358,9 @@ enum { ...@@ -358,6 +358,9 @@ enum {
MC5_MODE_72_BIT = 2 MC5_MODE_72_BIT = 2
}; };
/* MC5 min active region size */
enum { MC5_MIN_TIDS = 16 };
struct vpd_params { struct vpd_params {
unsigned int cclk; unsigned int cclk;
unsigned int mclk; unsigned int mclk;
......
...@@ -485,12 +485,14 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ ...@@ -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) static ssize_t set_nfilters(struct net_device *dev, unsigned int val)
{ {
struct adapter *adap = dev->priv; struct adapter *adap = dev->priv;
int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0;
if (adap->flags & FULL_INIT_DONE) if (adap->flags & FULL_INIT_DONE)
return -EBUSY; return -EBUSY;
if (val && adap->params.rev == 0) if (val && adap->params.rev == 0)
return -EINVAL; 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; return -EINVAL;
adap->params.mc5.nfilters = val; adap->params.mc5.nfilters = val;
return 0; return 0;
...@@ -508,7 +510,8 @@ static ssize_t set_nservers(struct net_device *dev, unsigned int val) ...@@ -508,7 +510,8 @@ static ssize_t set_nservers(struct net_device *dev, unsigned int val)
if (adap->flags & FULL_INIT_DONE) if (adap->flags & FULL_INIT_DONE)
return -EBUSY; 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; return -EINVAL;
adap->params.mc5.nservers = val; adap->params.mc5.nservers = val;
return 0; return 0;
......
...@@ -553,7 +553,9 @@ int cxgb3_alloc_atid(struct t3cdev *tdev, struct cxgb3_client *client, ...@@ -553,7 +553,9 @@ int cxgb3_alloc_atid(struct t3cdev *tdev, struct cxgb3_client *client,
struct tid_info *t = &(T3C_DATA(tdev))->tid_maps; struct tid_info *t = &(T3C_DATA(tdev))->tid_maps;
spin_lock_bh(&t->atid_lock); 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; union active_open_entry *p = t->afree;
atid = (p - t->atid_tab) + t->atid_base; atid = (p - t->atid_tab) + t->atid_base;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment