net: thunderx: Unembed netdev structure
authorBreno Leitao <leitao@debian.org>
Wed, 26 Jun 2024 17:35:02 +0000 (10:35 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 27 Jun 2024 23:55:34 +0000 (16:55 -0700)
commit94833addfaba89d12e5dbd82e350a692c00648ab
tree9fcd0195e1b25e4ca5f74663e5ac534f5debb45d
parent2d5f6801db8ec0ce97bc520ecd51a7be06a35042
net: thunderx: Unembed netdev structure

Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].

Un-embed the net_devices from struct lmac by converting them
into pointers, and allocating them dynamically. Use the leverage
alloc_netdev() to allocate the net_device object at
bgx_lmac_enable().

The free of the device occurs at bgx_lmac_disable().

 Do not free_netdevice() if bgx_lmac_enable() fails after lmac->netdev
is allocated, since bgx_lmac_disable() is called if bgx_lmac_enable()
fails, and lmac->netdev will be freed there (similarly to lmac->dmacs).

Link: https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20240626173503.87636-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cavium/thunder/thunder_bgx.c