How is Data packet TX/RX handled?

In a previous article <Network device driver interfaced to a Hardware peripheral>, we saw how a networking device driver which is connected to a peripheral hardware device is instantiated at its lower edge and later the driver creates a net device interface for the Linux system to access. The below image from the article will provide some clarity.

Network device being brought up during initialization

802.11 WiFi cards which are normally PCI/USB/SDIO based perform the same set of operations to initialize the lower hardware interface and the upper netdev interface as shown in the image above.

The mac80211 interface for a softmac driver registers an entry point for tx/rx data and also creates entry points for open/close in struct net_device_ops when a specific driver+mac80211 interface is being brought up.

The below mac80211 code snippet should provide details on the net device callbacks registered.

FIG Reference: Linux mac80211 iface.c

Once a network device is created with a specific name (e.g. wlan0), any user-space application opening a socket to the interface and transmitting a packet to this interface will reach “ieee80211_subif_start_xmit API” via the Linux kernel.

On the receive side, the packet is received from the hardware via DMA operation, the

  1. Hardware will trigger an interrupt to the softmac driver
  2. The softmac driver will process the interrupt via the registered Interrupt Service Routine (ISR)
  3. The softmac driver will queue the packet to its receive queues in the tasklet or workqueue.
  4. The receive buffers are processed by the driver and when handing it up to the TCP stack – netif_rx API is invoked.

Handling Receive packets via NAPI

Comments

  1. Pingback: wpa_supplicant and hostapd configuration files | Hitch Hiker's Guide to Learning

Leave a Reply

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