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>
This commit is contained in:
committed by
David S. Miller
parent
ee4fccbee7
commit
52bb6677d5
@@ -59,12 +59,6 @@
|
|||||||
#include <net/net_namespace.h>
|
#include <net/net_namespace.h>
|
||||||
#include <linux/u64_stats_sync.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
|
/* The higher levels take care of making this non-reentrant (it's
|
||||||
* called with bh's disabled).
|
* called with bh's disabled).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,12 +6,6 @@
|
|||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
#include <net/rtnetlink.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)
|
static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
{
|
{
|
||||||
int len = skb->len;
|
int len = skb->len;
|
||||||
|
|||||||
+4
-10
@@ -11,12 +11,6 @@
|
|||||||
#define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
|
#define DEFAULT_MTU (VIRTIO_VSOCK_MAX_PKT_BUF_SIZE + \
|
||||||
sizeof(struct af_vsockmon_hdr))
|
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)
|
static int vsockmon_dev_init(struct net_device *dev)
|
||||||
{
|
{
|
||||||
dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
|
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);
|
struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats);
|
||||||
|
|
||||||
u64_stats_update_begin(&stats->syncp);
|
u64_stats_update_begin(&stats->syncp);
|
||||||
stats->rx_bytes += len;
|
stats->bytes += len;
|
||||||
stats->rx_packets++;
|
stats->packets++;
|
||||||
u64_stats_update_end(&stats->syncp);
|
u64_stats_update_end(&stats->syncp);
|
||||||
|
|
||||||
dev_kfree_skb(skb);
|
dev_kfree_skb(skb);
|
||||||
@@ -80,8 +74,8 @@ vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
start = u64_stats_fetch_begin_irq(&vstats->syncp);
|
start = u64_stats_fetch_begin_irq(&vstats->syncp);
|
||||||
tbytes = vstats->rx_bytes;
|
tbytes = vstats->bytes;
|
||||||
tpackets = vstats->rx_packets;
|
tpackets = vstats->packets;
|
||||||
} while (u64_stats_fetch_retry_irq(&vstats->syncp, start));
|
} while (u64_stats_fetch_retry_irq(&vstats->syncp, start));
|
||||||
|
|
||||||
packets += tpackets;
|
packets += tpackets;
|
||||||
|
|||||||
@@ -2382,6 +2382,12 @@ struct pcpu_sw_netstats {
|
|||||||
struct u64_stats_sync syncp;
|
struct u64_stats_sync syncp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct pcpu_lstats {
|
||||||
|
u64 packets;
|
||||||
|
u64 bytes;
|
||||||
|
struct u64_stats_sync syncp;
|
||||||
|
};
|
||||||
|
|
||||||
#define __netdev_alloc_pcpu_stats(type, gfp) \
|
#define __netdev_alloc_pcpu_stats(type, gfp) \
|
||||||
({ \
|
({ \
|
||||||
typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\
|
typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\
|
||||||
|
|||||||
Reference in New Issue
Block a user