diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-06-23 20:55:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-06-29 02:24:31 -0400 |
commit | 9618e2ffd78aaa43a5815e1dd456b4dd95f9e53b (patch) | |
tree | 2d75562cd72aa8492154054b90a6d659a80ac4ee /net/8021q/vlan_dev.c | |
parent | bc66154efe163a80f269d448572f7906756e9338 (diff) |
vlan: 64 bit rx counters
Use u64_stats_sync infrastructure to implement 64bit rx stats.
(tx stats are addressed later)
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q/vlan_dev.c')
-rw-r--r-- | net/8021q/vlan_dev.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index 529842677817..c6456cb842fa 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -166,6 +166,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
166 | 166 | ||
167 | rx_stats = per_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats, | 167 | rx_stats = per_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats, |
168 | smp_processor_id()); | 168 | smp_processor_id()); |
169 | u64_stats_update_begin(&rx_stats->syncp); | ||
169 | rx_stats->rx_packets++; | 170 | rx_stats->rx_packets++; |
170 | rx_stats->rx_bytes += skb->len; | 171 | rx_stats->rx_bytes += skb->len; |
171 | 172 | ||
@@ -182,7 +183,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
182 | break; | 183 | break; |
183 | 184 | ||
184 | case PACKET_MULTICAST: | 185 | case PACKET_MULTICAST: |
185 | rx_stats->multicast++; | 186 | rx_stats->rx_multicast++; |
186 | break; | 187 | break; |
187 | 188 | ||
188 | case PACKET_OTHERHOST: | 189 | case PACKET_OTHERHOST: |
@@ -197,6 +198,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, | |||
197 | default: | 198 | default: |
198 | break; | 199 | break; |
199 | } | 200 | } |
201 | u64_stats_update_end(&rx_stats->syncp); | ||
200 | 202 | ||
201 | vlan_set_encap_proto(skb, vhdr); | 203 | vlan_set_encap_proto(skb, vhdr); |
202 | 204 | ||
@@ -801,27 +803,37 @@ static u32 vlan_ethtool_get_flags(struct net_device *dev) | |||
801 | return dev_ethtool_get_flags(vlan->real_dev); | 803 | return dev_ethtool_get_flags(vlan->real_dev); |
802 | } | 804 | } |
803 | 805 | ||
804 | static struct net_device_stats *vlan_dev_get_stats(struct net_device *dev) | 806 | static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev) |
805 | { | 807 | { |
806 | struct net_device_stats *stats = &dev->stats; | 808 | struct rtnl_link_stats64 *stats = &dev->stats64; |
807 | 809 | ||
808 | dev_txq_stats_fold(dev, stats); | 810 | dev_txq_stats_fold(dev, &dev->stats); |
809 | 811 | ||
810 | if (vlan_dev_info(dev)->vlan_rx_stats) { | 812 | if (vlan_dev_info(dev)->vlan_rx_stats) { |
811 | struct vlan_rx_stats *p, rx = {0}; | 813 | struct vlan_rx_stats *p, accum = {0}; |
812 | int i; | 814 | int i; |
813 | 815 | ||
814 | for_each_possible_cpu(i) { | 816 | for_each_possible_cpu(i) { |
817 | u64 rxpackets, rxbytes, rxmulticast; | ||
818 | unsigned int start; | ||
819 | |||
815 | p = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats, i); | 820 | p = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats, i); |
816 | rx.rx_packets += p->rx_packets; | 821 | do { |
817 | rx.rx_bytes += p->rx_bytes; | 822 | start = u64_stats_fetch_begin_bh(&p->syncp); |
818 | rx.rx_errors += p->rx_errors; | 823 | rxpackets = p->rx_packets; |
819 | rx.multicast += p->multicast; | 824 | rxbytes = p->rx_bytes; |
825 | rxmulticast = p->rx_multicast; | ||
826 | } while (u64_stats_fetch_retry_bh(&p->syncp, start)); | ||
827 | accum.rx_packets += rxpackets; | ||
828 | accum.rx_bytes += rxbytes; | ||
829 | accum.rx_multicast += rxmulticast; | ||
830 | /* rx_errors is an ulong, not protected by syncp */ | ||
831 | accum.rx_errors += p->rx_errors; | ||
820 | } | 832 | } |
821 | stats->rx_packets = rx.rx_packets; | 833 | stats->rx_packets = accum.rx_packets; |
822 | stats->rx_bytes = rx.rx_bytes; | 834 | stats->rx_bytes = accum.rx_bytes; |
823 | stats->rx_errors = rx.rx_errors; | 835 | stats->rx_errors = accum.rx_errors; |
824 | stats->multicast = rx.multicast; | 836 | stats->multicast = accum.rx_multicast; |
825 | } | 837 | } |
826 | return stats; | 838 | return stats; |
827 | } | 839 | } |
@@ -848,7 +860,7 @@ static const struct net_device_ops vlan_netdev_ops = { | |||
848 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, | 860 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, |
849 | .ndo_do_ioctl = vlan_dev_ioctl, | 861 | .ndo_do_ioctl = vlan_dev_ioctl, |
850 | .ndo_neigh_setup = vlan_dev_neigh_setup, | 862 | .ndo_neigh_setup = vlan_dev_neigh_setup, |
851 | .ndo_get_stats = vlan_dev_get_stats, | 863 | .ndo_get_stats64 = vlan_dev_get_stats64, |
852 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 864 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
853 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, | 865 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, |
854 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, | 866 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, |
@@ -872,7 +884,7 @@ static const struct net_device_ops vlan_netdev_accel_ops = { | |||
872 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, | 884 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, |
873 | .ndo_do_ioctl = vlan_dev_ioctl, | 885 | .ndo_do_ioctl = vlan_dev_ioctl, |
874 | .ndo_neigh_setup = vlan_dev_neigh_setup, | 886 | .ndo_neigh_setup = vlan_dev_neigh_setup, |
875 | .ndo_get_stats = vlan_dev_get_stats, | 887 | .ndo_get_stats64 = vlan_dev_get_stats64, |
876 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 888 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
877 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, | 889 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, |
878 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, | 890 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, |
@@ -897,7 +909,7 @@ static const struct net_device_ops vlan_netdev_ops_sq = { | |||
897 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, | 909 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, |
898 | .ndo_do_ioctl = vlan_dev_ioctl, | 910 | .ndo_do_ioctl = vlan_dev_ioctl, |
899 | .ndo_neigh_setup = vlan_dev_neigh_setup, | 911 | .ndo_neigh_setup = vlan_dev_neigh_setup, |
900 | .ndo_get_stats = vlan_dev_get_stats, | 912 | .ndo_get_stats64 = vlan_dev_get_stats64, |
901 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 913 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
902 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, | 914 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, |
903 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, | 915 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, |
@@ -922,7 +934,7 @@ static const struct net_device_ops vlan_netdev_accel_ops_sq = { | |||
922 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, | 934 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, |
923 | .ndo_do_ioctl = vlan_dev_ioctl, | 935 | .ndo_do_ioctl = vlan_dev_ioctl, |
924 | .ndo_neigh_setup = vlan_dev_neigh_setup, | 936 | .ndo_neigh_setup = vlan_dev_neigh_setup, |
925 | .ndo_get_stats = vlan_dev_get_stats, | 937 | .ndo_get_stats64 = vlan_dev_get_stats64, |
926 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 938 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
927 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, | 939 | .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup, |
928 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, | 940 | .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done, |