1285242Sachim/******************************************************************************* 2285242Sachim*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3285242Sachim* 4285242Sachim*Redistribution and use in source and binary forms, with or without modification, are permitted provided 5285242Sachim*that the following conditions are met: 6285242Sachim*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7285242Sachim*following disclaimer. 8285242Sachim*2. Redistributions in binary form must reproduce the above copyright notice, 9285242Sachim*this list of conditions and the following disclaimer in the documentation and/or other materials provided 10285242Sachim*with the distribution. 11285242Sachim* 12285242Sachim*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13285242Sachim*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14285242Sachim*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15285242Sachim*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16285242Sachim*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17285242Sachim*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18285242Sachim*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19285242Sachim*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20285242Sachim 21285242Sachim********************************************************************************/ 22285242Sachim/*******************************************************************************/ 23285242Sachim/*! \file sautil.c 24285242Sachim * \brief The file contains general helper routines. 25285242Sachim * 26285242Sachim * 27285242Sachim */ 28285242Sachim/******************************************************************************/ 29285242Sachim#include <sys/cdefs.h> 30285242Sachim__FBSDID("$FreeBSD$"); 31285242Sachim#include <dev/pms/config.h> 32285242Sachim 33285242Sachim#include <dev/pms/RefTisa/sallsdk/spc/saglobal.h> 34285242Sachim#ifdef SA_TESTBASE_EXTRA 35285242Sachim#include <string.h> 36285242Sachim#endif /* SA_TESTBASE_EXTRA */ 37285242Sachim 38285242Sachim 39285242Sachim#ifdef SA_ENABLE_TRACE_FUNCTIONS 40285242Sachim#ifdef siTraceFileID 41285242Sachim#undef siTraceFileID 42285242Sachim#endif 43285242Sachim#define siTraceFileID 'S' 44285242Sachim#endif 45285242Sachim 46285242Sachim/******************************************************************************/ 47285242Sachim/*! \brief Check for Hex digit 48285242Sachim * 49285242Sachim * 50285242Sachim * \param char value 51285242Sachim * 52285242Sachim * \return -void- 53285242Sachim * 54285242Sachim */ 55285242Sachim/*******************************************************************************/ 56285242Sachimint siIsHexDigit(char a) 57285242Sachim{ 58285242Sachim return ( (((a) >= 'a') && ((a) <= 'z')) || 59285242Sachim (((a) >= 'A') && ((a) <= 'Z')) || 60285242Sachim (((a) >= '0') && ((a) <= '9')) || 61285242Sachim ( (a) == '*')); 62285242Sachim} 63285242Sachim 64285242Sachim/******************************************************************************/ 65285242Sachim/*! \brief memcopy 66285242Sachim * 67285242Sachim * 68285242Sachim * \param char value 69285242Sachim * 70285242Sachim * \return -void- 71285242Sachim * 72285242Sachim */ 73285242Sachim/*******************************************************************************/ 74285242SachimFORCEINLINE 75285242Sachimvoid* 76285242Sachimsi_memcpy(void *dst, void *src, bit32 count) 77285242Sachim{ 78285242Sachim/* 79285242Sachim bit32 x; 80285242Sachim unsigned char *dst1 = (unsigned char *)dst; 81285242Sachim unsigned char *src1 = (unsigned char *)src; 82285242Sachim 83285242Sachim for (x=0; x < count; x++) 84285242Sachim dst1[x] = src1[x]; 85285242Sachim 86285242Sachim return dst; 87285242Sachim*/ 88285242Sachim return memcpy(dst, src, count); 89285242Sachim} 90285242Sachim 91285242Sachim 92285242Sachim/******************************************************************************/ 93285242Sachim/*! \brief memset 94285242Sachim * 95285242Sachim * 96285242Sachim * \param char value 97285242Sachim * 98285242Sachim * \return -void- 99285242Sachim * 100285242Sachim */ 101285242Sachim/*******************************************************************************/ 102285242SachimFORCEINLINE 103285242Sachimvoid* 104285242Sachimsi_memset(void *s, int c, bit32 n) 105285242Sachim{ 106285242Sachim/* 107285242Sachim bit32 i; 108285242Sachim char *dst = (char *)s; 109285242Sachim for (i=0; i < n; i++) 110285242Sachim { 111285242Sachim dst[i] = (char) c; 112285242Sachim } 113285242Sachim return (void *)(&dst[i-n]); 114285242Sachim*/ 115285242Sachim return memset(s, c, n); 116285242Sachim} 117285242Sachim 118285242Sachim 119285242Sachim/******************************************************************************/ 120285242Sachim/*! \brief siDumpActiveIORequests 121285242Sachim * 122285242Sachim * 123285242Sachim * \param char value 124285242Sachim * 125285242Sachim * \return -void- 126285242Sachim * 127285242Sachim */ 128285242Sachim/*******************************************************************************/ 129285242SachimGLOBAL void 130285242SachimsiDumpActiveIORequests( 131285242Sachim agsaRoot_t *agRoot, 132285242Sachim bit32 count) 133285242Sachim{ 134285242Sachim bit32 j, num_found = 0; 135285242Sachim agsaIORequestDesc_t *pRequestDesc = agNULL; 136285242Sachim agsaLLRoot_t *saRoot = agNULL; 137285242Sachim bit32 i; 138285242Sachim mpiOCQueue_t *circularQ; 139285242Sachim 140285242Sachim /* sanity check */ 141285242Sachim SA_ASSERT((agNULL != agRoot), ""); 142285242Sachim saRoot = (agsaLLRoot_t *)(agRoot->sdkData); 143285242Sachim SA_ASSERT((agNULL != saRoot), ""); 144285242Sachim 145285242Sachim 146285242Sachim saCountActiveIORequests(agRoot); 147285242Sachim // return; 148285242Sachim 149285242Sachim 150285242Sachim if(smIS_SPCV(agRoot)) 151285242Sachim { 152285242Sachim bit32 sp1; 153285242Sachim sp1= ossaHwRegRead(agRoot,V_Scratchpad_1_Register ); 154285242Sachim 155285242Sachim if(SCRATCH_PAD1_V_ERROR_STATE(sp1)) 156285242Sachim { 157285242Sachim SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD1_V_ERROR_STAT 0x%x\n",sp1 )); 158285242Sachim } 159285242Sachim SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_0_Register))); 160285242Sachim SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_1_Register))); 161285242Sachim SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_2_Register))); 162285242Sachim SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_3_Register))); 163285242Sachim } 164285242Sachim 165285242Sachim for ( i = 0; i < saRoot->QueueConfig.numOutboundQueues; i++ ) 166285242Sachim { 167285242Sachim circularQ = &saRoot->outboundQueue[i]; 168285242Sachim OSSA_READ_LE_32(circularQ->agRoot, &circularQ->producerIdx, circularQ->piPointer, 0); 169285242Sachim if(circularQ->producerIdx != circularQ->consumerIdx) 170285242Sachim { 171285242Sachim SA_DBG1(("siDumpActiveIORequests:OBQ%d PI 0x%03x CI 0x%03x\n", i,circularQ->producerIdx, circularQ->consumerIdx )); 172285242Sachim } 173285242Sachim } 174285242Sachim 175285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0); 176285242Sachim SA_DBG1(("siDumpActiveIORequests: Current Time: %d ticks (usecpertick=%d)\n", 177285242Sachim saRoot->timeTick, saRoot->usecsPerTick)); 178285242Sachim 179285242Sachim for ( j = 0; j < count; j ++ ) 180285242Sachim { 181285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j); 182285242Sachim 183285242Sachim if (pRequestDesc->valid == agTRUE) 184285242Sachim { 185285242Sachim num_found++; 186285242Sachim SA_DBG1(("siDumpActiveIORequests: IO #%4d: %p Tag=%03X Type=%08X Device 0x%X Pending for %d seconds\n", 187285242Sachim j, 188285242Sachim pRequestDesc->pIORequestContext, 189285242Sachim pRequestDesc->HTag, 190285242Sachim pRequestDesc->requestType, 191285242Sachim pRequestDesc->pDevice ? pRequestDesc->pDevice->DeviceMapIndex : 0, 192285242Sachim ((saRoot->timeTick - pRequestDesc->startTick)*saRoot->usecsPerTick)/1000000 )); 193285242Sachim 194285242Sachim } 195285242Sachim } 196285242Sachim if(count) 197285242Sachim { 198285242Sachim SA_DBG1(("siDumpActiveIORequests: %d found active\n",num_found)); 199285242Sachim } 200285242Sachim 201285242Sachim} 202285242Sachim 203285242Sachim/******************************************************************************/ 204285242Sachim/*! \brief saCountActiveIORequests 205285242Sachim * 206285242Sachim * 207285242Sachim * \param char value 208285242Sachim * 209285242Sachim * \return -void- 210285242Sachim * 211285242Sachim */ 212285242Sachim/*******************************************************************************/ 213285242SachimGLOBAL void 214285242SachimsiClearActiveIORequests( 215285242Sachim agsaRoot_t *agRoot) 216285242Sachim{ 217285242Sachim bit32 j; 218285242Sachim bit32 num_found = 0; 219285242Sachim agsaIORequestDesc_t *pRequestDesc = agNULL; 220285242Sachim agsaLLRoot_t *saRoot = agNULL; 221285242Sachim 222285242Sachim /* sanity check */ 223285242Sachim SA_ASSERT((agNULL != agRoot), ""); 224285242Sachim saRoot = (agsaLLRoot_t *)(agRoot->sdkData); 225285242Sachim SA_ASSERT((agNULL != saRoot), ""); 226285242Sachim 227285242Sachim if(saRoot) 228285242Sachim { 229285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0); 230285242Sachim 231285242Sachim for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ ) 232285242Sachim { 233285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j); 234285242Sachim 235285242Sachim if (pRequestDesc->valid == agTRUE) 236285242Sachim { 237285242Sachim num_found++; 238285242Sachim pRequestDesc->valid = agFALSE; 239285242Sachim } 240285242Sachim } 241285242Sachim if(num_found) 242285242Sachim { 243285242Sachim SA_DBG1(("siClearActiveIORequests %d found active\n",num_found)); 244285242Sachim } 245285242Sachim } 246285242Sachim else 247285242Sachim { 248285242Sachim SA_DBG1(("siClearActiveIORequests saroot NULL\n")); 249285242Sachim } 250285242Sachim 251285242Sachim} 252285242Sachim 253285242Sachim/******************************************************************************/ 254285242Sachim/*! \brief siCountActiveIORequestsOnDevice 255285242Sachim * count all active IO's 256285242Sachim * 257285242Sachim * \param char value 258285242Sachim * 259285242Sachim * \return -void- 260285242Sachim * 261285242Sachim */ 262285242Sachim/*******************************************************************************/ 263285242SachimGLOBAL void 264285242SachimsiClearActiveIORequestsOnDevice( 265285242Sachim agsaRoot_t *agRoot, 266285242Sachim bit32 device ) 267285242Sachim{ 268285242Sachim bit32 j, num_found = 0; 269285242Sachim agsaIORequestDesc_t *pRequestDesc = agNULL; 270285242Sachim agsaLLRoot_t *saRoot = agNULL; 271285242Sachim 272285242Sachim /* sanity check */ 273285242Sachim SA_ASSERT((agNULL != agRoot), ""); 274285242Sachim saRoot = (agsaLLRoot_t *)(agRoot->sdkData); 275285242Sachim SA_ASSERT((agNULL != saRoot), ""); 276285242Sachim 277285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0); 278285242Sachim 279285242Sachim for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ ) 280285242Sachim { 281285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j); 282285242Sachim 283285242Sachim if (pRequestDesc->valid == agTRUE) 284285242Sachim { 285285242Sachim if (pRequestDesc->pDevice) 286285242Sachim { 287285242Sachim if (pRequestDesc->pDevice->DeviceMapIndex == device) 288285242Sachim { 289285242Sachim num_found++; 290285242Sachim pRequestDesc->valid = agFALSE; 291285242Sachim } 292285242Sachim } 293285242Sachim } 294285242Sachim } 295285242Sachim if(num_found) 296285242Sachim { 297285242Sachim SA_DBG1(("siClearActiveIORequestsOnDevice 0x%x %d cleared\n",device,num_found)); 298285242Sachim } 299285242Sachim 300285242Sachim} 301285242Sachim 302285242Sachim 303285242Sachim 304285242Sachim/******************************************************************************/ 305285242Sachim/*! \brief siCountActiveIORequestsOnDevice 306285242Sachim * count all active IO's 307285242Sachim * 308285242Sachim * \param char value 309285242Sachim * 310285242Sachim * \return -void- 311285242Sachim * 312285242Sachim */ 313285242Sachim/*******************************************************************************/ 314285242SachimGLOBAL void 315285242SachimsiCountActiveIORequestsOnDevice( 316285242Sachim agsaRoot_t *agRoot, 317285242Sachim bit32 device ) 318285242Sachim{ 319285242Sachim bit32 j, num_found = 0; 320285242Sachim agsaIORequestDesc_t *pRequestDesc = agNULL; 321285242Sachim agsaLLRoot_t *saRoot = agNULL; 322285242Sachim 323285242Sachim /* sanity check */ 324285242Sachim SA_ASSERT((agNULL != agRoot), ""); 325285242Sachim saRoot = (agsaLLRoot_t *)(agRoot->sdkData); 326285242Sachim SA_ASSERT((agNULL != saRoot), ""); 327285242Sachim 328285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0); 329285242Sachim 330285242Sachim for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ ) 331285242Sachim { 332285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j); 333285242Sachim 334285242Sachim if (pRequestDesc->valid == agTRUE) 335285242Sachim { 336285242Sachim if (pRequestDesc->pDevice) 337285242Sachim { 338285242Sachim if (pRequestDesc->pDevice->DeviceMapIndex == device) 339285242Sachim { 340285242Sachim num_found++; 341285242Sachim if(saRoot->ResetStartTick > pRequestDesc->startTick) 342285242Sachim { 343285242Sachim SA_DBG2(("siCountActiveIORequestsOnDevice: saRoot->ResetStartTick %d pRequestDesc->startTick %d\n", 344285242Sachim saRoot->ResetStartTick, pRequestDesc->startTick)); 345285242Sachim } 346285242Sachim } 347285242Sachim } 348285242Sachim } 349285242Sachim } 350285242Sachim if(num_found) 351285242Sachim { 352285242Sachim SA_DBG1(("siCountActiveIORequestsOnDevice 0x%x %d found active\n",device,num_found)); 353285242Sachim } 354285242Sachim 355285242Sachim} 356285242Sachim 357285242Sachim 358285242Sachim 359285242Sachim/******************************************************************************/ 360285242Sachim/*! \brief saCountActiveIORequests 361285242Sachim * count all active IO's 362285242Sachim * 363285242Sachim * \param char value 364285242Sachim * 365285242Sachim * \return -void- 366285242Sachim * 367285242Sachim */ 368285242Sachim/*******************************************************************************/ 369285242SachimGLOBAL void 370285242SachimsaCountActiveIORequests( 371285242Sachim agsaRoot_t *agRoot) 372285242Sachim{ 373285242Sachim bit32 j, num_found = 0; 374285242Sachim agsaIORequestDesc_t *pRequestDesc = agNULL; 375285242Sachim agsaLLRoot_t *saRoot = agNULL; 376285242Sachim 377285242Sachim /* sanity check */ 378285242Sachim SA_ASSERT((agNULL != agRoot), ""); 379285242Sachim if( agRoot == agNULL) 380285242Sachim { 381285242Sachim return; 382285242Sachim } 383285242Sachim saRoot = (agsaLLRoot_t *)(agRoot->sdkData); 384285242Sachim if( saRoot == agNULL) 385285242Sachim { 386285242Sachim return; 387285242Sachim } 388285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0); 389285242Sachim 390285242Sachim for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ ) 391285242Sachim { 392285242Sachim pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j); 393285242Sachim 394285242Sachim if (pRequestDesc->valid == agTRUE) 395285242Sachim { 396285242Sachim num_found++; 397285242Sachim if(saRoot->ResetStartTick > pRequestDesc->startTick) 398285242Sachim { 399285242Sachim SA_DBG2(("saCountActiveIORequests: saRoot->ResetStartTick %d pRequestDesc->startTick %d\n", 400285242Sachim saRoot->ResetStartTick, pRequestDesc->startTick)); 401285242Sachim } 402285242Sachim } 403285242Sachim } 404285242Sachim if(num_found) 405285242Sachim { 406285242Sachim SA_DBG1(("saCountActiveIORequests %d found active\n",num_found)); 407285242Sachim } 408285242Sachim 409285242Sachim} 410285242Sachim 411285242Sachim 412285242SachimGLOBAL bit32 smIsCfg_V_ANY( agsaRoot_t *agRoot) 413285242Sachim{ 414285242Sachim 415285242Sachim if(smIsCfg_V8008(agRoot) == 1) return 1; 416285242Sachim if(smIsCfg_V8009(agRoot) == 1) return 1; 417285242Sachim if(smIsCfg_V8018(agRoot) == 1) return 1; 418285242Sachim if(smIsCfg_V8019(agRoot) == 1) return 1; 419285242Sachim if(smIsCfg_V8088(agRoot) == 1) return 1; 420285242Sachim if(smIsCfg_V8089(agRoot) == 1) return 1; 421285242Sachim if(smIsCfg_V8070(agRoot) == 1) return 1; 422285242Sachim if(smIsCfg_V8071(agRoot) == 1) return 1; 423285242Sachim if(smIsCfg_V8072(agRoot) == 1) return 1; 424285242Sachim if(smIsCfg_V8073(agRoot) == 1) return 1; 425285242Sachim if(smIS_SPCV8074(agRoot) == 1) return 1; 426285242Sachim if(smIS_SPCV8075(agRoot) == 1) return 1; 427285242Sachim if(smIS_SPCV8076(agRoot) == 1) return 1; 428285242Sachim if(smIS_SPCV8077(agRoot) == 1) return 1; 429285242Sachim if(smIsCfg_V8025(agRoot) == 1) return 1; 430285242Sachim if(smIsCfg_V9015(agRoot) == 1) return 1; 431285242Sachim if(smIsCfg_V9060(agRoot) == 1) return 1; 432285242Sachim if(smIsCfg_V8006(agRoot) == 1) return 1; 433285242Sachim 434285242Sachim return 0; 435285242Sachim} 436285242Sachim 437285242SachimGLOBAL bit32 smIS_SPC( agsaRoot_t *agRoot) 438285242Sachim{ 439285242Sachim if(smIS_spc8001(agRoot) == 1) return 1; 440285242Sachim if(smIS_spc8081(agRoot) == 1) return 1; 441285242Sachim if(smIS_SFC_AS_SPC(agRoot) == 1) return 1; 442285242Sachim return 0; 443285242Sachim} 444285242Sachim 445285242Sachim 446285242SachimGLOBAL bit32 smIS_HIL( agsaRoot_t *agRoot) /* or delray */ 447285242Sachim{ 448285242Sachim if(smIS_spc8081(agRoot) == 1) return 1; 449285242Sachim if(smIS_ADAP8088(agRoot) == 1) return 1; 450285242Sachim if(smIS_ADAP8089(agRoot) == 1) return 1; 451285242Sachim if(smIS_SPCV8074(agRoot) == 1) return 1; 452285242Sachim if(smIS_SPCV8075(agRoot) == 1) return 1; 453285242Sachim if(smIS_SPCV8076(agRoot) == 1) return 1; 454285242Sachim if(smIS_SPCV8077(agRoot) == 1) return 1; 455285242Sachim return 0; 456285242Sachim 457285242Sachim} 458285242Sachim 459285242SachimGLOBAL bit32 smIS_SPC6V( agsaRoot_t *agRoot) 460285242Sachim{ 461285242Sachim if(smIS_SPCV8008(agRoot) == 1) return 1; 462285242Sachim if(smIS_SPCV8009(agRoot) == 1) return 1; 463285242Sachim if(smIS_SPCV8018(agRoot) == 1) return 1; 464285242Sachim if(smIS_SPCV8019(agRoot) == 1) return 1; 465285242Sachim if(smIS_ADAP8088(agRoot) == 1) return 1; 466285242Sachim if(smIS_ADAP8089(agRoot) == 1) return 1; 467285242Sachim return 0; 468285242Sachim} 469285242Sachim 470285242SachimGLOBAL bit32 smIS_SPC12V( agsaRoot_t *agRoot) 471285242Sachim{ 472285242Sachim if(smIS_SPCV8070(agRoot) == 1) return 1; 473285242Sachim if(smIS_SPCV8071(agRoot) == 1) return 1; 474285242Sachim if(smIS_SPCV8072(agRoot) == 1) return 1; 475285242Sachim if(smIS_SPCV8073(agRoot) == 1) return 1; 476285242Sachim if(smIS_SPCV8074(agRoot) == 1) return 1; 477285242Sachim if(smIS_SPCV8075(agRoot) == 1) return 1; 478285242Sachim if(smIS_SPCV8076(agRoot) == 1) return 1; 479285242Sachim if(smIS_SPCV8077(agRoot) == 1) return 1; 480285242Sachim if(smIS_SPCV9015(agRoot) == 1) return 1; 481285242Sachim if(smIS_SPCV9060(agRoot) == 1) return 1; 482285242Sachim if(smIS_SPCV8006(agRoot) == 1) return 1; 483285242Sachim return 0; 484285242Sachim} 485285242Sachim 486285242SachimGLOBAL bit32 smIS_SPCV_2_IOP( agsaRoot_t *agRoot) 487285242Sachim{ 488285242Sachim if(smIS_SPCV8009(agRoot) == 1) return 1; 489285242Sachim if(smIS_SPCV8018(agRoot) == 1) return 1; 490285242Sachim if(smIS_SPCV8019(agRoot) == 1) return 1; 491285242Sachim if(smIS_SPCV8071(agRoot) == 1) return 1; 492285242Sachim if(smIS_SPCV8072(agRoot) == 1) return 1; 493285242Sachim if(smIS_SPCV8073(agRoot) == 1) return 1; 494285242Sachim if(smIS_SPCV8076(agRoot) == 1) return 1; 495285242Sachim if(smIS_SPCV8077(agRoot) == 1) return 1; 496285242Sachim if(smIS_ADAP8088(agRoot) == 1) return 1; 497285242Sachim if(smIS_ADAP8089(agRoot) == 1) return 1; 498285242Sachim if(smIS_SPCV8006(agRoot) == 1) return 1; 499285242Sachim return 0; 500285242Sachim} 501285242Sachim 502285242SachimGLOBAL bit32 smIS_SPCV( agsaRoot_t *agRoot) 503285242Sachim{ 504285242Sachim if(smIS_SPC6V(agRoot) == 1) return 1; 505285242Sachim if(smIS_SPC12V(agRoot) == 1) return 1; 506285242Sachim if(smIS_SFC_AS_V(agRoot) == 1 ) return 1; 507285242Sachim return 0; 508285242Sachim} 509285242Sachim 510285242SachimGLOBAL bit32 smIS_ENCRYPT( agsaRoot_t *agRoot) 511285242Sachim{ 512285242Sachim if(smIS_SPCV8009(agRoot) == 1) return 1; 513285242Sachim if(smIS_ADAP8088(agRoot) == 1) return 1; 514285242Sachim if(smIS_SPCV8019(agRoot) == 1) return 1; 515285242Sachim if(smIS_SPCV8071(agRoot) == 1) return 1; 516285242Sachim if(smIS_SPCV8073(agRoot) == 1) return 1; 517285242Sachim if(smIS_SPCV8077(agRoot) == 1) return 1; 518285242Sachim if(smIS_SPCV9015(agRoot) == 1) return 1; 519285242Sachim if(smIS_SPCV9060(agRoot) == 1) return 1; 520285242Sachim return 0; 521285242Sachim} 522285242Sachim 523285242Sachim 524285242Sachim 525285242Sachim#if defined(SALLSDK_DEBUG) 526285242Sachim 527285242Sachim/******************************************************************************/ 528285242Sachim/*! \brief Routine print buffer 529285242Sachim * 530285242Sachim * 531285242Sachim * \param debugLevel verbosity level 532285242Sachim * \param header header to print 533285242Sachim * \param buffer buffer to print 534285242Sachim * \param length length of buffer in bytes 535285242Sachim * 536285242Sachim * \return -void- 537285242Sachim * 538285242Sachim */ 539285242Sachim/*******************************************************************************/ 540285242SachimGLOBAL void siPrintBuffer( 541285242Sachim bit32 debugLevel, 542285242Sachim siPrintType type, 543285242Sachim char *header, 544285242Sachim void *a, 545285242Sachim bit32 length 546285242Sachim ) 547285242Sachim{ 548285242Sachim bit32 x, rem; 549285242Sachim bit8 *buffer = (bit8 *)a; 550285242Sachim bit32 *lPtr; 551285242Sachim bit8 temp[16]; 552285242Sachim 553285242Sachim ossaLogDebugString(gLLDebugLevel, debugLevel, ("%s\n", header)); 554285242Sachim 555285242Sachim if (type == SA_8) 556285242Sachim { 557285242Sachim for (x=0; x < length/16; x++) 558285242Sachim { 559285242Sachim ossaLogDebugString(gLLDebugLevel, debugLevel, 560285242Sachim ("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x == " 561285242Sachim "%c%c%c%c%c%c%c%c - %c%c%c%c%c%c%c%c\n", 562285242Sachim *(buffer), 563285242Sachim *(buffer+1), 564285242Sachim *(buffer+2), 565285242Sachim *(buffer+3), 566285242Sachim *(buffer+4), 567285242Sachim *(buffer+5), 568285242Sachim *(buffer+6), 569285242Sachim *(buffer+7), 570285242Sachim *(buffer+8), 571285242Sachim *(buffer+9), 572285242Sachim *(buffer+10), 573285242Sachim *(buffer+11), 574285242Sachim *(buffer+12), 575285242Sachim *(buffer+13), 576285242Sachim *(buffer+14), 577285242Sachim *(buffer+15), 578285242Sachim siIsHexDigit(*(buffer)) ? *(buffer) : ' ', 579285242Sachim siIsHexDigit(*(buffer+1)) ? *(buffer+1) : ' ', 580285242Sachim siIsHexDigit(*(buffer+2)) ? *(buffer+2) : ' ', 581285242Sachim siIsHexDigit(*(buffer+3)) ? *(buffer+3) : ' ', 582285242Sachim siIsHexDigit(*(buffer+4)) ? *(buffer+4) : ' ', 583285242Sachim siIsHexDigit(*(buffer+5)) ? *(buffer+5) : ' ', 584285242Sachim siIsHexDigit(*(buffer+6)) ? *(buffer+6) : ' ', 585285242Sachim siIsHexDigit(*(buffer+7)) ? *(buffer+7) : ' ', 586285242Sachim siIsHexDigit(*(buffer+8)) ? *(buffer+8) : ' ', 587285242Sachim siIsHexDigit(*(buffer+9)) ? *(buffer+9) : ' ', 588285242Sachim siIsHexDigit(*(buffer+10)) ? *(buffer+10) : ' ', 589285242Sachim siIsHexDigit(*(buffer+11)) ? *(buffer+11) : ' ', 590285242Sachim siIsHexDigit(*(buffer+12)) ? *(buffer+12) : ' ', 591285242Sachim siIsHexDigit(*(buffer+13)) ? *(buffer+13) : ' ', 592285242Sachim siIsHexDigit(*(buffer+14)) ? *(buffer+14) : ' ', 593285242Sachim siIsHexDigit(*(buffer+15)) ? *(buffer+15) : ' ') 594285242Sachim ); 595285242Sachim 596285242Sachim buffer += 16; 597285242Sachim } 598285242Sachim 599285242Sachim rem = length%16; 600285242Sachim if (rem) 601285242Sachim { 602285242Sachim for (x = 0; x < 16; x++) 603285242Sachim { 604285242Sachim temp[x] = ' '; 605285242Sachim } 606285242Sachim 607285242Sachim for (x = 0; x < rem; x++) 608285242Sachim { 609285242Sachim temp[x] = *(buffer+x); 610285242Sachim } 611285242Sachim 612285242Sachim buffer = temp; 613285242Sachim 614285242Sachim ossaLogDebugString(gLLDebugLevel, debugLevel, 615285242Sachim ("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x == " 616285242Sachim "%c%c%c%c%c%c%c%c - %c%c%c%c%c%c%c%c\n", 617285242Sachim *(buffer), 618285242Sachim *(buffer+1), 619285242Sachim *(buffer+2), 620285242Sachim *(buffer+3), 621285242Sachim *(buffer+4), 622285242Sachim *(buffer+5), 623285242Sachim *(buffer+6), 624285242Sachim *(buffer+7), 625285242Sachim *(buffer+8), 626285242Sachim *(buffer+9), 627285242Sachim *(buffer+10), 628285242Sachim *(buffer+11), 629285242Sachim *(buffer+12), 630285242Sachim *(buffer+13), 631285242Sachim *(buffer+14), 632285242Sachim *(buffer+15), 633285242Sachim siIsHexDigit(*(buffer)) ? *(buffer) : ' ', 634285242Sachim siIsHexDigit(*(buffer+1)) ? *(buffer+1) : ' ', 635285242Sachim siIsHexDigit(*(buffer+2)) ? *(buffer+2) : ' ', 636285242Sachim siIsHexDigit(*(buffer+3)) ? *(buffer+3) : ' ', 637285242Sachim siIsHexDigit(*(buffer+4)) ? *(buffer+4) : ' ', 638285242Sachim siIsHexDigit(*(buffer+5)) ? *(buffer+5) : ' ', 639285242Sachim siIsHexDigit(*(buffer+6)) ? *(buffer+6) : ' ', 640285242Sachim siIsHexDigit(*(buffer+7)) ? *(buffer+7) : ' ', 641285242Sachim siIsHexDigit(*(buffer+8)) ? *(buffer+8) : ' ', 642285242Sachim siIsHexDigit(*(buffer+9)) ? *(buffer+9) : ' ', 643285242Sachim siIsHexDigit(*(buffer+10)) ? *(buffer+10) : ' ', 644285242Sachim siIsHexDigit(*(buffer+11)) ? *(buffer+11) : ' ', 645285242Sachim siIsHexDigit(*(buffer+12)) ? *(buffer+12) : ' ', 646285242Sachim siIsHexDigit(*(buffer+13)) ? *(buffer+13) : ' ', 647285242Sachim siIsHexDigit(*(buffer+14)) ? *(buffer+14) : ' ', 648285242Sachim siIsHexDigit(*(buffer+15)) ? *(buffer+15) : ' ') 649285242Sachim ); 650285242Sachim } 651285242Sachim } 652285242Sachim else 653285242Sachim { 654285242Sachim bit32 *ltemp = (bit32 *)temp; 655285242Sachim lPtr = (bit32 *) a; 656285242Sachim 657285242Sachim for (x=0; x < length/4; x++) 658285242Sachim { 659285242Sachim ossaLogDebugString(gLLDebugLevel, debugLevel, 660285242Sachim ("%08x %08x %08x %08x\n", 661285242Sachim *(lPtr), 662285242Sachim *(lPtr+1), 663285242Sachim *(lPtr+2), 664285242Sachim *(lPtr+3)) 665285242Sachim ); 666285242Sachim 667285242Sachim lPtr += 4; 668285242Sachim } 669285242Sachim 670285242Sachim rem = length%4; 671285242Sachim if (rem) 672285242Sachim { 673285242Sachim for (x = 0; x < 4; x++) 674285242Sachim { 675285242Sachim ltemp[x] = 0; 676285242Sachim } 677285242Sachim 678285242Sachim for (x = 0; x < rem; x++) 679285242Sachim { 680285242Sachim ltemp[x] = lPtr[x]; 681285242Sachim } 682285242Sachim 683285242Sachim lPtr = ltemp; 684285242Sachim 685285242Sachim ossaLogDebugString(gLLDebugLevel, debugLevel, 686285242Sachim ("%08x %08x %08x %08x\n", 687285242Sachim *(lPtr), 688285242Sachim *(lPtr+1), 689285242Sachim *(lPtr+2), 690285242Sachim *(lPtr+3)) 691285242Sachim ); 692285242Sachim } 693285242Sachim } 694285242Sachim 695285242Sachim} 696285242Sachim 697285242Sachim 698285242Sachim 699285242Sachimvoid sidump_hwConfig(agsaHwConfig_t *hwConfig) 700285242Sachim{ 701285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->hwInterruptCoalescingTimer 0x%x\n",hwConfig->hwInterruptCoalescingTimer )); 702285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->hwInterruptCoalescingControl 0x%x\n",hwConfig->hwInterruptCoalescingControl )); 703285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->intReassertionOption 0x%x\n",hwConfig->intReassertionOption )); 704285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister0 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister0 )); 705285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister1 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister1 )); 706285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister2 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister2 )); 707285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister3 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister3 )); 708285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister4 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister4 )); 709285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister5 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister5 )); 710285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister6 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister6 )); 711285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister7 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister7 )); 712285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister8 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister8 )); 713285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister9 0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister9 )); 714285242Sachim SA_DBG2(("sidump_hwConfig:hwConfig->hwOption 0x%x\n",hwConfig->hwOption )); 715285242Sachim} 716285242Sachim 717285242Sachimvoid sidump_swConfig(agsaSwConfig_t *swConfig) 718285242Sachim{ 719285242Sachim SA_DBG2(("sidump_swConfig:swConfig->maxActiveIOs 0x%x\n",swConfig->maxActiveIOs )); 720285242Sachim SA_DBG2(("sidump_swConfig:swConfig->numDevHandles 0x%x\n",swConfig->numDevHandles )); 721285242Sachim SA_DBG2(("sidump_swConfig:swConfig->smpReqTimeout 0x%x\n",swConfig->smpReqTimeout )); 722285242Sachim SA_DBG2(("sidump_swConfig:swConfig->numberOfEventRegClients 0x%x\n",swConfig->numberOfEventRegClients )); 723285242Sachim SA_DBG2(("sidump_swConfig:swConfig->sizefEventLog1 0x%x\n",swConfig->sizefEventLog1 )); 724285242Sachim SA_DBG2(("sidump_swConfig:swConfig->sizefEventLog2 0x%x\n",swConfig->sizefEventLog2 )); 725285242Sachim SA_DBG2(("sidump_swConfig:swConfig->eventLog1Option 0x%x\n",swConfig->eventLog1Option )); 726285242Sachim SA_DBG2(("sidump_swConfig:swConfig->eventLog2Option 0x%x\n",swConfig->eventLog2Option )); 727285242Sachim SA_DBG2(("sidump_swConfig:swConfig->fatalErrorInterruptEnable 0x%x\n",swConfig->fatalErrorInterruptEnable )); 728285242Sachim SA_DBG2(("sidump_swConfig:swConfig->fatalErrorInterruptVector 0x%x\n",swConfig->fatalErrorInterruptVector )); 729285242Sachim SA_DBG2(("sidump_swConfig:swConfig->max_MSI_InterruptVectors 0x%x\n",swConfig->max_MSI_InterruptVectors )); 730285242Sachim SA_DBG2(("sidump_swConfig:swConfig->max_MSIX_InterruptVectors 0x%x\n",swConfig->max_MSIX_InterruptVectors )); 731285242Sachim SA_DBG2(("sidump_swConfig:swConfig->legacyInt_X 0x%x\n",swConfig->legacyInt_X )); 732285242Sachim SA_DBG2(("sidump_swConfig:swConfig->hostDirectAccessSupport 0x%x\n",swConfig->hostDirectAccessSupport )); 733285242Sachim SA_DBG2(("sidump_swConfig:swConfig->hostDirectAccessMode 0x%x\n",swConfig->hostDirectAccessMode )); 734285242Sachim SA_DBG2(("sidump_swConfig:swConfig->param1 0x%x\n",swConfig->param1 )); 735285242Sachim SA_DBG2(("sidump_swConfig:swConfig->param2 0x%x\n",swConfig->param2 )); 736285242Sachim SA_DBG2(("sidump_swConfig:swConfig->param3 %p\n",swConfig->param3 )); 737285242Sachim SA_DBG2(("sidump_swConfig:swConfig->param4 %p\n",swConfig->param4 )); 738285242Sachim 739285242Sachim} 740285242Sachim 741285242Sachim 742285242Sachimvoid sidump_Q_config( agsaQueueConfig_t *queueConfig ) 743285242Sachim{ 744285242Sachim bit32 x; 745285242Sachim 746285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->generalEventQueue 0x%x\n", queueConfig->generalEventQueue )); 747285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->numInboundQueues 0x%x\n", queueConfig->numInboundQueues )); 748285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->numOutboundQueues 0x%x\n", queueConfig->numOutboundQueues )); 749285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->iqHighPriorityProcessingDepth 0x%x\n", queueConfig->iqHighPriorityProcessingDepth )); 750285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->iqNormalPriorityProcessingDepth 0x%x\n", queueConfig->iqNormalPriorityProcessingDepth )); 751285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->queueOption 0x%x\n", queueConfig->queueOption )); 752285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->tgtDeviceRemovedEventQueue 0x%x\n", queueConfig->tgtDeviceRemovedEventQueue )); 753285242Sachim 754285242Sachim for(x=0;x < queueConfig->numInboundQueues;x++) 755285242Sachim { 756285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->inboundQueues[%d].elementCount 0x%x\n",x,queueConfig->inboundQueues[x].elementCount )); 757285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->inboundQueues[%d].elementSize 0x%x\n",x,queueConfig->inboundQueues[x].elementSize )); 758285242Sachim } 759285242Sachim 760285242Sachim for(x=0;x < queueConfig->numOutboundQueues;x++) 761285242Sachim { 762285242Sachim 763285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->outboundQueues[%d].elementCount 0x%x\n",x,queueConfig->outboundQueues[x].elementCount )); 764285242Sachim SA_DBG2(("sidump_Q_config: queueConfig->outboundQueues[%d].elementSize 0x%x\n",x,queueConfig->outboundQueues[x].elementSize )); 765285242Sachim } 766285242Sachim 767285242Sachim} 768285242Sachim#endif 769285242Sachim 770285242Sachim#ifdef SALL_API_TEST 771285242Sachim/******************************************************************************/ 772285242Sachim/*! \brief Get Performance IO counters 773285242Sachim * 774285242Sachim * Start/Abort SAS/SATA discovery 775285242Sachim * 776285242Sachim * \param agRoot Handles for this instance of SAS/SATA hardware 777285242Sachim * \param counters bit map of the counters 778285242Sachim * \param LLCountInfo pointer to the LLCounters 779285242Sachim * 780285242Sachim * \return 781285242Sachim * - \e AGSA_RC_SUCCESS 782285242Sachim * 783285242Sachim */ 784285242Sachim/*******************************************************************************/ 785285242SachimGLOBAL bit32 saGetLLCounters( 786285242Sachim agsaRoot_t *agRoot, 787285242Sachim bit32 counters, 788285242Sachim agsaLLCountInfo_t *LLCountInfo 789285242Sachim ) 790285242Sachim{ 791285242Sachim agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData); 792285242Sachim bit32 i; 793285242Sachim 794285242Sachim for (i = 0; i < LL_COUNTERS; i++) 795285242Sachim { 796285242Sachim if (counters & (1 << i)) 797285242Sachim LLCountInfo->arrayIOCounter[i] = saRoot->LLCounters.arrayIOCounter[i]; 798285242Sachim } 799285242Sachim 800285242Sachim return AGSA_RC_SUCCESS; 801285242Sachim} 802285242Sachim 803285242Sachim/******************************************************************************/ 804285242Sachim/*! \brief Function for target to remove stale initiator device handle 805285242Sachim * 806285242Sachim * function is called to ask the LL layer to remove all LL layer and SPC firmware 807285242Sachim * internal resources associated with a device handle 808285242Sachim * 809285242Sachim * \param agRoot Handles for this instance of SAS/SATA hardware 810285242Sachim * \param counters Bit map of the IO counters 811285242Sachim * 812285242Sachim * \return 813285242Sachim * - \e AGSA_RC_SUCCESS 814285242Sachim * 815285242Sachim */ 816285242Sachim/*******************************************************************************/ 817285242SachimGLOBAL bit32 saResetLLCounters( 818285242Sachim agsaRoot_t *agRoot, 819285242Sachim bit32 counters 820285242Sachim ) 821285242Sachim{ 822285242Sachim agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData); 823285242Sachim bit32 i; 824285242Sachim 825285242Sachim for (i = 0; i < LL_COUNTERS; i++) 826285242Sachim { 827285242Sachim if (counters & (1 << i)) 828285242Sachim saRoot->LLCounters.arrayIOCounter[i] = 0; 829285242Sachim } 830285242Sachim 831285242Sachim return AGSA_RC_SUCCESS; 832285242Sachim} 833285242Sachim#endif 834285242Sachim 835