net: move definition of pcpu_lstats to header file
authorLi RongQing <lirongqing@baidu.com>
Fri, 14 Sep 2018 08:00:51 +0000 (16:00 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Sep 2018 15:32:23 +0000 (08:32 -0700)
pcpu_lstats is defined in several files, so unify them as one
and move to header file

Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/loopback.c
drivers/net/nlmon.c
drivers/net/vsockmon.c
include/linux/netdevice.h

index 30612497643c08caa8a3bf352b13f784f729f725..a7207fa7e451311aed13cdeb100e0ea7922931bf 100644 (file)
 #include <net/net_namespace.h>
 #include <linux/u64_stats_sync.h>
 
-struct pcpu_lstats {
-       u64                     packets;
-       u64                     bytes;
-       struct u64_stats_sync   syncp;
-};
-
 /* The higher levels take care of making this non-reentrant (it's
  * called with bh's disabled).
  */
index 4b22955de1918f13923a4ab4ba584d8de7981308..dd0db7534cb323d949963a9fc590a3e8bf2fd91c 100644 (file)
@@ -6,12 +6,6 @@
 #include <linux/if_arp.h>
 #include <net/rtnetlink.h>
 
-struct pcpu_lstats {
-       u64 packets;
-       u64 bytes;
-       struct u64_stats_sync syncp;
-};
-
 static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        int len = skb->len;
index c28bdce14fd5e32b287419227d7d33bf7835c409..7bad5c95551fdf998ec4f6b543edda405e65c2f6 100644 (file)
 #define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
                     sizeof(struct af_vsockmon_hdr))
 
-struct pcpu_lstats {
-       u64 rx_packets;
-       u64 rx_bytes;
-       struct u64_stats_sync syncp;
-};
-
 static int vsockmon_dev_init(struct net_device *dev)
 {
        dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
@@ -56,8 +50,8 @@ static netdev_tx_t vsockmon_xmit(struct sk_buff *skb, struct net_device *dev)
        struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats);
 
        u64_stats_update_begin(&stats->syncp);
-       stats->rx_bytes += len;
-       stats->rx_packets++;
+       stats->bytes += len;
+       stats->packets++;
        u64_stats_update_end(&stats->syncp);
 
        dev_kfree_skb(skb);
@@ -80,8 +74,8 @@ vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 
                do {
                        start = u64_stats_fetch_begin_irq(&vstats->syncp);
-                       tbytes = vstats->rx_bytes;
-                       tpackets = vstats->rx_packets;
+                       tbytes = vstats->bytes;
+                       tpackets = vstats->packets;
                } while (u64_stats_fetch_retry_irq(&vstats->syncp, start));
 
                packets += tpackets;
index e2b3bd750c98d8182ce88af44b88d96b4c36ebdb..baed5d5088c58c0102e08eb098769403e7a73296 100644 (file)
@@ -2382,6 +2382,12 @@ struct pcpu_sw_netstats {
        struct u64_stats_sync   syncp;
 };
 
+struct pcpu_lstats {
+       u64 packets;
+       u64 bytes;
+       struct u64_stats_sync syncp;
+};
+
 #define __netdev_alloc_pcpu_stats(type, gfp)                           \
 ({                                                                     \
        typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\