...
The DMA controller is initialized and the hardware is informed of the address of descriptor list.
Reception
When a received frame is processed, the driver gets a pointer to a new data buffer and updates the current descriptor address field. The previous buffer address is passed to the protocol stack for processing. If a buffer pointer cannot be obtained, the existing pointer remains in place and the frame is dropped.
...
Once the Rx descriptor ring is ready, you have to configure controller register to enable the controller reception. Controller's interrupt generation should be enabled for the following events: reception of a packet with and without errors and completed transmission of a packet with and without errors.
What
...
Needs to be
...
Done in the ISR for
...
Reception
NetDev_ISR_Handler()
is the function called by the IF layer when a Ethernet related ISR is generated and handled by the BSP layer. When Rx ISR occur, only NetOS_IF_RxTaskSignal()
has to be called. Nothing has to be done on RxBufDescPtrCur
. The complete receive process is delayed in order to have the fastest ISR handler as possible. If an error occurred on RX, you can increment driver statistic into the ISR handler or into NetDev_Rx()
, it’s up to you to determine which of the cases is best. You must always signal the core that a packet is received using NetOS_IF_RxTaskSignal()
. If you fail to notify the core for each packet, a buffer leak will occur and performance will degrade. NetDev_Rx()
will discard the packet and it will say to the µC/TCP-IP module that the packet is received with an error.
Moving
...
Buffers from the
...
Device to the TCP-IP
...
Stack using DMA
NetDev_Rx()
is called by core once a NetOS_IF_RxTaskSignal()
call has been made to recover the received packet. If data received is valid, this function must replace the buffer of the current descriptor with a free buffer. Also, the current descriptor must be restarted (owned by the DMA) to be able to receive again. RxBufDescPtrCur
must be moved to point on the next descriptor. The sub-function NetDev_RxDescPtrCurInc()
is called to restart the current descriptor and to move the pointer to the next descriptor. If an error has occurred, you have to set data and length pointers to 0 and return an error. If there is no free Rx buffer available, the packet must be discarded by leaving the current data buffer assigned to the DMA, increment the current descriptor and return an error to the µC/TCP-IP module. Here is a pseudo code of NetDev_Rx()
:
...