I like the mutex idea, but I feel like there’s a performance impact when you are sending a lot of packets at the same time. It seems like this problem goes away if you increase the number of descriptors, which tells me that you can send multiple packets at the same time.
Here’s the code though, any changes that I made I try to put a “//!!!” in-line comment. FreeRTOS_Plus Portable.zip (25.3 KB)
That is an interesting solution, it also works for me. It is 3 percent faster than my solution with the extra mutex.
It looks like a silicon problem: as soon as the CPU fills all transmission descriptors , the peripheral “forgets” to call the transmit-complete-interrupt GMAC_ISR_TCOMP.
Solution:
When there are GMAC_TX_BUFFERS descriptors, we will make sure that there is always one descriptor free. That seems to do the trick.
The counting semaphore xTXDescriptorSemaphore will have a maximum count of GMAC_TX_BUFFERS-1.
While testing I saw that sometimes 2 TX descriptors were occupied, and both transmissions were completed with a GMAC_ISR_TCOMP interrupt.
I tried the latest code from your branch and I wasn’t able to break it.
Just a small bug/suggestion. Inside xNetworkInterfaceOutput() right after gmac_dev_write() gets called there is a configASSERT(). The bug is that there is a semicolon missing. I have never hit this assertion, but I was wondering if it’s even a good idea to have an assertion right there. I was thinking that it might be better to increment some (new?) member in the STransmitStats struct for diagnosis, release the semaphore, do any more clean-up work, and keep on chugging? The packet will get lost but the processor won’t hang. Thoughts?