simple examples of how to

Wednesday, October 5, 2011

[Linux Device Driver] Good hints to analyze linux networking driver source code

There are several mandatory points that all networking drivers should implement.

Lookup hints: net_device_ops, dev_queue_xmit, netif_rx, napi_gro_receive, netif_napi_add, request_irq, open_softirq, tasklet_init, request_firmware

Those are the interfacing parts to the linux networking kernel and should be used or implemented in the drivers

for instance, net_device_ops->ndo_xmit_start is the callback function called when kernel wants to send a packet.

netif_rx or napi_gro_receive is the function that takes a skb (or skbs) that are sent to the upper layer (host).

dev_queue_xmit is for forwarding the packets at the L2 (such as L2 switching)

netif_napi_add registers napi callback for polling the device receive

request_irq takes a function pointer for interrupt handler: that is the one that called whenever a packet is delivered to the device

open_softirq and tasklet_init are starting points of bottom-half. Bottom-half is for processing heavy load part of ISR (interrupt service routine). Top-half (fast and light) and bottom-half (slow and heavy).

If driver uses request_firmware, it means that this driver loads the firmware to the micro-controller in the device.

No comments:

Post a Comment