aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ppp
diff options
context:
space:
mode:
authorKevin Groeneveld <kgroeneveld@gmail.com>2012-07-27 13:38:53 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-03 23:40:12 -0400
commite51f6ff396eac38582eb583d16c5d9be05a848d2 (patch)
treeeab2eca74cb7b1459b50362d48cc6be5bbfc0de2 /drivers/net/ppp
parent8ff5105a2b9dd0ba596719b165c1827d101e5f1a (diff)
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>
Diffstat (limited to 'drivers/net/ppp')
-rw-r--r--drivers/net/ppp/ppp_generic.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 5c0557222f20..eb3f5cefeba3 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -94,6 +94,18 @@ struct ppp_file {
94#define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel) 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 */
101struct ppp_link_stats {
102 u64 rx_packets;
103 u64 tx_packets;
104 u64 rx_bytes;
105 u64 tx_bytes;
106};
107
108/*
97 * Data structure describing one ppp unit. 109 * Data structure describing one ppp unit.
98 * A ppp unit corresponds to a ppp network interface device 110 * A ppp unit corresponds to a ppp network interface device
99 * and represents a multilink bundle. 111 * and represents a multilink bundle.
@@ -136,6 +148,7 @@ struct ppp {
136 unsigned pass_len, active_len; 148 unsigned pass_len, active_len;
137#endif /* CONFIG_PPP_FILTER */ 149#endif /* CONFIG_PPP_FILTER */
138 struct net *ppp_net; /* the net we belong to */ 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/*
@@ -1021,9 +1034,34 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1021 return err; 1034 return err;
1022} 1035}
1023 1036
1037struct rtnl_link_stats64*
1038ppp_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
1024static const struct net_device_ops ppp_netdev_ops = { 1061static const struct net_device_ops ppp_netdev_ops = {
1025 .ndo_start_xmit = ppp_start_xmit, 1062 .ndo_start_xmit = ppp_start_xmit,
1026 .ndo_do_ioctl = ppp_net_ioctl, 1063 .ndo_do_ioctl = ppp_net_ioctl,
1064 .ndo_get_stats64 = ppp_get_stats64,
1027}; 1065};
1028 1066
1029static void ppp_setup(struct net_device *dev) 1067static void ppp_setup(struct net_device *dev)
@@ -1157,8 +1195,8 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1157#endif /* CONFIG_PPP_FILTER */ 1195#endif /* CONFIG_PPP_FILTER */
1158 } 1196 }
1159 1197
1160 ++ppp->dev->stats.tx_packets; 1198 ++ppp->stats64.tx_packets;
1161 ppp->dev->stats.tx_bytes += skb->len - 2; 1199 ppp->stats64.tx_bytes += skb->len - 2;
1162 1200
1163 switch (proto) { 1201 switch (proto) {
1164 case PPP_IP: 1202 case PPP_IP:
@@ -1745,8 +1783,8 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1745 break; 1783 break;
1746 } 1784 }
1747 1785
1748 ++ppp->dev->stats.rx_packets; 1786 ++ppp->stats64.rx_packets;
1749 ppp->dev->stats.rx_bytes += skb->len - 2; 1787 ppp->stats64.rx_bytes += skb->len - 2;
1750 1788
1751 npi = proto_to_npindex(proto); 1789 npi = proto_to_npindex(proto);
1752 if (npi < 0) { 1790 if (npi < 0) {
@@ -2570,12 +2608,12 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
2570 struct slcompress *vj = ppp->vj; 2608 struct slcompress *vj = ppp->vj;
2571 2609
2572 memset(st, 0, sizeof(*st)); 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 st->p.ppp_ierrors = ppp->dev->stats.rx_errors; 2612 st->p.ppp_ierrors = ppp->dev->stats.rx_errors;
2575 st->p.ppp_ibytes = ppp->dev->stats.rx_bytes; 2613 st->p.ppp_ibytes = ppp->stats64.rx_bytes;
2576 st->p.ppp_opackets = ppp->dev->stats.tx_packets; 2614 st->p.ppp_opackets = ppp->stats64.tx_packets;
2577 st->p.ppp_oerrors = ppp->dev->stats.tx_errors; 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 if (!vj) 2617 if (!vj)
2580 return; 2618 return;
2581 st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; 2619 st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;