I'm trying to solve a problem with an embedded application using the DP83816 Ethernet controller. The transmit state machine sometimes goes idle even though there are still unsent descriptors in the ring (with the OWN bit set).
My question is about the behavior of the transmit state machine when setting the "TXE" (Transmit Enable) bit in the Command Register. The datasheet has this statement.
"When set to a 1, and the transmit state machine is idle, then the transmit state machine becomes active.
This bit will read back as a 1 whenever the transmit state machine is active. After initial power-up,
software must insure that the transmitter has completely reset before setting this bit"
That implies the TXE bit is ignored if the transmit state machine is not idle. The problem is that software can set the "OWN" bit in a descriptor just after the state machine has read the descriptor. In that case the transmitter is going to transition to the idle state. When the software sets the "OWN" bit in the descriptor and then sets "TXE" in the Command Register, the state machine goes idle instead of re-reading the descriptor. I think that "TXE" is being ignored because the state machine has not yet transitioned to the idle state. I'm trying to determine if that is normal behavior for the chip or I am having an unusual problem.
The transmitter stops and a "TXIDLE" interrupt occurs. The software can restart the transmitter but this introduces a delay before the frame is transmitted. If software is polling rather than using interrupts the delay can be considerable depending on the frequency that the software polls the interrupt status. Another possible solution that I have not tried is adding a delay between when the software sets the "OWN" bit in the descriptor and the software sets the "TXE" bit. The delay would have to be long enough for the state machine to read the descriptor and stop completely. I avoided that solution to the problem since the delays for the state transitions are not documented. Also, the time required for the DMA to read the descriptor is difficult to predict.
I examined the Linux driver for the DP83816 and it simply adds an item to the ring, sets the "OWN" bit and then sets the "TXE" bit in the Command Register. There is no handler for the "TXIDLE" interrupt. I don't see how the driver avoids this problem. That makes me unsure if I am seeing abnormal behavior from the chip in my application.
If anyone can clarify the expected behavior of the chip or how to avoid this problem I will appreciate it.