Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


❑ dev_addrstores the hardware address of the device (e.g., the MAC address for Ethernet cards),
andaddr_lenspecifies the address length.broadcastis the broadcast address used to send mes-
sages to attached stations.
❑ ip_ptr,ip6_ptr,atalk_ptr, and so on are pointers to protocol-specific data not manipulated by
the generic code.

Several of these pointers may have a non-nullvalue because a network device can
be used with several network protocols at the same time.

Most elements of thenet_devicestructure are function pointers to perform network card-typical tasks.
Although the implementation differs from adapter to adapter, the call syntax (and the task performed) is
always the same. These elements therefore represent the abstraction interface to the next protocol level.
They enable the kernel to address all network cardsby means of a uniform set of functions, while the
low-level drivers are responsible for implementing the details.

❑ openandstopinitialize and terminate network cards. These actions are usually triggered from
outside the kernel by calling theifconfigcommand.openis responsible for initializing the
hardware registers and registering system resources such as interrupts, DMA, IO ports, and so
on.closereleases these resources and stops transmission.
❑ hard_start_xmitis called to remove finished packets from the wait queue and send them.
❑ header_opscontains a pointer to a structure that provides more function pointers to operations
on the hardware header.
Most important areheader_ops->create, which creates a new, andheader_ops->parse,toana-
lyze a given hardware header.
❑ get_statsqueries statistical data that are returned in a structure of typenet_device_stats.
This structure consists of more than 20 members, all of which are numeric values to indicate,
for example, the number of packets sent, received, with errors, discarded, and so on. (Lovers of
statistics can query these data usingifconfigandnetstat -i.)
Because thenet_devicestructure provides no specific field to store thenet_device_stats
object, the individual device drivers must keep it in their private data area.
❑ tx_timeoutis called to resolve the problem of packet transmission failure.
❑ do_ioctlforwards device-specific commands to the network card.
❑ nd_detis a pointer to the networking namespace (represented by an instance ofstruct net)to
which the device belongs.

Some functions are not normally implemented by driver-specific code but are identical for all Ethernet
cards. The kernel therefore makes default implementations available (innet/ethernet/net.c).

❑ change_mtuis implemented byeth_change_mtuand modifies themaximum transfer unit.The
default for Ethernet is 1.5 KiB, other transmission techniques have different defaults. In some
situations, it can be useful to increase or decrease this value. However, many cards do not allow
this and support only the default hardware setting.
Free download pdf