-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam0_eth: wait until the current tx buffer is no longer in use #20534
base: master
Are you sure you want to change the base?
Conversation
@@ -185,6 +185,7 @@ static void _init_desc_buf(void) | |||
/* Initialize TX buffer descriptors */ | |||
for (i=0; i < ETH_TX_BUFFER_COUNT; i++) { | |||
tx_desc[i].address = (uint32_t) tx_buf[i]; | |||
tx_desc[i].status = DESC_TX_STATUS_USED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why setting TX buffers to one here ? This is suppose to be done by the IP. Software should only clears this bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bit gets set by the hardware when it's done with the buffer.
So this will mark all buffers as unused to the driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But GMAC IP will not find an available buffer when it want to send data if they are all marked as used already.
GMAC IP is supposed to take an unused buffer (mark == 0) then take it (mark it to one to tell software this buffer is being used)
This is not software job to set it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bit is set to 0 before starting the transmission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I missed the inversion in the if statement for the thread_yield()
That's a bit weird but it makes sense.
So do we want really want to block this or drop the new frames (like this is the case for RX) ?
@benpicco could you describe a bit more your setup ? |
Huh, my setup is just like that. When I send a 16384 byte UDP packet on |
On my side with same54_xpro (lastest master) with
With your linux app:
Am I missing something ? |
Same thing if I do not use fe80:: addr
|
Huh that's odd - what does this print for you? void cpu_print_info(void)
{
const char *cpu[] = {
"?",
"?",
"?",
"?",
"?",
"?",
"M4F",
"?",
};
const char *series[] = {
"?",
"E51",
"E52",
"E53",
"E54",
"?",
"D51",
};
printf("CPU: Cortex-%s\n", cpu[DSU->DID.bit.PROCESSOR]);
printf("Series: SAM %s\n", series[DSU->DID.bit.SERIES]);
printf("Die: %x\n", DSU->DID.bit.DIE);
printf("Revision: %c\n", 'A' + DSU->DID.bit.REVISION);
} |
On my
|
I'm on Revision D 🤯 |
Usually, hardware works better on later revision :D |
Contribution description
When many (>4) packets are sent in rapid succession, the 5th packet will overwrite the first packet in the transmit buffer before it can be sent out.
This happens e.g. when sending large (> 4500 byte) fragmented packets.
As a solution, always set the USED bit:
This however is an incomplete fix: We clear the bit on each frame to be sent, if we sent the fifth frame before any of the frames has been sent, we still overwrite the first frame.
Strangely this instead disrupts transmission of non-fragmented packets afterwards, they are stuck in the tx queue.
Testing procedure
UDP Command
Compile Flags
Receiver App (Linux)
normal operation before fragmented packet
fragmented packet is transmitted
sending is disrupted afterwards
This is still an improvement over
master
where the fragmented packet is never received on the destination.Issues/PRs references