analysis of the freeze problem
I have tested the driver with both a DP83847 PHY and DP83848 PHY and I have found a bug causing the program to freeze. I have tested it with the lwip web server demo, using lwip-0.7.1.
The way to make the program freeze is to ping it while repeatedly requesting a web page from it (e.g. using a while loop with curl in cygwin). In less than a minute, the program will stop responding to ping.
I have done some analysis and come to the conclusion that it has something to do with interrupts. alt_avalon_opencores_mac_irq() handles interrupts of source RXE and BUSY, but ignores TXE interrupts.
When the program is stressed, it receives a TXE interrupt, which is not cleared. Since it is not cleared, the MAC component seems to issue another interrupt and we have starvation.
I tried to disable TXE interrupts in g_int_mask_contents, which improved the situation. The program no longer freezes, but after a while (sometimes almost 30 minutes), the program stops responding to pings and http requests. It still enters the opencores_ethernet_mac_output() function (which I am able to see in printf's I have inserted), but no response is sent to the pinging host.
Restarting the program does not help, I must reset the FPGA.
My guess is that the MAC component gets incapable of transmitting since its transmit buffers are filled with erroneous TX data.
Does anybody have any pointers to how to properly handle the TXE interrupts, equivalent of how the RXE interrutps are handled.