User Tools

Site Tools


alloc_netdev_etherdev

This is an old revision of the document!


Overview

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

alloc_netdev_mqs

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);

More

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