diff options
author | Li RongQing <roy.qing.li@gmail.com> | 2014-01-04 00:57:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-04 20:10:24 -0500 |
commit | 8f84985fec10de64a6b4cdfea45f2b0ab8f07c78 (patch) | |
tree | 03d58e9d72384e8066a6232c793b3ee4242668f6 | |
parent | 653864d9dd6ae26d884abfd53420e61e7383b1da (diff) |
net: unify the pcpu_tstats and br_cpu_netstats as one
They are same, so unify them as one, pcpu_sw_netstats.
Define pcpu_sw_netstat in netdevice.h, remove pcpu_tstats
from if_tunnel and remove br_cpu_netstats from br_private.h
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/vxlan.c | 11 | ||||
-rw-r--r-- | include/linux/if_tunnel.h | 9 | ||||
-rw-r--r-- | include/linux/netdevice.h | 11 | ||||
-rw-r--r-- | include/net/ip6_tunnel.h | 2 | ||||
-rw-r--r-- | include/net/ip_tunnels.h | 4 | ||||
-rw-r--r-- | net/bridge/br_device.c | 10 | ||||
-rw-r--r-- | net/bridge/br_input.c | 2 | ||||
-rw-r--r-- | net/bridge/br_private.h | 10 | ||||
-rw-r--r-- | net/ipv4/ip_tunnel.c | 9 | ||||
-rw-r--r-- | net/ipv4/ip_vti.c | 2 | ||||
-rw-r--r-- | net/ipv6/ip6_gre.c | 10 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 12 | ||||
-rw-r--r-- | net/ipv6/ip6_vti.c | 10 | ||||
-rw-r--r-- | net/ipv6/sit.c | 10 | ||||
-rw-r--r-- | net/openvswitch/vport.c | 12 | ||||
-rw-r--r-- | net/openvswitch/vport.h | 2 |
16 files changed, 60 insertions, 66 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index aef44aa44fe3..474a99ed0222 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -1081,7 +1081,7 @@ static void vxlan_rcv(struct vxlan_sock *vs, | |||
1081 | struct iphdr *oip = NULL; | 1081 | struct iphdr *oip = NULL; |
1082 | struct ipv6hdr *oip6 = NULL; | 1082 | struct ipv6hdr *oip6 = NULL; |
1083 | struct vxlan_dev *vxlan; | 1083 | struct vxlan_dev *vxlan; |
1084 | struct pcpu_tstats *stats; | 1084 | struct pcpu_sw_netstats *stats; |
1085 | union vxlan_addr saddr; | 1085 | union vxlan_addr saddr; |
1086 | __u32 vni; | 1086 | __u32 vni; |
1087 | int err = 0; | 1087 | int err = 0; |
@@ -1587,11 +1587,12 @@ EXPORT_SYMBOL_GPL(vxlan_xmit_skb); | |||
1587 | static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, | 1587 | static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, |
1588 | struct vxlan_dev *dst_vxlan) | 1588 | struct vxlan_dev *dst_vxlan) |
1589 | { | 1589 | { |
1590 | struct pcpu_tstats *tx_stats = this_cpu_ptr(src_vxlan->dev->tstats); | 1590 | struct pcpu_sw_netstats *tx_stats, *rx_stats; |
1591 | struct pcpu_tstats *rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats); | ||
1592 | union vxlan_addr loopback; | 1591 | union vxlan_addr loopback; |
1593 | union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip; | 1592 | union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip; |
1594 | 1593 | ||
1594 | tx_stats = this_cpu_ptr(src_vxlan->dev->tstats); | ||
1595 | rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats); | ||
1595 | skb->pkt_type = PACKET_HOST; | 1596 | skb->pkt_type = PACKET_HOST; |
1596 | skb->encapsulation = 0; | 1597 | skb->encapsulation = 0; |
1597 | skb->dev = dst_vxlan->dev; | 1598 | skb->dev = dst_vxlan->dev; |
@@ -1897,12 +1898,12 @@ static int vxlan_init(struct net_device *dev) | |||
1897 | struct vxlan_sock *vs; | 1898 | struct vxlan_sock *vs; |
1898 | int i; | 1899 | int i; |
1899 | 1900 | ||
1900 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1901 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1901 | if (!dev->tstats) | 1902 | if (!dev->tstats) |
1902 | return -ENOMEM; | 1903 | return -ENOMEM; |
1903 | 1904 | ||
1904 | for_each_possible_cpu(i) { | 1905 | for_each_possible_cpu(i) { |
1905 | struct pcpu_tstats *vxlan_stats; | 1906 | struct pcpu_sw_netstats *vxlan_stats; |
1906 | vxlan_stats = per_cpu_ptr(dev->tstats, i); | 1907 | vxlan_stats = per_cpu_ptr(dev->tstats, i); |
1907 | u64_stats_init(&vxlan_stats->syncp); | 1908 | u64_stats_init(&vxlan_stats->syncp); |
1908 | } | 1909 | } |
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h index f4e56ecd0b1a..712710bc0580 100644 --- a/include/linux/if_tunnel.h +++ b/include/linux/if_tunnel.h | |||
@@ -13,13 +13,4 @@ | |||
13 | #define for_each_ip_tunnel_rcu(pos, start) \ | 13 | #define for_each_ip_tunnel_rcu(pos, start) \ |
14 | for (pos = rcu_dereference(start); pos; pos = rcu_dereference(pos->next)) | 14 | for (pos = rcu_dereference(start); pos; pos = rcu_dereference(pos->next)) |
15 | 15 | ||
16 | /* often modified stats are per cpu, other are shared (netdev->stats) */ | ||
17 | struct pcpu_tstats { | ||
18 | u64 rx_packets; | ||
19 | u64 rx_bytes; | ||
20 | u64 tx_packets; | ||
21 | u64 tx_bytes; | ||
22 | struct u64_stats_sync syncp; | ||
23 | }; | ||
24 | |||
25 | #endif /* _IF_TUNNEL_H_ */ | 16 | #endif /* _IF_TUNNEL_H_ */ |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index bec60c481966..51c0fe258163 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1409,7 +1409,7 @@ struct net_device { | |||
1409 | union { | 1409 | union { |
1410 | void *ml_priv; | 1410 | void *ml_priv; |
1411 | struct pcpu_lstats __percpu *lstats; /* loopback stats */ | 1411 | struct pcpu_lstats __percpu *lstats; /* loopback stats */ |
1412 | struct pcpu_tstats __percpu *tstats; /* tunnel stats */ | 1412 | struct pcpu_sw_netstats __percpu *tstats; |
1413 | struct pcpu_dstats __percpu *dstats; /* dummy stats */ | 1413 | struct pcpu_dstats __percpu *dstats; /* dummy stats */ |
1414 | struct pcpu_vstats __percpu *vstats; /* veth stats */ | 1414 | struct pcpu_vstats __percpu *vstats; /* veth stats */ |
1415 | }; | 1415 | }; |
@@ -1685,6 +1685,15 @@ struct packet_offload { | |||
1685 | struct list_head list; | 1685 | struct list_head list; |
1686 | }; | 1686 | }; |
1687 | 1687 | ||
1688 | /* often modified stats are per cpu, other are shared (netdev->stats) */ | ||
1689 | struct pcpu_sw_netstats { | ||
1690 | u64 rx_packets; | ||
1691 | u64 rx_bytes; | ||
1692 | u64 tx_packets; | ||
1693 | u64 tx_bytes; | ||
1694 | struct u64_stats_sync syncp; | ||
1695 | }; | ||
1696 | |||
1688 | #include <linux/notifier.h> | 1697 | #include <linux/notifier.h> |
1689 | 1698 | ||
1690 | /* netdevice notifier chain. Please remember to update the rtnetlink | 1699 | /* netdevice notifier chain. Please remember to update the rtnetlink |
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h index 6d1549c4893c..a5593dab6af7 100644 --- a/include/net/ip6_tunnel.h +++ b/include/net/ip6_tunnel.h | |||
@@ -79,7 +79,7 @@ static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
79 | err = ip6_local_out(skb); | 79 | err = ip6_local_out(skb); |
80 | 80 | ||
81 | if (net_xmit_eval(err) == 0) { | 81 | if (net_xmit_eval(err) == 0) { |
82 | struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); | 82 | struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); |
83 | u64_stats_update_begin(&tstats->syncp); | 83 | u64_stats_update_begin(&tstats->syncp); |
84 | tstats->tx_bytes += pkt_len; | 84 | tstats->tx_bytes += pkt_len; |
85 | tstats->tx_packets++; | 85 | tstats->tx_packets++; |
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 9e25b1bc31da..cd729becbb07 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h | |||
@@ -162,10 +162,10 @@ struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum, | |||
162 | 162 | ||
163 | static inline void iptunnel_xmit_stats(int err, | 163 | static inline void iptunnel_xmit_stats(int err, |
164 | struct net_device_stats *err_stats, | 164 | struct net_device_stats *err_stats, |
165 | struct pcpu_tstats __percpu *stats) | 165 | struct pcpu_sw_netstats __percpu *stats) |
166 | { | 166 | { |
167 | if (err > 0) { | 167 | if (err > 0) { |
168 | struct pcpu_tstats *tstats = this_cpu_ptr(stats); | 168 | struct pcpu_sw_netstats *tstats = this_cpu_ptr(stats); |
169 | 169 | ||
170 | u64_stats_update_begin(&tstats->syncp); | 170 | u64_stats_update_begin(&tstats->syncp); |
171 | tstats->tx_bytes += err; | 171 | tstats->tx_bytes += err; |
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index f00cfd2a0143..e4401a531afb 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -32,7 +32,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
32 | const unsigned char *dest = skb->data; | 32 | const unsigned char *dest = skb->data; |
33 | struct net_bridge_fdb_entry *dst; | 33 | struct net_bridge_fdb_entry *dst; |
34 | struct net_bridge_mdb_entry *mdst; | 34 | struct net_bridge_mdb_entry *mdst; |
35 | struct br_cpu_netstats *brstats = this_cpu_ptr(br->stats); | 35 | struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats); |
36 | u16 vid = 0; | 36 | u16 vid = 0; |
37 | 37 | ||
38 | rcu_read_lock(); | 38 | rcu_read_lock(); |
@@ -90,12 +90,12 @@ static int br_dev_init(struct net_device *dev) | |||
90 | struct net_bridge *br = netdev_priv(dev); | 90 | struct net_bridge *br = netdev_priv(dev); |
91 | int i; | 91 | int i; |
92 | 92 | ||
93 | br->stats = alloc_percpu(struct br_cpu_netstats); | 93 | br->stats = alloc_percpu(struct pcpu_sw_netstats); |
94 | if (!br->stats) | 94 | if (!br->stats) |
95 | return -ENOMEM; | 95 | return -ENOMEM; |
96 | 96 | ||
97 | for_each_possible_cpu(i) { | 97 | for_each_possible_cpu(i) { |
98 | struct br_cpu_netstats *br_dev_stats; | 98 | struct pcpu_sw_netstats *br_dev_stats; |
99 | br_dev_stats = per_cpu_ptr(br->stats, i); | 99 | br_dev_stats = per_cpu_ptr(br->stats, i); |
100 | u64_stats_init(&br_dev_stats->syncp); | 100 | u64_stats_init(&br_dev_stats->syncp); |
101 | } | 101 | } |
@@ -135,12 +135,12 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev, | |||
135 | struct rtnl_link_stats64 *stats) | 135 | struct rtnl_link_stats64 *stats) |
136 | { | 136 | { |
137 | struct net_bridge *br = netdev_priv(dev); | 137 | struct net_bridge *br = netdev_priv(dev); |
138 | struct br_cpu_netstats tmp, sum = { 0 }; | 138 | struct pcpu_sw_netstats tmp, sum = { 0 }; |
139 | unsigned int cpu; | 139 | unsigned int cpu; |
140 | 140 | ||
141 | for_each_possible_cpu(cpu) { | 141 | for_each_possible_cpu(cpu) { |
142 | unsigned int start; | 142 | unsigned int start; |
143 | const struct br_cpu_netstats *bstats | 143 | const struct pcpu_sw_netstats *bstats |
144 | = per_cpu_ptr(br->stats, cpu); | 144 | = per_cpu_ptr(br->stats, cpu); |
145 | do { | 145 | do { |
146 | start = u64_stats_fetch_begin_bh(&bstats->syncp); | 146 | start = u64_stats_fetch_begin_bh(&bstats->syncp); |
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 7e73c32e205d..bf8dc7d308d6 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c | |||
@@ -28,7 +28,7 @@ static int br_pass_frame_up(struct sk_buff *skb) | |||
28 | { | 28 | { |
29 | struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev; | 29 | struct net_device *indev, *brdev = BR_INPUT_SKB_CB(skb)->brdev; |
30 | struct net_bridge *br = netdev_priv(brdev); | 30 | struct net_bridge *br = netdev_priv(brdev); |
31 | struct br_cpu_netstats *brstats = this_cpu_ptr(br->stats); | 31 | struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats); |
32 | 32 | ||
33 | u64_stats_update_begin(&brstats->syncp); | 33 | u64_stats_update_begin(&brstats->syncp); |
34 | brstats->rx_packets++; | 34 | brstats->rx_packets++; |
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 2e77d923c8ee..3733f152351c 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -210,21 +210,13 @@ static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device * | |||
210 | rtnl_dereference(dev->rx_handler_data) : NULL; | 210 | rtnl_dereference(dev->rx_handler_data) : NULL; |
211 | } | 211 | } |
212 | 212 | ||
213 | struct br_cpu_netstats { | ||
214 | u64 rx_packets; | ||
215 | u64 rx_bytes; | ||
216 | u64 tx_packets; | ||
217 | u64 tx_bytes; | ||
218 | struct u64_stats_sync syncp; | ||
219 | }; | ||
220 | |||
221 | struct net_bridge | 213 | struct net_bridge |
222 | { | 214 | { |
223 | spinlock_t lock; | 215 | spinlock_t lock; |
224 | struct list_head port_list; | 216 | struct list_head port_list; |
225 | struct net_device *dev; | 217 | struct net_device *dev; |
226 | 218 | ||
227 | struct br_cpu_netstats __percpu *stats; | 219 | struct pcpu_sw_netstats __percpu *stats; |
228 | spinlock_t hash_lock; | 220 | spinlock_t hash_lock; |
229 | struct hlist_head hash[BR_HASH_SIZE]; | 221 | struct hlist_head hash[BR_HASH_SIZE]; |
230 | #ifdef CONFIG_BRIDGE_NETFILTER | 222 | #ifdef CONFIG_BRIDGE_NETFILTER |
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index e2c9cff26eb5..07a5ed374262 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c | |||
@@ -132,7 +132,8 @@ struct rtnl_link_stats64 *ip_tunnel_get_stats64(struct net_device *dev, | |||
132 | int i; | 132 | int i; |
133 | 133 | ||
134 | for_each_possible_cpu(i) { | 134 | for_each_possible_cpu(i) { |
135 | const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); | 135 | const struct pcpu_sw_netstats *tstats = |
136 | per_cpu_ptr(dev->tstats, i); | ||
136 | u64 rx_packets, rx_bytes, tx_packets, tx_bytes; | 137 | u64 rx_packets, rx_bytes, tx_packets, tx_bytes; |
137 | unsigned int start; | 138 | unsigned int start; |
138 | 139 | ||
@@ -460,7 +461,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net, | |||
460 | int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, | 461 | int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb, |
461 | const struct tnl_ptk_info *tpi, bool log_ecn_error) | 462 | const struct tnl_ptk_info *tpi, bool log_ecn_error) |
462 | { | 463 | { |
463 | struct pcpu_tstats *tstats; | 464 | struct pcpu_sw_netstats *tstats; |
464 | const struct iphdr *iph = ip_hdr(skb); | 465 | const struct iphdr *iph = ip_hdr(skb); |
465 | int err; | 466 | int err; |
466 | 467 | ||
@@ -1049,12 +1050,12 @@ int ip_tunnel_init(struct net_device *dev) | |||
1049 | int i, err; | 1050 | int i, err; |
1050 | 1051 | ||
1051 | dev->destructor = ip_tunnel_dev_free; | 1052 | dev->destructor = ip_tunnel_dev_free; |
1052 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1053 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1053 | if (!dev->tstats) | 1054 | if (!dev->tstats) |
1054 | return -ENOMEM; | 1055 | return -ENOMEM; |
1055 | 1056 | ||
1056 | for_each_possible_cpu(i) { | 1057 | for_each_possible_cpu(i) { |
1057 | struct pcpu_tstats *ipt_stats; | 1058 | struct pcpu_sw_netstats *ipt_stats; |
1058 | ipt_stats = per_cpu_ptr(dev->tstats, i); | 1059 | ipt_stats = per_cpu_ptr(dev->tstats, i); |
1059 | u64_stats_init(&ipt_stats->syncp); | 1060 | u64_stats_init(&ipt_stats->syncp); |
1060 | } | 1061 | } |
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c index 52b802a0cd8c..0783200ad8d2 100644 --- a/net/ipv4/ip_vti.c +++ b/net/ipv4/ip_vti.c | |||
@@ -60,7 +60,7 @@ static int vti_rcv(struct sk_buff *skb) | |||
60 | tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY, | 60 | tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY, |
61 | iph->saddr, iph->daddr, 0); | 61 | iph->saddr, iph->daddr, 0); |
62 | if (tunnel != NULL) { | 62 | if (tunnel != NULL) { |
63 | struct pcpu_tstats *tstats; | 63 | struct pcpu_sw_netstats *tstats; |
64 | u32 oldmark = skb->mark; | 64 | u32 oldmark = skb->mark; |
65 | int ret; | 65 | int ret; |
66 | 66 | ||
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index e27fb78c61f2..e7a440dd5c0d 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -498,7 +498,7 @@ static int ip6gre_rcv(struct sk_buff *skb) | |||
498 | &ipv6h->saddr, &ipv6h->daddr, key, | 498 | &ipv6h->saddr, &ipv6h->daddr, key, |
499 | gre_proto); | 499 | gre_proto); |
500 | if (tunnel) { | 500 | if (tunnel) { |
501 | struct pcpu_tstats *tstats; | 501 | struct pcpu_sw_netstats *tstats; |
502 | 502 | ||
503 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) | 503 | if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) |
504 | goto drop; | 504 | goto drop; |
@@ -1265,12 +1265,12 @@ static int ip6gre_tunnel_init(struct net_device *dev) | |||
1265 | if (ipv6_addr_any(&tunnel->parms.raddr)) | 1265 | if (ipv6_addr_any(&tunnel->parms.raddr)) |
1266 | dev->header_ops = &ip6gre_header_ops; | 1266 | dev->header_ops = &ip6gre_header_ops; |
1267 | 1267 | ||
1268 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1268 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1269 | if (!dev->tstats) | 1269 | if (!dev->tstats) |
1270 | return -ENOMEM; | 1270 | return -ENOMEM; |
1271 | 1271 | ||
1272 | for_each_possible_cpu(i) { | 1272 | for_each_possible_cpu(i) { |
1273 | struct pcpu_tstats *ip6gre_tunnel_stats; | 1273 | struct pcpu_sw_netstats *ip6gre_tunnel_stats; |
1274 | ip6gre_tunnel_stats = per_cpu_ptr(dev->tstats, i); | 1274 | ip6gre_tunnel_stats = per_cpu_ptr(dev->tstats, i); |
1275 | u64_stats_init(&ip6gre_tunnel_stats->syncp); | 1275 | u64_stats_init(&ip6gre_tunnel_stats->syncp); |
1276 | } | 1276 | } |
@@ -1466,12 +1466,12 @@ static int ip6gre_tap_init(struct net_device *dev) | |||
1466 | 1466 | ||
1467 | ip6gre_tnl_link_config(tunnel, 1); | 1467 | ip6gre_tnl_link_config(tunnel, 1); |
1468 | 1468 | ||
1469 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1469 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1470 | if (!dev->tstats) | 1470 | if (!dev->tstats) |
1471 | return -ENOMEM; | 1471 | return -ENOMEM; |
1472 | 1472 | ||
1473 | for_each_possible_cpu(i) { | 1473 | for_each_possible_cpu(i) { |
1474 | struct pcpu_tstats *ip6gre_tap_stats; | 1474 | struct pcpu_sw_netstats *ip6gre_tap_stats; |
1475 | ip6gre_tap_stats = per_cpu_ptr(dev->tstats, i); | 1475 | ip6gre_tap_stats = per_cpu_ptr(dev->tstats, i); |
1476 | u64_stats_init(&ip6gre_tap_stats->syncp); | 1476 | u64_stats_init(&ip6gre_tap_stats->syncp); |
1477 | } | 1477 | } |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 8d7c9867a445..02894216a46d 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/if.h> | 29 | #include <linux/if.h> |
30 | #include <linux/in.h> | 30 | #include <linux/in.h> |
31 | #include <linux/ip.h> | 31 | #include <linux/ip.h> |
32 | #include <linux/if_tunnel.h> | ||
33 | #include <linux/net.h> | 32 | #include <linux/net.h> |
34 | #include <linux/in6.h> | 33 | #include <linux/in6.h> |
35 | #include <linux/netdevice.h> | 34 | #include <linux/netdevice.h> |
@@ -102,11 +101,12 @@ struct ip6_tnl_net { | |||
102 | 101 | ||
103 | static struct net_device_stats *ip6_get_stats(struct net_device *dev) | 102 | static struct net_device_stats *ip6_get_stats(struct net_device *dev) |
104 | { | 103 | { |
105 | struct pcpu_tstats sum = { 0 }; | 104 | struct pcpu_sw_netstats sum = { 0 }; |
106 | int i; | 105 | int i; |
107 | 106 | ||
108 | for_each_possible_cpu(i) { | 107 | for_each_possible_cpu(i) { |
109 | const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); | 108 | const struct pcpu_sw_netstats *tstats = |
109 | per_cpu_ptr(dev->tstats, i); | ||
110 | 110 | ||
111 | sum.rx_packets += tstats->rx_packets; | 111 | sum.rx_packets += tstats->rx_packets; |
112 | sum.rx_bytes += tstats->rx_bytes; | 112 | sum.rx_bytes += tstats->rx_bytes; |
@@ -784,7 +784,7 @@ static int ip6_tnl_rcv(struct sk_buff *skb, __u16 protocol, | |||
784 | 784 | ||
785 | if ((t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, | 785 | if ((t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, |
786 | &ipv6h->daddr)) != NULL) { | 786 | &ipv6h->daddr)) != NULL) { |
787 | struct pcpu_tstats *tstats; | 787 | struct pcpu_sw_netstats *tstats; |
788 | 788 | ||
789 | if (t->parms.proto != ipproto && t->parms.proto != 0) { | 789 | if (t->parms.proto != ipproto && t->parms.proto != 0) { |
790 | rcu_read_unlock(); | 790 | rcu_read_unlock(); |
@@ -1497,12 +1497,12 @@ ip6_tnl_dev_init_gen(struct net_device *dev) | |||
1497 | 1497 | ||
1498 | t->dev = dev; | 1498 | t->dev = dev; |
1499 | t->net = dev_net(dev); | 1499 | t->net = dev_net(dev); |
1500 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1500 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1501 | if (!dev->tstats) | 1501 | if (!dev->tstats) |
1502 | return -ENOMEM; | 1502 | return -ENOMEM; |
1503 | 1503 | ||
1504 | for_each_possible_cpu(i) { | 1504 | for_each_possible_cpu(i) { |
1505 | struct pcpu_tstats *ip6_tnl_stats; | 1505 | struct pcpu_sw_netstats *ip6_tnl_stats; |
1506 | ip6_tnl_stats = per_cpu_ptr(dev->tstats, i); | 1506 | ip6_tnl_stats = per_cpu_ptr(dev->tstats, i); |
1507 | u64_stats_init(&ip6_tnl_stats->syncp); | 1507 | u64_stats_init(&ip6_tnl_stats->syncp); |
1508 | } | 1508 | } |
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c index ed94ba61dda0..da1d9e4d62ca 100644 --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/if.h> | 24 | #include <linux/if.h> |
25 | #include <linux/in.h> | 25 | #include <linux/in.h> |
26 | #include <linux/ip.h> | 26 | #include <linux/ip.h> |
27 | #include <linux/if_tunnel.h> | ||
28 | #include <linux/net.h> | 27 | #include <linux/net.h> |
29 | #include <linux/in6.h> | 28 | #include <linux/in6.h> |
30 | #include <linux/netdevice.h> | 29 | #include <linux/netdevice.h> |
@@ -77,11 +76,12 @@ struct vti6_net { | |||
77 | 76 | ||
78 | static struct net_device_stats *vti6_get_stats(struct net_device *dev) | 77 | static struct net_device_stats *vti6_get_stats(struct net_device *dev) |
79 | { | 78 | { |
80 | struct pcpu_tstats sum = { 0 }; | 79 | struct pcpu_sw_netstats sum = { 0 }; |
81 | int i; | 80 | int i; |
82 | 81 | ||
83 | for_each_possible_cpu(i) { | 82 | for_each_possible_cpu(i) { |
84 | const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); | 83 | const struct pcpu_sw_netstats *tstats = |
84 | per_cpu_ptr(dev->tstats, i); | ||
85 | 85 | ||
86 | sum.rx_packets += tstats->rx_packets; | 86 | sum.rx_packets += tstats->rx_packets; |
87 | sum.rx_bytes += tstats->rx_bytes; | 87 | sum.rx_bytes += tstats->rx_bytes; |
@@ -312,7 +312,7 @@ static int vti6_rcv(struct sk_buff *skb) | |||
312 | 312 | ||
313 | if ((t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, | 313 | if ((t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, |
314 | &ipv6h->daddr)) != NULL) { | 314 | &ipv6h->daddr)) != NULL) { |
315 | struct pcpu_tstats *tstats; | 315 | struct pcpu_sw_netstats *tstats; |
316 | 316 | ||
317 | if (t->parms.proto != IPPROTO_IPV6 && t->parms.proto != 0) { | 317 | if (t->parms.proto != IPPROTO_IPV6 && t->parms.proto != 0) { |
318 | rcu_read_unlock(); | 318 | rcu_read_unlock(); |
@@ -753,7 +753,7 @@ static inline int vti6_dev_init_gen(struct net_device *dev) | |||
753 | 753 | ||
754 | t->dev = dev; | 754 | t->dev = dev; |
755 | t->net = dev_net(dev); | 755 | t->net = dev_net(dev); |
756 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 756 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
757 | if (!dev->tstats) | 757 | if (!dev->tstats) |
758 | return -ENOMEM; | 758 | return -ENOMEM; |
759 | return 0; | 759 | return 0; |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 366fbba3359a..9937b2616713 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -671,7 +671,7 @@ static int ipip6_rcv(struct sk_buff *skb) | |||
671 | tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, | 671 | tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, |
672 | iph->saddr, iph->daddr); | 672 | iph->saddr, iph->daddr); |
673 | if (tunnel != NULL) { | 673 | if (tunnel != NULL) { |
674 | struct pcpu_tstats *tstats; | 674 | struct pcpu_sw_netstats *tstats; |
675 | 675 | ||
676 | if (tunnel->parms.iph.protocol != IPPROTO_IPV6 && | 676 | if (tunnel->parms.iph.protocol != IPPROTO_IPV6 && |
677 | tunnel->parms.iph.protocol != 0) | 677 | tunnel->parms.iph.protocol != 0) |
@@ -1361,12 +1361,12 @@ static int ipip6_tunnel_init(struct net_device *dev) | |||
1361 | memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); | 1361 | memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4); |
1362 | 1362 | ||
1363 | ipip6_tunnel_bind_dev(dev); | 1363 | ipip6_tunnel_bind_dev(dev); |
1364 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1364 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1365 | if (!dev->tstats) | 1365 | if (!dev->tstats) |
1366 | return -ENOMEM; | 1366 | return -ENOMEM; |
1367 | 1367 | ||
1368 | for_each_possible_cpu(i) { | 1368 | for_each_possible_cpu(i) { |
1369 | struct pcpu_tstats *ipip6_tunnel_stats; | 1369 | struct pcpu_sw_netstats *ipip6_tunnel_stats; |
1370 | ipip6_tunnel_stats = per_cpu_ptr(dev->tstats, i); | 1370 | ipip6_tunnel_stats = per_cpu_ptr(dev->tstats, i); |
1371 | u64_stats_init(&ipip6_tunnel_stats->syncp); | 1371 | u64_stats_init(&ipip6_tunnel_stats->syncp); |
1372 | } | 1372 | } |
@@ -1391,12 +1391,12 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev) | |||
1391 | iph->ihl = 5; | 1391 | iph->ihl = 5; |
1392 | iph->ttl = 64; | 1392 | iph->ttl = 64; |
1393 | 1393 | ||
1394 | dev->tstats = alloc_percpu(struct pcpu_tstats); | 1394 | dev->tstats = alloc_percpu(struct pcpu_sw_netstats); |
1395 | if (!dev->tstats) | 1395 | if (!dev->tstats) |
1396 | return -ENOMEM; | 1396 | return -ENOMEM; |
1397 | 1397 | ||
1398 | for_each_possible_cpu(i) { | 1398 | for_each_possible_cpu(i) { |
1399 | struct pcpu_tstats *ipip6_fb_stats; | 1399 | struct pcpu_sw_netstats *ipip6_fb_stats; |
1400 | ipip6_fb_stats = per_cpu_ptr(dev->tstats, i); | 1400 | ipip6_fb_stats = per_cpu_ptr(dev->tstats, i); |
1401 | u64_stats_init(&ipip6_fb_stats->syncp); | 1401 | u64_stats_init(&ipip6_fb_stats->syncp); |
1402 | } | 1402 | } |
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index d830a95f03a4..f5275dd29cd9 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c | |||
@@ -136,14 +136,14 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, | |||
136 | vport->ops = ops; | 136 | vport->ops = ops; |
137 | INIT_HLIST_NODE(&vport->dp_hash_node); | 137 | INIT_HLIST_NODE(&vport->dp_hash_node); |
138 | 138 | ||
139 | vport->percpu_stats = alloc_percpu(struct pcpu_tstats); | 139 | vport->percpu_stats = alloc_percpu(struct pcpu_sw_netstats); |
140 | if (!vport->percpu_stats) { | 140 | if (!vport->percpu_stats) { |
141 | kfree(vport); | 141 | kfree(vport); |
142 | return ERR_PTR(-ENOMEM); | 142 | return ERR_PTR(-ENOMEM); |
143 | } | 143 | } |
144 | 144 | ||
145 | for_each_possible_cpu(i) { | 145 | for_each_possible_cpu(i) { |
146 | struct pcpu_tstats *vport_stats; | 146 | struct pcpu_sw_netstats *vport_stats; |
147 | vport_stats = per_cpu_ptr(vport->percpu_stats, i); | 147 | vport_stats = per_cpu_ptr(vport->percpu_stats, i); |
148 | u64_stats_init(&vport_stats->syncp); | 148 | u64_stats_init(&vport_stats->syncp); |
149 | } | 149 | } |
@@ -275,8 +275,8 @@ void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) | |||
275 | spin_unlock_bh(&vport->stats_lock); | 275 | spin_unlock_bh(&vport->stats_lock); |
276 | 276 | ||
277 | for_each_possible_cpu(i) { | 277 | for_each_possible_cpu(i) { |
278 | const struct pcpu_tstats *percpu_stats; | 278 | const struct pcpu_sw_netstats *percpu_stats; |
279 | struct pcpu_tstats local_stats; | 279 | struct pcpu_sw_netstats local_stats; |
280 | unsigned int start; | 280 | unsigned int start; |
281 | 281 | ||
282 | percpu_stats = per_cpu_ptr(vport->percpu_stats, i); | 282 | percpu_stats = per_cpu_ptr(vport->percpu_stats, i); |
@@ -344,7 +344,7 @@ int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb) | |||
344 | void ovs_vport_receive(struct vport *vport, struct sk_buff *skb, | 344 | void ovs_vport_receive(struct vport *vport, struct sk_buff *skb, |
345 | struct ovs_key_ipv4_tunnel *tun_key) | 345 | struct ovs_key_ipv4_tunnel *tun_key) |
346 | { | 346 | { |
347 | struct pcpu_tstats *stats; | 347 | struct pcpu_sw_netstats *stats; |
348 | 348 | ||
349 | stats = this_cpu_ptr(vport->percpu_stats); | 349 | stats = this_cpu_ptr(vport->percpu_stats); |
350 | u64_stats_update_begin(&stats->syncp); | 350 | u64_stats_update_begin(&stats->syncp); |
@@ -370,7 +370,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb) | |||
370 | int sent = vport->ops->send(vport, skb); | 370 | int sent = vport->ops->send(vport, skb); |
371 | 371 | ||
372 | if (likely(sent > 0)) { | 372 | if (likely(sent > 0)) { |
373 | struct pcpu_tstats *stats; | 373 | struct pcpu_sw_netstats *stats; |
374 | 374 | ||
375 | stats = this_cpu_ptr(vport->percpu_stats); | 375 | stats = this_cpu_ptr(vport->percpu_stats); |
376 | 376 | ||
diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h index 1a9fbcec6e1b..bc97ef7fa2af 100644 --- a/net/openvswitch/vport.h +++ b/net/openvswitch/vport.h | |||
@@ -87,7 +87,7 @@ struct vport { | |||
87 | struct hlist_node dp_hash_node; | 87 | struct hlist_node dp_hash_node; |
88 | const struct vport_ops *ops; | 88 | const struct vport_ops *ops; |
89 | 89 | ||
90 | struct pcpu_tstats __percpu *percpu_stats; | 90 | struct pcpu_sw_netstats __percpu *percpu_stats; |
91 | 91 | ||
92 | spinlock_t stats_lock; | 92 | spinlock_t stats_lock; |
93 | struct vport_err_stats err_stats; | 93 | struct vport_err_stats err_stats; |