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 #include <dev/pms/config.h> 24 25 #include <dev/pms/freebsd/driver/common/osenv.h> 26 #include <dev/pms/freebsd/driver/common/ostypes.h> 27 #include <dev/pms/freebsd/driver/common/osdebug.h> 28 29 #include <dev/pms/RefTisa/tisa/api/titypes.h> 30 31 #include <dev/pms/RefTisa/sallsdk/api/sa.h> 32 #include <dev/pms/RefTisa/sallsdk/api/saapi.h> 33 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h> 34 35 #include <dev/pms/RefTisa/sat/api/sm.h> 36 #include <dev/pms/RefTisa/sat/api/smapi.h> 37 #include <dev/pms/RefTisa/sat/api/tdsmapi.h> 38 39 #include <dev/pms/RefTisa/sat/src/smdefs.h> 40 #include <dev/pms/RefTisa/sat/src/smproto.h> 41 #include <dev/pms/RefTisa/sat/src/smtypes.h> 42 43 extern smRoot_t *gsmRoot; 44 45 /******************************** completion ***********************************************************/ 46 47 FORCEINLINE void 48 smllSATACompleted( 49 agsaRoot_t *agRoot, 50 agsaIORequest_t *agIORequest, 51 bit32 agIOStatus, 52 void *agFirstDword, 53 bit32 agIOInfoLen, 54 void *agParam 55 ) 56 { 57 smRoot_t *smRoot = agNULL; 58 // smIntRoot_t *smIntRoot = agNULL; 59 // smIntContext_t *smAllShared = agNULL; 60 smIORequestBody_t *smIORequestBody; 61 smSatIOContext_t *satIOContext; 62 smDeviceData_t *pSatDevData; 63 smDeviceHandle_t *smDeviceHandle = agNULL; 64 smDeviceData_t *oneDeviceData = agNULL; 65 66 SM_DBG2(("smllSATACompleted: start\n")); 67 68 if (agIORequest == agNULL) 69 { 70 SM_DBG1(("smllSATACompleted: agIORequest is NULL!!!\n")); 71 return; 72 } 73 74 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 75 76 if (smIORequestBody == agNULL) 77 { 78 SM_DBG1(("smllSATACompleted: smIORequestBody is NULL!!!\n")); 79 return; 80 } 81 82 /* for debugging */ 83 if (smIORequestBody->ioCompleted == agTRUE) 84 { 85 smDeviceHandle = smIORequestBody->smDevHandle; 86 if (smDeviceHandle == agNULL) 87 { 88 SM_DBG1(("smllSATACompleted: smDeviceHandle is NULL!!!\n")); 89 return; 90 } 91 oneDeviceData = (smDeviceData_t *)smDeviceHandle->smData; 92 SM_DBG1(("smllSATACompleted: Error!!!!!! double completion!!!, ID %d!!!\n", smIORequestBody->id)); 93 if (oneDeviceData == agNULL) 94 { 95 SM_DBG1(("smllSATACompleted: oneDeviceData is NULL!!!\n")); 96 return; 97 } 98 SM_DBG1(("smllSATACompleted: did %d!!!\n", oneDeviceData->id)); 99 return; 100 } 101 102 smIORequestBody->ioCompleted = agTRUE; 103 satIOContext = &(smIORequestBody->transport.SATA.satIOContext); 104 105 if (satIOContext == agNULL) 106 { 107 SM_DBG1(("smllSATACompleted: satIOContext is NULL!!!\n")); 108 return; 109 } 110 111 pSatDevData = satIOContext->pSatDevData; 112 113 if (pSatDevData == agNULL) 114 { 115 SM_DBG1(("smllSATACompleted: pSatDevData is NULL loc 1, wrong!!!\n")); 116 if (satIOContext->satIntIoContext == agNULL) 117 { 118 SM_DBG1(("smllSATACompleted: external command!!!\n")); 119 } 120 else 121 { 122 SM_DBG1(("smllSATACompleted: internal command!!!\n")); 123 } 124 return; 125 } 126 127 smDeviceHandle = smIORequestBody->smDevHandle; 128 129 if (smDeviceHandle == agNULL) 130 { 131 SM_DBG1(("smllSATACompleted: smDeviceHandle is NULL!!!!\n")); 132 return; 133 } 134 135 oneDeviceData = (smDeviceData_t *)smDeviceHandle->smData; 136 137 if (oneDeviceData != pSatDevData) 138 { 139 SM_DBG1(("smllSATACompleted: diff device handle!!!\n")); 140 if (satIOContext->satIntIoContext == agNULL) 141 { 142 SM_DBG1(("smllSATACompleted: external command!!!\n")); 143 } 144 else 145 { 146 SM_DBG1(("smllSATACompleted: internal command!!!\n")); 147 } 148 return; 149 } 150 151 if (oneDeviceData == agNULL) 152 { 153 SM_DBG1(("smllSATACompleted: oneDeviceData is NULL!!!!\n")); 154 if (satIOContext->satIntIoContext == agNULL) 155 { 156 SM_DBG1(("smllSATACompleted: external command!!!\n")); 157 } 158 else 159 { 160 SM_DBG1(("smllSATACompleted: internal command!!!\n")); 161 } 162 return; 163 } 164 165 smRoot = oneDeviceData->smRoot; 166 167 /* release tag value for SATA */ 168 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) || 169 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) ) 170 { 171 smsatTagRelease(smRoot, pSatDevData, satIOContext->sataTag); 172 SM_DBG3(("smllSATACompleted: ncq tag 0x%x\n",satIOContext->sataTag)); 173 } 174 175 /* just for debugging */ 176 if (agIOStatus == OSSA_IO_DS_NON_OPERATIONAL) 177 { 178 SM_DBG1(("smllSATACompleted: agIOStatus is OSSA_IO_DS_NON_OPERATIONAL!!!\n")); 179 } 180 if (agIOStatus == OSSA_IO_DS_IN_RECOVERY) 181 { 182 SM_DBG1(("smllSATACompleted: agIOStatus is OSSA_IO_DS_IN_RECOVERY!!!\n")); 183 } 184 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS) 185 { 186 SM_DBG1(("smllSATACompleted: agIOStatus is OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS!!!\n")); 187 } 188 189 satIOContext->satCompleteCB( agRoot, 190 agIORequest, 191 agIOStatus, 192 agFirstDword, 193 agIOInfoLen, 194 agParam, 195 satIOContext); 196 197 198 199 return; 200 } 201 /***************************************************************************** 202 *! \brief smsatPacketCB 203 * 204 * This routine is a callback function called from smllSATACompleted(). 205 * This CB routine deals with normal Packet command I/O SATA request. 206 * 207 * \param agRoot: Handles for this instance of SAS/SATA hardware 208 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 209 * \param agIOStatus: Status of completed I/O. 210 * \param agFirstDword:Pointer to the four bytes of FIS. 211 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 212 * length. 213 * \param agParam: Additional info based on status. 214 * \param ioContext: Pointer to smSatIOContext_t. 215 * 216 * \return: none 217 * 218 *****************************************************************************/ 219 220 osGLOBAL void 221 smsatPacketCB( 222 agsaRoot_t *agRoot, 223 agsaIORequest_t *agIORequest, 224 bit32 agIOStatus, 225 agsaFisHeader_t *agFirstDword, 226 bit32 agIOInfoLen, 227 void *agParam, 228 void *ioContext 229 ) 230 { 231 smRoot_t *smRoot = agNULL; 232 smIntRoot_t *smIntRoot = agNULL; 233 smIntContext_t *smAllShared = agNULL; 234 smIORequestBody_t *smIORequestBody; 235 smIORequestBody_t *smOrgIORequestBody; 236 smSatIOContext_t *satIOContext; 237 smSatIOContext_t *satOrgIOContext; 238 smSatIOContext_t *satNewIOContext; 239 smSatInternalIo_t *satIntIo; 240 smSatInternalIo_t *satNewIntIo = agNULL; 241 smDeviceData_t *oneDeviceData; 242 bit32 interruptContext; 243 smScsiRspSense_t *pSense; 244 smIniScsiCmnd_t *scsiCmnd; 245 smIORequest_t *smOrgIORequest; 246 // bit32 ataStatus = 0; 247 // bit32 ataError; 248 249 bit32 status = SM_RC_SUCCESS; 250 // agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 251 // bit32 dataLength; 252 bit8 bSenseKey = 0; 253 bit16 bSenseCodeInfo = 0; 254 255 SM_DBG3(("smsatPacketCB: start\n")); 256 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 257 satIOContext = (smSatIOContext_t *) ioContext; 258 if (satIOContext == agNULL) 259 { 260 SM_DBG1(("smsatPacketCB: satIOContext is NULL\n")); 261 return; 262 } 263 satIntIo = satIOContext->satIntIoContext; 264 oneDeviceData = satIOContext->pSatDevData; 265 interruptContext = satIOContext->interruptContext; 266 smRoot = oneDeviceData->smRoot; 267 smIntRoot = (smIntRoot_t *)smRoot->smData; 268 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 269 270 if (satIntIo == agNULL) 271 { 272 SM_DBG5(("smsatPacketCB: External smSatInternalIo_t satIntIoContext\n")); 273 satOrgIOContext = satIOContext; 274 smOrgIORequest = smIORequestBody->smIORequest; 275 pSense = satIOContext->pSense; 276 scsiCmnd = satIOContext->pScsiCmnd; 277 } 278 else 279 { 280 SM_DBG5(("smsatPacketCB: Internal smSatInternalIo_t satIntIoContext\n")); 281 satOrgIOContext = satIOContext->satOrgIOContext; 282 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 283 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 284 pSense = satOrgIOContext->pSense; 285 scsiCmnd = satOrgIOContext->pScsiCmnd; 286 } 287 288 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 289 290 smIORequestBody->ioCompleted = agTRUE; 291 smIORequestBody->ioStarted = agFALSE; 292 293 /* interal structure free */ 294 smsatFreeIntIoResource( smRoot, oneDeviceData, satIntIo); 295 if( agIOStatus == OSSA_IO_SUCCESS && agIOInfoLen == 0 && agFirstDword == agNULL) 296 { 297 SM_DBG3(("smsatPacketCB: First, agIOStatus == OSSA_IO_SUCCESS, agFirstDword == agNULL, agIOInfoLen = %d\n", agIOInfoLen)); 298 tdsmIOCompletedCB(smRoot, 299 smOrgIORequest, 300 smIOSuccess, 301 SCSI_STAT_GOOD, 302 agNULL, 303 interruptContext); 304 } 305 else if (agIOStatus == OSSA_IO_SUCCESS && !(agIOInfoLen == 0 && agFirstDword == agNULL)) 306 { 307 SM_DBG2(("smsatPacketCB: Second, agIOStatus == OSSA_IO_SUCCESS , agFirstDword %p agIOInfoLen = %d\n", agFirstDword, agIOInfoLen)); 308 /*The SCSI command status is error, need to send REQUEST SENSE for getting more sense information*/ 309 satNewIntIo = smsatAllocIntIoResource( smRoot, 310 smOrgIORequest, 311 oneDeviceData, 312 SENSE_DATA_LENGTH, 313 satNewIntIo); 314 if (satNewIntIo == agNULL) 315 { 316 /* memory allocation failure */ 317 /* just translate the ATAPI error register to sense information */ 318 smsatTranslateATAPIErrorsToSCSIErrors( 319 scsiCmnd->cdb[0], 320 agFirstDword->D2H.status, 321 agFirstDword->D2H.error, 322 &bSenseKey, 323 &bSenseCodeInfo 324 ); 325 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 326 tdsmIOCompletedCB( smRoot, 327 smOrgIORequest, 328 smIOSuccess, 329 SCSI_STAT_CHECK_CONDITION, 330 satOrgIOContext->pSmSenseData, 331 interruptContext); 332 SM_DBG1(("smsatPacketCB: momory allocation fails\n")); 333 return; 334 } /* end memory allocation */ 335 336 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 337 smOrgIORequest, 338 oneDeviceData, 339 scsiCmnd, 340 satOrgIOContext 341 ); 342 /* sends request sense to ATAPI device for acquiring sense information */ 343 status = smsatRequestSenseForATAPI(smRoot, 344 &satNewIntIo->satIntSmIORequest, 345 satNewIOContext->psmDeviceHandle, 346 &satNewIntIo->satIntSmScsiXchg, 347 satNewIOContext 348 ); 349 if (status != SM_RC_SUCCESS) 350 { 351 smsatFreeIntIoResource( smRoot, 352 oneDeviceData, 353 satNewIntIo); 354 /* just translate the ATAPI error register to sense information */ 355 smsatTranslateATAPIErrorsToSCSIErrors( 356 scsiCmnd->cdb[0], 357 agFirstDword->D2H.status, 358 agFirstDword->D2H.error, 359 &bSenseKey, 360 &bSenseCodeInfo 361 ); 362 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 363 tdsmIOCompletedCB(smRoot, 364 smOrgIORequest, 365 smIOSuccess, 366 SCSI_STAT_CHECK_CONDITION, 367 satOrgIOContext->pSmSenseData, 368 interruptContext); 369 SM_DBG1(("smsatPacketCB: failed to call satRequestSenseForATAPI()\n")); 370 } 371 } 372 else if (agIOStatus != OSSA_IO_SUCCESS ) 373 { 374 SM_DBG2(("smsatPacketCB: agIOStatus != OSSA_IO_SUCCESS, status %d\n", agIOStatus)); 375 smsatProcessAbnormalCompletion( 376 agRoot, 377 agIORequest, 378 agIOStatus, 379 agFirstDword, 380 agIOInfoLen, 381 agParam, 382 satIOContext); 383 } 384 else 385 { 386 SM_DBG1(("smsatPacketCB: Unknown error \n")); 387 tdsmIOCompletedCB(smRoot, 388 smOrgIORequest, 389 smIOFailed, 390 smDetailOtherError, 391 agNULL, 392 interruptContext); 393 } 394 } 395 /***************************************************************************** 396 *! \brief smsatRequestSenseForATAPICB 397 * 398 * This routine is a callback function called from smllSATACompleted(). 399 * This CB routine deals with normal non-chained data I/O SATA request. 400 * 401 * \param agRoot: Handles for this instance of SAS/SATA hardware 402 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 403 * \param agIOStatus: Status of completed I/O. 404 * \param agFirstDword:Pointer to the four bytes of FIS. 405 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 406 * length. 407 * \param agParam: Additional info based on status. 408 * \param ioContext: Pointer to smSatIOContext_t. 409 * 410 * \return: none 411 * 412 *****************************************************************************/ 413 osGLOBAL void 414 smsatRequestSenseForATAPICB( 415 agsaRoot_t *agRoot, 416 agsaIORequest_t *agIORequest, 417 bit32 agIOStatus, 418 agsaFisHeader_t *agFirstDword, 419 bit32 agIOInfoLen, 420 void *agParam, 421 void *ioContext 422 ) 423 { 424 smRoot_t *smRoot = agNULL; 425 smIntRoot_t *smIntRoot = agNULL; 426 smIntContext_t *smAllShared = agNULL; 427 smIORequestBody_t *smIORequestBody; 428 smIORequestBody_t *smOrgIORequestBody; 429 smSatIOContext_t *satIOContext; 430 smSatIOContext_t *satOrgIOContext; 431 // smSatIOContext_t *satNewIOContext; 432 smSatInternalIo_t *satIntIo; 433 // smSatInternalIo_t *satNewIntIo = agNULL; 434 smDeviceData_t *oneDeviceData; 435 bit32 interruptContext; 436 bit8 dataLength; 437 smIniScsiCmnd_t *scsiCmnd; 438 smIORequest_t *smOrgIORequest; 439 440 SM_DBG3(("smsatRequestSenseForATAPICB: start\n")); 441 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 442 satIOContext = (smSatIOContext_t *) ioContext; 443 if (satIOContext == agNULL) 444 { 445 SM_DBG1(("smsatRequestSenseForATAPICB: satIOContext is NULL\n")); 446 return; 447 } 448 satIntIo = satIOContext->satIntIoContext; 449 oneDeviceData = satIOContext->pSatDevData; 450 interruptContext = satIOContext->interruptContext; 451 smRoot = oneDeviceData->smRoot; 452 smIntRoot = (smIntRoot_t *)smRoot->smData; 453 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 454 if (satIntIo == agNULL) 455 { 456 SM_DBG5(("smsatRequestSenseForATAPICB: External smSatInternalIo_t satIntIoContext\n")); 457 satOrgIOContext = satIOContext; 458 smOrgIORequest = smIORequestBody->smIORequest; 459 scsiCmnd = satIOContext->pScsiCmnd; 460 } 461 else 462 { 463 SM_DBG5(("smsatRequestSenseForATAPICB: Internal smSatInternalIo_t satIntIoContext\n")); 464 satOrgIOContext = satIOContext->satOrgIOContext; 465 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 466 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 467 scsiCmnd = satOrgIOContext->pScsiCmnd; 468 } 469 470 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 471 smIORequestBody->ioCompleted = agTRUE; 472 smIORequestBody->ioStarted = agFALSE; 473 if ( (agIOStatus == OSSA_IO_SUCCESS && agIOInfoLen == 0 && agFirstDword == agNULL)) 474 { 475 /* copy the request sense buffer to original IO buffer*/ 476 if (satIntIo) 477 { 478 sm_memcpy(satOrgIOContext->pSmSenseData->senseData, satIntIo->satIntDmaMem.virtPtr, SENSE_DATA_LENGTH); 479 } 480 satOrgIOContext->pSmSenseData->senseLen = SENSE_DATA_LENGTH; 481 /* interal structure free */ 482 smsatFreeIntIoResource( smRoot, oneDeviceData, satIntIo); 483 484 /* notify the OS to complete this SRB */ 485 tdsmIOCompletedCB( smRoot, 486 smOrgIORequest, 487 smIOSuccess, 488 SCSI_STAT_CHECK_CONDITION, 489 satOrgIOContext->pSmSenseData, 490 interruptContext); 491 } 492 else if (agIOStatus == OSSA_IO_UNDERFLOW ) 493 { 494 /* copy the request sense buffer to original IO buffer*/ 495 SM_DBG1(("smsatRequestSenseForATAPICB: OSSA_IO_UNDERFLOW agIOInfoLen = %d\n", agIOInfoLen)); 496 dataLength = (bit8)(scsiCmnd->expDataLength - agIOInfoLen); 497 if (satIntIo) 498 { 499 sm_memcpy(satOrgIOContext->pSmSenseData->senseData, satIntIo->satIntDmaMem.virtPtr, dataLength); 500 } 501 satOrgIOContext->pSmSenseData->senseLen = dataLength; 502 /* interal structure free */ 503 smsatFreeIntIoResource( smRoot, oneDeviceData, satIntIo); 504 505 /* notify the OS to complete this SRB */ 506 tdsmIOCompletedCB( smRoot, 507 smOrgIORequest, 508 smIOSuccess, 509 SCSI_STAT_CHECK_CONDITION, 510 satOrgIOContext->pSmSenseData, 511 interruptContext); 512 } 513 else 514 { 515 SM_DBG1(("smsatRequestSenseForATAPICB: failed, agIOStatus error = 0x%x agIOInfoLen = %d\n", agIOStatus, agIOInfoLen)); 516 /* interal structure free */ 517 smsatFreeIntIoResource( smRoot, oneDeviceData, satIntIo); 518 519 /* notify the OS to complete this SRB */ 520 tdsmIOCompletedCB( smRoot, 521 smOrgIORequest, 522 smIOFailed, 523 smDetailOtherError, 524 agNULL, 525 interruptContext); 526 } 527 SM_DBG3(("smsatRequestSenseForATAPICB: end\n")); 528 } 529 530 /***************************************************************************** 531 *! \brief smsatSetFeaturesPIOCB 532 * 533 * This routine is a callback function called from smllSATACompleted(). 534 * This CB routine deals with normal non-chained data I/O SATA request. 535 * 536 * \param agRoot: Handles for this instance of SAS/SATA hardware 537 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 538 * \param agIOStatus: Status of completed I/O. 539 * \param agFirstDword:Pointer to the four bytes of FIS. 540 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 541 * length. 542 * \param agParam: Additional info based on status. 543 * \param ioContext: Pointer to smSatIOContext_t. 544 * 545 * \return: none 546 * 547 *****************************************************************************/ 548 osGLOBAL void 549 smsatSetFeaturesPIOCB( 550 agsaRoot_t *agRoot, 551 agsaIORequest_t *agIORequest, 552 bit32 agIOStatus, 553 agsaFisHeader_t *agFirstDword, 554 bit32 agIOInfoLen, 555 void *agParam, 556 void *ioContext 557 ) 558 { 559 smRoot_t *smRoot = agNULL; 560 smIntRoot_t *smIntRoot = agNULL; 561 smIntContext_t *smAllShared = agNULL; 562 smIORequestBody_t *smIORequestBody; 563 smIORequestBody_t *smOrgIORequestBody = agNULL; 564 smSatIOContext_t *satIOContext; 565 smSatIOContext_t *satOrgIOContext; 566 smSatIOContext_t *satNewIOContext; 567 smSatInternalIo_t *satIntIo; 568 smSatInternalIo_t *satNewIntIo = agNULL; 569 smDeviceData_t *oneDeviceData; 570 smIniScsiCmnd_t *scsiCmnd; 571 smIORequest_t *smOrgIORequest; 572 smDeviceHandle_t *smDeviceHandle; 573 bit32 status = SM_RC_FAILURE; 574 smIORequest_t *smIORequest; 575 576 SM_DBG2(("smsatSetFeaturesPIOCB: start\n")); 577 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 578 satIOContext = (smSatIOContext_t *) ioContext; 579 if (satIOContext == agNULL) 580 { 581 SM_DBG1(("smsatSetFeaturesPIOCB: satIOContext is NULL\n")); 582 return; 583 } 584 satIntIo = satIOContext->satIntIoContext; 585 oneDeviceData = satIOContext->pSatDevData; 586 smDeviceHandle = satIOContext->psmDeviceHandle; 587 smRoot = oneDeviceData->smRoot; 588 smIntRoot = (smIntRoot_t *)smRoot->smData; 589 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 590 if (satIntIo == agNULL) 591 { 592 SM_DBG2(("smsatSetFeaturesPIOCB: External smSatInternalIo_t satIntIoContext\n")); 593 satOrgIOContext = satIOContext; 594 smOrgIORequest = smIORequestBody->smIORequest; 595 scsiCmnd = satIOContext->pScsiCmnd; 596 } 597 else 598 { 599 SM_DBG2(("smsatSetFeaturesPIOCB: Internal smSatInternalIo_t satIntIoContext\n")); 600 satOrgIOContext = satIOContext->satOrgIOContext; 601 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 602 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 603 scsiCmnd = satOrgIOContext->pScsiCmnd; 604 } 605 smIORequest = smOrgIORequestBody->smIORequest; 606 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 607 smIORequestBody->ioCompleted = agTRUE; 608 smIORequestBody->ioStarted = agFALSE; 609 /* interal structure free */ 610 smsatFreeIntIoResource(smRoot, 611 oneDeviceData, 612 satIntIo); 613 if (smIORequest->tdData == smIORequest->smData) 614 { 615 SM_DBG1(("smsatSetFeaturesPIOCB: the same tdData and smData error!\n")); 616 } 617 /* check the agIOStatus */ 618 if (agIOStatus == OSSA_IO_ABORTED || 619 agIOStatus == OSSA_IO_NO_DEVICE || 620 agIOStatus == OSSA_IO_PORT_IN_RESET || 621 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL || 622 agIOStatus == OSSA_IO_DS_IN_RECOVERY || 623 agIOStatus == OSSA_IO_DS_IN_ERROR || 624 agIOStatus == OSSA_IO_DS_INVALID 625 ) 626 { 627 SM_DBG1(("smsatSetFeaturesPIOCB: error status 0x%x\n", agIOStatus)); 628 SM_DBG1(("smsatSetFeaturesPIOCB: did %d!!!\n", oneDeviceData->id)); 629 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 630 return; 631 } 632 /*if the ATAPI device support DMA, then enble this feature*/ 633 if (oneDeviceData->satDMASupport) 634 { 635 satNewIntIo = smsatAllocIntIoResource(smRoot, 636 smOrgIORequest, 637 oneDeviceData, 638 0, 639 satNewIntIo); 640 if (satNewIntIo == agNULL) 641 { 642 SM_DBG1(("smsatSetFeaturesPIOCB: memory allocation fails\n")); 643 /*Complete this identify packet device IO */ 644 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 645 return; 646 } /* end memory allocation */ 647 648 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 649 smOrgIORequest, 650 oneDeviceData, 651 scsiCmnd, 652 satOrgIOContext 653 ); 654 /* sends another ATA SET FEATURES based on DMA bit */ 655 status = smsatSetFeaturesDMA(smRoot, 656 &satNewIntIo->satIntSmIORequest, 657 satNewIOContext->psmDeviceHandle, 658 &satNewIntIo->satIntSmScsiXchg, 659 satNewIOContext 660 ); 661 if (status != SM_RC_SUCCESS) 662 { 663 smsatFreeIntIoResource(smRoot, oneDeviceData, satNewIntIo); 664 SM_DBG2(("satSetFeaturesPIOCB: failed to call smsatSetFeatures()\n")); 665 /*Complete this identify packet device IO */ 666 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 667 } 668 } 669 else 670 { 671 /*Complete this identify packet device IO */ 672 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 673 } 674 SM_DBG2(("smsatSetFeaturesPIOCB: exit, agIOStatus 0x%x\n", agIOStatus)); 675 } 676 677 /***************************************************************************** 678 *! \brief smsatDeviceResetCB 679 * 680 * This routine is a callback function called from smllSATACompleted(). 681 * This CB routine deals with normal non-chained data I/O SATA request. 682 * 683 * \param agRoot: Handles for this instance of SAS/SATA hardware 684 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 685 * \param agIOStatus: Status of completed I/O. 686 * \param agFirstDword:Pointer to the four bytes of FIS. 687 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 688 * length. 689 * \param agParam: Additional info based on status. 690 * \param ioContext: Pointer to smSatIOContext_t. 691 * 692 * \return: none 693 * 694 *****************************************************************************/ 695 osGLOBAL void 696 smsatDeviceResetCB( 697 agsaRoot_t *agRoot, 698 agsaIORequest_t *agIORequest, 699 bit32 agIOStatus, 700 agsaFisHeader_t *agFirstDword, 701 bit32 agIOInfoLen, 702 void *agParam, 703 void *ioContext 704 ) 705 { 706 smRoot_t *smRoot = agNULL; 707 smIntRoot_t *smIntRoot = agNULL; 708 smIntContext_t *smAllShared = agNULL; 709 smIORequestBody_t *smIORequestBody; 710 smSatIOContext_t *satIOContext; 711 smSatIOContext_t *satOrgIOContext; 712 // smSatIOContext_t *satNewIOContext; 713 smSatInternalIo_t *satIntIo; 714 // smSatInternalIo_t *satNewIntIo = agNULL; 715 smDeviceData_t *oneDeviceData; 716 #ifdef TD_DEBUG_ENABLE 717 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 718 bit32 ataStatus = 0; 719 bit32 ataError; 720 #endif 721 // bit32 status; 722 bit32 AbortTM = agFALSE; 723 smDeviceHandle_t *smDeviceHandle; 724 725 SM_DBG1(("smsatDeviceResetCB: start\n")); 726 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 727 satIOContext = (smSatIOContext_t *) ioContext; 728 satIntIo = satIOContext->satIntIoContext; 729 oneDeviceData = satIOContext->pSatDevData; 730 smRoot = oneDeviceData->smRoot; 731 smIntRoot = (smIntRoot_t *)smRoot->smData; 732 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 733 smDeviceHandle = oneDeviceData->smDevHandle; 734 if (satIntIo == agNULL) 735 { 736 SM_DBG6(("smsatDeviceResetCB: External, OS generated\n")); 737 satOrgIOContext = satIOContext; 738 } 739 else 740 { 741 SM_DBG6(("smsatDeviceResetCB: Internal, TD generated\n")); 742 satOrgIOContext = satIOContext->satOrgIOContext; 743 if (satOrgIOContext == agNULL) 744 { 745 SM_DBG6(("smsatDeviceResetCB: satOrgIOContext is NULL, wrong\n")); 746 return; 747 } 748 else 749 { 750 SM_DBG6(("smsatDeviceResetCB: satOrgIOContext is NOT NULL\n")); 751 } 752 } 753 smIORequestBody->ioCompleted = agTRUE; 754 smIORequestBody->ioStarted = agFALSE; 755 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 756 { 757 SM_DBG1(("smsatDeviceResetCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 758 /* TM completed */ 759 tdsmEventCB( smRoot, 760 smDeviceHandle, 761 smIntrEventTypeTaskManagement, 762 smTMFailed, 763 oneDeviceData->satTmTaskTag); 764 oneDeviceData->satTmTaskTag = agNULL; 765 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 766 smsatFreeIntIoResource( smRoot, 767 oneDeviceData, 768 satIntIo); 769 return; 770 } 771 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 772 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 773 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 774 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 775 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 776 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 777 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 778 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 779 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 780 ) 781 { 782 SM_DBG1(("smsatDeviceResetCB: OSSA_IO_OPEN_CNX_ERROR!!!\n")); 783 /* TM completed */ 784 tdsmEventCB( smRoot, 785 smDeviceHandle, 786 smIntrEventTypeTaskManagement, 787 smTMFailed, 788 oneDeviceData->satTmTaskTag); 789 oneDeviceData->satTmTaskTag = agNULL; 790 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 791 smsatFreeIntIoResource( smRoot, 792 oneDeviceData, 793 satIntIo); 794 return; 795 } 796 if (agIOStatus != OSSA_IO_SUCCESS) 797 { 798 #ifdef TD_DEBUG_ENABLE 799 /* only agsaFisPioSetup_t is expected */ 800 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 801 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 802 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 803 #endif 804 SM_DBG1(("smsatDeviceResetCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 805 /* TM completed */ 806 tdsmEventCB( smRoot, 807 smDeviceHandle, 808 smIntrEventTypeTaskManagement, 809 smTMFailed, 810 oneDeviceData->satTmTaskTag); 811 oneDeviceData->satTmTaskTag = agNULL; 812 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 813 smsatFreeIntIoResource( smRoot, 814 oneDeviceData, 815 satIntIo); 816 return; 817 } 818 /*success */ 819 if (satOrgIOContext->TMF == AG_ABORT_TASK) 820 { 821 AbortTM = agTRUE; 822 } 823 if (AbortTM == agTRUE) 824 { 825 SM_DBG1(("smsatDeviceResetCB: calling satAbort!!!\n")); 826 smsatAbort(smRoot, agRoot, satOrgIOContext->satToBeAbortedIOContext); 827 } 828 oneDeviceData->satTmTaskTag = agNULL; 829 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 830 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 831 SM_DBG1(("smsatDeviceResetCB: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 832 SM_DBG1(("smsatDeviceResetCB: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 833 smsatFreeIntIoResource( smRoot, 834 oneDeviceData, 835 satIntIo); 836 /* TM completed */ 837 tdsmEventCB( smRoot, 838 smDeviceHandle, 839 smIntrEventTypeTaskManagement, 840 smTMOK, 841 oneDeviceData->satTmTaskTag); 842 843 844 SM_DBG3(("smsatDeviceResetCB: return\n")); 845 } 846 847 848 /***************************************************************************** 849 *! \brief smsatExecuteDeviceDiagnosticCB 850 * 851 * This routine is a callback function called from smllSATACompleted(). 852 * This CB routine deals with normal non-chained data I/O SATA request. 853 * 854 * \param agRoot: Handles for this instance of SAS/SATA hardware 855 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 856 * \param agIOStatus: Status of completed I/O. 857 * \param agFirstDword:Pointer to the four bytes of FIS. 858 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 859 * length. 860 * \param agParam: Additional info based on status. 861 * \param ioContext: Pointer to smSatIOContext_t. 862 * 863 * \return: none 864 * 865 *****************************************************************************/ 866 osGLOBAL void 867 smsatExecuteDeviceDiagnosticCB( 868 agsaRoot_t *agRoot, 869 agsaIORequest_t *agIORequest, 870 bit32 agIOStatus, 871 agsaFisHeader_t *agFirstDword, 872 bit32 agIOInfoLen, 873 void *agParam, 874 void *ioContext 875 ) 876 { 877 smRoot_t *smRoot = agNULL; 878 smIntRoot_t *smIntRoot = agNULL; 879 smIntContext_t *smAllShared = agNULL; 880 smIORequestBody_t *smIORequestBody; 881 smSatIOContext_t *satIOContext; 882 smSatIOContext_t *satOrgIOContext; 883 // smSatIOContext_t *satNewIOContext; 884 smSatInternalIo_t *satIntIo; 885 // smSatInternalIo_t *satNewIntIo = agNULL; 886 smDeviceData_t *oneDeviceData; 887 888 SM_DBG6(("smsatSetFeaturesDMACB: start\n")); 889 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 890 satIOContext = (smSatIOContext_t *) ioContext; 891 satIntIo = satIOContext->satIntIoContext; 892 oneDeviceData = satIOContext->pSatDevData; 893 smRoot = oneDeviceData->smRoot; 894 smIntRoot = (smIntRoot_t *)smRoot->smData; 895 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 896 if (satIntIo == agNULL) 897 { 898 SM_DBG5(("smsatExecuteDeviceDiagnosticCB: External smSatInternalIo_t satIntIoContext\n")); 899 satOrgIOContext = satIOContext; 900 } 901 else 902 { 903 SM_DBG5(("smsatExecuteDeviceDiagnosticCB: Internal smSatInternalIo_t satIntIoContext\n")); 904 satOrgIOContext = satIOContext->satOrgIOContext; 905 if (satOrgIOContext == agNULL) 906 { 907 SM_DBG5(("smsatExecuteDeviceDiagnosticCB: satOrgIOContext is NULL\n")); 908 } 909 else 910 { 911 SM_DBG5(("smsatExecuteDeviceDiagnosticCB: satOrgIOContext is NOT NULL\n")); 912 } 913 } 914 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 915 smIORequestBody->ioCompleted = agTRUE; 916 smIORequestBody->ioStarted = agFALSE; 917 /* interal structure free */ 918 smsatFreeIntIoResource(smRoot,oneDeviceData, satIntIo); 919 } 920 921 GLOBAL void 922 smsatTranslateATAPIErrorsToSCSIErrors( 923 bit8 bCommand, 924 bit8 bATAStatus, 925 bit8 bATAError, 926 bit8 *pSenseKey, 927 bit16 *pSenseCodeInfo 928 ) 929 { 930 if (pSenseKey == agNULL || pSenseCodeInfo == agNULL) 931 { 932 SM_DBG1(("TranslateATAErrorsToSCSIErros: pSenseKey == agNULL || pSenseCodeInfo == agNULL\n")); 933 return; 934 } 935 if (bATAStatus & ERR_ATA_STATUS_MASK ) 936 { 937 if(bATAError & NM_ATA_ERROR_MASK) 938 { 939 *pSenseKey = SCSI_SNSKEY_NOT_READY; 940 *pSenseCodeInfo = 0x3a00; 941 } 942 else if(bATAError & ABRT_ATA_ERROR_MASK) 943 { 944 *pSenseKey = SCSI_SNSKEY_ABORTED_COMMAND; 945 *pSenseCodeInfo = 0; 946 } 947 else if(bATAError & MCR_ATA_ERROR_MASK) 948 { 949 *pSenseKey = SCSI_SNSKEY_UNIT_ATTENTION; 950 *pSenseCodeInfo = 0x5a01; 951 } 952 else if(bATAError & IDNF_ATA_ERROR_MASK) 953 { 954 *pSenseKey = SCSI_SNSKEY_MEDIUM_ERROR; 955 *pSenseCodeInfo = 0x1401; 956 } 957 else if(bATAError & MC_ATA_ERROR_MASK) 958 { 959 *pSenseKey = SCSI_SNSKEY_UNIT_ATTENTION; 960 *pSenseCodeInfo = 0x2800; 961 } 962 else if(bATAError & UNC_ATA_ERROR_MASK) 963 { 964 /*READ*/ 965 *pSenseKey = SCSI_SNSKEY_MEDIUM_ERROR; 966 *pSenseCodeInfo = 0x1100; 967 968 /*add WRITE here */ 969 } 970 else if(bATAError & ICRC_ATA_ERROR_MASK) 971 { 972 *pSenseKey = SCSI_SNSKEY_ABORTED_COMMAND; 973 *pSenseCodeInfo = 0x4703; 974 } 975 } 976 else if((bATAStatus & DF_ATA_STATUS_MASK)) 977 { 978 *pSenseKey = SCSI_SNSKEY_HARDWARE_ERROR; 979 *pSenseCodeInfo = 0x4400; 980 } 981 else 982 { 983 SM_DBG1(("unhandled ata error: bATAStatus = 0x%x, bATAError = 0x%x\n", bATAStatus, bATAError)); 984 } 985 } 986 987 GLOBAL void 988 smsatTranslateATAErrorsToSCSIErrors( 989 bit8 bATAStatus, 990 bit8 bATAError, 991 bit8 *pSenseKey, 992 bit16 *pSenseCodeInfo 993 ) 994 { 995 996 SM_DBG1(("TranslateATAErrorsToSCSIErros: bATAStatus=%d bATAError= %d \n",bATAStatus,bATAError)); 997 998 if (pSenseKey == agNULL || pSenseCodeInfo == agNULL) 999 { 1000 SM_DBG1(("TranslateATAErrorsToSCSIErros: pSenseKey == agNULL || pSenseCodeInfo == agNULL\n")); 1001 return; 1002 } 1003 1004 if (bATAStatus & ERR_ATA_STATUS_MASK) 1005 { 1006 if(bATAError & NM_ATA_ERROR_MASK) 1007 { 1008 *pSenseKey = SCSI_SNSKEY_NOT_READY; 1009 *pSenseCodeInfo = SCSI_SNSCODE_MEDIUM_NOT_PRESENT; 1010 } 1011 else if(bATAError & UNC_ATA_ERROR_MASK) 1012 { 1013 *pSenseKey = SCSI_SNSKEY_MEDIUM_ERROR; 1014 *pSenseCodeInfo = SCSI_SNSCODE_UNRECOVERED_READ_ERROR; 1015 } 1016 else if(bATAError & IDNF_ATA_ERROR_MASK) 1017 { 1018 *pSenseKey = SCSI_SNSKEY_ILLEGAL_REQUEST; 1019 *pSenseCodeInfo = SCSI_SNSCODE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 1020 } 1021 else if(bATAError & ABRT_ATA_ERROR_MASK) 1022 { 1023 *pSenseKey = SCSI_SNSKEY_ABORTED_COMMAND; 1024 *pSenseCodeInfo = SCSI_SNSCODE_NO_ADDITIONAL_INFO; 1025 } 1026 else if(bATAError & MC_ATA_ERROR_MASK) 1027 { 1028 *pSenseKey = SCSI_SNSKEY_UNIT_ATTENTION; 1029 *pSenseCodeInfo = SCSI_SNSCODE_NOT_READY_TO_READY_CHANGE; 1030 } 1031 else if(bATAError & MCR_ATA_ERROR_MASK) 1032 { 1033 *pSenseKey = SCSI_SNSKEY_UNIT_ATTENTION; 1034 *pSenseCodeInfo = SCSI_SNSCODE_OPERATOR_MEDIUM_REMOVAL_REQUEST; 1035 } 1036 else if(bATAError & ICRC_ATA_ERROR_MASK) 1037 { 1038 *pSenseKey = SCSI_SNSKEY_ABORTED_COMMAND; 1039 *pSenseCodeInfo = SCSI_SNSCODE_INFORMATION_UNIT_CRC_ERROR; 1040 } 1041 else 1042 { 1043 *pSenseKey = SCSI_SNSKEY_NO_SENSE; 1044 *pSenseCodeInfo = SCSI_SNSCODE_NO_ADDITIONAL_INFO; 1045 1046 } 1047 } 1048 else if (bATAStatus & DF_ATA_STATUS_MASK) /* INTERNAL TARGET FAILURE */ 1049 { 1050 *pSenseKey = SCSI_SNSKEY_HARDWARE_ERROR; 1051 *pSenseCodeInfo = SCSI_SNSCODE_INTERNAL_TARGET_FAILURE; 1052 } 1053 1054 1055 } 1056 1057 1058 FORCEINLINE void 1059 smsatNonChainedDataIOCB( 1060 agsaRoot_t *agRoot, 1061 agsaIORequest_t *agIORequest, 1062 bit32 agIOStatus, 1063 agsaFisHeader_t *agFirstDword, 1064 bit32 agIOInfoLen, 1065 void *agParam, 1066 void *ioContext 1067 ) 1068 { 1069 smIORequestBody_t *smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 1070 smSatIOContext_t *satIOContext = (smSatIOContext_t *) ioContext; 1071 smSatInternalIo_t *SatIntIo = satIOContext->satIntIoContext; 1072 smDeviceData_t *oneDeviceData = satIOContext->pSatDevData; 1073 smRoot_t *smRoot = oneDeviceData->smRoot; 1074 smIntRoot_t *smIntRoot = (smIntRoot_t *)smRoot->smData; 1075 smIntContext_t *smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 1076 bit32 interruptContext = satIOContext->interruptContext; 1077 1078 SM_DBG2(("smsatNonChainedDataIOCB: start\n")); 1079 1080 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1081 1082 smIORequestBody->ioCompleted = agTRUE; 1083 smIORequestBody->ioStarted = agFALSE; 1084 1085 /* interal structure free */ 1086 smsatFreeIntIoResource( smRoot, 1087 oneDeviceData, 1088 SatIntIo); 1089 1090 /* Process completion */ 1091 if( (agIOStatus == OSSA_IO_SUCCESS) && (agIOInfoLen == 0)) 1092 { 1093 SM_DBG5(("smsatNonChainedDataIOCB: success\n")); 1094 SM_DBG5(("smsatNonChainedDataIOCB: success agIORequest %p\n", agIORequest)); 1095 /* 1096 * Command was completed OK, this is the normal path. 1097 * Now call the OS-App Specific layer about this completion. 1098 */ 1099 tdsmIOCompletedCB( smRoot, 1100 smIORequestBody->smIORequest, 1101 smIOSuccess, 1102 SCSI_STAT_GOOD, 1103 agNULL, 1104 interruptContext); 1105 } 1106 else 1107 { 1108 SM_DBG1(("smsatNonChainedDataIOCB: calling smsatProcessAbnormalCompletion!!!\n")); 1109 /* More checking needed */ 1110 smsatProcessAbnormalCompletion( agRoot, 1111 agIORequest, 1112 agIOStatus, 1113 agFirstDword, 1114 agIOInfoLen, 1115 agParam, 1116 satIOContext); 1117 } 1118 1119 return; 1120 } 1121 1122 FORCEINLINE void 1123 smsatChainedDataIOCB( 1124 agsaRoot_t *agRoot, 1125 agsaIORequest_t *agIORequest, 1126 bit32 agIOStatus, 1127 agsaFisHeader_t *agFirstDword, 1128 bit32 agIOInfoLen, 1129 void *agParam, 1130 void *ioContext 1131 ) 1132 { 1133 1134 smRoot_t *smRoot = agNULL; 1135 smIntRoot_t *smIntRoot = agNULL; 1136 smIntContext_t *smAllShared = agNULL; 1137 smIORequestBody_t *smIORequestBody; 1138 smIORequestBody_t *smOrgIORequestBody; 1139 smSatIOContext_t *satIOContext; 1140 smSatIOContext_t *satOrgIOContext; 1141 smSatIOContext_t *satNewIOContext; 1142 smSatInternalIo_t *satIntIo; 1143 smSatInternalIo_t *satNewIntIo = agNULL; 1144 // smDeviceData_t *satDevData; 1145 smDeviceData_t *oneDeviceData; 1146 smScsiRspSense_t *pSense; 1147 smIniScsiCmnd_t *scsiCmnd; 1148 smIORequest_t *smOrgIORequest; 1149 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 1150 bit32 ataStatus = 0; 1151 bit32 status = tiError; 1152 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 1153 bit32 dataLength; 1154 1155 SM_DBG6(("smsatChainedDataIOCB: start\n")); 1156 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 1157 satIOContext = (smSatIOContext_t *) ioContext; 1158 if (satIOContext == agNULL) 1159 { 1160 SM_DBG1(("smsatChainedDataIOCB: satIOContext is NULL\n")); 1161 return; 1162 } 1163 satIntIo = satIOContext->satIntIoContext; 1164 oneDeviceData = satIOContext->pSatDevData; 1165 hostToDevFis = satIOContext->pFis; 1166 smRoot = oneDeviceData->smRoot; 1167 smIntRoot = (smIntRoot_t *)smRoot->smData; 1168 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 1169 if (satIntIo == agNULL) 1170 { 1171 SM_DBG5(("smsatChainedDataIOCB: External smSatInternalIo_t satIntIoContext\n")); 1172 satOrgIOContext = satIOContext; 1173 smOrgIORequest = smIORequestBody->smIORequest; 1174 pSense = satIOContext->pSense; 1175 scsiCmnd = satIOContext->pScsiCmnd; 1176 } 1177 else 1178 { 1179 SM_DBG5(("smsatChainedDataIOCB: Internal smSatInternalIo_t satIntIoContext\n")); 1180 satOrgIOContext = satIOContext->satOrgIOContext; 1181 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 1182 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 1183 pSense = satOrgIOContext->pSense; 1184 scsiCmnd = satOrgIOContext->pScsiCmnd; 1185 } 1186 smIORequestBody->ioCompleted = agTRUE; 1187 smIORequestBody->ioStarted = agFALSE; 1188 1189 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 1190 { 1191 SM_DBG1(("smsatChainedDataIOCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 1192 smsatSetSensePayload( pSense, 1193 SCSI_SNSKEY_NO_SENSE, 1194 0, 1195 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1196 satOrgIOContext); 1197 1198 tdsmIOCompletedCB( smRoot, 1199 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1200 smIOSuccess, 1201 SCSI_STAT_CHECK_CONDITION, 1202 satOrgIOContext->pSmSenseData, 1203 satOrgIOContext->interruptContext ); 1204 1205 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1206 1207 smsatFreeIntIoResource( smRoot, 1208 oneDeviceData, 1209 satIntIo); 1210 return; 1211 } 1212 1213 /* 1214 checking IO status, FIS type and error status 1215 */ 1216 if (agIOStatus != OSSA_IO_SUCCESS) 1217 { 1218 /* agsaFisPioSetup_t or agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for read 1219 agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for write 1220 first, assumed to be Reg Device to Host FIS 1221 This is OK to just find fis type 1222 */ 1223 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 1224 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 1225 /* for debugging */ 1226 if( (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) && 1227 (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 1228 (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 1229 ) 1230 { 1231 SM_DBG1(("smsatChainedDataIOCB: FAILED, Wrong FIS type 0x%x!!!\n", statDevToHostFisHeader->fisType)); 1232 } 1233 1234 /* for debugging */ 1235 if ( (ataStatus & ERR_ATA_STATUS_MASK) || 1236 (ataStatus & DF_ATA_STATUS_MASK) 1237 ) 1238 { 1239 SM_DBG1(("smsatChainedDataIOCB: FAILED, error status and command 0x%x!!!\n", hostToDevFis->h.command)); 1240 } 1241 1242 /* the function below handles abort case */ 1243 smsatDelayedProcessAbnormalCompletion(agRoot, 1244 agIORequest, 1245 agIOStatus, 1246 agFirstDword, 1247 agIOInfoLen, 1248 agParam, 1249 satIOContext); 1250 1251 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1252 smsatFreeIntIoResource( smRoot, 1253 oneDeviceData, 1254 satIntIo); 1255 return; 1256 } /* end of error */ 1257 1258 switch (hostToDevFis->h.command) 1259 { 1260 case SAT_READ_DMA: /* fall through */ 1261 case SAT_READ_SECTORS: /* fall through */ 1262 case SAT_READ_DMA_EXT: /* fall through */ 1263 case SAT_READ_SECTORS_EXT: /* fall through */ 1264 case SAT_READ_FPDMA_QUEUED: /* fall through */ 1265 case SAT_WRITE_DMA: /* fall through */ 1266 case SAT_WRITE_SECTORS:/* fall through */ 1267 case SAT_WRITE_DMA_FUA_EXT: /* fall through */ 1268 case SAT_WRITE_DMA_EXT: /* fall through */ 1269 case SAT_WRITE_SECTORS_EXT: /* fall through */ 1270 case SAT_WRITE_FPDMA_QUEUED: 1271 1272 SM_DBG5(("smsatChainedDataIOCB: READ/WRITE success case\n")); 1273 1274 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1275 1276 /* done with internally genereated SAT_SMART_RETURN_STATUS */ 1277 smsatFreeIntIoResource( smRoot, 1278 oneDeviceData, 1279 satIntIo); 1280 /* let's loop till TL */ 1281 1282 /* lba = lba + tl 1283 loopnum--; 1284 if (loopnum == 0) done 1285 */ 1286 (satOrgIOContext->LoopNum)--; 1287 if (satOrgIOContext->LoopNum == 0) 1288 { 1289 /* done with read */ 1290 tdsmIOCompletedCB( smRoot, 1291 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1292 smIOSuccess, 1293 SCSI_STAT_GOOD, 1294 agNULL, 1295 satOrgIOContext->interruptContext ); 1296 return; 1297 } 1298 1299 /* don't need to allocate payload memory here. Use the one allocated by OS layer */ 1300 dataLength = 0; 1301 1302 satNewIntIo = smsatAllocIntIoResource( smRoot, 1303 smOrgIORequest, 1304 oneDeviceData, 1305 dataLength, 1306 satNewIntIo); 1307 if (satNewIntIo == agNULL) 1308 { 1309 tdsmIOCompletedCB( smRoot, 1310 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1311 smIOFailed, 1312 smDetailOtherError, 1313 agNULL, 1314 satOrgIOContext->interruptContext ); 1315 1316 SM_DBG1(("smsatChainedDataIOCB: momory allocation fails!!!\n")); 1317 return; 1318 } /* end of memory allocation failure */ 1319 1320 /* 1321 * Need to initialize all the fields within satIOContext 1322 */ 1323 1324 satNewIOContext = smsatPrepareNewIO( 1325 satNewIntIo, 1326 smOrgIORequest, 1327 oneDeviceData, 1328 scsiCmnd, 1329 satOrgIOContext 1330 ); 1331 1332 /* sending another ATA command */ 1333 switch (scsiCmnd->cdb[0]) 1334 { 1335 case SCSIOPC_READ_6: 1336 /* no loop should occur with READ6 since it fits in one ATA command */ 1337 break; 1338 case SCSIOPC_READ_10: /* fall through */ 1339 case SCSIOPC_READ_12: /* fall through */ 1340 case SCSIOPC_READ_16: /* fall through */ 1341 status = smsatRead_1( smRoot, 1342 &satNewIntIo->satIntSmIORequest, 1343 satNewIOContext->psmDeviceHandle, 1344 &satNewIntIo->satIntSmScsiXchg, 1345 satNewIOContext); 1346 break; 1347 case SCSIOPC_WRITE_6: 1348 /* no loop should occur with WRITE6 since it fits in one ATA command */ 1349 break; 1350 case SCSIOPC_WRITE_10: /* fall through */ 1351 case SCSIOPC_WRITE_12: /* fall through */ 1352 case SCSIOPC_WRITE_16: /* fall through */ 1353 status = smsatWrite_1( smRoot, 1354 &satNewIntIo->satIntSmIORequest, 1355 satNewIOContext->psmDeviceHandle, 1356 &satNewIntIo->satIntSmScsiXchg, 1357 satNewIOContext); 1358 break; 1359 default: 1360 SM_DBG1(("smsatChainedDataIOCB: success but default case scsi cmd 0x%x ata cmd 0x%x!!!\n",scsiCmnd->cdb[0], hostToDevFis->h.command)); 1361 status = tiError; 1362 break; 1363 } 1364 1365 1366 1367 if (status != SM_RC_SUCCESS) 1368 { 1369 smsatFreeIntIoResource( smRoot, 1370 oneDeviceData, 1371 satNewIntIo); 1372 tdsmIOCompletedCB( smRoot, 1373 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1374 smIOFailed, 1375 smDetailOtherError, 1376 agNULL, 1377 satOrgIOContext->interruptContext ); 1378 SM_DBG1(("smsatChainedDataIOCB: calling satRead10_1 fails!!!\n")); 1379 return; 1380 } 1381 1382 break; 1383 1384 1385 default: 1386 SM_DBG1(("smsatChainedDataIOCB: success but default case command 0x%x!!!\n",hostToDevFis->h.command)); 1387 tdsmIOCompletedCB( smRoot, 1388 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1389 smIOFailed, 1390 smDetailOtherError, 1391 agNULL, 1392 satOrgIOContext->interruptContext ); 1393 1394 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1395 1396 smsatFreeIntIoResource( smRoot, 1397 oneDeviceData, 1398 satIntIo); 1399 1400 break; 1401 } 1402 1403 1404 return; 1405 } 1406 1407 osGLOBAL void 1408 smsatNonChainedVerifyCB( 1409 agsaRoot_t *agRoot, 1410 agsaIORequest_t *agIORequest, 1411 bit32 agIOStatus, 1412 agsaFisHeader_t *agFirstDword, 1413 bit32 agIOInfoLen, 1414 agsaFrameHandle_t agFrameHandle, 1415 void *ioContext 1416 ) 1417 { 1418 1419 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 1420 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 1421 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 1422 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 1423 smRoot_t *smRoot = agNULL; 1424 smIntRoot_t *smIntRoot = agNULL; 1425 smIntContext_t *smAllShared = agNULL; 1426 smIORequestBody_t *smIORequestBody; 1427 smIORequestBody_t *smOrgIORequestBody; 1428 smSatIOContext_t *satIOContext; 1429 smSatIOContext_t *satOrgIOContext; 1430 smSatInternalIo_t *satIntIo; 1431 // satDeviceData_t *satDevData; 1432 smDeviceData_t *oneDeviceData; 1433 smScsiRspSense_t *pSense; 1434 smIORequest_t *smOrgIORequest; 1435 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 1436 bit32 ataStatus = 0; 1437 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 1438 1439 SM_DBG2(("smsatNonChainedVerifyCB: start\n")); 1440 SM_DBG5(("smsatNonChainedVerifyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 1441 1442 /* internally generate smIOContext */ 1443 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 1444 satIOContext = (smSatIOContext_t *) ioContext; 1445 satIntIo = satIOContext->satIntIoContext; 1446 oneDeviceData = satIOContext->pSatDevData; 1447 hostToDevFis = satIOContext->pFis; 1448 smRoot = oneDeviceData->smRoot; 1449 smIntRoot = (smIntRoot_t *)smRoot->smData; 1450 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 1451 if (satIntIo == agNULL) 1452 { 1453 SM_DBG4(("smsatNonChainedVerifyCB: External smSatInternalIo_t satIntIoContext\n")); 1454 satOrgIOContext = satIOContext; 1455 smOrgIORequest = smIORequestBody->smIORequest; 1456 pSense = satIOContext->pSense; 1457 } 1458 else 1459 { 1460 SM_DBG4(("smsatNonChainedVerifyCB: Internal smSatInternalIo_t satIntIoContext\n")); 1461 satOrgIOContext = satIOContext->satOrgIOContext; 1462 if (satOrgIOContext == agNULL) 1463 { 1464 SM_DBG4(("smsatNonChainedVerifyCB: satOrgIOContext is NULL, wrong\n")); 1465 return; 1466 } 1467 else 1468 { 1469 SM_DBG4(("smsatNonChainedVerifyCB: satOrgIOContext is NOT NULL\n")); 1470 } 1471 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 1472 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 1473 pSense = satOrgIOContext->pSense; 1474 } 1475 1476 smIORequestBody->ioCompleted = agTRUE; 1477 smIORequestBody->ioStarted = agFALSE; 1478 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 1479 { 1480 SM_DBG1(("smsatNonChainedVerifyCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 1481 smsatSetSensePayload( pSense, 1482 SCSI_SNSKEY_NO_SENSE, 1483 0, 1484 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1485 satOrgIOContext); 1486 tdsmIOCompletedCB( smRoot, 1487 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1488 smIOSuccess, 1489 SCSI_STAT_CHECK_CONDITION, 1490 satOrgIOContext->pSmSenseData, 1491 satOrgIOContext->interruptContext ); 1492 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1493 1494 smsatFreeIntIoResource( smRoot, 1495 oneDeviceData, 1496 satIntIo); 1497 return; 1498 } 1499 if (agIOStatus != OSSA_IO_SUCCESS) 1500 { 1501 /* only agsaFisRegDeviceToHost_t is expected */ 1502 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 1503 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 1504 } 1505 1506 if( agIOStatus != OSSA_IO_SUCCESS) 1507 { 1508 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 1509 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 1510 ) 1511 { 1512 /* for debugging */ 1513 if( agIOStatus != OSSA_IO_SUCCESS) 1514 { 1515 SM_DBG1(("smsatNonChainedVerifyCB: FAILED, NOT IO_SUCCESS!!!\n")); 1516 } 1517 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 1518 { 1519 SM_DBG1(("smsatNonChainedVerifyCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 1520 } 1521 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 1522 (ataStatus & DF_ATA_STATUS_MASK) 1523 ) 1524 { 1525 SM_DBG1(("smsatNonChainedVerifyCB: FAILED, FAILED, error status!!!\n")); 1526 } 1527 1528 /* Process abort case */ 1529 if (agIOStatus == OSSA_IO_ABORTED) 1530 { 1531 smsatProcessAbort(smRoot, 1532 smOrgIORequest, 1533 satOrgIOContext 1534 ); 1535 1536 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1537 1538 smsatFreeIntIoResource( smRoot, 1539 oneDeviceData, 1540 satIntIo); 1541 return; 1542 } 1543 1544 /* for debugging */ 1545 switch (hostToDevFis->h.command) 1546 { 1547 case SAT_READ_VERIFY_SECTORS: 1548 SM_DBG1(("smsatNonChainedVerifyCB: SAT_READ_VERIFY_SECTORS!!!\n")); 1549 break; 1550 case SAT_READ_VERIFY_SECTORS_EXT: 1551 SM_DBG1(("smsatNonChainedVerifyCB: SAT_READ_VERIFY_SECTORS_EXT!!!\n")); 1552 break; 1553 default: 1554 SM_DBG1(("smsatNonChainedVerifyCB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 1555 break; 1556 } 1557 1558 smsatSetSensePayload( pSense, 1559 SCSI_SNSKEY_NO_SENSE, 1560 0, 1561 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1562 satOrgIOContext); 1563 1564 tdsmIOCompletedCB( smRoot, 1565 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1566 smIOSuccess, 1567 SCSI_STAT_CHECK_CONDITION, 1568 satOrgIOContext->pSmSenseData, 1569 satOrgIOContext->interruptContext ); 1570 1571 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1572 1573 smsatFreeIntIoResource( smRoot, 1574 oneDeviceData, 1575 satIntIo); 1576 return; 1577 } /* end error checking */ 1578 } 1579 1580 /* process success from this point on */ 1581 switch (hostToDevFis->h.command) 1582 { 1583 case SAT_READ_VERIFY_SECTORS: /* fall through */ 1584 case SAT_READ_VERIFY_SECTORS_EXT: 1585 SM_DBG5(("smsatNonChainedVerifyCB: SAT_WRITE_DMA_EXT success \n")); 1586 1587 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1588 1589 smsatFreeIntIoResource( smRoot, 1590 oneDeviceData, 1591 satIntIo); 1592 1593 tdsmIOCompletedCB( smRoot, 1594 smOrgIORequest, 1595 smIOSuccess, 1596 SCSI_STAT_GOOD, 1597 agNULL, 1598 satOrgIOContext->interruptContext); 1599 break; 1600 default: 1601 SM_DBG1(("smsatNonChainedVerifyCB: success but error default case command 0x%x!!!\n", hostToDevFis->h.command)); 1602 1603 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1604 1605 smsatFreeIntIoResource( smRoot, 1606 oneDeviceData, 1607 satIntIo); 1608 1609 smsatSetSensePayload( pSense, 1610 SCSI_SNSKEY_NO_SENSE, 1611 0, 1612 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1613 satOrgIOContext); 1614 1615 tdsmIOCompletedCB( smRoot, 1616 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1617 smIOSuccess, 1618 SCSI_STAT_CHECK_CONDITION, 1619 satOrgIOContext->pSmSenseData, 1620 satOrgIOContext->interruptContext ); 1621 1622 break; 1623 } 1624 1625 return; 1626 } 1627 1628 osGLOBAL void 1629 smsatChainedVerifyCB( 1630 agsaRoot_t *agRoot, 1631 agsaIORequest_t *agIORequest, 1632 bit32 agIOStatus, 1633 agsaFisHeader_t *agFirstDword, 1634 bit32 agIOInfoLen, 1635 agsaFrameHandle_t agFrameHandle, 1636 void *ioContext 1637 ) 1638 { 1639 1640 smRoot_t *smRoot = agNULL; 1641 smIntRoot_t *smIntRoot = agNULL; 1642 smIntContext_t *smAllShared = agNULL; 1643 smIORequestBody_t *smIORequestBody; 1644 smIORequestBody_t *smOrgIORequestBody; 1645 smSatIOContext_t *satIOContext; 1646 smSatIOContext_t *satOrgIOContext; 1647 smSatIOContext_t *satNewIOContext; 1648 smSatInternalIo_t *satIntIo; 1649 smSatInternalIo_t *satNewIntIo = agNULL; 1650 smDeviceData_t *oneDeviceData; 1651 smScsiRspSense_t *pSense; 1652 smIniScsiCmnd_t *scsiCmnd; 1653 smIORequest_t *smOrgIORequest; 1654 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 1655 bit32 ataStatus = 0; 1656 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 1657 bit32 status = tiError; 1658 bit32 dataLength; 1659 1660 SM_DBG2(("smsatChainedVerifyCB: start\n")); 1661 SM_DBG5(("smsatChainedVerifyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 1662 1663 /* internally generate smIOContext */ 1664 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 1665 satIOContext = (smSatIOContext_t *) ioContext; 1666 satIntIo = satIOContext->satIntIoContext; 1667 oneDeviceData = satIOContext->pSatDevData; 1668 hostToDevFis = satIOContext->pFis; 1669 smRoot = oneDeviceData->smRoot; 1670 smIntRoot = (smIntRoot_t *)smRoot->smData; 1671 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 1672 1673 if (satIntIo == agNULL) 1674 { 1675 SM_DBG4(("smsatChainedVerifyCB: External smSatInternalIo_t satIntIoContext\n")); 1676 satOrgIOContext = satIOContext; 1677 smOrgIORequest = smIORequestBody->smIORequest; 1678 pSense = satIOContext->pSense; 1679 scsiCmnd = satIOContext->pScsiCmnd; 1680 } 1681 else 1682 { 1683 SM_DBG4(("smsatChainedVerifyCB: Internal smSatInternalIo_t satIntIoContext\n")); 1684 satOrgIOContext = satIOContext->satOrgIOContext; 1685 if (satOrgIOContext == agNULL) 1686 { 1687 SM_DBG4(("smsatChainedVerifyCB: satOrgIOContext is NULL, wrong\n")); 1688 return; 1689 } 1690 else 1691 { 1692 SM_DBG4(("smsatChainedVerifyCB: satOrgIOContext is NOT NULL\n")); 1693 } 1694 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 1695 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 1696 pSense = satOrgIOContext->pSense; 1697 scsiCmnd = satOrgIOContext->pScsiCmnd; 1698 } 1699 1700 smIORequestBody->ioCompleted = agTRUE; 1701 smIORequestBody->ioStarted = agFALSE; 1702 1703 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 1704 { 1705 SM_DBG1(("smsatChainedVerifyCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 1706 smsatSetSensePayload( pSense, 1707 SCSI_SNSKEY_NO_SENSE, 1708 0, 1709 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1710 satOrgIOContext); 1711 1712 tdsmIOCompletedCB( smRoot, 1713 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1714 smIOSuccess, 1715 SCSI_STAT_CHECK_CONDITION, 1716 satOrgIOContext->pSmSenseData, 1717 satOrgIOContext->interruptContext ); 1718 1719 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1720 1721 smsatFreeIntIoResource( smRoot, 1722 oneDeviceData, 1723 satIntIo); 1724 return; 1725 } 1726 1727 if (agIOStatus != OSSA_IO_SUCCESS) 1728 { 1729 /* only agsaFisRegDeviceToHost_t is expected */ 1730 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 1731 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 1732 } 1733 1734 if( agIOStatus != OSSA_IO_SUCCESS) 1735 { 1736 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 1737 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 1738 ) 1739 { 1740 /* for debugging */ 1741 if( agIOStatus != OSSA_IO_SUCCESS) 1742 { 1743 SM_DBG1(("smsatChainedVerifyCB: FAILED, NOT IO_SUCCESS!!!\n")); 1744 } 1745 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 1746 { 1747 SM_DBG1(("smsatChainedVerifyCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 1748 } 1749 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 1750 (ataStatus & DF_ATA_STATUS_MASK) 1751 ) 1752 { 1753 SM_DBG1(("smsatChainedVerifyCB: FAILED, FAILED, error status!!!\n")); 1754 } 1755 1756 /* Process abort case */ 1757 if (agIOStatus == OSSA_IO_ABORTED) 1758 { 1759 smsatProcessAbort(smRoot, 1760 smOrgIORequest, 1761 satOrgIOContext 1762 ); 1763 1764 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1765 1766 smsatFreeIntIoResource( smRoot, 1767 oneDeviceData, 1768 satIntIo); 1769 return; 1770 } 1771 1772 /* for debugging */ 1773 switch (hostToDevFis->h.command) 1774 { 1775 case SAT_READ_VERIFY_SECTORS: 1776 SM_DBG1(("smsatChainedVerifyCB: SAT_READ_VERIFY_SECTORS!!!\n")); 1777 break; 1778 case SAT_READ_VERIFY_SECTORS_EXT: 1779 SM_DBG1(("smsatChainedVerifyCB: SAT_READ_VERIFY_SECTORS_EXT!!!\n")); 1780 break; 1781 default: 1782 SM_DBG1(("smsatChainedVerifyCB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 1783 break; 1784 } 1785 1786 smsatSetSensePayload( pSense, 1787 SCSI_SNSKEY_NO_SENSE, 1788 0, 1789 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1790 satOrgIOContext); 1791 1792 tdsmIOCompletedCB( smRoot, 1793 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1794 smIOSuccess, 1795 SCSI_STAT_CHECK_CONDITION, 1796 satOrgIOContext->pSmSenseData, 1797 satOrgIOContext->interruptContext ); 1798 1799 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1800 1801 smsatFreeIntIoResource( smRoot, 1802 oneDeviceData, 1803 satIntIo); 1804 return; 1805 } /* end error checking */ 1806 } 1807 1808 /* process success from this point on */ 1809 switch (hostToDevFis->h.command) 1810 { 1811 case SAT_READ_VERIFY_SECTORS: /* fall through */ 1812 case SAT_READ_VERIFY_SECTORS_EXT: 1813 SM_DBG5(("smsatChainedVerifyCB: SAT_WRITE_DMA_EXT success \n")); 1814 1815 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1816 1817 smsatFreeIntIoResource( smRoot, 1818 oneDeviceData, 1819 satIntIo); 1820 1821 /* let's loop till TL */ 1822 1823 /* lba = lba + tl 1824 loopnum--; 1825 if (loopnum == 0) done 1826 */ 1827 (satOrgIOContext->LoopNum)--; 1828 if (satOrgIOContext->LoopNum == 0) 1829 { 1830 /* 1831 done with write and verify 1832 */ 1833 tdsmIOCompletedCB( smRoot, 1834 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1835 smIOSuccess, 1836 SCSI_STAT_GOOD, 1837 agNULL, 1838 satOrgIOContext->interruptContext ); 1839 return; 1840 } 1841 1842 if (satOrgIOContext->superIOFlag) 1843 { 1844 dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 1845 } 1846 else 1847 { 1848 dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 1849 } 1850 1851 satNewIntIo = smsatAllocIntIoResource( smRoot, 1852 smOrgIORequest, 1853 oneDeviceData, 1854 dataLength, 1855 satNewIntIo); 1856 if (satNewIntIo == agNULL) 1857 { 1858 tdsmIOCompletedCB( smRoot, 1859 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1860 smIOFailed, 1861 smDetailOtherError, 1862 agNULL, 1863 satOrgIOContext->interruptContext ); 1864 1865 SM_DBG1(("smsatChainedVerifyCB: momory allocation fails!!!\n")); 1866 return; 1867 } /* end of memory allocation failure */ 1868 1869 /* 1870 * Need to initialize all the fields within satIOContext 1871 */ 1872 1873 satNewIOContext = smsatPrepareNewIO( 1874 satNewIntIo, 1875 smOrgIORequest, 1876 oneDeviceData, 1877 scsiCmnd, 1878 satOrgIOContext 1879 ); 1880 status = smsatChainedVerify(smRoot, 1881 &satNewIntIo->satIntSmIORequest, 1882 satNewIOContext->psmDeviceHandle, 1883 &satNewIntIo->satIntSmScsiXchg, 1884 satNewIOContext); 1885 1886 if (status != SM_RC_SUCCESS) 1887 { 1888 smsatFreeIntIoResource( smRoot, 1889 oneDeviceData, 1890 satNewIntIo); 1891 tdsmIOCompletedCB( smRoot, 1892 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1893 smIOFailed, 1894 smDetailOtherError, 1895 agNULL, 1896 satOrgIOContext->interruptContext ); 1897 SM_DBG1(("smsatChainedVerifyCB: calling satChainedVerify fails!!!\n")); 1898 return; 1899 } 1900 1901 break; 1902 default: 1903 SM_DBG1(("smsatChainedVerifyCB: success but error default case command 0x%x!!!\n", hostToDevFis->h.command)); 1904 1905 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 1906 1907 smsatFreeIntIoResource( smRoot, 1908 oneDeviceData, 1909 satIntIo); 1910 1911 smsatSetSensePayload( pSense, 1912 SCSI_SNSKEY_NO_SENSE, 1913 0, 1914 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1915 satOrgIOContext); 1916 1917 tdsmIOCompletedCB( smRoot, 1918 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 1919 smIOSuccess, 1920 SCSI_STAT_CHECK_CONDITION, 1921 satOrgIOContext->pSmSenseData, 1922 satOrgIOContext->interruptContext ); 1923 1924 break; 1925 } 1926 return; 1927 } 1928 1929 1930 osGLOBAL void 1931 smsatTestUnitReadyCB( 1932 agsaRoot_t *agRoot, 1933 agsaIORequest_t *agIORequest, 1934 bit32 agIOStatus, 1935 agsaFisHeader_t *agFirstDword, 1936 bit32 agIOInfoLen, 1937 agsaFrameHandle_t agFrameHandle, 1938 void *ioContext 1939 ) 1940 { 1941 /* 1942 In the process of TestUnitReady 1943 Process SAT_GET_MEDIA_STATUS 1944 Process SAT_CHECK_POWER_MODE 1945 */ 1946 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 1947 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 1948 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 1949 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 1950 smRoot_t *smRoot = agNULL; 1951 smIntRoot_t *smIntRoot = agNULL; 1952 smIntContext_t *smAllShared = agNULL; 1953 smIORequestBody_t *smIORequestBody; 1954 smIORequestBody_t *smOrgIORequestBody; 1955 smSatIOContext_t *satIOContext; 1956 smSatIOContext_t *satOrgIOContext; 1957 smSatIOContext_t *satNewIOContext; 1958 smSatInternalIo_t *satIntIo; 1959 smSatInternalIo_t *satNewIntIo = agNULL; 1960 // satDeviceData_t *satDevData; 1961 smDeviceData_t *oneDeviceData; 1962 1963 smScsiRspSense_t *pSense; 1964 smIniScsiCmnd_t *scsiCmnd; 1965 smIORequest_t *smOrgIORequest; 1966 1967 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 1968 bit32 ataStatus = 0; 1969 bit32 ataError; 1970 1971 bit32 status; 1972 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 1973 1974 SM_DBG2(("smsatTestUnitReadyCB: start\n")); 1975 SM_DBG6(("smsatTestUnitReadyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 1976 1977 /* internally generate smIOContext */ 1978 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 1979 satIOContext = (smSatIOContext_t *) ioContext; 1980 satIntIo = satIOContext->satIntIoContext; 1981 oneDeviceData = satIOContext->pSatDevData; 1982 hostToDevFis = satIOContext->pFis; 1983 smRoot = oneDeviceData->smRoot; 1984 smIntRoot = (smIntRoot_t *)smRoot->smData; 1985 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 1986 1987 if (satIntIo == agNULL) 1988 { 1989 SM_DBG5(("smsatTestUnitReadyCB: no internal smSatInternalIo_t satIntIoContext\n")); 1990 pSense = satIOContext->pSense; 1991 scsiCmnd = satIOContext->pScsiCmnd; 1992 satOrgIOContext = satIOContext; 1993 smOrgIORequest = smIORequestBody->smIORequest; 1994 } 1995 else 1996 { 1997 SM_DBG5(("smsatTestUnitReadyCB: yes internal smSatInternalIo_t satIntIoContext\n")); 1998 1999 /* orginal smIOContext */ 2000 smOrgIORequest = (smIORequest_t *)satIOContext->satIntIoContext->satOrgSmIORequest; 2001 smOrgIORequestBody = (smIORequestBody_t *)smOrgIORequest->tdData; 2002 satOrgIOContext = &(smOrgIORequestBody->transport.SATA.satIOContext); 2003 2004 pSense = satOrgIOContext->pSense; 2005 scsiCmnd = satOrgIOContext->pScsiCmnd; 2006 } 2007 2008 smIORequestBody->ioCompleted = agTRUE; 2009 smIORequestBody->ioStarted = agFALSE; 2010 2011 if (agIOStatus == OSSA_IO_ABORTED) 2012 { 2013 tdsmIOCompletedCB( smRoot, 2014 smOrgIORequest, 2015 smIOFailed, 2016 smDetailAborted, 2017 agNULL, 2018 satIOContext->interruptContext); 2019 2020 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2021 2022 smsatFreeIntIoResource( smRoot, 2023 oneDeviceData, 2024 satIntIo); 2025 2026 return; 2027 } 2028 2029 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 2030 { 2031 SM_DBG1(("smsatTestUnitReadyCB: agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 2032 smsatSetSensePayload( pSense, 2033 SCSI_SNSKEY_NOT_READY, 2034 0, 2035 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 2036 satOrgIOContext); 2037 2038 tdsmIOCompletedCB( smRoot, 2039 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2040 smIOSuccess, 2041 SCSI_STAT_CHECK_CONDITION, 2042 satOrgIOContext->pSmSenseData, 2043 satOrgIOContext->interruptContext ); 2044 2045 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2046 2047 smsatFreeIntIoResource( smRoot, 2048 oneDeviceData, 2049 satIntIo); 2050 2051 return; 2052 } 2053 /* 2054 HW checks an error for us and the results is agIOStatus 2055 */ 2056 if (agIOStatus != OSSA_IO_SUCCESS) 2057 { 2058 /* only agsaFisRegDeviceToHost_t is expected */ 2059 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 2060 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 2061 ataError = statDevToHostFisHeader->error; /* ATA Eror register */ 2062 if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 2063 { 2064 SM_DBG1(("smsatTestUnitReadyCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 2065 } 2066 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 2067 (ataStatus & DF_ATA_STATUS_MASK) 2068 ) 2069 { 2070 SM_DBG1(("smsatTestUnitReadyCB: FAILED, FAILED, error status!!!\n")); 2071 } 2072 2073 /* Process abort case */ 2074 if (agIOStatus == OSSA_IO_ABORTED) 2075 { 2076 smsatProcessAbort(smRoot, 2077 smOrgIORequest, 2078 satOrgIOContext 2079 ); 2080 2081 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2082 2083 smsatFreeIntIoResource( smRoot, 2084 oneDeviceData, 2085 satIntIo); 2086 return; 2087 } 2088 2089 switch (hostToDevFis->h.command) 2090 { 2091 case SAT_GET_MEDIA_STATUS: 2092 SM_DBG1(("smsatTestUnitReadyCB: SAT_GET_MEDIA_STATUS failed!!! \n")); 2093 2094 /* checking NM bit */ 2095 if (ataError & SCSI_NM_MASK) 2096 { 2097 smsatSetSensePayload( pSense, 2098 SCSI_SNSKEY_NOT_READY, 2099 0, 2100 SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 2101 satOrgIOContext); 2102 } 2103 else 2104 { 2105 smsatSetSensePayload( pSense, 2106 SCSI_SNSKEY_NOT_READY, 2107 0, 2108 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 2109 satOrgIOContext); 2110 } 2111 2112 tdsmIOCompletedCB( smRoot, 2113 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2114 smIOSuccess, 2115 SCSI_STAT_CHECK_CONDITION, 2116 satOrgIOContext->pSmSenseData, 2117 satOrgIOContext->interruptContext ); 2118 2119 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2120 2121 smsatFreeIntIoResource( smRoot, 2122 oneDeviceData, 2123 satIntIo); 2124 break; 2125 case SAT_CHECK_POWER_MODE: 2126 SM_DBG1(("smsatTestUnitReadyCB: SAT_CHECK_POWER_MODE failed!!! \n")); 2127 smsatSetSensePayload( pSense, 2128 SCSI_SNSKEY_NOT_READY, 2129 0, 2130 SCSI_SNSCODE_LOGICAL_UNIT_DOES_NOT_RESPOND_TO_SELECTION, 2131 satOrgIOContext); 2132 2133 tdsmIOCompletedCB( smRoot, 2134 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2135 smIOSuccess, 2136 SCSI_STAT_CHECK_CONDITION, 2137 satOrgIOContext->pSmSenseData, 2138 satOrgIOContext->interruptContext ); 2139 2140 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2141 2142 smsatFreeIntIoResource( smRoot, 2143 oneDeviceData, 2144 satIntIo); 2145 break; 2146 default: 2147 SM_DBG1(("smsatTestUnitReadyCB: default failed command %d!!!\n", hostToDevFis->h.command)); 2148 2149 smsatSetSensePayload( pSense, 2150 SCSI_SNSKEY_NOT_READY, 2151 0, 2152 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 2153 satOrgIOContext); 2154 2155 tdsmIOCompletedCB( smRoot, 2156 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2157 smIOSuccess, 2158 SCSI_STAT_CHECK_CONDITION, 2159 satOrgIOContext->pSmSenseData, 2160 satOrgIOContext->interruptContext ); 2161 2162 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2163 2164 smsatFreeIntIoResource( smRoot, 2165 oneDeviceData, 2166 satIntIo); 2167 break; 2168 2169 } 2170 return; 2171 }/* end error */ 2172 2173 /* ATA command completes sucessfully */ 2174 switch (hostToDevFis->h.command) 2175 { 2176 case SAT_GET_MEDIA_STATUS: 2177 2178 SM_DBG5(("smsatTestUnitReadyCB: SAT_GET_MEDIA_STATUS success\n")); 2179 2180 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2181 2182 smsatFreeIntIoResource( smRoot, 2183 oneDeviceData, 2184 satIntIo); 2185 2186 satNewIntIo = smsatAllocIntIoResource( smRoot, 2187 smOrgIORequest, 2188 oneDeviceData, 2189 0, 2190 satNewIntIo); 2191 if (satNewIntIo == agNULL) 2192 { 2193 smsatSetSensePayload( pSense, 2194 SCSI_SNSKEY_NOT_READY, 2195 0, 2196 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 2197 satOrgIOContext); 2198 2199 tdsmIOCompletedCB( smRoot, 2200 smOrgIORequest, 2201 smIOSuccess, 2202 SCSI_STAT_CHECK_CONDITION, 2203 satOrgIOContext->pSmSenseData, 2204 satOrgIOContext->interruptContext ); 2205 2206 SM_DBG1(("smsatTestUnitReadyCB: momory allocation fails!!!\n")); 2207 return; 2208 } 2209 2210 /* 2211 * Need to initialize all the fields within satIOContext 2212 */ 2213 2214 satNewIOContext = smsatPrepareNewIO( 2215 satNewIntIo, 2216 smOrgIORequest, 2217 oneDeviceData, 2218 scsiCmnd, 2219 satOrgIOContext 2220 ); 2221 2222 /* sends SAT_CHECK_POWER_MODE */ 2223 status = smsatTestUnitReady_1( smRoot, 2224 &satNewIntIo->satIntSmIORequest, 2225 satNewIOContext->psmDeviceHandle, 2226 &satNewIntIo->satIntSmScsiXchg, 2227 satNewIOContext); 2228 2229 if (status != SM_RC_SUCCESS) 2230 { 2231 /* sending SAT_CHECK_POWER_MODE fails */ 2232 smsatFreeIntIoResource( smRoot, 2233 oneDeviceData, 2234 satNewIntIo); 2235 smsatSetSensePayload( pSense, 2236 SCSI_SNSKEY_NOT_READY, 2237 0, 2238 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 2239 satOrgIOContext); 2240 2241 tdsmIOCompletedCB( smRoot, 2242 smOrgIORequest, 2243 smIOSuccess, 2244 SCSI_STAT_CHECK_CONDITION, 2245 satOrgIOContext->pSmSenseData, 2246 satOrgIOContext->interruptContext ); 2247 2248 SM_DBG1(("smsatTestUnitReadyCB: calling satTestUnitReady_1 fails!!!\n")); 2249 return; 2250 } 2251 2252 break; 2253 case SAT_CHECK_POWER_MODE: 2254 SM_DBG5(("smsatTestUnitReadyCB: SAT_CHECK_POWER_MODE success\n")); 2255 2256 2257 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2258 2259 smsatFreeIntIoResource( smRoot, 2260 oneDeviceData, 2261 satIntIo); 2262 2263 /* returns good status */ 2264 tdsmIOCompletedCB( smRoot, 2265 smOrgIORequest, 2266 smIOSuccess, 2267 SCSI_STAT_GOOD, 2268 agNULL, 2269 satOrgIOContext->interruptContext ); 2270 2271 break; 2272 default: 2273 SM_DBG1(("smsatTestUnitReadyCB: default success command %d!!!\n", hostToDevFis->h.command)); 2274 smsatSetSensePayload( pSense, 2275 SCSI_SNSKEY_NOT_READY, 2276 0, 2277 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 2278 satOrgIOContext); 2279 2280 tdsmIOCompletedCB( smRoot, 2281 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2282 smIOSuccess, 2283 SCSI_STAT_CHECK_CONDITION, 2284 satOrgIOContext->pSmSenseData, 2285 satOrgIOContext->interruptContext ); 2286 2287 2288 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2289 2290 smsatFreeIntIoResource( smRoot, 2291 oneDeviceData, 2292 satIntIo); 2293 break; 2294 } 2295 2296 return; 2297 } 2298 2299 osGLOBAL void 2300 smsatRequestSenseCB( 2301 agsaRoot_t *agRoot, 2302 agsaIORequest_t *agIORequest, 2303 bit32 agIOStatus, 2304 agsaFisHeader_t *agFirstDword, 2305 bit32 agIOInfoLen, 2306 void *agParam, 2307 void *ioContext 2308 ) 2309 { 2310 /* ATA Vol 1, p299 SAT_SMART_RETURN_STATUS */ 2311 /* 2312 if threshold exceeds, return SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE 2313 else call satRequestSense_1 to send CHECK_POWER_MODE 2314 */ 2315 2316 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 2317 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 2318 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 2319 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 2320 smRoot_t *smRoot = agNULL; 2321 smIntRoot_t *smIntRoot = agNULL; 2322 smIntContext_t *smAllShared = agNULL; 2323 smIORequestBody_t *smIORequestBody; 2324 smIORequestBody_t *smOrgIORequestBody; 2325 smSatIOContext_t *satIOContext; 2326 smSatIOContext_t *satOrgIOContext; 2327 smSatIOContext_t *satNewIOContext; 2328 smSatInternalIo_t *satIntIo; 2329 smSatInternalIo_t *satNewIntIo = agNULL; 2330 // satDeviceData_t *satDevData; 2331 smDeviceData_t *oneDeviceData; 2332 smScsiRspSense_t *pSense; 2333 smIniScsiCmnd_t *scsiCmnd; 2334 smIORequest_t *smOrgIORequest; 2335 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 2336 bit32 ataStatus = 0; 2337 bit32 status; 2338 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 2339 agsaFisRegD2HData_t statDevToHostFisData; 2340 bit32 allocationLen = 0; 2341 bit32 dataLength; 2342 bit8 *pDataBuffer = agNULL; 2343 2344 SM_DBG2(("smsatRequestSenseCB: start\n")); 2345 SM_DBG4(("smsatRequestSenseCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 2346 2347 /* internally generate smIOContext */ 2348 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 2349 satIOContext = (smSatIOContext_t *) ioContext; 2350 satIntIo = satIOContext->satIntIoContext; 2351 oneDeviceData = satIOContext->pSatDevData; 2352 hostToDevFis = satIOContext->pFis; 2353 smRoot = oneDeviceData->smRoot; 2354 smIntRoot = (smIntRoot_t *)smRoot->smData; 2355 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 2356 2357 /*ttttttthe one */ 2358 if (satIntIo == agNULL) 2359 { 2360 SM_DBG4(("smsatRequestSenseCB: External smSatInternalIo_t satIntIoContext\n")); 2361 satOrgIOContext = satIOContext; 2362 smOrgIORequest = smIORequestBody->smIORequest; 2363 if (satOrgIOContext->superIOFlag) 2364 { 2365 pDataBuffer = (bit8 *)(((tiSuperScsiInitiatorRequest_t *)satOrgIOContext->smScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 2366 } 2367 else 2368 { 2369 pDataBuffer = (bit8 *)(((tiScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 2370 2371 } 2372 scsiCmnd = satOrgIOContext->pScsiCmnd; 2373 pSense = satOrgIOContext->pSense; 2374 } 2375 else 2376 { 2377 SM_DBG4(("smsatRequestSenseCB: Internal smSatInternalIo_t satIntIoContext\n")); 2378 satOrgIOContext = satIOContext->satOrgIOContext; 2379 if (satOrgIOContext == agNULL) 2380 { 2381 SM_DBG4(("smsatRequestSenseCB: satOrgIOContext is NULL, wrong\n")); 2382 return; 2383 } 2384 else 2385 { 2386 SM_DBG4(("smsatRequestSenseCB: satOrgIOContext is NOT NULL\n")); 2387 } 2388 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 2389 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 2390 2391 if (satOrgIOContext->superIOFlag) 2392 { 2393 pDataBuffer = (bit8 *)(((tiSuperScsiInitiatorRequest_t *)satOrgIOContext->smScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 2394 } 2395 else 2396 { 2397 pDataBuffer = (bit8 *)(((tiScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 2398 2399 } 2400 scsiCmnd = satOrgIOContext->pScsiCmnd; 2401 pSense = satOrgIOContext->pSense; 2402 } 2403 2404 smIORequestBody->ioCompleted = agTRUE; 2405 smIORequestBody->ioStarted = agFALSE; 2406 2407 SM_DBG4(("smsatRequestSenseCB: fis command 0x%x\n", hostToDevFis->h.command)); 2408 2409 allocationLen = scsiCmnd->cdb[4]; 2410 allocationLen = MIN(allocationLen, scsiCmnd->expDataLength); 2411 SM_DBG1(("smsatRequestSenseCB: allocationLen in CDB %d 0x%x!!!\n", allocationLen,allocationLen)); 2412 2413 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 2414 { 2415 SM_DBG1(("smsatRequestSenseCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 2416 tdsmIOCompletedCB( 2417 smRoot, 2418 smOrgIORequest, 2419 smIOFailed, 2420 smDetailOtherError, 2421 agNULL, 2422 satOrgIOContext->interruptContext 2423 ); 2424 2425 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2426 2427 smsatFreeIntIoResource( smRoot, 2428 oneDeviceData, 2429 satIntIo); 2430 2431 return; 2432 } 2433 2434 /* 2435 checking IO status, FIS type and error status 2436 */ 2437 if (agIOStatus != OSSA_IO_SUCCESS) 2438 { 2439 /* only agsaFisRegDeviceToHost_t is expected */ 2440 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 2441 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 2442 2443 /* for debugging */ 2444 if( statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 2445 { 2446 if (hostToDevFis->h.command == SAT_SMART && hostToDevFis->h.features == SAT_SMART_RETURN_STATUS) 2447 { 2448 SM_DBG1(("smsatRequestSenseCB: FAILED, Wrong FIS type 0x%x and SAT_SMART_RETURN_STATU!!!\n", statDevToHostFisHeader->fisType)); 2449 } 2450 else 2451 { 2452 SM_DBG1(("smsatRequestSenseCB: FAILED, Wrong FIS type 0x%x and SAT_CHECK_POWER_MODE!!!\n",statDevToHostFisHeader->fisType)); 2453 } 2454 } 2455 2456 /* for debugging */ 2457 if ( (ataStatus & ERR_ATA_STATUS_MASK) || 2458 (ataStatus & DF_ATA_STATUS_MASK) 2459 ) 2460 { 2461 if (hostToDevFis->h.command == SAT_SMART && hostToDevFis->h.features == SAT_SMART_RETURN_STATUS) 2462 { 2463 SM_DBG1(("smsatRequestSenseCB: FAILED, error status and SAT_SMART_RETURN_STATU!!!\n")); 2464 } 2465 else 2466 { 2467 SM_DBG1(("smsatRequestSenseCB: FAILED, error status and SAT_CHECK_POWER_MODE!!!\n")); 2468 } 2469 } 2470 2471 /* Process abort case */ 2472 if (agIOStatus == OSSA_IO_ABORTED) 2473 { 2474 smsatProcessAbort(smRoot, 2475 smOrgIORequest, 2476 satOrgIOContext 2477 ); 2478 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2479 2480 smsatFreeIntIoResource( smRoot, 2481 oneDeviceData, 2482 satIntIo); 2483 return; 2484 } 2485 if (hostToDevFis->h.command == SAT_SMART && hostToDevFis->h.features == SAT_SMART_RETURN_STATUS) 2486 { 2487 /* report using the original tiIOrequst */ 2488 /* failed during sending SMART RETURN STATUS */ 2489 smsatSetSensePayload( pSense, 2490 SCSI_SNSKEY_NO_SENSE, 2491 0, 2492 SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE, 2493 satOrgIOContext); 2494 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2495 if (SENSE_DATA_LENGTH < allocationLen) 2496 { 2497 /* underrun */ 2498 tdsmIOCompletedCB( smRoot, 2499 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 2500 smIOUnderRun, 2501 allocationLen - SENSE_DATA_LENGTH, 2502 agNULL, 2503 satOrgIOContext->interruptContext ); 2504 } 2505 else 2506 { 2507 tdsmIOCompletedCB( smRoot, 2508 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 2509 smIOSuccess, 2510 SCSI_STAT_GOOD, 2511 agNULL, 2512 satOrgIOContext->interruptContext ); 2513 } 2514 } 2515 else 2516 { 2517 /* report using the original tiIOrequst */ 2518 /* failed during sending SAT_CHECK_POWER_MODE */ 2519 smsatSetSensePayload( pSense, 2520 SCSI_SNSKEY_NO_SENSE, 2521 0, 2522 SCSI_SNSCODE_LOW_POWER_CONDITION_ON, 2523 satOrgIOContext); 2524 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2525 2526 if (SENSE_DATA_LENGTH < allocationLen) 2527 { 2528 /* underrun */ 2529 tdsmIOCompletedCB( smRoot, 2530 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 2531 smIOUnderRun, 2532 allocationLen - SENSE_DATA_LENGTH, 2533 agNULL, 2534 satOrgIOContext->interruptContext ); 2535 } 2536 else 2537 { 2538 tdsmIOCompletedCB( smRoot, 2539 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 2540 smIOSuccess, 2541 SCSI_STAT_GOOD, 2542 agNULL, 2543 satOrgIOContext->interruptContext ); 2544 } 2545 } 2546 2547 2548 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2549 2550 smsatFreeIntIoResource( smRoot, 2551 oneDeviceData, 2552 satIntIo); 2553 return; 2554 } 2555 2556 saFrameReadBlock(agRoot, agParam, 0, &statDevToHostFisData, sizeof(agsaFisRegD2HData_t)); 2557 2558 switch (hostToDevFis->h.command) 2559 { 2560 case SAT_SMART: 2561 SM_DBG4(("smsatRequestSenseCB: SAT_SMART_RETURN_STATUS case\n")); 2562 if (statDevToHostFisData.lbaMid == 0xF4 || statDevToHostFisData.lbaHigh == 0x2C) 2563 { 2564 /* threshold exceeds */ 2565 SM_DBG1(("smsatRequestSenseCB: threshold exceeds!!!\n")); 2566 2567 2568 /* report using the original tiIOrequst */ 2569 /* failed during sending SMART RETURN STATUS */ 2570 smsatSetSensePayload( pSense, 2571 SCSI_SNSKEY_NO_SENSE, 2572 0, 2573 SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE, 2574 satOrgIOContext); 2575 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2576 2577 if (SENSE_DATA_LENGTH < allocationLen) 2578 { 2579 /* underrun */ 2580 tdsmIOCompletedCB( smRoot, 2581 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2582 smIOUnderRun, 2583 allocationLen - SENSE_DATA_LENGTH, 2584 agNULL, 2585 satOrgIOContext->interruptContext ); 2586 } 2587 else 2588 { 2589 tdsmIOCompletedCB( smRoot, 2590 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2591 smIOSuccess, 2592 SCSI_STAT_GOOD, 2593 agNULL, 2594 satOrgIOContext->interruptContext ); 2595 } 2596 2597 2598 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2599 2600 smsatFreeIntIoResource( smRoot, 2601 oneDeviceData, 2602 satIntIo); 2603 return; 2604 } 2605 2606 2607 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2608 2609 /* done with internally genereated SAT_SMART_RETURN_STATUS */ 2610 smsatFreeIntIoResource( smRoot, 2611 oneDeviceData, 2612 satIntIo); 2613 2614 /* at this point, successful SMART_RETURN_STATUS 2615 xmit SAT_CHECK_POWER_MODE 2616 */ 2617 if (satOrgIOContext->superIOFlag) 2618 { 2619 dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 2620 } 2621 else 2622 { 2623 dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 2624 } 2625 2626 satNewIntIo = smsatAllocIntIoResource( smRoot, 2627 smOrgIORequest, 2628 oneDeviceData, 2629 dataLength, 2630 satNewIntIo); 2631 if (satNewIntIo == agNULL) 2632 { 2633 /* failed as a part of sending SMART RETURN STATUS */ 2634 smsatSetSensePayload( pSense, 2635 SCSI_SNSKEY_NO_SENSE, 2636 0, 2637 SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE, 2638 satOrgIOContext); 2639 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2640 2641 if (SENSE_DATA_LENGTH < allocationLen) 2642 { 2643 /* underrun */ 2644 tdsmIOCompletedCB( smRoot, 2645 smOrgIORequest, 2646 smIOUnderRun, 2647 allocationLen - SENSE_DATA_LENGTH, 2648 agNULL, 2649 satOrgIOContext->interruptContext ); 2650 } 2651 else 2652 { 2653 tdsmIOCompletedCB( smRoot, 2654 smOrgIORequest, 2655 smIOSuccess, 2656 SCSI_STAT_GOOD, 2657 agNULL, 2658 satOrgIOContext->interruptContext ); 2659 } 2660 2661 SM_DBG1(("smsatRequestSenseCB: momory allocation fails!!!\n")); 2662 return; 2663 } /* end of memory allocation failure */ 2664 2665 2666 /* 2667 * Need to initialize all the fields within satIOContext 2668 */ 2669 2670 satNewIOContext = smsatPrepareNewIO( 2671 satNewIntIo, 2672 smOrgIORequest, 2673 oneDeviceData, 2674 scsiCmnd, 2675 satOrgIOContext 2676 ); 2677 2678 /* sending SAT_CHECK_POWER_MODE */ 2679 status = smsatRequestSense_1( smRoot, 2680 &satNewIntIo->satIntSmIORequest, 2681 satNewIOContext->psmDeviceHandle, 2682 &satNewIntIo->satIntSmScsiXchg, 2683 satNewIOContext); 2684 2685 if (status != SM_RC_SUCCESS) 2686 { 2687 /* sending SAT_CHECK_POWER_MODE fails */ 2688 smsatFreeIntIoResource( smRoot, 2689 oneDeviceData, 2690 satNewIntIo); 2691 2692 /* failed during sending SAT_CHECK_POWER_MODE */ 2693 smsatSetSensePayload( pSense, 2694 SCSI_SNSKEY_NO_SENSE, 2695 0, 2696 SCSI_SNSCODE_LOW_POWER_CONDITION_ON, 2697 satOrgIOContext); 2698 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2699 2700 if (SENSE_DATA_LENGTH < allocationLen) 2701 { 2702 /* underrun */ 2703 tdsmIOCompletedCB( smRoot, 2704 smOrgIORequest, 2705 smIOUnderRun, 2706 allocationLen - SENSE_DATA_LENGTH, 2707 agNULL, 2708 satOrgIOContext->interruptContext ); 2709 } 2710 else 2711 { 2712 tdsmIOCompletedCB( smRoot, 2713 smOrgIORequest, 2714 smIOSuccess, 2715 SCSI_STAT_GOOD, 2716 agNULL, 2717 satOrgIOContext->interruptContext ); 2718 } 2719 2720 SM_DBG1(("smsatRequestSenseCB: calling satRequestSense_1 fails!!!\n")); 2721 return; 2722 } 2723 2724 break; 2725 case SAT_CHECK_POWER_MODE: 2726 SM_DBG4(("smsatRequestSenseCB: SAT_CHECK_POWER_MODE case\n")); 2727 2728 /* check ATA STANDBY state */ 2729 if (statDevToHostFisData.sectorCount == 0x00) 2730 { 2731 /* in STANDBY */ 2732 SM_DBG1(("smsatRequestSenseCB: in standby!!!\n")); 2733 2734 2735 /* report using the original tiIOrequst */ 2736 /* failed during sending SAT_CHECK_POWER_MODE */ 2737 smsatSetSensePayload( pSense, 2738 SCSI_SNSKEY_NO_SENSE, 2739 0, 2740 SCSI_SNSCODE_LOW_POWER_CONDITION_ON, 2741 satOrgIOContext); 2742 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2743 2744 if (SENSE_DATA_LENGTH < allocationLen) 2745 { 2746 /* underrun */ 2747 tdsmIOCompletedCB( smRoot, 2748 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2749 smIOUnderRun, 2750 allocationLen - SENSE_DATA_LENGTH, 2751 agNULL, 2752 satOrgIOContext->interruptContext ); 2753 } 2754 else 2755 { 2756 tdsmIOCompletedCB( smRoot, 2757 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2758 smIOSuccess, 2759 SCSI_STAT_GOOD, 2760 agNULL, 2761 satOrgIOContext->interruptContext ); 2762 } 2763 2764 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2765 2766 smsatFreeIntIoResource( smRoot, 2767 oneDeviceData, 2768 satIntIo); 2769 return; 2770 } 2771 2772 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2773 2774 /* done with internnaly generated SAT_CHECK_POWER_MODE */ 2775 smsatFreeIntIoResource( smRoot, 2776 oneDeviceData, 2777 satIntIo); 2778 2779 if (oneDeviceData->satFormatState == agTRUE) 2780 { 2781 SM_DBG1(("smsatRequestSenseCB: in format!!!\n")); 2782 2783 2784 /* report using the original tiIOrequst */ 2785 smsatSetSensePayload( pSense, 2786 SCSI_SNSKEY_NOT_READY, 2787 0, 2788 SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS, 2789 satOrgIOContext); 2790 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2791 2792 if (SENSE_DATA_LENGTH < allocationLen) 2793 { 2794 /* underrun */ 2795 tdsmIOCompletedCB( smRoot, 2796 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2797 smIOUnderRun, 2798 allocationLen - SENSE_DATA_LENGTH, 2799 agNULL, 2800 satOrgIOContext->interruptContext ); 2801 } 2802 else 2803 { 2804 tdsmIOCompletedCB( smRoot, 2805 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2806 smIOSuccess, 2807 SCSI_STAT_GOOD, 2808 agNULL, 2809 satOrgIOContext->interruptContext ); 2810 } 2811 2812 return; 2813 } 2814 2815 /* normal: returns good status for requestsense */ 2816 /* report using the original tiIOrequst */ 2817 smsatSetSensePayload( pSense, 2818 SCSI_SNSKEY_NO_SENSE, 2819 0, 2820 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 2821 satOrgIOContext); 2822 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2823 SM_DBG4(("smsatRequestSenseCB: returning good status for requestsense\n")); 2824 if (SENSE_DATA_LENGTH < allocationLen) 2825 { 2826 /* underrun */ 2827 SM_DBG6(("smsatRequestSenseCB reporting underrun lenNeeded=0x%x lenReceived=0x%x smIORequest=%p\n", 2828 SENSE_DATA_LENGTH, allocationLen, smOrgIORequest)); 2829 tdsmIOCompletedCB( smRoot, 2830 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2831 smIOUnderRun, 2832 allocationLen - SENSE_DATA_LENGTH, 2833 agNULL, 2834 satOrgIOContext->interruptContext ); 2835 2836 } 2837 else 2838 { 2839 tdsmIOCompletedCB( smRoot, 2840 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2841 smIOSuccess, 2842 SCSI_STAT_GOOD, 2843 agNULL, 2844 satOrgIOContext->interruptContext ); 2845 } 2846 2847 break; 2848 default: 2849 SM_DBG1(("smsatRequestSenseCB: success but error default case command 0x%x!!!\n", hostToDevFis->h.command)); 2850 /* pSense here is a part of satOrgIOContext */ 2851 pSense = satOrgIOContext->pSmSenseData->senseData; 2852 satOrgIOContext->pSmSenseData->senseLen = SENSE_DATA_LENGTH; 2853 /* unspecified case, return no sense and no addition info */ 2854 smsatSetSensePayload( pSense, 2855 SCSI_SNSKEY_NO_SENSE, 2856 0, 2857 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 2858 satOrgIOContext); 2859 sm_memcpy(pDataBuffer, pSense, MIN(SENSE_DATA_LENGTH, allocationLen)); 2860 2861 tdsmIOCompletedCB( smRoot, 2862 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 2863 smIOSuccess, 2864 SCSI_STAT_CHECK_CONDITION, 2865 satOrgIOContext->pSmSenseData, 2866 satOrgIOContext->interruptContext ); 2867 2868 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2869 2870 smsatFreeIntIoResource( smRoot, 2871 oneDeviceData, 2872 satIntIo); 2873 break; 2874 } /* switch */ 2875 2876 return; 2877 2878 } 2879 2880 osGLOBAL void 2881 smsatSendDiagnosticCB( 2882 agsaRoot_t *agRoot, 2883 agsaIORequest_t *agIORequest, 2884 bit32 agIOStatus, 2885 agsaFisHeader_t *agFirstDword, 2886 bit32 agIOInfoLen, 2887 agsaFrameHandle_t agFrameHandle, 2888 void *ioContext 2889 ) 2890 { 2891 /* 2892 In the process of SendDiagnotic 2893 Process READ VERIFY SECTOR(S) EXT two time 2894 Process SMART ECECUTE OFF-LINE IMMEDIATE 2895 */ 2896 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 2897 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 2898 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 2899 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 2900 smRoot_t *smRoot = agNULL; 2901 smIntRoot_t *smIntRoot = agNULL; 2902 smIntContext_t *smAllShared = agNULL; 2903 smIORequestBody_t *smIORequestBody; 2904 smIORequestBody_t *smOrgIORequestBody; 2905 smSatIOContext_t *satIOContext; 2906 smSatIOContext_t *satOrgIOContext; 2907 smSatIOContext_t *satNewIOContext; 2908 smSatInternalIo_t *satIntIo; 2909 smSatInternalIo_t *satNewIntIo = agNULL; 2910 // satDeviceData_t *satDevData; 2911 smDeviceData_t *oneDeviceData; 2912 smScsiRspSense_t *pSense; 2913 smIniScsiCmnd_t *scsiCmnd; 2914 smIORequest_t *smOrgIORequest; 2915 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 2916 bit32 ataStatus = 0; 2917 2918 bit32 status; 2919 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 2920 2921 SM_DBG2(("smsatSendDiagnosticCB: start\n")); 2922 SM_DBG5(("smsatSendDiagnosticCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 2923 2924 /* internally generate smIOContext */ 2925 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 2926 satIOContext = (smSatIOContext_t *) ioContext; 2927 satIntIo = satIOContext->satIntIoContext; 2928 oneDeviceData = satIOContext->pSatDevData; 2929 hostToDevFis = satIOContext->pFis; 2930 smRoot = oneDeviceData->smRoot; 2931 smIntRoot = (smIntRoot_t *)smRoot->smData; 2932 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 2933 2934 if (satIntIo == agNULL) 2935 { 2936 SM_DBG4(("smsatSendDiagnosticCB: External smSatInternalIo_t satIntIoContext\n")); 2937 satOrgIOContext = satIOContext; 2938 smOrgIORequest = smIORequestBody->smIORequest; 2939 pSense = satOrgIOContext->pSense; 2940 scsiCmnd = satOrgIOContext->pScsiCmnd; 2941 } 2942 else 2943 { 2944 SM_DBG4(("smsatSendDiagnosticCB: Internal smSatInternalIo_t satIntIoContext\n")); 2945 satOrgIOContext = satIOContext->satOrgIOContext; 2946 if (satOrgIOContext == agNULL) 2947 { 2948 SM_DBG4(("smsatSendDiagnosticCB: satOrgIOContext is NULL, wrong\n")); 2949 return; 2950 } 2951 else 2952 { 2953 SM_DBG4(("smsatSendDiagnosticCB: satOrgIOContext is NOT NULL\n")); 2954 } 2955 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 2956 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 2957 pSense = satOrgIOContext->pSense; 2958 scsiCmnd = satOrgIOContext->pScsiCmnd; 2959 } 2960 2961 smIORequestBody->ioCompleted = agTRUE; 2962 smIORequestBody->ioStarted = agFALSE; 2963 2964 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 2965 { 2966 SM_DBG1(("smsatSendDiagnosticCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 2967 oneDeviceData->satVerifyState = 0; 2968 oneDeviceData->satBGPendingDiag = agFALSE; 2969 2970 if (hostToDevFis->d.lbaLow != 0x01 && hostToDevFis->d.lbaLow != 0x02) 2971 { 2972 /* no completion for background send diagnotic. It is done in satSendDiagnostic() */ 2973 tdsmIOCompletedCB( 2974 smRoot, 2975 smOrgIORequest, 2976 smIOFailed, 2977 smDetailOtherError, 2978 agNULL, 2979 satOrgIOContext->interruptContext 2980 ); 2981 } 2982 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 2983 2984 smsatFreeIntIoResource( smRoot, 2985 oneDeviceData, 2986 satIntIo); 2987 return; 2988 2989 } 2990 2991 if (agIOStatus != OSSA_IO_SUCCESS) 2992 { 2993 /* only agsaFisRegDeviceToHost_t is expected */ 2994 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 2995 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 2996 } 2997 2998 SM_DBG5(("smsatSendDiagnosticCB: fis command 0x%x\n", hostToDevFis->h.command)); 2999 3000 if( agIOStatus != OSSA_IO_SUCCESS) 3001 { 3002 /* 3003 checking IO status, FIS type and error status 3004 */ 3005 oneDeviceData->satVerifyState = 0; 3006 oneDeviceData->satBGPendingDiag = agFALSE; 3007 3008 if( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 3009 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 3010 ) 3011 { 3012 3013 /* for debugging */ 3014 if( agIOStatus != OSSA_IO_SUCCESS) 3015 { 3016 if ( hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT ) 3017 { 3018 SM_DBG1(("smsatSendDiagnosticCB: FAILED, NOT IO_SUCCESS and SAT_READ_VERIFY_SECTORS(_EXT)!!!\n")); 3019 } 3020 else 3021 { 3022 SM_DBG1(("smsatSendDiagnosticCB: FAILED, NOT IO_SUCCESS and SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE!!!\n")); 3023 } 3024 } 3025 3026 /* for debugging */ 3027 if( statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 3028 { 3029 if ( hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT ) 3030 { 3031 SM_DBG1(("smsatSendDiagnosticCB: FAILED, Wrong FIS type 0x%x and SAT_READ_VERIFY_SECTORS(_EXT)!!!\n", statDevToHostFisHeader->fisType)); 3032 } 3033 else 3034 { 3035 SM_DBG1(("smsatSendDiagnosticCB: FAILED, Wrong FIS type 0x%x and SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE!!!\n",statDevToHostFisHeader->fisType)); 3036 } 3037 } 3038 3039 /* for debugging */ 3040 if ( (ataStatus & ERR_ATA_STATUS_MASK) || 3041 (ataStatus & DF_ATA_STATUS_MASK) 3042 ) 3043 { 3044 if ( hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT ) 3045 { 3046 SM_DBG1(("smsatSendDiagnosticCB: FAILED, error status and SAT_READ_VERIFY_SECTORS(_EXT)!!!\n")); 3047 } 3048 else 3049 { 3050 SM_DBG1(("smsatSendDiagnosticCB: FAILED, error status and SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE!!!\n")); 3051 } 3052 } 3053 3054 /* Process abort case */ 3055 if (agIOStatus == OSSA_IO_ABORTED) 3056 { 3057 smsatProcessAbort(smRoot, 3058 smOrgIORequest, 3059 satOrgIOContext 3060 ); 3061 3062 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3063 3064 smsatFreeIntIoResource( smRoot, 3065 oneDeviceData, 3066 satIntIo); 3067 return; 3068 } 3069 3070 if ( (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS) || 3071 (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT) ) 3072 { 3073 /* report using the original tiIOrequst */ 3074 /* failed during sending SAT_READ_VERIFY_SECTORS(_EXT) */ 3075 smsatSetSensePayload( pSense, 3076 SCSI_SNSKEY_HARDWARE_ERROR, 3077 0, 3078 SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 3079 satOrgIOContext); 3080 3081 tdsmIOCompletedCB( smRoot, 3082 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3083 smIOSuccess, 3084 SCSI_STAT_CHECK_CONDITION, 3085 satOrgIOContext->pSmSenseData, 3086 satOrgIOContext->interruptContext ); 3087 3088 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3089 3090 smsatFreeIntIoResource( smRoot, 3091 oneDeviceData, 3092 satIntIo); 3093 return; 3094 } 3095 else 3096 { 3097 /* report using the original tiIOrequst */ 3098 /* failed during sending SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE */ 3099 smsatSetSensePayload( pSense, 3100 SCSI_SNSKEY_HARDWARE_ERROR, 3101 0, 3102 SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 3103 satOrgIOContext); 3104 3105 if (hostToDevFis->d.lbaLow != 0x01 && hostToDevFis->d.lbaLow != 0x02) 3106 { 3107 /* no completion for background send diagnotic. It is done in satSendDiagnostic() */ 3108 tdsmIOCompletedCB( smRoot, 3109 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3110 smIOSuccess, 3111 SCSI_STAT_CHECK_CONDITION, 3112 satOrgIOContext->pSmSenseData, 3113 satOrgIOContext->interruptContext ); 3114 3115 } 3116 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3117 3118 smsatFreeIntIoResource( smRoot, 3119 oneDeviceData, 3120 satIntIo); 3121 return; 3122 } 3123 } 3124 } 3125 3126 /* processing success case */ 3127 switch (hostToDevFis->h.command) 3128 { 3129 case SAT_READ_VERIFY_SECTORS: /* fall through */ 3130 case SAT_READ_VERIFY_SECTORS_EXT: 3131 SM_DBG5(("smsatSendDiagnosticCB: SAT_READ_VERIFY_SECTORS(_EXT) case\n")); 3132 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK); 3133 oneDeviceData->satVerifyState++; 3134 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK); 3135 SM_DBG5(("smsatSendDiagnosticCB: satVerifyState %d\n",oneDeviceData->satVerifyState)); 3136 3137 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3138 3139 /* done with internally genereated AT_READ_VERIFY_SECTORS(_EXT) */ 3140 smsatFreeIntIoResource( smRoot, 3141 oneDeviceData, 3142 satIntIo); 3143 3144 if (oneDeviceData->satVerifyState == 3) 3145 { 3146 /* reset satVerifyState */ 3147 oneDeviceData->satVerifyState = 0; 3148 /* return GOOD status */ 3149 SM_DBG5(("smsatSendDiagnosticCB: return GOOD status\n")); 3150 tdsmIOCompletedCB( smRoot, 3151 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 3152 smIOSuccess, 3153 SCSI_STAT_GOOD, 3154 agNULL, 3155 satOrgIOContext->interruptContext ); 3156 return; 3157 } 3158 else 3159 { 3160 /* prepare SAT_READ_VERIFY_SECTORS(_EXT) */ 3161 satNewIntIo = smsatAllocIntIoResource( smRoot, 3162 smOrgIORequest, 3163 oneDeviceData, 3164 0, 3165 satNewIntIo); 3166 if (satNewIntIo == agNULL) 3167 { 3168 /* reset satVerifyState */ 3169 oneDeviceData->satVerifyState = 0; 3170 3171 /* failed as a part of sending SAT_READ_VERIFY_SECTORS(_EXT) */ 3172 smsatSetSensePayload( pSense, 3173 SCSI_SNSKEY_HARDWARE_ERROR, 3174 0, 3175 SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 3176 satOrgIOContext); 3177 3178 tdsmIOCompletedCB( smRoot, 3179 smOrgIORequest, 3180 smIOSuccess, 3181 SCSI_STAT_CHECK_CONDITION, 3182 satOrgIOContext->pSmSenseData, 3183 satOrgIOContext->interruptContext ); 3184 3185 SM_DBG1(("smsatSendDiagnosticCB: momory allocation fails!!!\n")); 3186 return; 3187 } /* end of memory allocation failure */ 3188 3189 /* 3190 * Need to initialize all the fields within satIOContext 3191 */ 3192 3193 satNewIOContext = smsatPrepareNewIO( 3194 satNewIntIo, 3195 smOrgIORequest, 3196 oneDeviceData, 3197 scsiCmnd, 3198 satOrgIOContext 3199 ); 3200 3201 if (oneDeviceData->satVerifyState == 1) 3202 { 3203 /* sending SAT_CHECK_POWER_MODE */ 3204 status = smsatSendDiagnostic_1( smRoot, 3205 &satNewIntIo->satIntSmIORequest, 3206 satNewIOContext->psmDeviceHandle, 3207 &satNewIntIo->satIntSmScsiXchg, 3208 satNewIOContext); 3209 } 3210 else 3211 { 3212 /* oneDeviceData->satVerifyState == 2 */ 3213 status = smsatSendDiagnostic_2( smRoot, 3214 &satNewIntIo->satIntSmIORequest, 3215 satNewIOContext->psmDeviceHandle, 3216 &satNewIntIo->satIntSmScsiXchg, 3217 satNewIOContext); 3218 } 3219 3220 if (status != SM_RC_SUCCESS) 3221 { 3222 /* sending SAT_READ_VERIFY_SECTORS(_EXT) fails */ 3223 smsatFreeIntIoResource( smRoot, 3224 oneDeviceData, 3225 satNewIntIo); 3226 3227 /* failed during sending SAT_READ_VERIFY_SECTORS(_EXT) */ 3228 smsatSetSensePayload( pSense, 3229 SCSI_SNSKEY_HARDWARE_ERROR, 3230 0, 3231 SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 3232 satOrgIOContext); 3233 3234 tdsmIOCompletedCB( smRoot, 3235 smOrgIORequest, 3236 smIOSuccess, 3237 SCSI_STAT_CHECK_CONDITION, 3238 satOrgIOContext->pSmSenseData, 3239 satOrgIOContext->interruptContext ); 3240 3241 /* reset satVerifyState */ 3242 oneDeviceData->satVerifyState = 0; 3243 SM_DBG1(("smsatSendDiagnosticCB: calling satSendDiagnostic_1 or _2 fails!!!\n")); 3244 return; 3245 } 3246 } /* oneDeviceData->satVerifyState == 1 or 2 */ 3247 3248 break; 3249 case SAT_SMART: 3250 if (hostToDevFis->h.features == SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE) 3251 { 3252 SM_DBG5(("smsatSendDiagnosticCB: SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE case\n")); 3253 3254 oneDeviceData->satBGPendingDiag = agFALSE; 3255 3256 if (hostToDevFis->d.lbaLow == 0x01 || hostToDevFis->d.lbaLow == 0x02) 3257 { 3258 /* for background send diagnostic, no completion here. It is done already. */ 3259 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3260 3261 /* done with AT_SMART_EXEUTE_OFF_LINE_IMMEDIATE */ 3262 smsatFreeIntIoResource( smRoot, 3263 oneDeviceData, 3264 satIntIo); 3265 SM_DBG5(("smsatSendDiagnosticCB: returning but no IOCompleted\n")); 3266 } 3267 else 3268 { 3269 SM_DBG5(("smsatSendDiagnosticCB: returning good status for senddiagnostic\n")); 3270 tdsmIOCompletedCB( smRoot, 3271 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 3272 smIOSuccess, 3273 SCSI_STAT_GOOD, 3274 agNULL, 3275 satOrgIOContext->interruptContext ); 3276 3277 3278 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3279 3280 /* done with AT_SMART_EXEUTE_OFF_LINE_IMMEDIATE */ 3281 smsatFreeIntIoResource( smRoot, 3282 oneDeviceData, 3283 satIntIo); 3284 } 3285 } 3286 break; 3287 default: 3288 SM_DBG1(("smsatSendDiagnosticCB: success but error default case command 0x%x!!!\n", hostToDevFis->h.command)); 3289 /* unspecified case, return no sense and no addition info */ 3290 smsatSetSensePayload( pSense, 3291 SCSI_SNSKEY_NO_SENSE, 3292 0, 3293 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 3294 satOrgIOContext); 3295 3296 tdsmIOCompletedCB( smRoot, 3297 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 3298 smIOSuccess, 3299 SCSI_STAT_CHECK_CONDITION, 3300 satOrgIOContext->pSmSenseData, 3301 satOrgIOContext->interruptContext ); 3302 3303 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3304 3305 smsatFreeIntIoResource( smRoot, 3306 oneDeviceData, 3307 satIntIo); 3308 break; 3309 } 3310 return; 3311 3312 } 3313 3314 osGLOBAL void 3315 smsatStartStopUnitCB( 3316 agsaRoot_t *agRoot, 3317 agsaIORequest_t *agIORequest, 3318 bit32 agIOStatus, 3319 agsaFisHeader_t *agFirstDword, 3320 bit32 agIOInfoLen, 3321 agsaFrameHandle_t agFrameHandle, 3322 void *ioContext 3323 ) 3324 { 3325 /* 3326 In the process of StartStopUnit 3327 Process FLUSH CACHE (EXT) 3328 Process STANDBY 3329 Process READ VERIFY SECTOR(S) EXT 3330 Process MEDIA EJECT 3331 */ 3332 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3333 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3334 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 3335 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 3336 smRoot_t *smRoot = agNULL; 3337 smIntRoot_t *smIntRoot = agNULL; 3338 smIntContext_t *smAllShared = agNULL; 3339 smIORequestBody_t *smIORequestBody; 3340 smIORequestBody_t *smOrgIORequestBody; 3341 smSatIOContext_t *satIOContext; 3342 smSatIOContext_t *satOrgIOContext; 3343 smSatIOContext_t *satNewIOContext; 3344 smSatInternalIo_t *satIntIo; 3345 smSatInternalIo_t *satNewIntIo = agNULL; 3346 // satDeviceData_t *satDevData; 3347 smDeviceData_t *oneDeviceData; 3348 smScsiRspSense_t *pSense; 3349 smIniScsiCmnd_t *scsiCmnd; 3350 smIORequest_t *smOrgIORequest; 3351 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 3352 bit32 ataStatus = 0; 3353 bit32 status; 3354 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 3355 3356 SM_DBG2(("smsatStartStopUnitCB: start\n")); 3357 SM_DBG5(("smsatStartStopUnitCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 3358 3359 /* internally generate smIOContext */ 3360 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 3361 satIOContext = (smSatIOContext_t *) ioContext; 3362 satIntIo = satIOContext->satIntIoContext; 3363 oneDeviceData = satIOContext->pSatDevData; 3364 hostToDevFis = satIOContext->pFis; 3365 smRoot = oneDeviceData->smRoot; 3366 smIntRoot = (smIntRoot_t *)smRoot->smData; 3367 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 3368 if (satIntIo == agNULL) 3369 { 3370 SM_DBG4(("smsatStartStopUnitCB: External smSatInternalIo_t satIntIoContext\n")); 3371 satOrgIOContext = satIOContext; 3372 smOrgIORequest = smIORequestBody->smIORequest; 3373 pSense = satIOContext->pSense; 3374 scsiCmnd = satIOContext->pScsiCmnd; 3375 } 3376 else 3377 { 3378 SM_DBG4(("smsatStartStopUnitCB: Internal smSatInternalIo_t satIntIoContext\n")); 3379 satOrgIOContext = satIOContext->satOrgIOContext; 3380 if (satOrgIOContext == agNULL) 3381 { 3382 SM_DBG4(("smsatStartStopUnitCB: satOrgIOContext is NULL, wrong\n")); 3383 return; 3384 } 3385 else 3386 { 3387 SM_DBG4(("smsatStartStopUnitCB: satOrgIOContext is NOT NULL\n")); 3388 } 3389 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 3390 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 3391 3392 pSense = satOrgIOContext->pSense; 3393 scsiCmnd = satOrgIOContext->pScsiCmnd; 3394 } 3395 3396 smIORequestBody->ioCompleted = agTRUE; 3397 smIORequestBody->ioStarted = agFALSE; 3398 3399 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 3400 { 3401 SM_DBG1(("smsatStartStopUnitCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 3402 3403 /* IMMED == 0 */ 3404 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3405 { 3406 SM_DBG1(("smsatStartStopUnitCB: immed bit 0!!!\n")); 3407 smsatSetSensePayload( pSense, 3408 SCSI_SNSKEY_ABORTED_COMMAND, 3409 0, 3410 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3411 satOrgIOContext); 3412 3413 tdsmIOCompletedCB( smRoot, 3414 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3415 smIOSuccess, 3416 SCSI_STAT_CHECK_CONDITION, 3417 satOrgIOContext->pSmSenseData, 3418 satOrgIOContext->interruptContext ); 3419 3420 3421 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3422 smsatFreeIntIoResource( smRoot, 3423 oneDeviceData, 3424 satIntIo); 3425 } 3426 /* IMMED == 1 */ 3427 if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 3428 { 3429 SM_DBG1(("smsatStartStopUnitCB: immed bit 1!!!\n")); 3430 smsatSetDeferredSensePayload( pSense, 3431 SCSI_SNSKEY_ABORTED_COMMAND, 3432 0, 3433 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3434 satOrgIOContext); 3435 3436 tdsmIOCompletedCB( smRoot, 3437 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3438 smIOSuccess, 3439 SCSI_STAT_CHECK_CONDITION, 3440 satOrgIOContext->pSmSenseData, 3441 satOrgIOContext->interruptContext ); 3442 3443 3444 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3445 smsatFreeIntIoResource( smRoot, 3446 oneDeviceData, 3447 satIntIo); 3448 } 3449 3450 3451 3452 return; 3453 } 3454 3455 if (agIOStatus != OSSA_IO_SUCCESS) 3456 { 3457 /* only agsaFisRegDeviceToHost_t is expected */ 3458 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 3459 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 3460 } 3461 /* 3462 checking IO status, FIS type and error status 3463 */ 3464 if( agIOStatus != OSSA_IO_SUCCESS) 3465 { 3466 if( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 3467 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 3468 ) 3469 { 3470 /* for debugging */ 3471 if( agIOStatus != OSSA_IO_SUCCESS) 3472 { 3473 SM_DBG1(("smsatStartStopUnitCB: FAILED, NOT IO_SUCCESS!!!\n")); 3474 } 3475 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 3476 { 3477 SM_DBG1(("smsatStartStopUnitCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 3478 } 3479 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 3480 (ataStatus & DF_ATA_STATUS_MASK) 3481 ) 3482 { 3483 SM_DBG1(("smsatStartStopUnitCB: FAILED, FAILED, error status!!!\n")); 3484 } 3485 3486 3487 /* Process abort case */ 3488 if (agIOStatus == OSSA_IO_ABORTED) 3489 { 3490 smsatProcessAbort(smRoot, 3491 smOrgIORequest, 3492 satOrgIOContext 3493 ); 3494 3495 3496 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3497 3498 smsatFreeIntIoResource( smRoot, 3499 oneDeviceData, 3500 satIntIo); 3501 return; 3502 } 3503 3504 switch (hostToDevFis->h.command) 3505 { 3506 case SAT_FLUSH_CACHE: /* fall through */ 3507 case SAT_FLUSH_CACHE_EXT: 3508 SM_DBG1(("smsatStartStopUnitCB: SAT_FLUSH_CACHE(_EXT)!!!\n")); 3509 /* check immed bit in scsi command */ 3510 /* IMMED == 0 */ 3511 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3512 { 3513 smsatSetSensePayload( pSense, 3514 SCSI_SNSKEY_ABORTED_COMMAND, 3515 0, 3516 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3517 satOrgIOContext); 3518 3519 tdsmIOCompletedCB( smRoot, 3520 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3521 smIOSuccess, 3522 SCSI_STAT_CHECK_CONDITION, 3523 satOrgIOContext->pSmSenseData, 3524 satOrgIOContext->interruptContext ); 3525 3526 3527 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3528 3529 smsatFreeIntIoResource( smRoot, 3530 oneDeviceData, 3531 satIntIo); 3532 } 3533 /* IMMED == 1 */ 3534 if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 3535 { 3536 smsatSetDeferredSensePayload( pSense, 3537 SCSI_SNSKEY_ABORTED_COMMAND, 3538 0, 3539 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3540 satOrgIOContext); 3541 3542 tdsmIOCompletedCB( smRoot, 3543 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3544 smIOSuccess, 3545 SCSI_STAT_CHECK_CONDITION, 3546 satOrgIOContext->pSmSenseData, 3547 satOrgIOContext->interruptContext ); 3548 3549 3550 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3551 3552 smsatFreeIntIoResource( smRoot, 3553 oneDeviceData, 3554 satIntIo); 3555 } 3556 break; 3557 case SAT_STANDBY: 3558 SM_DBG5(("smsatStartStopUnitCB: SAT_STANDBY\n")); 3559 /* check immed bit in scsi command */ 3560 /* IMMED == 0 */ 3561 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3562 { 3563 smsatSetSensePayload( pSense, 3564 SCSI_SNSKEY_ABORTED_COMMAND, 3565 0, 3566 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3567 satOrgIOContext); 3568 3569 tdsmIOCompletedCB( smRoot, 3570 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3571 smIOSuccess, 3572 SCSI_STAT_CHECK_CONDITION, 3573 satOrgIOContext->pSmSenseData, 3574 satOrgIOContext->interruptContext ); 3575 3576 3577 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3578 3579 smsatFreeIntIoResource( smRoot, 3580 oneDeviceData, 3581 satIntIo); 3582 } 3583 /* IMMED == 1 */ 3584 if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 3585 { 3586 smsatSetDeferredSensePayload( pSense, 3587 SCSI_SNSKEY_ABORTED_COMMAND, 3588 0, 3589 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3590 satOrgIOContext); 3591 3592 tdsmIOCompletedCB( smRoot, 3593 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3594 smIOSuccess, 3595 SCSI_STAT_CHECK_CONDITION, 3596 satOrgIOContext->pSmSenseData, 3597 satOrgIOContext->interruptContext ); 3598 3599 3600 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3601 3602 smsatFreeIntIoResource( smRoot, 3603 oneDeviceData, 3604 satIntIo); 3605 } 3606 break; 3607 case SAT_READ_VERIFY_SECTORS: /* fall through */ 3608 case SAT_READ_VERIFY_SECTORS_EXT: 3609 SM_DBG5(("smsatStartStopUnitCB: SAT_READ_VERIFY_SECTORS(_EXT)\n")); 3610 /* IMMED == 0 */ 3611 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3612 { 3613 smsatSetSensePayload( pSense, 3614 SCSI_SNSKEY_ABORTED_COMMAND, 3615 0, 3616 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3617 satOrgIOContext); 3618 3619 tdsmIOCompletedCB( smRoot, 3620 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3621 smIOSuccess, 3622 SCSI_STAT_CHECK_CONDITION, 3623 satOrgIOContext->pSmSenseData, 3624 satOrgIOContext->interruptContext ); 3625 3626 3627 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3628 3629 smsatFreeIntIoResource( smRoot, 3630 oneDeviceData, 3631 satIntIo); 3632 } 3633 /* IMMED == 1 */ 3634 if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 3635 { 3636 smsatSetDeferredSensePayload( pSense, 3637 SCSI_SNSKEY_ABORTED_COMMAND, 3638 0, 3639 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3640 satOrgIOContext); 3641 3642 tdsmIOCompletedCB( smRoot, 3643 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3644 smIOSuccess, 3645 SCSI_STAT_CHECK_CONDITION, 3646 satOrgIOContext->pSmSenseData, 3647 satOrgIOContext->interruptContext ); 3648 3649 3650 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3651 3652 smsatFreeIntIoResource( smRoot, 3653 oneDeviceData, 3654 satIntIo); 3655 } 3656 break; 3657 case SAT_MEDIA_EJECT: 3658 SM_DBG5(("smsatStartStopUnitCB: SAT_MEDIA_EJECT\n")); 3659 /* IMMED == 0 */ 3660 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3661 { 3662 smsatSetSensePayload( pSense, 3663 SCSI_SNSKEY_ABORTED_COMMAND, 3664 0, 3665 SCSI_SNSCODE_MEDIA_LOAD_OR_EJECT_FAILED, 3666 satOrgIOContext); 3667 3668 tdsmIOCompletedCB( smRoot, 3669 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3670 smIOSuccess, 3671 SCSI_STAT_CHECK_CONDITION, 3672 satOrgIOContext->pSmSenseData, 3673 satOrgIOContext->interruptContext ); 3674 3675 3676 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3677 3678 smsatFreeIntIoResource( smRoot, 3679 oneDeviceData, 3680 satIntIo); 3681 } 3682 /* IMMED == 1 */ 3683 if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 3684 { 3685 smsatSetDeferredSensePayload( pSense, 3686 SCSI_SNSKEY_ABORTED_COMMAND, 3687 0, 3688 SCSI_SNSCODE_MEDIA_LOAD_OR_EJECT_FAILED, 3689 satOrgIOContext); 3690 3691 tdsmIOCompletedCB( smRoot, 3692 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 3693 smIOSuccess, 3694 SCSI_STAT_CHECK_CONDITION, 3695 satOrgIOContext->pSmSenseData, 3696 satOrgIOContext->interruptContext ); 3697 3698 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3699 3700 smsatFreeIntIoResource( smRoot, 3701 oneDeviceData, 3702 satIntIo); 3703 } 3704 break; 3705 default: 3706 /* unspecified case, return no sense and no addition info */ 3707 SM_DBG5(("smsatStartStopUnitCB: default command %d\n", hostToDevFis->h.command)); 3708 smsatSetSensePayload( pSense, 3709 SCSI_SNSKEY_NO_SENSE, 3710 0, 3711 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 3712 satOrgIOContext); 3713 3714 tdsmIOCompletedCB( smRoot, 3715 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 3716 smIOSuccess, 3717 SCSI_STAT_CHECK_CONDITION, 3718 satOrgIOContext->pSmSenseData, 3719 satOrgIOContext->interruptContext ); 3720 3721 3722 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3723 3724 smsatFreeIntIoResource( smRoot, 3725 oneDeviceData, 3726 satIntIo); 3727 break; 3728 } /* switch */ 3729 3730 return; 3731 } /* error check */ 3732 } 3733 3734 /* ATA command completes sucessfully */ 3735 switch (hostToDevFis->h.command) 3736 { 3737 case SAT_FLUSH_CACHE: /* fall through */ 3738 case SAT_FLUSH_CACHE_EXT: 3739 SM_DBG5(("smsatStartStopUnitCB: SAT_READ_VERIFY_SECTORS(_EXT) success case\n")); 3740 3741 3742 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3743 3744 /* done with SAT_FLUSH_CACHE(_EXT) */ 3745 smsatFreeIntIoResource( smRoot, 3746 oneDeviceData, 3747 satIntIo); 3748 3749 /* at this point, successful SAT_READ_VERIFY_SECTORS(_EXT) 3750 send SAT_SATNDBY 3751 */ 3752 satNewIntIo = smsatAllocIntIoResource( smRoot, 3753 smOrgIORequest, 3754 oneDeviceData, 3755 0, 3756 satNewIntIo); 3757 if (satNewIntIo == agNULL) 3758 { 3759 /* IMMED == 0 */ 3760 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3761 { 3762 smsatSetSensePayload( pSense, 3763 SCSI_SNSKEY_ABORTED_COMMAND, 3764 0, 3765 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3766 satOrgIOContext); 3767 } 3768 else /* IMMED == 1 */ 3769 { 3770 smsatSetDeferredSensePayload( pSense, 3771 SCSI_SNSKEY_ABORTED_COMMAND, 3772 0, 3773 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3774 satOrgIOContext); 3775 } 3776 tdsmIOCompletedCB( smRoot, 3777 smOrgIORequest, 3778 smIOSuccess, 3779 SCSI_STAT_CHECK_CONDITION, 3780 satOrgIOContext->pSmSenseData, 3781 satOrgIOContext->interruptContext ); 3782 3783 SM_DBG1(("smsatStartStopUnitCB: momory allocation fails!!!\n")); 3784 return; 3785 } /* end of memory allocation failure */ 3786 3787 /* 3788 * Need to initialize all the fields within satIOContext 3789 */ 3790 3791 satNewIOContext = smsatPrepareNewIO( 3792 satNewIntIo, 3793 smOrgIORequest, 3794 oneDeviceData, 3795 scsiCmnd, 3796 satOrgIOContext 3797 ); 3798 3799 /* sending SAT_STANDBY */ 3800 status = smsatStartStopUnit_1( smRoot, 3801 &satNewIntIo->satIntSmIORequest, 3802 satNewIOContext->psmDeviceHandle, 3803 &satNewIntIo->satIntSmScsiXchg, 3804 satNewIOContext); 3805 3806 if (status != SM_RC_SUCCESS) 3807 { 3808 /* sending SAT_CHECK_POWER_MODE fails */ 3809 smsatFreeIntIoResource( smRoot, 3810 oneDeviceData, 3811 satNewIntIo); 3812 3813 /* IMMED == 0 */ 3814 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3815 { 3816 smsatSetSensePayload( pSense, 3817 SCSI_SNSKEY_ABORTED_COMMAND, 3818 0, 3819 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3820 satOrgIOContext); 3821 } 3822 else /* IMMED == 1 */ 3823 { 3824 smsatSetDeferredSensePayload( pSense, 3825 SCSI_SNSKEY_ABORTED_COMMAND, 3826 0, 3827 SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 3828 satOrgIOContext); 3829 } 3830 tdsmIOCompletedCB( smRoot, 3831 smOrgIORequest, 3832 smIOSuccess, 3833 SCSI_STAT_CHECK_CONDITION, 3834 satOrgIOContext->pSmSenseData, 3835 satOrgIOContext->interruptContext ); 3836 3837 SM_DBG1(("smsatStartStopUnitCB: calling satStartStopUnit_1 fails!!!\n")); 3838 return; 3839 } 3840 break; 3841 case SAT_STANDBY: 3842 SM_DBG5(("smsatStartStopUnitCB: SAT_STANDBY success case\n")); 3843 3844 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3845 3846 /* done with SAT_STANDBY */ 3847 smsatFreeIntIoResource( smRoot, 3848 oneDeviceData, 3849 satIntIo); 3850 /* 3851 if immed == 0, return good status 3852 */ 3853 /* IMMED == 0 */ 3854 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3855 { 3856 tdsmIOCompletedCB( smRoot, 3857 smOrgIORequest, 3858 smIOSuccess, 3859 SCSI_STAT_GOOD, 3860 agNULL, 3861 satOrgIOContext->interruptContext ); 3862 } 3863 oneDeviceData->satStopState = agTRUE; 3864 break; 3865 case SAT_READ_VERIFY_SECTORS: /* fall through */ 3866 case SAT_READ_VERIFY_SECTORS_EXT: 3867 SM_DBG5(("smsatStartStopUnitCB: SAT_READ_VERIFY_SECTORS(_EXT) success case\n")); 3868 3869 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3870 3871 /* done with SAT_READ_VERIFY_SECTORS(_EXT) */ 3872 smsatFreeIntIoResource( smRoot, 3873 oneDeviceData, 3874 satIntIo); 3875 /* 3876 if immed == 0, return good status 3877 */ 3878 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3879 { 3880 tdsmIOCompletedCB( smRoot, 3881 smOrgIORequest, 3882 smIOSuccess, 3883 SCSI_STAT_GOOD, 3884 agNULL, 3885 satOrgIOContext->interruptContext ); 3886 } 3887 /* 3888 if immed == 0, return good status 3889 */ 3890 /* 3891 don't forget to check and set driver state; Active power state 3892 */ 3893 oneDeviceData->satStopState = agFALSE; 3894 break; 3895 case SAT_MEDIA_EJECT: 3896 SM_DBG5(("smsatStartStopUnitCB: SAT_MEDIA_EJECT success case\n")); 3897 3898 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3899 3900 /* done with SAT_READ_VERIFY_SECTORS(_EXT) */ 3901 smsatFreeIntIoResource( smRoot, 3902 oneDeviceData, 3903 satIntIo); 3904 /* 3905 if immed == 0, return good status 3906 */ 3907 if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 3908 { 3909 tdsmIOCompletedCB( smRoot, 3910 smOrgIORequest, 3911 smIOSuccess, 3912 SCSI_STAT_GOOD, 3913 agNULL, 3914 satOrgIOContext->interruptContext ); 3915 } 3916 break; 3917 default: 3918 SM_DBG1(("smsatStartStopUnitCB:success but error default case command 0x%x!!!\n", hostToDevFis->h.command)); 3919 3920 /* unspecified case, return no sense and no addition info */ 3921 smsatSetSensePayload( pSense, 3922 SCSI_SNSKEY_NO_SENSE, 3923 0, 3924 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 3925 satOrgIOContext); 3926 3927 tdsmIOCompletedCB( smRoot, 3928 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 3929 smIOSuccess, 3930 SCSI_STAT_CHECK_CONDITION, 3931 satOrgIOContext->pSmSenseData, 3932 satOrgIOContext->interruptContext ); 3933 3934 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 3935 3936 smsatFreeIntIoResource( smRoot, 3937 oneDeviceData, 3938 satIntIo); 3939 break; 3940 } 3941 return; 3942 3943 } 3944 3945 osGLOBAL void 3946 smsatWriteSame10CB( 3947 agsaRoot_t *agRoot, 3948 agsaIORequest_t *agIORequest, 3949 bit32 agIOStatus, 3950 agsaFisHeader_t *agFirstDword, 3951 bit32 agIOInfoLen, 3952 agsaFrameHandle_t agFrameHandle, 3953 void *ioContext 3954 ) 3955 { 3956 smRoot_t *smRoot = agNULL; 3957 smIntRoot_t *smIntRoot = agNULL; 3958 smIntContext_t *smAllShared = agNULL; 3959 smIORequestBody_t *smIORequestBody; 3960 smIORequestBody_t *smOrgIORequestBody; 3961 smIORequestBody_t *smNewIORequestBody; 3962 smSatIOContext_t *satIOContext; 3963 smSatIOContext_t *satOrgIOContext; 3964 smSatIOContext_t *satNewIOContext; 3965 smSatInternalIo_t *satIntIo; 3966 smSatInternalIo_t *satNewIntIo = agNULL; 3967 smDeviceData_t *oneDeviceData; 3968 smScsiRspSense_t *pSense; 3969 smIniScsiCmnd_t *scsiCmnd; 3970 smIORequest_t *smOrgIORequest; 3971 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 3972 bit32 ataStatus = 0; 3973 bit32 status; 3974 bit32 sectorcount = 0; 3975 bit32 lba = 0, tl = 0; 3976 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 3977 agsaFisSetDevBitsHeader_t *statSetDevBitFisHeader = agNULL; 3978 3979 SM_DBG2(("smsatWriteSame10CB: start\n")); 3980 SM_DBG5(("smsatWriteSame10CB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 3981 3982 /* internally generate smIOContext */ 3983 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 3984 satIOContext = (smSatIOContext_t *) ioContext; 3985 satIntIo = satIOContext->satIntIoContext; 3986 oneDeviceData = satIOContext->pSatDevData; 3987 hostToDevFis = satIOContext->pFis; 3988 smRoot = oneDeviceData->smRoot; 3989 smIntRoot = (smIntRoot_t *)smRoot->smData; 3990 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 3991 3992 if (satIntIo == agNULL) 3993 { 3994 SM_DBG4(("smsatWriteSame10CB: External smSatInternalIo_t satIntIoContext\n")); 3995 satOrgIOContext = satIOContext; 3996 smOrgIORequest = smIORequestBody->smIORequest; 3997 pSense = satIOContext->pSense; 3998 scsiCmnd = satIOContext->pScsiCmnd; 3999 } 4000 else 4001 { 4002 SM_DBG4(("smsatWriteSame10CB: Internal smSatInternalIo_t satIntIoContext\n")); 4003 satOrgIOContext = satIOContext->satOrgIOContext; 4004 if (satOrgIOContext == agNULL) 4005 { 4006 SM_DBG4(("smsatWriteSame10CB: satOrgIOContext is NULL, wrong\n")); 4007 return; 4008 } 4009 else 4010 { 4011 SM_DBG4(("smsatWriteSame10CB: satOrgIOContext is NOT NULL\n")); 4012 } 4013 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 4014 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 4015 4016 pSense = satOrgIOContext->pSense; 4017 scsiCmnd = satOrgIOContext->pScsiCmnd; 4018 } 4019 4020 4021 smIORequestBody->ioCompleted = agTRUE; 4022 smIORequestBody->ioStarted = agFALSE; 4023 4024 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 4025 { 4026 SM_DBG1(("smsatWriteSame10CB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 4027 smsatSetSensePayload( pSense, 4028 SCSI_SNSKEY_NO_SENSE, 4029 0, 4030 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4031 satOrgIOContext); 4032 4033 tdsmIOCompletedCB( smRoot, 4034 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4035 smIOSuccess, 4036 SCSI_STAT_CHECK_CONDITION, 4037 satOrgIOContext->pSmSenseData, 4038 satOrgIOContext->interruptContext ); 4039 4040 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4041 4042 smsatFreeIntIoResource( smRoot, 4043 oneDeviceData, 4044 satIntIo); 4045 return; 4046 } 4047 4048 if (agIOStatus != OSSA_IO_SUCCESS) 4049 { 4050 /* FP, DMA and PIO write */ 4051 /* First, assumed to be Reg Device to Host FIS */ 4052 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 4053 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 4054 } 4055 4056 if (agIOStatus != OSSA_IO_SUCCESS) 4057 { 4058 if (statDevToHostFisHeader->fisType == SET_DEV_BITS_FIS) 4059 { 4060 statSetDevBitFisHeader = (agsaFisSetDevBitsHeader_t *)&(agFirstDword->D2H); 4061 4062 /* Get ATA Status register */ 4063 ataStatus = (statSetDevBitFisHeader->statusHi_Lo & 0x70); /* bits 4,5,6 */ 4064 ataStatus = ataStatus | (statSetDevBitFisHeader->statusHi_Lo & 0x07); /* bits 0,1,2 */ 4065 } 4066 } 4067 4068 if( agIOStatus != OSSA_IO_SUCCESS) 4069 { 4070 /* 4071 checking IO status, FIS type and error status 4072 FIS type should be either REG_DEV_TO_HOST_FIS or SET_DEV_BITS_FIS 4073 */ 4074 if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 4075 (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS)) || 4076 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 4077 ) 4078 { 4079 /* for debugging */ 4080 if( agIOStatus != OSSA_IO_SUCCESS) 4081 { 4082 SM_DBG1(("smsatWriteSame10CB: FAILED, NOT IO_SUCCESS!!!\n")); 4083 } 4084 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 4085 { 4086 SM_DBG1(("smsatWriteSame10CB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 4087 } 4088 else if (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 4089 { 4090 SM_DBG1(("smsatWriteSame10CB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 4091 } 4092 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 4093 (ataStatus & DF_ATA_STATUS_MASK) 4094 ) 4095 { 4096 SM_DBG1(("smsatWriteSame10CB: FAILED, FAILED, error status!!!\n")); 4097 } 4098 4099 /* Process abort case */ 4100 if (agIOStatus == OSSA_IO_ABORTED) 4101 { 4102 smsatProcessAbort(smRoot, 4103 smOrgIORequest, 4104 satOrgIOContext 4105 ); 4106 4107 4108 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4109 4110 smsatFreeIntIoResource( smRoot, 4111 oneDeviceData, 4112 satIntIo); 4113 return; 4114 } 4115 4116 /* for debugging */ 4117 switch (hostToDevFis->h.command) 4118 { 4119 case SAT_WRITE_DMA_EXT: 4120 SM_DBG1(("smsatWriteSame10CB: SAT_WRITE_DMA_EXT!!!\n")); 4121 break; 4122 case SAT_WRITE_SECTORS_EXT: 4123 SM_DBG1(("smsatWriteSame10CB: SAT_WRITE_SECTORS_EXT!!!\n")); 4124 break; 4125 case SAT_WRITE_FPDMA_QUEUED: 4126 SM_DBG1(("smsatWriteSame10CB: SAT_WRITE_FPDMA_QUEUED!!!\n")); 4127 break; 4128 default: 4129 SM_DBG1(("smsatWriteSame10CB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 4130 break; 4131 } 4132 4133 smsatSetSensePayload( pSense, 4134 SCSI_SNSKEY_NO_SENSE, 4135 0, 4136 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4137 satOrgIOContext); 4138 4139 tdsmIOCompletedCB( smRoot, 4140 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4141 smIOSuccess, 4142 SCSI_STAT_CHECK_CONDITION, 4143 satOrgIOContext->pSmSenseData, 4144 satOrgIOContext->interruptContext ); 4145 4146 4147 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4148 4149 smsatFreeIntIoResource( smRoot, 4150 oneDeviceData, 4151 satIntIo); 4152 return; 4153 } /* end error */ 4154 } 4155 4156 /* process success from this point on */ 4157 /* 4158 note: inefficient implementation until a single block can be manipulated 4159 */ 4160 4161 if (hostToDevFis->h.command == SAT_WRITE_DMA_EXT) 4162 { 4163 SM_DBG5(("smsatWriteSame10CB: SAT_WRITE_DMA_EXT success\n")); 4164 } 4165 else if (hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT) 4166 { 4167 SM_DBG5(("smsatWriteSame10CB: SAT_WRITE_SECTORS_EXT success\n")); 4168 } 4169 else if (hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED) 4170 { 4171 SM_DBG5(("smsatWriteSame10CB: SAT_WRITE_FPDMA_QUEUED success\n")); 4172 } 4173 else 4174 { 4175 SM_DBG1(("smsatWriteSame10CB: error case command 0x%x success!!!\n", hostToDevFis->h.command)); 4176 smsatSetSensePayload( pSense, 4177 SCSI_SNSKEY_NO_SENSE, 4178 0, 4179 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4180 satOrgIOContext); 4181 4182 tdsmIOCompletedCB( smRoot, 4183 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4184 smIOSuccess, 4185 SCSI_STAT_CHECK_CONDITION, 4186 satOrgIOContext->pSmSenseData, 4187 satOrgIOContext->interruptContext ); 4188 4189 4190 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4191 4192 smsatFreeIntIoResource( smRoot, 4193 oneDeviceData, 4194 satIntIo); 4195 return; 4196 } 4197 4198 4199 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4200 4201 /* free */ 4202 smsatFreeIntIoResource( smRoot, 4203 oneDeviceData, 4204 satIntIo); 4205 4206 /* 4207 increment LBA by one, keeping the same sector count(1) 4208 sends another ATA command with the changed parameters 4209 */ 4210 4211 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK); 4212 oneDeviceData->satSectorDone++; 4213 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK); 4214 4215 SM_DBG1(("smsatWriteSame10CB: sectordone %d!!!\n", oneDeviceData->satSectorDone)); 4216 4217 lba = (scsiCmnd->cdb[2] << (8*3)) + (scsiCmnd->cdb[3] << (8*2)) 4218 + (scsiCmnd->cdb[4] << 8) + scsiCmnd->cdb[5]; 4219 tl = (scsiCmnd->cdb[7] << 8) + scsiCmnd->cdb[8]; 4220 4221 SM_DBG5(("smsatWriteSame10CB: lba 0x%x tl 0x%x\n", lba, tl)); 4222 4223 if (tl == 0) 4224 { 4225 /* (oneDeviceData->satMaxUserAddrSectors - 1) - lba*/ 4226 sectorcount = (0x0FFFFFFF - 1) - lba; 4227 } 4228 else 4229 { 4230 sectorcount = tl; 4231 } 4232 4233 if (sectorcount <= 0) 4234 { 4235 smsatSetSensePayload( pSense, 4236 SCSI_SNSKEY_NO_SENSE, 4237 0, 4238 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4239 satOrgIOContext); 4240 4241 tdsmIOCompletedCB( smRoot, 4242 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4243 smIOSuccess, 4244 SCSI_STAT_CHECK_CONDITION, 4245 satOrgIOContext->pSmSenseData, 4246 satOrgIOContext->interruptContext ); 4247 SM_DBG1(("smsatWriteSame10CB: incorrect sectorcount 0x%x!!!\n", sectorcount)); 4248 return; 4249 } 4250 4251 if (sectorcount == oneDeviceData->satSectorDone) 4252 { 4253 /* 4254 done with writesame 4255 */ 4256 SM_DBG1(("smsatWriteSame10CB: return writesame done!!!\n")); 4257 oneDeviceData->satSectorDone = 0; 4258 4259 tdsmIOCompletedCB( smRoot, 4260 smOrgIORequest, 4261 smIOSuccess, 4262 SCSI_STAT_GOOD, 4263 agNULL, 4264 satOrgIOContext->interruptContext ); 4265 } 4266 else 4267 { 4268 /* sends another ATA command */ 4269 if (hostToDevFis->h.command == SAT_WRITE_DMA_EXT) 4270 { 4271 SM_DBG1(("smsatWriteSame10CB: sends another SAT_WRITE_DMA_EXT!!!\n")); 4272 } 4273 else if (hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT) 4274 { 4275 SM_DBG1(("smsatWriteSame10CB: sends another SAT_WRITE_SECTORS_EXT!!!\n")); 4276 } 4277 else if (hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED) 4278 { 4279 SM_DBG1(("smsatWriteSame10CB: sends another SAT_WRITE_FPDMA_QUEUED!!!\n")); 4280 } 4281 4282 satNewIntIo = smsatAllocIntIoResource( smRoot, 4283 smOrgIORequest, 4284 oneDeviceData, 4285 0, 4286 satNewIntIo); 4287 if (satNewIntIo == agNULL) 4288 { 4289 smsatSetSensePayload( pSense, 4290 SCSI_SNSKEY_NO_SENSE, 4291 0, 4292 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4293 satOrgIOContext); 4294 4295 tdsmIOCompletedCB( smRoot, 4296 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4297 smIOSuccess, 4298 SCSI_STAT_CHECK_CONDITION, 4299 satOrgIOContext->pSmSenseData, 4300 satOrgIOContext->interruptContext ); 4301 SM_DBG1(("smsatWriteSame10CB: momory allocation fails!!!\n")); 4302 return; 4303 } /* end memory allocation */ 4304 4305 /* the one to be used */ 4306 smNewIORequestBody = satNewIntIo->satIntRequestBody; 4307 satNewIOContext = &smNewIORequestBody->transport.SATA.satIOContext; 4308 4309 satNewIOContext->pSatDevData = oneDeviceData; 4310 satNewIOContext->pFis = &smNewIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev; 4311 satNewIOContext->pScsiCmnd = &satNewIntIo->satIntSmScsiXchg.scsiCmnd; 4312 /* saves scsi command for LBA and number of blocks */ 4313 sm_memcpy(satNewIOContext->pScsiCmnd, scsiCmnd, sizeof(smIniScsiCmnd_t)); 4314 satNewIOContext->pSense = &smNewIORequestBody->transport.SATA.sensePayload; 4315 satNewIOContext->pSmSenseData = &smNewIORequestBody->transport.SATA.smSenseData; 4316 satNewIOContext->pSmSenseData->senseData = satNewIOContext->pSense; 4317 satNewIOContext->smRequestBody = satNewIntIo->satIntRequestBody; 4318 satNewIOContext->interruptContext = satNewIOContext->interruptContext; 4319 satNewIOContext->satIntIoContext = satNewIntIo; 4320 satNewIOContext->psmDeviceHandle = satIOContext->psmDeviceHandle; 4321 /* saves smScsiXchg; only for writesame10() */ 4322 satNewIOContext->smScsiXchg = satOrgIOContext->smScsiXchg; 4323 4324 if (hostToDevFis->h.command == SAT_WRITE_DMA_EXT) 4325 { 4326 status = smsatWriteSame10_1( smRoot, 4327 &satNewIntIo->satIntSmIORequest, 4328 satNewIOContext->psmDeviceHandle, 4329 &satNewIntIo->satIntSmScsiXchg, 4330 satNewIOContext, 4331 lba + oneDeviceData->satSectorDone 4332 ); 4333 } 4334 else if (hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT) 4335 { 4336 status = smsatWriteSame10_2( smRoot, 4337 &satNewIntIo->satIntSmIORequest, 4338 satNewIOContext->psmDeviceHandle, 4339 &satNewIntIo->satIntSmScsiXchg, 4340 satNewIOContext, 4341 lba + oneDeviceData->satSectorDone 4342 ); 4343 } 4344 else if (hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED) 4345 { 4346 status = smsatWriteSame10_3( smRoot, 4347 &satNewIntIo->satIntSmIORequest, 4348 satNewIOContext->psmDeviceHandle, 4349 &satNewIntIo->satIntSmScsiXchg, 4350 satNewIOContext, 4351 lba + oneDeviceData->satSectorDone 4352 ); 4353 } 4354 else 4355 { 4356 status = tiError; 4357 SM_DBG1(("smsatWriteSame10CB: sucess but error in command 0x%x!!!\n", hostToDevFis->h.command)); 4358 } 4359 4360 if (status != SM_RC_SUCCESS) 4361 { 4362 /* sending ATA command fails */ 4363 smsatFreeIntIoResource( smRoot, 4364 oneDeviceData, 4365 satNewIntIo); 4366 smsatSetSensePayload( pSense, 4367 SCSI_SNSKEY_NO_SENSE, 4368 0, 4369 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4370 satOrgIOContext); 4371 4372 tdsmIOCompletedCB( smRoot, 4373 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4374 smIOSuccess, 4375 SCSI_STAT_CHECK_CONDITION, 4376 satOrgIOContext->pSmSenseData, 4377 satOrgIOContext->interruptContext ); 4378 SM_DBG1(("smsatWriteSame10CB:calling satWriteSame10_1 fails!!!\n")); 4379 return; 4380 } /* end send fails */ 4381 4382 } /* end sends another ATA command */ 4383 4384 return; 4385 4386 } 4387 4388 osGLOBAL void 4389 smsatLogSenseCB( 4390 agsaRoot_t *agRoot, 4391 agsaIORequest_t *agIORequest, 4392 bit32 agIOStatus, 4393 agsaFisHeader_t *agFirstDword, 4394 bit32 agIOInfoLen, 4395 void *agParam, 4396 void *ioContext 4397 ) 4398 { 4399 smRoot_t *smRoot = agNULL; 4400 smIntRoot_t *smIntRoot = agNULL; 4401 smIntContext_t *smAllShared = agNULL; 4402 smIORequestBody_t *smIORequestBody; 4403 smIORequestBody_t *smOrgIORequestBody; 4404 smSatIOContext_t *satIOContext; 4405 smSatIOContext_t *satOrgIOContext; 4406 smSatInternalIo_t *satIntIo; 4407 // satDeviceData_t *satDevData; 4408 smDeviceData_t *oneDeviceData; 4409 4410 smScsiRspSense_t *pSense; 4411 smIORequest_t *smOrgIORequest; 4412 4413 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 4414 bit32 ataStatus = 0; 4415 smScsiInitiatorRequest_t *smScsiRequest; /* tiScsiXchg */ 4416 smScsiInitiatorRequest_t *smOrgScsiRequest; /* tiScsiXchg */ 4417 satReadLogExtSelfTest_t *virtAddr1; 4418 satSmartReadLogSelfTest_t *virtAddr2; 4419 bit8 *pLogPage; 4420 bit8 LogPage[SELFTEST_RESULTS_LOG_PAGE_LENGTH]; 4421 bit8 SelfTestExecutionStatus = 0; 4422 bit32 i = 0; 4423 4424 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 4425 agsaFisRegD2HData_t statDevToHostFisData; 4426 smIniScsiCmnd_t *scsiCmnd; 4427 bit32 allocationLen = 0; 4428 4429 SM_DBG2(("smsatLogSenseCB: start\n")); 4430 SM_DBG5(("smsatLogSenseCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 4431 4432 /* internally generate smIOContext */ 4433 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 4434 satIOContext = (smSatIOContext_t *) ioContext; 4435 if (satIOContext == agNULL) 4436 { 4437 SM_DBG1(("smsatLogSenseCB: satIOContext is NULL\n")); 4438 return; 4439 } 4440 satIntIo = satIOContext->satIntIoContext; 4441 oneDeviceData = satIOContext->pSatDevData; 4442 hostToDevFis = satIOContext->pFis; 4443 smRoot = oneDeviceData->smRoot; 4444 smIntRoot = (smIntRoot_t *)smRoot->smData; 4445 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 4446 4447 if (satIntIo == agNULL) 4448 { 4449 SM_DBG4(("smsatLogSenseCB: External smSatInternalIo_t satIntIoContext\n")); 4450 satOrgIOContext = satIOContext; 4451 smOrgIORequest = smIORequestBody->smIORequest; 4452 pSense = satOrgIOContext->pSense; 4453 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 4454 /* SCSI command response payload to OS layer */ 4455 pLogPage = (bit8 *) smOrgScsiRequest->sglVirtualAddr; 4456 /* ATA command response payload */ 4457 smScsiRequest = satOrgIOContext->smScsiXchg; 4458 scsiCmnd = satOrgIOContext->pScsiCmnd; 4459 } 4460 else 4461 { 4462 SM_DBG4(("smsatLogSenseCB: Internal smSatInternalIo_t satIntIoContext\n")); 4463 satOrgIOContext = satIOContext->satOrgIOContext; 4464 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 4465 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 4466 4467 pSense = satOrgIOContext->pSense; 4468 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 4469 /* SCSI command response payload to OS layer */ 4470 pLogPage = (bit8 *) smOrgScsiRequest->sglVirtualAddr; 4471 /* ATA command response payload */ 4472 smScsiRequest = (smScsiInitiatorRequest_t *)&(satIntIo->satIntSmScsiXchg); 4473 scsiCmnd = satOrgIOContext->pScsiCmnd; 4474 } 4475 4476 smIORequestBody->ioCompleted = agTRUE; 4477 smIORequestBody->ioStarted = agFALSE; 4478 4479 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 4480 { 4481 SM_DBG1(("smsatLogSenseCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 4482 tdsmIOCompletedCB( 4483 smRoot, 4484 smOrgIORequest, 4485 smIOFailed, 4486 smDetailOtherError, 4487 agNULL, 4488 satOrgIOContext->interruptContext 4489 ); 4490 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4491 4492 smsatFreeIntIoResource( smRoot, 4493 oneDeviceData, 4494 satIntIo); 4495 return; 4496 } 4497 4498 if (agIOStatus != OSSA_IO_SUCCESS) 4499 { 4500 /* non-data and pio read -> device to host and pio setup fis are expected */ 4501 /* 4502 first, assumed to be Reg Device to Host FIS 4503 This is OK to just find fis type 4504 */ 4505 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 4506 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 4507 } 4508 4509 if( agIOStatus != OSSA_IO_SUCCESS) 4510 { 4511 if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 4512 (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS)) || 4513 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 4514 ) 4515 { 4516 /* for debugging */ 4517 if( agIOStatus != OSSA_IO_SUCCESS) 4518 { 4519 SM_DBG1(("smsatLogSenseCB: FAILED, NOT IO_SUCCESS!!!\n")); 4520 } 4521 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 4522 { 4523 SM_DBG1(("smsatLogSenseCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 4524 } 4525 else if (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) 4526 { 4527 SM_DBG1(("smsatLogSenseCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 4528 } 4529 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 4530 (ataStatus & DF_ATA_STATUS_MASK) 4531 ) 4532 { 4533 SM_DBG1(("smsatLogSenseCB: FAILED, FAILED, error status!!!\n")); 4534 } 4535 4536 /* Process abort case */ 4537 if (agIOStatus == OSSA_IO_ABORTED) 4538 { 4539 smsatProcessAbort(smRoot, 4540 smOrgIORequest, 4541 satOrgIOContext 4542 ); 4543 4544 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4545 4546 smsatFreeIntIoResource( smRoot, 4547 oneDeviceData, 4548 satIntIo); 4549 return; 4550 } 4551 4552 /* for debugging */ 4553 if (hostToDevFis->h.command == SAT_READ_LOG_EXT) 4554 { 4555 SM_DBG1(("smsatLogSenseCB: SAT_READ_LOG_EXT failed!!!\n")); 4556 } 4557 else if (hostToDevFis->h.command == SAT_SMART) 4558 { 4559 if (hostToDevFis->h.features == SAT_SMART_READ_LOG) 4560 { 4561 SM_DBG1(("smsatLogSenseCB: SAT_SMART_READ_LOG failed!!!\n")); 4562 } 4563 else if (hostToDevFis->h.features == SAT_SMART_RETURN_STATUS) 4564 { 4565 SM_DBG1(("smsatLogSenseCB: SAT_SMART_RETURN_STATUS failed!!!\n")); 4566 } 4567 else 4568 { 4569 SM_DBG1(("smsatLogSenseCB: error unknown command 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 4570 } 4571 } 4572 else 4573 { 4574 SM_DBG1(("smsatLogSenseCB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 4575 } 4576 4577 smsatSetSensePayload( pSense, 4578 SCSI_SNSKEY_NO_SENSE, 4579 0, 4580 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4581 satOrgIOContext); 4582 4583 tdsmIOCompletedCB( smRoot, 4584 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4585 smIOSuccess, 4586 SCSI_STAT_CHECK_CONDITION, 4587 satOrgIOContext->pSmSenseData, 4588 satOrgIOContext->interruptContext ); 4589 4590 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4591 4592 smsatFreeIntIoResource( smRoot, 4593 oneDeviceData, 4594 satIntIo); 4595 return; 4596 4597 } /* error checking */ 4598 } 4599 4600 /* prcessing the success case */ 4601 saFrameReadBlock(agRoot, agParam, 0, &statDevToHostFisData, sizeof(agsaFisRegD2HData_t)); 4602 4603 allocationLen = (scsiCmnd->cdb[7] << 8) + scsiCmnd->cdb[8]; 4604 allocationLen = MIN(allocationLen, scsiCmnd->expDataLength); 4605 SM_DBG5(("smsatLogSenseCB: allocationLen in CDB %d 0x%x\n", allocationLen,allocationLen)); 4606 4607 4608 if (hostToDevFis->h.command == SAT_READ_LOG_EXT) 4609 { 4610 SM_DBG5(("smsatLogSenseCB: SAT_READ_LOG_EXT success\n")); 4611 4612 /* process log data and sends it to upper */ 4613 4614 /* ATA: Extended Self-Test Log */ 4615 virtAddr1 = (satReadLogExtSelfTest_t *)(smScsiRequest->sglVirtualAddr); 4616 /* 4617 ATA/ATAPI VOLII, p197, 287 4618 self-test execution status (4 bits); ((virtAddr1->byte[5] & 0xF0) >> 4) 4619 */ 4620 SelfTestExecutionStatus = (bit8)(((virtAddr1->byte[5] & 0xF0) >> 4)); 4621 4622 /* fills in the log page from ATA log page */ 4623 /* SPC-4, 7.2.10, Table 216, 217, p 259 - 260 */ 4624 LogPage[0] = 0x10; /* page code */ 4625 LogPage[1] = 0; 4626 LogPage[2] = 0x01; /* 0x190, page length */ 4627 LogPage[3] = 0x90; 4628 4629 /* SPC-4, Table 217 */ 4630 LogPage[4] = 0; /* Parameter Code */ 4631 LogPage[5] = 0x01; /* Parameter Code, unspecfied but ... */ 4632 LogPage[6] = 3; /* unspecified but ... */ 4633 LogPage[7] = 0x10; /* Parameter Length */ 4634 LogPage[8] = (bit8)(0 | ((virtAddr1->byte[5] & 0xF0) >> 4)); /* Self Test Code and Self-Test Result */ 4635 LogPage[9] = 0; /* self test number */ 4636 LogPage[10] = virtAddr1->byte[7]; /* time stamp, MSB */ 4637 LogPage[11] = virtAddr1->byte[6]; /* time stamp, LSB */ 4638 4639 LogPage[12] = 0; /* address of first failure MSB*/ 4640 LogPage[13] = 0; /* address of first failure */ 4641 LogPage[14] = virtAddr1->byte[14]; /* address of first failure */ 4642 LogPage[15] = virtAddr1->byte[13]; /* address of first failure */ 4643 LogPage[16] = virtAddr1->byte[12]; /* address of first failure */ 4644 LogPage[17] = virtAddr1->byte[11]; /* address of first failure */ 4645 LogPage[18] = virtAddr1->byte[10]; /* address of first failure */ 4646 LogPage[19] = virtAddr1->byte[9]; /* address of first failure LSB */ 4647 4648 /* SAT rev8 Table75, p 76 */ 4649 switch (SelfTestExecutionStatus) 4650 { 4651 case 0: 4652 LogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 4653 LogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 4654 LogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 4655 break; 4656 case 1: 4657 LogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 4658 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4659 LogPage[22] = 0x81; 4660 break; 4661 case 2: 4662 LogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 4663 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4664 LogPage[22] = 0x82; 4665 break; 4666 case 3: 4667 LogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 4668 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4669 LogPage[22] = 0x83; 4670 break; 4671 case 4: 4672 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4673 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4674 LogPage[22] = 0x84; 4675 break; 4676 case 5: 4677 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4678 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4679 LogPage[22] = 0x85; 4680 break; 4681 case 6: 4682 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4683 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4684 LogPage[22] = 0x86; 4685 break; 4686 case 7: 4687 LogPage[20] = 0 | SCSI_SNSKEY_MEDIUM_ERROR; 4688 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4689 LogPage[22] = 0x87; 4690 break; 4691 case 8: 4692 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4693 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4694 LogPage[22] = 0x88; 4695 break; 4696 case 9: /* fall through */ 4697 case 10:/* fall through */ 4698 case 11:/* fall through */ 4699 case 12:/* fall through */ 4700 case 13:/* fall through */ 4701 case 14: 4702 LogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 4703 LogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 4704 LogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 4705 break; 4706 case 15: 4707 LogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 4708 LogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 4709 LogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 4710 break; 4711 default: 4712 SM_DBG1(("smsatLogSenseCB: Error, incorrect SelfTestExecutionStatus 0x%x!!!\n", SelfTestExecutionStatus)); 4713 4714 smsatSetSensePayload( pSense, 4715 SCSI_SNSKEY_NO_SENSE, 4716 0, 4717 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4718 satOrgIOContext); 4719 4720 tdsmIOCompletedCB( smRoot, 4721 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4722 smIOSuccess, 4723 SCSI_STAT_CHECK_CONDITION, 4724 satOrgIOContext->pSmSenseData, 4725 satOrgIOContext->interruptContext ); 4726 4727 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4728 4729 smsatFreeIntIoResource( smRoot, 4730 oneDeviceData, 4731 satIntIo); 4732 4733 return; 4734 } 4735 4736 LogPage[23] = 0; /* vendor specific */ 4737 4738 /* the rest of Self-test results log */ 4739 /* 403 is from SPC-4, 7.2.10, Table 216, p 259*/ 4740 for (i=24;i<=403;i++) 4741 { 4742 LogPage[i] = 0; /* vendor specific */ 4743 } 4744 4745 sm_memcpy(pLogPage, LogPage, MIN(allocationLen, SELFTEST_RESULTS_LOG_PAGE_LENGTH)); 4746 if (SELFTEST_RESULTS_LOG_PAGE_LENGTH < allocationLen) 4747 { 4748 SM_DBG6(("smsatLogSenseCB: 1st underrun allocationLen %d len %d \n", allocationLen, SELFTEST_RESULTS_LOG_PAGE_LENGTH)); 4749 4750 /* underrun */ 4751 tdsmIOCompletedCB( smRoot, 4752 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 4753 smIOUnderRun, 4754 allocationLen - SELFTEST_RESULTS_LOG_PAGE_LENGTH, 4755 agNULL, 4756 satOrgIOContext->interruptContext ); 4757 4758 } 4759 else 4760 { 4761 tdsmIOCompletedCB( smRoot, 4762 smOrgIORequest, 4763 smIOSuccess, 4764 SCSI_STAT_GOOD, 4765 agNULL, 4766 satOrgIOContext->interruptContext); 4767 } 4768 4769 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4770 4771 smsatFreeIntIoResource( smRoot, 4772 oneDeviceData, 4773 satIntIo); 4774 4775 return; 4776 } 4777 else if (hostToDevFis->h.command == SAT_SMART) 4778 { 4779 if (hostToDevFis->h.features == SAT_SMART_READ_LOG) 4780 { 4781 SM_DBG5(("smsatLogSenseCB: SAT_SMART_READ_LOG success\n")); 4782 /* process log data and sends it to upper */ 4783 4784 /* ATA: Extended Self-Test Log */ 4785 virtAddr2 = (satSmartReadLogSelfTest_t *)(smScsiRequest->sglVirtualAddr); 4786 /* 4787 SPC-4, p197, 287 4788 self-test execution status (4 bits); ((virtAddr2->byte[3] & 0xF0) >> 4) 4789 */ 4790 SelfTestExecutionStatus = (bit8)(((virtAddr2->byte[3] & 0xF0) >> 4)); 4791 4792 /* fills in the log page from ATA log page */ 4793 /* SPC-4, 7.2.10, Table 216, 217, p 259 - 260 */ 4794 LogPage[0] = 0x10; /* page code */ 4795 LogPage[1] = 0; 4796 LogPage[2] = 0x01; /* 0x190, page length */ 4797 LogPage[3] = 0x90; /* 0x190, page length */ 4798 4799 /* SPC-4, Table 217 */ 4800 LogPage[4] = 0; /* Parameter Code */ 4801 LogPage[5] = 0x01; /* Parameter Code unspecfied but ... */ 4802 LogPage[6] = 3; /* unspecified but ... */ 4803 LogPage[7] = 0x10; /* Parameter Length */ 4804 LogPage[8] = (bit8)(0 | ((virtAddr2->byte[3] & 0xF0) >> 4)); /* Self Test Code and Self-Test Result */ 4805 LogPage[9] = 0; /* self test number */ 4806 LogPage[10] = virtAddr2->byte[5]; /* time stamp, MSB */ 4807 LogPage[11] = virtAddr2->byte[4]; /* time stamp, LSB */ 4808 4809 LogPage[12] = 0; /* address of first failure MSB*/ 4810 LogPage[13] = 0; /* address of first failure */ 4811 LogPage[14] = 0; /* address of first failure */ 4812 LogPage[15] = 0; /* address of first failure */ 4813 LogPage[16] = virtAddr2->byte[10]; /* address of first failure */ 4814 LogPage[17] = virtAddr2->byte[9]; /* address of first failure */ 4815 LogPage[18] = virtAddr2->byte[8]; /* address of first failure */ 4816 LogPage[19] = virtAddr2->byte[7]; /* address of first failure LSB */ 4817 4818 /* SAT rev8 Table75, p 76 */ 4819 switch (SelfTestExecutionStatus) 4820 { 4821 case 0: 4822 LogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 4823 LogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 4824 LogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 4825 break; 4826 case 1: 4827 LogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 4828 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4829 LogPage[22] = 0x81; 4830 break; 4831 case 2: 4832 LogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 4833 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4834 LogPage[22] = 0x82; 4835 break; 4836 case 3: 4837 LogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 4838 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4839 LogPage[22] = 0x83; 4840 break; 4841 case 4: 4842 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4843 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4844 LogPage[22] = 0x84; 4845 break; 4846 case 5: 4847 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4848 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4849 LogPage[22] = 0x85; 4850 break; 4851 case 6: 4852 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4853 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4854 LogPage[22] = 0x86; 4855 break; 4856 case 7: 4857 LogPage[20] = 0 | SCSI_SNSKEY_MEDIUM_ERROR; 4858 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4859 LogPage[22] = 0x87; 4860 break; 4861 case 8: 4862 LogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 4863 LogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 4864 LogPage[22] = 0x88; 4865 break; 4866 case 9: /* fall through */ 4867 case 10:/* fall through */ 4868 case 11:/* fall through */ 4869 case 12:/* fall through */ 4870 case 13:/* fall through */ 4871 case 14: 4872 /* unspecified */ 4873 LogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 4874 LogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 4875 LogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 4876 break; 4877 case 15: 4878 LogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 4879 LogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 4880 LogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 4881 break; 4882 default: 4883 SM_DBG1(("smsatLogSenseCB: Error, incorrect SelfTestExecutionStatus 0x%x!!!\n", SelfTestExecutionStatus)); 4884 4885 smsatSetSensePayload( pSense, 4886 SCSI_SNSKEY_NO_SENSE, 4887 0, 4888 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4889 satOrgIOContext); 4890 4891 tdsmIOCompletedCB( smRoot, 4892 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 4893 smIOSuccess, 4894 SCSI_STAT_CHECK_CONDITION, 4895 satOrgIOContext->pSmSenseData, 4896 satOrgIOContext->interruptContext ); 4897 4898 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4899 4900 smsatFreeIntIoResource( smRoot, 4901 oneDeviceData, 4902 satIntIo); 4903 4904 return; 4905 } 4906 4907 LogPage[23] = 0; /* vendor specific */ 4908 4909 /* the rest of Self-test results log */ 4910 /* 403 is from SPC-4, 7.2.10, Table 216, p 259*/ 4911 for (i=24;i<=403;i++) 4912 { 4913 LogPage[i] = 0; /* vendor specific */ 4914 } 4915 4916 sm_memcpy(pLogPage, LogPage, MIN(allocationLen, SELFTEST_RESULTS_LOG_PAGE_LENGTH)); 4917 if (SELFTEST_RESULTS_LOG_PAGE_LENGTH < allocationLen) 4918 { 4919 SM_DBG6(("smsatLogSenseCB: 2nd underrun allocationLen %d len %d \n", allocationLen, SELFTEST_RESULTS_LOG_PAGE_LENGTH)); 4920 4921 /* underrun */ 4922 tdsmIOCompletedCB( smRoot, 4923 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 4924 smIOUnderRun, 4925 allocationLen - SELFTEST_RESULTS_LOG_PAGE_LENGTH, 4926 agNULL, 4927 satOrgIOContext->interruptContext ); 4928 4929 } 4930 else 4931 { 4932 tdsmIOCompletedCB( smRoot, 4933 smOrgIORequest, 4934 smIOSuccess, 4935 SCSI_STAT_GOOD, 4936 agNULL, 4937 satOrgIOContext->interruptContext); 4938 } 4939 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 4940 4941 smsatFreeIntIoResource( smRoot, 4942 oneDeviceData, 4943 satIntIo); 4944 4945 return; 4946 } 4947 else if (hostToDevFis->h.features == SAT_SMART_RETURN_STATUS) 4948 { 4949 SM_DBG5(("smsatLogSenseCB: SAT_SMART_RETURN_STATUS success\n")); 4950 4951 /* fills in the log page from ATA output */ 4952 /* SPC-4, 7.2.5, Table 209, 211, p 255 */ 4953 LogPage[0] = 0x2F; /* page code unspecified */ 4954 LogPage[1] = 0; /* reserved */ 4955 LogPage[2] = 0; /* page length */ 4956 LogPage[3] = 0x07; /* page length */ 4957 4958 /* 4959 SPC-4, 7.2.5, Table 211, p 255 4960 no vendor specific field 4961 */ 4962 LogPage[4] = 0; /* Parameter Code */ 4963 LogPage[5] = 0; /* Parameter Code unspecfied but to do: */ 4964 LogPage[6] = 0; /* unspecified */ 4965 LogPage[7] = 0x03; /* Parameter length, unspecified */ 4966 4967 /* SAT rev8, 10.2.3.1 Table 72, p 73 */ 4968 if (statDevToHostFisData.lbaMid == 0x4F || statDevToHostFisData.lbaHigh == 0xC2) 4969 { 4970 LogPage[8] = 0; /* Sense code */ 4971 LogPage[9] = 0; /* Sense code qualifier */ 4972 } 4973 else if (statDevToHostFisData.lbaMid == 0xF4 || statDevToHostFisData.lbaHigh == 0x2C) 4974 { 4975 LogPage[8] = 0x5D; /* Sense code */ 4976 LogPage[9] = 0x10; /* Sense code qualifier */ 4977 } 4978 4979 /* Assumption: No support for SCT */ 4980 LogPage[10] = 0xFF; /* Most Recent Temperature Reading */ 4981 4982 sm_memcpy(pLogPage, LogPage, MIN(allocationLen, INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH)); 4983 if (INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH < allocationLen) 4984 { 4985 SM_DBG6(("smsatLogSenseCB: 3rd underrun allocationLen %d len %d \n", allocationLen, INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH)); 4986 4987 /* underrun */ 4988 tdsmIOCompletedCB( smRoot, 4989 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 4990 smIOUnderRun, 4991 allocationLen - INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH, 4992 agNULL, 4993 satOrgIOContext->interruptContext ); 4994 4995 } 4996 else 4997 { 4998 tdsmIOCompletedCB( smRoot, 4999 smOrgIORequest, 5000 smIOSuccess, 5001 SCSI_STAT_GOOD, 5002 agNULL, 5003 satOrgIOContext->interruptContext); 5004 } 5005 5006 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5007 5008 smsatFreeIntIoResource( smRoot, 5009 oneDeviceData, 5010 satIntIo); 5011 5012 5013 return; 5014 } 5015 else 5016 { 5017 SM_DBG1(("smsatLogSenseCB: error unknown command success 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 5018 smsatSetSensePayload( pSense, 5019 SCSI_SNSKEY_NO_SENSE, 5020 0, 5021 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5022 satOrgIOContext); 5023 5024 tdsmIOCompletedCB( smRoot, 5025 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5026 smIOSuccess, 5027 SCSI_STAT_CHECK_CONDITION, 5028 satOrgIOContext->pSmSenseData, 5029 satOrgIOContext->interruptContext ); 5030 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5031 5032 smsatFreeIntIoResource( smRoot, 5033 oneDeviceData, 5034 satIntIo); 5035 5036 return; 5037 } 5038 } 5039 else 5040 { 5041 SM_DBG1(("smsatLogSenseCB: error unknown command success 0x%x!!!\n", hostToDevFis->h.command)); 5042 smsatSetSensePayload( pSense, 5043 SCSI_SNSKEY_NO_SENSE, 5044 0, 5045 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5046 satOrgIOContext); 5047 5048 tdsmIOCompletedCB( smRoot, 5049 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5050 smIOSuccess, 5051 SCSI_STAT_CHECK_CONDITION, 5052 satOrgIOContext->pSmSenseData, 5053 satOrgIOContext->interruptContext ); 5054 5055 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5056 5057 smsatFreeIntIoResource( smRoot, 5058 oneDeviceData, 5059 satIntIo); 5060 5061 return; 5062 } 5063 5064 return; 5065 } 5066 5067 osGLOBAL void 5068 smsatSMARTEnableCB( 5069 agsaRoot_t *agRoot, 5070 agsaIORequest_t *agIORequest, 5071 bit32 agIOStatus, 5072 agsaFisHeader_t *agFirstDword, 5073 bit32 agIOInfoLen, 5074 agsaFrameHandle_t agFrameHandle, 5075 void *ioContext 5076 ) 5077 { 5078 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5079 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5080 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 5081 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 5082 smRoot_t *smRoot = agNULL; 5083 smIntRoot_t *smIntRoot = agNULL; 5084 smIntContext_t *smAllShared = agNULL; 5085 smIORequestBody_t *smIORequestBody; 5086 smIORequestBody_t *smOrgIORequestBody; 5087 smSatIOContext_t *satIOContext; 5088 smSatIOContext_t *satOrgIOContext; 5089 smSatIOContext_t *satNewIOContext; 5090 smSatInternalIo_t *satIntIo; 5091 smSatInternalIo_t *satNewIntIo = agNULL; 5092 // satDeviceData_t *satDevData; 5093 smDeviceData_t *oneDeviceData; 5094 smIniScsiCmnd_t *scsiCmnd; 5095 smIORequest_t *smOrgIORequest; 5096 bit32 status; 5097 5098 SM_DBG2(("smsatSMARTEnableCB: start\n")); 5099 SM_DBG4(("smsatSMARTEnableCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 5100 5101 /* internally generate tiIOContext */ 5102 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 5103 satIOContext = (smSatIOContext_t *) ioContext; 5104 satIntIo = satIOContext->satIntIoContext; 5105 oneDeviceData = satIOContext->pSatDevData; 5106 smRoot = oneDeviceData->smRoot; 5107 smIntRoot = (smIntRoot_t *)smRoot->smData; 5108 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 5109 /*ttttttthe one */ 5110 if (satIntIo == agNULL) 5111 { 5112 SM_DBG4(("smsatSMARTEnableCB: External smSatInternalIo_t satIntIoContext\n")); 5113 satOrgIOContext = satIOContext; 5114 smOrgIORequest = smIORequestBody->smIORequest; 5115 scsiCmnd = satOrgIOContext->pScsiCmnd; 5116 } 5117 else 5118 { 5119 SM_DBG4(("smsatSMARTEnableCB: Internal smSatInternalIo_t satIntIoContext\n")); 5120 satOrgIOContext = satIOContext->satOrgIOContext; 5121 if (satOrgIOContext == agNULL) 5122 { 5123 SM_DBG4(("smsatSMARTEnableCB: satOrgIOContext is NULL, wrong\n")); 5124 return; 5125 } 5126 else 5127 { 5128 SM_DBG4(("smsatSMARTEnableCB: satOrgIOContext is NOT NULL\n")); 5129 } 5130 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 5131 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 5132 scsiCmnd = satOrgIOContext->pScsiCmnd; 5133 } 5134 smIORequestBody->ioCompleted = agTRUE; 5135 smIORequestBody->ioStarted = agFALSE; 5136 5137 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 5138 { 5139 SM_DBG1(("smsatSMARTEnableCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 5140 tdsmIOCompletedCB( 5141 smRoot, 5142 smOrgIORequest, 5143 smIOFailed, 5144 smDetailOtherError, 5145 agNULL, 5146 satOrgIOContext->interruptContext 5147 ); 5148 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5149 smsatFreeIntIoResource( smRoot, 5150 oneDeviceData, 5151 satIntIo); 5152 return; 5153 } 5154 /* 5155 checking IO status, FIS type and error status 5156 */ 5157 if (agIOStatus != OSSA_IO_SUCCESS) 5158 { 5159 SM_DBG1(("smsatSMARTEnableCB: not success status, status %d!!!\n", agIOStatus)); 5160 tdsmIOCompletedCB( 5161 smRoot, 5162 smOrgIORequest, 5163 smIOFailed, 5164 smDetailOtherError, 5165 agNULL, 5166 satOrgIOContext->interruptContext 5167 ); 5168 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5169 smsatFreeIntIoResource( smRoot, 5170 oneDeviceData, 5171 satIntIo); 5172 return; 5173 } 5174 /* process success case */ 5175 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5176 smsatFreeIntIoResource( smRoot, 5177 oneDeviceData, 5178 satIntIo); 5179 satNewIntIo = smsatAllocIntIoResource( smRoot, 5180 smOrgIORequest, 5181 oneDeviceData, 5182 512, 5183 satNewIntIo); 5184 if (satNewIntIo == agNULL) 5185 { 5186 tdsmIOCompletedCB( 5187 smRoot, 5188 smOrgIORequest, 5189 smIOFailed, 5190 smDetailOtherError, 5191 agNULL, 5192 satOrgIOContext->interruptContext 5193 ); 5194 return; 5195 } 5196 satNewIOContext = smsatPrepareNewIO( 5197 satNewIntIo, 5198 smOrgIORequest, 5199 oneDeviceData, 5200 scsiCmnd, 5201 satOrgIOContext 5202 ); 5203 status = smsatLogSense_1(smRoot, 5204 &satNewIntIo->satIntSmIORequest, 5205 satNewIOContext->psmDeviceHandle, 5206 &satNewIntIo->satIntSmScsiXchg, 5207 satNewIOContext); 5208 if (status != SM_RC_SUCCESS) 5209 { 5210 /* sending SAT_CHECK_POWER_MODE fails */ 5211 smsatFreeIntIoResource( smRoot, 5212 oneDeviceData, 5213 satNewIntIo); 5214 tdsmIOCompletedCB( 5215 smRoot, 5216 smOrgIORequest, 5217 smIOFailed, 5218 smDetailOtherError, 5219 agNULL, 5220 satOrgIOContext->interruptContext 5221 ); 5222 return; 5223 } 5224 return; 5225 } 5226 5227 osGLOBAL void 5228 smsatModeSelect6n10CB( 5229 agsaRoot_t *agRoot, 5230 agsaIORequest_t *agIORequest, 5231 bit32 agIOStatus, 5232 agsaFisHeader_t *agFirstDword, 5233 bit32 agIOInfoLen, 5234 agsaFrameHandle_t agFrameHandle, 5235 void *ioContext 5236 ) 5237 { 5238 smRoot_t *smRoot = agNULL; 5239 smIntRoot_t *smIntRoot = agNULL; 5240 smIntContext_t *smAllShared = agNULL; 5241 smIORequestBody_t *smIORequestBody; 5242 smIORequestBody_t *smOrgIORequestBody; 5243 smSatIOContext_t *satIOContext; 5244 smSatIOContext_t *satOrgIOContext; 5245 smSatIOContext_t *satNewIOContext; 5246 smSatInternalIo_t *satIntIo; 5247 smSatInternalIo_t *satNewIntIo = agNULL; 5248 // satDeviceData_t *satDevData; 5249 smDeviceData_t *oneDeviceData; 5250 5251 smScsiRspSense_t *pSense; 5252 smIniScsiCmnd_t *scsiCmnd; 5253 smIORequest_t *smOrgIORequest; 5254 5255 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 5256 bit32 ataStatus = 0; 5257 bit32 status; 5258 smScsiInitiatorRequest_t *smScsiRequest; /* smScsiXchg */ 5259 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 5260 5261 SM_DBG2(("smsatModeSelect6n10CB: start\n")); 5262 SM_DBG5(("smsatModeSelect6n10CB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 5263 5264 /* internally generate smIOContext */ 5265 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 5266 satIOContext = (smSatIOContext_t *) ioContext; 5267 satIntIo = satIOContext->satIntIoContext; 5268 oneDeviceData = satIOContext->pSatDevData; 5269 hostToDevFis = satIOContext->pFis; 5270 smRoot = oneDeviceData->smRoot; 5271 smIntRoot = (smIntRoot_t *)smRoot->smData; 5272 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 5273 5274 if (satIntIo == agNULL) 5275 { 5276 SM_DBG4(("smsatModeSelect6n10CB: External smSatInternalIo_t satIntIoContext\n")); 5277 satOrgIOContext = satIOContext; 5278 smOrgIORequest = smIORequestBody->smIORequest; 5279 smScsiRequest = satOrgIOContext->smScsiXchg; 5280 pSense = satOrgIOContext->pSense; 5281 scsiCmnd = satOrgIOContext->pScsiCmnd; 5282 } 5283 else 5284 { 5285 SM_DBG4(("smsatModeSelect6n10CB: Internal smSatInternalIo_t satIntIoContext\n")); 5286 satOrgIOContext = satIOContext->satOrgIOContext; 5287 if (satOrgIOContext == agNULL) 5288 { 5289 SM_DBG4(("smsatModeSelect6n10CB: satOrgIOContext is NULL, wrong\n")); 5290 return; 5291 } 5292 else 5293 { 5294 SM_DBG4(("smsatModeSelect6n10CB: satOrgIOContext is NOT NULL\n")); 5295 } 5296 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 5297 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 5298 5299 smScsiRequest = satOrgIOContext->smScsiXchg; 5300 pSense = satOrgIOContext->pSense; 5301 scsiCmnd = satOrgIOContext->pScsiCmnd; 5302 } 5303 5304 smIORequestBody->ioCompleted = agTRUE; 5305 smIORequestBody->ioStarted = agFALSE; 5306 5307 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 5308 { 5309 SM_DBG1(("smsatModeSelect6n10CB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 5310 tdsmIOCompletedCB( 5311 smRoot, 5312 smOrgIORequest, 5313 smIOFailed, 5314 smDetailOtherError, 5315 agNULL, 5316 satOrgIOContext->interruptContext 5317 ); 5318 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5319 5320 smsatFreeIntIoResource( smRoot, 5321 oneDeviceData, 5322 satIntIo); 5323 return; 5324 } 5325 5326 if (agIOStatus != OSSA_IO_SUCCESS) 5327 { 5328 /* only agsaFisRegDeviceToHost_t is expected */ 5329 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 5330 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 5331 } 5332 5333 if (agIOStatus != OSSA_IO_SUCCESS) 5334 { 5335 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 5336 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 5337 ) 5338 { 5339 /* for debugging */ 5340 if( agIOStatus != OSSA_IO_SUCCESS) 5341 { 5342 SM_DBG1(("smsatModeSelect6n10CB: FAILED, NOT IO_SUCCESS!!!\n")); 5343 } 5344 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 5345 { 5346 SM_DBG1(("smsatModeSelect6n10CB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 5347 } 5348 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 5349 (ataStatus & DF_ATA_STATUS_MASK) 5350 ) 5351 { 5352 SM_DBG1(("smsatModeSelect6n10CB: FAILED, FAILED, error status!!!\n")); 5353 } 5354 5355 /* Process abort case */ 5356 if (agIOStatus == OSSA_IO_ABORTED) 5357 { 5358 smsatProcessAbort(smRoot, 5359 smOrgIORequest, 5360 satOrgIOContext 5361 ); 5362 5363 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5364 5365 smsatFreeIntIoResource( smRoot, 5366 oneDeviceData, 5367 satIntIo); 5368 return; 5369 } 5370 5371 /* for debugging */ 5372 if (hostToDevFis->h.command == SAT_SET_FEATURES) 5373 { 5374 if ((hostToDevFis->h.features == 0x82) || (hostToDevFis->h.features == 0x02)) 5375 { 5376 SM_DBG1(("smsatModeSelect6n10CB: 1 SAT_SET_FEATURES failed, feature 0x%x!!!\n", hostToDevFis->h.features)); 5377 } 5378 else if ((hostToDevFis->h.features == 0xAA) || (hostToDevFis->h.features == 0x55)) 5379 { 5380 SM_DBG1(("smsatModeSelect6n10CB: 2 SAT_SET_FEATURES failed, feature 0x%x!!!\n", hostToDevFis->h.features)); 5381 } 5382 else 5383 { 5384 SM_DBG1(("smsatModeSelect6n10CB: error unknown command 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 5385 } 5386 } 5387 else if (hostToDevFis->h.command == SAT_SMART) 5388 { 5389 if ((hostToDevFis->h.features == SAT_SMART_ENABLE_OPERATIONS) || (hostToDevFis->h.features == SAT_SMART_DISABLE_OPERATIONS)) 5390 { 5391 SM_DBG1(("smsatModeSelect6n10CB: SAT_SMART_ENABLE/DISABLE_OPERATIONS failed, feature 0x%x!!!\n", hostToDevFis->h.features)); 5392 } 5393 else 5394 { 5395 SM_DBG1(("smsatModeSelect6n10CB: error unknown command 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 5396 } 5397 } 5398 else 5399 { 5400 SM_DBG1(("smsatModeSelect6n10CB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 5401 } 5402 5403 5404 smsatSetSensePayload( pSense, 5405 SCSI_SNSKEY_NO_SENSE, 5406 0, 5407 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5408 satOrgIOContext); 5409 5410 tdsmIOCompletedCB( smRoot, 5411 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5412 smIOSuccess, 5413 SCSI_STAT_CHECK_CONDITION, 5414 satOrgIOContext->pSmSenseData, 5415 satOrgIOContext->interruptContext ); 5416 5417 5418 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5419 5420 smsatFreeIntIoResource( smRoot, 5421 oneDeviceData, 5422 satIntIo); 5423 return; 5424 } /* error checking */ 5425 } 5426 5427 5428 /* prcessing the success case */ 5429 5430 5431 if (hostToDevFis->h.command == SAT_SET_FEATURES) 5432 { 5433 if ((hostToDevFis->h.features == 0x82) || (hostToDevFis->h.features == 0x02)) 5434 { 5435 SM_DBG5(("smsatModeSelect6n10CB: 1 SAT_SET_FEATURES success, feature 0x%x\n", hostToDevFis->h.features)); 5436 if (hostToDevFis->h.features == 0x02) 5437 { 5438 /* enable write cache */ 5439 oneDeviceData->satWriteCacheEnabled = agTRUE; 5440 } 5441 else 5442 { 5443 /* disable write cache */ 5444 oneDeviceData->satWriteCacheEnabled = agFALSE; 5445 } 5446 5447 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5448 5449 smsatFreeIntIoResource( smRoot, 5450 oneDeviceData, 5451 satIntIo); 5452 5453 satNewIntIo = smsatAllocIntIoResource( smRoot, 5454 smOrgIORequest, 5455 oneDeviceData, 5456 0, 5457 satNewIntIo); 5458 if (satNewIntIo == agNULL) 5459 { 5460 smsatSetSensePayload( pSense, 5461 SCSI_SNSKEY_NO_SENSE, 5462 0, 5463 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5464 satOrgIOContext); 5465 5466 tdsmIOCompletedCB( smRoot, 5467 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5468 smIOSuccess, 5469 SCSI_STAT_CHECK_CONDITION, 5470 satOrgIOContext->pSmSenseData, 5471 satOrgIOContext->interruptContext ); 5472 SM_DBG1(("smsatModeSelect6n10CB: momory allocation fails!!!\n")); 5473 return; 5474 } /* end memory allocation */ 5475 5476 satNewIOContext = smsatPrepareNewIO( 5477 satNewIntIo, 5478 smOrgIORequest, 5479 oneDeviceData, 5480 scsiCmnd, 5481 satOrgIOContext 5482 ); 5483 /* sends either ATA SET FEATURES based on DRA bit */ 5484 status = smsatModeSelect6n10_1( smRoot, 5485 &satNewIntIo->satIntSmIORequest, 5486 satNewIOContext->psmDeviceHandle, 5487 smScsiRequest, /* orginal from OS layer */ 5488 satNewIOContext 5489 ); 5490 5491 if (status != SM_RC_SUCCESS) 5492 { 5493 /* sending ATA command fails */ 5494 smsatFreeIntIoResource( smRoot, 5495 oneDeviceData, 5496 satNewIntIo); 5497 smsatSetSensePayload( pSense, 5498 SCSI_SNSKEY_NO_SENSE, 5499 0, 5500 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5501 satOrgIOContext); 5502 5503 tdsmIOCompletedCB( smRoot, 5504 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5505 smIOSuccess, 5506 SCSI_STAT_CHECK_CONDITION, 5507 satOrgIOContext->pSmSenseData, 5508 satOrgIOContext->interruptContext ); 5509 SM_DBG1(("smsatModeSelect6n10CB: calling satModeSelect6_1 fails!!!\n")); 5510 return; 5511 } /* end send fails */ 5512 return; 5513 } 5514 else if ((hostToDevFis->h.features == 0xAA) || (hostToDevFis->h.features == 0x55)) 5515 { 5516 SM_DBG5(("smsatModeSelect6n10CB: 2 SAT_SET_FEATURES success, feature 0x%x\n", hostToDevFis->h.features)); 5517 5518 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5519 5520 smsatFreeIntIoResource( smRoot, 5521 oneDeviceData, 5522 satIntIo); 5523 5524 /* return stat_good */ 5525 tdsmIOCompletedCB( smRoot, 5526 smOrgIORequest, 5527 smIOSuccess, 5528 SCSI_STAT_GOOD, 5529 agNULL, 5530 satOrgIOContext->interruptContext ); 5531 return; 5532 } 5533 else 5534 { 5535 SM_DBG1(("smsatModeSelect6n10CB: error unknown command success 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 5536 5537 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5538 5539 smsatFreeIntIoResource( smRoot, 5540 oneDeviceData, 5541 satIntIo); 5542 smsatSetSensePayload( pSense, 5543 SCSI_SNSKEY_NO_SENSE, 5544 0, 5545 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5546 satOrgIOContext); 5547 5548 tdsmIOCompletedCB( smRoot, 5549 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5550 smIOSuccess, 5551 SCSI_STAT_CHECK_CONDITION, 5552 satOrgIOContext->pSmSenseData, 5553 satOrgIOContext->interruptContext ); 5554 return; 5555 } 5556 } 5557 else if (hostToDevFis->h.command == SAT_SMART ) 5558 { 5559 if ((hostToDevFis->h.features == SAT_SMART_ENABLE_OPERATIONS) || (hostToDevFis->h.features == SAT_SMART_DISABLE_OPERATIONS)) 5560 { 5561 SM_DBG5(("smsatModeSelect6n10CB: SAT_SMART_ENABLE/DISABLE_OPERATIONS success, feature 0x%x\n", hostToDevFis->h.features)); 5562 5563 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5564 5565 smsatFreeIntIoResource( smRoot, 5566 oneDeviceData, 5567 satIntIo); 5568 /* return stat_good */ 5569 tdsmIOCompletedCB( smRoot, 5570 smOrgIORequest, 5571 smIOSuccess, 5572 SCSI_STAT_GOOD, 5573 agNULL, 5574 satOrgIOContext->interruptContext ); 5575 return; 5576 } 5577 else 5578 { 5579 SM_DBG1(("smsatModeSelect6n10CB: error unknown command failed 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 5580 5581 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5582 5583 smsatFreeIntIoResource( smRoot, 5584 oneDeviceData, 5585 satIntIo); 5586 smsatSetSensePayload( pSense, 5587 SCSI_SNSKEY_NO_SENSE, 5588 0, 5589 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5590 satOrgIOContext); 5591 5592 tdsmIOCompletedCB( smRoot, 5593 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5594 smIOSuccess, 5595 SCSI_STAT_CHECK_CONDITION, 5596 satOrgIOContext->pSmSenseData, 5597 satOrgIOContext->interruptContext ); 5598 return; 5599 } 5600 } 5601 5602 else 5603 { 5604 SM_DBG1(("smsatModeSelect6n10CB: error default case command success 0x%x!!!\n", hostToDevFis->h.command)); 5605 5606 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5607 5608 smsatFreeIntIoResource( smRoot, 5609 oneDeviceData, 5610 satIntIo); 5611 5612 smsatSetSensePayload( pSense, 5613 SCSI_SNSKEY_NO_SENSE, 5614 0, 5615 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5616 satOrgIOContext); 5617 5618 tdsmIOCompletedCB( smRoot, 5619 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5620 smIOSuccess, 5621 SCSI_STAT_CHECK_CONDITION, 5622 satOrgIOContext->pSmSenseData, 5623 satOrgIOContext->interruptContext ); 5624 return; 5625 } 5626 5627 return; 5628 5629 } 5630 5631 osGLOBAL void 5632 smsatSynchronizeCache10n16CB( 5633 agsaRoot_t *agRoot, 5634 agsaIORequest_t *agIORequest, 5635 bit32 agIOStatus, 5636 agsaFisHeader_t *agFirstDword, 5637 bit32 agIOInfoLen, 5638 agsaFrameHandle_t agFrameHandle, 5639 void *ioContext 5640 ) 5641 { 5642 /* 5643 In the process of SynchronizeCache10 and SynchronizeCache16 5644 Process SAT_FLUSH_CACHE_EXT 5645 Process SAT_FLUSH_CACHE 5646 */ 5647 5648 5649 smRoot_t *smRoot = agNULL; 5650 smIntRoot_t *smIntRoot = agNULL; 5651 smIntContext_t *smAllShared = agNULL; 5652 smIORequestBody_t *smIORequestBody; 5653 smIORequestBody_t *smOrgIORequestBody; 5654 smSatIOContext_t *satIOContext; 5655 smSatIOContext_t *satOrgIOContext; 5656 smSatInternalIo_t *satIntIo; 5657 smDeviceData_t *oneDeviceData; 5658 5659 smScsiRspSense_t *pSense; 5660 smIniScsiCmnd_t *scsiCmnd; 5661 smIORequest_t *smOrgIORequest; 5662 5663 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 5664 bit32 ataStatus = 0; 5665 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 5666 5667 SM_DBG2(("smsatSynchronizeCache10n16CB: start\n")); 5668 SM_DBG5(("smsatSynchronizeCache10n16CB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 5669 5670 /* internally generate smIOContext */ 5671 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 5672 satIOContext = (smSatIOContext_t *) ioContext; 5673 satIntIo = satIOContext->satIntIoContext; 5674 oneDeviceData = satIOContext->pSatDevData; 5675 hostToDevFis = satIOContext->pFis; 5676 smRoot = oneDeviceData->smRoot; 5677 smIntRoot = (smIntRoot_t *)smRoot->smData; 5678 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 5679 5680 /* SPC: Self-Test Result Log page */ 5681 if (satIntIo == agNULL) 5682 { 5683 SM_DBG4(("smsatSynchronizeCache10n16CB: External smSatInternalIo_t satIntIoContext\n")); 5684 satOrgIOContext = satIOContext; 5685 smOrgIORequest = smIORequestBody->smIORequest; 5686 pSense = satIOContext->pSense; 5687 scsiCmnd = satIOContext->pScsiCmnd; 5688 } 5689 else 5690 { 5691 SM_DBG4(("smsatSynchronizeCache10n16CB: Internal smSatInternalIo_t satIntIoContext\n")); 5692 satOrgIOContext = satIOContext->satOrgIOContext; 5693 if (satOrgIOContext == agNULL) 5694 { 5695 SM_DBG4(("smsatSynchronizeCache10n16CB: satOrgIOContext is NULL, wrong\n")); 5696 return; 5697 } 5698 else 5699 { 5700 SM_DBG4(("smsatSynchronizeCache10n16CB: satOrgIOContext is NOT NULL\n")); 5701 } 5702 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 5703 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 5704 5705 pSense = satOrgIOContext->pSense; 5706 scsiCmnd = satOrgIOContext->pScsiCmnd; 5707 } 5708 5709 smIORequestBody->ioCompleted = agTRUE; 5710 smIORequestBody->ioStarted = agFALSE; 5711 5712 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 5713 { 5714 SM_DBG1(("smsatSynchronizeCache10n16CB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 5715 5716 tdsmIOCompletedCB( 5717 smRoot, 5718 smOrgIORequest, 5719 smIOFailed, 5720 smDetailOtherError, 5721 agNULL, 5722 satOrgIOContext->interruptContext 5723 ); 5724 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5725 5726 smsatFreeIntIoResource( smRoot, 5727 oneDeviceData, 5728 satIntIo); 5729 return; 5730 } 5731 5732 if( agIOStatus != OSSA_IO_SUCCESS) 5733 { 5734 /* only agsaFisRegDeviceToHost_t is expected */ 5735 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 5736 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 5737 } 5738 5739 if( agIOStatus != OSSA_IO_SUCCESS) 5740 { 5741 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 5742 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 5743 ) 5744 { 5745 /* for debugging */ 5746 if( agIOStatus != OSSA_IO_SUCCESS) 5747 { 5748 SM_DBG1(("smsatSynchronizeCache10n16CB: FAILED, NOT IO_SUCCESS!!!\n")); 5749 } 5750 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 5751 { 5752 SM_DBG1(("smsatSynchronizeCache10n16CB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 5753 } 5754 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 5755 (ataStatus & DF_ATA_STATUS_MASK) 5756 ) 5757 { 5758 SM_DBG1(("smsatSynchronizeCache10n16CB: FAILED, FAILED, error status!!!\n")); 5759 } 5760 5761 5762 /* Process abort case */ 5763 if (agIOStatus == OSSA_IO_ABORTED) 5764 { 5765 smsatProcessAbort(smRoot, 5766 smOrgIORequest, 5767 satOrgIOContext 5768 ); 5769 5770 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5771 5772 smsatFreeIntIoResource( smRoot, 5773 oneDeviceData, 5774 satIntIo); 5775 return; 5776 } 5777 5778 switch (hostToDevFis->h.command) 5779 { 5780 case SAT_FLUSH_CACHE: 5781 SM_DBG1(("smsatSynchronizeCache10n16CB: SAT_FLUSH_CACHE failed!!!\n")); 5782 /* checking IMMED bit */ 5783 if (scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK) 5784 { 5785 smsatSetDeferredSensePayload( pSense, 5786 SCSI_SNSKEY_NO_SENSE, 5787 0, 5788 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5789 satOrgIOContext); 5790 } 5791 else 5792 { 5793 smsatSetDeferredSensePayload( pSense, 5794 SCSI_SNSKEY_NO_SENSE, 5795 0, 5796 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5797 satOrgIOContext); 5798 } 5799 5800 5801 tdsmIOCompletedCB( smRoot, 5802 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5803 smIOSuccess, 5804 SCSI_STAT_CHECK_CONDITION, 5805 satOrgIOContext->pSmSenseData, 5806 satOrgIOContext->interruptContext ); 5807 5808 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5809 5810 smsatFreeIntIoResource( smRoot, 5811 oneDeviceData, 5812 satIntIo); 5813 return; 5814 break; 5815 case SAT_FLUSH_CACHE_EXT: 5816 SM_DBG1(("smsatSynchronizeCache10n16CB: SAT_FLUSH_CACHE_EXT failed!!!\n")); 5817 /* checking IMMED bit */ 5818 if (scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK) 5819 { 5820 smsatSetDeferredSensePayload( pSense, 5821 SCSI_SNSKEY_NO_SENSE, 5822 0, 5823 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5824 satOrgIOContext); 5825 } 5826 else 5827 { 5828 smsatSetDeferredSensePayload( pSense, 5829 SCSI_SNSKEY_NO_SENSE, 5830 0, 5831 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5832 satOrgIOContext); 5833 } 5834 5835 5836 tdsmIOCompletedCB( smRoot, 5837 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5838 smIOSuccess, 5839 SCSI_STAT_CHECK_CONDITION, 5840 satOrgIOContext->pSmSenseData, 5841 satOrgIOContext->interruptContext ); 5842 5843 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5844 5845 smsatFreeIntIoResource( smRoot, 5846 oneDeviceData, 5847 satIntIo); 5848 return; 5849 break; 5850 default: 5851 SM_DBG1(("smsatSynchronizeCache10n16CB: error unknown command 0x%x!!!\n", hostToDevFis->h.command)); 5852 smsatSetSensePayload( pSense, 5853 SCSI_SNSKEY_NO_SENSE, 5854 0, 5855 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5856 satOrgIOContext); 5857 5858 5859 tdsmIOCompletedCB( smRoot, 5860 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5861 smIOSuccess, 5862 SCSI_STAT_CHECK_CONDITION, 5863 satOrgIOContext->pSmSenseData, 5864 satOrgIOContext->interruptContext ); 5865 5866 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5867 5868 smsatFreeIntIoResource( smRoot, 5869 oneDeviceData, 5870 satIntIo); 5871 return; 5872 break; 5873 } 5874 5875 return; 5876 } /* end of error checking */ 5877 } 5878 5879 /* prcessing the success case */ 5880 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 5881 5882 smsatFreeIntIoResource( smRoot, 5883 oneDeviceData, 5884 satIntIo); 5885 5886 5887 switch (hostToDevFis->h.command) 5888 { 5889 case SAT_FLUSH_CACHE: 5890 SM_DBG5(("smsatSynchronizeCache10n16CB: SAT_FLUSH_CACHE success\n")); 5891 5892 /* checking IMMED bit */ 5893 if ( !(scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK)) 5894 { 5895 tdsmIOCompletedCB( smRoot, 5896 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5897 smIOSuccess, 5898 SCSI_STAT_GOOD, 5899 agNULL, 5900 satOrgIOContext->interruptContext ); 5901 return; 5902 } 5903 5904 5905 break; 5906 case SAT_FLUSH_CACHE_EXT: 5907 SM_DBG5(("smsatSynchronizeCache10n16CB: SAT_FLUSH_CACHE_EXT success\n")); 5908 5909 /* checking IMMED bit */ 5910 if ( !(scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK)) 5911 { 5912 tdsmIOCompletedCB( smRoot, 5913 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5914 smIOSuccess, 5915 SCSI_STAT_GOOD, 5916 agNULL, 5917 satOrgIOContext->interruptContext ); 5918 return; 5919 } 5920 5921 break; 5922 default: 5923 SM_DBG5(("smsatSynchronizeCache10n16CB: error unknown command 0x%x\n", hostToDevFis->h.command)); 5924 smsatSetSensePayload( pSense, 5925 SCSI_SNSKEY_NO_SENSE, 5926 0, 5927 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5928 satOrgIOContext); 5929 5930 5931 tdsmIOCompletedCB( smRoot, 5932 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 5933 smIOSuccess, 5934 SCSI_STAT_CHECK_CONDITION, 5935 satOrgIOContext->pSmSenseData, 5936 satOrgIOContext->interruptContext ); 5937 5938 return; 5939 break; 5940 } 5941 5942 return; 5943 } 5944 5945 //qqqqqqqq 5946 osGLOBAL void 5947 smsatNonChainedWriteNVerifyCB( 5948 agsaRoot_t *agRoot, 5949 agsaIORequest_t *agIORequest, 5950 bit32 agIOStatus, 5951 agsaFisHeader_t *agFirstDword, 5952 bit32 agIOInfoLen, 5953 void *agParam, 5954 void *ioContext 5955 ) 5956 { 5957 /* 5958 In the process of WriteAndVerify10 5959 Process SAT_WRITE_DMA_FUA_EXT 5960 Process SAT_WRITE_DMA_EXT 5961 Process SAT_WRITE_SECTORS_EXT 5962 Process SAT_WRITE_FPDMA_QUEUED 5963 Process SAT_READ_VERIFY_SECTORS 5964 Process SAT_READ_VERIFY_SECTORS_EXT 5965 chained command 5966 */ 5967 5968 5969 smRoot_t *smRoot = agNULL; 5970 smIntRoot_t *smIntRoot = agNULL; 5971 smIntContext_t *smAllShared = agNULL; 5972 smIORequestBody_t *smIORequestBody; 5973 smIORequestBody_t *smOrgIORequestBody; 5974 smSatIOContext_t *satIOContext; 5975 smSatIOContext_t *satOrgIOContext; 5976 smSatIOContext_t *satNewIOContext; 5977 smSatInternalIo_t *satIntIo; 5978 smSatInternalIo_t *satNewIntIo = agNULL; 5979 // satDeviceData_t *satDevData; 5980 smDeviceData_t *oneDeviceData; 5981 5982 smScsiRspSense_t *pSense; 5983 smIniScsiCmnd_t *scsiCmnd; 5984 smIORequest_t *smOrgIORequest; 5985 5986 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 5987 bit32 ataStatus = 0; 5988 bit32 status; 5989 smScsiInitiatorRequest_t *smScsiRequest; /* smScsiXchg */ 5990 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 5991 agsaFisSetDevBitsHeader_t *statSetDevBitFisHeader = agNULL; 5992 5993 /* internally generate smIOContext */ 5994 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 5995 satIOContext = (smSatIOContext_t *) ioContext; 5996 satIntIo = satIOContext->satIntIoContext; 5997 oneDeviceData = satIOContext->pSatDevData; 5998 hostToDevFis = satIOContext->pFis; 5999 smRoot = oneDeviceData->smRoot; 6000 smIntRoot = (smIntRoot_t *)smRoot->smData; 6001 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 6002 6003 /* SPC: Self-Test Result Log page */ 6004 smScsiRequest = satIOContext->smScsiXchg; 6005 6006 SM_DBG2(("smsatNonChainedWriteNVerifyCB: start\n")); 6007 SM_DBG5(("smsatNonChainedWriteNVerifyCB: start agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 6008 6009 6010 if (satIntIo == agNULL) 6011 { 6012 SM_DBG4(("smsatNonChainedWriteNVerifyCB: External smSatInternalIo_t satIntIoContext\n")); 6013 satOrgIOContext = satIOContext; 6014 smOrgIORequest = smIORequestBody->smIORequest; 6015 pSense = satOrgIOContext->pSense; 6016 scsiCmnd = satOrgIOContext->pScsiCmnd; 6017 } 6018 else 6019 { 6020 SM_DBG4(("smsatNonChainedWriteNVerifyCB: Internal smSatInternalIo_t satIntIoContext\n")); 6021 satOrgIOContext = satIOContext->satOrgIOContext; 6022 if (satOrgIOContext == agNULL) 6023 { 6024 SM_DBG4(("smsatNonChainedWriteNVerifyCB: satOrgIOContext is NULL, wrong\n")); 6025 return; 6026 } 6027 else 6028 { 6029 SM_DBG4(("smsatNonChainedWriteNVerifyCB: satOrgIOContext is NOT NULL\n")); 6030 } 6031 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 6032 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 6033 6034 pSense = satOrgIOContext->pSense; 6035 scsiCmnd = satOrgIOContext->pScsiCmnd; 6036 } 6037 6038 smIORequestBody->ioCompleted = agTRUE; 6039 smIORequestBody->ioStarted = agFALSE; 6040 6041 6042 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 6043 { 6044 SM_DBG1(("smsatNonChainedWriteNVerifyCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 6045 tdsmIOCompletedCB( smRoot, 6046 smOrgIORequest, 6047 smIOFailed, 6048 smDetailOtherError, 6049 agNULL, 6050 satOrgIOContext->interruptContext 6051 ); 6052 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6053 6054 smsatFreeIntIoResource( smRoot, 6055 oneDeviceData, 6056 satIntIo); 6057 return; 6058 } 6059 6060 6061 if (agIOStatus != OSSA_IO_SUCCESS) 6062 { 6063 /* 6064 FIS type should be either REG_DEV_TO_HOST_FIS or SET_DEV_BITS_FIS 6065 */ 6066 /* First, assumed to be Reg Device to Host FIS */ 6067 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 6068 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 6069 } 6070 6071 if (agIOStatus != OSSA_IO_SUCCESS) 6072 { 6073 if (statDevToHostFisHeader->fisType == SET_DEV_BITS_FIS) 6074 { 6075 statSetDevBitFisHeader = (agsaFisSetDevBitsHeader_t *)&(agFirstDword->D2H); 6076 6077 /* Get ATA Status register */ 6078 ataStatus = (statSetDevBitFisHeader->statusHi_Lo & 0x70); /* bits 4,5,6 */ 6079 ataStatus = ataStatus | (statSetDevBitFisHeader->statusHi_Lo & 0x07); /* bits 0,1,2 */ 6080 } 6081 } 6082 6083 6084 if( agIOStatus != OSSA_IO_SUCCESS) 6085 { 6086 /* 6087 checking IO status, FIS type and error status 6088 FIS type should be either REG_DEV_TO_HOST_FIS or SET_DEV_BITS_FIS 6089 Both have fisType in the same location 6090 */ 6091 if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 6092 (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS)) || 6093 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 6094 ) 6095 { 6096 /* for debugging */ 6097 if( agIOStatus != OSSA_IO_SUCCESS) 6098 { 6099 SM_DBG1(("smsatNonChainedWriteNVerifyCB: FAILED, NOT IO_SUCCESS!!!\n")); 6100 } 6101 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 6102 { 6103 SM_DBG1(("smsatNonChainedWriteNVerifyCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 6104 } 6105 else if (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 6106 { 6107 SM_DBG1(("smsatNonChainedWriteNVerifyCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 6108 } 6109 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 6110 (ataStatus & DF_ATA_STATUS_MASK) 6111 ) 6112 { 6113 SM_DBG1(("smsatNonChainedWriteNVerifyCB: FAILED, FAILED, error status!!!\n")); 6114 } 6115 6116 6117 /* Process abort case */ 6118 if (agIOStatus == OSSA_IO_ABORTED) 6119 { 6120 smsatProcessAbort(smRoot, 6121 smOrgIORequest, 6122 satOrgIOContext 6123 ); 6124 6125 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6126 6127 smsatFreeIntIoResource( smRoot, 6128 oneDeviceData, 6129 satIntIo); 6130 return; 6131 } 6132 6133 /* for debugging */ 6134 switch (hostToDevFis->h.command) 6135 { 6136 case SAT_WRITE_DMA_FUA_EXT: 6137 SM_DBG1(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_DMA_FUA_EXT!!!\n")); 6138 break; 6139 case SAT_WRITE_DMA_EXT: 6140 SM_DBG1(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_DMA_EXT!!!\n")); 6141 break; 6142 case SAT_WRITE_SECTORS_EXT: 6143 SM_DBG1(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_SECTORS_EXT!!!\n")); 6144 break; 6145 case SAT_WRITE_FPDMA_QUEUED: 6146 SM_DBG1(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_FPDMA_QUEUED!!!\n")); 6147 break; 6148 case SAT_READ_VERIFY_SECTORS: 6149 SM_DBG1(("smsatNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS!!!\n")); 6150 break; 6151 case SAT_READ_VERIFY_SECTORS_EXT: 6152 SM_DBG1(("smsatNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS_EXT!!!\n")); 6153 break; 6154 default: 6155 SM_DBG1(("smsatNonChainedWriteNVerifyCB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 6156 break; 6157 } 6158 6159 smsatSetSensePayload( pSense, 6160 SCSI_SNSKEY_NO_SENSE, 6161 0, 6162 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6163 satOrgIOContext); 6164 6165 tdsmIOCompletedCB( smRoot, 6166 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6167 smIOSuccess, 6168 SCSI_STAT_CHECK_CONDITION, 6169 satOrgIOContext->pSmSenseData, 6170 satOrgIOContext->interruptContext ); 6171 6172 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6173 6174 smsatFreeIntIoResource( smRoot, 6175 oneDeviceData, 6176 satIntIo); 6177 return; 6178 } /* end error checking */ 6179 } 6180 6181 /* process success from this point on */ 6182 6183 switch (hostToDevFis->h.command) 6184 { 6185 case SAT_WRITE_DMA_FUA_EXT: 6186 SM_DBG5(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_DMA_FUA_EXT success\n")); 6187 break; 6188 case SAT_WRITE_DMA_EXT: 6189 SM_DBG5(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_DMA_EXT success\n")); 6190 break; 6191 case SAT_WRITE_SECTORS_EXT: 6192 SM_DBG5(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_SECTORS_EXT succes\n")); 6193 6194 break; 6195 case SAT_WRITE_FPDMA_QUEUED: 6196 SM_DBG5(("smsatNonChainedWriteNVerifyCB: SAT_WRITE_FPDMA_QUEUED succes\n")); 6197 break; 6198 case SAT_READ_VERIFY_SECTORS: 6199 SM_DBG5(("smsatNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS succes\n")); 6200 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6201 6202 /* free */ 6203 smsatFreeIntIoResource( smRoot, 6204 oneDeviceData, 6205 satIntIo); 6206 6207 /* return stat_good */ 6208 tdsmIOCompletedCB( smRoot, 6209 smOrgIORequest, 6210 smIOSuccess, 6211 SCSI_STAT_GOOD, 6212 agNULL, 6213 satOrgIOContext->interruptContext ); 6214 return; 6215 break; 6216 case SAT_READ_VERIFY_SECTORS_EXT: 6217 SM_DBG5(("smsatNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS_EXT succes\n")); 6218 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6219 6220 /* free */ 6221 smsatFreeIntIoResource( smRoot, 6222 oneDeviceData, 6223 satIntIo); 6224 6225 /* return stat_good */ 6226 tdsmIOCompletedCB( smRoot, 6227 smOrgIORequest, 6228 smIOSuccess, 6229 SCSI_STAT_GOOD, 6230 agNULL, 6231 satOrgIOContext->interruptContext ); 6232 return; 6233 break; 6234 default: 6235 SM_DBG1(("smsatNonChainedWriteNVerifyCB: error default case command 0x%x success!!!\n", hostToDevFis->h.command)); 6236 6237 smsatSetSensePayload( pSense, 6238 SCSI_SNSKEY_NO_SENSE, 6239 0, 6240 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6241 satOrgIOContext); 6242 6243 tdsmIOCompletedCB( smRoot, 6244 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6245 smIOSuccess, 6246 SCSI_STAT_CHECK_CONDITION, 6247 satOrgIOContext->pSmSenseData, 6248 satOrgIOContext->interruptContext ); 6249 6250 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6251 6252 smsatFreeIntIoResource( smRoot, 6253 oneDeviceData, 6254 satIntIo); 6255 return; 6256 break; 6257 } 6258 6259 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6260 6261 /* free */ 6262 smsatFreeIntIoResource( smRoot, 6263 oneDeviceData, 6264 satIntIo); 6265 6266 satNewIntIo = smsatAllocIntIoResource( smRoot, 6267 smOrgIORequest, 6268 oneDeviceData, 6269 0, 6270 satNewIntIo); 6271 if (satNewIntIo == agNULL) 6272 { 6273 smsatSetSensePayload( pSense, 6274 SCSI_SNSKEY_NO_SENSE, 6275 0, 6276 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6277 satOrgIOContext); 6278 6279 tdsmIOCompletedCB( smRoot, 6280 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6281 smIOSuccess, 6282 SCSI_STAT_CHECK_CONDITION, 6283 satOrgIOContext->pSmSenseData, 6284 satOrgIOContext->interruptContext ); 6285 SM_DBG1(("smsatNonChainedWriteNVerifyCB: momory allocation fails!!!\n")); 6286 return; 6287 } /* end memory allocation */ 6288 6289 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 6290 smOrgIORequest, 6291 oneDeviceData, 6292 scsiCmnd, 6293 satOrgIOContext 6294 ); 6295 6296 /* sends ATA verify command(READ_VERIFY_SECTORS or READ_VERIFY_SECTORS_EXT) */ 6297 status = smsatNonChainedWriteNVerify_Verify(smRoot, 6298 &satNewIntIo->satIntSmIORequest, 6299 satNewIOContext->psmDeviceHandle, 6300 smScsiRequest, /* orginal from OS layer */ 6301 satNewIOContext 6302 ); 6303 6304 6305 if (status != SM_RC_SUCCESS) 6306 { 6307 /* sending ATA command fails */ 6308 smsatFreeIntIoResource( smRoot, 6309 oneDeviceData, 6310 satNewIntIo); 6311 smsatSetSensePayload( pSense, 6312 SCSI_SNSKEY_NO_SENSE, 6313 0, 6314 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6315 satOrgIOContext); 6316 6317 tdsmIOCompletedCB( smRoot, 6318 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6319 smIOSuccess, 6320 SCSI_STAT_CHECK_CONDITION, 6321 satOrgIOContext->pSmSenseData, 6322 satOrgIOContext->interruptContext ); 6323 SM_DBG1(("smsatNonChainedWriteNVerifyCB: calling satWriteAndVerify10_1 fails!!!\n")); 6324 return; 6325 } /* end send fails */ 6326 6327 return; 6328 6329 } 6330 6331 osGLOBAL void 6332 smsatChainedWriteNVerifyCB( 6333 agsaRoot_t *agRoot, 6334 agsaIORequest_t *agIORequest, 6335 bit32 agIOStatus, 6336 agsaFisHeader_t *agFirstDword, 6337 bit32 agIOInfoLen, 6338 void *agParam, 6339 void *ioContext 6340 ) 6341 { 6342 /* 6343 send write in loop 6344 then, send verify in loop 6345 */ 6346 6347 smRoot_t *smRoot = agNULL; 6348 smIntRoot_t *smIntRoot = agNULL; 6349 smIntContext_t *smAllShared = agNULL; 6350 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6351 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6352 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 6353 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 6354 smIORequestBody_t *smIORequestBody; 6355 smIORequestBody_t *smOrgIORequestBody; 6356 smSatIOContext_t *satIOContext; 6357 smSatIOContext_t *satOrgIOContext; 6358 smSatIOContext_t *satNewIOContext; 6359 smSatInternalIo_t *satIntIo; 6360 smSatInternalIo_t *satNewIntIo = agNULL; 6361 // satDeviceData_t *satDevData; 6362 smDeviceData_t *oneDeviceData; 6363 6364 smScsiRspSense_t *pSense; 6365 smIniScsiCmnd_t *scsiCmnd; 6366 smIORequest_t *smOrgIORequest; 6367 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 6368 bit32 ataStatus = 0; 6369 bit32 dataLength; 6370 bit32 status = tiError; 6371 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 6372 6373 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 6374 satIOContext = (smSatIOContext_t *) ioContext; 6375 satIntIo = satIOContext->satIntIoContext; 6376 oneDeviceData = satIOContext->pSatDevData; 6377 hostToDevFis = satIOContext->pFis; 6378 smRoot = oneDeviceData->smRoot; 6379 smIntRoot = (smIntRoot_t *)smRoot->smData; 6380 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 6381 SM_DBG2(("smsatChainedWriteNVerifyCB: start\n")); 6382 SM_DBG6(("smsatChainedWriteNVerifyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 6383 agIORequest, agIOStatus, agIOInfoLen)); 6384 6385 if (satIntIo == agNULL) 6386 { 6387 SM_DBG5(("smsatChainedWriteNVerifyCB: External smSatInternalIo_t satIntIoContext\n")); 6388 satOrgIOContext = satIOContext; 6389 smOrgIORequest = smIORequestBody->smIORequest; 6390 pSense = satIOContext->pSense; 6391 scsiCmnd = satIOContext->pScsiCmnd; 6392 } 6393 else 6394 { 6395 SM_DBG5(("smsatChainedWriteNVerifyCB: Internal smSatInternalIo_t satIntIoContext\n")); 6396 satOrgIOContext = satIOContext->satOrgIOContext; 6397 if (satOrgIOContext == agNULL) 6398 { 6399 SM_DBG5(("smsatChainedWriteNVerifyCB: satOrgIOContext is NULL, wrong\n")); 6400 return; 6401 } 6402 else 6403 { 6404 SM_DBG5(("smsatChainedWriteNVerifyCB: satOrgIOContext is NOT NULL\n")); 6405 } 6406 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 6407 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 6408 6409 pSense = satOrgIOContext->pSense; 6410 scsiCmnd = satOrgIOContext->pScsiCmnd; 6411 } 6412 6413 smIORequestBody->ioCompleted = agTRUE; 6414 smIORequestBody->ioStarted = agFALSE; 6415 6416 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 6417 { 6418 SM_DBG1(("smsatChainedWriteNVerifyCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 6419 smsatSetSensePayload( pSense, 6420 SCSI_SNSKEY_NO_SENSE, 6421 0, 6422 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6423 satOrgIOContext); 6424 6425 tdsmIOCompletedCB( smRoot, 6426 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6427 smIOSuccess, 6428 SCSI_STAT_CHECK_CONDITION, 6429 satOrgIOContext->pSmSenseData, 6430 satOrgIOContext->interruptContext ); 6431 6432 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6433 6434 smsatFreeIntIoResource( smRoot, 6435 oneDeviceData, 6436 satIntIo); 6437 return; 6438 } 6439 6440 /* 6441 checking IO status, FIS type and error status 6442 */ 6443 if (agIOStatus != OSSA_IO_SUCCESS) 6444 { 6445 /* agsaFisPioSetup_t or agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for read 6446 agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for write 6447 first, assumed to be Reg Device to Host FIS 6448 This is OK to just find fis type 6449 */ 6450 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 6451 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 6452 /* for debugging */ 6453 if( (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) && 6454 (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 6455 (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 6456 ) 6457 { 6458 SM_DBG1(("smsatChainedWriteNVerifyCB: FAILED, Wrong FIS type 0x%x!!!\n", statDevToHostFisHeader->fisType)); 6459 } 6460 6461 /* for debugging */ 6462 if ( (ataStatus & ERR_ATA_STATUS_MASK) || 6463 (ataStatus & DF_ATA_STATUS_MASK) 6464 ) 6465 { 6466 SM_DBG1(("smsatChainedWriteNVerifyCB: FAILED, error status and command 0x%x!!!\n", hostToDevFis->h.command)); 6467 } 6468 6469 /* the function below handles abort case */ 6470 smsatDelayedProcessAbnormalCompletion(agRoot, 6471 agIORequest, 6472 agIOStatus, 6473 agFirstDword, 6474 agIOInfoLen, 6475 agParam, 6476 satIOContext); 6477 6478 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6479 smsatFreeIntIoResource( smRoot, 6480 oneDeviceData, 6481 satIntIo); 6482 return; 6483 } /* end of error */ 6484 6485 /* process the success case */ 6486 switch (hostToDevFis->h.command) 6487 { 6488 case SAT_WRITE_DMA: /* fall through */ 6489 case SAT_WRITE_SECTORS:/* fall through */ 6490 // case SAT_WRITE_DMA_FUA_EXT: /* fall through */ 6491 case SAT_WRITE_DMA_EXT: /* fall through */ 6492 case SAT_WRITE_SECTORS_EXT: /* fall through */ 6493 case SAT_WRITE_FPDMA_QUEUED: 6494 6495 SM_DBG5(("smsatChainedWriteNVerifyCB: WRITE success case\n")); 6496 6497 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6498 6499 /* done with internally genereated SAT_SMART_RETURN_STATUS */ 6500 smsatFreeIntIoResource( smRoot, 6501 oneDeviceData, 6502 satIntIo); 6503 /* let's loop till TL */ 6504 6505 /* lba = lba + tl 6506 loopnum--; 6507 if (loopnum == 0) done 6508 */ 6509 (satOrgIOContext->LoopNum)--; 6510 6511 if (satOrgIOContext->superIOFlag) 6512 { 6513 dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 6514 } 6515 else 6516 { 6517 dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 6518 } 6519 6520 satNewIntIo = smsatAllocIntIoResource( smRoot, 6521 smOrgIORequest, 6522 oneDeviceData, 6523 dataLength, 6524 satNewIntIo); 6525 if (satNewIntIo == agNULL) 6526 { 6527 tdsmIOCompletedCB( smRoot, 6528 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6529 smIOFailed, 6530 smDetailOtherError, 6531 agNULL, 6532 satOrgIOContext->interruptContext ); 6533 6534 SM_DBG1(("smsatChainedWriteNVerifyCB: momory allocation fails!!!\n")); 6535 return; 6536 } /* end of memory allocation failure */ 6537 6538 /* 6539 * Need to initialize all the fields within satIOContext 6540 */ 6541 6542 satNewIOContext = smsatPrepareNewIO( 6543 satNewIntIo, 6544 smOrgIORequest, 6545 oneDeviceData, 6546 scsiCmnd, 6547 satOrgIOContext 6548 ); 6549 6550 if (satOrgIOContext->LoopNum == 0) 6551 { 6552 /* 6553 done with write 6554 start with verify 6555 */ 6556 satOrgIOContext->LoopNum = satOrgIOContext->LoopNum2; 6557 status = smsatChainedWriteNVerify_Start_Verify(smRoot, 6558 &satNewIntIo->satIntSmIORequest, 6559 satNewIOContext->psmDeviceHandle, 6560 &satNewIntIo->satIntSmScsiXchg, 6561 satNewIOContext); 6562 } 6563 else 6564 { 6565 status = smsatChainedWriteNVerify_Write(smRoot, 6566 &satNewIntIo->satIntSmIORequest, 6567 satNewIOContext->psmDeviceHandle, 6568 &satNewIntIo->satIntSmScsiXchg, 6569 satNewIOContext); 6570 } 6571 6572 if (status != SM_RC_SUCCESS) 6573 { 6574 smsatFreeIntIoResource( smRoot, 6575 oneDeviceData, 6576 satNewIntIo); 6577 tdsmIOCompletedCB( smRoot, 6578 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6579 smIOFailed, 6580 smDetailOtherError, 6581 agNULL, 6582 satOrgIOContext->interruptContext ); 6583 SM_DBG1(("smsatChainedWriteNVerifyCB: calling satChainedWriteNVerify_Write fails!!!\n")); 6584 return; 6585 } 6586 6587 break; 6588 6589 case SAT_READ_VERIFY_SECTORS: /* fall through */ 6590 case SAT_READ_VERIFY_SECTORS_EXT: 6591 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6592 6593 /* done with internally genereated SAT_SMART_RETURN_STATUS */ 6594 smsatFreeIntIoResource( smRoot, 6595 oneDeviceData, 6596 satIntIo); 6597 /* let's loop till TL */ 6598 6599 /* lba = lba + tl 6600 loopnum--; 6601 if (loopnum == 0) done 6602 */ 6603 (satOrgIOContext->LoopNum)--; 6604 if (satOrgIOContext->LoopNum == 0) 6605 { 6606 /* 6607 done with write and verify 6608 */ 6609 tdsmIOCompletedCB( smRoot, 6610 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6611 smIOSuccess, 6612 SCSI_STAT_GOOD, 6613 agNULL, 6614 satOrgIOContext->interruptContext ); 6615 return; 6616 } 6617 6618 if (satOrgIOContext->superIOFlag) 6619 { 6620 dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 6621 } 6622 else 6623 { 6624 dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->smScsiXchg)->scsiCmnd.expDataLength; 6625 } 6626 6627 satNewIntIo = smsatAllocIntIoResource( smRoot, 6628 smOrgIORequest, 6629 oneDeviceData, 6630 dataLength, 6631 satNewIntIo); 6632 if (satNewIntIo == agNULL) 6633 { 6634 tdsmIOCompletedCB( smRoot, 6635 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6636 smIOFailed, 6637 smDetailOtherError, 6638 agNULL, 6639 satOrgIOContext->interruptContext ); 6640 6641 SM_DBG1(("smsatChainedWriteNVerifyCB: momory allocation fails!!!\n")); 6642 return; 6643 } /* end of memory allocation failure */ 6644 6645 /* 6646 * Need to initialize all the fields within satIOContext 6647 */ 6648 6649 satNewIOContext = smsatPrepareNewIO( 6650 satNewIntIo, 6651 smOrgIORequest, 6652 oneDeviceData, 6653 scsiCmnd, 6654 satOrgIOContext 6655 ); 6656 status = smsatChainedWriteNVerify_Verify(smRoot, 6657 &satNewIntIo->satIntSmIORequest, 6658 satNewIOContext->psmDeviceHandle, 6659 &satNewIntIo->satIntSmScsiXchg, 6660 satNewIOContext); 6661 6662 if (status != SM_RC_SUCCESS) 6663 { 6664 smsatFreeIntIoResource( smRoot, 6665 oneDeviceData, 6666 satNewIntIo); 6667 tdsmIOCompletedCB( smRoot, 6668 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6669 smIOFailed, 6670 smDetailOtherError, 6671 agNULL, 6672 satOrgIOContext->interruptContext ); 6673 SM_DBG1(("smsatChainedWriteNVerifyCB: calling satChainedWriteNVerify_Verify fails!!!\n")); 6674 return; 6675 } 6676 6677 break; 6678 6679 default: 6680 SM_DBG1(("smsatChainedWriteNVerifyCB: success but default case command 0x%x!!!\n",hostToDevFis->h.command)); 6681 tdsmIOCompletedCB( smRoot, 6682 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6683 smIOFailed, 6684 smDetailOtherError, 6685 agNULL, 6686 satOrgIOContext->interruptContext ); 6687 6688 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6689 6690 smsatFreeIntIoResource( smRoot, 6691 oneDeviceData, 6692 satIntIo); 6693 6694 break; 6695 } 6696 6697 6698 return; 6699 } 6700 6701 osGLOBAL void 6702 smsatReadMediaSerialNumberCB( 6703 agsaRoot_t *agRoot, 6704 agsaIORequest_t *agIORequest, 6705 bit32 agIOStatus, 6706 agsaFisHeader_t *agFirstDword, 6707 bit32 agIOInfoLen, 6708 agsaFrameHandle_t agFrameHandle, 6709 void *ioContext 6710 ) 6711 { 6712 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6713 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6714 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 6715 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 6716 smRoot_t *smRoot = agNULL; 6717 smIntRoot_t *smIntRoot = agNULL; 6718 smIntContext_t *smAllShared = agNULL; 6719 smIORequestBody_t *smIORequestBody; 6720 smIORequestBody_t *smOrgIORequestBody; 6721 smSatIOContext_t *satIOContext; 6722 smSatIOContext_t *satOrgIOContext; 6723 smSatInternalIo_t *satIntIo; 6724 // satDeviceData_t *satDevData; 6725 smDeviceData_t *oneDeviceData; 6726 6727 smScsiRspSense_t *pSense; 6728 smIORequest_t *smOrgIORequest; 6729 6730 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 6731 smScsiInitiatorRequest_t *smOrgScsiRequest; /* tiScsiXchg */ 6732 bit8 *pMediaSerialNumber; 6733 bit8 MediaSerialNumber[ZERO_MEDIA_SERIAL_NUMBER_LENGTH] = {0}; 6734 smIniScsiCmnd_t *scsiCmnd; 6735 bit32 allocationLen = 0; 6736 6737 SM_DBG2(("smsatReadMediaSerialNumberCB: start\n")); 6738 SM_DBG4(("smsatReadMediaSerialNumberCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 6739 6740 /* internally generate tiIOContext */ 6741 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 6742 satIOContext = (smSatIOContext_t *) ioContext; 6743 satIntIo = satIOContext->satIntIoContext; 6744 oneDeviceData = satIOContext->pSatDevData; 6745 hostToDevFis = satIOContext->pFis; 6746 smRoot = oneDeviceData->smRoot; 6747 smIntRoot = (smIntRoot_t *)smRoot->smData; 6748 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 6749 6750 if (satIntIo == agNULL) 6751 { 6752 SM_DBG4(("smsatReadMediaSerialNumberCB: External smSatInternalIo_t satIntIoContext\n")); 6753 satOrgIOContext = satIOContext; 6754 smOrgIORequest = smIORequestBody->smIORequest; 6755 pSense = satOrgIOContext->pSense; 6756 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 6757 /* SCSI command response payload to OS layer */ 6758 pMediaSerialNumber = (bit8 *) smOrgScsiRequest->sglVirtualAddr; 6759 /* ATA command response payload */ 6760 scsiCmnd = satOrgIOContext->pScsiCmnd; 6761 } 6762 else 6763 { 6764 SM_DBG4(("smsatReadMediaSerialNumberCB: Internal smSatInternalIo_t satIntIoContext\n")); 6765 satOrgIOContext = satIOContext->satOrgIOContext; 6766 if (satOrgIOContext == agNULL) 6767 { 6768 SM_DBG4(("smsatReadMediaSerialNumberCB: satOrgIOContext is NULL, wrong\n")); 6769 return; 6770 } 6771 else 6772 { 6773 SM_DBG4(("smsatReadMediaSerialNumberCB: satOrgIOContext is NOT NULL\n")); 6774 } 6775 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 6776 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 6777 6778 pSense = satOrgIOContext->pSense; 6779 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 6780 /* SCSI command response payload to OS layer */ 6781 pMediaSerialNumber = (bit8 *) smOrgScsiRequest->sglVirtualAddr; 6782 scsiCmnd = satOrgIOContext->pScsiCmnd; 6783 } 6784 6785 smIORequestBody->ioCompleted = agTRUE; 6786 smIORequestBody->ioStarted = agFALSE; 6787 6788 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 6789 { 6790 SM_DBG1(("smsatReadMediaSerialNumberCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 6791 tdsmIOCompletedCB( 6792 smRoot, 6793 smOrgIORequest, 6794 smIOFailed, 6795 smDetailOtherError, 6796 agNULL, 6797 satOrgIOContext->interruptContext 6798 ); 6799 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6800 6801 smsatFreeIntIoResource( smRoot, 6802 oneDeviceData, 6803 satIntIo); 6804 return; 6805 } 6806 6807 if( agIOStatus != OSSA_IO_SUCCESS) 6808 { 6809 /* Process abort case */ 6810 if (agIOStatus == OSSA_IO_ABORTED) 6811 { 6812 smsatProcessAbort(smRoot, 6813 smOrgIORequest, 6814 satOrgIOContext 6815 ); 6816 6817 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6818 6819 smsatFreeIntIoResource( smRoot, 6820 oneDeviceData, 6821 satIntIo); 6822 return; 6823 } 6824 smsatSetSensePayload( pSense, 6825 SCSI_SNSKEY_NOT_READY, 6826 0, 6827 SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 6828 satOrgIOContext); 6829 6830 tdsmIOCompletedCB( smRoot, 6831 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6832 smIOSuccess, 6833 SCSI_STAT_CHECK_CONDITION, 6834 satOrgIOContext->pSmSenseData, 6835 satOrgIOContext->interruptContext ); 6836 6837 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6838 6839 smsatFreeIntIoResource( smRoot, 6840 oneDeviceData, 6841 satIntIo); 6842 return; 6843 } 6844 6845 /* process success case */ 6846 allocationLen = (scsiCmnd->cdb[6] << (8*3)) + (scsiCmnd->cdb[7] << (8*2)) 6847 + (scsiCmnd->cdb[8] << 8) + scsiCmnd->cdb[9]; 6848 allocationLen = MIN(allocationLen, scsiCmnd->expDataLength); 6849 SM_DBG5(("smsatReadMediaSerialNumberCB: allocationLen in CDB %d 0x%x\n", allocationLen,allocationLen)); 6850 6851 if (hostToDevFis->h.command == SAT_READ_SECTORS || 6852 hostToDevFis->h.command == SAT_READ_SECTORS_EXT 6853 ) 6854 { 6855 MediaSerialNumber[0] = 0; 6856 MediaSerialNumber[1] = 0; 6857 MediaSerialNumber[2] = 0; 6858 MediaSerialNumber[3] = 4; 6859 MediaSerialNumber[4] = 0; 6860 MediaSerialNumber[5] = 0; 6861 MediaSerialNumber[6] = 0; 6862 MediaSerialNumber[7] = 0; 6863 6864 sm_memcpy(pMediaSerialNumber, MediaSerialNumber, MIN(allocationLen, ZERO_MEDIA_SERIAL_NUMBER_LENGTH)); 6865 if (ZERO_MEDIA_SERIAL_NUMBER_LENGTH < allocationLen) 6866 { 6867 SM_DBG1(("smsatReadMediaSerialNumberCB: 1st underrun allocationLen %d len %d !!!\n", allocationLen, ZERO_MEDIA_SERIAL_NUMBER_LENGTH)); 6868 6869 /* underrun */ 6870 tdsmIOCompletedCB( smRoot, 6871 smOrgIORequest, /* == satIntIo->satOrgSmIORequest */ 6872 smIOUnderRun, 6873 allocationLen - ZERO_MEDIA_SERIAL_NUMBER_LENGTH, 6874 agNULL, 6875 satOrgIOContext->interruptContext ); 6876 6877 } 6878 else 6879 { 6880 tdsmIOCompletedCB( smRoot, 6881 smOrgIORequest, 6882 smIOSuccess, 6883 SCSI_STAT_GOOD, 6884 agNULL, 6885 satOrgIOContext->interruptContext); 6886 } 6887 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6888 6889 smsatFreeIntIoResource( smRoot, 6890 oneDeviceData, 6891 satIntIo); 6892 return; 6893 } 6894 else 6895 { 6896 SM_DBG1(("smsatReadMediaSerialNumberCB: error unknown command success 0x%x!!!\n", hostToDevFis->h.command)); 6897 smsatSetSensePayload( pSense, 6898 SCSI_SNSKEY_NO_SENSE, 6899 0, 6900 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6901 satOrgIOContext); 6902 6903 tdsmIOCompletedCB( smRoot, 6904 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 6905 smIOSuccess, 6906 SCSI_STAT_CHECK_CONDITION, 6907 satOrgIOContext->pSmSenseData, 6908 satOrgIOContext->interruptContext ); 6909 6910 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6911 6912 smsatFreeIntIoResource( smRoot, 6913 oneDeviceData, 6914 satIntIo); 6915 6916 return; 6917 } 6918 return; 6919 } 6920 6921 osGLOBAL void 6922 smsatReadBufferCB( 6923 agsaRoot_t *agRoot, 6924 agsaIORequest_t *agIORequest, 6925 bit32 agIOStatus, 6926 agsaFisHeader_t *agFirstDword, 6927 bit32 agIOInfoLen, 6928 agsaFrameHandle_t agFrameHandle, 6929 void *ioContext 6930 ) 6931 { 6932 smRoot_t *smRoot = agNULL; 6933 smIntRoot_t *smIntRoot = agNULL; 6934 smIntContext_t *smAllShared = agNULL; 6935 smIORequestBody_t *smIORequestBody; 6936 smIORequestBody_t *smOrgIORequestBody; 6937 smSatIOContext_t *satIOContext; 6938 smSatIOContext_t *satOrgIOContext; 6939 smSatInternalIo_t *satIntIo; 6940 smDeviceData_t *oneDeviceData; 6941 smScsiRspSense_t *pSense; 6942 smIORequest_t *smOrgIORequest; 6943 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 6944 6945 6946 SM_DBG2(("smsatReadBufferCB: start\n")); 6947 SM_DBG4(("smsatReadBufferCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 6948 /* internally generate tiIOContext */ 6949 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 6950 satIOContext = (smSatIOContext_t *) ioContext; 6951 satIntIo = satIOContext->satIntIoContext; 6952 oneDeviceData = satIOContext->pSatDevData; 6953 hostToDevFis = satIOContext->pFis; 6954 smRoot = oneDeviceData->smRoot; 6955 smIntRoot = (smIntRoot_t *)smRoot->smData; 6956 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 6957 if (satIntIo == agNULL) 6958 { 6959 SM_DBG4(("smsatReadBufferCB: External smSatInternalIo_t satIntIoContext\n")); 6960 satOrgIOContext = satIOContext; 6961 smOrgIORequest = smIORequestBody->smIORequest; 6962 pSense = satOrgIOContext->pSense; 6963 } 6964 else 6965 { 6966 SM_DBG4(("smsatReadBufferCB: Internal smSatInternalIo_t satIntIoContext\n")); 6967 satOrgIOContext = satIOContext->satOrgIOContext; 6968 if (satOrgIOContext == agNULL) 6969 { 6970 SM_DBG4(("smsatReadBufferCB: satOrgIOContext is NULL, wrong\n")); 6971 return; 6972 } 6973 else 6974 { 6975 SM_DBG4(("smsatReadBufferCB: satOrgIOContext is NOT NULL\n")); 6976 } 6977 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 6978 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 6979 pSense = satOrgIOContext->pSense; 6980 } 6981 smIORequestBody->ioCompleted = agTRUE; 6982 smIORequestBody->ioStarted = agFALSE; 6983 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 6984 { 6985 SM_DBG1(("smsatReadBufferCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 6986 tdsmIOCompletedCB( 6987 smRoot, 6988 smOrgIORequest, 6989 smIOFailed, 6990 smDetailOtherError, 6991 agNULL, 6992 satOrgIOContext->interruptContext 6993 ); 6994 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 6995 6996 smsatFreeIntIoResource( smRoot, 6997 oneDeviceData, 6998 satIntIo); 6999 return; 7000 } 7001 7002 if( agIOStatus != OSSA_IO_SUCCESS) 7003 { 7004 /* Process abort case */ 7005 if (agIOStatus == OSSA_IO_ABORTED) 7006 { 7007 smsatProcessAbort(smRoot, 7008 smOrgIORequest, 7009 satOrgIOContext 7010 ); 7011 7012 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7013 7014 smsatFreeIntIoResource( smRoot, 7015 oneDeviceData, 7016 satIntIo); 7017 return; 7018 } 7019 smsatSetSensePayload( pSense, 7020 SCSI_SNSKEY_NOT_READY, 7021 0, 7022 SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 7023 satOrgIOContext); 7024 7025 tdsmIOCompletedCB( smRoot, 7026 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7027 smIOSuccess, 7028 SCSI_STAT_CHECK_CONDITION, 7029 satOrgIOContext->pSmSenseData, 7030 satOrgIOContext->interruptContext ); 7031 7032 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7033 7034 smsatFreeIntIoResource( smRoot, 7035 oneDeviceData, 7036 satIntIo); 7037 return; 7038 } 7039 7040 /* process success case */ 7041 if (hostToDevFis->h.command == SAT_READ_BUFFER ) 7042 { 7043 7044 tdsmIOCompletedCB( smRoot, 7045 smOrgIORequest, 7046 smIOSuccess, 7047 SCSI_STAT_GOOD, 7048 agNULL, 7049 satOrgIOContext->interruptContext); 7050 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7051 7052 smsatFreeIntIoResource( smRoot, 7053 oneDeviceData, 7054 satIntIo); 7055 return; 7056 } 7057 else 7058 { 7059 SM_DBG1(("smsatReadBufferCB: error unknown command success 0x%x!!!\n", hostToDevFis->h.command)); 7060 smsatSetSensePayload( pSense, 7061 SCSI_SNSKEY_NO_SENSE, 7062 0, 7063 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 7064 satOrgIOContext); 7065 7066 tdsmIOCompletedCB( smRoot, 7067 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7068 smIOSuccess, 7069 SCSI_STAT_CHECK_CONDITION, 7070 satOrgIOContext->pSmSenseData, 7071 satOrgIOContext->interruptContext ); 7072 7073 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7074 7075 smsatFreeIntIoResource( smRoot, 7076 oneDeviceData, 7077 satIntIo); 7078 7079 return; 7080 } 7081 7082 return; 7083 } 7084 7085 osGLOBAL void 7086 smsatWriteBufferCB( 7087 agsaRoot_t *agRoot, 7088 agsaIORequest_t *agIORequest, 7089 bit32 agIOStatus, 7090 agsaFisHeader_t *agFirstDword, 7091 bit32 agIOInfoLen, 7092 agsaFrameHandle_t agFrameHandle, 7093 void *ioContext 7094 ) 7095 { 7096 smRoot_t *smRoot = agNULL; 7097 smIntRoot_t *smIntRoot = agNULL; 7098 smIntContext_t *smAllShared = agNULL; 7099 smIORequestBody_t *smIORequestBody; 7100 smIORequestBody_t *smOrgIORequestBody; 7101 smSatIOContext_t *satIOContext; 7102 smSatIOContext_t *satOrgIOContext; 7103 smSatInternalIo_t *satIntIo; 7104 smDeviceData_t *oneDeviceData; 7105 smScsiRspSense_t *pSense; 7106 smIORequest_t *smOrgIORequest; 7107 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 7108 7109 7110 SM_DBG2(("smsatWriteBufferCB: start\n")); 7111 SM_DBG4(("smsatWriteBufferCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 7112 /* internally generate tiIOContext */ 7113 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 7114 satIOContext = (smSatIOContext_t *) ioContext; 7115 satIntIo = satIOContext->satIntIoContext; 7116 oneDeviceData = satIOContext->pSatDevData; 7117 hostToDevFis = satIOContext->pFis; 7118 smRoot = oneDeviceData->smRoot; 7119 smIntRoot = (smIntRoot_t *)smRoot->smData; 7120 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 7121 if (satIntIo == agNULL) 7122 { 7123 SM_DBG4(("smsatWriteBufferCB: External smSatInternalIo_t satIntIoContext\n")); 7124 satOrgIOContext = satIOContext; 7125 smOrgIORequest = smIORequestBody->smIORequest; 7126 pSense = satOrgIOContext->pSense; 7127 /* SCSI command response payload to OS layer */ 7128 // pMediaSerialNumber = (bit8 *) s,OrgScsiRequest->sglVirtualAddr; 7129 } 7130 else 7131 { 7132 SM_DBG4(("smsatWriteBufferCB: Internal smSatInternalIo_t satIntIoContext\n")); 7133 satOrgIOContext = satIOContext->satOrgIOContext; 7134 if (satOrgIOContext == agNULL) 7135 { 7136 SM_DBG4(("smsatWriteBufferCB: satOrgIOContext is NULL, wrong\n")); 7137 return; 7138 } 7139 else 7140 { 7141 SM_DBG4(("smsatWriteBufferCB: satOrgIOContext is NOT NULL\n")); 7142 } 7143 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 7144 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 7145 pSense = satOrgIOContext->pSense; 7146 } 7147 smIORequestBody->ioCompleted = agTRUE; 7148 smIORequestBody->ioStarted = agFALSE; 7149 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 7150 { 7151 SM_DBG1(("smsatWriteBufferCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 7152 tdsmIOCompletedCB( 7153 smRoot, 7154 smOrgIORequest, 7155 smIOFailed, 7156 smDetailOtherError, 7157 agNULL, 7158 satOrgIOContext->interruptContext 7159 ); 7160 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7161 7162 smsatFreeIntIoResource( smRoot, 7163 oneDeviceData, 7164 satIntIo); 7165 return; 7166 } 7167 if( agIOStatus != OSSA_IO_SUCCESS) 7168 { 7169 /* Process abort case */ 7170 if (agIOStatus == OSSA_IO_ABORTED) 7171 { 7172 smsatProcessAbort(smRoot, 7173 smOrgIORequest, 7174 satOrgIOContext 7175 ); 7176 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7177 7178 smsatFreeIntIoResource( smRoot, 7179 oneDeviceData, 7180 satIntIo); 7181 return; 7182 } 7183 smsatSetSensePayload( pSense, 7184 SCSI_SNSKEY_NOT_READY, 7185 0, 7186 SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 7187 satOrgIOContext); 7188 tdsmIOCompletedCB( smRoot, 7189 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7190 smIOSuccess, 7191 SCSI_STAT_CHECK_CONDITION, 7192 satOrgIOContext->pSmSenseData, 7193 satOrgIOContext->interruptContext ); 7194 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7195 7196 smsatFreeIntIoResource( smRoot, 7197 oneDeviceData, 7198 satIntIo); 7199 return; 7200 } 7201 /* process success case */ 7202 if (hostToDevFis->h.command == SAT_WRITE_BUFFER ) 7203 { 7204 tdsmIOCompletedCB( smRoot, 7205 smOrgIORequest, 7206 smIOSuccess, 7207 SCSI_STAT_GOOD, 7208 agNULL, 7209 satOrgIOContext->interruptContext); 7210 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7211 7212 smsatFreeIntIoResource( smRoot, 7213 oneDeviceData, 7214 satIntIo); 7215 return; 7216 } 7217 else 7218 { 7219 SM_DBG1(("smsatWriteBufferCB: error unknown command success 0x%x!!!\n", hostToDevFis->h.command)); 7220 smsatSetSensePayload( pSense, 7221 SCSI_SNSKEY_NO_SENSE, 7222 0, 7223 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 7224 satOrgIOContext); 7225 tdsmIOCompletedCB( smRoot, 7226 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7227 smIOSuccess, 7228 SCSI_STAT_CHECK_CONDITION, 7229 satOrgIOContext->pSmSenseData, 7230 satOrgIOContext->interruptContext ); 7231 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7232 smsatFreeIntIoResource( smRoot, 7233 oneDeviceData, 7234 satIntIo); 7235 return; 7236 } 7237 return; 7238 } 7239 7240 osGLOBAL void 7241 smsatReassignBlocksCB( 7242 agsaRoot_t *agRoot, 7243 agsaIORequest_t *agIORequest, 7244 bit32 agIOStatus, 7245 agsaFisHeader_t *agFirstDword, 7246 bit32 agIOInfoLen, 7247 agsaFrameHandle_t agFrameHandle, 7248 void *ioContext 7249 ) 7250 { 7251 smRoot_t *smRoot = agNULL; 7252 smIntRoot_t *smIntRoot = agNULL; 7253 smIntContext_t *smAllShared = agNULL; 7254 smIORequestBody_t *smIORequestBody; 7255 smIORequestBody_t *smOrgIORequestBody; 7256 smSatIOContext_t *satIOContext; 7257 smSatIOContext_t *satOrgIOContext; 7258 smSatIOContext_t *satNewIOContext; 7259 smSatInternalIo_t *satIntIo; 7260 smSatInternalIo_t *satNewIntIo = agNULL; 7261 smDeviceData_t *oneDeviceData; 7262 smScsiRspSense_t *pSense; 7263 smIniScsiCmnd_t *scsiCmnd; 7264 smIORequest_t *smOrgIORequest; 7265 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 7266 bit32 ataStatus = 0; 7267 bit32 status; 7268 smScsiInitiatorRequest_t *smScsiRequest; /* smScsiXchg */ 7269 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 7270 7271 SM_DBG2(("smsatReassignBlocksCB: start\n")); 7272 SM_DBG5(("smsatReassignBlocksCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 7273 7274 /* internally generate tiIOContext */ 7275 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 7276 satIOContext = (smSatIOContext_t *) ioContext; 7277 satIntIo = satIOContext->satIntIoContext; 7278 oneDeviceData = satIOContext->pSatDevData; 7279 hostToDevFis = satIOContext->pFis; 7280 smRoot = oneDeviceData->smRoot; 7281 smIntRoot = (smIntRoot_t *)smRoot->smData; 7282 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 7283 if (satIntIo == agNULL) 7284 { 7285 SM_DBG4(("smsatReassignBlocksCB: External smSatInternalIo_t satIntIoContext\n")); 7286 satOrgIOContext = satIOContext; 7287 smOrgIORequest = smIORequestBody->smIORequest; 7288 smScsiRequest = satOrgIOContext->smScsiXchg; 7289 pSense = satOrgIOContext->pSense; 7290 scsiCmnd = satOrgIOContext->pScsiCmnd; 7291 } 7292 else 7293 { 7294 SM_DBG4(("smsatReassignBlocksCB: Internal smSatInternalIo_t satIntIoContext\n")); 7295 satOrgIOContext = satIOContext->satOrgIOContext; 7296 if (satOrgIOContext == agNULL) 7297 { 7298 SM_DBG4(("smsatReassignBlocksCB: satOrgIOContext is NULL, Wrong\n")); 7299 return; 7300 } 7301 else 7302 { 7303 SM_DBG4(("smsatReassignBlocksCB: satOrgIOContext is NOT NULL, Wrong\n")); 7304 } 7305 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 7306 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 7307 smScsiRequest = satOrgIOContext->smScsiXchg; 7308 pSense = satOrgIOContext->pSense; 7309 scsiCmnd = satOrgIOContext->pScsiCmnd; 7310 } 7311 7312 smIORequestBody->ioCompleted = agTRUE; 7313 smIORequestBody->ioStarted = agFALSE; 7314 7315 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 7316 { 7317 SM_DBG1(("smsatReassignBlocksCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 7318 tdsmIOCompletedCB( 7319 smRoot, 7320 smOrgIORequest, 7321 smIOFailed, 7322 smDetailOtherError, 7323 agNULL, 7324 satOrgIOContext->interruptContext 7325 ); 7326 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7327 7328 smsatFreeIntIoResource( smRoot, 7329 oneDeviceData, 7330 satIntIo); 7331 return; 7332 } 7333 if (agIOStatus != OSSA_IO_SUCCESS) 7334 { 7335 /* only agsaFisRegDeviceToHost_t is expected */ 7336 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 7337 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 7338 } 7339 if (agIOStatus != OSSA_IO_SUCCESS) 7340 { 7341 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 7342 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 7343 ) 7344 { 7345 /* for debugging */ 7346 if( agIOStatus != OSSA_IO_SUCCESS) 7347 { 7348 SM_DBG1(("smsatReassignBlocksCB FAILED, NOT IO_SUCCESS!!!\n")); 7349 } 7350 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 7351 { 7352 SM_DBG1(("smsatReassignBlocksCB FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 7353 } 7354 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 7355 (ataStatus & DF_ATA_STATUS_MASK) 7356 ) 7357 { 7358 SM_DBG1(("smsatReassignBlocksCB FAILED, FAILED, error status!!!\n")); 7359 } 7360 7361 /* Process abort case */ 7362 if (agIOStatus == OSSA_IO_ABORTED) 7363 { 7364 smsatProcessAbort(smRoot, 7365 smOrgIORequest, 7366 satOrgIOContext 7367 ); 7368 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7369 7370 smsatFreeIntIoResource( smRoot, 7371 oneDeviceData, 7372 satIntIo); 7373 return; 7374 } 7375 /* for debugging */ 7376 if (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS || 7377 hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT 7378 ) 7379 { 7380 SM_DBG1(("smsatReassignBlocksCB SAT_READ_VERIFY_SECTORS(_EXT) failed!!!\n")); 7381 /* Verify failed; send Write with same LBA */ 7382 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7383 7384 smsatFreeIntIoResource( smRoot, 7385 oneDeviceData, 7386 satIntIo); 7387 7388 satNewIntIo = smsatAllocIntIoResource( smRoot, 7389 smOrgIORequest, 7390 oneDeviceData, 7391 512, /* writing 1 sector */ 7392 satNewIntIo); 7393 if (satNewIntIo == agNULL) 7394 { 7395 smsatSetSensePayload( pSense, 7396 SCSI_SNSKEY_HARDWARE_ERROR, 7397 0, 7398 SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 7399 satOrgIOContext); 7400 tdsmIOCompletedCB( smRoot, 7401 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7402 smIOSuccess, 7403 SCSI_STAT_CHECK_CONDITION, 7404 satOrgIOContext->pSmSenseData, 7405 satOrgIOContext->interruptContext ); 7406 SM_DBG1(("smsatReassignBlocksCB: momory allocation fails!!!\n")); 7407 return; 7408 } /* end memory allocation */ 7409 satNewIOContext = smsatPrepareNewIO( 7410 satNewIntIo, 7411 smOrgIORequest, 7412 oneDeviceData, 7413 scsiCmnd, 7414 satOrgIOContext 7415 ); 7416 /* send Write with same LBA */ 7417 status = smsatReassignBlocks_2( 7418 smRoot, 7419 &satNewIntIo->satIntSmIORequest, 7420 satNewIOContext->psmDeviceHandle, 7421 &satNewIntIo->satIntSmScsiXchg, 7422 satNewIOContext, 7423 satOrgIOContext->LBA 7424 ); 7425 7426 if (status != SM_RC_SUCCESS) 7427 { 7428 /* sending ATA command fails */ 7429 smsatFreeIntIoResource( smRoot, 7430 oneDeviceData, 7431 satNewIntIo); 7432 smsatSetSensePayload( pSense, 7433 SCSI_SNSKEY_HARDWARE_ERROR, 7434 0, 7435 SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 7436 satOrgIOContext); 7437 7438 tdsmIOCompletedCB( smRoot, 7439 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7440 smIOSuccess, 7441 SCSI_STAT_CHECK_CONDITION, 7442 satOrgIOContext->pSmSenseData, 7443 satOrgIOContext->interruptContext ); 7444 SM_DBG1(("smsatReassignBlocksCB calling fail 1!!!\n")); 7445 return; 7446 } /* end send fails */ 7447 7448 return; 7449 } 7450 else if (hostToDevFis->h.command == SAT_WRITE_DMA || 7451 hostToDevFis->h.command == SAT_WRITE_SECTORS || 7452 hostToDevFis->h.command == SAT_WRITE_DMA_EXT || 7453 hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT || 7454 hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED 7455 ) 7456 { 7457 SM_DBG1(("smsatReassignBlocksCB SAT_WRITE failed!!!\n")); 7458 /* fall through */ 7459 } 7460 else 7461 { 7462 SM_DBG1(("smsatReassignBlocksCB error default case unexpected command 0x%x!!!\n", hostToDevFis->h.command)); 7463 } 7464 7465 7466 smsatSetSensePayload( pSense, 7467 SCSI_SNSKEY_HARDWARE_ERROR, 7468 0, 7469 SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 7470 satOrgIOContext); 7471 7472 tdsmIOCompletedCB( smRoot, 7473 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7474 smIOSuccess, 7475 SCSI_STAT_CHECK_CONDITION, 7476 satOrgIOContext->pSmSenseData, 7477 satOrgIOContext->interruptContext ); 7478 7479 7480 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7481 7482 smsatFreeIntIoResource( smRoot, 7483 oneDeviceData, 7484 satIntIo); 7485 return; 7486 } /* error checking */ 7487 } 7488 7489 7490 /* prcessing the success case */ 7491 if (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS || 7492 hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT || 7493 hostToDevFis->h.command == SAT_WRITE_DMA || 7494 hostToDevFis->h.command == SAT_WRITE_SECTORS || 7495 hostToDevFis->h.command == SAT_WRITE_DMA_EXT || 7496 hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT || 7497 hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED 7498 ) 7499 { 7500 /* next LBA; verify */ 7501 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7502 7503 smsatFreeIntIoResource( smRoot, 7504 oneDeviceData, 7505 satIntIo); 7506 7507 if (satOrgIOContext->ParmIndex >= satOrgIOContext->ParmLen) 7508 { 7509 SM_DBG5(("smsatReassignBlocksCB: GOOD status\n")); 7510 /* return stat_good */ 7511 tdsmIOCompletedCB( smRoot, 7512 smOrgIORequest, 7513 smIOSuccess, 7514 SCSI_STAT_GOOD, 7515 agNULL, 7516 satOrgIOContext->interruptContext ); 7517 return; 7518 } 7519 else 7520 { 7521 SM_DBG5(("smsatReassignBlocksCB: processing next LBA\n")); 7522 satNewIntIo = smsatAllocIntIoResource( smRoot, 7523 smOrgIORequest, 7524 oneDeviceData, 7525 0, 7526 satNewIntIo); 7527 if (satNewIntIo == agNULL) 7528 { 7529 smsatSetSensePayload( pSense, 7530 SCSI_SNSKEY_HARDWARE_ERROR, 7531 0, 7532 SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 7533 satOrgIOContext); 7534 7535 tdsmIOCompletedCB( smRoot, 7536 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7537 smIOSuccess, 7538 SCSI_STAT_CHECK_CONDITION, 7539 satOrgIOContext->pSmSenseData, 7540 satOrgIOContext->interruptContext ); 7541 SM_DBG1(("smsatReassignBlocksCB: momory allocation fails!!!\n")); 7542 return; 7543 } /* end memory allocation */ 7544 7545 satNewIOContext = smsatPrepareNewIO( 7546 satNewIntIo, 7547 smOrgIORequest, 7548 oneDeviceData, 7549 scsiCmnd, 7550 satOrgIOContext 7551 ); 7552 7553 /* send Verify with the next LBA */ 7554 status = smsatReassignBlocks_1( 7555 smRoot, 7556 &satNewIntIo->satIntSmIORequest, 7557 satNewIOContext->psmDeviceHandle, 7558 smScsiRequest, /* orginal from OS layer */ 7559 satNewIOContext, 7560 satOrgIOContext 7561 ); 7562 7563 if (status != SM_RC_SUCCESS) 7564 { 7565 /* sending ATA command fails */ 7566 smsatFreeIntIoResource( smRoot, 7567 oneDeviceData, 7568 satNewIntIo); 7569 smsatSetSensePayload( pSense, 7570 SCSI_SNSKEY_HARDWARE_ERROR, 7571 0, 7572 SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 7573 satOrgIOContext); 7574 7575 tdsmIOCompletedCB( smRoot, 7576 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7577 smIOSuccess, 7578 SCSI_STAT_CHECK_CONDITION, 7579 satOrgIOContext->pSmSenseData, 7580 satOrgIOContext->interruptContext ); 7581 SM_DBG1(("smsatReassignBlocksCB calling satModeSelect6_1 fails!!!\n")); 7582 return; 7583 } /* end send fails */ 7584 } /* else */ 7585 return; 7586 7587 } 7588 else if (hostToDevFis->h.command == SAT_WRITE_DMA || 7589 hostToDevFis->h.command == SAT_WRITE_SECTORS || 7590 hostToDevFis->h.command == SAT_WRITE_DMA_EXT || 7591 hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT || 7592 hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED 7593 ) 7594 { 7595 /* next LBA; verify */ 7596 } 7597 else 7598 { 7599 SM_DBG1(("smsatReassignBlocksCB error unknown command success 0x%x !!!\n", hostToDevFis->h.command)); 7600 7601 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 7602 7603 smsatFreeIntIoResource( smRoot, 7604 oneDeviceData, 7605 satIntIo); 7606 smsatSetSensePayload( pSense, 7607 SCSI_SNSKEY_HARDWARE_ERROR, 7608 0, 7609 SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 7610 satOrgIOContext); 7611 7612 tdsmIOCompletedCB( smRoot, 7613 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 7614 smIOSuccess, 7615 SCSI_STAT_CHECK_CONDITION, 7616 satOrgIOContext->pSmSenseData, 7617 satOrgIOContext->interruptContext ); 7618 return; 7619 } 7620 return; 7621 } 7622 7623 7624 osGLOBAL FORCEINLINE void 7625 smsatDecrementPendingIO( 7626 smRoot_t *smRoot, 7627 smIntContext_t *smAllShared, 7628 smSatIOContext_t *satIOContext 7629 ) 7630 { 7631 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK 7632 bit32 volatile satPendingNCQIO = 0; 7633 bit32 volatile satPendingNONNCQIO = 0; 7634 bit32 volatile satPendingIO = 0; 7635 #endif /* CCFLAG_OPTIMIZE_SAT_LOCK */ 7636 smDeviceData_t *oneDeviceData = satIOContext->pSatDevData; 7637 smSatInternalIo_t *satIntIo = satIOContext->satIntIoContext; 7638 smSatIOContext_t *satOrgIOContext = satIOContext->satOrgIOContext; 7639 #ifdef TD_DEBUG_ENABLE 7640 smIORequestBody_t *smIORequestBody = agNULL; 7641 smIORequestBody = (smIORequestBody_t *)satIOContext->smRequestBody; 7642 #endif 7643 7644 SM_DBG3(("smsatDecrementPendingIO: start\n")); 7645 7646 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK 7647 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) || 7648 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) ) 7649 { 7650 tdsmInterlockedDecrement(smRoot,&oneDeviceData->satPendingNCQIO); 7651 } 7652 else 7653 { 7654 tdsmInterlockedDecrement(smRoot,&oneDeviceData->satPendingNONNCQIO); 7655 } 7656 tdsmInterlockedDecrement(smRoot,&oneDeviceData->satPendingIO); 7657 /* temp */ 7658 tdsmInterlockedExchange(smRoot, &satPendingNCQIO, oneDeviceData->satPendingNCQIO); 7659 tdsmInterlockedExchange(smRoot, &satPendingNONNCQIO, oneDeviceData->satPendingNONNCQIO); 7660 tdsmInterlockedExchange(smRoot, &satPendingIO, oneDeviceData->satPendingIO); 7661 if (satPendingNCQIO == -1) 7662 { 7663 SM_DBG1(("smsatDecrementPendingIO: satPendingNCQIO adjustment!!!\n")); 7664 oneDeviceData->satPendingNCQIO = 0; 7665 } 7666 if (satPendingNONNCQIO == -1) 7667 { 7668 SM_DBG1(("smsatDecrementPendingIO: satPendingNONNCQIO adjustment!!!\n")); 7669 oneDeviceData->satPendingNONNCQIO = 0; 7670 } 7671 if (satPendingIO == -1) 7672 { 7673 SM_DBG1(("smsatDecrementPendingIO: satPendingIO adjustment!!!\n")); 7674 oneDeviceData->satPendingIO = 0; 7675 } 7676 7677 #else 7678 7679 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) || 7680 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) ) 7681 { 7682 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK); 7683 oneDeviceData->satPendingNCQIO--; 7684 oneDeviceData->satPendingIO--; 7685 SMLIST_DEQUEUE_THIS (&satIOContext->satIoContextLink); 7686 /* temp */ 7687 if (oneDeviceData->satPendingNCQIO == -1) 7688 { 7689 SM_DBG1(("smsatDecrementPendingIO: satPendingNCQIO adjustment!!!\n")); 7690 oneDeviceData->satPendingNCQIO = 0; 7691 } 7692 if (oneDeviceData->satPendingIO == -1) 7693 { 7694 SM_DBG1(("smsatDecrementPendingIO: satPendingIO adjustment!!!\n")); 7695 oneDeviceData->satPendingIO = 0; 7696 } 7697 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK); 7698 } 7699 else 7700 { 7701 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK); 7702 oneDeviceData->satPendingNONNCQIO--; 7703 oneDeviceData->satPendingIO--; 7704 SMLIST_DEQUEUE_THIS (&satIOContext->satIoContextLink); 7705 /* temp */ 7706 if (oneDeviceData->satPendingNONNCQIO == -1) 7707 { 7708 SM_DBG1(("smsatDecrementPendingIO: satPendingNONNCQIO adjustment!!!\n")); 7709 oneDeviceData->satPendingNONNCQIO = 0; 7710 } 7711 if (oneDeviceData->satPendingIO == -1) 7712 { 7713 SM_DBG1(("smsatDecrementPendingIO: satPendingIO adjustment!!!\n")); 7714 oneDeviceData->satPendingIO = 0; 7715 } 7716 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK); 7717 } 7718 7719 #endif /* CCFLAG_OPTIMIZE_SAT_LOCK */ 7720 7721 if (satIntIo == agNULL) 7722 { 7723 SM_DBG3(("smsatDecrementPendingIO: external command!!!\n")); 7724 /*smEnqueueIO(smRoot, satIOContext);*/ 7725 } 7726 else 7727 { 7728 SM_DBG3(("smsatDecrementPendingIO: internal command!!!\n")); 7729 if (satOrgIOContext == agNULL) 7730 { 7731 /* No smEnqueueIO since only alloc used */ 7732 SM_DBG3(("smsatDecrementPendingIO: internal only command!!!, ID %d!!!\n", smIORequestBody->id)); 7733 return; 7734 } 7735 else 7736 { 7737 /* smDequeueIO used */ 7738 /*smEnqueueIO(smRoot, satOrgIOContext);*/ 7739 } 7740 } 7741 7742 return; 7743 } 7744 7745 7746 osGLOBAL void 7747 smsatProcessAbnormalCompletion( 7748 agsaRoot_t *agRoot, 7749 agsaIORequest_t *agIORequest, 7750 bit32 agIOStatus, 7751 agsaFisHeader_t *agFirstDword, 7752 bit32 agIOInfoLen, 7753 void *agParam, 7754 smSatIOContext_t *satIOContext 7755 ) 7756 { 7757 7758 smRoot_t *smRoot = agNULL; 7759 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7760 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7761 bit32 interruptContext; 7762 smIORequestBody_t *smIORequestBody; 7763 // satDeviceData_t *pSatDevData; 7764 smDeviceHandle_t *smDeviceHandle; 7765 smDeviceData_t *oneDeviceData = agNULL; 7766 agsaDevHandle_t *agDevHandle = agNULL; 7767 7768 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 7769 oneDeviceData = satIOContext->pSatDevData; 7770 if (oneDeviceData == agNULL) 7771 { 7772 SM_DBG1(("smsatProcessAbnormalCompletion: oneDeviceData is NULL\n")); 7773 return; 7774 } 7775 smDeviceHandle = satIOContext->psmDeviceHandle; 7776 smRoot = oneDeviceData->smRoot; 7777 interruptContext = satIOContext->interruptContext; 7778 7779 SM_DBG5(("smsatProcessAbnormalCompletion: start\n")); 7780 7781 /* Get into the detail */ 7782 switch(agIOStatus) 7783 { 7784 case OSSA_IO_SUCCESS: 7785 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_SUCCESS agIOInfoLen 0x%x calling smsatIOCompleted!!!\n", agIOInfoLen)); 7786 /* 7787 * At this point agIOInfoLen should be non-zero and there is valid FIS 7788 * to read. Pass this info to the SAT layer in order to do the ATA status 7789 * to SCSI status translation. 7790 */ 7791 smsatIOCompleted( smRoot, 7792 smIORequestBody->smIORequest, 7793 agFirstDword, 7794 agIOInfoLen, 7795 agParam, 7796 satIOContext, 7797 interruptContext); 7798 break; 7799 7800 7801 case OSSA_IO_ABORTED: 7802 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORTED!!!\n")); 7803 7804 tdsmIOCompletedCB( smRoot, 7805 smIORequestBody->smIORequest, 7806 smIOFailed, 7807 smDetailAborted, 7808 agNULL, 7809 interruptContext); 7810 7811 #ifdef REMOVED 7812 if ( oneDeviceData->satTmTaskTag != agNULL ) 7813 { 7814 SM_DBG1(("smsatProcessAbnormalCompletion: TM callback!!!\n")); 7815 if (smDeviceHandle == agNULL) 7816 { 7817 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 7818 } 7819 /* TM completed */ 7820 tdsmEventCB( smRoot, 7821 smDeviceHandle, 7822 smIntrEventTypeTaskManagement, 7823 smTMOK, 7824 oneDeviceData->satTmTaskTag); 7825 /* 7826 * Reset flag 7827 */ 7828 oneDeviceData->satTmTaskTag = agNULL; 7829 } 7830 #endif 7831 7832 /* 7833 * Check if we are in recovery mode and need to update the recovery flag 7834 */ 7835 if ((oneDeviceData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 7836 (oneDeviceData->satPendingIO == 0 )) 7837 { 7838 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 7839 SM_DBG1(("smsatProcessAbnormalCompletion: STATE NORMAL!!!\n")); 7840 } 7841 7842 SM_DBG1(("smsatProcessAbnormalCompletion: did %d satDriveState %d!!!\n", oneDeviceData->id, oneDeviceData->satDriveState)); 7843 SM_DBG1(("smsatProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 7844 SM_DBG1(("smsatProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 7845 7846 break; 7847 #ifdef REMOVED 7848 case OSSA_IO_OVERFLOW: 7849 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_OVERFLOW!!!\n")); 7850 tdsmIOCompletedCB( smRoot, 7851 smIORequestBody->smIORequest, 7852 smIOOverRun, 7853 agIOInfoLen, 7854 agNULL, 7855 interruptContext); 7856 break; 7857 #endif 7858 case OSSA_IO_UNDERFLOW: 7859 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_UNDERFLOW!!!\n")); 7860 tdsmIOCompletedCB( smRoot, 7861 smIORequestBody->smIORequest, 7862 smIOUnderRun, 7863 agIOInfoLen, 7864 agNULL, 7865 interruptContext); 7866 break; 7867 7868 7869 case OSSA_IO_FAILED: 7870 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_FAILED!!!\n")); 7871 tdsmIOCompletedCB( smRoot, 7872 smIORequestBody->smIORequest, 7873 smIOFailed, 7874 smDetailOtherError, 7875 agNULL, 7876 interruptContext); 7877 break; 7878 7879 case OSSA_IO_ABORT_RESET: 7880 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORT_RESET!!!\n")); 7881 tdsmIOCompletedCB( smRoot, 7882 smIORequestBody->smIORequest, 7883 smIOFailed, 7884 smDetailAbortReset, 7885 agNULL, 7886 interruptContext); 7887 /* 7888 * Check if we are in recovery mode and need to update the recovery flag 7889 */ 7890 if ((oneDeviceData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 7891 (oneDeviceData->satPendingIO == 0 )) 7892 { 7893 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 7894 SM_DBG1(("smsatProcessAbnormalCompletion: STATE NORMAL!!!\n")); 7895 } 7896 7897 SM_DBG1(("smsatProcessAbnormalCompletion: satDriveState %d!!!\n", oneDeviceData->satDriveState)); 7898 SM_DBG1(("smsatProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 7899 SM_DBG1(("smsatProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 7900 7901 break; 7902 7903 #ifdef REMOVED 7904 case OSSA_IO_NOT_VALID: 7905 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_NOT_VALID!!!\n")); 7906 tdsmIOCompletedCB( smRoot, 7907 smIORequestBody->smIORequest, 7908 smIOFailed, 7909 smDetailNotValid, 7910 agNULL, 7911 interruptContext); 7912 break; 7913 #endif 7914 7915 case OSSA_IO_NO_DEVICE: 7916 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_NO_DEVICE!!!\n")); 7917 tdsmIOCompletedCB( smRoot, 7918 smIORequestBody->smIORequest, 7919 smIOFailed, 7920 smDetailNoLogin, 7921 agNULL, 7922 interruptContext); 7923 break; 7924 7925 #ifdef REMOVED /* removed from spec */ 7926 case OSSA_IO_ILLEGAL_PARAMETER: 7927 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_ILLEGAL_PARAMETER!!!\n")); 7928 tdsmIOCompletedCB( smRoot, 7929 smIORequestBody->smIORequest, 7930 smIOFailed, 7931 smDetailOtherError, 7932 agNULL, 7933 interruptContext); 7934 break; 7935 7936 case OSSA_IO_LINK_FAILURE: 7937 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_LINK_FAILURE!!!\n")); 7938 tdsmIOCompletedCB( smRoot, 7939 smIORequestBody->smIORequest, 7940 smIOFailed, 7941 smDetailOtherError, 7942 agNULL, 7943 interruptContext); 7944 break; 7945 7946 case OSSA_IO_PROG_ERROR: 7947 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_PROG_ERROR!!!\n")); 7948 tdsmIOCompletedCB( smRoot, 7949 smIORequestBody->smIORequest, 7950 smIOFailed, 7951 smDetailOtherError, 7952 agNULL, 7953 interruptContext); 7954 break; 7955 #endif 7956 case OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: /* fall through */ 7957 case OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION: /* fall through */ 7958 case OSSA_IO_OPEN_CNX_ERROR_BREAK: /* fall through */ 7959 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: /* fall through */ 7960 case OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION: /* fall through */ 7961 case OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: /* fall through */ 7962 case OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION: /* fall through */ 7963 case OSSA_IO_OPEN_CNX_ERROR_OPEN_PREEMPTED: /* fall through */ 7964 #ifdef REMOVED /* removed from spec */ 7965 case OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR: /* fall through */ 7966 #endif 7967 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_* 0x%x!!!\n", agIOStatus)); 7968 if (smDeviceHandle == agNULL) 7969 { 7970 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 7971 tdsmIOCompletedCB( smRoot, 7972 smIORequestBody->smIORequest, 7973 smIOFailed, 7974 smDetailOtherError, 7975 agNULL, 7976 interruptContext); 7977 return; 7978 } 7979 if (oneDeviceData == agNULL) 7980 { 7981 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 7982 } 7983 else 7984 { 7985 SM_DBG1(("smsatProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 7986 } 7987 7988 tdsmIOCompletedCB( smRoot, 7989 smIORequestBody->smIORequest, 7990 smIOFailed, 7991 smDetailOtherError, 7992 agNULL, 7993 interruptContext); 7994 break; 7995 case OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY: 7996 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY!!!\n")); 7997 tdsmIOCompletedCB( smRoot, 7998 smIORequestBody->smIORequest, 7999 smIOFailed, 8000 smDetailBusy, 8001 agNULL, 8002 interruptContext); 8003 break; 8004 #ifdef REMOVED 8005 case OSSA_IO_XFER_ERROR_BREAK: /* fall throuth */ 8006 #endif 8007 8008 case OSSA_IO_XFER_ERROR_PHY_NOT_READY: /* fall throuth */ 8009 case OSSA_IO_XFER_ERROR_NAK_RECEIVED: /* fall throuth */ 8010 8011 #ifdef REMOVED 8012 case OSSA_IO_XFER_ERROR_ACK_NAK_TIMEOUT: /* fall throuth */ 8013 case OSSA_IO_XFER_ERROR_PEER_ABORTED: /* fall throuth */ 8014 #endif 8015 case OSSA_IO_XFER_ERROR_DMA: /* fall throuth */ 8016 #ifdef REMOVED 8017 case OSSA_IO_XFER_ERROR_RX_FRAME: /* fall throuth */ 8018 case OSSA_IO_XFER_ERROR_CREDIT_TIMEOUT: /* fall throuth */ 8019 case OSSA_IO_XFER_ERROR_SATA: /* fall throuth */ 8020 #endif 8021 case OSSA_IO_XFER_ERROR_SATA_LINK_TIMEOUT: /* fall throuth */ 8022 case OSSA_IO_XFER_ERROR_ABORTED_DUE_TO_SRST: /* fall throuth */ 8023 case OSSA_IO_XFER_ERROR_REJECTED_NCQ_MODE: /* fall throuth */ 8024 #ifdef REMOVED 8025 case OSSA_IO_XFER_ERR_EOB_DATA_OVERRUN: 8026 case OSSA_IO_XFER_ERROR_ABORTED_NCQ_MODE: /* fall throuth */ 8027 case OSSA_IO_XFER_ERROR_DISRUPTED_PHY_DOWN: /* fall throuth */ 8028 case OSSA_IO_XFER_ERROR_OFFSET_MISMATCH: /* fall throuth */ 8029 case OSSA_IO_XFER_ERROR_XFER_ZERO_DATA_LEN: /* fall throuth */ 8030 #endif 8031 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_ERROR_* 0x%x!!!\n", agIOStatus)); 8032 tdsmIOCompletedCB( smRoot, 8033 smIORequestBody->smIORequest, 8034 smIOFailed, 8035 smDetailOtherError, 8036 agNULL, 8037 interruptContext); 8038 break; 8039 #ifdef REMOVED 8040 case OSSA_IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT: /* fall throuth */ 8041 case OSSA_IO_XFER_ERROR_CMD_ISSUE_BREAK_BEFORE_ACK_NAK: /* fall throuth */ 8042 case OSSA_IO_XFER_ERROR_CMD_ISSUE_PHY_DOWN_BEFORE_ACK_NAK: /* fall throuth */ 8043 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_ERROR_CMD_ISSUE_* 0x%x!!!\n", agIOStatus)); 8044 tdsmIOCompletedCB( smRoot, 8045 smIORequestBody->smIORequest, 8046 smIOFailed, 8047 smDetailOtherError, 8048 agNULL, 8049 interruptContext); 8050 break; 8051 case OSSA_IO_XFER_PIO_SETUP_ERROR: 8052 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_PIO_SETUP_ERROR!!!\n")); 8053 tdsmIOCompletedCB( smRoot, 8054 smIORequestBody->smIORequest, 8055 smIOFailed, 8056 smDetailOtherError, 8057 agNULL, 8058 interruptContext); 8059 break; 8060 #endif 8061 case OSSA_IO_DS_IN_ERROR: 8062 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_IN_ERROR!!!\n")); 8063 if (smDeviceHandle == agNULL) 8064 { 8065 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8066 tdsmIOCompletedCB( smRoot, 8067 smIORequestBody->smIORequest, 8068 smIOFailed, 8069 smDetailOtherError, 8070 agNULL, 8071 interruptContext); 8072 return; 8073 } 8074 if (oneDeviceData == agNULL) 8075 { 8076 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 8077 } 8078 else 8079 { 8080 SM_DBG1(("smsatProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8081 } 8082 tdsmIOCompletedCB( smRoot, 8083 smIORequestBody->smIORequest, 8084 smIOFailed, 8085 smDetailOtherError, 8086 agNULL, 8087 interruptContext); 8088 break; 8089 case OSSA_IO_DS_NON_OPERATIONAL: 8090 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_NON_OPERATIONAL!!!\n")); 8091 if (smDeviceHandle == agNULL) 8092 { 8093 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8094 tdsmIOCompletedCB( smRoot, 8095 smIORequestBody->smIORequest, 8096 smIOFailed, 8097 smDetailOtherError, 8098 agNULL, 8099 interruptContext); 8100 return; 8101 } 8102 if (oneDeviceData == agNULL) 8103 { 8104 SM_DBG1(("smsatProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 8105 } 8106 else 8107 { 8108 SM_DBG1(("smsatProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8109 agDevHandle = oneDeviceData->agDevHandle; 8110 if (oneDeviceData->valid == agTRUE) 8111 { 8112 saSetDeviceState(agRoot, agNULL, tdsmRotateQnumber(smRoot, smDeviceHandle), agDevHandle, SA_DS_OPERATIONAL); 8113 } 8114 } 8115 8116 tdsmIOCompletedCB( smRoot, 8117 smIORequestBody->smIORequest, 8118 smIOFailed, 8119 smDetailOtherError, 8120 agNULL, 8121 interruptContext); 8122 break; 8123 8124 case OSSA_IO_PORT_IN_RESET: 8125 case OSSA_IO_DS_IN_RECOVERY: 8126 SM_DBG1(("smsatProcessAbnormalCompletion: OSSA_IO_DS_IN_RECOVERY or OSSA_IO_PORT_IN_RESET status %x\n", agIOStatus)); 8127 tdsmIOCompletedCB( smRoot, 8128 smIORequestBody->smIORequest, 8129 smIOFailed, 8130 smDetailOtherError, 8131 agNULL, 8132 interruptContext); 8133 break; 8134 8135 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 8136 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 8137 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 8138 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 8139 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 8140 SM_DBG1(("smsatProcessAbnormalCompletion: SSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_XX status %x\n", agIOStatus)); 8141 tdsmIOCompletedCB( smRoot, 8142 smIORequestBody->smIORequest, 8143 smIOFailed, 8144 smDetailOtherError, 8145 agNULL, 8146 interruptContext); 8147 break; 8148 8149 case OSSA_MPI_IO_RQE_BUSY_FULL: 8150 case OSSA_MPI_ERR_IO_RESOURCE_UNAVAILABLE: 8151 case OSSA_MPI_ERR_ATAPI_DEVICE_BUSY: 8152 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = OSSA_MPI_%x!!!\n", agIOStatus)); 8153 tdsmIOCompletedCB( smRoot, 8154 smIORequestBody->smIORequest, 8155 smIOFailed, 8156 smDetailBusy, 8157 agNULL, 8158 interruptContext); 8159 break; 8160 8161 case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS: /* fall through */ 8162 #ifdef REMOVED 8163 case OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH: 8164 #endif 8165 case OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID: /* fall through */ 8166 case OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH: /* fall through */ 8167 case OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR: /* fall through */ 8168 case OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS: 8169 case OSSA_IO_XFR_ERROR_DEK_ILLEGAL_TABLE: 8170 8171 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = ENCRYPTION ERROR 0x%x!!!\n", agIOStatus)); 8172 smsatEncryptionHandler(smRoot, 8173 agIORequest, 8174 agIOStatus, 8175 agIOInfoLen, 8176 agParam, 8177 0, 8178 interruptContext); 8179 break; 8180 8181 #ifdef REMOVED 8182 case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH: /* fall through */ 8183 case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH: /* fall through */ 8184 case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH: 8185 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = DIF ERROR 0x%x!!!\n", agIOStatus)); 8186 smsatDifHandler(smRoot, 8187 agIORequest, 8188 agIOStatus, 8189 agIOInfoLen, 8190 agParam, 8191 0, 8192 interruptContext); 8193 break; 8194 #endif 8195 8196 default: 8197 SM_DBG1(("smsatProcessAbnormalCompletion: agIOStatus = unknown 0x%x!!!\n", agIOStatus)); 8198 if (oneDeviceData != agNULL) 8199 { 8200 SM_DBG1(("smsatProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8201 } 8202 else 8203 { 8204 SM_DBG1(("smsatProcessAbnormalCompletion: oneDeviceData is NULL!!!\n")); 8205 } 8206 8207 tdsmIOCompletedCB( smRoot, 8208 smIORequestBody->smIORequest, 8209 smIOFailed, 8210 smDetailOtherError, 8211 agNULL, 8212 interruptContext); 8213 break; 8214 8215 } /* switch */ 8216 8217 return; 8218 } 8219 8220 osGLOBAL void 8221 smsatDelayedProcessAbnormalCompletion( 8222 agsaRoot_t *agRoot, 8223 agsaIORequest_t *agIORequest, 8224 bit32 agIOStatus, 8225 agsaFisHeader_t *agFirstDword, 8226 bit32 agIOInfoLen, 8227 void *agParam, 8228 smSatIOContext_t *satIOContext 8229 ) 8230 { 8231 smRoot_t *smRoot = agNULL; 8232 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8233 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8234 // bit32 interruptContext = osData->IntContext; 8235 bit32 interruptContext; 8236 smIORequestBody_t *smIORequestBody; 8237 // satDeviceData_t *pSatDevData; 8238 smDeviceHandle_t *smDeviceHandle; 8239 smDeviceData_t *oneDeviceData = agNULL; 8240 agsaDevHandle_t *agDevHandle = agNULL; 8241 8242 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 8243 oneDeviceData = satIOContext->pSatDevData; 8244 if (oneDeviceData == agNULL) 8245 { 8246 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: oneDeviceData is NULL\n")); 8247 return; 8248 } 8249 smDeviceHandle = satIOContext->psmDeviceHandle; 8250 smRoot = oneDeviceData->smRoot; 8251 interruptContext = satIOContext->interruptContext; 8252 8253 SM_DBG5(("smsatDelayedProcessAbnormalCompletion: start\n")); 8254 8255 /* Get into the detail */ 8256 switch(agIOStatus) 8257 { 8258 case OSSA_IO_SUCCESS: 8259 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_SUCCESS calling smsatIOCompleted!!!\n")); 8260 /* do nothing */ 8261 break; 8262 8263 8264 case OSSA_IO_ABORTED: 8265 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORTED!!!\n")); 8266 8267 tdsmIOCompletedCB( smRoot, 8268 smIORequestBody->smIORequest, 8269 smIOFailed, 8270 smDetailAborted, 8271 agNULL, 8272 interruptContext); 8273 8274 if ( oneDeviceData->satTmTaskTag != agNULL ) 8275 { 8276 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: TM callback!!!\n")); 8277 if (smDeviceHandle == agNULL) 8278 { 8279 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8280 } 8281 else 8282 { 8283 /* TM completed */ 8284 tdsmEventCB( smRoot, 8285 smDeviceHandle, 8286 smIntrEventTypeTaskManagement, 8287 smTMOK, 8288 oneDeviceData->satTmTaskTag); 8289 /* 8290 * Reset flag 8291 */ 8292 oneDeviceData->satTmTaskTag = agNULL; 8293 } 8294 } 8295 8296 /* 8297 * Check if we are in recovery mode and need to update the recovery flag 8298 */ 8299 if ((oneDeviceData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 8300 (oneDeviceData->satPendingIO == 0 )) 8301 { 8302 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 8303 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: STATE NORMAL.!!!\n")); 8304 } 8305 8306 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: satDriveState %d!!!\n", oneDeviceData->satDriveState)); 8307 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 8308 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 8309 8310 break; 8311 #ifdef REMOVED 8312 case OSSA_IO_OVERFLOW: 8313 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_OVERFLOW!!!\n")); 8314 tdsmIOCompletedCB( smRoot, 8315 smIORequestBody->smIORequest, 8316 smIOOverRun, 8317 agIOInfoLen, 8318 agNULL, 8319 interruptContext); 8320 break; 8321 #endif 8322 case OSSA_IO_UNDERFLOW: 8323 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_UNDERFLOW!!!\n")); 8324 tdsmIOCompletedCB( smRoot, 8325 smIORequestBody->smIORequest, 8326 smIOUnderRun, 8327 agIOInfoLen, 8328 agNULL, 8329 interruptContext); 8330 break; 8331 8332 8333 case OSSA_IO_FAILED: 8334 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_FAILED!!!\n")); 8335 tdsmIOCompletedCB( smRoot, 8336 smIORequestBody->smIORequest, 8337 smIOFailed, 8338 smDetailOtherError, 8339 agNULL, 8340 interruptContext); 8341 break; 8342 8343 case OSSA_IO_ABORT_RESET: 8344 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORT_RESET!!!\n")); 8345 tdsmIOCompletedCB( smRoot, 8346 smIORequestBody->smIORequest, 8347 smIOFailed, 8348 smDetailAbortReset, 8349 agNULL, 8350 interruptContext); 8351 /* 8352 * Check if we are in recovery mode and need to update the recovery flag 8353 */ 8354 if ((oneDeviceData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 8355 (oneDeviceData->satPendingIO == 0 )) 8356 { 8357 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 8358 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: STATE NORMAL.!!!\n")); 8359 } 8360 8361 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: satDriveState %d!!!\n", oneDeviceData->satDriveState)); 8362 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 8363 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 8364 8365 break; 8366 8367 #ifdef REMOVED 8368 case OSSA_IO_NOT_VALID: 8369 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_NOT_VALID!!!\n")); 8370 tdsmIOCompletedCB( smRoot, 8371 smIORequestBody->smIORequest, 8372 smIOFailed, 8373 smDetailNotValid, 8374 agNULL, 8375 interruptContext); 8376 break; 8377 #endif 8378 8379 case OSSA_IO_NO_DEVICE: 8380 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_NO_DEVICE!!!\n")); 8381 tdsmIOCompletedCB( smRoot, 8382 smIORequestBody->smIORequest, 8383 smIOFailed, 8384 smDetailNoLogin, 8385 agNULL, 8386 interruptContext); 8387 break; 8388 8389 #ifdef REMOVED /* removed from spec */ 8390 case OSSA_IO_ILLEGAL_PARAMETER: 8391 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_ILLEGAL_PARAMETER!!!\n")); 8392 tdsmIOCompletedCB( smRoot, 8393 smIORequestBody->smIORequest, 8394 smIOFailed, 8395 smDetailOtherError, 8396 agNULL, 8397 interruptContext); 8398 break; 8399 8400 case OSSA_IO_LINK_FAILURE: 8401 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_LINK_FAILURE!!!\n")); 8402 tdsmIOCompletedCB( smRoot, 8403 smIORequestBody->smIORequest, 8404 smIOFailed, 8405 smDetailOtherError, 8406 agNULL, 8407 interruptContext); 8408 break; 8409 8410 case OSSA_IO_PROG_ERROR: 8411 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_PROG_ERROR!!!\n")); 8412 tdsmIOCompletedCB( smRoot, 8413 smIORequestBody->smIORequest, 8414 smIOFailed, 8415 smDetailOtherError, 8416 agNULL, 8417 interruptContext); 8418 break; 8419 #endif 8420 case OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: /* fall through */ 8421 case OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION: /* fall through */ 8422 case OSSA_IO_OPEN_CNX_ERROR_BREAK: /* fall through */ 8423 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: /* fall through */ 8424 case OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION: /* fall through */ 8425 case OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: /* fall through */ 8426 case OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION: /* fall through */ 8427 case OSSA_IO_OPEN_CNX_ERROR_OPEN_PREEMPTED: /* fall through */ 8428 #ifdef REMOVED /* removed from spec */ 8429 case OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR: /* fall through */ 8430 #endif 8431 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_* 0x%x!!!\n", agIOStatus)); 8432 if (smDeviceHandle == agNULL) 8433 { 8434 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8435 tdsmIOCompletedCB( smRoot, 8436 smIORequestBody->smIORequest, 8437 smIOFailed, 8438 smDetailOtherError, 8439 agNULL, 8440 interruptContext); 8441 return; 8442 } 8443 if (oneDeviceData == agNULL) 8444 { 8445 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 8446 } 8447 else 8448 { 8449 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8450 } 8451 tdsmIOCompletedCB( smRoot, 8452 smIORequestBody->smIORequest, 8453 smIOFailed, 8454 smDetailOtherError, 8455 agNULL, 8456 interruptContext); 8457 break; 8458 8459 case OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY: 8460 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY!!!\n")); 8461 tdsmIOCompletedCB( smRoot, 8462 smIORequestBody->smIORequest, 8463 smIOFailed, 8464 smDetailBusy, 8465 agNULL, 8466 interruptContext); 8467 break; 8468 #ifdef REMOVED 8469 case OSSA_IO_XFER_ERROR_BREAK: /* fall throuth */ 8470 #endif 8471 8472 case OSSA_IO_XFER_ERROR_PHY_NOT_READY: /* fall throuth */ 8473 case OSSA_IO_XFER_ERROR_NAK_RECEIVED: /* fall throuth */ 8474 8475 #ifdef REMOVED 8476 case OSSA_IO_XFER_ERROR_ACK_NAK_TIMEOUT: /* fall throuth */ 8477 case OSSA_IO_XFER_ERROR_PEER_ABORTED: /* fall throuth */ 8478 #endif 8479 8480 case OSSA_IO_XFER_ERROR_DMA: /* fall throuth */ 8481 8482 #ifdef REMOVED 8483 case OSSA_IO_XFER_ERROR_RX_FRAME: /* fall throuth */ 8484 case OSSA_IO_XFER_ERROR_CREDIT_TIMEOUT: /* fall throuth */ 8485 case OSSA_IO_XFER_ERROR_SATA: /* fall throuth */ 8486 #endif 8487 case OSSA_IO_XFER_ERROR_SATA_LINK_TIMEOUT: /* fall throuth */ 8488 case OSSA_IO_XFER_ERROR_ABORTED_DUE_TO_SRST: /* fall throuth */ 8489 case OSSA_IO_XFER_ERROR_REJECTED_NCQ_MODE: /* fall throuth */ 8490 #ifdef REMOVED 8491 case OSSA_IO_XFER_ERROR_ABORTED_NCQ_MODE: /* fall throuth */ 8492 case OSSA_IO_XFER_ERROR_DISRUPTED_PHY_DOWN: /* fall throuth */ 8493 case OSSA_IO_XFER_ERROR_OFFSET_MISMATCH: /* fall throuth */ 8494 case OSSA_IO_XFER_ERROR_XFER_ZERO_DATA_LEN: /* fall throuth */ 8495 #endif 8496 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_ERROR_* 0x%x!!!\n", agIOStatus)); 8497 8498 tdsmIOCompletedCB( smRoot, 8499 smIORequestBody->smIORequest, 8500 smIOFailed, 8501 smDetailOtherError, 8502 agNULL, 8503 interruptContext); 8504 break; 8505 #ifdef REMOVED 8506 case OSSA_IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT: /* fall throuth */ 8507 case OSSA_IO_XFER_ERROR_CMD_ISSUE_BREAK_BEFORE_ACK_NAK: /* fall throuth */ 8508 case OSSA_IO_XFER_ERROR_CMD_ISSUE_PHY_DOWN_BEFORE_ACK_NAK: /* fall throuth */ 8509 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_ERROR_CMD_ISSUE_* 0x%x!!!\n", agIOStatus)); 8510 tdsmIOCompletedCB( smRoot, 8511 smIORequestBody->smIORequest, 8512 smIOFailed, 8513 smDetailOtherError, 8514 agNULL, 8515 interruptContext); 8516 break; 8517 case OSSA_IO_XFER_PIO_SETUP_ERROR: 8518 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_PIO_SETUP_ERROR!!!\n")); 8519 if (smDeviceHandle == agNULL) 8520 { 8521 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8522 } 8523 if (oneDeviceData == agNULL) 8524 { 8525 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 8526 } 8527 else 8528 { 8529 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8530 } 8531 tdsmIOCompletedCB( smRoot, 8532 smIORequestBody->smIORequest, 8533 smIOFailed, 8534 smDetailOtherError, 8535 agNULL, 8536 interruptContext); 8537 break; 8538 #endif 8539 case OSSA_IO_DS_IN_ERROR: 8540 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_IN_ERROR!!!\n")); 8541 if (smDeviceHandle == agNULL) 8542 { 8543 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8544 tdsmIOCompletedCB( smRoot, 8545 smIORequestBody->smIORequest, 8546 smIOFailed, 8547 smDetailOtherError, 8548 agNULL, 8549 interruptContext); 8550 return; 8551 } 8552 if (oneDeviceData == agNULL) 8553 { 8554 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 8555 } 8556 else 8557 { 8558 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8559 } 8560 tdsmIOCompletedCB( smRoot, 8561 smIORequestBody->smIORequest, 8562 smIOFailed, 8563 smDetailOtherError, 8564 agNULL, 8565 interruptContext); 8566 break; 8567 case OSSA_IO_DS_NON_OPERATIONAL: 8568 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_NON_OPERATIONAL!!!\n")); 8569 if (smDeviceHandle == agNULL) 8570 { 8571 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, smDeviceHandle is NULL!!!\n")); 8572 tdsmIOCompletedCB( smRoot, 8573 smIORequestBody->smIORequest, 8574 smIOFailed, 8575 smDetailOtherError, 8576 agNULL, 8577 interruptContext); 8578 return; 8579 } 8580 if (oneDeviceData == agNULL) 8581 { 8582 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL!!!\n")); 8583 } 8584 else 8585 { 8586 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: did %d!!!\n", oneDeviceData->id)); 8587 agDevHandle = oneDeviceData->agDevHandle; 8588 if (oneDeviceData->valid == agTRUE) 8589 { 8590 saSetDeviceState(agRoot, agNULL, tdsmRotateQnumber(smRoot, smDeviceHandle), agDevHandle, SA_DS_OPERATIONAL); 8591 } 8592 } 8593 tdsmIOCompletedCB( smRoot, 8594 smIORequestBody->smIORequest, 8595 smIOFailed, 8596 smDetailOtherError, 8597 agNULL, 8598 interruptContext); 8599 break; 8600 8601 case OSSA_IO_PORT_IN_RESET: 8602 case OSSA_IO_DS_IN_RECOVERY: 8603 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: OSSA_IO_DS_IN_RECOVERY or OSSA_IO_PORT_IN_RESET status %x\n", agIOStatus)); 8604 tdsmIOCompletedCB( smRoot, 8605 smIORequestBody->smIORequest, 8606 smIOFailed, 8607 smDetailOtherError, 8608 agNULL, 8609 interruptContext); 8610 break; 8611 8612 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 8613 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 8614 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 8615 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 8616 case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 8617 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: SSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_XX status %x\n", agIOStatus)); 8618 tdsmIOCompletedCB( smRoot, 8619 smIORequestBody->smIORequest, 8620 smIOFailed, 8621 smDetailOtherError, 8622 agNULL, 8623 interruptContext); 8624 break; 8625 case OSSA_IO_DS_INVALID: 8626 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: OSSA_IO_DS_INVALID status %x\n", agIOStatus)); 8627 tdsmIOCompletedCB( smRoot, 8628 smIORequestBody->smIORequest, 8629 smIOFailed, 8630 smDetailOtherError, 8631 agNULL, 8632 interruptContext); 8633 break; 8634 8635 case OSSA_MPI_IO_RQE_BUSY_FULL: 8636 case OSSA_MPI_ERR_IO_RESOURCE_UNAVAILABLE: 8637 case OSSA_MPI_ERR_ATAPI_DEVICE_BUSY: 8638 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_MPI_%x!!!\n", agIOStatus)); 8639 tdsmIOCompletedCB( smRoot, 8640 smIORequestBody->smIORequest, 8641 smIOFailed, 8642 smDetailBusy, 8643 agNULL, 8644 interruptContext); 8645 break; 8646 8647 case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS: /* fall through */ 8648 #ifdef REMOVED 8649 case OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH: 8650 #endif 8651 case OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID: /* fall through */ 8652 case OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH: /* fall through */ 8653 case OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR: /* fall through */ 8654 case OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS: 8655 case OSSA_IO_XFR_ERROR_DEK_ILLEGAL_TABLE: 8656 8657 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = ENCRYPTION ERROR 0x%x!!!\n", agIOStatus)); 8658 smsatEncryptionHandler(smRoot, 8659 agIORequest, 8660 agIOStatus, 8661 agIOInfoLen, 8662 agParam, 8663 0, 8664 interruptContext); 8665 break; 8666 8667 #ifdef REMOVED 8668 case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH: /* fall through */ 8669 case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH: /* fall through */ 8670 case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH: 8671 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = DIF ERROR 0x%x!!!\n", agIOStatus)); 8672 smsatDifHandler(smRoot, 8673 agIORequest, 8674 agIOStatus, 8675 agIOInfoLen, 8676 agParam, 8677 0, 8678 interruptContext); 8679 break; 8680 #endif 8681 8682 default: 8683 SM_DBG1(("smsatDelayedProcessAbnormalCompletion: agIOStatus = unknown!!!\n")); 8684 tdsmIOCompletedCB( smRoot, 8685 smIORequestBody->smIORequest, 8686 smIOFailed, 8687 smDetailOtherError, 8688 agNULL, 8689 interruptContext); 8690 break; 8691 8692 } /* switch */ 8693 return; 8694 } 8695 8696 osGLOBAL void 8697 smsatIDStartCB( 8698 agsaRoot_t *agRoot, 8699 agsaIORequest_t *agIORequest, 8700 bit32 agIOStatus, 8701 agsaFisHeader_t *agFirstDword, 8702 bit32 agIOInfoLen, 8703 void *agParam, 8704 void *ioContext 8705 ) 8706 { 8707 /* 8708 In the process of SAT_IDENTIFY_DEVICE during discovery 8709 */ 8710 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8711 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8712 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8713 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8714 smRoot_t *smRoot = agNULL; 8715 smIntRoot_t *smIntRoot = agNULL; 8716 smIntContext_t *smAllShared = agNULL; 8717 smIORequestBody_t *smIORequestBody; 8718 smIORequestBody_t *smOrgIORequestBody = agNULL; 8719 smDeviceHandle_t *smDeviceHandle; 8720 smSatIOContext_t *satIOContext; 8721 smSatIOContext_t *satOrgIOContext; 8722 smSatIOContext_t *satNewIOContext; 8723 smSatInternalIo_t *satIntIo; 8724 smSatInternalIo_t *satNewIntIo = agNULL; 8725 smDeviceData_t *oneDeviceData; 8726 smIORequest_t *smOrgIORequest = agNULL; 8727 // agsaFisRegD2HData_t *deviceToHostFisData = agNULL; 8728 // bit8 signature[8]; 8729 #ifdef TD_DEBUG_ENABLE 8730 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 8731 bit32 ataStatus = 0; 8732 bit32 ataError; 8733 #endif 8734 agsaSATAIdentifyData_t *pSATAIdData; 8735 bit16 *tmpptr, tmpptr_tmp; 8736 bit32 x; 8737 void *sglVirtualAddr; 8738 bit32 status = 0; 8739 // tdsaPortContext_t *onePortContext = agNULL; 8740 // tiPortalContext_t *tiPortalContext = agNULL; 8741 // bit32 retry_status; 8742 smIORequest_t *smIORequest; 8743 agsaDevHandle_t *agDevHandle = agNULL; 8744 8745 SM_DBG1(("smsatIDStartCB: start\n")); 8746 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 8747 satIOContext = (smSatIOContext_t *) ioContext; 8748 satIntIo = satIOContext->satIntIoContext; 8749 oneDeviceData = satIOContext->pSatDevData; 8750 smDeviceHandle = satIOContext->psmDeviceHandle; 8751 smRoot = oneDeviceData->smRoot; 8752 smIntRoot = (smIntRoot_t *)smRoot->smData; 8753 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 8754 SM_DBG1(("smsatIDStartCB: did %d\n", oneDeviceData->id)); 8755 // onePortContext = oneDeviceData->tdPortContext; 8756 // tiPortalContext= onePortContext->tiPortalContext; 8757 oneDeviceData->IDDeviceValid = agFALSE; 8758 if (satIntIo == agNULL) 8759 { 8760 SM_DBG1(("smsatIDStartCB: External, OS generated!!!\n")); 8761 SM_DBG1(("smsatIDStartCB: Not possible case!!!\n")); 8762 satOrgIOContext = satIOContext; 8763 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 8764 8765 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8766 8767 smsatFreeIntIoResource( smRoot, 8768 oneDeviceData, 8769 satIntIo); 8770 return; 8771 } 8772 else 8773 { 8774 SM_DBG3(("smsatIDStartCB: Internal, SM generated\n")); 8775 satOrgIOContext = satIOContext->satOrgIOContext; 8776 if (satOrgIOContext == agNULL) 8777 { 8778 SM_DBG5(("smsatIDStartCB: satOrgIOContext is NULL\n")); 8779 } 8780 else 8781 { 8782 SM_DBG5(("smsatIDStartCB: satOrgIOContext is NOT NULL\n")); 8783 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 8784 if (smOrgIORequestBody == agNULL) 8785 { 8786 SM_DBG1(("smsatIDStartCB: smOrgIORequestBody is NULL!!!\n")); 8787 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8788 8789 smsatFreeIntIoResource(smRoot, oneDeviceData, satIntIo); 8790 return; 8791 } 8792 } 8793 sglVirtualAddr = satIntIo->satIntSmScsiXchg.sglVirtualAddr; 8794 } 8795 smOrgIORequest = smIORequestBody->smIORequest; 8796 smIORequest = smOrgIORequestBody->smIORequest; 8797 smIORequestBody->ioCompleted = agTRUE; 8798 smIORequestBody->ioStarted = agFALSE; 8799 8800 8801 if ( agIOStatus == OSSA_IO_XFER_OPEN_RETRY_TIMEOUT || 8802 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY || 8803 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED || 8804 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL ) 8805 { 8806 SM_DBG1(("smsatIDStartCB: OPEN_RETRY_TIMEOUT or STP_RESOURCES_BUSY or OPEN_RETRY_BACKOFF_THRESHOLD_REACHED or OSSA_IO_DS_NON_OPERATIONAL!!! 0x%x\n", agIOStatus)); 8807 SM_DBG1(("smsatIDStartCB: did %d!!!\n", oneDeviceData->id)); 8808 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8809 8810 smsatFreeIntIoResource( smRoot, 8811 oneDeviceData, 8812 satIntIo); 8813 8814 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody %p smIORequest %p\n", smOrgIORequestBody, smIORequest)); 8815 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody->id %d\n", smOrgIORequestBody->id)); 8816 if (agIOStatus == OSSA_IO_XFER_OPEN_RETRY_TIMEOUT) 8817 { 8818 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIORetry, &(oneDeviceData->satIdentifyData)); 8819 } 8820 else if ( agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED || 8821 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL ) 8822 { 8823 /* set device to operational */ 8824 agDevHandle = oneDeviceData->agDevHandle; 8825 if (oneDeviceData->valid == agTRUE) 8826 { 8827 saSetDeviceState(agRoot, agNULL, tdsmRotateQnumber(smRoot, smDeviceHandle), agDevHandle, SA_DS_OPERATIONAL); 8828 } 8829 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIORetry, &(oneDeviceData->satIdentifyData)); 8830 } 8831 else 8832 { 8833 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSTPResourceBusy, &(oneDeviceData->satIdentifyData)); 8834 } 8835 return; 8836 } 8837 8838 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 8839 { 8840 SM_DBG1(("smsatIDStartCB: agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 8841 SM_DBG1(("smsatIDStartCB: did %d!!!\n", oneDeviceData->id)); 8842 SM_DBG1(("smsatIDStartCB: before pending IO %d NCQ pending IO %d NONNCQ pending IO %d\n", 8843 oneDeviceData->satPendingIO, oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 8844 8845 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8846 8847 SM_DBG1(("smsatIDStartCB: after pending IO %d NCQ pending IO %d NONNCQ pending IO %d\n", 8848 oneDeviceData->satPendingIO, oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 8849 8850 smsatFreeIntIoResource( smRoot, 8851 oneDeviceData, 8852 satIntIo); 8853 8854 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody %p smIORequest %p\n", smOrgIORequestBody, smIORequest)); 8855 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody->id %d\n", smOrgIORequestBody->id)); 8856 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 8857 return; 8858 } 8859 8860 if (agIOStatus == OSSA_IO_ABORTED || 8861 agIOStatus == OSSA_IO_UNDERFLOW || 8862 agIOStatus == OSSA_IO_XFER_ERROR_BREAK || 8863 agIOStatus == OSSA_IO_XFER_ERROR_PHY_NOT_READY || 8864 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 8865 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 8866 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 8867 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 8868 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 8869 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 8870 agIOStatus == OSSA_IO_XFER_ERROR_NAK_RECEIVED || 8871 agIOStatus == OSSA_IO_XFER_ERROR_DMA || 8872 agIOStatus == OSSA_IO_XFER_ERROR_SATA_LINK_TIMEOUT || 8873 agIOStatus == OSSA_IO_XFER_ERROR_REJECTED_NCQ_MODE || 8874 agIOStatus == OSSA_IO_NO_DEVICE || 8875 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 8876 agIOStatus == OSSA_IO_PORT_IN_RESET || 8877 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL || 8878 agIOStatus == OSSA_IO_DS_IN_RECOVERY || 8879 agIOStatus == OSSA_IO_DS_IN_ERROR || 8880 agIOStatus == OSSA_IO_DS_INVALID 8881 ) 8882 { 8883 SM_DBG1(("smsatIDStartCB: OSSA_IO_OPEN_CNX_ERROR 0x%x!!!\n", agIOStatus)); 8884 SM_DBG1(("smsatIDStartCB: did %d!!!\n", oneDeviceData->id)); 8885 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8886 8887 smsatFreeIntIoResource( smRoot, 8888 oneDeviceData, 8889 satIntIo); 8890 8891 8892 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody %p smIORequest %p\n", smOrgIORequestBody, smIORequest)); 8893 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody->id %d\n", smOrgIORequestBody->id)); 8894 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 8895 return; 8896 } 8897 8898 if ( agIOStatus != OSSA_IO_SUCCESS || 8899 (agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL && agIOInfoLen != 0) 8900 ) 8901 { 8902 #ifdef TD_DEBUG_ENABLE 8903 /* only agsaFisPioSetup_t is expected */ 8904 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 8905 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 8906 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 8907 #endif 8908 SM_DBG1(("smsatIDStartCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 8909 8910 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8911 8912 smsatFreeIntIoResource( smRoot, 8913 oneDeviceData, 8914 satIntIo); 8915 8916 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody %p smIORequest %p\n", smOrgIORequestBody, smIORequest)); 8917 SM_DBG2(("smsatIDStartCB: smOrgIORequestBody->id %d\n", smOrgIORequestBody->id)); 8918 8919 { 8920 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 8921 } 8922 return; 8923 } 8924 8925 8926 /* success */ 8927 SM_DBG3(("smsatIDStartCB: Success\n")); 8928 SM_DBG3(("smsatIDStartCB: Success did %d\n", oneDeviceData->id)); 8929 8930 /* Convert to host endian */ 8931 tmpptr = (bit16*)sglVirtualAddr; 8932 for (x=0; x < sizeof(agsaSATAIdentifyData_t)/sizeof(bit16); x++) 8933 { 8934 OSSA_READ_LE_16(AGROOT, &tmpptr_tmp, tmpptr, 0); 8935 *tmpptr = tmpptr_tmp; 8936 tmpptr++; 8937 } 8938 8939 pSATAIdData = (agsaSATAIdentifyData_t *)sglVirtualAddr; 8940 //smhexdump("satAddSATAIDDevCB before", (bit8 *)pSATAIdData, sizeof(agsaSATAIdentifyData_t)); 8941 8942 SM_DBG5(("smsatIDStartCB: OS satOrgIOContext %p \n", satOrgIOContext)); 8943 SM_DBG5(("smsatIDStartCB: TD satIOContext %p \n", satIOContext)); 8944 SM_DBG5(("smsatIDStartCB: OS tiScsiXchg %p \n", satOrgIOContext->smScsiXchg)); 8945 SM_DBG5(("smsatIDStartCB: TD tiScsiXchg %p \n", satIOContext->smScsiXchg)); 8946 8947 8948 /* copy ID Dev data to oneDeviceData */ 8949 oneDeviceData->satIdentifyData = *pSATAIdData; 8950 oneDeviceData->IDDeviceValid = agTRUE; 8951 8952 #ifdef SM_INTERNAL_DEBUG 8953 smhexdump("smsatIDStartCB ID Dev data",(bit8 *)pSATAIdData, sizeof(agsaSATAIdentifyData_t)); 8954 smhexdump("smsatIDStartCB Device ID Dev data",(bit8 *)&oneDeviceData->satIdentifyData, sizeof(agsaSATAIdentifyData_t)); 8955 #endif 8956 8957 /* set oneDeviceData fields from IndentifyData */ 8958 smsatSetDevInfo(oneDeviceData,pSATAIdData); 8959 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 8960 8961 smsatFreeIntIoResource( smRoot, 8962 oneDeviceData, 8963 satIntIo); 8964 8965 if (smIORequest->tdData == smIORequest->smData) 8966 { 8967 SM_DBG1(("smsatIDStartCB: the same tdData and smData error!\n")); 8968 } 8969 8970 /* send the Set Feature ATA command to SATA device for enbling PIO and DMA transfer mode*/ 8971 satNewIntIo = smsatAllocIntIoResource( smRoot, 8972 smOrgIORequest, 8973 oneDeviceData, 8974 0, 8975 satNewIntIo); 8976 8977 if (satNewIntIo == agNULL) 8978 { 8979 SM_DBG1(("smsatIDStartCB: momory allocation fails\n")); 8980 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 8981 return; 8982 } /* end memory allocation */ 8983 8984 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 8985 smOrgIORequest, 8986 oneDeviceData, 8987 agNULL, 8988 satOrgIOContext 8989 ); 8990 /*enable PIO mode*/ 8991 status = smsatSetFeaturesPIO(smRoot, 8992 &satNewIntIo->satIntSmIORequest, 8993 satNewIOContext->psmDeviceHandle, 8994 &satNewIntIo->satIntSmScsiXchg, /* orginal from OS layer */ 8995 satNewIOContext 8996 ); 8997 8998 if (status != SM_RC_SUCCESS) 8999 { 9000 smsatFreeIntIoResource(smRoot, 9001 oneDeviceData, 9002 satNewIntIo); 9003 /* clean up TD layer's IORequestBody */ 9004 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 9005 } 9006 9007 SM_DBG2(("smsatIDStartCB: End device id %d\n", oneDeviceData->id)); 9008 return; 9009 } 9010 9011 9012 osGLOBAL void 9013 smsatIOCompleted( 9014 smRoot_t *smRoot, 9015 smIORequest_t *smIORequest, 9016 agsaFisHeader_t *agFirstDword, 9017 bit32 respFisLen, 9018 agsaFrameHandle_t agFrameHandle, 9019 smSatIOContext_t *satIOContext, 9020 bit32 interruptContext 9021 ) 9022 { 9023 // satDeviceData_t *pSatDevData; 9024 smDeviceData_t *oneDeviceData; 9025 smScsiRspSense_t *pSense; 9026 #ifdef TD_DEBUG_ENABLE 9027 smIniScsiCmnd_t *pScsiCmnd; 9028 #endif 9029 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 9030 bit32 ataStatus = 0; 9031 bit32 ataError; 9032 smSatInternalIo_t *satIntIo = agNULL; 9033 bit32 status; 9034 // agsaRoot_t *agRoot; 9035 // agsaDevHandle_t *agDevHandle; 9036 smDeviceHandle_t *smDeviceHandle; 9037 smSatIOContext_t *satIOContext2; 9038 smIORequestBody_t *smIORequestBody; 9039 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 9040 agsaFisSetDevBitsHeader_t *statSetDevBitFisHeader = agNULL; 9041 smIORequest_t smIORequestTMP; 9042 9043 pSense = satIOContext->pSense; 9044 oneDeviceData = satIOContext->pSatDevData; 9045 #ifdef TD_DEBUG_ENABLE 9046 pScsiCmnd = satIOContext->pScsiCmnd; 9047 #endif 9048 hostToDevFis = satIOContext->pFis; 9049 9050 9051 // agRoot = ((tdsaDeviceData_t *)(pSatDevData->satSaDeviceData))->agRoot; 9052 // agDevHandle = ((tdsaDeviceData_t *)(pSatDevData->satSaDeviceData))->agDevHandle; 9053 // tiDeviceHandle = &((tdsaDeviceData_t *)(pSatDevData->satSaDeviceData))->tiDeviceHandle; 9054 smDeviceHandle = satIOContext->psmDeviceHandle; 9055 /* 9056 * Find out the type of response FIS: 9057 * Set Device Bit FIS or Reg Device To Host FIS. 9058 */ 9059 9060 /* First assume it is Reg Device to Host FIS */ 9061 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 9062 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 9063 ataError = statDevToHostFisHeader->error; /* ATA Eror register */ 9064 9065 SM_DBG5(("smsatIOCompleted: start\n")); 9066 9067 /* for debugging */ 9068 SM_DBG1(("smsatIOCompleted: H to D command 0x%x!!!\n", hostToDevFis->h.command)); 9069 SM_DBG1(("smsatIOCompleted: D to H fistype 0x%x!!!\n", statDevToHostFisHeader->fisType)); 9070 9071 9072 if (statDevToHostFisHeader->fisType == SET_DEV_BITS_FIS) 9073 { 9074 /* It is Set Device Bits FIS */ 9075 statSetDevBitFisHeader = (agsaFisSetDevBitsHeader_t *)&(agFirstDword->D2H); 9076 /* Get ATA Status register */ 9077 ataStatus = (statSetDevBitFisHeader->statusHi_Lo & 0x70); /* bits 4,5,6 */ 9078 ataStatus = ataStatus | (statSetDevBitFisHeader->statusHi_Lo & 0x07); /* bits 0,1,2 */ 9079 9080 /* ATA Eror register */ 9081 ataError = statSetDevBitFisHeader->error; 9082 9083 statDevToHostFisHeader = agNULL; 9084 } 9085 9086 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 9087 { 9088 SM_DBG1(("smsatIOCompleted: *** UNEXPECTED RESP FIS TYPE 0x%x *** smIORequest=%p!!!\n", 9089 statDevToHostFisHeader->fisType, smIORequest)); 9090 9091 smsatSetSensePayload( pSense, 9092 SCSI_SNSKEY_HARDWARE_ERROR, 9093 0, 9094 SCSI_SNSCODE_INTERNAL_TARGET_FAILURE, 9095 satIOContext); 9096 9097 tdsmIOCompletedCB( smRoot, 9098 smIORequest, 9099 smIOSuccess, 9100 SCSI_STAT_CHECK_CONDITION, 9101 satIOContext->pSmSenseData, 9102 interruptContext ); 9103 return; 9104 9105 } 9106 9107 if ( ataStatus & DF_ATA_STATUS_MASK ) 9108 { 9109 oneDeviceData->satDeviceFaultState = agTRUE; 9110 } 9111 else 9112 { 9113 oneDeviceData->satDeviceFaultState = agFALSE; 9114 } 9115 9116 SM_DBG5(("smsatIOCompleted: smIORequest=%p CDB=0x%x ATA CMD =0x%x\n", 9117 smIORequest, pScsiCmnd->cdb[0], hostToDevFis->h.command)); 9118 9119 /* 9120 * Decide which ATA command is the translation needed 9121 */ 9122 switch(hostToDevFis->h.command) 9123 { 9124 case SAT_READ_FPDMA_QUEUED: 9125 case SAT_WRITE_FPDMA_QUEUED: 9126 9127 /************************************************************************ 9128 * 9129 * !!!! See Section 13.5.2.4 of SATA 2.5 specs. !!!! 9130 * !!!! If the NCQ error ends up here, it means that the device sent !!!! 9131 * !!!! Set Device Bit FIS (which has SActive register) instead of !!!! 9132 * !!!! Register Device To Host FIS (which does not have SActive !!!! 9133 * !!!! register). The callback ossaSATAEvent() deals with the case !!!! 9134 * !!!! where Register Device To Host FIS was sent by the device. !!!! 9135 * 9136 * For NCQ we need to issue READ LOG EXT command with log page 10h 9137 * to get the error and to allow other I/Os to continue. 9138 * 9139 * Here is the basic flow or sequence of error recovery, note that due 9140 * to the SATA HW assist that we have, this sequence is slighly different 9141 * from the one described in SATA 2.5: 9142 * 9143 * 1. Set SATA device flag to indicate error condition and returning busy 9144 * for all new request. 9145 * return SM_RC_SUCCESS; 9146 9147 * 2. Because the HW/LL layer received Set Device Bit FIS, it can get the 9148 * tag or I/O context for NCQ request, SATL would translate the ATA error 9149 * to SCSI status and return the original NCQ I/O with the appopriate 9150 * SCSI status. 9151 * 9152 * 3. Prepare READ LOG EXT page 10h command. Set flag to indicate that 9153 * the failed I/O has been returned to the OS Layer. Send command. 9154 * 9155 * 4. When the device receives READ LOG EXT page 10h request all other 9156 * pending I/O are implicitly aborted. No completion (aborted) status 9157 * will be sent to the host for these aborted commands. 9158 * 9159 * 5. SATL receives the completion for READ LOG EXT command in 9160 * smsatReadLogExtCB(). Steps 6,7,8,9 below are the step 1,2,3,4 in 9161 * smsatReadLogExtCB(). 9162 * 9163 * 6. Check flag that indicates whether the failed I/O has been returned 9164 * to the OS Layer. If not, search the I/O context in device data 9165 * looking for a matched tag. Then return the completion of the failed 9166 * NCQ command with the appopriate/trasnlated SCSI status. 9167 * 9168 * 7. Issue abort to LL layer to all other pending I/Os for the same SATA 9169 * drive. 9170 * 9171 * 8. Free resource allocated for the internally generated READ LOG EXT. 9172 * 9173 * 9. At the completion of abort, in the context of ossaSATACompleted(), 9174 * return the I/O with error status to the OS-App Specific layer. 9175 * When all I/O aborts are completed, clear SATA device flag to 9176 * indicate ready to process new request. 9177 * 9178 ***********************************************************************/ 9179 9180 SM_DBG1(("smsatIOCompleted: NCQ ERROR smIORequest=%p ataStatus=0x%x ataError=0x%x!!!\n", 9181 smIORequest, ataStatus, ataError )); 9182 9183 /* Set flag to indicate we are in recovery */ 9184 oneDeviceData->satDriveState = SAT_DEV_STATE_IN_RECOVERY; 9185 9186 /* Return the failed NCQ I/O to OS-Apps Specifiic layer */ 9187 smsatDefaultTranslation( smRoot, 9188 smIORequest, 9189 satIOContext, 9190 pSense, 9191 (bit8)ataStatus, 9192 (bit8)ataError, 9193 interruptContext ); 9194 9195 /* 9196 * Allocate resource for READ LOG EXT page 10h 9197 */ 9198 satIntIo = smsatAllocIntIoResource( smRoot, 9199 &(smIORequestTMP), /* anything but NULL */ 9200 oneDeviceData, 9201 sizeof (satReadLogExtPage10h_t), 9202 satIntIo); 9203 9204 /* 9205 * If we cannot allocate resource for READ LOG EXT 10 in order to do 9206 * the normal NCQ recovery, we will do SATA device reset. 9207 */ 9208 if (satIntIo == agNULL) 9209 { 9210 SM_DBG1(("smsatIOCompleted: can't send RLE due to resource lack!!!\n")); 9211 9212 /* Abort I/O after completion of device reset */ 9213 oneDeviceData->satAbortAfterReset = agTRUE; 9214 #ifdef NOT_YET 9215 /* needs further investigation */ 9216 /* no report to OS layer */ 9217 satSubTM(smRoot, 9218 smDeviceHandle, 9219 SM_INTERNAL_TM_RESET, 9220 agNULL, 9221 agNULL, 9222 agNULL, 9223 agFALSE); 9224 #endif 9225 9226 9227 SM_DBG1(("smsatIOCompleted: calling saSATADeviceReset 1!!!\n")); 9228 return; 9229 } 9230 9231 9232 /* 9233 * Set flag to indicate that the failed I/O has been returned to the 9234 * OS-App specific Layer. 9235 */ 9236 satIntIo->satIntFlag = AG_SAT_INT_IO_FLAG_ORG_IO_COMPLETED; 9237 9238 /* compare to satPrepareNewIO() */ 9239 /* Send READ LOG EXIT page 10h command */ 9240 9241 /* 9242 * Need to initialize all the fields within satIOContext except 9243 * reqType and satCompleteCB which will be set depending on cmd. 9244 */ 9245 9246 smIORequestBody = (smIORequestBody_t *)satIntIo->satIntRequestBody; 9247 satIOContext2 = &(smIORequestBody->transport.SATA.satIOContext); 9248 9249 satIOContext2->pSatDevData = oneDeviceData; 9250 satIOContext2->pFis = &(smIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev); 9251 satIOContext2->pScsiCmnd = &(satIntIo->satIntSmScsiXchg.scsiCmnd); 9252 satIOContext2->pSense = &(smIORequestBody->transport.SATA.sensePayload); 9253 satIOContext2->pSmSenseData = &(smIORequestBody->transport.SATA.smSenseData); 9254 satIOContext2->pSmSenseData->senseData = satIOContext2->pSense; 9255 9256 satIOContext2->smRequestBody = satIntIo->satIntRequestBody; 9257 satIOContext2->interruptContext = interruptContext; 9258 satIOContext2->satIntIoContext = satIntIo; 9259 9260 satIOContext2->psmDeviceHandle = smDeviceHandle; 9261 satIOContext2->satOrgIOContext = agNULL; 9262 satIOContext2->smScsiXchg = agNULL; 9263 9264 status = smsatSendReadLogExt( smRoot, 9265 &satIntIo->satIntSmIORequest, 9266 smDeviceHandle, 9267 &satIntIo->satIntSmScsiXchg, 9268 satIOContext2); 9269 9270 if (status != SM_RC_SUCCESS) 9271 { 9272 SM_DBG1(("smsatIOCompleted: can't send RLE due to LL api failure!!!\n")); 9273 smsatFreeIntIoResource( smRoot, 9274 oneDeviceData, 9275 satIntIo); 9276 9277 /* Abort I/O after completion of device reset */ 9278 oneDeviceData->satAbortAfterReset = agTRUE; 9279 #ifdef NOT_YET 9280 /* needs further investigation */ 9281 /* no report to OS layer */ 9282 satSubTM(smRoot, 9283 smDeviceHandle, 9284 SM_INTERNAL_TM_RESET, 9285 agNULL, 9286 agNULL, 9287 agNULL, 9288 agFALSE); 9289 #endif 9290 9291 SM_DBG1(("smsatIOCompleted: calling saSATADeviceReset 2!!!\n")); 9292 return; 9293 } 9294 9295 break; 9296 9297 case SAT_READ_DMA_EXT: 9298 /* fall through */ 9299 /* Use default status/error translation */ 9300 9301 case SAT_READ_DMA: 9302 /* fall through */ 9303 /* Use default status/error translation */ 9304 9305 default: 9306 smsatDefaultTranslation( smRoot, 9307 smIORequest, 9308 satIOContext, 9309 pSense, 9310 (bit8)ataStatus, 9311 (bit8)ataError, 9312 interruptContext ); 9313 break; 9314 9315 } /* end switch */ 9316 return; 9317 } 9318 9319 9320 osGLOBAL void 9321 smsatEncryptionHandler( 9322 smRoot_t *smRoot, 9323 agsaIORequest_t *agIORequest, 9324 bit32 agIOStatus, 9325 bit32 agIOInfoLen, 9326 void *agParam, 9327 bit32 agOtherInfo, 9328 bit32 interruptContext 9329 ) 9330 { 9331 smIORequestBody_t *smIORequestBody; 9332 bit32 errorDetail = smDetailOtherError; 9333 9334 SM_DBG1(("smsatEncryptionHandler: start\n")); 9335 SM_DBG1(("smsatEncryptionHandler: agIOStatus 0x%x\n", agIOStatus)); 9336 9337 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 9338 9339 switch (agIOStatus) 9340 { 9341 case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS: 9342 SM_DBG1(("smsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS\n")); 9343 errorDetail = smDetailDekKeyCacheMiss; 9344 break; 9345 case OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID: 9346 SM_DBG1(("smsatEncryptionHandler: OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID\n")); 9347 errorDetail = smDetailCipherModeInvalid; 9348 break; 9349 case OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH: 9350 SM_DBG1(("smsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH\n")); 9351 errorDetail = smDetailDekIVMismatch; 9352 break; 9353 case OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR: 9354 SM_DBG1(("smsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR\n")); 9355 errorDetail = smDetailDekRamInterfaceError; 9356 break; 9357 case OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS: 9358 SM_DBG1(("smsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS\n")); 9359 errorDetail = smDetailDekIndexOutofBounds; 9360 break; 9361 case OSSA_IO_XFR_ERROR_DEK_ILLEGAL_TABLE: 9362 SM_DBG1(("smsatEncryptionHandler:OSSA_IO_XFR_ERROR_DEK_ILLEGAL_TABLE\n")); 9363 errorDetail = smDetailOtherError; 9364 break; 9365 default: 9366 SM_DBG1(("smsatEncryptionHandler: other error!!! 0x%x\n", agIOStatus)); 9367 errorDetail = smDetailOtherError; 9368 break; 9369 } 9370 9371 tdsmIOCompletedCB( smRoot, 9372 smIORequestBody->smIORequest, 9373 smIOEncryptError, 9374 errorDetail, 9375 agNULL, 9376 interruptContext 9377 ); 9378 return; 9379 } 9380 9381 osGLOBAL void 9382 smsatDifHandler( 9383 smRoot_t *smRoot, 9384 agsaIORequest_t *agIORequest, 9385 bit32 agIOStatus, 9386 bit32 agIOInfoLen, 9387 void *agParam, 9388 bit32 agOtherInfo, 9389 bit32 interruptContext 9390 ) 9391 { 9392 smIORequestBody_t *smIORequestBody; 9393 bit32 errorDetail = smDetailOtherError; 9394 #ifdef TD_DEBUG_ENABLE 9395 agsaDifDetails_t *DifDetail; 9396 #endif 9397 9398 SM_DBG1(("smsatDifHandler: start\n")); 9399 SM_DBG1(("smsatDifHandler: agIOStatus 0x%x\n", agIOStatus)); 9400 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 9401 #ifdef TD_DEBUG_ENABLE 9402 DifDetail = (agsaDifDetails_t *)agParam; 9403 #endif 9404 9405 switch (agIOStatus) 9406 { 9407 case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH: 9408 SM_DBG1(("smsatDifHandler: OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH\n")); 9409 errorDetail = smDetailDifAppTagMismatch; 9410 break; 9411 case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH: 9412 SM_DBG1(("smsatDifHandler: OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH\n")); 9413 errorDetail = smDetailDifRefTagMismatch; 9414 break; 9415 case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH: 9416 SM_DBG1(("smsatDifHandler: OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH\n")); 9417 errorDetail = smDetailDifCrcMismatch; 9418 break; 9419 default: 9420 SM_DBG1(("smsatDifHandler: other error!!! 0x%x\n", agIOStatus)); 9421 errorDetail = smDetailOtherError; 9422 break; 9423 } 9424 9425 SM_DBG1(("smsatDifHandler: DIF detail UpperLBA 0x%08x LowerLBA 0x%08x\n", DifDetail->UpperLBA, DifDetail->LowerLBA)); 9426 9427 tdsmIOCompletedCB( smRoot, 9428 smIORequestBody->smIORequest, 9429 smIODifError, 9430 errorDetail, 9431 agNULL, 9432 interruptContext 9433 ); 9434 return; 9435 } 9436 9437 osGLOBAL void 9438 smsatProcessAbort( 9439 smRoot_t *smRoot, 9440 smIORequest_t *smIORequest, 9441 smSatIOContext_t *satIOContext 9442 ) 9443 { 9444 smDeviceData_t *oneDeviceData; 9445 #ifdef REMOVED 9446 smDeviceHandle_t *smDeviceHandle; 9447 #endif 9448 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 9449 9450 SM_DBG5(("smsatProcessAbort: start\n")); 9451 9452 oneDeviceData = satIOContext->pSatDevData; 9453 #ifdef REMOVED 9454 smDeviceHandle = satIOContext->psmDeviceHandle; 9455 #endif 9456 hostToDevFis = satIOContext->pFis; 9457 9458 if ( (hostToDevFis->h.command == SAT_SMART && hostToDevFis->h.features == SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE) && 9459 (hostToDevFis->d.lbaLow != 0x01 && hostToDevFis->d.lbaLow != 0x02) 9460 ) 9461 { 9462 /* no completion for send diagnotic in background. It is done in satSendDiagnostic() */ 9463 tdsmIOCompletedCB( smRoot, 9464 smIORequest, 9465 smIOFailed, 9466 smDetailAborted, 9467 agNULL, 9468 satIOContext->interruptContext); 9469 } 9470 9471 if ( oneDeviceData->satTmTaskTag != agNULL ) 9472 { 9473 SM_DBG1(("smsatProcessAbort: TM callback!!!\n")); 9474 #ifdef REMOVED 9475 /* TM completed */ 9476 tdsmEventCB( smRoot, 9477 smDeviceHandle, 9478 smIntrEventTypeTaskManagement, 9479 smTMOK, 9480 oneDeviceData->satTmTaskTag); 9481 #endif 9482 /* 9483 * Reset flag 9484 */ 9485 oneDeviceData->satTmTaskTag = agNULL; 9486 } 9487 9488 /* 9489 * Check if we are in recovery mode and need to update the recovery flag 9490 */ 9491 if ((oneDeviceData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 9492 (oneDeviceData->satPendingIO == 0 )) 9493 { 9494 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 9495 SM_DBG1(("smsatProcessAbort: STATE NORMAL.!!!\n")); 9496 } 9497 SM_DBG1(("smsatProcessAbort: satDriveState %d!!!\n", oneDeviceData->satDriveState)); 9498 SM_DBG1(("smsatProcessAbort: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 9499 SM_DBG1(("smsatProcessAbort: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 9500 9501 return; 9502 } 9503 9504 9505 osGLOBAL void 9506 smsatNonDataIOCB( 9507 agsaRoot_t *agRoot, 9508 agsaIORequest_t *agIORequest, 9509 bit32 agIOStatus, 9510 agsaFisHeader_t *agFirstDword, 9511 bit32 agIOInfoLen, 9512 void *agParam, 9513 void *ioContext 9514 ) 9515 { 9516 smRoot_t *smRoot = agNULL; 9517 smIntRoot_t *smIntRoot = agNULL; 9518 smIntContext_t *smAllShared = agNULL; 9519 smIORequestBody_t *smIORequestBody; 9520 bit32 interruptContext; 9521 smSatIOContext_t *satIOContext; 9522 smDeviceData_t *oneDeviceData; 9523 9524 SM_DBG2(("smsatNonDataIOCB: start\n")); 9525 SM_DBG5(("satNonDataIOCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 9526 agIORequest, agIOStatus, agIOInfoLen)); 9527 9528 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 9529 satIOContext = (smSatIOContext_t *) ioContext; 9530 oneDeviceData = satIOContext->pSatDevData; 9531 smRoot = oneDeviceData->smRoot; 9532 smIntRoot = (smIntRoot_t *)smRoot->smData; 9533 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 9534 interruptContext = satIOContext->interruptContext; 9535 9536 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9537 9538 9539 smIORequestBody->ioCompleted = agTRUE; 9540 smIORequestBody->ioStarted = agFALSE; 9541 9542 /* Process completion */ 9543 if( (agIOStatus == OSSA_IO_SUCCESS) && (agIOInfoLen==0)) 9544 { 9545 9546 SM_DBG1(("satNonDataIOCB: *** ERROR*** agIORequest=%p agIOStatus=0x%x agIOInfoLen %d!!!\n", 9547 agIORequest, agIOStatus, agIOInfoLen)); 9548 9549 tdsmIOCompletedCB( smRoot, 9550 smIORequestBody->smIORequest, 9551 smIOFailed, 9552 smDetailOtherError, 9553 agNULL, 9554 interruptContext); 9555 } 9556 else 9557 { 9558 /* More checking needed, for non-data IO this should be the normal case */ 9559 smsatProcessAbnormalCompletion( agRoot, 9560 agIORequest, 9561 agIOStatus, 9562 agFirstDword, 9563 agIOInfoLen, 9564 agParam, 9565 satIOContext); 9566 } 9567 return; 9568 } 9569 9570 osGLOBAL void 9571 smsatInquiryCB( 9572 agsaRoot_t *agRoot, 9573 agsaIORequest_t *agIORequest, 9574 bit32 agIOStatus, 9575 agsaFisHeader_t *agFirstDword, 9576 bit32 agIOInfoLen, 9577 void *agParam, 9578 void *ioContext 9579 ) 9580 { 9581 /* 9582 In the process of Inquiry 9583 Process SAT_IDENTIFY_DEVICE 9584 */ 9585 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 9586 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 9587 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 9588 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 9589 smRoot_t *smRoot = agNULL; 9590 smIntRoot_t *smIntRoot = agNULL; 9591 smIntContext_t *smAllShared = agNULL; 9592 smIORequestBody_t *smIORequestBody; 9593 smIORequestBody_t *smOrgIORequestBody; 9594 smSatIOContext_t *satIOContext; 9595 smSatIOContext_t *satOrgIOContext; 9596 smSatInternalIo_t *satIntIo; 9597 // satDeviceData_t *satDevData; 9598 smDeviceData_t *oneDeviceData; 9599 smScsiRspSense_t *pSense; 9600 smIniScsiCmnd_t *scsiCmnd; 9601 smIORequest_t *smOrgIORequest; 9602 #ifdef TD_DEBUG_ENABLE 9603 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 9604 bit32 ataStatus = 0; 9605 bit32 ataError; 9606 #endif 9607 smScsiInitiatorRequest_t *smScsiRequest; /* TD's smScsiXchg */ 9608 smScsiInitiatorRequest_t *smOrgScsiRequest; /* OS's smScsiXchg */ 9609 agsaSATAIdentifyData_t *pSATAIdData; 9610 bit8 *pInquiry; 9611 bit8 page = 0xFF; 9612 bit16 *tmpptr,tmpptr_tmp; 9613 bit32 x; 9614 bit32 lenReceived = 0; 9615 bit32 allocationLen = 0; 9616 bit32 lenNeeded = 0; 9617 bit8 dataBuffer[SATA_PAGE89_INQUIRY_SIZE] = {0}; 9618 9619 9620 SM_DBG6(("smsatInquiryCB: start\n")); 9621 SM_DBG6(("smsatInquiryCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 9622 9623 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 9624 satIOContext = (smSatIOContext_t *) ioContext; 9625 satIntIo = satIOContext->satIntIoContext; 9626 oneDeviceData = satIOContext->pSatDevData; 9627 smScsiRequest = satIOContext->smScsiXchg; 9628 smRoot = oneDeviceData->smRoot; 9629 smIntRoot = (smIntRoot_t *)smRoot->smData; 9630 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 9631 9632 if (satIntIo == agNULL) 9633 { 9634 SM_DBG6(("smsatInquiryCB: External, OS generated\n")); 9635 pSense = satIOContext->pSense; 9636 scsiCmnd = satIOContext->pScsiCmnd; 9637 satOrgIOContext = satIOContext; 9638 smOrgIORequest = smIORequestBody->smIORequest; 9639 } 9640 else 9641 { 9642 SM_DBG6(("smsatInquiryCB: Internal, TD generated\n")); 9643 satOrgIOContext = satIOContext->satOrgIOContext; 9644 if (satOrgIOContext == agNULL) 9645 { 9646 SM_DBG1(("smsatInquiryCB: satOrgIOContext is NULL, wrong!!!\n")); 9647 return; 9648 } 9649 else 9650 { 9651 SM_DBG6(("smsatInquiryCB: satOrgIOContext is NOT NULL\n")); 9652 } 9653 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 9654 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 9655 pSense = satOrgIOContext->pSense; 9656 scsiCmnd = satOrgIOContext->pScsiCmnd; 9657 } 9658 9659 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 9660 pInquiry = dataBuffer; 9661 9662 smIORequestBody->ioCompleted = agTRUE; 9663 smIORequestBody->ioStarted = agFALSE; 9664 9665 SM_DBG3(("smsatInquiryCB: did %d\n", oneDeviceData->id)); 9666 9667 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 9668 { 9669 SM_DBG1(("smsatInquiryCB: agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 9670 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY) 9671 { 9672 SM_DBG1(("smsatInquiryCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY!!!\n")); 9673 /* should NOT be retried */ 9674 tdsmIOCompletedCB( smRoot, 9675 smOrgIORequest, 9676 smIOFailed, 9677 smDetailNoLogin, 9678 agNULL, 9679 satOrgIOContext->interruptContext 9680 ); 9681 } 9682 else 9683 { 9684 SM_DBG1(("smsatInquiryCB: NOT OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY!!!\n")); 9685 tdsmIOCompletedCB( smRoot, 9686 smOrgIORequest, 9687 smIOFailed, 9688 smDetailNoLogin, 9689 agNULL, 9690 satOrgIOContext->interruptContext 9691 ); 9692 } 9693 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9694 9695 smsatFreeIntIoResource( smRoot, 9696 oneDeviceData, 9697 satIntIo); 9698 return; 9699 } 9700 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 9701 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 9702 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 9703 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 9704 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 9705 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 9706 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 9707 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 9708 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 9709 ) 9710 { 9711 SM_DBG1(("smsatInquiryCB: OSSA_IO_OPEN_CNX_ERROR!!!\n")); 9712 9713 tdsmIOCompletedCB( smRoot, 9714 smOrgIORequest, 9715 smIOFailed, 9716 smDetailNoLogin, 9717 agNULL, 9718 satOrgIOContext->interruptContext 9719 ); 9720 9721 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9722 9723 smsatFreeIntIoResource( smRoot, 9724 oneDeviceData, 9725 satIntIo); 9726 return; 9727 } 9728 9729 if ( agIOStatus != OSSA_IO_SUCCESS || 9730 (agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL && agIOInfoLen != 0) 9731 ) 9732 { 9733 #ifdef TD_DEBUG_ENABLE 9734 /* only agsaFisPioSetup_t is expected */ 9735 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 9736 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 9737 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 9738 #endif 9739 SM_DBG1(("smsatInquiryCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 9740 9741 /* Process abort case */ 9742 if (agIOStatus == OSSA_IO_ABORTED) 9743 { 9744 smsatProcessAbort(smRoot, 9745 smOrgIORequest, 9746 satOrgIOContext 9747 ); 9748 9749 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9750 9751 smsatFreeIntIoResource( smRoot, 9752 oneDeviceData, 9753 satIntIo); 9754 return; 9755 } 9756 9757 tdsmIOCompletedCB( smRoot, 9758 smOrgIORequest, 9759 smIOFailed, 9760 smDetailOtherError, 9761 agNULL, 9762 satOrgIOContext->interruptContext 9763 ); 9764 9765 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9766 9767 smsatFreeIntIoResource( smRoot, 9768 oneDeviceData, 9769 satIntIo); 9770 return; 9771 } 9772 9773 /* success */ 9774 9775 9776 /* Convert to host endian */ 9777 tmpptr = (bit16*)(smScsiRequest->sglVirtualAddr); 9778 for (x=0; x < sizeof(agsaSATAIdentifyData_t)/sizeof(bit16); x++) 9779 { 9780 OSSA_READ_LE_16(AGROOT, &tmpptr_tmp, tmpptr, 0); 9781 *tmpptr = tmpptr_tmp; 9782 tmpptr++; 9783 /*Print tmpptr_tmp here for debugging purpose*/ 9784 } 9785 9786 pSATAIdData = (agsaSATAIdentifyData_t *)(smScsiRequest->sglVirtualAddr); 9787 9788 SM_DBG5(("smsatInquiryCB: OS satOrgIOContext %p \n", satOrgIOContext)); 9789 SM_DBG5(("smsatInquiryCB: TD satIOContext %p \n", satIOContext)); 9790 SM_DBG5(("smsatInquiryCB: OS smScsiXchg %p \n", satOrgIOContext->smScsiXchg)); 9791 SM_DBG5(("smsatInquiryCB: TD smScsiXchg %p \n", satIOContext->smScsiXchg)); 9792 9793 /* copy ID Dev data to oneDeviceData */ 9794 oneDeviceData->satIdentifyData = *pSATAIdData; 9795 oneDeviceData->IDDeviceValid = agTRUE; 9796 #ifdef SM_INTERNAL_DEBUG 9797 smhexdump("smsatInquiryCB ID Dev data",(bit8 *)pSATAIdData, sizeof(agsaSATAIdentifyData_t)); 9798 smhexdump("smsatInquiryCB Device ID Dev data",(bit8 *)&oneDeviceData->satIdentifyData, sizeof(agsaSATAIdentifyData_t)); 9799 #endif 9800 // smhexdump("smsatInquiryCB Device ID Dev data",(bit8 *)&oneDeviceData->satIdentifyData, sizeof(agsaSATAIdentifyData_t)); 9801 9802 /* set oneDeviceData fields from IndentifyData */ 9803 smsatSetDevInfo(oneDeviceData,pSATAIdData); 9804 9805 allocationLen = ((scsiCmnd->cdb[3]) << 8) + scsiCmnd->cdb[4]; 9806 allocationLen = MIN(allocationLen, scsiCmnd->expDataLength); 9807 9808 /* SPC-4, spec 6.4 p 141 */ 9809 /* EVPD bit == 0 */ 9810 if (!(scsiCmnd->cdb[1] & SCSI_EVPD_MASK)) 9811 { 9812 /* Returns the standard INQUIRY data */ 9813 lenNeeded = STANDARD_INQUIRY_SIZE; 9814 9815 9816 smsatInquiryStandard(pInquiry, pSATAIdData, scsiCmnd); 9817 //smhexdump("smsatInquiryCB ***standard***", (bit8 *)pInquiry, 36); 9818 9819 } 9820 else 9821 { 9822 /* EVPD bit != 0 && PAGE CODE != 0 */ 9823 /* returns the pages of vital product data information */ 9824 9825 /* we must support page 00h, 83h and 89h */ 9826 page = scsiCmnd->cdb[2]; 9827 if ((page != INQUIRY_SUPPORTED_VPD_PAGE) && 9828 (page != INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE) && 9829 (page != INQUIRY_ATA_INFORMATION_VPD_PAGE) && 9830 (page != INQUIRY_BLOCK_DEVICE_CHARACTERISTICS_VPD_PAGE)) 9831 { 9832 smsatSetSensePayload( pSense, 9833 SCSI_SNSKEY_ILLEGAL_REQUEST, 9834 0, 9835 SCSI_SNSCODE_INVALID_FIELD_IN_CDB, 9836 satOrgIOContext); 9837 9838 tdsmIOCompletedCB( smRoot, 9839 smOrgIORequest, 9840 smIOSuccess, 9841 SCSI_STAT_CHECK_CONDITION, 9842 satOrgIOContext->pSmSenseData, 9843 satOrgIOContext->interruptContext ); 9844 9845 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9846 9847 smsatFreeIntIoResource( smRoot, 9848 oneDeviceData, 9849 satIntIo); 9850 SM_DBG1(("smsatInquiryCB: invalid PAGE CODE 0x%x!!!\n", page)); 9851 return; 9852 } 9853 9854 /* checking length */ 9855 switch (page) 9856 { 9857 case INQUIRY_SUPPORTED_VPD_PAGE: 9858 lenNeeded = SATA_PAGE0_INQUIRY_SIZE; /* 9 */ 9859 break; 9860 case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 9861 if (oneDeviceData->satWWNSupport) 9862 { 9863 lenNeeded = SATA_PAGE83_INQUIRY_WWN_SIZE; /* 16 */ 9864 } 9865 else 9866 { 9867 lenNeeded = SATA_PAGE83_INQUIRY_NO_WWN_SIZE; /* 76 */ 9868 } 9869 break; 9870 case INQUIRY_ATA_INFORMATION_VPD_PAGE: 9871 lenNeeded = SATA_PAGE89_INQUIRY_SIZE; /* 572 */ 9872 break; 9873 case INQUIRY_BLOCK_DEVICE_CHARACTERISTICS_VPD_PAGE: 9874 lenNeeded = SATA_PAGEB1_INQUIRY_SIZE; /* 64 */ 9875 break; 9876 default: 9877 SM_DBG1(("smsatInquiryCB: wrong!!! invalid PAGE CODE 0x%x!!!\n", page)); 9878 break; 9879 } 9880 9881 9882 /* 9883 * Fill in the Inquiry data depending on what Inquiry data we are returning. 9884 */ 9885 switch (page) 9886 { 9887 case INQUIRY_SUPPORTED_VPD_PAGE: 9888 smsatInquiryPage0(pInquiry, pSATAIdData); 9889 break; 9890 case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 9891 smsatInquiryPage83(pInquiry, pSATAIdData, oneDeviceData); 9892 break; 9893 case INQUIRY_ATA_INFORMATION_VPD_PAGE: 9894 smsatInquiryPage89(pInquiry, pSATAIdData, oneDeviceData, lenReceived); 9895 break; 9896 case INQUIRY_BLOCK_DEVICE_CHARACTERISTICS_VPD_PAGE: 9897 smsatInquiryPageB1(pInquiry, pSATAIdData); 9898 break; 9899 default: 9900 SM_DBG1(("smsatInquiryCB: wrong!!! invalidinvalid PAGE CODE 0x%x!!!\n", page)); 9901 break; 9902 } 9903 } /* else */ 9904 9905 SM_DBG6(("smsatInquiryCB: calling tdsmIOCompletedCB\n")); 9906 9907 /* if this is a standard Inquiry command, notify Stoport to set the device queue depth to max NCQ */ 9908 if ( (oneDeviceData->satNCQ == agTRUE) && 9909 ((scsiCmnd->cdb[1] & 0x01) == 0)) 9910 { 9911 if (tdsmSetDeviceQueueDepth(smRoot, 9912 smOrgIORequest, 9913 oneDeviceData->satNCQMaxIO-1 9914 ) == agFALSE) 9915 { 9916 SM_DBG1(("smsatInquiryCB: failed to call tdsmSetDeviceQueueDepth()!!! Q=%d\n", oneDeviceData->satNCQMaxIO)); 9917 } 9918 } 9919 9920 sm_memcpy(smOrgScsiRequest->sglVirtualAddr, dataBuffer, MIN(allocationLen, lenNeeded)); 9921 if (allocationLen > lenNeeded) 9922 { 9923 SM_DBG6(("smsatInquiryCB reporting underrun lenNeeded=0x%x allocationLen=0x%x smIORequest=%p\n", 9924 lenNeeded, allocationLen, smOrgIORequest)); 9925 9926 tdsmIOCompletedCB( smRoot, 9927 smOrgIORequest, 9928 smIOUnderRun, 9929 allocationLen - lenNeeded, 9930 agNULL, 9931 satOrgIOContext->interruptContext ); 9932 } 9933 else 9934 { 9935 tdsmIOCompletedCB( smRoot, 9936 smOrgIORequest, 9937 smIOSuccess, 9938 SCSI_STAT_GOOD, 9939 agNULL, 9940 satOrgIOContext->interruptContext); 9941 } 9942 9943 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 9944 9945 smsatFreeIntIoResource( smRoot, 9946 oneDeviceData, 9947 satIntIo); 9948 SM_DBG5(("smsatInquiryCB: device %p pending IO %d\n", oneDeviceData, oneDeviceData->satPendingIO)); 9949 SM_DBG6(("smsatInquiryCB: end\n")); 9950 return; 9951 } 9952 9953 osGLOBAL void 9954 smsatInquiryIntCB( 9955 smRoot_t *smRoot, 9956 smIORequest_t *smIORequest, 9957 smDeviceHandle_t *smDeviceHandle, 9958 smScsiInitiatorRequest_t *smScsiRequest, 9959 smSatIOContext_t *satIOContext 9960 ) 9961 { 9962 smScsiRspSense_t *pSense; 9963 smIniScsiCmnd_t *scsiCmnd; 9964 // satDeviceData_t *satDevData; 9965 smDeviceData_t *oneDeviceData; 9966 agsaSATAIdentifyData_t *pSATAIdData; 9967 9968 bit8 *pInquiry; 9969 bit8 page = 0xFF; 9970 bit32 lenReceived = 0; 9971 bit32 allocationLen = 0; 9972 bit32 lenNeeded = 0; 9973 bit8 dataBuffer[SATA_PAGE89_INQUIRY_SIZE] = {0}; 9974 9975 SM_DBG6(("smsatInquiryIntCB: start\n")); 9976 9977 pSense = satIOContext->pSense; 9978 scsiCmnd = &smScsiRequest->scsiCmnd; 9979 pInquiry = dataBuffer; 9980 oneDeviceData = satIOContext->pSatDevData; 9981 pSATAIdData = &oneDeviceData->satIdentifyData; 9982 9983 allocationLen = ((scsiCmnd->cdb[3]) << 8) + scsiCmnd->cdb[4]; 9984 allocationLen = MIN(allocationLen, scsiCmnd->expDataLength); 9985 9986 /* SPC-4, spec 6.4 p 141 */ 9987 /* EVPD bit == 0 */ 9988 if (!(scsiCmnd->cdb[1] & SCSI_EVPD_MASK)) 9989 { 9990 /* Returns the standard INQUIRY data */ 9991 lenNeeded = STANDARD_INQUIRY_SIZE; 9992 9993 smsatInquiryStandard(pInquiry, pSATAIdData, scsiCmnd); 9994 //smhexdump("satInquiryIntCB ***standard***", (bit8 *)pInquiry, 36); 9995 9996 } 9997 else 9998 { 9999 /* EVPD bit != 0 && PAGE CODE != 0 */ 10000 /* returns the pages of vital product data information */ 10001 10002 /* we must support page 00h, 83h and 89h */ 10003 page = scsiCmnd->cdb[2]; 10004 if ((page != INQUIRY_SUPPORTED_VPD_PAGE) && 10005 (page != INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE) && 10006 (page != INQUIRY_ATA_INFORMATION_VPD_PAGE) && 10007 (page != INQUIRY_UNIT_SERIAL_NUMBER_VPD_PAGE) && 10008 (page != INQUIRY_BLOCK_DEVICE_CHARACTERISTICS_VPD_PAGE)) 10009 { 10010 smsatSetSensePayload( pSense, 10011 SCSI_SNSKEY_ILLEGAL_REQUEST, 10012 0, 10013 SCSI_SNSCODE_INVALID_FIELD_IN_CDB, 10014 satIOContext); 10015 10016 tdsmIOCompletedCB( smRoot, 10017 smIORequest, 10018 smIOSuccess, 10019 SCSI_STAT_CHECK_CONDITION, 10020 satIOContext->pSmSenseData, 10021 satIOContext->interruptContext ); 10022 10023 SM_DBG1(("smsatInquiryIntCB: invalid PAGE CODE 0x%x!!!\n", page)); 10024 return; 10025 } 10026 10027 /* checking length */ 10028 switch (page) 10029 { 10030 case INQUIRY_SUPPORTED_VPD_PAGE: 10031 lenNeeded = SATA_PAGE0_INQUIRY_SIZE; /* 36 */ 10032 break; 10033 case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 10034 if (oneDeviceData->satWWNSupport) 10035 { 10036 lenNeeded = SATA_PAGE83_INQUIRY_WWN_SIZE; /* 16 */ 10037 } 10038 else 10039 { 10040 lenNeeded = SATA_PAGE83_INQUIRY_NO_WWN_SIZE; /* 76 */ 10041 } 10042 break; 10043 case INQUIRY_ATA_INFORMATION_VPD_PAGE: 10044 lenNeeded = SATA_PAGE89_INQUIRY_SIZE; /* 572 */ 10045 break; 10046 case INQUIRY_UNIT_SERIAL_NUMBER_VPD_PAGE: 10047 lenNeeded = SATA_PAGE80_INQUIRY_SIZE; /* 24 */ 10048 break; 10049 case INQUIRY_BLOCK_DEVICE_CHARACTERISTICS_VPD_PAGE: 10050 lenNeeded = SATA_PAGEB1_INQUIRY_SIZE; /* 64 */ 10051 break; 10052 default: 10053 SM_DBG1(("smsatInquiryIntCB: wrong!!! invalidinvalid PAGE CODE 0x%x!!!\n", page)); 10054 break; 10055 } 10056 10057 10058 /* 10059 * Fill in the Inquiry data depending on what Inquiry data we are returning. 10060 */ 10061 switch (page) 10062 { 10063 case INQUIRY_SUPPORTED_VPD_PAGE: 10064 smsatInquiryPage0(pInquiry, pSATAIdData); 10065 break; 10066 case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 10067 smsatInquiryPage83(pInquiry, pSATAIdData, oneDeviceData); 10068 break; 10069 case INQUIRY_ATA_INFORMATION_VPD_PAGE: 10070 smsatInquiryPage89(pInquiry, pSATAIdData, oneDeviceData, lenReceived); 10071 break; 10072 case INQUIRY_UNIT_SERIAL_NUMBER_VPD_PAGE: 10073 smsatInquiryPage80(pInquiry, pSATAIdData); 10074 break; 10075 case INQUIRY_BLOCK_DEVICE_CHARACTERISTICS_VPD_PAGE: 10076 smsatInquiryPageB1(pInquiry, pSATAIdData); 10077 break; 10078 default: 10079 SM_DBG1(("smsatInquiryIntCB: wrong!!! invalidinvalid PAGE CODE 0x%x!!!\n", page)); 10080 break; 10081 } 10082 } /* else */ 10083 10084 SM_DBG6(("smsatInquiryIntCB: calling tdsmIOCompletedCB\n")); 10085 10086 /* if this is a standard Inquiry command, notify Stoport to set the device queue depth to max NCQ */ 10087 if ( (oneDeviceData->satNCQ == agTRUE) && 10088 ((scsiCmnd->cdb[1] & 0x01) == 0)) 10089 { 10090 if (tdsmSetDeviceQueueDepth(smRoot, 10091 smIORequest, 10092 oneDeviceData->satNCQMaxIO-1 10093 ) == agFALSE) 10094 { 10095 SM_DBG1(("smsatInquiryIntCB: failed to call tdsmSetDeviceQueueDepth()!!! Q=%d\n", oneDeviceData->satNCQMaxIO)); 10096 } 10097 } 10098 10099 sm_memcpy(smScsiRequest->sglVirtualAddr, dataBuffer, MIN(allocationLen, lenNeeded)); 10100 if (allocationLen > lenNeeded) 10101 { 10102 SM_DBG6(("smsatInquiryIntCB reporting underrun lenNeeded=0x%x allocationLen=0x%x smIORequest=%p\n", 10103 lenNeeded, allocationLen, smIORequest)); 10104 10105 tdsmIOCompletedCB( smRoot, 10106 smIORequest, 10107 smIOUnderRun, 10108 allocationLen - lenNeeded, 10109 agNULL, 10110 satIOContext->interruptContext ); 10111 } 10112 else 10113 { 10114 tdsmIOCompletedCB( smRoot, 10115 smIORequest, 10116 smIOSuccess, 10117 SCSI_STAT_GOOD, 10118 agNULL, 10119 satIOContext->interruptContext); 10120 } 10121 10122 SM_DBG5(("smsatInquiryIntCB: device %p pending IO %d\n", oneDeviceData, oneDeviceData->satPendingIO)); 10123 SM_DBG6(("smsatInquiryIntCB: end\n")); 10124 return; 10125 10126 } 10127 10128 osGLOBAL void 10129 smsatVerify10CB( 10130 agsaRoot_t *agRoot, 10131 agsaIORequest_t *agIORequest, 10132 bit32 agIOStatus, 10133 agsaFisHeader_t *agFirstDword, 10134 bit32 agIOInfoLen, 10135 void *agParam, 10136 void *ioContext 10137 ) 10138 { 10139 smRoot_t *smRoot = agNULL; 10140 smIntRoot_t *smIntRoot = agNULL; 10141 smIntContext_t *smAllShared = agNULL; 10142 smIORequestBody_t *smIORequestBody; 10143 smIORequestBody_t *smOrgIORequestBody; 10144 smSatIOContext_t *satIOContext; 10145 smSatIOContext_t *satOrgIOContext; 10146 smSatInternalIo_t *satIntIo; 10147 smDeviceData_t *oneDeviceData; 10148 10149 smScsiRspSense_t *pSense; 10150 smIORequest_t *smOrgIORequest; 10151 10152 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 10153 bit32 ataStatus = 0; 10154 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 10155 10156 SM_DBG5(("smsatVerify10CB: start\n")); 10157 SM_DBG5(("smsatVerify10CB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 10158 10159 /* internally generate smIOContext */ 10160 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 10161 satIOContext = (smSatIOContext_t *) ioContext; 10162 satIntIo = satIOContext->satIntIoContext; 10163 oneDeviceData = satIOContext->pSatDevData; 10164 hostToDevFis = satIOContext->pFis; 10165 smRoot = oneDeviceData->smRoot; 10166 smIntRoot = (smIntRoot_t *)smRoot->smData; 10167 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 10168 10169 if (satIntIo == agNULL) 10170 { 10171 SM_DBG4(("smsatVerify10CB: External smSatInternalIo_t satIntIoContext\n")); 10172 satOrgIOContext = satIOContext; 10173 smOrgIORequest = smIORequestBody->smIORequest; 10174 pSense = satIOContext->pSense; 10175 } 10176 else 10177 { 10178 SM_DBG4(("smsatVerify10CB: Internal smSatInternalIo_t satIntIoContext\n")); 10179 satOrgIOContext = satIOContext->satOrgIOContext; 10180 if (satOrgIOContext == agNULL) 10181 { 10182 SM_DBG4(("smsatVerify10CB: satOrgIOContext is NULL, wrong\n")); 10183 return; 10184 } 10185 else 10186 { 10187 SM_DBG4(("smsatVerify10CB: satOrgIOContext is NOT NULL\n")); 10188 } 10189 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 10190 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 10191 pSense = satOrgIOContext->pSense; 10192 } 10193 10194 smIORequestBody->ioCompleted = agTRUE; 10195 smIORequestBody->ioStarted = agFALSE; 10196 10197 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 10198 { 10199 SM_DBG1(("smsatVerify10CB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 10200 smsatSetSensePayload( pSense, 10201 SCSI_SNSKEY_NO_SENSE, 10202 0, 10203 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 10204 satOrgIOContext); 10205 10206 tdsmIOCompletedCB( smRoot, 10207 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 10208 smIOSuccess, 10209 SCSI_STAT_CHECK_CONDITION, 10210 satOrgIOContext->pSmSenseData, 10211 satOrgIOContext->interruptContext ); 10212 10213 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 10214 10215 smsatFreeIntIoResource( smRoot, 10216 oneDeviceData, 10217 satIntIo); 10218 return; 10219 } 10220 10221 if (agIOStatus != OSSA_IO_SUCCESS) 10222 { 10223 /* only agsaFisRegDeviceToHost_t is expected */ 10224 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 10225 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 10226 } 10227 10228 if( agIOStatus != OSSA_IO_SUCCESS) 10229 { 10230 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 10231 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 10232 ) 10233 { 10234 /* for debugging */ 10235 if( agIOStatus != OSSA_IO_SUCCESS) 10236 { 10237 SM_DBG1(("smsatVerify10CB: FAILED, NOT IO_SUCCESS!!!\n")); 10238 } 10239 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 10240 { 10241 SM_DBG1(("smsatVerify10CB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 10242 } 10243 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 10244 (ataStatus & DF_ATA_STATUS_MASK) 10245 ) 10246 { 10247 SM_DBG1(("smsatVerify10CB: FAILED, FAILED, error status!!!\n")); 10248 } 10249 10250 /* Process abort case */ 10251 if (agIOStatus == OSSA_IO_ABORTED) 10252 { 10253 smsatProcessAbort(smRoot, 10254 smOrgIORequest, 10255 satOrgIOContext 10256 ); 10257 10258 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 10259 10260 smsatFreeIntIoResource( smRoot, 10261 oneDeviceData, 10262 satIntIo); 10263 return; 10264 } 10265 10266 /* for debugging */ 10267 switch (hostToDevFis->h.command) 10268 { 10269 case SAT_READ_VERIFY_SECTORS_EXT: 10270 SM_DBG1(("smsatVerify10CB: SAT_READ_VERIFY_SECTORS_EXT!!!\n")); 10271 break; 10272 default: 10273 SM_DBG1(("smsatVerify10CB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 10274 break; 10275 } 10276 10277 smsatSetSensePayload( pSense, 10278 SCSI_SNSKEY_NO_SENSE, 10279 0, 10280 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 10281 satOrgIOContext); 10282 10283 tdsmIOCompletedCB( smRoot, 10284 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 10285 smIOSuccess, 10286 SCSI_STAT_CHECK_CONDITION, 10287 satOrgIOContext->pSmSenseData, 10288 satOrgIOContext->interruptContext ); 10289 10290 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 10291 10292 smsatFreeIntIoResource( smRoot, 10293 oneDeviceData, 10294 satIntIo); 10295 return; 10296 } /* end error checking */ 10297 } 10298 10299 /* process success from this point on */ 10300 switch (hostToDevFis->h.command) 10301 { 10302 case SAT_READ_VERIFY_SECTORS_EXT: 10303 SM_DBG5(("smsatVerify10CB: SAT_WRITE_DMA_EXT success \n")); 10304 10305 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 10306 10307 smsatFreeIntIoResource( smRoot, 10308 oneDeviceData, 10309 satIntIo); 10310 10311 tdsmIOCompletedCB( smRoot, 10312 smOrgIORequest, 10313 smIOSuccess, 10314 SCSI_STAT_GOOD, 10315 agNULL, 10316 satOrgIOContext->interruptContext); 10317 break; 10318 default: 10319 SM_DBG1(("smsatVerify10CB: success but error default case command 0x%x!!!\n", hostToDevFis->h.command)); 10320 10321 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 10322 10323 smsatFreeIntIoResource( smRoot, 10324 oneDeviceData, 10325 satIntIo); 10326 10327 smsatSetSensePayload( pSense, 10328 SCSI_SNSKEY_NO_SENSE, 10329 0, 10330 SCSI_SNSCODE_NO_ADDITIONAL_INFO, 10331 satOrgIOContext); 10332 10333 tdsmIOCompletedCB( smRoot, 10334 smOrgIORequest, /* == &satIntIo->satOrgSmIORequest */ 10335 smIOSuccess, 10336 SCSI_STAT_CHECK_CONDITION, 10337 satOrgIOContext->pSmSenseData, 10338 satOrgIOContext->interruptContext ); 10339 10340 break; 10341 } 10342 10343 return; 10344 } 10345 10346 osGLOBAL void 10347 smsatReadLogExtCB( 10348 agsaRoot_t *agRoot, 10349 agsaIORequest_t *agIORequest, 10350 bit32 agIOStatus, 10351 agsaFisHeader_t *agFirstDword, 10352 bit32 agIOInfoLen, 10353 void *agParam, 10354 void *ioContext 10355 ) 10356 { 10357 smRoot_t *smRoot = agNULL; 10358 smIntRoot_t *smIntRoot = agNULL; 10359 smIntContext_t *smAllShared = agNULL; 10360 smIORequestBody_t *smIORequestBody; 10361 smSatIOContext_t *satReadLogExtIOContext; 10362 smSatIOContext_t *satIOContext; 10363 smSatInternalIo_t *satIntIo; 10364 smDeviceData_t *oneDeviceData; 10365 agsaIORequest_t *agAbortIORequest; 10366 smIORequestBody_t *smAbortIORequestBody; 10367 bit32 PhysUpper32; 10368 bit32 PhysLower32; 10369 bit32 memAllocStatus; 10370 void *osMemHandle; 10371 smDeviceHandle_t *smDeviceHandle; 10372 10373 SM_DBG5(("smsatReadLogExtCB: start\n")); 10374 SM_DBG1(("smsatReadLogExtCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 10375 agIORequest, agIOStatus, agIOInfoLen)); 10376 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 10377 satReadLogExtIOContext = (smSatIOContext_t *) ioContext; 10378 satIntIo = satReadLogExtIOContext->satIntIoContext; 10379 oneDeviceData = satReadLogExtIOContext->pSatDevData; 10380 smDeviceHandle = satReadLogExtIOContext->psmDeviceHandle; 10381 smRoot = oneDeviceData->smRoot; 10382 smIntRoot = (smIntRoot_t *)smRoot->smData; 10383 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 10384 SM_DBG1(("smsatReadLogExtCB: did %d!!!\n", oneDeviceData->id)); 10385 SM_DBG1(("smsatReadLogExtCB: smIORequestBody ID %d!!!\n", smIORequestBody->id)); 10386 SM_DBG1(("smsatReadLogExtCB: smIORequestBody ioCompleted %d ioStarted %d\n", smIORequestBody->ioCompleted, smIORequestBody->ioStarted)); 10387 smsatDecrementPendingIO(smRoot, smAllShared, satReadLogExtIOContext); 10388 10389 smIORequestBody->ioCompleted = agTRUE; 10390 smIORequestBody->ioStarted = agFALSE; 10391 10392 /* 10393 * If READ LOG EXT failed, we issue device reset. 10394 */ 10395 if ( agIOStatus != OSSA_IO_SUCCESS || 10396 (agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL && agIOInfoLen != 0) 10397 ) 10398 { 10399 SM_DBG1(("smsatReadLogExtCB: FAILED.!!!\n")); 10400 10401 smsatFreeIntIoResource( smRoot, 10402 oneDeviceData, 10403 satIntIo); 10404 /* Abort I/O after completion of device reset */ 10405 oneDeviceData->satAbortAfterReset = agTRUE; 10406 #ifdef NOT_YET 10407 /* needs to investigate this case */ 10408 /* no report to OS layer */ 10409 satSubTM(smRoot, 10410 satReadLogExtIOContext->ptiDeviceHandle, 10411 TD_INTERNAL_TM_RESET, 10412 agNULL, 10413 agNULL, 10414 agNULL, 10415 agFALSE); 10416 #endif 10417 return; 10418 } 10419 10420 10421 /*************************************************************************** 10422 * The following steps take place when READ LOG EXT successfully completed. 10423 ***************************************************************************/ 10424 10425 /************************************************************************ 10426 * 10427 * 1. Issue abort to LL layer to all other pending I/Os for the same SATA 10428 * drive. 10429 * 10430 * 2. Free resource allocated for the internally generated READ LOG EXT. 10431 * 10432 * 3. At the completion of abort, in the context of ossaSATACompleted(), 10433 * return the I/O with error status to the OS-App Specific layer. 10434 * When all I/O aborts are completed, clear SATA device flag to 10435 * indicate ready to process new request. 10436 * 10437 ***********************************************************************/ 10438 10439 /* 10440 * Issue abort to LL layer to all other pending I/Os for the same SATA drive 10441 */ 10442 /* 10443 replace the single IO abort with device abort 10444 */ 10445 10446 SM_DBG1(("smsatReadLogExtCB: issuing saSATAAbort. Device Abort!!!\n")); 10447 oneDeviceData->SMAbortAll = agTRUE; 10448 /* 10449 smAbortIORequestBody = smDequeueIO(smRoot); 10450 10451 if (smAbortIORequestBody == agNULL) 10452 { 10453 SM_DBG1(("smsatReadLogExtCB: empty freeIOList!!!\n")); 10454 return; 10455 } 10456 */ 10457 /* allocating agIORequest for abort itself */ 10458 memAllocStatus = tdsmAllocMemory( 10459 smRoot, 10460 &osMemHandle, 10461 (void **)&smAbortIORequestBody, 10462 &PhysUpper32, 10463 &PhysLower32, 10464 8, 10465 sizeof(smIORequestBody_t), 10466 agTRUE 10467 ); 10468 10469 if (memAllocStatus != tiSuccess) 10470 { 10471 /* let os process IO */ 10472 SM_DBG1(("smsatReadLogExtCB: ostiAllocMemory failed...\n")); 10473 return; 10474 } 10475 10476 if (smAbortIORequestBody == agNULL) 10477 { 10478 /* let os process IO */ 10479 SM_DBG1(("smsatReadLogExtCB: ostiAllocMemory returned NULL smAbortIORequestBody\n")); 10480 return; 10481 } 10482 smIOReInit(smRoot, smAbortIORequestBody); 10483 /* setup task management structure */ 10484 smAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 10485 smAbortIORequestBody->smDevHandle = smDeviceHandle; 10486 /* setup task management structure */ 10487 // smAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 10488 satIOContext = &(smAbortIORequestBody->transport.SATA.satIOContext); 10489 satIOContext->smRequestBody = smAbortIORequestBody; 10490 10491 /* initialize agIORequest */ 10492 agAbortIORequest = &(smAbortIORequestBody->agIORequest); 10493 agAbortIORequest->osData = (void *) smAbortIORequestBody; 10494 agAbortIORequest->sdkData = agNULL; /* LL takes care of this */ 10495 10496 /* 10497 * Issue abort (device abort all) 10498 */ 10499 saSATAAbort( agRoot, agAbortIORequest, tdsmRotateQnumber(smRoot, smDeviceHandle), oneDeviceData->agDevHandle, 1, agNULL, smaSATAAbortCB); 10500 10501 /* 10502 * Free resource allocated for the internally generated READ LOG EXT. 10503 */ 10504 smsatFreeIntIoResource( smRoot, 10505 oneDeviceData, 10506 satIntIo); 10507 10508 /* 10509 * Sequence of recovery continue at some other context: 10510 * At the completion of abort, in the context of ossaSATACompleted(), 10511 * return the I/O with error status to the OS-App Specific layer. 10512 * When all I/O aborts are completed, clear SATA device flag to 10513 * indicate ready to process new request. 10514 */ 10515 10516 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 10517 10518 SM_DBG1(("smsatReadLogExtCB: end return!!!\n")); 10519 return; 10520 } 10521 10522 osGLOBAL void 10523 ossaSATAEvent( 10524 agsaRoot_t *agRoot, 10525 agsaIORequest_t *agIORequest, 10526 agsaPortContext_t *agPortContext, 10527 agsaDevHandle_t *agDevHandle, 10528 bit32 event, 10529 bit32 agIOInfoLen, 10530 void *agParam 10531 ) 10532 { 10533 smRoot_t *smRoot = gsmRoot; 10534 smIntRoot_t *smIntRoot = (smIntRoot_t *)smRoot->smData; 10535 smIntContext_t *smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 10536 smDeviceHandle_t *smDeviceHandle = agNULL; 10537 smDeviceData_t *oneDeviceData = agNULL; 10538 smList_t *DeviceListList; 10539 bit32 found = agFALSE; 10540 smIORequestBody_t *smIORequestBody = agNULL; 10541 smSatInternalIo_t *satIntIo = agNULL; 10542 smSatIOContext_t *satIOContext2; 10543 smIORequest_t smIORequestTMP; 10544 bit32 status; 10545 #ifdef REMOVED 10546 agsaDifDetails_t agDifDetails; 10547 bit8 framePayload[256]; 10548 bit16 frameOffset = 0; 10549 bit16 frameLen = 0; 10550 #endif 10551 10552 SM_DBG1(("ossaSATAEvent: start\n")); 10553 if (event == OSSA_IO_XFER_ERROR_ABORTED_NCQ_MODE) 10554 { 10555 /* agIORequest is invalid, search for smDeviceHandle from smAllShared using agDevHandle */ 10556 /* find a device's existence */ 10557 DeviceListList = smAllShared->MainDeviceList.flink; 10558 while (DeviceListList != &(smAllShared->MainDeviceList)) 10559 { 10560 oneDeviceData = SMLIST_OBJECT_BASE(smDeviceData_t, MainLink, DeviceListList); 10561 if (oneDeviceData == agNULL) 10562 { 10563 SM_DBG1(("ossaSATAEvent: oneDeviceData is NULL!!!\n")); 10564 return; 10565 } 10566 if (oneDeviceData->agDevHandle == agDevHandle) 10567 { 10568 SM_DBG2(("ossaSATAEvent: did %d\n", oneDeviceData->id)); 10569 found = agTRUE; 10570 break; 10571 } 10572 DeviceListList = DeviceListList->flink; 10573 } 10574 if (found == agFALSE) 10575 { 10576 SM_DBG2(("ossaSATAEvent: not found!!!\n")); 10577 return; 10578 } 10579 if (oneDeviceData->valid == agFALSE) 10580 { 10581 SM_DBG2(("ossaSATAEvent: oneDeviceData is not valid did %d!!!\n", oneDeviceData->id)); 10582 return; 10583 } 10584 /************************************************************************** 10585 * 10586 * !!!! See Section 13.5.2.4 of SATA 2.5 specs. !!!! 10587 * !!!! If the NCQ error ends up here, it means that the device sent !!!! 10588 * !!!! Register Device To Host FIS (which does not have SActive !!!! 10589 * !!!! register) instead of Set Device Bit FIS (which has SActive !!!! 10590 * !!!! register). The routine osSatIOCompleted() deals with the case !!!! 10591 * !!!! where Set Device Bit FIS was sent by the device. !!!! 10592 * 10593 * For NCQ we need to issue READ LOG EXT command with log page 10h 10594 * to get the error and to allow other I/Os to continue. 10595 * 10596 * Here is the basic flow or sequence of error recovery, this sequence is 10597 * similar to the one described in SATA 2.5: 10598 * 10599 * 1. Set SATA device flag to indicate error condition and returning busy 10600 * for all new request. 10601 * 10602 * 2. Prepare READ LOG EXT page 10h command. Set flag to indicate that 10603 * the failed I/O has NOT been returned to the OS Layer. Send command. 10604 * 10605 * 3. When the device receives READ LOG EXT page 10h request all other 10606 * pending I/O are implicitly aborted. No completion (aborted) status 10607 * will be sent to the host for these aborted commands. 10608 * 10609 * 4. SATL receives the completion for READ LOG EXT command in 10610 * smsatReadLogExtCB(). Steps 5,6,7,8 below are the step 1,2,3,4 in 10611 * smsatReadLogExtCB(). 10612 * 10613 * 5. Check flag that indicates whether the failed I/O has been returned 10614 * to the OS Layer. If not, search the I/O context in device data 10615 * looking for a matched tag. Then return the completion of the failed 10616 * NCQ command with the appopriate/trasnlated SCSI status. 10617 * 10618 * 6. Issue abort to LL layer to all other pending I/Os for the same SATA 10619 * drive. 10620 * 10621 * 7. Free resource allocated for the internally generated READ LOG EXT. 10622 * 10623 * 8. At the completion of abort, in the context of ossaSATACompleted(), 10624 * return the I/O with error status to the OS-App Specific layer. 10625 * When all I/O aborts are completed, clear SATA device flag to 10626 * indicate ready to process new request. 10627 * 10628 *************************************************************************/ 10629 10630 smDeviceHandle = oneDeviceData->smDevHandle; 10631 SM_DBG1(("ossaSATAEvent: did %d!!!\n", oneDeviceData->id)); 10632 10633 if (oneDeviceData->satDriveState == SAT_DEV_STATE_NORMAL) 10634 { 10635 SM_DBG1(("ossaSATAEvent: NCQ ERROR did %d!!!\n", oneDeviceData->id )); 10636 10637 /* Set flag to indicate we are in recovery */ 10638 oneDeviceData->satDriveState = SAT_DEV_STATE_IN_RECOVERY; 10639 10640 /* 10641 * Allocate resource for READ LOG EXIT page 10h 10642 */ 10643 satIntIo = smsatAllocIntIoResource( smRoot, 10644 &(smIORequestTMP), /* anything but NULL */ 10645 oneDeviceData, 10646 sizeof (satReadLogExtPage10h_t), 10647 satIntIo); 10648 10649 /* 10650 * If we cannot allocate resource to do the normal NCQ recovery, we 10651 * will do SATA device reset. 10652 */ 10653 if (satIntIo == agNULL) 10654 { 10655 /* Abort I/O after completion of device reset */ 10656 oneDeviceData->satAbortAfterReset = agTRUE; 10657 SM_DBG1(("ossaSATAEvent: can't send RLE due to resource lack!!!\n")); 10658 10659 #ifdef NOT_YET 10660 /* needs to investigate this case */ 10661 /* no report to OS layer */ 10662 smsatSubTM(smRoot, 10663 smDeviceHandle, 10664 TD_INTERNAL_TM_RESET, 10665 agNULL, 10666 agNULL, 10667 agNULL, 10668 agFALSE); 10669 #endif 10670 10671 return; 10672 } 10673 10674 10675 /* 10676 * Clear flag to indicate that the failed I/O has NOT been returned to the 10677 * OS-App specific Layer. 10678 */ 10679 satIntIo->satIntFlag = 0; 10680 10681 /* compare to satPrepareNewIO() */ 10682 /* Send READ LOG EXIT page 10h command */ 10683 10684 /* 10685 * Need to initialize all the fields within satIOContext except 10686 * reqType and satCompleteCB which will be set depending on cmd. 10687 */ 10688 10689 smIORequestBody = (smIORequestBody_t *)satIntIo->satIntRequestBody; 10690 satIOContext2 = &(smIORequestBody->transport.SATA.satIOContext); 10691 10692 satIOContext2->pSatDevData = oneDeviceData; 10693 satIOContext2->pFis = &(smIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev); 10694 satIOContext2->pScsiCmnd = &(satIntIo->satIntSmScsiXchg.scsiCmnd); 10695 satIOContext2->pSense = &(smIORequestBody->transport.SATA.sensePayload); 10696 satIOContext2->pSmSenseData = &(smIORequestBody->transport.SATA.smSenseData); 10697 satIOContext2->pSmSenseData->senseData = satIOContext2->pSense; 10698 10699 satIOContext2->smRequestBody = satIntIo->satIntRequestBody; 10700 //not used 10701 // satIOContext2->interruptContext = interruptContext; 10702 satIOContext2->satIntIoContext = satIntIo; 10703 10704 satIOContext2->psmDeviceHandle = smDeviceHandle; 10705 satIOContext2->satOrgIOContext = agNULL; 10706 satIOContext2->smScsiXchg = agNULL; 10707 10708 SM_DBG1(("ossaSATAEvent: smIORequestBody ID %d!!!\n", smIORequestBody->id)); 10709 SM_DBG1(("ossaSATAEvent: smIORequestBody ioCompleted %d ioStarted %d\n", smIORequestBody->ioCompleted, smIORequestBody->ioStarted)); 10710 status = smsatSendReadLogExt( smRoot, 10711 &satIntIo->satIntSmIORequest, 10712 smDeviceHandle, 10713 &satIntIo->satIntSmScsiXchg, 10714 satIOContext2); 10715 10716 if (status != SM_RC_SUCCESS) 10717 { 10718 SM_DBG1(("ossaSATAEvent: can't send RLE due to LL api failure!!!\n")); 10719 smsatFreeIntIoResource( smRoot, 10720 oneDeviceData, 10721 satIntIo); 10722 /* Abort I/O after completion of device reset */ 10723 oneDeviceData->satAbortAfterReset = agTRUE; 10724 #ifdef NOT_YET 10725 /* needs to investigate this case */ 10726 /* no report to OS layer */ 10727 smsatSubTM(smRoot, 10728 smDeviceHandle, 10729 TD_INTERNAL_TM_RESET, 10730 agNULL, 10731 agNULL, 10732 agNULL, 10733 agFALSE); 10734 #endif 10735 10736 return; 10737 } 10738 } 10739 else 10740 { 10741 SM_DBG1(("ossaSATAEvent: NCQ ERROR but recovery in progress!!!\n")); 10742 } 10743 } 10744 else if (event == OSSA_IO_XFER_CMD_FRAME_ISSUED) 10745 { 10746 SM_DBG1(("ossaSATAEvent: OSSA_IO_XFER_CMD_FRAME_ISSUED\n")); 10747 } 10748 else if (event == OSSA_IO_XFER_PIO_SETUP_ERROR) 10749 { 10750 SM_DBG1(("ossaSATAEvent: OSSA_IO_XFER_PIO_SETUP_ERROR\n")); 10751 } 10752 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED) 10753 { 10754 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED\n")); 10755 } 10756 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO) 10757 { 10758 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO\n")); 10759 } 10760 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST) 10761 { 10762 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST\n")); 10763 } 10764 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE) 10765 { 10766 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE\n")); 10767 } 10768 else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED) 10769 { 10770 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED\n")); 10771 } 10772 else if (event == OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH) 10773 { 10774 SM_DBG1(("ossaSATAEvent: OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH\n")); 10775 } 10776 #ifdef REMOVED 10777 else if (event == OSSA_IO_XFR_ERROR_DIF_MISMATCH || event == OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH || 10778 event == OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH || event == OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH ) 10779 { 10780 SM_DBG1(("ossaSATAEvent: DIF related, event 0x%x\n", event)); 10781 /* process DIF detail information */ 10782 SM_DBG2(("ossaSATAEvent: agIOInfoLen %d\n", agIOInfoLen)); 10783 if (agParam == agNULL) 10784 { 10785 SM_DBG2(("ossaSATAEvent: agParam is NULL!!!\n")); 10786 return; 10787 } 10788 if (agIOInfoLen < sizeof(agsaDifDetails_t)) 10789 { 10790 SM_DBG2(("ossaSATAEvent: wrong agIOInfoLen!!! agIOInfoLen %d sizeof(agsaDifDetails_t) %d\n", agIOInfoLen, (int)sizeof(agsaDifDetails_t))); 10791 return; 10792 } 10793 /* reads agsaDifDetails_t */ 10794 saFrameReadBlock(agRoot, agParam, 0, &agDifDetails, sizeof(agsaDifDetails_t)); 10795 frameOffset = (agDifDetails.ErrBoffsetEDataLen & 0xFFFF); 10796 frameLen = (agDifDetails.ErrBoffsetEDataLen & 0xFFFF0000) >> 16; 10797 10798 SM_DBG2(("ossaSATAEvent: UpperLBA 0x%08x LowerLBA 0x%08x\n", agDifDetails.UpperLBA, agDifDetails.LowerLBA)); 10799 SM_DBG2(("ossaSATAEvent: SASAddrHI 0x%08x SASAddrLO 0x%08x\n", 10800 SM_GET_SAS_ADDRESSHI(agDifDetails.sasAddressHi), SM_GET_SAS_ADDRESSLO(agDifDetails.sasAddressLo))); 10801 SM_DBG2(("ossaSATAEvent: DIF error mask 0x%x Device ID 0x%x\n", 10802 (agDifDetails.DIFErrDevID) & 0xFF, (agDifDetails.DIFErrDevID & 0xFFFF0000) >> 16)); 10803 if (frameLen != 0 && frameLen <= 256) 10804 { 10805 saFrameReadBlock(agRoot, agParam, sizeof(agsaDifDetails_t), framePayload, frameLen); 10806 smhexdump("ossaSATAEvent frame", framePayload, frameLen); 10807 } 10808 } 10809 #endif 10810 else if (event == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY) 10811 { 10812 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 10813 if (smIORequestBody == agNULL) 10814 { 10815 SM_DBG1(("ossaSATAEvent: smIORequestBody is NULL!!!\n")); 10816 return; 10817 } 10818 smDeviceHandle = smIORequestBody->smDevHandle; 10819 if (smDeviceHandle == agNULL) 10820 { 10821 SM_DBG1(("ossaSATAEvent: smDeviceHandle is NULL!!!\n")); 10822 return; 10823 } 10824 oneDeviceData = (smDeviceData_t *)smDeviceHandle->smData; 10825 if (oneDeviceData == agNULL) 10826 { 10827 SM_DBG1(("ossaSATAEvent: oneDeviceData is NULL!!!\n")); 10828 return; 10829 } 10830 SM_DBG1(("ossaSATAEvent: ERROR event %d did=%d\n", event, oneDeviceData->id)); 10831 10832 10833 if (smAllShared->FCA) 10834 { 10835 if (oneDeviceData->SMNumOfFCA <= 0) /* does SMP HARD RESET only upto one time */ 10836 { 10837 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n")); 10838 oneDeviceData->SMNumOfFCA++; 10839 smPhyControlSend(smRoot, 10840 oneDeviceData, 10841 SMP_PHY_CONTROL_HARD_RESET, 10842 agNULL, 10843 tdsmRotateQnumber(smRoot, smDeviceHandle) 10844 ); 10845 } 10846 else 10847 { 10848 /* given up after one time of SMP HARD RESET; */ 10849 SM_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; but giving up sending HARD_RESET!!!\n")); 10850 } 10851 } 10852 } 10853 else if (event == OSSA_IO_XFER_ERROR_NAK_RECEIVED) 10854 { 10855 SM_DBG1(("ossaSATAEvent: OSSA_IO_XFER_ERROR_NAK_RECEIVED\n")); 10856 } 10857 else if (event == OSSA_IO_XFER_ERROR_DMA_ACTIVATE_TIMEOUT) 10858 { 10859 SM_DBG1(("ossaSATAEvent: OSSA_IO_XFER_ERROR_DMA_ACTIVATE_TIMEOUT\n")); 10860 } 10861 else 10862 { 10863 SM_DBG1(("ossaSATAEvent: other event 0x%x\n", event)); 10864 } 10865 10866 return; 10867 } 10868 10869 osGLOBAL void 10870 smSMPCompletedCB( 10871 agsaRoot_t *agRoot, 10872 agsaIORequest_t *agIORequest, 10873 bit32 agIOStatus, 10874 bit32 agIOInfoLen, 10875 agsaFrameHandle_t agFrameHandle 10876 ) 10877 { 10878 smSMPRequestBody_t *smSMPRequestBody = (smSMPRequestBody_t *) agIORequest->osData; 10879 10880 SM_DBG2(("smSMPCompletedCB: start\n")); 10881 10882 if (smSMPRequestBody == agNULL) 10883 { 10884 SM_DBG1(("smSMPCompletedCB: smSMPRequestBody is NULL!!!\n")); 10885 return; 10886 } 10887 10888 if (smSMPRequestBody->SMPCompletionFunc == agNULL) 10889 { 10890 SM_DBG1(("smSMPCompletedCB: smSMPRequestBody->SMPCompletionFunc is NULL!!!\n")); 10891 return; 10892 } 10893 10894 /* calling smSMPCompleted */ 10895 smSMPRequestBody->SMPCompletionFunc( 10896 agRoot, 10897 agIORequest, 10898 agIOStatus, 10899 agIOInfoLen, 10900 agFrameHandle 10901 ); 10902 return; 10903 } 10904 10905 osGLOBAL void 10906 smSMPCompleted( 10907 agsaRoot_t *agRoot, 10908 agsaIORequest_t *agIORequest, 10909 bit32 agIOStatus, 10910 bit32 agIOInfoLen, 10911 agsaFrameHandle_t agFrameHandle 10912 ) 10913 { 10914 smRoot_t *smRoot = gsmRoot; 10915 smSMPRequestBody_t *smSMPRequestBody = (smSMPRequestBody_t *) agIORequest->osData; 10916 smDeviceData_t *oneDeviceData; 10917 smDeviceHandle_t *smDeviceHandle; 10918 smIORequest_t *CurrentTaskTag; 10919 bit8 smpHeader[4]; 10920 smSMPFrameHeader_t *smSMPFrameHeader; 10921 agsaDevHandle_t *agDevHandle = agNULL; 10922 10923 SM_DBG2(("smSMPCompleted: start\n")); 10924 10925 if (smSMPRequestBody == agNULL) 10926 { 10927 SM_DBG1(("smSMPCompleted: smSMPRequestBody is NULL, wrong!!!\n")); 10928 return; 10929 } 10930 10931 CurrentTaskTag = smSMPRequestBody->CurrentTaskTag; 10932 oneDeviceData = smSMPRequestBody->smDeviceData; 10933 smDeviceHandle = smSMPRequestBody->smDevHandle; 10934 if (smDeviceHandle == agNULL) 10935 { 10936 SM_DBG2(("smSMPCompleted: smDeviceHandle is NULL, wrong!!!\n")); 10937 return; 10938 } 10939 10940 if (oneDeviceData == agNULL) 10941 { 10942 SM_DBG2(("smSMPCompleted: oneDeviceData is NULL, wrong!!!\n")); 10943 return; 10944 } 10945 agDevHandle = oneDeviceData->agExpDevHandle; 10946 if (agIOStatus == OSSA_IO_SUCCESS) 10947 { 10948 saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4); 10949 smSMPFrameHeader = (smSMPFrameHeader_t *)smpHeader; 10950 if (smSMPFrameHeader->smpFunction == SMP_PHY_CONTROL) 10951 { 10952 SM_DBG3(("smSMPCompleted: phy control\n")); 10953 if (agIOInfoLen != 4 && 10954 smSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED) /*zero length is expected */ 10955 { 10956 SM_DBG1(("smSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x!!!\n", agIOInfoLen, 4)); 10957 tdsmFreeMemory( 10958 smRoot, 10959 smSMPRequestBody->osMemHandle, 10960 sizeof(smSMPRequestBody_t) 10961 ); 10962 if (CurrentTaskTag != agNULL) 10963 { 10964 tdsmEventCB(smRoot, 10965 smDeviceHandle, 10966 smIntrEventTypeTaskManagement, 10967 smTMFailed, 10968 CurrentTaskTag); 10969 } 10970 10971 return; 10972 } 10973 smPhyControlRespRcvd(smRoot, 10974 agRoot, 10975 agIORequest, 10976 oneDeviceData, 10977 smSMPFrameHeader, 10978 agFrameHandle, 10979 CurrentTaskTag 10980 ); 10981 } 10982 else 10983 { 10984 /* unknown SMP function */ 10985 SM_DBG2(("smSMPCompleted: unknown smSMPFrameHeader %d!!!\n", smSMPFrameHeader->smpFunction)); 10986 tdsmFreeMemory( 10987 smRoot, 10988 smSMPRequestBody->osMemHandle, 10989 sizeof(smSMPRequestBody_t) 10990 ); 10991 if (CurrentTaskTag != agNULL) 10992 { 10993 tdsmEventCB(smRoot, 10994 smDeviceHandle, 10995 smIntrEventTypeTaskManagement, 10996 smTMFailed, 10997 CurrentTaskTag); 10998 } 10999 return; 11000 } 11001 } 11002 else 11003 { 11004 SM_DBG2(("smSMPCompleted: failed agIOStatus %d!!!\n", agIOStatus)); 11005 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 11006 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED || 11007 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO || 11008 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST || 11009 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE || 11010 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED || 11011 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL 11012 ) 11013 { 11014 SM_DBG1(("smSMPCompleted: setting back to operational\n")); 11015 if (agDevHandle != agNULL) 11016 { 11017 saSetDeviceState(agRoot, agNULL, tdsmRotateQnumber(smRoot, smDeviceHandle), agDevHandle, SA_DS_OPERATIONAL); 11018 } 11019 else 11020 { 11021 SM_DBG1(("smSMPCompleted: agDevHandle is NULL\n")); 11022 } 11023 } 11024 tdsmFreeMemory( 11025 smRoot, 11026 smSMPRequestBody->osMemHandle, 11027 sizeof(smSMPRequestBody_t) 11028 ); 11029 if (CurrentTaskTag != agNULL) 11030 { 11031 tdsmEventCB(smRoot, 11032 smDeviceHandle, 11033 smIntrEventTypeTaskManagement, 11034 smTMFailed, 11035 CurrentTaskTag); 11036 } 11037 return; 11038 } 11039 11040 tdsmFreeMemory( 11041 smRoot, 11042 smSMPRequestBody->osMemHandle, 11043 sizeof(smSMPRequestBody_t) 11044 ); 11045 return; 11046 } 11047 11048 osGLOBAL void 11049 smPhyControlRespRcvd( 11050 smRoot_t *smRoot, 11051 agsaRoot_t *agRoot, 11052 agsaIORequest_t *agIORequest, 11053 smDeviceData_t *oneDeviceData, /* sata disk */ 11054 smSMPFrameHeader_t *frameHeader, 11055 agsaFrameHandle_t frameHandle, 11056 smIORequest_t *CurrentTaskTag 11057 ) 11058 { 11059 smDeviceData_t *TargetDeviceData = agNULL; 11060 agsaDevHandle_t *agDevHandle = agNULL; 11061 smSMPRequestBody_t *smSMPRequestBody; 11062 smDeviceHandle_t *smDeviceHandle; 11063 11064 SM_DBG2(("smPhyControlRespRcvd: start\n")); 11065 11066 if (CurrentTaskTag == agNULL ) 11067 { 11068 SM_DBG1(("smPhyControlRespRcvd: CurrentTaskTag is NULL; allowed\n")); 11069 return; 11070 } 11071 11072 smSMPRequestBody = (smSMPRequestBody_t *)CurrentTaskTag->smData; 11073 if (smSMPRequestBody == agNULL) 11074 { 11075 SM_DBG1(("smPhyControlRespRcvd: smSMPRequestBody is NULL!!!\n")); 11076 return; 11077 } 11078 11079 smDeviceHandle = smSMPRequestBody->smDevHandle; 11080 if (smDeviceHandle == agNULL) 11081 { 11082 SM_DBG2(("smPhyControlRespRcvd: smDeviceHandle is NULL!!!\n")); 11083 return; 11084 } 11085 11086 TargetDeviceData = smSMPRequestBody->smDeviceData; 11087 if (oneDeviceData != TargetDeviceData) 11088 { 11089 SM_DBG1(("smPhyControlRespRcvd: oneDeviceData != TargetDeviceData!!!\n")); 11090 return; 11091 } 11092 11093 agDevHandle = TargetDeviceData->agDevHandle; 11094 11095 11096 if (frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED) 11097 { 11098 SM_DBG2(("smPhyControlRespRcvd: SMP success\n")); 11099 SM_DBG1(("smPhyControlRespRcvd: callback to TD layer with success\n")); 11100 TargetDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 11101 saSetDeviceState(agRoot, agNULL, tdsmRotateQnumber(smRoot, smDeviceHandle), agDevHandle, SA_DS_OPERATIONAL); 11102 11103 tdsmEventCB(smRoot, 11104 smDeviceHandle, 11105 smIntrEventTypeTaskManagement, 11106 smTMOK, 11107 CurrentTaskTag); 11108 } 11109 else 11110 { 11111 SM_DBG1(("smPhyControlRespRcvd: SMP failure; result %d!!!\n", frameHeader->smpFunctionResult)); 11112 tdsmEventCB(smRoot, 11113 smDeviceHandle, 11114 smIntrEventTypeTaskManagement, 11115 smTMFailed, 11116 CurrentTaskTag); 11117 } 11118 return; 11119 } 11120 11121 osGLOBAL void 11122 smsatCheckPowerModeCB( 11123 agsaRoot_t *agRoot, 11124 agsaIORequest_t *agIORequest, 11125 bit32 agIOStatus, 11126 agsaFisHeader_t *agFirstDword, 11127 bit32 agIOInfoLen, 11128 agsaFrameHandle_t agFrameHandle, 11129 void *ioContext 11130 ) 11131 { 11132 /* callback for satDeResetDevice */ 11133 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11134 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11135 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 11136 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 11137 smRoot_t *smRoot = agNULL; 11138 smIntRoot_t *smIntRoot = agNULL; 11139 smIntContext_t *smAllShared = agNULL; 11140 smIORequestBody_t *smIORequestBody; 11141 smSatIOContext_t *satIOContext; 11142 smSatIOContext_t *satOrgIOContext; 11143 smSatInternalIo_t *satIntIo; 11144 // satDeviceData_t *satDevData; 11145 smDeviceData_t *oneDeviceData; 11146 #ifdef TD_DEBUG_ENABLE 11147 bit32 ataStatus = 0; 11148 bit32 ataError; 11149 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 11150 #endif 11151 bit32 AbortTM = agFALSE; 11152 smDeviceHandle_t *smDeviceHandle; 11153 11154 SM_DBG1(("smsatCheckPowerModeCB: start\n")); 11155 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 11156 satIOContext = (smSatIOContext_t *) ioContext; 11157 satIntIo = satIOContext->satIntIoContext; 11158 oneDeviceData = satIOContext->pSatDevData; 11159 smRoot = oneDeviceData->smRoot; 11160 smIntRoot = (smIntRoot_t *)smRoot->smData; 11161 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 11162 smDeviceHandle = oneDeviceData->smDevHandle; 11163 if (satIntIo == agNULL) 11164 { 11165 SM_DBG6(("smsatCheckPowerModeCB: External, OS generated\n")); 11166 satOrgIOContext = satIOContext; 11167 } 11168 else 11169 { 11170 SM_DBG6(("smsatCheckPowerModeCB: Internal, TD generated\n")); 11171 satOrgIOContext = satIOContext->satOrgIOContext; 11172 if (satOrgIOContext == agNULL) 11173 { 11174 SM_DBG6(("smsatCheckPowerModeCB: satOrgIOContext is NULL, wrong\n")); 11175 return; 11176 } 11177 else 11178 { 11179 SM_DBG6(("smsatCheckPowerModeCB: satOrgIOContext is NOT NULL\n")); 11180 } 11181 } 11182 smIORequestBody->ioCompleted = agTRUE; 11183 smIORequestBody->ioStarted = agFALSE; 11184 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 11185 { 11186 SM_DBG1(("smsatCheckPowerModeCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 11187 /* TM completed */ 11188 tdsmEventCB( smRoot, 11189 smDeviceHandle, 11190 smIntrEventTypeTaskManagement, 11191 smTMFailed, 11192 oneDeviceData->satTmTaskTag); 11193 11194 oneDeviceData->satTmTaskTag = agNULL; 11195 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11196 11197 smsatFreeIntIoResource( smRoot, 11198 oneDeviceData, 11199 satIntIo); 11200 return; 11201 } 11202 11203 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 11204 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 11205 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 11206 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 11207 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 11208 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 11209 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 11210 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 11211 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 11212 ) 11213 { 11214 SM_DBG1(("smsatCheckPowerModeCB: OSSA_IO_OPEN_CNX_ERROR!!!\n")); 11215 /* TM completed */ 11216 tdsmEventCB( smRoot, 11217 smDeviceHandle, 11218 smIntrEventTypeTaskManagement, 11219 smTMFailed, 11220 oneDeviceData->satTmTaskTag); 11221 oneDeviceData->satTmTaskTag = agNULL; 11222 11223 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11224 smsatFreeIntIoResource( smRoot, 11225 oneDeviceData, 11226 satIntIo); 11227 return; 11228 } 11229 if (agIOStatus != OSSA_IO_SUCCESS) 11230 { 11231 /* only agsaFisPioSetup_t is expected */ 11232 #ifdef TD_DEBUG_ENABLE 11233 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 11234 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 11235 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 11236 #endif 11237 SM_DBG1(("smsatCheckPowerModeCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 11238 /* TM completed */ 11239 tdsmEventCB( smRoot, 11240 smDeviceHandle, 11241 smIntrEventTypeTaskManagement, 11242 smTMFailed, 11243 oneDeviceData->satTmTaskTag); 11244 oneDeviceData->satTmTaskTag = agNULL; 11245 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11246 smsatFreeIntIoResource( smRoot, 11247 oneDeviceData, 11248 satIntIo); 11249 return; 11250 } 11251 /* success */ 11252 SM_DBG1(("smsatCheckPowerModeCB: success!!!\n")); 11253 SM_DBG1(("smsatCheckPowerModeCB: TMF %d!!!\n", satOrgIOContext->TMF)); 11254 11255 if (satOrgIOContext->TMF == AG_ABORT_TASK) 11256 { 11257 AbortTM = agTRUE; 11258 } 11259 if (AbortTM == agTRUE) 11260 { 11261 SM_DBG1(("smsatCheckPowerModeCB: calling local satAbort!!!\n")); 11262 smsatAbort(smRoot, agRoot, satOrgIOContext->satToBeAbortedIOContext); 11263 } 11264 oneDeviceData->satTmTaskTag = agNULL; 11265 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 11266 11267 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11268 11269 SM_DBG1(("smsatCheckPowerModeCB: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 11270 SM_DBG1(("smsatCheckPowerModeCB: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 11271 smsatFreeIntIoResource( smRoot, 11272 oneDeviceData, 11273 satIntIo); 11274 11275 /* TM completed */ 11276 tdsmEventCB( smRoot, 11277 smDeviceHandle, 11278 smIntrEventTypeTaskManagement, 11279 smTMOK, 11280 oneDeviceData->satTmTaskTag); 11281 SM_DBG5(("smsatCheckPowerModeCB: device %p pending IO %d\n", oneDeviceData, oneDeviceData->satPendingIO)); 11282 SM_DBG2(("smsatCheckPowerModeCB: end\n")); 11283 return; 11284 } 11285 11286 osGLOBAL void 11287 smsatCheckPowerModePassCB( 11288 agsaRoot_t *agRoot, 11289 agsaIORequest_t *agIORequest, 11290 bit32 agIOStatus, 11291 agsaFisHeader_t *agFirstDword, 11292 bit32 agIOInfoLen, 11293 agsaFrameHandle_t agFrameHandle, 11294 void *ioContext 11295 ) 11296 11297 { 11298 11299 smRoot_t *smRoot = agNULL; 11300 smIntRoot_t *smIntRoot = agNULL; 11301 smIntContext_t *smAllShared = agNULL; 11302 smIORequestBody_t *smIORequestBody; 11303 smSatIOContext_t *satIOContext; 11304 smSatIOContext_t *satOrgIOContext; 11305 smSatInternalIo_t *satIntIo; 11306 smIORequest_t *smOrgIORequest; 11307 smIORequestBody_t *smOrgIORequestBody; 11308 // satDeviceData_t *satDevData; 11309 smDeviceData_t *oneDeviceData; 11310 #ifdef TD_DEBUG_ENABLE 11311 bit32 ataStatus = 0; 11312 bit32 ataError; 11313 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 11314 #endif 11315 11316 smScsiRspSense_t *pSense; 11317 bit8 bSenseKey = 0; 11318 bit16 bSenseCodeInfo = 0; 11319 11320 SM_DBG1(("smsatCheckPowerModePassCB: start\n")); 11321 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 11322 satIOContext = (smSatIOContext_t *) ioContext; 11323 satIntIo = satIOContext->satIntIoContext; 11324 oneDeviceData = satIOContext->pSatDevData; 11325 smRoot = oneDeviceData->smRoot; 11326 smIntRoot = (smIntRoot_t *)smRoot->smData; 11327 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 11328 11329 if (satIntIo == agNULL) 11330 { 11331 SM_DBG6(("smsatCheckPowerModePassCB: External, OS generated\n")); 11332 satOrgIOContext = satIOContext; 11333 smOrgIORequest = smIORequestBody->smIORequest; 11334 pSense = satOrgIOContext->pSense; 11335 } 11336 else 11337 { 11338 SM_DBG6(("smsatCheckPowerModePassCB: Internal, TD generated\n")); 11339 satOrgIOContext = satIOContext->satOrgIOContext; 11340 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 11341 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 11342 pSense = satOrgIOContext->pSense; 11343 if (satOrgIOContext == agNULL) 11344 { 11345 SM_DBG6(("smsatCheckPowerModePassCB: satOrgIOContext is NULL, wrong\n")); 11346 return; 11347 } 11348 else 11349 { 11350 SM_DBG6(("smsatCheckPowerModePassCB: satOrgIOContext is NOT NULL\n")); 11351 } 11352 } 11353 smIORequestBody->ioCompleted = agTRUE; 11354 smIORequestBody->ioStarted = agFALSE; 11355 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 11356 { 11357 SM_DBG1(("smsatCheckPowerModePassCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 11358 11359 tdsmIOCompletedCB( 11360 smRoot, 11361 smOrgIORequest, 11362 smIOFailed, 11363 smDetailOtherError, 11364 agNULL, 11365 satOrgIOContext->interruptContext 11366 ); 11367 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11368 11369 smsatFreeIntIoResource( smRoot, 11370 oneDeviceData, 11371 satIntIo); 11372 return; 11373 11374 } 11375 11376 if (agIOStatus != OSSA_IO_SUCCESS) 11377 { 11378 /* only agsaFisPioSetup_t is expected */ 11379 #ifdef TD_DEBUG_ENABLE 11380 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 11381 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 11382 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 11383 #endif 11384 SM_DBG1(("smsatCheckPowerModePassCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 11385 11386 11387 if (agIOStatus == OSSA_IO_ABORTED) 11388 { 11389 smsatProcessAbort(smRoot, 11390 smOrgIORequest, 11391 satOrgIOContext 11392 ); 11393 11394 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11395 11396 smsatFreeIntIoResource( smRoot, 11397 oneDeviceData, 11398 satIntIo); 11399 return; 11400 } 11401 smsatTranslateATAErrorsToSCSIErrors( 11402 agFirstDword->D2H.status, 11403 agFirstDword->D2H.error, 11404 &bSenseKey, 11405 &bSenseCodeInfo 11406 ); 11407 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 11408 tdsmIOCompletedCB(smRoot, 11409 smOrgIORequest, 11410 smIOSuccess, 11411 SCSI_STAT_CHECK_CONDITION, 11412 satOrgIOContext->pSmSenseData, 11413 satOrgIOContext->interruptContext ); 11414 11415 11416 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11417 11418 smsatFreeIntIoResource( smRoot, 11419 oneDeviceData, 11420 satIntIo); 11421 return; 11422 11423 } 11424 /* success */ 11425 SM_DBG1(("smsatCheckPowerModePassCB: success!!!\n")); 11426 11427 tdsmIOCompletedCB( smRoot, 11428 smOrgIORequest, 11429 smIOSuccess, 11430 SCSI_STAT_GOOD, 11431 agNULL, 11432 satOrgIOContext->interruptContext); 11433 11434 11435 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11436 11437 smsatFreeIntIoResource( smRoot, 11438 oneDeviceData, 11439 satIntIo); 11440 11441 11442 return; 11443 } 11444 11445 osGLOBAL void 11446 smsatIDDataPassCB( 11447 agsaRoot_t *agRoot, 11448 agsaIORequest_t *agIORequest, 11449 bit32 agIOStatus, 11450 agsaFisHeader_t *agFirstDword, 11451 bit32 agIOInfoLen, 11452 agsaFrameHandle_t agFrameHandle, 11453 void *ioContext 11454 ) 11455 { 11456 smRoot_t *smRoot = agNULL; 11457 smIntRoot_t *smIntRoot = agNULL; 11458 smIntContext_t *smAllShared = agNULL; 11459 smIORequestBody_t *smIORequestBody; 11460 smSatIOContext_t *satIOContext; 11461 smSatIOContext_t *satOrgIOContext; 11462 smSatInternalIo_t *satIntIo; 11463 smIORequest_t *smOrgIORequest; 11464 smIORequestBody_t *smOrgIORequestBody; 11465 // satDeviceData_t *satDevData; 11466 smDeviceData_t *oneDeviceData; 11467 #ifdef TD_DEBUG_ENABLE 11468 bit32 ataStatus = 0; 11469 bit32 ataError; 11470 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 11471 #endif 11472 11473 smScsiRspSense_t *pSense; 11474 bit8 bSenseKey = 0; 11475 bit16 bSenseCodeInfo = 0; 11476 11477 SM_DBG3(("smsatIDDataPassCB: start\n")); 11478 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 11479 satIOContext = (smSatIOContext_t *) ioContext; 11480 satIntIo = satIOContext->satIntIoContext; 11481 oneDeviceData = satIOContext->pSatDevData; 11482 smRoot = oneDeviceData->smRoot; 11483 smIntRoot = (smIntRoot_t *)smRoot->smData; 11484 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 11485 11486 if (satIntIo == agNULL) 11487 { 11488 SM_DBG6(("smsatIDDataPassCB: External, OS generated\n")); 11489 satOrgIOContext = satIOContext; 11490 smOrgIORequest = smIORequestBody->smIORequest; 11491 pSense = satOrgIOContext->pSense; 11492 } 11493 else 11494 { 11495 SM_DBG6(("smsatIDDataPassCB: Internal, TD generated\n")); 11496 satOrgIOContext = satIOContext->satOrgIOContext; 11497 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 11498 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 11499 pSense = satOrgIOContext->pSense; 11500 if (satOrgIOContext == agNULL) 11501 { 11502 SM_DBG6(("smsatIDDataPassCB: satOrgIOContext is NULL, wrong\n")); 11503 return; 11504 } 11505 else 11506 { 11507 SM_DBG6(("smsatIDDataPassCB: satOrgIOContext is NOT NULL\n")); 11508 } 11509 } 11510 smIORequestBody->ioCompleted = agTRUE; 11511 smIORequestBody->ioStarted = agFALSE; 11512 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 11513 { 11514 SM_DBG1(("smsatIDDataPassCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 11515 11516 tdsmIOCompletedCB( 11517 smRoot, 11518 smOrgIORequest, 11519 smIOFailed, 11520 smDetailOtherError, 11521 agNULL, 11522 satOrgIOContext->interruptContext 11523 ); 11524 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11525 11526 smsatFreeIntIoResource( smRoot, 11527 oneDeviceData, 11528 satIntIo); 11529 return; 11530 11531 } 11532 11533 if (agIOStatus != OSSA_IO_SUCCESS) 11534 { 11535 /* only agsaFisPioSetup_t is expected */ 11536 #ifdef TD_DEBUG_ENABLE 11537 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 11538 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 11539 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 11540 #endif 11541 SM_DBG1(("smsatIDDataPassCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 11542 11543 11544 if (agIOStatus == OSSA_IO_ABORTED) 11545 { 11546 smsatProcessAbort(smRoot, 11547 smOrgIORequest, 11548 satOrgIOContext 11549 ); 11550 11551 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11552 11553 smsatFreeIntIoResource( smRoot, 11554 oneDeviceData, 11555 satIntIo); 11556 return; 11557 } 11558 smsatTranslateATAErrorsToSCSIErrors( 11559 agFirstDword->D2H.status, 11560 agFirstDword->D2H.error, 11561 &bSenseKey, 11562 &bSenseCodeInfo 11563 ); 11564 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 11565 tdsmIOCompletedCB(smRoot, 11566 smOrgIORequest, 11567 smIOSuccess, 11568 SCSI_STAT_CHECK_CONDITION, 11569 satOrgIOContext->pSmSenseData, 11570 satOrgIOContext->interruptContext ); 11571 11572 11573 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11574 11575 smsatFreeIntIoResource( smRoot, 11576 oneDeviceData, 11577 satIntIo); 11578 return; 11579 11580 } 11581 /* success */ 11582 SM_DBG3(("smsatIDDataPassCB: success!!!\n")); 11583 11584 SM_DBG3(("smsatIDDataPassCB: extend 0x%x ck_cond 0x%x sectorCnt07 0x%x\n", satOrgIOContext->extend, 11585 satIOContext->ck_cond, satOrgIOContext->sectorCnt07)); 11586 SM_DBG3(("smsatIDDataPassCB: LBAHigh07 0x%x LBAMid07 0x%x LBALow07 0x%x\n", satOrgIOContext->LBAHigh07, 11587 satOrgIOContext->LBAMid07, satOrgIOContext->LBALow07)); 11588 11589 if (satIOContext->ck_cond) 11590 { 11591 smsatSetSensePayload( pSense, 11592 SCSI_SNSKEY_RECOVERED_ERROR, 11593 satOrgIOContext->sectorCnt07, 11594 SCSI_SNSCODE_ATA_PASS_THROUGH_INFORMATION_AVAILABLE, 11595 satIOContext); 11596 11597 tdsmIOCompletedCB( smRoot, 11598 smOrgIORequest, 11599 smIOSuccess, 11600 SCSI_STAT_CHECK_CONDITION, 11601 satIOContext->pSmSenseData, 11602 satOrgIOContext->interruptContext ); 11603 } 11604 else 11605 { 11606 tdsmIOCompletedCB( smRoot, 11607 smOrgIORequest, 11608 smIOSuccess, 11609 SCSI_STAT_GOOD, 11610 agNULL, 11611 satOrgIOContext->interruptContext); 11612 } 11613 11614 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11615 11616 smsatFreeIntIoResource( smRoot, 11617 oneDeviceData, 11618 satIntIo); 11619 11620 11621 return; 11622 } 11623 11624 osGLOBAL void 11625 smsatResetDeviceCB( 11626 agsaRoot_t *agRoot, 11627 agsaIORequest_t *agIORequest, 11628 bit32 agIOStatus, 11629 agsaFisHeader_t *agFirstDword, 11630 bit32 agIOInfoLen, 11631 agsaFrameHandle_t agFrameHandle, 11632 void *ioContext 11633 ) 11634 { 11635 /* callback for satResetDevice */ 11636 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11637 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11638 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 11639 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 11640 smRoot_t *smRoot = agNULL; 11641 smIntRoot_t *smIntRoot = agNULL; 11642 smIntContext_t *smAllShared = agNULL; 11643 smIORequestBody_t *smIORequestBody; 11644 smIORequestBody_t *smOrgIORequestBody; 11645 smSatIOContext_t *satIOContext; 11646 smSatIOContext_t *satOrgIOContext; 11647 smSatIOContext_t *satNewIOContext; 11648 smSatInternalIo_t *satIntIo; 11649 smSatInternalIo_t *satNewIntIo = agNULL; 11650 // satDeviceData_t *satDevData; 11651 smDeviceData_t *oneDeviceData; 11652 smIORequest_t *smOrgIORequest; 11653 #ifdef TD_DEBUG_ENABLE 11654 bit32 ataStatus = 0; 11655 bit32 ataError; 11656 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 11657 #endif 11658 bit32 status; 11659 smDeviceHandle_t *smDeviceHandle; 11660 11661 SM_DBG1(("smsatResetDeviceCB: start\n")); 11662 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 11663 satIOContext = (smSatIOContext_t *) ioContext; 11664 satIntIo = satIOContext->satIntIoContext; 11665 oneDeviceData = satIOContext->pSatDevData; 11666 smRoot = oneDeviceData->smRoot; 11667 smIntRoot = (smIntRoot_t *)smRoot->smData; 11668 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 11669 smDeviceHandle = oneDeviceData->smDevHandle; 11670 11671 if (satIntIo == agNULL) 11672 { 11673 SM_DBG6(("smsatResetDeviceCB: External, OS generated\n")); 11674 satOrgIOContext = satIOContext; 11675 smOrgIORequest = smIORequestBody->smIORequest; 11676 } 11677 else 11678 { 11679 SM_DBG6(("smsatResetDeviceCB: Internal, TD generated\n")); 11680 satOrgIOContext = satIOContext->satOrgIOContext; 11681 if (satOrgIOContext == agNULL) 11682 { 11683 SM_DBG6(("smsatResetDeviceCB: satOrgIOContext is NULL, wrong\n")); 11684 return; 11685 } 11686 else 11687 { 11688 SM_DBG6(("smsatResetDeviceCB: satOrgIOContext is NOT NULL\n")); 11689 } 11690 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 11691 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 11692 } 11693 smIORequestBody->ioCompleted = agTRUE; 11694 smIORequestBody->ioStarted = agFALSE; 11695 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 11696 { 11697 SM_DBG1(("smsatResetDeviceCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 11698 /* TM completed */ 11699 tdsmEventCB( smRoot, 11700 smDeviceHandle, 11701 smIntrEventTypeTaskManagement, 11702 smTMFailed, 11703 oneDeviceData->satTmTaskTag); 11704 oneDeviceData->satTmTaskTag = agNULL; 11705 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11706 smsatFreeIntIoResource( smRoot, 11707 oneDeviceData, 11708 satIntIo); 11709 return; 11710 } 11711 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 11712 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 11713 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 11714 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 11715 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 11716 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 11717 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 11718 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 11719 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 11720 ) 11721 { 11722 SM_DBG1(("smsatResetDeviceCB: OSSA_IO_OPEN_CNX_ERROR!!!\n")); 11723 /* TM completed */ 11724 tdsmEventCB( smRoot, 11725 smDeviceHandle, 11726 smIntrEventTypeTaskManagement, 11727 smTMFailed, 11728 oneDeviceData->satTmTaskTag); 11729 11730 oneDeviceData->satTmTaskTag = agNULL; 11731 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11732 smsatFreeIntIoResource( smRoot, 11733 oneDeviceData, 11734 satIntIo); 11735 return; 11736 } 11737 if (agIOStatus != OSSA_IO_SUCCESS) 11738 { 11739 /* only agsaFisPioSetup_t is expected */ 11740 #ifdef TD_DEBUG_ENABLE 11741 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 11742 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 11743 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 11744 #endif 11745 SM_DBG1(("smsatResetDeviceCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 11746 /* TM completed */ 11747 tdsmEventCB( smRoot, 11748 smDeviceHandle, 11749 smIntrEventTypeTaskManagement, 11750 smTMFailed, 11751 oneDeviceData->satTmTaskTag); 11752 11753 oneDeviceData->satTmTaskTag = agNULL; 11754 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11755 smsatFreeIntIoResource( smRoot, 11756 oneDeviceData, 11757 satIntIo); 11758 return; 11759 } 11760 11761 /* success */ 11762 satNewIntIo = smsatAllocIntIoResource( smRoot, 11763 smOrgIORequest, 11764 oneDeviceData, 11765 0, 11766 satNewIntIo); 11767 if (satNewIntIo == agNULL) 11768 { 11769 oneDeviceData->satTmTaskTag = agNULL; 11770 11771 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11772 /* memory allocation failure */ 11773 smsatFreeIntIoResource( smRoot, 11774 oneDeviceData, 11775 satIntIo); 11776 /* TM completed */ 11777 tdsmEventCB( smRoot, 11778 smDeviceHandle, 11779 smIntrEventTypeTaskManagement, 11780 smTMFailed, 11781 oneDeviceData->satTmTaskTag); 11782 SM_DBG1(("smsatResetDeviceCB: momory allocation fails!!!\n")); 11783 return; 11784 } /* end of memory allocation failure */ 11785 /* 11786 * Need to initialize all the fields within satIOContext 11787 */ 11788 satNewIOContext = smsatPrepareNewIO( 11789 satNewIntIo, 11790 smOrgIORequest, 11791 oneDeviceData, 11792 agNULL, 11793 satOrgIOContext 11794 ); 11795 /* send AGSA_SATA_PROTOCOL_SRST_DEASSERT */ 11796 status = smsatDeResetDevice(smRoot, 11797 smOrgIORequest, 11798 satOrgIOContext->psmDeviceHandle, 11799 agNULL, 11800 satNewIOContext 11801 ); 11802 if (status != SM_RC_SUCCESS) 11803 { 11804 /* TM completed */ 11805 tdsmEventCB( smRoot, 11806 smDeviceHandle, 11807 smIntrEventTypeTaskManagement, 11808 smTMFailed, 11809 oneDeviceData->satTmTaskTag); 11810 /* sending AGSA_SATA_PROTOCOL_SRST_DEASSERT fails */ 11811 oneDeviceData->satTmTaskTag = agNULL; 11812 11813 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11814 smsatFreeIntIoResource( smRoot, 11815 oneDeviceData, 11816 satIntIo); 11817 11818 smsatFreeIntIoResource( smRoot, 11819 oneDeviceData, 11820 satNewIntIo); 11821 return; 11822 } 11823 // oneDeviceData->satTmTaskTag = agNULL; 11824 11825 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11826 11827 smsatFreeIntIoResource( smRoot, 11828 oneDeviceData, 11829 satIntIo); 11830 SM_DBG5(("smsatResetDeviceCB: device %p pending IO %d\n", oneDeviceData, oneDeviceData->satPendingIO)); 11831 SM_DBG6(("smsatResetDeviceCB: end\n")); 11832 return; 11833 } 11834 11835 osGLOBAL void 11836 smsatDeResetDeviceCB( 11837 agsaRoot_t *agRoot, 11838 agsaIORequest_t *agIORequest, 11839 bit32 agIOStatus, 11840 agsaFisHeader_t *agFirstDword, 11841 bit32 agIOInfoLen, 11842 agsaFrameHandle_t agFrameHandle, 11843 void *ioContext 11844 ) 11845 { 11846 /* callback for satDeResetDevice */ 11847 // tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11848 // tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11849 // tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 11850 // tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 11851 smRoot_t *smRoot = agNULL; 11852 smIntRoot_t *smIntRoot = agNULL; 11853 smIntContext_t *smAllShared = agNULL; 11854 smIORequestBody_t *smIORequestBody; 11855 smSatIOContext_t *satIOContext; 11856 smSatIOContext_t *satOrgIOContext; 11857 smSatInternalIo_t *satIntIo; 11858 // satDeviceData_t *satDevData; 11859 smDeviceData_t *oneDeviceData; 11860 #ifdef TD_DEBUG_ENABLE 11861 bit32 ataStatus = 0; 11862 bit32 ataError; 11863 agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 11864 #endif 11865 bit32 AbortTM = agFALSE; 11866 smDeviceHandle_t *smDeviceHandle; 11867 11868 SM_DBG1(("smsatDeResetDeviceCB: start!!!\n")); 11869 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 11870 satIOContext = (smSatIOContext_t *) ioContext; 11871 satIntIo = satIOContext->satIntIoContext; 11872 oneDeviceData = satIOContext->pSatDevData; 11873 smRoot = oneDeviceData->smRoot; 11874 smIntRoot = (smIntRoot_t *)smRoot->smData; 11875 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 11876 smDeviceHandle = oneDeviceData->smDevHandle; 11877 if (satIntIo == agNULL) 11878 { 11879 SM_DBG6(("smsatDeResetDeviceCB: External, OS generated\n")); 11880 satOrgIOContext = satIOContext; 11881 } 11882 else 11883 { 11884 SM_DBG6(("smsatDeResetDeviceCB: Internal, TD generated\n")); 11885 satOrgIOContext = satIOContext->satOrgIOContext; 11886 if (satOrgIOContext == agNULL) 11887 { 11888 SM_DBG6(("smsatDeResetDeviceCB: satOrgIOContext is NULL, wrong\n")); 11889 return; 11890 } 11891 else 11892 { 11893 SM_DBG6(("smsatDeResetDeviceCB: satOrgIOContext is NOT NULL\n")); 11894 } 11895 } 11896 smIORequestBody->ioCompleted = agTRUE; 11897 smIORequestBody->ioStarted = agFALSE; 11898 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 11899 { 11900 SM_DBG1(("smsatDeResetDeviceCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 11901 /* TM completed */ 11902 tdsmEventCB( smRoot, 11903 smDeviceHandle, 11904 smIntrEventTypeTaskManagement, 11905 smTMFailed, 11906 oneDeviceData->satTmTaskTag); 11907 oneDeviceData->satTmTaskTag = agNULL; 11908 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11909 smsatFreeIntIoResource( smRoot, 11910 oneDeviceData, 11911 satIntIo); 11912 return; 11913 } 11914 11915 if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 11916 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 11917 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 11918 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 11919 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 11920 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 11921 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 11922 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 11923 agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 11924 ) 11925 { 11926 SM_DBG1(("smsatDeResetDeviceCB: OSSA_IO_OPEN_CNX_ERROR!!!\n")); 11927 11928 /* TM completed */ 11929 tdsmEventCB( smRoot, 11930 smDeviceHandle, 11931 smIntrEventTypeTaskManagement, 11932 smTMFailed, 11933 oneDeviceData->satTmTaskTag); 11934 oneDeviceData->satTmTaskTag = agNULL; 11935 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11936 smsatFreeIntIoResource( smRoot, 11937 oneDeviceData, 11938 satIntIo); 11939 return; 11940 } 11941 if (agIOStatus != OSSA_IO_SUCCESS) 11942 { 11943 /* only agsaFisPioSetup_t is expected */ 11944 #ifdef TD_DEBUG_ENABLE 11945 satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 11946 ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 11947 ataError = satPIOSetupHeader->error; /* ATA Eror register */ 11948 #endif 11949 SM_DBG1(("smsatDeResetDeviceCB: ataStatus 0x%x ataError 0x%x!!!\n", ataStatus, ataError)); 11950 /* TM completed */ 11951 tdsmEventCB( smRoot, 11952 smDeviceHandle, 11953 smIntrEventTypeTaskManagement, 11954 smTMFailed, 11955 oneDeviceData->satTmTaskTag); 11956 oneDeviceData->satTmTaskTag = agNULL; 11957 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11958 smsatFreeIntIoResource( smRoot, 11959 oneDeviceData, 11960 satIntIo); 11961 return; 11962 } 11963 11964 /* success */ 11965 SM_DBG1(("smsatDeResetDeviceCB: success !!!\n")); 11966 SM_DBG1(("smsatDeResetDeviceCB: TMF %d!!!\n", satOrgIOContext->TMF)); 11967 11968 if (satOrgIOContext->TMF == AG_ABORT_TASK) 11969 { 11970 AbortTM = agTRUE; 11971 } 11972 if (AbortTM == agTRUE) 11973 { 11974 SM_DBG1(("smsatDeResetDeviceCB: calling satAbort!!!\n")); 11975 smsatAbort(smRoot, agRoot, satOrgIOContext->satToBeAbortedIOContext); 11976 } 11977 oneDeviceData->satTmTaskTag = agNULL; 11978 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 11979 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 11980 11981 SM_DBG1(("smsatDeResetDeviceCB: satPendingIO %d satNCQMaxIO %d!!!\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 11982 SM_DBG1(("smsatDeResetDeviceCB: satPendingNCQIO %d satPendingNONNCQIO %d!!!\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 11983 smsatFreeIntIoResource( smRoot, oneDeviceData, satIntIo ); 11984 11985 /* TM completed */ 11986 tdsmEventCB( smRoot, 11987 smDeviceHandle, 11988 smIntrEventTypeTaskManagement, 11989 smTMOK, 11990 oneDeviceData->satTmTaskTag); 11991 SM_DBG5(("smsatDeResetDeviceCB: device %p pending IO %d\n", oneDeviceData, oneDeviceData->satPendingIO)); 11992 SM_DBG6(("smsatDeResetDeviceCB: end\n")); 11993 return; 11994 } 11995 11996 osGLOBAL void 11997 smaSATAAbortCB( 11998 agsaRoot_t *agRoot, 11999 agsaIORequest_t *agIORequest, 12000 bit32 flag, 12001 bit32 status 12002 ) 12003 { 12004 smRoot_t *smRoot = gsmRoot; 12005 smIORequestBody_t *smIORequestBody = agNULL; 12006 smSatIOContext_t *satIOContext; 12007 smDeviceHandle_t *smDeviceHandle; 12008 smDeviceData_t *oneDeviceData = agNULL; 12009 12010 SM_DBG1(("smaSATAAbortCB: start\n")); 12011 12012 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 12013 if (smIORequestBody == agNULL) 12014 { 12015 SM_DBG1(("smaSATAAbortCB: smIORequestBody is NULL!!! \n")); 12016 return; 12017 } 12018 12019 satIOContext = &(smIORequestBody->transport.SATA.satIOContext); 12020 if (satIOContext == agNULL) 12021 { 12022 SM_DBG1(("smaSATAAbortCB: satIOContext is NULL!!! \n")); 12023 if (smIORequestBody->IOType.InitiatorTMIO.osMemHandle != agNULL) 12024 { 12025 tdsmFreeMemory(smRoot, 12026 smIORequestBody->IOType.InitiatorTMIO.osMemHandle, 12027 sizeof(smIORequestBody_t) 12028 ); 12029 } 12030 return; 12031 } 12032 12033 smDeviceHandle = smIORequestBody->smDevHandle; 12034 if (smDeviceHandle == agNULL) 12035 { 12036 SM_DBG1(("smaSATAAbortCB: smDeviceHandle is NULL!!!\n")); 12037 if (smIORequestBody->IOType.InitiatorTMIO.osMemHandle != agNULL) 12038 { 12039 tdsmFreeMemory(smRoot, 12040 smIORequestBody->IOType.InitiatorTMIO.osMemHandle, 12041 sizeof(smIORequestBody_t) 12042 ); 12043 } 12044 return; 12045 } 12046 12047 oneDeviceData = (smDeviceData_t *)smDeviceHandle->smData; 12048 if (oneDeviceData == agNULL) 12049 { 12050 SM_DBG1(("smaSATAAbortCB: oneDeviceData is NULL!!!\n")); 12051 if (smIORequestBody->IOType.InitiatorTMIO.osMemHandle != agNULL) 12052 { 12053 tdsmFreeMemory(smRoot, 12054 smIORequestBody->IOType.InitiatorTMIO.osMemHandle, 12055 sizeof(smIORequestBody_t) 12056 ); 12057 } 12058 12059 return; 12060 } 12061 12062 if (flag == 2) 12063 { 12064 /* abort per port */ 12065 SM_DBG1(("smaSATAAbortCB: abort per port, not yet!!!\n")); 12066 } 12067 else if (flag == 1) 12068 { 12069 SM_DBG1(("smaSATAAbortCB: abort all!!!\n")); 12070 if (oneDeviceData->OSAbortAll == agTRUE) 12071 { 12072 oneDeviceData->OSAbortAll = agFALSE; 12073 #if 0 12074 ostiInitiatorEvent( tiRoot, 12075 agNULL, 12076 tiDeviceHandle, 12077 tiIntrEventTypeLocalAbort, 12078 tiAbortOK, 12079 agNULL); 12080 #endif 12081 #if 1 12082 tdsmEventCB( smRoot, 12083 smDeviceHandle, 12084 smIntrEventTypeLocalAbort, 12085 smTMOK, 12086 agNULL); 12087 #endif 12088 12089 } 12090 if (smIORequestBody->IOType.InitiatorTMIO.osMemHandle != agNULL) 12091 { 12092 tdsmFreeMemory(smRoot, 12093 smIORequestBody->IOType.InitiatorTMIO.osMemHandle, 12094 sizeof(smIORequestBody_t) 12095 ); 12096 } 12097 } 12098 else if (flag == 0) 12099 { 12100 SM_DBG1(("smaSATAAbortCB: abort one\n")); 12101 if (status == OSSA_IO_SUCCESS) 12102 { 12103 SM_DBG1(("smaSATAAbortCB: OSSA_IO_SUCCESS\n")); 12104 } 12105 else if (status == OSSA_IO_NOT_VALID) 12106 { 12107 SM_DBG1(("smaSATAAbortCB: OSSA_IO_NOT_VALID\n")); 12108 } 12109 else if (status == OSSA_IO_NO_DEVICE) 12110 { 12111 SM_DBG1(("smaSATAAbortCB: OSSA_IO_NO_DEVICE\n")); 12112 } 12113 else if (status == OSSA_IO_ABORT_IN_PROGRESS) 12114 { 12115 SM_DBG1(("smaSATAAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 12116 } 12117 #ifdef REMOVED 12118 else if (status == OSSA_IO_ABORT_DELAYED) 12119 { 12120 SM_DBG1(("smaSATAAbortCB: OSSA_IO_ABORT_DELAYED\n")); 12121 } 12122 #endif 12123 else 12124 { 12125 SM_DBG1(("smaSATAAbortCB: unspecified status 0x%x\n", status )); 12126 } 12127 if (smIORequestBody->IOType.InitiatorTMIO.osMemHandle != agNULL) 12128 { 12129 tdsmFreeMemory(smRoot, 12130 smIORequestBody->IOType.InitiatorTMIO.osMemHandle, 12131 sizeof(smIORequestBody_t) 12132 ); 12133 } 12134 } 12135 else 12136 { 12137 SM_DBG1(("smaSATAAbortCB: wrong flag %d\n", flag)); 12138 } 12139 12140 return; 12141 } 12142 12143 osGLOBAL void 12144 smLocalPhyControlCB( 12145 agsaRoot_t *agRoot, 12146 agsaContext_t *agContext, 12147 bit32 phyId, 12148 bit32 phyOperation, 12149 bit32 status, 12150 void *parm 12151 ) 12152 { 12153 smRoot_t *smRoot = gsmRoot; 12154 smIORequestBody_t *smIORequestBody = agNULL; 12155 smDeviceHandle_t *smDeviceHandle; 12156 smDeviceData_t *oneDeviceData = agNULL; 12157 smIORequest_t *currentTaskTag; 12158 agsaDevHandle_t *agDevHandle = agNULL; 12159 12160 SM_DBG1(("smLocalPhyControlCB: start phyId 0x%x phyOperation 0x%x status 0x%x\n",phyId,phyOperation,status)); 12161 12162 if (agContext == agNULL) 12163 { 12164 SM_DBG1(("smLocalPhyControlCB: agContext is NULL!!!\n")); 12165 return; 12166 } 12167 currentTaskTag = (smIORequest_t *)agContext->osData; 12168 if (currentTaskTag == agNULL) 12169 { 12170 SM_DBG1(("smLocalPhyControlCB: currentTaskTag is NULL!!!\n")); 12171 return; 12172 } 12173 smIORequestBody = (smIORequestBody_t *)currentTaskTag->smData; 12174 if (smIORequestBody == agNULL) 12175 { 12176 SM_DBG1(("smLocalPhyControlCB: smIORequestBody is NULL!!!\n")); 12177 return; 12178 } 12179 smDeviceHandle = smIORequestBody->smDevHandle; 12180 if (smDeviceHandle == agNULL) 12181 { 12182 SM_DBG1(("smLocalPhyControlCB: smDeviceHandle is NULL!!!\n")); 12183 return; 12184 } 12185 oneDeviceData = (smDeviceData_t *)smDeviceHandle->smData; 12186 if (oneDeviceData == agNULL) 12187 { 12188 SM_DBG1(("smLocalPhyControlCB: oneDeviceData is NULL!!!\n")); 12189 return; 12190 } 12191 switch (phyOperation) 12192 { 12193 case AGSA_PHY_LINK_RESET: /* fall through */ 12194 case AGSA_PHY_HARD_RESET: 12195 if (status == OSSA_SUCCESS) 12196 { 12197 SM_DBG2(("smLocalPhyControlCB: callback to TD layer with success\n")); 12198 agDevHandle = oneDeviceData->agDevHandle; 12199 SM_DBG2(("smLocalPhyControlCB: satPendingIO %d satNCQMaxIO %d\n", oneDeviceData->satPendingIO, oneDeviceData->satNCQMaxIO )); 12200 SM_DBG1(("smLocalPhyControlCB: satPendingNCQIO %d satPendingNONNCQIO %d\n", oneDeviceData->satPendingNCQIO, oneDeviceData->satPendingNONNCQIO)); 12201 oneDeviceData->satDriveState = SAT_DEV_STATE_NORMAL; 12202 #ifdef REMOVED 12203 saSetDeviceState(agRoot, 12204 agNULL, 12205 tdsmRotateQnumber(smRoot, smDeviceHandle), 12206 agDevHandle, 12207 SA_DS_OPERATIONAL 12208 ); 12209 /* TM completed */ 12210 tdsmEventCB( smRoot, 12211 smDeviceHandle, 12212 smIntrEventTypeTaskManagement, 12213 smTMOK, 12214 currentTaskTag); 12215 #endif 12216 } 12217 else 12218 { 12219 SM_DBG1(("smLocalPhyControlCB: callback to TD layer with failure!!!\n")); 12220 /* TM completed */ 12221 tdsmEventCB( smRoot, 12222 smDeviceHandle, 12223 smIntrEventTypeTaskManagement, 12224 smTMFailed, 12225 currentTaskTag); 12226 } 12227 break; 12228 default: 12229 SM_DBG1(("ossaLocalPhyControlCB: error default case. phyOperation is %d!!!\n", phyOperation)); 12230 /* TM completed */ 12231 tdsmEventCB( smRoot, 12232 smDeviceHandle, 12233 smIntrEventTypeTaskManagement, 12234 smTMFailed, 12235 currentTaskTag); 12236 break; 12237 } 12238 return; 12239 } 12240 12241 osGLOBAL void 12242 smsatSetFeaturesAACB( 12243 agsaRoot_t *agRoot, 12244 agsaIORequest_t *agIORequest, 12245 bit32 agIOStatus, 12246 agsaFisHeader_t *agFirstDword, 12247 bit32 agIOInfoLen, 12248 void *agParam, 12249 void *ioContext 12250 ) 12251 { 12252 smRoot_t *smRoot = agNULL; 12253 smIntRoot_t *smIntRoot = agNULL; 12254 smIntContext_t *smAllShared = agNULL; 12255 smIORequestBody_t *smIORequestBody; 12256 smIORequestBody_t *smOrgIORequestBody = agNULL; 12257 smSatIOContext_t *satIOContext; 12258 smSatIOContext_t *satOrgIOContext; 12259 smSatInternalIo_t *satIntIo; 12260 smDeviceData_t *oneDeviceData; 12261 smIORequest_t *smOrgIORequest; 12262 smDeviceHandle_t *smDeviceHandle; 12263 smIORequest_t *smIORequest; 12264 bit32 ataStatus = 0; 12265 bit32 ataError = 0; 12266 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 12267 12268 SM_DBG2(("smsatSetFeaturesAACB: start\n")); 12269 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 12270 satIOContext = (smSatIOContext_t *) ioContext; 12271 if (satIOContext == agNULL) 12272 { 12273 SM_DBG1(("smsatSetFeaturesAACB: satIOContext is NULL\n")); 12274 return; 12275 } 12276 satIntIo = satIOContext->satIntIoContext; 12277 oneDeviceData = satIOContext->pSatDevData; 12278 smDeviceHandle = satIOContext->psmDeviceHandle; 12279 smRoot = oneDeviceData->smRoot; 12280 smIntRoot = (smIntRoot_t *)smRoot->smData; 12281 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 12282 if (satIntIo == agNULL) 12283 { 12284 SM_DBG5(("smsatSetFeaturesAACB: External smSatInternalIo_t satIntIoContext\n")); 12285 satOrgIOContext = satIOContext; 12286 smOrgIORequest = smIORequestBody->smIORequest; 12287 smIORequest = smOrgIORequest; 12288 } 12289 else 12290 { 12291 SM_DBG5(("smsatSetFeaturesAACB: Internal smSatInternalIo_t satIntIoContext\n")); 12292 satOrgIOContext = satIOContext->satOrgIOContext; 12293 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 12294 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 12295 } 12296 smIORequest = smOrgIORequestBody->smIORequest; 12297 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 12298 smIORequestBody->ioCompleted = agTRUE; 12299 smIORequestBody->ioStarted = agFALSE; 12300 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 12301 { 12302 SM_DBG1(("smsatSetFeaturesAACB: fail, case 1 agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 12303 } 12304 if (agIOStatus != OSSA_IO_SUCCESS) 12305 { 12306 SM_DBG1(("smsatSetFeaturesAACB: fail, case 2 status %d!!!\n", agIOStatus)); 12307 } 12308 if (agIOInfoLen != 0 && agIOStatus == OSSA_IO_SUCCESS) 12309 { 12310 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 12311 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 12312 ataError = statDevToHostFisHeader->error; /* ATA Eror register */ 12313 if ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 12314 { 12315 SM_DBG1(("smsatSetFeaturesAACB: fail, case 3 ataStatus %d ataError %d!!!\n", ataStatus, ataError)); 12316 } 12317 if (ataError != 0) 12318 { 12319 SM_DBG1(("smsatSetFeaturesAACB: fail, case 4 ataStatus %d ataError %d!!!\n", ataStatus, ataError)); 12320 } 12321 } 12322 /* interal structure free */ 12323 smsatFreeIntIoResource(smRoot,oneDeviceData, satIntIo); 12324 if (smIORequest->tdData == smIORequest->smData) 12325 { 12326 SM_DBG1(("smsatSetFeaturesAACB: the same tdData and smData error!\n")); 12327 } 12328 /*Complete this identify device IO */ 12329 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12330 SM_DBG2(("smsatSetFeaturesAACB: end\n")); 12331 } 12332 12333 /***************************************************************************** 12334 *! \brief smsatSetFeaturesDMACB 12335 * 12336 * This routine is a callback function called from smllSATACompleted(). 12337 * This CB routine deals with normal non-chained data I/O SATA request. 12338 * 12339 * \param agRoot: Handles for this instance of SAS/SATA hardware 12340 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 12341 * \param agIOStatus: Status of completed I/O. 12342 * \param agFirstDword:Pointer to the four bytes of FIS. 12343 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 12344 * length. 12345 * \param agParam: Additional info based on status. 12346 * \param ioContext: Pointer to smSatIOContext_t. 12347 * 12348 * \return: none 12349 * 12350 *****************************************************************************/ 12351 osGLOBAL void 12352 smsatSetFeaturesDMACB( 12353 agsaRoot_t *agRoot, 12354 agsaIORequest_t *agIORequest, 12355 bit32 agIOStatus, 12356 agsaFisHeader_t *agFirstDword, 12357 bit32 agIOInfoLen, 12358 void *agParam, 12359 void *ioContext 12360 ) 12361 { 12362 smRoot_t *smRoot = agNULL; 12363 smIntRoot_t *smIntRoot = agNULL; 12364 smIntContext_t *smAllShared = agNULL; 12365 smIORequestBody_t *smIORequestBody; 12366 smIORequestBody_t *smOrgIORequestBody = agNULL; 12367 smSatIOContext_t *satIOContext; 12368 smSatIOContext_t *satOrgIOContext; 12369 smSatIOContext_t *satNewIOContext; 12370 smSatInternalIo_t *satIntIo; 12371 smSatInternalIo_t *satNewIntIo = agNULL; 12372 smDeviceData_t *oneDeviceData; 12373 smIniScsiCmnd_t *scsiCmnd; 12374 smIORequest_t *smOrgIORequest; 12375 smDeviceHandle_t *smDeviceHandle; 12376 bit32 status = SM_RC_FAILURE; 12377 smIORequest_t *smIORequest; 12378 12379 SM_DBG2(("smsatSetFeaturesDMACB: start\n")); 12380 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 12381 satIOContext = (smSatIOContext_t *) ioContext; 12382 if (satIOContext == agNULL) 12383 { 12384 SM_DBG1(("smsatSetFeaturesDMACB: satIOContext is NULL\n")); 12385 return; 12386 } 12387 satIntIo = satIOContext->satIntIoContext; 12388 oneDeviceData = satIOContext->pSatDevData; 12389 smDeviceHandle = satIOContext->psmDeviceHandle; 12390 smRoot = oneDeviceData->smRoot; 12391 smIntRoot = (smIntRoot_t *)smRoot->smData; 12392 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 12393 if (satIntIo == agNULL) 12394 { 12395 SM_DBG2(("smsatSetFeaturesDMACB: External smSatInternalIo_t satIntIoContext\n")); 12396 satOrgIOContext = satIOContext; 12397 smOrgIORequest = smIORequestBody->smIORequest; 12398 scsiCmnd = satIOContext->pScsiCmnd; 12399 } 12400 else 12401 { 12402 SM_DBG2(("smsatSetFeaturesDMACB: Internal smSatInternalIo_t satIntIoContext\n")); 12403 satOrgIOContext = satIOContext->satOrgIOContext; 12404 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 12405 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 12406 scsiCmnd = satOrgIOContext->pScsiCmnd; 12407 } 12408 smIORequest = smOrgIORequestBody->smIORequest; 12409 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 12410 smIORequestBody->ioCompleted = agTRUE; 12411 smIORequestBody->ioStarted = agFALSE; 12412 12413 oneDeviceData->satDMAEnabled = agTRUE; 12414 /* interal structure free */ 12415 smsatFreeIntIoResource(smRoot, 12416 oneDeviceData, 12417 satIntIo); 12418 12419 if (smIORequest->tdData == smIORequest->smData) 12420 { 12421 SM_DBG1(("smsatSetFeaturesDMACB: the same tdData and smData error!\n")); 12422 } 12423 SM_DBG2(("smsatSetFeaturesDMACB: agIOStatus 0x%x\n", agIOStatus)); 12424 /* check the agIOStatus */ 12425 if (agIOStatus == OSSA_IO_ABORTED || 12426 agIOStatus == OSSA_IO_NO_DEVICE || 12427 agIOStatus == OSSA_IO_PORT_IN_RESET || 12428 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL || 12429 agIOStatus == OSSA_IO_DS_IN_RECOVERY || 12430 agIOStatus == OSSA_IO_DS_IN_ERROR || 12431 agIOStatus == OSSA_IO_DS_INVALID 12432 ) 12433 { 12434 SM_DBG1(("smsatSetFeaturesDMACB: error status 0x%x\n", agIOStatus)); 12435 SM_DBG1(("smsatSetFeaturesDMACB: did %d!!!\n", oneDeviceData->id)); 12436 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12437 return; 12438 } 12439 if (oneDeviceData->satDeviceType == SATA_ATAPI_DEVICE) 12440 { 12441 /*if ATAPI device, only need to enable PIO and DMA transfer mode, then complete this identify device command */ 12442 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12443 return; 12444 } 12445 12446 /* enble read look-ahead feature*/ 12447 if (oneDeviceData->satReadLookAheadSupport == agTRUE) 12448 { 12449 satNewIntIo = smsatAllocIntIoResource(smRoot, 12450 smOrgIORequest, 12451 oneDeviceData, 12452 0, 12453 satNewIntIo); 12454 if (satNewIntIo == agNULL) 12455 { 12456 SM_DBG1(("smsatSetFeaturesDMACB: memory allocation fails\n")); 12457 /*Complete this identify packet device IO */ 12458 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12459 return; 12460 } /* end memory allocation */ 12461 12462 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 12463 smOrgIORequest, 12464 oneDeviceData, 12465 scsiCmnd, 12466 satOrgIOContext 12467 ); 12468 /* sends SET FEATURES command to enable Read Look-Ahead */ 12469 status = smsatSetFeaturesReadLookAhead(smRoot, 12470 &satNewIntIo->satIntSmIORequest, 12471 satNewIOContext->psmDeviceHandle, 12472 &satNewIntIo->satIntSmScsiXchg, 12473 satNewIOContext 12474 ); 12475 if (status != SM_RC_SUCCESS) 12476 { 12477 smsatFreeIntIoResource(smRoot, oneDeviceData, satNewIntIo); 12478 SM_DBG1(("smsatSetFeaturesDMACB: failed to call smsatSetFeatures()\n")); 12479 /*Complete this identify device IO */ 12480 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12481 } 12482 SM_DBG2(("smsatSetFeaturesDMACB: end\n")); 12483 return; 12484 } 12485 /* enble Volatile Write Cache feature*/ 12486 if (oneDeviceData->satVolatileWriteCacheSupport == agTRUE) 12487 { 12488 satNewIntIo = smsatAllocIntIoResource(smRoot, 12489 smOrgIORequest, 12490 oneDeviceData, 12491 0, 12492 satNewIntIo); 12493 if (satNewIntIo == agNULL) 12494 { 12495 SM_DBG1(("smsatSetFeaturesDMACB: memory allocation fails\n")); 12496 /*Complete this identify packet device IO */ 12497 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12498 return; 12499 } /* end memory allocation */ 12500 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 12501 smOrgIORequest, 12502 oneDeviceData, 12503 scsiCmnd, 12504 satOrgIOContext 12505 ); 12506 /* sends SET FEATURES command to enable Volatile Write Cache */ 12507 status = smsatSetFeaturesVolatileWriteCache(smRoot, 12508 &satNewIntIo->satIntSmIORequest, 12509 satNewIOContext->psmDeviceHandle, 12510 &satNewIntIo->satIntSmScsiXchg, 12511 satNewIOContext 12512 ); 12513 if (status != SM_RC_SUCCESS) 12514 { 12515 smsatFreeIntIoResource(smRoot, oneDeviceData, satNewIntIo); 12516 SM_DBG1(("smsatSetFeaturesDMACB: failed to call smsatSetFeatures()\n")); 12517 /*Complete this identify device IO */ 12518 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12519 } 12520 SM_DBG2(("smsatSetFeaturesDMACB: end\n")); 12521 return; 12522 } 12523 /* turn on DMA Setup FIS auto-activate by sending set feature FIS */ 12524 if (oneDeviceData->satNCQ == agTRUE && oneDeviceData->satDMASetupAA == agTRUE) 12525 { 12526 satNewIntIo = smsatAllocIntIoResource( smRoot, 12527 smOrgIORequest, 12528 oneDeviceData, 12529 0, 12530 satNewIntIo); 12531 12532 if (satNewIntIo == agNULL) 12533 { 12534 SM_DBG1(("smsatSetFeaturesDMACB: momory allocation fails; can't send set feature\n")); 12535 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12536 return; 12537 } /* end memory allocation */ 12538 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 12539 smOrgIORequest, 12540 oneDeviceData, 12541 agNULL, 12542 satOrgIOContext 12543 ); 12544 /* send the Set Feature ATA command to SATA device for enable DMA Setup FIS auto-activate */ 12545 status = smsatSetFeaturesAA(smRoot, 12546 &satNewIntIo->satIntSmIORequest, 12547 satNewIOContext->psmDeviceHandle, 12548 &satNewIntIo->satIntSmScsiXchg, /* orginal from OS layer */ 12549 satNewIOContext); 12550 if (status != SM_RC_SUCCESS) 12551 { 12552 SM_DBG1(("smsatSetFeaturesDMACB: failed to send set feature!!!\n")); 12553 smsatFreeIntIoResource( smRoot, 12554 oneDeviceData, 12555 satNewIntIo); 12556 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 12557 } 12558 } 12559 else 12560 { 12561 /*Complete this identify device IO */ 12562 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12563 } 12564 SM_DBG2(("smsatSetFeaturesDMACB: end\n")); 12565 } 12566 12567 /***************************************************************************** 12568 *! \brief smsatSetFeaturesReadLookAheadCB 12569 * 12570 * This routine is a callback function called from smllSATACompleted(). 12571 * This CB routine deals with normal non-chained data I/O SATA request. 12572 * 12573 * \param agRoot: Handles for this instance of SAS/SATA hardware 12574 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 12575 * \param agIOStatus: Status of completed I/O. 12576 * \param agFirstDword:Pointer to the four bytes of FIS. 12577 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 12578 * length. 12579 * \param agParam: Additional info based on status. 12580 * \param ioContext: Pointer to smSatIOContext_t. 12581 * 12582 * \return: none 12583 * 12584 *****************************************************************************/ 12585 osGLOBAL void 12586 smsatSetFeaturesReadLookAheadCB( 12587 agsaRoot_t *agRoot, 12588 agsaIORequest_t *agIORequest, 12589 bit32 agIOStatus, 12590 agsaFisHeader_t *agFirstDword, 12591 bit32 agIOInfoLen, 12592 void *agParam, 12593 void *ioContext 12594 ) 12595 { 12596 smRoot_t *smRoot = agNULL; 12597 smIntRoot_t *smIntRoot = agNULL; 12598 smIntContext_t *smAllShared = agNULL; 12599 smIORequestBody_t *smIORequestBody; 12600 smIORequestBody_t *smOrgIORequestBody = agNULL; 12601 smSatIOContext_t *satIOContext; 12602 smSatIOContext_t *satOrgIOContext; 12603 smSatIOContext_t *satNewIOContext; 12604 smSatInternalIo_t *satIntIo; 12605 smSatInternalIo_t *satNewIntIo = agNULL; 12606 smDeviceData_t *oneDeviceData; 12607 smIniScsiCmnd_t *scsiCmnd; 12608 smIORequest_t *smOrgIORequest; 12609 smDeviceHandle_t *smDeviceHandle; 12610 bit32 status = SM_RC_FAILURE; 12611 smIORequest_t *smIORequest; 12612 12613 SM_DBG2(("smsatSetFeaturesReadLookAheadCB: start\n")); 12614 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 12615 satIOContext = (smSatIOContext_t *) ioContext; 12616 if (satIOContext == agNULL) 12617 { 12618 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: satIOContext is NULL\n")); 12619 return; 12620 } 12621 satIntIo = satIOContext->satIntIoContext; 12622 oneDeviceData = satIOContext->pSatDevData; 12623 smDeviceHandle = satIOContext->psmDeviceHandle; 12624 smRoot = oneDeviceData->smRoot; 12625 smIntRoot = (smIntRoot_t *)smRoot->smData; 12626 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 12627 12628 if (satIntIo == agNULL) 12629 { 12630 SM_DBG2(("smsatSetFeaturesReadLookAheadCB: External smSatInternalIo_t satIntIoContext\n")); 12631 satOrgIOContext = satIOContext; 12632 smOrgIORequest = smIORequestBody->smIORequest; 12633 scsiCmnd = satIOContext->pScsiCmnd; 12634 } 12635 else 12636 { 12637 SM_DBG2(("smsatSetFeaturesReadLookAheadCB: Internal smSatInternalIo_t satIntIoContext\n")); 12638 satOrgIOContext = satIOContext->satOrgIOContext; 12639 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 12640 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 12641 scsiCmnd = satOrgIOContext->pScsiCmnd; 12642 } 12643 smIORequest = smOrgIORequestBody->smIORequest; 12644 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 12645 12646 smIORequestBody->ioCompleted = agTRUE; 12647 smIORequestBody->ioStarted = agFALSE; 12648 12649 oneDeviceData->satLookAheadEnabled = agTRUE; 12650 12651 /* interal structure free */ 12652 smsatFreeIntIoResource(smRoot, 12653 oneDeviceData, 12654 satIntIo); 12655 12656 /* check the agIOStatus */ 12657 if (agIOStatus == OSSA_IO_ABORTED || 12658 agIOStatus == OSSA_IO_NO_DEVICE || 12659 agIOStatus == OSSA_IO_PORT_IN_RESET || 12660 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL || 12661 agIOStatus == OSSA_IO_DS_IN_RECOVERY || 12662 agIOStatus == OSSA_IO_DS_IN_ERROR || 12663 agIOStatus == OSSA_IO_DS_INVALID 12664 ) 12665 { 12666 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: error status 0x%x\n", agIOStatus)); 12667 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: did %d!!!\n", oneDeviceData->id)); 12668 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12669 return; 12670 } 12671 12672 12673 12674 /* enble Volatile Write Cache feature*/ 12675 if (oneDeviceData->satVolatileWriteCacheSupport == agTRUE) 12676 { 12677 satNewIntIo = smsatAllocIntIoResource(smRoot, 12678 smOrgIORequest, 12679 oneDeviceData, 12680 0, 12681 satNewIntIo); 12682 if (satNewIntIo == agNULL) 12683 { 12684 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: memory allocation fails\n")); 12685 /*Complete this identify packet device IO */ 12686 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12687 return; 12688 } /* end memory allocation */ 12689 12690 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 12691 smOrgIORequest, 12692 oneDeviceData, 12693 scsiCmnd, 12694 satOrgIOContext 12695 ); 12696 /* sends SET FEATURES command to enable Volatile Write Cache */ 12697 status = smsatSetFeaturesVolatileWriteCache(smRoot, 12698 &satNewIntIo->satIntSmIORequest, 12699 satNewIOContext->psmDeviceHandle, 12700 &satNewIntIo->satIntSmScsiXchg, 12701 satNewIOContext 12702 ); 12703 if (status != SM_RC_SUCCESS) 12704 { 12705 smsatFreeIntIoResource(smRoot, oneDeviceData, satNewIntIo); 12706 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: failed to call smsatSetFeatures()\n")); 12707 /*Complete this identify device IO */ 12708 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12709 } 12710 SM_DBG2(("smsatSetFeaturesReadLookAheadCB: end\n")); 12711 12712 return; 12713 } 12714 12715 /* turn on DMA Setup FIS auto-activate by sending set feature FIS */ 12716 if (oneDeviceData->satNCQ == agTRUE && oneDeviceData->satDMASetupAA == agTRUE) 12717 { 12718 satNewIntIo = smsatAllocIntIoResource( smRoot, 12719 smOrgIORequest, 12720 oneDeviceData, 12721 0, 12722 satNewIntIo); 12723 12724 if (satNewIntIo == agNULL) 12725 { 12726 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: momory allocation fails; can't send set feature\n")); 12727 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12728 return; 12729 } /* end memory allocation */ 12730 12731 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 12732 smOrgIORequest, 12733 oneDeviceData, 12734 agNULL, 12735 satOrgIOContext 12736 ); 12737 /* send the Set Feature ATA command to SATA device for enable DMA Setup FIS auto-activate */ 12738 status = smsatSetFeaturesAA(smRoot, 12739 &satNewIntIo->satIntSmIORequest, 12740 satNewIOContext->psmDeviceHandle, 12741 &satNewIntIo->satIntSmScsiXchg, /* orginal from OS layer */ 12742 satNewIOContext); 12743 12744 if (status != SM_RC_SUCCESS) 12745 { 12746 SM_DBG1(("smsatSetFeaturesReadLookAheadCB: failed to send set feature!!!\n")); 12747 smsatFreeIntIoResource( smRoot, 12748 oneDeviceData, 12749 satNewIntIo); 12750 /* clean up TD layer's IORequestBody */ 12751 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 12752 } 12753 } 12754 else 12755 { 12756 /*Complete this identify device IO */ 12757 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12758 } 12759 SM_DBG2(("smsatSetFeaturesReadLookAheadCB: end\n")); 12760 } 12761 /***************************************************************************** 12762 *! \brief smsatSetFeaturesVolatileWriteCacheCB 12763 * 12764 * This routine is a callback function called from smllSATACompleted(). 12765 * This CB routine deals with normal non-chained data I/O SATA request. 12766 * 12767 * \param agRoot: Handles for this instance of SAS/SATA hardware 12768 * \param agIORequest: Pointer to the LL I/O request context for this I/O. 12769 * \param agIOStatus: Status of completed I/O. 12770 * \param agFirstDword:Pointer to the four bytes of FIS. 12771 * \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 12772 * length. 12773 * \param agParam: Additional info based on status. 12774 * \param ioContext: Pointer to smSatIOContext_t. 12775 * 12776 * \return: none 12777 * 12778 *****************************************************************************/ 12779 osGLOBAL void 12780 smsatSetFeaturesVolatileWriteCacheCB( 12781 agsaRoot_t *agRoot, 12782 agsaIORequest_t *agIORequest, 12783 bit32 agIOStatus, 12784 agsaFisHeader_t *agFirstDword, 12785 bit32 agIOInfoLen, 12786 void *agParam, 12787 void *ioContext 12788 ) 12789 { 12790 smRoot_t *smRoot = agNULL; 12791 smIntRoot_t *smIntRoot = agNULL; 12792 smIntContext_t *smAllShared = agNULL; 12793 smIORequestBody_t *smIORequestBody; 12794 smIORequestBody_t *smOrgIORequestBody = agNULL; 12795 smSatIOContext_t *satIOContext; 12796 smSatIOContext_t *satOrgIOContext; 12797 smSatIOContext_t *satNewIOContext; 12798 smSatInternalIo_t *satIntIo; 12799 smSatInternalIo_t *satNewIntIo = agNULL; 12800 smDeviceData_t *oneDeviceData; 12801 smIORequest_t *smOrgIORequest; 12802 smDeviceHandle_t *smDeviceHandle; 12803 smIORequest_t *smIORequest; 12804 bit32 ataStatus = 0; 12805 bit32 ataError = 0; 12806 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 12807 bit32 status = SM_RC_FAILURE; 12808 12809 SM_DBG2(("smsatSetFeaturesVolatileWriteCacheCB: start\n")); 12810 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 12811 satIOContext = (smSatIOContext_t *) ioContext; 12812 if (satIOContext == agNULL) 12813 { 12814 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: satIOContext is NULL\n")); 12815 return; 12816 } 12817 satIntIo = satIOContext->satIntIoContext; 12818 oneDeviceData = satIOContext->pSatDevData; 12819 smDeviceHandle = satIOContext->psmDeviceHandle; 12820 smRoot = oneDeviceData->smRoot; 12821 smIntRoot = (smIntRoot_t *)smRoot->smData; 12822 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 12823 if (satIntIo == agNULL) 12824 { 12825 SM_DBG5(("smsatSetFeaturesVolatileWriteCacheCB: External smSatInternalIo_t satIntIoContext\n")); 12826 satOrgIOContext = satIOContext; 12827 smOrgIORequest = smIORequestBody->smIORequest; 12828 smIORequest = smOrgIORequest; 12829 } 12830 else 12831 { 12832 SM_DBG5(("smsatSetFeaturesVolatileWriteCacheCB: Internal smSatInternalIo_t satIntIoContext\n")); 12833 satOrgIOContext = satIOContext->satOrgIOContext; 12834 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 12835 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 12836 } 12837 smIORequest = smOrgIORequestBody->smIORequest; 12838 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 12839 12840 smIORequestBody->ioCompleted = agTRUE; 12841 smIORequestBody->ioStarted = agFALSE; 12842 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 12843 { 12844 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: fail, case 1 agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 12845 } 12846 if (agIOStatus != OSSA_IO_SUCCESS) 12847 { 12848 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: fail, case 2 status %d!!!\n", agIOStatus)); 12849 } 12850 if (agIOInfoLen != 0 && agIOStatus == OSSA_IO_SUCCESS) 12851 { 12852 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 12853 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 12854 ataError = statDevToHostFisHeader->error; /* ATA Eror register */ 12855 if ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 12856 { 12857 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: fail, case 3 ataStatus %d ataError %d!!!\n", ataStatus, ataError)); 12858 } 12859 if (ataError != 0) 12860 { 12861 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: fail, case 4 ataStatus %d ataError %d!!!\n", ataStatus, ataError)); 12862 } 12863 } 12864 12865 oneDeviceData->satWriteCacheEnabled = agTRUE; 12866 12867 /* interal structure free */ 12868 smsatFreeIntIoResource(smRoot,oneDeviceData, satIntIo); 12869 /* check the agIOStatus */ 12870 if (agIOStatus == OSSA_IO_ABORTED || 12871 agIOStatus == OSSA_IO_NO_DEVICE || 12872 agIOStatus == OSSA_IO_PORT_IN_RESET || 12873 agIOStatus == OSSA_IO_DS_NON_OPERATIONAL || 12874 agIOStatus == OSSA_IO_DS_IN_RECOVERY || 12875 agIOStatus == OSSA_IO_DS_IN_ERROR || 12876 agIOStatus == OSSA_IO_DS_INVALID 12877 ) 12878 { 12879 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: error status 0x%x\n", agIOStatus)); 12880 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: did %d!!!\n", oneDeviceData->id)); 12881 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12882 return; 12883 } 12884 /* turn on DMA Setup FIS auto-activate by sending set feature FIS */ 12885 if (oneDeviceData->satNCQ == agTRUE && oneDeviceData->satDMASetupAA == agTRUE) 12886 { 12887 satNewIntIo = smsatAllocIntIoResource( smRoot, 12888 smOrgIORequest, 12889 oneDeviceData, 12890 0, 12891 satNewIntIo); 12892 if (satNewIntIo == agNULL) 12893 { 12894 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: momory allocation fails; can't send set feature\n")); 12895 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12896 return; 12897 } /* end memory allocation */ 12898 satNewIOContext = smsatPrepareNewIO(satNewIntIo, 12899 smOrgIORequest, 12900 oneDeviceData, 12901 agNULL, 12902 satOrgIOContext 12903 ); 12904 /* send the Set Feature ATA command to SATA device for enable DMA Setup FIS auto-activate */ 12905 status = smsatSetFeaturesAA(smRoot, 12906 &satNewIntIo->satIntSmIORequest, 12907 satNewIOContext->psmDeviceHandle, 12908 &satNewIntIo->satIntSmScsiXchg, /* orginal from OS layer */ 12909 satNewIOContext); 12910 if (status != SM_RC_SUCCESS) 12911 { 12912 SM_DBG1(("smsatSetFeaturesVolatileWriteCacheCB: failed to send set feature!!!\n")); 12913 smsatFreeIntIoResource( smRoot, 12914 oneDeviceData, 12915 satNewIntIo); 12916 /* clean up TD layer's IORequestBody */ 12917 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOFailed, &(oneDeviceData->satIdentifyData)); 12918 } 12919 } 12920 else 12921 { 12922 /*Complete this identify device IO */ 12923 tdsmIDCompletedCB(smRoot, smIORequest, smDeviceHandle, smIOSuccess, &(oneDeviceData->satIdentifyData)); 12924 } 12925 SM_DBG2(("smsatSetFeaturesVolatileWriteCacheCB: end\n")); 12926 } 12927 12928 12929 osGLOBAL void 12930 smsatSMARTEnablePassCB( 12931 agsaRoot_t *agRoot, 12932 agsaIORequest_t *agIORequest, 12933 bit32 agIOStatus, 12934 agsaFisHeader_t *agFirstDword, 12935 bit32 agIOInfoLen, 12936 agsaFrameHandle_t agFrameHandle, 12937 void *ioContext 12938 ) 12939 { 12940 12941 smRoot_t *smRoot = agNULL; 12942 smIntRoot_t *smIntRoot = agNULL; 12943 smIntContext_t *smAllShared = agNULL; 12944 smIORequestBody_t *smIORequestBody; 12945 smIORequestBody_t *smOrgIORequestBody; 12946 smSatIOContext_t *satIOContext; 12947 smSatIOContext_t *satOrgIOContext; 12948 //smSatIOContext_t *satNewIOContext; 12949 smSatInternalIo_t *satIntIo; 12950 //smSatInternalIo_t *satNewIntIo = agNULL; 12951 // satDeviceData_t *satDevData; 12952 smDeviceData_t *oneDeviceData; 12953 smIniScsiCmnd_t *scsiCmnd; 12954 smIORequest_t *smOrgIORequest; 12955 //bit32 status; 12956 smScsiRspSense_t *pSense; 12957 bit8 bSenseKey = 0; 12958 bit16 bSenseCodeInfo = 0; 12959 12960 12961 SM_DBG2(("smsatSMARTEnablePassCB: start\n")); 12962 SM_DBG4(("smsatSMARTEnablePassCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 12963 12964 /* internally generate tiIOContext */ 12965 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 12966 satIOContext = (smSatIOContext_t *) ioContext; 12967 satIntIo = satIOContext->satIntIoContext; 12968 oneDeviceData = satIOContext->pSatDevData; 12969 smRoot = oneDeviceData->smRoot; 12970 smIntRoot = (smIntRoot_t *)smRoot->smData; 12971 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 12972 /*ttttttthe one */ 12973 if (satIntIo == agNULL) 12974 { 12975 SM_DBG4(("smsatSMARTEnablePassCB: External smSatInternalIo_t satIntIoContext\n")); 12976 satOrgIOContext = satIOContext; 12977 smOrgIORequest = smIORequestBody->smIORequest; 12978 scsiCmnd = satOrgIOContext->pScsiCmnd; 12979 pSense = satOrgIOContext->pSense; 12980 } 12981 else 12982 { 12983 SM_DBG4(("smsatSMARTEnablePassCB: Internal smSatInternalIo_t satIntIoContext\n")); 12984 satOrgIOContext = satIOContext->satOrgIOContext; 12985 if (satOrgIOContext == agNULL) 12986 { 12987 SM_DBG4(("smsatSMARTEnablePassCB: satOrgIOContext is NULL, wrong\n")); 12988 return; 12989 } 12990 else 12991 { 12992 SM_DBG4(("smsatSMARTEnablePassCB: satOrgIOContext is NOT NULL\n")); 12993 } 12994 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 12995 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 12996 scsiCmnd = satOrgIOContext->pScsiCmnd; 12997 pSense = satOrgIOContext->pSense; 12998 } 12999 smIORequestBody->ioCompleted = agTRUE; 13000 smIORequestBody->ioStarted = agFALSE; 13001 13002 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 13003 { 13004 SM_DBG1(("smsatSMARTEnablePassCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 13005 tdsmIOCompletedCB( 13006 smRoot, 13007 smOrgIORequest, 13008 smIOFailed, 13009 smDetailOtherError, 13010 agNULL, 13011 satOrgIOContext->interruptContext 13012 ); 13013 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13014 smsatFreeIntIoResource( smRoot, 13015 oneDeviceData, 13016 satIntIo); 13017 return; 13018 } 13019 /* 13020 checking IO status, FIS type and error status 13021 */ 13022 if (agIOStatus != OSSA_IO_SUCCESS) 13023 { 13024 SM_DBG1(("smsatSMARTEnablePassCB: not success status, status %d!!!\n", agIOStatus)); 13025 if (agIOStatus == OSSA_IO_ABORTED) 13026 { 13027 smsatProcessAbort(smRoot, 13028 smOrgIORequest, 13029 satOrgIOContext 13030 ); 13031 13032 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13033 smsatFreeIntIoResource( smRoot, 13034 oneDeviceData, 13035 satIntIo); 13036 return; 13037 } 13038 13039 smsatTranslateATAErrorsToSCSIErrors( 13040 agFirstDword->D2H.status, 13041 agFirstDword->D2H.error, 13042 &bSenseKey, 13043 &bSenseCodeInfo 13044 ); 13045 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 13046 tdsmIOCompletedCB(smRoot, 13047 smOrgIORequest, 13048 smIOSuccess, 13049 SCSI_STAT_CHECK_CONDITION, 13050 satOrgIOContext->pSmSenseData, 13051 satOrgIOContext->interruptContext ); 13052 13053 13054 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13055 13056 smsatFreeIntIoResource( smRoot, 13057 oneDeviceData, 13058 satIntIo); 13059 13060 return; 13061 } 13062 /* process success case */ 13063 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13064 smsatFreeIntIoResource( smRoot, 13065 oneDeviceData, 13066 satIntIo); 13067 13068 SM_DBG1(("smsatSMARTEnablePassCB:success status, status %d!!!\n", agIOStatus)); 13069 tdsmIOCompletedCB( 13070 smRoot, 13071 smOrgIORequest, 13072 smIOSuccess, 13073 SCSI_STAT_GOOD, 13074 agNULL, 13075 satOrgIOContext->interruptContext 13076 ); 13077 13078 13079 13080 return; 13081 } 13082 13083 osGLOBAL void 13084 smsatSMARTRStatusPassCB( 13085 agsaRoot_t *agRoot, 13086 agsaIORequest_t *agIORequest, 13087 bit32 agIOStatus, 13088 agsaFisHeader_t *agFirstDword, 13089 bit32 agIOInfoLen, 13090 void *agParam, 13091 void *ioContext 13092 ) 13093 13094 { 13095 13096 13097 smRoot_t *smRoot = agNULL; 13098 smIntRoot_t *smIntRoot = agNULL; 13099 smIntContext_t *smAllShared = agNULL; 13100 smIORequestBody_t *smIORequestBody; 13101 smIORequestBody_t *smOrgIORequestBody; 13102 smSatIOContext_t *satIOContext; 13103 smSatIOContext_t *satOrgIOContext; 13104 smSatInternalIo_t *satIntIo; 13105 // satDeviceData_t *satDevData; 13106 smDeviceData_t *oneDeviceData; 13107 13108 smScsiRspSense_t *pSense; 13109 smIORequest_t *smOrgIORequest; 13110 13111 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 13112 bit32 ataStatus = 0; 13113 smScsiInitiatorRequest_t *smScsiRequest; /* tiScsiXchg */ 13114 smScsiInitiatorRequest_t *smOrgScsiRequest; /* tiScsiXchg */ 13115 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 13116 // agsaFisRegD2HData_t statDevToHostFisData; 13117 smIniScsiCmnd_t *scsiCmnd; 13118 bit8 bSenseKey = 0; 13119 bit16 bSenseCodeInfo = 0; 13120 13121 13122 SM_DBG2(("smsatSMARTRStatusPassCB: start\n")); 13123 SM_DBG5(("smsatSMARTRStatusPassCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 13124 13125 /* internally generate smIOContext */ 13126 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 13127 satIOContext = (smSatIOContext_t *) ioContext; 13128 satIntIo = satIOContext->satIntIoContext; 13129 oneDeviceData = satIOContext->pSatDevData; 13130 hostToDevFis = satIOContext->pFis; 13131 smRoot = oneDeviceData->smRoot; 13132 smIntRoot = (smIntRoot_t *)smRoot->smData; 13133 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 13134 13135 if (satIntIo == agNULL) 13136 { 13137 SM_DBG4(("smsatSMARTRStatusPassCB: External smSatInternalIo_t satIntIoContext\n")); 13138 satOrgIOContext = satIOContext; 13139 smOrgIORequest = smIORequestBody->smIORequest; 13140 pSense = satOrgIOContext->pSense; 13141 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 13142 /* ATA command response payload */ 13143 smScsiRequest = satOrgIOContext->smScsiXchg; 13144 scsiCmnd = satOrgIOContext->pScsiCmnd; 13145 SM_DBG1((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", scsiCmnd->cdb[0], scsiCmnd->cdb[1],scsiCmnd->cdb[2], scsiCmnd->cdb[3])); 13146 SM_DBG1((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", scsiCmnd->cdb[4], scsiCmnd->cdb[5],scsiCmnd->cdb[6], scsiCmnd->cdb[7])); 13147 SM_DBG1((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", scsiCmnd->cdb[8], scsiCmnd->cdb[9],scsiCmnd->cdb[10], scsiCmnd->cdb[11])); 13148 13149 13150 } 13151 else 13152 { 13153 SM_DBG4(("smsatSMARTRStatusPassCB: Internal smSatInternalIo_t satIntIoContext\n")); 13154 satOrgIOContext = satIOContext->satOrgIOContext; 13155 if (satOrgIOContext == agNULL) 13156 { 13157 SM_DBG4(("smsatSMARTRStatusPassCB: satOrgIOContext is NULL\n")); 13158 13159 return; 13160 13161 } 13162 else 13163 { 13164 SM_DBG4(("smsatSMARTRStatusPassCB: satOrgIOContext is NOT NULL\n")); 13165 } 13166 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 13167 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 13168 13169 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 13170 /* ATA command response payload */ 13171 smScsiRequest = (smScsiInitiatorRequest_t *)&(satIntIo->satIntSmScsiXchg); 13172 scsiCmnd = satOrgIOContext->pScsiCmnd; 13173 pSense = satOrgIOContext->pSense; 13174 } 13175 13176 smIORequestBody->ioCompleted = agTRUE; 13177 smIORequestBody->ioStarted = agFALSE; 13178 13179 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 13180 { 13181 SM_DBG1(("smsatSMARTRStatusPassCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 13182 tdsmIOCompletedCB( 13183 smRoot, 13184 smOrgIORequest, 13185 smIOFailed, 13186 smDetailOtherError, 13187 agNULL, 13188 satOrgIOContext->interruptContext 13189 ); 13190 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13191 13192 smsatFreeIntIoResource( smRoot, 13193 oneDeviceData, 13194 satIntIo); 13195 return; 13196 } 13197 13198 if( agIOStatus != OSSA_IO_SUCCESS) 13199 { 13200 13201 /* non-data -> device to host fis are expected */ 13202 13203 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 13204 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 13205 13206 if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 13207 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 13208 ) 13209 { 13210 /* for debugging */ 13211 if( agIOStatus != OSSA_IO_SUCCESS) 13212 { 13213 SM_DBG1(("smsatSMARTRStatusPassCB: FAILED, NOT IO_SUCCESS!!!\n")); 13214 } 13215 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 13216 { 13217 SM_DBG1(("smsatSMARTRStatusPassCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 13218 } 13219 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 13220 (ataStatus & DF_ATA_STATUS_MASK) 13221 ) 13222 { 13223 SM_DBG1(("smsatSMARTRStatusPassCB: FAILED, FAILED, error status!!!\n")); 13224 } 13225 13226 /* Process abort case */ 13227 if (agIOStatus == OSSA_IO_ABORTED) 13228 { 13229 smsatProcessAbort(smRoot, 13230 smOrgIORequest, 13231 satOrgIOContext 13232 ); 13233 13234 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13235 13236 smsatFreeIntIoResource( smRoot, 13237 oneDeviceData, 13238 satIntIo); 13239 return; 13240 } 13241 13242 smsatTranslateATAErrorsToSCSIErrors( 13243 agFirstDword->D2H.status, 13244 agFirstDword->D2H.error, 13245 &bSenseKey, 13246 &bSenseCodeInfo 13247 ); 13248 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 13249 tdsmIOCompletedCB(smRoot, 13250 smOrgIORequest, 13251 smIOSuccess, 13252 SCSI_STAT_CHECK_CONDITION, 13253 satOrgIOContext->pSmSenseData, 13254 satOrgIOContext->interruptContext ); 13255 13256 13257 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13258 13259 smsatFreeIntIoResource( smRoot, 13260 oneDeviceData, 13261 satIntIo); 13262 return; 13263 13264 } /* error checking */ 13265 } 13266 13267 /* prcessing the success case */ 13268 SM_DBG5(("smsatSMARTRStatusPassCB: SAT_SMART_RETURN_STATUS success\n")); 13269 13270 tdsmIOCompletedCB( smRoot, 13271 smOrgIORequest, 13272 smIOSuccess, 13273 SCSI_STAT_GOOD, 13274 agNULL, 13275 satOrgIOContext->interruptContext); 13276 13277 13278 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13279 13280 smsatFreeIntIoResource( smRoot, 13281 oneDeviceData, 13282 satIntIo); 13283 13284 13285 return; 13286 } 13287 13288 osGLOBAL void 13289 smsatSMARTReadLogCB( 13290 agsaRoot_t *agRoot, 13291 agsaIORequest_t *agIORequest, 13292 bit32 agIOStatus, 13293 agsaFisHeader_t *agFirstDword, 13294 bit32 agIOInfoLen, 13295 void *agParam, 13296 void *ioContext 13297 ) 13298 { 13299 13300 smRoot_t *smRoot = agNULL; 13301 smIntRoot_t *smIntRoot = agNULL; 13302 smIntContext_t *smAllShared = agNULL; 13303 smIORequestBody_t *smIORequestBody; 13304 smIORequestBody_t *smOrgIORequestBody; 13305 smSatIOContext_t *satIOContext; 13306 smSatIOContext_t *satOrgIOContext; 13307 smSatInternalIo_t *satIntIo; 13308 // satDeviceData_t *satDevData; 13309 smDeviceData_t *oneDeviceData; 13310 13311 smScsiRspSense_t *pSense; 13312 smIORequest_t *smOrgIORequest; 13313 13314 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 13315 bit32 ataStatus = 0; 13316 smScsiInitiatorRequest_t *smScsiRequest; /* tiScsiXchg */ 13317 smScsiInitiatorRequest_t *smOrgScsiRequest; /* tiScsiXchg */ 13318 // satReadLogExtSelfTest_t *virtAddr1; 13319 // satSmartReadLogSelfTest_t *virtAddr2; 13320 //bit8 *pLogPage; 13321 // bit8 SelfTestExecutionStatus = 0; 13322 // bit32 i = 0; 13323 13324 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 13325 // agsaFisRegD2HData_t statDevToHostFisData; 13326 smIniScsiCmnd_t *scsiCmnd; 13327 // bit32 lenReceived = 0; 13328 bit8 bSenseKey = 0; 13329 bit16 bSenseCodeInfo = 0; 13330 13331 SM_DBG2(("smsatSMARTReadLogCB: start\n")); 13332 SM_DBG5(("smsatSMARTReadLogCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 13333 13334 /* internally generate smIOContext */ 13335 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 13336 satIOContext = (smSatIOContext_t *) ioContext; 13337 satIntIo = satIOContext->satIntIoContext; 13338 oneDeviceData = satIOContext->pSatDevData; 13339 hostToDevFis = satIOContext->pFis; 13340 smRoot = oneDeviceData->smRoot; 13341 smIntRoot = (smIntRoot_t *)smRoot->smData; 13342 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 13343 13344 if (satIntIo == agNULL) 13345 { 13346 SM_DBG4(("smsatSMARTReadLogCB: External smSatInternalIo_t satIntIoContext\n")); 13347 satOrgIOContext = satIOContext; 13348 smOrgIORequest = smIORequestBody->smIORequest; 13349 pSense = satOrgIOContext->pSense; 13350 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 13351 13352 /* ATA command response payload */ 13353 smScsiRequest = satOrgIOContext->smScsiXchg; 13354 scsiCmnd = satOrgIOContext->pScsiCmnd; 13355 13356 13357 } 13358 else 13359 { 13360 SM_DBG4(("smsatSMARTReadLogCB: Internal smSatInternalIo_t satIntIoContext\n")); 13361 satOrgIOContext = satIOContext->satOrgIOContext; 13362 if (satOrgIOContext == agNULL) 13363 { 13364 SM_DBG4(("smsatSMARTReadLogCB: satOrgIOContext is NULL\n")); 13365 13366 return; 13367 13368 } 13369 else 13370 { 13371 SM_DBG4(("smsatSMARTReadLogCB: satOrgIOContext is NOT NULL\n")); 13372 } 13373 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 13374 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 13375 13376 pSense = satOrgIOContext->pSense; 13377 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 13378 13379 /* ATA command response payload */ 13380 smScsiRequest = (smScsiInitiatorRequest_t *)&(satIntIo->satIntSmScsiXchg); 13381 scsiCmnd = satOrgIOContext->pScsiCmnd; 13382 } 13383 13384 smIORequestBody->ioCompleted = agTRUE; 13385 smIORequestBody->ioStarted = agFALSE; 13386 13387 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 13388 { 13389 SM_DBG1(("smsatSMARTReadLogCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 13390 tdsmIOCompletedCB( 13391 smRoot, 13392 smOrgIORequest, 13393 smIOFailed, 13394 smDetailOtherError, 13395 agNULL, 13396 satOrgIOContext->interruptContext 13397 ); 13398 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13399 13400 smsatFreeIntIoResource( smRoot, 13401 oneDeviceData, 13402 satIntIo); 13403 return; 13404 } 13405 13406 //for Debuggings 13407 if(agFirstDword != NULL) 13408 { 13409 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 13410 SM_DBG1(("smsatSMARTReadLogCB: statDevToHostFisHeader->status, status %d!!!\n", statDevToHostFisHeader->status)); 13411 } 13412 if ((agIOStatus != OSSA_IO_SUCCESS) && (agFirstDword != NULL)) 13413 { 13414 /* non-data and pio read -> device to host and pio setup fis are expected */ 13415 /* 13416 first, assumed to be Reg Device to Host FIS 13417 This is OK to just find fis type 13418 */ 13419 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 13420 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 13421 } 13422 13423 if( agIOStatus != OSSA_IO_SUCCESS) 13424 { 13425 if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 13426 (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS)) || 13427 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 13428 ) 13429 { 13430 /* for debugging */ 13431 if( agIOStatus != OSSA_IO_SUCCESS) 13432 { 13433 SM_DBG1(("smsatSMARTReadLogCB: FAILED, NOT IO_SUCCESS!!!\n")); 13434 } 13435 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 13436 { 13437 SM_DBG1(("smsatSMARTReadLogCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 13438 } 13439 else if (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) 13440 { 13441 SM_DBG1(("smsatSMARTReadLogCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 13442 } 13443 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 13444 (ataStatus & DF_ATA_STATUS_MASK) 13445 ) 13446 { 13447 SM_DBG1(("smsatSMARTReadLogCB: FAILED, FAILED, error status!!!\n")); 13448 } 13449 13450 /* Process abort case */ 13451 if (agIOStatus == OSSA_IO_ABORTED) 13452 { 13453 smsatProcessAbort(smRoot, 13454 smOrgIORequest, 13455 satOrgIOContext 13456 ); 13457 13458 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13459 13460 smsatFreeIntIoResource( smRoot, 13461 oneDeviceData, 13462 satIntIo); 13463 return; 13464 } 13465 13466 /* for debugging */ 13467 13468 if (hostToDevFis->h.command == SAT_SMART) 13469 { 13470 if (hostToDevFis->h.features == SAT_SMART_READ_LOG) 13471 { 13472 SM_DBG1(("smsatSMARTReadLogCB: SAT_SMART_READ_LOG failed!!!\n")); 13473 } 13474 else 13475 { 13476 SM_DBG1(("smsatSMARTReadLogCB: error unknown command 0x%x feature 0x%x!!!\n", hostToDevFis->h.command, hostToDevFis->h.features)); 13477 } 13478 } 13479 else 13480 { 13481 SM_DBG1(("smsatSMARTReadLogCB: error default case command 0x%x!!!\n", hostToDevFis->h.command)); 13482 } 13483 13484 smsatTranslateATAErrorsToSCSIErrors( 13485 agFirstDword->D2H.status, 13486 agFirstDword->D2H.error, 13487 &bSenseKey, 13488 &bSenseCodeInfo 13489 ); 13490 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 13491 tdsmIOCompletedCB(smRoot, 13492 smOrgIORequest, 13493 smIOSuccess, 13494 SCSI_STAT_CHECK_CONDITION, 13495 satOrgIOContext->pSmSenseData, 13496 satOrgIOContext->interruptContext ); 13497 13498 13499 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13500 13501 smsatFreeIntIoResource( smRoot, 13502 oneDeviceData, 13503 satIntIo); 13504 return; 13505 13506 } /* error checking */ 13507 } 13508 13509 /* prcessing the success case */ 13510 13511 13512 tdsmIOCompletedCB( smRoot, 13513 smOrgIORequest, 13514 smIOSuccess, 13515 SCSI_STAT_GOOD, 13516 agNULL, 13517 satOrgIOContext->interruptContext); 13518 13519 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13520 13521 smsatFreeIntIoResource( smRoot, 13522 oneDeviceData, 13523 satIntIo); 13524 13525 return; 13526 } 13527 13528 osGLOBAL void 13529 smsatPassthroughCB( 13530 agsaRoot_t *agRoot, 13531 agsaIORequest_t *agIORequest, 13532 bit32 agIOStatus, 13533 agsaFisHeader_t *agFirstDword, 13534 bit32 agIOInfoLen, 13535 void *agParam, 13536 void *ioContext 13537 ) 13538 { 13539 smRoot_t *smRoot = agNULL; 13540 smIntRoot_t *smIntRoot = agNULL; 13541 smIntContext_t *smAllShared = agNULL; 13542 smIORequestBody_t *smIORequestBody; 13543 smIORequestBody_t *smOrgIORequestBody; 13544 smSatIOContext_t *satIOContext; 13545 smSatIOContext_t *satOrgIOContext; 13546 smSatInternalIo_t *satIntIo; 13547 smDeviceData_t *oneDeviceData; 13548 smScsiRspSense_t *pSense; 13549 smIORequest_t *smOrgIORequest; 13550 agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 13551 bit32 ataStatus = 0; 13552 smScsiInitiatorRequest_t *smScsiRequest; /* tiScsiXchg */ 13553 smScsiInitiatorRequest_t *smOrgScsiRequest; /* tiScsiXchg */ 13554 13555 agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 13556 smIniScsiCmnd_t *scsiCmnd; 13557 bit8 bSenseKey = 0; 13558 bit16 bSenseCodeInfo = 0; 13559 13560 SM_DBG2(("smsatPassthroughCB: start\n")); 13561 SM_DBG5(("smsatPassthroughCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 13562 13563 /* internally generate smIOContext */ 13564 smIORequestBody = (smIORequestBody_t *)agIORequest->osData; 13565 satIOContext = (smSatIOContext_t *) ioContext; 13566 satIntIo = satIOContext->satIntIoContext; 13567 oneDeviceData = satIOContext->pSatDevData; 13568 hostToDevFis = satIOContext->pFis; 13569 smRoot = oneDeviceData->smRoot; 13570 smIntRoot = (smIntRoot_t *)smRoot->smData; 13571 smAllShared = (smIntContext_t *)&smIntRoot->smAllShared; 13572 13573 if (satIntIo == agNULL) 13574 { 13575 SM_DBG4(("smsatPassthroughCB: External smSatInternalIo_t satIntIoContext\n")); 13576 satOrgIOContext = satIOContext; 13577 smOrgIORequest = smIORequestBody->smIORequest; 13578 pSense = satOrgIOContext->pSense; 13579 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 13580 13581 /* ATA command response payload */ 13582 smScsiRequest = satOrgIOContext->smScsiXchg; 13583 scsiCmnd = satOrgIOContext->pScsiCmnd; 13584 } 13585 else 13586 { 13587 SM_DBG4(("smsatPassthroughCB: Internal smSatInternalIo_t satIntIoContext\n")); 13588 satOrgIOContext = satIOContext->satOrgIOContext; 13589 if (satOrgIOContext == agNULL) 13590 { 13591 SM_DBG4(("smsatPassthroughCB: satOrgIOContext is NULL\n")); 13592 return; 13593 } 13594 else 13595 { 13596 SM_DBG4(("smsatPassthroughCB: satOrgIOContext is NOT NULL\n")); 13597 } 13598 smOrgIORequestBody = (smIORequestBody_t *)satOrgIOContext->smRequestBody; 13599 smOrgIORequest = (smIORequest_t *)smOrgIORequestBody->smIORequest; 13600 13601 pSense = satOrgIOContext->pSense; 13602 smOrgScsiRequest = satOrgIOContext->smScsiXchg; 13603 13604 /* ATA command response payload */ 13605 smScsiRequest = (smScsiInitiatorRequest_t *)&(satIntIo->satIntSmScsiXchg); 13606 scsiCmnd = satOrgIOContext->pScsiCmnd; 13607 } 13608 13609 smIORequestBody->ioCompleted = agTRUE; 13610 smIORequestBody->ioStarted = agFALSE; 13611 13612 13613 if (agIOStatus == OSSA_IO_UNDERFLOW) 13614 { 13615 SM_DBG1(("smsatPassthroughCB: IO_UNDERFLOW, status %d!!!\n", agIOStatus)); 13616 tdsmIOCompletedCB( smRoot, 13617 smOrgIORequest, 13618 smIOUnderRun, 13619 agIOInfoLen, 13620 agNULL, 13621 satOrgIOContext->interruptContext 13622 ); 13623 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13624 13625 smsatFreeIntIoResource( smRoot, 13626 oneDeviceData, 13627 satIntIo); 13628 return; 13629 } 13630 13631 13632 if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 13633 { 13634 SM_DBG1(("smsatPassthroughCB: wrong. agFirstDword is NULL when error, status %d!!!\n", agIOStatus)); 13635 tdsmIOCompletedCB( smRoot, 13636 smOrgIORequest, 13637 smIOFailed, 13638 smDetailOtherError, 13639 agNULL, 13640 satOrgIOContext->interruptContext 13641 ); 13642 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13643 13644 smsatFreeIntIoResource( smRoot, 13645 oneDeviceData, 13646 satIntIo); 13647 return; 13648 } 13649 13650 //for Debuggings 13651 13652 if ((agIOStatus != OSSA_IO_SUCCESS) && (agFirstDword != NULL)) 13653 { 13654 /* non-data and pio read -> device to host and pio setup fis are expected */ 13655 /* 13656 first, assumed to be Reg Device to Host FIS 13657 This is OK to just find fis type 13658 */ 13659 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 13660 ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 13661 } 13662 if( agIOStatus != OSSA_IO_SUCCESS) 13663 { 13664 if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 13665 (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS)) || 13666 ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 13667 ) 13668 { 13669 /* for debugging */ 13670 if( agIOStatus != OSSA_IO_SUCCESS) 13671 { 13672 SM_DBG1(("smsatPassthroughCB: FAILED, NOT IO_SUCCESS!!!\n")); 13673 } 13674 else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 13675 { 13676 SM_DBG1(("smsatPassthroughCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 13677 } 13678 else if (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) 13679 { 13680 SM_DBG1(("smsatPassthroughCB: FAILED, Wrong FIS type 0x%x!!!\n",statDevToHostFisHeader->fisType)); 13681 } 13682 else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 13683 (ataStatus & DF_ATA_STATUS_MASK) 13684 ) 13685 { 13686 SM_DBG1(("smsatPassthroughCB: FAILED, FAILED, error status!!!\n")); 13687 } 13688 13689 /* Process abort case */ 13690 if (agIOStatus == OSSA_IO_ABORTED) 13691 { 13692 smsatProcessAbort( smRoot, 13693 smOrgIORequest, 13694 satOrgIOContext); 13695 13696 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13697 13698 smsatFreeIntIoResource( smRoot, 13699 oneDeviceData, 13700 satIntIo); 13701 return; 13702 } 13703 13704 smsatTranslateATAErrorsToSCSIErrors( agFirstDword->D2H.status, 13705 agFirstDword->D2H.error, 13706 &bSenseKey, 13707 &bSenseCodeInfo 13708 ); 13709 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 13710 tdsmIOCompletedCB( smRoot, 13711 smOrgIORequest, 13712 smIOSuccess, 13713 SCSI_STAT_CHECK_CONDITION, 13714 satOrgIOContext->pSmSenseData, 13715 satOrgIOContext->interruptContext ); 13716 13717 13718 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13719 smsatFreeIntIoResource( smRoot, 13720 oneDeviceData, 13721 satIntIo); 13722 return; 13723 13724 } /* error checking */ 13725 } 13726 13727 /* prcessing the success case */ 13728 if(agFirstDword != NULL) 13729 { 13730 statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 13731 SM_DBG1(("smsatPassthroughCB: statDevToHostFisHeader->status, status %d!!!\n", statDevToHostFisHeader->status)); 13732 smsatTranslateATAErrorsToSCSIErrors( agFirstDword->D2H.status, 13733 agFirstDword->D2H.error, 13734 &bSenseKey, 13735 &bSenseCodeInfo); 13736 smsatSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 13737 if(agFirstDword->D2H.status & 0x01) 13738 { 13739 tdsmIOCompletedCB( smRoot, 13740 smOrgIORequest, 13741 smIOSuccess, 13742 SCSI_STAT_CHECK_CONDITION, 13743 satOrgIOContext->pSmSenseData, 13744 satOrgIOContext->interruptContext ); 13745 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13746 smsatFreeIntIoResource( smRoot, 13747 oneDeviceData, 13748 satIntIo); 13749 return; 13750 } 13751 } 13752 13753 tdsmIOCompletedCB( smRoot, 13754 smOrgIORequest, 13755 smIOSuccess, 13756 SCSI_STAT_GOOD, 13757 agNULL, 13758 satOrgIOContext->interruptContext); 13759 13760 smsatDecrementPendingIO(smRoot, smAllShared, satIOContext); 13761 13762 smsatFreeIntIoResource( smRoot, 13763 oneDeviceData, 13764 satIntIo); 13765 13766 return; 13767 } 13768 13769