User Tools

Site Tools


This is an old revision of the document!


The various forms of allocating a netdevice.

netdev private data

From netdevice.h, private data is stored (aligned) after the end of the structure:

static inline void *netdev_priv(const struct net_device *dev)
	return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
#define	NETDEV_ALIGN		32

The variations of allocating net devices


The base allocation routine from net/core/dev.c:

struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
				    unsigned char name_assign_type,
				    void (*setup)(struct net_device *),
				    unsigned int txqs, unsigned int rxqs);


struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
				      unsigned int rxqs)
	return alloc_netdev_mqs(sizeof_priv, "eth%d", NET_NAME_UNKNOWN,
				ether_setup, txqs, rxqs);
alloc_netdev_etherdev.1535440273.txt.gz · Last modified: 2018/08/28 07:11 by rpjday