Commit 3ed91226 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

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

No need to hand-code the exact same functions.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dd5382a0
...@@ -9,13 +9,7 @@ ...@@ -9,13 +9,7 @@
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; dev_lstats_add(dev, skb->len);
struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats);
u64_stats_update_begin(&stats->syncp);
stats->bytes += len;
stats->packets++;
u64_stats_update_end(&stats->syncp);
dev_kfree_skb(skb); dev_kfree_skb(skb);
...@@ -56,25 +50,9 @@ static int nlmon_close(struct net_device *dev) ...@@ -56,25 +50,9 @@ static int nlmon_close(struct net_device *dev)
static void static void
nlmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) nlmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ {
int i; u64 packets, bytes;
u64 bytes = 0, packets = 0;
for_each_possible_cpu(i) {
const struct pcpu_lstats *nl_stats;
u64 tbytes, tpackets;
unsigned int start;
nl_stats = per_cpu_ptr(dev->lstats, i);
do {
start = u64_stats_fetch_begin_irq(&nl_stats->syncp);
tbytes = nl_stats->bytes;
tpackets = nl_stats->packets;
} while (u64_stats_fetch_retry_irq(&nl_stats->syncp, start));
packets += tpackets; dev_lstats_read(dev, &packets, &bytes);
bytes += tbytes;
}
stats->rx_packets = packets; stats->rx_packets = packets;
stats->tx_packets = 0; stats->tx_packets = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment