This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SRIO RX Buffer allocate problem

Other Parts Discussed in Thread: TMS320C6678, SYSBIOS

Hi,

I'm working on a project  where a tms320c6678 are used to communicate with a xilinx FPGA through SRIO.

On the DSP side, i tried to initiate a NREAD opration to read data from the FPGA.

I modified the DIO loopback example project into normal 1X  mode, and the program works fine.

But when i tried to get a lager payload, an exception was given by the BIOS indicated that the system heap overflowed.

I noticed that the sys heap set in the defult     .cfg file has a size of 32768B. and mapped into the L2SRAM. I changed the heap size into a lager one,and get larger payload transfered correctly. 

As i want to get a much larger payload up to 1MB, the L2SRAM won't fit anymore.

I noticed the problem posted in this:

http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/125626.aspx

It seems that we are faced with the same kind of problem. So i change the systemHeap map form:

Program.sectMap["systemHeap"] = Program.platform.stackMemory;

into

Program.sectMap["systemHeap"] = "MSMCSRAM";

But when the program ran, the FPGA side responed correctly, but the DSP buffer did not change at all;

When i change this in the loopback example project as above and lanuched it on the 6678evm board  the transfer failed too.

So i'm wonddering what else do i have to change to accomplish the large payload transfer goal.

Help! Please!

Tommy.

  • Tommy

    You may want to change the  SRIO_MAX_MTU for a larger payload. Take a look at this e2e to answer your question.

    http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/p/199765/711981.aspx#711981


    Elush

  • Hi Ted cooper,

    Sorry for a delayed response; I did not see a verified answer for this, so I will put in some tidbits I noticed about the SRIO DIO example. The root of the problem is memory management and how the OSAL allocates memory for SRIO.

    • Like you indicated, you will have to increase the systemHeap in the .cfg file for space to allocate bigger buffers. And as such, for payloads of 1MB, putting it in MSMC is a valid choice.
    • In the function, Osal_dataBufferInitMemory, there is a call Osal_local2Global. This should NOT be done for addresses not in L2. For example, if you are allocating a buffer in MSMC, this would return an invalid address. I added an if statement, if ((int)ptrMemory > 0x00800000 && (int)ptrMemory < 0x00880000), to this call.
    • Next is how the memory is initialized. In it's default state, a SRIO_MAX_MTU size buffer is needed for every RX/TX buffer for the SRIO Driver (that's indicated by numRxBuffers and numTxBuffers, respectively) as well as every source and destination buffer the application uses (srcDataBuffer and dstDataBuffer, respectively). The max number of SRIO_MAX_MTU sized buffers is held by the variable MAX_MEM_MGR_ENTRIES. At the beginning of the application, the program will try to allocate a chunk of space equal to SRIO_MAX_MTU x MAX_MEM_MGR_ENTRIES. Already we can see that if you increase SRIO_MAX_MTU size carelessly, you will run into out-of-memory problems. If you decrease the number of MAX_MEM_MGR_ENTRIES, the program may not have enough buffer entries to run.
    • The misleading thing is that numRxBuffers and numTxBuffers do not really come into play for DIO operations. The SRIO_MAX_MTU x MAX_MEM_MGR_ENTRIES chunk of space is handled by gDataBufferMemMgr. Subsequent OSAL call to Osal_srioDataBufferMalloc and Osal_srioDataBufferFree will simply operate on gDataBufferMemMgr, without any actual need for Memory_alloc or Memory_free.
    • srcDataBuffer and dstDataBuffer will try to use an entry from gDataBufferMemMgr if they use Osal_srioDataBufferMalloc. Instead, try changing the SIZE_DIO_PACKET to the size of the packet you want to send, and then using Memory_alloc. Eg. srcDataBuffer[i] = (uint8_t*)Memory_alloc(NULL, SIZE_DIO_PACKET, 16, &errorBlock); -- this would also apply for using Memory_free instead of Osal_srioDataBufferFree
    • Remember, srcDataBuffer and dstDataBuffer are also declared based on the number of SRIO sockets opened times the number of transfer. You can play around with this, but for a huge transfer, you may want to try SRIO_DIO_LSU_ISR_NUM_SOCKETS = 1, and SRIO_DIO_LSU_ISR_NUM_TRANSFERS = 1 first.
    • Now comes some of the cache issues. You will have to do a cache writeback whenever you update the src/dstDataBuffers and a cache invalidate after the SRIO send operation. I recommend grabbing the SYS/BIOS api from ti/sysbios/hal/Cache.h since we are already using BIOS. EDIT: Just want to point out that cache management should be handled via the application and not the driver. "SRIO send" is a bit ambiguous, since the Srio_sockSend_DIO function can be configured for NREAD or NWRITE ttypes. Cache invalidate would only be needed for the receiving end of the SRIO operation.

    Let me know if this helps in your large SRIO payload operation.
    -Ivan