Debian Codegraph @

drivers/net/ovpn-dco/stats.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* OpenVPN data channel accelerator
3 *
4 * Copyright (C) 2020- OpenVPN, Inc.
5 *
6 * Author: James Yonan <[email protected]>
7 * Antonio Quartulli <[email protected]>
8 * Lev Stipakov <[email protected]>
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 /* per-peer stats, measured on transport layer */
20
21 /* one stat */
22 struct ovpn_peer_stat {
23 atomic64_t bytes;
24 atomic_t packets;
25 };
26
27 /* rx and tx stats, enabled by notify_per != 0 or period != 0 */
28 struct ovpn_peer_stats {
29 struct ovpn_peer_stat rx;
30 struct ovpn_peer_stat tx;
31 };
32
33 /* struct for OVPN_ERR_STATS */
34
35 struct ovpn_err_stat {
36 unsigned int category;
37 int errcode;
38 u64 count;
39 };
40
41 struct ovpn_err_stats {
42 /* total stats, returned by kovpn */
43 unsigned int total_stats;
44 /* number of stats dimensioned below */
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 /* _NET_OVPN_DCO_OVPNSTATS_H_ */