diff options
| author | Li RongQing <lirongqing@baidu.com> | 2018-09-14 04:00:51 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2018-09-14 11:32:23 -0400 |
| commit | 52bb6677d530d37055092d86b4eab69dce6c166a (patch) | |
| tree | 9701036db4955aa531c835ca07e186aaf3662601 /drivers/net/vsockmon.c | |
| parent | ee4fccbee7d397c4d937e20d8c76212ffc23a7e3 (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/net/vsockmon.c')
| -rw-r--r-- | drivers/net/vsockmon.c | 14 |
1 files changed, 4 insertions, 10 deletions
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 | ||
| 14 | struct pcpu_lstats { | ||
| 15 | u64 rx_packets; | ||
| 16 | u64 rx_bytes; | ||
| 17 | struct u64_stats_sync syncp; | ||
| 18 | }; | ||
| 19 | |||
| 20 | static int vsockmon_dev_init(struct net_device *dev) | 14 | static 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; |
