void qdStatus(void) { int port; GT_BOOL linkState; GT_PORT_STP_STATE stpState; GT_PORT_STAT counters; GT_U16 pvid; GT_LPORT portList[GT_NUM_OF_SWITCH_PORTS]; GT_U8 portNum; char portListStr[100]; gtOsPrintf("Port Link PVID Group State RxCntr TxCntr\n\n"); for (port=0; port<GT_NUM_OF_SWITCH_PORTS; port++) { gprtGetLinkState(qd_dev, port, &linkState); gstpGetPortState(qd_dev, port, &stpState); gprtGetPortCtr(qd_dev,port, &counters); gstpGetPortState(qd_dev, port, &stpState); gvlnGetPortVid(qd_dev, port, &pvid); gvlnGetPortVlanPorts(qd_dev, port, portList, &portNum); qdPortListToStr(portList, portNum, portListStr); gtOsPrintf(" %d. %4s %d %-10s %-10s 0x%-8x 0x%-8x\n", port, (linkState==GT_TRUE) ? "UP" : "DOWN", pvid, portListStr, qdPortStpStates[stpState], counters.rxCtr, counters.txCtr); } }
/* * Initialize the QuarterDeck. This should be done in BSP driver init routine. * Since BSP is not combined with QuarterDeck driver, we are doing here. */ GT_STATUS qdStart(void) /* devId is used for simulator only */ { GT_STATUS status; /* * Register all the required functions to QuarterDeck Driver. */ cfg.BSPFunctions.readMii = ffReadMii; cfg.BSPFunctions.writeMii = ffWriteMii; #ifdef USE_SEMAPHORE cfg.BSPFunctions.semCreate = osSemCreate; cfg.BSPFunctions.semDelete = osSemDelete; cfg.BSPFunctions.semTake = osSemWait; cfg.BSPFunctions.semGive = osSemSignal; #else /* USE_SEMAPHORE */ cfg.BSPFunctions.semCreate = NULL; cfg.BSPFunctions.semDelete = NULL; cfg.BSPFunctions.semTake = NULL; cfg.BSPFunctions.semGive = NULL; #endif /* USE_SEMAPHORE */ cfg.initPorts = GT_TRUE; cfg.cpuPortNum = GT_CPU_SWITCH_PORT; qd_dev->cpuPortNum = GT_CPU_SWITCH_PORT; if((status = qdLoadDriver(&cfg, qd_dev)) != GT_OK) { gtOsPrintf("qdLoadDriver is failed: status = 0x%x\n", status); return status; } /* * start the QuarterDeck */ if (qd_dev->deviceId == GT_88E6063) { phyPatch(qd_dev); } /* to which VID should we set the CPU_PORT? (1 is temporary)*/ if((status = gvlnSetPortVid(qd_dev, GT_CPU_SWITCH_PORT, 5)) != GT_OK) { gtOsPrintf("gprtSetPortVid returned fail for CPU port.\n"); return status; } #ifdef QD_TRAILER_MODE /* set ingress trailer mode*/ gprtSetIngressMode(qd_dev, GT_CPU_SWITCH_PORT, GT_TRAILER_INGRESS); /* set egress trailer*/ gprtSetTrailerMode(qd_dev, GT_CPU_SWITCH_PORT, GT_TRUE); #endif #ifdef QD_HEADER_MODE if((status = gprtSetHeaderMode(qd_dev, GT_CPU_SWITCH_PORT, GT_TRUE)) != GT_OK) { gtOsPrintf("gprtSetHeaderMode return Failed\n"); return status; } #endif return GT_OK; }
static void printUnimacStructs(OUT MV_UNM_CONFIG* _cnf, char _names[MV_UNM_MAX_VID][MAX_VLAN_NAME], unsigned char _macs[MV_UNM_MAX_VID][GT_ETHERNET_HEADER_SIZE]) { int i; for(i=0;i<MV_UNM_MAX_VID;i++) { gtOsPrintf("[%d] - MAC=%x%x%x%x%x%x Name=%s\n",i, _macs[i][0], _macs[i][1], _macs[i][2], _macs[i][3], _macs[i][4], _macs[i][5], _names[i]); } for(i=0;i<GT_NUM_OF_SWITCH_PORTS;i++) { gtOsPrintf(" %d", _cnf->vidOfPort[i]); } gtOsPrintf("\n"); }
/* * ---------------------------------------------------------------------------- * GT_STATUS getNetConfig(OUT MV_UNM_CONFIG* unmConfig) * * This function is a part of the unimca manager API. * The unimac manager API (mv_unimac_mgr.c) requires a get function * in order to init the net-conf data. * While being loaded, the unimac manager request for its init * configuration data with that function. * * Inputs: * * Outputs: * unmConfig - A pointer to the net config to be filled with the init data. * */ GT_STATUS getNetConfig(OUT MV_UNM_CONFIG* unmConfig) { int i; /* Let's fill it with the following defaults for now: WAN - port 0. LAN - ports 1,2,3,4. */ memset( mv_nc_macs, 0 , sizeof(mv_nc_macs) ); memset( mv_nc_vlan_names, 0 , sizeof(mv_nc_vlan_names) ); if(!inited) return GT_FAIL; memcpy(unmConfig, &file_cnf, sizeof(MV_UNM_CONFIG)); /* init all VLAN fields */ /* We are using two set of structures here * 1. The: mv_nc_conf_file_macs, mv_nc_conf_file_names, mv_nc_unmConfig * those three conf structs are being filled by an IOCTL call of a configuration application * * 2. mv_nc_macs, mv_nc_vlan_names, cnf, that are being updated here from the structures above * here at the context of UNM initialize, the system gets ready to work. */ for( i = 0 ; i < MV_UNM_MAX_VID ; i++) { if(strlen(mv_nc_file_names[i]) > 0 ) { memcpy(mv_nc_vlan_names[i], mv_nc_file_names[i], strlen(mv_nc_file_names[i])); if( i > 0 && i < MV_UNM_VID_ISOLATED ) { memcpy(mv_nc_macs[i], mv_nc_file_macs[i], GT_ETHERNET_HEADER_SIZE); if( memcmp(mv_nc_file_macs[i], null_mac, GT_ETHERNET_HEADER_SIZE) == 0 ) { gtOsPrintf("Error - No MAC ADDR is set for VLAN WAN\n"); return GT_FAIL; } } } } #ifdef ETH_DBG_INFO printUnimacStructs(unmConfig, mv_nc_vlan_names, mv_nc_macs); #endif /* ETH_DBG_INFO */ return (GT_OK); }
void mv_nc_printConf(void) { MV_UNM_CONFIG cfg; GT_STATUS status = mvUnmGetNetConfig(&cfg); int i; if (status == GT_OK) { gtOsPrintf ("Port association table:\n"); gtOsPrintf("---------------------------------------\n"); gtOsPrintf("| Port |"); for (i = 0; i < (GT_NUM_OF_SWITCH_PORTS-2); i++) { gtOsPrintf("%4d |", i); } gtOsPrintf("\n| VID |"); for (i = 0; i < (GT_NUM_OF_SWITCH_PORTS-2); i++) { gtOsPrintf("%4d |", cfg.vidOfPort[i]); } gtOsPrintf("\n---------------------------------------\n"); } else { gtOsPrintf("Configuration error %d.\n", status); } }
GT_STATUS qdInit(void) { GT_STATUS status = GT_OK; unsigned int i; status = qdStart(); if (GT_OK != status) { gtOsPrintf("qdStart is failed: status = 0x%x\n", status); return status; } #ifdef DB_6093_88E6218 /* start 88E6090 device, assumes SMI Address 0x11 and CPU Port 10 */ if(loadDev(qd_ext, SMI_MULTI_ADDR_MODE, 0x11, 10) == NULL) { gtOsPrintf("Failed to start External Device. Please check the SMI Address 0x11!\n"); } /* allow larger than 1522 bytes of frame (header + marvell tag) */ gsysSetMaxFrameSize(qd_dev,GT_FALSE); #endif for (i=0; i<qd_dev->numOfPorts; i++) { /* default port prio to three */ gcosSetPortDefaultTc(qd_dev, i, 3); /* disable IP TOS Prio */ gqosIpPrioMapEn(qd_dev, i, GT_FALSE); /* disable QOS Prio */ gqosUserPrioMapEn(qd_dev, i, GT_FALSE); /* Force flow control for all ports */ gprtSetForceFc(qd_dev, i, GT_FALSE); } /* Enable port #6 */ status = gstpSetPortState(qd_dev, 6, GT_PORT_FORWARDING); if((status = gprtClearAllCtr(qd_dev)) != GT_OK) { return status; } for (i=0; i<GT_CPU_SWITCH_PORT; i++) { gprtSetMcRateLimit(qd_dev, i, GT_MC_100_PERCENT_RL); } #ifdef QD_DEBUG for (i=0; i<qd_dev->numOfPorts; i++) { short sdata; hwReadPortReg(qd_dev, i, 0x4, &sdata); gtOsPrintf("Control reg for port[%d] is: %x\n",i,sdata); hwReadPortReg(qd_dev, i, 0x0, &sdata); gtOsPrintf("Status reg for port[%d] is: %x\n",i,sdata); } qdStatus(); #endif /* QD_DEBUG */ gtOsPrintf("QD initiated\n"); return status; }