Example of PCI NIC Driver Registration
Let's use the Intel PRO/100 Ethernet driver in drivers/net/e100.c to illustrate a driver registration:
#define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) {\
PCI_VENDOR_ID_INTEL, device_id, PCI_ANY_ID, PCI_ANY_ID, \
PCI_CLASS_NETWORK_ETHERNET << 8, 0xFFFF00, ich }
static struct pci_device_id e100_id_table[] = {
INTEL_8255X_ETHERNET_DEVICE(0x1029, 0),
INTEL_8255X_ETHERNET_DEVICE(0x1030, 0),
...
}We saw in the section "Registering a PCI
NIC Device Driver" that a PCI NIC device driver registers with the kernel a
vector of pci_device_id structures that lists the
devices it can handle. e100_id_table is, for instance,
the structure used by the e100.c driver. Note that:
The first field (which corresponds to
vendorin the structure's definition) has the fixed value ofPCI_VENDOR_ID_INTELwhich is initialized to the vendor ID assigned to Intel.[*]The third and fourth fields (
subvendorandsubdevice) are often initialized to the wildcard valuePCI_ANY_ID, because the first two fields (vendoranddevice) are sufficient to identify the devices.Many devices use the macro
_ _devinitdataon the table of devices to mark it as initialization data, althoughe100_id_tabledoes not. You will see in Chapter 7 exactly what that macro is used for.
The module is initialized by e100_init_module, as
specified by the module_init macro.[*] When the function is executed by the kernel at boot time or at module loading
time, it calls pci_module_init, the function introduced ...
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