Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f84985f authored by Li RongQing's avatar Li RongQing Committed by David S. Miller
Browse files

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: default avatarLi RongQing <roy.qing.li@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 653864d9
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -1081,7 +1081,7 @@ static void vxlan_rcv(struct vxlan_sock *vs,
	struct iphdr *oip = NULL;
	struct ipv6hdr *oip6 = NULL;
	struct vxlan_dev *vxlan;
	struct pcpu_tstats *stats;
	struct pcpu_sw_netstats *stats;
	union vxlan_addr saddr;
	__u32 vni;
	int err = 0;
@@ -1587,11 +1587,12 @@ EXPORT_SYMBOL_GPL(vxlan_xmit_skb);
static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
			       struct vxlan_dev *dst_vxlan)
{
	struct pcpu_tstats *tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
	struct pcpu_tstats *rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats);
	struct pcpu_sw_netstats *tx_stats, *rx_stats;
	union vxlan_addr loopback;
	union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;

	tx_stats = this_cpu_ptr(src_vxlan->dev->tstats);
	rx_stats = this_cpu_ptr(dst_vxlan->dev->tstats);
	skb->pkt_type = PACKET_HOST;
	skb->encapsulation = 0;
	skb->dev = dst_vxlan->dev;
@@ -1897,12 +1898,12 @@ static int vxlan_init(struct net_device *dev)
	struct vxlan_sock *vs;
	int i;

	dev->tstats = alloc_percpu(struct pcpu_tstats);
	dev->tstats = alloc_percpu(struct pcpu_sw_netstats);
	if (!dev->tstats)
		return -ENOMEM;

	for_each_possible_cpu(i) {
		struct pcpu_tstats *vxlan_stats;
		struct pcpu_sw_netstats *vxlan_stats;
		vxlan_stats = per_cpu_ptr(dev->tstats, i);
		u64_stats_init(&vxlan_stats->syncp);
	}
+0 −9
Original line number Diff line number Diff line
@@ -13,13 +13,4 @@
#define for_each_ip_tunnel_rcu(pos, start) \
	for (pos = rcu_dereference(start); pos; pos = rcu_dereference(pos->next))

/* often modified stats are per cpu, other are shared (netdev->stats) */
struct pcpu_tstats {
	u64	rx_packets;
	u64	rx_bytes;
	u64	tx_packets;
	u64	tx_bytes;
	struct u64_stats_sync	syncp;
};

#endif /* _IF_TUNNEL_H_ */
+10 −1
Original line number Diff line number Diff line
@@ -1409,7 +1409,7 @@ struct net_device {
	union {
		void				*ml_priv;
		struct pcpu_lstats __percpu	*lstats; /* loopback stats */
		struct pcpu_tstats __percpu	*tstats; /* tunnel stats */
		struct pcpu_sw_netstats __percpu	*tstats;
		struct pcpu_dstats __percpu	*dstats; /* dummy stats */
		struct pcpu_vstats __percpu	*vstats; /* veth stats */
	};
@@ -1685,6 +1685,15 @@ struct packet_offload {
	struct list_head	 list;
};

/* often modified stats are per cpu, other are shared (netdev->stats) */
struct pcpu_sw_netstats {
	u64     rx_packets;
	u64     rx_bytes;
	u64     tx_packets;
	u64     tx_bytes;
	struct u64_stats_sync   syncp;
};

#include <linux/notifier.h>

/* netdevice notifier chain. Please remember to update the rtnetlink
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
	err = ip6_local_out(skb);

	if (net_xmit_eval(err) == 0) {
		struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats);
		struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
		u64_stats_update_begin(&tstats->syncp);
		tstats->tx_bytes += pkt_len;
		tstats->tx_packets++;
+2 −2
Original line number Diff line number Diff line
@@ -162,10 +162,10 @@ struct sk_buff *iptunnel_handle_offloads(struct sk_buff *skb, bool gre_csum,

static inline void iptunnel_xmit_stats(int err,
				       struct net_device_stats *err_stats,
				       struct pcpu_tstats __percpu *stats)
				       struct pcpu_sw_netstats __percpu *stats)
{
	if (err > 0) {
		struct pcpu_tstats *tstats = this_cpu_ptr(stats);
		struct pcpu_sw_netstats *tstats = this_cpu_ptr(stats);

		u64_stats_update_begin(&tstats->syncp);
		tstats->tx_bytes += err;
Loading