Skip to content

Commit 52bb667

Browse files
lrq-maxdavem330
authored andcommitted
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>
1 parent ee4fccb commit 52bb667

4 files changed

Lines changed: 10 additions & 22 deletions

File tree

‎drivers/net/loopback.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@
5959
#include <net/net_namespace.h>
6060
#include <linux/u64_stats_sync.h>
6161

62-
struct pcpu_lstats {
63-
u64 packets;
64-
u64 bytes;
65-
struct u64_stats_sync syncp;
66-
};
67-
6862
/* The higher levels take care of making this non-reentrant (it's
6963
* called with bh's disabled).
7064
*/

‎drivers/net/nlmon.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
#include <linux/if_arp.h>
77
#include <net/rtnetlink.h>
88

9-
struct pcpu_lstats {
10-
u64 packets;
11-
u64 bytes;
12-
struct u64_stats_sync syncp;
13-
};
14-
159
static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev)
1610
{
1711
int len = skb->len;

‎drivers/net/vsockmon.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
#define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
1212
sizeof(struct af_vsockmon_hdr))
1313

14-
struct pcpu_lstats {
15-
u64 rx_packets;
16-
u64 rx_bytes;
17-
struct u64_stats_sync syncp;
18-
};
19-
2014
static int vsockmon_dev_init(struct net_device *dev)
2115
{
2216
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)
5650
struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats);
5751

5852
u64_stats_update_begin(&stats->syncp);
59-
stats->rx_bytes += len;
60-
stats->rx_packets++;
53+
stats->bytes += len;
54+
stats->packets++;
6155
u64_stats_update_end(&stats->syncp);
6256

6357
dev_kfree_skb(skb);
@@ -80,8 +74,8 @@ vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
8074

8175
do {
8276
start = u64_stats_fetch_begin_irq(&vstats->syncp);
83-
tbytes = vstats->rx_bytes;
84-
tpackets = vstats->rx_packets;
77+
tbytes = vstats->bytes;
78+
tpackets = vstats->packets;
8579
} while (u64_stats_fetch_retry_irq(&vstats->syncp, start));
8680

8781
packets += tpackets;

‎include/linux/netdevice.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,12 @@ struct pcpu_sw_netstats {
23822382
struct u64_stats_sync syncp;
23832383
};
23842384

2385+
struct pcpu_lstats {
2386+
u64 packets;
2387+
u64 bytes;
2388+
struct u64_stats_sync syncp;
2389+
};
2390+
23852391
#define __netdev_alloc_pcpu_stats(type, gfp) \
23862392
({ \
23872393
typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\

0 commit comments

Comments
 (0)