Allocating net_device Structures
Network devices are defined with net_device structures. Because they are usually named dev in the kernel code, I use that name frequently in this
chapter for a net_device. These data structures are
allocated with alloc_netdev, defined in net/core/dev.c, which requires three input parameters:
- Size of private data structure
We will see in the section "Organization of net_device Structures" that the
net_devicedata structure can be extended by device drivers with a private data block to store the driver's parameters. This parameter specifies the size of the block.- Device name
This may be a partial name that the kernel will complete through some scheme that ensures unique device names.
- Setup routine
This routine is used to initialize a portion of the
net_device's fields. See the sections "Device Initialization" and "Device Type Initialization: xxx_setup Functions" for more details.
The return value is a pointer to the net_device
structure allocated, or NULL in case of errors.
Every device is assigned a name that depends on the device type and that, to be unique, contains a number that is assigned sequentially as devices of the same type are registered. Ethernet devices, for instance, are called eth0, eth1, and so on. A single device may be called with different names depending on the order with which the devices are registered. For instance, if you had two cards handled by two different modules, the names of the devices would depend on the order in which ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access