| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef _NET_OVPN_DCO_OVPNSTATS_H_ |
| 12 |
#define _NET_OVPN_DCO_OVPNSTATS_H_ |
| 13 |
|
| 14 |
#include <linux/atomic.h> |
| 15 |
#include <linux/jiffies.h> |
| 16 |
|
| 17 |
struct ovpn_struct; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
struct ovpn_peer_stat { |
| 23 |
atomic64_t bytes; |
| 24 |
atomic_t packets; |
| 25 |
}; |
| 26 |
|
| 27 |
|
| 28 |
struct ovpn_peer_stats { |
| 29 |
struct ovpn_peer_stat rx; |
| 30 |
struct ovpn_peer_stat tx; |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
struct ovpn_err_stat { |
| 36 |
unsigned int category; |
| 37 |
int errcode; |
| 38 |
u64 count; |
| 39 |
}; |
| 40 |
|
| 41 |
struct ovpn_err_stats { |
| 42 |
|
| 43 |
unsigned int total_stats; |
| 44 |
|
| 45 |
unsigned int n_stats; |
| 46 |
struct ovpn_err_stat stats[]; |
| 47 |
}; |
| 48 |
|
| 49 |
void ovpn_peer_stats_init(struct ovpn_peer_stats *ps); |
| 50 |
|
| 51 |
static inline void ovpn_peer_stats_increment(struct ovpn_peer_stat *stat, const unsigned int n) |
| 52 |
{ |
| 53 |
atomic64_add(n, &stat->bytes); |
| 54 |
atomic_inc(&stat->packets); |
| 55 |
} |
| 56 |
|
| 57 |
static inline void ovpn_peer_stats_increment_rx(struct ovpn_peer_stats *stats, const unsigned int n) |
| 58 |
{ |
| 59 |
ovpn_peer_stats_increment(&stats->rx, n); |
| 60 |
} |
| 61 |
|
| 62 |
static inline void ovpn_peer_stats_increment_tx(struct ovpn_peer_stats *stats, const unsigned int n) |
| 63 |
{ |
| 64 |
ovpn_peer_stats_increment(&stats->tx, n); |
| 65 |
} |
| 66 |
|
| 67 |
#endif |