Switch further drivers to core functionality for handling per-cpu
byte/packet counters.
All changes are compile-tested only.
Heiner Kallweit (5):
IB/hfi1: switch to core handling of rx/tx byte/packet counters
qmi_wwan: switch to core handling of rx/tx byte/packet counters
qtnfmac: switch to core handling of rx/tx byte/packet counters
usbnet: switch to core handling of rx/tx byte/packet counters
net: usb: switch to dev_get_tstats64 and remove usbnet_get_stats64
alias
drivers/infiniband/hw/hfi1/driver.c | 4 +-
drivers/infiniband/hw/hfi1/ipoib.h | 27 -------
drivers/infiniband/hw/hfi1/ipoib_main.c | 15 +---
drivers/infiniband/hw/hfi1/ipoib_tx.c | 2 +-
drivers/net/usb/aqc111.c | 2 +-
drivers/net/usb/asix_devices.c | 6 +-
drivers/net/usb/ax88172a.c | 2 +-
drivers/net/usb/ax88179_178a.c | 2 +-
drivers/net/usb/cdc_mbim.c | 2 +-
drivers/net/usb/cdc_ncm.c | 2 +-
drivers/net/usb/dm9601.c | 2 +-
drivers/net/usb/int51x1.c | 2 +-
drivers/net/usb/mcs7830.c | 2 +-
drivers/net/usb/qmi_wwan.c | 41 +++-------
drivers/net/usb/rndis_host.c | 2 +-
drivers/net/usb/sierra_net.c | 2 +-
drivers/net/usb/smsc75xx.c | 2 +-
drivers/net/usb/smsc95xx.c | 2 +-
drivers/net/usb/sr9700.c | 2 +-
drivers/net/usb/sr9800.c | 2 +-
drivers/net/usb/usbnet.c | 23 ++----
drivers/net/wireless/quantenna/qtnfmac/core.c | 78 ++++---------------
drivers/net/wireless/quantenna/qtnfmac/core.h | 4 -
.../quantenna/qtnfmac/pcie/pearl_pcie.c | 4 +-
.../quantenna/qtnfmac/pcie/topaz_pcie.c | 4 +-
drivers/net/wireless/rndis_wlan.c | 2 +-
include/linux/usb/usbnet.h | 4 -
27 files changed, 59 insertions(+), 183 deletions(-)
--
2.29.2
Replace usbnet_get_stats64() with new identical core function
dev_get_tstats64() in all users and remove usbnet_get_stats64().
Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/net/usb/aqc111.c | 2 +-
drivers/net/usb/asix_devices.c | 6 +++---
drivers/net/usb/ax88172a.c | 2 +-
drivers/net/usb/ax88179_178a.c | 2 +-
drivers/net/usb/cdc_mbim.c | 2 +-
drivers/net/usb/cdc_ncm.c | 2 +-
drivers/net/usb/dm9601.c | 2 +-
drivers/net/usb/int51x1.c | 2 +-
drivers/net/usb/mcs7830.c | 2 +-
drivers/net/usb/qmi_wwan.c | 2 +-
drivers/net/usb/rndis_host.c | 2 +-
drivers/net/usb/sierra_net.c | 2 +-
drivers/net/usb/smsc75xx.c | 2 +-
drivers/net/usb/smsc95xx.c | 2 +-
drivers/net/usb/sr9700.c | 2 +-
drivers/net/usb/sr9800.c | 2 +-
drivers/net/wireless/rndis_wlan.c | 2 +-
include/linux/usb/usbnet.h | 2 --
18 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index 0717c1801..73b97f4cc 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -641,7 +641,7 @@ static const struct net_device_ops aqc111_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_change_mtu = aqc111_change_mtu,
.ndo_set_mac_address = aqc111_set_mac_addr,
.ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index ef548beba..6e13d8165 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -194,7 +194,7 @@ static const struct net_device_ops ax88172_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = asix_ioctl,
@@ -580,7 +580,7 @@ static const struct net_device_ops ax88772_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = asix_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = asix_ioctl,
@@ -1050,7 +1050,7 @@ static const struct net_device_ops ax88178_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = asix_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = asix_set_multicast,
diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c
index fd3a04d98..b404c9462 100644
--- a/drivers/net/usb/ax88172a.c
+++ b/drivers/net/usb/ax88172a.c
@@ -120,7 +120,7 @@ static const struct net_device_ops ax88172a_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = asix_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = phy_do_ioctl_running,
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 5541f3fae..d650b39b6 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1031,7 +1031,7 @@ static const struct net_device_ops ax88179_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_change_mtu = ax88179_change_mtu,
.ndo_set_mac_address = ax88179_set_mac_addr,
.ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index eb100eb33..5db66272f 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -98,7 +98,7 @@ static const struct net_device_ops cdc_mbim_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_change_mtu = cdc_ncm_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index e04f58853..abe1162dc 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -793,7 +793,7 @@ static const struct net_device_ops cdc_ncm_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_set_rx_mode = usbnet_set_rx_mode,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_change_mtu = cdc_ncm_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 915ac75b5..b5d2ac55a 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -343,7 +343,7 @@ static const struct net_device_ops dm9601_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = dm9601_ioctl,
.ndo_set_rx_mode = dm9601_set_multicast,
diff --git a/drivers/net/usb/int51x1.c b/drivers/net/usb/int51x1.c
index cb5bc1a7f..ed05f992c 100644
--- a/drivers/net/usb/int51x1.c
+++ b/drivers/net/usb/int51x1.c
@@ -133,7 +133,7 @@ static const struct net_device_ops int51x1_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = int51x1_set_multicast,
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 09bfa6a4d..fc512b780 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -462,7 +462,7 @@ static const struct net_device_ops mcs7830_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = mcs7830_ioctl,
.ndo_set_rx_mode = mcs7830_set_multicast,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index b9d74d9a7..afeb09b96 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -575,7 +575,7 @@ static const struct net_device_ops qmi_wwan_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = qmi_wwan_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 6fa7a009a..6609d21ef 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -279,7 +279,7 @@ static const struct net_device_ops rndis_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 0abd257b6..55a244eca 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -184,7 +184,7 @@ static const struct net_device_ops sierra_net_device_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 8689835a5..4353b3702 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -1435,7 +1435,7 @@ static const struct net_device_ops smsc75xx_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_change_mtu = smsc75xx_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index ea0d5f04d..4c8ee1cff 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1041,7 +1041,7 @@ static const struct net_device_ops smsc95xx_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = smsc95xx_ioctl,
diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c
index e04c8054c..878557ad0 100644
--- a/drivers/net/usb/sr9700.c
+++ b/drivers/net/usb/sr9700.c
@@ -308,7 +308,7 @@ static const struct net_device_ops sr9700_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = sr9700_ioctl,
.ndo_set_rx_mode = sr9700_set_multicast,
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 681e0def6..da56735d7 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -681,7 +681,7 @@ static const struct net_device_ops sr9800_netdev_ops = {
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = sr_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = sr_ioctl,
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 75b5d545b..9fe775568 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -3379,7 +3379,7 @@ static const struct net_device_ops rndis_wlan_netdev_ops = {
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = rndis_wlan_set_multicast_list,
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 1f6dfa977..88a767389 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -284,6 +284,4 @@ extern void usbnet_status_stop(struct usbnet *dev);
extern void usbnet_update_max_qlen(struct usbnet *dev);
-#define usbnet_get_stats64 dev_get_tstats64
-
#endif /* __LINUX_USB_USBNET_H */
--
2.29.2
Use netdev->tstats instead of a member of qtnf_vif for storing a pointer
to the per-cpu counters. This allows us to use core functionality for
statistics handling.
The driver sets netdev->needs_free_netdev, therefore freeing the per-cpu
counters at the right point in time is a little bit tricky. Best option
seems to be to use the ndo_init/ndo_uninit callbacks.
Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/net/wireless/quantenna/qtnfmac/core.c | 78 ++++---------------
drivers/net/wireless/quantenna/qtnfmac/core.h | 4 -
.../quantenna/qtnfmac/pcie/pearl_pcie.c | 4 +-
.../quantenna/qtnfmac/pcie/topaz_pcie.c | 4 +-
4 files changed, 20 insertions(+), 70 deletions(-)
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index bf6dbeb61..ad726bd10 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -126,28 +126,13 @@ qtnf_netdev_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
if (unlikely(skb->protocol == htons(ETH_P_PAE))) {
qtnf_packet_send_hi_pri(skb);
- qtnf_update_tx_stats(ndev, skb);
+ dev_sw_netstats_tx_add(ndev, 1, skb->len);
return NETDEV_TX_OK;
}
return qtnf_bus_data_tx(mac->bus, skb, mac->macid, vif->vifid);
}
-/* Netdev handler for getting stats.
- */
-static void qtnf_netdev_get_stats64(struct net_device *ndev,
- struct rtnl_link_stats64 *stats)
-{
- struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
-
- netdev_stats_to_stats64(stats, &ndev->stats);
-
- if (!vif->stats64)
- return;
-
- dev_fetch_sw_netstats(stats, vif->stats64);
-}
-
/* Netdev handler for transmission timeout.
*/
static void qtnf_netdev_tx_timeout(struct net_device *ndev, unsigned int txqueue)
@@ -211,13 +196,27 @@ static int qtnf_netdev_port_parent_id(struct net_device *ndev,
return 0;
}
+static int qtnf_netdev_alloc_pcpu_stats(struct net_device *dev)
+{
+ dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
+
+ return dev->tstats ? 0 : -ENOMEM;
+}
+
+static void qtnf_netdev_free_pcpu_stats(struct net_device *dev)
+{
+ free_percpu(dev->tstats);
+}
+
/* Network device ops handlers */
const struct net_device_ops qtnf_netdev_ops = {
+ .ndo_init = qtnf_netdev_alloc_pcpu_stats,
+ .ndo_uninit = qtnf_netdev_free_pcpu_stats,
.ndo_open = qtnf_netdev_open,
.ndo_stop = qtnf_netdev_close,
.ndo_start_xmit = qtnf_netdev_hard_start_xmit,
.ndo_tx_timeout = qtnf_netdev_tx_timeout,
- .ndo_get_stats64 = qtnf_netdev_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = qtnf_netdev_set_mac_address,
.ndo_get_port_parent_id = qtnf_netdev_port_parent_id,
};
@@ -448,10 +447,6 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus,
qtnf_sta_list_init(&vif->sta_list);
INIT_WORK(&vif->high_pri_tx_work, qtnf_vif_send_data_high_pri);
skb_queue_head_init(&vif->high_pri_tx_queue);
- vif->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
- if (!vif->stats64)
- pr_warn("VIF%u.%u: per cpu stats allocation failed\n",
- macid, i);
}
qtnf_mac_init_primary_intf(mac);
@@ -531,7 +526,6 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid)
}
rtnl_unlock();
qtnf_sta_list_free(&vif->sta_list);
- free_percpu(vif->stats64);
}
if (mac->wiphy_registered)
@@ -924,46 +918,6 @@ void qtnf_wake_all_queues(struct net_device *ndev)
}
EXPORT_SYMBOL_GPL(qtnf_wake_all_queues);
-void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb)
-{
- struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
- struct pcpu_sw_netstats *stats64;
-
- if (unlikely(!vif || !vif->stats64)) {
- ndev->stats.rx_packets++;
- ndev->stats.rx_bytes += skb->len;
- return;
- }
-
- stats64 = this_cpu_ptr(vif->stats64);
-
- u64_stats_update_begin(&stats64->syncp);
- stats64->rx_packets++;
- stats64->rx_bytes += skb->len;
- u64_stats_update_end(&stats64->syncp);
-}
-EXPORT_SYMBOL_GPL(qtnf_update_rx_stats);
-
-void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb)
-{
- struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
- struct pcpu_sw_netstats *stats64;
-
- if (unlikely(!vif || !vif->stats64)) {
- ndev->stats.tx_packets++;
- ndev->stats.tx_bytes += skb->len;
- return;
- }
-
- stats64 = this_cpu_ptr(vif->stats64);
-
- u64_stats_update_begin(&stats64->syncp);
- stats64->tx_packets++;
- stats64->tx_bytes += skb->len;
- u64_stats_update_end(&stats64->syncp);
-}
-EXPORT_SYMBOL_GPL(qtnf_update_tx_stats);
-
struct dentry *qtnf_get_debugfs_dir(void)
{
return qtnf_debugfs_dir;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h
index 269ce12cf..b204a2407 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.h
@@ -70,8 +70,6 @@ struct qtnf_vif {
struct qtnf_sta_list sta_list;
unsigned long cons_tx_timeout_cnt;
int generation;
-
- struct pcpu_sw_netstats __percpu *stats64;
};
struct qtnf_mac_info {
@@ -139,8 +137,6 @@ int qtnf_cmd_send_update_phy_params(struct qtnf_wmac *mac, u32 changed);
struct qtnf_wmac *qtnf_core_get_mac(const struct qtnf_bus *bus, u8 macid);
struct net_device *qtnf_classify_skb(struct qtnf_bus *bus, struct sk_buff *skb);
void qtnf_wake_all_queues(struct net_device *ndev);
-void qtnf_update_rx_stats(struct net_device *ndev, const struct sk_buff *skb);
-void qtnf_update_tx_stats(struct net_device *ndev, const struct sk_buff *skb);
void qtnf_virtual_intf_cleanup(struct net_device *ndev);
diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c
index 9a20c0f29..0003df577 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c
@@ -489,7 +489,7 @@ static void qtnf_pearl_data_tx_reclaim(struct qtnf_pcie_pearl_state *ps)
PCI_DMA_TODEVICE);
if (skb->dev) {
- qtnf_update_tx_stats(skb->dev, skb);
+ dev_sw_netstats_tx_add(skb->dev, 1, skb->len);
if (unlikely(priv->tx_stopped)) {
qtnf_wake_all_queues(skb->dev);
priv->tx_stopped = 0;
@@ -756,7 +756,7 @@ static int qtnf_pcie_pearl_rx_poll(struct napi_struct *napi, int budget)
skb_put(skb, psize);
ndev = qtnf_classify_skb(bus, skb);
if (likely(ndev)) {
- qtnf_update_rx_stats(ndev, skb);
+ dev_sw_netstats_rx_add(ndev, skb->len);
skb->protocol = eth_type_trans(skb, ndev);
napi_gro_receive(napi, skb);
} else {
diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
index 4b87d3151..24f1be8dd 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c
@@ -418,7 +418,7 @@ static void qtnf_topaz_data_tx_reclaim(struct qtnf_pcie_topaz_state *ts)
PCI_DMA_TODEVICE);
if (skb->dev) {
- qtnf_update_tx_stats(skb->dev, skb);
+ dev_sw_netstats_tx_add(skb->dev, 1, skb->len);
if (unlikely(priv->tx_stopped)) {
qtnf_wake_all_queues(skb->dev);
priv->tx_stopped = 0;
@@ -662,7 +662,7 @@ static int qtnf_topaz_rx_poll(struct napi_struct *napi, int budget)
skb_put(skb, psize);
ndev = qtnf_classify_skb(bus, skb);
if (likely(ndev)) {
- qtnf_update_rx_stats(ndev, skb);
+ dev_sw_netstats_rx_add(ndev, skb->len);
skb->protocol = eth_type_trans(skb, ndev);
netif_receive_skb(skb);
} else {
--
2.29.2
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 <[email protected]>
---
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
Use netdev->tstats instead of a member of usbnet for storing a pointer
to the per-cpu counters. This allows us to use core functionality for
statistics handling.
Signed-off-by: Heiner Kallweit <[email protected]>
---
drivers/net/usb/usbnet.c | 23 +++++++----------------
include/linux/usb/usbnet.h | 6 ++----
2 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 6062dc278..1447da1d5 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -304,7 +304,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev)
*/
void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
{
- struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64);
+ struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats);
unsigned long flags;
int status;
@@ -980,15 +980,6 @@ int usbnet_set_link_ksettings(struct net_device *net,
}
EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings);
-void usbnet_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats)
-{
- struct usbnet *dev = netdev_priv(net);
-
- netdev_stats_to_stats64(stats, &net->stats);
- dev_fetch_sw_netstats(stats, dev->stats64);
-}
-EXPORT_SYMBOL_GPL(usbnet_get_stats64);
-
u32 usbnet_get_link (struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
@@ -1220,7 +1211,7 @@ static void tx_complete (struct urb *urb)
struct usbnet *dev = entry->dev;
if (urb->status == 0) {
- struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64);
+ struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->net->tstats);
unsigned long flags;
flags = u64_stats_update_begin_irqsave(&stats64->syncp);
@@ -1596,7 +1587,7 @@ void usbnet_disconnect (struct usb_interface *intf)
usb_free_urb(dev->interrupt);
kfree(dev->padding_pkt);
- free_percpu(dev->stats64);
+ free_percpu(net->tstats);
free_netdev(net);
}
EXPORT_SYMBOL_GPL(usbnet_disconnect);
@@ -1608,7 +1599,7 @@ static const struct net_device_ops usbnet_netdev_ops = {
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_set_rx_mode = usbnet_set_rx_mode,
.ndo_change_mtu = usbnet_change_mtu,
- .ndo_get_stats64 = usbnet_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
@@ -1671,8 +1662,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->driver_info = info;
dev->driver_name = name;
- dev->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
- if (!dev->stats64)
+ net->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
+ if (!net->tstats)
goto out0;
dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
@@ -1812,7 +1803,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
*/
cancel_work_sync(&dev->kevent);
del_timer_sync(&dev->delay);
- free_percpu(dev->stats64);
+ free_percpu(net->tstats);
out0:
free_netdev(net);
out:
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 2e4f7721f..1f6dfa977 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -65,8 +65,6 @@ struct usbnet {
struct usb_anchor deferred;
struct tasklet_struct bh;
- struct pcpu_sw_netstats __percpu *stats64;
-
struct work_struct kevent;
unsigned long flags;
# define EVENT_TX_HALT 0
@@ -285,7 +283,7 @@ extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags);
extern void usbnet_status_stop(struct usbnet *dev);
extern void usbnet_update_max_qlen(struct usbnet *dev);
-extern void usbnet_get_stats64(struct net_device *dev,
- struct rtnl_link_stats64 *stats);
+
+#define usbnet_get_stats64 dev_get_tstats64
#endif /* __LINUX_USB_USBNET_H */
--
2.29.2
Use netdev->tstats instead of a member of hfi1_ipoib_dev_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 <[email protected]>
---
drivers/infiniband/hw/hfi1/driver.c | 4 +---
drivers/infiniband/hw/hfi1/ipoib.h | 27 -------------------------
drivers/infiniband/hw/hfi1/ipoib_main.c | 15 +++-----------
drivers/infiniband/hw/hfi1/ipoib_tx.c | 2 +-
4 files changed, 5 insertions(+), 43 deletions(-)
diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c
index a40701a6e..0b64aa87a 100644
--- a/drivers/infiniband/hw/hfi1/driver.c
+++ b/drivers/infiniband/hw/hfi1/driver.c
@@ -1686,7 +1686,6 @@ static void hfi1_ipoib_ib_rcv(struct hfi1_packet *packet)
u32 extra_bytes;
u32 tlen, qpnum;
bool do_work, do_cnp;
- struct hfi1_ipoib_dev_priv *priv;
trace_hfi1_rcvhdr(packet);
@@ -1734,8 +1733,7 @@ static void hfi1_ipoib_ib_rcv(struct hfi1_packet *packet)
if (unlikely(!skb))
goto drop;
- priv = hfi1_ipoib_priv(netdev);
- hfi1_ipoib_update_rx_netstats(priv, 1, skb->len);
+ dev_sw_netstats_rx_add(netdev, skb->len);
skb->dev = netdev;
skb->pkt_type = PACKET_HOST;
diff --git a/drivers/infiniband/hw/hfi1/ipoib.h b/drivers/infiniband/hw/hfi1/ipoib.h
index b8c9d0a00..f650cac9d 100644
--- a/drivers/infiniband/hw/hfi1/ipoib.h
+++ b/drivers/infiniband/hw/hfi1/ipoib.h
@@ -110,7 +110,6 @@ struct hfi1_ipoib_dev_priv {
const struct net_device_ops *netdev_ops;
struct rvt_qp *qp;
- struct pcpu_sw_netstats __percpu *netstats;
};
/* hfi1 ipoib rdma netdev's private data structure */
@@ -126,32 +125,6 @@ hfi1_ipoib_priv(const struct net_device *dev)
return &((struct hfi1_ipoib_rdma_netdev *)netdev_priv(dev))->dev_priv;
}
-static inline void
-hfi1_ipoib_update_rx_netstats(struct hfi1_ipoib_dev_priv *priv,
- u64 packets,
- u64 bytes)
-{
- struct pcpu_sw_netstats *netstats = this_cpu_ptr(priv->netstats);
-
- u64_stats_update_begin(&netstats->syncp);
- netstats->rx_packets += packets;
- netstats->rx_bytes += bytes;
- u64_stats_update_end(&netstats->syncp);
-}
-
-static inline void
-hfi1_ipoib_update_tx_netstats(struct hfi1_ipoib_dev_priv *priv,
- u64 packets,
- u64 bytes)
-{
- struct pcpu_sw_netstats *netstats = this_cpu_ptr(priv->netstats);
-
- u64_stats_update_begin(&netstats->syncp);
- netstats->tx_packets += packets;
- netstats->tx_bytes += bytes;
- u64_stats_update_end(&netstats->syncp);
-}
-
int hfi1_ipoib_send_dma(struct net_device *dev,
struct sk_buff *skb,
struct ib_ah *address,
diff --git a/drivers/infiniband/hw/hfi1/ipoib_main.c b/drivers/infiniband/hw/hfi1/ipoib_main.c
index 9f71b9d70..3242290eb 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_main.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_main.c
@@ -21,7 +21,7 @@ static int hfi1_ipoib_dev_init(struct net_device *dev)
struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
int ret;
- priv->netstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
+ dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
ret = priv->netdev_ops->ndo_init(dev);
if (ret)
@@ -93,21 +93,12 @@ static int hfi1_ipoib_dev_stop(struct net_device *dev)
return priv->netdev_ops->ndo_stop(dev);
}
-static void hfi1_ipoib_dev_get_stats64(struct net_device *dev,
- struct rtnl_link_stats64 *storage)
-{
- struct hfi1_ipoib_dev_priv *priv = hfi1_ipoib_priv(dev);
-
- netdev_stats_to_stats64(storage, &dev->stats);
- dev_fetch_sw_netstats(storage, priv->netstats);
-}
-
static const struct net_device_ops hfi1_ipoib_netdev_ops = {
.ndo_init = hfi1_ipoib_dev_init,
.ndo_uninit = hfi1_ipoib_dev_uninit,
.ndo_open = hfi1_ipoib_dev_open,
.ndo_stop = hfi1_ipoib_dev_stop,
- .ndo_get_stats64 = hfi1_ipoib_dev_get_stats64,
+ .ndo_get_stats64 = dev_get_tstats64,
};
static int hfi1_ipoib_send(struct net_device *dev,
@@ -182,7 +173,7 @@ static void hfi1_ipoib_netdev_dtor(struct net_device *dev)
hfi1_ipoib_txreq_deinit(priv);
hfi1_ipoib_rxq_deinit(priv->netdev);
- free_percpu(priv->netstats);
+ free_percpu(dev->tstats);
}
static void hfi1_ipoib_free_rdma_netdev(struct net_device *dev)
diff --git a/drivers/infiniband/hw/hfi1/ipoib_tx.c b/drivers/infiniband/hw/hfi1/ipoib_tx.c
index 9df292b51..edd4eeac8 100644
--- a/drivers/infiniband/hw/hfi1/ipoib_tx.c
+++ b/drivers/infiniband/hw/hfi1/ipoib_tx.c
@@ -121,7 +121,7 @@ static void hfi1_ipoib_free_tx(struct ipoib_txreq *tx, int budget)
struct hfi1_ipoib_dev_priv *priv = tx->priv;
if (likely(!tx->sdma_status)) {
- hfi1_ipoib_update_tx_netstats(priv, 1, tx->skb->len);
+ dev_sw_netstats_tx_add(priv->netdev, 1, tx->skb->len);
} else {
++priv->netdev->stats.tx_errors;
dd_dev_warn(priv->dd,
--
2.29.2
Heiner Kallweit <[email protected]> writes:
> 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 <[email protected]>
Acked-by: Bjørn Mork <[email protected]>
Heiner Kallweit <[email protected]> writes:
> Replace usbnet_get_stats64() with new identical core function
> dev_get_tstats64() in all users and remove usbnet_get_stats64().
>
> Signed-off-by: Heiner Kallweit <[email protected]>
> ---
> drivers/net/usb/aqc111.c | 2 +-
> drivers/net/usb/asix_devices.c | 6 +++---
> drivers/net/usb/ax88172a.c | 2 +-
> drivers/net/usb/ax88179_178a.c | 2 +-
> drivers/net/usb/cdc_mbim.c | 2 +-
> drivers/net/usb/cdc_ncm.c | 2 +-
> drivers/net/usb/dm9601.c | 2 +-
> drivers/net/usb/int51x1.c | 2 +-
> drivers/net/usb/mcs7830.c | 2 +-
> drivers/net/usb/qmi_wwan.c | 2 +-
> drivers/net/usb/rndis_host.c | 2 +-
> drivers/net/usb/sierra_net.c | 2 +-
> drivers/net/usb/smsc75xx.c | 2 +-
> drivers/net/usb/smsc95xx.c | 2 +-
> drivers/net/usb/sr9700.c | 2 +-
> drivers/net/usb/sr9800.c | 2 +-
> drivers/net/wireless/rndis_wlan.c | 2 +-
> include/linux/usb/usbnet.h | 2 --
> 18 files changed, 19 insertions(+), 21 deletions(-)
For the qmi_wwan part:
Acked-by: Bjørn Mork <[email protected]>
On Tue, 10 Nov 2020 20:47:34 +0100 Heiner Kallweit wrote:
> Use netdev->tstats instead of a member of hfi1_ipoib_dev_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 <[email protected]>
RDMA folks, ack for merging via net-next?
Heiner Kallweit <[email protected]> writes:
> Use netdev->tstats instead of a member of qtnf_vif for storing a pointer
> to the per-cpu counters. This allows us to use core functionality for
> statistics handling.
> The driver sets netdev->needs_free_netdev, therefore freeing the per-cpu
> counters at the right point in time is a little bit tricky. Best option
> seems to be to use the ndo_init/ndo_uninit callbacks.
>
> Signed-off-by: Heiner Kallweit <[email protected]>
> ---
> drivers/net/wireless/quantenna/qtnfmac/core.c | 78 ++++---------------
> drivers/net/wireless/quantenna/qtnfmac/core.h | 4 -
> .../quantenna/qtnfmac/pcie/pearl_pcie.c | 4 +-
> .../quantenna/qtnfmac/pcie/topaz_pcie.c | 4 +-
> 4 files changed, 20 insertions(+), 70 deletions(-)
Jakub, feel free to take this to net-next:
Acked-by: Kalle Valo <[email protected]>
But I can also take this to wireless-drivers-next, whichever you prefer.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
On Wed, Nov 11, 2020 at 09:03:55AM -0800, Jakub Kicinski wrote:
> On Tue, 10 Nov 2020 20:47:34 +0100 Heiner Kallweit wrote:
> > Use netdev->tstats instead of a member of hfi1_ipoib_dev_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 <[email protected]>
>
> RDMA folks, ack for merging via net-next?
Yes OK
Ack-by: Jason Gunthorpe <[email protected]>
Jason
Am 12.11.2020 um 14:49 schrieb Jason Gunthorpe:
> On Wed, Nov 11, 2020 at 09:03:55AM -0800, Jakub Kicinski wrote:
>> On Tue, 10 Nov 2020 20:47:34 +0100 Heiner Kallweit wrote:
>>> Use netdev->tstats instead of a member of hfi1_ipoib_dev_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 <[email protected]>
>>
>> RDMA folks, ack for merging via net-next?
>
> Yes OK
>
> Ack-by: Jason Gunthorpe <[email protected]>
>
> Jason
>
Thanks. It just should have been Acked-by, patchwork doesn't understand Ack-by.
On Tue, 10 Nov 2020 20:46:26 +0100 Heiner Kallweit wrote:
> Switch further drivers to core functionality for handling per-cpu
> byte/packet counters.
> All changes are compile-tested only.
Applied, thanks everyone!