Skip to content

Commit 79e0c5b

Browse files
borkmannMartin KaFai Lau
authored andcommitted
net, vrf: Move dstats structure to core
Just move struct pcpu_dstats out of the vrf into the core, and streamline the field names slightly, so they better align with the {t,l}stats ones. No functional change otherwise. A conversion of the u64s to u64_stats_t could be done at a separate point in future. This move is needed as we are moving the {t,l,d}stats allocation/freeing to the core. Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
1 parent 76df934 commit 79e0c5b

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

drivers/net/vrf.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,12 @@ struct net_vrf {
121121
int ifindex;
122122
};
123123

124-
struct pcpu_dstats {
125-
u64 tx_pkts;
126-
u64 tx_bytes;
127-
u64 tx_drps;
128-
u64 rx_pkts;
129-
u64 rx_bytes;
130-
u64 rx_drps;
131-
struct u64_stats_sync syncp;
132-
};
133-
134124
static void vrf_rx_stats(struct net_device *dev, int len)
135125
{
136126
struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
137127

138128
u64_stats_update_begin(&dstats->syncp);
139-
dstats->rx_pkts++;
129+
dstats->rx_packets++;
140130
dstats->rx_bytes += len;
141131
u64_stats_update_end(&dstats->syncp);
142132
}
@@ -161,10 +151,10 @@ static void vrf_get_stats64(struct net_device *dev,
161151
do {
162152
start = u64_stats_fetch_begin(&dstats->syncp);
163153
tbytes = dstats->tx_bytes;
164-
tpkts = dstats->tx_pkts;
165-
tdrops = dstats->tx_drps;
154+
tpkts = dstats->tx_packets;
155+
tdrops = dstats->tx_drops;
166156
rbytes = dstats->rx_bytes;
167-
rpkts = dstats->rx_pkts;
157+
rpkts = dstats->rx_packets;
168158
} while (u64_stats_fetch_retry(&dstats->syncp, start));
169159
stats->tx_bytes += tbytes;
170160
stats->tx_packets += tpkts;
@@ -421,7 +411,7 @@ static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev,
421411
if (likely(__netif_rx(skb) == NET_RX_SUCCESS))
422412
vrf_rx_stats(dev, len);
423413
else
424-
this_cpu_inc(dev->dstats->rx_drps);
414+
this_cpu_inc(dev->dstats->rx_drops);
425415

426416
return NETDEV_TX_OK;
427417
}
@@ -616,11 +606,11 @@ static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev)
616606
struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
617607

618608
u64_stats_update_begin(&dstats->syncp);
619-
dstats->tx_pkts++;
609+
dstats->tx_packets++;
620610
dstats->tx_bytes += len;
621611
u64_stats_update_end(&dstats->syncp);
622612
} else {
623-
this_cpu_inc(dev->dstats->tx_drps);
613+
this_cpu_inc(dev->dstats->tx_drops);
624614
}
625615

626616
return ret;

include/linux/netdevice.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,6 +2755,16 @@ struct pcpu_sw_netstats {
27552755
struct u64_stats_sync syncp;
27562756
} __aligned(4 * sizeof(u64));
27572757

2758+
struct pcpu_dstats {
2759+
u64 rx_packets;
2760+
u64 rx_bytes;
2761+
u64 rx_drops;
2762+
u64 tx_packets;
2763+
u64 tx_bytes;
2764+
u64 tx_drops;
2765+
struct u64_stats_sync syncp;
2766+
} __aligned(8 * sizeof(u64));
2767+
27582768
struct pcpu_lstats {
27592769
u64_stats_t packets;
27602770
u64_stats_t bytes;

0 commit comments

Comments
 (0)