Device Registration
Device registration, whose basic model is shown in Figure 8-1(a), does not consist simply of
inserting the net_device structure into the global list
and hash tables introduced in the section "Organization of net_device Structures." It also involves the initialization of
some parameters in the net_device structure, the
generation of a broadcast notification that will inform other kernel components about the
registration, and other tasks. Devices are registered with register_netdev, which is a simple wrapper around register_netdevice. The wrapper mainly takes care of locking and name
completion as described earlier in the section "Allocating net_device Structures." The lock protects the dev_base list of registered devices.
register_netdevice Function
As described in Figure 8-5(a),
register_netdevice starts device registration and
calls net_set_todo, which ultimately asks netdev_run_todo to complete the registration.
Here are the main tasks carried out by register_netdevice:
Initialize some of the
net_device's fields, including the ones used for locking, listed in the section "Locking."When the kernel has support for the Divert feature, allocate a configuration block needed by the feature and link it to
dev->divert. This is taken care of byalloc_divert_blk.If the device driver had initialized
dev->init, execute that function. See the section "Virtual Devices."Assign the device a unique identifier with
dev_new_index. The identifier is generated using a counter that ...
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