290 likes | 451 Views
Galileo Confidential. GalNet II driver for VxWorks. Ofir Drang Uri Safrai 18/Nov/99. Objectives. Supported features API functions Internal structure DORA test . Supported features. Init the Galnet II system. Interrupt handling by the driver
E N D
Galileo Confidential GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo SV Software Engineering
Objectives • Supported features • API functions • Internal structure • DORA test Galileo SV Software Engineering
Supported features • Init the Galnet II system. • Interrupt handling by the driver • Insertion of API call back function per interrupt. • Transmit packets. • Access to switch/CrossBar internal registers. • Access for read/write to switch control/data DRAM. • Access for read/write to PHY MII registers. • Setting Switch properties via API function. Galileo SV Software Engineering
Supported features (cont.) • Read/Reset of switch Port MIB counter/counters. • Reading of switch Glink counters. • Program/Query Entry in the Switch Address Table. • Count Address in the Switch Address table. • Handling an hash table in the CPU. (NDA) • Program Entry in the Switch Valn Table. • No Glink Interrupts handling. Galileo SV Software Engineering
API functions (45 functions) • cfgIntCBFuncConnect() • cfgSetDriversConfig() • cfgGetDriversConfig() • cfgSetcfgRxMask() • cfgGetcfgRxMask() • cfgSetDefault() • cfgAPIReleaseRxDesc() • galnet2Init() Galileo SV Software Engineering
API functions (cont.) • galnetInitDevTables() • galnetIncrInitDevTables() • hashRstCPUTable() • hashCPUNewAddr() • hashInsert2CPUTable() • hashCPUSkipAddr() • hashQueryCPUAddr() • hashCountCPUAddr() Galileo SV Software Engineering
API functions (cont.) • hashReadCPUEntry() • hashQueryAddr() • hashCountAddr() • hashReadEntry() • hashClearTable() • hwCBWriteRegister() • hwCBReadRegister() • hwSwWriteRegister() Galileo SV Software Engineering
API functions (cont.) • hwSwReadRegister() • hwSwReadDRAM() • hwSwWriteDRAM() • hwReadMIIRegister() • hwWriteMIIRegister() • hwCBSetRegField() • hwCBGetRegField() • hwSwSetRegField() Galileo SV Software Engineering
API functions (cont.) • hwSwGetRegField() • hwSwSetPortProperty() • hwCBSetDeviceProperty() • hwSwSetDeviceProperty() • hwSetSniffer() • hwReadPortMIBs() • hwReadPortMIB() • hwReadGLinkCounters() Galileo SV Software Engineering
API functions (cont.) • hwResetAllCounters() • hwResetCounters() • hwTriggerAging() • txPacket() • vlanSetEntry() Galileo SV Software Engineering
Internal structure Interrupt SEM task 0 1 2 . . ID count prio next prev ID count prio next prev ID count prio next prev ID count prio next prev ID count prio next prev ID count prio next prev ID count prio next prev Galileo SV Software Engineering
Interrupt add events Event queue (implemented as link list) Task handle events Galileo SV Software Engineering
Event information • Number of events which weren’t handled. • Total number of events. • Interrupt Id. • Priority. • Pointer to the device that own this event. • Pointer to event handler (function). Galileo SV Software Engineering
Interrupt sequence (ISR) • Identify the device in which the interrupt occurred. • Read the device interrupt cause registers. • For each interrupt that occurred if (Counter = 0) increase the counter and queue a new event. Else increase the counter. • If new event was queued, Enable the task through the semaphore. Galileo SV Software Engineering
Task • while the queue isn’t empty, queue out events and for each event, call the driver function, in order to handle immediate needs. • Increase the counter by 1. • If (counter = 0) queue the event out. Else re queue the event. Event Application callback function Immediate driverfunction Galileo SV Software Engineering
Performance tests - Rx with App CB Function without App CB Function Rate 70,000 79,000 Length 64 bytes 64 bytes ---------------------------------------------------------------------------------- Rate 50,000 50,000 Length 504 bytes 504 bytes ---------------------------------------------------------------------------------- Rate 17,000 (can be higher) 17,000 (can be higher) Length 1518 bytes 1518 bytes ---------------------------------------------------------------------------------- Galileo SV Software Engineering
Performance tests - Tx with App CB Function without App CB Function Rate 57,000 23,855 Length 64 bytes 504 bytes Galileo SV Software Engineering
DORA (Dead OR Alive) test NIC EV48302 EV64115 Glink1 Glink0 EVB48310 EVB48310 port0 port0 Galileo SV Software Engineering
Connect 48302 interrupt to intD CUT!!! PCI - P5 (GT64115) GT48302 Pin B8 Blue Wire PCI - P6 (NIC) Galileo SV Software Engineering
DORA test code #include "drvApiFunc.h" #include "cfg.h" #include <taskLib.h> volatile int pktRxFlag; int pktTxCounter; UINT32* buffer; STRUCT_TX_DESC *txPkt; UINT32 doraPktRxed(void* ptr, UINT32 index); void printHashTable(UINT32 DevId); void doraTest(void); #define NUM_OF_TX_PKT_IN_DORA_TEST 15 Galileo SV Software Engineering
void startApp() { STRUCT_CONFIG_VALUES initStruct; /* init the struct for Galnet II drivers initializations */ initStruct.EnableHashTable = ENABLE_CPU_HT_DEFAULT_VAL; initStruct.CPUHashFunc = CPU_HT_DEFAULT_MODE; initStruct.HashChain = CPU_HT_CHAIN_DEFAULT_LEN; initStruct.CheckRxCause = CHECK_RX_CAUSE_DEFAULT_VAL; initStruct.RxMask = RX_MASK_DEFAULT_VAL; initStruct.CpuNum = CPU_DEFAULT_DEV_NUM; initStruct.RxDescNum = RX_DESC_DEFAULT_NUM; initStruct.RxBufferSize = RX_BUFFER_DEFAULT_SIZE; initStruct.NaBlockSize = NA_BLOCK_DEFAULT_SIZE; initStruct.galnet2TaskPri = GALNET_DEFAULT_TASK_PRI; Galileo SV Software Engineering
if(galnet2Init(&initStruct) != OK) { printf("API: Initialization failed.\n"); return; } taskSpawn ("DoraTest", (initStruct.galnet2TaskPri + 1), 0, 2000, (FUNCPTR)doraTest, 0,0,0,0,0,0,0,0,0,0); } Galileo SV Software Engineering
void doraTest(void) { STRUCT_HASH_ENTRY hashEntry; STRUCT_HASH_COUNT hashCounter0; STRUCT_HASH_COUNT hashCounter1; STRUCT_HASH_COUNT hashCounterC; UINT32 pktCount; UINT32 timeOut; printf("Dora Test\n"); pktTxCounter = 0; txPkt = (STRUCT_TX_DESC*)commonChachDmaMallocAlign( TX_DESC_ALIGN,sizeof(STRUCT_TX_DESC)); buffer = (UINT32*)(commonChachDmaMallocAlign(TX_BUFFER_ALIGN,64)); if(galnetIncrInitDevTables() != OK) { printf("DoraTest: Device table initialization failed.\n"); return; } printf("Dora Device table initialization Done\n"); Galileo SV Software Engineering
/* Enable forwarding of newAddr in the device */ hwSwSetDeviceProperty(1,FORWARD_NEW_ADDRESS,1); hwSwSetDeviceProperty(0,FORWARD_NEW_ADDRESS,1); printf("DoraTest: NewAddr bit is set.\n"); /* Connect the application PktRx routine Low-Glink#1 */ cfgIntCBFuncConnect(RX_1_LOW_PKT, doraPktRxed); printf("Dora Test connect API Demo function Done\n"); hashEntry.valid = 1; hashEntry.skip = 0; hashEntry.aging = 1; hashEntry.addrl = 0x1234; hashEntry.addrh = 0; hashEntry.vid = 0; hashEntry.id = 0; hashEntry.is = 0; Galileo SV Software Engineering
hashEntry.dev = CPU_DEFAULT_DEV_NUM; hashEntry.port = 0; hashEntry.ps = 0; hashEntry.pd = 0; hashEntry.st = 0; hashEntry.m = 0; hashEntry.vidx = 0; hashEntry.t = 0; hashEntry.reserved = 0; hashWriteEntry(1, &hashEntry); /* Learn the CPU MAC address */ printf("DoraTest: NewAddr is sent.\n"); Galileo SV Software Engineering
txPkt->word1 = BYTE_SWAP(0xe0002001); /* F=1,L=1,Int=1,Own=1 */ txPkt->word2 = BYTE_SWAP(0x003c0000); /* pkt length = 60+4 */ txPkt->BuffPointer = (UINT32)(BYTE_SWAP(VIRTUAL_TO_PHY(buffer))); txPkt->HandlerId = 0; txPkt->NextDesc = NULL; txPkt->NextFirstDesc = NULL; buffer[0] = 0x00000000; buffer[1] = 0x12340000; /* Dst MAC = 0x000000001234 */ buffer[2] = 0x00000201; /* Src MAC = 0x000000000201 */ printf("DoraTest: Ready for Tx.\n"); Galileo SV Software Engineering
for (pktCount=0; pktCount<NUM_OF_TX_PKT_IN_DORA_TEST; pktCount++) { pktRxFlag = 0; txPacket(txPkt); /* Transmit the packet */ timeOut = 0; while (pktRxFlag != 1) /* Wait for doraPktRxed */ { /* to do its job. */ timeOut++; if(timeOut == 1000) { printf("Dora Test failed Time Out Pass\n"); return; } } } Galileo SV Software Engineering
printf("DoraTest Hash Table Addr Count...\n"); hashCountAddr(0, &hashCounter0); hashCountAddr(1, &hashCounter1); hashCountCPUAddr(&hashCounterC); if( (hashCounter0.valid != NUM_OF_TX_PKT_IN_DORA_TEST ) || (hashCounter1.valid != (NUM_OF_TX_PKT_IN_DORA_TEST+1)) || (hashCounterC.valid != NUM_OF_TX_PKT_IN_DORA_TEST) ) printf("Unexpected number of hash enries\n"); else printf("Good number of hash enries\n Test Passed\n"); } Galileo SV Software Engineering
UINT32 doraPktRxed(void* ptr, UINT32 index) { UINT32* rxBuff; rxBuff = (UINT32*)(PHY_TO_VIRTUAL(BYTE_SWAP(((STRUCT_RX_DESC*)ptr)->BuffPointer))); if(rxBuff[0] != buffer[0]) printf("Tx[0] != Rx[0]\n"); if(rxBuff[1] != buffer[1]) printf("Tx[1] != Rx[1]\n"); if(rxBuff[2] != buffer[2]) printf("Tx[2] != Rx[2]\n"); if(rxBuff[3] != buffer[3]) printf("Tx[3] != Rx[3]\n"); /*else printf("Rx[0..3] = Tx[0..3]\n");*/ txPkt->word1 = BYTE_SWAP(0xe0002001); /* Own=1 */ (buffer[2])++; /* return the Rx descriptor & Buffer to the Budget */ cfgAPIReleaseRxDesc((STRUCT_RX_DESC*)ptr); pktRxFlag = 1; return OK; } Galileo SV Software Engineering