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 #include <sys/cdefs.h> 23 __FBSDID("$FreeBSD$"); 24 #include <dev/pms/config.h> 25 26 #include <dev/pms/freebsd/driver/common/osenv.h> 27 #include <dev/pms/freebsd/driver/common/ostypes.h> 28 #include <dev/pms/freebsd/driver/common/osdebug.h> 29 30 #include <dev/pms/RefTisa/tisa/api/titypes.h> 31 #include <dev/pms/RefTisa/tisa/api/ostiapi.h> 32 #include <dev/pms/RefTisa/tisa/api/tiapi.h> 33 /* for TIDEBUG_MSG */ 34 #include <dev/pms/RefTisa/tisa/api/tiglobal.h> 35 36 #ifdef FDS_SM 37 38 #include <dev/pms/RefTisa/sat/api/sm.h> 39 #include <dev/pms/RefTisa/sat/api/smapi.h> 40 #include <dev/pms/RefTisa/sat/api/tdsmapi.h> 41 42 #ifdef FDS_DM 43 #include <dev/pms/RefTisa/discovery/api/dm.h> 44 #endif 45 46 #ifdef INITIATOR_DRIVER 47 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h> 48 #endif 49 50 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h> 51 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h> 52 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h> 53 54 #if defined(SM_DEBUG) 55 extern bit32 gSMDebugLevel; 56 #endif 57 58 osGLOBAL void 59 smReportRemovalDirect( 60 tiRoot_t *tiRoot, 61 agsaRoot_t *agRoot, 62 tdsaDeviceData_t *oneDeviceData 63 ) 64 { 65 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 66 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 67 bit8 PhyID; 68 69 TI_DBG2(("smReportRemovalDirect: start\n")); 70 71 PhyID = oneDeviceData->phyID; 72 73 tdsaAbortAll(tiRoot, agRoot, oneDeviceData); 74 oneDeviceData->valid = agFALSE; 75 oneDeviceData->valid2 = agFALSE; 76 /* put onedevicedata back to free list */ 77 osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t)); 78 TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink)); 79 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 80 81 /* notifying link up */ 82 ostiPortEvent ( 83 tiRoot, 84 tiPortLinkUp, 85 tiSuccess, 86 (void *)tdsaAllShared->Ports[PhyID].tiPortalContext 87 ); 88 #ifdef INITIATOR_DRIVER 89 /* triggers discovery */ 90 ostiPortEvent( 91 tiRoot, 92 tiPortDiscoveryReady, 93 tiSuccess, 94 (void *) tdsaAllShared->Ports[PhyID].tiPortalContext 95 ); 96 #endif 97 return; 98 } 99 100 osGLOBAL void 101 smReportRemoval( 102 tiRoot_t *tiRoot, 103 agsaRoot_t *agRoot, 104 tdsaDeviceData_t *oneDeviceData, 105 tdsaPortContext_t *onePortContext 106 ) 107 { 108 TI_DBG2(("smReportRemoval: start\n")); 109 110 if (oneDeviceData->registered == agTRUE) 111 { 112 /* 113 1. remove this device 114 2. device removal event 115 */ 116 tdsaAbortAll(tiRoot, agRoot, oneDeviceData); 117 oneDeviceData->valid = agFALSE; 118 oneDeviceData->valid2 = agFALSE; 119 oneDeviceData->registered = agFALSE; 120 ostiInitiatorEvent( 121 tiRoot, 122 onePortContext->tiPortalContext, 123 agNULL, 124 tiIntrEventTypeDeviceChange, 125 tiDeviceRemoval, 126 agNULL 127 ); 128 } 129 130 return; 131 } 132 osGLOBAL void 133 smHandleDirect( 134 tiRoot_t *tiRoot, 135 agsaRoot_t *agRoot, 136 tdsaDeviceData_t *oneDeviceData, 137 void *IDdata 138 ) 139 { 140 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 141 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 142 agsaSATAIdentifyData_t *pSATAIdData; 143 tdList_t *DeviceListList; 144 tdsaDeviceData_t *tmpOneDeviceData = agNULL; 145 int new_device = agTRUE; 146 bit8 PhyID; 147 148 TI_DBG2(("smHandleDirect: start\n")); 149 PhyID = oneDeviceData->phyID; 150 151 pSATAIdData = (agsaSATAIdentifyData_t *)IDdata; 152 //tdhexdump("satAddSATAIDDevCB after", (bit8 *)pSATAIdData, sizeof(agsaSATAIdentifyData_t)); 153 154 /* compare idenitfy device data to the exiting list */ 155 DeviceListList = tdsaAllShared->MainDeviceList.flink; 156 while (DeviceListList != &(tdsaAllShared->MainDeviceList)) 157 { 158 tmpOneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList); 159 if (tmpOneDeviceData == agNULL) 160 { 161 TI_DBG1(("smHandleDirect: tmpOneDeviceData is NULL!!!\n")); 162 return; 163 } 164 TI_DBG1(("smHandleDirect: LOOP tmpOneDeviceData %p did %d\n", tmpOneDeviceData, tmpOneDeviceData->id)); 165 //tdhexdump("smHandleDirect LOOP", (bit8 *)&tmpOneDeviceData->satDevData.satIdentifyData, sizeof(agsaSATAIdentifyData_t)); 166 167 /* what is unique ID for sata device -> response of identify devicedata; not really 168 Let's compare serial number, firmware version, model number 169 */ 170 if ( tmpOneDeviceData->DeviceType == TD_SATA_DEVICE && 171 (osti_memcmp (tmpOneDeviceData->satDevData.satIdentifyData.serialNumber, 172 pSATAIdData->serialNumber, 173 20) == 0) && 174 (osti_memcmp (tmpOneDeviceData->satDevData.satIdentifyData.firmwareVersion, 175 pSATAIdData->firmwareVersion, 176 8) == 0) && 177 (osti_memcmp (tmpOneDeviceData->satDevData.satIdentifyData.modelNumber, 178 pSATAIdData->modelNumber, 179 40) == 0) 180 ) 181 { 182 TI_DBG2(("smHandleDirect: did %d\n", tmpOneDeviceData->id)); 183 new_device = agFALSE; 184 break; 185 } 186 DeviceListList = DeviceListList->flink; 187 } 188 189 190 if (new_device == agFALSE) 191 { 192 TI_DBG2(("smHandleDirect: old device data\n")); 193 tmpOneDeviceData->valid = agTRUE; 194 tmpOneDeviceData->valid2 = agTRUE; 195 /* save data field from new device data */ 196 tmpOneDeviceData->agRoot = agRoot; 197 tmpOneDeviceData->agDevHandle = oneDeviceData->agDevHandle; 198 tmpOneDeviceData->agDevHandle->osData = tmpOneDeviceData; /* TD layer */ 199 tmpOneDeviceData->tdPortContext = oneDeviceData->tdPortContext; 200 tmpOneDeviceData->phyID = oneDeviceData->phyID; 201 202 /* 203 one SATA directly attached device per phy; 204 Therefore, deregister then register 205 */ 206 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 207 208 if (tmpOneDeviceData->registered == agFALSE) 209 { 210 TI_DBG2(("smHandleDirect: re-registering old device data\n")); 211 /* already has old information; just register it again */ 212 saRegisterNewDevice( /* smHandleDirect */ 213 agRoot, 214 &tmpOneDeviceData->agContext, 215 0,/*tdsaRotateQnumber(tiRoot, tmpOneDeviceData),*/ 216 &tmpOneDeviceData->agDeviceInfo, 217 tmpOneDeviceData->tdPortContext->agPortContext, 218 0 219 ); 220 } 221 222 // tdsaAbortAll(tiRoot, agRoot, oneDeviceData); 223 /* put tmpOneDeviceData back to free list */ 224 osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t)); 225 TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink)); 226 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 227 228 TI_DBG2(("smHandleDirect: pid %d\n", tdsaAllShared->Ports[PhyID].portContext->id)); 229 /* notifying link up */ 230 ostiPortEvent ( 231 tiRoot, 232 tiPortLinkUp, 233 tiSuccess, 234 (void *)tdsaAllShared->Ports[PhyID].tiPortalContext 235 ); 236 237 238 #ifdef INITIATOR_DRIVER 239 /* triggers discovery */ 240 ostiPortEvent( 241 tiRoot, 242 tiPortDiscoveryReady, 243 tiSuccess, 244 (void *) tdsaAllShared->Ports[PhyID].tiPortalContext 245 ); 246 #endif 247 return; 248 } 249 250 TI_DBG2(("smHandleDirect: new device data\n")); 251 oneDeviceData->satDevData.satIdentifyData = *pSATAIdData; 252 /* notifying link up */ 253 ostiPortEvent ( 254 tiRoot, 255 tiPortLinkUp, 256 tiSuccess, 257 (void *)tdsaAllShared->Ports[PhyID].tiPortalContext 258 ); 259 #ifdef INITIATOR_DRIVER 260 /* triggers discovery */ 261 ostiPortEvent( 262 tiRoot, 263 tiPortDiscoveryReady, 264 tiSuccess, 265 (void *) tdsaAllShared->Ports[PhyID].tiPortalContext 266 ); 267 #endif 268 269 return; 270 } 271 272 /* 273 combine satAddSATAIDDevCB(expander) and satAddSATAIDDevCB(directly attached) 274 */ 275 osGLOBAL void 276 tdsmIDCompletedCB( 277 smRoot_t *smRoot, 278 smIORequest_t *smIORequest, 279 smDeviceHandle_t *smDeviceHandle, 280 bit32 status, 281 void *IDdata 282 ) 283 { 284 tdsaRoot_t *tdsaRoot; 285 tdsaContext_t *tdsaAllShared; 286 tiRoot_t *tiRoot; 287 agsaRoot_t *agRoot; 288 tdIORequestBody_t *tdIORequestBody; 289 tdsaDeviceData_t *oneDeviceData; 290 tdsaPortContext_t *onePortContext; 291 tiPortalContext_t *tiPortalContext; 292 bit32 pid = 0xff; 293 bit32 IDstatus; 294 agsaSATAIdentifyData_t *pSATAIdData; 295 296 TI_DBG2(("tdsmIDCompletedCB: start\n")); 297 298 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 299 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 300 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 301 tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData; 302 303 if (smDeviceHandle == agNULL) 304 { 305 TI_DBG1(("tdsmIDCompletedCB: smDeviceHandle is NULL !!!!\n")); 306 ostiFreeMemory( 307 tiRoot, 308 tdIORequestBody->osMemHandle, 309 sizeof(tdIORequestBody_t) 310 ); 311 return; 312 } 313 314 oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData; 315 onePortContext = oneDeviceData->tdPortContext; 316 agRoot = oneDeviceData->agRoot; 317 pid = tdIORequestBody->pid; 318 319 320 // oneDeviceData->satDevData.IDDeviceValid = agFALSE; 321 oneDeviceData->satDevData.IDPending = agFALSE; 322 323 TI_DBG2(("tdsmIDCompletedCB: tdIORequestBody %p tdIORequestBody->osMemHandle %p\n", tdIORequestBody, tdIORequestBody->osMemHandle)); 324 325 tdsaSingleThreadedEnter(tiRoot, TD_TIMER_LOCK); 326 327 if (oneDeviceData->tdIDTimer.timerRunning == agTRUE) 328 { 329 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK); 330 tdsaKillTimer( 331 tiRoot, 332 &oneDeviceData->tdIDTimer 333 ); 334 } 335 else 336 { 337 tdsaSingleThreadedLeave(tiRoot, TD_TIMER_LOCK); 338 } 339 340 if (onePortContext == agNULL) 341 { 342 TI_DBG1(("tdsmIDCompletedCB: onePortContext is NULL!!!\n")); 343 ostiFreeMemory( 344 tiRoot, 345 tdIORequestBody->osMemHandle, 346 sizeof(tdIORequestBody_t) 347 ); 348 return; 349 } 350 351 /* check port id */ 352 if (pid != onePortContext->id) 353 { 354 TI_DBG1(("tdsmIDCompletedCB: not matching pid; pid %d onePortContext->id %d!!!\n", pid, onePortContext->id)); 355 if (oneDeviceData->directlyAttached == agTRUE) 356 { 357 smReportRemovalDirect(tiRoot, agRoot, oneDeviceData); 358 } 359 else 360 { 361 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 362 } 363 ostiFreeMemory( 364 tiRoot, 365 tdIORequestBody->osMemHandle, 366 sizeof(tdIORequestBody_t) 367 ); 368 return; 369 } 370 371 tiPortalContext= onePortContext->tiPortalContext; 372 373 if (tiPortalContext == agNULL) 374 { 375 TI_DBG1(("tdsmIDCompletedCB: tiPortalContext is NULL!!!\n")); 376 if (oneDeviceData->directlyAttached == agTRUE) 377 { 378 smReportRemovalDirect(tiRoot, agRoot, oneDeviceData); 379 } 380 else 381 { 382 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 383 } 384 ostiFreeMemory( 385 tiRoot, 386 tdIORequestBody->osMemHandle, 387 sizeof(tdIORequestBody_t) 388 ); 389 return; 390 } 391 392 if (agRoot == agNULL) 393 { 394 TI_DBG1(("tdsmIDCompletedCB: agRoot is NULL!!!\n")); 395 ostiFreeMemory( 396 tiRoot, 397 tdIORequestBody->osMemHandle, 398 sizeof(tdIORequestBody_t) 399 ); 400 return; 401 } 402 403 if (status == smIOSuccess) 404 { 405 TI_DBG2(("tdsmIDCompletedCB: smIOSuccess\n")); 406 407 oneDeviceData->satDevData.IDDeviceValid = agTRUE; 408 if (oneDeviceData->directlyAttached == agTRUE) 409 { 410 TI_DBG2(("tdsmIDCompletedCB: directlyAttached\n")); 411 pSATAIdData = (agsaSATAIdentifyData_t *)IDdata; 412 smHandleDirect(tiRoot, agRoot, oneDeviceData, IDdata); 413 /* filling in */ 414 osti_memcpy(onePortContext->remoteName, pSATAIdData->serialNumber, 20); 415 osti_memcpy(&(onePortContext->remoteName[20]), pSATAIdData->firmwareVersion, 8); 416 osti_memcpy(&(onePortContext->remoteName[28]), pSATAIdData->modelNumber, 40); 417 } 418 else /* expander attached */ 419 { 420 421 TI_DBG2(("tdsmIDCompletedCB: expander attached\n")); 422 423 if (onePortContext->DiscoveryState == ITD_DSTATE_COMPLETED) 424 { 425 TI_DBG1(("tdsmIDCompletedCB: ID completed after discovery is done; tiDeviceArrival\n")); 426 /* ID data completed after discovery is completed */ 427 ostiInitiatorEvent( 428 tiRoot, 429 tiPortalContext, 430 agNULL, 431 tiIntrEventTypeDeviceChange, 432 tiDeviceArrival, 433 agNULL 434 ); 435 } 436 } 437 TI_DBG2(("tdsmIDCompletedCB: tdIORequestBody %p tdIORequestBody->osMemHandle %p\n", tdIORequestBody, tdIORequestBody->osMemHandle)); 438 ostiFreeMemory( 439 tiRoot, 440 tdIORequestBody->osMemHandle, 441 sizeof(tdIORequestBody_t) 442 ); 443 444 } 445 else if ( status == smIORetry) 446 { 447 TI_DBG1(("tdsmIDCompletedCB: smIORetry!!!\n")); 448 if ( !(oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && 449 oneDeviceData->tdPortContext != agNULL) 450 ) 451 { 452 TI_DBG1(("tdsmIDCompletedCB: smIORetry but device is not valid!!!\n")); 453 tdIORequestBody->reTries = 0; 454 tdIORequestBody->ioCompleted = agTRUE; 455 tdIORequestBody->ioStarted = agFALSE; 456 ostiFreeMemory( 457 tiRoot, 458 tdIORequestBody->osMemHandle, 459 sizeof(tdIORequestBody_t) 460 ); 461 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 462 return; 463 } 464 465 if (tdIORequestBody->reTries <= SM_RETRIES) 466 { 467 tdIORequestBody->tiIORequest = agNULL; /* not in use */ 468 tdIORequestBody->pid = onePortContext->id; 469 smIORequest->tdData = tdIORequestBody; 470 smIORequest->smData = &tdIORequestBody->smIORequestBody; 471 472 smDeviceHandle->tdData = oneDeviceData; 473 474 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 475 476 IDstatus = smIDStart(smRoot, 477 smIORequest, 478 smDeviceHandle 479 ); 480 if (IDstatus != SM_RC_SUCCESS) 481 { 482 /* identify device data is not valid */ 483 TI_DBG1(("tdsmIDCompletedCB: smIDStart fail or busy %d!!!\n", IDstatus)); 484 tdIORequestBody->reTries = 0; 485 tdIORequestBody->ioCompleted = agTRUE; 486 tdIORequestBody->ioStarted = agFALSE; 487 ostiFreeMemory( 488 tiRoot, 489 tdIORequestBody->osMemHandle, 490 sizeof(tdIORequestBody_t) 491 ); 492 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 493 return; 494 } 495 tdIORequestBody->reTries++; 496 tdIORequestBody->ioCompleted = agFALSE; 497 tdIORequestBody->ioStarted = agTRUE; 498 oneDeviceData->satDevData.IDPending = agTRUE; 499 /* start a timer */ 500 tdIDStartTimer(tiRoot, smIORequest, oneDeviceData); 501 TI_DBG1(("tdsmIDCompletedCB: being retried!!!\n")); 502 } 503 else 504 { 505 /* give up */ 506 TI_DBG1(("tdsmIDCompletedCB: retries are over!!!\n")); 507 tdIORequestBody->reTries = 0; 508 tdIORequestBody->ioCompleted = agTRUE; 509 tdIORequestBody->ioStarted = agFALSE; 510 ostiFreeMemory( 511 tiRoot, 512 tdIORequestBody->osMemHandle, 513 sizeof(tdIORequestBody_t) 514 ); 515 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 516 /* SATA device is not usable; remove it */ 517 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 518 } 519 } 520 else if ( status == smIOSTPResourceBusy) 521 { 522 /* decides to send smp hard reset or not */ 523 TI_DBG1(("tdsmIDCompletedCB: smIOSTPResourceBusy\n")); 524 ostiFreeMemory( 525 tiRoot, 526 tdIORequestBody->osMemHandle, 527 sizeof(tdIORequestBody_t) 528 ); 529 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 530 if (tdsaAllShared->FCA) 531 { 532 if (oneDeviceData->SMNumOfFCA <= 0) /* does SMP HARD RESET only upto one time */ 533 { 534 TI_DBG1(("tdsmIDCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n")); 535 oneDeviceData->SMNumOfFCA++; 536 tdsaPhyControlSend(tiRoot, 537 oneDeviceData, 538 SMP_PHY_CONTROL_HARD_RESET, 539 agNULL, 540 tdsaRotateQnumber(tiRoot, oneDeviceData) 541 ); 542 } 543 else 544 { 545 /* given up after one time of SMP HARD RESET; */ 546 TI_DBG1(("tdsmIDCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; but giving up sending HARD_RESET!!!\n")); 547 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 548 } 549 } 550 else 551 { 552 /* do nothing */ 553 } 554 } 555 else 556 { 557 TI_DBG1(("tdsmIDCompletedCB: smIDStart fail, status 0x%x!!!\n", status)); 558 TI_DBG1(("tdsmIDCompletedCB: did %d!!!\n", oneDeviceData->id)); 559 if ( !(oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && 560 oneDeviceData->tdPortContext != agNULL) 561 ) 562 { 563 TI_DBG1(("tdsmIDCompletedCB: fail but device is not valid!!!\n")); 564 tdIORequestBody->reTries = 0; 565 tdIORequestBody->ioCompleted = agTRUE; 566 tdIORequestBody->ioStarted = agFALSE; 567 ostiFreeMemory( 568 tiRoot, 569 tdIORequestBody->osMemHandle, 570 sizeof(tdIORequestBody_t) 571 ); 572 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 573 return; 574 } 575 tdsaAllShared->IDRetry = agTRUE; 576 if (tdsaAllShared->IDRetry) 577 { 578 if (tdIORequestBody->reTries <= SM_RETRIES) 579 { 580 tdIORequestBody->tiIORequest = agNULL; /* not in use */ 581 tdIORequestBody->pid = onePortContext->id; 582 smIORequest->tdData = tdIORequestBody; 583 smIORequest->smData = &tdIORequestBody->smIORequestBody; 584 585 smDeviceHandle->tdData = oneDeviceData; 586 IDstatus = smIDStart(smRoot, 587 smIORequest, 588 smDeviceHandle 589 ); 590 if (IDstatus != SM_RC_SUCCESS) 591 { 592 /* identify device data is not valid */ 593 TI_DBG1(("tdsmIDCompletedCB: smIDStart fail or busy %d!!!\n", IDstatus)); 594 tdIORequestBody->reTries = 0; 595 tdIORequestBody->ioCompleted = agTRUE; 596 tdIORequestBody->ioStarted = agFALSE; 597 ostiFreeMemory( 598 tiRoot, 599 tdIORequestBody->osMemHandle, 600 sizeof(tdIORequestBody_t) 601 ); 602 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 603 if (oneDeviceData->directlyAttached == agTRUE) 604 { 605 smReportRemovalDirect(tiRoot, agRoot, oneDeviceData); 606 } 607 else 608 { 609 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 610 } 611 return; 612 } 613 tdIORequestBody->reTries++; 614 tdIORequestBody->ioCompleted = agFALSE; 615 tdIORequestBody->ioStarted = agTRUE; 616 oneDeviceData->satDevData.IDPending = agTRUE; 617 /* start a timer */ 618 tdIDStartTimer(tiRoot, smIORequest, oneDeviceData); 619 TI_DBG1(("tdsmIDCompletedCB: being retried!!!\n")); 620 } 621 else 622 { 623 /* give up */ 624 TI_DBG1(("tdsmIDCompletedCB: retries are over; sending hard reset!!!\n")); 625 tdIORequestBody->reTries = 0; 626 tdIORequestBody->ioCompleted = agTRUE; 627 tdIORequestBody->ioStarted = agFALSE; 628 ostiFreeMemory( 629 tiRoot, 630 tdIORequestBody->osMemHandle, 631 sizeof(tdIORequestBody_t) 632 ); 633 oneDeviceData->satDevData.IDDeviceValid = agFALSE; 634 635 if (oneDeviceData->SMNumOfID <= 0) /* does SMP HARD RESET only upto one time */ 636 { 637 TI_DBG1(("tdsmIDCompletedCB: fail; sending HARD_RESET\n")); 638 oneDeviceData->SMNumOfID++; 639 if (oneDeviceData->directlyAttached == agTRUE) 640 { 641 saLocalPhyControl(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), oneDeviceData->phyID, AGSA_PHY_HARD_RESET, agNULL); 642 } 643 else 644 { 645 tdsaPhyControlSend(tiRoot, 646 oneDeviceData, 647 SMP_PHY_CONTROL_HARD_RESET, 648 agNULL, 649 tdsaRotateQnumber(tiRoot, oneDeviceData) 650 ); 651 } 652 } 653 else 654 { 655 /* given up after one time of SMP HARD RESET; */ 656 TI_DBG1(("tdsmIDCompletedCB: fail; but giving up sending HARD_RESET!!!\n")); 657 if (oneDeviceData->directlyAttached == agTRUE) 658 { 659 smReportRemovalDirect(tiRoot, agRoot, oneDeviceData); 660 } 661 else 662 { 663 smReportRemoval(tiRoot, agRoot, oneDeviceData, onePortContext); 664 } 665 } 666 } 667 } 668 else 669 { 670 /* do nothing */ 671 } 672 673 674 } 675 676 677 return; 678 } 679 680 FORCEINLINE void 681 tdsmIOCompletedCB( 682 smRoot_t *smRoot, 683 smIORequest_t *smIORequest, 684 bit32 status, 685 bit32 statusDetail, 686 smSenseData_t *senseData, 687 bit32 interruptContext 688 ) 689 { 690 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 691 tdsaContext_t *tdsaAllShared = &(tdsaRoot->tdsaAllShared); 692 tiRoot_t *tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 693 tdIORequestBody_t *tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData; 694 tiIORequest_t *tiIORequest = tdIORequestBody->tiIORequest; 695 696 tdsaDeviceData_t *oneDeviceData; 697 tiDeviceHandle_t *tiDeviceHandle; 698 smDeviceHandle_t *smDeviceHandle; 699 smScsiInitiatorRequest_t *smSCSIRequest; 700 smSuperScsiInitiatorRequest_t *smSuperSCSIRequest; 701 702 bit32 SMStatus = SM_RC_FAILURE; 703 704 705 TI_DBG5(("tdsmIOCompletedCB: start\n")); 706 707 if (status == smIOSuccess) 708 { 709 ostiInitiatorIOCompleted( tiRoot, 710 tiIORequest, 711 status, 712 statusDetail, 713 (tiSenseData_t *)senseData, 714 interruptContext); 715 } 716 else if (status == smIORetry) 717 { 718 TI_DBG1(("tdsmIOCompletedCB: smIORetry!!!\n")); 719 smIORequest = (smIORequest_t *)&(tdIORequestBody->smIORequest); 720 tiDeviceHandle = tdIORequestBody->tiDevHandle; 721 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 722 723 if (! (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && 724 oneDeviceData->tdPortContext != agNULL) 725 ) 726 { 727 TI_DBG1(("tdsmIOCompletedCB: smIORetry but device is not valid!!!\n")); 728 tdIORequestBody->reTries = 0; 729 tdIORequestBody->ioCompleted = agTRUE; 730 tdIORequestBody->ioStarted = agFALSE; 731 ostiInitiatorIOCompleted( tiRoot, 732 tiIORequest, 733 status, 734 statusDetail, 735 (tiSenseData_t *)senseData, 736 interruptContext); 737 return; 738 } 739 if (tdIORequestBody->reTries <= SM_RETRIES) 740 { 741 smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle); 742 if (tdIORequestBody->superIOFlag == agTRUE) 743 { 744 smSuperSCSIRequest = (smSuperScsiInitiatorRequest_t *)&(tdIORequestBody->SM.smSuperSCSIRequest); 745 SMStatus = smSuperIOStart(smRoot, 746 smIORequest, 747 smDeviceHandle, 748 smSuperSCSIRequest, 749 oneDeviceData->SASAddressID.sasAddressHi, 750 oneDeviceData->SASAddressID.sasAddressLo, 751 interruptContext); 752 } 753 else 754 { 755 smSCSIRequest = (smScsiInitiatorRequest_t *)&(tdIORequestBody->SM.smSCSIRequest); 756 SMStatus = smIOStart(smRoot, 757 smIORequest, 758 smDeviceHandle, 759 smSCSIRequest, 760 interruptContext); 761 } 762 763 764 if (SMStatus != SM_RC_SUCCESS) 765 { 766 TI_DBG1(("tdsmIOCompletedCB: smIDStart fail or busy %d!!!\n", SMStatus)); 767 tdIORequestBody->reTries = 0; 768 tdIORequestBody->ioCompleted = agTRUE; 769 tdIORequestBody->ioStarted = agFALSE; 770 ostiInitiatorIOCompleted( tiRoot, 771 tiIORequest, 772 status, 773 statusDetail, 774 (tiSenseData_t *)senseData, 775 interruptContext); 776 return; 777 } 778 else 779 { 780 TI_DBG1(("tdsmIOCompletedCB: being retried!!!\n")); 781 tdIORequestBody->reTries++; 782 tdIORequestBody->ioCompleted = agFALSE; 783 tdIORequestBody->ioStarted = agTRUE; 784 } 785 } 786 else 787 { 788 /* give up; complete IO */ 789 TI_DBG1(("tdsmIOCompletedCB: retries are over!!!\n")); 790 tdIORequestBody->reTries = 0; 791 tdIORequestBody->ioCompleted = agTRUE; 792 tdIORequestBody->ioStarted = agFALSE; 793 ostiInitiatorIOCompleted( tiRoot, 794 tiIORequest, 795 status, 796 statusDetail, 797 (tiSenseData_t *)senseData, 798 interruptContext); 799 return; 800 } 801 802 } 803 else if ( status == smIOSTPResourceBusy) 804 { 805 /* decides to send smp hard reset or not */ 806 TI_DBG1(("tdsmIOCompletedCB: smIOSTPResourceBusy\n")); 807 if (tdsaAllShared->FCA) 808 { 809 smIORequest = (smIORequest_t *)&(tdIORequestBody->smIORequest); 810 tiDeviceHandle = tdIORequestBody->tiDevHandle; 811 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 812 if (oneDeviceData->SMNumOfFCA <= 0) /* does SMP HARD RESET only upto one time */ 813 { 814 TI_DBG1(("tdsmIOCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n")); 815 oneDeviceData->SMNumOfFCA++; 816 tdsaPhyControlSend(tiRoot, 817 oneDeviceData, 818 SMP_PHY_CONTROL_HARD_RESET, 819 agNULL, 820 tdsaRotateQnumber(tiRoot, oneDeviceData) 821 ); 822 } 823 else 824 { 825 /* given up after one time of SMP HARD RESET; */ 826 TI_DBG1(("tdsmIOCompletedCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; but giving up sending HARD_RESET!!!\n")); 827 } 828 } 829 ostiInitiatorIOCompleted( tiRoot, 830 tiIORequest, 831 status, 832 statusDetail, 833 (tiSenseData_t *)senseData, 834 interruptContext); 835 return; 836 } 837 else 838 { 839 if (statusDetail == smDetailAborted) 840 { 841 tiDeviceHandle = tdIORequestBody->tiDevHandle; 842 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 843 TI_DBG1(("tdsmIOCompletedCB: agIOStatus = OSSA_IO_ABORTED did %d\n", oneDeviceData->id)); 844 } 845 ostiInitiatorIOCompleted( tiRoot, 846 tiIORequest, 847 status, 848 statusDetail, 849 (tiSenseData_t *)senseData, 850 interruptContext); 851 } 852 853 return; 854 } 855 856 /* completion of taskmanagement 857 osGLOBAL void ostiInitiatorEvent ( 858 tiRoot_t *tiRoot, 859 tiPortalContext_t *portalContext, 860 tiDeviceHandle_t *tiDeviceHandle, 861 tiIntrEventType_t eventType, 862 bit32 eventStatus, 863 void *parm 864 ); 865 866 */ 867 //qqq1 868 osGLOBAL void 869 tdsmEventCB( 870 smRoot_t *smRoot, 871 smDeviceHandle_t *smDeviceHandle, 872 smIntrEventType_t eventType, 873 bit32 eventStatus, 874 void *parm 875 ) 876 { 877 tdsaRoot_t *tdsaRoot; 878 tdsaContext_t *tdsaAllShared; 879 tiRoot_t *tiRoot; 880 tdIORequestBody_t *tdIORequestBody; 881 smIORequest_t *SMcurrentTaskTag; 882 tiIORequest_t *currentTaskTag; 883 tdsaDeviceData_t *oneDeviceData; 884 void *osMemHandle; 885 tdsaPortContext_t *onePortContext; 886 tiPortalContext_t *tiportalContext; 887 tiDeviceHandle_t *tiDeviceHandle; 888 889 /* be sure to free using tdIORequestBody->->IOType.InitiatorTMIO.osMemHandle but how??? 890 parm = pSatDevData->satTmTaskTag (currentTaskTag in tiINITaskManagement) 891 In this case, parm is smIORequest_t 892 */ 893 894 TI_DBG2(("tdsmEventCB: start\n")); 895 896 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 897 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 898 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 899 900 901 if (eventType == smIntrEventTypeLocalAbort) 902 { 903 oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData; 904 if (oneDeviceData == agNULL) 905 { 906 TI_DBG1(("tdsmEventCB: oneDeviceData is NULL\n")); 907 return; 908 } 909 else 910 { 911 tiDeviceHandle = &(oneDeviceData->tiDeviceHandle); 912 if (oneDeviceData->OSAbortAll == agTRUE) 913 { 914 oneDeviceData->OSAbortAll = agFALSE; 915 ostiInitiatorEvent( tiRoot, 916 agNULL, 917 tiDeviceHandle, 918 tiIntrEventTypeLocalAbort, 919 tiAbortOK, 920 agNULL); 921 } 922 } 923 } 924 else 925 { 926 927 SMcurrentTaskTag = (smIORequest_t *)parm; 928 if (SMcurrentTaskTag == agNULL) 929 { 930 TI_DBG1(("tdsmEventCB: SMcurrentTaskTag is NULL!!!\n")); 931 return; 932 } 933 934 tdIORequestBody = (tdIORequestBody_t *)SMcurrentTaskTag->tdData; 935 if (tdIORequestBody == agNULL) 936 { 937 TI_DBG1(("tdsmEventCB: tdIORequestBody is NULL!!!\n")); 938 return; 939 } 940 941 osMemHandle = tdIORequestBody->IOType.InitiatorTMIO.osMemHandle; 942 currentTaskTag = tdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag; 943 944 945 oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData; 946 if (oneDeviceData == agNULL) 947 { 948 TI_DBG1(("tdsmEventCB: oneDeviceData is NULL!!!\n")); 949 return; 950 } 951 952 tiDeviceHandle = &(oneDeviceData->tiDeviceHandle); 953 onePortContext = oneDeviceData->tdPortContext; 954 if (onePortContext == agNULL) 955 { 956 TI_DBG1(("tdsmEventCB: onePortContext is NULL!!!\n")); 957 return; 958 } 959 tiportalContext = onePortContext->tiPortalContext; 960 961 /* free tdIORequestBody */ 962 ostiFreeMemory( 963 tiRoot, 964 osMemHandle, 965 sizeof(tdIORequestBody_t) 966 ); 967 968 969 TI_DBG2(("tdsmEventCB: calling ostiInitiatorEvent\n")); 970 ostiInitiatorEvent( 971 tiRoot, 972 tiportalContext, 973 tiDeviceHandle, 974 eventType, 975 eventStatus, 976 (void *)currentTaskTag 977 ); 978 979 980 /* completion of taskmanagement 981 osGLOBAL void ostiInitiatorEvent ( 982 tiRoot_t *tiRoot, 983 tiPortalContext_t *portalContext, 984 tiDeviceHandle_t *tiDeviceHandle, 985 tiIntrEventType_t eventType, 986 bit32 eventStatus, 987 void *parm 988 ); 989 990 991 ostiFreeAlloc() 992 */ 993 994 } 995 996 return; 997 } 998 999 1000 FORCEINLINE void 1001 tdsmSingleThreadedEnter( 1002 smRoot_t *smRoot, 1003 bit32 syncLockId 1004 ) 1005 { 1006 tdsaRoot_t *tdsaRoot; 1007 tdsaContext_t *tdsaAllShared; 1008 tiRoot_t *tiRoot; 1009 bit32 offset = 0; 1010 1011 TI_DBG7(("tdsmSingleThreadedEnter: start\n")); 1012 1013 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 1014 if (tdsaRoot == agNULL) 1015 { 1016 TI_DBG1(("tdsmSingleThreadedEnter: tdsaRoot is NULL\n")); 1017 return; 1018 } 1019 1020 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 1021 if (tdsaAllShared == agNULL) 1022 { 1023 TI_DBG1(("tdsmSingleThreadedEnter: tdsaAllShared is NULL\n")); 1024 return; 1025 } 1026 1027 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 1028 if (tiRoot == agNULL) 1029 { 1030 TI_DBG1(("tdsmSingleThreadedEnter: tiRoot is NULL\n")); 1031 return; 1032 } 1033 1034 offset = tdsaAllShared->MaxNumLLLocks + tdsaAllShared->MaxNumOSLocks + TD_MAX_LOCKS + tdsaAllShared->MaxNumDMLocks; 1035 1036 ostiSingleThreadedEnter(tiRoot, syncLockId + offset); 1037 1038 return; 1039 } 1040 1041 FORCEINLINE void 1042 tdsmSingleThreadedLeave( 1043 smRoot_t *smRoot, 1044 bit32 syncLockId 1045 ) 1046 { 1047 tdsaRoot_t *tdsaRoot; 1048 tdsaContext_t *tdsaAllShared; 1049 tiRoot_t *tiRoot; 1050 bit32 offset = 0; 1051 1052 TI_DBG7(("tdsmSingleThreadedLeave: start\n")); 1053 1054 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 1055 if (tdsaRoot == agNULL) 1056 { 1057 TI_DBG1(("tdsmSingleThreadedLeave: tdsaRoot is NULL\n")); 1058 return; 1059 } 1060 1061 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 1062 if (tdsaAllShared == agNULL) 1063 { 1064 TI_DBG1(("tdsmSingleThreadedLeave: tdsaAllShared is NULL\n")); 1065 return; 1066 } 1067 1068 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 1069 if (tiRoot == agNULL) 1070 { 1071 TI_DBG1(("tdsmSingleThreadedLeave: tiRoot is NULL\n")); 1072 return; 1073 } 1074 offset = tdsaAllShared->MaxNumLLLocks + tdsaAllShared->MaxNumOSLocks + TD_MAX_LOCKS + tdsaAllShared->MaxNumDMLocks; 1075 1076 ostiSingleThreadedLeave(tiRoot, syncLockId + offset); 1077 1078 return; 1079 } 1080 1081 osGLOBAL FORCEINLINE bit8 1082 tdsmBitScanForward( 1083 smRoot_t *smRoot, 1084 bit32 *Index, 1085 bit32 Mask 1086 ) 1087 { 1088 return ostiBitScanForward(agNULL, Index, Mask); 1089 } 1090 1091 #ifdef LINUX_VERSION_CODE 1092 1093 osGLOBAL FORCEINLINE sbit32 1094 tdsmInterlockedIncrement( 1095 smRoot_t *smRoot, 1096 sbit32 volatile *Addend 1097 ) 1098 { 1099 return ostiAtomicIncrement(agNULL, Addend); 1100 } 1101 1102 osGLOBAL FORCEINLINE sbit32 1103 tdsmInterlockedDecrement( 1104 smRoot_t *smRoot, 1105 sbit32 volatile *Addend 1106 ) 1107 { 1108 return ostiAtomicDecrement(agNULL, Addend); 1109 } 1110 1111 1112 1113 osGLOBAL FORCEINLINE sbit32 1114 tdsmAtomicBitClear( 1115 smRoot_t *smRoot, 1116 sbit32 volatile *Destination, 1117 sbit32 Value 1118 ) 1119 { 1120 return ostiAtomicBitClear(agNULL, Destination, Value); 1121 } 1122 1123 osGLOBAL FORCEINLINE sbit32 1124 tdsmAtomicBitSet( 1125 smRoot_t *smRoot, 1126 sbit32 volatile *Destination, 1127 sbit32 Value 1128 ) 1129 { 1130 return ostiAtomicBitSet(agNULL, Destination, Value); 1131 } 1132 1133 osGLOBAL FORCEINLINE sbit32 1134 tdsmAtomicExchange( 1135 smRoot_t *smRoot, 1136 sbit32 volatile *Target, 1137 sbit32 Value 1138 ) 1139 { 1140 return ostiAtomicExchange(agNULL, Target, Value); 1141 } 1142 1143 #else 1144 1145 osGLOBAL FORCEINLINE sbit32 1146 tdsmInterlockedIncrement( 1147 smRoot_t *smRoot, 1148 sbit32 volatile *Addend 1149 ) 1150 { 1151 return ostiInterlockedIncrement(agNULL, Addend); 1152 } 1153 1154 osGLOBAL FORCEINLINE sbit32 1155 tdsmInterlockedDecrement( 1156 smRoot_t *smRoot, 1157 sbit32 volatile *Addend 1158 ) 1159 { 1160 return ostiInterlockedDecrement(agNULL, Addend); 1161 } 1162 1163 1164 1165 osGLOBAL FORCEINLINE sbit32 1166 tdsmInterlockedAnd( 1167 smRoot_t *smRoot, 1168 sbit32 volatile *Destination, 1169 sbit32 Value 1170 ) 1171 { 1172 1173 return ostiInterlockedAnd(agNULL, Destination, Value); 1174 } 1175 1176 osGLOBAL FORCEINLINE sbit32 1177 tdsmInterlockedOr( 1178 smRoot_t *smRoot, 1179 sbit32 volatile *Destination, 1180 sbit32 Value 1181 ) 1182 { 1183 return ostiInterlockedOr(agNULL, Destination, Value); 1184 } 1185 1186 osGLOBAL FORCEINLINE sbit32 1187 tdsmInterlockedExchange( 1188 smRoot_t *smRoot, 1189 sbit32 volatile *Target, 1190 sbit32 Value 1191 ) 1192 { 1193 return ostiInterlockedExchange(agNULL, Target, Value); 1194 } 1195 1196 #endif /*LINUX_VERSION_CODE*/ 1197 1198 osGLOBAL bit32 1199 tdsmAllocMemory( 1200 smRoot_t *smRoot, 1201 void **osMemHandle, 1202 void ** virtPtr, 1203 bit32 * physAddrUpper, 1204 bit32 * physAddrLower, 1205 bit32 alignment, 1206 bit32 allocLength, 1207 smBOOLEAN isCacheable 1208 ) 1209 { 1210 tdsaRoot_t *tdsaRoot; 1211 tdsaContext_t *tdsaAllShared; 1212 tiRoot_t *tiRoot; 1213 bit32 status; 1214 1215 TI_DBG5(("tdsmAllocMemory: start\n")); 1216 1217 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 1218 if (tdsaRoot == agNULL) 1219 { 1220 TI_DBG1(("tdsmAllocMemory: tdsaRoot is NULL\n")); 1221 return SM_RC_FAILURE; 1222 } 1223 1224 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 1225 if (tdsaAllShared == agNULL) 1226 { 1227 TI_DBG1(("tdsmAllocMemory: tdsaAllShared is NULL\n")); 1228 return SM_RC_FAILURE; 1229 } 1230 1231 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 1232 if (tiRoot == agNULL) 1233 { 1234 TI_DBG1(("tdsmAllocMemory: tiRoot is NULL\n")); 1235 return SM_RC_FAILURE; 1236 } 1237 1238 status = ostiAllocMemory(tiRoot, 1239 osMemHandle, 1240 virtPtr, 1241 physAddrUpper, 1242 physAddrLower, 1243 alignment, 1244 allocLength, 1245 isCacheable); 1246 1247 if (status == tiSuccess) 1248 { 1249 return SM_RC_SUCCESS; 1250 } 1251 else 1252 { 1253 return SM_RC_FAILURE; 1254 } 1255 1256 } 1257 1258 osGLOBAL bit32 1259 tdsmFreeMemory( 1260 smRoot_t *smRoot, 1261 void *osDMAHandle, 1262 bit32 allocLength 1263 ) 1264 { 1265 tdsaRoot_t *tdsaRoot; 1266 tdsaContext_t *tdsaAllShared; 1267 tiRoot_t *tiRoot; 1268 bit32 status; 1269 1270 TI_DBG5(("tdsmFreeMemory: start\n")); 1271 1272 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 1273 if (tdsaRoot == agNULL) 1274 { 1275 TI_DBG1(("tdsmFreeMemory: tdsaRoot is NULL\n")); 1276 return SM_RC_FAILURE; 1277 } 1278 1279 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 1280 if (tdsaAllShared == agNULL) 1281 { 1282 TI_DBG1(("tdsmFreeMemory: tdsaAllShared is NULL\n")); 1283 return SM_RC_FAILURE; 1284 } 1285 1286 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 1287 if (tiRoot == agNULL) 1288 { 1289 TI_DBG1(("tdsmFreeMemory: tiRoot is NULL\n")); 1290 return SM_RC_FAILURE; 1291 } 1292 1293 status = ostiFreeMemory(tiRoot, 1294 osDMAHandle, 1295 allocLength); 1296 1297 if (status == tiSuccess) 1298 { 1299 return SM_RC_SUCCESS; 1300 } 1301 else 1302 { 1303 return SM_RC_FAILURE; 1304 } 1305 } 1306 1307 FORCEINLINE bit32 1308 tdsmRotateQnumber(smRoot_t *smRoot, 1309 smDeviceHandle_t *smDeviceHandle 1310 ) 1311 { 1312 tdsaRoot_t *tdsaRoot; 1313 tdsaContext_t *tdsaAllShared; 1314 tiRoot_t *tiRoot; 1315 tdsaDeviceData_t *oneDeviceData; 1316 bit32 ret = 0; 1317 1318 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 1319 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 1320 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 1321 1322 1323 TI_DBG6(("tdsmRotateQnumber: start\n")); 1324 1325 if (smDeviceHandle == agNULL) 1326 { 1327 TI_DBG1(("tdsmRotateQnumber: smDeviceHandle is NULL !!!!\n")); 1328 return ret; 1329 } 1330 oneDeviceData = (tdsaDeviceData_t *)smDeviceHandle->tdData; 1331 if (oneDeviceData == agNULL) 1332 { 1333 TI_DBG1(("tdsmRotateQnumber: oneDeviceData is NULL !!!!\n")); 1334 return ret; 1335 } 1336 return tdsaRotateQnumber(tiRoot, oneDeviceData); 1337 } 1338 1339 osGLOBAL bit32 1340 tdsmSetDeviceQueueDepth(smRoot_t *smRoot, 1341 smIORequest_t *smIORequest, 1342 bit32 QueueDepth 1343 ) 1344 { 1345 tdsaRoot_t *tdsaRoot = agNULL; 1346 tdsaContext_t *tdsaAllShared = agNULL; 1347 tiRoot_t *tiRoot = agNULL; 1348 tdIORequestBody_t *tdIORequestBody = (tdIORequestBody_t *)smIORequest->tdData; 1349 tiIORequest_t *tiIORequest = tdIORequestBody->tiIORequest; 1350 1351 1352 TI_DBG5(("tdsmSetDeviceQueueDepth: start\n")); 1353 1354 tdsaRoot = (tdsaRoot_t *)smRoot->tdData; 1355 if (tdsaRoot == agNULL) 1356 { 1357 TI_DBG1(("tdsmSetDeviceQueueDepth: tdsaRoot is NULL\n")); 1358 return SM_RC_FAILURE; 1359 } 1360 1361 tdsaAllShared = &(tdsaRoot->tdsaAllShared); 1362 if (tdsaAllShared == agNULL) 1363 { 1364 TI_DBG1(("tdsmSetDeviceQueueDepth: tdsaAllShared is NULL\n")); 1365 return SM_RC_FAILURE; 1366 } 1367 1368 tiRoot = tdsaAllShared->agRootOsDataForInt.tiRoot; 1369 if (tiRoot == agNULL) 1370 { 1371 TI_DBG1(("tdsmFreeMemory: tiRoot is NULL\n")); 1372 return SM_RC_FAILURE; 1373 } 1374 1375 return ostiSetDeviceQueueDepth(tiRoot, tiIORequest, QueueDepth); 1376 } 1377 1378 osGLOBAL bit32 tdsmGetTransportParam( 1379 smRoot_t *smRoot, 1380 char *key, 1381 char *subkey1, 1382 char *subkey2, 1383 char *subkey3, 1384 char *subkey4, 1385 char *subkey5, 1386 char *valueName, 1387 char *buffer, 1388 bit32 bufferLen, 1389 bit32 *lenReceived 1390 ) 1391 { 1392 bit32 ret = tiError; 1393 1394 TI_DBG7(("tdsmGetTransportParam: start\n")); 1395 ret = ostiGetTransportParam(agNULL, 1396 key, 1397 subkey1, 1398 subkey2, 1399 subkey3, 1400 subkey4, 1401 subkey5, 1402 valueName, 1403 buffer, 1404 bufferLen, 1405 lenReceived 1406 ); 1407 return ret; 1408 } 1409 #endif /* FDS_SM */ 1410 1411