[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c3eb3707-cac8-5db2-545d-8a3b4de39dad@gmail.com>
Date: Tue, 10 Nov 2020 20:48:14 +0100
From: Heiner Kallweit <hkallweit1@...il.com>
To: Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>,
Mike Marciniszyn <mike.marciniszyn@...nelisnetworks.com>,
Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
Doug Ledford <dledford@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Bjørn Mork <bjorn@...k.no>,
Igor Mitsyanko <imitsyanko@...ntenna.com>,
Sergey Matyukevich <geomatsi@...il.com>,
Kalle Valo <kvalo@...eaurora.org>,
Oliver Neukum <oneukum@...e.com>,
Peter Korsgaard <jacmet@...site.dk>,
Steve Glendinning <steve.glendinning@...well.net>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
Jussi Kivilinna <jussi.kivilinna@....fi>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
linux-rdma@...r.kernel.org,
Linux USB Mailing List <linux-usb@...r.kernel.org>,
linux-wireless <linux-wireless@...r.kernel.org>
Subject: [PATCH net-next 2/5] 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: Heiner Kallweit <hkallweit1@...il.com>
---
drivers/net/usb/qmi_wwan.c | 39 ++++++++------------------------------
1 file changed, 8 insertions(+), 31 deletions(-)
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 581ed51ab..b9d74d9a7 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -72,7 +72,6 @@ struct qmimux_hdr {
struct qmimux_priv {
struct net_device *real_dev;
u8 mux_id;
- struct pcpu_sw_netstats __percpu *stats64;
};
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
skb->dev = priv->real_dev;
ret = dev_queue_xmit(skb);
- if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
- struct pcpu_sw_netstats *stats64 = this_cpu_ptr(priv->stats64);
-
- u64_stats_update_begin(&stats64->syncp);
- stats64->tx_packets++;
- stats64->tx_bytes += len;
- u64_stats_update_end(&stats64->syncp);
- } else {
+ if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN))
+ dev_sw_netstats_tx_add(dev, 1, len);
+ else
dev->stats.tx_dropped++;
- }
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 = {
.ndo_open = qmimux_open,
.ndo_stop = qmimux_stop,
.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)
@@ -224,14 +208,7 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
net->stats.rx_errors++;
return 0;
} else {
- struct pcpu_sw_netstats *stats64;
- 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);
+ dev_sw_netstats_rx_add(net, pkt_len);
}
skip:
@@ -256,8 +233,8 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
priv->mux_id = mux_id;
priv->real_dev = real_dev;
- priv->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
- if (!priv->stats64) {
+ new_dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
+ if (!new_dev->tstats) {
err = -ENOBUFS;
goto out_free_newdev;
}
@@ -292,7 +269,7 @@ static void qmimux_unregister_device(struct net_device *dev,
struct qmimux_priv *priv = netdev_priv(dev);
struct net_device *real_dev = priv->real_dev;
- free_percpu(priv->stats64);
+ free_percpu(dev->tstats);
netdev_upper_dev_unlink(real_dev, dev);
unregister_netdevice_queue(dev, head);
--
2.29.2
Powered by blists - more mailing lists