⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ixethdbevents.c

📁 有关ARM开发板上的IXP400网络驱动程序的源码以。
💻 C
📖 第 1 页 / 共 2 页
字号:
    IX_ETH_DB_EVENTS_TRACE("DB: (Events) Event processor loop was started\n");    while (!ixEthDBLearningShutdown)    {        BOOL keepProcessing    = TRUE;        UINT32 processedEvents = 0;        IX_ETH_DB_EVENTS_VERBOSE_TRACE("DB: (Events) Waiting for new learning event...\n");        ixOsalSemaphoreWait(&eventQueueSemaphore, IX_OSAL_WAIT_FOREVER);        IX_ETH_DB_EVENTS_VERBOSE_TRACE("DB: (Events) Received new event\n");        if (!ixEthDBLearningShutdown)        {            /* port update handling */            SET_EMPTY_DEPENDENCY_MAP(triggerPorts);            while (keepProcessing)            {                PortEvent local_event;                UINT32 intLockKey;                /* lock queue */                ixOsalMutexLock(&eventQueueLock, IX_OSAL_WAIT_FOREVER);                /* lock NPE interrupts */                intLockKey = ixOsalIrqLock();                /* extract event */                local_event = *(QUEUE_TAIL(&eventQueue));                SHIFT_UPDATE_QUEUE(&eventQueue);                ixOsalIrqUnlock(intLockKey);                ixOsalMutexUnlock(&eventQueueLock);                IX_ETH_DB_EVENTS_TRACE("DB: (Events) Processing event with ID 0x%X\n", local_event.eventType);                ixEthDBProcessEvent(&local_event, triggerPorts);                processedEvents++;                if (processedEvents > EVENT_PROCESSING_LIMIT /* maximum burst reached? */                    || ixOsalSemaphoreTryWait(&eventQueueSemaphore) != IX_SUCCESS) /* or empty queue? */                {                    keepProcessing = FALSE;                }            }            ixEthDBUpdatePortLearningTrees(triggerPorts);        }    }    /* turn off automatic updates */    for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)    {        ixEthDBPortInfo[portIndex].updateMethod.updateEnabled = FALSE;    }    ixEthDBEventProcessorRunning = FALSE;}/** * @brief event processor routine * * @param event event to be processed * @param triggerPorts port map accumulating ports to be updated * * Processes learning events by synchronizing the database with * newly learnt data. Called only by @ref ixEthDBEventProcessorLoop(). * * @warning do not call directly * * @internal */IX_ETH_DB_PRIVATEvoid ixEthDBProcessEvent(PortEvent *local_event, IxEthDBPortMap triggerPorts){    MacDescriptor recordTemplate;    switch (local_event->eventType)    {        case IX_ETH_DB_ADD_FILTERING_RECORD:            /* add record */            memset(&recordTemplate, 0, sizeof (recordTemplate));            memcpy(recordTemplate.macAddress, local_event->macAddr.macAddress, IX_IEEE803_MAC_ADDRESS_SIZE);                        recordTemplate.type   = IX_ETH_DB_FILTERING_RECORD;            recordTemplate.portID = local_event->portID;            recordTemplate.recordData.filteringData.staticEntry = local_event->staticEntry;                        ixEthDBAdd(&recordTemplate, triggerPorts);            IX_ETH_DB_EVENTS_TRACE("DB: (Events) Added record on port %d\n", local_event->portID);            break;        case IX_ETH_DB_REMOVE_FILTERING_RECORD:            /* remove record */            memset(&recordTemplate, 0, sizeof (recordTemplate));            memcpy(recordTemplate.macAddress, local_event->macAddr.macAddress, IX_IEEE803_MAC_ADDRESS_SIZE);                        recordTemplate.type = IX_ETH_DB_FILTERING_RECORD | IX_ETH_DB_FILTERING_VLAN_RECORD;                        ixEthDBRemove(&recordTemplate, triggerPorts);                        IX_ETH_DB_EVENTS_TRACE("DB: (Events) Removed record on port %d\n", local_event->portID);            break;        default:            /* can't handle/not interested in this event type */            ERROR_LOG("DB: (Events) Event processor received an unknown event type (0x%X)\n", local_event->eventType);            return;    }}/** * @brief asynchronously adds a filtering record * by posting an ADD_FILTERING_RECORD event to the event queue * * @param macAddr MAC address of the new record * @param portID port ID of the new record * @param staticEntry TRUE if record is static, FALSE if dynamic * * @return IX_ETH_DB_SUCCESS if the event creation was * successfull or IX_ETH_DB_BUSY if the event queue is full * * @internal */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBTriggerAddPortUpdate(IxEthDBMacAddr *macAddr, IxEthDBPortId portID, BOOL staticEntry){    MacDescriptor reference;        TEST_FIXTURE_INCREMENT_DB_CORE_ACCESS_COUNTER;    /* fill search fields */    memcpy(reference.macAddress, macAddr, IX_IEEE803_MAC_ADDRESS_SIZE);    reference.portID = portID;        /* set acceptable record types */    reference.type = IX_ETH_DB_ALL_FILTERING_RECORDS;    if (ixEthDBPeekHashEntry(&dbHashtable, IX_ETH_DB_MAC_PORT_KEY, &reference) == IX_ETH_DB_SUCCESS)    {        /* already have an identical record */        return IX_ETH_DB_SUCCESS;    }    else    {        return ixEthDBTriggerPortUpdate(IX_ETH_DB_ADD_FILTERING_RECORD, macAddr, portID, staticEntry);    }}/** * @brief asynchronously removes a filtering record * by posting a REMOVE_FILTERING_RECORD event to the event queue * * @param macAddr MAC address of the record to remove * @param portID port ID of the record to remove * * @return IX_ETH_DB_SUCCESS if the event creation was * successfull or IX_ETH_DB_BUSY if the event queue is full * * @internal */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBTriggerRemovePortUpdate(IxEthDBMacAddr *macAddr, IxEthDBPortId portID){    if (ixEthDBPeek(macAddr, IX_ETH_DB_ALL_FILTERING_RECORDS) != IX_ETH_DB_NO_SUCH_ADDR)    {        return ixEthDBTriggerPortUpdate(IX_ETH_DB_REMOVE_FILTERING_RECORD, macAddr, portID, FALSE);    }    else    {        return IX_ETH_DB_NO_SUCH_ADDR;    }}/** * @brief adds an ADD or REMOVE event to the main event queue * * @param eventType event type - IX_ETH_DB_ADD_FILTERING_RECORD  * to add and IX_ETH_DB_REMOVE_FILTERING_RECORD to remove a * record. * * @return IX_ETH_DB_SUCCESS if the event was successfully * sent or IX_ETH_DB_BUSY if the event queue is full * * @internal */IX_ETH_DB_PRIVATEIxEthDBStatus ixEthDBTriggerPortUpdate(UINT32 eventType, IxEthDBMacAddr *macAddr, IxEthDBPortId portID, BOOL staticEntry){    UINT32 intLockKey;    /* lock interrupts to protect queue */    intLockKey = ixOsalIrqLock();    if (CAN_ENQUEUE(&eventQueue))    {        PortEvent *queueEvent = QUEUE_HEAD(&eventQueue);        /* update fields on the queue */        memcpy(queueEvent->macAddr.macAddress, macAddr->macAddress, IX_IEEE803_MAC_ADDRESS_SIZE);                queueEvent->eventType     = eventType;        queueEvent->portID        = portID;        queueEvent->staticEntry   = staticEntry;        PUSH_UPDATE_QUEUE(&eventQueue);        /* imcrement event queue semaphore */        ixOsalSemaphorePost(&eventQueueSemaphore);                /* unlock interrupts */        ixOsalIrqUnlock(intLockKey);        return IX_ETH_DB_SUCCESS;    }    else /* event queue full */    {        /* unlock interrupts */        ixOsalIrqUnlock(intLockKey);        return IX_ETH_DB_BUSY;    }}/** * @brief Locks learning tree updates and port disable * * * This function locks portUpdateLock single mutex. It is primarily used * to avoid executing 'port disable' during ELT maintenance. * * @internal */IX_ETH_DB_PUBLICvoid ixEthDBUpdateLock(void){    ixOsalMutexLock(&portUpdateLock, IX_OSAL_WAIT_FOREVER);}/** * @brief Unlocks learning tree updates and port disable * * * This function unlocks a portUpdateLock mutex. It is primarily used * to avoid executing 'port disable' during ELT maintenance. * * @internal */IX_ETH_DB_PUBLICvoid ixEthDBUpdateUnlock(void){    ixOsalMutexUnlock(&portUpdateLock);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -