extern unsigned int g_fixture_exp_port_to_ioc_disabled; //extern void scsih_dgDisableLocalFalconPhy(void); extern void sasdiag_disableExpPortToAllIoc(void); case IPC_PEER_SAS_STRESS_COMPLETE: { g_fixture_sas_ready = 1; //printk("\n"); //printk("== Received peer stress complete.=="); //printk("\n"); break; } case IPC_PEER_INIT_ENV_COMPLETE: { g_fixture_sas_ready = 1; //printk("\n"); //printk("== Received peer initial envirnoment complete.=="); //printk("\n"); break; } case IPC_CONFIG_PEER_HD_COMPLETE: { g_fixture_sas_ready = 1; //printk("\n"); //printk("== Received peer configure hard drive port complete.=="); //printk("\n"); break; } case IPC_INIT_IOC_READY: { //printk("\n"); //printk("== Received initial IOC ready. =="); //printk("\n"); g_fixture_sas_ready = 1; break; } case IPC_CONFIG_ONE_EXPANDER_PHY_READY: { //printk("\n"); //printk("== Received peer configure expander PHY ready. (PHY %d %s) ==", msg->body[0], // ((int)msg->body[1]) ? "enable" : "disable"); //printk("\n"); g_fixture_sas_ready = 1; break; } case IPC_STRESS_SAS_INIT: { extern void sasdiag_disableAllExpPhyNotifyPeer(void); sasdiag_disableAllExpPhyNotifyPeer(); break; } case IPC_SAS_STRESS_PARAM: { extern void sasStressParam(u32, u32, u32, u32, u32, u32, u8, u8); u32 rangeSz; u32 blockSz; u32 ITERATIONS; u32 START_BLOCK_NUMBER; u32 PATTERN; u32 stopOnError; u8* ptr, conVal, runVal; printk("\n=== Receive SAS Stress Params! ===\n"); ptr = (u8*)msg->body; memcpy(&rangeSz, ptr, sizeof(rangeSz)); ptr += sizeof(rangeSz); memcpy(&blockSz, ptr, sizeof(blockSz)); ptr += sizeof(blockSz); memcpy(&ITERATIONS, ptr, sizeof(ITERATIONS)); ptr += sizeof(ITERATIONS); memcpy(&START_BLOCK_NUMBER, ptr, sizeof(START_BLOCK_NUMBER)); ptr += sizeof(START_BLOCK_NUMBER); memcpy(&PATTERN, ptr, sizeof(PATTERN)); ptr += sizeof(PATTERN); memcpy(&stopOnError, ptr, sizeof(stopOnError)); ptr += sizeof(stopOnError); memcpy(&conVal, ptr, 1); ptr += 1; memcpy(&runVal, ptr, 1); ptr += 1; printk("\trangeSz=0x%08x, blockSz=0x%08x, iteration=%d\n", rangeSz, blockSz, ITERATIONS); printk("\tSTART_BLOCK_NUMBER=0x%08x, pattern=0x%08x\n", START_BLOCK_NUMBER, PATTERN); printk("\tstopOnError=0x%08x, conVal=%d, runVal=%d\n", stopOnError, conVal, runVal); sasStressParam(rangeSz, blockSz, ITERATIONS, START_BLOCK_NUMBER, PATTERN, stopOnError, conVal, runVal); break; } case IPC_PEER_SAS_STRESS_START: { unsigned int tmp[2]; extern VOID stressTestStart(VOID); extern unsigned int g_stress_select_item; extern unsigned int g_stress_run_time; extern void sslock_IPC_TX(void); printk("\n=== Receive SAS Stress START! ===\n"); memcpy(tmp, &msg->body[0], (sizeof(unsigned int)*2)); sslock_IPC_TX(); g_stress_select_item=tmp[0]; g_stress_run_time=tmp[1]; printk("g_stress_select_item=0x%08x run_time=0x%08x\n", tmp[0], tmp[1]); stressTestStart(); break; } case IPC_PEER_SAS_STRESS_STOP: { extern VOID stressTestStop(VOID); extern unsigned int g_stress_ACK; extern unsigned int g_stress_del_item; extern void sslock_IPC_TX(void); extern void ssunlock_IPC_TX(void); unsigned int tmp; printk("\n=== Receive SAS Stress STOP! ===\n"); memcpy(&tmp, &msg->body[0], sizeof(unsigned int)); sslock_IPC_TX(); if(tmp == 7){ g_stress_ACK=1; ssunlock_IPC_TX(); } else { g_stress_del_item=tmp; stressTestStop(); } break; } case IPC_INIT_IOC_TARGET: { extern int sasdiag_changeFirmware(u8 configId, u8 ioc_num, u8 fwIdx); printk("\n=== Change IOC Port To Target (ConfigId 0x%02x) Request Received! ===\n", msg->body[0]); sasdiag_changeFirmware(msg->body[0], 0, 0); break; } case IPC_EXPANDER_PORT_CONFIG_READY: { char* str = ""; switch(msg->body[0]) { case 0: str = "Expansion port"; break; case 1: str = "Remote IOC port"; break; case 2: str = "Local IOC port"; break; case 3: str = "Hard drive port"; break; } //printk("\n"); //printk("== Received expander port configure ready. (%s %s) ==", str, // (msg->body[1]) ? "enable" : "disable"); //printk("\n"); g_fixture_sas_ready = 1; break; } case IPC_SET_IOC_PHY_READY: { char* str = ""; printk("\n"); printk("== Received set ioc phy setting (through IPC Protocol) =="); printk("\n"); g_fixture_sas_ready = 1; break; } case IPC_EXPANDER_PHY_CONFIG_READY: { printk("\n"); printk("== Received expander PHY configure ready. (through IPC Protocol) =="); printk("\n"); g_fixture_sas_ready = 1; break; } case IPC_GET_PEER_IOC_ERROR_CNT: { extern int getPeerIocErrorCnt(u8, u8); getPeerIocErrorCnt(msg->body[0], msg->body[1]); break; } case IPC_APP_FIXTURE_FALCON_PHY_DISABLE_INIT: { printk("== Fixture SAS IOC PHY Disable Request Received!! (through IPC Protocol) == \n"); //scsih_dgDisableLocalFalconPhy(); sasdiag_disableExpPortToAllIoc(); break; } case IPC_APP_FIXTURE_FALCON_PHY_DISABLE_READY: { printk("== Fixture SAS IOC PHY Disable Request Received!! (through IPC Protocol) == \n"); //scsih_dgDisableLocalFalconPhy(); sasdiag_disableExpPortToAllIoc(); g_fixture_exp_port_to_ioc_disabled = 1; break; } case IPC_PEER_SAS_STRESS_FAILURE: { extern unsigned int g_peer_stress_failure_hd_num; g_peer_stress_failure_hd_num = (unsigned int)msg->body[0]; break; } // ===================== Alston : for peer expander configure. ========================== case IPC_EXPANDER_PHY_CONFIG: { extern void sasdiag_disableExpPhy(u8); extern void sasdiag_enableExpPhy(u8); u8 i; EIPC_MSG replayMsg; int numExpPhys = 36; printk("\n"); printk("== Received configure PHY request. (through IPC Protocol) =="); printk("\n"); for(i = 0; i < numExpPhys; i++) if(msg->body[i]) sasdiag_enableExpPhy(i); else sasdiag_disableExpPhy(i); ipcEthernetRegister(IPC_EXPANDER_PHY_CONFIG_READY, NULL); replayMsg.hdr.app = IPC_EXPANDER_PHY_CONFIG_READY; replayMsg.hdr.flag = IPC_APP_REQUEST; replayMsg.hdr.len = 0; ipcEthernetSend(&replayMsg); ipcEthernetDeregister(IPC_EXPANDER_PHY_CONFIG_READY); //printk("\n"); //printk("== Sended expander PHY configure ready. (through IPC Protocol) =="); //printk("\n"); break; } case IPC_EXPANDER_PORT_CONFIG: { //extern int scsih_dgConfigExpanderPort(u8, u8); extern void sasdiag_setupExpPhysicalPhys(u8, u16, u8); EIPC_MSG replyMsg; u16 path; printk("\n"); path = ((msg->body[1] << 8) | msg->body[0]); printk("== Received configure expander port request (path 0x%04x) ==", path); printk("\n"); //scsih_dgConfigExpanderPort((u8)msg->body[0], (u8)msg->body[1]); sasdiag_setupExpPhysicalPhys(0xFF, path, (u8)msg->body[2]); ipcEthernetRegister(IPC_EXPANDER_PORT_CONFIG_READY, NULL); replyMsg.hdr.app = IPC_EXPANDER_PORT_CONFIG_READY; replyMsg.hdr.flag = IPC_APP_REQUEST; replyMsg.hdr.len = 2; replyMsg.body[0] = msg->body[0]; replyMsg.body[1] = msg->body[1]; ipcEthernetSend(&replyMsg); ipcEthernetDeregister(IPC_EXPANDER_PORT_CONFIG_READY); //printk("\n"); //printk("== Sended expander port configure ready. (port %d) ==", msg->body[0]); //printk("\n"); break; } case IPC_SET_IOC_PHY: { extern void sasdiag_set_ioc_phy_by_sasioc_page1(U8); EIPC_MSG replyMsg; u8 ioc_num; ioc_num = msg->body[0]; sasdiag_set_ioc_phy_by_sasioc_page1(ioc_num); ipcEthernetRegister(IPC_SET_IOC_PHY_READY, NULL); replyMsg.hdr.app = IPC_SET_IOC_PHY_READY; replyMsg.hdr.flag = IPC_APP_REQUEST; replyMsg.hdr.len = 0; ipcEthernetSend(&replyMsg); ipcEthernetDeregister(IPC_SET_IOC_PHY_READY); break; } case IPC_INIT_IOC: { extern void scsih_dgFixtureIocInit(void); EIPC_MSG replyMsg; //printk("\n"); //printk("== Received initial IOC request. (through IPC Protocol) =="); //printk("\n"); scsih_dgFixtureIocInit(); ipcEthernetRegister(IPC_INIT_IOC_READY, NULL); replyMsg.hdr.app = IPC_INIT_IOC_READY; replyMsg.hdr.flag = IPC_APP_REQUEST; replyMsg.hdr.len = 0; ipcEthernetSend(&replyMsg); ipcEthernetDeregister(IPC_INIT_IOC_READY); //printk("\n"); //printk("== Sended initial IOC ready. =="); //printk("\n"); break; } case IPC_CONFIG_ONE_EXPANDER_PHY: { extern void sasdiag_disableExpPhy(u8); extern void sasdiag_enableExpPhy(u8); EIPC_MSG replyMsg; printk("\n"); printk("== Received configure expander PHY request. (PHY %d %s) ==", msg->body[0], ((int)msg->body[1]) ? "enable" : "disable"); printk("\n"); if(msg->body[1]) sasdiag_enableExpPhy((u8)msg->body[0]); else sasdiag_disableExpPhy((u8)msg->body[0]); ipcEthernetRegister(IPC_CONFIG_ONE_EXPANDER_PHY_READY, NULL); replyMsg.hdr.app = IPC_CONFIG_ONE_EXPANDER_PHY_READY; replyMsg.hdr.flag = IPC_APP_REQUEST; replyMsg.hdr.len = 2; replyMsg.body[0] = msg->body[0]; replyMsg.body[1] = msg->body[1]; ipcEthernetSend(&replyMsg); ipcEthernetDeregister(IPC_CONFIG_ONE_EXPANDER_PHY_READY); //printk("\n"); //printk("== Sended configure expander PHY ready. (PHY %d %s) ==", msg->body[0], // ((int)msg->body[1]) ? "enable" : "disable"); //printk("\n"); break; } case IPC_SAVE_PEER_IOC_ERROR_CNT: { extern unsigned int g_expander_phy_error; u32* pErrCnt; u32 invalidDwordCnt; u32 RunDispErrCnt; u32 lossDwordSyncCnt; u32 phyResetProblemCnt; struct file *fp; mm_segment_t fs; char buf[128]; int i; int numIocPhys = 8; #ifndef ALANWANG // 2010/07/15 extern int ssDoesCtlRoleSwap(void); int swapFlag=ssDoesCtlRoleSwap(); char *slotStr=(swapFlag)? "Slot B":"Slot A"; char *fileStr=(swapFlag)? "/tmp/SAS/errorCnt_slotB":"/tmp/SAS/errorCnt_slotA"; #endif pErrCnt = (u32*)msg->body; fp = filp_open(fileStr, O_RDWR | O_APPEND | O_CREAT, S_IRUSR); if(IS_ERR(fp)) { printk("Cannot open log file"); break; } fs = get_fs(); set_fs(KERNEL_DS); { char headLine1[64]; char headLine2[64]; char headLine3[64]; snprintf(headLine1, sizeof(headLine1), "**********************************************\n"); snprintf(headLine2, sizeof(headLine2), "* SAS 2008 IOC (%s) *\n", slotStr); snprintf(headLine3, sizeof(headLine3), "**********************************************\n"); fp->f_op->write(fp, headLine1, strlen(headLine1), &fp->f_pos); fp->f_op->write(fp, headLine2, strlen(headLine2), &fp->f_pos); fp->f_op->write(fp, headLine3, strlen(headLine3), &fp->f_pos); } for(i = 0; i < numIocPhys; i++) { invalidDwordCnt = le32_to_cpu(*pErrCnt); pErrCnt++; RunDispErrCnt = le32_to_cpu(*pErrCnt); pErrCnt++; lossDwordSyncCnt = le32_to_cpu(*pErrCnt); pErrCnt++; phyResetProblemCnt = le32_to_cpu(*pErrCnt); pErrCnt++; snprintf(buf, sizeof(buf), "%s IOC Phy(%d) : -------------------------------------------\n", slotStr,i); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s IOC Phy(%d) : Invalid Dword Count=%d\n", slotStr, i, invalidDwordCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s IOC Phy(%d) : Running Disparity Error Count=%d\n", slotStr, i, RunDispErrCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s IOC Phy(%d) : Loss Dword Synch Count=%d\n", slotStr, i, lossDwordSyncCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s IOC Phy(%d) : PHY Reset Problem Count=%d\n", slotStr, i, phyResetProblemCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); if(invalidDwordCnt != 0 || lossDwordSyncCnt != 0 || lossDwordSyncCnt != 0 || phyResetProblemCnt != 0) g_expander_phy_error = 1; } set_fs(fs); filp_close(fp,NULL); break; } case IPC_GET_PEER_EXP_ERROR_CNT: { extern void getPeerExpanderErrorCnt(u16); u16 path; path = ((msg->body[1] << 8) | msg->body[0]); printk("== Received Get Peer expander Error Cnt request (path 0x%04x) ==", path); getPeerExpanderErrorCnt(path); break; } case IPC_SAVE_PEER_EXP_ERROR_CNT: { extern unsigned int g_expander_phy_error; u32* pErrCnt; u32 invalidDwordCnt; u32 RunDispErrCnt; u32 lossDwordSyncCnt; u32 phyResetProblemCnt; struct file *fp; mm_segment_t fs; char buf[128]; int i; int numExpPhys = 36; #ifndef ALANWANG // 2010/07/15 extern unsigned int g_last_stress_type; extern int ssDoesCtlRoleSwap(void); int swapFlag=ssDoesCtlRoleSwap(); char *slotStr=(swapFlag)? "Slot B":"Slot A"; char *fileStr=(swapFlag)? "/tmp/SAS/errorCnt_slotB":"/tmp/SAS/errorCnt_slotA"; int start, end; #endif pErrCnt = (u32*)msg->body; fp = filp_open(fileStr, O_RDWR | O_APPEND | O_CREAT, S_IRUSR); if(IS_ERR(fp)) { printk("Cannot open log file"); break; } fs = get_fs(); set_fs(KERNEL_DS); { char headLine1[64]; char headLine2[64]; char headLine3[64]; snprintf(headLine1, sizeof(headLine1), "**********************************************\n"); snprintf(headLine2, sizeof(headLine2), "* SAS 2x36 Expander (%s) *\n", slotStr); snprintf(headLine3, sizeof(headLine3), "**********************************************\n"); fp->f_op->write(fp, headLine1, strlen(headLine1), &fp->f_pos); fp->f_op->write(fp, headLine2, strlen(headLine2), &fp->f_pos); fp->f_op->write(fp, headLine3, strlen(headLine3), &fp->f_pos); } #ifndef ALANWANG // 2010/07/15 start=(g_last_stress_type == 5)? 0:4; pErrCnt += start*4; end=(g_last_stress_type == 5)? 4:numExpPhys; for(i = start; i < end; i++) #endif { invalidDwordCnt = le32_to_cpu(*pErrCnt); pErrCnt++; RunDispErrCnt = le32_to_cpu(*pErrCnt); pErrCnt++; lossDwordSyncCnt = le32_to_cpu(*pErrCnt); pErrCnt++; phyResetProblemCnt = le32_to_cpu(*pErrCnt); pErrCnt++; snprintf(buf, sizeof(buf), "%s Exp Phy(%d) : -------------------------------------------\n", slotStr,i); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s Exp Phy(%d) : Invalid Dword Count=%d\n", slotStr, i, invalidDwordCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s Exp Phy(%d) : Running Disparity Error Count=%d\n", slotStr, i, RunDispErrCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s Exp Phy(%d) : Loss Dword Synch Count=%d\n", slotStr, i, lossDwordSyncCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s Exp Phy(%d) : PHY Reset Problem Count=%d\n", slotStr, i, phyResetProblemCnt); fp->f_op->write(fp, buf, strlen(buf), &fp->f_pos); memset(buf, '\0', sizeof(buf)); if(invalidDwordCnt != 0 || lossDwordSyncCnt != 0 || lossDwordSyncCnt != 0 || phyResetProblemCnt != 0) g_expander_phy_error = 1; } set_fs(fs); filp_close(fp,NULL); break; } // TODO // case IPC_CONFIG_PEER_HD_PORT: // { // #if defined(CHASSIS_WSAS) // extern void configHardDrive(u32); // u32 phyMap; // #else // extern void configHardDrive(u64); // u64 phyMap; // #endif // memcpy(&phyMap, msg->body, sizeof(phyMap)); // configHardDrive(phyMap); // break; // } case IPC_PEER_PARSE_PHY_MAP: { #if defined(CHASSIS_WSAS) extern void parsePhyMap(u64); u64 phyMap; #else extern void parsePhyMap(u32); u32 phyMap; #endif memcpy(&phyMap, msg->body, sizeof(phyMap)); parsePhyMap(phyMap); break; } case IPC_FPGA_REG_GET: { extern UINT8 fpgaRegisterRead(UINT32 fpgaOffset); uint8_t temp = 0; uint32_t reg[10]; int i, num; num = msg->body[0]; memcpy(reg, &msg->body[sizeof(uint8_t)], sizeof(uint32_t)*num); for(i = 0; i < num; i++){ temp = fpgaRegisterRead(reg[i]); memcpy(&msg->body[sizeof(uint8_t)*i], &temp, sizeof(uint8_t)); } msg->hdr.cookie = 0; msg->hdr.flag = IPC_APP_RESPONSE; msg->hdr.len = sizeof(uint8_t)*num; ipcEthernetSend(msg); break; } #if 0 case IPC_BOARD_TEMP_STATUS: { //extern void mfgCtlTempShow(int senNO); PUBLIC int16_t gBoardTempFlag; //mfgCtlTempShow(0); memcpy(&msg->body[0], &gBoardTempFlag, sizeof(int16_t)); msg->hdr.cookie = 0; msg->hdr.flag = IPC_APP_RESPONSE; msg->hdr.len = sizeof(int16_t); ipcEthernetSend(msg); break; } #endif #if 0 case IPC_READ_SUM_FRU: { extern struct i2c_adapter *pca9548Adapter[8]; // extern int i2cEEpromRead(struct i2c_adapter *adap, uint16_t i2c_addr, // uint16_t offset, uint8_t *buf, int count); extern int hic9548ChSet(uint8_t channel, int mode); extern HOST_CARD_TYPE sysHostCardType; extern uint8_t fpgaRegisterRead(uint32_t fpgaOffset); // extern int qe8SFPread(int AdapID, uint8_t *data, int len); // extern int qe8HICSFPread(int AdapID, uint8_t *data, int len); uint8_t Buf[200] = {0}, ret, regValue, idx; int len = 80; if(msg->body[0] == 1){ struct i2c_adapter *adap = pca9548Adapter[7]; if(i2cEEpromRead(adap, (0xac >> 1), 0, Buf, len) == 0){ msg->body[0] = 0; memcpy(&msg->body[1], Buf, (sizeof(uint8_t)*len)); } else{ msg->body[0] = 0xff; len = 1; } } else if(msg->body[0] == 2){ struct i2c_adapter *adap = pca9548Adapter[6]; ret = 0; if(sysHostCardType != 0){ if(sysHostCardType == 1 || sysHostCardType == 2){ if(hic9548ChSet(0x10, 1) != 1){ ret = 1; msg->body[0] = 0xff; len = 1; } } if(ret == 0){ if(i2cEEpromRead(adap, (0xac >> 1), 0, Buf, len) == 0){ msg->body[0] = 0; memcpy(&msg->body[1], Buf, len*sizeof(uint8_t)); } else{ msg->body[0] = 0xff; len = 1; } } } else{ msg->body[0] = 0xee; len = 1; } } else if(msg->body[0] == 3){ regValue = fpgaRegisterRead(0x66); if(regValue&0x4){ struct i2c_adapter *adap = pca9548Adapter[5]; if(i2cEEpromRead(adap, (0xa0 >> 1), 0, Buf, len) == 0){ msg->body[0] = 0; memcpy(&msg->body[1], Buf, len*sizeof(uint8_t)); } else{ msg->body[0] = 0xff; len = 1; } } else{ msg->body[0] = 0xee; len = 1; } } else if(msg->body[0] == 4){ len = 100; idx = msg->body[1]; if( idx < 4 ){ // ret = qe8SFPread(idx, Buf, len); ret = 0; } else{ // ret = qe8HICSFPread(( idx-4 ), Buf, len); ret = 0; } if(ret == 0){ msg->body[0] = 0; memcpy(&msg->body[1], Buf, len*sizeof(uint8_t)); } else{ msg->body[0] = 0xee; len = 1; } } msg->hdr.cookie = 0; msg->hdr.flag = IPC_APP_RESPONSE; msg->hdr.len = len*sizeof(uint8_t); ipcEthernetSend(msg); break; } #endif // ======================================================================================