]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: usb: qmi_wwan: Leverage core stats allocator
authorBreno Leitao <leitao@debian.org>
Tue, 9 Apr 2024 13:33:05 +0000 (06:33 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 12 Apr 2024 02:45:53 +0000 (19:45 -0700)
With commit 34d21de99cea9 ("net: Move {l,t,d}stats allocation to core and
convert veth & vrf"), stats allocation could be done on net core
instead of in this driver.

With this new approach, the driver doesn't have to bother with error
handling (allocation failure checking, making sure free happens in the
right spot, etc). This is core responsibility now.

Remove the allocation in the qmi_wwan driver and leverage the network
core allocation instead.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20240409133307.2058099-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/usb/qmi_wwan.c
drivers/net/usb/usbnet.c

index e2e181378f4124c64b1d02bbe910f6209b57a356..5528a9c2b9d6ebd2f41e1a8e0e64952e3d7c98bc 100644 (file)
@@ -133,6 +133,7 @@ static void qmimux_setup(struct net_device *dev)
        dev->flags           = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
        dev->netdev_ops      = &qmimux_netdev_ops;
        dev->mtu             = 1500;
+       dev->pcpu_stat_type  = NETDEV_PCPU_STAT_TSTATS;
        dev->needs_free_netdev = true;
 }
 
@@ -257,12 +258,6 @@ static int qmimux_register_device(struct net_device *real_dev, u8 mux_id)
        priv->mux_id = mux_id;
        priv->real_dev = real_dev;
 
-       new_dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
-       if (!new_dev->tstats) {
-               err = -ENOBUFS;
-               goto out_free_newdev;
-       }
-
        new_dev->sysfs_groups[0] = &qmi_wwan_sysfs_qmimux_attr_group;
 
        err = register_netdevice(new_dev);
@@ -295,7 +290,6 @@ 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(dev->tstats);
        netdev_upper_dev_unlink(real_dev, dev);
        unregister_netdevice_queue(dev, head);
 
index e84efa661589cad5d79273a143951b8fee008180..f3f7f686fe9ce04fe998a44664d878fe6e51ae7c 100644 (file)
@@ -1733,6 +1733,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
        dev->hard_mtu = net->mtu + net->hard_header_len;
        net->min_mtu = 0;
        net->max_mtu = ETH_MAX_MTU;
+       net->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
 
        net->netdev_ops = &usbnet_netdev_ops;
        net->watchdog_timeo = TX_TIMEOUT_JIFFIES;