xmos / lib_ethernet

Ethernet MAC library
Other
3 stars 15 forks source link

lib_ethernet with RGMII interface causes random sending delays #51

Open aritec opened 4 months ago

aritec commented 4 months ago

Using lib_ethernet with RGMII interface causes random sending delays up to 21s. The reason for this is on the rgmii_10_100_master_tx_pins task:

int word_count = byte_count >> 2;
tail_byte_count = byte_count & 3;  

// Ensure that the interframe gap is respected
tmr when timerafter(ifg_time) :> ifg_time;

// Send the preamble
{tmp1, tmp2} = zip2(0x55555555, 0x55555555);`

ifg_time is calculated at the end of the last sent buffer. If there is a idle time between buffers for more than 21 seconds, the timerafter(ifg_time) adds another (up to 21 seconds) delay before handling the buffer! tmr is a 2^32 bit 100MHz counter but timerafter() can only handle delays up to 2^31 ticks. Longer delays are handelt after a "rollover" of 42 seconds.

See: https://www.xcore.com/viewtopic.php?t=8771

ed-xmos commented 4 weeks ago

Thanks for logging this and providing a helpful amount of detail. I can see how the timer wrap behaviour would cause this issue. We're currently updating the library over the next few weeks and will look into this. It will need some external counter to monitor time greater than the timer period.

It seems out other MAC implementations might have the same issue so glad you reported this.