Commit 9d922d4b authored by Kumar Sanghvi's avatar Kumar Sanghvi Committed by David S. Miller

cxgb4: add support to retrieve stats for hash filters

Add support to retrieve packet-count and byte-count for hash-filters
by retrieving filter-entry appropriately based on whether the
request is for hash-filter or not.
Signed-off-by: default avatarKumar Sanghvi <kumaras@chelsio.com>
Signed-off-by: default avatarRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: default avatarGanesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3b0b3bee
...@@ -341,7 +341,7 @@ static int get_filter_steerq(struct net_device *dev, ...@@ -341,7 +341,7 @@ static int get_filter_steerq(struct net_device *dev,
} }
static int get_filter_count(struct adapter *adapter, unsigned int fidx, static int get_filter_count(struct adapter *adapter, unsigned int fidx,
u64 *pkts, u64 *bytes) u64 *pkts, u64 *bytes, bool hash)
{ {
unsigned int tcb_base, tcbaddr; unsigned int tcb_base, tcbaddr;
unsigned int word_offset; unsigned int word_offset;
...@@ -350,14 +350,24 @@ static int get_filter_count(struct adapter *adapter, unsigned int fidx, ...@@ -350,14 +350,24 @@ static int get_filter_count(struct adapter *adapter, unsigned int fidx,
int ret; int ret;
tcb_base = t4_read_reg(adapter, TP_CMM_TCB_BASE_A); tcb_base = t4_read_reg(adapter, TP_CMM_TCB_BASE_A);
if ((fidx != (adapter->tids.nftids + adapter->tids.nsftids - 1)) && if (is_hashfilter(adapter) && hash) {
fidx >= adapter->tids.nftids) if (fidx < adapter->tids.ntids) {
return -E2BIG; f = adapter->tids.tid_tab[fidx];
if (!f)
f = &adapter->tids.ftid_tab[fidx]; return -EINVAL;
if (!f->valid) } else {
return -EINVAL; return -E2BIG;
}
} else {
if ((fidx != (adapter->tids.nftids +
adapter->tids.nsftids - 1)) &&
fidx >= adapter->tids.nftids)
return -E2BIG;
f = &adapter->tids.ftid_tab[fidx];
if (!f->valid)
return -EINVAL;
}
tcbaddr = tcb_base + f->tid * TCB_SIZE; tcbaddr = tcb_base + f->tid * TCB_SIZE;
spin_lock(&adapter->win0_lock); spin_lock(&adapter->win0_lock);
...@@ -409,11 +419,11 @@ static int get_filter_count(struct adapter *adapter, unsigned int fidx, ...@@ -409,11 +419,11 @@ static int get_filter_count(struct adapter *adapter, unsigned int fidx,
} }
int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx, int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx,
u64 *hitcnt, u64 *bytecnt) u64 *hitcnt, u64 *bytecnt, bool hash)
{ {
struct adapter *adapter = netdev2adap(dev); struct adapter *adapter = netdev2adap(dev);
return get_filter_count(adapter, fidx, hitcnt, bytecnt); return get_filter_count(adapter, fidx, hitcnt, bytecnt, hash);
} }
int cxgb4_get_free_ftid(struct net_device *dev, int family) int cxgb4_get_free_ftid(struct net_device *dev, int family)
......
...@@ -755,7 +755,8 @@ static void ch_flower_stats_cb(struct timer_list *t) ...@@ -755,7 +755,8 @@ static void ch_flower_stats_cb(struct timer_list *t)
hash_for_each_rcu(adap->flower_anymatch_tbl, i, flower_entry, link) { hash_for_each_rcu(adap->flower_anymatch_tbl, i, flower_entry, link) {
ret = cxgb4_get_filter_counters(adap->port[0], ret = cxgb4_get_filter_counters(adap->port[0],
flower_entry->filter_id, flower_entry->filter_id,
&packets, &bytes); &packets, &bytes,
flower_entry->fs.hash);
if (!ret) { if (!ret) {
spin_lock(&flower_entry->lock); spin_lock(&flower_entry->lock);
ofld_stats = &flower_entry->stats; ofld_stats = &flower_entry->stats;
...@@ -788,7 +789,8 @@ int cxgb4_tc_flower_stats(struct net_device *dev, ...@@ -788,7 +789,8 @@ int cxgb4_tc_flower_stats(struct net_device *dev,
} }
ret = cxgb4_get_filter_counters(dev, ch_flower->filter_id, ret = cxgb4_get_filter_counters(dev, ch_flower->filter_id,
&packets, &bytes); &packets, &bytes,
ch_flower->fs.hash);
if (ret < 0) if (ret < 0)
goto err; goto err;
......
...@@ -224,7 +224,7 @@ int cxgb4_set_filter(struct net_device *dev, int filter_id, ...@@ -224,7 +224,7 @@ int cxgb4_set_filter(struct net_device *dev, int filter_id,
int cxgb4_del_filter(struct net_device *dev, int filter_id, int cxgb4_del_filter(struct net_device *dev, int filter_id,
struct ch_filter_specification *fs); struct ch_filter_specification *fs);
int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx, int cxgb4_get_filter_counters(struct net_device *dev, unsigned int fidx,
u64 *hitcnt, u64 *bytecnt); u64 *hitcnt, u64 *bytecnt, bool hash);
static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue) static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)
{ {
......
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