/* 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; } port_hndl = mvEthPortHndlGet(port); if(port_hndl == NULL) return 1; switch(command) { case COM_RX_COAL: mvEthRxCoalSet(mvEthPortHndlGet(port), value); break; case COM_TX_COAL: mvEthTxCoalSet(mvEthPortHndlGet(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_TX_NOQUEUE: mv_eth_set_noqueue(port, value); break; default: printk(" Unknown port command \n"); } return 0; }
void run_com_srq(void) { void* port_hndl = mvEthPortHndlGet(port); if(port_hndl == NULL) return; if(q >= MV_ETH_RX_Q_NUM) q = -1; switch(packet) { case PT_BPDU: mvEthBpduRxQueue(port_hndl, q); break; case PT_ARP: mvEthArpRxQueue(port_hndl, q); break; case PT_TCP: mvEthTcpRxQueue(port_hndl, q); break; case PT_UDP: mvEthUdpRxQueue(port_hndl, q); break; default: printk("eth proc unknown packet type.\n"); } }
void ethRxPolicy(int port) { int queue; ETH_RX_POLICY* pRxPolicy = (ETH_RX_POLICY*)mvEthRxPolicyHndlGet(port); ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)mvEthPortHndlGet(port); if( (pPortCtrl == NULL) || (pRxPolicy == NULL) ) { return; } mvOsPrintf("rxDefQ=%d, arpQ=%d, bpduQ=%d, ucastQ=%d, tcpQ=%d, udpQ=%d\n\n", pPortCtrl->portConfig.rxDefQ, pPortCtrl->portConfig.rxArpQ, pPortCtrl->portConfig.rxBpduQ, pPortCtrl->portConfig.rxUcastQ, pPortCtrl->portConfig.rxTcpQ, pPortCtrl->portConfig.rxUdpQ); mvOsPrintf("ethRxPolicy #%d: hndl=%p, mode=%s, curQ=%d, curQuota=%d\n", pRxPolicy->port, pRxPolicy, (pRxPolicy->rxPrioMode == MV_ETH_PRIO_FIXED) ? "FIXED" : "WRR", pRxPolicy->rxCurQ, pRxPolicy->rxCurQuota); for(queue=0; queue<MV_ETH_RX_Q_NUM; queue++) { mvOsPrintf("\t rxQ #%d: rxQuota=%d\n", queue, pRxPolicy->rxQuota[queue]); } }
void ethTxPolicy(int port) { ETH_TX_POLICY* pTxPolicy = (ETH_TX_POLICY*) mvEthTxPolicyHndlGet(port); int idx,i,queue; char macStr[MV_MAC_STR_SIZE]; ETH_PORT_CTRL* pPortCtrl = (ETH_PORT_CTRL*)mvEthPortHndlGet(port); if((pPortCtrl == NULL) || (pTxPolicy == NULL)) { return; } for(queue=0; queue<MV_ETH_TX_Q_NUM; queue++) { mvOsPrintf("TX Queue #%d: mode=%s, quota=%d\n", queue, (pPortCtrl->txQueueConfig[queue].prioMode == MV_ETH_PRIO_FIXED) ? "FIXED" : "WRR", pPortCtrl->txQueueConfig[queue].quota ); } mvOsPrintf("\nethDefTxPolicy : hndl=%p, defQ=%d, defHeader=%p, defSize=%d, maxDa=%d\n\n", pTxPolicy, pTxPolicy->txPolDef.txQ, pTxPolicy->txPolDef.pHeader, pTxPolicy->txPolDef.headerSize, pTxPolicy->txPolMaxDa); if(pTxPolicy->txPolDef.headerSize != 0) { for(i = 0; i < pTxPolicy->txPolDef.headerSize; i++) { mvOsPrintf(" %02x",pTxPolicy->txPolDef.pHeader[i]); if( (i & 0xf) == 0xf ) mvOsPrintf("\n"); } mvOsPrintf("\n"); } for(idx=0; idx<pTxPolicy->txPolMaxDa; idx++) { if(pTxPolicy->txPolDa[idx].policy.txQ == MV_INVALID) continue; mvMacHexToStr(pTxPolicy->txPolDa[idx].macDa, macStr); mvOsPrintf("%d. MAC = %s, txQ=%d, pHeader=%p, headerSize=%d\n", idx, macStr, pTxPolicy->txPolDa[idx].policy.txQ, pTxPolicy->txPolDa[idx].policy.pHeader, pTxPolicy->txPolDa[idx].policy.headerSize); if(pTxPolicy->txPolDa[idx].policy.headerSize != 0) { for(i = 0; i < pTxPolicy->txPolDa[idx].policy.headerSize; i++) { mvOsPrintf(" %02x",pTxPolicy->txPolDa[idx].policy.pHeader[i]); if( (i & 0xf) == 0xf ) mvOsPrintf("\n"); } mvOsPrintf("\n"); } } }
void ethRxCoal(int port, int usec) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthRxCoalSet(pHndl, usec); } }
/* Print port queues information */ void ethPortQueues(int port, int rxQueue, int txQueue, int mode) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthQueuesShow(pHndl, rxQueue, txQueue, mode); } }
/* Print port information */ void ethPortStatus(int port) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthPortShow(pHndl); } }
/******************************************************************************* * ethClearMibCounters - Clear all MIB counters * * DESCRIPTION: * This function clears all MIB counters of a specific ethernet port. * A read from the MIB counter will reset the counter. * * INPUT: * int port - Ethernet Port number. * * RETURN: None * *******************************************************************************/ void ethClearCounters(int port) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) mvEthMibCountersClear(pHndl); return; }
void ethUdpRxQ(int port, int udpQueue) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthUdpRxQueue(pHndl, udpQueue); } }
void ethTcpRxQ(int port, int tcpQueue) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthTcpRxQueue(pHndl, tcpQueue); } }
void ethArpRxQ(int port, int arpQueue) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthArpRxQueue(pHndl, arpQueue); } }
void ethBpduRxQ(int port, int bpduQueue) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthBpduRxQueue(pHndl, bpduQueue); } }
void ethTxQ(int port, int txQueue, MV_ETH_PRIO_MODE txPrioMode, int txQuota) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvEthTxQueueConfig(pHndl, txQueue, txPrioMode, txQuota); } }
void ethMcastAdd(int port, char* macStr, int queue) { void* pHndl; MV_U8 macAddr[MV_MAC_ADDR_SIZE]; pHndl = mvEthPortHndlGet(port); if(pHndl != NULL) { mvMacStrToHex(macStr, macAddr); mvEthMcastAddrSet(pHndl, macAddr, queue); } }
/* Print RMON counters of the Ethernet port */ void ethPortRmonCounters(int port) { void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl == NULL) return; mvOsPrintf("\n\t Port #%d RMON MIB Counters\n\n", port); mvOsPrintf("64 ByteFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_64_OCTETS, NULL)); mvOsPrintf("65...127 ByteFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_65_TO_127_OCTETS, NULL)); mvOsPrintf("128...255 ByteFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_128_TO_255_OCTETS, NULL)); mvOsPrintf("256...511 ByteFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_256_TO_511_OCTETS, NULL)); mvOsPrintf("512...1023 ByteFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_512_TO_1023_OCTETS, NULL)); mvOsPrintf("1024...Max ByteFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_FRAMES_1024_TO_MAX_OCTETS, NULL)); }
/* Print counters of the Ethernet port */ void ethPortCounters(int port) { MV_U32 regValue, regValHigh; void* pHndl; pHndl = mvEthPortHndlGet(port); if(pHndl == NULL) return; mvOsPrintf("\n\t Port #%d MIB Counters\n\n", port); mvOsPrintf("GoodFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_FRAMES_RECEIVED, NULL)); mvOsPrintf("BadFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_BAD_FRAMES_RECEIVED, NULL)); mvOsPrintf("BroadcastFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_BROADCAST_FRAMES_RECEIVED, NULL)); mvOsPrintf("MulticastFramesReceived = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_MULTICAST_FRAMES_RECEIVED, NULL)); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW, ®ValHigh); mvOsPrintf("GoodOctetsReceived = 0x%08x%08x\n", regValHigh, regValue); mvOsPrintf("\n"); mvOsPrintf("GoodFramesSent = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_FRAMES_SENT, NULL)); mvOsPrintf("BroadcastFramesSent = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_BROADCAST_FRAMES_SENT, NULL)); mvOsPrintf("MulticastFramesSent = %u\n", mvEthMibCounterRead(pHndl, ETH_MIB_MULTICAST_FRAMES_SENT, NULL)); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_OCTETS_SENT_LOW, ®ValHigh); mvOsPrintf("GoodOctetsSent = 0x%08x%08x\n", regValHigh, regValue); mvOsPrintf("\n\t FC Control Counters\n"); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_UNREC_MAC_CONTROL_RECEIVED, NULL); mvOsPrintf("UnrecogMacControlReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_GOOD_FC_RECEIVED, NULL); mvOsPrintf("GoodFCFramesReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_BAD_FC_RECEIVED, NULL); mvOsPrintf("BadFCFramesReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_FC_SENT, NULL); mvOsPrintf("FCFramesSent = %u\n", regValue); mvOsPrintf("\n\t RX Errors\n"); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_BAD_OCTETS_RECEIVED, NULL); mvOsPrintf("BadOctetsReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_UNDERSIZE_RECEIVED, NULL); mvOsPrintf("UndersizeFramesReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_FRAGMENTS_RECEIVED, NULL); mvOsPrintf("FragmentsReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_OVERSIZE_RECEIVED, NULL); mvOsPrintf("OversizeFramesReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_JABBER_RECEIVED, NULL); mvOsPrintf("JabbersReceived = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_MAC_RECEIVE_ERROR, NULL); mvOsPrintf("MacReceiveErrors = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_BAD_CRC_EVENT, NULL); mvOsPrintf("BadCrcReceived = %u\n", regValue); mvOsPrintf("\n\t TX Errors\n"); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR, NULL); mvOsPrintf("TxMacErrors = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_EXCESSIVE_COLLISION, NULL); mvOsPrintf("TxExcessiveCollisions = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_COLLISION, NULL); mvOsPrintf("TxCollisions = %u\n", regValue); regValue = mvEthMibCounterRead(pHndl, ETH_MIB_LATE_COLLISION, NULL); mvOsPrintf("TxLateCollisions = %u\n", regValue); mvOsPrintf("\n"); regValue = MV_REG_READ( ETH_RX_DISCARD_PKTS_CNTR_REG(port)); mvOsPrintf("Rx Discarded packets counter = %u\n", regValue); regValue = MV_REG_READ(ETH_RX_OVERRUN_PKTS_CNTR_REG(port)); mvOsPrintf("Rx Overrun packets counter = %u\n", regValue); }