aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2018-09-14 04:00:51 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-14 11:32:23 -0400
commit52bb6677d530d37055092d86b4eab69dce6c166a (patch)
tree9701036db4955aa531c835ca07e186aaf3662601 /drivers
parentee4fccbee7d397c4d937e20d8c76212ffc23a7e3 (diff)
net: move definition of pcpu_lstats to header file
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/loopback.c6
-rw-r--r--drivers/net/nlmon.c6
-rw-r--r--drivers/net/vsockmon.c14
3 files changed, 4 insertions, 22 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 30612497643c..a7207fa7e451 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -59,12 +59,6 @@
59#include <net/net_namespace.h> 59#include <net/net_namespace.h>
60#include <linux/u64_stats_sync.h> 60#include <linux/u64_stats_sync.h>
61 61
62struct pcpu_lstats {
63 u64 packets;
64 u64 bytes;
65 struct u64_stats_sync syncp;
66};
67
68/* The higher levels take care of making this non-reentrant (it's 62/* The higher levels take care of making this non-reentrant (it's
69 * called with bh's disabled). 63 * called with bh's disabled).
70 */ 64 */
diff --git a/drivers/net/nlmon.c b/drivers/net/nlmon.c
index 4b22955de191..dd0db7534cb3 100644
--- a/drivers/net/nlmon.c
+++ b/drivers/net/nlmon.c
@@ -6,12 +6,6 @@
6#include <linux/if_arp.h> 6#include <linux/if_arp.h>
7#include <net/rtnetlink.h> 7#include <net/rtnetlink.h>
8 8
9struct pcpu_lstats {
10 u64 packets;
11 u64 bytes;
12 struct u64_stats_sync syncp;
13};
14
15static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev) 9static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev)
16{ 10{
17 int len = skb->len; 11 int len = skb->len;
diff --git a/drivers/net/vsockmon.c b/drivers/net/vsockmon.c
index c28bdce14fd5..7bad5c95551f 100644
--- a/drivers/net/vsockmon.c
+++ b/drivers/net/vsockmon.c
@@ -11,12 +11,6 @@
11#define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \ 11#define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
12 sizeof(struct af_vsockmon_hdr)) 12 sizeof(struct af_vsockmon_hdr))
13 13
14struct pcpu_lstats {
15 u64 rx_packets;
16 u64 rx_bytes;
17 struct u64_stats_sync syncp;
18};
19
20static int vsockmon_dev_init(struct net_device *dev) 14static int vsockmon_dev_init(struct net_device *dev)
21{ 15{
22 dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats); 16 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)
56 struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats); 50 struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats);
57 51
58 u64_stats_update_begin(&stats->syncp); 52 u64_stats_update_begin(&stats->syncp);
59 stats->rx_bytes += len; 53 stats->bytes += len;
60 stats->rx_packets++; 54 stats->packets++;
61 u64_stats_update_end(&stats->syncp); 55 u64_stats_update_end(&stats->syncp);
62 56
63 dev_kfree_skb(skb); 57 dev_kfree_skb(skb);
@@ -80,8 +74,8 @@ vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
80 74
81 do { 75 do {
82 start = u64_stats_fetch_begin_irq(&vstats->syncp); 76 start = u64_stats_fetch_begin_irq(&vstats->syncp);
83 tbytes = vstats->rx_bytes; 77 tbytes = vstats->bytes;
84 tpackets = vstats->rx_packets; 78 tpackets = vstats->packets;
85 } while (u64_stats_fetch_retry_irq(&vstats->syncp, start)); 79 } while (u64_stats_fetch_retry_irq(&vstats->syncp, start));
86 80
87 packets += tpackets; 81 packets += tpackets;