[PATCH net-next v3 1/5] net: create a dummy net_device allocator

Breno Leitao leitao at debian.org
Thu Apr 4 12:03:36 PDT 2024


Hello Alexander,

On Thu, Apr 04, 2024 at 06:40:33PM +0200, Alexander Lobakin wrote:
> > @@ -11063,6 +11070,17 @@ void free_netdev(struct net_device *dev)
> >  }
> >  EXPORT_SYMBOL(free_netdev);
> >  
> > +/**
> > + * alloc_netdev_dummy - Allocate and initialize a dummy net device.
> > + * @sizeof_priv: size of private data to allocate space for
> > + */
> > +struct net_device *alloc_netdev_dummy(int sizeof_priv)
> 
> Repeating my question from the previous thread: I see that in your
> series you always pass 0 as @sizeof_priv, does it make sense to have
> this argument or we can just pass 0 here to alloc_netdev() unconditionally?
> Drivers that have &net_device embedded can't have any private data there
> anyway.

Sorry, I answered you this question in the previous thread, and gave you an
example why we need the @sizeof_priv.

	https://lore.kernel.org/all/ZgWrcvKyAzDvl%2Fjn@gmail.com/

I didn't see any reply from you, so, I suppose you were OK with it, but
maybe you missed it?!

Anyway, let me paste what I've sent there here, so, we can continue the
discussion in this thread, which might make the reviewing process here.

This is what I wrote in the thread/message above:

  We need to have this private size for cases where we need to get the
pointer to their private structure given the dummy device.  In the
embedded case you can use container_of(), but, with a pointer to
net_device, that is not the case anymore, and we should use the dummy private
data pointer back to the private data.

For instance, see the example of iwlwifi:
https://lore.kernel.org/all/20240307174843.1719130-1-leitao@debian.org/



More information about the linux-arm-kernel mailing list