Commit 470c60c4 authored by Kumar Sanghvi's avatar Kumar Sanghvi Committed by David S. Miller

cxgb4: Assign filter server TIDs properly

The LE workaround code is incorrectly reusing the TCAM TIDs
(meant for allocation by firmware in case of hash collisions) for filter
servers. This patch assigns the filter server TIDs properly starting from
sftid_base index.

Based on original work by Santosh Rastapur <santosh@chelsio.com>
Signed-off-by: default avatarKumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: default avatarHariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7c89e555
...@@ -3012,7 +3012,8 @@ int cxgb4_alloc_sftid(struct tid_info *t, int family, void *data) ...@@ -3012,7 +3012,8 @@ int cxgb4_alloc_sftid(struct tid_info *t, int family, void *data)
} }
if (stid >= 0) { if (stid >= 0) {
t->stid_tab[stid].data = data; t->stid_tab[stid].data = data;
stid += t->stid_base; stid -= t->nstids;
stid += t->sftid_base;
t->stids_in_use++; t->stids_in_use++;
} }
spin_unlock_bh(&t->stid_lock); spin_unlock_bh(&t->stid_lock);
...@@ -3024,7 +3025,14 @@ EXPORT_SYMBOL(cxgb4_alloc_sftid); ...@@ -3024,7 +3025,14 @@ EXPORT_SYMBOL(cxgb4_alloc_sftid);
*/ */
void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family) void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family)
{ {
/* Is it a server filter TID? */
if (t->nsftids && (stid >= t->sftid_base)) {
stid -= t->sftid_base;
stid += t->nstids;
} else {
stid -= t->stid_base; stid -= t->stid_base;
}
spin_lock_bh(&t->stid_lock); spin_lock_bh(&t->stid_lock);
if (family == PF_INET) if (family == PF_INET)
__clear_bit(stid, t->stid_bmap); __clear_bit(stid, t->stid_bmap);
...@@ -4185,7 +4193,7 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid, ...@@ -4185,7 +4193,7 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid,
adap = netdev2adap(dev); adap = netdev2adap(dev);
/* Adjust stid to correct filter index */ /* Adjust stid to correct filter index */
stid -= adap->tids.nstids; stid -= adap->tids.sftid_base;
stid += adap->tids.nftids; stid += adap->tids.nftids;
/* Check to make sure the filter requested is writable ... /* Check to make sure the filter requested is writable ...
...@@ -4248,7 +4256,7 @@ int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid, ...@@ -4248,7 +4256,7 @@ int cxgb4_remove_server_filter(const struct net_device *dev, unsigned int stid,
adap = netdev2adap(dev); adap = netdev2adap(dev);
/* Adjust stid to correct filter index */ /* Adjust stid to correct filter index */
stid -= adap->tids.nstids; stid -= adap->tids.sftid_base;
stid += adap->tids.nftids; stid += adap->tids.nftids;
f = &adap->tids.ftid_tab[stid]; f = &adap->tids.ftid_tab[stid];
......
...@@ -131,7 +131,14 @@ static inline void *lookup_atid(const struct tid_info *t, unsigned int atid) ...@@ -131,7 +131,14 @@ static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
static inline void *lookup_stid(const struct tid_info *t, unsigned int stid) static inline void *lookup_stid(const struct tid_info *t, unsigned int stid)
{ {
/* Is it a server filter TID? */
if (t->nsftids && (stid >= t->sftid_base)) {
stid -= t->sftid_base;
stid += t->nstids;
} else {
stid -= t->stid_base; stid -= t->stid_base;
}
return stid < (t->nstids + t->nsftids) ? t->stid_tab[stid].data : NULL; return stid < (t->nstids + t->nsftids) ? t->stid_tab[stid].data : NULL;
} }
......
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