aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-06-23 20:55:06 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-29 02:24:31 -0400
commit9618e2ffd78aaa43a5815e1dd456b4dd95f9e53b (patch)
tree2d75562cd72aa8492154054b90a6d659a80ac4ee /net/8021q
parentbc66154efe163a80f269d448572f7906756e9338 (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')
-rw-r--r--net/8021q/vlan.h13
-rw-r--r--net/8021q/vlan_core.c7
-rw-r--r--net/8021q/vlan_dev.c46
3 files changed, 41 insertions, 25 deletions
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 6abdcac1b2e8..8d9503ad01da 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -2,6 +2,7 @@
2#define __BEN_VLAN_802_1Q_INC__ 2#define __BEN_VLAN_802_1Q_INC__
3 3
4#include <linux/if_vlan.h> 4#include <linux/if_vlan.h>
5#include <linux/u64_stats_sync.h>
5 6
6 7
7/** 8/**
@@ -21,14 +22,16 @@ struct vlan_priority_tci_mapping {
21 * struct vlan_rx_stats - VLAN percpu rx stats 22 * struct vlan_rx_stats - VLAN percpu rx stats
22 * @rx_packets: number of received packets 23 * @rx_packets: number of received packets
23 * @rx_bytes: number of received bytes 24 * @rx_bytes: number of received bytes
24 * @multicast: number of received multicast packets 25 * @rx_multicast: number of received multicast packets
26 * @syncp: synchronization point for 64bit counters
25 * @rx_errors: number of errors 27 * @rx_errors: number of errors
26 */ 28 */
27struct vlan_rx_stats { 29struct vlan_rx_stats {
28 unsigned long rx_packets; 30 u64 rx_packets;
29 unsigned long rx_bytes; 31 u64 rx_bytes;
30 unsigned long multicast; 32 u64 rx_multicast;
31 unsigned long rx_errors; 33 struct u64_stats_sync syncp;
34 unsigned long rx_errors;
32}; 35};
33 36
34/** 37/**
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 50f58f5f1c34..1b9406a31f0c 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -41,9 +41,9 @@ int vlan_hwaccel_do_receive(struct sk_buff *skb)
41 skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci); 41 skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
42 skb->vlan_tci = 0; 42 skb->vlan_tci = 0;
43 43
44 rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats, 44 rx_stats = this_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats);
45 smp_processor_id());
46 45
46 u64_stats_update_begin(&rx_stats->syncp);
47 rx_stats->rx_packets++; 47 rx_stats->rx_packets++;
48 rx_stats->rx_bytes += skb->len; 48 rx_stats->rx_bytes += skb->len;
49 49
@@ -51,7 +51,7 @@ int vlan_hwaccel_do_receive(struct sk_buff *skb)
51 case PACKET_BROADCAST: 51 case PACKET_BROADCAST:
52 break; 52 break;
53 case PACKET_MULTICAST: 53 case PACKET_MULTICAST:
54 rx_stats->multicast++; 54 rx_stats->rx_multicast++;
55 break; 55 break;
56 case PACKET_OTHERHOST: 56 case PACKET_OTHERHOST:
57 /* Our lower layer thinks this is not local, let's make sure. 57 /* Our lower layer thinks this is not local, let's make sure.
@@ -62,6 +62,7 @@ int vlan_hwaccel_do_receive(struct sk_buff *skb)
62 skb->pkt_type = PACKET_HOST; 62 skb->pkt_type = PACKET_HOST;
63 break; 63 break;
64 } 64 }
65 u64_stats_update_end(&rx_stats->syncp);
65 return 0; 66 return 0;
66} 67}
67 68
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
804static struct net_device_stats *vlan_dev_get_stats(struct net_device *dev) 806static 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,