Basic Goals of NIC Initialization
Each network device is represented in the Linux
kernel by an instance of the net_device data structure.
In Chapter 8, you will see how net_device data structures are allocated and how their fields
are initialized, partly by the device driver and partly by core kernel routines. In this
chapter, we focus on how device drivers allocate the resources needed to establish
device/kernel communication, such as:
- IRQ line
As you will see in the section "Interaction Between Devices and Kernel," NICs need to be assigned an IRQ and to use it to call for the kernel's attention when needed. Virtual devices, however, do not need to be assigned an IRQ: the loopback device is an example because its activity is totally internal (see the later section "Virtual Devices").
The two functions used to request and release IRQ lines are introduced in the later section "Hardware Interrupts." As you will see in the later section "Tuning via /proc Filesystem," the /proc/interrupts file can be used to view the status of the current assignments.
- I/O ports and memory registration
It is common for a driver to map an area of its device's memory (its configuration registers, for example) into the system memory so that read/write operations by the driver will be made on system memory addresses directly; this can simplify the code. I/O ports and memory are registered and released with
request_regionandrelease_region, respectively.
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