Commit 2d5c27da authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski

qmi_wwan: switch to core handling of rx/tx byte/packet counters

Use netdev->tstats instead of a member of qmimux_priv for storing
a pointer to the per-cpu counters. This allows us to use core
functionality for statistics handling.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Acked-by: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent aa0616a9
...@@ -72,7 +72,6 @@ struct qmimux_hdr { ...@@ -72,7 +72,6 @@ struct qmimux_hdr {
struct qmimux_priv { struct qmimux_priv {
struct net_device *real_dev; struct net_device *real_dev;
u8 mux_id; u8 mux_id;
struct pcpu_sw_netstats __percpu *stats64;
}; };
static int qmimux_open(struct net_device *dev) static int qmimux_open(struct net_device *dev)
...@@ -108,34 +107,19 @@ static netdev_tx_t qmimux_start_xmit(struct sk_buff *skb, struct net_device *dev ...@@ -108,34 +107,19 @@ static netdev_tx_t qmimux_start_xmit(struct sk_buff *skb, struct net_device *dev
skb->dev = priv->real_dev; skb->dev = priv->real_dev;
ret = dev_queue_xmit(skb); ret = dev_queue_xmit(skb);
if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) { if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN))
struct pcpu_sw_netstats *stats64 = this_cpu_ptr(priv->stats64); dev_sw_netstats_tx_add(dev, 1, len);
else
u64_stats_update_begin(&stats64->syncp);
stats64->tx_packets++;
stats64->tx_bytes += len;
u64_stats_update_end(&stats64->syncp);
} else {
dev->stats.tx_dropped++; dev->stats.tx_dropped++;
}
return ret; return ret;
} }
static void qmimux_get_stats64(struct net_device *net,
struct rtnl_link_stats64 *stats)
{
struct qmimux_priv *priv = netdev_priv(net);
netdev_stats_to_stats64(stats, &net->stats);
dev_fetch_sw_netstats(stats, priv->stats64);
}
static const struct net_device_ops qmimux_netdev_ops = { static const struct net_device_ops qmimux_netdev_ops = {
.ndo_open = qmimux_open, .ndo_open = qmimux_open,
.ndo_stop = qmimux_stop, .ndo_stop = qmimux_stop,
.ndo_start_xmit = qmimux_start_xmit, .ndo_start_xmit = qmimux_start_xmit,
.ndo_get_stats64 = qmimux_get_stats64, .ndo_get_stats64 = dev_get_tstats64,
}; };
static void qmimux_setup(struct net_device *dev) static void qmimux_setup(struct net_device *dev)
...@@ -224,14 +208,7 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ...@@ -224,14 +208,7 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
net->stats.rx_errors++; net->stats.rx_errors++;
return 0; return 0;
} else { } else {
struct pcpu_sw_netstats *stats64; dev_sw_netstats_rx_add(net, pkt_len);
struct qmimux_priv *priv = netdev_priv(net);
stats64 = this_cpu_ptr(priv->stats64);
u64_stats_update_begin(&stats64->syncp);
stats64->rx_packets++;
stats64->rx_bytes += pkt_len;
u64_stats_update_end(&stats64->syncp);
} }
skip: skip:
...@@ -256,8 +233,8 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id) ...@@ -256,8 +233,8 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
priv->mux_id = mux_id; priv->mux_id = mux_id;
priv->real_dev = real_dev; priv->real_dev = real_dev;
priv->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); new_dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
if (!priv->stats64) { if (!new_dev->tstats) {
err = -ENOBUFS; err = -ENOBUFS;
goto out_free_newdev; goto out_free_newdev;
} }
...@@ -292,7 +269,7 @@ static void qmimux_unregister_device(struct net_device *dev, ...@@ -292,7 +269,7 @@ static void qmimux_unregister_device(struct net_device *dev,
struct qmimux_priv *priv = netdev_priv(dev); struct qmimux_priv *priv = netdev_priv(dev);
struct net_device *real_dev = priv->real_dev; struct net_device *real_dev = priv->real_dev;
free_percpu(priv->stats64); free_percpu(dev->tstats);
netdev_upper_dev_unlink(real_dev, dev); netdev_upper_dev_unlink(real_dev, dev);
unregister_netdevice_queue(dev, head); unregister_netdevice_queue(dev, head);
......
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