mbox series

[net-next,v5,00/10] allocate dummy device dynamically

Message ID 20240410131407.3897251-1-leitao@debian.org (mailing list archive)
Headers show
Series allocate dummy device dynamically | expand

Message

Breno Leitao April 10, 2024, 1:13 p.m. UTC
struct net_device shouldn't be embedded into any structure, instead,
the owner should use the private space to embed their state into
net_device.

But, in some cases the net_device is embedded inside the private
structure, which blocks the usage of zero-length arrays inside
net_device.

Create a helper to allocate a dummy device at dynamically runtime, and
move the Ethernet devices to use it, instead of embedding the dummy
device inside the private structure.

This fixes all the network cases plus some wireless drivers.

PS: Due to lack of hardware, unfortunately most these patches are
compiled tested only, except ath11k that was kindly tested by Kalle Valo.

---
Changelog:

v1:
	* https://lore.kernel.org/all/20240327200809.512867-1-leitao@debian.org/

v2:
	* Patch 1: Use a pre-defined name ("dummy#") for the dummy
	  net_devices.
	* Patch 2-5: Added users for the new helper.
v3:
	* Use free_netdev() instead of kfree() as suggested by Jakub.
	* Change the free_netdev() place in ipa driver, as suggested by
	  Alex Elder.
	* Set err in the error path in the Marvell driver, as suggested
	  by Simon Horman.
v4:
	* Added a new patch to add dummy device at free_netdev(), as suggested
	  by Jakub.
	* Added support for some wireless driver.
	* Added some Acked-by and Reviewed-by.
v5:
	* Added a new patch to fix some typos in the previous code,
	  suggested by Ido.
	* Rebased to net-net/main


Breno Leitao (10):
  net: core: Fix documentation
  net: free_netdev: exit earlier if dummy
  net: create a dummy net_device allocator
  net: marvell: prestera: allocate dummy net_device dynamically
  net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically
  net: ipa: allocate dummy net_device dynamically
  net: ibm/emac: allocate dummy net_device dynamically
  wifi: qtnfmac: Use netdev dummy allocator helper
  wifi: ath10k: allocate dummy net_device dynamically
  wifi: ath11k: allocate dummy net_device dynamically

 drivers/net/ethernet/ibm/emac/mal.c           | 14 ++++-
 drivers/net/ethernet/ibm/emac/mal.h           |  2 +-
 .../ethernet/marvell/prestera/prestera_rxtx.c | 15 ++++-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c   | 17 ++++--
 drivers/net/ethernet/mediatek/mtk_eth_soc.h   |  2 +-
 drivers/net/ipa/gsi.c                         | 12 ++--
 drivers/net/ipa/gsi.h                         |  2 +-
 drivers/net/wireless/ath/ath10k/core.c        |  9 ++-
 drivers/net/wireless/ath/ath10k/core.h        |  2 +-
 drivers/net/wireless/ath/ath10k/pci.c         |  2 +-
 drivers/net/wireless/ath/ath10k/sdio.c        |  2 +-
 drivers/net/wireless/ath/ath10k/snoc.c        |  4 +-
 drivers/net/wireless/ath/ath10k/usb.c         |  2 +-
 drivers/net/wireless/ath/ath11k/ahb.c         |  9 ++-
 drivers/net/wireless/ath/ath11k/core.h        |  2 +-
 drivers/net/wireless/ath/ath11k/pcic.c        | 21 +++++--
 .../wireless/quantenna/qtnfmac/pcie/pcie.c    |  3 +-
 include/linux/netdevice.h                     |  3 +
 net/core/dev.c                                | 57 ++++++++++++-------
 19 files changed, 127 insertions(+), 53 deletions(-)

Comments

Kalle Valo April 11, 2024, 8:38 a.m. UTC | #1
Breno Leitao <leitao@debian.org> writes:

> struct net_device shouldn't be embedded into any structure, instead,
> the owner should use the private space to embed their state into
> net_device.
>
> But, in some cases the net_device is embedded inside the private
> structure, which blocks the usage of zero-length arrays inside
> net_device.
>
> Create a helper to allocate a dummy device at dynamically runtime, and
> move the Ethernet devices to use it, instead of embedding the dummy
> device inside the private structure.
>
> This fixes all the network cases plus some wireless drivers.
>
> PS: Due to lack of hardware, unfortunately most these patches are
> compiled tested only, except ath11k that was kindly tested by Kalle Valo.
>
> ---
> Changelog:
>
> v1:
> 	* https://lore.kernel.org/all/20240327200809.512867-1-leitao@debian.org/
>
> v2:
> 	* Patch 1: Use a pre-defined name ("dummy#") for the dummy
> 	  net_devices.
> 	* Patch 2-5: Added users for the new helper.
> v3:
> 	* Use free_netdev() instead of kfree() as suggested by Jakub.
> 	* Change the free_netdev() place in ipa driver, as suggested by
> 	  Alex Elder.
> 	* Set err in the error path in the Marvell driver, as suggested
> 	  by Simon Horman.
> v4:
> 	* Added a new patch to add dummy device at free_netdev(), as suggested
> 	  by Jakub.
> 	* Added support for some wireless driver.
> 	* Added some Acked-by and Reviewed-by.
> v5:
> 	* Added a new patch to fix some typos in the previous code,
> 	  suggested by Ido.
> 	* Rebased to net-net/main

I'm nitpicking here but I prefer to have the changelog in reverse order,
that is v5 first and v1 last. I'm most interested about the changes in
v5, I don't care about v1 at this point. Though I don't know if net
folks have a different prefence, just wanted to mention this.
Jakub Kicinski April 11, 2024, 1:09 p.m. UTC | #2
On Wed, 10 Apr 2024 06:13:41 -0700 Breno Leitao wrote:
>   wifi: ath11k: allocate dummy net_device dynamically

Sorry Breno, I didn't notice earlier, patch 10 didn't make it
to the list. The series wasn't ingested by CI and tested because 
of this. Could you repost?
Breno Leitao April 11, 2024, 1:41 p.m. UTC | #3
On Thu, Apr 11, 2024 at 06:09:26AM -0700, Jakub Kicinski wrote:
> On Wed, 10 Apr 2024 06:13:41 -0700 Breno Leitao wrote:
> >   wifi: ath11k: allocate dummy net_device dynamically
> 
> Sorry Breno, I didn't notice earlier, patch 10 didn't make it
> to the list. The series wasn't ingested by CI and tested because 
> of this. Could you repost?

Thanks for the heads-up. I debugged it and it was my mistake, this is
how I've sent it.

	git send-email patches/v5-000*

I will repost.