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.

Example of TI 6678 receiving a SRIO doorbell

Other Parts Discussed in Thread: SYSBIOS, TMS320C6678

Hello,

Is example source code available showing how to receive (and action) a SRIO doorbell on a TI 6678 device?

As far as I can tell, none of the supplied examples use doorbells.

Thanks in advance,

Simon

  • Simon,

     

    Please refer to the C:\Program Files\Texas Instruments\pdk_C6678_1_0_0_11\packages\ti\drv\srio\src\srio_drv.c file.  The RX doorbell handling is done by the Srio_dioCompletionIsr function.

    Regards,

    Travis

     

    /**
     *  @b Description
     *  @n 
     *      The function is the SRIO DIO ISR handler which is used to handle the
     *      DIO Interrupts. SRIO Driver users need to ensure that this ISR is
     *      plugged with their OS Interrupt Management API. The function expects
     *      the Interrupt Destination information to be passed along to the API
     *      because the DIO Doorbell interrupt destination mapping is configurable
     *      during SRIO device initialization.
     *
     *  @param[in]  hSrioDrv
     *      SRIO Driver Handle
     *  @param[in]  intDstDoorbell
     *      This is an array of the interrupt destination to which the doorbells are
     *      routed to.
     *
     *  @retval
     *      Not Applicable
     */
    void Srio_dioCompletionIsr
    (
        Srio_DrvHandle  hSrioDrv,
        uint8_t         intDstDoorbell[]
    )
    {
        Srio_DriverInst*        ptr_srioDrvInst;
        Srio_Socket*            ptrSocket;
        uint32_t                intStatus;
        uint8_t                 doorbellReg;
        uint8_t                 doorbellBit;
        void*                   criticalSectionInfo;
        Srio_SockDataPacket*    ptr_sockData;

        /* Get the SRIO Driver Instance */
        ptr_srioDrvInst = (Srio_DriverInst*)hSrioDrv;

        /* Cycle through all the doorbells */
        for (doorbellReg = 0; doorbellReg < MAX_DOORBELL_REG; doorbellReg++)
        {
            /* Get the interrupt status register */
            CSL_SRIO_GetInterruptStatusDecode (gSRIODriverMCB.hSrio, intDstDoorbell[doorbellReg], &intStatus);

            /* Are there any interrupts pending? */
            if (intStatus != 0)
            {
                /* YES. Now run through and determine which all bits were pending? */
                for (doorbellBit = 0; doorbellBit < MAX_DOORBELL_BIT; doorbellBit++)
                {
                    /* Is the Doorbell bit pending? */
                    if (intStatus & (1 << doorbellBit))
                    {
                        /* YES. Determine the socket information to which this doorbell is mapped to. */
                        ptrSocket = ptr_srioDrvInst->socketDoorbellDatabase[doorbellReg][doorbellBit];

                        /* Did we get a matching socket? */
                        if (ptrSocket == NULL)
                            continue;

                        /* Dequeue a packet from the Free queue. */
                        criticalSectionInfo = Srio_osalEnterSingleCoreCriticalSection(ptr_srioDrvInst);
                        ptr_sockData = (Srio_SockDataPacket *)Srio_listRemove ((Srio_ListNode**)&ptrSocket->freePkts);
                        Srio_osalExitSingleCoreCriticalSection(ptr_srioDrvInst, criticalSectionInfo);

                        /* Was there space to receive in the socket to receive the doorbell? */
                        if (ptr_sockData == NULL)
                        {
                            /* Error: Socket was full and the doorbell was not received */
                            ptrSocket->sockRxOverrun++;
                            continue;
                        }

                        /* Store the doorbell information */
                        ptr_sockData->drvBuffer = (Srio_DrvBuffer)(SRIO_SET_DBELL_INFO(doorbellReg, doorbellBit));
                        ptr_sockData->numBytes  = 1;
     
                        /* Add this to the socket data queue. */
                        criticalSectionInfo = Srio_osalEnterSingleCoreCriticalSection(ptr_srioDrvInst);
                        Srio_listCat ((Srio_ListNode**)&ptrSocket->pendingPkts, (Srio_ListNode**)&ptr_sockData);
                        Srio_osalExitSingleCoreCriticalSection(ptr_srioDrvInst, criticalSectionInfo);

                        /* Data is available and has been posted on the socket pending list. If the socket is
                         * a blocking socket; we need to wake it because data is now available for it to receive. */
                        if (ptrSocket->blockingSocket == 1)
                            Srio_osalPostSem (ptrSocket->semHandle);
                    }
                }
                /* Clear the doorbell interrupts. */
                CSL_SRIO_ClearDoorbellPendingInterrupt(gSRIODriverMCB.hSrio, doorbellReg, intStatus);
            }
        }
        return;
    }

  • Please can you explain how to do this:

    "SRIO Driver users need to ensure that this ISR is  plugged with their OS Interrupt Management API. The function expects the Interrupt Destination information to be passed along to the API  because the DIO Doorbell interrupt destination mapping is configurable during SRIO device initialization."

    My application is quite simple - I need to call a function (ISR) each time a doorbell is received. Please can you explain how I "plug the OS with the ISR", and how do I call my own function when the interrupt is received?

    Thanks,

    Simon

  • Hello Simon,

    The comment "plug the OS with the ISR" meant that the ISR handler function should be registered with the OS so that when the interrupt is raised OS will call the appropriate function (ISR handler). Below is an example code snippet which demonstrates ISR registration using SYS/BIOS APIs. If you are not using SYS/BIOS then similar configuration needs to be done with the underlying OS to register the ISR.

    Note: Below myDIOIsr is the user implemented ISR handler function.

        /* Hook up the SRIO interrupts with the core. */
        /* SRIO DIO Interrupts need to be routed from the CPINTC0 to GEM Event.
         *  - We have configured DIO Interrupts to get routed to Interrupt Destination 0
         *    (Refer to the CSL_SRIO_SetDoorbellRoute API configuration in the SRIO Initialization)
         *  - We want this to mapped to Host Interrupt 8
         *
         *  Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */
        CpIntc_dispatchPlug(CSL_INTC0_INTDST0, myDIOIsr, (UArg)hAppManagedSrioDrv, TRUE);

        /* The configuration is for CPINTC0. We map system interrupt 112 to Host Interrupt 8. */
        CpIntc_mapSysIntToHostInt(0, CSL_INTC0_INTDST0, 8);

        /* Enable the Host Interrupt. */
        CpIntc_enableHostInt(0, 8);

        /* Enable the System Interrupt */
        CpIntc_enableSysInt(0, CSL_INTC0_INTDST0);

        /* Get the event id associated with the host interrupt. */
        eventId = CpIntc_getEventId(8);

        /* Plug the CPINTC Dispatcher. */
        EventCombiner_dispatchPlug (eventId, CpIntc_dispatch, 8, TRUE);

    Regards,

    Murtaza

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Murtaza,

    Thanks for the code example. A few additional questions :

    1) With reference to this post : http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/133193.aspx "The CpIntc_getEventId() API is broken for C6678 in BIOS 6.32.01.38". We are using BIOS 6.32.01.38, so I'm assuming the above code will not work if used verbatim? If so please can you suggest a work around, for example what is the appropriate EventId for the 6678?

    2) For the XDCscript we have added :

    var CpIntc = xdc.useModule('ti.sysbios.family.c66.tci66xx.CpIntc');

    to the .cfg file.

    Do we need any additional configuration in this file?

    3) From the definition of CpIntc_FuncPtr ( typedef Void (*CpIntc_FuncPtr)(UArg); ) I assume our ISR has to be defined in the form:

    Void myDIOIsr ( UArg value );

    ? And that we don't need to use the 'interrupt' keyword? or #pragma vector = XXX; before ? An example ISR would be greatly appreciated good!

    4) Why do you pass hAppManagedSrioDrv as the argument to the ISR via CpIntc_dispatchPlug()? Does the ISR need this handle? We are using hDrvManagedSrioDrv  (from the SRIO_LoopbackTestProject) , will this still work with the Doorbell interrupt?

    Thanks in advance,

    Simon

     

  • Hello Simon,

    Here are the answers to your queries:

    1.) Please use the latest version of BIOS MCSDK (02_00_02_14) available at http://software-dl.ti.com/sdoemb/sdoemb_public_sw/bios_mcsdk/latest/index_FDS.html link. This release includes an updated version of SYS/BIOS tools, 6.32.04.49, which fixes the problem related with CpIntc_getEventId() with SYS/BIOS 6.32.01.38 version.

    2.) No, you don't need any additional XDC configuration for CPINTC.

    3.) Yes, this is fine. Here's an example:

        /* Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */
        CpIntc_dispatchPlug(CSL_INTC0_INTDST0, (CpIntc_FuncPtr)myDioTxCompletionIsr, (UArg)hSrioCSL, TRUE);

        /* ISR declaration */
        void myDioTxCompletionIsr (CSL_SrioHandle  hSrioCSL);

    4.) No, there is no such dependency on hAppManagedSrioDrv argument. It was only shown as an example. The 3rd argument to CpIntc_dispatchPlug function should be what parameter is required/expected by the ISR handler to process the interrupt. For example, in the above code snippet the argument is a handle to CSL SRIO registers.

    Let us know if you have any more questions. Thanks!

    Regards,

    Murtaza

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • hi,

    The link to http://software-dl.ti.com/sdoemb/sdoemb_public_sw/bios_mcsdk/latest/index_FDS.html   link us version 12 not 14.

    thaks

    Tuli

     

     

     

  • Tuli,

    Could you please clear your browser's cache/cookies etc. and try again. I checked using different browsers and the link is taking me to version 14. Here's the official announcement of 2.0.2 release on E2E Community which also provides the download link.

    Regards,
    Murtaza

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Hi Murtaza

    I work with simon64 (who is out of office today) and have been asked to investigate the difficulties we've been experiencing in getting our ISR to be registered/called from the API. As far as I can see, we have functionally very similar code to the example you've given AND I've ensured that I'm using BIOS MCSDK (02_00_02_14) as you indicate, however, we're still not able to invoke our ISR on doorbell events. We know that we're reciving doorbells (as Simon stated previously), but since any ISR-related activity is going on "under the hood" of BIOS, debugging is somewhat intractable.

    If you have any further thoughts regarding what might need to be changed/ configured differently then they would be very much appreciated. Also is there any way we can trace/debug the signalling chain from the incoming doorbell event through BIOS to our handing ISR?

    Best regards,


    Peter L.

  • Hello Peter,

    Could you please check in your CCS project settings (Right Click and select "Show Build Settings" --> Select "CCS Build" in left panel ---> Select "RTSC" tab on the right panel) that SYS/BIOS tools used by the project is pointed to 6.32.04.49 version? This is to make sure that you are not using old SYS/BIOS tools which had a CpIntc related issue with C6678 devices.

    If you feel that using BIOS APIs for ISR registration is creating difficulties in debugging the project then you can try using CPINTC CSL APIs (available in the PDK) to do the same. A good example of using CSL APIs to register an ISR is shown in Hyperlink LLD (.\packages\ti\drv\hyplnk). Please refer the code flow of hyplnkExampleInstallIsr() available in .\packages\ti\drv\hyplnk\example\common\hyplnkIsr.c and see if using CSL APIs could help in resolving your problem. The steps followed in this function are basically trying to simulate what BIOS APIs are doing. There is some additional programming complexity here but it provides more debugging capabilities. Note that the ISR example shown in Hyperlink LLD is tuned for Hyperlink application and will require customizations to be applicable to SRIO application. Please refer Figure 2-31 (Interrupt Mapping to CPU) from SPRUGW1 and Figure 7-12 (TMS320C6678 Interrupt Topology) from SPRS691 for an overview of interrupt sources and mappings.

    Regards,
    Murtaza

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • I have tried the above example code as follows:

     static void Rt_MyDIOIsr(void)

    {

    static UInt8 DrblliCount;

    System_printf("Received D2211.SRIO_test_project3rdOct.raroorbell number %d Please chcek memory\n",DrblliCount);

     return;

    }

    /**

    * @b Description

    * @n

    * Utility function which hooks the ISR to INTDST

    *

    * @param[in] void

    *

    *

    * @retval

    * void

    */
    static Void Rt_SrioSetISr(Void)
    {

    #if 1 
     /* Hook up the SRIO interrupts with the core. */

    /* SRIO DIO Interrupts need to be routed from the CPINTC0 to GEM Event.

    * - We have configured DIO Interrupts to get routed to Interrupt Destination 0

    * (Refer to the CSL_SRIO_SetDoorbellRoute API configuration in the SRIO Initialization)

    * - We want this to mapped to Host Interrupt 8

    *

    * Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */

    UInt8 eventId;

    //Maintain the Event ID
     CpIntc_dispatchPlug(CSL_INTC0_INTDST0, Rt_MyDIOIsr, (UArg)hAppManagedSrioDrv, TRUE);

     /* The configuration is for CPINTC0. We map system interrupt 112 to Host Interrupt 8. */

    CpIntc_mapSysIntToHostInt(0, CSL_INTC0_INTDST0, 8);

    /* Enable the Host Interrupt. */

    CpIntc_enableHostInt(0, 8);

    /* Enable the System Interrupt */

    CpIntc_enableSysInt(0, CSL_INTC0_INTDST0);

    /* Get the event id associated with the host interrupt. */

    eventId = CpIntc_getEventId(8);

     /* Plug the CPINTC Dispatcher. */

    EventCombiner_dispatchPlug (eventId,CpIntc_dispatch, 8, TRUE);

     //(EventCombiner_FuncPtr)Rt_MyDIOIsr

     #endif

    return;

    }

    I am not able to see the ISR executing.

    Also I have verified that the doorbell is received by adding the following functionality in my code:

    while (1)

    {

    Srio_DrvBuffer DoorBellInfo;

    unsigned char DoorBellInfo1[4] = {0};

     unsigned char

    num_bytes = 0;

    /* POLL the SRIO Driver to check if any packets have been received or not? */

    //Srio_rxCompletionIsr(hSrioDrv);

    /* Receive data */

    num_bytes = Srio_sockRecv (srioSocket,DoorBellInfo, &from);  

    if (num_bytes > 0)

    {  

    printf("Doorbell received\n"\);  

    }

     Srio_dioCompletionIsr(hAppManagedSrioDrv,0);


    In Srio_dioCompletionIsr()  

    for (doorbellBit = 0; doorbellBit < MAX_DOORBELL_BIT; doorbellBit++)

    {/* Is the Doorbell bit pending? */

    if(intStatus & (1 << doorbellBit))
    {

    printf("Entered in Dorbell ISR\n");  

    /* YES. Determine the socket information to which this doorbell is mapped to. */

    ptrSocket = ptr_srioDrvInst->

    socketDoorbellDatabase[doorbellReg][doorbellBit];
    I am getting the" Entered in Dorbell ISR" in console window.

    1)Can you please suggest how to configure the ISR?

    2)Please provide an example code for plugging Srio_dioCompletionIsr() with OS interrupt management API.

    3)I am using the Sys Bios v6.31.04.27. So is that Sys Bios Version problem?

    If possible I will be attaching my current project.

  • Pratik,

     

    I believe the bad version of the BIOS was v6.32.01.38.  I'm not sure about the version you list.  I know the issue is resolved in the latest MCSDK release that used BIOS v6.32.04.49.

     

    Regards,

    Travis

     

  • Hi, Simon:

       Have you solved the problem, I have the same question,

       Could you give your code about how to plug the doorbell isr? My mail is liuqingben511@163.com.

        Thanks a lot.