mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
vsockmon: use standard dev_lstats_add() and dev_lstats_read()
This cleanup will ease u64_stats_t adoption in a single location. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b4fba476dc
commit
4f77eb0941
@@ -47,13 +47,7 @@ static int vsockmon_close(struct net_device *dev)
|
|||||||
|
|
||||||
static netdev_tx_t vsockmon_xmit(struct sk_buff *skb, struct net_device *dev)
|
static netdev_tx_t vsockmon_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);
|
||||||
|
|
||||||
@@ -63,30 +57,9 @@ static netdev_tx_t vsockmon_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||||||
static void
|
static void
|
||||||
vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
vsockmon_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
||||||
{
|
{
|
||||||
int i;
|
dev_lstats_read(dev, &stats->rx_packets, &stats->rx_bytes);
|
||||||
u64 bytes = 0, packets = 0;
|
|
||||||
|
|
||||||
for_each_possible_cpu(i) {
|
|
||||||
const struct pcpu_lstats *vstats;
|
|
||||||
u64 tbytes, tpackets;
|
|
||||||
unsigned int start;
|
|
||||||
|
|
||||||
vstats = per_cpu_ptr(dev->lstats, i);
|
|
||||||
|
|
||||||
do {
|
|
||||||
start = u64_stats_fetch_begin_irq(&vstats->syncp);
|
|
||||||
tbytes = vstats->bytes;
|
|
||||||
tpackets = vstats->packets;
|
|
||||||
} while (u64_stats_fetch_retry_irq(&vstats->syncp, start));
|
|
||||||
|
|
||||||
packets += tpackets;
|
|
||||||
bytes += tbytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
stats->rx_packets = packets;
|
|
||||||
stats->tx_packets = 0;
|
stats->tx_packets = 0;
|
||||||
|
|
||||||
stats->rx_bytes = bytes;
|
|
||||||
stats->tx_bytes = 0;
|
stats->tx_bytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user