mirror of
https://github.com/torvalds/linux.git
synced 2024-11-18 10:01:43 +00:00
veth: 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:
parent
3ed912264f
commit
b4fba476dc
@ -260,14 +260,8 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||||||
|
|
||||||
skb_tx_timestamp(skb);
|
skb_tx_timestamp(skb);
|
||||||
if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) {
|
if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) {
|
||||||
if (!rcv_xdp) {
|
if (!rcv_xdp)
|
||||||
struct pcpu_lstats *stats = this_cpu_ptr(dev->lstats);
|
dev_lstats_add(dev, length);
|
||||||
|
|
||||||
u64_stats_update_begin(&stats->syncp);
|
|
||||||
stats->bytes += length;
|
|
||||||
stats->packets++;
|
|
||||||
u64_stats_update_end(&stats->syncp);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
drop:
|
drop:
|
||||||
atomic64_inc(&priv->dropped);
|
atomic64_inc(&priv->dropped);
|
||||||
@ -281,26 +275,11 @@ drop:
|
|||||||
return NETDEV_TX_OK;
|
return NETDEV_TX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 veth_stats_tx(struct pcpu_lstats *result, struct net_device *dev)
|
static u64 veth_stats_tx(struct net_device *dev, u64 *packets, u64 *bytes)
|
||||||
{
|
{
|
||||||
struct veth_priv *priv = netdev_priv(dev);
|
struct veth_priv *priv = netdev_priv(dev);
|
||||||
int cpu;
|
|
||||||
|
|
||||||
result->packets = 0;
|
dev_lstats_read(dev, packets, bytes);
|
||||||
result->bytes = 0;
|
|
||||||
for_each_possible_cpu(cpu) {
|
|
||||||
struct pcpu_lstats *stats = per_cpu_ptr(dev->lstats, cpu);
|
|
||||||
u64 packets, bytes;
|
|
||||||
unsigned int start;
|
|
||||||
|
|
||||||
do {
|
|
||||||
start = u64_stats_fetch_begin_irq(&stats->syncp);
|
|
||||||
packets = stats->packets;
|
|
||||||
bytes = stats->bytes;
|
|
||||||
} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
|
|
||||||
result->packets += packets;
|
|
||||||
result->bytes += bytes;
|
|
||||||
}
|
|
||||||
return atomic64_read(&priv->dropped);
|
return atomic64_read(&priv->dropped);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,11 +314,11 @@ static void veth_get_stats64(struct net_device *dev,
|
|||||||
struct veth_priv *priv = netdev_priv(dev);
|
struct veth_priv *priv = netdev_priv(dev);
|
||||||
struct net_device *peer;
|
struct net_device *peer;
|
||||||
struct veth_rq_stats rx;
|
struct veth_rq_stats rx;
|
||||||
struct pcpu_lstats tx;
|
u64 packets, bytes;
|
||||||
|
|
||||||
tot->tx_dropped = veth_stats_tx(&tx, dev);
|
tot->tx_dropped = veth_stats_tx(dev, &packets, &bytes);
|
||||||
tot->tx_bytes = tx.bytes;
|
tot->tx_bytes = bytes;
|
||||||
tot->tx_packets = tx.packets;
|
tot->tx_packets = packets;
|
||||||
|
|
||||||
veth_stats_rx(&rx, dev);
|
veth_stats_rx(&rx, dev);
|
||||||
tot->rx_dropped = rx.xdp_drops;
|
tot->rx_dropped = rx.xdp_drops;
|
||||||
@ -349,9 +328,9 @@ static void veth_get_stats64(struct net_device *dev,
|
|||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
peer = rcu_dereference(priv->peer);
|
peer = rcu_dereference(priv->peer);
|
||||||
if (peer) {
|
if (peer) {
|
||||||
tot->rx_dropped += veth_stats_tx(&tx, peer);
|
tot->rx_dropped += veth_stats_tx(peer, &packets, &bytes);
|
||||||
tot->rx_bytes += tx.bytes;
|
tot->rx_bytes += bytes;
|
||||||
tot->rx_packets += tx.packets;
|
tot->rx_packets += packets;
|
||||||
|
|
||||||
veth_stats_rx(&rx, peer);
|
veth_stats_rx(&rx, peer);
|
||||||
tot->tx_bytes += rx.xdp_bytes;
|
tot->tx_bytes += rx.xdp_bytes;
|
||||||
|
Loading…
Reference in New Issue
Block a user