Network Packet Reception Overview
This section is a quick overview of the mechanism put in place to handle the reception of network packets within the device driver, the μC/TCP-IP module and the OS.
A device’s receive interrupt signals the μC/TCP-IP module for each packet received so that each receive is queued and later handled by μC/TCP-IP’s network interface Receive task. Processing devices’ received packets is deferred to the network interface Receive task to keep device ISRs as short as possible and make the driver easier to write.
(1) The μC/TCP-IP’s network interface Receive task calls NetOS_IF_RxTaskWait()
to wait for device receive packets to arrive by waiting (ideally without timeout) for the Device Rx Signal to be signaled.
(2) When a device packet is received, the device generates a receive interrupt which calls the device’s BSP-level ISR handler.
(3) The device’s BSP-level ISR handler determines which network interface number the specific device’s interrupt is signaling and then calls NetIF_ISR_Handler()
to handle the device’s receive interrupt.
(4) NetIF_Ether_ISR_Handler()
and NetDev_ISR_Handler()
) (the network interface and device ISR handlers) call NetOS_IF_RxTaskSignal()
to signal the Device Rx Signal for each received packet.
(5) μC/TCP-IP’s network interface Receive task’s call to NetOS_IF_RxTaskWait()
is made ready for each received packet that signals the Device Rx Signal. The network interface Receive task then calls the specific network interface and device receive handler functions to retrieve the packet from the device. If the packet was not already received directly into a network buffer (e.g., via DMA), it is copied into a network buffer data. The network buffer is then de-multiplexed to higher-layer protocol(s) for further processing.