/* * Function definition: ixEthAccCodeletSwBridgeStop() * * Stop bridge datapath */ IX_STATUS ixEthAccCodeletSwBridgeStop(IxEthAccPortId firstPortId, IxEthAccPortId secondPortId) { /* Unconfigure the traffic callbacks for both ports */ if ( ixEthAccCodeletPortUnconfigure(firstPortId) != IX_SUCCESS) { printf("SwBridge: Failed to unconfigure Port %u\n", firstPortId); return (IX_FAIL); } if ( ixEthAccCodeletPortUnconfigure(secondPortId) != IX_SUCCESS) { printf("SwBridge: Failed to unconfigure Port %u\n", secondPortId); return (IX_FAIL); } /* Disable the traffic over both ports */ if ( ixEthAccPortDisable(firstPortId) != IX_SUCCESS) { printf("SwBridge: Failed to disable Port %u\n", firstPortId); return (IX_FAIL); } if ( ixEthAccPortDisable(secondPortId) != IX_SUCCESS) { printf("SwBridge: Failed to disable Port %u\n", secondPortId); return (IX_FAIL); } return (IX_SUCCESS); }
PRIVATE void ixTimeSyncAccCodeletPortDisable () { IxEthAccPortId portId; IxEthAccStatus status; for (portId = IX_ETH_PORT_1; portId <= IX_ETH_PORT_3; portId++) { status = ixEthAccPortDisable (portId); if (IX_ETH_ACC_SUCCESS != status) { ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, "ixTimeSyncAccCodeletPortDisable: failed to disable port %d, error code %d\n", portId, status, 0, 0, 0, 0); } } } /* end of ixTimeSyncAccCodeletPortDisable function */
/* * Function definition: ixEthAccCodeletStop() * * Stop datapath traffic for the demo. This works assuming nobody will * continue to transmit or replenish for this port. This function * will first change the registered callbacks to callbacks which will * drop all traffic. After this portDisable is called to flush all * pending traffic inside the NPEs. */ PRIVATE IX_STATUS ixEthAccCodeletPortLoopbackStop(IxEthAccPortId portId) { if (ixEthAccCodeletPortMultiBufferUnconfigure(portId) != IX_ETH_ACC_SUCCESS) { printf("Loopbacks: Failed to unconfigure the port %u\n", (UINT32)portId); return IX_FAIL; } /* disable traffic */ if(ixEthAccPortDisable(portId) != IX_ETH_ACC_SUCCESS) { printf("Loopbacks: Error Disabling port %u\n", (UINT32)portId); return (IX_FAIL); } return (IX_SUCCESS); }
/* * Function definition: ixEthAccCodeletSwBridgeQoSStop() * * Unconfigure QoS and Stop bridge datapath */ IX_STATUS ixEthAccCodeletSwBridgeQoSStop(IxEthAccPortId firstPortId, IxEthAccPortId secondPortId) { /* Stop the receive and transmit traffic */ if ( ixEthAccCodeletPortUnconfigure(firstPortId) != IX_SUCCESS) { printf("SwBridgeQos: Failed to unconfigure the Bridge Operation for port %u\n", firstPortId); return (IX_FAIL); } if ( ixEthAccCodeletPortUnconfigure(secondPortId) != IX_SUCCESS) { printf("SwBridgeQos: Failed to unconfigure the Bridge Operation for port %u\n", secondPortId); return (IX_FAIL); } if ( ixEthAccPortDisable(firstPortId) != IX_SUCCESS) { printf("SwBridgeQos: Failed to stop the Bridge Operation for port %u\n", firstPortId); return (IX_FAIL); } if ( ixEthAccPortDisable(secondPortId) != IX_SUCCESS) { printf("SwBridgeQos: Failed to stop the Bridge Operation for port %u\n", secondPortId); return (IX_FAIL); } /* Disable Xscale QoS */ printf("Set Tx Scheduling discipline...\n"); if (ixEthAccTxSchedulingDisciplineSet(firstPortId, FIFO_NO_PRIORITY) != IX_ETH_ACC_SUCCESS) { printf("SwBridgeQos: Failed to set Tx Scheduling discipline port %u\n", (UINT32)firstPortId); return (IX_FAIL); } if (ixEthAccTxSchedulingDisciplineSet(secondPortId, FIFO_NO_PRIORITY) != IX_ETH_ACC_SUCCESS) { printf("SwBridgeQos: Failed to set Tx Scheduling discipline port %u\n", (UINT32)secondPortId); return (IX_FAIL); } printf("Set Rx Scheduling discipline...\n"); if (ixEthAccRxSchedulingDisciplineSet(FIFO_NO_PRIORITY) != IX_ETH_ACC_SUCCESS) { printf("SwBridgeQos: Failed to set Rx Scheduling discipline\n"); return (IX_FAIL); } /* Enable the EDB Port again and disable the VLAN/QoS configuration * note that no traffic will pass in this mode. After the restoring the * configuration to a known state that will not affect other operation * modes the ethDB port will be disabled */ if ((ixEthDBPortEnable(firstPortId)) != IX_ETH_DB_SUCCESS) { printf("SwBridgeQoS: Cannot enable port %u\n", firstPortId); return (IX_FAIL); } if ((ixEthDBPortEnable(secondPortId)) != IX_ETH_DB_SUCCESS) { printf("SwBridgeQoS: Cannot enable port %u\n", secondPortId); return (IX_FAIL); } /* Disable NPE QoS and VLAN setup */ printf("Disable VLAN tagging...\n"); if (ixEthDBEgressVlanRangeTaggingEnabledSet(firstPortId, IX_ETHACC_CODELET_VLANID_MIN, IX_ETHACC_CODELET_VLANID_MAX, FALSE) != IX_ETH_DB_SUCCESS) { printf("SwBridgeQos: Failed to disable VLAN Egress tagging for port %u\n", firstPortId); return (IX_FAIL); } printf("Disable tagged frames...\n"); if (ixEthDBAcceptableFrameTypeSet(firstPortId, IX_ETH_DB_UNTAGGED_FRAMES) != IX_ETH_DB_SUCCESS) { printf("SwBridgeQos: Failed to set the acceptable frame type for port %u\n", firstPortId); return (IX_FAIL); } /* Disable the VLAN/QoS Feature to return to the initial processing * capabilities */ if ( ixEthDBFeatureEnable((IxEthDBPortId) firstPortId, IX_ETH_DB_VLAN_QOS, FALSE) != IX_ETH_DB_SUCCESS ) { printf("SwBridgeQoS: Failed to disable the VLAN/QoS Feature for port %u\n", firstPortId); return (IX_FAIL); } /* disable the ethDB port */ if ((ixEthDBPortDisable(firstPortId)) != IX_ETH_DB_SUCCESS) { printf("SwBridgeQoS: Cannot disable port %u\n", firstPortId); return (IX_FAIL); } if ((ixEthDBPortDisable(secondPortId)) != IX_ETH_DB_SUCCESS) { printf("SwBridgeQoS: Cannot disable port %u\n", secondPortId); return (IX_FAIL); } /* Restore the link speed to 100 Mbit */ if (ixEthAccCodeletLinkDefaultSpeedSet(secondPortId) != IX_SUCCESS) { printf("SwBridgeQos: Failed to reset port %u to a 100 Mbit port!\n", secondPortId); return (IX_FAIL); } return (IX_SUCCESS); }
/* * Function definition: ixEthAccCodeletDBLearningRun() * * Run ethDB demo for all ports passed as parameters */ IX_STATUS ixEthAccCodeletDBLearningRun(BOOL validPorts[]) { IxEthAccPortId portId; IxEthDBPortId portPtr; IxEthDBMacAddr staticMacAddress[IX_ETHACC_CODELET_MAX_PORT] = {{{0,1,2,3,4,5}}, {{6,7,8,9,0,1}}}; IxEthDBMacAddr dynamMacAddress[IX_ETHACC_CODELET_MAX_PORT] = {{{0xa,0xb,0xc,0xd,0xe,0xf}}, {{0x0,0xb,0x3,0xc,0x4,0xd}}}; if (ixEthAccCodeletDBMaintenanceStart() != IX_SUCCESS) { printf("DbLearning: Error spawning DB maintenance task\n"); return (IX_FAIL); } /* configure all existing ports */ for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++) { if (validPorts[portId]) { /* Configure the port */ printf("Configuring the port...\n"); if (ixEthAccCodeletPortConfigure(portId, ixEthAccCodeletMemPoolFreeRxCB, (IxEthAccPortMultiBufferRxCallback) NULL, ixEthAccCodeletMemPoolFreeTxCB, portId) != IX_ETH_ACC_SUCCESS) { printf("DbLearning: Failed to configure the port %u\n", (UINT32)portId); return IX_FAIL; } /* Enable the port */ printf("Enabling the port...\n"); if(ixEthAccPortEnable(portId) != IX_ETH_ACC_SUCCESS) { printf("DbLearning: Error enabling port %u\n", (UINT32)portId); return (IX_FAIL); } /* Add some static entries */ printf("Adding static entries...\n"); if (ixEthDBFilteringStaticEntryProvision(portId, &staticMacAddress[portId]) != IX_ETH_DB_SUCCESS) { printf("DbLearning: Failed to add static MAC to port %u\n", (UINT32)portId); return (IX_FAIL); } ixOsalSleep(100); /* Verify that the address has successfully been added */ if (ixEthDBFilteringDatabaseSearch(&portPtr, &staticMacAddress[portId]) == IX_ETH_DB_NO_SUCH_ADDR) { printf("DbLearning: Static MAC address not found in Database\n"); return (IX_FAIL); } /* Add some dynamic entries */ printf("Adding dynamic entries...\n"); if (ixEthDBFilteringDynamicEntryProvision(portId, &dynamMacAddress[portId]) != IX_ETH_DB_SUCCESS) { printf("DbLearning: Failed to add dynamic MAC to port %u\n", (UINT32)portId); } printf("Enabling aging...\n"); if (ixEthDBPortAgingEnable(portId) != IX_ETH_DB_SUCCESS) { printf("DbLearning: Failed to enable aging for port %u\n", (UINT32)portId); return (IX_FAIL); } } } ixEthDBFilteringDatabaseShowAll(); /* Wait 4 minutes over aging time (for safety) and verify that the * dynamic entries have been removed */ printf("Aging entries.\nWaiting for %d minutes...\n", IX_ETH_DB_LEARNING_ENTRY_AGE_TIME / 60 + 3); ixOsalSleep((IX_ETH_DB_LEARNING_ENTRY_AGE_TIME + 180) * 1000); ixEthDBFilteringDatabaseShowAll(); for (portId = 0; portId < IX_ETHACC_CODELET_MAX_PORT; portId++) { if (validPorts[portId]) { if(ixEthDBFilteringEntryDelete(&staticMacAddress[portId]) != IX_ETH_DB_SUCCESS) { printf("DbLearning: Failed to remove static MAC on port %u\n", (UINT32)portId); } /* Disable ports */ if(ixEthAccPortDisable(portId) != IX_ETH_ACC_SUCCESS) { printf("DbLearning: Error disabling port %u\n", (UINT32)portId); return (IX_FAIL); } } } /* wait for pending traffic to be completely received */ if (ixEthAccCodeletRecoverBuffers() != IX_SUCCESS) { printf("Warning : Not all buffers are accounted for!\n"); } return (IX_SUCCESS); }
IX_STATUS ixEthAccCodeletUninit(void) { IxEthAccPortId portId; IxEthAccStatus status; if(!ixEthAccCodeletInitialised) { /* already uninitialized */ return(IX_SUCCESS); } if (!ixEthAccCodeletStatsPollTaskStop) { ixEthAccCodeletStatsPollTaskStop = TRUE; if (ixOsalMutexLock (&ixEthAccCodeletStatsPollTaskRunning, IX_OSAL_WAIT_FOREVER) != IX_SUCCESS) { printf("CodeletMain: Error stopping Statistics Polling thread!\n"); return (IX_FAIL); } ixOsalMutexUnlock (&ixEthAccCodeletStatsPollTaskRunning); } for (portId = IX_ETH_PORT_1; portId < IX_ETHACC_CODELET_MAX_PORT; portId++) { status = ixEthAccPortDisable (portId); if (IX_ETH_ACC_SUCCESS != status) { printf("CodeletMain: Failed to disable port %d, error code %d\n", portId, status); return (IX_FAIL); } } if (ixEthAccCodeletDBMaintenanceStop() != IX_SUCCESS) { printf("CodeletMain: Error stopping DB Maintenance task!\n"); return (IX_FAIL); } if (ixEthAccUninit() != IX_SUCCESS) { printf("CodeletMain: Failed to uninitialize Ethernet Access Layer!\n"); return (IX_FAIL); } #ifdef __ixp46X if (ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEA) != IX_SUCCESS) { printf("CodeletMain: Failed to stop and reset NPE A!\n"); return (IX_FAIL); } #endif if (ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEB) != IX_SUCCESS) { printf("CodeletMain: Failed to stop and reset NPE B!\n"); return (IX_FAIL); } if (ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEC) != IX_SUCCESS) { printf("CodeletMain: Failed to stop and reset NPE C!\n"); return (IX_FAIL); } if (ixNpeDlUnload() != IX_SUCCESS) { printf("CodeletMain: Failed to unload NPE Downloader!\n"); return (IX_FAIL); } if (ixNpeMhUnload() != IX_SUCCESS) { printf("CodeletMain: Failed to unload NPE Message Handler!\n"); return (IX_FAIL); } if (ixEthAccCodeletDispatcherStop(IX_ETH_CODELET_QMGR_DISPATCH_MODE) != IX_SUCCESS) { printf("CodeletMain: Error stopping QMgr Dispatcher loop!\n"); return (IX_FAIL); } if (ixQMgrUnload() != IX_SUCCESS) { printf("CodeletMain: Failed to unload QMgr!\n"); return (IX_FAIL); } if (ixEthAccCodeletMemPoolFree() != IX_SUCCESS) { printf("CodeletMain: Failed to free memory pool!\n"); return (IX_FAIL); } ixEthAccCodeletInitialised = FALSE; return (IX_SUCCESS); }