linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator
@ 2024-04-09 13:33 Breno Leitao
  2024-04-09 13:33 ` [PATCH net-next 2/2] net: usb: qmi_wwan: Remove generic .ndo_get_stats64 Breno Leitao
  2024-04-12  3:00 ` [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2024-04-09 13:33 UTC (permalink / raw)
  To: kuba, davem, pabeni, edumazet, Bjørn Mork, Oliver Neukum
  Cc: linux-kernel, netdev, open list:USB NETWORKING DRIVERS

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>
---
PS: This was compiled-tested only due to lack of hardware.
---
 drivers/net/usb/qmi_wwan.c | 8 +-------
 drivers/net/usb/usbnet.c   | 1 +
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index e2e181378f41..5528a9c2b9d6 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -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);
 
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index e84efa661589..f3f7f686fe9c 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -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;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH net-next 2/2] net: usb: qmi_wwan: Remove generic .ndo_get_stats64
  2024-04-09 13:33 [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator Breno Leitao
@ 2024-04-09 13:33 ` Breno Leitao
  2024-04-12  3:00 ` [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2024-04-09 13:33 UTC (permalink / raw)
  To: kuba, davem, pabeni, edumazet, Bjørn Mork
  Cc: linux-kernel, netdev, open list:USB NETWORKING DRIVERS

Commit 3e2f544dd8a33 ("net: get stats64 if device if driver is
configured") moved the callback to dev_get_tstats64() to net core, so,
unless the driver is doing some custom stats collection, it does not
need to set .ndo_get_stats64.

Since this driver is now relying in NETDEV_PCPU_STAT_TSTATS, then, it
doesn't need to set the dev_get_tstats64() generic .ndo_get_stats64
function pointer.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
PS: This was compiled-tested only due to lack of hardware.
---
 drivers/net/usb/qmi_wwan.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 5528a9c2b9d6..0e764f09a57d 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -121,7 +121,6 @@ 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 = dev_get_tstats64,
 };
 
 static void qmimux_setup(struct net_device *dev)
@@ -638,7 +637,6 @@ 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	= dev_get_tstats64,
 	.ndo_set_mac_address	= qmi_wwan_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator
  2024-04-09 13:33 [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator Breno Leitao
  2024-04-09 13:33 ` [PATCH net-next 2/2] net: usb: qmi_wwan: Remove generic .ndo_get_stats64 Breno Leitao
@ 2024-04-12  3:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-12  3:00 UTC (permalink / raw)
  To: Breno Leitao
  Cc: kuba, davem, pabeni, edumazet, bjorn, oneukum, linux-kernel,
	netdev, linux-usb

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue,  9 Apr 2024 06:33:05 -0700 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: usb: qmi_wwan: Leverage core stats allocator
    https://git.kernel.org/netdev/net-next/c/8959bf2acfbc
  - [net-next,2/2] net: usb: qmi_wwan: Remove generic .ndo_get_stats64
    https://git.kernel.org/netdev/net-next/c/3cddfeca9f02

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-12  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09 13:33 [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator Breno Leitao
2024-04-09 13:33 ` [PATCH net-next 2/2] net: usb: qmi_wwan: Remove generic .ndo_get_stats64 Breno Leitao
2024-04-12  3:00 ` [PATCH net-next 1/2] net: usb: qmi_wwan: Leverage core stats allocator patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).