April 2012
Intermediate to advanced
352 pages
8h
English
Now that you’re familiar with the if* structures and their management routines, let’s go through an example. The following function, named em_setup_interface and defined in /sys/dev/e1000/if_em.c, sets up em(4)’s ifnet and ifmedia structures. (The em(4) driver is for Intel’s PCI Gigabit Ethernet adapters.)
static int
em_setup_interface(device_t dev, struct adapter *adapter)
{
struct ifnet *ifp;
ifp =
adapter->ifp =
if_alloc(
IFT_ETHER); ...