Forum Discussion
Altera_Forum
Honored Contributor
13 years agoStephan,
This is interesting. I see how you're right, but I also think there is a change that does not increase latency. The reason it was kept so short is that our system requires as close to 0 latency as possible. I think the root problem is the location of this line:
// decrement packet counter
--tse_info->mRxCount;
I believe the following also solves the problem since the packet count (which tells us if there is a free space) is decremented last:
// start the critical section by disabling IRQs
const alt_irq_context cpu_sr;
// assign current packet from lwIP packet buffer as the new data
*data = tse_info->mRxBuffer;
// assign next packet instead and move forward in buffer
tse_info->mRxBuffer = (void*)next_packet;
if (++tse_info->mRxIndex >= TSE_RX_BUFFER)
{
tse_info->mRxIndex = UINT32_L(0);
}
cpu_sr = alt_irq_disable_all();
// decrement packet counter
--tse_info->mRxCount;
// stop the critical section by enabling IRQs
alt_irq_enable_all(cpu_sr);
This also could make the second change uneccessary since the count doesn't show a free slot until the pbuf pointer has replaced the previous one. Good catch. We, as well might be the case with most users, don't load the system until the buffers are full. We have enough memory that this array is quite large. Bill