/**Create by Hans*/ #include #include #include #include #include #include #include #include #include "commIpcApi.h" #include "qe8Stress.h" #define SIG_IO_TEST_START SIGUSR1 #define SIG_IO_TEST_STOP SIGUSR2 fc_stress_Param_t g_local_fc_stress_param; /* global parameters */ unsigned int g_fc_stress_channel0 = 0; unsigned int g_fc_stress_channel1 = 0; unsigned int g_fc_stress_channel2 = 0; unsigned int g_fc_stress_channel3 = 0; unsigned int g_fc_stress_channel4 = 0; // hic card channel unsigned int g_fc_stress_channel5 = 0; unsigned int g_fc_stress_channel6 = 0; unsigned int g_fc_stress_channel7 = 0; unsigned int g_fc_stress_testTime = 0; unsigned int g_fc_stress_blockSize = 0; unsigned int g_fc_stress_speed = 0; unsigned int g_fc_stress_pattern = 0; unsigned int g_fc_stress_SOE=0; unsigned int g_fc_stress_dv=1; unsigned int g_fc_stress_change_speed_flag = 0; unsigned int g_fc_stress_run_flage=0; unsigned int g_stress_run_time = 0; EXPORT_SYMBOL(g_stress_run_time); unsigned int g_stress_del_item = 0; //for service EXPORT_SYMBOL(g_stress_del_item); unsigned int g_stress_select_item = 0; //for service EXPORT_SYMBOL(g_stress_select_item); unsigned int g_fc_msg_item=0; //selet a massage item to show EXPORT_SYMBOL(g_fc_msg_item); unsigned int g_fc_msg_value0=0; //get a num into the massage EXPORT_SYMBOL(g_fc_msg_value0); unsigned int g_fc_msg_value1=0; //get a num into the massage EXPORT_SYMBOL(g_fc_msg_value1); static bool s_fc_get_qe8_stress_num_notify; static bit8 port_dis_flag=0; extern INT32 sysStressInit(VOID); extern VOID sysStressExit(VOID); static uint32_t s_bs_ports[QE8_TGT_INI_NUM][QE8_CONTROLLER_NUM] = {{( QE8_PORT_1 | QE8_PORT_2 | QE8_PORT_3 | QE8_PORT_4 | QE8_PORT_5 | QE8_PORT_6 | QE8_PORT_7 | QE8_PORT_8), (0)}, {(0), (QE8_PORT_1 | QE8_PORT_2 | QE8_PORT_3 | QE8_PORT_4 | QE8_PORT_5 | QE8_PORT_6 | QE8_PORT_7 | QE8_PORT_8)}}; extern pid_t g_sysStressd_pid; extern void sslock_lock_UUT(void); extern void ssunlock_lock_UUT(void); static void qe8GetPeerStressNumNotify(EIPC_MSG *msgP) { memcpy(&g_local_fc_stress_param, &msgP->body[0], sizeof(fc_stress_Param_t)); s_fc_get_qe8_stress_num_notify = true; } int qe8GetPeerStressNum(void) { int ret = 0; unsigned int idx; IPC_MSG msg; /* Register an IPC notification routine */ ipcEthernetRegister(IPC_GET_FC_STRESS_NUM, (void *) qe8GetPeerStressNumNotify); s_fc_get_qe8_stress_num_notify = false; /* send request */ msg.hdr.app = IPC_GET_FC_STRESS_NUM; msg.hdr.flag = IPC_APP_REQUEST; msg.hdr.len = sizeof(fc_stress_Param_t); ipcEthernetSend((EIPC_MSG*) &msg); /* wait for complete */ for(idx=0;idx>= 1; } } } } static int __qe8GetStressPortSpeed(unsigned int port_idx, int *speed) { #define SPEED_MASK 0x0000001e #define FC_rFMConfig3 0x100 /* FM config 3 register */ #define fcSpeed2G 0x0000000a #define fcSpeed4G 0x00000014 #define fcSpeed8G 0x0000001e hpRoot_t *hp_rootP = NULL; unsigned int regVal = 0; bool ret=1; sslock_lock_UUT(); if ( sysCtrlRole == ROLE_UUT){ ret=QE8GetHpRoot(port_idx, &hp_rootP); }else{ ret=QE8IniGetHpRoot(port_idx, &hp_rootP); } ssunlock_lock_UUT(); if ( ret == 0 ) { printk( "GetHpRoot is fail!!\n"); return -1; } regVal = osChipRegRead(hp_rootP, FC_rFMConfig3); regVal &= SPEED_MASK; switch (regVal) { case fcSpeed2G: *speed=2; return 0; case fcSpeed4G: *speed=4; return 0; case fcSpeed8G: *speed=8; return 0; } return 0; } void qe8GetStressPortErrCnt(unsigned int port_idx, unsigned int *link_status1, unsigned int *link_status2) { hpRoot_t *hp_rootP = NULL; bool ret=1; sslock_lock_UUT(); if ( sysCtrlRole == ROLE_UUT){ ret = QE8GetHpRoot(port_idx, &hp_rootP); }else{ ret = QE8IniGetHpRoot(port_idx, &hp_rootP); } ssunlock_lock_UUT(); if ( ret == 0 ) { printk( "GetHpRoot is fail!!\n"); }else{ *link_status1 = osChipRegRead(hp_rootP, 0x1D0); *link_status2 = osChipRegRead(hp_rootP, 0x1D4); } } int qe8GetStressPortSpeed(unsigned int port_idx){ int speed=0; if ( __qe8GetStressPortSpeed(port_idx,&speed) != -1 ){ return(speed); } return 0; } void qe8SetStressPortSpeed(uint32_t port_speed){ if ( port_speed != qe8GetStressPortSpeed(0) ) { g_fc_stress_change_speed_flag=1; switch (port_speed){ case 2: __qe8SetStressAllPortSpeed(QE8_BS_PORT_SPEED_2G); break; case 4: __qe8SetStressAllPortSpeed(QE8_BS_PORT_SPEED_4G); break; case 8: __qe8SetStressAllPortSpeed(QE8_BS_PORT_SPEED_8G); break; default: break; } g_fc_stress_change_speed_flag=0; } } // Set a port speed. void qe8SetPS(uint32_t port_idx, uint32_t port_speed){ QE8_BS_REQ_OPS_FNPTR ops_fnptr; sslock_lock_UUT(); if ( sysCtrlRole == ROLE_UUT){ ops_fnptr=QE8BSTgtSetPortSpeed; }else{ ops_fnptr=QE8BSIniSetPortSpeed; } ssunlock_lock_UUT(); ops_fnptr(port_idx, port_speed); } void qe8StressPortDisable(uint32_t port_idx){ hpRoot_t *hp_rootP = NULL; bool ret=1; bit32 regVal; if ( port_idx < g_local_qe8_cnt ){ sslock_lock_UUT(); if ( sysCtrlRole == ROLE_UUT){ ret = QE8GetHpRoot(port_idx, &hp_rootP); }else{ ret = QE8IniGetHpRoot(port_idx, &hp_rootP); } ssunlock_lock_UUT(); regVal = osChipRegRead(hp_rootP, 0x11c); regVal |= 0x00000080; osChipRegWrite(hp_rootP, 0x11c, regVal); port_dis_flag |= ( 1 << port_idx ); } } void qe8StressPortEnable(uint32_t port_idx){ hpRoot_t *hp_rootP = NULL; bool ret=1; bit32 regVal; if ( port_idx < g_local_qe8_cnt){ sslock_lock_UUT(); if ( sysCtrlRole == ROLE_UUT){ ret = QE8GetHpRoot(port_idx, &hp_rootP); }else{ ret = QE8IniGetHpRoot(port_idx, &hp_rootP); } ssunlock_lock_UUT(); regVal = osChipRegRead(hp_rootP, 0x11c); regVal &= ~ 0x00000080; osChipRegWrite(hp_rootP, 0x11c, regVal); port_dis_flag &= ~( 1 << port_idx ); } } bool qe8TestPortDis(uint32_t port_idx){ bit8 regVal; regVal = port_dis_flag >> port_idx & 1; if ( regVal == 1 ) return true; return false; } #endif void qe8GetStressParam(EIPC_MSG *msg) { g_local_fc_stress_param.channel[0] = g_fc_stress_channel0; g_local_fc_stress_param.channel[1] = g_fc_stress_channel1; g_local_fc_stress_param.channel[2] = g_fc_stress_channel2; g_local_fc_stress_param.channel[3] = g_fc_stress_channel3; g_local_fc_stress_param.channel[4] = g_fc_stress_channel4; g_local_fc_stress_param.channel[5] = g_fc_stress_channel5; g_local_fc_stress_param.channel[6] = g_fc_stress_channel6; g_local_fc_stress_param.channel[7] = g_fc_stress_channel7; g_local_fc_stress_param.times = g_fc_stress_testTime; g_local_fc_stress_param.BS = g_fc_stress_blockSize; g_local_fc_stress_param.speed = g_fc_stress_speed; g_local_fc_stress_param.pattern = g_fc_stress_pattern; g_local_fc_stress_param.SOE = g_fc_stress_SOE; g_local_fc_stress_param.dv = g_fc_stress_dv; memcpy(&msg->body[0],&g_local_fc_stress_param, sizeof(fc_stress_Param_t)); /* Send a IPC response */ msg->hdr.flag = IPC_APP_RESPONSE; ipcEthernetSend(msg); } static int __init qe8Stress_Init( void ) { sysStressInit(); return 0; } static void __exit qe8Stress_Exit( void ) { sysStressExit(); } module_init( qe8Stress_Init ); module_exit( qe8Stress_Exit ); MODULE_AUTHOR( "merck.hung@netapp.com" ); MODULE_DESCRIPTION( "\"QE8\"/General Stress Code" ); MODULE_LICENSE( "GPL" );