From 8a24a1c2c3cfbf93d661cfb50468b4a9a5a74254 Mon Sep 17 00:00:00 2001 From: Murat Sezgin Date: Tue, 27 Jan 2015 18:06:30 +0000 Subject: [PATCH 091/500] vlan: Add vlan stats update function Change-Id: Ib1165b37f29d48e5dbcee2c709b2f873dfb3e34d Signed-off-by: Murat Sezgin --- include/linux/if_vlan.h | 9 +++++++++ net/8021q/vlan_core.c | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -143,6 +143,9 @@ extern struct net_device *__vlan_find_de extern int vlan_for_each(struct net_device *dev, int (*action)(struct net_device *dev, int vid, void *arg), void *arg); +extern void __vlan_dev_update_accel_stats(struct net_device *dev, + struct rtnl_link_stats64 *stats); + extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); extern struct net_device *vlan_dev_next_dev(const struct net_device *dev); extern u16 vlan_dev_vlan_id(const struct net_device *dev); @@ -237,6 +240,12 @@ extern void vlan_vids_del_by_dev(struct extern bool vlan_uses_dev(const struct net_device *dev); #else +static inline void __vlan_dev_update_accel_stats(struct net_device *dev, + struct rtnl_link_stats64 *stats) +{ + +} + static inline struct net_device * __vlan_find_dev_deep_rcu(struct net_device *real_dev, __be16 vlan_proto, u16 vlan_id) --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -72,6 +72,26 @@ bool vlan_do_receive(struct sk_buff **sk return true; } +/* Update the VLAN device with statistics from network offload engines */ +void __vlan_dev_update_accel_stats(struct net_device *dev, + struct rtnl_link_stats64 *nlstats) +{ + struct vlan_pcpu_stats *stats; + + if (!is_vlan_dev(dev)) + return; + + stats = this_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats); + + u64_stats_update_begin(&stats->syncp); + u64_stats_add(&stats->rx_packets, nlstats->rx_packets); + u64_stats_add(&stats->rx_bytes, nlstats->rx_bytes); + u64_stats_add(&stats->tx_packets, nlstats->tx_packets); + u64_stats_add(&stats->tx_bytes, nlstats->tx_bytes); + u64_stats_update_end(&stats->syncp); +} +EXPORT_SYMBOL(__vlan_dev_update_accel_stats); + /* Must be invoked with rcu_read_lock. */ struct net_device *__vlan_find_dev_deep_rcu(struct net_device *dev, __be16 vlan_proto, u16 vlan_id)