📄 ixatmcodelet.c
字号:
/**************** ATM initialisation ****************/ /* Setup Utopia loopback mode */ if (IX_ATMCODELET_UTOPIA_LOOPBACK == ixAtmCodeletMode) { if (numPorts == 1) { loopbackMode = IX_ATMM_UTOPIA_LOOPBACK_ENABLED; } else { IX_ATMCODELET_LOG("codeletInit():utopiaLoopbackEnabled(TRUE) not allowed for > 1 port\n"); return IX_FAIL; } } else {#ifdef VALIDATION_PLATFORM_USED /* Request test and stimulus FPGA (validation platform only) to * configure Utopia as a master */ ixAtmUtilsUtopiaFpgaStimulusAsMasterSet();#endif loopbackMode = IX_ATMM_UTOPIA_LOOPBACK_DISABLED; } /* * Set the UTOPIA Phy port addresss for each port. These addresses need to be defined * as per the Physical interface used. */ for (port=0; port < (IxAtmLogicalPort)numPorts; port++) { portCfgs[port].UtopiaTxPhyAddr = IX_ATMCODELET_UTOPIA_PHY_ADDR_BASE + port; portCfgs[port].UtopiaRxPhyAddr = IX_ATMCODELET_UTOPIA_PHY_ADDR_BASE + port; } /* The following is the order in which each component should be initialised: Lower Level Components->IxAtmSch->IxAtmdAcc->IxAtmm->IxAtmCodelet. At this stage all lower level components(IxQMgr, IxNpeMh) have been initialised and the NPE image have been downloaded. */ IX_ATMCODELET_COMP_INIT(ixAtmSchInit()); IX_ATMCODELET_COMP_INIT(ixAtmdAccInit()); IX_ATMCODELET_COMP_INIT(ixAtmmInit()); IX_ATMCODELET_COMP_INIT(ixAtmmUtopiaInit(numPorts, phyMode, portCfgs, loopbackMode)); IX_ATMCODELET_COMP_INIT(ixAtmUtilsMbufPoolInit()); /* Initialize Ports */ for (port=0; port < (IxAtmLogicalPort)numPorts; port++) { /* Initialise the port with IxAtmm */ retval = ixAtmmPortInitialize (port, IX_ATMCODELET_UTOPIA_TX_PORT_RATE, IX_ATMCODELET_UTOPIA_RX_PORT_RATE); if (retval != IX_SUCCESS) { IX_ATMCODELET_LOG ("Port Initialization failed for port %u\n", port); return IX_FAIL; } /* Enable the port in AtmdAcc */ retval = ixAtmmPortEnable(port); if (retval != IX_SUCCESS) { IX_ATMCODELET_LOG ("Port Enable failed for port %u\n", port); return IX_FAIL; } } /**************** Codelet initialisation ****************/ /* Utopia Loopback/ Remote Loopback */ if ((IX_ATMCODELET_UTOPIA_LOOPBACK == ixAtmCodeletMode) || (IX_ATMCODELET_REMOTE_LOOPBACK == ixAtmCodeletMode)) { /* Initialize the RxTx subcomponent */ IX_ATMCODELET_COMP_INIT(ixAtmRxTxInit (&ixAtmCodeletStats)); } else /* Software Loopback */ { /* Initialize the SwLoopback subcomponent */ IX_ATMCODELET_COMP_INIT(ixAtmSwLbInit (&ixAtmCodeletStats, rxToTxRatio)); } /* Set the number of ports configured */ ixAtmCodeletNumPortsConfigured = numPorts; /* Now provision the OAM Tx Port VCs and Rx VC channels */ retval = ixOamCodeletInit (numPorts); if (retval != IX_SUCCESS) { IX_ATMCODELET_LOG ("ixOamCodeletInit failed\n"); return IX_FAIL; } /* set initialised flag */ ixAtmCodeletInitialized = TRUE; IX_ATMCODELET_LOG ("Initialization Phase Complete\n"); return IX_SUCCESS;}/* -------------------------------------------------------------- Provision a specified number of ports and channels. The number of ports provisioned must be <= the number of ports specified to ixAtmCodeletInit(). -------------------------------------------------------------- */PUBLIC IX_STATUSixAtmCodeletUbrChannelsProvision (UINT32 numPorts, UINT32 numChannels, IxAtmdAccAalType aalType){ IX_STATUS retval; /* -------------------------------------------------------------- A call to ixAtmCodeletInit() must be made before this function can be called. The initialisation function sets the following values used by this function: - ixAtmCodeletInitialized - ixAtmCodeletSoftwareLoopbackEnabled - ixAtmCodeletUtopiaLoopbackEnabled -------------------------------------------------------------- */ if (!ixAtmCodeletInitialized) { IX_ATMCODELET_LOG("System not initialized\n"); return IX_FAIL; } /* * Check that the number of ports specified is not greater than the number * specified at initialisation */ if (numPorts > ixAtmCodeletNumPortsConfigured) { IX_ATMCODELET_LOG("numPorts is > ports configured at initialization %u\n", ixAtmCodeletNumPortsConfigured); return IX_FAIL; } if (ixAtmCodeletSoftwareLoopbackEnabled) { retval = ixAtmSwLbChannelsProvision (numPorts, numChannels, aalType); } else { retval = ixAtmRxTxChannelsProvision (numPorts, numChannels, aalType); } if (retval != IX_SUCCESS) { IX_ATMCODELET_LOG("Failed to provision channels\n"); } else { /* Add to the total channels configured */ ixAtmCodeletNumChannelsConfigured += numChannels; } return retval;}/* -------------------------------------------------------------- Remove all VCs registered in a previous call to ixAtmCodeletTransportChannelsProvision -------------------------------------------------------------- */PUBLIC IX_STATUSixAtmCodeletUbrChannelsRemove (void){ IX_STATUS retval; if (ixAtmCodeletSoftwareLoopbackEnabled) { retval = ixAtmSwLbChannelsRemove(); } else { retval = ixAtmRxTxChannelsRemove(); } return retval;}/* -------------------------------------------------------------- Transmit a number of Aal0 packets each containing cellsPerPacket cells. Packets are transmitted using the following algorithm: 1st packet is transmitted on the first Aal0 channel configured 2nd packet is transmitted on the next Aal0 channel configured 3rd ... If the number of packets to send is greater than the number of channels configured then the (numChannlesConfigured + 1)th packet is sent on the 1st channel configured and so on. -------------------------------------------------------------- */IX_STATUSixAtmCodeletAal0PacketsSend (UINT32 cellsPerPacket){ IX_STATUS retval; /* Check it is less than max cells to transmit */ if (cellsPerPacket > IX_ATMCODELET_MAX_CELLS_TO_SEND) { IX_ATMCODELET_LOG ("cellsPerPacket must be <= %u\n", IX_ATMCODELET_MAX_CELLS_TO_SEND); return IX_FAIL; } retval = ixAtmRxTxAal0PacketsSend (cellsPerPacket); if (IX_SUCCESS != retval) { IX_ATMCODELET_LOG ("Failed to send AAL0 Packets\n"); } return retval;}/* -------------------------------------------------------------- Transmit a number of Aal5 CPCS SDUs of length sduLength. Sdus are transmitted using the following algorithm: 1st sdu is transmitted on the first Aal5 channel configured 2nd sdu is transmitted on the next Aal5 channel configured 3rd ... If the number of sdus to send is greater than the number of channels configured then (numChannlesConfigured + 1)th sdu is sent on the 1st channel configured and so on. -------------------------------------------------------------- */PUBLIC IX_STATUSixAtmCodeletAal5CpcsSdusSend (UINT32 sduLength){ IX_STATUS retval; if (sduLength > IX_ATMCODELET_MAX_PACKET_LENGTH) { IX_ATMCODELET_LOG ("SDU Length must be <= %u\n", IX_ATMCODELET_MAX_PACKET_LENGTH); return IX_FAIL; } retval = ixAtmRxTxAal5CpcsSdusSend (sduLength); if (IX_SUCCESS != retval) { IX_ATMCODELET_LOG ("Failed to send Aal5 SDUs\n"); } return retval;}/* -------------------------------------------------------------- Modify the transmit port rate. The transmit port rate the is by IxAtmSch to perform its shaping functions. -------------------------------------------------------------- */PUBLIC IX_STATUSixAtmCodeletPortRateModify (IxAtmLogicalPort port, UINT32 portRate){ IX_STATUS retval; retval = ixAtmSchPortRateModify (port, portRate); if (retval != IX_SUCCESS) { IX_ATMCODELET_LOG("ixAtmCodeletPortRateModify(): Failed to modifiy the port rate\n"); } return retval;}/* -------------------------------------------------------------- Display some statistics about each port configured. -------------------------------------------------------------- */PUBLIC voidixAtmCodeletPortQuery (void){ ixAtmdAccShow ();}/* -------------------------------------------------------------- Dispaly some statistics about the transmit and receive streams. -------------------------------------------------------------- */PUBLIC voidixAtmCodeletShow (void){ IX_ATMCODELET_LOG("\nTx =============================\n"); IX_ATMCODELET_LOG(" Pdus transmitted............. %10.10u\n", ixAtmCodeletStats.txPdus); IX_ATMCODELET_LOG(" Bytes transmitted........ %10.10u\n", ixAtmCodeletStats.txBytes); IX_ATMCODELET_LOG(" Pdus submit busy......... %10.10u\n", ixAtmCodeletStats.txPdusSubmitBusy); IX_ATMCODELET_LOG(" Pdus submit fail......... %10.10u\n", ixAtmCodeletStats.txPdusSubmitFail); IX_ATMCODELET_LOG("TxDone ==========================\n"); IX_ATMCODELET_LOG(" Pdus transmit done........... %10.10u\n", ixAtmCodeletStats.txDonePdus); IX_ATMCODELET_LOG("Rx =============================\n"); IX_ATMCODELET_LOG(" Pdus received................ %10.10u\n", ixAtmCodeletStats.rxPdus); IX_ATMCODELET_LOG(" Bytes received........... %10.10u\n", ixAtmCodeletStats.rxBytes); IX_ATMCODELET_LOG(" Pdus Invalid............. %10.10u\n", ixAtmCodeletStats.rxPdusInvalid); IX_ATMCODELET_LOG("RxFree =============================\n"); IX_ATMCODELET_LOG(" Buffers receive replenish.... %10.10u\n\n\n\n", ixAtmCodeletStats.rxFreeBuffers);}/* -------------------------------------------------------------- IxQMgrDispatcher task entry point. -------------------------------------------------------------- */PRIVATE intixAtmCodeletDispatchTask (void *arg, void **ptrRetObj){ /* This is an example of a task based dispatcher */ while (TRUE) { /* ATM Tx, Rx, TxDone queues */ (*dispatcherFunc) (IX_QMGR_QUELOW_GROUP); /* ATM RxFree queues */ (*dispatcherFunc) (IX_QMGR_QUEUPP_GROUP); ixOsalSleep(0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -