mbox series

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

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

Message

Breno Leitao April 22, 2024, 12:38 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:

v7:
	* Document the return value of alloc_netdev_dummy()
v6:
	* No code change. Just added Reviewed-by: and fix a commit message
v5:
	* Added a new patch to fix some typos in the previous code
	* Rebased to net-net/main
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.
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.
v2:
	* Patch 1: Use a pre-defined name ("dummy#") for the dummy
	  net_devices.
	* Patch 2-5: Added users for the new helper.
v1:
	* https://lore.kernel.org/all/20240327200809.512867-1-leitao@debian.org/

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                                | 59 +++++++++++++------
 19 files changed, 129 insertions(+), 53 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 24, 2024, 11:10 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon, 22 Apr 2024 05:38:53 -0700 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v7,01/10] net: core: Fix documentation
    https://git.kernel.org/netdev/net-next/c/c6e7f276841d
  - [net-next,v7,02/10] net: free_netdev: exit earlier if dummy
    https://git.kernel.org/netdev/net-next/c/f8d05679fb3f
  - [net-next,v7,03/10] net: create a dummy net_device allocator
    https://git.kernel.org/netdev/net-next/c/c661050f93d3
  - [net-next,v7,04/10] net: marvell: prestera: allocate dummy net_device dynamically
    https://git.kernel.org/netdev/net-next/c/ec24c06eb312
  - [net-next,v7,05/10] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically
    https://git.kernel.org/netdev/net-next/c/b209bd6d0bff
  - [net-next,v7,06/10] net: ipa: allocate dummy net_device dynamically
    https://git.kernel.org/netdev/net-next/c/1bdab0ee635d
  - [net-next,v7,07/10] net: ibm/emac: allocate dummy net_device dynamically
    https://git.kernel.org/netdev/net-next/c/2eb5e25d8495
  - [net-next,v7,08/10] wifi: qtnfmac: Use netdev dummy allocator helper
    https://git.kernel.org/netdev/net-next/c/4a8b77eff7e5
  - [net-next,v7,09/10] wifi: ath10k: allocate dummy net_device dynamically
    https://git.kernel.org/netdev/net-next/c/57738dab12d9
  - [net-next,v7,10/10] wifi: ath11k: allocate dummy net_device dynamically
    https://git.kernel.org/netdev/net-next/c/bca592ead825

You are awesome, thank you!