/* ****************************************************************************** * diag_port_cfg.c * * Copyright (C) LSI LOGIC, Inc. 2011 * ****************************************************************************** */ #include #include #include #include #include "../mpi/mpi2_type.h" #include "../mpt3sas_base.h" #include "inc/sasdiag.h" #include "inc/diag_mpt.h" #include "inc/diag_debug.h" #include "inc/diag_platform.h" #define NUM_DATA_PATTERN_FOR_TEST 12 /* * Extern Declaration */ extern U8 g_numIocOnboard; static int rand_seed = 152L; int rand(void) { rand_seed = rand_seed * 69069L + 1; return((rand_seed >> 16) + (rand_seed << 16)); } void generateDataPatterns(U8 pat, void *buf, U32 len) { U8 *buf1 = (U8 *)buf; U16 *buf2 = (U16 *)buf, i, j; // If invalid pattern number, just zero-out the buf if ((pat <= 0) || (pat > NUM_DATA_PATTERN_FOR_TEST)) memset(buf, 0, len); // 1 = Alternating, 8-Bit, 00 and FF // 2 = Alternating, 8-Bit, 55 and AA // 3 = Incrementing, 8-Bit // 4 = Walking 1s and 0s, 8-Bit // 5 = Alternating, 16-Bit, 0000 and FFFF // 6 = Alternating, 16-Bit, 5555 and AAAA // 7 = Incrementing, 16-Bit // 8 = Walking 1s and 0s, 16-Bit // 9 = Random // 10 = All B5 // 11 = All 4A // 12 = CJTPAT switch (pat) { case 1: for (i = 0; i < len / 2; i++) { *buf1++ = 0x00; *buf1++ = 0xff; } break; case 2: for (i = 0; i < len / 2; i++) { *buf1++ = 0x55; *buf1++ = 0xaa; } break; case 3: for (i = 0; i < len; i++) { *buf1++ = i; } break; case 4: for (i = 0; i < len / 2; i++) { *buf1++ = 1 << (i & 7); *buf1++ = ~(1 << (i & 7)); } break; case 5: for (i = 0; i < len / 4; i++) { *buf2++ = 0x0000; *buf2++ = 0xffff; } break; case 6: for (i = 0; i < len / 4; i++) { *buf2++ = 0x5555; *buf2++ = 0xaaaa; } break; case 7: for (i = 0; i < len / 2; i++) { *buf2++ = i; } break; case 8: for (i = 0; i < len / 4; i++) { *buf2++ = 1 << (i & 15); *buf2++ = ~(1 << (i & 15)); } break; case 9: for (i = 0; i < len; i++) { *buf1++ = rand(); } break; case 10: for (j = 0; j < len / 0x200; j++) { for (i = 0x0; i < 0x200; i++) *buf1++ = 0xb5; } break; case 11: for (j = 0; j < len / 0x200; j++) { for (i = 0x0; i < 0x200; i++) *buf1++ = 0x4a; } break; case 12: for(j=0; j<9 ; j++) /*CJTPAT 228 bytes * 8 = 1824 bytes, need 2048 bytes totally */ { for( i=0; i<167; i++) /*167 bytes 7E*/ *buf1++ = 0x7E; *buf1++ = 0x74; *buf1++ = 0x7E; *buf1++ = 0xAB; for( i=0; i<51; i++) /*51 bytes B5*/ *buf1++ = 0xB5; *buf1++ = 0x5E; *buf1++ = 0x4A; *buf1++ = 0x7E; if(j < 8) /* 1824 + 224 = 2048 bytes, so do not need last 4 bytes */ { *buf1++ = 0x7E; *buf1++ = 0x7E; *buf1++ = 0x7E; *buf1++ = 0xFE; } } break; default: break; } // switch } bool isIocNumValid(U8 ioc_num) { if ((ioc_num != IOC_NUM_ALL) && (ioc_num >= g_numIocOnboard)) return FALSE; else return TRUE; } // Get the IOC phynum of the first phy in the port U8 sasdiag_getIocPortStartPhy(U8 ioc_num, U8 port_num) { //TODO return PHY_NUM_INVALID; } // Return the IOC port number that the phy belongs to U8 sasdiag_mapIocPhyToPortNum(U8 ioc_num, U8 phy_num) { //TODO return PORT_NUM_INVALID; } // Check if an IOC phy specified belongs to the port number specified bool sasdiag_isIocPhyNumInPort(U8 ioc_num, U8 port_num, U8 phy_num) { U8 port; // find the port the phy is in if ((port = sasdiag_mapIocPhyToPortNum(ioc_num, phy_num)) != PORT_NUM_INVALID) if (port == port_num) return TRUE; return FALSE; }