MV_VOID mvNfpSecSaPrint(MV_NFP_SEC_SA_ENTRY *pSAEntry) { mvDebugPrintIpAddr(MV_32BIT_BE(pSAEntry->tunnelHdr.sIp)); mvOsPrintf("->"); mvDebugPrintIpAddr(MV_32BIT_BE(pSAEntry->tunnelHdr.dIp)); mvOsPrintf(" out_if=%d da=", pSAEntry->tunnelHdr.outIfIndex); mvDebugPrintMacAddr(pSAEntry->tunnelHdr.dstMac); mvOsPrintf(" spi=0x%x", MV_32BIT_BE(pSAEntry->spi)); if (pSAEntry) mvOsPrintf("\tstats: encrypt:%d decrypt:%d reject:%d drop:%d bytes:%d", pSAEntry->stats.encrypt, pSAEntry->stats.decrypt, pSAEntry->stats.rejected, pSAEntry->stats.dropped, pSAEntry->stats.bytes); mvOsPrintf("\n"); }
/******************************************************************************* * mvFlash32Wr - Write 32bit (word) to flash. * * DESCRIPTION: * This function writes 32bit data to a given flash offset. * * INPUT: * pFlash - Flash identifier structure (flash cockie). * offset - Offset from flash base address. * data - 32bit data to be written to flash. * * OUTPUT: * None. * * RETURN: * MV_BAD_PARAM if one of the inputs values is illegal, * MV_OK if write completed successfully, * MV_FAIL otherwise (e.g. sector protected). * *******************************************************************************/ MV_STATUS mvFlash32Wr(MV_FLASH_INFO *pFlash, MV_U32 offset, MV_U32 data) { MV_U32 i, status = MV_OK, temp,secNum; DB(mvOsPrintf("Flash: mvFlash32Wr offset %x data %x \n",offset,data)); /* check that the offset is aligned to 32 bit */ if((NULL == pFlash) || (offset % 4)) return MV_BAD_PARAM; secNum = mvFlashInWhichSec(pFlash,offset); DB(mvOsPrintf("Flash: mvFlashProg \n")); /* check if offset is in flash range */ if( secNum >= mvFlashNumOfSecsGet(pFlash)) { DB(mvOsPrintf("Flash: mvFlashProg offset out of flash range \n")); return MV_BAD_PARAM; } /* check if sector is locked */ if(MV_TRUE == mvFlashSecLockGet(pFlash, secNum) ) { mvOsPrintf("Flash: ERROR mvFlashProg protected sector.\n"); return MV_FAIL; } /* check if offset is erased enough */ if((mvFlash32Rd(pFlash, offset) & data) != data ) { mvOsPrintf("%s ERROR: offset 0x%x (sector %d) isn't erased !!!.\n", __FUNCTION__, offset, secNum); return MV_FAIL; } /* bus width is 32 bit */ if(mvFlashBusWidthGet(pFlash) == 4) { data = MV_32BIT_BE(data); status = mvFlashProg(pFlash, offset,data); } /* bus width is 16 bit */ else if(mvFlashBusWidthGet(pFlash) == 2) { for(i = 0; i < 2; i++) { /* 0x44556677 -> [44][55][66][77] */ temp = MV_16BIT_BE(((data >> (16*(1-i))) & FLASH_MASK_16BIT)); if(MV_OK != mvFlashProg(pFlash, offset + (i*2), temp) ) { status = MV_FAIL; break; } } } /* bus width is 8 bit */ else if(mvFlashBusWidthGet(pFlash) == 1)
/* Print a NFP NAT Rule */ void mvFpNatRulePrint(const MV_FP_NAT_RULE *rule) { /* Note: some of the fields in the NAT rule may contain invalid values */ mvOsPrintf("Original packet: "); mvOsPrintf("SIP="); mvDebugPrintIpAddr(MV_32BIT_BE(rule->srcIp)), mvOsPrintf(", DIP="); mvDebugPrintIpAddr(MV_32BIT_BE(rule->dstIp)), mvOsPrintf(", SPort=%d", MV_16BIT_BE(rule->srcPort)); mvOsPrintf(", DPort=%d", MV_16BIT_BE(rule->dstPort)); mvOsPrintf("\nNAT Info: "); mvOsPrintf("count=%u, flags=0x%x", rule->new_count, rule->flags); mvOsPrintf(", newIP="); mvDebugPrintIpAddr(MV_32BIT_BE(rule->newIp)); mvOsPrintf(", newPort=%d", MV_16BIT_BE(rule->newPort)); mvOsPrintf("\n"); }
/* Append sequence number and spi, save some space for IV */ INLINE MV_VOID mvNfpSecBuildEspHdr(MV_PKT_INFO *pPktInfo, MV_NFP_SEC_SA_ENTRY *pSAEntry) { MV_ESP_HEADER *pEspHdr; pEspHdr = (MV_ESP_HEADER *) (pPktInfo->pFrags[0].bufVirtPtr + sizeof(MV_802_3_HEADER) + sizeof(MV_IP_HEADER)); pEspHdr->spi = pSAEntry->spi; pSAEntry->seqNum = (pSAEntry->seqNum++); pEspHdr->seqNum = MV_32BIT_BE(pSAEntry->seqNum); }
int run_ip_rule_del_com(const char *buffer) { int scan_count; MV_STATUS status = MV_OK; scan_count = sscanf(buffer, IP_RULE_DEL_STRING, IP_RULE_DEL_SCANF_LIST); if( scan_count != IP_RULE_DEL_LIST_LEN) { printk("eth proc bad format %x != %x\n", scan_count, IP_RULE_DEL_LIST_LEN); return 1; } status = fp_rule_delete(MV_32BIT_BE(sip), MV_32BIT_BE(dip), MV_FP_STATIC_RULE); if(status != MV_OK) { printk("fp_rule_delete FAILED: status=%d\n", status); } return status; }
/* Print a NFP Rule */ void mvFpRulePrint(const MV_FP_RULE *rule) { mvFpActionTypePrint(rule); mvFpRuleTypePrint(rule); mvOsPrintf(", SIP="); mvDebugPrintIpAddr(MV_32BIT_BE(rule->routingInfo.srcIp)); mvOsPrintf(", DIP="); mvDebugPrintIpAddr(MV_32BIT_BE(rule->routingInfo.dstIp)); mvOsPrintf(", GTW="); mvDebugPrintIpAddr(MV_32BIT_BE(rule->routingInfo.defGtwIp)); mvOsPrintf(", DA="); mvDebugPrintMacAddr(rule->routingInfo.dstMac); mvOsPrintf(", SA="); mvDebugPrintMacAddr(rule->routingInfo.srcMac); mvOsPrintf(", inIf=%d", rule->routingInfo.inIfIndex); mvOsPrintf(", outIf=%d", rule->routingInfo.outIfIndex); mvOsPrintf(", count=%d, aware_flags=0x%X", rule->mgmtInfo.new_count, rule->routingInfo.aware_flags); mvOsPrintf("\n"); }
int run_ip_rule_set_com(const char *buffer) { int scan_count, i; MV_FP_RULE ip_rule; MV_STATUS status = MV_OK; scan_count = sscanf(buffer, IP_RULE_STRING, IP_RULE_SCANF_LIST); if( scan_count != IP_RULE_LIST_LEN) { printk("eth proc bad format %x != %x\n", scan_count, IP_RULE_LIST_LEN); return 1; } memset(&ip_rule, 0, sizeof(ip_rule)); printk("run_ip_rule_set_com: dip=%08x, sip=%08x, inport=%d, outport=%d\n", dip, sip, inport, outport); ip_rule.routingInfo.dstIp = MV_32BIT_BE(dip); ip_rule.routingInfo.srcIp = MV_32BIT_BE(sip); ip_rule.routingInfo.defGtwIp = MV_32BIT_BE(dip); ip_rule.routingInfo.inIfIndex = inport; ip_rule.routingInfo.outIfIndex = outport; ip_rule.routingInfo.aware_flags = 0; for(i=0; i<MV_MAC_ADDR_SIZE; i++) { ip_rule.routingInfo.dstMac[i] = (MV_U8)(da[i] & 0xFF); ip_rule.routingInfo.srcMac[i] = (MV_U8)(sa[i] & 0xFF);; } ip_rule.mgmtInfo.actionType = MV_FP_ROUTE_CMD; ip_rule.mgmtInfo.ruleType = MV_FP_STATIC_RULE; status = fp_rule_set(&ip_rule); if(status != MV_OK) { printk("fp_rule_set FAILED: status=%d\n", status); } return status; }
MV_VOID mvNfpSecDbPrint(MV_VOID) { MV_U32 i; mvOsPrintf("NFP IPSec:\n"); for (i = 0; i < spdInRuleCount; i++) { mvOsPrintf("inbound[%d] ", i); mvDebugPrintIpAddr(MV_32BIT_BE(spdInDb[i].sIp)); mvOsPrintf("->"); mvDebugPrintIpAddr(MV_32BIT_BE(spdInDb[i].dIp)); mvOsPrintf(" "); mvNfpSecSaPrint(spdInDb[i].pSAEntry); } for (i = 0; i < spdOutRuleCount; i++) { mvOsPrintf("outbound[%d] ", i); mvDebugPrintIpAddr(MV_32BIT_BE(spdOutDb[i].sIp)); mvOsPrintf("->"); mvDebugPrintIpAddr(MV_32BIT_BE(spdOutDb[i].dIp)); mvOsPrintf(" "); mvNfpSecSaPrint(spdOutDb[i].pSAEntry); } }