LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2.6.21 1/4] cxgb3 - Safeguard TCAM size usage
@ 2007-03-31  7:23 divy
  2007-04-04  2:31 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: divy @ 2007-03-31  7:23 UTC (permalink / raw)
  To: jeff; +Cc: netdev, linux-kernel, swise

From: Divy Le Ray <divy@chelsio.com>

Ensure that the TCAM active region size is at least 16.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
---

 drivers/net/cxgb3/common.h        |    3 +++
 drivers/net/cxgb3/cxgb3_main.c    |    7 +++++--
 drivers/net/cxgb3/cxgb3_offload.c |    4 +++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 85e5543..38a0565 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -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;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index d553836..b82544e 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
 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_d
 
 	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;
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index f6ed033..eed7a48 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 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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2.6.21 1/4] cxgb3 - Safeguard TCAM size usage
  2007-03-31  7:23 [PATCH 2.6.21 1/4] cxgb3 - Safeguard TCAM size usage divy
@ 2007-04-04  2:31 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-04-04  2:31 UTC (permalink / raw)
  To: divy; +Cc: netdev, linux-kernel, swise

divy@chelsio.com wrote:
> From: Divy Le Ray <divy@chelsio.com>
> 
> Ensure that the TCAM active region size is at least 16.
> 
> Signed-off-by: Divy Le Ray <divy@chelsio.com>
> ---
> 
>  drivers/net/cxgb3/common.h        |    3 +++
>  drivers/net/cxgb3/cxgb3_main.c    |    7 +++++--
>  drivers/net/cxgb3/cxgb3_offload.c |    4 +++-
>  3 files changed, 11 insertions(+), 3 deletions(-)

applied 1-4



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-04  2:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-31  7:23 [PATCH 2.6.21 1/4] cxgb3 - Safeguard TCAM size usage divy
2007-04-04  2:31 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).