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工程合并出现的问题



我用的硬件是TMDSEVM6678LE评估版,CCS5.2,pdk_C6678_1_1_2_5。我想将测试SRIO内环的工程(路径C:\ti\pdk_C6678_1_1_2_5\packages\ti\drv\srio\example\SRIOLoopbackDioIsr)和测试网络的工程(路径C:\ti\pdk_C6678_1_1_2_5\packages\ti\drv\pa\example\emacExample)合并成一个工程。我的整个工程如附件所示(编译时要将附件中SRIO_LoopbackDioIsrexampleproject文件夹内的emac包含进去)。我的做法是:将emacExample中的C代码加入SRIOLoopbackDioIsr工程中,cfg文件用loopbackDioIsr.cfg。下边是main函数:

Void main(Void)
{

Task_Params cpswTaskParams;
/* Get the core number. */
coreNum = CSL_chipReadReg (CSL_CHIP_DNUM);

#if 0 //SRIO测试函数
Task_Params taskParams;

#ifdef SIMULATOR_SUPPORT
#warn SRIO DIO LSU ISR example is not supported on SIMULATOR !!!
System_printf ("SRIO DIO LSU ISR example is not supported on SIMULATOR. Exiting!\n");
return;
#else
System_printf ("Executing the SRIO DIO example on the DEVICE\n");
#endif

/* Initialize the system only if the core was configured to do so. */
if (coreNum == 0)
{

System_printf ("Debug(Core %d): System Initialization for CPPI & QMSS\n", coreNum);

/* System Initialization */
if (system_init() < 0)
return;
//Cpsw_SingleCoreApp();
/* Power on SRIO peripheral before using it */
if (enable_srio () < 0)
{
System_printf ("Error: SRIO PSC Initialization Failed\n");
return;
}

/* Device Specific SRIO Initializations: This should always be called before
* initializing the SRIO Driver. */
if (SrioDevice_init() < 0)
return;

/* Initialize the SRIO Driver */
if (Srio_init () < 0)
{
System_printf ("Error: SRIO Driver Initialization Failed\n");
return;
}

/* SRIO Driver is operational at this time. */
System_printf ("Debug(Core %d): SRIO Driver has been initialized\n", coreNum);

/* Write to the SHARED memory location at this point in time. The other cores cannot execute
* till the SRIO Driver is up and running. */
isSRIOInitialized[0] = 1;

/* The SRIO IP block has been initialized. We need to writeback the cache here because it will
* ensure that the rest of the cores which are waiting for SRIO to be initialized would now be
* woken up. */
CACHE_wbL1d ((void *) &isSRIOInitialized[0], 128, CACHE_WAIT);

}
else
{
/* All other cores need to wait for the SRIO to be initialized before they proceed. */
System_printf ("Debug(Core %d): Waiting for SRIO to be initialized.\n", coreNum);

/* All other cores loop around forever till the SRIO is up and running.
* We need to invalidate the cache so that we always read this from the memory. */
while (isSRIOInitialized[0] == 0)
CACHE_invL1d ((void *) &isSRIOInitialized[0], 128, CACHE_WAIT);

/* Start the QMSS. */
if (Qmss_start() != QMSS_SOK)
{
System_printf ("Error: Unable to start the QMSS\n");
return;
}
//Cpsw_SingleCoreApp();
System_printf ("Debug(Core %d): SRIO can now be used.\n", coreNum);

}

if (coreNum == 0)
{
/* Create the DIO Example Task.*/
Task_Params_init(&taskParams);
taskParams.priority = 1;
Task_create(dioExampleTask, &taskParams, NULL);
}

#endif

#if 1 //emac测试函数
if (!cpswSimTest)
{
passPowerUp();
}
/* Initialize the task params */
Task_Params_init(&cpswTaskParams);
//cpswTaskParams.priority = 2;
/* Create the CPSW single core example task */
Task_create((Task_FuncPtr)&Cpsw_SingleCoreApp, &cpswTaskParams, NULL);
#endif

/* Start the BIOS */
BIOS_start();
}

main 函数中有两个测试函数,一个是网络测试函数,一个是SRIO测试函数,每个函数单独测试,运行正常。现在我想将两者一起用,即在一个核中既运行网络测试函数,又可以运行SRIO函数。我的做法参考了e2e.ti.com/.../198711.aspx,改法如下:

1.对Cpsw_SingleCoreApp任务的Init_Qmss函数中的

