PRIVATE void ixHssAccCodeletChannelisedDataSampleTransmit ( IxHssAccHssPort hssPortId, unsigned channelIndex, UINT8 *sample) { ClientInfo *pClientInfo = &clientInfo[hssPortId]; UINT8 *temp = NULL; /* to allow for caching, we request a cache flush before tx */ IX_OSAL_CACHE_FLUSH ( sample, IX_HSSACC_CODELET_CHAN_BYTES_PER_SAMPLE); /* update the pointer in the pointer list to point to the sample */ /* endianess conversion on txPointers */ temp = (UINT8 *) IX_OSAL_MMU_VIRT_TO_PHYS((UINT32)sample); (*pClientInfo->txPointers)[pClientInfo->lastTxOffset][channelIndex] = (UINT8 *) IX_OSAL_SWAP_BE_SHARED_LONG((UINT32) temp); IX_OSAL_CACHE_FLUSH ( &(*pClientInfo->txPointers)[pClientInfo->lastTxOffset][channelIndex], sizeof((*pClientInfo->txPointers)[pClientInfo->lastTxOffset][channelIndex])); /* update TX stats */ stats[hssPortId].chan.txSamples++; stats[hssPortId].chan.txBytes += IX_HSSACC_CODELET_CHAN_BYTES_PER_SAMPLE; }
/* * This function Converts a virtual address into a physical * address, including the dynamically mapped memory. * * Parameters virtAddr - virtual address to convert * Return value: corresponding physical address, or NULL * if there is no physical address addressable * by the given virtual address * OS: VxWorks, Linux, WinCE, QNX, eCos * Reentrant: Yes * IRQ safe: Yes */ PUBLIC UINT32 ixOsalIoMemVirtToPhys (UINT32 virtualAddress, UINT32 requestedCoherency) { IxOsalMemoryMap *map = ixOsalMemMapFind (virtualAddress, 0, SEARCH_VIRTUAL_ADDRESS, requestedCoherency); if (map != NULL) { return map->physicalAddress + virtualAddress - map->virtualAddress; } else { return (UINT32) IX_OSAL_MMU_VIRT_TO_PHYS (virtualAddress); } }
IX_ETH_DB_PUBLIC void ixEthDBDatabaseMaintenance() { HashIterator iterator; UINT32 portIndex; BOOL agingRequired = FALSE; /* ports who will have deleted records and therefore will need updating */ IxEthDBPortMap triggerPorts; if (IX_FEATURE_CTRL_SWCONFIG_ENABLED != ixFeatureCtrlSwConfigurationCheck (IX_FEATURECTRL_ETH_LEARNING)) { return; } SET_EMPTY_DEPENDENCY_MAP(triggerPorts); /* check if there's at least a port that needs aging */ for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++) { if (ixEthDBPortInfo[portIndex].agingEnabled && ixEthDBPortInfo[portIndex].enabled) { agingRequired = TRUE; } } if (agingRequired) { /* ask each NPE port to write back the database for aging inspection */ for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++) { if (ixEthDBPortDefinitions[portIndex].type == IX_ETH_NPE && ixEthDBPortInfo[portIndex].agingEnabled && ixEthDBPortInfo[portIndex].enabled) { IxNpeMhMessage message; IX_STATUS result; /* send EDB_GetMACAddressDatabase message */ FILL_GETMACADDRESSDATABASE(message, 0 /* unused */, IX_OSAL_MMU_VIRT_TO_PHYS(ixEthDBPortInfo[portIndex].updateMethod.npeUpdateZone)); IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portIndex), message, result); if (result == IX_SUCCESS) { /* analyze NPE copy */ ixEthDBNPESyncScan(portIndex, ixEthDBPortInfo[portIndex].updateMethod.npeUpdateZone, FULL_ELT_BYTE_SIZE); IX_ETH_DB_SUPPORT_TRACE("DB: (API) Finished scanning NPE tree on port %d\n", portIndex); } else { ixOsalLog(IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT, "EthDB: (Maintenance) warning, Clearing Database records for all types for port %d\n", portIndex, 0, 0, 0, 0, 0); ixEthDBDatabaseClear(portIndex, IX_ETH_DB_ALL_RECORD_TYPES); } } } /* browse database and age entries */ BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator)); while (IS_ITERATOR_VALID(&iterator)) { MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data; UINT32 *age = NULL; BOOL staticEntry = TRUE; if (descriptor->type == IX_ETH_DB_FILTERING_RECORD) { age = &descriptor->recordData.filteringData.age; staticEntry = descriptor->recordData.filteringData.staticEntry; } else if (descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD) { age = &descriptor->recordData.filteringVlanData.age; staticEntry = descriptor->recordData.filteringVlanData.staticEntry; } else { staticEntry = TRUE; } if (ixEthDBPortInfo[descriptor->portID].agingEnabled && (staticEntry == FALSE)) { /* manually increment the age if the port has no such capability */ if ((ixEthDBPortDefinitions[descriptor->portID].capabilities & IX_ETH_ENTRY_AGING) == 0) { *age += (IX_ETH_DB_MAINTENANCE_TIME / 60); } /* age entry if it exceeded the maximum time to live */ if (*age >= (IX_ETH_DB_LEARNING_ENTRY_AGE_TIME / 60)) { /* add port to the set of update trigger ports */ JOIN_PORT_TO_MAP(triggerPorts, descriptor->portID); /* delete entry */ BUSY_RETRY(ixEthDBRemoveEntryAtHashIterator(&dbHashtable, &iterator)); } else { /* move to the next record */ BUSY_RETRY(ixEthDBIncrementHashIterator(&dbHashtable, &iterator)); } } else { /* move to the next record */ BUSY_RETRY(ixEthDBIncrementHashIterator(&dbHashtable, &iterator)); } } /* update ports which lost records */ ixEthDBUpdatePortLearningTrees(triggerPorts); } }
IX_ETH_DB_PUBLIC void ixEthDBELTShow(IxEthDBPortId portID) { IxNpeMhMessage message; IX_STATUS result; /* send EDB_GetMACAddressDatabase message */ FILL_GETMACADDRESSDATABASE(message, 0 /* reserved */, IX_OSAL_MMU_VIRT_TO_PHYS(ixEthDBPortInfo[portID].updateMethod.npeUpdateZone)); IX_ETHDB_SEND_NPE_MSG(IX_ETH_DB_PORT_ID_TO_NPE(portID), message, result); if (result == IX_SUCCESS) { /* analyze NPE copy */ UINT32 eltEntryOffset; UINT32 entryPortID; UINT32 eltBaseAddress = (UINT32) ixEthDBPortInfo[portID].updateMethod.npeUpdateZone; UINT32 eltSize = FULL_ELT_BYTE_SIZE; /* invalidate cache */ IX_OSAL_CACHE_INVALIDATE((void *) eltBaseAddress, eltSize); printf("Listing records in main learning tree for port %d\n", portID); for (eltEntryOffset = ELT_ROOT_OFFSET ; eltEntryOffset < eltSize ; eltEntryOffset += ELT_ENTRY_SIZE) { /* (eltBaseAddress + eltEntryOffset) points to a valid NPE tree node * * the format of the node is MAC[6 bytes]:PortID[1 byte]:Reserved[6 bits]:Active[1 bit]:Valid[1 bit] * therefore we can just use the pointer for database searches as only the first 6 bytes are checked */ void *eltNodeAddress = (void *) ((UINT32) eltBaseAddress + eltEntryOffset); if (IX_EDB_NPE_NODE_VALID(eltNodeAddress)) { HashNode *node; entryPortID = IX_ETH_DB_NPE_LOGICAL_ID_TO_PORT_ID(IX_EDB_NPE_NODE_PORT_ID(eltNodeAddress)); /* search record */ node = ixEthDBSearch((IxEthDBMacAddr *) eltNodeAddress, IX_ETH_DB_ALL_RECORD_TYPES); printf("%s - port %d - %s ", mac2string((unsigned char *) eltNodeAddress), entryPortID, IX_EDB_NPE_NODE_ACTIVE(eltNodeAddress) ? "active" : "inactive"); /* safety check, maybe user deleted record right before sync? */ if (node != NULL) { /* found record */ MacDescriptor *descriptor = (MacDescriptor *) node->data; printf("- %s ", descriptor->type == IX_ETH_DB_FILTERING_RECORD ? "filtering" : descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD ? "vlan" : descriptor->type == IX_ETH_DB_WIFI_RECORD ? "wifi" : "other (check main DB)"); if (descriptor->type == IX_ETH_DB_FILTERING_RECORD) printf("- age %d - %s ", descriptor->recordData.filteringData.age, descriptor->recordData.filteringData.staticEntry ? "static" : "dynamic"); if (descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD) printf("- age %d - %s - tci %d ", descriptor->recordData.filteringVlanData.age, descriptor->recordData.filteringVlanData.staticEntry ? "static" : "dynamic", descriptor->recordData.filteringVlanData.ieee802_1qTag); /* end transaction */ ixEthDBReleaseHashNode(node); } else { printf("- not synced"); } printf("\n"); } } } else { ixOsalLog(IX_OSAL_LOG_LVL_FATAL, IX_OSAL_LOG_DEV_STDOUT, "EthDB: (ShowELT) Could not complete action (communication failure)\n", portID, 0, 0, 0, 0, 0); } }
/** * @brief standard NPE update handler * * @param portID id of the port to be updated * @param type record type to be pushed during this update * * The NPE update handler manages updating the NPE databases * given a certain record type. * * @internal */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBNPEUpdateHandler(IxEthDBPortId portID, IxEthDBRecordType type) { UINT32 epDelta, blockCount; IxNpeMhMessage message; UINT32 treeSize = 0; PortInfo *port = &ixEthDBPortInfo[portID]; /* size selection and type check */ if (type == IX_ETH_DB_FILTERING_RECORD || type == IX_ETH_DB_WIFI_RECORD) { treeSize = FULL_ELT_BYTE_SIZE; } else if (type == IX_ETH_DB_FIREWALL_RECORD) { treeSize = FULL_FW_BYTE_SIZE; } else if (type == IX_ETH_DB_MASKED_FIREWALL_RECORD) { treeSize = FULL_FW_M_BYTE_SIZE; } else { return IX_ETH_DB_INVALID_ARG; } /* serialize tree into memory */ ixEthDBNPETreeWrite(type, treeSize, port->updateMethod.npeUpdateZone, port->updateMethod.searchTree, &epDelta, &blockCount); /* free internal copy */ if (port->updateMethod.searchTree != NULL) { ixEthDBFreeMacTreeNode(port->updateMethod.searchTree); } /* forget last used search tree */ port->updateMethod.searchTree = NULL; port->updateMethod.searchTreePendingWrite = FALSE; /* dependending on the update type we do different things */ if (type == IX_ETH_DB_FILTERING_RECORD || type == IX_ETH_DB_WIFI_RECORD) { IX_STATUS result; FILL_SETMACADDRESSDATABASE_MSG(message, IX_ETHNPE_PHYSICAL_ID_TO_NODE_LOGICAL_ID(portID), epDelta, blockCount, IX_OSAL_MMU_VIRT_TO_PHYS(port->updateMethod.npeUpdateZone)); IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result); if (result == IX_SUCCESS) { IX_ETH_DB_UPDATE_TRACE("DB: (PortUpdate) Finished downloading NPE tree on port %d\n", portID); } else { ixEthDBPortInfo[portID].agingEnabled = FALSE; ixEthDBPortInfo[portID].updateMethod.updateEnabled = FALSE; ixEthDBPortInfo[portID].updateMethod.userControlled = TRUE; ERROR_LOG("EthDB: (PortUpdate) disabling aging and updates on port %d (assumed dead)\n", portID); ixEthDBDatabaseClear(portID, IX_ETH_DB_ALL_RECORD_TYPES); return IX_ETH_DB_FAIL; } return IX_ETH_DB_SUCCESS; } else if (type & IX_ETH_DB_FIREWALL_RECORD) { return ixEthDBFirewallUpdate(portID, port->updateMethod.npeUpdateZone, epDelta); } return IX_ETH_DB_INVALID_ARG; }