void mvEthAddrDecShow(void) { int port; for(port=0; port<mvCtrlEthMaxPortGet(); port++) mvEthPortAddrDecShow(port); }
/******************************************************************************* * mvEthRxPolicyInit - Initialize RX policy component. * * DESCRIPTION: * Create RX policy database for ethernet port, set to it to default * (FIXED mode) and return port handle. * * INPUT: * int port - Ethernet port number * * * RETURN: * void* pRxPolicyHndl - RX Policy component handler; * *******************************************************************************/ void* mvEthRxPolicyInit(int port, int defQuota, MV_ETH_PRIO_MODE defMode) { int queue; if( (port < 0) || (port >= mvCtrlEthMaxPortGet()) ) { mvOsPrintf("ethRxPolicy: port #%d is not exist\n", port); return NULL; } rxPolicy[port] = mvOsMalloc(sizeof(ETH_RX_POLICY)); if(rxPolicy[port] == NULL) { mvOsPrintf("ethRxPolicy: Port #%d, Can't allocate %d bytes\n", port, sizeof(ETH_RX_POLICY)); return NULL; } /* Set defaults */ memset(rxPolicy[port], 0, sizeof(ETH_RX_POLICY)); for(queue=0; queue<MV_ETH_RX_Q_NUM; queue++) { rxPolicy[port]->rxQuota[queue] = defQuota; } rxPolicy[port]->port = port; rxPolicy[port]->rxPrioMode = defMode; rxPolicy[port]->rxCurQ = MV_ETH_RX_Q_NUM-1; rxPolicy[port]->rxCurQuota = rxPolicy[port]->rxQuota[rxPolicy[port]->rxCurQ]; return rxPolicy[port]; }
/******************************************************************************* * mvEthTxPolicyInit - Initialize TX policy component. * * DESCRIPTION: * Create TX policy database for ethernet port, set to it to default * values and return port handle. * * INPUT: * int port - Ethernet port number * * * RETURN: * void* pTxPolHndl - TX Policy component handler * *******************************************************************************/ void* mvEthTxPolicyInit(int port, MV_ETH_TX_POLICY_ENTRY* pDefPolicy) { int daIdx; if( (port < 0) || (port >= mvCtrlEthMaxPortGet()) ) { mvOsPrintf("ethTxPolicy: port #%d is not exist\n", port); return NULL; } txPolicy[port] = mvOsMalloc(sizeof(ETH_TX_POLICY)); if(txPolicy[port] == NULL) { mvOsPrintf("ethTxPolicy: Port #%d, Can't allocate %d bytes\n", port, sizeof(ETH_TX_POLICY)); return NULL; } /* Set defaults */ memset(txPolicy[port], 0, sizeof(ETH_TX_POLICY)); txPolicy[port]->port = port; mvEthTxPolicyDef(txPolicy[port],pDefPolicy); /* Invalidate all entries */ txPolicy[port]->txPolMaxDa = 0; for(daIdx=0; daIdx<MV_ETH_TX_POLICY_MAX_MACDA; daIdx++) txPolicy[port]->txPolDa[daIdx].policy.txQ = MV_INVALID; return txPolicy[port]; }
void mvEthAddrDecShow(void) { int port; for(port=0; port<mvCtrlEthMaxPortGet(); port++) { if (MV_FALSE == mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port)) continue; mvEthPortAddrDecShow(port); } }
void mvEthInit(void) { MV_U32 port; /* Power down all existing ports */ for(port=0; port<mvCtrlEthMaxPortGet(); port++) { mvEthWinInit(port); } mvEthHalInit(); }
void l2fw(int cmd, int rx_port, int tx_port) { struct eth_port_l2fw *ppl2fw; mv_eth_ports_l2fw_num = mvCtrlEthMaxPortGet(); ppl2fw = mv_eth_ports_l2fw[rx_port]; mvOsPrintf("cmd=%d rx_port=%d tx_port=%d in %s \n", cmd, rx_port, tx_port, __func__); ppl2fw->txPort = tx_port; ppl2fw->cmd = cmd; mv_eth_set_l2fw(cmd, rx_port, tx_port); }
void mvEthInit(void) { MV_U32 port; /* Power down all existing ports */ for(port=0; port<mvCtrlEthMaxPortGet(); port++) { if (MV_FALSE == mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port)) continue; mvEthWinInit(port); } mvEthHalInit(); }
int __devinit mv_l2fw_init(void) { int size, port; MV_U32 bytes; MV_U32 regVal; mv_eth_ports_l2fw_num = mvCtrlEthMaxPortGet(); mvOsPrintf("in %s: mv_eth_ports_l2fw_num=%d\n", __func__, mv_eth_ports_l2fw_num); size = mv_eth_ports_l2fw_num * sizeof(struct eth_port_l2fw *); mv_eth_ports_l2fw = mvOsMalloc(size); if (!mv_eth_ports_l2fw) goto oom; memset(mv_eth_ports_l2fw, 0, size); for (port = 0; port < mv_eth_ports_l2fw_num; port++) { mv_eth_ports_l2fw[port] = mvOsMalloc(sizeof(struct eth_port_l2fw)); if (!mv_eth_ports_l2fw[port]) goto oom1; mv_eth_ports_l2fw[port]->cmd = L2FW_DISABLE; mv_eth_ports_l2fw[port]->txPort = -1; } bytes = sizeof(L2FW_RULE *) * L2FW_HASH_SIZE; l2fw_jhash_iv = mvOsRand(); l2fw_hash = (L2FW_RULE **)mvOsMalloc(bytes); if (l2fw_hash == NULL) { mvOsPrintf("l2fw hash: not enough memory\n"); return MV_NO_RESOURCE; } mvOsMemset(l2fw_hash, 0, bytes); mvOsPrintf("L2FW hash init %d entries, %d bytes\n", L2FW_HASH_SIZE, bytes); regVal = 0; #ifdef CONFIG_MV_ETH_L2SEC cesa_init(); #endif #ifdef CONFIG_MV_INCLUDE_XOR setXorDesc(); #endif return 0; oom: mvOsPrintf("%s: out of memory in L2FW initialization\n", __func__); oom1: mvOsFree(mv_eth_ports_l2fw); return -ENOMEM; }
/******************************************************************************* * mvSysEthPhyInit - Initialize the EthPhy subsystem * * DESCRIPTION: * * INPUT: * None * OUTPUT: * None * RETURN: * None * *******************************************************************************/ MV_STATUS mvSysEthPhyInit(void) { MV_ETHPHY_HAL_DATA halData; MV_U32 port; for (port=0; port < mvCtrlEthMaxPortGet(); port++) { halData.phyAddr[port] = mvBoardPhyAddrGet(port); halData.LinkCryptPortAddr[port] = mvBoardPhyLinkCryptPortAddrGet(port); halData.boardSpecInit = MV_FALSE; halData.isSgmii[port] = mvBoardIsPortInSgmii(port); halData.QuadPhyPort0[port] = mvBoardQuadPhyAddr0Get(port); } halData.ethPhySmiReg = ETH_SMI_REG(MV_ETH_SMI_PORT); return mvEthPhyHalInit(&halData); }
/******************************************************************************* * mvSysEthInit - Initialize the Eth subsystem * * DESCRIPTION: * * INPUT: * None * OUTPUT: * None * RETURN: * None * *******************************************************************************/ MV_VOID mvSysEthInit(MV_VOID) { MV_ETH_HAL_DATA halData; MV_U32 port; MV_UNIT_WIN_INFO addrWinMap[MAX_TARGETS + 1]; MV_STATUS status; int i; status = mvCtrlAddrWinMapBuild(addrWinMap, MAX_TARGETS + 1); if (status != MV_OK) return; for (i = 0; i < MAX_TARGETS; i++) { if (addrWinMap[i].enable == MV_FALSE) continue; } halData.maxPortNum = mvCtrlEthMaxPortGet(); halData.cpuPclk = mvCpuPclkGet(); halData.tclk = mvBoardTclkGet(); #ifdef ETH_DESCR_IN_SRAM halData.sramSize = mvCtrlSramSizeGet(); #endif for (port = 0; port < halData.maxPortNum; port++) { if (MV_FALSE == mvBoardIsGbEPortConnected(port)) continue; if (mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port) == MV_FALSE) { halData.portData[port].powerOn = MV_FALSE; continue; } status = mvEthWinInit(port, addrWinMap); if (status == MV_OK) { halData.portData[port].powerOn = MV_TRUE; halData.portData[port].phyAddr = mvBoardPhyAddrGet(port); halData.portData[port].isSgmii = mvBoardIsPortInSgmii(port); halData.portData[port].macSpeed = mvBoardMacSpeedGet(port); } } mvEthHalInit(&halData); return; }
/*********************************************************** * mv_eth_initialize -- * * main driver initialization. loading the interfaces. * ***********************************************************/ int mv_eth_initialize(bd_t *bis) { int port; MV_8 *enet_addr; MV_8 name[NAMESIZE+1]; MV_8 enetvar[9]; /* HAL init + port power up + port win init */ mvSysPp2Init(); mv_eth_bm_init(); /* Parser default initialization */ if (mvPrsDefaultInit()) printf("Warning PARSER default init failed\n"); if (mvPp2ClassifierDefInit()) printf("Warning Classifier defauld init failed\n"); if (mvPp2AggrTxqInit(0/*cpu*/, EGIGA_TXQ_LEN) == NULL) { printf("Error failed to init aggr TXQ\n"); return -1; } for (port = 0; port < mvCtrlEthMaxPortGet(); port++) { if (MV_PP2_IS_PON_PORT(port) || mvBoardIsPortLoopback(port)) continue; if (mvBoardIsEthActive(port) == MV_FALSE) continue; if (mvCtrlPwrClckGet(ETH_GIG_UNIT_ID, port) == MV_FALSE) continue; /* interface name */ sprintf(name, "egiga%d", port); /* interface MAC addr extract */ sprintf(enetvar, port ? "eth%daddr" : "ethaddr", port); enet_addr = getenv(enetvar); mvEgigaLoad(port, name, enet_addr); } return 0; }
/******************************************************************************* * mvEthProtWinSet - Set access protection of Ethernet to target window. * * DESCRIPTION: * Each Ethernet port can be configured with access attributes for each * of the Ethenret to target windows (address decode windows). This * function sets access attributes to a given window for the given channel. * * INPUTS: * ethPort - ETH channel number. See MV_ETH_CHANNEL enumerator. * winNum - IETH to target address decode window number. * access - IETH access rights. See MV_ACCESS_RIGHTS enumerator. * * OUTPUT: * None. * * RETURN: * MV_ERROR in case window number is invalid or access right reserved. * *******************************************************************************/ MV_STATUS mvEthProtWinSet(MV_U32 portNo, MV_U32 winNum, MV_ACCESS_RIGHTS access) { MV_U32 protReg; /* Parameter checking */ if(portNo >= mvCtrlEthMaxPortGet()) { mvOsPrintf("mvEthProtWinSet:ERR. Invalid port number %d\n", portNo); return MV_ERROR; } if (winNum >= ETH_MAX_DECODE_WIN) { mvOsPrintf("mvEthProtWinSet:ERR. Invalid winNum%d\n",winNum); return MV_ERROR; } if((access == ACC_RESERVED) || (access >= MAX_ACC_RIGHTS)) { mvOsPrintf("mvEthProtWinSet:ERR. Inv access param %d\n", access); return MV_ERROR; } /* Read current protection register */ protReg = MV_REG_READ(ETH_ACCESS_PROTECT_REG(portNo)); /* Clear protection window field */ protReg &= ~(ETH_PROT_WIN_MASK(winNum)); /* Set new protection field value */ protReg |= (access << (ETH_PROT_WIN_OFFS(winNum))); /* Write protection register back */ MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(portNo), protReg); return MV_OK; }
int do_active_units(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { MV_U32 cpuNum, egigaNum, pexNum; MV_U32 i; printf("Active: "); /* CPU */ cpuNum = mvCtrlGetCpuNum(); for (i = 0; i <= cpuNum; i++) { if (i) printf(", "); printf("cpu%d", i); } /* PEX */ pexNum = mvCtrlPexActiveUnitNumGet(); for (i = 0; i < pexNum; i++) printf(", pex%d", i); /* EGIGA */ egigaNum = mvCtrlEthMaxPortGet(); for (i = 0; i < egigaNum; i++) { if (mvBoardIsEthActive(i) == MV_TRUE) printf(", egiga%d", i); } #ifdef MV_USB /* USB */ MV_U32 usbNum = mvCtrlUsbMaxGet() + mvCtrlUsb3MaxGet(); for (i = 0; i < usbNum; i++) printf(", usb%d", i); #endif /* SDIO */ #ifdef CONFIG_MRVL_MMC if (mvCtrlSdioSupport() == MV_TRUE) printf(", mmc0"); #endif /* SATA */ #if defined(MV_INCLUDE_INTEG_SATA) MV_U32 sataNum = mvCtrlSataMaxPortGet(); for (i = 0; i < sataNum; i++) printf(", sata%d", i); #endif /* SPI */ #if defined(MV_INCLUDE_SPI) printf(", spi"); #endif /* NAND */ #if defined(MV_NAND) printf(", nand"); #endif /* I2C */ #if defined(MV_INCLUDE_TWSI) printf(", i2c0"); #endif #if defined (MV_INCLUDE_TDM) /* TDM */ if (mvBoardSlicUnitTypeGet() != MV_BOARD_SLIC_DISABLED) printf(", tdm0"); #endif printf("\n"); return 0; }
/* Giga Port commands */ int run_port_com(const char *buffer) { int scan_count; void* port_hndl; scan_count = sscanf(buffer, PORT_CMD_STRING, PORT_SCANF_LIST); if( scan_count != PORT_LIST_LEN) { printk("eth port command bad format %x != %x\n", scan_count, PORT_LIST_LEN ); return 1; } if( (port < 0) || (port > mvCtrlEthMaxPortGet()) ) return 1; port_hndl = mvEthPortHndlGet(port); if(port_hndl == NULL) return 1; switch(command) { case COM_RX_COAL: mv_eth_rxcoal_set(port, value); break; case COM_TX_COAL: mv_eth_txcoal_set(port, value); break; #ifdef ETH_MV_TX_EN case COM_TX_EN: if(value > CONFIG_MV_ETH_NUM_OF_RX_DESCR) { printk("Eth TX_EN command bad param: value=%d\n", value); return 1; } eth_tx_en_config(port, value); break; #endif /* ETH_MV_TX_EN */ #if (MV_ETH_VERSION >= 4) case COM_EJP_MODE: mvEthEjpModeSet(mvEthPortHndlGet(port), value); break; #endif /* (MV_ETH_VERSION >= 4) */ case COM_LRO: mv_eth_set_lro(port, value); break; case COM_LRO_DESC: mv_eth_set_lro_desc(port, value); break; case COM_TX_NOQUEUE: mv_eth_set_noqueue(port, value); break; default: printk(" Unknown port command \n"); } return 0; }
/* Configure EthDrv memory map registes. */ MV_STATUS mvEthWinInit (void) { MV_U32 winNum, status, accessProtReg = 0, i, regVal = 0; MV_ETH_DEC_WIN ethWin; MV_CPU_DEC_WIN cpuAddrDecWin; MV_U32 winPrioIndex = 0; /* Initiate Ethernet address decode */ /* First disable all address decode windows */ for(winNum=0; winNum<ETH_MAX_DECODE_WIN; winNum++) { regVal |= MV_BIT_MASK(winNum); } MV_REG_WRITE(ETH_BASE_ADDR_ENABLE_REG, regVal); /* Go through all windows in user table until table terminator */ for (winNum=0; ((ethAddrDecPrioTap[winPrioIndex] != TBL_TERM) && (winNum < ETH_MAX_DECODE_WIN)); ) { /* first get attributes from CPU If */ status = mvCpuIfTargetWinGet(ethAddrDecPrioTap[winPrioIndex], &cpuAddrDecWin); if(MV_NO_SUCH == status) { winPrioIndex++; continue; } if (MV_OK != status) { mvOsPrintf("mvEthWinInit: ERR. mvCpuIfTargetWinGet failed\n"); return MV_ERROR; } if (cpuAddrDecWin.enable == MV_TRUE) { ethWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh; ethWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow; ethWin.addrWin.size = cpuAddrDecWin.addrWin.size; ethWin.enable = MV_TRUE; ethWin.target = ethAddrDecPrioTap[winPrioIndex]; if(MV_OK != mvEthWinSet(winNum, ðWin)) { mvOsPrintf("mvEthWinInit: ERR. mvEthWinSet failed winNum=%d\n", winNum); return MV_ERROR; } winNum++; } winPrioIndex ++; } /* set full access to all windows. */ for(i=0; i<winNum; i++) { accessProtReg |= (FULL_ACCESS << (i*2)); } for(i=0; i < mvCtrlEthMaxPortGet(); i++) { MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(i), accessProtReg); } return MV_OK; }