Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

NetDev_Start() starts the network interface hardware by initializing the receive and transmit descriptors, enabling the transmitter and receiver and starting and enabling the DMA. Initialization the Rx DMA descriptors list can be done in a sub-function NetDev_RxDescInit(). The memory needed by the descriptors must be reserved by the function NetDev_Init(). Initialization of the Rx descriptor list consist consists of setting the descriptors pointers of the NET_DEV_DATA and fill filling all Receive descriptors with a Receive buffer.

...

You also have to initialize each descriptor. You must initialize descriptor field fields according to the controller documentation. Note that the descriptor must be configured to be owned by the DMA and not the software. Here is the pseudo code of the descriptor ring initialization:

Once the Rx descriptor ring is ready, you have to configure controller register registers 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.

...

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 an Rx ISR occuroccurs, 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 statistics 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.

...

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 some pseudo code of NetDev_Rx():

...