//------------------------------------------------------------------------------
static tOplkError cbProcessRpdo(tFrameInfo* pFrameInfo_p)
{
    tOplkError      ret = kErrorOk;
    tEvent          event;

    event.eventSink = kEventSinkPdokCal;
    event.eventType = kEventTypePdoRx;
#if CONFIG_DLL_DEFERRED_RXFRAME_RELEASE_SYNC != FALSE
    event.eventArgSize   = sizeof(tFrameInfo);
    event.pEventArg      = pFrameInfo_p;
#else
    // limit copied data to size of PDO (because from some CNs the frame is larger than necessary)
    event.eventArgSize = ami_getUint16Le(&pFrameInfo_p->pFrame->data.pres.sizeLe) +
                                         PLK_FRAME_OFFSET_PDO_PAYLOAD; // pFrameInfo_p->frameSize;
    event.pEventArg = pFrameInfo_p->pFrame;
#endif
    ret = eventk_postEvent(&event);
#if CONFIG_DLL_DEFERRED_RXFRAME_RELEASE_SYNC != FALSE
    if (ret == kErrorOk)
    {
        ret = kErrorReject; // Reject release of rx buffer
    }
#endif

    return ret;
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
tOplkError dllknode_issueLossOfPres(UINT nodeId_p)
{
    tOplkError          ret = kErrorOk;
    tDllkNodeInfo*      pIntNodeInfo;
    tEvent              event;
    tDllNodeOpParam     nodeOpParam;

    pIntNodeInfo = dllknode_getNodeInfo(nodeId_p);
    if (pIntNodeInfo != NULL)
    {
        if (pIntNodeInfo->fSoftDelete == FALSE)
        {   // normal isochronous CN
            tEventDllError  dllEvent;

            dllEvent.dllErrorEvents = DLL_ERR_MN_CN_LOSS_PRES;
            dllEvent.nodeId = pIntNodeInfo->nodeId;
            ret = errhndk_postError(&dllEvent);
            if (ret != kErrorOk)
                return ret;
        }
        else
        {   // CN shall be deleted softly, so remove it now without issuing any error
            nodeOpParam.opNodeType = kDllNodeOpTypeIsochronous;
            nodeOpParam.nodeId = pIntNodeInfo->nodeId;

            event.eventSink = kEventSinkDllkCal;
            event.eventType = kEventTypeDllkDelNode;
            // $$$ d.k. set Event.netTime to current time
            event.eventArgSize = sizeof(nodeOpParam);
            event.pEventArg = &nodeOpParam;
            eventk_postEvent(&event);
        }
    }
    return ret;
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------------
static tOplkError controlTimeSync(BOOL fEnable_p)
{
    tOplkError  ret = kErrorOk;
    tEvent      event;
    BOOL        fEnable = fEnable_p;

    event.eventSink = kEventSinkTimesynck;
    event.eventType = kEventTypeTimesynckControl;
    event.eventArg.pEventArg = &fEnable;
    event.eventArgSize = sizeof(fEnable);

    ret = eventk_postEvent(&event);

#if CONFIG_DLL_PROCESS_SYNC == DLL_PROCESS_SYNC_ON_TIMER
    if (ret == kErrorOk)
    {
        // Activate/deactivate external synchronization interrupt
        synctimer_controlExtSyncIrq(fEnable);
    }
#endif

#if CONFIG_TIMER_USE_HIGHRES == TRUE
    if (ret == kErrorOk)
    {
        // Activate/deactivate external synchronization interrupt
        hrestimer_controlExtSyncIrq(fEnable);
    }
#endif

    return ret;
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------------
tOplkError dllk_postEvent(tEventType eventType_p)
{
    tOplkError              ret;
    tEvent                  event;

    event.eventSink = kEventSinkDllk;
    event.eventType = eventType_p;
    event.eventArgSize = 0;
    event.pEventArg = NULL;
    ret = eventk_postEvent(&event);
    return ret;
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------------
static tOplkError postHistoryEntryEvent(tErrHistoryEntry* pHistoryEntry_p)
{
    tOplkError              ret;
    tEvent                  event;

    event.eventSink = kEventSinkApi;
    event.eventType = kEventTypeHistoryEntry;
    event.eventArgSize = sizeof(*pHistoryEntry_p);
    event.pEventArg = pHistoryEntry_p;
    ret = eventk_postEvent(&event);

    return ret;
}
Ejemplo n.º 6
0
//------------------------------------------------------------------------------
tOplkError errhndk_postError(tEventDllError* pErrEvent_p)
{
    tOplkError              Ret;
    tEvent                  Event;

    Event.eventSink = kEventSinkErrk;
    Event.eventType = kEventTypeDllError;
    Event.eventArgSize = sizeof(tEventDllError);
    Event.pEventArg = pErrEvent_p;
    Ret = eventk_postEvent(&Event);

    return Ret;
}
Ejemplo n.º 7
0
//------------------------------------------------------------------------------
static tOplkError postNmtEvent(tNmtEvent nmtEvent_p)
{
    tOplkError                  ret;
    tNmtEvent                   nmtEvent;
    tEvent                      event;

    nmtEvent = nmtEvent_p;
    event.eventSink = kEventSinkNmtk;
    event.eventType = kEventTypeNmtEvent;
    event.pEventArg = &nmtEvent;
    event.eventArgSize = sizeof(nmtEvent);
    ret = eventk_postEvent(&event);
    return ret;
}
Ejemplo n.º 8
0
//------------------------------------------------------------------------------
tOplkError dllk_cbTimerSwitchOver(tTimerEventArg* pEventArg_p)
{
    tOplkError      ret = kErrorOk;
    tNmtState       nmtState;
    UINT32          arg;
    tNmtEvent       nmtEvent;
    tEvent          event;

    TGT_DLLK_DECLARE_FLAGS;

    TGT_DLLK_ENTER_CRITICAL_SECTION();

#if CONFIG_TIMER_USE_HIGHRES != FALSE
    if (pEventArg_p->timerHdl != dllkInstance_g.timerHdlSwitchOver)
    {   // zombie callback - just exit
        goto Exit;
    }
#endif

    nmtState = dllkInstance_g.nmtState;
    if (!NMT_IF_ACTIVE_CN(nmtState))
        goto Exit;

    ret = edrv_sendTxBuffer(&dllkInstance_g.pTxBuffer[DLLK_TXFRAME_AMNI]);
    if (ret != kErrorOk)
        goto Exit;

    // increment relativeTime for missing SoC
    dllkInstance_g.relativeTime += dllkInstance_g.dllConfigParam.cycleLen;

    nmtEvent = kNmtEventDllReSwitchOverTimeout;
    event.eventSink = kEventSinkNmtk;
    event.eventType = kEventTypeNmtEvent;
    event.eventArgSize = sizeof(nmtEvent);
    event.pEventArg = &nmtEvent;
    ret = eventk_postEvent(&event);

Exit:
    if (ret != kErrorOk)
    {
        BENCHMARK_MOD_02_TOGGLE(7);
        arg = dllkInstance_g.dllState | (kNmtEventDllReSwitchOverTimeout << 8);
        // Error event for API layer
        ret = eventk_postError(kEventSourceDllk, ret, sizeof(arg), &arg);
    }
    TGT_DLLK_LEAVE_CRITICAL_SECTION();
    return ret;
}
Ejemplo n.º 9
0
//------------------------------------------------------------------------------
static tOplkError postHeartbeatEvent(UINT nodeId_p, tNmtState state_p,
                                     UINT16 errorCode_p)
{
    tOplkError              ret;
    tHeartbeatEvent         heartbeatEvent;
    tEvent                  event;

    heartbeatEvent.nodeId = nodeId_p;
    heartbeatEvent.nmtState = state_p;
    heartbeatEvent.errorCode = errorCode_p;
    event.eventSink = kEventSinkNmtMnu;
    event.eventType = kEventTypeHeartbeat;
    event.eventArgSize = sizeof(heartbeatEvent);
    event.pEventArg = &heartbeatEvent;
    ret = eventk_postEvent(&event);
    return ret;
}
Ejemplo n.º 10
0
//------------------------------------------------------------------------------
tOplkError dllkcal_asyncFrameReceived(tFrameInfo* pFrameInfo_p)
{
    tOplkError  ret = kErrorOk;
    tEvent      event;

#if CONFIG_DLL_DEFERRED_RXFRAME_RELEASE_ASYNC == FALSE
    // Copy the frame into event queue
    event.eventType = kEventTypeAsndRx;
    event.eventArg.pEventArg = pFrameInfo_p->frame.pBuffer;
    event.eventArgSize = pFrameInfo_p->frameSize;
#else
    tPlkFrame*  pTempFrame;
    // Clear padding before forwarding the event to user layer.
    pTempFrame = pFrameInfo_p->frame.pBuffer;
    pFrameInfo_p->frame.padding2 = 0;
    pFrameInfo_p->frame.pBuffer = pTempFrame;
    event.eventType = kEventTypeAsndRxInfo;
    event.eventArg.pEventArg = pFrameInfo_p;
    event.eventArgSize = sizeof(tFrameInfo);
#endif
    event.eventSink = kEventSinkDlluCal;

    ret = eventk_postEvent(&event);
#if CONFIG_DLL_DEFERRED_RXFRAME_RELEASE_ASYNC == TRUE
    if (ret == kErrorOk)
    {
        instance_l.asyncFrameReceived++;

        instance_l.statistics.curRxFrameCount = instance_l.asyncFrameReceived - instance_l.asyncFrameFreed;
        if (instance_l.statistics.curRxFrameCount > instance_l.statistics.maxRxFrameCount)
            instance_l.statistics.maxRxFrameCount = instance_l.statistics.curRxFrameCount;

        ret = kErrorReject; // Signalizes dllk to release buffer later
    }
#endif

    return ret;
}
Ejemplo n.º 11
0
//------------------------------------------------------------------------------
tOplkError dllkcal_sendAsyncFrame(tFrameInfo* pFrameInfo_p,
                                  tDllAsyncReqPriority priority_p)
{
    tOplkError  ret = kErrorOk;
    tEvent      event;

    switch (priority_p)
    {
        case kDllAsyncReqPrioNmt:    // NMT request priority
            ret = instance_l.pTxNmtFuncs->pfnInsertDataBlock(
                                        instance_l.dllCalQueueTxNmt,
                                        (BYTE*)pFrameInfo_p->frame.pBuffer,
                                        &(pFrameInfo_p->frameSize));
            break;

        default:    // generic priority
            ret = sendGenericAsyncFrame(pFrameInfo_p);
            break;
    }

    if (ret != kErrorOk)
    {
        goto Exit;
    }

    // post event to DLL
    event.eventSink = kEventSinkDllk;
    event.eventType = kEventTypeDllkFillTx;
    OPLK_MEMSET(&event.netTime, 0x00, sizeof(event.netTime));
    event.eventArg.pEventArg = &priority_p;
    event.eventArgSize = sizeof(priority_p);
    ret = eventk_postEvent(&event);

Exit:
    return ret;
}
Ejemplo n.º 12
0
//------------------------------------------------------------------------------
tOplkError dllknode_addNodeIsochronous(tDllkNodeInfo* pIntNodeInfo_p)
{
    tOplkError          ret = kErrorOk;
    tDllkNodeInfo**     ppIntNodeInfo;
    tPlkFrame *         pTxFrame;

    if (pIntNodeInfo_p->nodeId == dllkInstance_g.dllConfigParam.nodeId)
    {   // we shall send PRes ourself
        // insert our node as first entry in the list
        ppIntNodeInfo = &dllkInstance_g.pFirstNodeInfo;
        if (*ppIntNodeInfo != NULL)
        {
            if ((*ppIntNodeInfo)->nodeId == pIntNodeInfo_p->nodeId)
            {   // node was already added to list
                // $$$ d.k. maybe this should be an error
                goto Exit;
            }
        }
        // set "PReq"-TxBuffer to PRes-TxBuffer
        pIntNodeInfo_p->pPreqTxBuffer = &dllkInstance_g.pTxBuffer[DLLK_TXFRAME_PRES];

        // Reset PRC Slot Timeout
        // which is required if falling back to PreOp1
        pIntNodeInfo_p->presTimeoutNs = 0;
    }
    else
    {   // normal CN shall be added to isochronous phase
        // insert node into list in ascending order
        if (pIntNodeInfo_p->pPreqTxBuffer == NULL)
        {
            ppIntNodeInfo = &dllkInstance_g.pFirstPrcNodeInfo;
        }
        else
        {
            ppIntNodeInfo = &dllkInstance_g.pFirstNodeInfo;
        }

        while ((*ppIntNodeInfo != NULL) &&
               (((*ppIntNodeInfo)->nodeId < pIntNodeInfo_p->nodeId) ||
               ((*ppIntNodeInfo)->nodeId == dllkInstance_g.dllConfigParam.nodeId)))
        {
            ppIntNodeInfo = &(*ppIntNodeInfo)->pNextNodeInfo;
        }

        if ((*ppIntNodeInfo != NULL) && ((*ppIntNodeInfo)->nodeId == pIntNodeInfo_p->nodeId))
        {   // node was already added to list
            // $$$ d.k. maybe this should be an error
            goto Exit;
        }

        if (pIntNodeInfo_p->pPreqTxBuffer != NULL)
        {   // TxBuffer entry exists
            tEvent          event;

            pTxFrame = (tPlkFrame*)pIntNodeInfo_p->pPreqTxBuffer[0].pBuffer;
            // set up destination MAC address
            OPLK_MEMCPY(pTxFrame->aDstMac, pIntNodeInfo_p->aMacAddr, 6);
            // set destination node-ID in PReq
            ami_setUint8Le(&pTxFrame->dstNodeId, (UINT8)pIntNodeInfo_p->nodeId);
            // do the same for second frame buffer
            pTxFrame = (tPlkFrame*)pIntNodeInfo_p->pPreqTxBuffer[1].pBuffer;
            // set up destination MAC address
            OPLK_MEMCPY(pTxFrame->aDstMac, pIntNodeInfo_p->aMacAddr, 6);
            // set destination node-ID in PReq
            ami_setUint8Le(&pTxFrame->dstNodeId, (UINT8) pIntNodeInfo_p->nodeId);

            event.eventSink = kEventSinkNmtMnu;
            event.eventType = kEventTypeNmtMnuNodeAdded;
            event.eventArgSize = sizeof(pIntNodeInfo_p->nodeId);
            event.pEventArg = &pIntNodeInfo_p->nodeId;
            ret = eventk_postEvent(&event);
            if (ret != kErrorOk)
                goto Exit;

        }

        ret = errhndk_resetCnError(pIntNodeInfo_p->nodeId);
    }

    // initialize elements of internal node info structure
    pIntNodeInfo_p->fSoftDelete = FALSE;
    pIntNodeInfo_p->nmtState = kNmtCsNotActive;
    pIntNodeInfo_p->dllErrorEvents = 0L;
    // add node to list
    pIntNodeInfo_p->pNextNodeInfo = *ppIntNodeInfo;
    *ppIntNodeInfo = pIntNodeInfo_p;

Exit:
    return ret;
}