Understanding network device drivers in the Linux Kernel

A network device driver interfaces with a hardware to transmit and receive network protocol. it provides a means for upper layer protocols to be able to communicate with hardware devices and to send/receive information with remote systems. In some unique cases, a network device driver might not interface with a network hardware device but be a virtual device. an example of this is the loopback interface in linux.

A network device file is not seen in /dev folder. The list of network interfaces can be seen in /proc/net/dev ouput. It is provided below

/proc/net/devices output

a typcial network device driver would need to register to the kernel via net_device structure via “register_netdev” API. The net_device structure is a very large structure and contains many parameters which can be configured for the network connection if desired. The interested reader can refer the net_device_ops structure in /linux/netdevice.h.

In the above structure, a few members need to be mandatorily implemented and they are callbacks for open/close/xmit/uninit in the net_device_ops structure which is a member of the net_device structure. They are as shown below from a snippet taken from

A sample network driver code is available in “Linux Device Drivers – third edition by Jonathan corbet/Alessandro Rubini and Greg Kroah-Hartman”. The example is a superb example for a sample Linux network driver and the interested is nudged to read that chapter in the book.

Drivers for PCI BUS based peripherals

Comments

  1. Pingback: Platform device driver code example | Hitch Hiker's Guide to Learning

  2. Pingback: Network device driver interfaced to a Hardware peripheral | Hitch Hiker's Guide to Learning

Leave a Reply

Your email address will not be published. Required fields are marked *