galileo sv software engineering1 galnet ii driver for vxworks ofir drang uri safrai 18/nov/99...

29
Galileo SV Software Engin eering 1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Post on 21-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 1

GalNet II driver for VxWorks

Ofir Drang

Uri Safrai

18/Nov/99

Galileo Confidential

Page 2: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 2

Galileo Confidential

Objectives

Supported features API functions Internal structure DORA test

Page 3: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 3

Galileo Confidential

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.

Page 4: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 4

Galileo Confidential

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.

Page 5: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 5

Galileo Confidential

API functions (45 functions) cfgIntCBFuncConnect() cfgSetDriversConfig() cfgGetDriversConfig() cfgSetcfgRxMask() cfgGetcfgRxMask() cfgSetDefault() cfgAPIReleaseRxDesc() galnet2Init()

Page 6: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 6

Galileo Confidential

API functions (cont.) galnetInitDevTables() galnetIncrInitDevTables() hashRstCPUTable() hashCPUNewAddr() hashInsert2CPUTable() hashCPUSkipAddr() hashQueryCPUAddr() hashCountCPUAddr()

Page 7: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 7

Galileo Confidential

API functions (cont.) hashReadCPUEntry() hashQueryAddr() hashCountAddr() hashReadEntry() hashClearTable() hwCBWriteRegister() hwCBReadRegister() hwSwWriteRegister()

Page 8: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 8

Galileo Confidential

API functions (cont.) hwSwReadRegister() hwSwReadDRAM() hwSwWriteDRAM() hwReadMIIRegister() hwWriteMIIRegister() hwCBSetRegField() hwCBGetRegField() hwSwSetRegField()

Page 9: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 9

Galileo Confidential

API functions (cont.) hwSwGetRegField() hwSwSetPortProperty() hwCBSetDeviceProperty() hwSwSetDeviceProperty() hwSetSniffer() hwReadPortMIBs() hwReadPortMIB() hwReadGLinkCounters()

Page 10: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 10

Galileo Confidential

API functions (cont.) hwResetAllCounters() hwResetCounters() hwTriggerAging() txPacket() vlanSetEntry()

Page 11: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 11

Galileo Confidential

ID

Internal structure

count prio next prevID count prio next prevID count prio next prev

ID count prio next prev

0

1

2

.

.

ID count prio next prev

ID count prio next prev

ID count prio next prev

Interrupt taskSEM

Page 12: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 12

Galileo Confidential

Interruptadd events

Event queue(implemented as link list)

Task handle events

Page 13: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 13

Galileo ConfidentialEvent 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).

Page 14: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 14

Galileo Confidential

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.

Page 15: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 15

Galileo Confidential

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.

Elsere queue the event.

Event Immediate driver

functionApplication callback

function

Page 16: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 16

Galileo ConfidentialPerformance 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

----------------------------------------------------------------------------------

Page 17: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 17

Galileo ConfidentialPerformance tests - Tx

with App CB Function without App CB Function

Rate 57,000 23,855

Length 64 bytes 504 bytes

Page 18: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 18

Galileo Confidential

DORA (Dead OR Alive) test

EV48302EV64115

NIC

EVB48310EVB48310

port0port0

Glink1 Glink0

Page 19: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 19

Galileo Confidential

Connect 48302 interrupt to intD

GT48302

PCI - P5 (GT64115)

PCI - P6 (NIC)

Pin B8

Page 20: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 20

Galileo Confidential

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

Page 21: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 21

Galileo Confidential

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;

Page 22: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 22

Galileo Confidential

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);

}

Page 23: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 23

Galileo Confidential

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");

Page 24: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 24

Galileo Confidential

/* 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;

Page 25: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 25

Galileo Confidential

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");

Page 26: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 26

Galileo Confidential

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");

Page 27: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 27

Galileo Confidential

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;

}}

}

Page 28: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 28

Galileo Confidential

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");

}

Page 29: Galileo SV Software Engineering1 GalNet II driver for VxWorks Ofir Drang Uri Safrai 18/Nov/99 Galileo Confidential

Galileo SV Software Engineering 29

Galileo Confidential

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;

}