Bingo, two frames sent, in the order you expect and you are still in sync with the FEC. It should be obvious that the BD ring must only be modified when interrupts are disabled (this is a critical section).
Does this help? If not I will happily expand on this.
Cheers,
Paul.
Message Edited by Jon Harris on 2007-04-1701:56 PM
Hi Paul,
My application just does UDP (and ICMP and ARP), so I guess you would say it is a minimalist stack. No TCP/IP and we don't have a real RTOS either.
I guess the main issue here is that we don't have the "two levels" you are talking about. You talk about allocating a frame buffer and getting a buffer descriptor. For me, those are the same thing. I allocate a buffer descriptor, which includes a pointer to a frame buffer, so I have a place to build my outgoing packet data. This is all based on the example code for the 5272 (see http://www.freescale.com/files/soft_dev_tools/software/app_software/code_examples/MCF5272SC.zip).
When I declare the buffer descriptor structure, I also declare 8 data buffers and map the pointers in the BD table to the buffers. From then on, the pointers in the BD table don't change, (except in the case of an outgoing ARP, in which 2 packets are swapped).
It sounds like you are advocating decoupling the data buffers from the buffer descriptors. So when I would allocate a buffer, I would grab a 1600 byte buffer, fill it. When I was finally ready to send it, I would allocate a new buffer descriptor and change its pointer to point to the buffer I just filled. Right?
This would be a fairly significant departure from the example code, but not unmanageable. It just seems odd to me that the "official" example code would be written as it was. Or maybe it was assuming the application code would be disabling interrupts, etc. to prevent the issues we've been discussing.
Thanks again for your detailed and clearly written reply!
-Jon
I assume the example must work, but only because it is written to make every tx happen in a particular order so that the app can keep track of the BD ring next pointer state.
For anything more complex, like only ARPing when you need to know an address, you will need to treat the frame buffers (the data element in the buffer descriptor) separately from the buffer descriptors.