📄 ixethaccdataplane.c
字号:
ixEthAccPortData[portId].ixEthAccTxData.schDiscipline = sched; return (IX_ETH_ACC_SUCCESS);}IX_ETH_ACC_PUBLICIxEthAccStatus ixEthAccRxSchedulingDisciplineSetPriv(IxEthAccSchedulerDiscipline sched){ if (sched != FIFO_PRIORITY && sched != FIFO_NO_PRIORITY) { return (IX_ETH_ACC_INVALID_ARG); } ixEthAccDataInfo.schDiscipline = sched; return (IX_ETH_ACC_SUCCESS);}/** * @fn ixEthRxFrameProcess(IxEthAccPortId portId, IX_OSAL_MBUF *mbufPtr) * * @brief process incoming frame : * * @param @ref IxQMgrCallback IxQMgrMultiBufferCallback * * @return none * * @internal * */IX_ETH_ACC_PRIVATE BOOLixEthRxFrameProcess(IxEthAccPortId portId, IX_OSAL_MBUF *mbufPtr){ UINT32 flags; IxEthDBStatus result;#ifndef NDEBUG /* Prudent to at least check the port is within range */ if (portId >= IX_ETH_ACC_NUMBER_OF_PORTS) { ixEthAccDataStats.unexpectedError++; IX_ETH_ACC_FATAL_LOG( "ixEthRxFrameProcess: Illegal port: %u\n", (UINT32)portId, 0, 0, 0, 0, 0); return FALSE; }#endif /* convert fields from mbuf header */ ixEthAccMbufFromRxQ(mbufPtr); /* check about any special processing for this frame */ flags = IX_ETHACC_NE_FLAGS(mbufPtr); if ((flags & (IX_ETHACC_NE_FILTERMASK | IX_ETHACC_NE_NEWSRCMASK)) == 0) { /* "best case" scenario : nothing special to do for this frame */ return TRUE; }#ifdef CONFIG_IXP425_COMPONENT_ETHDB /* if a new source MAC address is detected by the NPE, * update IxEthDB with the portId and the MAC address. */ if ((flags & IX_ETHACC_NE_NEWSRCMASK & ixEthAccNewSrcMask) != 0) { result = ixEthDBFilteringDynamicEntryProvision(portId, (IxEthDBMacAddr *) IX_ETHACC_NE_SOURCEMAC(mbufPtr)); if (result != IX_ETH_DB_SUCCESS && result != IX_ETH_DB_FEATURE_UNAVAILABLE) { if ((ixEthAccMacState[portId].portDisableState == ACTIVE) && (result != IX_ETH_DB_BUSY)) { RX_STATS_INC(portId, rxUnexpectedError); IX_ETH_ACC_FATAL_LOG("ixEthRxFrameProcess: Failed to add source MAC \ to the Learning/Filtering database\n", 0, 0, 0, 0, 0, 0); } else { /* we expect this to fail during PortDisable, as EthDB is disabled for * that port and will refuse to learn new addresses */ } } else { RX_STATS_INC(portId, rxUnlearnedMacAddress); } }#endif /* check if this frame should have been filtered * by the NPE and take the appropriate action */ if (((flags & IX_ETHACC_NE_FILTERMASK) != 0) && (ixEthAccMacState[portId].portDisableState == ACTIVE)) { /* If the mbuf was allocated with a small data size, or the current data pointer is not * within the allocated data area, then the buffer is non-standard and has to be * replenished with the minimum size only */ if( (IX_OSAL_MBUF_ALLOCATED_BUFF_LEN(mbufPtr) < IX_ETHNPE_ACC_RXFREE_BUFFER_LENGTH_MIN) || ((UINT8 *)IX_OSAL_MBUF_ALLOCATED_BUFF_DATA(mbufPtr) > IX_OSAL_MBUF_MDATA(mbufPtr)) || ((UINT8 *)(IX_OSAL_MBUF_ALLOCATED_BUFF_DATA(mbufPtr) + IX_OSAL_MBUF_ALLOCATED_BUFF_LEN(mbufPtr)) < IX_OSAL_MBUF_MDATA(mbufPtr)) ) { /* set to minimum length */ IX_OSAL_MBUF_MLEN(mbufPtr) = IX_OSAL_MBUF_PKT_LEN(mbufPtr) = IX_ETHNPE_ACC_RXFREE_BUFFER_LENGTH_MIN; } else { /* restore original length */ IX_OSAL_MBUF_MLEN(mbufPtr) = IX_OSAL_MBUF_PKT_LEN(mbufPtr) = ( IX_OSAL_MBUF_ALLOCATED_BUFF_LEN(mbufPtr) - (IX_OSAL_MBUF_MDATA(mbufPtr) - (UINT8 *)IX_OSAL_MBUF_ALLOCATED_BUFF_DATA(mbufPtr)) ); } /* replenish from here */ if (ixEthAccPortRxFreeReplenish(portId, mbufPtr) != IX_ETH_ACC_SUCCESS) { IX_ETH_ACC_FATAL_LOG("ixEthRxFrameProcess: Failed to replenish with filtered frame\ on port %d\n", portId, 0, 0, 0, 0, 0); } RX_STATS_INC(portId, rxFiltered); /* indicate that frame should not be subjected to further processing */ return FALSE; } return TRUE;}/** * @fn ixEthRxFrameQMCallback * * @brief receive callback for Frame receive Q from NPE * * Frames are passed one-at-a-time to the user * * @param @ref IxQMgrCallback * * @return none * * @internal * * Design note : while processing the entry X, entry X+1 is preloaded * into memory to reduce the number of stall cycles * */void ixEthRxFrameQMCallback(IxQMgrQId qId, IxQMgrCallbackId callbackId){ IX_OSAL_MBUF *mbufPtr; IX_OSAL_MBUF *nextMbufPtr; UINT32 qEntry; UINT32 nextQEntry; UINT32 *qEntryPtr; UINT32 portId; UINT32 destPortId; UINT32 npeId; UINT32 rxQReadStatus; /* * Design note : entries are read in a buffer, This buffer contains * an extra zeroed entry so the loop will * always terminate on a null entry, whatever the result of Burst read is. */ UINT32 rxQEntry[IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK + 1]; /* * Indication of the number of times the callback is used. */ IX_ETH_ACC_STATS_INC(ixEthAccDataStats.rxCallbackCounter); do { /* * Indication of the number of times the queue is drained */ IX_ETH_ACC_STATS_INC(ixEthAccDataStats.rxCallbackBurstRead); /* ensure the last entry of the array contains a zeroed value */ qEntryPtr = rxQEntry; qEntryPtr[IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK] = 0; rxQReadStatus = ixQMgrQBurstRead(qId, IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK, qEntryPtr);#ifndef NDEBUG if ((rxQReadStatus != IX_QMGR_Q_UNDERFLOW) && (rxQReadStatus != IX_SUCCESS)) { ixEthAccDataStats.unexpectedError++; /*major error*/ IX_ETH_ACC_FATAL_LOG( "ixEthRxFrameQMCallback:Error: %u\n", (UINT32)rxQReadStatus, 0, 0, 0, 0, 0); return; }#endif /* convert and preload the next entry * (the conversion function takes care about null pointers which * are used to mark the end of the loop) */ nextQEntry = *qEntryPtr; nextMbufPtr = ixEthAccEntryFromQConvert(nextQEntry, IX_ETHNPE_QM_Q_RXENET_ADDR_MASK); while(nextQEntry != 0) { /* get the next entry */ qEntry = nextQEntry; mbufPtr = nextMbufPtr;#ifndef NDEBUG if (mbufPtr == NULL) { ixEthAccDataStats.unexpectedError++; IX_ETH_ACC_FATAL_LOG( "ixEthRxFrameQMCallback: Null Mbuf Ptr\n", 0, 0, 0, 0, 0, 0); return; }#endif /* convert the next entry * (the conversion function takes care about null pointers which * are used to mark the end of the loop) */ nextQEntry = *(++qEntryPtr); nextMbufPtr = ixEthAccEntryFromQConvert(nextQEntry, IX_ETHNPE_QM_Q_RXENET_ADDR_MASK); /* * Get Port and Npe ID from message. */ npeId = ((IX_ETHNPE_QM_Q_RXENET_NPEID_MASK & qEntry) >> IX_ETHNPE_QM_Q_FIELD_NPEID_R); portId = IX_ETH_ACC_NPE_TO_PORT_ID(npeId); /* process frame, check the return code and skip the remaining of * the loop if the frame is to be filtered out */ if (ixEthRxFrameProcess(portId, mbufPtr)) { /* destination portId for this packet */ destPortId = IX_ETHACC_NE_DESTPORTID(mbufPtr); if (destPortId != IX_ETH_DB_UNKNOWN_PORT) { destPortId = IX_ETH_DB_NPE_LOGICAL_ID_TO_PORT_ID(destPortId); } /* test if QoS is enabled in ethAcc */ if (ixEthAccDataInfo.schDiscipline == FIFO_PRIORITY) { /* check if there is a higher priority queue * which may require processing and then process it. */ if (ixEthAccDataInfo.higherPriorityQueue[qId] < IX_QMGR_MAX_NUM_QUEUES) { ixEthRxFrameQMCallback(ixEthAccDataInfo.higherPriorityQueue[qId], callbackId); } } /* * increment priority stats */ RX_STATS_INC(portId,rxPriority[IX_ETHACC_NE_QOS(mbufPtr)]); /* * increment callback count stats */ RX_STATS_INC(portId,rxFrameClientCallback); /* * Call user level callback. */ ixEthAccPortData[portId].ixEthAccRxData.rxCallbackFn( ixEthAccPortData[portId].ixEthAccRxData.rxCallbackTag, mbufPtr, destPortId); } } } while (rxQReadStatus == IX_SUCCESS);}/** * @fn ixEthRxMultiBufferQMCallback * * @brief receive callback for Frame receive Q from NPE * * Frames are passed as an array to the user * * @param @ref IxQMgrCallback * * @return none * * @internal * * Design note : while processing the entry X, entry X+1 is preloaded * into memory to reduce the number of stall cycles * */void ixEthRxMultiBufferQMCallback(IxQMgrQId qId, IxQMgrCallbackId callbackId){ IX_OSAL_MBUF *mbufPtr; IX_OSAL_MBUF *nextMbufPtr; UINT32 qEntry; UINT32 nextQEntry; UINT32 *qEntryPtr; UINT32 portId; UINT32 npeId; UINT32 rxQReadStatus; /* * Design note : entries are read in a static buffer, This buffer contains * an extra zeroed entry so the loop will * always terminate on a null entry, whatever the result of Burst read is. */ static UINT32 rxQEntry[IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK + 1]; static IX_OSAL_MBUF *rxMbufPortArray[IX_ETH_ACC_NUMBER_OF_PORTS][IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK + 1]; IX_OSAL_MBUF **rxMbufPtr[IX_ETH_ACC_NUMBER_OF_PORTS]; for (portId = 0; portId < IX_ETH_ACC_NUMBER_OF_PORTS; portId++) { rxMbufPtr[portId] = rxMbufPortArray[portId]; } /* * Indication of the number of times the callback is used. */ IX_ETH_ACC_STATS_INC(ixEthAccDataStats.rxCallbackCounter); do { /* * Indication of the number of times the queue is drained */ IX_ETH_ACC_STATS_INC(ixEthAccDataStats.rxCallbackBurstRead); /* ensure the last entry of the array contains a zeroed value */ qEntryPtr = rxQEntry; qEntryPtr[IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK] = 0; rxQReadStatus = ixQMgrQBurstRead(qId, IX_ETH_ACC_MAX_RX_FRAME_CONSUME_PER_CALLBACK, qEntryPtr);#ifndef NDEBUG if ((rxQReadStatus != IX_QMGR_Q_UNDERFLOW) && (rxQReadStatus != IX_SUCCESS)) { ixEthAccDataStats.unexpectedError++; /*major error*/ IX_ETH_ACC_FATAL_LOG( "ixEthRxFrameMultiBufferQMCallback:Error: %u\n", (UINT32)rxQReadStatus, 0, 0, 0, 0, 0); return; }#endif /* convert and preload the next entry * (the conversion function takes care about null pointers which * are used to mark the end of the loop) */ nextQEntry = *qEntryPtr; nextMbufPtr = ixEthAccEntryFromQConvert(nextQEntry, IX_ETHNPE_QM_Q_RXENET_ADDR_MASK); while(nextQEntry != 0) { /* get the next entry */ qEntry = nextQEntry; mbufPtr = nextMbufPtr;#ifndef NDEBUG if (mbufPtr == NULL) { ixEthAccDataStats.unexpectedError++; IX_ETH_ACC_FATAL_LOG( "ixEthRxFrameMultiBufferQMCallback:Error: Null Mbuf Ptr\n", 0, 0, 0, 0, 0, 0); return; }#endif /* convert the next entry * (the conversion function takes care about null pointers which * are used to mark the end of the loop) */ nextQEntry = *(++qEntryPtr); nextMbufPtr = ixEthAccEntryFromQConvert(nextQEntry, IX_ETHNPE_QM_Q_RXENET_ADDR_MASK); /* * Get Port and Npe ID from message. */ npeId = ((IX_ETHNPE_QM_Q_RXENET_NPEID_MASK & qEntry) >> IX_ETHNPE_QM_Q_FIELD_NPEID_R); portId = IX_ETH_ACC_NPE_TO_PORT_ID(npeId); /* skip the remaining of the loop if the frame is * to be filtered out */ if (ixEthRxFrameProcess(portId, mbufPtr)) { /* store a mbuf pointer in an array */ *rxMbufPtr[portId]++ = mbufPtr; /* * increment priority stats */ RX_STATS_INC(portId,rxPriority[IX_ETHACC_NE_QOS(mbufPtr)]); } /* test for QoS enabled in ethAcc */ if (ixEthAccDataInfo.schDiscipline == FIFO_PRIORITY) { /* check if there is a higher priority queue * which may require processing and then process it. */ if (ixEthAccDataInfo.higherPriorityQueue[qId] < IX_QMGR_MAX_NUM_QUEUES) { ixEthRxMultiBufferQMCallback(ixEthAccDataInfo.higherPriorityQueue[qId], callbackId); } } } /* check if any of the the arrays contains any entry */ for (portId = 0; portId < IX_ETH_ACC_NUMBER_OF_PORTS; portId++) { if (rxMbufPtr[portId] != rxMbufPortArray[portId]) { /* add a last NULL pointer at the end of the * array of mbuf pointers */ *rxMbufPtr[portId] = NULL; /* * increment callback count stats */ RX_STATS_INC(portId,rxFrameClientCallback); /* * Call user level callback with an array of * buffers (NULL terminated) */ ixEthAccPortData[portId].ixEthAccRxData. rxMultiBufferCallbackFn( ixEthAccPortData[portId].ixEthAccRxData. rxMultiBufferCallbackTag, rxMbufPortArray[portId]); /* reset the buffer pointer to the beginning of * the array */ rxMbufPtr[portId] = rxMbufPortArray[portId]; } } } while (rxQReadStatus == IX_SUCCESS);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -