Commit 3b51788a authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski

IB/hfi1: use new function dev_fetch_sw_netstats

Simplify the code by using new function dev_fetch_sw_netstats().
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/6cad1a04-f021-d94b-45fd-7cc7cf07367d@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 44fa32f0
...@@ -97,41 +97,9 @@ static void hfi1_ipoib_dev_get_stats64(struct net_device *dev, ...@@ -97,41 +97,9 @@ static void hfi1_ipoib_dev_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *storage) struct rtnl_link_stats64 *storage)
{ {
struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev); struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
u64 rx_packets = 0ull;
u64 rx_bytes = 0ull;
u64 tx_packets = 0ull;
u64 tx_bytes = 0ull;
int i;
netdev_stats_to_stats64(storage, &dev->stats); netdev_stats_to_stats64(storage, &dev->stats);
dev_fetch_sw_netstats(storage, priv->netstats);
for_each_possible_cpu(i) {
const struct pcpu_sw_netstats *stats;
unsigned int start;
u64 trx_packets;
u64 trx_bytes;
u64 ttx_packets;
u64 ttx_bytes;
stats = per_cpu_ptr(priv->netstats, i);
do {
start = u64_stats_fetch_begin_irq(&stats->syncp);
trx_packets = stats->rx_packets;
trx_bytes = stats->rx_bytes;
ttx_packets = stats->tx_packets;
ttx_bytes = stats->tx_bytes;
} while (u64_stats_fetch_retry_irq(&stats->syncp, start));
rx_packets += trx_packets;
rx_bytes += trx_bytes;
tx_packets += ttx_packets;
tx_bytes += ttx_bytes;
}
storage->rx_packets += rx_packets;
storage->rx_bytes += rx_bytes;
storage->tx_packets += tx_packets;
storage->tx_bytes += tx_bytes;
} }
static const struct net_device_ops hfi1_ipoib_netdev_ops = { static const struct net_device_ops hfi1_ipoib_netdev_ops = {
......
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