Commit af0c351c authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski

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

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: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 45fc3fd4
...@@ -304,7 +304,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev) ...@@ -304,7 +304,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev)
*/ */
void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) 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; unsigned long flags;
int status; int status;
...@@ -980,15 +980,6 @@ int usbnet_set_link_ksettings(struct net_device *net, ...@@ -980,15 +980,6 @@ int usbnet_set_link_ksettings(struct net_device *net,
} }
EXPORT_SYMBOL_GPL(usbnet_set_link_ksettings); 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) u32 usbnet_get_link (struct net_device *net)
{ {
struct usbnet *dev = netdev_priv(net); struct usbnet *dev = netdev_priv(net);
...@@ -1220,7 +1211,7 @@ static void tx_complete (struct urb *urb) ...@@ -1220,7 +1211,7 @@ static void tx_complete (struct urb *urb)
struct usbnet *dev = entry->dev; struct usbnet *dev = entry->dev;
if (urb->status == 0) { 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; unsigned long flags;
flags = u64_stats_update_begin_irqsave(&stats64->syncp); flags = u64_stats_update_begin_irqsave(&stats64->syncp);
...@@ -1596,7 +1587,7 @@ void usbnet_disconnect (struct usb_interface *intf) ...@@ -1596,7 +1587,7 @@ void usbnet_disconnect (struct usb_interface *intf)
usb_free_urb(dev->interrupt); usb_free_urb(dev->interrupt);
kfree(dev->padding_pkt); kfree(dev->padding_pkt);
free_percpu(dev->stats64); free_percpu(net->tstats);
free_netdev(net); free_netdev(net);
} }
EXPORT_SYMBOL_GPL(usbnet_disconnect); EXPORT_SYMBOL_GPL(usbnet_disconnect);
...@@ -1608,7 +1599,7 @@ static const struct net_device_ops usbnet_netdev_ops = { ...@@ -1608,7 +1599,7 @@ static const struct net_device_ops usbnet_netdev_ops = {
.ndo_tx_timeout = usbnet_tx_timeout, .ndo_tx_timeout = usbnet_tx_timeout,
.ndo_set_rx_mode = usbnet_set_rx_mode, .ndo_set_rx_mode = usbnet_set_rx_mode,
.ndo_change_mtu = usbnet_change_mtu, .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_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
}; };
...@@ -1671,8 +1662,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) ...@@ -1671,8 +1662,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->driver_info = info; dev->driver_info = info;
dev->driver_name = name; dev->driver_name = name;
dev->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); net->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
if (!dev->stats64) if (!net->tstats)
goto out0; goto out0;
dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV 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) ...@@ -1812,7 +1803,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
*/ */
cancel_work_sync(&dev->kevent); cancel_work_sync(&dev->kevent);
del_timer_sync(&dev->delay); del_timer_sync(&dev->delay);
free_percpu(dev->stats64); free_percpu(net->tstats);
out0: out0:
free_netdev(net); free_netdev(net);
out: out:
......
...@@ -65,8 +65,6 @@ struct usbnet { ...@@ -65,8 +65,6 @@ struct usbnet {
struct usb_anchor deferred; struct usb_anchor deferred;
struct tasklet_struct bh; struct tasklet_struct bh;
struct pcpu_sw_netstats __percpu *stats64;
struct work_struct kevent; struct work_struct kevent;
unsigned long flags; unsigned long flags;
# define EVENT_TX_HALT 0 # define EVENT_TX_HALT 0
...@@ -285,7 +283,7 @@ extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags); ...@@ -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_status_stop(struct usbnet *dev);
extern void usbnet_update_max_qlen(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 */ #endif /* __LINUX_USB_USBNET_H */
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