diff options
author | Jakub Kicinski <kuba@kernel.org> | 2020-10-13 17:34:26 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-10-13 17:37:37 -0700 |
commit | a003ec1f47bc7c34e1dc96653b903c48f63adcdb (patch) | |
tree | 995db2093a9e84457f0ac54e6a048294ab41abec /drivers/net/macsec.c | |
parent | 3618ad2a7c0e78e4258386394d5d5f92a3dbccf8 (diff) | |
parent | 5fc3594d36d16794facc533cc2a80d3f5bd7c921 (diff) |
Merge branch 'net-add-and-use-function-dev_fetch_sw_netstats-for-fetching-pcpu_sw_netstats'
Heiner Kallweit says:
====================
net: add and use function dev_fetch_sw_netstats for fetching pcpu_sw_netstats
In several places the same code is used to populate rtnl_link_stats64
fields with data from pcpu_sw_netstats. Therefore factor out this code
to a new function dev_fetch_sw_netstats().
====================
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/macsec.c')
-rw-r--r-- | drivers/net/macsec.c | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 2b0c8f01ddc3..11ca5fa902a1 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3647,30 +3647,10 @@ static int macsec_change_mtu(struct net_device *dev, int new_mtu) static void macsec_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *s) { - int cpu; - if (!dev->tstats) return; - for_each_possible_cpu(cpu) { - struct pcpu_sw_netstats *stats; - struct pcpu_sw_netstats tmp; - int start; - - stats = per_cpu_ptr(dev->tstats, cpu); - do { - start = u64_stats_fetch_begin_irq(&stats->syncp); - tmp.rx_packets = stats->rx_packets; - tmp.rx_bytes = stats->rx_bytes; - tmp.tx_packets = stats->tx_packets; - tmp.tx_bytes = stats->tx_bytes; - } while (u64_stats_fetch_retry_irq(&stats->syncp, start)); - - s->rx_packets += tmp.rx_packets; - s->rx_bytes += tmp.rx_bytes; - s->tx_packets += tmp.tx_packets; - s->tx_bytes += tmp.tx_bytes; - } + dev_fetch_sw_netstats(s, dev->tstats); s->rx_dropped = dev->stats.rx_dropped; s->tx_dropped = dev->stats.tx_dropped; |