--- zzzz-none-000/linux-4.4.271/drivers/net/macvlan.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/drivers/net/macvlan.c 2023-04-19 10:22:29.000000000 +0000 @@ -841,6 +841,32 @@ macvlan_port_destroy(port->dev); } +/* Update macvlan statistics processed by offload engines */ +static void macvlan_dev_update_stats(struct net_device *dev, + struct rtnl_link_stats64 *offl_stats, + bool update_mcast_rx_stats) +{ + struct vlan_pcpu_stats *stats; + struct macvlan_dev *macvlan; + + /* Is this a macvlan? */ + if (!netif_is_macvlan(dev)) + return; + + macvlan = netdev_priv(dev); + stats = this_cpu_ptr(macvlan->pcpu_stats); + u64_stats_update_begin(&stats->syncp); + stats->rx_packets += offl_stats->rx_packets; + stats->rx_bytes += offl_stats->rx_bytes; + stats->tx_packets += offl_stats->tx_packets; + stats->tx_bytes += offl_stats->tx_bytes; + /* Update multicast statistics */ + if (unlikely(update_mcast_rx_stats)) { + stats->rx_multicast += offl_stats->rx_packets; + } + u64_stats_update_end(&stats->syncp); +} + static struct rtnl_link_stats64 *macvlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { @@ -1310,6 +1336,7 @@ vlan->port = port; vlan->set_features = MACVLAN_FEATURES; vlan->nest_level = dev_get_nest_level(lowerdev, netif_is_macvlan) + 1; + vlan->offload_stats_update = macvlan_dev_update_stats; vlan->mode = MACVLAN_MODE_VEPA; if (data && data[IFLA_MACVLAN_MODE])