aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/main.h
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2012-04-20 11:02:45 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-06-18 12:00:58 -0400
commitf8214865a55f805e65c33350bc0f1eb46dd8433d (patch)
tree0fb4582b2ec3b045a094acd6063f5559e6d4dcb5 /net/batman-adv/main.h
parent66a1b2bcb34b0c74a3422968b15a7ea853ea5a2d (diff)
batman-adv: Add get_ethtool_stats() support
Added additional counters in a bat_stats structure, which are exported through the ethtool api. The counters are specific to batman-adv and includes: forwarded packets and bytes management packets and bytes (aggregated OGMs at this point) translation table packets New counters are added by extending "enum bat_counters" in types.h and adding corresponding descriptive string(s) to bat_counters_strings in soft-iface.c. Counters are increased by calling batadv_add_counter() and incremented by one by calling batadv_inc_counter(). Signed-off-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/main.h')
-rw-r--r--net/batman-adv/main.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 630bbe8968ca..6e0cbdc48321 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -138,6 +138,7 @@ enum dbg_level {
138#include <linux/kthread.h> /* kernel threads */ 138#include <linux/kthread.h> /* kernel threads */
139#include <linux/pkt_sched.h> /* schedule types */ 139#include <linux/pkt_sched.h> /* schedule types */
140#include <linux/workqueue.h> /* workqueue */ 140#include <linux/workqueue.h> /* workqueue */
141#include <linux/percpu.h>
141#include <linux/slab.h> 142#include <linux/slab.h>
142#include <net/sock.h> /* struct sock */ 143#include <net/sock.h> /* struct sock */
143#include <linux/jiffies.h> 144#include <linux/jiffies.h>
@@ -242,4 +243,30 @@ static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout)
242 _dummy > smallest_signed_int(_dummy); }) 243 _dummy > smallest_signed_int(_dummy); })
243#define seq_after(x, y) seq_before(y, x) 244#define seq_after(x, y) seq_before(y, x)
244 245
246/* Stop preemption on local cpu while incrementing the counter */
247static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx,
248 size_t count)
249{
250 int cpu = get_cpu();
251 per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
252 put_cpu();
253}
254
255#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
256
257/* Sum and return the cpu-local counters for index 'idx' */
258static inline uint64_t batadv_sum_counter(struct bat_priv *bat_priv, size_t idx)
259{
260 uint64_t *counters;
261 int cpu;
262 int sum = 0;
263
264 for_each_possible_cpu(cpu) {
265 counters = per_cpu_ptr(bat_priv->bat_counters, cpu);
266 sum += counters[idx];
267 }
268
269 return sum;
270}
271
245#endif /* _NET_BATMAN_ADV_MAIN_H_ */ 272#endif /* _NET_BATMAN_ADV_MAIN_H_ */