Commit e51f6ff396eac38582eb583d16c5d9be05a848d2
Committed by
David S. Miller
1 parent
8ff5105a2b
Exists in
master
and in
20 other branches
ppp: add 64 bit stats
Add 64 bit stats to ppp driver. The 64 bit stats include tx_bytes, rx_bytes, tx_packets and rx_packets. Other stats are still 32 bit. The 64 bit stats can be retrieved via the ndo_get_stats operation. The SIOCGPPPSTATS ioctl is still 32 bit stats only. Signed-off-by: Kevin Groeneveld <kgroeneveld@gmail.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 48 additions and 10 deletions Side-by-side Diff
drivers/net/ppp/ppp_generic.c
... | ... | @@ -94,6 +94,18 @@ |
94 | 94 | #define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel) |
95 | 95 | |
96 | 96 | /* |
97 | + * Data structure to hold primary network stats for which | |
98 | + * we want to use 64 bit storage. Other network stats | |
99 | + * are stored in dev->stats of the ppp strucute. | |
100 | + */ | |
101 | +struct ppp_link_stats { | |
102 | + u64 rx_packets; | |
103 | + u64 tx_packets; | |
104 | + u64 rx_bytes; | |
105 | + u64 tx_bytes; | |
106 | +}; | |
107 | + | |
108 | +/* | |
97 | 109 | * Data structure describing one ppp unit. |
98 | 110 | * A ppp unit corresponds to a ppp network interface device |
99 | 111 | * and represents a multilink bundle. |
... | ... | @@ -136,6 +148,7 @@ |
136 | 148 | unsigned pass_len, active_len; |
137 | 149 | #endif /* CONFIG_PPP_FILTER */ |
138 | 150 | struct net *ppp_net; /* the net we belong to */ |
151 | + struct ppp_link_stats stats64; /* 64 bit network stats */ | |
139 | 152 | }; |
140 | 153 | |
141 | 154 | /* |
142 | 155 | |
... | ... | @@ -1021,9 +1034,34 @@ |
1021 | 1034 | return err; |
1022 | 1035 | } |
1023 | 1036 | |
1037 | +struct rtnl_link_stats64* | |
1038 | +ppp_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats64) | |
1039 | +{ | |
1040 | + struct ppp *ppp = netdev_priv(dev); | |
1041 | + | |
1042 | + ppp_recv_lock(ppp); | |
1043 | + stats64->rx_packets = ppp->stats64.rx_packets; | |
1044 | + stats64->rx_bytes = ppp->stats64.rx_bytes; | |
1045 | + ppp_recv_unlock(ppp); | |
1046 | + | |
1047 | + ppp_xmit_lock(ppp); | |
1048 | + stats64->tx_packets = ppp->stats64.tx_packets; | |
1049 | + stats64->tx_bytes = ppp->stats64.tx_bytes; | |
1050 | + ppp_xmit_unlock(ppp); | |
1051 | + | |
1052 | + stats64->rx_errors = dev->stats.rx_errors; | |
1053 | + stats64->tx_errors = dev->stats.tx_errors; | |
1054 | + stats64->rx_dropped = dev->stats.rx_dropped; | |
1055 | + stats64->tx_dropped = dev->stats.tx_dropped; | |
1056 | + stats64->rx_length_errors = dev->stats.rx_length_errors; | |
1057 | + | |
1058 | + return stats64; | |
1059 | +} | |
1060 | + | |
1024 | 1061 | static const struct net_device_ops ppp_netdev_ops = { |
1025 | - .ndo_start_xmit = ppp_start_xmit, | |
1026 | - .ndo_do_ioctl = ppp_net_ioctl, | |
1062 | + .ndo_start_xmit = ppp_start_xmit, | |
1063 | + .ndo_do_ioctl = ppp_net_ioctl, | |
1064 | + .ndo_get_stats64 = ppp_get_stats64, | |
1027 | 1065 | }; |
1028 | 1066 | |
1029 | 1067 | static void ppp_setup(struct net_device *dev) |
... | ... | @@ -1157,8 +1195,8 @@ |
1157 | 1195 | #endif /* CONFIG_PPP_FILTER */ |
1158 | 1196 | } |
1159 | 1197 | |
1160 | - ++ppp->dev->stats.tx_packets; | |
1161 | - ppp->dev->stats.tx_bytes += skb->len - 2; | |
1198 | + ++ppp->stats64.tx_packets; | |
1199 | + ppp->stats64.tx_bytes += skb->len - 2; | |
1162 | 1200 | |
1163 | 1201 | switch (proto) { |
1164 | 1202 | case PPP_IP: |
... | ... | @@ -1745,8 +1783,8 @@ |
1745 | 1783 | break; |
1746 | 1784 | } |
1747 | 1785 | |
1748 | - ++ppp->dev->stats.rx_packets; | |
1749 | - ppp->dev->stats.rx_bytes += skb->len - 2; | |
1786 | + ++ppp->stats64.rx_packets; | |
1787 | + ppp->stats64.rx_bytes += skb->len - 2; | |
1750 | 1788 | |
1751 | 1789 | npi = proto_to_npindex(proto); |
1752 | 1790 | if (npi < 0) { |
1753 | 1791 | |
1754 | 1792 | |
... | ... | @@ -2570,12 +2608,12 @@ |
2570 | 2608 | struct slcompress *vj = ppp->vj; |
2571 | 2609 | |
2572 | 2610 | memset(st, 0, sizeof(*st)); |
2573 | - st->p.ppp_ipackets = ppp->dev->stats.rx_packets; | |
2611 | + st->p.ppp_ipackets = ppp->stats64.rx_packets; | |
2574 | 2612 | st->p.ppp_ierrors = ppp->dev->stats.rx_errors; |
2575 | - st->p.ppp_ibytes = ppp->dev->stats.rx_bytes; | |
2576 | - st->p.ppp_opackets = ppp->dev->stats.tx_packets; | |
2613 | + st->p.ppp_ibytes = ppp->stats64.rx_bytes; | |
2614 | + st->p.ppp_opackets = ppp->stats64.tx_packets; | |
2577 | 2615 | st->p.ppp_oerrors = ppp->dev->stats.tx_errors; |
2578 | - st->p.ppp_obytes = ppp->dev->stats.tx_bytes; | |
2616 | + st->p.ppp_obytes = ppp->stats64.tx_bytes; | |
2579 | 2617 | if (!vj) |
2580 | 2618 | return; |
2581 | 2619 | st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; |