Ethernet (ETH): media access control (MAC) with DMA controller
RM0090
1172/1731
DocID018909 Rev 11
Receive descriptor acquisition
The receive engine always attempts to acquire an extra descriptor in anticipation of an
incoming frame. Descriptor acquisition is attempted if any of the following conditions is/are
satisfied:
•
The receive Start/Stop bit (ETH_DMAOMR register[1]) has been set immediately after
the DMA has been placed in the Run state.
•
The data buffer of the current descriptor is full before the end of the frame currently
being transferred
•
The controller has completed frame reception, but the current receive descriptor has
not yet been closed.
•
The receive process has been suspended because of a CPU-owned buffer
(RDES0[31] = 0) and a new frame is received.
•
A Receive poll demand has been issued.
Receive frame processing
The MAC transfers the received frames to the STM32F4xx memory only when the frame
passes the address filter and the frame size is greater than or equal to the configurable
threshold bytes set for the Receive FIFO, or when the complete frame is written to the FIFO
in Store-and-forward mode. If the frame fails the address filtering, it is dropped in the MAC
block itself (unless Receive All ETH_MACFFR [31] bit is set). Frames that are shorter than
64 bytes, because of collision or premature termination, can be purged from the Receive
FIFO. After 64 (configurable threshold) bytes have been received, the DMA block begins
transferring the frame data to the receive buffer pointed to by the current descriptor. The
DMA sets the first descriptor (RDES0[9]) after the DMA AHB Interface becomes ready to
receive a data transfer (if DMA is not fetching transmit data from the memory), to delimit the
frame. The descriptors are released when the OWN (RDES0[31]) bit is reset to 0, either as
the data buffer fills up or as the last segment of the frame is transferred to the receive buffer.
If the frame is contained in a single descriptor, both the last descriptor (RDES0[8]) and first
descriptor (RDES0[9]) bits are set. The DMA fetches the next descriptor, sets the last
descriptor (RDES0[8]) bit, and releases the RDES0 status bits in the previous frame
descriptor. Then the DMA sets the receive interrupt bit (ETH_DMASR register [6]). The
same process repeats unless the DMA encounters a descriptor flagged as being owned by
the CPU. If this occurs, the receive process sets the receive buffer unavailable bit
(ETH_DMASR register[7]) and then enters the Suspend state. The position in the receive
list is retained.
Receive process suspended
If a new receive frame arrives while the receive process is in Suspend state, the DMA re-
fetches the current descriptor in the STM32F4xx memory. If the descriptor is now owned by
the DMA, the receive process re-enters the Run state and starts frame reception. If the
descriptor is still owned by the host, by default, the DMA discards the current frame at the
top of the Rx FIFO and increments the missed frame counter. If more than one frame is
stored in the Rx FIFO, the process repeats. The discarding or flushing of the frame at the
top of the Rx FIFO can be avoided by setting the DMA Operation mode register bit 24
(DFRF). In such conditions, the receive process sets the receive buffer unavailable status
bit and returns to the Suspend state.