qmssInitConfig.maxDescNum       =   NUM_HOST_DESC;修改成qmssInitConfig.maxDescNum       =   NUM_HOST_DESC+128;

memset (gHostDesc, 0, SIZE_HOST_DESC * (NUM_HOST_DESC));修改成memset (gHostDesc, 0, SIZE_HOST_DESC * (NUM_HOST_DESC+128));

memCfg.descNum              =   NUM_HOST_DESC;修改成memCfg.descNum              =   NUM_HOST_DESC+128;

cppiDescCfg.descNum         =   NUM_HOST_DESC修改成cppiDescCfg.descNum         =   NUM_HOST_DESC+128;

2.由于SRIO和emac都初始化了QMSS,将SRIO的QMSS初始化加到Cpsw_SingleCoreApp函数中;

.SRIO的QMSS初始化函数如下:

void mysrioqmssinit() {

Int32 result; Qmss_MemRegInfo memRegInfo;

/* Memory Region 1Configuration */

memRegInfo.descBase = (UInt32 *)Convert_CoreLocal2GlobalAddr((UInt32)gHostDesc);

memRegInfo.descSize = SIZE_HOST_DESC;

memRegInfo.descNum = NUM_HOST_DESC;

memRegInfo.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR;

memRegInfo.memRegion = Qmss_MemRegion_MEMORY_REGION1;//Qmss_MemRegion_MEMORY_REGION_NOT_SPECIFIED;

memRegInfo.startIndex = 128;

/* Initialize and inset the memory region. */
//Success - Inserted Memory region index. Range is 0 to 19.
//Failure - QMSS_INVALID_PARAM
// Failure - QMSS_NOT_INITIALIZED
// Failure - QMSS_MEMREGION_ALREADY_INITIALIZED
//Failure - QMSS_MEMREGION_INVALID_PARAM
//Failure - QMSS_MAX_DESCRIPTORS_CONFIGURED
//Failure - QMSS_MEMREGION_INVALID_INDEX
//Failure - QMSS_MEMREGION_OVERLAP
//Failure - QMSS_QUEUE_OPEN_ERROR
//Failure - QMSS_RESOURCE_MEMORY_REGION_INIT_DENIED
//Failure - QMSS_RESOURCE_LINKING_RAM_INIT_DENIED

result = Qmss_insertMemoryRegion (&memRegInfo);

if (result < QMSS_SOK)

{

System_printf ("Error inserting memory region: %d\n", result);

return;

}

}

3.在Cpsw_SingleCoreApp中初始化顺序如下:

Init_Qmss();

mysrioqmssinit();

Init_Cppi ();

Init_PASS ();

Init_Cpsw ();

Setup_Tx ();

Setup_Rx ();

Setup_PASS ();

4.运行结果:在函数mysrioqmssinit()中 result = Qmss_insertMemoryRegion (&memRegInfo)的返回值为-135,但是emac函数运行正常;

现在我的问题是:

1.我这样初始化正确与否?哪里出了毛病?

2.将srio和emac合并,还需要做什么修改?

srio_emac.rar
  • 另外感觉在所有的附带例程中没有找到一个既使用SRIO又使用网络的工程文件,发现所有的例程都是测试一种接口;我想一个工程应用肯定不只使用一种接口,TI支持应该有此类合并使用SRIO和网络的工程文件吧,希望可以提供一份例程代码参考,谢谢

  • EMAC和SRIO都是navigator peripheral,各自的工程中都会对QMSS进行初始化,各自需要分配descriptor,以及相应的队列queue资源。在合并时需要注意QMSS的初始化只能一次,注意queue的使用分配不能冲突,对descriptor总数的定义要根据两个模块的需求有所增加。

    根据你的错误提示,可以查看 Qmss_insertMemoryRegion的实现,返回值-135对应QMSS_MAX_DESCRIPTORS_CONFIGURED,即在申请描述符时发现已经耗尽,可以将系统定义的最大描述符个数增大。在集成过程中遇到类似问题,可以查看pdk中相关函数的源码对应错误类型进行解决。

  • Andy,你好,按照你的意见修改了相关值,但是又出现返回值是-137,经查询得知是QMSS_MEMREGION_OVERLAP,意思是/** QMSS memory region overlap */ ,但是我一个分配的是Qmss_MemRegion_MEMORY_REGION0,一个是Qmss_MemRegion_MEMORY_REGION1,而且index也不同,为什么还会出现这样的情况?有无工程合并时的QMSS初始化code提供参考?

  • 其实你可以参考一下PDK中CPPI的几个例子,你的问题就能够解决了。