Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: nlmon: use standard dev_lstats_add() and dev_lstats_read()

No need to hand-code the exact same functions.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
3ed91226 dd5382a0

+3 -25
+3 -25
drivers/net/nlmon.c
··· 9 9 10 10 static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev) 11 11 { 12 - int len = skb->len; 13 - struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats); 14 - 15 - u64_stats_update_begin(&stats->syncp); 16 - stats->bytes += len; 17 - stats->packets++; 18 - u64_stats_update_end(&stats->syncp); 12 + dev_lstats_add(dev, skb->len); 19 13 20 14 dev_kfree_skb(skb); 21 15 ··· 50 56 static void 51 57 nlmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) 52 58 { 53 - int i; 54 - u64 bytes = 0, packets = 0; 59 + u64 packets, bytes; 55 60 56 - for_each_possible_cpu(i) { 57 - const struct pcpu_lstats *nl_stats; 58 - u64 tbytes, tpackets; 59 - unsigned int start; 60 - 61 - nl_stats = per_cpu_ptr(dev->lstats, i); 62 - 63 - do { 64 - start = u64_stats_fetch_begin_irq(&nl_stats->syncp); 65 - tbytes = nl_stats->bytes; 66 - tpackets = nl_stats->packets; 67 - } while (u64_stats_fetch_retry_irq(&nl_stats->syncp, start)); 68 - 69 - packets += tpackets; 70 - bytes += tbytes; 71 - } 61 + dev_lstats_read(dev, &packets, &bytes); 72 62 73 63 stats->rx_packets = packets; 74 64 stats->tx_packets = 0;