1 /******************************************************************************* 2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3 * 4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided 5 *that the following conditions are met: 6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7 *following disclaimer. 8 *2. Redistributions in binary form must reproduce the above copyright notice, 9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided 10 *with the distribution. 11 * 12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20 21 ********************************************************************************/ 22 /*******************************************************************************/ 23 /** \file 24 * 25 * 26 * 27 * This file contains CB functions used by lower layer in SAS/SATA TD layer 28 * 29 */ 30 #include <sys/cdefs.h> 31 __FBSDID("$FreeBSD$"); 32 #include <dev/pms/config.h> 33 34 #include <dev/pms/freebsd/driver/common/osenv.h> 35 #include <dev/pms/freebsd/driver/common/ostypes.h> 36 #include <dev/pms/freebsd/driver/common/osdebug.h> 37 38 #include <dev/pms/RefTisa/sallsdk/api/sa.h> 39 #include <dev/pms/RefTisa/sallsdk/api/saapi.h> 40 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h> 41 42 #include <dev/pms/RefTisa/tisa/api/titypes.h> 43 #include <dev/pms/RefTisa/tisa/api/ostiapi.h> 44 #include <dev/pms/RefTisa/tisa/api/tiapi.h> 45 #include <dev/pms/RefTisa/tisa/api/tiglobal.h> 46 47 #ifdef FDS_SM 48 #include <dev/pms/RefTisa/sat/api/sm.h> 49 #include <dev/pms/RefTisa/sat/api/smapi.h> 50 #include <dev/pms/RefTisa/sat/api/tdsmapi.h> 51 #endif 52 53 #ifdef FDS_DM 54 #include <dev/pms/RefTisa/discovery/api/dm.h> 55 #include <dev/pms/RefTisa/discovery/api/dmapi.h> 56 #include <dev/pms/RefTisa/discovery/api/tddmapi.h> 57 #endif 58 59 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h> 60 #include <dev/pms/freebsd/driver/common/osstring.h> 61 #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h> 62 63 #ifdef INITIATOR_DRIVER 64 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h> 65 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h> 66 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h> 67 #endif 68 69 #ifdef TARGET_DRIVER 70 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h> 71 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h> 72 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h> 73 #endif 74 75 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h> 76 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h> 77 78 #ifdef ECHO_TESTING 79 /* temporary to test saEchoCommand() */ 80 extern bit8 gEcho; 81 #endif 82 83 #if defined(SALLSDK_DEBUG) 84 extern bit32 gLLDebugLevel; 85 #endif 86 87 88 #include <dev/pms/RefTisa/sallsdk/spc/mpidebug.h> 89 90 #ifdef SA_ENABLE_TRACE_FUNCTIONS 91 92 #ifdef siTraceFileID 93 #undef siTraceFileID 94 #endif 95 #define siTraceFileID 'R' 96 #endif 97 /* 98 functions that are common to SAS and SATA 99 */ 100 101 FORCEINLINE 102 void ossaCacheInvalidate( 103 agsaRoot_t *agRoot, 104 void *osMemHandle, 105 void *virtPtr, 106 bit32 length 107 ) 108 { 109 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 110 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 111 112 TI_DBG6(("ossaCacheInvalidate: start\n")); 113 ostiCacheInvalidate(tiRoot, osMemHandle, virtPtr, length); 114 return; 115 } 116 117 FORCEINLINE 118 void ossaCacheFlush( 119 agsaRoot_t *agRoot, 120 void *osMemHandle, 121 void *virtPtr, 122 bit32 length 123 ) 124 { 125 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 126 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 127 128 TI_DBG6(("ossaCacheFlush: start\n")); 129 ostiCacheFlush(tiRoot, osMemHandle, virtPtr, length); 130 return; 131 } 132 133 FORCEINLINE 134 void ossaCachePreFlush( 135 agsaRoot_t *agRoot, 136 void *osMemHandle, 137 void *virtPtr, 138 bit32 length 139 ) 140 141 { 142 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 143 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 144 145 TI_DBG6(("ossaCachePreFlush: start\n")); 146 ostiCachePreFlush(tiRoot, osMemHandle, virtPtr, length); 147 return; 148 } 149 150 /***************************************************************************** 151 *! \brief ossaDeviceHandleAccept 152 * 153 * Purpose: This function is called by lower layer to inform TD layer of 154 * a new SAS device arrival. Used only at the target 155 * 156 * 157 * \param agRoot Pointer to chip/driver Instance. 158 * \param agDevHandle Pointer to the device handle of the device 159 * \param agDevInfo Pointer to the device info structure 160 * \param agPortContext Pointer to a port context 161 * 162 * \return: 163 * OSSA_RC_REJECT A device is accpeted 164 * OSSA_RC_ACCEPT A device is rejected 165 * 166 * \note - For details, refer to SAS/SATA Low-Level API Specification 167 * 168 *****************************************************************************/ 169 osGLOBAL bit32 ossaDeviceHandleAccept( 170 agsaRoot_t *agRoot, 171 agsaDevHandle_t *agDevHandle, 172 agsaSASDeviceInfo_t *agDevInfo, 173 agsaPortContext_t *agPortContext, 174 bit32 *hostAssignedDeviceId 175 ) 176 { 177 #ifdef TARGET_DRIVER 178 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 179 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 180 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 181 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 182 183 tdsaPortContext_t *onePortContext = agNULL; 184 tiPortalContext_t *tiPortalContext = agNULL; 185 tdsaDeviceData_t *oneDeviceData = agNULL; 186 tiDeviceHandle_t *tiDeviceHandle = agNULL; 187 tdsaSASSubID_t agSASSubID; 188 bit32 option; 189 bit32 param; 190 /* 191 at target only 192 by default TD layer accpets all devices 193 */ 194 /* 195 at this point, 196 by LINK_UP event tdsaPortContext should have been created 197 */ 198 smTraceFuncEnter(hpDBG_VERY_LOUD, "Y0"); 199 TI_DBG1(("ossaDeviceHandleAccept: start hostAssignedDeviceId 0x%X\n",*hostAssignedDeviceId)); 200 201 202 if (agPortContext == agNULL) 203 { 204 TI_DBG1(("ossaDeviceHandleAccept: NULL agsaPortContext; wrong\n")); 205 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y0"); 206 return OSSA_RC_REJECT; 207 } 208 209 210 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 211 212 if (onePortContext == agNULL) 213 { 214 TI_DBG1(("ossaDeviceHandleAccept: NULL oneportcontext; wrong\n")); 215 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "Y0"); 216 return OSSA_RC_REJECT; 217 } 218 219 tiPortalContext = (tiPortalContext_t *)onePortContext->tiPortalContext; 220 221 if (tiPortalContext == agNULL) 222 { 223 TI_DBG1(("ossaDeviceHandleAccept: NULL tiPortalContext; wrong\n")); 224 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "Y0"); 225 return OSSA_RC_REJECT; 226 } 227 228 /* 229 add the device to device list 230 cf) OSSA_DISCOVER_FOUND_DEVICE 231 */ 232 TI_DBG4(("ossaDeviceHandleAccept: sasAddressHi 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSHI(&agDevInfo->commonDevInfo))); 233 TI_DBG4(("ossaDeviceHandleAccept: sasAddressLo 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSLO(&agDevInfo->commonDevInfo))); 234 TI_DBG4(("ossaDeviceHandleAccept: device type 0x%x\n", DEVINFO_GET_DEVICETTYPE(&agDevInfo->commonDevInfo))); 235 TI_DBG4(("ossaDeviceHandleAccept: phys %d\n", agDevInfo->numOfPhys)); 236 TI_DBG4(("ossaDeviceHandleAccept: pid %d\n", onePortContext->id)); 237 238 if (DEVINFO_GET_DEVICETTYPE(&agDevInfo->commonDevInfo) == SAS_END_DEVICE) 239 { 240 TI_DBG4(("ossaDeviceHandleAccept: SAS_END_DEVICE\n")); 241 } 242 else if (DEVINFO_GET_DEVICETTYPE(&agDevInfo->commonDevInfo) == SAS_EDGE_EXPANDER_DEVICE) 243 { 244 TI_DBG4(("ossaDeviceHandleAccept: SAS_EDGE_EXPANDER_DEVICE\n")); 245 } 246 else /* SAS_FANOUT_EXPANDER_DEVICE */ 247 { 248 TI_DBG4(("ossaDeviceHandleAccept: SAS_FANOUT_EXPANDER_DEVICE\n")); 249 } 250 agSASSubID.sasAddressHi = SA_DEVINFO_GET_SAS_ADDRESSHI(&agDevInfo->commonDevInfo); 251 agSASSubID.sasAddressLo = SA_DEVINFO_GET_SAS_ADDRESSLO(&agDevInfo->commonDevInfo); 252 agSASSubID.initiator_ssp_stp_smp = agDevInfo->initiator_ssp_stp_smp; 253 agSASSubID.target_ssp_stp_smp = agDevInfo->target_ssp_stp_smp; 254 255 256 tdssAddSASToSharedcontext( 257 onePortContext, 258 agRoot, 259 agDevHandle, 260 &agSASSubID, 261 agTRUE, 262 0xFF, 263 TD_OPERATION_TARGET 264 ); 265 266 /* at this point devicedata for new device exists */ 267 oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData; 268 269 if (oneDeviceData == agNULL) 270 { 271 TI_DBG1(("ossaDeviceHandleAccept: NULL oneDeviceData; wrong\n")); 272 return OSSA_RC_REJECT; 273 } 274 275 oneDeviceData->registered = agTRUE; 276 277 tiDeviceHandle = &(oneDeviceData->tiDeviceHandle); 278 279 if (tiDeviceHandle == agNULL) 280 { 281 TI_DBG1(("ossaDeviceHandleAccept: NULL tiDeviceHandle; wrong\n")); 282 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "Y0"); 283 return OSSA_RC_REJECT; 284 } 285 286 /* setting MCN in agsaDeviceInfo_t*/ 287 agDevInfo->commonDevInfo.flag = agDevInfo->commonDevInfo.flag | (tdsaAllShared->MCN << 16); 288 /* increment RegisteredDevNums */ 289 onePortContext->RegisteredDevNums++; 290 291 *hostAssignedDeviceId |= 0xBEEF0000; 292 293 TI_DBG1(("ossaDeviceHandleAccept: Now hostAssignedDeviceId 0x%X\n", *hostAssignedDeviceId)); 294 295 296 /* no login in SAS */ 297 /* 298 osGLOBAL bit32 ostiTargetEvent ( 299 tiRoot_t *tiRoot, 300 tiPortalContext_t *portalContext, 301 tiDeviceHandle_t *tiDeviceHandle, 302 tiTgtEventType_t eventType, 303 bit32 eventStatus, 304 void *parm 305 ); 306 */ 307 308 ostiTargetEvent( 309 tiRoot, 310 tiPortalContext, 311 tiDeviceHandle, 312 tiTgtEventTypeDeviceChange, 313 tiDeviceArrival, 314 agNULL 315 ); 316 /* set MCN and initiator role bit using saSetDeviceInfo */ 317 option = 24; /* setting MCN and initiator role 1 1000b*/ 318 param = (1 << 18) | (tdsaAllShared->MCN << 24); 319 TI_DBG1(("ossaDeviceHandleAccept: option 0x%x param 0x%x MCN 0x%x\n", option, param, tdsaAllShared->MCN)); 320 saSetDeviceInfo(agRoot, agNULL, 0, agDevHandle, option, param, ossaSetDeviceInfoCB); 321 smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "Y0"); 322 return OSSA_RC_ACCEPT; 323 #endif 324 325 #ifdef INITIATOR_DRIVER 326 /* this function is not used in case of Initiator */ 327 return OSSA_RC_ACCEPT; 328 #endif 329 } 330 331 #ifdef INITIATOR_DRIVER 332 /***************************************************************************** 333 *! \brief ossaDiscoverSasCB 334 * 335 * Purpose: This function is called by lower layer to inform TD layer of 336 * SAS discovery results 337 * 338 * 339 * \param agRoot Pointer to chip/driver Instance. 340 * \param agPortContext Pointer to the port context of TD and Lower layer 341 * \param event event type 342 * \param pParm1 Pointer to data associated with event 343 * \param pParm2 Pointer to data associated with event 344 * 345 * \return: none 346 * 347 * \note - For details, refer to SAS/SATA Low-Level API Specification 348 * 349 *****************************************************************************/ 350 osGLOBAL void ossaDiscoverSasCB(agsaRoot_t *agRoot, 351 agsaPortContext_t *agPortContext, 352 bit32 event, 353 void *pParm1, 354 void *pParm2 355 ) 356 { 357 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 358 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 359 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)osData->tdsaAllShared; 360 361 tdsaPortContext_t *onePortContext = agNULL; 362 tdsaDeviceData_t *oneDeviceData = agNULL; 363 364 agsaDevHandle_t *agDevHandle = agNULL; 365 agsaSASDeviceInfo_t *agDeviceInfo = agNULL; 366 tiPortalContext_t *tiPortalContext = agNULL; 367 tdList_t *DeviceListList; 368 tdsaSASSubID_t agSASSubID; 369 370 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y1"); 371 TI_DBG2(("ossaDiscoverSasCB: start\n")); 372 373 if (agPortContext == agNULL) 374 { 375 TI_DBG1(("ossaDiscoverSasCB: NULL agsaPortContext; wrong\n")); 376 return; 377 } 378 379 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 380 tiPortalContext = (tiPortalContext_t *)onePortContext->tiPortalContext; 381 382 switch ( event ) 383 { 384 case OSSA_DISCOVER_STARTED: 385 { 386 TI_DBG3(("ossaDiscoverSasCB: STARTED pid %d\n", onePortContext->id)); 387 /* 388 invalidate all devices in current device list 389 */ 390 DeviceListList = tdsaAllShared->MainDeviceList.flink; 391 while (DeviceListList != &(tdsaAllShared->MainDeviceList)) 392 { 393 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList); 394 TI_DBG3(("ossaDiscoverSasCB: loop did %d\n", oneDeviceData->id)); 395 TI_DBG3(("ossaDiscoverSasCB: loop sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi)); 396 TI_DBG6(("ossaDiscoverSasCB: loop sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo)); 397 if (oneDeviceData->tdPortContext == onePortContext) 398 { 399 TI_DBG3(("ossaDiscoverSasCB: did %d is invalidated \n", oneDeviceData->id)); 400 /* temporary solution: only for sata direct attached */ 401 } 402 DeviceListList = DeviceListList->flink; 403 } 404 onePortContext->DiscoveryState = ITD_DSTATE_STARTED; 405 break; 406 } 407 408 case OSSA_DISCOVER_FOUND_DEVICE: 409 { 410 TI_DBG4(("ossaDiscoverSasCB: $$$$$ FOUND_DEVICE pid %d\n", onePortContext->id)); 411 agDevHandle = (agsaDevHandle_t *)pParm1; 412 agDeviceInfo = (agsaSASDeviceInfo_t *)pParm2; 413 TI_DBG5(("ossaDiscoverSasCB: sasAddressHi 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSHI(&agDeviceInfo->commonDevInfo))); 414 TI_DBG5(("ossaDiscoverSasCB: sasAddressLo 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSLO(&agDeviceInfo->commonDevInfo))); 415 TI_DBG5(("ossaDiscoverSasCB: device type 0x%x\n", DEVINFO_GET_DEVICETTYPE(&agDeviceInfo->commonDevInfo))); 416 417 TI_DBG6(("ossaDiscoverSasCB: phys %d\n", agDeviceInfo->numOfPhys)); 418 TI_DBG4(("ossaDiscoverSasCB: pid %d\n", onePortContext->id)); 419 420 421 /* Add only target devices; do not add expander device */ 422 if (DEVINFO_GET_DEVICETTYPE(&agDeviceInfo->commonDevInfo) == SAS_END_DEVICE) 423 { 424 agSASSubID.sasAddressHi = SA_DEVINFO_GET_SAS_ADDRESSHI(&agDeviceInfo->commonDevInfo); 425 agSASSubID.sasAddressLo = SA_DEVINFO_GET_SAS_ADDRESSLO(&agDeviceInfo->commonDevInfo); 426 agSASSubID.initiator_ssp_stp_smp = agDeviceInfo->initiator_ssp_stp_smp; 427 agSASSubID.target_ssp_stp_smp = agDeviceInfo->target_ssp_stp_smp; 428 429 TI_DBG2(("ossaDiscoverSasCB: adding ....\n")); 430 431 tdssAddSASToSharedcontext( 432 onePortContext, 433 agRoot, 434 agDevHandle, 435 &agSASSubID, 436 agTRUE, 437 agDeviceInfo->phyIdentifier, 438 TD_OPERATION_INITIATOR 439 ); 440 ostiInitiatorEvent( 441 tiRoot, 442 tiPortalContext, 443 agNULL, 444 tiIntrEventTypeDeviceChange, 445 tiDeviceArrival, 446 agNULL 447 ); 448 } 449 else 450 { 451 TI_DBG5(("ossaDiscoverSasCB: $$$$$ not end device. not adding....\n")); 452 } 453 454 455 break; 456 } 457 458 case OSSA_DISCOVER_REMOVED_DEVICE: 459 { 460 TI_DBG3(("ossaDiscoverSasCB: REMOVED_DEVICE\n")); 461 agDevHandle = (agsaDevHandle_t *)pParm1; 462 agDeviceInfo = (agsaSASDeviceInfo_t *)pParm2; 463 oneDeviceData = (tdsaDeviceData_t *) agDevHandle->osData; 464 465 TI_DBG6(("ossaDiscoverSasCB: sasAddressHi 0x%08x\n", 466 SA_DEVINFO_GET_SAS_ADDRESSHI(&agDeviceInfo->commonDevInfo))); 467 TI_DBG6(("ossaDiscoverSasCB: sasAddressLo 0x%08x\n", 468 SA_DEVINFO_GET_SAS_ADDRESSLO(&agDeviceInfo->commonDevInfo))); 469 TI_DBG6(("ossaDiscoverSasCB: phys %d\n", agDeviceInfo->numOfPhys)); 470 TI_DBG6(("ossaDiscoverSasCB: onePortContext->id %d\n", onePortContext->id)); 471 472 if (oneDeviceData == agNULL) 473 { 474 TI_DBG1(("ossaDiscoverSasCB: Wrong. DevHandle->osData is NULL but is being removed\n")); 475 } 476 else 477 { 478 tdssRemoveSASFromSharedcontext(onePortContext, 479 oneDeviceData, 480 agRoot); 481 agDevHandle->osData = agNULL; 482 ostiInitiatorEvent( 483 tiRoot, 484 tiPortalContext, 485 agNULL, 486 tiIntrEventTypeDeviceChange, 487 tiDeviceRemoval, 488 agNULL 489 ); 490 } 491 492 break; 493 } 494 case OSSA_DISCOVER_COMPLETE: 495 { 496 TI_DBG2(("ossaDiscoverSasCB: SAS COMPLETE pid %d\n", onePortContext->id)); 497 /* 498 note: 499 SAS discovery must be called before SATA discovery 500 "onePortContext->DiscoveryState = ITD_DSTATE_COMPLETED" is 501 in ossaDiscoverSataCB not in ossaDiscoverSasCB when SATA_ENABLE 502 */ 503 #ifndef SATA_ENABLE 504 onePortContext->DiscoveryState = ITD_DSTATE_COMPLETED; 505 TI_DBG6(("ossaDiscoverSasCB: COMPLETE pid %d\n", onePortContext->id)); 506 #endif 507 508 #ifdef SATA_ENABLE 509 TI_DBG2(("ossaDiscoverSasCB: calling SATA discovery\n")); 510 511 /* Continue with SATA discovery */ 512 saDiscover(agRoot, agPortContext, AG_SA_DISCOVERY_TYPE_SATA, 513 onePortContext->discoveryOptions); 514 515 #else /* SATA not enable */ 516 517 #ifdef TD_INTERNAL_DEBUG /* for debugging */ 518 /* dump device list */ 519 DeviceListList = tdsaAllShared->MainPortContextList.flink; 520 521 while (DeviceListList != &(tdsaAllShared->MainPortContextList)) 522 { 523 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList); 524 TI_DBG2(("ossaDiscoverSasCB: did %d valid %d\n", oneDeviceData->id, oneDeviceData->valid)); 525 TI_DBG2(("ossaDiscoverSasCB: device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi)); 526 TI_DBG2(("ossaDiscoverSasCB: device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo)); 527 DeviceListList = DeviceListList->flink; 528 } 529 #endif 530 531 /* letting OS layer know discovery has been successfully complete */ 532 ostiInitiatorEvent( 533 tiRoot, 534 tiPortalContext, 535 agNULL, 536 tiIntrEventTypeDiscovery, 537 tiDiscOK, 538 agNULL 539 ); 540 #endif /* SATA_ENABLE */ 541 542 break; 543 } 544 case OSSA_DISCOVER_ABORT: 545 { 546 TI_DBG3(("ossaDiscoverSasCB: ABORT\n")); 547 /* letting OS layer know discovery has not been successfully complete */ 548 ostiInitiatorEvent( 549 tiRoot, 550 tiPortalContext, 551 agNULL, 552 tiIntrEventTypeDiscovery, 553 tiDiscFailed, 554 agNULL 555 ); 556 break; 557 } 558 case OSSA_DISCOVER_ABORT_ERROR_1: 559 { 560 TI_DBG3(("ossaDiscoverSasCB: ERROR 1\n")); 561 /* letting OS layer know discovery has not been successfully complete */ 562 ostiInitiatorEvent( 563 tiRoot, 564 tiPortalContext, 565 agNULL, 566 tiIntrEventTypeDiscovery, 567 tiDiscFailed, 568 agNULL 569 ); 570 break; 571 } 572 573 case OSSA_DISCOVER_ABORT_ERROR_2: 574 { 575 TI_DBG3(("ossaDiscoverSasCB: ERROR 2\n")); 576 /* letting OS layer know discovery has not been successfully complete */ 577 ostiInitiatorEvent( 578 tiRoot, 579 tiPortalContext, 580 agNULL, 581 tiIntrEventTypeDiscovery, 582 tiDiscFailed, 583 agNULL 584 ); 585 break; 586 } 587 588 case OSSA_DISCOVER_ABORT_ERROR_3: 589 { 590 TI_DBG3(("ossaDiscoverSasCB: ERROR 3\n")); 591 /* letting OS layer know discovery has not been successfully complete */ 592 ostiInitiatorEvent( 593 tiRoot, 594 tiPortalContext, 595 agNULL, 596 tiIntrEventTypeDiscovery, 597 tiDiscFailed, 598 agNULL 599 ); 600 break; 601 } 602 case OSSA_DISCOVER_ABORT_ERROR_4: 603 { 604 TI_DBG3(("ossaDiscoverSasCB: ERROR 4\n")); 605 /* letting OS layer know discovery has not been successfully complete */ 606 ostiInitiatorEvent( 607 tiRoot, 608 tiPortalContext, 609 agNULL, 610 tiIntrEventTypeDiscovery, 611 tiDiscFailed, 612 agNULL 613 ); 614 break; 615 } 616 case OSSA_DISCOVER_ABORT_ERROR_5: 617 { 618 TI_DBG3(("ossaDiscoverSasCB: ERROR 5\n")); 619 /* letting OS layer know discovery has not been successfully complete */ 620 ostiInitiatorEvent( 621 tiRoot, 622 tiPortalContext, 623 agNULL, 624 tiIntrEventTypeDiscovery, 625 tiDiscFailed, 626 agNULL 627 ); 628 break; 629 } 630 case OSSA_DISCOVER_ABORT_ERROR_6: 631 { 632 TI_DBG3(("ossaDiscoverSasCB: ERROR 6\n")); 633 /* letting OS layer know discovery has not been successfully complete */ 634 ostiInitiatorEvent( 635 tiRoot, 636 tiPortalContext, 637 agNULL, 638 tiIntrEventTypeDiscovery, 639 tiDiscFailed, 640 agNULL 641 ); 642 break; 643 } 644 case OSSA_DISCOVER_ABORT_ERROR_7: 645 { 646 TI_DBG3(("ossaDiscoverSasCB: ERROR 7\n")); 647 /* letting OS layer know discovery has not been successfully complete */ 648 ostiInitiatorEvent( 649 tiRoot, 650 tiPortalContext, 651 agNULL, 652 tiIntrEventTypeDiscovery, 653 tiDiscFailed, 654 agNULL 655 ); 656 break; 657 } 658 case OSSA_DISCOVER_ABORT_ERROR_8: 659 { 660 TI_DBG3(("ossaDiscoverSasCB: ERROR 8\n")); 661 /* letting OS layer know discovery has not been successfully complete */ 662 ostiInitiatorEvent( 663 tiRoot, 664 tiPortalContext, 665 agNULL, 666 tiIntrEventTypeDiscovery, 667 tiDiscFailed, 668 agNULL 669 ); 670 break; 671 } 672 case OSSA_DISCOVER_ABORT_ERROR_9: 673 { 674 TI_DBG3(("ossaDiscoverSasCB: ERROR 9\n")); 675 /* letting OS layer know discovery has not been successfully complete */ 676 ostiInitiatorEvent( 677 tiRoot, 678 tiPortalContext, 679 agNULL, 680 tiIntrEventTypeDiscovery, 681 tiDiscFailed, 682 agNULL 683 ); 684 break; 685 } 686 default: 687 TI_DBG3(("ossaDiscoverSasCB: ERROR default event 0x%x\n", event)); 688 /* letting OS layer know discovery has not been successfully complete */ 689 ostiInitiatorEvent( 690 tiRoot, 691 tiPortalContext, 692 agNULL, 693 tiIntrEventTypeDiscovery, 694 tiDiscFailed, 695 agNULL 696 ); 697 break; 698 } /* end of switch */ 699 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y1"); 700 return; 701 } 702 #endif // #ifdef INITIATOR_DRIVER 703 704 osGLOBAL void ossaLogTrace0( 705 agsaRoot_t *agRoot, 706 bit32 traceCode 707 ) 708 { 709 return; 710 } 711 712 osGLOBAL void ossaLogTrace1( 713 agsaRoot_t *agRoot, 714 bit32 traceCode, 715 bit32 value1 716 ) 717 { 718 return; 719 } 720 721 osGLOBAL void ossaLogTrace2( 722 agsaRoot_t *agRoot, 723 bit32 traceCode, 724 bit32 value1, 725 bit32 value2 726 ) 727 { 728 return; 729 } 730 731 osGLOBAL void ossaLogTrace3( 732 agsaRoot_t *agRoot, 733 bit32 traceCode, 734 bit32 value1, 735 bit32 value2, 736 bit32 value3 737 ) 738 { 739 return; 740 } 741 742 743 osGLOBAL void 744 ossaLogTrace4( 745 agsaRoot_t *agRoot, 746 bit32 traceCode, 747 bit32 value1, 748 bit32 value2, 749 bit32 value3, 750 bit32 value4 751 ) 752 { 753 return; 754 } 755 756 757 /***************************************************************************** 758 *! \brief ossaHwCB 759 * 760 * Purpose: This function is called by lower layer to inform TD layer of 761 * HW related results 762 * 763 * \param agRoot Pointer to chip/driver Instance. 764 * \param agPortContext Pointer to the port context of TD and Lower layer 765 * \param event event type 766 * \param eventParm1 event-specific parameter 767 * \param eventParm2 event-specific parameter 768 * \param eventParm3 event-specific parameter of pointer type 769 * 770 * \return: none 771 * 772 * \note - For details, refer to SAS/SATA Low-Level API Specification 773 * 774 *****************************************************************************/ 775 osGLOBAL void ossaHwCB( 776 agsaRoot_t *agRoot, 777 agsaPortContext_t *agPortContext, 778 bit32 event, 779 bit32 eventParm1, 780 void *eventParm2, 781 void *eventParm3 782 ) 783 { 784 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 785 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 786 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)osData->tdsaAllShared; 787 tdList_t *PortContextList = agNULL; 788 tdsaPortContext_t *onePortContext = agNULL; 789 agsaDevHandle_t *agDevHandle = agNULL; 790 agsaSASIdentify_t *IDframe = agNULL; 791 int i = 0; 792 #ifdef INITIATOR_DRIVER 793 tdsaSASSubID_t agSASSubID; 794 #endif 795 bit32 PhyID; 796 bit32 PhyStatus; 797 bit32 LinkRate; 798 bit32 PortState; 799 bit32 HwAckSatus = AGSA_RC_SUCCESS; 800 801 // #ifdef INITIATOR_DRIVER 802 #ifdef INITIATOR_DRIVER 803 agsaFisRegDeviceToHost_t *RegD2H = agNULL; 804 tdsaDeviceData_t *oneDeviceData = agNULL; 805 tdList_t *DeviceListList; 806 #endif 807 #ifdef REMOVED 808 bit32 found = agFALSE; 809 #endif 810 agsaHWEventEncrypt_t *pEncryptCBData; 811 agsaEncryptInfo_t *pEncryptInfo; 812 agsaHWEventMode_t *pModeEvent; 813 tiEncryptPort_t encryptEventData; 814 tiEncryptInfo_t encryptInfo; 815 bit32 *pModePage; 816 bit32 securityMode; 817 bit32 cipherMode; 818 bit32 encryptStatus; 819 bit32 securitySetModeStatus; 820 bit32 securityModeStatus; 821 822 // #endif /* INITIATOR_DRIVER */ 823 agsaPhyErrCountersPage_t *agPhyErrCountersPage; 824 agsaEventSource_t eventSource; 825 826 #ifdef FDS_DM 827 dmRoot_t *dmRoot = &(tdsaAllShared->dmRoot); 828 dmPortContext_t *dmPortContext = agNULL; 829 bit32 status = DM_RC_FAILURE; 830 dmPortInfo_t dmPortInfo; 831 // bit32 discStatus = dmDiscInProgress; 832 #endif 833 834 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y2"); 835 836 TI_DBG2(("ossaHwCB: agPortContext %p event 0x%x eventParm1 0x%x eventParm2 %p eventParm3 %p\n", 837 agPortContext,event,eventParm1,eventParm2,eventParm3 )); 838 839 switch ( event ) 840 { 841 case OSSA_HW_EVENT_SAS_PHY_UP: 842 { 843 PhyID = TD_GET_PHY_ID(eventParm1); 844 LinkRate = TD_GET_LINK_RATE(eventParm1); 845 PortState = TD_GET_PORT_STATE(eventParm1); 846 agDevHandle = agNULL; 847 IDframe = (agsaSASIdentify_t *)eventParm3; 848 849 850 TI_DBG2(("ossaHwCB: Phy%d SAS link Up\n", PhyID)); 851 852 if (agPortContext == agNULL) 853 { 854 TI_DBG1(("ossaHwCB: agPortContext null, wrong\n")); 855 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y2"); 856 return; 857 } 858 if (agDevHandle == agNULL) 859 { 860 TI_DBG3(("ossaHwCB: agDevHandle null by design change\n")); 861 } 862 863 if (IDframe == agNULL) 864 { 865 TI_DBG1(("ossaHwCB: IDframe null, wrong\n")); 866 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "Y2"); 867 return; 868 } 869 /* debugging only */ 870 if (LinkRate == 0x01) 871 { 872 TI_DBG1(("ossaHwCB: SAS Link Rate is 1.5 Gbps PhyID %d\n",PhyID)); 873 } 874 if (LinkRate == 0x02) 875 { 876 TI_DBG1(("ossaHwCB: SAS Link Rate is 3.0 Gbps PhyID %d\n",PhyID)); 877 } 878 if (LinkRate == 0x04) 879 { 880 TI_DBG1(("ossaHwCB: SAS Link Rate is 6.0 Gbps PhyID %d\n",PhyID)); 881 } 882 if (LinkRate == 0x08) 883 { 884 TI_DBG1(("ossaHwCB: SAS Link Rate is 12.0 Gbps PhyID %d\n",PhyID)); 885 } 886 887 if (PortState == OSSA_PORT_INVALID) 888 { 889 TI_DBG1(("ossaHwCB: Wrong port state with SAS link up\n")); 890 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "Y2"); 891 return; 892 } 893 894 if ( agPortContext->osData == agNULL) 895 {/* if */ 896 TI_DBG6 (("ossaHwCB: PhyID %d tdsaAllShared %p\n", PhyID, tdsaAllShared)); 897 if (tdsaAllShared->Ports[PhyID].tiPortalContext == agNULL) 898 { 899 TI_DBG6(("ossaHwCB: NULL portalcontext\n")); 900 } 901 else 902 { 903 TI_DBG6(("ossaHwCB: NOT NULL portalcontext\n")); 904 } 905 906 if (IDframe == agNULL) 907 { 908 TI_DBG1(("ossaHwCB: IDFrame is NULL; SATA !!!!\n")); 909 } 910 else 911 { 912 TI_DBG3(("ossaHwCB: IDframe->sasAddressHi 0x%08x \n", 913 SA_IDFRM_GET_SAS_ADDRESSHI(IDframe))); 914 TI_DBG3(("ossaHwCB: IDframe->sasAddressLo 0x%08x \n", 915 SA_IDFRM_GET_SAS_ADDRESSLO(IDframe))); 916 917 } 918 /* 919 setting tdsaPortContext fields 920 take the head from the FreeLink of tdsaPortContext_t 921 then modify it 922 then put it in MainLink of tdsaPortContext_t 923 */ 924 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 925 if (TDLIST_NOT_EMPTY(&(tdsaAllShared->FreePortContextList))) 926 { 927 TDLIST_DEQUEUE_FROM_HEAD(&PortContextList, &(tdsaAllShared->FreePortContextList)); 928 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 929 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, FreeLink, PortContextList); 930 TI_DBG2(("ossaHwCB: pid %d\n", onePortContext->id)); 931 TI_DBG6(("ossaHwCB: onePortContext %p\n", onePortContext)); 932 if (onePortContext == agNULL) 933 { 934 TI_DBG1(("ossaHwCB: onePortContext is NULL in allocation, wrong!\n")); 935 return; 936 } 937 938 /* sets fields of tdsaportcontext */ 939 #ifdef INITIATOR_DRIVER 940 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED; 941 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START; 942 #endif 943 onePortContext->PhyIDList[PhyID] = agTRUE; 944 if (IDframe == agNULL) 945 { 946 onePortContext->sasRemoteAddressHi = 0xFFFFFFFF; 947 onePortContext->sasRemoteAddressLo = 0xFFFFFFFF; 948 onePortContext->directAttatchedSAS = agTRUE; 949 } 950 else 951 { 952 onePortContext->sasRemoteAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(IDframe); 953 onePortContext->sasRemoteAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(IDframe); 954 /* Create ID frame and storing ID frame */ 955 osti_memcpy(&onePortContext->sasIDframe, IDframe, sizeof(agsaSASIdentify_t)); 956 tdhexdump("ossaHWCB: sasIDframe", (bit8 *)(&onePortContext->sasIDframe), sizeof(agsaSASIdentify_t)); 957 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) == SAS_END_DEVICE) 958 { 959 onePortContext->directAttatchedSAS = agTRUE; 960 } 961 #ifdef FDS_DM 962 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) == SAS_EDGE_EXPANDER_DEVICE || 963 SA_IDFRM_GET_DEVICETTYPE(IDframe) == SAS_FANOUT_EXPANDER_DEVICE 964 ) 965 { 966 onePortContext->UseDM = agTRUE; 967 } 968 #endif 969 } 970 971 onePortContext->sasLocalAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(&tdsaAllShared->Ports[PhyID].SASID); 972 onePortContext->sasLocalAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(&tdsaAllShared->Ports[PhyID].SASID); 973 onePortContext->tiPortalContext = tdsaAllShared->Ports[PhyID].tiPortalContext; 974 onePortContext->agRoot = agRoot; 975 onePortContext->agPortContext = agPortContext; 976 tdsaAllShared->Ports[PhyID].portContext = onePortContext; 977 agPortContext->osData = onePortContext; 978 onePortContext->valid = agTRUE; 979 if (LinkRate == 0x01) 980 { 981 onePortContext->LinkRate = SAS_CONNECTION_RATE_1_5G; 982 } 983 else if (LinkRate == 0x02) 984 { 985 onePortContext->LinkRate = SAS_CONNECTION_RATE_3_0G; 986 } 987 else if (LinkRate == 0x04) 988 { 989 onePortContext->LinkRate = SAS_CONNECTION_RATE_6_0G; 990 } 991 else /* (LinkRate == 0x08) */ 992 { 993 onePortContext->LinkRate = SAS_CONNECTION_RATE_12_0G; 994 } 995 996 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 997 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->MainLink), &(tdsaAllShared->MainPortContextList)); 998 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 999 #ifdef FDS_DM 1000 dmPortContext = &(onePortContext->dmPortContext); 1001 dmPortContext->tdData = onePortContext; 1002 /* set up dmPortInfo_t */ 1003 PORTINFO_PUT_SAS_REMOTE_ADDRESSLO(&dmPortInfo, onePortContext->sasRemoteAddressLo); 1004 PORTINFO_PUT_SAS_REMOTE_ADDRESSHI(&dmPortInfo, onePortContext->sasRemoteAddressHi); 1005 PORTINFO_PUT_SAS_LOCAL_ADDRESSLO(&dmPortInfo, onePortContext->sasLocalAddressLo); 1006 PORTINFO_PUT_SAS_LOCAL_ADDRESSHI(&dmPortInfo, onePortContext->sasLocalAddressHi); 1007 1008 TI_DBG2(("ossaHwCB: phy %d hi 0x%x lo 0x%x\n", PhyID, 1009 SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[PhyID].SASID)), 1010 SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[PhyID].SASID)))); 1011 TI_DBG2(("ossaHwCB: LocalAddrHi 0x%08x LocaAddrLo 0x%08x\n", onePortContext->sasLocalAddressHi, onePortContext->sasLocalAddressLo)); 1012 1013 dmPortInfo.flag = onePortContext->LinkRate; 1014 1015 if (onePortContext->UseDM == agTRUE) 1016 { 1017 TI_DBG1(("ossaHwCB: calling dmCreatePort\n")); 1018 status = dmCreatePort(dmRoot, dmPortContext, &dmPortInfo); 1019 if (status != DM_RC_SUCCESS) 1020 { 1021 TI_DBG1(("ossaHwCB: dmCreatePort failed!!! 0x%x\n", status)); 1022 } 1023 } 1024 #endif 1025 1026 } 1027 else 1028 { 1029 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1030 TI_DBG1(("\nossaHwCB: Attention!!! no more free PortContext.\n")); 1031 } 1032 #ifdef TD_INTERNAL_DEBUG /* for debugging only */ 1033 1034 print_tdlist_flink(&(tdsaPortContext->FreeLink), 1, 1); 1035 print_tdlist_flink(&(tdsaPortContext->MainLink), 1, 2); 1036 print_tdlist_flink(&(tdsaDeviceData->FreeLink), 2, 1); 1037 print_tdlist_flink(&(tdsaDeviceData->MainLink), 2, 2); 1038 #endif 1039 1040 #ifdef TD_INTERNAL_DEBUG /* for debugging */ 1041 PortContextList = tdsaPortContext->MainLink.flink; 1042 while (PortContextList != &(tdsaPortContext->MainLink)) 1043 { 1044 twoPortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList); 1045 TI_DBG6(("ossaHwCB: in while portContext ID %d\n", twoPortContext->id)); 1046 TI_DBG6(("ossaHwCB: in while PortContext %p\n", twoPortContext)); 1047 PortContextList = PortContextList->flink; 1048 } 1049 #endif 1050 /* add agDevHandle */ 1051 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) != SAS_NO_DEVICE) 1052 { 1053 #ifdef INITIATOR_DRIVER 1054 agSASSubID.sasAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(IDframe); 1055 agSASSubID.sasAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(IDframe); 1056 agSASSubID.initiator_ssp_stp_smp = IDframe->initiator_ssp_stp_smp; 1057 agSASSubID.target_ssp_stp_smp = IDframe->target_ssp_stp_smp; 1058 #endif 1059 1060 TI_DBG2(("ossaHwCB: adding ....\n")); 1061 /* uses only SASIDframe not agsaSASDeviceInfo_t */ 1062 #ifdef INITIATOR_DRIVER 1063 tdssAddSASToSharedcontext( 1064 onePortContext, 1065 agRoot, 1066 agDevHandle, /* agNULL */ 1067 &agSASSubID, 1068 agTRUE, 1069 (bit8)PhyID, 1070 TD_OPERATION_INITIATOR 1071 ); 1072 #endif 1073 1074 #ifdef FDS_DM 1075 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) == SAS_END_DEVICE && 1076 SA_IDFRM_IS_SSP_TARGET(IDframe) ) 1077 { 1078 TI_DBG2(("ossaHwCB: NOTIFY_ENABLE_SPINUP PhyID %d \n", PhyID)); 1079 1080 for (i=0;i<TD_MAX_NUM_NOTIFY_SPINUP;i++) 1081 { 1082 saLocalPhyControl(agRoot, agNULL, 0, PhyID, AGSA_PHY_NOTIFY_ENABLE_SPINUP, agNULL); 1083 } 1084 } 1085 1086 /* update MCN */ 1087 tdsaUpdateMCN(dmRoot, onePortContext); 1088 #endif 1089 1090 #ifdef TARGET_DRIVER 1091 TI_DBG1(("ossaHwCB: target, link up PhyID 0x%x\n",PhyID)); 1092 1093 /* notifying link up */ 1094 ostiPortEvent ( 1095 tiRoot, 1096 tiPortLinkUp, 1097 tiSuccess, 1098 (void *)tdsaAllShared->Ports[PhyID].tiPortalContext 1099 ); 1100 #endif 1101 } 1102 else 1103 { 1104 TI_DBG5(("ossaHwCB: $$$$$ not end device. not adding....\n")); 1105 } 1106 1107 saPortControl(agRoot, /* AGSA_PORT_SET_PORT_RECOVERY_TIME */ 1108 agNULL, 1109 0, 1110 agPortContext, 1111 AGSA_PORT_SET_PORT_RECOVERY_TIME, 1112 tdsaAllShared->portTMO, //PORT_RECOVERY_TIMEOUT 1113 0 1114 ); 1115 /* setting SAS PORT RESET TMO and SATA PORT RESET TMO*/ 1116 if (tIsSPCV12G(agRoot)) 1117 { 1118 saPortControl(agRoot, /* AGSA_PORT_SET_PORT_RESET_TIME */ 1119 agNULL, 1120 0, 1121 agPortContext, 1122 AGSA_PORT_SET_PORT_RESET_TIME, 1123 SAS_12G_PORT_RESET_TMO, // 800 ms 1124 0 1125 ); 1126 } 1127 else 1128 { 1129 saPortControl(agRoot, /* AGSA_PORT_SET_PORT_RESET_TIME */ 1130 agNULL, 1131 0, 1132 agPortContext, 1133 AGSA_PORT_SET_PORT_RESET_TIME, 1134 SAS_PORT_RESET_TMO, // 300 ms 1135 0 1136 ); 1137 } 1138 } 1139 else 1140 { 1141 /* 1142 an existing portcontext 1143 to be tested 1144 */ 1145 1146 TI_DBG2(("ossaHwCB: SAS existing portcontext returned\n")); 1147 1148 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 1149 if (onePortContext == agNULL) 1150 { 1151 TI_DBG1(("ossaHwCB: onePortContext is NULL, wrong!\n")); 1152 return; 1153 } 1154 if (onePortContext->valid == agFALSE) 1155 { 1156 /* port has been invalidated; needs to be allocated */ 1157 TI_DBG2(("ossaHwCB: SAS allocating port context\n")); 1158 1159 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 1160 if (TDLIST_NOT_EMPTY(&(tdsaAllShared->FreePortContextList))) 1161 { 1162 TDLIST_DEQUEUE_FROM_HEAD(&PortContextList, &(tdsaAllShared->FreePortContextList)); 1163 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1164 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, FreeLink, PortContextList); 1165 TI_DBG2(("ossaHwCB: allocating pid %d\n", onePortContext->id)); 1166 TI_DBG6(("ossaHwCB: allocating onePortContext %p\n", onePortContext)); 1167 if (onePortContext == agNULL) 1168 { 1169 TI_DBG1(("ossaHwCB: onePortContext is NULL in allocation, wrong!\n")); 1170 return; 1171 } 1172 /* sets fields of tdsaportcontext */ 1173 #ifdef INITIATOR_DRIVER 1174 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED; 1175 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START; 1176 #endif 1177 onePortContext->PhyIDList[PhyID] = agTRUE; 1178 if (IDframe == agNULL) 1179 { 1180 onePortContext->sasRemoteAddressHi = 0xFFFFFFFF; 1181 onePortContext->sasRemoteAddressLo = 0xFFFFFFFF; 1182 onePortContext->directAttatchedSAS = agTRUE; 1183 } 1184 else 1185 { 1186 onePortContext->sasRemoteAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(IDframe); 1187 onePortContext->sasRemoteAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(IDframe); 1188 /* Create ID frame and storing ID frame */ 1189 osti_memcpy(&onePortContext->sasIDframe, IDframe, sizeof(agsaSASIdentify_t)); 1190 tdhexdump("ossaHWCB: sasIDframe", (bit8 *)(&onePortContext->sasIDframe), sizeof(agsaSASIdentify_t)); 1191 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) == SAS_END_DEVICE) 1192 { 1193 onePortContext->directAttatchedSAS = agTRUE; 1194 } 1195 } 1196 1197 onePortContext->sasLocalAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(&tdsaAllShared->Ports[PhyID].SASID); 1198 onePortContext->sasLocalAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(&tdsaAllShared->Ports[PhyID].SASID); 1199 onePortContext->tiPortalContext = tdsaAllShared->Ports[PhyID].tiPortalContext; 1200 onePortContext->agRoot = agRoot; 1201 onePortContext->agPortContext = agPortContext; 1202 tdsaAllShared->Ports[PhyID].portContext = onePortContext; 1203 agPortContext->osData = onePortContext; 1204 onePortContext->valid = agTRUE; 1205 if (LinkRate == 0x01) 1206 { 1207 onePortContext->LinkRate = SAS_CONNECTION_RATE_1_5G; 1208 } 1209 else if (LinkRate == 0x02) 1210 { 1211 onePortContext->LinkRate = SAS_CONNECTION_RATE_3_0G; 1212 } 1213 else if (LinkRate == 0x04) 1214 { 1215 onePortContext->LinkRate = SAS_CONNECTION_RATE_6_0G; 1216 } 1217 else /* (LinkRate == 0x08) */ 1218 { 1219 onePortContext->LinkRate = SAS_CONNECTION_RATE_12_0G; 1220 } 1221 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 1222 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->MainLink), &(tdsaAllShared->MainPortContextList)); 1223 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1224 } 1225 else 1226 { 1227 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1228 TI_DBG1(("\nossaHwCB: Attention!!! no more free PortContext.\n")); 1229 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "Y2"); 1230 return; 1231 } 1232 } /* invalidated port */ 1233 else 1234 { 1235 /* already alloacated */ 1236 TI_DBG2(("ossaHwCB: SAS already allocated port context\n")); 1237 if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList))) 1238 { 1239 TI_DBG1(("ossaHwCB: wrong!!! null tdsaPortContext list\n")); 1240 smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "Y2"); 1241 return; 1242 } 1243 if (onePortContext == agNULL) 1244 { 1245 TI_DBG1(("ossaHwCB: wrong !!! No corressponding tdsaPortContext\n")); 1246 smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "Y2"); 1247 return; 1248 } 1249 1250 TI_DBG2(("ossaHwCB: existing pid %d\n", onePortContext->id)); 1251 if (tdsaAllShared->Ports[PhyID].portContext == agNULL) 1252 { 1253 TI_DBG1(("ossaHwCB: existing allshared pid is NULL\n")); 1254 } 1255 else 1256 { 1257 TI_DBG2(("ossaHwCB: existing allshared pid %d\n", tdsaAllShared->Ports[PhyID].portContext->id)); 1258 } 1259 /* updates PhyID belong to a port */ 1260 onePortContext->PhyIDList[PhyID] = agTRUE; 1261 #ifdef FDS_DM 1262 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) == SAS_END_DEVICE && 1263 SA_IDFRM_IS_SSP_TARGET(IDframe) ) 1264 { 1265 TI_DBG2(("ossaHwCB: NOTIFY_ENABLE_SPINUP PhyID %d \n", PhyID)); 1266 1267 for (i=0;i<TD_MAX_NUM_NOTIFY_SPINUP;i++) 1268 { 1269 saLocalPhyControl(agRoot, agNULL, 0, PhyID, AGSA_PHY_NOTIFY_ENABLE_SPINUP, agNULL); 1270 } 1271 } 1272 1273 /* update MCN */ 1274 tdsaUpdateMCN(dmRoot, onePortContext); 1275 #endif 1276 } 1277 onePortContext->SeenLinkUp = agTRUE; 1278 } /* else, old portcontext */ 1279 1280 break; 1281 } 1282 #ifdef INITIATOR_DRIVER 1283 case OSSA_HW_EVENT_SATA_PHY_UP: 1284 { 1285 PhyID = TD_GET_PHY_ID(eventParm1); 1286 LinkRate = TD_GET_LINK_RATE(eventParm1); 1287 PortState = TD_GET_PORT_STATE(eventParm1); 1288 agDevHandle = agNULL; 1289 RegD2H = ( agsaFisRegDeviceToHost_t *)eventParm3; 1290 1291 TI_DBG2(("ossaHwCB: Phy%d SATA link Up\n", PhyID)); 1292 1293 if (agDevHandle == agNULL) 1294 { 1295 TI_DBG3(("ossaHwCB: agDevHandle null by design change\n")); 1296 } 1297 1298 if (RegD2H == agNULL) 1299 { 1300 TI_DBG1(("ossaHwCB: RegD2H null, wrong\n")); 1301 smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "Y2"); 1302 return; 1303 } 1304 1305 1306 TI_DBG2(("ossaHwCB: agDevHandle %p\n", agDevHandle)); 1307 tdhexdump("ossaHWCB RegD2H", (bit8 *)RegD2H, sizeof(agsaFisRegDeviceToHost_t)); 1308 TI_DBG2(("ossaHwCB: Sector Count %d\n", RegD2H->d.sectorCount)); 1309 TI_DBG2(("ossaHwCB: LBA LOW %d\n", RegD2H->d.lbaLow)); 1310 TI_DBG2(("ossaHwCB: LBA MID %d\n", RegD2H->d.lbaMid)); 1311 TI_DBG2(("ossaHwCB: LBA HIGH %d\n", RegD2H->d.lbaHigh)); 1312 TI_DBG2(("ossaHwCB: DEVICE %d\n", RegD2H->d.device)); 1313 1314 /* debugging only */ 1315 if (LinkRate == 0x01) 1316 { 1317 TI_DBG1(("ossaHwCB: SATA Link Rate is 1.5 Gbps PhyID %d\n",PhyID)); 1318 } 1319 if (LinkRate == 0x02) 1320 { 1321 TI_DBG1(("ossaHwCB: SATA Link Rate is 3.0 Gbps PhyID %d\n",PhyID)); 1322 } 1323 if (LinkRate == 0x04) 1324 { 1325 TI_DBG1(("ossaHwCB: SATA Link Rate is 6.0 Gbps PhyID %d\n",PhyID)); 1326 } 1327 if (LinkRate == 0x08) 1328 { 1329 TI_DBG1(("ossaHwCB: SATA Link Rate is 12.0 Gbps PhyID %d\n",PhyID)); 1330 } 1331 1332 if (PortState == OSSA_PORT_INVALID) 1333 { 1334 TI_DBG1(("ossaHwCB: Wrong port state with SATA link up\n")); 1335 smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "Y2"); 1336 return; 1337 } 1338 1339 if ( agPortContext->osData == agNULL) 1340 {/* if */ 1341 TI_DBG6 (("ossaHwCB: PhyID %d tdsaAllShared %p\n", PhyID, tdsaAllShared)); 1342 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 1343 if (TDLIST_NOT_EMPTY(&(tdsaAllShared->FreePortContextList))) 1344 { 1345 TDLIST_DEQUEUE_FROM_HEAD(&PortContextList, &(tdsaAllShared->FreePortContextList)); 1346 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1347 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, FreeLink, PortContextList); 1348 TI_DBG2(("ossaHwCB: pid %d\n", onePortContext->id)); 1349 TI_DBG6(("ossaHwCB: onePortContext %p\n", onePortContext)); 1350 if (onePortContext == agNULL) 1351 { 1352 TI_DBG1(("ossaHwCB: onePortContext is NULL in allocation, wrong!\n")); 1353 return; 1354 } 1355 1356 /* sets fields of tdsaportcontext */ 1357 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED; 1358 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START; 1359 onePortContext->PhyIDList[PhyID] = agTRUE; 1360 /* NO sas address for SATA */ 1361 onePortContext->sasRemoteAddressHi = 0xFFFFFFFF; 1362 onePortContext->sasRemoteAddressLo = 0xFFFFFFFF; 1363 /* copying the signature */ 1364 onePortContext->remoteSignature[0] = RegD2H->d.sectorCount; 1365 onePortContext->remoteSignature[1] = RegD2H->d.lbaLow; 1366 onePortContext->remoteSignature[2] = RegD2H->d.lbaMid; 1367 onePortContext->remoteSignature[3] = RegD2H->d.lbaHigh; 1368 onePortContext->remoteSignature[4] = RegD2H->d.device; 1369 1370 onePortContext->sasLocalAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(&tdsaAllShared->Ports[PhyID].SASID); 1371 onePortContext->sasLocalAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(&tdsaAllShared->Ports[PhyID].SASID); 1372 onePortContext->tiPortalContext = tdsaAllShared->Ports[PhyID].tiPortalContext; 1373 onePortContext->agRoot = agRoot; 1374 onePortContext->agPortContext = agPortContext; 1375 tdsaAllShared->Ports[PhyID].portContext = onePortContext; 1376 agPortContext->osData = onePortContext; 1377 onePortContext->nativeSATAMode = agTRUE; 1378 onePortContext->valid = agTRUE; 1379 if (LinkRate == 0x01) 1380 { 1381 onePortContext->LinkRate = SAS_CONNECTION_RATE_1_5G; 1382 } 1383 else if (LinkRate == 0x02) 1384 { 1385 onePortContext->LinkRate = SAS_CONNECTION_RATE_3_0G; 1386 } 1387 else if (LinkRate == 0x04) 1388 { 1389 onePortContext->LinkRate = SAS_CONNECTION_RATE_6_0G; 1390 } 1391 else /* (LinkRate == 0x08) */ 1392 { 1393 onePortContext->LinkRate = SAS_CONNECTION_RATE_12_0G; 1394 } 1395 1396 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 1397 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->MainLink), &(tdsaAllShared->MainPortContextList)); 1398 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1399 } 1400 else 1401 { 1402 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1403 TI_DBG1(("\nossaHwCB: Attention!!! no more free PortContext.\n")); 1404 smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "Y2"); 1405 return; 1406 } 1407 #ifdef SATA_ENABLE 1408 /* tdssAddSATAToSharedcontext() sends identify device data to find out the uniqueness of 1409 target. In identify device data CB fn (satAddSATAIDDevCB()), 1410 tiPortLinkUp and tiPortDiscoveryReady happen 1411 */ 1412 tdssAddSATAToSharedcontext( 1413 onePortContext, 1414 agRoot, 1415 agDevHandle, /* agNULL */ 1416 agNULL, 1417 agTRUE, 1418 (bit8)PhyID 1419 ); 1420 #endif 1421 /* setting SAS PORT RESET TMO and SATA PORT RESET TMO*/ 1422 saPortControl(agRoot, /* AGSA_PORT_SET_PORT_RESET_TIME */ 1423 agNULL, 1424 0, 1425 agPortContext, 1426 AGSA_PORT_SET_PORT_RESET_TIME, 1427 0, 1428 SATA_PORT_RESET_TMO // 8000 ms 1429 ); 1430 1431 } 1432 else 1433 { 1434 /* 1435 an existing portcontext 1436 to be tested 1437 */ 1438 1439 TI_DBG1(("ossaHwCB: SATA existing portcontext returned. need testing\n")); 1440 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 1441 /* for debugging only */ 1442 if (onePortContext->valid == agFALSE) 1443 { 1444 /* port has been invalidated; needs to be allocated */ 1445 TI_DBG2(("ossaHwCB: SATA allocating port context\n")); 1446 } 1447 else 1448 { 1449 /* already alloacated */ 1450 TI_DBG1(("ossaHwCB: Wrong!!! SATA already allocated port context\n")); 1451 smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "Y2"); 1452 return; 1453 } 1454 1455 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 1456 if (TDLIST_NOT_EMPTY(&(tdsaAllShared->FreePortContextList))) 1457 { 1458 TDLIST_DEQUEUE_FROM_HEAD(&PortContextList, &(tdsaAllShared->FreePortContextList)); 1459 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1460 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, FreeLink, PortContextList); 1461 TI_DBG2(("ossaHwCB: pid %d\n", onePortContext->id)); 1462 TI_DBG6(("ossaHwCB: onePortContext %p\n", onePortContext)); 1463 if (onePortContext == agNULL) 1464 { 1465 TI_DBG1(("ossaHwCB: onePortContext is NULL in allocation, wrong!\n")); 1466 return; 1467 } 1468 1469 /* sets fields of tdsaportcontext */ 1470 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED; 1471 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START; 1472 onePortContext->PhyIDList[PhyID] = agTRUE; 1473 /* NO sas address for SATA */ 1474 onePortContext->sasRemoteAddressHi = 0xFFFFFFFF; 1475 onePortContext->sasRemoteAddressLo = 0xFFFFFFFF; 1476 /* copying the signature */ 1477 onePortContext->remoteSignature[0] = RegD2H->d.sectorCount; 1478 onePortContext->remoteSignature[1] = RegD2H->d.lbaLow; 1479 onePortContext->remoteSignature[2] = RegD2H->d.lbaMid; 1480 onePortContext->remoteSignature[3] = RegD2H->d.lbaHigh; 1481 onePortContext->remoteSignature[4] = RegD2H->d.device; 1482 1483 onePortContext->sasLocalAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(&tdsaAllShared->Ports[PhyID].SASID); 1484 onePortContext->sasLocalAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(&tdsaAllShared->Ports[PhyID].SASID); 1485 onePortContext->tiPortalContext = tdsaAllShared->Ports[PhyID].tiPortalContext; 1486 onePortContext->agRoot = agRoot; 1487 onePortContext->agPortContext = agPortContext; 1488 tdsaAllShared->Ports[PhyID].portContext = onePortContext; 1489 agPortContext->osData = onePortContext; 1490 onePortContext->nativeSATAMode = agTRUE; 1491 onePortContext->valid = agTRUE; 1492 if (LinkRate == 0x01) 1493 { 1494 onePortContext->LinkRate = SAS_CONNECTION_RATE_1_5G; 1495 } 1496 else if (LinkRate == 0x02) 1497 { 1498 onePortContext->LinkRate = SAS_CONNECTION_RATE_3_0G; 1499 } 1500 else if (LinkRate == 0x04) 1501 { 1502 onePortContext->LinkRate = SAS_CONNECTION_RATE_6_0G; 1503 } 1504 else /* (LinkRate == 0x08) */ 1505 { 1506 onePortContext->LinkRate = SAS_CONNECTION_RATE_12_0G; 1507 } 1508 1509 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 1510 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->MainLink), &(tdsaAllShared->MainPortContextList)); 1511 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1512 } 1513 else 1514 { 1515 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 1516 TI_DBG1(("\nossaHwCB: Attention!!! no more free PortContext.\n")); 1517 smTraceFuncExit(hpDBG_VERY_LOUD, 'k', "Y2"); 1518 return; 1519 } 1520 1521 1522 /*hotplug */ 1523 #ifdef SATA_ENABLE 1524 tdssAddSATAToSharedcontext( 1525 onePortContext, 1526 agRoot, 1527 agDevHandle, /* agNULL */ 1528 agNULL, 1529 agTRUE, 1530 (bit8)PhyID 1531 ); 1532 #endif 1533 /* end hotplug */ 1534 } 1535 1536 break; 1537 } 1538 #endif 1539 case OSSA_HW_EVENT_SATA_SPINUP_HOLD: 1540 { 1541 PhyID = TD_GET_PHY_ID(eventParm1); 1542 1543 TI_DBG2(("ossaHwCB: spinup hold PhyID %d\n", PhyID)); 1544 break; 1545 } 1546 1547 case OSSA_HW_EVENT_PHY_DOWN: 1548 { 1549 bit32 AllPhyDown = agTRUE; 1550 1551 /* 4/15/08 spec */ 1552 PhyID = TD_GET_PHY_ID(eventParm1); 1553 LinkRate = TD_GET_LINK_RATE(eventParm1); 1554 PortState = TD_GET_PORT_STATE(eventParm1); 1555 1556 1557 TI_DBG2(("ossaHwCB: Phy%d link Down\n", PhyID)); 1558 1559 if (agPortContext == agNULL) 1560 { 1561 TI_DBG1(("ossaHwCB: agPortContext null, wrong\n")); 1562 smTraceFuncExit(hpDBG_VERY_LOUD, 'l', "Y2"); 1563 return; 1564 } 1565 1566 if ( agPortContext->osData == agNULL) 1567 { /* if */ 1568 /* PortContext must exit at this point */ 1569 TI_DBG1(("ossaHwCB: NULL portalcontext. Error. Can't be NULL\n")); 1570 } 1571 else 1572 { 1573 TI_DBG3(("ossaHwCB: NOT NULL portalcontext\n")); 1574 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 1575 if (onePortContext == agNULL) 1576 { 1577 TI_DBG1(("ossaHwCB: wrong !!! No corressponding tdsaPortContext\n")); 1578 smTraceFuncExit(hpDBG_VERY_LOUD, 'm', "Y2"); 1579 return; 1580 } 1581 onePortContext->PhyIDList[PhyID] = agFALSE; 1582 for(i=0;i<TD_MAX_NUM_PHYS;i++) 1583 { 1584 if (onePortContext->PhyIDList[i] == agTRUE) 1585 { 1586 TI_DBG3(("ossaHwCB: Phy %d is still up\n", i)); 1587 AllPhyDown = agFALSE; 1588 break; 1589 } 1590 } 1591 1592 /* last phy belong to the portcontext */ 1593 if (AllPhyDown == agTRUE) 1594 { 1595 #ifdef NOT_YET 1596 TI_DBG1(("ossaHwCB: calling tiPortLinkDown\n")); 1597 ostiPortEvent ( 1598 tiRoot, 1599 tiPortLinkDown, 1600 tiSuccess, 1601 (void *)onePortContext->tiPortalContext 1602 ); 1603 #endif 1604 } 1605 1606 if (PortState == OSSA_PORT_VALID) 1607 { 1608 /* do nothing */ 1609 /* no ack for every phy down */ 1610 #ifdef FDS_DM 1611 /* update MCN for all devices belong to this port */ 1612 tdsaUpdateMCN(dmRoot, onePortContext); 1613 #endif 1614 } 1615 else if (PortState == OSSA_PORT_LOSTCOMM) 1616 { 1617 /* 1618 1. Mark the port as invalid and stop the io for that port and its device 1619 No ack here. Otherwise, port will be released by FW. 1620 */ 1621 TI_DBG2(("ossaHwCB: phy Down and OSSA_PORT_LOSTCOMM\n")); 1622 /* save eventSource related information in tdsaAllShared */ 1623 tdsaAllShared->eventSource[PhyID].EventValid = agTRUE; 1624 tdsaAllShared->eventSource[PhyID].Source.agPortContext = agPortContext; 1625 tdsaAllShared->eventSource[PhyID].Source.event = OSSA_HW_EVENT_PHY_DOWN; 1626 /* phy ID */ 1627 tdsaAllShared->eventSource[PhyID].Source.param = PhyID; 1628 /* phy ID */ 1629 onePortContext->eventPhyID = PhyID; 1630 /* to stop IO's */ 1631 onePortContext->valid = agFALSE; 1632 break; 1633 } 1634 else if (PortState == OSSA_PORT_IN_RESET) 1635 { 1636 TI_DBG2(("ossaHwCB: phy Down and OSSA_PORT_IN_RESET\n")); 1637 /* save eventSource related information in tdsaAllShared */ 1638 tdsaAllShared->eventSource[PhyID].EventValid = agTRUE; 1639 tdsaAllShared->eventSource[PhyID].Source.agPortContext = agPortContext; 1640 tdsaAllShared->eventSource[PhyID].Source.event = OSSA_HW_EVENT_PHY_DOWN; 1641 /* phy ID */ 1642 tdsaAllShared->eventSource[PhyID].Source.param = PhyID; 1643 /* phy ID */ 1644 onePortContext->eventPhyID = PhyID; 1645 /* to stop IO's */ 1646 onePortContext->valid = agFALSE; 1647 break; 1648 } 1649 else if (PortState == OSSA_PORT_INVALID) 1650 { 1651 TI_DBG1(("ossaHwCB: Last phy Down and port invalid OSSA_PORT_INVALID\n")); 1652 /* 1653 invalidate port 1654 then, saHwEventAck() in ossaDeregisterDeviceHandleCB() 1655 */ 1656 1657 /* save eventSource related information in tdsaAllShared */ 1658 tdsaAllShared->eventSource[PhyID].EventValid = agTRUE; 1659 tdsaAllShared->eventSource[PhyID].Source.agPortContext = agPortContext; 1660 tdsaAllShared->eventSource[PhyID].Source.event = OSSA_HW_EVENT_PHY_DOWN; 1661 /* phy ID */ 1662 tdsaAllShared->eventSource[PhyID].Source.param = PhyID; 1663 /* phy ID */ 1664 onePortContext->eventPhyID = PhyID; 1665 1666 onePortContext->valid = agFALSE; 1667 1668 TI_DBG2(("ossaHwCB: pid %d\n", onePortContext->id)); 1669 #ifdef INITIATOR_DRIVER 1670 /* notifying link down (all links belonging to a port are down) */ 1671 ostiPortEvent( 1672 tiRoot, 1673 tiPortStopped, 1674 tiSuccess, 1675 (void *)onePortContext->tiPortalContext 1676 ); 1677 #endif 1678 1679 #ifdef TARGET_DRIVER 1680 ostiPortEvent( 1681 tiRoot, 1682 tiPortLinkDown, 1683 tiSuccess, 1684 (void *)onePortContext->tiPortalContext 1685 ); 1686 1687 #endif 1688 1689 #ifdef INITIATOR_DRIVER 1690 tdssReportRemovals(agRoot, 1691 onePortContext, 1692 agFALSE 1693 ); 1694 #endif 1695 #ifdef TARGET_DRIVER 1696 ttdssReportRemovals(agRoot, 1697 onePortContext, 1698 agFALSE 1699 ); 1700 1701 #endif 1702 1703 /* find a PhyID and reset for portContext in tdssSASShared */ 1704 for(i=0;i<TD_MAX_NUM_PHYS;i++) 1705 { 1706 if (onePortContext->PhyIDList[i] == agTRUE) 1707 { 1708 tdsaAllShared->Ports[i].portContext = agNULL; 1709 } 1710 } 1711 /* portcontext is removed from MainLink to FreeLink in tdssReportRemovals or 1712 ossaDeregisterDeviceHandleCB 1713 */ 1714 }/* OSSA_PORT_INVALID */ 1715 else 1716 { 1717 /* other newly defined port state */ 1718 /* do nothing */ 1719 TI_DBG2(("ossaHwCB: portstate 0x%x\n", PortState)); 1720 } 1721 } /* big else */ 1722 break; 1723 } 1724 case OSSA_HW_EVENT_PHY_START_STATUS: 1725 { 1726 PhyID = TD_GET_PHY_ID(eventParm1); 1727 PhyStatus = TD_GET_PHY_STATUS(eventParm1); 1728 1729 TI_DBG6(("ossaHwCB: OSSA_HW_EVENT_PHY_START_STATUS\n")); 1730 if (PhyStatus == 0x00) 1731 { 1732 TI_DBG6(("ossaHwCB: OSSA_HW_EVENT_PHY_START_STATUS, SUCCESS\n")); 1733 } 1734 else if (PhyStatus == 0x01) 1735 { 1736 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_START_STATUS, INVALID_PHY\n")); 1737 } 1738 else if (PhyStatus == 0x02) 1739 { 1740 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_START_STATUS, PHY_NOT_DISABLED\n")); 1741 } 1742 else 1743 { 1744 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_START_STATUS, OTHER_FAILURE %d\n", PhyStatus)); 1745 } 1746 break; 1747 } 1748 case OSSA_HW_EVENT_PHY_STOP_STATUS: 1749 { 1750 agsaContext_t *agContext; 1751 PhyID = TD_GET_PHY_ID(eventParm1); 1752 PhyStatus = TD_GET_PHY_STATUS(eventParm1); 1753 PortState = TD_GET_PORT_STATE(eventParm1); 1754 1755 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS\n")); 1756 if (PhyStatus == 0x00) 1757 { 1758 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS, SUCCESS\n")); 1759 agContext = (agsaContext_t *)eventParm2; 1760 onePortContext = (tdsaPortContext_t *)agContext->osData;; 1761 if (onePortContext == agNULL) 1762 { 1763 TI_DBG1(("ossaHwCB: onePortContext is null, wrong!!!\n")); 1764 return; 1765 } 1766 onePortContext->PhyIDList[PhyID] = agFALSE; 1767 if (PortState == OSSA_PORT_INVALID) /* invalid port */ 1768 { 1769 TI_DBG1(("ossaHwCB: OSSA_PORT_INVALID\n")); 1770 tdsaAllShared->eventSource[PhyID].EventValid = NO_ACK; 1771 onePortContext->eventPhyID = PhyID; 1772 onePortContext->valid = agFALSE; 1773 1774 TI_DBG2(("ossaHwCB: pid %d\n", onePortContext->id)); 1775 #ifdef INITIATOR_DRIVER 1776 /* notifying link down (all links belonging to a port are down) */ 1777 ostiPortEvent( 1778 tiRoot, 1779 tiPortStopped, 1780 tiSuccess, 1781 (void *)onePortContext->tiPortalContext 1782 ); 1783 #endif 1784 1785 #ifdef TARGET_DRIVER 1786 ostiPortEvent( 1787 tiRoot, 1788 tiPortLinkDown, 1789 tiSuccess, 1790 (void *)onePortContext->tiPortalContext 1791 ); 1792 1793 #endif 1794 1795 #ifdef INITIATOR_DRIVER 1796 tdssReportRemovals(agRoot, 1797 onePortContext, 1798 agFALSE 1799 ); 1800 #endif 1801 #ifdef TARGET_DRIVER 1802 ttdssReportRemovals(agRoot, 1803 onePortContext, 1804 agFALSE 1805 ); 1806 1807 #endif 1808 1809 /* find a PhyID and reset for portContext in tdssSASShared */ 1810 for(i=0;i<TD_MAX_NUM_PHYS;i++) 1811 { 1812 if (onePortContext->PhyIDList[i] == agTRUE) 1813 { 1814 tdsaAllShared->Ports[i].portContext = agNULL; 1815 } 1816 } 1817 /* portcontext is removed from MainLink to FreeLink in tdssReportRemovals or 1818 ossaDeregisterDeviceHandleCB 1819 */ 1820 } /* invalid port */ 1821 } 1822 else if (PhyStatus == 0x01) 1823 { 1824 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS, INVALID_PHY\n")); 1825 } 1826 else if (PhyStatus == 0x02) 1827 { 1828 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS, DEVICES_ATTACHED\n")); 1829 } 1830 else if (PhyStatus == 0x03) 1831 { 1832 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS, OTHER_FAILURE\n")); 1833 } 1834 else if (PhyStatus == 0x04) 1835 { 1836 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS, PHY_NOT_DISABLED\n")); 1837 } 1838 else 1839 { 1840 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_STOP_STATUS, Unknown %d\n", PhyStatus)); 1841 } 1842 break; 1843 } 1844 1845 case OSSA_HW_EVENT_RESET_START: 1846 { 1847 bit32 new_status = TD_GET_RESET_STATUS(eventParm1); 1848 TI_DBG2(("ossaHwCB: RESET_START, status %d\n", new_status)); 1849 if (new_status == OSSA_SUCCESS) 1850 { 1851 tdsaAllShared->flags.resetInProgress = agTRUE; 1852 TI_DBG2(("ossaHwCB: RESET_START, SUCCESS\n")); 1853 } 1854 else if (new_status == OSSA_FAILURE) 1855 { 1856 TI_DBG1(("ossaHwCB: RESET_START, FAILURE\n")); 1857 } 1858 else 1859 { 1860 TI_DBG1(("ossaHwCB: RESET_START, PENDING\n")); 1861 } 1862 break; 1863 } 1864 1865 case OSSA_HW_EVENT_RESET_COMPLETE: 1866 { 1867 bit32 new_status = TD_GET_RESET_STATUS(eventParm1); 1868 #ifdef SOFT_RESET_TEST 1869 DbgPrint("Reset Complete\n"); 1870 #endif 1871 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_RESET_COMPLETE, status %d\n", new_status)); 1872 if (new_status == OSSA_SUCCESS) 1873 { 1874 /* remove all portcontext and devices */ 1875 #ifdef INITIATOR_DRIVER 1876 tdssRemoveSASSATAFromSharedcontextByReset(agRoot); 1877 #endif 1878 tdsaAllShared->flags.resetInProgress = agFALSE; 1879 /* 1880 a callback notifying reset completion 1881 */ 1882 ostiPortEvent( 1883 tiRoot, 1884 tiPortResetComplete, 1885 tiSuccess, 1886 agNULL 1887 ); 1888 } 1889 else 1890 { 1891 /* 1892 a callback notifying reset completion 1893 */ 1894 tdsaAllShared->flags.resetInProgress = agFALSE; 1895 ostiPortEvent( 1896 tiRoot, 1897 tiPortResetComplete, 1898 tiError, 1899 agNULL 1900 ); 1901 1902 } 1903 break; 1904 } 1905 1906 case OSSA_HW_EVENT_PHY_ERR_INBOUND_CRC: 1907 { 1908 PhyID = TD_GET_PHY_ID(eventParm1); 1909 PortState = TD_GET_PORT_STATE(eventParm1); 1910 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 1911 1912 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_INBOUND_CRC from PhyID %d; to be tested\n", PhyID)); 1913 1914 if (PortState == OSSA_PORT_INVALID) 1915 { 1916 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_PHY_ERR_INBOUND_CRC\n")); 1917 smTraceFuncExit(hpDBG_VERY_LOUD, 'n', "Y2"); 1918 return; 1919 } 1920 1921 if (agPhyErrCountersPage != agNULL) 1922 { 1923 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_INBOUND_CRC from PhyID %d\n", PhyID)); 1924 TI_DBG1(("ossaHwCB: iDw %d rDE %d cV %d lS %d rP %d iCRC %d\n", 1925 agPhyErrCountersPage->invalidDword, 1926 agPhyErrCountersPage->runningDisparityError, 1927 agPhyErrCountersPage->codeViolation, 1928 agPhyErrCountersPage->lossOfDwordSynch, 1929 agPhyErrCountersPage->phyResetProblem, 1930 agPhyErrCountersPage->inboundCRCError )); 1931 } 1932 else 1933 { 1934 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_INBOUND_CRC: Error!!! eventParm2 is NULL\n")); 1935 } 1936 1937 /* saHwEventAck() */ 1938 eventSource.agPortContext = agPortContext; 1939 eventSource.event = OSSA_HW_EVENT_PHY_ERR_INBOUND_CRC; 1940 /* phy ID */ 1941 eventSource.param = PhyID; 1942 HwAckSatus = saHwEventAck( 1943 agRoot, 1944 agNULL, /* agContext */ 1945 0, 1946 &eventSource, /* agsaEventSource_t */ 1947 0, 1948 0 1949 ); 1950 if ( HwAckSatus != AGSA_RC_SUCCESS) 1951 { 1952 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 1953 smTraceFuncExit(hpDBG_VERY_LOUD, 'o', "Y2"); 1954 return; 1955 } 1956 break; 1957 } 1958 #ifdef REMOVED 1959 case OSSA_HW_EVENT_PORT_INVALID: 1960 { 1961 TI_DBG1(("ossaHwCB: PORT_INVALID\n")); 1962 1963 if ( agPortContext == agNULL) 1964 { 1965 TI_DBG1(("ossaHwCB: agPortContext is NULL, wrong.\n")); 1966 smTraceFuncExit(hpDBG_VERY_LOUD, 'p', "Y2"); 1967 return; 1968 } 1969 if ( agPortContext->osData != agNULL) 1970 { 1971 TI_DBG1(("ossaHwCB: NOT NULL osDATA\n")); 1972 /* 1973 put the old portcontext back to free list 1974 */ 1975 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 1976 TI_DBG1(("ossaHwCB: pid %d\n", onePortContext->id)); 1977 1978 #ifdef INITIATOR_DRIVER 1979 /* notifying link down (all links belonging to a port are down) */ 1980 ostiPortEvent ( 1981 tiRoot, 1982 tiPortStopped, 1983 tiSuccess, 1984 (void *)onePortContext->tiPortalContext 1985 1986 ); 1987 #endif /* INITIATOR_DRIVER */ 1988 #ifdef TARGET_DRIVER 1989 ostiPortEvent( 1990 tiRoot, 1991 tiPortLinkDown, 1992 tiSuccess, 1993 (void *)onePortContext->tiPortalContext 1994 ); 1995 1996 #endif /*TARGET_DRIVER */ 1997 1998 /* find the device belonging to the port and remove it from the device list */ 1999 //tdssRemoveSASSATAFromSharedcontext(agRoot, tdsaDeviceData, onePortContext); 2000 2001 2002 #ifdef INITIATOR_DRIVER 2003 /* reset the fields of portcontext */ 2004 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED; 2005 tdssReportRemovals(agRoot, 2006 onePortContext, 2007 agFALSE 2008 ); 2009 2010 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START; 2011 onePortContext->DiscoveryRdyGiven = agFALSE; 2012 onePortContext->SeenLinkUp = agFALSE; 2013 2014 #endif /* INITIATOR_DRIVER */ 2015 2016 2017 2018 /* for hotplug */ 2019 2020 /* find a PhyID and reset for portContext in tdssSASShared */ 2021 for(i=0;i<TD_MAX_NUM_PHYS;i++) 2022 { 2023 if (onePortContext->PhyIDList[i] == agTRUE) 2024 { 2025 tdsaAllShared->Ports[i].portContext = agNULL; 2026 } 2027 } 2028 2029 /* reset PhyIDList in portcontext */ 2030 for(i=0;i<TD_MAX_NUM_PHYS;i++) 2031 { 2032 onePortContext->PhyIDList[i] = agFALSE; 2033 } 2034 2035 // onePortContext->tiPortalContext = agNULL; 2036 // onePortContext->agRoot = agNULL; 2037 onePortContext->agPortContext = agNULL; 2038 onePortContext->valid = agFALSE; 2039 2040 TI_DBG4(("ossaHwCB: pid %d count %d\n", onePortContext->id, onePortContext->Count)); 2041 2042 /* resets the number of devices in onePortContext */ 2043 onePortContext->Count = 0; 2044 onePortContext->discovery.pendingSMP = 0; 2045 onePortContext->discovery.SeenBC = agFALSE; 2046 2047 2048 /* 2049 put all devices belonging to the onePortContext 2050 back to the free link 2051 */ 2052 2053 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 2054 TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink)); 2055 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaPortContext->FreeLink)); 2056 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 2057 } 2058 else 2059 { 2060 TI_DBG1(("ossaHwCB: NULL osDATA: wrong\n")); 2061 } 2062 TI_DBG6(("ossaHwCB: PORT_INVALID end\n")); 2063 break; 2064 } 2065 #endif /* REMOVED */ 2066 2067 case OSSA_HW_EVENT_BROADCAST_CHANGE: 2068 { 2069 PhyID = TD_GET_PHY_ID(eventParm1); 2070 PortState = TD_GET_PORT_STATE(eventParm1); 2071 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE from PhyID %d\n", PhyID)); 2072 2073 if (PortState == OSSA_PORT_INVALID) 2074 { 2075 TI_DBG1(("ossaHwCB: Wrong port state with BROADCAST_CHANGE\n")); 2076 smTraceFuncExit(hpDBG_VERY_LOUD, 'q', "Y2"); 2077 return; 2078 } 2079 /* saHwEventAck() */ 2080 eventSource.agPortContext = agPortContext; 2081 eventSource.event = OSSA_HW_EVENT_BROADCAST_CHANGE; 2082 /* phy ID */ 2083 eventSource.param = PhyID; 2084 HwAckSatus = saHwEventAck( 2085 agRoot, 2086 agNULL, /* agContext */ 2087 0, 2088 &eventSource, /* agsaEventSource_t */ 2089 0, 2090 0 2091 ); 2092 TI_DBG4(("ossaHwCB: calling saHwEventAck\n")); 2093 2094 if ( HwAckSatus != AGSA_RC_SUCCESS) 2095 { 2096 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 2097 smTraceFuncExit(hpDBG_VERY_LOUD, 'r', "Y2"); 2098 return; 2099 } 2100 if (tIsSPC12SATA(agRoot)) 2101 { 2102 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE received for SATA Controller\n")); 2103 break; 2104 } 2105 /* 2106 * incremental discovery is to be tested and debugged further 2107 */ 2108 2109 /* just for testing discovery abort */ 2110 #ifdef FDS_DM_NO 2111 if (agPortContext == agNULL) 2112 { 2113 /* this case happens when broadcase is received first before the link up */ 2114 TI_DBG2(("ossaHwCB: agPortContext is NULL. Do nothing.\n")); 2115 } 2116 else if ( agPortContext->osData != agNULL) 2117 { 2118 dmRoot = &(tdsaAllShared->dmRoot); 2119 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2120 dmPortContext = &(onePortContext->dmPortContext); 2121 2122 dmQueryDiscovery(dmRoot, dmPortContext); 2123 // dmDiscover(dmRoot, dmPortContext, DM_DISCOVERY_OPTION_ABORT); 2124 2125 #if 1 2126 if (onePortContext->DMDiscoveryState == dmDiscInProgress) 2127 { 2128 dmDiscover(dmRoot, dmPortContext, DM_DISCOVERY_OPTION_ABORT); 2129 } 2130 #endif /* 1 */ 2131 2132 TI_DBG2(("ossaHwCB: portcontext pid %d\n", onePortContext->id)); 2133 if (onePortContext->DMDiscoveryState == dmDiscCompleted || 2134 onePortContext->DMDiscoveryState == dmDiscAborted || 2135 onePortContext->DMDiscoveryState == dmDiscAbortInvalid ) 2136 { 2137 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE; calling dmNotifyBC and does incremental discovery\n")); 2138 dmNotifyBC(dmRoot, dmPortContext, OSSA_HW_EVENT_BROADCAST_CHANGE); 2139 dmDiscover(dmRoot, dmPortContext, DM_DISCOVERY_OPTION_INCREMENTAL_START); 2140 2141 } 2142 else 2143 { 2144 TI_DBG2(("ossaHwCB: pid %d BROADCAST_CHANGE; updating SeenBC. calling dmNotifyBC\n", onePortContext->id)); 2145 dmNotifyBC(dmRoot, dmPortContext, OSSA_HW_EVENT_BROADCAST_CHANGE); 2146 } 2147 } 2148 else 2149 { 2150 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE NULL osDATA wrong !!! \n")); 2151 } 2152 2153 2154 #endif /* FDS_DM_NO */ 2155 2156 #ifdef FDS_DM 2157 if (agPortContext == agNULL) 2158 { 2159 /* this case happens when broadcase is received first before the link up */ 2160 TI_DBG2(("ossaHwCB: agPortContext is NULL. Do nothing.\n")); 2161 } 2162 else if ( agPortContext->osData != agNULL) 2163 { 2164 dmRoot = &(tdsaAllShared->dmRoot); 2165 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2166 dmPortContext = &(onePortContext->dmPortContext); 2167 2168 dmQueryDiscovery(dmRoot, dmPortContext); 2169 2170 TI_DBG2(("ossaHwCB: portcontext pid %d\n", onePortContext->id)); 2171 if (onePortContext->DMDiscoveryState == dmDiscCompleted || 2172 onePortContext->DMDiscoveryState == dmDiscAborted || 2173 onePortContext->DMDiscoveryState == dmDiscAbortInvalid ) 2174 { 2175 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE; calling dmNotifyBC and does incremental discovery, pid %d\n", onePortContext->id)); 2176 onePortContext->DiscoveryState = ITD_DSTATE_STARTED; 2177 dmNotifyBC(dmRoot, dmPortContext, OSSA_HW_EVENT_BROADCAST_CHANGE); 2178 dmDiscover(dmRoot, dmPortContext, DM_DISCOVERY_OPTION_INCREMENTAL_START); 2179 2180 } 2181 else if (onePortContext->DMDiscoveryState == dmDiscFailed ) 2182 { 2183 TI_DBG1(("ossaHwCB: dmDiscFailed; pid %d BROADCAST_CHANGE; updating SeenBC. calling dmNotifyBC\n", onePortContext->id)); 2184 onePortContext->DiscFailNSeenBC = agTRUE; 2185 dmNotifyBC(dmRoot, dmPortContext, OSSA_HW_EVENT_BROADCAST_CHANGE); 2186 } 2187 else 2188 { 2189 TI_DBG2(("ossaHwCB: pid %d BROADCAST_CHANGE; updating SeenBC. calling dmNotifyBC\n", onePortContext->id)); 2190 dmNotifyBC(dmRoot, dmPortContext, OSSA_HW_EVENT_BROADCAST_CHANGE); 2191 } 2192 } 2193 else 2194 { 2195 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE NULL osDATA wrong !!! \n")); 2196 } 2197 #endif /* FDS_DM */ 2198 2199 #ifdef FDS_DM_WORKED 2200 if (agPortContext == agNULL) 2201 { 2202 /* this case happens when broadcase is received first before the link up */ 2203 TI_DBG2(("ossaHwCB: agPortContext is NULL. Do nothing.\n")); 2204 } 2205 else if ( agPortContext->osData != agNULL) 2206 { 2207 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2208 TI_DBG2(("ossaHwCB: calling dmNotifyBC\n")); 2209 dmRoot = &(tdsaAllShared->dmRoot); 2210 dmPortContext = &(onePortContext->dmPortContext); 2211 dmNotifyBC(dmRoot, dmPortContext, OSSA_HW_EVENT_BROADCAST_CHANGE); 2212 } 2213 #endif /* FDS_DM_WORKED */ 2214 2215 #ifndef FDS_DM 2216 #ifdef INITIATOR_DRIVER 2217 if (agPortContext == agNULL) 2218 { 2219 /* this case happens when broadcase is received first before the link up */ 2220 TI_DBG2(("ossaHwCB: agPortContext is NULL. Do nothing.\n")); 2221 } 2222 else if ( agPortContext->osData != agNULL) 2223 { 2224 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2225 TI_DBG2(("ossaHwCB: portcontext pid %d\n", onePortContext->id)); 2226 if (onePortContext->DiscoveryState == ITD_DSTATE_COMPLETED) 2227 { 2228 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE; does incremental discovery\n")); 2229 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED; 2230 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_INCREMENTAL_START; 2231 /* processed broadcast change */ 2232 onePortContext->discovery.SeenBC = agFALSE; 2233 #ifdef TD_DISCOVER 2234 if (tdsaAllShared->ResetInDiscovery != 0 && 2235 onePortContext->discovery.ResetTriggerred == agTRUE) 2236 { 2237 TI_DBG2(("ossaHwCB: tdsaBCTimer\n")); 2238 tdsaBCTimer(tiRoot, onePortContext); 2239 } 2240 else 2241 { 2242 tdsaDiscover( 2243 tiRoot, 2244 onePortContext, 2245 TDSA_DISCOVERY_TYPE_SAS, 2246 TDSA_DISCOVERY_OPTION_INCREMENTAL_START 2247 ); 2248 } 2249 #else 2250 saDiscover(agRoot, 2251 agPortContext, 2252 AG_SA_DISCOVERY_TYPE_SAS, 2253 onePortContext->discoveryOptions); 2254 #endif 2255 } 2256 else 2257 { 2258 TI_DBG2(("ossaHwCB: pid %d BROADCAST_CHANGE; updating SeenBC. Do nothing.\n", onePortContext->id)); 2259 onePortContext->discovery.SeenBC = agTRUE; 2260 } 2261 } 2262 else 2263 { 2264 TI_DBG1(("ossaHwCB: BROADCAST_CHANGE NULL osDATA wrong !!! \n")); 2265 } 2266 #endif 2267 #endif /* ifndef FDS_DM */ 2268 2269 break; 2270 } 2271 2272 case OSSA_HW_EVENT_PORT_RECOVERY_TIMER_TMO: 2273 { 2274 PhyID = TD_GET_PHY_ID(eventParm1); 2275 PortState = TD_GET_PORT_STATE(eventParm1); 2276 2277 /* 2278 1. tear town the portcontext just like link down last phy down 2279 2. ack 2280 port state must be invalid 2281 */ 2282 2283 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PORT_RECOVERY_TIMER_TMO\n")); 2284 2285 if (PortState == OSSA_PORT_VALID) 2286 { 2287 TI_DBG1(("ossaHwCB: Wrong port state\n")); 2288 smTraceFuncExit(hpDBG_VERY_LOUD, 's', "Y2"); 2289 return; 2290 } 2291 2292 TD_ASSERT(agPortContext, "agPortContext"); 2293 if ( agPortContext->osData == agNULL) 2294 { /* if */ 2295 /* PortContext must exit at this point */ 2296 TI_DBG1(("ossaHwCB: NULL portalcontext. Error. Can't be NULL\n")); 2297 } 2298 else 2299 { 2300 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2301 onePortContext->valid = agFALSE; 2302 2303 TI_DBG1(("ossaHwCB: tiPortStopped pid %d\n", onePortContext->id)); 2304 #ifdef INITIATOR_DRIVER 2305 /* notifying link down (all links belonging to a port are down) */ 2306 ostiPortEvent( 2307 tiRoot, 2308 tiPortStopped, 2309 tiSuccess, 2310 (void *)onePortContext->tiPortalContext 2311 ); 2312 #endif 2313 2314 #ifdef TARGET_DRIVER 2315 ostiPortEvent( 2316 tiRoot, 2317 tiPortLinkDown, 2318 tiSuccess, 2319 (void *)onePortContext->tiPortalContext 2320 ); 2321 2322 #endif 2323 2324 #ifdef INITIATOR_DRIVER 2325 tdssReportRemovals(agRoot, 2326 onePortContext, 2327 agFALSE 2328 ); 2329 #endif 2330 #ifdef TARGET_DRIVER 2331 ttdssReportRemovals(agRoot, 2332 onePortContext, 2333 agFALSE 2334 ); 2335 2336 #endif 2337 /* find a PhyID and reset for portContext in tdssSASShared */ 2338 for(i=0;i<TD_MAX_NUM_PHYS;i++) 2339 { 2340 if (onePortContext->PhyIDList[i] == agTRUE) 2341 { 2342 tdsaAllShared->Ports[i].portContext = agNULL; 2343 } 2344 } 2345 /* portcontext is removed from MainLink to FreeLink in tdssReportRemovals or 2346 ossaDeregisterDeviceHandleCB 2347 */ 2348 } 2349 2350 break; 2351 } 2352 2353 case OSSA_HW_EVENT_PORT_RESET_TIMER_TMO: 2354 { 2355 /* 2356 clean up 2357 */ 2358 PhyID = TD_GET_PHY_ID(eventParm1); 2359 PortState = TD_GET_PORT_STATE(eventParm1); 2360 2361 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PORT_RESET_TIMER_TMO\n")); 2362 2363 if (PortState == OSSA_PORT_VALID) 2364 { 2365 TI_DBG1(("ossaHwCB: Wrong port state\n")); 2366 smTraceFuncExit(hpDBG_VERY_LOUD, 't', "Y2"); 2367 return; 2368 } 2369 2370 if (agPortContext == agNULL) 2371 { 2372 TI_DBG1(("ossaHwCB: agPortContext is NULL, error\n")); 2373 smTraceFuncExit(hpDBG_VERY_LOUD, 'u', "Y2"); 2374 return; 2375 } 2376 2377 if ( agPortContext->osData == agNULL) 2378 { /* if */ 2379 /* PortContext must exit at this point */ 2380 TI_DBG1(("ossaHwCB: NULL portalcontext. Error. Can't be NULL\n")); 2381 } 2382 else 2383 { 2384 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2385 onePortContext->valid = agFALSE; 2386 2387 TI_DBG1(("ossaHwCB: pid %d tiPortStopped\n", onePortContext->id)); 2388 2389 #ifdef INITIATOR_DRIVER 2390 /* notifying link down (all links belonging to a port are down) */ 2391 ostiPortEvent( 2392 tiRoot, 2393 tiPortStopped, 2394 tiSuccess, 2395 (void *)onePortContext->tiPortalContext 2396 ); 2397 #endif 2398 2399 #ifdef TARGET_DRIVER 2400 ostiPortEvent( 2401 tiRoot, 2402 tiPortLinkDown, 2403 tiSuccess, 2404 (void *)onePortContext->tiPortalContext 2405 ); 2406 2407 #endif 2408 2409 #ifdef INITIATOR_DRIVER 2410 tdssReportRemovals(agRoot, 2411 onePortContext, 2412 agFALSE 2413 ); 2414 #endif 2415 #ifdef TARGET_DRIVER 2416 ttdssReportRemovals(agRoot, 2417 onePortContext, 2418 agFALSE 2419 ); 2420 2421 #endif 2422 /* find a PhyID and reset for portContext in tdssSASShared */ 2423 for(i=0;i<TD_MAX_NUM_PHYS;i++) 2424 { 2425 if (onePortContext->PhyIDList[i] == agTRUE) 2426 { 2427 tdsaAllShared->Ports[i].portContext = agNULL; 2428 } 2429 } 2430 /* portcontext is removed from MainLink to FreeLink in tdssReportRemovals or 2431 ossaDeregisterDeviceHandleCB 2432 */ 2433 } 2434 2435 break; 2436 } 2437 2438 case OSSA_HW_EVENT_PORT_RESET_COMPLETE: 2439 { 2440 #ifdef INITIATOR_DRIVER 2441 tiIORequest_t *currentTaskTag = agNULL; 2442 #endif 2443 2444 #ifdef REMOVED 2445 smRoot_t *smRoot = &(tdsaAllShared->smRoot); 2446 #endif 2447 2448 PhyID = TD_GET_PHY_ID(eventParm1); 2449 PortState = TD_GET_PORT_STATE(eventParm1); 2450 IDframe = (agsaSASIdentify_t *)eventParm3; 2451 2452 /* completes for Lun Reset and Target reset for directly attached SATA */ 2453 /* completes for Target reset for directly attached SAS */ 2454 2455 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PORT_RESET_COMPLETE, phyID %d\n", PhyID)); 2456 2457 /* error check */ 2458 if (PortState == OSSA_PORT_INVALID) 2459 { 2460 TI_DBG1(("ossaHwCB: Wrong port state\n")); 2461 smTraceFuncExit(hpDBG_VERY_LOUD, 'v', "Y2"); 2462 return; 2463 } 2464 2465 if (agPortContext == agNULL) 2466 { 2467 TI_DBG1(("ossaHwCB: agPortContext null, wrong\n")); 2468 smTraceFuncExit(hpDBG_VERY_LOUD, 'w', "Y2"); 2469 return; 2470 } 2471 if ( agPortContext->osData == agNULL) 2472 { 2473 TI_DBG1(("ossaHwCB: agPortContext->osData null, wrong\n")); 2474 smTraceFuncExit(hpDBG_VERY_LOUD, 'x', "Y2"); 2475 return; 2476 } 2477 2478 /* find a corresponding portcontext */ 2479 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2480 2481 if (onePortContext == agNULL) 2482 { 2483 TI_DBG1(("ossaHwCB: oneportContext is NULL; wrong??????\n")); 2484 } 2485 else 2486 { 2487 TI_DBG1(("ossaHwCB: oneportContext %p pid %d\n", onePortContext, onePortContext->id)); 2488 onePortContext->valid = agTRUE; 2489 #ifdef INITIATOR_DRIVER 2490 #ifdef REMOVED 2491 if (tdsaAllShared->ResetInDiscovery != 0) 2492 { 2493 DeviceListList = tdsaAllShared->MainDeviceList.flink; 2494 while (DeviceListList != &(tdsaAllShared->MainDeviceList)) 2495 { 2496 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList); 2497 if (oneDeviceData->tdPortContext != onePortContext) 2498 { 2499 DeviceListList = DeviceListList->flink; 2500 } 2501 else 2502 { 2503 found = agTRUE; 2504 break; 2505 } 2506 } /* while */ 2507 if (found == agTRUE) 2508 { 2509 /* applied to only SATA devices */ 2510 if (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 2511 { 2512 #ifdef FDS_SM 2513 tdIDStart(tiRoot, agRoot, smRoot, oneDeviceData, onePortContext); 2514 #else 2515 tdssRetrySATAID(tiRoot, oneDeviceData); 2516 #endif 2517 } 2518 } 2519 else 2520 { 2521 TI_DBG1(("ossaHwCB: no onedevicedata found!\n")); 2522 } 2523 } 2524 #endif 2525 /* completed TM */ 2526 DeviceListList = tdsaAllShared->MainDeviceList.flink; 2527 while (DeviceListList != &(tdsaAllShared->MainDeviceList)) 2528 { 2529 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList); 2530 if ( oneDeviceData == agNULL) 2531 { 2532 TI_DBG1(("ossaHwCB: oneDeviceData is NULL!!!\n")); 2533 return; 2534 } 2535 2536 if ( (oneDeviceData->tdPortContext == onePortContext) && 2537 (oneDeviceData->directlyAttached == agTRUE) && 2538 (oneDeviceData->phyID == PhyID) ) 2539 { 2540 TI_DBG1(("ossaHwCB: found the onePortContext and oneDeviceData!!\n")); 2541 2542 currentTaskTag = (tiIORequest_t *)oneDeviceData->agDeviceResetContext.osData; 2543 if (currentTaskTag != agNULL ) 2544 { 2545 /* applied to only SATA devices */ 2546 if (DEVICE_IS_SATA_DEVICE(oneDeviceData)) 2547 { 2548 tdIORequestBody_t *SMTMtdIORequestBody = agNULL; 2549 SMTMtdIORequestBody = (tdIORequestBody_t *)currentTaskTag->tdData; 2550 if (SMTMtdIORequestBody != agNULL) 2551 { 2552 /* free the SMTMtdIORequestBody memory allocated in tiINITaskManagement function */ 2553 ostiFreeMemory( 2554 tiRoot, 2555 SMTMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle, 2556 sizeof(tdIORequestBody_t) 2557 ); 2558 } 2559 else 2560 { 2561 TI_DBG1(("ossaHwCB: SATA device but SMTMtdIORequestBody is NULL!!!\n")); 2562 } 2563 } 2564 /* set device state to DS_OPERATIONAL */ 2565 saSetDeviceState(agRoot, 2566 agNULL, 2567 tdsaRotateQnumber(tiRoot, oneDeviceData), 2568 oneDeviceData->agDevHandle, 2569 SA_DS_OPERATIONAL 2570 ); 2571 /* notify OS layer to complete the TMF IO */ 2572 ostiInitiatorEvent(tiRoot, 2573 agNULL, 2574 agNULL, 2575 tiIntrEventTypeTaskManagement, 2576 tiTMOK, 2577 currentTaskTag 2578 ); 2579 2580 } 2581 else 2582 { 2583 TI_DBG1(("ossaHwCB: currentTaskTag is NULL!!!\n")); 2584 } 2585 2586 break; 2587 } 2588 else 2589 { 2590 DeviceListList = DeviceListList->flink; 2591 } 2592 } 2593 #endif 2594 } 2595 break; 2596 } 2597 case OSSA_HW_EVENT_BROADCAST_ASYNCH_EVENT: 2598 { 2599 PhyID = TD_GET_PHY_ID(eventParm1); 2600 PortState = TD_GET_PORT_STATE(eventParm1); 2601 2602 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_BROADCAST_ASYNCH_EVENT\n")); 2603 if (tIsSPC12SATA(agRoot)) 2604 { 2605 TI_DBG1(("ossaHwCB: BROADCAST_ASYNCH_EVENT received for SATA Controller\n")); 2606 break; 2607 } 2608 if (agPortContext == agNULL) 2609 { 2610 TI_DBG1(("ossaHwCB: Error!!! agPortContext is NULL %d\n", PhyID)); 2611 smTraceFuncExit(hpDBG_VERY_LOUD, 'y', "Y2"); 2612 return; 2613 } 2614 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2615 if (onePortContext == agNULL) 2616 { 2617 TI_DBG1(("ossaHwCB: Error!!! onePortContext is NULL %d\n", PhyID)); 2618 smTraceFuncExit(hpDBG_VERY_LOUD, 'z', "Y2"); 2619 return; 2620 } 2621 2622 if (onePortContext->tiPortalContext != agNULL) 2623 { 2624 #if 0 2625 ostiInitiatorEvent( 2626 tiRoot, 2627 onePortContext->tiPortalContext, 2628 agNULL, 2629 tiIntrEventTypeDeviceChange, 2630 OSSA_HW_EVENT_BROADCAST_ASYNCH_EVENT, 2631 agNULL 2632 ); 2633 #endif 2634 } 2635 else 2636 { 2637 TI_DBG1(("ossaHwCB: Error!!! onePortContext->tiPortalContext is NULL\n")); 2638 smTraceFuncExit(hpDBG_VERY_LOUD, 'A', "Y2"); 2639 return; 2640 } 2641 2642 break; 2643 } 2644 2645 case OSSA_HW_EVENT_PORT_RECOVER: 2646 { 2647 2648 PhyID = TD_GET_PHY_ID(eventParm1); 2649 if (agPortContext == agNULL) 2650 { 2651 TI_DBG1(("ossaHwCB: Error!!! agPortContext is NULL %d\n", PhyID)); 2652 smTraceFuncExit(hpDBG_VERY_LOUD, 'B', "Y2"); 2653 return; 2654 } 2655 2656 LinkRate = TD_GET_LINK_RATE(eventParm1); 2657 PortState = TD_GET_PORT_STATE(eventParm1); 2658 agDevHandle = agNULL; 2659 IDframe = (agsaSASIdentify_t *)eventParm3; 2660 2661 /* 2662 1. this is like link up 2663 2. handle the phyID 2664 3. no trigger discovery (broadcast change will do this later) 2665 port state must be valid 2666 */ 2667 2668 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PORT_RECOVER, phyID %d\n", PhyID)); 2669 2670 if (PortState == OSSA_PORT_INVALID) 2671 { 2672 TI_DBG1(("ossaHwCB: Wrong port state\n")); 2673 smTraceFuncExit(hpDBG_VERY_LOUD, 'C', "Y2"); 2674 return; 2675 } 2676 if ( agPortContext->osData == agNULL) 2677 { /* if */ 2678 /* PortContext must exit at this point */ 2679 TI_DBG1(("ossaHwCB: NULL portalcontext. Error. Can't be NULL\n")); 2680 } 2681 else 2682 { 2683 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 2684 TI_DBG2(("ossaHwCB: pid %d\n", onePortContext->id)); 2685 onePortContext->PhyIDList[PhyID] = agTRUE; 2686 onePortContext->valid = agTRUE; 2687 tdsaAllShared->Ports[PhyID].portContext = onePortContext; 2688 onePortContext->tiPortalContext = tdsaAllShared->Ports[PhyID].tiPortalContext; 2689 onePortContext->PortRecoverPhyID = PhyID; 2690 if (LinkRate == 0x01) 2691 { 2692 onePortContext->LinkRate = SAS_CONNECTION_RATE_1_5G; 2693 } 2694 else if (LinkRate == 0x02) 2695 { 2696 onePortContext->LinkRate = SAS_CONNECTION_RATE_3_0G; 2697 } 2698 else if (LinkRate == 0x04) 2699 { 2700 onePortContext->LinkRate = SAS_CONNECTION_RATE_6_0G; 2701 } 2702 else /* (LinkRate == 0x08) */ 2703 { 2704 onePortContext->LinkRate = SAS_CONNECTION_RATE_12_0G; 2705 } 2706 2707 if (SA_IDFRM_GET_DEVICETTYPE(&onePortContext->sasIDframe) == SAS_END_DEVICE && 2708 SA_IDFRM_IS_SSP_TARGET(&onePortContext->sasIDframe) ) 2709 { 2710 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PORT_RECOVER, sending spinup on phyID %d\n", PhyID)); 2711 for (i=0;i<TD_MAX_NUM_NOTIFY_SPINUP;i++) 2712 { 2713 saLocalPhyControl(agRoot, agNULL, 0, PhyID, AGSA_PHY_NOTIFY_ENABLE_SPINUP, agNULL); 2714 } 2715 } 2716 2717 /* transient period between link up and link down/port recovery */ 2718 if (onePortContext->Transient == agTRUE && onePortContext->RegisteredDevNums == 0) 2719 { 2720 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PORT_RECOVER transient period")); 2721 if (SA_IDFRM_GET_DEVICETTYPE(IDframe) != SAS_NO_DEVICE) 2722 { 2723 #ifdef INITIATOR_DRIVER 2724 agSASSubID.sasAddressHi = SA_IDFRM_GET_SAS_ADDRESSHI(IDframe); 2725 agSASSubID.sasAddressLo = SA_IDFRM_GET_SAS_ADDRESSLO(IDframe); 2726 agSASSubID.initiator_ssp_stp_smp = IDframe->initiator_ssp_stp_smp; 2727 agSASSubID.target_ssp_stp_smp = IDframe->target_ssp_stp_smp; 2728 tdssAddSASToSharedcontext( 2729 onePortContext, 2730 agRoot, 2731 agDevHandle, /* agNULL */ 2732 &agSASSubID, 2733 agTRUE, 2734 (bit8)PhyID, 2735 TD_OPERATION_INITIATOR 2736 ); 2737 #endif 2738 } 2739 onePortContext->Transient = agFALSE; 2740 } 2741 2742 2743 2744 2745 } 2746 break; 2747 } 2748 2749 case OSSA_HW_EVENT_BROADCAST_SES: 2750 { 2751 PhyID = TD_GET_PHY_ID(eventParm1); 2752 PortState = TD_GET_PORT_STATE(eventParm1); 2753 2754 TI_DBG2(("ossaHwCB: BROADCAST_SES from PhyID %d; to be tested\n", PhyID)); 2755 if (tIsSPC12SATA(agRoot)) 2756 { 2757 TI_DBG1(("ossaHwCB: BROADCAST_SES received for SATA Controller\n")); 2758 break; 2759 } 2760 if (PortState == OSSA_PORT_INVALID) 2761 { 2762 TI_DBG1(("ossaHwCB: Wrong port state with BROADCAST_SES\n")); 2763 smTraceFuncExit(hpDBG_VERY_LOUD, 'D', "Y2"); 2764 return; 2765 } 2766 2767 /* 2768 let os layer read payload 2769 */ 2770 break; 2771 } 2772 case OSSA_HW_EVENT_BROADCAST_EXP: 2773 { 2774 PhyID = TD_GET_PHY_ID(eventParm1); 2775 PortState = TD_GET_PORT_STATE(eventParm1); 2776 2777 TI_DBG2(("ossaHwCB: BROADCAST_EXP from PhyID %d; to be tested\n", PhyID)); 2778 if (tIsSPC12SATA(agRoot)) 2779 { 2780 TI_DBG1(("ossaHwCB: BROADCAST_EXP received for SATA Controller\n")); 2781 break; 2782 } 2783 2784 if (PortState == OSSA_PORT_INVALID) 2785 { 2786 TI_DBG1(("ossaHwCB: Wrong port state with BROADCAST_EXP\n")); 2787 smTraceFuncExit(hpDBG_VERY_LOUD, 'E', "Y2"); 2788 return; 2789 } 2790 /* to-do: 2791 let os layer read payload 2792 */ 2793 break; 2794 } 2795 2796 case OSSA_HW_EVENT_HARD_RESET_RECEIVED: 2797 { 2798 PhyID = TD_GET_PHY_ID(eventParm1); 2799 PortState = TD_GET_PORT_STATE(eventParm1); 2800 2801 TI_DBG2(("ossaHwCB: HARD_RESET_RECEIVED from PhyID %d\n", PhyID)); 2802 2803 if (PortState == OSSA_PORT_VALID && tiIS_SPC(agRoot)) 2804 { 2805 TI_DBG1(("ossaHwCB: calling saPortControl and OSSA_PORT_VALID\n")); 2806 saPortControl(agRoot, agNULL, 0, agPortContext, AGSA_PORT_HARD_RESET, 0,0); 2807 } 2808 else if (PortState == OSSA_PORT_3RDPARTY_RESET && (tIsSPCV12or6G(agRoot)) ) 2809 { 2810 TI_DBG1(("ossaHwCB: calling saPortControl and OSSA_PORT_3RDPARTY_RESET\n")); 2811 saPortControl(agRoot, agNULL, 0, agPortContext, AGSA_PORT_HARD_RESET, 0,0); 2812 } 2813 else /* PortState == OSSA_PORT_INVALID */ 2814 { 2815 TI_DBG1(("ossaHwCB: Error. Port state is invalid\n")); 2816 #ifdef REMOVED 2817 TI_DBG1(("ossaHwCB: calling saLocalPhyControl on phyID %d\n", PhyID)); 2818 saLocalPhyControl(agRoot, agNULL, 0, PhyID, AGSA_PHY_LINK_RESET, agNULL); 2819 #endif 2820 } 2821 2822 break; 2823 } 2824 2825 case OSSA_HW_EVENT_MALFUNCTION: 2826 { 2827 #ifdef TD_DEBUG_ENABLE 2828 agsaFatalErrorInfo_t *FatalError = (agsaFatalErrorInfo_t *)eventParm2; 2829 #endif 2830 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_MALFUNCTION \n")); 2831 TI_DBG1(("ossaHwCB: errorInfo0 %8X errorInfo1 %8X\n", FatalError->errorInfo0, FatalError->errorInfo1)); 2832 TI_DBG1(("ossaHwCB: errorInfo2 %8X errorInfo3 %8X\n", FatalError->errorInfo2, FatalError->errorInfo3)); 2833 TI_DBG1(("ossaHwCB: regDumpBusBaseNum0 %8X regDumpOffset0 %8X regDumpLen0 %8X\n", FatalError->regDumpBusBaseNum0, FatalError->regDumpOffset0, FatalError->regDumpLen0)); 2834 TI_DBG1(("ossaHwCB: regDumpBusBaseNum1 %8X regDumpOffset1 %8X regDumpLen1 %8X\n", FatalError->regDumpBusBaseNum1, FatalError->regDumpOffset1, FatalError->regDumpLen1)); 2835 2836 2837 if (eventParm1 == agTRUE) 2838 { 2839 TI_DBG1(("ossaHwCB: fatal error\n")); 2840 /* port panic */ 2841 ostiPortEvent ( 2842 tiRoot, 2843 tiPortPanic, 2844 0, 2845 agNULL 2846 ); 2847 } 2848 else 2849 { 2850 TI_DBG1(("ossaHwCB: non-fatal error \n")); 2851 } 2852 break; 2853 } 2854 2855 case OSSA_HW_EVENT_ID_FRAME_TIMEOUT: 2856 { 2857 PhyID = TD_GET_PHY_ID(eventParm1); 2858 PortState = TD_GET_PORT_STATE(eventParm1); 2859 2860 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_ID_FRAME_TIMEOUT from PhyID %d\n", PhyID)); 2861 2862 if (PortState == OSSA_PORT_INVALID) 2863 { 2864 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_ID_FRAME_TIMEOUT\n")); 2865 smTraceFuncExit(hpDBG_VERY_LOUD, 'F', "Y2"); 2866 return; 2867 } 2868 break; 2869 } 2870 2871 case OSSA_HW_EVENT_PHY_ERR_INVALID_DWORD: 2872 { 2873 PhyID = TD_GET_PHY_ID(eventParm1); 2874 PortState = TD_GET_PORT_STATE(eventParm1); 2875 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 2876 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_INVALID_DWORD\n")); 2877 2878 if (PortState == OSSA_PORT_INVALID) 2879 { 2880 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_PHY_ERR_INVALID_DWORD\n")); 2881 smTraceFuncExit(hpDBG_VERY_LOUD, 'G', "Y2"); 2882 return; 2883 } 2884 2885 if (agPhyErrCountersPage != agNULL) 2886 { 2887 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_INVALID_DWORD from PhyID %d\n", PhyID)); 2888 TI_DBG1(("ossaHwCB: invalidDword %d\n", agPhyErrCountersPage->invalidDword)); 2889 } 2890 else 2891 { 2892 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_INVALID_DWORD: Error!!! eventParm2 is NULL\n")); 2893 } 2894 2895 /* saHwEventAck() */ 2896 eventSource.agPortContext = agPortContext; 2897 eventSource.event = OSSA_HW_EVENT_PHY_ERR_INVALID_DWORD; 2898 /* phy ID */ 2899 eventSource.param = PhyID; 2900 HwAckSatus = saHwEventAck( 2901 agRoot, 2902 agNULL, /* agContext */ 2903 0, 2904 &eventSource, /* agsaEventSource_t */ 2905 0, 2906 0 2907 ); 2908 if ( HwAckSatus != AGSA_RC_SUCCESS) 2909 { 2910 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 2911 smTraceFuncExit(hpDBG_VERY_LOUD, 'H', "Y2"); 2912 return; 2913 } 2914 2915 break; 2916 } 2917 2918 case OSSA_HW_EVENT_PHY_ERR_DISPARITY_ERROR: 2919 { 2920 PhyID = TD_GET_PHY_ID(eventParm1); 2921 PortState = TD_GET_PORT_STATE(eventParm1); 2922 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 2923 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_DISPARITY_ERROR\n")); 2924 2925 if (PortState == OSSA_PORT_INVALID) 2926 { 2927 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_PHY_ERR_DISPARITY_ERROR\n")); 2928 smTraceFuncExit(hpDBG_VERY_LOUD, 'I', "Y2"); 2929 return; 2930 } 2931 2932 if (agPhyErrCountersPage != agNULL) 2933 { 2934 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_DISPARITY_ERROR from PhyID %d\n", PhyID)); 2935 TI_DBG1(("ossaHwCB: runningDisparityError %d\n", agPhyErrCountersPage->runningDisparityError)); 2936 } 2937 else 2938 { 2939 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_DISPARITY_ERROR: Error!!! eventParm2 is NULL\n")); 2940 } 2941 2942 /* saHwEventAck() */ 2943 eventSource.agPortContext = agPortContext; 2944 eventSource.event = OSSA_HW_EVENT_PHY_ERR_DISPARITY_ERROR; 2945 /* phy ID */ 2946 eventSource.param = PhyID; 2947 HwAckSatus = saHwEventAck( 2948 agRoot, 2949 agNULL, /* agContext */ 2950 0, 2951 &eventSource, /* agsaEventSource_t */ 2952 0, 2953 0 2954 ); 2955 if ( HwAckSatus != AGSA_RC_SUCCESS) 2956 { 2957 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 2958 smTraceFuncExit(hpDBG_VERY_LOUD, 'J', "Y2"); 2959 return; 2960 } 2961 2962 break; 2963 } 2964 2965 case OSSA_HW_EVENT_PHY_ERR_CODE_VIOLATION: 2966 { 2967 PhyID = TD_GET_PHY_ID(eventParm1); 2968 PortState = TD_GET_PORT_STATE(eventParm1); 2969 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 2970 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_CODE_VIOLATION\n")); 2971 2972 if (PortState == OSSA_PORT_INVALID) 2973 { 2974 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_PHY_ERR_CODE_VIOLATION\n")); 2975 smTraceFuncExit(hpDBG_VERY_LOUD, 'K', "Y2"); 2976 return; 2977 } 2978 2979 if (agPhyErrCountersPage != agNULL) 2980 { 2981 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_CODE_VIOLATION from PhyID %d\n", PhyID)); 2982 TI_DBG1(("ossaHwCB: codeViolation %d\n", agPhyErrCountersPage->codeViolation)); 2983 } 2984 else 2985 { 2986 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_CODE_VIOLATION: Error!!! eventParm2 is NULL\n")); 2987 } 2988 2989 /* saHwEventAck() */ 2990 eventSource.agPortContext = agPortContext; 2991 eventSource.event = OSSA_HW_EVENT_PHY_ERR_CODE_VIOLATION; 2992 /* phy ID */ 2993 eventSource.param = PhyID; 2994 HwAckSatus = saHwEventAck( 2995 agRoot, 2996 agNULL, /* agContext */ 2997 0, 2998 &eventSource, /* agsaEventSource_t */ 2999 0, 3000 0 3001 ); 3002 if ( HwAckSatus != AGSA_RC_SUCCESS) 3003 { 3004 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 3005 smTraceFuncExit(hpDBG_VERY_LOUD, 'L', "Y2"); 3006 return; 3007 } 3008 3009 break; 3010 } 3011 3012 #ifdef REMOVED 3013 case OSSA_HW_EVENT_LINK_ERR_CODE_VIOLATION1: 3014 { 3015 PhyID = eventParm1 & 0xFF; 3016 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 3017 3018 if (agPhyErrCountersPage != agNULL) 3019 { 3020 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_LINK_ERR_CODE_VIOLATION1 from PhyID %d\n", PhyID)); 3021 TI_DBG1(("ossaHwCB: invalidDword %d\n", agPhyErrCountersPage->invalidDword)); 3022 TI_DBG1(("ossaHwCB: runningDisparityError %d\n", agPhyErrCountersPage->runningDisparityError)); 3023 TI_DBG1(("ossaHwCB: codeViolation %d\n", agPhyErrCountersPage->codeViolation)); 3024 TI_DBG1(("ossaHwCB: lostOfDwordSynch %d\n", agPhyErrCountersPage->lossOfDwordSynch)); 3025 TI_DBG1(("ossaHwCB: phyResetProblem %d\n", agPhyErrCountersPage->phyResetProblem)); 3026 TI_DBG1(("ossaHwCB: inboundCRCError %d\n", agPhyErrCountersPage->inboundCRCError)); 3027 } 3028 else 3029 { 3030 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_LINK_ERR_CODE_VIOLATION1: Error!!! eventParm2 is NULL\n")); 3031 } 3032 break; 3033 } 3034 #endif /* REMOVED */ 3035 3036 case OSSA_HW_EVENT_PHY_ERR_LOSS_OF_DWORD_SYNCH: 3037 { 3038 PhyID = TD_GET_PHY_ID(eventParm1); 3039 PortState = TD_GET_PORT_STATE(eventParm1); 3040 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 3041 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_LOSS_OF_DWORD_SYNCH\n")); 3042 3043 if (PortState == OSSA_PORT_INVALID) 3044 { 3045 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_PHY_ERR_LOSS_OF_DWORD_SYNCH\n")); 3046 smTraceFuncExit(hpDBG_VERY_LOUD, 'M', "Y2"); 3047 return; 3048 } 3049 3050 if (agPhyErrCountersPage != agNULL) 3051 { 3052 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_LOSS_OF_DWORD_SYNCH from PhyID %d\n", PhyID)); 3053 TI_DBG1(("ossaHwCB: lostOfDwordSynch %d\n", agPhyErrCountersPage->lossOfDwordSynch)); 3054 } 3055 else 3056 { 3057 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_LOSS_OF_DWORD_SYNCH: Error!!! eventParm2 is NULL\n")); 3058 } 3059 3060 /* saHwEventAck() */ 3061 eventSource.agPortContext = agPortContext; 3062 eventSource.event = OSSA_HW_EVENT_PHY_ERR_LOSS_OF_DWORD_SYNCH; 3063 /* phy ID */ 3064 eventSource.param = PhyID; 3065 HwAckSatus = saHwEventAck( 3066 agRoot, 3067 agNULL, /* agContext */ 3068 0, 3069 &eventSource, /* agsaEventSource_t */ 3070 0, 3071 0 3072 ); 3073 if ( HwAckSatus != AGSA_RC_SUCCESS) 3074 { 3075 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 3076 smTraceFuncExit(hpDBG_VERY_LOUD, 'N', "Y2"); 3077 return; 3078 } 3079 3080 break; 3081 } 3082 3083 case OSSA_HW_EVENT_PHY_ERR_PHY_RESET_FAILED: 3084 { 3085 PhyID = TD_GET_PHY_ID(eventParm1); 3086 PortState = TD_GET_PORT_STATE(eventParm1); 3087 agPhyErrCountersPage = (agsaPhyErrCountersPage_t *)eventParm2; 3088 3089 TI_DBG2(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_PHY_RESET_FAILED\n")); 3090 3091 if (PortState == OSSA_PORT_INVALID) 3092 { 3093 TI_DBG1(("ossaHwCB: Wrong port state with OSSA_HW_EVENT_PHY_ERR_PHY_RESET_FAILED\n")); 3094 smTraceFuncExit(hpDBG_VERY_LOUD, 'O', "Y2"); 3095 return; 3096 } 3097 3098 if (agPhyErrCountersPage != agNULL) 3099 { 3100 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_PHY_RESET_FAILED from PhyID %d\n", PhyID)); 3101 TI_DBG1(("ossaHwCB: phyResetProblem %d\n", agPhyErrCountersPage->phyResetProblem)); 3102 } 3103 else 3104 { 3105 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_ERR_PHY_RESET_FAILED: Error!!! eventParm2 is NULL\n")); 3106 } 3107 3108 /* saHwEventAck() */ 3109 eventSource.agPortContext = agPortContext; 3110 eventSource.event = OSSA_HW_EVENT_PHY_ERR_PHY_RESET_FAILED; 3111 /* phy ID */ 3112 eventSource.param = PhyID; 3113 HwAckSatus = saHwEventAck( 3114 agRoot, 3115 agNULL, /* agContext */ 3116 0, 3117 &eventSource, /* agsaEventSource_t */ 3118 0, 3119 0 3120 ); 3121 if ( HwAckSatus != AGSA_RC_SUCCESS) 3122 { 3123 TI_DBG1(("ossaHwCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 3124 smTraceFuncExit(hpDBG_VERY_LOUD, 'P', "Y2"); 3125 return; 3126 } 3127 3128 break; 3129 } 3130 3131 // #ifdef INITIATOR_DRIVER 3132 case OSSA_HW_EVENT_ENCRYPTION: 3133 { 3134 pEncryptCBData = (agsaHWEventEncrypt_t *) eventParm2; 3135 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_ENCRYPTION: encryptOperation 0x%x\n",pEncryptCBData->encryptOperation)); 3136 TI_DBG1(("ossaHwCB: event 0x%x eventParm1 0x%x eventParm2 %p eventParm3 %p\n",event,eventParm1,eventParm2,eventParm3)); 3137 3138 /* 3139 * All events and status need to be translated from 3140 * SAS specific values to TISA specific values. This 3141 * is effectively a NOP, but the OS layer won't want to 3142 * look for SAS values. 3143 */ 3144 if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_KEK_UPDATE_AND_STORE) 3145 { 3146 TI_DBG1(("ossaHwCB: OSSA_HW_ENCRYPT_KEK_UPDATE_AND_STORE\n")); 3147 encryptEventData.encryptEvent = tiEncryptKekStore; 3148 } 3149 else if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_KEK_UPDATE) 3150 { 3151 TI_DBG1(("ossaHwCB:OSSA_HW_ENCRYPT_KEK_UPDATE \n")); 3152 encryptEventData.encryptEvent = tiEncryptKekAdd; 3153 } 3154 else if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_KEK_INVALIDTE) 3155 { 3156 TI_DBG1(("ossaHwCB:OSSA_HW_ENCRYPT_KEK_INVALIDTE \n")); 3157 /* none */ 3158 } 3159 else if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_DEK_UPDATE) 3160 { 3161 TI_DBG1(("ossaHwCB: OSSA_HW_ENCRYPT_DEK_UPDATE\n")); 3162 encryptEventData.encryptEvent = tiEncryptDekAdd; 3163 } 3164 else if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_DEK_INVALIDTE) 3165 { 3166 TI_DBG1(("ossaHwCB: OSSA_HW_ENCRYPT_DEK_INVALIDTE\n")); 3167 encryptEventData.encryptEvent = tiEncryptDekInvalidate; 3168 } 3169 else if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_OPERATOR_MANAGEMENT) 3170 { 3171 TI_DBG1(("ossaHwCB: OSSA_HW_ENCRYPT_OPERATOR_MANAGEMENT\n")); 3172 encryptEventData.encryptEvent = tiEncryptOperatorManagement; 3173 } 3174 else if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_TEST_EXECUTE) 3175 { 3176 TI_DBG1(("ossaHwCB: OSSA_HW_ENCRYPT_TEST_EXECUTE\n")); 3177 encryptEventData.encryptEvent = tiEncryptSelfTest; 3178 encryptEventData.subEvent = pEncryptCBData->eq; 3179 } 3180 else 3181 { 3182 TI_DBG1(("ossaHwCB: unknown encryptOperation 0x%x\n",pEncryptCBData->encryptOperation)); 3183 } 3184 3185 if (pEncryptCBData->status != OSSA_SUCCESS) 3186 { 3187 encryptStatus = tiError; 3188 3189 /* prints out status and error qualifier */ 3190 TI_DBG1(("ossaHwCB: encrypt response status 0x%x error qualifier 0x%x\n", pEncryptCBData->status, pEncryptCBData->eq)); 3191 } 3192 else 3193 { 3194 encryptStatus = tiSuccess; 3195 } 3196 3197 if (pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_KEK_UPDATE_AND_STORE || 3198 pEncryptCBData->encryptOperation == OSSA_HW_ENCRYPT_KEK_UPDATE ) 3199 { 3200 /* returning new KEK index */ 3201 encryptEventData.pData = pEncryptCBData->handle; 3202 } 3203 else 3204 { 3205 /* returning current KEK index or DEK index */ 3206 encryptEventData.pData = pEncryptCBData->param; 3207 } 3208 3209 ostiPortEvent(tiRoot, 3210 tiEncryptOperation, 3211 encryptStatus, 3212 &encryptEventData); 3213 break; 3214 } 3215 case OSSA_HW_EVENT_SECURITY_MODE: 3216 { 3217 securitySetModeStatus = eventParm1; 3218 pEncryptInfo = (agsaEncryptInfo_t *) eventParm2; 3219 3220 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_SECURITY_MODE\n")); 3221 if (securitySetModeStatus == OSSA_SUCCESS) 3222 { 3223 securityModeStatus = tiSuccess; 3224 } 3225 else 3226 { 3227 securityModeStatus = tiError; 3228 } 3229 3230 encryptEventData.encryptEvent = tiEncryptSetMode; 3231 /* process status to fill in subevent */ 3232 /* See PM 4.26.12.6 */ 3233 TI_DBG1(("ossaHwCB: pEncryptInfo->status 0x%x\n", pEncryptInfo->status)); 3234 if ( pEncryptInfo->status == OSSA_SUCCESS) 3235 { 3236 encryptEventData.subEvent = tiNVRAMSuccess; 3237 } 3238 else if (pEncryptInfo->status == 0x24) 3239 { 3240 encryptEventData.subEvent = tiNVRAMNotFound; 3241 } 3242 else if (pEncryptInfo->status == 0x05 || pEncryptInfo->status == 0x20 || pEncryptInfo->status == 0x21) 3243 { 3244 encryptEventData.subEvent = tiNVRAMAccessTimeout; 3245 } 3246 else 3247 { 3248 encryptEventData.subEvent = tiNVRAMWriteFail; 3249 } 3250 3251 encryptEventData.pData = agNULL; 3252 ostiPortEvent(tiRoot, 3253 tiEncryptOperation, 3254 securityModeStatus, 3255 &encryptEventData); 3256 3257 break; 3258 } 3259 case OSSA_HW_EVENT_MODE: 3260 { 3261 pModeEvent = (agsaHWEventMode_t *) eventParm2; 3262 pModePage = (bit32 *) pModeEvent->modePage; 3263 3264 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_MODE modePageOperation 0x%x status 0x%x modePageLen 0x%x\n", 3265 pModeEvent->modePageOperation, pModeEvent->status, pModeEvent->modePageLen)); 3266 3267 if (pModeEvent->modePageOperation == agsaModePageSet) 3268 { 3269 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_MODE page code 0x%x error qualifier 0x%x\n", (eventParm1 & 0xFF), (eventParm1 >> 16))); 3270 ostiPortEvent(tiRoot, 3271 tiModePageOperation, 3272 pModeEvent->status, 3273 eventParm2); 3274 } 3275 else if (pModeEvent->modePageOperation == agsaModePageGet) 3276 { 3277 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_MODE error qualifier 0x%x\n", eventParm1)); 3278 switch ((*pModePage) & 0xFF) 3279 { 3280 case AGSA_ENCRYPTION_GENERAL_CONFIG_PAGE: 3281 TI_DBG1(("ossaHwCB: AGSA_ENCRYPTION_GENERAL_CONFIG_PAGE 0x%x %p\n", pModeEvent->status,eventParm2)); 3282 TI_DBG1(("ossaHwCB:modePageOperation 0x%x status 0x%x modePageLen 0x%x modePage %p context %p\n", 3283 pModeEvent->modePageOperation, 3284 pModeEvent->status, 3285 pModeEvent->modePageLen, 3286 pModeEvent->modePage, 3287 pModeEvent->context)); 3288 ostiPortEvent(tiRoot, 3289 tiModePageOperation, 3290 pModeEvent->status, 3291 eventParm2); 3292 break; 3293 case AGSA_ENCRYPTION_DEK_CONFIG_PAGE: 3294 TI_DBG1(("ossaHwCB: AGSA_ENCRYPTION_DEK_CONFIG_PAGE 0x%x %p\n", pModeEvent->status,eventParm2)); 3295 ostiPortEvent(tiRoot, 3296 tiModePageOperation, 3297 pModeEvent->status, 3298 eventParm2); 3299 break; 3300 case AGSA_ENCRYPTION_HMAC_CONFIG_PAGE: 3301 TI_DBG1(("ossaHwCB: AGSA_ENCRYPTION_HMAC_CONFIG_PAGE 0x%x %p\n", pModeEvent->status,eventParm2)); 3302 ostiPortEvent(tiRoot, 3303 tiModePageOperation, 3304 pModeEvent->status, 3305 eventParm2); 3306 break; 3307 case AGSA_ENCRYPTION_CONTROL_PARM_PAGE: 3308 TI_DBG1(("ossaHwCB: AGSA_ENCRYPTION_CONTROL_PARM_PAGE 0x%x %p\n", pModeEvent->status,eventParm2)); 3309 /* 3310 * This page is directly related to tiCOMEncryptGetInfo() and 3311 * will be translated into a tiEncrytOperation for the OS layer. 3312 */ 3313 3314 /* Fill out tiEncryptInfo_t */ 3315 securityMode = *pModePage & 0x0F00 >> 8; 3316 cipherMode = *pModePage & 0xF000 >> 12; 3317 3318 if (securityMode == agsaEncryptSMA) 3319 { 3320 encryptInfo.securityCipherMode = TI_ENCRYPT_SEC_MODE_A; 3321 } 3322 else if (securityMode == agsaEncryptSMB) 3323 { 3324 encryptInfo.securityCipherMode = TI_ENCRYPT_SEC_MODE_B; 3325 } 3326 else 3327 { 3328 encryptInfo.securityCipherMode = TI_ENCRYPT_SEC_MODE_FACT_INIT; 3329 } 3330 3331 if (cipherMode == agsaEncryptCipherModeECB) 3332 { 3333 encryptInfo.securityCipherMode |= TI_ENCRYPT_ATTRIB_CIPHER_ECB; 3334 } 3335 3336 if (cipherMode == agsaEncryptCipherModeXTS) 3337 { 3338 encryptInfo.securityCipherMode |= TI_ENCRYPT_ATTRIB_CIPHER_XTS; 3339 } 3340 3341 /* How will subEvents be tracked? */ 3342 encryptInfo.status = 0; 3343 3344 encryptInfo.sectorSize[0] = 512; /* DIF is allowed on 512 BPS SATA drives */ 3345 encryptInfo.sectorSize[1] = 520; 3346 encryptInfo.sectorSize[2] = 528; 3347 encryptInfo.sectorSize[3] = 4104; 3348 encryptInfo.sectorSize[4] = 4168; 3349 encryptInfo.sectorSize[5] = 4232; 3350 3351 encryptEventData.encryptEvent = tiEncryptGetInfo; 3352 encryptEventData.subEvent = 0; 3353 encryptEventData.pData = &encryptInfo; 3354 3355 ostiPortEvent(tiRoot, 3356 tiEncryptOperation, 3357 pModeEvent->status, 3358 &encryptEventData); 3359 break; 3360 case AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE: 3361 TI_DBG1(("ossaHwCB: AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE 0x%x %p\n", pModeEvent->status,eventParm2)); 3362 3363 #ifdef IOCTL_INTERRUPT_TIME_CONFIG 3364 ostiPortEvent(tiRoot, 3365 tiModePageOperation, 3366 pModeEvent->status, 3367 eventParm2 3368 ); 3369 #endif /* IOCTL_INTERRUPT_TIME_CONFIG */ 3370 3371 /*ostiPortEvent(tiRoot, 3372 tiModePageOperation, 3373 pModeEvent->status, 3374 &encryptEventData);*/ 3375 break; 3376 case AGSA_INTERRUPT_CONFIGURATION_PAGE: 3377 TI_DBG1(("ossaHwCB: AGSA_INTERRUPT_CONFIGURATION_PAGE 0x%x %p\n", pModeEvent->status,eventParm2)); 3378 3379 #ifdef IOCTL_INTERRUPT_TIME_CONFIG 3380 ostiPortEvent(tiRoot, 3381 tiModePageOperation, 3382 pModeEvent->status, 3383 eventParm2 3384 ); 3385 #endif /* IOCTL_INTERRUPT_TIME_CONFIG */ 3386 3387 break; 3388 default: 3389 TI_DBG1(("ossaHwCB: Unknown Mode Event %x\n", *pModePage)); 3390 break; 3391 } 3392 3393 } 3394 else 3395 { 3396 TI_DBG1(("ossaHwCB: Unknown modePageOperation %x\n", pModeEvent->modePageOperation)); 3397 } 3398 break; 3399 } 3400 3401 // #endif /* INITIATOR_DRIVER */ 3402 3403 #ifdef REMOVED 3404 case OSSA_HW_EVENT_PHY_UNRECOVERABLE_ERROR: 3405 { 3406 PhyID = TD_GET_PHY_ID(eventParm1); 3407 PortState = TD_GET_PORT_STATE(eventParm1); 3408 3409 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_PHY_UNRECOVERABLE_ERROR\n")); 3410 3411 if (PortState == OSSA_PORT_INVALID) 3412 { 3413 TI_DBG1(("ossaHwCB: INVALID port state\n")); 3414 } 3415 else 3416 { 3417 TI_DBG1(("ossaHwCB: VALID port state\n")); 3418 } 3419 break; 3420 } 3421 #endif /* REMOVED */ 3422 case OSSA_HW_EVENT_OPEN_RETRY_BACKOFF_THR_ADJUSTED: 3423 { 3424 TI_DBG1(("ossaHwCB: OSSA_HW_EVENT_OPEN_RETRY_BACKOFF_THR_ADJUSTED\n")); 3425 break; 3426 } 3427 3428 default: 3429 { 3430 TI_DBG1(("ossaHwCB: default error (0x%X)!!!!!\n",event)); 3431 break; 3432 } 3433 } 3434 3435 smTraceFuncExit(hpDBG_VERY_LOUD, 'R', "Y2"); 3436 return; 3437 } 3438 3439 osGLOBAL void ossaPortControlCB( 3440 agsaRoot_t *agRoot, 3441 agsaContext_t *agContext, 3442 agsaPortContext_t *agPortContext, 3443 bit32 portOperation, 3444 bit32 status) 3445 { 3446 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3447 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3448 tdsaPortContext_t *onePortContext = agNULL; 3449 3450 TI_DBG6(("ossaPortControlCB: start\n")); 3451 3452 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y3"); 3453 if (portOperation == AGSA_PORT_SET_SMP_PHY_WIDTH) 3454 { 3455 TI_DBG1(("ossaPortControlCB: portOperation AGSA_PORT_SET_SMP_PHY_WIDTH\n")); 3456 } 3457 else if (portOperation == AGSA_PORT_SET_PORT_RECOVERY_TIME) 3458 { 3459 TI_DBG1(("ossaPortControlCB: portOperation AGSA_PORT_SET_PORT_RECOVERY_TIME\n")); 3460 } 3461 else if (portOperation == AGSA_PORT_IO_ABORT) 3462 { 3463 TI_DBG1(("ossaPortControlCB: portOperation AGSA_PORT_IO_ABORT\n")); 3464 /* code is here because disocvery failed 3465 deregister all targets. Then, later call discovery if broacast is seen in ossaDeregisterDeviceHandleCB. 3466 */ 3467 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 3468 if (onePortContext == agNULL) 3469 { 3470 TI_DBG1(("ossaPortControlCB: onePortContext is NULL\n")); 3471 return; 3472 } 3473 /* qqqqq deregister all devices */ 3474 tdsaDeregisterDevicesInPort(tiRoot, onePortContext); 3475 3476 } 3477 else if (portOperation == AGSA_PORT_SET_PORT_RESET_TIME) 3478 { 3479 TI_DBG1(("ossaPortControlCB: portOperation AGSA_PORT_SET_PORT_RESET_TIME\n")); 3480 } 3481 else if (portOperation == AGSA_PORT_HARD_RESET) 3482 { 3483 TI_DBG1(("ossaPortControlCB: portOperation AGSA_PORT_HARD_RESET\n")); 3484 } 3485 else if (portOperation == AGSA_PORT_CLEAN_UP) 3486 { 3487 TI_DBG1(("ossaPortControlCB: portOperation AGSA_PORT_CLEAN_UP\n")); 3488 } 3489 else if (portOperation == AGSA_STOP_PORT_RECOVERY_TIMER) 3490 { 3491 TI_DBG1(("ossaPortControlCB: portOperation AGSA_STOP_PORT_RECOVERY_TIMER\n")); 3492 } 3493 else 3494 { 3495 TI_DBG1(("ossaPortControlCB: undefined portOperation %d\n", portOperation)); 3496 } 3497 3498 TI_DBG1(("ossaPortControlCB: status %d\n", status)); 3499 3500 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y3"); 3501 return; 3502 } 3503 3504 /***************************************************************************** 3505 *! \brief ossaHwRegRead 3506 * 3507 * Purpose: This routine is called to read a 32-bit value from the PCI 3508 * registers of the controller 3509 * 3510 * \param agRoot: Pointer to chip/driver Instance. 3511 * \param regOffset: Byte offset to chip register from which to read a 32-bit 3512 * value. 3513 * 3514 * \return: 32-bit value. 3515 * 3516 * \note - The scope is shared target and initiator. 3517 * 3518 *****************************************************************************/ 3519 FORCEINLINE 3520 bit32 3521 ossaHwRegRead(agsaRoot_t *agRoot, 3522 bit32 regOffset 3523 ) 3524 { 3525 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData); 3526 bit32 return_value; 3527 3528 3529 return_value = ostiChipReadBit32 ( 3530 osData->tiRoot, 3531 regOffset 3532 ); 3533 if( agNULL != agRoot->sdkData ) 3534 { 3535 smTrace(hpDBG_REGISTERS,"RR",regOffset); 3536 /* TP:RR regOffset */ 3537 smTrace(hpDBG_REGISTERS,"RV",return_value); 3538 /* TP:RV value read */ 3539 } 3540 3541 return(return_value); 3542 3543 } 3544 3545 /***************************************************************************** 3546 *! \brief ossaHwRegWrite 3547 * 3548 * Purpose: This routine is called to write a 32-bit value to the PCI 3549 * registers of the controller. 3550 * 3551 * \param agRoot: Pointer to chip/driver Instance. 3552 * \param regOffset: Byte offset to chip register to which chipIOValue is 3553 * written. 3554 * \param regValue: 32-bit value to write at chipIOOffset in host byte order. 3555 * 3556 * \return: None. 3557 * 3558 * \note - The scope is shared target and initiator. 3559 * 3560 *****************************************************************************/ 3561 FORCEINLINE 3562 void 3563 ossaHwRegWrite(agsaRoot_t *agRoot, 3564 bit32 regOffset, 3565 bit32 regValue 3566 ) 3567 { 3568 3569 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData); 3570 if( agNULL != agRoot->sdkData ) 3571 { 3572 smTrace(hpDBG_REGISTERS,"RW",regOffset); 3573 /* TP:RW regOffset */ 3574 smTrace(hpDBG_REGISTERS,"VW",regValue); 3575 /* TP:VW value written */ 3576 } 3577 3578 ostiChipWriteBit32 ( 3579 osData->tiRoot, 3580 regOffset, 3581 regValue 3582 ); 3583 return; 3584 } 3585 3586 /***************************************************************************** 3587 *! \brief ossaHwRegReadExt 3588 * 3589 * Purpose: This routine is called to read a 32-bit value from a bus-specific 3590 * mapped registers of the controller 3591 * 3592 * \param agRoot: Pointer to chip/driver Instance. 3593 * \param regOffset: Byte offset to chip register from which to read a 32-bit 3594 * value. 3595 * 3596 * \return: 32-bit value. 3597 * 3598 * \note - The scope is shared target and initiator. 3599 * 3600 *****************************************************************************/ 3601 FORCEINLINE 3602 bit32 3603 ossaHwRegReadExt( 3604 agsaRoot_t *agRoot, 3605 bit32 busBaseNumber, 3606 bit32 regOffset 3607 ) 3608 { 3609 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData); 3610 3611 bit32 return_value; 3612 3613 return_value = ostiChipReadBit32Ext( 3614 osData->tiRoot, 3615 busBaseNumber, 3616 regOffset 3617 ); 3618 3619 /* TI_DBG4(("#_R: 0x%x:0x%x=0x%x\n",busBaseNumber,regOffset,return_value)); */ 3620 3621 if( agNULL != agRoot->sdkData ) 3622 { 3623 smTrace(hpDBG_REGISTERS,"EB",busBaseNumber); 3624 /* TP:EB EX read busBaseNumber */ 3625 smTrace(hpDBG_REGISTERS,"EO",regOffset); 3626 /* TP:EO regOffset */ 3627 smTrace(hpDBG_REGISTERS,"ER",return_value); 3628 /* TP:ER value read */ 3629 } 3630 return(return_value); 3631 } 3632 3633 void ossaPCI_TRIGGER(agsaRoot_t *agRoot ) 3634 { 3635 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData); 3636 ostiPCI_TRIGGER(osData->tiRoot); 3637 3638 } 3639 3640 3641 3642 /***************************************************************************** 3643 *! \brief ossaHwRegWriteExt 3644 * 3645 * Purpose: This routine is called to write a 32-bit value to a bus specific 3646 * mapped registers of the controller. 3647 * 3648 * \param agRoot: Pointer to chip/driver Instance. 3649 * \param regOffset: Byte offset to chip register to which chipIOValue is 3650 * written. 3651 * \param regValue: 32-bit value to write at chipIOOffset in host byte order. 3652 * 3653 * \return: None. 3654 * 3655 * \note - The scope is shared target and initiator. 3656 * 3657 *****************************************************************************/ 3658 FORCEINLINE 3659 void 3660 ossaHwRegWriteExt( 3661 agsaRoot_t *agRoot, 3662 bit32 busBaseNumber, 3663 bit32 regOffset, 3664 bit32 regValue 3665 ) 3666 { 3667 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData); 3668 ostiChipWriteBit32Ext( 3669 osData->tiRoot, 3670 busBaseNumber, 3671 regOffset, 3672 regValue 3673 ); 3674 3675 /* TI_DBG4(("#_W: 0x%x:0x%x=0x%x\n",busBaseNumber,regOffset,regValue)); */ 3676 3677 if( agNULL != agRoot->sdkData ) 3678 { 3679 smTrace(hpDBG_REGISTERS,"Eb",busBaseNumber); 3680 /* TP:Eb Ex Write busBaseNumber */ 3681 smTrace(hpDBG_REGISTERS,"Eo",regOffset); 3682 /* TP:Eo regOffset */ 3683 smTrace(hpDBG_REGISTERS,"Ew",regValue); 3684 /* TP:Ew value written regValue*/ 3685 } 3686 return; 3687 } 3688 3689 3690 osGLOBAL bit32 ossaHwRegReadConfig32( 3691 agsaRoot_t *agRoot, 3692 bit32 regOffset 3693 ) 3694 { 3695 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData); 3696 bit32 to_ret; 3697 to_ret= ostiChipConfigReadBit32( osData->tiRoot, regOffset); 3698 TI_DBG4(("ossaHwRegReadConfig32: regOffset 0x%x returns 0x%x\n",regOffset,to_ret)); 3699 return(to_ret); 3700 } 3701 3702 3703 3704 3705 #ifdef TD_INT_COALESCE 3706 void 3707 ossaIntCoalesceInitCB( 3708 agsaRoot_t *agRoot, 3709 agsaIntCoalesceContext_t *agIntCoContext, 3710 bit32 status 3711 ) 3712 { 3713 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3714 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3715 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)osData->tdsaAllShared; 3716 tiIntCoalesceContext_t *tiIntCoalesceCxt; 3717 tdsaIntCoalesceContext_t *tdsaIntCoalCxt; 3718 tdsaIntCoalesceContext_t *tdsaIntCoalCxtHead 3719 = (tdsaIntCoalesceContext_t *)tdsaAllShared->IntCoalesce;; 3720 bit32 tiStatus; 3721 3722 TI_DBG2(("ossaIntCoalesceInitCB: start\n")); 3723 3724 tdsaIntCoalCxt = (tdsaIntCoalesceContext_t *)agIntCoContext->osData; 3725 tiIntCoalesceCxt = tdsaIntCoalCxt->tiIntCoalesceCxt; 3726 switch (status) 3727 { 3728 case AGSA_RC_SUCCESS: 3729 tiStatus = tiSuccess; 3730 break; 3731 case AGSA_RC_BUSY: 3732 tiStatus = tiBusy; 3733 break; 3734 case AGSA_RC_FAILURE: 3735 tiStatus = tiError; 3736 break; 3737 default: 3738 TI_DBG1(("ossaIntCoalesceInitCB: unknown status %d\n", status)); 3739 tiStatus = tiError; 3740 break; 3741 } 3742 3743 TI_DBG2(("ossaIntCoalesceInitCB: status %d\n", tiStatus)); 3744 3745 /* enqueue tdsaIntCoalCxt to freelink */ 3746 tdsaIntCoalCxt->tiIntCoalesceCxt = agNULL; 3747 TI_DBG2(("ossaIntCoalesceInitCB: id %d\n", tdsaIntCoalCxt->id)); 3748 3749 tdsaSingleThreadedEnter(tiRoot, TD_INTCOAL_LOCK); 3750 TDLIST_DEQUEUE_THIS(&(tdsaIntCoalCxt->MainLink)); 3751 TDLIST_ENQUEUE_AT_TAIL(&(tdsaIntCoalCxt->FreeLink), &(tdsaIntCoalCxtHead->FreeLink)); 3752 tdsaSingleThreadedLeave(tiRoot, TD_INTCOAL_LOCK); 3753 3754 #ifdef OS_INT_COALESCE 3755 ostiInitiatorIntCoalesceInitCB(tiRoot, 3756 tiIntCoalesceCxt, 3757 tiStatus); 3758 #endif 3759 3760 TI_DBG2(("ossaIntCoalesceInitCB: return end\n")); 3761 3762 return; 3763 } 3764 #endif /* TD_INT_COALESCE */ 3765 3766 /*****************************************************************************/ 3767 /*! \brief ossaSingleThreadedEnter 3768 * 3769 * 3770 * Purpose: This routine is called to ensure that only a single thread of 3771 * the given port instance executes code in the region protected by 3772 * this function. 3773 * 3774 * 3775 * \param agRoot: Pointer to chip/driver Instance. 3776 * \param syncLockId to be explained. 3777 * 3778 * 3779 * \return None. 3780 * 3781 * \note - The scope is shared target and initiator. 3782 * 3783 */ 3784 /*****************************************************************************/ 3785 FORCEINLINE 3786 void ossaSingleThreadedEnter( 3787 agsaRoot_t *agRoot, 3788 bit32 syncLockId 3789 ) 3790 { 3791 tdsaRootOsData_t *pOsData = agNULL; 3792 tiRoot_t *ptiRoot = agNULL; 3793 tdsaContext_t *tdsaAllShared = agNULL; 3794 3795 TD_ASSERT(agRoot, "agRoot"); 3796 pOsData = (tdsaRootOsData_t *) (agRoot->osData); 3797 TD_ASSERT(pOsData, "pOsData"); 3798 ptiRoot = pOsData->tiRoot; 3799 TD_ASSERT(ptiRoot, "ptiRoot"); 3800 3801 tdsaAllShared = (tdsaContext_t *)pOsData->tdsaAllShared; 3802 TD_ASSERT(tdsaAllShared, "tdsaAllShared"); 3803 3804 ostiSingleThreadedEnter(ptiRoot, syncLockId + tdsaAllShared->MaxNumOSLocks); 3805 return; 3806 } 3807 3808 /*****************************************************************************/ 3809 /*! \brief ossaSingleThreadedLeave 3810 * 3811 * 3812 * Purpose: This routine is called to leave a critical region of code 3813 * previously protected by a call to osSingleThreadedEnter() 3814 * 3815 * 3816 * \param agRoot: Pointer to chip/driver Instance. 3817 * \param syncLockId to be explained. 3818 * 3819 * 3820 * \return None. 3821 * 3822 * \note - The scope is shared target and initiator. 3823 * 3824 */ 3825 /*****************************************************************************/ 3826 FORCEINLINE 3827 void ossaSingleThreadedLeave( 3828 agsaRoot_t *agRoot, 3829 bit32 syncLockId 3830 ) 3831 { 3832 tdsaRootOsData_t *pOsData = agNULL; 3833 tiRoot_t *ptiRoot = agNULL; 3834 tdsaContext_t *tdsaAllShared = agNULL; 3835 3836 TD_ASSERT(agRoot, "agRoot"); 3837 pOsData = (tdsaRootOsData_t *) (agRoot->osData); 3838 TD_ASSERT(pOsData, "pOsData"); 3839 ptiRoot = pOsData->tiRoot; 3840 TD_ASSERT(ptiRoot, "ptiRoot"); 3841 3842 tdsaAllShared = (tdsaContext_t *)pOsData->tdsaAllShared; 3843 TD_ASSERT(tdsaAllShared, "tdsaAllShared"); 3844 3845 ostiSingleThreadedLeave(ptiRoot, syncLockId + tdsaAllShared->MaxNumOSLocks); 3846 return; 3847 } 3848 3849 #ifdef PERF_COUNT 3850 osGLOBAL void ossaEnter(agsaRoot_t *agRoot, int io) 3851 { 3852 ostiEnter(((tdsaRootOsData_t*)(agRoot->osData))->tiRoot, 0, io); 3853 return; 3854 } 3855 3856 osGLOBAL void ossaLeave(agsaRoot_t *agRoot, int io) 3857 { 3858 ostiLeave(((tdsaRootOsData_t*)(agRoot->osData))->tiRoot, 0, io); 3859 return; 3860 } 3861 #endif 3862 3863 3864 osGLOBAL void 3865 ossaSSPIoctlCompleted( 3866 agsaRoot_t *agRoot, 3867 agsaIORequest_t *agIORequest, 3868 bit32 agIOStatus, 3869 bit32 agIOInfoLen, 3870 void *agParam, 3871 bit16 sspTag, 3872 bit32 agOtherInfo 3873 ) 3874 { 3875 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3876 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3877 tdIORequestBody_t *tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 3878 agsaSASRequestBody_t *agSASRequestBody = agNULL; 3879 agsaSSPInitiatorRequest_t *agSSPFrame = agNULL; 3880 bit8 scsiOpcode = 0; 3881 3882 agSASRequestBody = &(tdIORequestBody->transport.SAS.agSASRequestBody); 3883 agSSPFrame = &(agSASRequestBody->sspInitiatorReq); 3884 scsiOpcode = agSSPFrame->sspCmdIU.cdb[0]; 3885 3886 TI_DBG2(("ossaSSPIoctlCompleted: start\n")); 3887 3888 if (agIOStatus == OSSA_SUCCESS) 3889 { 3890 TI_DBG2(("ossaSSPIoctlCompleted: Success status\n")); 3891 } 3892 else 3893 { 3894 TI_DBG1(("ossaSSPIoctlCompleted: Status 0x%x\n", agIOStatus)); 3895 } 3896 switch(scsiOpcode) 3897 { 3898 case REPORT_LUN_OPCODE: 3899 ostiNumOfLUNIOCTLRsp(tiRoot, agIOStatus); 3900 break; 3901 3902 default: 3903 TI_DBG1(("ossaSSPIoctlCompleted: Unsupported SCSI command Response 0x%x\n",scsiOpcode)); 3904 break; 3905 } 3906 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yi"); 3907 return; 3908 3909 } 3910 3911 osGLOBAL void 3912 ossaSMPIoctlCompleted( 3913 agsaRoot_t *agRoot, 3914 agsaIORequest_t *agIORequest, 3915 bit32 agIOStatus, 3916 bit32 agIOInfoLen, 3917 agsaFrameHandle_t agFrameHandle 3918 ) 3919 { 3920 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3921 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3922 TI_DBG2(("ossaSMPIoctlCompleted: start\n")); 3923 3924 if (agIOStatus == OSSA_SUCCESS) 3925 { 3926 TI_DBG2(("ossaSMPIoctlCompleted: Success status\n")); 3927 } 3928 else 3929 { 3930 TI_DBG1(("ossaSMPIoctlCompleted: Status 0x%x\n", agIOStatus)); 3931 } 3932 3933 ostiSendSMPIOCTLRsp(tiRoot, agIOStatus); 3934 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yi"); 3935 return; 3936 3937 } 3938 3939 3940 /*****************************************************************************/ 3941 /*! \brief ossaSMPCompleted 3942 * 3943 * 3944 * Purpose: This routine is called by lower layer to indicate the completion of 3945 * SMP request 3946 * 3947 * \param agRoot: Pointer to chip/driver Instance. 3948 * \param agIORequest Pointer to SMP request handle 3949 * \param agIOStatus Status 3950 * \param agFrameHeader:Pointer to SMP frame header. 3951 * \param agIOInfoLen IO information length assoicated with the IO 3952 * \param agFrameHandle A Handle used to refer to the response frame 3953 * 3954 * 3955 * \return None. 3956 * 3957 * \note - The scope is shared target and initiator. 3958 * For details, refer to SAS/SATA Low-Level API Specification 3959 */ 3960 /*****************************************************************************/ 3961 osGLOBAL void ossaSMPCompleted( 3962 agsaRoot_t *agRoot, 3963 agsaIORequest_t *agIORequest, 3964 bit32 agIOStatus, 3965 bit32 agIOInfoLen, 3966 agsaFrameHandle_t agFrameHandle 3967 ) 3968 { 3969 #ifdef PASSTHROUGH 3970 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3971 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3972 tdPassthroughCmndBody_t *tdPTCmndBody = (tdPassthroughCmndBody_t *)agIORequest->osData; 3973 bit32 tiStatus = tiPassthroughError; 3974 bit8 SMPframe[agIOInfoLen + sizeof(agsaSMPFrameHeader_t)]; 3975 bit8 SMPpayload[agIOInfoLen]; 3976 3977 TI_DBG2(("ossaSMPCompleted: start and passthrough\n")); 3978 #else /* not PASSTHROUGH */ 3979 3980 tdssSMPRequestBody_t *pSMPRequestBody = (tdssSMPRequestBody_t *) agIORequest->osData; 3981 TI_DBG4(("ossaSMPCompleted: start\n")); 3982 #endif /* end not PASSTHROUGH */ 3983 3984 TDSA_OUT_ENTER((tiRoot_t *)((tdsaRootOsData_t *)agRoot->osData)->tiRoot); 3985 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y4"); 3986 3987 #ifdef PASSTHROUGH 3988 if (tdPTCmndBody == agNULL) 3989 { 3990 TI_DBG1(("ossaSMPCompleted: tdPTCmndBody is NULL \n")); 3991 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y4"); 3992 goto ext; 3993 } 3994 3995 if (tdPTCmndBody->EventCB == agNULL) 3996 { 3997 TI_DBG1(("ossaSMPCompleted: tdPTCmndBody->EventCB is NULL \n")); 3998 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "Y4"); 3999 goto ext; 4000 } 4001 4002 if (agIOStatus == OSSA_IO_SUCCESS) 4003 { 4004 tiStatus = tiPassthroughSuccess; 4005 } 4006 else if (agIOStatus == OSSA_IO_ABORTED) 4007 { 4008 tiStatus = tiPassthroughAborted; 4009 } 4010 else 4011 { 4012 tiStatus = tiPassthroughError; 4013 } 4014 4015 osti_memset(SMPpayload, 0, agIOInfoLen); 4016 osti_memset(SMPframe, 0, agIOInfoLen + sizeof(agsaSMPFrameHeader_t)); 4017 4018 /* combine the header and payload */ 4019 saFrameReadBlock(agRoot, agFrameHandle, 0, &SMPpayload, agIOInfoLen); 4020 osti_memcpy(SMPframe, agFrameHeader, sizeof(agsaSMPFrameHeader_t)); 4021 osti_memcpy(SMPframe+sizeof(agsaSMPFrameHeader_t), SMPpayload, agIOInfoLen); 4022 4023 tdPTCmndBody->EventCB(tiRoot, 4024 tdPTCmndBody->tiPassthroughRequest, 4025 tiStatus, 4026 SMPframe, 4027 agIOInfoLen + sizeof(agsaSMPFrameHeader_t) 4028 ); 4029 4030 4031 #else /* not PASSTHROUGH */ 4032 4033 /* 4034 At initiator, passing SMP to TD layer, itdssSMPCompleted(), which does nothing. 4035 At target, passing SMP to TD layer, ttdsaSMPCompleted() 4036 */ 4037 /* 4038 how to use agFrameHandle, when saFrameReadBlock() is used 4039 */ 4040 4041 /* SPC can't be SMP target */ 4042 4043 TI_DBG4(("ossaSMPCompleted: start\n")); 4044 4045 if (pSMPRequestBody == agNULL) 4046 { 4047 TI_DBG1(("ossaSMPCompleted: pSMPRequestBody is NULL \n")); 4048 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "Y4"); 4049 goto ext; 4050 } 4051 4052 if (pSMPRequestBody->SMPCompletionFunc == agNULL) 4053 { 4054 TI_DBG1(("ossaSMPCompleted: pSMPRequestBody->SMPCompletionFunc is NULL \n")); 4055 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "Y4"); 4056 goto ext; 4057 } 4058 #ifdef TD_INTERNAL_DEBUG /* debugging */ 4059 TI_DBG4(("ossaSMPCompleted: agIOrequest %p\n", agIORequest->osData)); 4060 TI_DBG4(("ossaSMPCompleted: sizeof(tdIORequestBody_t) %d 0x%x\n", sizeof(tdIORequestBody_t), 4061 sizeof(tdIORequestBody_t))); 4062 TI_DBG4(("ossaSMPCompleted: SMPRequestbody %p\n", pSMPRequestBody)); 4063 TI_DBG4(("ossaSMPCompleted: calling callback fn\n")); 4064 TI_DBG4(("ossaSMPCompleted: callback fn %p\n",pSMPRequestBody->SMPCompletionFunc)); 4065 #endif /* TD_INTERNAL_DEBUG */ 4066 /* 4067 if initiator, calling itdssSMPCompleted() in itdcb.c 4068 if target, calling ttdsaSMPCompleted() in ttdsmp.c 4069 */ 4070 pSMPRequestBody->SMPCompletionFunc( 4071 agRoot, 4072 agIORequest, 4073 agIOStatus, 4074 agIOInfoLen, 4075 agFrameHandle 4076 ); 4077 4078 #endif /* Not PASSTHROUGH */ 4079 4080 smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "Y4"); 4081 ext: 4082 TDSA_OUT_LEAVE((tiRoot_t *)((tdsaRootOsData_t *)agRoot->osData)->tiRoot); 4083 return; 4084 } 4085 4086 osGLOBAL void 4087 ossaSMPReqReceived( 4088 agsaRoot_t *agRoot, 4089 agsaDevHandle_t *agDevHandle, 4090 agsaFrameHandle_t agFrameHandle, 4091 bit32 agIOInfoLen, 4092 bit32 phyId 4093 ) 4094 { 4095 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y5"); 4096 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y5"); 4097 return; 4098 } 4099 4100 /*****************************************************************************/ 4101 /*! \brief ossaSMPCAMCompleted 4102 * 4103 * 4104 * Purpose: This routine is called by lower layer to indicate the completion of 4105 * SMP request 4106 * 4107 * \param agRoot: Pointer to chip/driver Instance. 4108 * \param agIORequest Pointer to SMP request handle 4109 * \param agIOStatus Status 4110 * \param agIOInfoLen IO information length assoicated with the IO 4111 * \param agFrameHandle A Handle used to refer to the response frame 4112 * 4113 * 4114 * \return None. 4115 * 4116 * \note - The scope is shared target and initiator. 4117 * For details, refer to SAS/SATA Low-Level API Specification 4118 */ 4119 /*****************************************************************************/ 4120 osGLOBAL void ossaSMPCAMCompleted( 4121 agsaRoot_t *agRoot, 4122 agsaIORequest_t *agIORequest, 4123 bit32 agIOStatus, 4124 bit32 agIOInfoLen, 4125 agsaFrameHandle_t agFrameHandle 4126 ) 4127 { 4128 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 4129 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 4130 tdIORequestBody_t *tdSMPRequestBody = agNULL; 4131 bit32 context = osData->IntContext; 4132 tiSMPStatus_t status; 4133 bit32 PhysUpper32; 4134 bit32 PhysLower32; 4135 bit32 memAllocStatus; 4136 void *osMemHandle; 4137 bit32 *SMPpayload; 4138 TI_DBG2(("ossaSMPCAMCompleted: start\n")); 4139 TI_DBG2(("ossaSMPCAMCompleted: agIOInfoLen %d\n", agIOInfoLen)); 4140 if (!agIORequest->osData) 4141 { 4142 TD_ASSERT((0), "ossaSMPCAMCompleted agIORequest->osData"); 4143 goto ext; 4144 } 4145 tdSMPRequestBody = (tdIORequestBody_t *)agIORequest->osData; 4146 if (tdSMPRequestBody->tiIORequest->osData == agNULL) 4147 { 4148 TI_DBG1(("ossaSMPCAMCompleted: tdIORequestBody->tiIORequest->osData is null, wrong\n")); 4149 goto ext; 4150 } 4151 /* allocating agIORequest for SMP Payload itself */ 4152 memAllocStatus = ostiAllocMemory( 4153 tiRoot, 4154 &osMemHandle, 4155 (void **)&SMPpayload, 4156 &PhysUpper32, 4157 &PhysLower32, 4158 8, 4159 agIOInfoLen, 4160 agTRUE 4161 ); 4162 if (memAllocStatus != tiSuccess) 4163 { 4164 /* let os process IO */ 4165 TI_DBG1(("ossaSMPCAMCompleted: ostiAllocMemory failed...\n")); 4166 goto ext; 4167 } 4168 if (SMPpayload == agNULL) 4169 { 4170 TI_DBG1(("ossaSMPCAMCompleted: ostiAllocMemory returned NULL SMPpayload\n")); 4171 goto ext; 4172 } 4173 if (agIOStatus == OSSA_IO_SUCCESS) 4174 { 4175 TI_DBG1(("ossaSMPCAMCompleted: Success status\n")); 4176 osti_memset(SMPpayload, 0, agIOInfoLen); 4177 TI_DBG1(("ossaSMPCAMCompleted: after memset\n")); 4178 saFrameReadBlock(agRoot, agFrameHandle, 0, SMPpayload, agIOInfoLen); 4179 TI_DBG1(("ossaSMPCAMCompleted: after read \n")); 4180 status = tiSMPSuccess; 4181 } 4182 else if (agIOStatus == OSSA_IO_ABORTED) 4183 { 4184 TI_DBG1(("ossaSMPCAMCompleted: SMP Aborted status\n")); 4185 status = tiSMPAborted; 4186 TI_DBG1(("ossaSMPCAMCompleted: failed status=%d\n", status)); 4187 //failed to send smp command, we need to free the memory 4188 ostiFreeMemory( 4189 tiRoot, 4190 osMemHandle, 4191 agIOInfoLen 4192 ); 4193 } 4194 else 4195 { 4196 TI_DBG1(("ossaSMPCAMCompleted: SMP failed status\n")); 4197 status = tiSMPFailed; 4198 TI_DBG1(("ossaSMPCAMCompleted: failed status=%d\n", status)); 4199 //failed to send smp command, we need to free the memory 4200 ostiFreeMemory( 4201 tiRoot, 4202 osMemHandle, 4203 agIOInfoLen 4204 ); 4205 } 4206 ostiInitiatorSMPCompleted(tiRoot, 4207 tdSMPRequestBody->tiIORequest, 4208 status, 4209 agIOInfoLen, 4210 SMPpayload, 4211 context 4212 ); 4213 ext: 4214 TDSA_OUT_LEAVE((tiRoot_t*)((tdsaRootOsData_t*)agRoot->osData)->tiRoot); 4215 return; 4216 } 4217 #ifdef REMOVED 4218 #ifdef TARGET_DRIVER 4219 /*****************************************************************************/ 4220 /*! \brief ossaSMPReqReceived 4221 * 4222 * 4223 * Purpose: This routine is called by lower layer to indicate the reception of 4224 * SMP request 4225 * 4226 * \param agRoot: Pointer to chip/driver Instance. 4227 * \param agDevHandle Pointer to the device handle of the device 4228 * \param agFrameHandle A Handle used to refer to the response frame 4229 * 4230 * 4231 * \return None. 4232 * 4233 * \note - The scope is target only 4234 * For details, refer to SAS/SATA Low-Level API Specification 4235 */ 4236 /*****************************************************************************/ 4237 osGLOBAL void ossaSMPReqReceived( 4238 agsaRoot_t *agRoot, 4239 agsaDevHandle_t *agDevHandle, 4240 agsaFrameHandle_t agFrameHandle, 4241 bit32 agFrameLength, 4242 bit32 phyId 4243 ) 4244 { 4245 bit8 smpHeader[4]; 4246 agsaSMPFrameHeader_t *agFrameHeader; 4247 #ifdef PASSTHROUGH 4248 /* call the registered function(parameter in tiTGTPassthroughCmndRegister() by target */ 4249 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 4250 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 4251 ttdsaTgt_t *Target = (ttdsaTgt_t *)osData->ttdsaTgt; 4252 4253 bit8 SMPframe[agIOInfoLen + sizeof(agsaSMPFrameHeader_t)]; 4254 bit8 SMPpayload[agIOInfoLen]; 4255 4256 TI_DBG2(("ossaSMPReqReceived: start and passthrough\n")); 4257 osti_memset(SMPpayload, 0, agIOInfoLen); 4258 osti_memset(SMPframe, 0, agIOInfoLen + sizeof(agsaSMPFrameHeader_t)); 4259 /* combine smp header and payload */ 4260 saFrameReadBlock(agRoot, agFrameHandle, 0, &SMPpayload, agIOInfoLen); 4261 osti_memcpy(SMPframe, agFrameHeader, sizeof(agsaSMPFrameHeader_t)); 4262 osti_memcpy(SMPframe+sizeof(agsaSMPFrameHeader_t), SMPpayload, agIOInfoLen); 4263 4264 Target->PasthroughCB( 4265 tiRoot, 4266 tiSASATA, 4267 tiSMP, 4268 tiSMPResponse, 4269 SMPframe, 4270 agIOInfoLen + sizeof(agsaSMPFrameHeader_t), 4271 phyId 4272 ); 4273 4274 #else 4275 4276 /* 4277 agDevHandle_t->osData points to tdssDeviceData_t 4278 */ 4279 tdsaDeviceData_t *pDeviceData = (tdsaDeviceData_t *) agDevHandle->osData; 4280 4281 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4); 4282 agFrameHeader = (agsaSMPFrameHeader_t *)smpHeader; 4283 TI_DBG4(("ossaSMPReqReceived: start\n")); 4284 4285 /* tdtypes.h, calling ttdsaSMPReqReceived in ttdsmp.c */ 4286 pDeviceData->pJumpTable->pSMPReqReceived ( 4287 agRoot, 4288 agDevHandle, 4289 agFrameHeader, 4290 agFrameHandle, 4291 agFrameLength, 4292 phyId 4293 ); 4294 #endif 4295 return; 4296 } 4297 #endif 4298 #endif 4299 4300 /*****************************************************************************/ 4301 /*! \brief ossaSSPCompleted 4302 * 4303 * 4304 * Purpose: This routine is called by lower layer to indicate the completion of 4305 * SSP request 4306 * 4307 * \param agRoot: Pointer to chip/driver Instance. 4308 * \param agIORequest Pointer to SMP request handle 4309 * \param agIOStatus Status 4310 * \param agIOInfoLen IO information length assoicated with the IO 4311 * \param agFrameHandle A Handle used to refer to the response frame 4312 * 4313 * 4314 * \return None. 4315 * 4316 * \note - The scope is shared target and initiator. 4317 * For details, refer to SAS/SATA Low-Level API Specification 4318 */ 4319 /*****************************************************************************/ 4320 FORCEINLINE 4321 void ossaSSPCompleted( 4322 agsaRoot_t *agRoot, 4323 agsaIORequest_t *agIORequest, 4324 bit32 agIOStatus, 4325 bit32 agIOInfoLen, 4326 void *agParam, 4327 bit16 sspTag, 4328 bit32 agOtherInfo 4329 ) 4330 { 4331 tdIORequestBody_t *pIORequestBody; 4332 #ifdef TD_DEBUG_ENABLE 4333 tiDeviceHandle_t *tiDeviceHandle = agNULL; 4334 tdsaDeviceData_t *oneDeviceData = agNULL; 4335 #endif 4336 4337 TDSA_OUT_ENTER((tiRoot_t*)((tdsaRootOsData_t*)agRoot->osData)->tiRoot); 4338 smTraceFuncEnter(hpDBG_VERY_LOUD,"2L"); 4339 4340 if(!agIORequest->osData) 4341 { 4342 TD_ASSERT((0), "ossaSSPCompleted agIORequest->osData"); 4343 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "2L"); 4344 goto ext; 4345 } 4346 pIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4347 4348 4349 TI_DBG4(("ossaSSPCompleted: start\n")); 4350 4351 if (pIORequestBody == agNULL) 4352 { 4353 TI_DBG1(("ossaSSPCompleted: pIORequestBody is NULL \n")); 4354 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "2L"); 4355 goto ext; 4356 } 4357 if (pIORequestBody->IOCompletionFunc == agNULL) 4358 { 4359 #ifdef TD_DEBUG_ENABLE 4360 tiDeviceHandle = pIORequestBody->tiDevHandle; 4361 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 4362 #endif 4363 TI_DBG1(("ossaSSPCompleted: IOCompletionFunc is NULL \n")); 4364 TI_DBG1(("ossaSSPCompleted: did %d \n", oneDeviceData->id)); 4365 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "2L"); 4366 goto ext; 4367 } 4368 4369 /* 4370 if initiator, calling itdssIOCompleted() in itdcb.c 4371 if initiator, calling itdssTaskCompleted in itdcb.c 4372 if target, calling ttdsaIOCompleted() in ttdio.c 4373 */ 4374 pIORequestBody->IOCompletionFunc( 4375 agRoot, 4376 agIORequest, 4377 agIOStatus, 4378 agIOInfoLen, 4379 agParam, 4380 agOtherInfo 4381 ); 4382 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "2L"); 4383 ext: 4384 TDSA_OUT_LEAVE((tiRoot_t*)((tdsaRootOsData_t*)agRoot->osData)->tiRoot); 4385 return; 4386 } 4387 4388 #ifdef FAST_IO_TEST 4389 GLOBAL void ossaFastSSPCompleted( 4390 agsaRoot_t *agRoot, 4391 agsaIORequest_t *cbArg, 4392 bit32 agIOStatus, 4393 bit32 agIOInfoLen, 4394 void *agParam, 4395 bit16 sspTag, 4396 bit32 agOtherInfo 4397 ) 4398 { 4399 agsaFastCBBuf_t *safb = (agsaFastCBBuf_t*)cbArg; 4400 tdsaRootOsData_t *osData = (tdsaRootOsData_t*)agRoot->osData; 4401 tiRoot_t *tiRoot = (tiRoot_t*)osData->tiRoot; 4402 bit32 scsi_status; 4403 bit32 data_status; 4404 bit32 respLen; 4405 bit8 respData[128]; 4406 bit32 senseLen; 4407 agsaSSPResponseInfoUnit_t agSSPRespIU; 4408 4409 TDSA_OUT_ENTER((tiRoot_t*)((tdsaRootOsData_t*)agRoot->osData)->tiRoot); 4410 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y6"); 4411 4412 TI_DBG4(("ossaSSPCompleted: start\n")); 4413 4414 if (safb->cb == agNULL || safb->cbArg == agNULL) 4415 { 4416 TI_DBG1(("ossaFastSSPCompleted: pIORequestBody is NULL \n")); 4417 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y6"); 4418 TD_ASSERT((0), ""); 4419 goto ext; 4420 } 4421 4422 switch (agIOStatus) 4423 { 4424 case OSSA_IO_SUCCESS: 4425 4426 /* ~ itdssIOSuccessHandler */ 4427 if ((agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t))) 4428 { 4429 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, OSSA_IO_SUCCESS, 0); 4430 break; 4431 } 4432 4433 /* reads agsaSSPResponseInfoUnit_t */ 4434 saFrameReadBlock(agRoot, agParam, 0, &agSSPRespIU, 4435 sizeof(agsaSSPResponseInfoUnit_t)); 4436 4437 data_status = SA_SSPRESP_GET_DATAPRES(&agSSPRespIU); 4438 scsi_status = agSSPRespIU.status; 4439 4440 TI_DBG1(("itdssIOSuccessHandler: scsi_status %d\n", scsi_status)); 4441 4442 /* endianess is invovled here */ 4443 senseLen = SA_SSPRESP_GET_SENSEDATALEN(&agSSPRespIU); 4444 respLen = SA_SSPRESP_GET_RESPONSEDATALEN(&agSSPRespIU); 4445 TI_DBG2(("itdssIOSuccessHandler: scsi status=0x%x, senselen=0x%x resplen " 4446 "0x%x\n", scsi_status, senseLen, respLen)); 4447 4448 if (agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen) 4449 { 4450 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOFailed, 4451 tiDetailOtherError); 4452 break; 4453 } 4454 4455 /* reads response data */ 4456 saFrameReadBlock(agRoot, agParam, sizeof(agsaSSPResponseInfoUnit_t), 4457 respData, respLen); 4458 /* reads sense data */ 4459 saFrameReadBlock(agRoot, agParam, sizeof(agsaSSPResponseInfoUnit_t) 4460 + respLen, safb->pSenseData, senseLen); 4461 4462 if (data_status == 0) 4463 { 4464 /* NO_DATA */ 4465 TI_DBG2(("ossaFastSSPCompleted: no data\n")); 4466 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOSuccess, 4467 scsi_status); 4468 break; 4469 } 4470 4471 if (data_status == 1) 4472 { 4473 /* RESPONSE_DATA */ 4474 TI_DBG1(("ossaFastSSPCompleted: response data \n")); 4475 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOSuccess, 0); 4476 break; 4477 } 4478 4479 if (data_status == 2) 4480 { 4481 tiSenseData_t senseData; 4482 4483 /* SENSE_DATA */ 4484 TI_DBG2(("itdssIOSuccessHandler: sense data \n")); 4485 4486 senseData.senseData = safb->pSenseData; 4487 senseData.senseLen = MIN(*(safb->senseLen), senseLen); 4488 4489 /* when ASC = 0x04 - Log Unit Not Ready, 4490 and ASCQ = 0x11 - Enable Spinup Required: 4491 call saLocalPhyControl to notify spinup */ 4492 if (((char*)safb->pSenseData)[12] == 0x04 && 4493 ((char*)safb->pSenseData)[13] == 0x11) 4494 { 4495 int i; 4496 4497 TI_DBG2(("ossaFastSSPCompleted: sending notfify spinup\n")); 4498 4499 if (((tdsaDeviceData_t*)safb->oneDeviceData)->directlyAttached == 4500 agTRUE) 4501 { 4502 for (i = 0; i < TD_MAX_NUM_NOTIFY_SPINUP; i++) 4503 { 4504 saLocalPhyControl(agRoot, agNULL, 0, 4505 ((tdsaDeviceData_t*)safb->oneDeviceData)->phyID, 4506 AGSA_PHY_NOTIFY_ENABLE_SPINUP, 4507 agNULL); 4508 } 4509 } 4510 } 4511 4512 if (*(safb->senseLen) > senseData.senseLen) 4513 *(safb->senseLen) = senseData.senseLen; 4514 // memcpy((void *)safb->pSenseData, senseData.senseData, safb->senseLen); 4515 4516 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOSuccess, 4517 scsi_status); 4518 break; 4519 } 4520 4521 if (data_status == 3) 4522 { 4523 /* RESERVED */ 4524 TI_DBG1(("ossaFastSSPCompleted: reserved wrong!!!\n")); 4525 4526 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOFailed, 4527 scsi_status); 4528 break; 4529 } 4530 break; 4531 #ifdef REMOVED 4532 case OSSA_IO_OVERFLOW: 4533 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOOverRun, 4534 agIOInfoLen); 4535 break; 4536 #endif /* REMOVED */ 4537 case OSSA_IO_UNDERFLOW: 4538 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOUnderRun, 4539 agIOInfoLen); 4540 break; 4541 4542 case OSSA_IO_ABORTED: 4543 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOFailed, 4544 tiDetailAborted); 4545 break; 4546 case OSSA_IO_ABORT_RESET: 4547 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOFailed, 4548 tiDetailAbortReset); 4549 break; 4550 case OSSA_IO_NO_DEVICE: 4551 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOFailed, 4552 tiDetailNoLogin); 4553 break; 4554 case OSSA_IO_DS_NON_OPERATIONAL: 4555 { 4556 4557 tdsaDeviceData_t *oneDeviceData; 4558 4559 oneDeviceData = (tdsaDeviceData_t*)safb->oneDeviceData; 4560 if (oneDeviceData->valid == agTRUE && 4561 oneDeviceData->registered == agTRUE && 4562 oneDeviceData->tdPortContext != agNULL) 4563 { 4564 saSetDeviceState(oneDeviceData->agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), 4565 oneDeviceData->agDevHandle, SA_DS_OPERATIONAL); 4566 } 4567 /* fall through */ 4568 } 4569 4570 default: 4571 ((ostiFastSSPCb_t)safb->cb)(tiRoot, safb->cbArg, tiIOFailed, 4572 tiDetailOtherError); 4573 break; 4574 } 4575 4576 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "Y6"); 4577 4578 ext: 4579 TDSA_OUT_LEAVE((tiRoot_t*)((tdsaRootOsData_t*)agRoot->osData)->tiRoot); 4580 return; 4581 } /* ossaFastSSPCompleted */ 4582 #endif 4583 4584 /*****************************************************************************/ 4585 /*! \brief ossaSSPReqReceived 4586 * 4587 * 4588 * Purpose: This routine is called by lower layer to indicate the reception of 4589 * SMP request 4590 * 4591 * \param agRoot: Pointer to chip/driver Instance. 4592 * \param agDevHandle Pointer to the device handle of the device 4593 * \param agFrameHandle A Handle used to refer to the response frame 4594 * \param agInitiatorTag the initiator tag 4595 * \param agFrameType SSP frame type 4596 * 4597 * \return none. 4598 * 4599 * \note - The scope is target only 4600 * For details, refer to SAS/SATA Low-Level API Specification 4601 */ 4602 /*****************************************************************************/ 4603 osGLOBAL void ossaSSPReqReceived( 4604 agsaRoot_t *agRoot, 4605 agsaDevHandle_t *agDevHandle, 4606 agsaFrameHandle_t agFrameHandle, 4607 bit16 agInitiatorTag, 4608 bit32 parameter, 4609 bit32 agFrameLen 4610 ) 4611 { 4612 /* 4613 at target only 4614 uses jumptable, not callback 4615 */ 4616 /* 4617 agDevHandle_t->osData points to tdssDeviceData_t 4618 */ 4619 tdsaDeviceData_t *pDeviceData = (tdsaDeviceData_t *) agDevHandle->osData; 4620 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y7"); 4621 4622 /* tdtypes.h, calling ttdsaSSPReqReceived() in ttdio.c */ 4623 pDeviceData->pJumpTable->pSSPReqReceived ( 4624 agRoot, 4625 agDevHandle, 4626 agFrameHandle, 4627 agInitiatorTag, 4628 parameter, 4629 agFrameLen 4630 ); 4631 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y7"); 4632 return; 4633 } 4634 /*****************************************************************************/ 4635 /*! \brief ossaStallThread 4636 * 4637 * 4638 * Purpose: This routine is called to stall this thread for a number of 4639 * microseconds. 4640 * 4641 * 4642 * \param agRoot: Pointer to chip/driver Instance. 4643 * \param microseconds: Micro second to stall. 4644 * 4645 * 4646 * \return None. 4647 * 4648 * \note - The scope is shared target and initiator. 4649 * 4650 */ 4651 /*****************************************************************************/ 4652 osGLOBAL void ossaStallThread(agsaRoot_t *agRoot, 4653 bit32 microseconds 4654 ) 4655 { 4656 tdsaRootOsData_t *pOsData = (tdsaRootOsData_t *) (agRoot->osData); 4657 4658 ostiStallThread ( 4659 pOsData->tiRoot, 4660 microseconds 4661 ); 4662 return; 4663 } 4664 4665 4666 /***************************************************************************** 4667 *! \brief ossaSSPEvent 4668 * 4669 * This routine is called to notify the OS Layer of an event associated with 4670 * SAS port or SAS device 4671 * 4672 * \param agRoot: Handles for this instance of SAS/SATA hardware 4673 * \param agIORequest Pointer to IO request 4674 * \param event: event type 4675 * \param agIOInfoLen: not in use 4676 * \param agFrameHandle: not in use 4677 * 4678 * \return: none 4679 * 4680 *****************************************************************************/ 4681 /* in case of CMD ACK_NAK timeout, send query task */ 4682 osGLOBAL void ossaSSPEvent( 4683 agsaRoot_t *agRoot, 4684 agsaIORequest_t *agIORequest, 4685 agsaPortContext_t *agPortContext, 4686 agsaDevHandle_t *agDevHandle, 4687 bit32 event, 4688 bit16 sspTag, 4689 bit32 agIOInfoLen, 4690 void *agParam 4691 ) 4692 { 4693 #ifdef INITIATOR_DRIVER 4694 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 4695 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 4696 /* bit32 intContext = osData->IntContext; */ 4697 void *osMemHandle; 4698 tdIORequestBody_t *TMtdIORequestBody; 4699 bit32 PhysUpper32; 4700 bit32 PhysLower32; 4701 bit32 memAllocStatus; 4702 bit32 agRequestType; 4703 agsaIORequest_t *agTMIORequest = agNULL; /* task management itself */ 4704 agsaSASRequestBody_t *agSASRequestBody = agNULL; 4705 agsaSSPScsiTaskMgntReq_t *agSSPTaskMgntRequest; 4706 bit32 saStatus; 4707 bit32 agIORequestType; /* type of IO recevied */ 4708 tiIORequest_t *taskTag; /* being task managed one */ 4709 tdIORequestBody_t *tdIORequestBody; 4710 #endif 4711 4712 #ifdef REMOVED 4713 tiDeviceHandle_t *tiDeviceHandle; 4714 tdsaDeviceData_t *oneDeviceData = agNULL; 4715 tdIORequestBody_t *tdAbortIORequestBody; 4716 #endif 4717 agsaDifDetails_t agDifDetails; 4718 bit8 framePayload[256]; 4719 #ifdef REMOVED 4720 bit16 frameOffset = 0; 4721 #endif 4722 bit16 frameLen = 0; 4723 4724 TI_DBG6(("ossaSSPEvent: start\n")); 4725 smTraceFuncEnter(hpDBG_VERY_LOUD,"Y9"); 4726 4727 4728 4729 if (event == OSSA_IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT || 4730 event == OSSA_IO_XFER_ERROR_BREAK || 4731 event == OSSA_IO_XFER_ERROR_PHY_NOT_READY 4732 ) 4733 { 4734 4735 /* IO being task managed(the original IO) depending on event */ 4736 #ifdef INITIATOR_DRIVER 4737 tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4738 taskTag = tdIORequestBody->tiIORequest; 4739 #endif 4740 #ifdef REMOVED 4741 tiDeviceHandle = tdIORequestBody->tiDevHandle; 4742 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 4743 #endif 4744 4745 #ifdef INITIATOR_DRIVER 4746 agIORequestType = tdIORequestBody->agRequestType; 4747 4748 /* error checking; only command is expected here */ 4749 if (agIORequestType == AGSA_REQ_TYPE_UNKNOWN) 4750 { 4751 TI_DBG1(("ossaSSPEvent: incorrect frame 0x%x. Should be command\n", agIORequestType)); 4752 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Y9"); 4753 return; 4754 } 4755 4756 /* Allocate memory for query task management */ 4757 memAllocStatus = ostiAllocMemory( 4758 tiRoot, 4759 &osMemHandle, 4760 (void **)&TMtdIORequestBody, 4761 &PhysUpper32, 4762 &PhysLower32, 4763 8, 4764 sizeof(tdIORequestBody_t), 4765 agTRUE 4766 ); 4767 4768 if (memAllocStatus != tiSuccess) 4769 { 4770 /* let os process IO */ 4771 TI_DBG1(("ossaSSPEvent: ostiAllocMemory failed...\n")); 4772 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "Y9"); 4773 return; 4774 } 4775 4776 if (TMtdIORequestBody == agNULL) 4777 { 4778 /* let os process IO */ 4779 TI_DBG1(("ossaSSPEvent: ostiAllocMemory returned NULL TMIORequestBody\n")); 4780 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "Y9"); 4781 return; 4782 } 4783 4784 /* setup task management structure */ 4785 TMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 4786 /* TD generates Query Task not OS layer */ 4787 TMtdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag = agNULL; 4788 TMtdIORequestBody->IOType.InitiatorTMIO.TaskTag = taskTag; 4789 4790 /* initialize callback function */ 4791 TMtdIORequestBody->IOCompletionFunc = itdssQueryTaskCompleted; 4792 4793 /* initialize tiDevhandle */ 4794 TMtdIORequestBody->tiDevHandle = tdIORequestBody->tiDevHandle; 4795 4796 4797 /* initialize agIORequest */ 4798 agTMIORequest = &(TMtdIORequestBody->agIORequest); 4799 agTMIORequest->osData = (void *) TMtdIORequestBody; 4800 agTMIORequest->sdkData = agNULL; /* LL takes care of this */ 4801 4802 /* request type */ 4803 agRequestType = AGSA_SSP_TASK_MGNT_REQ; 4804 TMtdIORequestBody->agRequestType = AGSA_SSP_TASK_MGNT_REQ; 4805 4806 /* 4807 initialize 4808 tdIORequestBody_t tdIORequestBody -> agSASRequestBody 4809 */ 4810 agSASRequestBody = &(TMtdIORequestBody->transport.SAS.agSASRequestBody); 4811 agSSPTaskMgntRequest = &(agSASRequestBody->sspTaskMgntReq); 4812 4813 /* fill up LUN field */ 4814 osti_memset(agSSPTaskMgntRequest->lun, 0, 8); 4815 4816 /* sets taskMgntFunction field */ 4817 agSSPTaskMgntRequest->taskMgntFunction = AGSA_QUERY_TASK; 4818 /* debugging */ 4819 if (TMtdIORequestBody->IOCompletionFunc == agNULL) 4820 { 4821 TI_DBG1(("ossaSSPEvent: Error !!! IOCompletionFunc is NULL\n")); 4822 } 4823 /* send query task management */ 4824 saStatus = saSSPStart(agRoot, 4825 agTMIORequest, 4826 0, 4827 agDevHandle, 4828 agRequestType, 4829 agSASRequestBody, 4830 agIORequest, 4831 &ossaSSPCompleted); 4832 4833 if (saStatus != AGSA_RC_SUCCESS) 4834 { 4835 /* free up allocated memory */ 4836 ostiFreeMemory( 4837 tiRoot, 4838 TMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle, 4839 sizeof(tdIORequestBody_t) 4840 ); 4841 TI_DBG1(("ossaSSPEvent: saSSPStart failed\n")); 4842 return; 4843 } 4844 #endif 4845 } 4846 #ifdef REMOVED 4847 else if (event == OSSA_IO_ABORTED) 4848 { 4849 TI_DBG2(("ossaSSPEvent: OSSA_IO_ABORTED\n")); 4850 /* clean up TD layer's IORequestBody */ 4851 tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4852 ostiFreeMemory( 4853 tiRoot, 4854 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 4855 sizeof(tdIORequestBody_t) 4856 ); 4857 4858 } 4859 else if (event == OSSA_IO_NOT_VALID) 4860 { 4861 TI_DBG1(("ossaSSPEvent: OSSA_IO_NOT_VALID\n")); 4862 tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4863 ostiFreeMemory( 4864 tiRoot, 4865 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 4866 sizeof(tdIORequestBody_t) 4867 ); 4868 4869 4870 } 4871 #endif 4872 else if (event == OSSA_IO_XFER_CMD_FRAME_ISSUED) 4873 { 4874 TI_DBG2(("ossaSSPEvent: OSSA_IO_XFER_CMD_FRAME_ISSUED\n")); 4875 } 4876 else if (event == OSSA_IO_XFER_ERROR_OFFSET_MISMATCH) 4877 { 4878 TI_DBG1(("ossaSSPEvent: OSSA_IO_XFER_ERROR_OFFSET_MISMATCH\n")); 4879 } 4880 else if (event == OSSA_IO_OVERFLOW) 4881 { 4882 TI_DBG1(("ossaSSPEvent: OSSA_IO_OVERFLOW\n")); 4883 /* 4884 ??? can't call; missing agIOInfoLen 4885 ostiInitiatorIOCompleted ( 4886 tiRoot, 4887 tdIORequestBody->tiIORequest, 4888 tiIOOverRun, 4889 agIOInfoLen, 4890 agNULL, 4891 intContext 4892 ); 4893 4894 */ 4895 4896 } 4897 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED) 4898 { 4899 TI_DBG1(("ossaSSPEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED\n")); 4900 } 4901 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO) 4902 { 4903 TI_DBG1(("ossaSSPEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO\n")); 4904 } 4905 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST) 4906 { 4907 TI_DBG1(("ossaSSPEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST\n")); 4908 } 4909 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE) 4910 { 4911 TI_DBG1(("ossaSSPEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE\n")); 4912 } 4913 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED) 4914 { 4915 TI_DBG1(("ossaSSPEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED\n")); 4916 } 4917 else if (event == OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH) 4918 { 4919 TI_DBG1(("ossaSSPEvent: OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH\n")); 4920 } 4921 else if (event == OSSA_IO_XFER_ERROR_XFER_RDY_OVERRUN) 4922 { 4923 TI_DBG1(("ossaSSPEvent: OSSA_IO_XFER_ERROR_XFER_RDY_OVERRUN\n")); 4924 } 4925 else if (event == OSSA_IO_XFR_ERROR_DIF_MISMATCH || 4926 event == OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH || 4927 event == OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH || 4928 event == OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH ) 4929 { 4930 TI_DBG1(("ossaSSPEvent: DIF related, event 0x%x\n", event)); 4931 /* process DIF detail information */ 4932 TI_DBG2(("ossaSSPEvent: agIOInfoLen %d\n", agIOInfoLen)); 4933 if (agParam == agNULL) 4934 { 4935 TI_DBG2(("ossaSSPEvent: agParam is NULL!!!\n")); 4936 return; 4937 } 4938 if (agIOInfoLen < sizeof(agsaDifDetails_t)) 4939 { 4940 TI_DBG2(("ossaSSPEvent: wrong agIOInfoLen!!! agIOInfoLen %d sizeof(agsaDifDetails_t) %d\n", agIOInfoLen, (int)sizeof(agsaDifDetails_t))); 4941 return; 4942 } 4943 /* reads agsaDifDetails_t */ 4944 saFrameReadBlock(agRoot, agParam, 0, &agDifDetails, sizeof(agsaDifDetails_t)); 4945 #ifdef REMOVED 4946 frameOffset = (agDifDetails.ErrBoffsetEDataLen & 0xFFFF); 4947 #endif 4948 frameLen = (bit16)((agDifDetails.ErrBoffsetEDataLen & 0xFFFF0000) >> 16); 4949 4950 TI_DBG2(("ossaSSPEvent: UpperLBA 0x%08x LowerLBA 0x%08x\n", agDifDetails.UpperLBA, agDifDetails.LowerLBA)); 4951 TI_DBG2(("ossaSSPEvent: SASAddrHI 0x%08x SASAddrLO 0x%08x\n", 4952 TD_GET_SAS_ADDRESSHI(agDifDetails.sasAddressHi), TD_GET_SAS_ADDRESSLO(agDifDetails.sasAddressLo))); 4953 TI_DBG2(("ossaSSPEvent: DIF error mask 0x%x Device ID 0x%x\n", 4954 (agDifDetails.DIFErrDevID) & 0xFF, (agDifDetails.DIFErrDevID & 0xFFFF0000) >> 16)); 4955 if (frameLen != 0 && frameLen <= 256) 4956 { 4957 saFrameReadBlock(agRoot, agParam, sizeof(agsaDifDetails_t), framePayload, frameLen); 4958 tdhexdump("ossaSSPEvent frame", framePayload, frameLen); 4959 } 4960 } 4961 else 4962 { 4963 TI_DBG1(("ossaSSPEvent: other event 0x%x\n", event)); 4964 } 4965 4966 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "Y9"); 4967 return; 4968 } 4969 4970 #ifdef FDS_SM 4971 osGLOBAL void ossaSATAIDAbortCB( 4972 agsaRoot_t *agRoot, 4973 agsaIORequest_t *agIORequest, 4974 bit32 flag, 4975 bit32 status) 4976 { 4977 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 4978 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 4979 tdIORequestBody_t *tdAbortIORequestBody; 4980 4981 TI_DBG1(("ossaSATAIDAbortCB: start flag %d status %d\n", flag, status)); 4982 4983 tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4984 4985 /* 4986 triggered by tdIDStartTimerCB 4987 */ 4988 ostiFreeMemory( 4989 tiRoot, 4990 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 4991 sizeof(tdIORequestBody_t) 4992 ); 4993 return; 4994 } 4995 #endif 4996 4997 #ifdef INITIATOR_DRIVER 4998 osGLOBAL void ossaSSPAbortCB( 4999 agsaRoot_t *agRoot, 5000 agsaIORequest_t *agIORequest, 5001 bit32 flag, 5002 bit32 status) 5003 { 5004 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5005 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5006 tdIORequestBody_t *tdAbortIORequestBody = agNULL; 5007 tdsaDeviceData_t *oneDeviceData = agNULL; 5008 tiDeviceHandle_t *tiDeviceHandle = agNULL; 5009 tiIORequest_t *taskTag = agNULL; 5010 5011 TI_DBG2(("ossaSSPAbortCB: start\n")); 5012 smTraceFuncEnter(hpDBG_VERY_LOUD,"Ya"); 5013 5014 tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 5015 if (tdAbortIORequestBody == agNULL) 5016 { 5017 TI_DBG1(("ossaSSPAbortCB: tdAbortIORequestBody is NULL warning!!!!\n")); 5018 return; 5019 } 5020 5021 if (flag == 2) 5022 { 5023 /* abort per port */ 5024 TI_DBG1(("ossaSSPAbortCB: abort per port\n")); 5025 } 5026 else if (flag == 1) 5027 { 5028 TI_DBG2(("ossaSSPAbortCB: abort all\n")); 5029 5030 tiDeviceHandle = (tiDeviceHandle_t *)tdAbortIORequestBody->tiDevHandle; 5031 if (tiDeviceHandle == agNULL) 5032 { 5033 TI_DBG1(("ossaSSPAbortCB: tiDeviceHandle is NULL warning!!!!\n")); 5034 ostiFreeMemory( 5035 tiRoot, 5036 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5037 sizeof(tdIORequestBody_t) 5038 ); 5039 return; 5040 } 5041 5042 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 5043 if (oneDeviceData == agNULL) 5044 { 5045 TI_DBG1(("ossaSSPAbortCB: oneDeviceData is NULL warning!!!!\n")); 5046 ostiFreeMemory( 5047 tiRoot, 5048 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5049 sizeof(tdIORequestBody_t) 5050 ); 5051 return; 5052 } 5053 5054 if (status == OSSA_IO_SUCCESS) 5055 { 5056 TI_DBG2(("ossaSSPAbortCB: OSSA_IO_SUCCESS\n")); 5057 /* clean up TD layer's IORequestBody */ 5058 if (oneDeviceData->OSAbortAll == agTRUE) 5059 { 5060 oneDeviceData->OSAbortAll = agFALSE; 5061 ostiInitiatorEvent( tiRoot, 5062 agNULL, 5063 tiDeviceHandle, 5064 tiIntrEventTypeLocalAbort, 5065 tiAbortOK, 5066 agNULL); 5067 } 5068 else 5069 { 5070 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5071 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5072 } 5073 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5074 ostiFreeMemory( 5075 tiRoot, 5076 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5077 sizeof(tdIORequestBody_t) 5078 ); 5079 5080 } 5081 else if (status == OSSA_IO_NOT_VALID) 5082 { 5083 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NOT_VALID\n")); 5084 /* clean up TD layer's IORequestBody */ 5085 if (oneDeviceData->OSAbortAll == agTRUE) 5086 { 5087 oneDeviceData->OSAbortAll = agFALSE; 5088 ostiInitiatorEvent( tiRoot, 5089 agNULL, 5090 tiDeviceHandle, 5091 tiIntrEventTypeLocalAbort, 5092 tiAbortFailed, 5093 agNULL ); 5094 } 5095 else 5096 { 5097 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5098 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5099 } 5100 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5101 ostiFreeMemory( 5102 tiRoot, 5103 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5104 sizeof(tdIORequestBody_t) 5105 ); 5106 } 5107 else if (status == OSSA_IO_NO_DEVICE) 5108 { 5109 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NO_DEVICE\n")); 5110 /* clean up TD layer's IORequestBody */ 5111 if (oneDeviceData->OSAbortAll == agTRUE) 5112 { 5113 oneDeviceData->OSAbortAll = agFALSE; 5114 ostiInitiatorEvent( tiRoot, 5115 agNULL, 5116 tiDeviceHandle, 5117 tiIntrEventTypeLocalAbort, 5118 tiAbortInProgress, 5119 agNULL ); 5120 } 5121 else 5122 { 5123 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5124 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5125 } 5126 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5127 ostiFreeMemory( 5128 tiRoot, 5129 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5130 sizeof(tdIORequestBody_t) 5131 ); 5132 } 5133 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 5134 { 5135 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 5136 /* clean up TD layer's IORequestBody */ 5137 if (oneDeviceData->OSAbortAll == agTRUE) 5138 { 5139 oneDeviceData->OSAbortAll = agFALSE; 5140 ostiInitiatorEvent( tiRoot, 5141 agNULL, 5142 tiDeviceHandle, 5143 tiIntrEventTypeLocalAbort, 5144 tiAbortInProgress, 5145 agNULL ); 5146 } 5147 else 5148 { 5149 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5150 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5151 } 5152 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5153 ostiFreeMemory( 5154 tiRoot, 5155 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5156 sizeof(tdIORequestBody_t) 5157 ); 5158 } 5159 #ifdef REMOVED 5160 else if (status == OSSA_IO_ABORT_DELAYED) 5161 { 5162 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_DELAYED\n")); 5163 /* clean up TD layer's IORequestBody */ 5164 if (oneDeviceData->OSAbortAll == agTRUE) 5165 { 5166 oneDeviceData->OSAbortAll = agFALSE; 5167 ostiInitiatorEvent( tiRoot, 5168 agNULL, 5169 tiDeviceHandle, 5170 tiIntrEventTypeLocalAbort, 5171 tiAbortDelayed, 5172 agNULL ); 5173 } 5174 else 5175 { 5176 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5177 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5178 } 5179 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5180 ostiFreeMemory( 5181 tiRoot, 5182 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5183 sizeof(tdIORequestBody_t) 5184 ); 5185 } 5186 #endif 5187 else 5188 { 5189 TI_DBG1(("ossaSSPAbortCB: other status %d\n", status)); 5190 /* clean up TD layer's IORequestBody */ 5191 if (oneDeviceData->OSAbortAll == agTRUE) 5192 { 5193 oneDeviceData->OSAbortAll = agFALSE; 5194 ostiInitiatorEvent( tiRoot, 5195 agNULL, 5196 tiDeviceHandle, 5197 tiIntrEventTypeLocalAbort, 5198 tiAbortInProgress, 5199 agNULL ); 5200 } 5201 else 5202 { 5203 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5204 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5205 } 5206 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5207 ostiFreeMemory( 5208 tiRoot, 5209 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5210 sizeof(tdIORequestBody_t) 5211 ); 5212 } 5213 } 5214 else if (flag == 0) 5215 { 5216 TI_DBG2(("ossaSSPAbortCB: abort one\n")); 5217 taskTag = tdAbortIORequestBody->tiIOToBeAbortedRequest; 5218 5219 if ( taskTag == agNULL) 5220 { 5221 TI_DBG1(("ossaSSPAbortCB: taskTag is NULL; triggered by itdssQueryTaskCompleted\n")); 5222 } 5223 if (status == OSSA_IO_SUCCESS) 5224 { 5225 TI_DBG2(("ossaSSPAbortCB: OSSA_IO_SUCCESS\n")); 5226 if (taskTag != agNULL) 5227 { 5228 ostiInitiatorEvent( tiRoot, 5229 agNULL, 5230 agNULL, 5231 tiIntrEventTypeLocalAbort, 5232 tiAbortOK, 5233 taskTag ); 5234 } 5235 ostiFreeMemory( 5236 tiRoot, 5237 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5238 sizeof(tdIORequestBody_t) 5239 ); 5240 5241 } 5242 else if (status == OSSA_IO_NOT_VALID) 5243 { 5244 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NOT_VALID\n")); 5245 5246 if (taskTag != agNULL) 5247 { 5248 ostiInitiatorEvent( tiRoot, 5249 agNULL, 5250 agNULL, 5251 tiIntrEventTypeLocalAbort, 5252 tiAbortFailed, 5253 taskTag ); 5254 } 5255 ostiFreeMemory( 5256 tiRoot, 5257 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5258 sizeof(tdIORequestBody_t) 5259 ); 5260 } 5261 else if (status == OSSA_IO_NO_DEVICE) 5262 { 5263 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NO_DEVICE\n")); 5264 5265 if (taskTag != agNULL) 5266 { 5267 ostiInitiatorEvent( tiRoot, 5268 agNULL, 5269 agNULL, 5270 tiIntrEventTypeLocalAbort, 5271 tiAbortInProgress, 5272 taskTag ); 5273 } 5274 ostiFreeMemory( 5275 tiRoot, 5276 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5277 sizeof(tdIORequestBody_t) 5278 ); 5279 } 5280 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 5281 { 5282 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 5283 5284 if (taskTag != agNULL) 5285 { 5286 ostiInitiatorEvent( tiRoot, 5287 agNULL, 5288 agNULL, 5289 tiIntrEventTypeLocalAbort, 5290 tiAbortInProgress, 5291 taskTag ); 5292 } 5293 ostiFreeMemory( 5294 tiRoot, 5295 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5296 sizeof(tdIORequestBody_t) 5297 ); 5298 } 5299 #ifdef REMOVED 5300 else if (status == OSSA_IO_ABORT_DELAYED) 5301 { 5302 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_DELAYED\n")); 5303 5304 if (taskTag != agNULL) 5305 { 5306 ostiInitiatorEvent( tiRoot, 5307 agNULL, 5308 agNULL, 5309 tiIntrEventTypeLocalAbort, 5310 tiAbortDelayed, 5311 taskTag ); 5312 } 5313 ostiFreeMemory( 5314 tiRoot, 5315 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5316 sizeof(tdIORequestBody_t) 5317 ); 5318 } 5319 #endif 5320 else 5321 { 5322 TI_DBG1(("ossaSSPAbortCB: other status %d\n", status)); 5323 5324 if (taskTag != agNULL) 5325 { 5326 ostiInitiatorEvent( tiRoot, 5327 agNULL, 5328 agNULL, 5329 tiIntrEventTypeLocalAbort, 5330 tiAbortFailed, 5331 taskTag ); 5332 } 5333 ostiFreeMemory( 5334 tiRoot, 5335 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5336 sizeof(tdIORequestBody_t) 5337 ); 5338 } 5339 } 5340 else 5341 { 5342 TI_DBG1(("ossaSSPAbortCB: wrong flag %d\n", flag)); 5343 } 5344 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Ya"); 5345 return; 5346 5347 } 5348 #endif 5349 5350 5351 #ifdef TARGET_DRIVER 5352 osGLOBAL void ossaSSPAbortCB( 5353 agsaRoot_t *agRoot, 5354 agsaIORequest_t *agIORequest, 5355 bit32 flag, 5356 bit32 status) 5357 { 5358 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5359 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5360 tdIORequestBody_t *tdAbortIORequestBody; 5361 tdsaDeviceData_t *oneDeviceData; 5362 tiDeviceHandle_t *tiDeviceHandle; 5363 5364 TI_DBG3(("ossaSSPAbortCB: start\n")); 5365 tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 5366 5367 if (flag == 2) 5368 { 5369 /* abort per port */ 5370 TI_DBG2(("ossaSSPAbortCB: abort per port\n")); 5371 } 5372 else if (flag == 1) 5373 { 5374 TI_DBG2(("ossaSSPAbortCB: abort all\n")); 5375 tiDeviceHandle = (tiDeviceHandle_t *)tdAbortIORequestBody->tiDevHandle; 5376 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 5377 if (status == OSSA_IO_SUCCESS) 5378 { 5379 TI_DBG2(("ossaSSPAbortCB: OSSA_IO_SUCCESS\n")); 5380 /* clean up TD layer's IORequestBody */ 5381 TI_DBG3(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5382 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5383 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5384 ostiFreeMemory( 5385 tiRoot, 5386 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5387 sizeof(tdIORequestBody_t) 5388 ); 5389 5390 } 5391 else if (status == OSSA_IO_NOT_VALID) 5392 { 5393 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NOT_VALID\n")); 5394 /* clean up TD layer's IORequestBody */ 5395 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5396 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5397 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5398 ostiFreeMemory( 5399 tiRoot, 5400 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5401 sizeof(tdIORequestBody_t) 5402 ); 5403 } 5404 else if (status == OSSA_IO_NO_DEVICE) 5405 { 5406 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NO_DEVICE\n")); 5407 /* clean up TD layer's IORequestBody */ 5408 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5409 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5410 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5411 ostiFreeMemory( 5412 tiRoot, 5413 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5414 sizeof(tdIORequestBody_t) 5415 ); 5416 } 5417 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 5418 { 5419 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 5420 /* clean up TD layer's IORequestBody */ 5421 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5422 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5423 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5424 ostiFreeMemory( 5425 tiRoot, 5426 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5427 sizeof(tdIORequestBody_t) 5428 ); 5429 } 5430 #ifdef REMOVED 5431 else if (status == OSSA_IO_ABORT_DELAYED) 5432 { 5433 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_DELAYED\n")); 5434 /* clean up TD layer's IORequestBody */ 5435 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5436 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5437 TI_DBG2(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5438 ostiFreeMemory( 5439 tiRoot, 5440 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5441 sizeof(tdIORequestBody_t) 5442 ); 5443 } 5444 #endif 5445 else 5446 { 5447 TI_DBG1(("ossaSSPAbortCB: other status %d\n", status)); 5448 /* clean up TD layer's IORequestBody */ 5449 TI_DBG2(("ossaSSPAbortCB: calling saDeregisterDeviceHandle\n")); 5450 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 5451 TI_DBG1(("ossaSSPAbortCB: did %d\n", oneDeviceData->id)); 5452 ostiFreeMemory( 5453 tiRoot, 5454 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5455 sizeof(tdIORequestBody_t) 5456 ); 5457 } 5458 } 5459 else if (flag == 0) 5460 { 5461 TI_DBG2(("ossaSSPAbortCB: abort one\n")); 5462 if (status == OSSA_IO_SUCCESS) 5463 { 5464 TI_DBG2(("ossaSSPAbortCB: OSSA_IO_SUCCESS\n")); 5465 ostiFreeMemory( 5466 tiRoot, 5467 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5468 sizeof(tdIORequestBody_t) 5469 ); 5470 5471 } 5472 else if (status == OSSA_IO_NOT_VALID) 5473 { 5474 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NOT_VALID\n")); 5475 ostiFreeMemory( 5476 tiRoot, 5477 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5478 sizeof(tdIORequestBody_t) 5479 ); 5480 } 5481 else if (status == OSSA_IO_NO_DEVICE) 5482 { 5483 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_NO_DEVICE\n")); 5484 ostiFreeMemory( 5485 tiRoot, 5486 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5487 sizeof(tdIORequestBody_t) 5488 ); 5489 } 5490 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 5491 { 5492 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 5493 ostiFreeMemory( 5494 tiRoot, 5495 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5496 sizeof(tdIORequestBody_t) 5497 ); 5498 } 5499 #ifdef REMOVED 5500 else if (status == OSSA_IO_ABORT_DELAYED) 5501 { 5502 TI_DBG1(("ossaSSPAbortCB: OSSA_IO_ABORT_DELAYED\n")); 5503 ostiFreeMemory( 5504 tiRoot, 5505 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5506 sizeof(tdIORequestBody_t) 5507 ); 5508 } 5509 #endif 5510 else 5511 { 5512 TI_DBG1(("ossaSSPAbortCB: other status %d\n", status)); 5513 ostiFreeMemory( 5514 tiRoot, 5515 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 5516 sizeof(tdIORequestBody_t) 5517 ); 5518 } 5519 } 5520 else 5521 { 5522 TI_DBG1(("ossaSSPAbortCB: wrong flag %d\n", flag)); 5523 } 5524 5525 return; 5526 5527 } 5528 #endif 5529 5530 5531 /*****************************************************************************/ 5532 /*! \brief ossaLocalPhyControlCB 5533 * 5534 * 5535 * Purpose: This routine is called by lower layer to indicate the status of 5536 * phy operations 5537 * 5538 * \param agRoot: Pointer to chip/driver Instance. 5539 * \param phyId Phy id 5540 * \param phyOperation Operation to be done on the phy 5541 * \param status Phy operation specific completion status 5542 * \param parm Additional parameter, phy operation and status specific 5543 * 5544 * 5545 * \return None. 5546 * 5547 */ 5548 /*****************************************************************************/ 5549 osGLOBAL void ossaLocalPhyControlCB( 5550 agsaRoot_t *agRoot, 5551 agsaContext_t *agContext, 5552 bit32 phyId, 5553 bit32 phyOperation, 5554 bit32 status, 5555 void *parm 5556 ) 5557 { 5558 #ifdef REMVOED 5559 agsaPhyErrCounters_t *agPhyErrCounters; 5560 #endif 5561 #ifdef INITIATOR_DRIVER 5562 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5563 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5564 tiIORequest_t *currentTaskTag; 5565 tdsaDeviceData_t *TargetDeviceData; 5566 satDeviceData_t *pSatDevData; 5567 agsaDevHandle_t *agDevHandle = agNULL; 5568 agsaContext_t *agContextDevice; 5569 #endif 5570 5571 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yb"); 5572 TI_DBG3(("ossaLocalPhyControlCB: start phyID %d\n", phyId)); 5573 TI_DBG3(("ossaLocalPhyControlCB: phyOperation %d status 0x%x\n", phyOperation, status)); 5574 switch (phyOperation) 5575 { 5576 case AGSA_PHY_LINK_RESET: /* fall through */ 5577 case AGSA_PHY_HARD_RESET: 5578 if (phyOperation == AGSA_PHY_LINK_RESET) 5579 { 5580 TI_DBG1(("ossaLocalPhyControlCB: AGSA_PHY_LINK_RESET, status 0x%x\n", status)); 5581 } 5582 else 5583 { 5584 TI_DBG1(("ossaLocalPhyControlCB: AGSA_PHY_HARD_RESET, status 0x%x\n", status)); 5585 } 5586 #ifdef INITIATOR_DRIVER 5587 if (agContext != agNULL) 5588 { 5589 currentTaskTag = (tiIORequest_t *)agContext->osData; 5590 if (status == OSSA_SUCCESS) 5591 { 5592 if (currentTaskTag != agNULL) 5593 { 5594 TI_DBG2(("ossaLocalPhyControlCB: callback to OS layer with success\n")); 5595 TargetDeviceData = (tdsaDeviceData_t *)currentTaskTag->tdData; 5596 pSatDevData = (satDeviceData_t *)&(TargetDeviceData->satDevData); 5597 agDevHandle = TargetDeviceData->agDevHandle; 5598 TI_DBG2(("ossaLocalPhyControlCB: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 5599 TI_DBG2(("ossaLocalPhyControlCB: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 5600 pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 5601 5602 if (TargetDeviceData->TRflag == agTRUE) 5603 { 5604 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, TargetDeviceData), agDevHandle, SA_DS_OPERATIONAL); 5605 TargetDeviceData->TRflag = agFALSE; 5606 ostiInitiatorEvent(tiRoot, 5607 TargetDeviceData->tdPortContext->tiPortalContext, 5608 &(TargetDeviceData->tiDeviceHandle), 5609 tiIntrEventTypeTransportRecovery, 5610 tiRecOK, 5611 agNULL 5612 ); 5613 } 5614 else 5615 { 5616 agDevHandle = TargetDeviceData->agDevHandle; 5617 if (agDevHandle == agNULL) 5618 { 5619 TI_DBG1(("ossaLocalPhyControlCB: wrong, agDevHandle is NULL\n")); 5620 } 5621 /* move this to OSSA_HW_EVENT_PORT_RESET_COMPLETE in ossaHwCB() */ 5622 agContextDevice = &(TargetDeviceData->agDeviceResetContext); 5623 agContextDevice->osData = currentTaskTag; 5624 5625 #ifdef REMOVED 5626 ostiInitiatorEvent( tiRoot, 5627 NULL, 5628 NULL, 5629 tiIntrEventTypeTaskManagement, 5630 tiTMOK, 5631 currentTaskTag ); 5632 #endif 5633 } 5634 } 5635 } 5636 else 5637 { 5638 if (currentTaskTag != agNULL) 5639 { 5640 TI_DBG1(("ossaLocalPhyControlCB: callback to OS layer with failure\n")); 5641 TargetDeviceData = (tdsaDeviceData_t *)currentTaskTag->tdData; 5642 pSatDevData = (satDeviceData_t *)&(TargetDeviceData->satDevData); 5643 TI_DBG1(("ossaLocalPhyControlCB: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 5644 TI_DBG1(("ossaLocalPhyControlCB: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 5645 if (TargetDeviceData->TRflag == agTRUE) 5646 { 5647 TargetDeviceData->TRflag = agFALSE; 5648 ostiInitiatorEvent(tiRoot, 5649 TargetDeviceData->tdPortContext->tiPortalContext, 5650 &(TargetDeviceData->tiDeviceHandle), 5651 tiIntrEventTypeTransportRecovery, 5652 tiRecFailed , 5653 agNULL 5654 ); 5655 } 5656 else 5657 { 5658 ostiInitiatorEvent( tiRoot, 5659 NULL, 5660 NULL, 5661 tiIntrEventTypeTaskManagement, 5662 tiTMFailed, 5663 currentTaskTag ); 5664 } 5665 } 5666 } 5667 } 5668 #endif 5669 break; 5670 #ifdef REMOVED 5671 case AGSA_PHY_GET_ERROR_COUNTS: 5672 5673 TI_DBG2(("ossaLocalPhyControlCB: AGSA_PHY_GET_ERROR_COUNTS, status 0x%x\n", status)); 5674 if(parm !=agNULL ) 5675 { 5676 agPhyErrCounters = (agsaPhyErrCounters_t *)parm; 5677 TI_DBG2(("ossaLocalPhyControlCB: invalidDword %d\n", agPhyErrCounters->invalidDword)); 5678 TI_DBG2(("ossaLocalPhyControlCB: runningDisparityError %d\n", agPhyErrCounters->runningDisparityError)); 5679 TI_DBG2(("ossaLocalPhyControlCB: lostOfDwordSynch %d\n", agPhyErrCounters->lossOfDwordSynch)); 5680 TI_DBG2(("ossaLocalPhyControlCB: phyResetProblem %d\n", agPhyErrCounters->phyResetProblem)); 5681 TI_DBG2(("ossaLocalPhyControlCB: elasticityBufferOverflow %d\n", agPhyErrCounters->elasticityBufferOverflow)); 5682 TI_DBG2(("ossaLocalPhyControlCB: receivedErrorPrimitive %d\n", agPhyErrCounters->receivedErrorPrimitive)); 5683 } 5684 break; 5685 case AGSA_PHY_CLEAR_ERROR_COUNTS: 5686 TI_DBG2(("ossaLocalPhyControlCB: AGSA_PHY_CLEAR_ERROR_COUNTS, status 0x%x\n", status)); 5687 break; 5688 #endif 5689 case AGSA_PHY_NOTIFY_ENABLE_SPINUP: 5690 TI_DBG2(("ossaLocalPhyControlCB: AGSA_PHY_NOTIFY_ENABLE_SPINUP, status 0x%x\n", status)); 5691 break; 5692 case AGSA_PHY_BROADCAST_ASYNCH_EVENT: 5693 TI_DBG2(("ossaLocalPhyControlCB: AGSA_PHY_BROADCAST_ASYNCH_EVENT, status 0x%x\n", status)); 5694 if (tIsSPC12SATA(agRoot)) 5695 { 5696 TI_DBG1(("ossaLocalPhyControlCB: BROADCAST_ASYNCH_EVENT received for SATA Controller\n")); 5697 break; 5698 } 5699 break; 5700 case AGSA_PHY_COMINIT_OOB : 5701 TI_DBG2(("ossaLocalPhyControlCB: AGSA_PHY_COMINIT_OOB, status 0x%x\n", status)); 5702 break; 5703 default: 5704 TI_DBG1(("ossaLocalPhyControlCB: UNKNOWN default case. phyOperation %d status 0x%x\n", phyOperation, status)); 5705 break; 5706 } 5707 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yb"); 5708 return; 5709 } 5710 5711 GLOBAL void ossaGetPhyProfileCB( 5712 agsaRoot_t *agRoot, 5713 agsaContext_t *agContext, 5714 bit32 status, 5715 bit32 ppc, 5716 bit32 phyID, 5717 void *parm ) 5718 { 5719 5720 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5721 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5722 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 5723 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 5724 #ifdef CCFLAGS_PHYCONTROL_COUNTS 5725 agsaPhyAnalogSettingsPage_t *analog; 5726 #endif /* CCFLAGS_PHYCONTROL_COUNTS */ 5727 tdPhyCount_t *PhyBlob = agNULL; 5728 5729 agsaPhyBWCountersPage_t *agBWCounters; 5730 agsaPhyErrCountersPage_t *agPhyErrCounters; 5731 TI_DBG1(("ossaGetPhyProfileCB: agContext %p parm %p\n", agContext, parm)); 5732 /* 5733 if( tdsaAllShared->tdFWControlEx.inProgress ) 5734 { 5735 tdsaAllShared->tdFWControlEx.inProgress = 0; 5736 PhyBlob = (tdPhyCount_t *)tdsaAllShared->tdFWControlEx.usrAddr; 5737 } 5738 */ 5739 switch(ppc) 5740 { 5741 case AGSA_SAS_PHY_BW_COUNTERS_PAGE: 5742 TI_DBG1(("ossaGetPhyProfileCB: AGSA_SAS_PHY_BW_COUNTERS_PAGE, status 0x%x phyID %d\n", status, phyID)); 5743 if(parm !=agNULL ) 5744 { 5745 agBWCounters = (agsaPhyBWCountersPage_t *)parm; 5746 TI_DBG1(("ossaGetPhyProfileCB: RX %d TX %d\n", agBWCounters->RXBWCounter,agBWCounters->TXBWCounter)); 5747 if(PhyBlob !=agNULL ) 5748 { 5749 PhyBlob->InvalidDword = 0; 5750 PhyBlob->runningDisparityError = 0; 5751 PhyBlob->codeViolation = 0; 5752 PhyBlob->phyResetProblem = 0; 5753 PhyBlob->inboundCRCError = 0; 5754 PhyBlob->BW_rx = agBWCounters->RXBWCounter; 5755 PhyBlob->BW_tx = agBWCounters->TXBWCounter; 5756 } 5757 5758 } 5759 break; 5760 case AGSA_SAS_PHY_ERR_COUNTERS_PAGE: 5761 if( tdsaAllShared->tdFWControlEx.inProgress ) 5762 { 5763 tdsaAllShared->tdFWControlEx.inProgress = 0; 5764 PhyBlob = (tdPhyCount_t *)tdsaAllShared->tdFWControlEx.usrAddr; 5765 } 5766 TI_DBG1(("ossaGetPhyProfileCB: AGSA_SAS_PHY_ERR_COUNTERS_PAGE, status 0x%x phyID %d\n", status, phyID)); 5767 if(parm !=agNULL ) 5768 { 5769 agPhyErrCounters = (agsaPhyErrCountersPage_t *)parm; 5770 if(PhyBlob !=agNULL ) 5771 { 5772 5773 PhyBlob->InvalidDword = agPhyErrCounters->invalidDword; 5774 PhyBlob->runningDisparityError = agPhyErrCounters->runningDisparityError; 5775 PhyBlob->LossOfSyncDW = agPhyErrCounters->lossOfDwordSynch; 5776 PhyBlob->codeViolation = agPhyErrCounters->codeViolation; 5777 PhyBlob->phyResetProblem = agPhyErrCounters->phyResetProblem; 5778 PhyBlob->inboundCRCError = agPhyErrCounters->inboundCRCError; 5779 PhyBlob->BW_rx = 0; 5780 PhyBlob->BW_tx = 0; 5781 5782 TI_DBG2(("ossaGetPhyProfileCB: invalidDword %d\n", agPhyErrCounters->invalidDword)); 5783 TI_DBG2(("ossaGetPhyProfileCB: runningDisparityError %d\n", agPhyErrCounters->runningDisparityError)); 5784 TI_DBG2(("ossaGetPhyProfileCB: lostOfDwordSynch %d\n", agPhyErrCounters->lossOfDwordSynch)); 5785 TI_DBG2(("ossaGetPhyProfileCB: phyResetProblem %d\n", agPhyErrCounters->phyResetProblem)); 5786 TI_DBG2(("ossaGetPhyProfileCB: inboundCRCError %d\n", agPhyErrCounters->inboundCRCError)); 5787 } 5788 } 5789 break; 5790 case AGSA_SAS_PHY_ERR_COUNTERS_CLR_PAGE: 5791 TI_DBG1(("ossaGetPhyProfileCB: AGSA_SAS_PHY_ERR_COUNTERS_CLR_PAGE status 0x%x phyID %d\n", status, phyID)); 5792 break; 5793 case AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE: 5794 TI_DBG1(("ossaGetPhyProfileCB:AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE status 0x%x phyID %d\n", status, phyID)); 5795 #ifdef CCFLAGS_PHYCONTROL_COUNTS 5796 if(parm !=agNULL ) 5797 { 5798 analog = (agsaPhyAnalogSettingsPage_t *)parm; 5799 TI_DBG1(("ossaGetPhyProfileCB: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", 5800 analog->Dword0, analog->Dword1, analog->Dword2, analog->Dword3, analog->Dword4, 5801 analog->Dword5, analog->Dword6, analog->Dword7, analog->Dword8, analog->Dword9)); 5802 tdsaAllShared->analog[phyID].spaRegister0 = analog->Dword0; 5803 tdsaAllShared->analog[phyID].spaRegister1 = analog->Dword1; 5804 tdsaAllShared->analog[phyID].spaRegister2 = analog->Dword2; 5805 tdsaAllShared->analog[phyID].spaRegister3 = analog->Dword3; 5806 tdsaAllShared->analog[phyID].spaRegister4 = analog->Dword4; 5807 saSetPhyProfile( agRoot,agContext,tdsaRotateQnumber(tiRoot, agNULL), AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE,sizeof(agsaPhyAnalogSetupRegisters_t),&tdsaAllShared->analog[phyID],phyID); 5808 } 5809 #endif /* CCFLAGS_PHYCONTROL_COUNTS */ 5810 break; 5811 case AGSA_SAS_PHY_OPEN_REJECT_RETRY_BACKOFF_THRESHOLD_PAGE: 5812 { 5813 TI_DBG1(("ossaGetPhyProfileCB:AGSA_SAS_PHY_OPEN_REJECT_RETRY_BACKOFF_THRESHOLD_PAGE status 0x%x phyID %d\n", status, phyID)); 5814 if( parm !=agNULL ) 5815 { 5816 #ifdef TD_DEBUG_ENABLE 5817 agsaSASPhyOpenRejectRetryBackOffThresholdPage_t *Backoff = 5818 (agsaSASPhyOpenRejectRetryBackOffThresholdPage_t *)parm; 5819 #endif 5820 TI_DBG2(("ossaGetPhyProfileCB: DW0 0x%X DW1 0x%X DW2 0x%X DW3 0x%X\n", 5821 Backoff->Dword0,Backoff->Dword1, 5822 Backoff->Dword2,Backoff->Dword3)); 5823 } 5824 break; 5825 } 5826 5827 case AGSA_SAS_PHY_GENERAL_STATUS_PAGE: 5828 { 5829 agsaSASPhyGeneralStatusPage_t * GenStatus = NULL; 5830 5831 TI_DBG1(("ossaGetPhyProfileCB: AGSA_SAS_PHY_GENERAL_STATUS_PAGE status 0x%x phyID %d\n", 5832 status, phyID)); 5833 if( parm !=agNULL ) 5834 { 5835 GenStatus= 5836 (agsaSASPhyGeneralStatusPage_t *)parm; 5837 TI_DBG2(("ossaGetPhyProfileCB: " 5838 "AGSA_SAS_PHY_GENERAL_STATUS_PAGE status %d DW0 0x%x DW1 0x%x\n", 5839 status, GenStatus->Dword0, GenStatus->Dword1)); 5840 } 5841 ostiGetPhyGeneralStatusRsp(tiRoot, GenStatus, phyID); 5842 // break; 5843 return ; 5844 } 5845 5846 default: 5847 TI_DBG1(("ossaGetPhyProfileCB: UNKNOWN default case. phyOperation %d status 0x%x\n", ppc, status)); 5848 break; 5849 5850 } 5851 5852 ostiGetPhyProfileIOCTLRsp(tiRoot, status); 5853 5854 } 5855 5856 5857 GLOBAL void ossaSetPhyProfileCB( 5858 agsaRoot_t *agRoot, 5859 agsaContext_t *agContext, 5860 bit32 status, 5861 bit32 ppc, 5862 bit32 phyID, 5863 void *parm ) 5864 { 5865 TI_DBG1(("ossaSetPhyProfileCB:agContext %p status 0x%x ppc %d phyID %d parm %p\n",agContext, status, ppc, phyID,parm)); 5866 } 5867 5868 5869 /*****************************************************************************/ 5870 /*! \brief ossaGetDeviceHandlesCB 5871 * 5872 * 5873 * Purpose: This routine is called by lower layer to corresponding to 5874 * saGetDeviceHandles() 5875 * 5876 * \param agRoot: Pointer to chip/driver Instance. 5877 * \param agContext: Context of the get device handle request originally passed into 5878 * saGetDeviceHandles(). 5879 * \param agPortContext:Pointer to this instance of a port context 5880 * \param agDev: Array containing pointers to the device handles 5881 5882 * \param validDevs Number of valid device handles 5883 * 5884 * 5885 * \return None. 5886 * 5887 * \note - The scope is shared target and initiator. 5888 * For details, refer to SAS/SATA Low-Level API Specification 5889 */ 5890 /*****************************************************************************/ 5891 osGLOBAL void ossaGetDeviceHandlesCB( 5892 agsaRoot_t *agRoot, 5893 agsaContext_t *agContext, 5894 agsaPortContext_t *agPortContext, 5895 agsaDevHandle_t *agDev[], 5896 bit32 validDevs 5897 ) 5898 { 5899 TI_DBG2(("ossaGetDeviceHandlesCB: start\n")); 5900 TI_DBG2(("ossaGetDeviceHandlesCB: validDevs %d\n", validDevs)); 5901 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yc"); 5902 #ifdef TO_DO 5903 for (i = 0 ; i < validDevs ; i++) 5904 { 5905 agDev[i]; 5906 } 5907 #endif 5908 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yc"); 5909 return; 5910 } 5911 5912 /*****************************************************************************/ 5913 /*! \brief ossaGetDeviceInfoCB 5914 * 5915 * 5916 * Purpose: This routine is called by lower layer to corresponding to 5917 * saGetDeviceInfo() 5918 * 5919 * \param agRoot: Pointer to chip/driver Instance. 5920 * \param agDevHandle: Handle of the device 5921 * \param status: status 5922 * \param agInfo: Pointer to the structure that describes device information 5923 * 5924 * 5925 * \return None. 5926 * 5927 * \note - The scope is shared target and initiator. 5928 * For details, refer to SAS/SATA Low-Level API Specification 5929 */ 5930 /*****************************************************************************/ 5931 osGLOBAL void ossaGetDeviceInfoCB( 5932 agsaRoot_t *agRoot, 5933 agsaContext_t *agContext, 5934 agsaDevHandle_t *agDevHandle, 5935 bit32 status, 5936 void *agInfo 5937 ) 5938 { 5939 5940 #ifdef TD_DEBUG_ENABLE 5941 agsaDeviceInfo_t *agDeviceInfo; 5942 agsaSASDeviceInfo_t *agSASDeviceInfo; 5943 agsaSATADeviceInfo_t *agSATADeviceInfo; 5944 #endif 5945 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yd"); 5946 5947 TI_DBG1(("ossaGetDeviceInfoCB: start agContext %p\n",agContext)); 5948 switch (status) 5949 { 5950 case OSSA_DEV_INFO_INVALID_HANDLE: 5951 TI_DBG1(("ossaGetDeviceInfoCB: OSSA_DEV_INFO_INVALID_HANDLE\n")); 5952 /*ostiGetDeviceInfoIOCTLRsp(tiRoot, status, agNULL);*/ 5953 break; 5954 case OSSA_DEV_INFO_NO_EXTENDED_INFO: 5955 #ifdef TD_DEBUG_ENABLE 5956 agDeviceInfo = (agsaDeviceInfo_t *)agInfo; 5957 #endif 5958 TI_DBG1(("ossaGetDeviceInfoCB: OSSA_DEV_INFO_NO_EXTENDED_INFO\n")); 5959 TI_DBG1(("ossaGetDeviceInfoCB: sasAddressHi 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSHI(agDeviceInfo))); 5960 TI_DBG1(("ossaGetDeviceInfoCB: sasAddressLo 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSLO(agDeviceInfo))); 5961 TI_DBG1(("ossaGetDeviceInfoCB: devType_S_Rate 0x%08x\n", agDeviceInfo->devType_S_Rate)); 5962 TI_DBG1(("ossaGetDeviceInfoCB: firstBurstSize 0x%08x\n", agDeviceInfo->firstBurstSize)); 5963 5964 /*ostiPortEvent (tiRoot, tiGetDevInfo, tiSuccess,(void *)agContext );*/ 5965 /*ostiGetDeviceInfoIOCTLRsp(tiRoot, status, agDeviceInfo);*/ 5966 break; 5967 case OSSA_DEV_INFO_SAS_EXTENDED_INFO: 5968 #ifdef TD_DEBUG_ENABLE 5969 agSASDeviceInfo = (agsaSASDeviceInfo_t *)agInfo; 5970 #endif 5971 TI_DBG2(("ossaGetDeviceInfoCB: OSSA_DEV_INFO_SAS_EXTENDED_INFO\n")); 5972 TI_DBG2(("ossaGetDeviceInfoCB: sasAddressHi 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSHI(&agSASDeviceInfo->commonDevInfo))); 5973 TI_DBG2(("ossaGetDeviceInfoCB: sasAddressLo 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSLO(&agSASDeviceInfo->commonDevInfo))); 5974 TI_DBG2(("ossaGetDeviceInfoCB: initiator_ssp_stp_smp %d\n", agSASDeviceInfo->initiator_ssp_stp_smp)); 5975 TI_DBG2(("ossaGetDeviceInfoCB: target_ssp_stp_smp %d\n", agSASDeviceInfo->target_ssp_stp_smp)); 5976 TI_DBG2(("ossaGetDeviceInfoCB: numOfPhys %d\n", agSASDeviceInfo->numOfPhys)); 5977 TI_DBG2(("ossaGetDeviceInfoCB: phyIdentifier %d\n", agSASDeviceInfo->phyIdentifier)); 5978 5979 break; 5980 case OSSA_DEV_INFO_SATA_EXTENDED_INFO: 5981 #ifdef TD_DEBUG_ENABLE 5982 agSATADeviceInfo = (agsaSATADeviceInfo_t *)agInfo; 5983 #endif 5984 TI_DBG2(("ossaGetDeviceInfoCB: OSSA_DEV_INFO_SATA_EXTENDED_INFO\n")); 5985 TI_DBG2(("ossaGetDeviceInfoCB: sasAddressHi 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSHI(&agSATADeviceInfo->commonDevInfo))); 5986 TI_DBG2(("ossaGetDeviceInfoCB: sasAddressLo 0x%08x\n", SA_DEVINFO_GET_SAS_ADDRESSLO(&agSATADeviceInfo->commonDevInfo))); 5987 TI_DBG2(("ossaGetDeviceInfoCB: connection %d\n", agSATADeviceInfo->connection)); 5988 TI_DBG2(("ossaGetDeviceInfoCB: portMultiplierField %d\n", agSATADeviceInfo->portMultiplierField)); 5989 TI_DBG2(("ossaGetDeviceInfoCB: stpPhyIdentifier %d\n", agSATADeviceInfo->stpPhyIdentifier)); 5990 #ifdef TD_DEBUG_ENABLE 5991 tdhexdump("ossaGetDeviceInfoCB: signature", (bit8 *)agSATADeviceInfo->signature, 8); 5992 #endif 5993 break; 5994 default: 5995 TI_DBG2(("ossaGetDeviceInfoCB: error default case, status is %d\n", status)); 5996 break; 5997 } 5998 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yd"); 5999 return; 6000 } 6001 6002 /*****************************************************************************/ 6003 /*! \brief ossaDeviceRegistrationCB 6004 * 6005 * 6006 * Purpose: This routine is called by lower layer to corresponding to 6007 * saRegisterNewDevice() 6008 * 6009 * \param agRoot: Pointer to chip/driver Instance. 6010 * \param agContext: Context of the get device handle request originally 6011 * passed into saRegisterNewDevice(). 6012 * \param status: status 6013 * \param agDevHandle: Pointer to the assigned device handle for the 6014 * registered device. 6015 * 6016 * 6017 * \return None. 6018 * 6019 */ 6020 /*****************************************************************************/ 6021 osGLOBAL void ossaDeviceRegistrationCB( 6022 agsaRoot_t *agRoot, 6023 agsaContext_t *agContext, 6024 bit32 status, 6025 agsaDevHandle_t *agDevHandle, 6026 bit32 deviceID 6027 ) 6028 { 6029 #ifdef INITIATOR_DRIVER 6030 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6031 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6032 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 6033 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 6034 bit32 Indenom = tdsaAllShared->QueueConfig.numInboundQueues; 6035 bit32 Outdenom = tdsaAllShared->QueueConfig.numOutboundQueues; 6036 tdsaDeviceData_t *oneDeviceData = (tdsaDeviceData_t *)agContext->osData; 6037 tdsaPortContext_t *onePortContext = oneDeviceData->tdPortContext; 6038 tiPortalContext_t *tiPortalContext = onePortContext->tiPortalContext; 6039 #ifdef FDS_DM 6040 dmRoot_t *dmRoot = &(tdsaAllShared->dmRoot); 6041 dmPortContext_t *dmPortContext = &(onePortContext->dmPortContext); 6042 dmDeviceInfo_t dmDeviceInfo; 6043 bit32 DMstatus = DM_RC_FAILURE; 6044 bit16 ext = 0; 6045 bit32 expanderType = 1; 6046 #endif 6047 6048 #if defined(FDS_DM) && !defined(FDS_SM) 6049 bit32 IDstatus; 6050 #endif 6051 6052 #ifdef FDS_SM 6053 smRoot_t *smRoot = &(tdsaAllShared->smRoot); 6054 bit32 SMstatus = SM_RC_FAILURE; 6055 #endif 6056 smTraceFuncEnter(hpDBG_VERY_LOUD,"Ye"); 6057 TI_DBG3(("ossaDeviceRegistrationCB: start status 0x%x\n",status)); 6058 TI_DBG3(("ossaDeviceRegistrationCB: device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi)); 6059 TI_DBG3(("ossaDeviceRegistrationCB: device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo)); 6060 TI_DBG3(("ossaDeviceRegistrationCB: did 0x%x\n", oneDeviceData->id)); 6061 TI_DBG3(("ossaDeviceRegistrationCB: deviceID 0x%x\n", deviceID)); 6062 TI_DBG3(("ossaDeviceRegistrationCB: agDevHandle %p %p %p\n",agDevHandle,agDevHandle->osData,agDevHandle->sdkData )); 6063 6064 /* transient period caused by tdssReportRemovals(), device was in the middle 6065 of registration but port is invalidated 6066 */ 6067 if (oneDeviceData->valid == agFALSE && oneDeviceData->valid2 == agFALSE 6068 && oneDeviceData->DeviceType == TD_DEFAULT_DEVICE) 6069 { 6070 if (status == OSSA_SUCCESS) 6071 { 6072 TI_DBG2(("ossaDeviceRegistrationCB: transient, calling saDeregisterDeviceHandle, did %d\n", oneDeviceData->id)); 6073 oneDeviceData->agDevHandle = agDevHandle; 6074 agDevHandle->osData = oneDeviceData; 6075 if (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6076 { 6077 if (oneDeviceData->satDevData.IDDeviceValid == agFALSE) 6078 { 6079 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, 0); 6080 } 6081 else 6082 { 6083 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 6084 } 6085 } 6086 else 6087 { 6088 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 6089 } 6090 } 6091 else if (status == OSSA_FAILURE_PORT_NOT_VALID_STATE || status == OSSA_ERR_PORT_STATE_NOT_VALID) 6092 { 6093 /* do nothing */ 6094 TI_DBG2(("ossaDeviceRegistrationCB: transient, do nothing did %d\n", oneDeviceData->id)); 6095 } 6096 return; 6097 } 6098 6099 if (agDevHandle == agNULL) 6100 { 6101 TI_DBG3(("ossaDeviceRegistrationCB: agDevHandle is NULL\n")); 6102 } 6103 else 6104 { 6105 TI_DBG3(("ossaDeviceRegistrationCB: agDevHandle is NOT NULL\n")); 6106 } 6107 6108 switch (status) 6109 { 6110 case OSSA_SUCCESS: 6111 TI_DBG3(("ossaDeviceRegistrationCB: success\n")); 6112 TI_DBG2(("ossaDeviceRegistrationCB: Success did %d FW did 0x%x\n", oneDeviceData->id, deviceID)); 6113 TI_DBG2(("ossaDeviceRegistrationCB: Success pid %d\n", onePortContext->id)); 6114 if (agDevHandle == agNULL) 6115 { 6116 TI_DBG1(("ossaDeviceRegistrationCB: agDevHandle is NULL, wrong!\n")); 6117 return; 6118 } 6119 oneDeviceData->agDevHandle = agDevHandle; 6120 agDevHandle->osData = oneDeviceData; 6121 oneDeviceData->registered = agTRUE; 6122 oneDeviceData->InQID = oneDeviceData->id % Indenom; 6123 oneDeviceData->OutQID = oneDeviceData->id % Outdenom; 6124 onePortContext->RegisteredDevNums++; 6125 6126 TI_DBG3(("ossaDeviceRegistrationCB: direct %d STP target %d target_ssp_stp_smp %d\n", oneDeviceData->directlyAttached, DEVICE_IS_STP_TARGET(oneDeviceData), oneDeviceData->target_ssp_stp_smp)); 6127 TI_DBG3(("ossaDeviceRegistrationCB: pid %d registeredNumDevice %d\n", onePortContext->id, onePortContext->RegisteredDevNums)); 6128 TI_DBG3(("ossaDeviceRegistrationCB: pid %d Count %d\n", onePortContext->id, onePortContext->Count)); 6129 6130 #ifdef FDS_DM 6131 /* if device is an expander, register it to DM */ 6132 if (onePortContext->valid == agTRUE) 6133 { 6134 if (DEVICE_IS_SMP_TARGET(oneDeviceData)) 6135 { 6136 TI_DBG1(("ossaDeviceRegistrationCB: calling dmRegisterDevice\n")); 6137 TI_DBG1(("ossaDeviceRegistrationCB: device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi)); 6138 TI_DBG1(("ossaDeviceRegistrationCB: device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo)); 6139 /* set up dmDeviceInfo */ 6140 osti_memset(&dmDeviceInfo, 0, sizeof(dmDeviceInfo_t)); 6141 DEVINFO_PUT_SAS_ADDRESSLO(&dmDeviceInfo, oneDeviceData->SASAddressID.sasAddressLo); 6142 DEVINFO_PUT_SAS_ADDRESSHI(&dmDeviceInfo, oneDeviceData->SASAddressID.sasAddressHi); 6143 dmDeviceInfo.initiator_ssp_stp_smp = oneDeviceData->initiator_ssp_stp_smp; 6144 dmDeviceInfo.target_ssp_stp_smp = oneDeviceData->target_ssp_stp_smp; 6145 dmDeviceInfo.devType_S_Rate = oneDeviceData->agDeviceInfo.devType_S_Rate; 6146 if (oneDeviceData->directlyAttached == agTRUE) 6147 { 6148 /* setting SMP bit */ 6149 ext = (bit16)(ext | 0x100); 6150 expanderType = SA_IDFRM_GET_DEVICETTYPE(&onePortContext->sasIDframe); 6151 ext = (bit16)( ext | (expanderType << 9)); 6152 /* setting MCN field to 0xF */ 6153 ext = (bit16)(ext | (bit16)(0xF << 11)); 6154 TI_DBG1(("ossaDeviceRegistrationCB: directlyAttached ext 0x%x\n", ext)); 6155 dmDeviceInfo.ext = ext; 6156 } 6157 DMstatus = dmRegisterDevice(dmRoot, dmPortContext, &dmDeviceInfo, oneDeviceData->agDevHandle); 6158 if (DMstatus != DM_RC_SUCCESS) 6159 { 6160 TI_DBG1(("ossaDeviceRegistrationCB: dmRegisterDevice failed!!! 0x%x\n", DMstatus)); 6161 } 6162 } 6163 } 6164 #endif /* FDS_DM */ 6165 #ifdef FDS_SM 6166 /* if device is SATA, register it to SM */ 6167 if (onePortContext->valid == agTRUE) 6168 { 6169 if (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6170 { 6171 TI_DBG1(("ossaDeviceRegistrationCB: calling smRegisterDevice\n")); 6172 if (oneDeviceData->directlyAttached == agTRUE) 6173 { 6174 SMstatus = smRegisterDevice(smRoot, 6175 agDevHandle, 6176 &(oneDeviceData->smDeviceHandle), 6177 agNULL, 6178 (bit32)oneDeviceData->phyID, 6179 oneDeviceData->satDevData.satDeviceType); 6180 } 6181 else 6182 { 6183 if (oneDeviceData->ExpDevice == agNULL) 6184 { 6185 TI_DBG1(("ossaDeviceRegistrationCB: oneDeviceData->ExpDevice NULL!!!\n")); 6186 return; 6187 } 6188 if (oneDeviceData->ExpDevice->agDevHandle == agNULL) 6189 { 6190 TI_DBG1(("ossaDeviceRegistrationCB: oneDeviceData->ExpDevice->agDevHandle NULL!!!\n")); 6191 } 6192 SMstatus = smRegisterDevice(smRoot, 6193 agDevHandle, 6194 &(oneDeviceData->smDeviceHandle), 6195 oneDeviceData->ExpDevice->agDevHandle, 6196 (bit32)oneDeviceData->phyID, 6197 oneDeviceData->satDevData.satDeviceType); 6198 } 6199 if (SMstatus != SM_RC_SUCCESS) 6200 { 6201 TI_DBG1(("ossaDeviceRegistrationCB: smRegisterDevice failed!!! 0x%x\n", DMstatus)); 6202 } 6203 } 6204 } 6205 #endif /* FDS_SM */ 6206 /* special case for directly attached targets */ 6207 if (oneDeviceData->directlyAttached == agTRUE) 6208 { 6209 TI_DBG3(("ossaDeviceRegistrationCB: directly attached did %d\n", oneDeviceData->id)); 6210 if (oneDeviceData->DeviceType == TD_SAS_DEVICE) 6211 { 6212 TI_DBG3(("ossaDeviceRegistrationCB: SAS target\n")); 6213 if (onePortContext->valid == agTRUE) 6214 { 6215 if (onePortContext->PortRecoverPhyID != 0xFF) 6216 { 6217 oneDeviceData->phyID = (bit8)onePortContext->PortRecoverPhyID; 6218 onePortContext->PortRecoverPhyID = 0xFF; 6219 TI_DBG3(("ossaDeviceRegistrationCB: PortRecoverPhyID %d\n", oneDeviceData->phyID)); 6220 } 6221 /* link up and discovery ready event */ 6222 if (onePortContext->DiscoveryRdyGiven == agFALSE) 6223 { 6224 TI_DBG2(("ossaDeviceRegistrationCB: link up and discovery ready\n")); 6225 TI_DBG3(("ossaDeviceRegistrationCB: phyID %d pid %d\n", oneDeviceData->phyID, onePortContext->id)); 6226 TI_DBG3(("ossaDeviceRegistrationCB: tiPortalContext %p\n", tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext)); 6227 TI_DBG3(("ossaDeviceRegistrationCB: onePortContext->tiPortalContext %p\n", onePortContext->tiPortalContext)); 6228 onePortContext->DiscoveryRdyGiven = agTRUE; 6229 if (onePortContext->DiscoveryState != ITD_DSTATE_NOT_STARTED) 6230 { 6231 TI_DBG1(("ossaDeviceRegistrationCB: wrong discovery state 0x%x\n", onePortContext->DiscoveryState)); 6232 } 6233 /* notifying link up */ 6234 ostiPortEvent ( 6235 tiRoot, 6236 tiPortLinkUp, 6237 tiSuccess, 6238 (void *)onePortContext->tiPortalContext 6239 ); 6240 #ifdef INITIATOR_DRIVER 6241 /* triggers discovery */ 6242 ostiPortEvent( 6243 tiRoot, 6244 tiPortDiscoveryReady, 6245 tiSuccess, 6246 (void *)onePortContext->tiPortalContext 6247 ); 6248 #endif 6249 } 6250 } 6251 else 6252 { 6253 TI_DBG2(("ossaDeviceRegistrationCB: abort call\n")); 6254 /* abort all followed by deregistration of sas target */ 6255 tdsaAbortAll(tiRoot, agRoot, oneDeviceData); 6256 } 6257 } 6258 else 6259 { 6260 TI_DBG2(("ossaDeviceRegistrationCB: SATA target\n")); 6261 if (onePortContext->valid == agTRUE) 6262 { 6263 if (oneDeviceData->satDevData.IDDeviceValid == agFALSE) 6264 { 6265 #ifdef FDS_SM 6266 /* send identify device data */ 6267 tdIDStart(tiRoot, agRoot, smRoot, oneDeviceData, onePortContext); 6268 6269 #else 6270 /* send identify device data */ 6271 tdssSubAddSATAToSharedcontext(tiRoot, oneDeviceData); 6272 #endif 6273 } 6274 } 6275 else 6276 { 6277 TI_DBG2(("ossaDeviceRegistrationCB: abort call\n")); 6278 /* abort all followed by deregistration of sas target */ 6279 tdsaAbortAll(tiRoot, agRoot, oneDeviceData); 6280 } 6281 } 6282 } 6283 else /* behind the expander */ 6284 { 6285 #if defined(FDS_DM) && defined(FDS_SM) 6286 /* send ID to SATA targets 6287 needs go allocate tdIORequestBody_t for smIORequest 6288 */ 6289 6290 if ( (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6291 && 6292 oneDeviceData->satDevData.IDDeviceValid == agFALSE) 6293 { 6294 tdIDStart(tiRoot, agRoot, smRoot, oneDeviceData, onePortContext); 6295 } 6296 6297 #elif defined(FDS_DM) /* worked with DM */ 6298 if ( (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6299 && 6300 oneDeviceData->satDevData.IDDeviceValid == agFALSE) 6301 { 6302 IDstatus = tdsaDiscoveryStartIDDev(tiRoot, 6303 agNULL, 6304 &(oneDeviceData->tiDeviceHandle), 6305 agNULL, 6306 oneDeviceData); 6307 6308 if (IDstatus != tiSuccess) 6309 { 6310 /* identify device data is not valid */ 6311 TI_DBG1(("ossaDeviceRegistrationCB: fail or busy %d\n", IDstatus)); 6312 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 6313 } 6314 } 6315 #endif 6316 6317 6318 } 6319 /* after discovery is finished */ 6320 if (onePortContext->DiscoveryState == ITD_DSTATE_COMPLETED) 6321 { 6322 TI_DBG2(("ossaDeviceRegistrationCB: calling new device arrival\n")); 6323 if (DEVICE_IS_SSP_TARGET(oneDeviceData)) 6324 { 6325 /* in case registration is finished after discovery is finished */ 6326 #ifdef AGTIAPI_CTL 6327 if (tdsaAllShared->SASConnectTimeLimit) 6328 tdsaCTLSet(tiRoot, onePortContext, tiIntrEventTypeDeviceChange, 6329 tiDeviceArrival); 6330 else 6331 #endif 6332 ostiInitiatorEvent( 6333 tiRoot, 6334 tiPortalContext, 6335 agNULL, 6336 tiIntrEventTypeDeviceChange, 6337 tiDeviceArrival, 6338 agNULL 6339 ); 6340 } 6341 else if ( (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6342 && 6343 oneDeviceData->satDevData.IDDeviceValid == agTRUE ) 6344 { 6345 /* in case registration is finished after discovery is finished */ 6346 ostiInitiatorEvent( 6347 tiRoot, 6348 tiPortalContext, 6349 agNULL, 6350 tiIntrEventTypeDeviceChange, 6351 tiDeviceArrival, 6352 agNULL 6353 ); 6354 } 6355 } 6356 break; 6357 case OSSA_FAILURE_OUT_OF_RESOURCE: /* fall through */ 6358 case OSSA_ERR_DEVICE_HANDLE_UNAVAILABLE: 6359 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_OUT_OF_RESOURCE or OSSA_ERR_DEVICE_HANDLE_UNAVAILABLE\n")); 6360 oneDeviceData->registered = agFALSE; 6361 break; 6362 case OSSA_FAILURE_DEVICE_ALREADY_REGISTERED: /* fall through */ 6363 case OSSA_ERR_DEVICE_ALREADY_REGISTERED: 6364 /* do nothing */ 6365 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_DEVICE_ALREADY_REGISTERED or OSSA_ERR_DEVICE_ALREADY_REGISTERED\n")); 6366 break; 6367 case OSSA_FAILURE_INVALID_PHY_ID: /* fall through */ 6368 case OSSA_ERR_PHY_ID_INVALID: 6369 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_INVALID_PHY_ID or OSSA_ERR_PHY_ID_INVALID\n")); 6370 oneDeviceData->registered = agFALSE; 6371 break; 6372 case OSSA_FAILURE_PHY_ID_ALREADY_REGISTERED: /* fall through */ 6373 case OSSA_ERR_PHY_ID_ALREADY_REGISTERED: 6374 /* do nothing */ 6375 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_PHY_ID_ALREADY_REGISTERED or OSSA_ERR_PHY_ID_ALREADY_REGISTERED\n")); 6376 break; 6377 case OSSA_FAILURE_PORT_ID_OUT_OF_RANGE: /* fall through */ 6378 case OSSA_ERR_PORT_INVALID: 6379 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_PORT_ID_OUT_OF_RANGE or OSSA_ERR_PORT_INVALID\n")); 6380 oneDeviceData->registered = agFALSE; 6381 break; 6382 case OSSA_FAILURE_PORT_NOT_VALID_STATE: /* fall through */ 6383 case OSSA_ERR_PORT_STATE_NOT_VALID: 6384 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_PORT_NOT_VALID_STATE or OSSA_ERR_PORT_STATE_NOT_VALID\n")); 6385 TI_DBG2(("ossaDeviceRegistrationCB: did %d pid %d\n", oneDeviceData->id, onePortContext->id)); 6386 oneDeviceData->registered = agFALSE; 6387 /* transient period between link up and link down/port recovery */ 6388 onePortContext->Transient = agTRUE; 6389 if (onePortContext->valid == agTRUE && (oneDeviceData->valid == agTRUE || oneDeviceData->valid2 == agTRUE)) 6390 { 6391 TI_DBG1(("ossaDeviceRegistrationCB: retries regisration\n")); 6392 #ifdef REMOVED 6393 //temp; setting MCN to tdsaAllShared->MCN 6394 oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | (tdsaAllShared->MCN << 16); 6395 //end temp 6396 #endif 6397 saRegisterNewDevice( /* ossaDeviceRegistrationCB */ 6398 agRoot, 6399 &oneDeviceData->agContext, 6400 0, 6401 &oneDeviceData->agDeviceInfo, 6402 onePortContext->agPortContext, 6403 0 6404 ); 6405 } 6406 else if (oneDeviceData->directlyAttached == agTRUE && DEVICE_IS_SATA_DEVICE(oneDeviceData)) 6407 { 6408 TI_DBG1(("ossaDeviceRegistrationCB: directly attached SATA, put back into free list\n")); 6409 tdsaDeviceDataReInit(tiRoot, oneDeviceData); 6410 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 6411 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 6412 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 6413 } 6414 break; 6415 case OSSA_FAILURE_DEVICE_TYPE_NOT_VALID: /* fall through */ 6416 case OSSA_ERR_DEVICE_TYPE_NOT_VALID: 6417 TI_DBG1(("ossaDeviceRegistrationCB: OSSA_FAILURE_DEVICE_TYPE_NOT_VALID or OSSA_ERR_DEVICE_TYPE_NOT_VALID\n")); 6418 oneDeviceData->registered = agFALSE; 6419 break; 6420 default: 6421 TI_DBG1(("ossaDeviceRegistrationCB: wrong. default status is %d\n", status)); 6422 break; 6423 6424 6425 } 6426 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Ye"); 6427 return; 6428 #endif 6429 } 6430 6431 /*****************************************************************************/ 6432 /*! \brief ossaDeregisterDeviceHandleCB 6433 * 6434 * 6435 * Purpose: This routine is called by lower layer to corresponding to 6436 * saDeregisterDeviceHandle() 6437 * 6438 * \param agRoot: Pointer to chip/driver Instance. 6439 * \param agDevHandle: Pointer to the assigned device handle for the 6440 * registered device. 6441 * \param status: status 6442 * 6443 * 6444 * \return None. 6445 * 6446 */ 6447 /*****************************************************************************/ 6448 osGLOBAL void ossaDeregisterDeviceHandleCB( 6449 agsaRoot_t *agRoot, 6450 agsaContext_t *agContext, 6451 agsaDevHandle_t *agDevHandle, 6452 bit32 status 6453 ) 6454 { 6455 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6456 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6457 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 6458 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 6459 tdsaDeviceData_t *oneDeviceData = agNULL; 6460 tdsaPortContext_t *onePortContext = agNULL; 6461 agsaEventSource_t *eventSource; 6462 bit32 HwAckSatus; 6463 bit32 PhyID; 6464 #ifdef FDS_DM 6465 dmRoot_t *dmRoot = &(tdsaAllShared->dmRoot); 6466 dmPortContext_t *dmPortContext = agNULL; 6467 dmPortInfo_t dmPortInfo; 6468 bit32 DMstatus = DM_RC_FAILURE; 6469 #endif 6470 #ifdef FDS_SM 6471 smRoot_t *smRoot = &(tdsaAllShared->smRoot); 6472 #endif 6473 6474 TI_DBG3(("ossaDeregisterDeviceHandleCB: start\n")); 6475 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yf"); 6476 6477 if (status == OSSA_ERR_DEVICE_HANDLE_INVALID) 6478 { 6479 /* there is no device handle to process */ 6480 TI_DBG2(("ossaDeregisterDeviceHandleCB: OSSA_ERR_DEVICE_HANDLE_INVALID\n")); 6481 return; 6482 } 6483 6484 oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData; 6485 onePortContext = oneDeviceData->tdPortContext; 6486 #ifdef FDS_DM 6487 dmPortContext = &(onePortContext->dmPortContext); 6488 #endif 6489 6490 if (oneDeviceData->valid == agFALSE && oneDeviceData->valid2 == agFALSE && 6491 oneDeviceData->DeviceType == TD_DEFAULT_DEVICE && onePortContext->valid == agTRUE) 6492 { 6493 TI_DBG2(("ossaDeregisterDeviceHandleCB: transient did %d\n", oneDeviceData->id)); 6494 return; 6495 } 6496 6497 if (onePortContext != agNULL) 6498 { 6499 TI_DBG2(("ossaDeregisterDeviceHandleCB: pid %d registeredNumDevice %d\n", onePortContext->id, onePortContext->RegisteredDevNums)); 6500 } 6501 6502 switch (status) 6503 { 6504 case OSSA_SUCCESS: 6505 TI_DBG3(("ossaDeregisterDeviceHandleCB: Success\n")); 6506 if (onePortContext == agNULL) 6507 { 6508 TI_DBG1(("ossaDeregisterDeviceHandleCB: onePortContext is NULL, wrong!\n")); 6509 return; 6510 } 6511 /* port is going down */ 6512 if (onePortContext->valid == agFALSE) 6513 { 6514 if (!(oneDeviceData->valid == agFALSE && oneDeviceData->valid2 == agFALSE && oneDeviceData->DeviceType == TD_DEFAULT_DEVICE)) 6515 { 6516 /* remove oneDevice from MainLink */ 6517 TI_DBG2(("ossaDeregisterDeviceHandleCB: delete from MainLink\n")); 6518 #ifdef FDS_SM 6519 if (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6520 { 6521 TI_DBG1(("ossaDeregisterDeviceHandleCB: did %d calling smDeregisterDevice\n", oneDeviceData->id)); 6522 smDeregisterDevice(smRoot, oneDeviceData->agDevHandle, &(oneDeviceData->smDeviceHandle)); 6523 } 6524 #endif 6525 tdsaDeviceDataReInit(tiRoot, oneDeviceData); 6526 osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t)); 6527 6528 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 6529 TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink)); 6530 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 6531 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 6532 } 6533 /* for portcontext */ 6534 PhyID = onePortContext->eventPhyID; 6535 TI_DBG3(("ossaDeregisterDeviceHandleCB: PhyID %d\n", PhyID)); 6536 onePortContext->RegisteredDevNums--; 6537 /* 6538 check if valid in tdsaAllShared and the last registered device in a portcontext; 6539 if so, call saHwEventAck() 6540 */ 6541 if (tdsaAllShared->eventSource[PhyID].EventValid == agTRUE && 6542 onePortContext->RegisteredDevNums == 0 && 6543 PhyID != 0xFF 6544 ) 6545 { 6546 TI_DBG2(("ossaDeregisterDeviceHandleCB: calling saHwEventAck\n")); 6547 eventSource = &(tdsaAllShared->eventSource[PhyID].Source); 6548 HwAckSatus = saHwEventAck( 6549 agRoot, 6550 agNULL, /* agContext */ 6551 0, 6552 eventSource, /* agsaEventSource_t */ 6553 0, 6554 0 6555 ); 6556 if ( HwAckSatus != AGSA_RC_SUCCESS) 6557 { 6558 TI_DBG1(("ossaDeregisterDeviceHandleCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 6559 } 6560 6561 /* toggle */ 6562 tdsaAllShared->eventSource[PhyID].EventValid = agFALSE; 6563 6564 #ifdef FDS_DM 6565 if (onePortContext->UseDM == agTRUE) 6566 { 6567 TI_DBG1(("ossaDeregisterDeviceHandleCB: calling dmDestroyPort\n")); 6568 /* setup dmPortInfo */ 6569 PORTINFO_PUT_SAS_REMOTE_ADDRESSLO(&dmPortInfo, onePortContext->sasRemoteAddressLo); 6570 PORTINFO_PUT_SAS_REMOTE_ADDRESSHI(&dmPortInfo, onePortContext->sasRemoteAddressHi); 6571 PORTINFO_PUT_SAS_LOCAL_ADDRESSLO(&dmPortInfo, onePortContext->sasLocalAddressLo); 6572 PORTINFO_PUT_SAS_LOCAL_ADDRESSHI(&dmPortInfo, onePortContext->sasLocalAddressHi); 6573 DMstatus = dmDestroyPort(dmRoot, dmPortContext, &dmPortInfo); 6574 if (DMstatus != DM_RC_SUCCESS) 6575 { 6576 TI_DBG1(("ossaDeregisterDeviceHandleCB: dmDestroyPort failed!!! 0x%x\n", DMstatus)); 6577 } 6578 } 6579 #endif 6580 tdsaPortContextReInit(tiRoot, onePortContext); 6581 /* 6582 put all devices belonging to the onePortContext 6583 back to the free link 6584 */ 6585 6586 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 6587 TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink)); 6588 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList)); 6589 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 6590 } 6591 else if (tdsaAllShared->eventSource[PhyID].EventValid == NO_ACK && 6592 onePortContext->RegisteredDevNums == 0 6593 ) 6594 { 6595 TI_DBG2(("ossaDeregisterDeviceHandleCB: NO ACK case\n")); 6596 #ifdef FDS_DM 6597 if (onePortContext->UseDM == agTRUE) 6598 { 6599 TI_DBG1(("ossaDeregisterDeviceHandleCB: calling dmDestroyPort\n")); 6600 /* setup dmPortInfo */ 6601 PORTINFO_PUT_SAS_REMOTE_ADDRESSLO(&dmPortInfo, onePortContext->sasRemoteAddressLo); 6602 PORTINFO_PUT_SAS_REMOTE_ADDRESSHI(&dmPortInfo, onePortContext->sasRemoteAddressHi); 6603 PORTINFO_PUT_SAS_LOCAL_ADDRESSLO(&dmPortInfo, onePortContext->sasLocalAddressLo); 6604 PORTINFO_PUT_SAS_LOCAL_ADDRESSHI(&dmPortInfo, onePortContext->sasLocalAddressHi); 6605 DMstatus = dmDestroyPort(dmRoot, dmPortContext, &dmPortInfo); 6606 if (DMstatus != DM_RC_SUCCESS) 6607 { 6608 TI_DBG1(("ossaDeregisterDeviceHandleCB: dmDestroyPort failed!!! 0x%x\n", DMstatus)); 6609 } 6610 } 6611 #endif 6612 tdsaPortContextReInit(tiRoot, onePortContext); 6613 /* 6614 put all devices belonging to the onePortContext 6615 back to the free link 6616 */ 6617 6618 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK); 6619 TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink)); 6620 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList)); 6621 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK); 6622 } 6623 else 6624 { 6625 if (PhyID < TD_MAX_NUM_PHYS) 6626 { 6627 TI_DBG3(("ossaDeregisterDeviceHandleCB: pid %d eventvalid %d registeredNumDevice %d\n", onePortContext->id, tdsaAllShared->eventSource[PhyID].EventValid , onePortContext->RegisteredDevNums)); 6628 } 6629 else 6630 { 6631 TI_DBG3(("ossaDeregisterDeviceHandleCB: pid %d registeredNumDevice %d wrong phyid %d\n", onePortContext->id, onePortContext->RegisteredDevNums, PhyID)); 6632 } 6633 } 6634 } 6635 else 6636 { 6637 PhyID = onePortContext->eventPhyID; 6638 TI_DBG3(("ossaDeregisterDeviceHandleCB: PhyID %d\n", PhyID)); 6639 onePortContext->RegisteredDevNums--; 6640 #ifdef FDS_SM 6641 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 6642 if (DEVICE_IS_SATA_DEVICE(oneDeviceData) || DEVICE_IS_STP_TARGET(oneDeviceData)) 6643 { 6644 smDeregisterDevice(smRoot, oneDeviceData->agDevHandle, &(oneDeviceData->smDeviceHandle)); 6645 } 6646 #endif 6647 /* 6648 check if valid in tdsaAllShared and the last registered device in a portcontext; 6649 if so, call saHwEventAck() 6650 */ 6651 if (tdsaAllShared->eventSource[PhyID].EventValid == agTRUE && 6652 onePortContext->RegisteredDevNums == 0 && 6653 PhyID != 0xFF 6654 ) 6655 { 6656 TI_DBG2(("ossaDeregisterDeviceHandleCB: calling saHwEventAck\n")); 6657 eventSource = &(tdsaAllShared->eventSource[PhyID].Source); 6658 HwAckSatus = saHwEventAck( 6659 agRoot, 6660 agNULL, /* agContext */ 6661 0, 6662 eventSource, /* agsaEventSource_t */ 6663 0, 6664 0 6665 ); 6666 if ( HwAckSatus != AGSA_RC_SUCCESS) 6667 { 6668 TI_DBG1(("ossaDeregisterDeviceHandleCB: failing in saHwEventAck; status %d\n", HwAckSatus)); 6669 } 6670 6671 /* toggle */ 6672 tdsaAllShared->eventSource[PhyID].EventValid = agFALSE; 6673 } 6674 #ifdef INITIATOR_DRIVER 6675 else if (onePortContext->RegisteredDevNums == 1) 6676 { 6677 TI_DBG1(("ossaDeregisterDeviceHandleCB: all devices have been deregistered except directly attached EXP\n")); 6678 /* qqqqq If broadcast has been seen, call incremental discovery*/ 6679 if (onePortContext->DiscFailNSeenBC == agTRUE) 6680 { 6681 TI_DBG1(("ossaDeregisterDeviceHandleCB: calling dmDiscover, incremental, pid %d\n", onePortContext->id)); 6682 dmDiscover(dmRoot, dmPortContext, DM_DISCOVERY_OPTION_INCREMENTAL_START); 6683 onePortContext->DiscFailNSeenBC = agFALSE; 6684 } 6685 else 6686 { 6687 TI_DBG1(("ossaDeregisterDeviceHandleCB: not calling dmDiscover\n")); 6688 /* qqqqq needs to change discovery state to onePortContext->DMDiscoveryState == dmDiscCompleted 6689 in dmQueryDiscovery 6690 change the discovery state from dmDiscFailed to dmDiscCompleted 6691 */ 6692 dmResetFailedDiscovery(dmRoot, dmPortContext); 6693 6694 } 6695 } 6696 #endif 6697 else 6698 { 6699 if (PhyID < TD_MAX_NUM_PHYS) 6700 { 6701 TI_DBG3(("ossaDeregisterDeviceHandleCB: pid %d eventvalid %d registeredNumDevice %d\n", onePortContext->id, tdsaAllShared->eventSource[PhyID].EventValid , onePortContext->RegisteredDevNums)); 6702 } 6703 else 6704 { 6705 TI_DBG3(("ossaDeregisterDeviceHandleCB: pid %d registeredNumDevice %d wrong phyid %d\n", onePortContext->id, onePortContext->RegisteredDevNums, PhyID)); 6706 } 6707 } 6708 } 6709 break; 6710 case OSSA_INVALID_HANDLE: 6711 TI_DBG1(("ossaDeregisterDeviceHandleCB: OSSA_INVALID_HANDLE\n")); 6712 break; 6713 #ifdef REMOVED 6714 case OSSA_FAILURE_DEVICE_DIRECT_ATTACH: 6715 TI_DBG1(("ossaDeregisterDeviceHandleCB: OSSA_FAILURE_DEVICE_DIRECT_ATTACH\n")); 6716 break; 6717 #endif 6718 case OSSA_ERR_DEVICE_HANDLE_INVALID: 6719 TI_DBG1(("ossaDeregisterDeviceHandleCB: OSSA_ERR_DEVICE_HANDLE_INVALID\n")); 6720 break; 6721 case OSSA_ERR_DEVICE_BUSY: 6722 TI_DBG1(("ossaDeregisterDeviceHandleCB: OSSA_ERR_DEVICE_BUSY\n")); 6723 break; 6724 default: 6725 TI_DBG1(("ossaDeregisterDeviceHandleCB: unknown status 0x%x\n", status)); 6726 break; 6727 } 6728 6729 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yf"); 6730 return; 6731 } 6732 6733 /*****************************************************************************/ 6734 /*! \brief ossaDeviceHandleRemovedEvent 6735 * 6736 * 6737 * Purpose: This routine is called by lower layer to notify the device removal 6738 * 6739 * 6740 * \param agRoot: Pointer to chip/driver Instance. 6741 * \param agDevHandle: Pointer to the assigned device handle for the 6742 * registered device. 6743 * \param agPortContext:Pointer to this instance of port context. 6744 * 6745 * 6746 * \return None. 6747 * 6748 */ 6749 /*****************************************************************************/ 6750 osGLOBAL void ossaDeviceHandleRemovedEvent ( 6751 agsaRoot_t *agRoot, 6752 agsaDevHandle_t *agDevHandle, 6753 agsaPortContext_t *agPortContext 6754 ) 6755 { 6756 #ifdef NOT_YET 6757 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6758 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6759 #endif 6760 tdsaPortContext_t *onePortContext = agNULL; 6761 tdsaDeviceData_t *oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData; 6762 6763 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yg"); 6764 TI_DBG2(("ossaDeviceHandleRemovedEvent: start\n")); 6765 if (oneDeviceData == agNULL) 6766 { 6767 TI_DBG1(("ossaDeviceHandleRemovedEvent: Wrong! oneDeviceData is NULL\n")); 6768 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yg"); 6769 return; 6770 } 6771 TI_DBG2(("ossaDeviceHandleRemovedEvent: did %d\n", oneDeviceData->id)); 6772 oneDeviceData->registered = agFALSE; 6773 onePortContext = (tdsaPortContext_t *)agPortContext->osData; 6774 if (onePortContext == agNULL) 6775 { 6776 TI_DBG1(("ossaDeviceHandleRemovedEvent: Wrong! onePortContext is NULL\n")); 6777 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "Yg"); 6778 return; 6779 } 6780 TI_DBG2(("ossaDeviceHandleRemovedEvent: pid %d\n", onePortContext->id)); 6781 onePortContext->RegisteredDevNums--; 6782 #ifdef NOT_YET 6783 ostiInitiatorEvent( 6784 tiRoot, 6785 onePortContext->tiPortalContext, 6786 agNULL, 6787 tiIntrEventTypeDeviceChange, 6788 tiDeviceRemoval, 6789 agNULL 6790 ); 6791 #endif 6792 6793 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "Yg"); 6794 return; 6795 } 6796 6797 #ifdef SPC_ENABLE_PROFILE 6798 /*****************************************************************************/ 6799 /*! \brief ossaFwProfileCB 6800 * 6801 * 6802 * Purpose: This routine is called by lower layer to corresponding to 6803 * saFwProfile() 6804 * 6805 * \param agRoot: Pointer to chip/driver Instance. 6806 * \param agContext: Context of the operation originally passed 6807 * into saFwProfile() 6808 * \param status: status 6809 * 6810 * 6811 * \return None. 6812 * 6813 */ 6814 /*****************************************************************************/ 6815 osGLOBAL void ossaFwProfileCB( 6816 agsaRoot_t *agRoot, 6817 agsaContext_t *agContext, 6818 bit32 status, 6819 bit32 len) 6820 { 6821 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6822 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6823 6824 TI_DBG2(("ossaFwProfileCB: start\n")); 6825 6826 switch (status) 6827 { 6828 case AGSA_RC_SUCCESS: 6829 { 6830 TI_DBG2(("ossaFwProfileCB: SUCCESS\n")); 6831 break; 6832 } 6833 case AGSA_RC_FAILURE: 6834 { 6835 TI_DBG1(("ossaFwProfileCB: FAIL\n")); 6836 break; 6837 } 6838 default: 6839 { 6840 TI_DBG1(("ossaFwProfileCB: !!! default, status %d\n", status)); 6841 break; 6842 } 6843 } 6844 6845 ostiFWProfileIOCTLRsp(tiRoot, status, len); 6846 return; 6847 } 6848 #endif 6849 /*****************************************************************************/ 6850 /*! \brief ossaFwFlashUpdateCB 6851 * 6852 * 6853 * Purpose: This routine is called by lower layer to corresponding to 6854 * saFwFlashUpdate() 6855 * 6856 * \param agRoot: Pointer to chip/driver Instance. 6857 * \param agContext: Context of the operation originally passed 6858 * into saFwFlashUpdate() 6859 * \param status: status 6860 * 6861 * 6862 * \return None. 6863 * 6864 */ 6865 /*****************************************************************************/ 6866 osGLOBAL void ossaFwFlashUpdateCB( 6867 agsaRoot_t *agRoot, 6868 agsaContext_t *agContext, 6869 bit32 status 6870 ) 6871 { 6872 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6873 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6874 6875 TI_DBG2(("ossaFwFlashUpdateCB: start\n")); 6876 6877 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yh"); 6878 switch (status) 6879 { 6880 case OSSA_FLASH_UPDATE_COMPLETE_PENDING_REBOOT: 6881 { 6882 TI_DBG2(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_COMPLETE_PENDING_REBOOT\n")); 6883 break; 6884 } 6885 case OSSA_FLASH_UPDATE_IN_PROGRESS: 6886 { 6887 TI_DBG2(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_IN_PROGRESS\n")); 6888 break; 6889 } 6890 case OSSA_FLASH_UPDATE_HDR_ERR: 6891 { 6892 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_HDR_ERR\n")); 6893 break; 6894 } 6895 case OSSA_FLASH_UPDATE_OFFSET_ERR: 6896 { 6897 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_OFFSET_ERR\n")); 6898 break; 6899 } 6900 case OSSA_FLASH_UPDATE_CRC_ERR: 6901 { 6902 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_CRC_ERR\n")); 6903 break; 6904 } 6905 case OSSA_FLASH_UPDATE_LENGTH_ERR: 6906 { 6907 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_LENGTH_ERR\n")); 6908 break; 6909 } 6910 case OSSA_FLASH_UPDATE_HW_ERR: 6911 { 6912 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_HW_ERR\n")); 6913 break; 6914 } 6915 case OSSA_FLASH_UPDATE_DNLD_NOT_SUPPORTED: 6916 { 6917 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_DNLD_NOT_SUPPORTED\n")); 6918 break; 6919 } 6920 case OSSA_FLASH_UPDATE_DISABLED: 6921 { 6922 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_DISABLED\n")); 6923 break; 6924 } 6925 case OSSA_FLASH_FWDNLD_DEVICE_UNSUPPORT: 6926 { 6927 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_FWDNLD_DEVICE_UNSUPPORT\n")); 6928 break; 6929 } 6930 case OSSA_MPI_ERR_IO_RESOURCE_UNAVAILABLE: 6931 { 6932 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_MPI_ERR_IO_RESOURCE_UNAVAILABLE\n")); 6933 break; 6934 } 6935 case OSSA_FLASH_UPDATE_HMAC_ERR: 6936 { 6937 TI_DBG1(("ossaFwFlashUpdateCB: OSSA_FLASH_UPDATE_HMAC_ERR\n")); 6938 break; 6939 } 6940 6941 default: 6942 { 6943 TI_DBG1(("ossaFwFlashUpdateCB: !!! default, status 0x%X\n", status)); 6944 break; 6945 } 6946 } 6947 6948 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yh"); 6949 ostiCOMMgntIOCTLRsp(tiRoot, status); 6950 return; 6951 6952 } 6953 6954 6955 GLOBAL void ossaFlashExtExecuteCB( 6956 agsaRoot_t *agRoot, 6957 agsaContext_t *agContext, 6958 bit32 status, 6959 bit32 command, 6960 agsaFlashExtResponse_t *agFlashExtRsp) 6961 { 6962 TI_DBG1(("ossaFlashExtExecuteCB: command 0x%X status 0x%X\n",command, status)); 6963 6964 } 6965 6966 6967 6968 /*****************************************************************************/ 6969 /*! \brief ossaGetNVMDResponseCB 6970 * 6971 * 6972 * Purpose: This routine is called by lower layer to corresponding to 6973 * saGetNVMDCommand() 6974 * 6975 * \param agRoot: Pointer to chip/driver Instance. 6976 * \param agContext: Context of the operation originally passed 6977 * into saGetVPDCommand() 6978 * \param status: status 6979 * \param indirectPayload: The value passed in agsaNVMDData_t when 6980 * calling saGetNVMDCommand() 6981 * \param agInfoLen: the length of VPD information 6982 * \param agFrameHandle: handler of VPD information 6983 * 6984 * 6985 * \return None. 6986 * 6987 */ 6988 /*****************************************************************************/ 6989 osGLOBAL void ossaGetNVMDResponseCB( 6990 agsaRoot_t *agRoot, 6991 agsaContext_t *agContext, 6992 bit32 status, 6993 bit8 indirectPayload, 6994 bit32 agInfoLen, 6995 agsaFrameHandle_t agFrameHandle 6996 ) 6997 { 6998 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6999 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7000 TI_DBG2(("ossaGetNVMDResponseCB: start\n")); 7001 TI_DBG2(("ossaGetNVMDResponseCB: agInfoLen %d\n", agInfoLen)); 7002 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yi"); 7003 7004 if (status == OSSA_SUCCESS) 7005 { 7006 TI_DBG2(("ossaGetNVMDResponseCB: Success status\n")); 7007 if (indirectPayload == 0 && agInfoLen != 0) 7008 { 7009 TI_DBG2(("ossaGetNVMDResponseCB: direct\n")); 7010 tdhexdump("ossaGetNVMDResponseCB", (bit8 *)agFrameHandle, agInfoLen); 7011 } 7012 } 7013 else 7014 { 7015 TI_DBG1(("ossaGetNVMDResponseCB: Status 0x%x\n", status)); 7016 } 7017 7018 if (indirectPayload == 0) 7019 { 7020 TI_DBG2(("ossaGetNVMDResponseCB: direct\n")); 7021 } 7022 else 7023 { 7024 TI_DBG2(("ossaGetNVMDResponseCB: indirect\n")); 7025 } 7026 7027 ostiGetNVMDIOCTLRsp(tiRoot, status); 7028 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yi"); 7029 return; 7030 } 7031 7032 7033 /*****************************************************************************/ 7034 /*! \brief ossaSetNVMDResponseCB 7035 * 7036 * 7037 * Purpose: This routine is called by lower layer to corresponding to 7038 * saSetNVMDCommand() 7039 * 7040 * \param agRoot: Pointer to chip/driver Instance. 7041 * \param agContext: Context of the operation originally passed 7042 * into saSetVPDCommand() 7043 * \param status: status 7044 * 7045 * 7046 * \return None. 7047 * 7048 */ 7049 /*****************************************************************************/ 7050 osGLOBAL void ossaSetNVMDResponseCB( 7051 agsaRoot_t *agRoot, 7052 agsaContext_t *agContext, 7053 bit32 status 7054 ) 7055 { 7056 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7057 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7058 TI_DBG2(("ossaSetNVMDResponseCB: start\n")); 7059 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yj"); 7060 if (status == OSSA_SUCCESS) 7061 { 7062 TI_DBG2(("ossaSetNVMDResponseCB: success\n")); 7063 } 7064 else 7065 { 7066 TI_DBG1(("ossaSetNVMDResponseCB: fail or undefined staus %d\n", status)); 7067 } 7068 ostiSetNVMDIOCTLRsp(tiRoot, status); 7069 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yj"); 7070 return; 7071 } 7072 7073 7074 #ifdef REMOVED 7075 /*****************************************************************************/ 7076 /*! \brief ossaGetVPDResponseCB 7077 * 7078 * 7079 * Purpose: This routine is called by lower layer to corresponding to 7080 * saGetVPDCommand() 7081 * 7082 * \param agRoot: Pointer to chip/driver Instance. 7083 * \param agContext: Context of the operation originally passed 7084 * into saGetVPDCommand() 7085 * \param status: status 7086 * \param agInfoLen: the length of VPD information 7087 * \param agFrameHandle:handler of VPD information 7088 * 7089 * 7090 * \return None. 7091 * 7092 */ 7093 /*****************************************************************************/ 7094 osGLOBAL void ossaGetVPDResponseCB( 7095 agsaRoot_t *agRoot, 7096 agsaContext_t *agContext, 7097 bit32 status, 7098 bit8 indirectMode, 7099 bit32 agInfoLen, 7100 agsaFrameHandle_t agFrameHandle 7101 ) 7102 { 7103 bit8 VPDData[48]; 7104 7105 TI_DBG2(("ossaGetVPDResponseCB: start\n")); 7106 7107 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yk"); 7108 if (status == OSSA_SUCCESS) 7109 { 7110 TI_DBG2(("ossaGetVPDResponseCB: agInfoLen %d\n", agInfoLen)); 7111 osti_memset(VPDData, 0, 48); 7112 /* We can read only in case of Direct */ 7113 saFrameReadBlock(agRoot, agFrameHandle, 0, VPDData, agInfoLen); 7114 tdhexdump("ossaGetVPDResponseCB", (bit8 *)VPDData, agInfoLen); 7115 /* 7116 callback osti.... 7117 */ 7118 } 7119 else 7120 { 7121 TI_DBG1(("ossaGetVPDResponseCB: fail or undefined staus %d\n", status)); 7122 } 7123 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yk"); 7124 return; 7125 } 7126 7127 7128 /*****************************************************************************/ 7129 /*! \brief ossaSetVPDResponseCB 7130 * 7131 * 7132 * Purpose: This routine is called by lower layer to corresponding to 7133 * saSetVPDCommand() 7134 * 7135 * \param agRoot: Pointer to chip/driver Instance. 7136 * \param agContext: Context of the operation originally passed 7137 * into saSetVPDCommand() 7138 * \param status: status 7139 * 7140 * 7141 * \return None. 7142 * 7143 */ 7144 /*****************************************************************************/ 7145 osGLOBAL void ossaSetVPDResponseCB( 7146 agsaRoot_t *agRoot, 7147 agsaContext_t *agContext, 7148 bit32 status 7149 ) 7150 { 7151 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7152 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7153 7154 TI_DBG2(("ossaSetVPDResponseCB: start\n")); 7155 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yl"); 7156 7157 if (status == OSSA_SUCCESS) 7158 { 7159 TI_DBG2(("ossaSetVPDResponseCB: success\n")); 7160 ostiCOMMgntVPDSetIOCTLRsp(tiRoot, 0); 7161 /* 7162 callback osti..... 7163 */ 7164 7165 #ifdef VPD_TESTING 7166 /* temporary to test saSetVPDCommand() and saGetVPDCommand */ 7167 tdsaVPDGet(tiRoot); 7168 #endif 7169 7170 } 7171 else 7172 { 7173 TI_DBG1(("ossaSetVPDResponseCB: fail or undefined staus %d\n", status)); 7174 } 7175 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yl"); 7176 return; 7177 } 7178 #endif 7179 7180 /*****************************************************************************/ 7181 /*! \brief ossaEchoCB 7182 * 7183 * 7184 * Purpose: This routine is called by lower layer to corresponding to 7185 * saEchoCommand() 7186 * 7187 * \param agRoot: Pointer to chip/driver Instance. 7188 * \param agContext: Context of the operation originally passed 7189 * into saEchoCommand() 7190 * \param echoPayload: Pointer to the echo payload 7191 * 7192 * 7193 * \return None. 7194 * 7195 */ 7196 /*****************************************************************************/ 7197 osGLOBAL void ossaEchoCB( 7198 agsaRoot_t *agRoot, 7199 agsaContext_t *agContext, 7200 void *echoPayload 7201 ) 7202 { 7203 #ifdef ECHO_TESTING 7204 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7205 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7206 bit8 payload[56]; 7207 #endif 7208 7209 TI_DBG2(("ossaEchoCB: start\n")); 7210 smTraceFuncEnter(hpDBG_VERY_LOUD,"Ym"); 7211 7212 /* dumping received echo payload is 56 bytes */ 7213 tdhexdump("ossaEchoCB: echoPayload", (bit8 *)(echoPayload), 56); 7214 7215 #ifdef ECHO_TESTING 7216 /* temporary to test saEchoCommand() */ 7217 7218 /* new echo payload */ 7219 osti_memset(payload,0, sizeof(payload)); 7220 7221 payload[0] = gEcho; 7222 payload[55] = gEcho; 7223 7224 TI_DBG2(("ossaEchoCB: gEcho %d\n", gEcho)); 7225 7226 saEchoCommand(agRoot, agNULL, tdsaRotateQnumber(tiRoot, agNULL), (void *)&payload); 7227 7228 if (gEcho == 0xFF) 7229 { 7230 gEcho = 0; 7231 } 7232 else 7233 { 7234 gEcho++; 7235 } 7236 #endif 7237 7238 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Ym"); 7239 return; 7240 } 7241 7242 /*****************************************************************************/ 7243 /*! \brief ossaGpioResponseCB 7244 * 7245 * 7246 * Purpose: This routine is called by lower layer to corresponding to 7247 * saGpioEventSetup(), saGpioPinSetup(), saGpioRead(), or 7248 * saGpioWrite() 7249 * 7250 * \param agRoot: Pointer to chip/driver Instance. 7251 * \param agContext: Context of the operation originally passed 7252 * in. 7253 * \param status: GPIO operation completion status 7254 * \param gpioReadValue: a bit map containing the corresponding 7255 * value for each GPIO pin. 7256 * \param gpioPinSetupInfo: Pointer to agsaGpioPinSetupInfo_t structure 7257 * describing the GPIO pin setup 7258 * \param gpioEventSetupInfo Pointer to agsaGpioEventSetupInfo_t structure 7259 * describing the GPIO event setups 7260 * 7261 * 7262 * \return None. 7263 * 7264 */ 7265 /*****************************************************************************/ 7266 osGLOBAL void ossaGpioResponseCB( 7267 agsaRoot_t *agRoot, 7268 agsaContext_t *agContext, 7269 bit32 status, 7270 bit32 gpioReadValue, 7271 agsaGpioPinSetupInfo_t *gpioPinSetupInfo, 7272 agsaGpioEventSetupInfo_t *gpioEventSetupInfo 7273 ) 7274 { 7275 TI_DBG2(("ossaGpioResponseCB: start\n")); 7276 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yn"); 7277 if (status == OSSA_SUCCESS) 7278 { 7279 TI_DBG2(("ossaGpioResponseCB: Success\n")); 7280 /* printing gpioReadValue, agsaGpioPinSetupInfo_t and agsaGpioEventSetupInfo_t */ 7281 TI_DBG2(("ossaGpioResponseCB: gpioReadValue 0x%x\n", gpioReadValue)); 7282 TI_DBG2(("ossaGpioResponseCB: PinSetupInfo gpioInputEnabled 0x%x\n", gpioPinSetupInfo->gpioInputEnabled)); 7283 TI_DBG2(("ossaGpioResponseCB: PinSetupInfo gpioTypePart1 0x%x\n", gpioPinSetupInfo->gpioTypePart1)); 7284 TI_DBG2(("ossaGpioResponseCB: PinSetupInfo gpioTypePart2 0x%x\n", gpioPinSetupInfo->gpioTypePart2)); 7285 TI_DBG2(("ossaGpioResponseCB: EventSetupInfo gpioEventLevel 0x%x\n", gpioEventSetupInfo->gpioEventLevel)); 7286 TI_DBG2(("ossaGpioResponseCB: EventSetupInfo gpioEventRisingEdge 0x%x\n", gpioEventSetupInfo->gpioEventRisingEdge)); 7287 TI_DBG2(("ossaGpioResponseCB: EventSetupInfo gpioEventFallingEdge 0x%x\n", gpioEventSetupInfo->gpioEventFallingEdge)); 7288 } 7289 else 7290 { 7291 TI_DBG1(("ossaGpioResponseCB: Failure\n")); 7292 } 7293 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yn"); 7294 return; 7295 } 7296 7297 /*****************************************************************************/ 7298 /*! \brief ossaGpioEvent 7299 * 7300 * 7301 * Purpose: This routine is called by lower layer to corresponding to 7302 * saGpioEventSetup(), saGpioPinSetup(), saGpioRead(), or 7303 * saGpioWrite() 7304 * 7305 * \param agRoot: Pointer to chip/driver Instance. 7306 * \param gpioEvent: a bit map that indicates which GPIO 7307 * input pins have generated the event. 7308 * 7309 * 7310 * \return None. 7311 * 7312 */ 7313 /*****************************************************************************/ 7314 osGLOBAL void ossaGpioEvent( 7315 agsaRoot_t *agRoot, 7316 bit32 gpioEvent 7317 ) 7318 { 7319 TI_DBG2(("ossaGpioEvent: start\n")); 7320 TI_DBG2(("ossaGpioEvent: gpioEvent 0x%x\n", gpioEvent)); 7321 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yo"); 7322 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yo"); 7323 return; 7324 } 7325 7326 7327 /*****************************************************************************/ 7328 /*! \brief ossaSASDiagExecuteCB 7329 * 7330 * 7331 * Purpose: This routine is called by lower layer to corresponding to 7332 * saSASDiagExecute() 7333 * 7334 * \param agRoot: Pointer to chip/driver Instance. 7335 * \param agContext: Context of the operation originally passed 7336 * in. 7337 * \param status: Diagnostic operation completion status 7338 * \param command: SAS diagnostic command field in agsaSASDiagExecute_t 7339 * structure passed in saSASDiagExecute(). 7340 * \param reportData: Report Diagnostic Data 7341 * 7342 * 7343 * \return None. 7344 * 7345 */ 7346 /*****************************************************************************/ 7347 osGLOBAL void ossaSASDiagExecuteCB( 7348 agsaRoot_t *agRoot, 7349 agsaContext_t *agContext, 7350 bit32 status, 7351 bit32 command, 7352 bit32 reportData) 7353 { 7354 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yq"); 7355 TI_DBG2(("ossaSASDiagExecuteCB: start\n")); 7356 TI_DBG2(("ossaSASDiagExecuteCB: status %d\n", status)); 7357 TI_DBG2(("ossaSASDiagExecuteCB: command %d\n", command)); 7358 TI_DBG2(("ossaSASDiagExecuteCB: reportData %d\n", reportData)); 7359 7360 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yq"); 7361 return; 7362 7363 } 7364 7365 7366 /*****************************************************************************/ 7367 /*! \brief ossaSASDiagStartEndCB 7368 * 7369 * 7370 * Purpose: This routine is called by lower layer to corresponding to 7371 * saSASDiagExecute() 7372 * 7373 * \param agRoot: Pointer to chip/driver Instance. 7374 * \param agContext: Context of the operation originally passed 7375 * in. 7376 * \param status: Diagnostic operation completion status 7377 * 7378 * 7379 * \return None. 7380 * 7381 */ 7382 /*****************************************************************************/ 7383 osGLOBAL void ossaSASDiagStartEndCB( 7384 agsaRoot_t *agRoot, 7385 agsaContext_t *agContext, 7386 bit32 status) 7387 { 7388 TI_DBG2(("ossaSASDiagStartEndCB: start\n")); 7389 TI_DBG2(("ossaSASDiagStartEndCB: status %d\n", status)); 7390 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yr"); 7391 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yr"); 7392 return; 7393 } 7394 7395 /*****************************************************************************/ 7396 /*! \brief ossaReconfigSASParamsCB 7397 * 7398 * 7399 * Purpose: This routine is called by lower layer to corresponding to 7400 * saReconfigSASParams() 7401 * 7402 * \param agRoot: Pointer to chip/driver Instance. 7403 * \param agContext: Context of the operation originally passed 7404 * in saReconfigSASParams(). 7405 * \param status: saReconfigSASParams() completion status 7406 * \param agSASConfig: Pointer to the data structure agsaSASReconfig_t 7407 * 7408 * 7409 * \return None. 7410 * 7411 */ 7412 /*****************************************************************************/ 7413 osGLOBAL void ossaReconfigSASParamsCB( 7414 agsaRoot_t *agRoot, 7415 agsaContext_t *agContext, 7416 bit32 status, 7417 agsaSASReconfig_t *agSASConfig) 7418 { 7419 TI_DBG2(("ossaReconfigSASParamsCB: status %d\n", status)); 7420 return; 7421 } 7422 7423 GLOBAL void ossaPCIeDiagExecuteCB( 7424 agsaRoot_t *agRoot, 7425 agsaContext_t *agContext, 7426 bit32 status, 7427 bit32 command, 7428 agsaPCIeDiagResponse_t *resp ) 7429 { 7430 TI_DBG2(("ossaPCIeDiagExecuteCB: status %d\n", status)); 7431 TI_DBG2(("ossaPCIeDiagExecuteCB: ERR_BLKH 0x%X\n",resp->ERR_BLKH )); 7432 TI_DBG2(("ossaPCIeDiagExecuteCB: ERR_BLKL 0x%X\n",resp->ERR_BLKL )); 7433 TI_DBG2(("ossaPCIeDiagExecuteCB: DWord8 0x%X\n",resp->DWord8 )); 7434 TI_DBG2(("ossaPCIeDiagExecuteCB: DWord9 0x%X\n",resp->DWord9 )); 7435 TI_DBG2(("ossaPCIeDiagExecuteCB: DWord10 0x%X\n",resp->DWord10 )); 7436 TI_DBG2(("ossaPCIeDiagExecuteCB: DWord11 0x%X\n",resp->DWord11 )); 7437 TI_DBG2(("ossaPCIeDiagExecuteCB: DIF_ERR 0x%X\n",resp->DIF_ERR )); 7438 7439 return; 7440 } 7441 7442 7443 #ifndef BIOS 7444 GLOBAL void ossaSGpioCB( 7445 agsaRoot_t *agRoot, 7446 agsaContext_t *agContext, 7447 agsaSGpioReqResponse_t *pSgpioResponse 7448 ) 7449 { 7450 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7451 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7452 7453 TI_DBG2(("ossaSGpioCB: smpFrameType: 0x%02x \n", pSgpioResponse->smpFrameType)); 7454 // printf("SS:ossaSGpioCB: smpFrameType: 0x%02x \n", pSgpioResponse->smpFrameType); 7455 TI_DBG2(("ossaSGpioCB: function: 0x%02x \n", pSgpioResponse->function)); 7456 TI_DBG2(("ossaSGpioCB: functionResult: 0x%02x \n", pSgpioResponse->functionResult)); 7457 //printf("SS:ossaSGpioCB: functionResult: 0x%02x \n", pSgpioResponse->functionResult); 7458 7459 tdhexdump("ossaSGpioCB Response", (bit8 *)pSgpioResponse, sizeof(agsaSGpioReqResponse_t)); 7460 ostiSgpioIoctlRsp(tiRoot, pSgpioResponse); 7461 } 7462 7463 #endif /* BIOS */ 7464 7465 /*****************************************************************************/ 7466 /*! \brief ossaLogDebugString 7467 * 7468 * 7469 * Purpose: This routine is called by lower layer to log. 7470 * 7471 * \param agRoot: Pointer to chip/driver Instance. 7472 * \param level: Detail of information desired. 7473 * \param string: Pointer to the character string. 7474 * \param ptr1: First pointer value. 7475 * \param ptr2: Second pointer value. 7476 * \param value1: First 32-bit value related to the specific information. 7477 * \param value2: Second 32-bit value related to the specific information. 7478 * 7479 * \return None. 7480 * 7481 */ 7482 /*****************************************************************************/ 7483 GLOBAL void ossaLogDebugString( 7484 agsaRoot_t *agRoot, 7485 bit32 level, 7486 char *string, 7487 void *ptr1, 7488 void *ptr2, 7489 bit32 value1, 7490 bit32 value2 7491 ) 7492 { 7493 #if defined(SALLSDK_DEBUG) 7494 TIDEBUG_MSG(gLLDebugLevel, level, ("%s %p %p %d %d\n", string, ptr1, ptr2, value1, value2)); 7495 #endif 7496 return; 7497 } 7498 7499 /*****************************************************************************/ 7500 /*! \brief ossaHwEventAckCB 7501 * 7502 * 7503 * Purpose: This routine is called by lower layer to corresponding to 7504 * saHwEventAck(() 7505 * 7506 * \param agRoot: Pointer to chip/driver Instance. 7507 * \param agContext: Context of the operation originally passed 7508 * in. 7509 * \param status: Status 7510 * 7511 * 7512 * \return None. 7513 * 7514 */ 7515 /*****************************************************************************/ 7516 GLOBAL void ossaHwEventAckCB( 7517 agsaRoot_t *agRoot, 7518 agsaContext_t *agContext, 7519 bit32 status 7520 ) 7521 { 7522 TI_DBG3(("ossaHwEventAckCB: start\n")); 7523 smTraceFuncEnter(hpDBG_VERY_LOUD,"Ys"); 7524 if (status == tiSuccess) 7525 { 7526 TI_DBG3(("ossaHwEventAckCB: SUCCESS status\n")); 7527 } 7528 else 7529 { 7530 TI_DBG1(("ossaHwEventAckCB: FAIL status 0x%X\n", status)); 7531 TI_DBG1(("ossaHwEventAckCB: invalid event status bit0 %d\n", status & 0x01)); 7532 TI_DBG1(("ossaHwEventAckCB: invalid phyid status bit1 %d\n", (status & 0x02) >> 1 )); 7533 TI_DBG1(("ossaHwEventAckCB: invalid portcontext status bit2 %d\n", (status & 0x04) >> 2)); 7534 TI_DBG1(("ossaHwEventAckCB: invalid param0 status bit3 %d\n", (status & 0x08) >> 3)); 7535 } 7536 7537 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Ys"); 7538 return; 7539 } 7540 7541 /*****************************************************************************/ 7542 /*! \brief ossaGetTimeStampCB 7543 * 7544 * 7545 * Purpose: This routine is called by lower layer to corresponding to 7546 * saGetTimeStamp() 7547 * 7548 * \param agRoot: Pointer to chip/driver Instance. 7549 * \param agContext: Context of the operation originally passed 7550 * in. 7551 * \param timeStampLower: The controller lower 32-bit of internal time 7552 * stamp associated with event log. 7553 * \param timeStampUpper: The controller upper 32-bit of internal time 7554 * stamp associated with event log. 7555 * 7556 * 7557 * \return None. 7558 * 7559 */ 7560 /*****************************************************************************/ 7561 GLOBAL void ossaGetTimeStampCB( 7562 agsaRoot_t *agRoot, 7563 agsaContext_t *agContext, 7564 bit32 timeStampLower, 7565 bit32 timeStampUpper 7566 ) 7567 { 7568 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yt"); 7569 TI_DBG4(("ossaGetTimeStampCB: start\n")); 7570 TI_DBG4(("ossaGetTimeStampCB: timeStampUpper 0x%x timeStampLower 0x%x\n", timeStampUpper, timeStampLower)); 7571 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yt"); 7572 return; 7573 } 7574 7575 7576 /*****************************************************************************/ 7577 /*! \brief ossaSMPAbortCB 7578 * 7579 * 7580 * Purpose: This routine is called by lower layer to corresponding to 7581 * saSMPAbort() 7582 * 7583 * \param agRoot: Pointer to chip/driver Instance. 7584 * \param agIORequest: This is the agIORequest parameter passed in 7585 * saSMPAbort() 7586 * \param status: Status of abort 7587 * 7588 * \return None. 7589 * 7590 */ 7591 /*****************************************************************************/ 7592 GLOBAL void ossaSMPAbortCB( 7593 agsaRoot_t *agRoot, 7594 agsaIORequest_t *agIORequest, 7595 bit32 flag, 7596 bit32 status) 7597 { 7598 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7599 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7600 tdIORequestBody_t *tdAbortIORequestBody = agNULL; 7601 tdsaDeviceData_t *oneDeviceData = agNULL; 7602 tiDeviceHandle_t *tiDeviceHandle = agNULL; 7603 7604 TI_DBG4(("ossaSMPAbortCB: start\n")); 7605 TI_DBG4(("ossaSMPAbortCB: flag %d\n", flag)); 7606 TI_DBG4(("ossaSMPAbortCB: status %d\n", status)); 7607 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yu"); 7608 7609 tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 7610 if (tdAbortIORequestBody == agNULL) 7611 { 7612 TI_DBG1(("ossaSMPAbortCB: tdAbortIORequestBody is NULL warning!!!!\n")); 7613 return; 7614 } 7615 7616 if (flag == 2) 7617 { 7618 /* abort per port */ 7619 TI_DBG2(("ossaSMPAbortCB: abort per port\n")); 7620 } 7621 else if (flag == 1) 7622 { 7623 TI_DBG2(("ossaSMPAbortCB: abort all\n")); 7624 7625 tiDeviceHandle = (tiDeviceHandle_t *)tdAbortIORequestBody->tiDevHandle; 7626 if (tiDeviceHandle == agNULL) 7627 { 7628 TI_DBG1(("ossaSMPAbortCB: tiDeviceHandle is NULL warning!!!!\n")); 7629 ostiFreeMemory( 7630 tiRoot, 7631 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7632 sizeof(tdIORequestBody_t) 7633 ); 7634 return; 7635 } 7636 7637 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 7638 if (oneDeviceData == agNULL) 7639 { 7640 TI_DBG1(("ossaSMPAbortCB: oneDeviceData is NULL warning!!!!\n")); 7641 ostiFreeMemory( 7642 tiRoot, 7643 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7644 sizeof(tdIORequestBody_t) 7645 ); 7646 return; 7647 } 7648 7649 if (status == OSSA_IO_SUCCESS) 7650 { 7651 TI_DBG2(("ossaSMPAbortCB: OSSA_IO_SUCCESS\n")); 7652 /* clean up TD layer's IORequestBody */ 7653 TI_DBG3(("ossaSMPAbortCB: calling saDeregisterDeviceHandle\n")); 7654 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 7655 TI_DBG2(("ossaSMPAbortCB: did %d\n", oneDeviceData->id)); 7656 ostiFreeMemory( 7657 tiRoot, 7658 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7659 sizeof(tdIORequestBody_t) 7660 ); 7661 7662 } 7663 else if (status == OSSA_IO_NOT_VALID) 7664 { 7665 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_NOT_VALID\n")); 7666 /* clean up TD layer's IORequestBody */ 7667 TI_DBG1(("ossaSMPAbortCB: calling saDeregisterDeviceHandle\n")); 7668 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 7669 TI_DBG1(("ossaSMPAbortCB: did %d\n", oneDeviceData->id)); 7670 ostiFreeMemory( 7671 tiRoot, 7672 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7673 sizeof(tdIORequestBody_t) 7674 ); 7675 } 7676 else if (status == OSSA_IO_NO_DEVICE) 7677 { 7678 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_NO_DEVICE\n")); 7679 /* clean up TD layer's IORequestBody */ 7680 TI_DBG1(("ossaSMPAbortCB: calling saDeregisterDeviceHandle\n")); 7681 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 7682 TI_DBG1(("ossaSMPAbortCB: did %d\n", oneDeviceData->id)); 7683 ostiFreeMemory( 7684 tiRoot, 7685 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7686 sizeof(tdIORequestBody_t) 7687 ); 7688 } 7689 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 7690 { 7691 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 7692 /* clean up TD layer's IORequestBody */ 7693 TI_DBG1(("ossaSMPAbortCB: calling saDeregisterDeviceHandle\n")); 7694 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 7695 TI_DBG1(("ossaSMPAbortCB: did %d\n", oneDeviceData->id)); 7696 ostiFreeMemory( 7697 tiRoot, 7698 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7699 sizeof(tdIORequestBody_t) 7700 ); 7701 } 7702 #ifdef REMOVED 7703 else if (status == OSSA_IO_ABORT_DELAYED) 7704 { 7705 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_ABORT_DELAYED\n")); 7706 /* clean up TD layer's IORequestBody */ 7707 TI_DBG1(("ossaSMPAbortCB: calling saDeregisterDeviceHandle\n")); 7708 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 7709 TI_DBG1(("ossaSMPAbortCB: did %d\n", oneDeviceData->id)); 7710 ostiFreeMemory( 7711 tiRoot, 7712 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7713 sizeof(tdIORequestBody_t) 7714 ); 7715 } 7716 #endif 7717 else 7718 { 7719 TI_DBG1(("ossaSMPAbortCB: other status %d\n", status)); 7720 /* clean up TD layer's IORequestBody */ 7721 TI_DBG1(("ossaSMPAbortCB: calling saDeregisterDeviceHandle\n")); 7722 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 7723 TI_DBG1(("ossaSMPAbortCB: did %d\n", oneDeviceData->id)); 7724 ostiFreeMemory( 7725 tiRoot, 7726 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7727 sizeof(tdIORequestBody_t) 7728 ); 7729 } 7730 } 7731 else if (flag == 0) 7732 { 7733 TI_DBG2(("ossaSMPAbortCB: abort one\n")); 7734 if (status == OSSA_IO_SUCCESS) 7735 { 7736 TI_DBG2(("ossaSMPAbortCB: OSSA_IO_SUCCESS\n")); 7737 ostiFreeMemory( 7738 tiRoot, 7739 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7740 sizeof(tdIORequestBody_t) 7741 ); 7742 7743 } 7744 else if (status == OSSA_IO_NOT_VALID) 7745 { 7746 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_NOT_VALID\n")); 7747 ostiFreeMemory( 7748 tiRoot, 7749 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7750 sizeof(tdIORequestBody_t) 7751 ); 7752 } 7753 else if (status == OSSA_IO_NO_DEVICE) 7754 { 7755 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_NO_DEVICE\n")); 7756 ostiFreeMemory( 7757 tiRoot, 7758 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7759 sizeof(tdIORequestBody_t) 7760 ); 7761 } 7762 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 7763 { 7764 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 7765 ostiFreeMemory( 7766 tiRoot, 7767 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7768 sizeof(tdIORequestBody_t) 7769 ); 7770 } 7771 #ifdef REMOVED 7772 else if (status == OSSA_IO_ABORT_DELAYED) 7773 { 7774 TI_DBG1(("ossaSMPAbortCB: OSSA_IO_ABORT_DELAYED\n")); 7775 ostiFreeMemory( 7776 tiRoot, 7777 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7778 sizeof(tdIORequestBody_t) 7779 ); 7780 } 7781 #endif 7782 else 7783 { 7784 TI_DBG1(("ossaSMPAbortCB: other status %d\n", status)); 7785 ostiFreeMemory( 7786 tiRoot, 7787 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 7788 sizeof(tdIORequestBody_t) 7789 ); 7790 } 7791 } 7792 else 7793 { 7794 TI_DBG1(("ossaSMPAbortCB: wrong flag %d\n", flag)); 7795 } 7796 7797 7798 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yu"); 7799 return; 7800 } 7801 7802 /*****************************************************************************/ 7803 /*! \brief ossaGeneralEvent 7804 * 7805 * 7806 * Purpose: This is the event notification for debugging purposes sent to 7807 * inform the OS layer of some general error related to a specific 7808 * inbound operation. 7809 * 7810 * \param agRoot: Pointer to chip/driver Instance. 7811 * \param status: Status associated with this event 7812 * \param msg: Pointer to controller specific command 7813 * massage that caused the error 7814 * 7815 * \return None. 7816 * 7817 */ 7818 /*****************************************************************************/ 7819 GLOBAL void ossaGeneralEvent( 7820 agsaRoot_t *agRoot, 7821 bit32 status, 7822 agsaContext_t *agContext, 7823 bit32 *msg) 7824 { 7825 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7826 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7827 7828 TI_DBG1(("ossaGeneralEvent: start\n")); 7829 TI_DBG1(("ossaGeneralEvent: status %d\n", status)); 7830 7831 if(msg) 7832 { 7833 TI_DBG1(("ossaGeneralEvent: *msg %X\n", *msg)); 7834 } 7835 7836 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yv"); 7837 ostiGenEventIOCTLRsp(tiRoot, status); 7838 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yv"); 7839 return; 7840 } 7841 7842 GLOBAL void ossaGetForensicDataCB ( 7843 agsaRoot_t *agRoot, 7844 agsaContext_t *agContext, 7845 bit32 status, 7846 agsaForensicData_t *forensicData) 7847 { 7848 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7849 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7850 7851 ostiGetForensicDataIOCTLRsp(tiRoot, status, forensicData); 7852 return; 7853 } 7854 7855 7856 #ifdef INITIATOR_DRIVER 7857 7858 GLOBAL void ossaGetIOErrorStatsCB ( 7859 agsaRoot_t *agRoot, 7860 agsaContext_t *agContext, 7861 bit32 status, 7862 agsaIOErrorEventStats_t *stats) 7863 7864 { 7865 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7866 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7867 7868 ostiGetIoErrorStatsIOCTLRsp(tiRoot, status, stats); 7869 } 7870 #else 7871 GLOBAL void ossaGetIOErrorStatsCB ( 7872 agsaRoot_t *agRoot, 7873 agsaContext_t *agContext, 7874 bit32 status, 7875 agsaIOErrorEventStats_t *stats) 7876 7877 { 7878 7879 } 7880 7881 #endif 7882 7883 GLOBAL void ossaGetIOEventStatsCB ( 7884 agsaRoot_t *agRoot, 7885 agsaContext_t *agContext, 7886 bit32 status, 7887 agsaIOErrorEventStats_t *stats) 7888 7889 { 7890 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7891 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7892 7893 ostiGetIoEventStatsIOCTLRsp(tiRoot, status, stats); 7894 } 7895 7896 7897 /*****************************************************************************/ 7898 /*! \brief ossaGetRegisterDumpCB 7899 * 7900 * 7901 * Purpose: ossaGetRegisterDumpCB() is the response callback function 7902 * called by the LL Layer to indicate a response to 7903 * saGetRegisterDump() 7904 * 7905 * \param agRoot: Pointer to chip/driver Instance. 7906 * \param agContext: Context of the operation originally 7907 * passed into saGetRegisterDump() 7908 * \param status: status 7909 * 7910 * \return None. 7911 * 7912 */ 7913 /*****************************************************************************/ 7914 GLOBAL void ossaGetRegisterDumpCB( 7915 agsaRoot_t *agRoot, 7916 agsaContext_t *agContext, 7917 bit32 status 7918 ) 7919 { 7920 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7921 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7922 7923 TI_DBG4(("ossaGetRegisterDumpCB: start\n")); 7924 TI_DBG4(("ossaGetRegisterDumpCB: status %d\n", status)); 7925 smTraceFuncEnter(hpDBG_VERY_LOUD,"Yw"); 7926 7927 ostiRegDumpIOCTLRsp(tiRoot, status); 7928 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "Yw"); 7929 return; 7930 } 7931 7932 /*****************************************************************************/ 7933 /*! \brief ossaSetDeviceStateCB 7934 * 7935 * 7936 * Purpose: ossaSetDeviceStateCB() is the response callback function 7937 * called by the LL Layer to indicate a response to 7938 * saSetDeviceState() 7939 * 7940 * \param agRoot: Pointer to chip/driver Instance. 7941 * \param agContext: Context of the operation originally 7942 * passed into saGetRegisterDump() 7943 * \param agDevHandle Pointer to the device handle of the device 7944 * \param status: status 7945 * \param newDeviceState: newly set device status 7946 * \param previousDeviceState: old device status 7947 * 7948 * \return None. 7949 * 7950 */ 7951 /*****************************************************************************/ 7952 GLOBAL void ossaSetDeviceStateCB( 7953 agsaRoot_t *agRoot, 7954 agsaContext_t *agContext, 7955 agsaDevHandle_t *agDevHandle, 7956 bit32 status, 7957 bit32 newDeviceState, 7958 bit32 previousDeviceState 7959 ) 7960 { 7961 tdsaDeviceData_t *oneDeviceData = agNULL; 7962 7963 TI_DBG2(("ossaSetDeviceStateCB: start\n")); 7964 TI_DBG2(("ossaSetDeviceStateCB: status %d\n", status)); 7965 TI_DBG2(("ossaSetDeviceStateCB: newDeviceState %d\n", newDeviceState)); 7966 TI_DBG2(("ossaSetDeviceStateCB: previousDeviceState %d\n", previousDeviceState)); 7967 7968 if (agDevHandle == agNULL) 7969 { 7970 TI_DBG4(("ossaSetDeviceStateCB: agDevHandle is NULL\n")); 7971 return; 7972 } 7973 7974 oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData; 7975 7976 if (oneDeviceData == agNULL) 7977 { 7978 TI_DBG1(("ossaSetDeviceStateCB: wrong; oneDeviceData is NULL\n")); 7979 } 7980 else 7981 { 7982 TI_DBG2(("ossaSetDeviceStateCB: did %d\n", oneDeviceData->id)); 7983 } 7984 7985 return; 7986 } 7987 7988 /*****************************************************************************/ 7989 /*! \brief ossaGetDeviceStateCB 7990 * 7991 * 7992 * Purpose: ossaGetDeviceStateCB() is the response callback function 7993 * called by the LL Layer to indicate a response to 7994 * saGetDeviceState() 7995 * 7996 * \param agRoot: Pointer to chip/driver Instance. 7997 * \param agContext: Context of the operation originally 7998 * passed into saGetRegisterDump() 7999 * \param agDevHandle Pointer to the device handle of the device 8000 * \param status: status 8001 * \param deviceState: device status 8002 * 8003 * \return None. 8004 * 8005 */ 8006 /*****************************************************************************/ 8007 GLOBAL void ossaGetDeviceStateCB( 8008 agsaRoot_t *agRoot, 8009 agsaContext_t *agContext, 8010 agsaDevHandle_t *agDevHandle, 8011 bit32 status, 8012 bit32 deviceState 8013 ) 8014 { 8015 TI_DBG4(("ossaGetDeviceStateCB: start\n")); 8016 TI_DBG4(("ossaGetDeviceStateCB: status %d\n", status)); 8017 TI_DBG4(("ossaGetDeviceStateCB: deviceState %d\n", deviceState)); 8018 8019 return; 8020 } 8021 8022 #ifdef INITIATOR_DRIVER 8023 /*****************************************************************************/ 8024 /*! \brief ossaIniSetDeviceInfoCB 8025 * 8026 * 8027 * Purpose: ossaIniSetDeviceInfoCB() is the response callback function 8028 * called by the LL Layer to indicate a response to 8029 * saSetDeviceInfo() 8030 * 8031 * \param agRoot: Pointer to chip/driver Instance. 8032 * \param agContext: Context of the operation originally 8033 * passed into saSetDeviceInfo() 8034 * \param agDevHandle Pointer to the device handle of the device 8035 * \param status: status 8036 * \param option: option parameter passed in saSetDeviceInfo() 8037 * \param param: param parameter passed in saSetDeviceInfo() 8038 * 8039 * \return None. 8040 * 8041 */ 8042 /*****************************************************************************/ 8043 osGLOBAL void 8044 ossaIniSetDeviceInfoCB( 8045 agsaRoot_t *agRoot, 8046 agsaContext_t *agContext, 8047 agsaDevHandle_t *agDevHandle, 8048 bit32 status, 8049 bit32 option, 8050 bit32 param 8051 ) 8052 { 8053 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8054 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8055 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8056 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8057 itdsaIni_t *Initiator = (itdsaIni_t *)tdsaAllShared->itdsaIni; 8058 bit32 intContext = osData->IntContext; 8059 tdIORequestBody_t *tdIORequestBody = agNULL; 8060 agsaIORequest_t *agIORequest = agNULL; 8061 bit32 saStatus = AGSA_RC_FAILURE; 8062 bit8 devType_S_Rate; 8063 tdsaDeviceData_t *oneDeviceData = agNULL; 8064 8065 TI_DBG4(("ossaIniSetDeviceInfoCB: start\n")); 8066 TI_DBG4(("ossaIniSetDeviceInfoCB: status 0x%x\n", status)); 8067 TI_DBG4(("ossaIniSetDeviceInfoCB: option 0x%x\n", option)); 8068 TI_DBG4(("ossaIniSetDeviceInfoCB: param 0x%x\n", param)); 8069 8070 if (status != OSSA_SUCCESS) 8071 { 8072 TI_DBG1(("ossaIniSetDeviceInfoCB: status %d\n", status)); 8073 TI_DBG1(("ossaIniSetDeviceInfoCB: option 0x%x\n", option)); 8074 TI_DBG1(("ossaIniSetDeviceInfoCB: param 0x%x\n", param)); 8075 if (option == 32) /* set connection rate */ 8076 { 8077 TI_DBG1(("ossaIniSetDeviceInfoCB: IO failure\n")); 8078 agIORequest = (agsaIORequest_t *)agContext->osData; 8079 tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 8080 ostiInitiatorIOCompleted( 8081 tiRoot, 8082 tdIORequestBody->tiIORequest, 8083 tiIOFailed, 8084 tiDetailOtherError, 8085 agNULL, 8086 intContext 8087 ); 8088 } 8089 } 8090 if (agDevHandle == agNULL) 8091 { 8092 TI_DBG4(("ossaIniSetDeviceInfoCB: agDevHandle is NULL\n")); 8093 return; 8094 } 8095 oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData; 8096 if (oneDeviceData == agNULL) 8097 { 8098 TI_DBG1(("ossaIniSetDeviceInfoCB: wrong; oneDeviceData is NULL\n")); 8099 return; 8100 } 8101 else 8102 { 8103 TI_DBG4(("ossaIniSetDeviceInfoCB: did %d\n", oneDeviceData->id)); 8104 } 8105 8106 /* retry IOs */ 8107 if (option == 32) /* set connection rate */ 8108 { 8109 TI_DBG1(("ossaIniSetDeviceInfoCB: set connection rate option\n")); 8110 agIORequest = (agsaIORequest_t *)agContext->osData; 8111 tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 8112 devType_S_Rate = oneDeviceData->agDeviceInfo.devType_S_Rate; 8113 devType_S_Rate = (devType_S_Rate & 0xF0) | (param >> 28); 8114 oneDeviceData->agDeviceInfo.devType_S_Rate = devType_S_Rate; 8115 TI_DBG1(("ossaIniSetDeviceInfoCB: new rate is 0x%x\n", DEVINFO_GET_LINKRATE(&oneDeviceData->agDeviceInfo))); 8116 if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && 8117 oneDeviceData->tdPortContext != agNULL ) 8118 { 8119 saStatus = saSSPStart(agRoot, 8120 agIORequest, 8121 tdsaRotateQnumber(tiRoot, oneDeviceData), 8122 agDevHandle, 8123 tdIORequestBody->agRequestType, 8124 &(tdIORequestBody->transport.SAS.agSASRequestBody), 8125 agNULL, 8126 &ossaSSPCompleted); 8127 if (saStatus == AGSA_RC_SUCCESS) 8128 { 8129 TI_DBG1(("ossaIniSetDeviceInfoCB: retried\n")); 8130 Initiator->NumIOsActive++; 8131 tdIORequestBody->ioStarted = agTRUE; 8132 tdIORequestBody->ioCompleted = agFALSE; 8133 return; 8134 } 8135 else 8136 { 8137 TI_DBG1(("ossaIniSetDeviceInfoCB: retry failed\n")); 8138 tdIORequestBody->ioStarted = agFALSE; 8139 tdIORequestBody->ioCompleted = agTRUE; 8140 ostiInitiatorIOCompleted( 8141 tiRoot, 8142 tdIORequestBody->tiIORequest, 8143 tiIOFailed, 8144 tiDetailOtherError, 8145 agNULL, 8146 intContext 8147 ); 8148 } 8149 } 8150 } 8151 return; 8152 } 8153 #endif 8154 /*****************************************************************************/ 8155 /*! \brief ossaSetDeviceInfoCB 8156 * 8157 * 8158 * Purpose: ossaSetDeviceInfoCB() is the response callback function 8159 * called by the LL Layer to indicate a response to 8160 * saSetDeviceInfo() 8161 * 8162 * \param agRoot: Pointer to chip/driver Instance. 8163 * \param agContext: Context of the operation originally 8164 * passed into saSetDeviceInfo() 8165 * \param agDevHandle Pointer to the device handle of the device 8166 * \param status: status 8167 * \param option: option parameter passed in saSetDeviceInfo() 8168 * \param param: param parameter passed in saSetDeviceInfo() 8169 * 8170 * \return None. 8171 * 8172 */ 8173 /*****************************************************************************/ 8174 GLOBAL void ossaSetDeviceInfoCB( 8175 agsaRoot_t *agRoot, 8176 agsaContext_t *agContext, 8177 agsaDevHandle_t *agDevHandle, 8178 bit32 status, 8179 bit32 option, 8180 bit32 param 8181 ) 8182 { 8183 tdsaDeviceData_t *oneDeviceData = agNULL; 8184 8185 TI_DBG4(("ossaSetDeviceInfoCB: start\n")); 8186 TI_DBG4(("ossaSetDeviceInfoCB: status 0x%x\n", status)); 8187 TI_DBG4(("ossaSetDeviceInfoCB: option 0x%x\n", option)); 8188 TI_DBG4(("ossaSetDeviceInfoCB: param 0x%x\n", param)); 8189 8190 if (status != OSSA_SUCCESS) 8191 { 8192 TI_DBG1(("ossaSetDeviceInfoCB: status %d\n", status)); 8193 TI_DBG1(("ossaSetDeviceInfoCB: option 0x%x\n", option)); 8194 TI_DBG1(("ossaSetDeviceInfoCB: param 0x%x\n", param)); 8195 } 8196 8197 if (agDevHandle == agNULL) 8198 { 8199 TI_DBG4(("ossaSetDeviceInfoCB: agDevHandle is NULL\n")); 8200 return; 8201 } 8202 8203 oneDeviceData = (tdsaDeviceData_t *)agDevHandle->osData; 8204 8205 if (oneDeviceData == agNULL) 8206 { 8207 TI_DBG1(("ossaSetDeviceInfoCB: wrong; oneDeviceData is NULL\n")); 8208 } 8209 else 8210 { 8211 TI_DBG4(("ossaSetDeviceInfoCB: did %d\n", oneDeviceData->id)); 8212 } 8213 8214 return; 8215 } 8216 8217 /*****************************************************************************/ 8218 /*! \brief ossaGetDFEDataCB 8219 * 8220 * 8221 * Purpose: ossaGetDFEDataCB() is the response callback function 8222 * called by the LL Layer to indicate a response to 8223 * saGetDFEData() 8224 * 8225 * \param agRoot: Pointer to chip/driver Instance. 8226 * \param agContext: Context of the operation originally 8227 * passed into saGetDFEData() 8228 * \param status: status 8229 * \param agInfoLen: length in bytes of DFE data captured and transferred 8230 * 8231 * \return None. 8232 * 8233 */ 8234 /*****************************************************************************/ 8235 GLOBAL void ossaGetDFEDataCB( 8236 agsaRoot_t *agRoot, 8237 agsaContext_t *agContext, 8238 bit32 status, 8239 bit32 agInfoLen) 8240 { 8241 TI_DBG1(("ossaGetDFEDataCB: start\n")); 8242 TI_DBG1(("ossaGetDFEDataCB: status 0x%x agInfoLen 0x%x\n", status, agInfoLen)); 8243 return; 8244 } 8245 8246 /*****************************************************************************/ 8247 /*! \brief ossaVhistCaptureCB 8248 * 8249 * 8250 * Purpose: ossaVhistCaptureCB() is the response callback function 8251 * called by the LL Layer to indicate a response to 8252 * saGetDFEData() 8253 * 8254 * \param agRoot: Pointer to chip/driver Instance. 8255 * \param agContext: Context of the operation originally 8256 * passed into () 8257 * \param status: status 8258 * \param len: length in bytes of Vis data captured and transferred 8259 * 8260 * \return None. 8261 * 8262 */ 8263 /*****************************************************************************/ 8264 8265 void ossaVhistCaptureCB( 8266 agsaRoot_t *agRoot, 8267 agsaContext_t *agContext, 8268 bit32 status, 8269 bit32 len) 8270 { 8271 TI_DBG1(("ossaVhistCaptureCB: start\n")); 8272 TI_DBG1(("ossaVhistCaptureCB: status 0x%x agInfoLen 0x%x\n", status,len )); 8273 return; 8274 } 8275 8276 GLOBAL void ossaOperatorManagementCB( 8277 agsaRoot_t *agRoot, 8278 agsaContext_t *agContext, 8279 bit32 status, 8280 bit32 eq 8281 ) 8282 { 8283 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8284 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8285 tiEncryptPort_t encryptEventData; 8286 8287 TI_DBG1(("ossaOperatorManagementCB: status 0x%x eq 0x%x\n", status, eq)); 8288 8289 osti_memset(&encryptEventData, 0, sizeof(tiEncryptPort_t)); 8290 encryptEventData.encryptEvent = tiEncryptOperatorManagement; 8291 encryptEventData.subEvent = eq; 8292 encryptEventData.pData = agNULL; 8293 8294 ostiPortEvent(tiRoot, 8295 tiEncryptOperation, 8296 status, 8297 &encryptEventData); 8298 } 8299 8300 GLOBAL void ossaEncryptSelftestExecuteCB ( 8301 agsaRoot_t *agRoot, 8302 agsaContext_t *agContext, 8303 bit32 status, 8304 bit32 type, 8305 bit32 length, 8306 void *TestResult 8307 ) 8308 { 8309 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8310 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8311 tiEncryptPort_t encryptEventData; 8312 8313 TI_DBG1(("ossaEncryptSelftestExecuteCB: status 0x%x type 0x%x length 0x%x\n", status, type, length)); 8314 8315 osti_memset(&encryptEventData, 0, sizeof(tiEncryptPort_t)); 8316 encryptEventData.encryptEvent = tiEncryptSelfTest; 8317 encryptEventData.subEvent = type; 8318 encryptEventData.pData = (void*)TestResult; 8319 8320 ostiPortEvent(tiRoot, 8321 tiEncryptOperation, 8322 status, 8323 &encryptEventData); 8324 } 8325 8326 GLOBAL void ossaGetOperatorCB( 8327 agsaRoot_t *agRoot, 8328 agsaContext_t *agContext, 8329 bit32 status, 8330 bit32 option, 8331 bit32 num, 8332 bit32 role, 8333 agsaID_t *id 8334 ) 8335 { 8336 8337 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8338 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8339 tiEncryptPort_t encryptEventData; 8340 8341 TI_DBG1(("ossaGetOperatorCB: status 0x%x option 0x%x num 0x%x role 0x%x\n", 8342 status, option, num, role)); 8343 TI_DBG1(("ossaGetOperatorCB: agContext %p id %p\n",agContext,id)); 8344 osti_memset(&encryptEventData, 0, sizeof(tiEncryptPort_t)); 8345 encryptEventData.encryptEvent = tiEncryptGetOperator; 8346 encryptEventData.subEvent = option; 8347 encryptEventData.pData = agNULL; 8348 8349 switch(status) 8350 { 8351 case OSSA_IO_SUCCESS: 8352 TI_DBG1(("ossaGetOperatorCB: OSSA_IO_SUCCESS option 0x%x\n", option)); 8353 if(option == 1) 8354 { 8355 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[0], id->ID[1], id->ID[2], id->ID[3])); 8356 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[4], id->ID[5], id->ID[6], id->ID[7])); 8357 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[8], id->ID[9], id->ID[10],id->ID[11])); 8358 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[12],id->ID[13],id->ID[14],id->ID[15])); 8359 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[16],id->ID[17],id->ID[18],id->ID[19])); 8360 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[20],id->ID[21],id->ID[22],id->ID[23])); 8361 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x 0x%02x\n",id->ID[24],id->ID[25],id->ID[26],id->ID[27])); 8362 TI_DBG2(("ossaGetOperatorCB: 0x%02x 0x%02x 0x%02x\n", id->ID[28],id->ID[29],id->ID[30])); 8363 }else if(option == 2) 8364 { 8365 TI_DBG1(("ossaGetOperatorCB: number operators 0x%02x\n", num )); 8366 } 8367 8368 encryptEventData.pData = id; 8369 break; 8370 case OSSA_MPI_ENC_ERR_UNSUPPORTED_OPTION: 8371 TI_DBG1(("ossaGetOperatorCB: OSSA_MPI_ENC_ERR_UNSUPPORTED_OPTION 0x%x\n",option)); 8372 break; 8373 case OSSA_MPI_ENC_ERR_ID_TRANSFER_FAILURE: 8374 TI_DBG1(("ossaGetOperatorCB: OSSA_MPI_ENC_ERR_ID_TRANSFER_FAILURE 0x%x\n",option)); 8375 break; 8376 default: 8377 TI_DBG1(("ossaGetOperatorCB: Unknown status 0x%x\n",status)); 8378 } 8379 ostiPortEvent(tiRoot, 8380 tiEncryptOperation, 8381 status, 8382 &encryptEventData); 8383 8384 } 8385 8386 GLOBAL void ossaSetOperatorCB( 8387 agsaRoot_t *agRoot, 8388 agsaContext_t *agContext, 8389 bit32 status, 8390 bit32 eq 8391 ) 8392 { 8393 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8394 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8395 tiEncryptPort_t encryptEventData; 8396 8397 TI_DBG1(("ossaSetOperatorCB: agContext %p status 0x%x eq 0x%x\n",agContext, status, eq)); 8398 8399 osti_memset(&encryptEventData, 0, sizeof(tiEncryptPort_t)); 8400 encryptEventData.encryptEvent = tiEncryptSetOperator; 8401 encryptEventData.subEvent = 0; 8402 switch(status) 8403 { 8404 case OSSA_IO_SUCCESS: 8405 TI_DBG1(("ossaSetOperatorCB: OSSA_IO_SUCCESS\n")); 8406 encryptEventData.pData = agNULL; 8407 break; 8408 case OSSA_MPI_ENC_ERR_CONTROLLER_NOT_IDLE: 8409 TI_DBG1(("ossaSetOperatorCB: OSSA_MPI_ENC_ERR_CONTROLLER_NOT_IDLE\n")); 8410 break; 8411 case OSSA_MPI_ENC_OPERATOR_AUTH_FAILURE: 8412 TI_DBG1(("ossaSetOperatorCB: OSSA_MPI_ENC_OPERATOR_AUTH_FAILURE error qualifier 0x%x\n",eq)); 8413 break; 8414 case OSSA_MPI_ENC_OPERATOR_OPERATOR_ALREADY_LOGGED_IN: 8415 TI_DBG1(("ossaSetOperatorCB: OSSA_MPI_ENC_OPERATOR_OPERATOR_ALREADY_LOGGED_IN\n")); 8416 break; 8417 case OSSA_MPI_ENC_OPERATOR_ILLEGAL_PARAMETER: 8418 TI_DBG1(("ossaSetOperatorCB: OSSA_MPI_ENC_OPERATOR_ILLEGAL_PARAMETER\n")); 8419 break; 8420 case OSSA_MPI_ENC_ERR_UNSUPPORTED_OPTION: 8421 TI_DBG1(("ossaSetOperatorCB: OSSA_MPI_ENC_ERR_UNSUPPORTED_OPTION\n")); 8422 break; 8423 case OSSA_MPI_ENC_ERR_ID_TRANSFER_FAILURE: 8424 TI_DBG1(("ossaSetOperatorCB: OSSA_MPI_ENC_ERR_ID_TRANSFER_FAILURE\n")); 8425 break; 8426 default: 8427 TI_DBG1(("ossaGetOperatorCB: Unknown status 0x%x\n",status)); 8428 } 8429 ostiPortEvent(tiRoot, 8430 tiEncryptOperation, 8431 status, 8432 &encryptEventData); 8433 } 8434 8435 GLOBAL void ossaDIFEncryptionOffloadStartCB( 8436 agsaRoot_t *agRoot, 8437 agsaContext_t *agContext, 8438 bit32 status, 8439 agsaOffloadDifDetails_t *agsaOffloadDifDetails) 8440 { 8441 TI_DBG1(("ossaDIFEncryptionOffloadStartCB: start\n")); 8442 TI_DBG1(("ossaDIFEncryptionOffloadStartCB: status 0x%x agsaOffloadDifDetails=%p\n", status, agsaOffloadDifDetails)); 8443 return; 8444 } 8445 8446 GLOBAL bit32 ossaTimeStamp( agsaRoot_t *agRoot ) 8447 { 8448 tdsaRootOsData_t *osData= agNULL; 8449 tiRoot_t *tiRoot= agNULL; 8450 if(agRoot) 8451 { 8452 osData = (tdsaRootOsData_t *)agRoot->osData; 8453 } 8454 if(osData) 8455 { 8456 tiRoot = (tiRoot_t *)osData->tiRoot; 8457 } 8458 return(ostiTimeStamp(tiRoot)); 8459 } 8460 8461 GLOBAL bit64 ossaTimeStamp64( agsaRoot_t *agRoot) 8462 { 8463 tdsaRootOsData_t *osData= agNULL; 8464 tiRoot_t *tiRoot= agNULL; 8465 if(agRoot) 8466 { 8467 osData = (tdsaRootOsData_t *)agRoot->osData; 8468 } 8469 if(osData) 8470 { 8471 tiRoot = (tiRoot_t *)osData->tiRoot; 8472 } 8473 return(ostiTimeStamp64(tiRoot)); 8474 } 8475 8476 #ifdef FDS_SM 8477 osGLOBAL void 8478 tdIDStartTimer(tiRoot_t *tiRoot, 8479 smIORequest_t *smIORequest, 8480 tdsaDeviceData_t *oneDeviceData 8481 ) 8482 { 8483 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8484 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8485 itdsaIni_t *Initiator = (itdsaIni_t *)tdsaAllShared->itdsaIni; 8486 8487 TI_DBG1(("tdIDStartTimer: start\n")); 8488 8489 tdsaSingleThreadedEnter(tiRoot, TD_TIMER_LOCK); 8490 if (oneDeviceData->tdIDTimer.timerRunning == agTRUE) 8491 { 8492 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK); 8493 tdsaKillTimer( 8494 tiRoot, 8495 &oneDeviceData->tdIDTimer 8496 ); 8497 } 8498 else 8499 { 8500 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK); 8501 } 8502 8503 tdsaSetTimerRequest( 8504 tiRoot, 8505 &oneDeviceData->tdIDTimer, 8506 SATA_ID_DEVICE_DATA_TIMER_VALUE/Initiator->OperatingOption.UsecsPerTick, 8507 tdIDStartTimerCB, 8508 smIORequest, 8509 oneDeviceData, 8510 agNULL 8511 ); 8512 8513 tdsaAddTimer( 8514 tiRoot, 8515 &Initiator->timerlist, 8516 &oneDeviceData->tdIDTimer 8517 ); 8518 TI_DBG1(("tdIDStartTimer: end\n")); 8519 return; 8520 } 8521 8522 osGLOBAL void 8523 tdIDStartTimerCB( 8524 tiRoot_t * tiRoot, 8525 void * timerData1, 8526 void * timerData2, 8527 void * timerData3 8528 ) 8529 { 8530 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8531 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8532 smIORequest_t *smIORequest; 8533 tdsaDeviceData_t *oneDeviceData; 8534 smRoot_t *smRoot; 8535 tdIORequestBody_t *tdIORequestBody; 8536 smDeviceHandle_t *smDeviceHandle; 8537 tdsaPortContext_t *onePortContext; 8538 #ifdef REMOVED 8539 agsaRoot_t *agRoot; 8540 bit32 IDstatus; 8541 //#endif 8542 //#ifdef REMOVED 8543 agsaIORequest_t *agAbortIORequest = agNULL; 8544 tdIORequestBody_t *tdAbortIORequestBody = agNULL; 8545 bit32 PhysUpper32; 8546 bit32 PhysLower32; 8547 bit32 memAllocStatus; 8548 void *osMemHandle; 8549 #endif // REMOVED 8550 #ifdef TD_DEBUG_ENABLE 8551 bit32 status = AGSA_RC_FAILURE; 8552 #endif 8553 8554 TI_DBG1(("tdIDStartTimerCB start\n")); 8555 smIORequest = (smIORequest_t *)timerData1; 8556 oneDeviceData = (tdsaDeviceData_t *)timerData2; 8557 smRoot = &(tdsaAllShared->smRoot); 8558 #ifdef REMOVED 8559 agRoot = oneDeviceData->agRoot; 8560 #endif // REMOVED 8561 8562 if (smIORequest == agNULL) 8563 { 8564 TI_DBG1(("tdIDStartTimerCB: smIORequest == agNULL !!!!!!\n")); 8565 return; 8566 } 8567 8568 if (oneDeviceData == agNULL) 8569 { 8570 TI_DBG1(("tdIDStartTimerCB: oneDeviceData == agNULL !!!!!!\n")); 8571 return; 8572 } 8573 8574 if (oneDeviceData->satDevData.IDPending == agFALSE || oneDeviceData->satDevData.IDDeviceValid == agTRUE) 8575 { 8576 /*the Identify Device command already normally completed, just return*/ 8577 return; 8578 } 8579 8580 tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData; 8581 smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle); 8582 onePortContext = oneDeviceData->tdPortContext; 8583 if (tdIORequestBody == agNULL) 8584 { 8585 TI_DBG1(("tdIDStartTimerCB: tdIORequestBody == agNULL !!!!!!\n")); 8586 return; 8587 } 8588 8589 if (smDeviceHandle == agNULL) 8590 { 8591 TI_DBG1(("tdIDStartTimerCB: smDeviceHandle == agNULL !!!!!!\n")); 8592 return; 8593 } 8594 8595 if (onePortContext == agNULL) 8596 { 8597 TI_DBG1(("tdIDStartTimerCB: onePortContext == agNULL !!!!!!\n")); 8598 return; 8599 } 8600 8601 TI_DBG1(("tdIDStartTimerCB: did %d\n", oneDeviceData->id)); 8602 /* 8603 1. smIOabort() 8604 2. in tdsmIDCompletedCB(), retry 8605 */ 8606 if (oneDeviceData->valid == agFALSE) 8607 { 8608 TI_DBG1(("tdIDStartTimerCB: invalid device\n")); 8609 return; 8610 } 8611 #ifdef TD_DEBUG_ENABLE 8612 status = smIOAbort( smRoot, smIORequest ); 8613 #else 8614 smIOAbort( smRoot, smIORequest ); 8615 #endif 8616 8617 #ifdef REMOVED 8618 /* allocating agIORequest for abort itself */ 8619 memAllocStatus = ostiAllocMemory( 8620 tiRoot, 8621 &osMemHandle, 8622 (void **)&tdAbortIORequestBody, 8623 &PhysUpper32, 8624 &PhysLower32, 8625 8, 8626 sizeof(tdIORequestBody_t), 8627 agTRUE 8628 ); 8629 if (memAllocStatus != tiSuccess) 8630 { 8631 /* let os process IO */ 8632 TI_DBG1(("tdIDStartTimerCB: ostiAllocMemory failed...; can't retry ID data \n")); 8633 return; 8634 } 8635 if (tdAbortIORequestBody == agNULL) 8636 { 8637 /* let os process IO */ 8638 TI_DBG1(("tdIDStartTimerCB: ostiAllocMemory returned NULL tdAbortIORequestBody; can't retry ID data\n")); 8639 return; 8640 } 8641 /* setup task management structure */ 8642 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 8643 /* setting callback but not used later */ 8644 tdAbortIORequestBody->IOCompletionFunc = agNULL; 8645 //tdAbortIORequestBody->IOCompletionFunc = itdssIOAbortedHandler; 8646 tdAbortIORequestBody->tiDevHandle = (tiDeviceHandle_t *)&(oneDeviceData->tiDeviceHandle); 8647 /* initialize agIORequest */ 8648 agAbortIORequest = &(tdAbortIORequestBody->agIORequest); 8649 agAbortIORequest->osData = (void *) tdAbortIORequestBody; 8650 agAbortIORequest->sdkData = agNULL; /* LL takes care of this */ 8651 //#endif 8652 //#ifdef REMOVED 8653 status = saSATAAbort(agRoot, 8654 agAbortIORequest, 8655 0, 8656 oneDeviceData->agDevHandle, 8657 1, /* abort all */ 8658 agNULL, 8659 ossaSATAIDAbortCB 8660 ); 8661 status = saSATAAbort(agRoot, 8662 agAbortIORequest, 8663 0, 8664 oneDeviceData->agDevHandle, 8665 0, /* abort one */ 8666 agIORequest, 8667 ossaSATAIDAbortCB 8668 ); 8669 //#endif 8670 //#ifdef REMOVED 8671 if (status != AGSA_RC_SUCCESS) 8672 { 8673 TI_DBG1(("tdIDStartTimerCB: saSATAAbort failed; can't retry ID data\n")); 8674 } 8675 if (oneDeviceData->satDevData.IDDeviceValid == agTRUE) 8676 { 8677 TI_DBG1(("tdIDStartTimerCB: IDDeviceValid is valid, no need to retry\n")); 8678 return; 8679 } 8680 if (tdIORequestBody->reTries <= SM_RETRIES) 8681 { 8682 tdIORequestBody->tiIORequest = agNULL; /* not in use */ 8683 tdIORequestBody->pid = onePortContext->id; 8684 smIORequest->tdData = tdIORequestBody; 8685 smIORequest->smData = &tdIORequestBody->smIORequestBody; 8686 smDeviceHandle->tdData = oneDeviceData; 8687 IDstatus = smIDStart(smRoot, smIORequest, smDeviceHandle ); 8688 if (IDstatus == SM_RC_SUCCESS) 8689 { 8690 TI_DBG1(("tdIDStartTimerCB: being retried!!!\n")); 8691 tdIORequestBody->reTries++; 8692 tdIORequestBody->ioCompleted = agFALSE; 8693 tdIORequestBody->ioStarted = agTRUE; 8694 tdIDStartTimer(tiRoot, smIORequest, oneDeviceData); 8695 } 8696 else 8697 { 8698 /* identify device data is not valid */ 8699 TI_DBG1(("tdIDStartTimerCB: smIDStart fail or busy %d!!!\n", IDstatus)); 8700 tdIORequestBody->reTries = 0; 8701 tdIORequestBody->ioCompleted = agTRUE; 8702 tdIORequestBody->ioStarted = agFALSE; 8703 ostiFreeMemory( tiRoot, 8704 tdIORequestBody->osMemHandle, 8705 sizeof(tdIORequestBody_t) 8706 ); 8707 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 8708 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 8709 return; 8710 } 8711 } 8712 else 8713 { 8714 /* give up */ 8715 TI_DBG1(("tdIDStartTimerCB: retries are over!!!\n")); 8716 if (oneDeviceData->tdIDTimer.timerRunning == agTRUE) 8717 { 8718 tdsaKillTimer( tiRoot, &oneDeviceData->tdIDTimer ); 8719 } 8720 tdIORequestBody->reTries = 0; 8721 tdIORequestBody->ioCompleted = agTRUE; 8722 tdIORequestBody->ioStarted = agFALSE; 8723 ostiFreeMemory( 8724 tiRoot, 8725 tdIORequestBody->osMemHandle, 8726 sizeof(tdIORequestBody_t) 8727 ); 8728 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 8729 8730 if (oneDeviceData->SMNumOfID <= 0) /* does SMP HARD RESET only upto one time */ 8731 { 8732 TI_DBG1(("tdIDStartTimerCB: fail; sending HARD_RESET\n")); 8733 oneDeviceData->SMNumOfID++; 8734 if (oneDeviceData->directlyAttached == agTRUE) 8735 { 8736 saLocalPhyControl(agRoot, agNULL, 0, oneDeviceData->phyID, AGSA_PHY_HARD_RESET, agNULL); 8737 } 8738 else 8739 { 8740 tdsaPhyControlSend(tiRoot, 8741 oneDeviceData, 8742 SMP_PHY_CONTROL_HARD_RESET, 8743 agNULL); 8744 } 8745 } 8746 else 8747 { 8748 /* given up after one time of SMP HARD RESET; */ 8749 TI_DBG1(("tdIDStartTimerCB: fail; but giving up sending HARD_RESET!!!\n")); 8750 if (oneDeviceData->directlyAttached == agTRUE) 8751 { 8752 smReportRemovalDirect(tiRoot, agRoot, oneDeviceData); 8753 } 8754 else 8755 { 8756 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 8757 } 8758 } 8759 } 8760 #endif // REMOVED 8761 8762 TI_DBG1(("tdIDStartTimerCB: end, smIOAbort status %d\n", status)); 8763 return; 8764 } 8765 #endif // FDS_SM 8766 8767 8768 #if defined(FDS_DM) && defined(FDS_SM) 8769 //start here 8770 GLOBAL void 8771 tdIDStart( 8772 tiRoot_t *tiRoot, 8773 agsaRoot_t *agRoot, 8774 smRoot_t *smRoot, 8775 tdsaDeviceData_t *oneDeviceData, 8776 tdsaPortContext_t *onePortContext 8777 ) 8778 { 8779 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8780 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8781 bit32 SMstatus = SM_RC_FAILURE; 8782 tdIORequestBody_t *tdIORequestBody; 8783 smIORequest_t *smIORequest; 8784 smDeviceHandle_t *smDeviceHandle; 8785 bit32 PhysUpper32; 8786 bit32 PhysLower32; 8787 bit32 memAllocStatus; 8788 void *osMemHandle; 8789 8790 8791 TI_DBG1(("tdIDStart: start, did %d\n",oneDeviceData->id)); 8792 8793 if ( (DEVICE_IS_SATA_DEVICE(oneDeviceData)|| DEVICE_IS_STP_TARGET(oneDeviceData)) 8794 && 8795 oneDeviceData->satDevData.IDDeviceValid == agFALSE 8796 && 8797 oneDeviceData->satDevData.IDPending == agFALSE 8798 ) 8799 { 8800 TI_DBG2(("tdIDStart: in loop, did %d\n", oneDeviceData->id)); 8801 /* allocating tdIORequestBody */ 8802 memAllocStatus = ostiAllocMemory( 8803 tiRoot, 8804 &osMemHandle, 8805 (void **)&tdIORequestBody, 8806 &PhysUpper32, 8807 &PhysLower32, 8808 8, 8809 sizeof(tdIORequestBody_t), 8810 agTRUE 8811 ); 8812 if (memAllocStatus != tiSuccess || tdIORequestBody == agNULL) 8813 { 8814 /* let os process IO */ 8815 TI_DBG1(("tdIDStart: ostiAllocMemory failed... or ostiAllocMemory returned NULL tdIORequestBody!!!\n")); 8816 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 8817 if (oneDeviceData->directlyAttached == agTRUE) 8818 { 8819 /* notifying link up */ 8820 ostiPortEvent( 8821 tiRoot, 8822 tiPortLinkUp, 8823 tiSuccess, 8824 (void *)onePortContext->tiPortalContext 8825 ); 8826 #ifdef INITIATOR_DRIVER 8827 /* triggers discovery */ 8828 ostiPortEvent( 8829 tiRoot, 8830 tiPortDiscoveryReady, 8831 tiSuccess, 8832 (void *) onePortContext->tiPortalContext 8833 ); 8834 #endif 8835 } 8836 } 8837 else 8838 { 8839 /* initialize */ 8840 osti_memset(tdIORequestBody, 0, sizeof(tdIORequestBody_t)); 8841 8842 tdIORequestBody->osMemHandle = osMemHandle; 8843 TI_DBG2(("tdIDStart: tdIORequestBody %p tdIORequestBody->osMemHandle %p\n", tdIORequestBody, tdIORequestBody->osMemHandle)); 8844 8845 /* not in use */ 8846 tdIORequestBody->IOCompletionFunc = agNULL; 8847 tdIORequestBody->tiDevHandle = agNULL; 8848 8849 tdIORequestBody->tiIORequest = agNULL; /* not in use */ 8850 tdIORequestBody->pid = onePortContext->id; 8851 tdIORequestBody->reTries = 0; 8852 smIORequest = (smIORequest_t *)&(tdIORequestBody->smIORequest); 8853 smIORequest->tdData = tdIORequestBody; 8854 smIORequest->smData = &tdIORequestBody->smIORequestBody; 8855 8856 smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle); 8857 smDeviceHandle->tdData = oneDeviceData; 8858 8859 TI_DBG2(("tdIDStart: smIORequest %p\n", smIORequest)); 8860 8861 SMstatus = smIDStart(smRoot, 8862 smIORequest, 8863 &(oneDeviceData->smDeviceHandle) 8864 ); 8865 8866 if (SMstatus == SM_RC_SUCCESS) 8867 { 8868 if (oneDeviceData->directlyAttached == agTRUE) 8869 { 8870 TI_DBG2(("tdIDStart: successfully sent identify device data\n")); 8871 8872 /* Add the devicedata to the mainlink */ 8873 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 8874 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList)); 8875 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 8876 TI_DBG6(("tdIDStart: one case did %d \n", oneDeviceData->id)); 8877 } 8878 oneDeviceData->satDevData.IDPending = agTRUE; 8879 /* start a timer */ 8880 tdIDStartTimer(tiRoot, smIORequest, oneDeviceData); 8881 } 8882 else 8883 { 8884 /* failed to send */ 8885 TI_DBG1(("tdIDStart: smIDStart fail or busy %d\n", SMstatus)); 8886 8887 /* free up allocated memory */ 8888 ostiFreeMemory( 8889 tiRoot, 8890 tdIORequestBody->IOType.InitiatorTMIO.osMemHandle, 8891 sizeof(tdIORequestBody_t) 8892 ); 8893 8894 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 8895 if (oneDeviceData->directlyAttached == agTRUE) 8896 { 8897 TI_DBG1(("tdIDStart: failed in sending identify device data\n")); 8898 /* put onedevicedata back to free list */ 8899 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 8900 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 8901 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 8902 /* notifying link up */ 8903 ostiPortEvent( 8904 tiRoot, 8905 tiPortLinkUp, 8906 tiSuccess, 8907 (void *)onePortContext->tiPortalContext 8908 ); 8909 #ifdef INITIATOR_DRIVER 8910 /* triggers discovery */ 8911 ostiPortEvent( 8912 tiRoot, 8913 tiPortDiscoveryReady, 8914 tiSuccess, 8915 (void *) onePortContext->tiPortalContext 8916 ); 8917 #endif 8918 } 8919 else 8920 { 8921 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 8922 } 8923 } 8924 } 8925 } 8926 TI_DBG1(("tdIDStart: exit\n")); 8927 return; 8928 } 8929 8930 #endif 8931 8932 #ifdef SALLSDK_OS_IOMB_LOG_ENABLE 8933 GLOBAL void ossaLogIomb(agsaRoot_t *agRoot, 8934 bit32 queueNum, 8935 agBOOLEAN isInbound, 8936 void *pMsg, 8937 bit32 msgLength) 8938 { 8939 return; 8940 } 8941 #endif /* SALLSDK_OS_IOMB_LOG_ENABLE */ 8942 8943 #ifndef SATA_ENABLE 8944 /* 8945 * These callback routines are defined in ossasat.c which are included in the 8946 * compilation if SATA_ENABLED is defined. 8947 */ 8948 8949 /***************************************************************************** 8950 *! \brief ossaDiscoverSataCB 8951 * 8952 * Purpose: This function is called by lower layer to inform TD layer of 8953 * STP/SATA discovery results 8954 * 8955 * 8956 * \param agRoot Pointer to chip/driver Instance. 8957 * \param agPortContext Pointer to the port context of TD and Lower layer 8958 * \param event event type 8959 * \param pParm1 Pointer to data associated with event 8960 * \param pParm2 Pointer to data associated with event 8961 * 8962 * \return: none 8963 * 8964 * \note - For details, refer to SAS/SATA Low-Level API Specification 8965 * 8966 *****************************************************************************/ 8967 8968 osGLOBAL void ossaDiscoverSataCB( agsaRoot_t *agRoot, 8969 agsaPortContext_t *agPortContext, 8970 bit32 event, 8971 void *pParm1, 8972 void *pParm2 8973 ) 8974 { 8975 return; 8976 } 8977 8978 8979 /***************************************************************************** 8980 *! \brief ossaSATACompleted 8981 * 8982 * This routine is called to complete a SATA request previously issued to the 8983 * LL Layer in saSATAStart() 8984 * 8985 * \param agRoot: Handles for this instance of SAS/SATA hardware 8986 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 8987 * \param agIOStatus: Status of completed I/O. 8988 * \param agFirstDword:Pointer to the four bytes of FIS. 8989 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 8990 * length. 8991 * \param agParam: Additional info based on status. 8992 * 8993 * \return: none 8994 * 8995 *****************************************************************************/ 8996 GLOBAL void ossaSATACompleted( 8997 agsaRoot_t *agRoot, 8998 agsaIORequest_t *agIORequest, 8999 bit32 agIOStatus, 9000 void *agFirstDword, 9001 bit32 agIOInfoLen, 9002 void *agParam 9003 ) 9004 { 9005 return; 9006 } 9007 9008 9009 /***************************************************************************** 9010 *! \brief ossaSATAEvent 9011 * 9012 * This routine is called to notify the OS Layer of an event associated with 9013 * SATA port or SATA device 9014 * 9015 * \param agRoot: Handles for this instance of SAS/SATA hardware 9016 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 9017 * \param agPortContext Pointer to the port context of TD and Lower layer 9018 * \param agDevHandle: Pointer to a device handle 9019 * \param event: event type 9020 * 9021 * \return: none 9022 * 9023 *****************************************************************************/ 9024 osGLOBAL void ossaSATAEvent( 9025 agsaRoot_t *agRoot, 9026 agsaIORequest_t *agIORequest, 9027 agsaPortContext_t *agPortContext, 9028 agsaDevHandle_t *agDevHandle, 9029 bit32 event, 9030 bit32 agIOInfoLen, 9031 void *agParam 9032 ) 9033 { 9034 return; 9035 } 9036 9037 9038 /***************************************************************************** 9039 *! \brief ossaSATADeviceResetCB 9040 * 9041 * This routine is called to complete a SATA device reset request previously 9042 * issued to the LL Layer in saSATADeviceReset(). 9043 * 9044 * \param agRoot: Handles for this instance of SAS/SATA hardware 9045 * \param agDevHandle: Pointer to a device handle 9046 * \param resetStatus: Reset status: 9047 * OSSA_SUCCESS: The reset operation completed successfully. 9048 * OSSA_FAILURE: The reset operation failed. 9049 * \param resetparm: Pointer to the Device-To-Host FIS received from the device. 9050 * 9051 * \return: none 9052 * 9053 *****************************************************************************/ 9054 osGLOBAL void ossaSATADeviceResetCB( 9055 agsaRoot_t *agRoot, 9056 agsaDevHandle_t *agDevHandle, 9057 bit32 resetStatus, 9058 void *resetparm) 9059 { 9060 9061 return; 9062 9063 } 9064 9065 /***************************************************************************** 9066 *! \brief ossaDiscoverSasCB 9067 * 9068 * Purpose: This function is called by lower layer to inform TD layer of 9069 * SAS discovery results 9070 * 9071 * 9072 * \param agRoot Pointer to chip/driver Instance. 9073 * \param agPortContext Pointer to the port context of TD and Lower layer 9074 * \param event event type 9075 * \param pParm1 Pointer to data associated with event 9076 * \param pParm2 Pointer to data associated with event 9077 * 9078 * \return: none 9079 * 9080 * \note - For details, refer to SAS/SATA Low-Level API Specification 9081 * 9082 *****************************************************************************/ 9083 osGLOBAL void ossaDiscoverSasCB(agsaRoot_t *agRoot, 9084 agsaPortContext_t *agPortContext, 9085 bit32 event, 9086 void *pParm1, 9087 void *pParm2 9088 ) 9089 { 9090 return; 9091 } 9092 #endif 9093 9094